@opra/common 0.5.0 → 0.6.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/constants.js +1 -0
- package/cjs/exception/enums/issue-severity.enum.js +23 -0
- package/cjs/{types.js → exception/error-issue.js} +0 -0
- package/cjs/exception/http-errors/bad-request.error.js +22 -0
- package/cjs/exception/http-errors/failed-dependency.error.js +21 -0
- package/cjs/exception/http-errors/forbidden.error.js +23 -0
- package/cjs/exception/http-errors/internal-server.error.js +21 -0
- package/cjs/exception/http-errors/method-not-allowed.error.js +22 -0
- package/cjs/exception/http-errors/not-acceptable.error.js +22 -0
- package/cjs/exception/http-errors/not-found.error.js +25 -0
- package/cjs/exception/http-errors/unauthorized.error.js +22 -0
- package/cjs/exception/http-errors/unprocessable-entity.error.js +21 -0
- package/cjs/exception/index.js +18 -0
- package/cjs/exception/opra-exception.js +56 -0
- package/cjs/exception/resource-errors/resource-conflict.error.js +20 -0
- package/cjs/exception/resource-errors/resource-not-found.error.js +20 -0
- package/cjs/exception/wrap-exception.js +42 -0
- package/cjs/filter/antlr/OpraFilterLexer.js +386 -0
- package/cjs/filter/antlr/OpraFilterParser.js +2070 -0
- package/cjs/filter/antlr/OpraFilterVisitor.js +3 -0
- package/cjs/filter/ast/abstract/ast.js +10 -0
- package/cjs/filter/ast/abstract/expression.js +7 -0
- package/cjs/filter/ast/abstract/literal.js +14 -0
- package/cjs/filter/ast/abstract/term.js +7 -0
- package/cjs/filter/ast/expressions/arithmetic-expression.js +29 -0
- package/cjs/filter/ast/expressions/array-expression.js +15 -0
- package/cjs/filter/ast/expressions/comparison-expression.js +18 -0
- package/cjs/filter/ast/expressions/logical-expression.js +18 -0
- package/cjs/filter/ast/expressions/parentheses-expression.js +15 -0
- package/cjs/filter/ast/index.js +19 -0
- package/cjs/filter/ast/terms/boolean-literal.js +10 -0
- package/cjs/filter/ast/terms/date-literal.js +28 -0
- package/cjs/filter/ast/terms/external-constant.js +13 -0
- package/cjs/filter/ast/terms/null-literal.js +11 -0
- package/cjs/filter/ast/terms/number-literal.js +40 -0
- package/cjs/filter/ast/terms/qualified-identifier.js +10 -0
- package/cjs/filter/ast/terms/string-literal.js +14 -0
- package/cjs/filter/ast/terms/time-literal.js +33 -0
- package/cjs/filter/build.js +129 -0
- package/cjs/filter/error-listener.js +14 -0
- package/cjs/filter/errors.js +21 -0
- package/cjs/filter/filter-tree-visitor.js +113 -0
- package/cjs/filter/index.js +8 -0
- package/cjs/filter/parse.js +37 -0
- package/cjs/filter/utils.js +26 -0
- package/cjs/helpers/index.js +4 -0
- package/cjs/{classes → helpers}/responsive-map.js +1 -1
- package/cjs/{enums → http/enums}/http-headers.enum.js +9 -0
- package/cjs/{enums → http/enums}/http-status.enum.js +0 -0
- package/cjs/http/http-request.js +118 -0
- package/cjs/http/index.js +9 -0
- package/cjs/http/interfaces/client-http-headers.interface.js +2 -0
- package/cjs/http/interfaces/server-http-headers.interface.js +2 -0
- package/cjs/http/multipart/batch-multipart.js +155 -0
- package/cjs/http/multipart/http-request-content.js +16 -0
- package/cjs/http/multipart/http-response-content.js +14 -0
- package/cjs/http/multipart/index.js +4 -0
- package/cjs/http/utils/normalize-headers.js +28 -0
- package/cjs/i18n/i18n.js +175 -0
- package/cjs/i18n/index.js +10 -0
- package/cjs/i18n/string-utils.js +13 -0
- package/cjs/i18n/translate.js +15 -0
- package/cjs/index.js +12 -5
- package/cjs/schema/constants.js +11 -0
- package/cjs/schema/decorators/opr-collection-resource.decorator.js +23 -0
- package/cjs/schema/decorators/opr-complex-type.decorator.js +27 -0
- package/cjs/schema/decorators/opr-field.decorator.js +28 -0
- package/cjs/schema/decorators/opr-resolver.decorator.js +81 -0
- package/cjs/schema/decorators/opr-simple-type.decorator.js +18 -0
- package/cjs/schema/decorators/opr-singleton-resource.decorator.js +23 -0
- package/cjs/schema/implementation/data-type/builtin/any.type.js +9 -0
- package/cjs/schema/implementation/data-type/builtin/base64-binary.type.js +15 -0
- package/cjs/schema/implementation/data-type/builtin/bigint.type.js +15 -0
- package/cjs/schema/implementation/data-type/builtin/boolean.type.js +15 -0
- package/cjs/schema/implementation/data-type/builtin/date-string.type.js +15 -0
- package/cjs/schema/implementation/data-type/builtin/date.type.js +15 -0
- package/cjs/schema/implementation/data-type/builtin/guid.type.js +15 -0
- package/cjs/schema/implementation/data-type/builtin/integer.type.js +15 -0
- package/cjs/schema/implementation/data-type/builtin/number.type.js +15 -0
- package/cjs/schema/implementation/data-type/builtin/object.type.js +15 -0
- package/cjs/schema/implementation/data-type/builtin/string.type.js +15 -0
- package/cjs/schema/implementation/data-type/builtin-data-types.js +37 -0
- package/cjs/schema/implementation/data-type/complex-type.js +111 -0
- package/cjs/schema/implementation/data-type/data-type.js +36 -0
- package/cjs/schema/implementation/data-type/simple-type.js +21 -0
- package/cjs/schema/implementation/data-type/union-type.js +25 -0
- package/cjs/schema/implementation/document-builder.js +140 -0
- package/cjs/schema/implementation/opra-document.js +181 -0
- package/cjs/schema/implementation/query/collection-count-query.js +19 -0
- package/cjs/schema/implementation/query/collection-create-query.js +28 -0
- package/cjs/schema/implementation/query/collection-delete-many-query.js +19 -0
- package/cjs/schema/implementation/query/collection-delete-query.js +27 -0
- package/cjs/schema/implementation/query/collection-get-query.js +38 -0
- package/cjs/schema/implementation/query/collection-search-query.js +55 -0
- package/cjs/schema/implementation/query/collection-update-many-query.js +21 -0
- package/cjs/schema/implementation/query/collection-update-query.js +39 -0
- package/cjs/schema/implementation/query/field-get-query.js +45 -0
- package/cjs/schema/implementation/query/index.js +22 -0
- package/cjs/schema/implementation/query/singleton-get-query.js +27 -0
- package/cjs/schema/implementation/resource/collection-resource-info.js +58 -0
- package/cjs/schema/implementation/resource/container-resource-info.js +30 -0
- package/cjs/schema/implementation/resource/resource-info.js +39 -0
- package/cjs/schema/implementation/resource/singleton-resource-info.js +37 -0
- package/cjs/schema/implementation/schema-builder/extract-resource-metadata.util.js +84 -0
- package/cjs/schema/implementation/schema-builder/extract-type-metadata.util.js +94 -0
- package/cjs/schema/index.js +28 -0
- package/cjs/schema/interfaces/child-field-query.interface.js +2 -0
- package/cjs/schema/interfaces/data-type.metadata.js +2 -0
- package/cjs/schema/interfaces/resource-container.interface.js +2 -0
- package/cjs/schema/interfaces/resource.metadata.js +2 -0
- package/cjs/schema/opra-schema.definition.js +49 -0
- package/cjs/schema/type-helpers/extend-type.helper.js +65 -0
- package/cjs/schema/type-helpers/mixin-type.helper.js +46 -0
- package/cjs/schema/type-helpers/mixin.utils.js +32 -0
- package/cjs/schema/types.js +2 -0
- package/cjs/schema/utils/class.utils.js +8 -0
- package/cjs/schema/utils/clone-object.util.js +19 -0
- package/cjs/schema/utils/inspect.util.js +7 -0
- package/cjs/schema/utils/normalize-field-array.util.js +44 -0
- package/cjs/schema/utils/path-to-tree.util.js +26 -0
- package/cjs/schema/utils/string-compare.util.js +11 -0
- package/cjs/url/formats/boolean-format.js +25 -0
- package/cjs/url/formats/date-format.js +48 -0
- package/cjs/url/formats/filter-format.js +18 -0
- package/cjs/url/formats/format.js +6 -0
- package/cjs/url/formats/integer-format.js +20 -0
- package/cjs/url/formats/number-format.js +28 -0
- package/cjs/url/formats/string-format.js +28 -0
- package/cjs/url/index.js +8 -0
- package/cjs/url/opra-url-path-component.js +33 -0
- package/cjs/url/opra-url-path.js +128 -0
- package/cjs/url/opra-url-search-params.js +247 -0
- package/cjs/url/opra-url.js +299 -0
- package/cjs/url/utils/path-utils.js +86 -0
- package/cjs/utils/index.js +6 -0
- package/cjs/utils/is-url.js +8 -0
- package/cjs/utils/path-to-tree.js +28 -0
- package/cjs/utils/type-guards.js +46 -0
- package/esm/constants.d.ts +0 -0
- package/esm/constants.js +1 -0
- package/esm/exception/enums/issue-severity.enum.d.ts +13 -0
- package/esm/exception/enums/issue-severity.enum.js +20 -0
- package/esm/exception/error-issue.d.ts +9 -0
- package/esm/{types.js → exception/error-issue.js} +0 -0
- package/esm/exception/http-errors/bad-request.error.d.ts +10 -0
- package/esm/exception/http-errors/bad-request.error.js +18 -0
- package/esm/exception/http-errors/failed-dependency.error.d.ts +9 -0
- package/esm/exception/http-errors/failed-dependency.error.js +17 -0
- package/esm/exception/http-errors/forbidden.error.d.ts +11 -0
- package/esm/exception/http-errors/forbidden.error.js +19 -0
- package/esm/exception/http-errors/internal-server.error.d.ts +9 -0
- package/esm/exception/http-errors/internal-server.error.js +17 -0
- package/esm/exception/http-errors/method-not-allowed.error.d.ts +10 -0
- package/esm/exception/http-errors/method-not-allowed.error.js +18 -0
- package/esm/exception/http-errors/not-acceptable.error.d.ts +10 -0
- package/esm/exception/http-errors/not-acceptable.error.js +18 -0
- package/esm/exception/http-errors/not-found.error.d.ts +13 -0
- package/esm/exception/http-errors/not-found.error.js +21 -0
- package/esm/exception/http-errors/unauthorized.error.d.ts +10 -0
- package/esm/exception/http-errors/unauthorized.error.js +18 -0
- package/esm/exception/http-errors/unprocessable-entity.error.d.ts +9 -0
- package/esm/exception/http-errors/unprocessable-entity.error.js +17 -0
- package/esm/exception/index.d.ts +15 -0
- package/esm/exception/index.js +15 -0
- package/esm/exception/opra-exception.d.ts +15 -0
- package/esm/exception/opra-exception.js +52 -0
- package/esm/exception/resource-errors/resource-conflict.error.d.ts +5 -0
- package/esm/exception/resource-errors/resource-conflict.error.js +16 -0
- package/esm/exception/resource-errors/resource-not-found.error.d.ts +4 -0
- package/esm/exception/resource-errors/resource-not-found.error.js +16 -0
- package/esm/exception/wrap-exception.d.ts +2 -0
- package/esm/exception/wrap-exception.js +38 -0
- package/esm/filter/antlr/OpraFilterLexer.d.ts +78 -0
- package/esm/filter/antlr/OpraFilterLexer.js +381 -0
- package/esm/filter/antlr/OpraFilterParser.d.ts +365 -0
- package/esm/filter/antlr/OpraFilterParser.js +2022 -0
- package/esm/filter/antlr/OpraFilterVisitor.d.ts +290 -0
- package/esm/filter/antlr/OpraFilterVisitor.js +2 -0
- package/esm/filter/ast/abstract/ast.d.ts +5 -0
- package/esm/filter/ast/abstract/ast.js +6 -0
- package/esm/filter/ast/abstract/expression.d.ts +3 -0
- package/esm/filter/ast/abstract/expression.js +3 -0
- package/esm/filter/ast/abstract/literal.d.ts +6 -0
- package/esm/filter/ast/abstract/literal.js +10 -0
- package/esm/filter/ast/abstract/term.d.ts +3 -0
- package/esm/filter/ast/abstract/term.js +3 -0
- package/esm/filter/ast/expressions/arithmetic-expression.d.ts +13 -0
- package/esm/filter/ast/expressions/arithmetic-expression.js +24 -0
- package/esm/filter/ast/expressions/array-expression.d.ts +7 -0
- package/esm/filter/ast/expressions/array-expression.js +11 -0
- package/esm/filter/ast/expressions/comparison-expression.d.ts +10 -0
- package/esm/filter/ast/expressions/comparison-expression.js +14 -0
- package/esm/filter/ast/expressions/logical-expression.d.ts +8 -0
- package/esm/filter/ast/expressions/logical-expression.js +14 -0
- package/esm/filter/ast/expressions/parentheses-expression.d.ts +6 -0
- package/esm/filter/ast/expressions/parentheses-expression.js +11 -0
- package/esm/filter/ast/index.d.ts +16 -0
- package/esm/filter/ast/index.js +16 -0
- package/esm/filter/ast/terms/boolean-literal.d.ts +5 -0
- package/esm/filter/ast/terms/boolean-literal.js +6 -0
- package/esm/filter/ast/terms/date-literal.d.ts +6 -0
- package/esm/filter/ast/terms/date-literal.js +24 -0
- package/esm/filter/ast/terms/external-constant.d.ts +5 -0
- package/esm/filter/ast/terms/external-constant.js +9 -0
- package/esm/filter/ast/terms/null-literal.d.ts +5 -0
- package/esm/filter/ast/terms/null-literal.js +7 -0
- package/esm/filter/ast/terms/number-literal.d.ts +6 -0
- package/esm/filter/ast/terms/number-literal.js +36 -0
- package/esm/filter/ast/terms/qualified-identifier.d.ts +4 -0
- package/esm/filter/ast/terms/qualified-identifier.js +6 -0
- package/esm/filter/ast/terms/string-literal.d.ts +5 -0
- package/esm/filter/ast/terms/string-literal.js +10 -0
- package/esm/filter/ast/terms/time-literal.d.ts +6 -0
- package/esm/filter/ast/terms/time-literal.js +29 -0
- package/esm/filter/build.d.ts +31 -0
- package/esm/filter/build.js +105 -0
- package/esm/filter/error-listener.d.ts +8 -0
- package/esm/filter/error-listener.js +10 -0
- package/esm/filter/errors.d.ts +20 -0
- package/esm/filter/errors.js +15 -0
- package/esm/filter/filter-tree-visitor.d.ts +30 -0
- package/esm/filter/filter-tree-visitor.js +109 -0
- package/esm/filter/index.d.ts +5 -0
- package/esm/filter/index.js +5 -0
- package/esm/filter/parse.d.ts +2 -0
- package/esm/filter/parse.js +33 -0
- package/esm/filter/utils.d.ts +2 -0
- package/esm/filter/utils.js +21 -0
- package/esm/helpers/index.d.ts +1 -0
- package/esm/helpers/index.js +1 -0
- package/esm/{classes → helpers}/responsive-map.d.ts +0 -0
- package/esm/{classes → helpers}/responsive-map.js +1 -1
- package/esm/{enums → http/enums}/http-headers.enum.d.ts +9 -0
- package/esm/{enums → http/enums}/http-headers.enum.js +9 -0
- package/esm/{enums → http/enums}/http-status.enum.d.ts +0 -0
- package/esm/{enums → http/enums}/http-status.enum.js +0 -0
- package/esm/http/http-request.d.ts +34 -0
- package/esm/http/http-request.js +114 -0
- package/esm/http/index.d.ts +6 -0
- package/esm/http/index.js +6 -0
- package/esm/http/interfaces/client-http-headers.interface.d.ts +65 -0
- package/esm/http/interfaces/client-http-headers.interface.js +1 -0
- package/esm/http/interfaces/server-http-headers.interface.d.ts +1 -0
- package/esm/http/interfaces/server-http-headers.interface.js +1 -0
- package/esm/http/multipart/batch-multipart.d.ts +30 -0
- package/esm/http/multipart/batch-multipart.js +150 -0
- package/esm/http/multipart/http-request-content.d.ts +8 -0
- package/esm/http/multipart/http-request-content.js +12 -0
- package/esm/http/multipart/http-response-content.d.ts +7 -0
- package/esm/http/multipart/http-response-content.js +10 -0
- package/esm/http/multipart/index.d.ts +1 -0
- package/esm/http/multipart/index.js +1 -0
- package/esm/http/utils/normalize-headers.d.ts +1 -0
- package/esm/http/utils/normalize-headers.js +24 -0
- package/esm/i18n/i18n.d.ts +28 -0
- package/esm/i18n/i18n.js +170 -0
- package/esm/i18n/index.d.ts +5 -0
- package/esm/i18n/index.js +6 -0
- package/esm/i18n/string-utils.d.ts +2 -0
- package/esm/i18n/string-utils.js +8 -0
- package/esm/i18n/translate.d.ts +4 -0
- package/esm/i18n/translate.js +11 -0
- package/esm/index.d.ts +10 -5
- package/esm/index.js +10 -5
- package/esm/schema/constants.d.ts +8 -0
- package/esm/schema/constants.js +8 -0
- package/esm/schema/decorators/opr-collection-resource.decorator.d.ts +8 -0
- package/esm/schema/decorators/opr-collection-resource.decorator.js +19 -0
- package/esm/schema/decorators/opr-complex-type.decorator.d.ts +6 -0
- package/esm/schema/decorators/opr-complex-type.decorator.js +23 -0
- package/esm/schema/decorators/opr-field.decorator.d.ts +3 -0
- package/esm/schema/decorators/opr-field.decorator.js +24 -0
- package/esm/schema/decorators/opr-resolver.decorator.d.ts +8 -0
- package/esm/schema/decorators/opr-resolver.decorator.js +71 -0
- package/esm/schema/decorators/opr-simple-type.decorator.d.ts +6 -0
- package/esm/schema/decorators/opr-simple-type.decorator.js +14 -0
- package/esm/schema/decorators/opr-singleton-resource.decorator.d.ts +8 -0
- package/esm/schema/decorators/opr-singleton-resource.decorator.js +19 -0
- package/esm/schema/implementation/data-type/builtin/any.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/any.type.js +6 -0
- package/esm/schema/implementation/data-type/builtin/base64-binary.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/base64-binary.type.js +12 -0
- package/esm/schema/implementation/data-type/builtin/bigint.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/bigint.type.js +12 -0
- package/esm/schema/implementation/data-type/builtin/boolean.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/boolean.type.js +12 -0
- package/esm/schema/implementation/data-type/builtin/date-string.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/date-string.type.js +12 -0
- package/esm/schema/implementation/data-type/builtin/date.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/date.type.js +12 -0
- package/esm/schema/implementation/data-type/builtin/guid.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/guid.type.js +12 -0
- package/esm/schema/implementation/data-type/builtin/integer.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/integer.type.js +12 -0
- package/esm/schema/implementation/data-type/builtin/number.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/number.type.js +12 -0
- package/esm/schema/implementation/data-type/builtin/object.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/object.type.js +12 -0
- package/esm/schema/implementation/data-type/builtin/string.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/string.type.js +12 -0
- package/esm/schema/implementation/data-type/builtin-data-types.d.ts +4 -0
- package/esm/schema/implementation/data-type/builtin-data-types.js +34 -0
- package/esm/schema/implementation/data-type/complex-type.d.ts +29 -0
- package/esm/schema/implementation/data-type/complex-type.js +107 -0
- package/esm/schema/implementation/data-type/data-type.d.ts +16 -0
- package/esm/schema/implementation/data-type/data-type.js +32 -0
- package/esm/schema/implementation/data-type/simple-type.d.ts +12 -0
- package/esm/schema/implementation/data-type/simple-type.js +17 -0
- package/esm/schema/implementation/data-type/union-type.d.ts +16 -0
- package/esm/schema/implementation/data-type/union-type.js +21 -0
- package/esm/schema/implementation/document-builder.d.ts +16 -0
- package/esm/schema/implementation/document-builder.js +135 -0
- package/esm/schema/implementation/opra-document.d.ts +44 -0
- package/esm/schema/implementation/opra-document.js +177 -0
- package/esm/schema/implementation/query/collection-count-query.d.ts +14 -0
- package/esm/schema/implementation/query/collection-count-query.js +15 -0
- package/esm/schema/implementation/query/collection-create-query.d.ts +18 -0
- package/esm/schema/implementation/query/collection-create-query.js +24 -0
- package/esm/schema/implementation/query/collection-delete-many-query.d.ts +14 -0
- package/esm/schema/implementation/query/collection-delete-many-query.js +15 -0
- package/esm/schema/implementation/query/collection-delete-query.d.ts +10 -0
- package/esm/schema/implementation/query/collection-delete-query.js +23 -0
- package/esm/schema/implementation/query/collection-get-query.d.ts +21 -0
- package/esm/schema/implementation/query/collection-get-query.js +34 -0
- package/esm/schema/implementation/query/collection-search-query.d.ts +30 -0
- package/esm/schema/implementation/query/collection-search-query.js +51 -0
- package/esm/schema/implementation/query/collection-update-many-query.d.ts +15 -0
- package/esm/schema/implementation/query/collection-update-many-query.js +17 -0
- package/esm/schema/implementation/query/collection-update-query.d.ts +19 -0
- package/esm/schema/implementation/query/collection-update-query.js +35 -0
- package/esm/schema/implementation/query/field-get-query.d.ts +30 -0
- package/esm/schema/implementation/query/field-get-query.js +41 -0
- package/esm/schema/implementation/query/index.d.ts +27 -0
- package/esm/schema/implementation/query/index.js +17 -0
- package/esm/schema/implementation/query/singleton-get-query.d.ts +20 -0
- package/esm/schema/implementation/query/singleton-get-query.js +23 -0
- package/esm/schema/implementation/resource/collection-resource-info.d.ts +19 -0
- package/esm/schema/implementation/resource/collection-resource-info.js +54 -0
- package/esm/schema/implementation/resource/container-resource-info.d.ts +13 -0
- package/esm/schema/implementation/resource/container-resource-info.js +26 -0
- package/esm/schema/implementation/resource/resource-info.d.ts +17 -0
- package/esm/schema/implementation/resource/resource-info.js +35 -0
- package/esm/schema/implementation/resource/singleton-resource-info.d.ts +14 -0
- package/esm/schema/implementation/resource/singleton-resource-info.js +33 -0
- package/esm/schema/implementation/schema-builder/extract-resource-metadata.util.d.ts +3 -0
- package/esm/schema/implementation/schema-builder/extract-resource-metadata.util.js +80 -0
- package/esm/schema/implementation/schema-builder/extract-type-metadata.util.d.ts +4 -0
- package/esm/schema/implementation/schema-builder/extract-type-metadata.util.js +89 -0
- package/esm/schema/index.d.ts +25 -0
- package/esm/schema/index.js +25 -0
- package/esm/schema/interfaces/child-field-query.interface.d.ts +4 -0
- package/esm/schema/interfaces/child-field-query.interface.js +1 -0
- package/esm/schema/interfaces/data-type.metadata.d.ts +18 -0
- package/esm/schema/interfaces/data-type.metadata.js +1 -0
- package/esm/schema/interfaces/resource-container.interface.d.ts +8 -0
- package/esm/schema/interfaces/resource-container.interface.js +1 -0
- package/esm/schema/interfaces/resource.metadata.d.ts +18 -0
- package/esm/schema/interfaces/resource.metadata.js +1 -0
- package/esm/schema/opra-schema.definition.d.ts +178 -0
- package/esm/schema/opra-schema.definition.js +46 -0
- package/esm/schema/type-helpers/extend-type.helper.d.ts +3 -0
- package/esm/schema/type-helpers/extend-type.helper.js +59 -0
- package/esm/schema/type-helpers/mixin-type.helper.d.ts +2 -0
- package/esm/schema/type-helpers/mixin-type.helper.js +41 -0
- package/esm/schema/type-helpers/mixin.utils.d.ts +3 -0
- package/esm/schema/type-helpers/mixin.utils.js +27 -0
- package/esm/{types.d.ts → schema/types.d.ts} +8 -1
- package/esm/schema/types.js +1 -0
- package/esm/schema/utils/class.utils.d.ts +2 -0
- package/esm/schema/utils/class.utils.js +4 -0
- package/esm/schema/utils/clone-object.util.d.ts +1 -0
- package/esm/schema/utils/clone-object.util.js +14 -0
- package/esm/schema/utils/inspect.util.d.ts +4 -0
- package/esm/schema/utils/inspect.util.js +4 -0
- package/esm/schema/utils/normalize-field-array.util.d.ts +3 -0
- package/esm/schema/utils/normalize-field-array.util.js +40 -0
- package/esm/schema/utils/path-to-tree.util.d.ts +4 -0
- package/esm/schema/utils/path-to-tree.util.js +22 -0
- package/esm/schema/utils/string-compare.util.d.ts +1 -0
- package/esm/schema/utils/string-compare.util.js +7 -0
- package/esm/url/formats/boolean-format.d.ts +5 -0
- package/esm/url/formats/boolean-format.js +21 -0
- package/esm/url/formats/date-format.d.ts +16 -0
- package/esm/url/formats/date-format.js +44 -0
- package/esm/url/formats/filter-format.d.ts +6 -0
- package/esm/url/formats/filter-format.js +14 -0
- package/esm/url/formats/format.d.ts +4 -0
- package/esm/url/formats/format.js +2 -0
- package/esm/url/formats/integer-format.d.ts +9 -0
- package/esm/url/formats/integer-format.js +16 -0
- package/esm/url/formats/number-format.d.ts +12 -0
- package/esm/url/formats/number-format.js +24 -0
- package/esm/url/formats/string-format.d.ts +14 -0
- package/esm/url/formats/string-format.js +24 -0
- package/esm/url/index.d.ts +5 -0
- package/esm/url/index.js +5 -0
- package/esm/url/opra-url-path-component.d.ts +15 -0
- package/esm/url/opra-url-path-component.js +29 -0
- package/esm/url/opra-url-path.d.ts +30 -0
- package/esm/url/opra-url-path.js +124 -0
- package/esm/url/opra-url-search-params.d.ts +46 -0
- package/esm/url/opra-url-search-params.js +243 -0
- package/esm/url/opra-url.d.ts +79 -0
- package/esm/url/opra-url.js +295 -0
- package/esm/url/utils/path-utils.d.ts +8 -0
- package/esm/url/utils/path-utils.js +78 -0
- package/esm/utils/index.d.ts +3 -0
- package/esm/utils/index.js +3 -0
- package/esm/utils/is-url.d.ts +1 -0
- package/esm/utils/is-url.js +4 -0
- package/esm/utils/path-to-tree.d.ts +4 -0
- package/esm/utils/path-to-tree.js +24 -0
- package/esm/utils/type-guards.d.ts +9 -0
- package/esm/utils/type-guards.js +37 -0
- package/package.json +30 -10
- package/umd/opra-common.umd.min.js +1 -0
- package/cjs/classes/headers-map.js +0 -18
- package/esm/classes/headers-map.d.ts +0 -5
- package/esm/classes/headers-map.js +0 -14
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CollectionResourceInfo = void 0;
|
|
4
|
+
const constants_js_1 = require("../../constants.js");
|
|
5
|
+
const normalize_field_array_util_js_1 = require("../../utils/normalize-field-array.util.js");
|
|
6
|
+
const resource_info_js_1 = require("./resource-info.js");
|
|
7
|
+
class CollectionResourceInfo extends resource_info_js_1.ResourceInfo {
|
|
8
|
+
dataType;
|
|
9
|
+
constructor(document, name, dataType, metadata) {
|
|
10
|
+
if (!metadata.keyFields)
|
|
11
|
+
throw new TypeError(`You should provide key fields for ${name}`);
|
|
12
|
+
super(document, name, metadata);
|
|
13
|
+
metadata.keyFields = Array.isArray(metadata.keyFields) ? metadata.keyFields : [metadata.keyFields];
|
|
14
|
+
metadata.keyFields.forEach(f => dataType.getField(f));
|
|
15
|
+
this.dataType = dataType;
|
|
16
|
+
if (metadata.search && metadata.search.sortFields) {
|
|
17
|
+
metadata.search.sortFields = (0, normalize_field_array_util_js_1.normalizeFieldArray)(document, dataType, metadata.search.sortFields);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
get keyFields() {
|
|
21
|
+
return this.metadata.keyFields;
|
|
22
|
+
}
|
|
23
|
+
get create() {
|
|
24
|
+
return this.metadata.create;
|
|
25
|
+
}
|
|
26
|
+
get count() {
|
|
27
|
+
return this.metadata.count;
|
|
28
|
+
}
|
|
29
|
+
get delete() {
|
|
30
|
+
return this.metadata.delete;
|
|
31
|
+
}
|
|
32
|
+
get deleteMany() {
|
|
33
|
+
return this.metadata.deleteMany;
|
|
34
|
+
}
|
|
35
|
+
get get() {
|
|
36
|
+
return this.metadata.get;
|
|
37
|
+
}
|
|
38
|
+
get update() {
|
|
39
|
+
return this.metadata.update;
|
|
40
|
+
}
|
|
41
|
+
get updateMany() {
|
|
42
|
+
return this.metadata.updateMany;
|
|
43
|
+
}
|
|
44
|
+
get search() {
|
|
45
|
+
return this.metadata.search;
|
|
46
|
+
}
|
|
47
|
+
getSchema(jsonOnly) {
|
|
48
|
+
const out = super.getSchema(jsonOnly);
|
|
49
|
+
if (out.keyFields.length < 2)
|
|
50
|
+
out.keyFields = out.keyFields[0];
|
|
51
|
+
for (const k of constants_js_1.collectionMethods) {
|
|
52
|
+
if (typeof out[k] === 'object' && !Object.keys(out[k]).length)
|
|
53
|
+
out[k] = true;
|
|
54
|
+
}
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.CollectionResourceInfo = CollectionResourceInfo;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContainerResourceInfo = void 0;
|
|
4
|
+
const collection_resource_info_js_1 = require("./collection-resource-info.js");
|
|
5
|
+
const resource_info_js_1 = require("./resource-info.js");
|
|
6
|
+
const singleton_resource_info_js_1 = require("./singleton-resource-info.js");
|
|
7
|
+
class ContainerResourceInfo extends resource_info_js_1.ResourceInfo {
|
|
8
|
+
constructor(service, name, metadata) {
|
|
9
|
+
super(service, name, metadata);
|
|
10
|
+
}
|
|
11
|
+
getResource(name) {
|
|
12
|
+
const t = this.metadata.resources[name];
|
|
13
|
+
if (!t)
|
|
14
|
+
throw new Error(`Resource "${name}" does not exists`);
|
|
15
|
+
return t;
|
|
16
|
+
}
|
|
17
|
+
getCollectionResource(name) {
|
|
18
|
+
const t = this.getResource(name);
|
|
19
|
+
if (!(t instanceof collection_resource_info_js_1.CollectionResourceInfo))
|
|
20
|
+
throw new Error(`"${name}" is not a Collection Resource`);
|
|
21
|
+
return t;
|
|
22
|
+
}
|
|
23
|
+
getSingletonResource(name) {
|
|
24
|
+
const t = this.getResource(name);
|
|
25
|
+
if (!(t instanceof singleton_resource_info_js_1.SingletonResourceInfo))
|
|
26
|
+
throw new Error(`"${name}" is not a SingletonResource`);
|
|
27
|
+
return t;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.ContainerResourceInfo = ContainerResourceInfo;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResourceInfo = void 0;
|
|
4
|
+
const clone_object_util_js_1 = require("../../utils/clone-object.util.js");
|
|
5
|
+
const inspect_util_js_1 = require("../../utils/inspect.util.js");
|
|
6
|
+
class ResourceInfo {
|
|
7
|
+
metadata;
|
|
8
|
+
document;
|
|
9
|
+
name;
|
|
10
|
+
path;
|
|
11
|
+
constructor(document, name, metadata) {
|
|
12
|
+
this.document = document;
|
|
13
|
+
this.name = name;
|
|
14
|
+
this.metadata = metadata;
|
|
15
|
+
}
|
|
16
|
+
get instance() {
|
|
17
|
+
return this.metadata.instance;
|
|
18
|
+
}
|
|
19
|
+
get kind() {
|
|
20
|
+
return this.metadata.kind;
|
|
21
|
+
}
|
|
22
|
+
get description() {
|
|
23
|
+
return this.metadata.description;
|
|
24
|
+
}
|
|
25
|
+
toString() {
|
|
26
|
+
return `[${Object.getPrototypeOf(this).constructor.name} ${this.name}]`;
|
|
27
|
+
}
|
|
28
|
+
validateQueryOptions() {
|
|
29
|
+
//
|
|
30
|
+
}
|
|
31
|
+
getSchema(jsonOnly) {
|
|
32
|
+
return (0, clone_object_util_js_1.cloneObject)(this.metadata, jsonOnly);
|
|
33
|
+
}
|
|
34
|
+
[inspect_util_js_1.nodeInspectCustom]() {
|
|
35
|
+
return `[${inspect_util_js_1.colorFgYellow + Object.getPrototypeOf(this).constructor.name + inspect_util_js_1.colorReset}` +
|
|
36
|
+
` ${inspect_util_js_1.colorFgMagenta + this.name + inspect_util_js_1.colorReset}]`;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.ResourceInfo = ResourceInfo;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SingletonResourceInfo = void 0;
|
|
4
|
+
const constants_js_1 = require("../../constants.js");
|
|
5
|
+
const complex_type_js_1 = require("../data-type/complex-type.js");
|
|
6
|
+
const resource_info_js_1 = require("./resource-info.js");
|
|
7
|
+
class SingletonResourceInfo extends resource_info_js_1.ResourceInfo {
|
|
8
|
+
dataType;
|
|
9
|
+
constructor(document, name, dataType, metadata) {
|
|
10
|
+
// noinspection SuspiciousTypeOfGuard
|
|
11
|
+
if (!(dataType instanceof complex_type_js_1.ComplexType))
|
|
12
|
+
throw new TypeError(`You should provide a ComplexType as "dataType" argument`);
|
|
13
|
+
super(document, name, metadata);
|
|
14
|
+
this.dataType = dataType;
|
|
15
|
+
}
|
|
16
|
+
get create() {
|
|
17
|
+
return this.metadata.create;
|
|
18
|
+
}
|
|
19
|
+
get delete() {
|
|
20
|
+
return this.metadata.delete;
|
|
21
|
+
}
|
|
22
|
+
get get() {
|
|
23
|
+
return this.metadata.get;
|
|
24
|
+
}
|
|
25
|
+
get update() {
|
|
26
|
+
return this.metadata.update;
|
|
27
|
+
}
|
|
28
|
+
getSchema(jsonOnly) {
|
|
29
|
+
const out = super.getSchema(jsonOnly);
|
|
30
|
+
for (const k of constants_js_1.singletonMethods) {
|
|
31
|
+
if (typeof out[k] === 'object' && !Object.keys(out[k]).length)
|
|
32
|
+
out[k] = true;
|
|
33
|
+
}
|
|
34
|
+
return out;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.SingletonResourceInfo = SingletonResourceInfo;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractResourceSchema = void 0;
|
|
4
|
+
const constants_js_1 = require("../../constants.js");
|
|
5
|
+
const opra_schema_definition_js_1 = require("../../opra-schema.definition.js");
|
|
6
|
+
const clone_object_util_js_1 = require("../../utils/clone-object.util.js");
|
|
7
|
+
async function extractResourceSchema(instance) {
|
|
8
|
+
const proto = Object.getPrototypeOf(instance);
|
|
9
|
+
const ctor = proto.constructor;
|
|
10
|
+
const metadata = Reflect.getMetadata(constants_js_1.RESOURCE_METADATA, ctor);
|
|
11
|
+
if (!metadata)
|
|
12
|
+
throw new TypeError(`Class "${ctor.name}" doesn't have "Resource" metadata information`);
|
|
13
|
+
const schema = (0, clone_object_util_js_1.cloneObject)(metadata);
|
|
14
|
+
schema.instance = instance;
|
|
15
|
+
schema.name = metadata.name || ctor.name.replace(/(Resource|Controller)$/, '');
|
|
16
|
+
if (opra_schema_definition_js_1.OpraSchema.isCollectionResource(metadata))
|
|
17
|
+
return await processCollectionResource(schema);
|
|
18
|
+
if (opra_schema_definition_js_1.OpraSchema.isSingletonResource(metadata))
|
|
19
|
+
return await processSingletonResource(schema);
|
|
20
|
+
throw new TypeError(`Invalid Resource metadata`);
|
|
21
|
+
}
|
|
22
|
+
exports.extractResourceSchema = extractResourceSchema;
|
|
23
|
+
async function processCollectionResource(schema) {
|
|
24
|
+
const instance = schema.instance;
|
|
25
|
+
const proto = Object.getPrototypeOf(schema.instance);
|
|
26
|
+
let methodMetadata;
|
|
27
|
+
let fn;
|
|
28
|
+
const locateFn = (inst, methodName) => {
|
|
29
|
+
fn = inst[methodName];
|
|
30
|
+
methodMetadata = Reflect.getMetadata(constants_js_1.RESOLVER_METADATA, inst, methodName);
|
|
31
|
+
if (fn == null) {
|
|
32
|
+
if (methodMetadata) {
|
|
33
|
+
inst = Object.getPrototypeOf(inst);
|
|
34
|
+
fn = inst[methodName];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
for (const methodName of constants_js_1.collectionMethods) {
|
|
39
|
+
locateFn(instance, methodName);
|
|
40
|
+
if (typeof fn !== 'function')
|
|
41
|
+
continue;
|
|
42
|
+
const info = schema[methodName] = {
|
|
43
|
+
...methodMetadata
|
|
44
|
+
};
|
|
45
|
+
if (!Reflect.hasMetadata(constants_js_1.IGNORE_RESOLVER_METHOD, proto.constructor, methodName)) {
|
|
46
|
+
info.handler = fn.bind(instance);
|
|
47
|
+
fn = instance['pre_' + methodName];
|
|
48
|
+
if (typeof fn === 'function')
|
|
49
|
+
schema['pre_' + methodName] = fn.bind(instance);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return schema;
|
|
53
|
+
}
|
|
54
|
+
async function processSingletonResource(schema) {
|
|
55
|
+
const instance = schema.instance;
|
|
56
|
+
const proto = Object.getPrototypeOf(schema.instance);
|
|
57
|
+
let methodMetadata;
|
|
58
|
+
let fn;
|
|
59
|
+
const locateFn = (inst, methodName) => {
|
|
60
|
+
fn = inst[methodName];
|
|
61
|
+
methodMetadata = Reflect.getMetadata(constants_js_1.RESOLVER_METADATA, inst, methodName);
|
|
62
|
+
if (fn == null) {
|
|
63
|
+
if (methodMetadata) {
|
|
64
|
+
inst = Object.getPrototypeOf(inst);
|
|
65
|
+
fn = inst[methodName];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
for (const methodName of constants_js_1.singletonMethods) {
|
|
70
|
+
locateFn(instance, methodName);
|
|
71
|
+
if (typeof fn !== 'function')
|
|
72
|
+
continue;
|
|
73
|
+
const info = schema[methodName] = {
|
|
74
|
+
...methodMetadata
|
|
75
|
+
};
|
|
76
|
+
if (!Reflect.hasMetadata(constants_js_1.IGNORE_RESOLVER_METHOD, proto.constructor, methodName)) {
|
|
77
|
+
info.handler = fn.bind(instance);
|
|
78
|
+
fn = instance['pre_' + methodName];
|
|
79
|
+
if (typeof fn === 'function')
|
|
80
|
+
schema['pre_' + methodName] = fn.bind(instance);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return schema;
|
|
84
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractDataTypeSchema = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const Optionals = tslib_1.__importStar(require("@opra/optionals"));
|
|
6
|
+
const constants_js_1 = require("../../constants.js");
|
|
7
|
+
const opra_schema_definition_js_1 = require("../../opra-schema.definition.js");
|
|
8
|
+
const clone_object_util_js_1 = require("../../utils/clone-object.util.js");
|
|
9
|
+
const builtin_data_types_js_1 = require("../data-type/builtin-data-types.js");
|
|
10
|
+
async function extractDataTypeSchema(ctor) {
|
|
11
|
+
const metadata = Reflect.getMetadata(constants_js_1.DATATYPE_METADATA, ctor);
|
|
12
|
+
if (!metadata)
|
|
13
|
+
throw new TypeError(`Class "${ctor}" doesn't have "DataType" metadata information`);
|
|
14
|
+
if (opra_schema_definition_js_1.OpraSchema.isComplexType(metadata))
|
|
15
|
+
return await extractComplexTypeSchema(ctor, metadata);
|
|
16
|
+
if (opra_schema_definition_js_1.OpraSchema.isSimpleType(metadata))
|
|
17
|
+
return await extractSimpleTypeSchema(ctor, metadata);
|
|
18
|
+
throw new TypeError(`Invalid DataType metadata`);
|
|
19
|
+
}
|
|
20
|
+
exports.extractDataTypeSchema = extractDataTypeSchema;
|
|
21
|
+
async function extractSimpleTypeSchema(ctor, metadata) {
|
|
22
|
+
const out = (0, clone_object_util_js_1.cloneObject)(metadata);
|
|
23
|
+
out.ctor = ctor;
|
|
24
|
+
return out;
|
|
25
|
+
}
|
|
26
|
+
async function extractComplexTypeSchema(ctor, metadata) {
|
|
27
|
+
const out = (0, clone_object_util_js_1.cloneObject)(metadata);
|
|
28
|
+
out.ctor = ctor;
|
|
29
|
+
const mappedTypeMetadata = Reflect.getMetadata(constants_js_1.MAPPED_TYPE_METADATA, ctor);
|
|
30
|
+
if (mappedTypeMetadata) {
|
|
31
|
+
out.extends = [...mappedTypeMetadata.map(x => (0, clone_object_util_js_1.cloneObject)(x))];
|
|
32
|
+
}
|
|
33
|
+
const fields = Reflect.getMetadata(constants_js_1.COMPLEXTYPE_FIELDS, ctor);
|
|
34
|
+
if (fields) {
|
|
35
|
+
out.fields = (0, clone_object_util_js_1.cloneObject)(fields);
|
|
36
|
+
for (const [fieldName, field] of Object.entries(out.fields)) {
|
|
37
|
+
if (typeof field.type === 'function') {
|
|
38
|
+
const type = builtin_data_types_js_1.primitiveClasses.get(field.type);
|
|
39
|
+
if (type)
|
|
40
|
+
field.type = type;
|
|
41
|
+
}
|
|
42
|
+
let sqbField;
|
|
43
|
+
if (Optionals.SqbConnect) {
|
|
44
|
+
const { EntityMetadata, isAssociationField } = Optionals.SqbConnect;
|
|
45
|
+
const meta = EntityMetadata.get(ctor);
|
|
46
|
+
sqbField = meta && EntityMetadata.getField(meta, fieldName);
|
|
47
|
+
if (sqbField) {
|
|
48
|
+
if (field.type === Function || field.type === 'object' ||
|
|
49
|
+
field.type === Object || field.type === 'any') {
|
|
50
|
+
field.type = 'any';
|
|
51
|
+
if (isAssociationField(sqbField)) {
|
|
52
|
+
if (!sqbField.association.returnsMany())
|
|
53
|
+
delete field.isArray;
|
|
54
|
+
const trg = await sqbField.association.resolveTarget();
|
|
55
|
+
if (trg) {
|
|
56
|
+
field.type = trg.ctor;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (sqbField.exclusive && field.exclusive === undefined)
|
|
61
|
+
field.exclusive = sqbField.exclusive;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (sqbField && sqbField.kind === 'column') {
|
|
65
|
+
const DataType = Optionals.SqbConnect.DataType;
|
|
66
|
+
if (field.type === 'number' || field.type === Number) {
|
|
67
|
+
switch (sqbField.dataType) {
|
|
68
|
+
case DataType.INTEGER:
|
|
69
|
+
case DataType.SMALLINT:
|
|
70
|
+
field.type = 'integer';
|
|
71
|
+
break;
|
|
72
|
+
case DataType.BIGINT:
|
|
73
|
+
field.type = 'bigint';
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else if (field.type === 'string' || field.type === String) {
|
|
78
|
+
switch (sqbField.dataType) {
|
|
79
|
+
case DataType.GUID:
|
|
80
|
+
field.type = 'guid';
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (sqbField.notNull && field.required === undefined)
|
|
85
|
+
field.required = sqbField.notNull;
|
|
86
|
+
if (sqbField.exclusive && field.exclusive === undefined)
|
|
87
|
+
field.exclusive = sqbField.exclusive;
|
|
88
|
+
if (sqbField.default !== undefined && field.default === undefined)
|
|
89
|
+
field.default = sqbField.default;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return out;
|
|
94
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
tslib_1.__exportStar(require("./constants.js"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./types.js"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./opra-schema.definition.js"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./decorators/opr-complex-type.decorator.js"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./decorators/opr-field.decorator.js"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./decorators/opr-collection-resource.decorator.js"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./decorators/opr-singleton-resource.decorator.js"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./decorators/opr-resolver.decorator.js"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./interfaces/resource-container.interface.js"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./implementation/document-builder.js"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./implementation/opra-document.js"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./implementation/data-type/data-type.js"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./implementation/data-type/complex-type.js"), exports);
|
|
18
|
+
tslib_1.__exportStar(require("./implementation/data-type/simple-type.js"), exports);
|
|
19
|
+
tslib_1.__exportStar(require("./implementation/data-type/union-type.js"), exports);
|
|
20
|
+
tslib_1.__exportStar(require("./implementation/resource/resource-info.js"), exports);
|
|
21
|
+
tslib_1.__exportStar(require("./implementation/resource/container-resource-info.js"), exports);
|
|
22
|
+
tslib_1.__exportStar(require("./implementation/resource/collection-resource-info.js"), exports);
|
|
23
|
+
tslib_1.__exportStar(require("./implementation/resource/singleton-resource-info.js"), exports);
|
|
24
|
+
tslib_1.__exportStar(require("./implementation/query/index.js"), exports);
|
|
25
|
+
tslib_1.__exportStar(require("./type-helpers/mixin-type.helper.js"), exports);
|
|
26
|
+
tslib_1.__exportStar(require("./type-helpers/extend-type.helper.js"), exports);
|
|
27
|
+
tslib_1.__exportStar(require("./implementation/schema-builder/extract-type-metadata.util.js"), exports);
|
|
28
|
+
tslib_1.__exportStar(require("./implementation/schema-builder/extract-resource-metadata.util.js"), exports);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OpraSchema = void 0;
|
|
4
|
+
var OpraSchema;
|
|
5
|
+
(function (OpraSchema) {
|
|
6
|
+
/**
|
|
7
|
+
* *** === Constants === ***
|
|
8
|
+
*/
|
|
9
|
+
OpraSchema.Version = '1.0';
|
|
10
|
+
/**
|
|
11
|
+
* *** === Type Guards === ***
|
|
12
|
+
*/
|
|
13
|
+
function isDataType(obj) {
|
|
14
|
+
return obj && typeof obj === 'object' &&
|
|
15
|
+
(obj.kind === 'ComplexType' || obj.kind === 'SimpleType' || obj.kind === 'UnionType');
|
|
16
|
+
}
|
|
17
|
+
OpraSchema.isDataType = isDataType;
|
|
18
|
+
function isComplexType(obj) {
|
|
19
|
+
return obj && typeof obj === 'object' && obj.kind === 'ComplexType';
|
|
20
|
+
}
|
|
21
|
+
OpraSchema.isComplexType = isComplexType;
|
|
22
|
+
function isSimpleType(obj) {
|
|
23
|
+
return obj && typeof obj === 'object' && obj.kind === 'SimpleType';
|
|
24
|
+
}
|
|
25
|
+
OpraSchema.isSimpleType = isSimpleType;
|
|
26
|
+
function isUnionTypee(obj) {
|
|
27
|
+
return obj && typeof obj === 'object' && obj.kind === 'UnionType';
|
|
28
|
+
}
|
|
29
|
+
OpraSchema.isUnionTypee = isUnionTypee;
|
|
30
|
+
function isResource(obj) {
|
|
31
|
+
return obj && typeof obj === 'object' &&
|
|
32
|
+
obj.kind === 'ContainerResource' ||
|
|
33
|
+
obj.kind === 'CollectionResource' ||
|
|
34
|
+
obj.kind === 'SingletonResource';
|
|
35
|
+
}
|
|
36
|
+
OpraSchema.isResource = isResource;
|
|
37
|
+
function isCollectionResource(obj) {
|
|
38
|
+
return obj && typeof obj === 'object' && obj.kind === 'CollectionResource';
|
|
39
|
+
}
|
|
40
|
+
OpraSchema.isCollectionResource = isCollectionResource;
|
|
41
|
+
function isSingletonResource(obj) {
|
|
42
|
+
return obj && typeof obj === 'object' && obj.kind === 'SingletonResource';
|
|
43
|
+
}
|
|
44
|
+
OpraSchema.isSingletonResource = isSingletonResource;
|
|
45
|
+
function isContainerResource(obj) {
|
|
46
|
+
return obj && typeof obj === 'object' && obj.kind === 'ContainerResource';
|
|
47
|
+
}
|
|
48
|
+
OpraSchema.isContainerResource = isContainerResource;
|
|
49
|
+
})(OpraSchema = exports.OpraSchema || (exports.OpraSchema = {}));
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OmitType = exports.PickType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const Optionals = tslib_1.__importStar(require("@opra/optionals"));
|
|
6
|
+
const constants_js_1 = require("../constants.js");
|
|
7
|
+
const mixin_utils_js_1 = require("./mixin.utils.js");
|
|
8
|
+
function PickType(classRef, keys) {
|
|
9
|
+
return ExtendType(classRef, classRef, { pickKeys: keys });
|
|
10
|
+
}
|
|
11
|
+
exports.PickType = PickType;
|
|
12
|
+
function OmitType(classRef, keys) {
|
|
13
|
+
return ExtendType(classRef, classRef, { omitKeys: keys });
|
|
14
|
+
}
|
|
15
|
+
exports.OmitType = OmitType;
|
|
16
|
+
function ExtendType(classRef, orgClassRef, options) {
|
|
17
|
+
const pickKeys = options.pickKeys && options.pickKeys.map(x => String(x).toLowerCase());
|
|
18
|
+
const omitKeys = options.omitKeys && options.omitKeys.map(x => String(x).toLowerCase());
|
|
19
|
+
const isInheritedPredicate = (propertyName) => {
|
|
20
|
+
if (omitKeys && omitKeys.includes(propertyName.toLowerCase()))
|
|
21
|
+
return false;
|
|
22
|
+
if (pickKeys)
|
|
23
|
+
return pickKeys.includes(propertyName.toLowerCase());
|
|
24
|
+
return true;
|
|
25
|
+
};
|
|
26
|
+
// const isRequiredPredicate = (propertyName: string): boolean | undefined => {
|
|
27
|
+
// if (options.requiredKeys && options.requiredKeys.includes(propertyName as RequiredKey))
|
|
28
|
+
// return true;
|
|
29
|
+
// if (options.partialKeys && options.partialKeys.includes(propertyName as PartialKey))
|
|
30
|
+
// return false;
|
|
31
|
+
// return;
|
|
32
|
+
// };
|
|
33
|
+
class MappedClass {
|
|
34
|
+
constructor() {
|
|
35
|
+
(0, mixin_utils_js_1.inheritPropertyInitializers)(this, classRef, isInheritedPredicate);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
(0, mixin_utils_js_1.applyMixins)(MappedClass, classRef);
|
|
39
|
+
const mappedTypeMetadata = [];
|
|
40
|
+
const m = Reflect.getOwnMetadata(constants_js_1.DATATYPE_METADATA, classRef);
|
|
41
|
+
if (m) {
|
|
42
|
+
if (!(m.kind === 'ComplexType'))
|
|
43
|
+
throw new TypeError(`Class "${classRef}" is not a ComplexType`);
|
|
44
|
+
const meta = {
|
|
45
|
+
type: classRef
|
|
46
|
+
};
|
|
47
|
+
if (options.pickKeys)
|
|
48
|
+
meta.pick = options.pickKeys;
|
|
49
|
+
if (options.omitKeys)
|
|
50
|
+
meta.omit = options.omitKeys;
|
|
51
|
+
mappedTypeMetadata.push(meta);
|
|
52
|
+
}
|
|
53
|
+
else
|
|
54
|
+
throw new TypeError(`Class "${classRef}" doesn't have datatype metadata information`);
|
|
55
|
+
if (Optionals.SqbConnect) {
|
|
56
|
+
const { Entity, EntityMetadata } = Optionals.SqbConnect;
|
|
57
|
+
const srcMeta = Entity.getMetadata(classRef);
|
|
58
|
+
if (srcMeta) {
|
|
59
|
+
const trgMeta = EntityMetadata.define(MappedClass);
|
|
60
|
+
EntityMetadata.mixin(trgMeta, srcMeta, k => isInheritedPredicate(k));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
Reflect.defineMetadata(constants_js_1.MAPPED_TYPE_METADATA, mappedTypeMetadata, MappedClass);
|
|
64
|
+
return MappedClass;
|
|
65
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MixinType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const Optionals = tslib_1.__importStar(require("@opra/optionals"));
|
|
6
|
+
const constants_js_1 = require("../constants.js");
|
|
7
|
+
const mixin_utils_js_1 = require("./mixin.utils.js");
|
|
8
|
+
function MixinType(c1, c2, c3, c4) {
|
|
9
|
+
const clasRefs = [...arguments].filter(x => !!x);
|
|
10
|
+
if (!clasRefs.length)
|
|
11
|
+
throw new TypeError('You must provide base classeses');
|
|
12
|
+
if (clasRefs.length === 1)
|
|
13
|
+
return clasRefs[0];
|
|
14
|
+
class MappedClass {
|
|
15
|
+
constructor() {
|
|
16
|
+
for (const c of clasRefs)
|
|
17
|
+
(0, mixin_utils_js_1.inheritPropertyInitializers)(this, c);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const mappedTypeMetadata = [];
|
|
21
|
+
for (const c of clasRefs) {
|
|
22
|
+
const m = Reflect.getOwnMetadata(constants_js_1.DATATYPE_METADATA, c);
|
|
23
|
+
if (m) {
|
|
24
|
+
if (!(m.kind === 'ComplexType'))
|
|
25
|
+
throw new TypeError(`Class "${c}" is not a ComplexType`);
|
|
26
|
+
mappedTypeMetadata.push({
|
|
27
|
+
type: c
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
else if (Reflect.hasMetadata(constants_js_1.MAPPED_TYPE_METADATA, c)) {
|
|
31
|
+
const mtm = Reflect.getMetadata(constants_js_1.MAPPED_TYPE_METADATA, c);
|
|
32
|
+
if (mtm)
|
|
33
|
+
mappedTypeMetadata.push(...mtm);
|
|
34
|
+
}
|
|
35
|
+
else
|
|
36
|
+
throw new TypeError(`Class "${c}" doesn't have datatype metadata information`);
|
|
37
|
+
(0, mixin_utils_js_1.applyMixins)(MappedClass, c);
|
|
38
|
+
}
|
|
39
|
+
if (Optionals.SqbConnect) {
|
|
40
|
+
const { Entity } = Optionals.SqbConnect;
|
|
41
|
+
Entity.mixin(MappedClass, ...clasRefs);
|
|
42
|
+
}
|
|
43
|
+
Reflect.defineMetadata(constants_js_1.MAPPED_TYPE_METADATA, mappedTypeMetadata, MappedClass);
|
|
44
|
+
return MappedClass;
|
|
45
|
+
}
|
|
46
|
+
exports.MixinType = MixinType;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.inheritPropertyInitializers = exports.applyMixins = void 0;
|
|
4
|
+
function applyMixins(derivedCtor, baseCtor, filter) {
|
|
5
|
+
for (const k of Object.getOwnPropertyNames(baseCtor.prototype)) {
|
|
6
|
+
if ((k === 'constructor' || k === '__proto__' || k === 'toJSON' || k === 'toString') ||
|
|
7
|
+
filter && !filter(k))
|
|
8
|
+
continue;
|
|
9
|
+
Object.defineProperty(derivedCtor.prototype, k, Object.getOwnPropertyDescriptor(baseCtor.prototype, k) ||
|
|
10
|
+
Object.create(null));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.applyMixins = applyMixins;
|
|
14
|
+
function inheritPropertyInitializers(target, sourceClass,
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
16
|
+
isPropertyInherited = (key) => true) {
|
|
17
|
+
try {
|
|
18
|
+
const tempInstance = new sourceClass();
|
|
19
|
+
const propertyNames = Object.getOwnPropertyNames(tempInstance);
|
|
20
|
+
propertyNames
|
|
21
|
+
.filter((propertyName) => typeof tempInstance[propertyName] !== 'undefined' &&
|
|
22
|
+
typeof target[propertyName] === 'undefined')
|
|
23
|
+
.filter((propertyName) => isPropertyInherited(propertyName))
|
|
24
|
+
.forEach((propertyName) => {
|
|
25
|
+
target[propertyName] = tempInstance[propertyName];
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
//
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.inheritPropertyInitializers = inheritPropertyInitializers;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isConstructor = void 0;
|
|
4
|
+
function isConstructor(obj) {
|
|
5
|
+
return typeof obj === 'function' &&
|
|
6
|
+
!!(obj.prototype && obj.prototype.constructor);
|
|
7
|
+
}
|
|
8
|
+
exports.isConstructor = isConstructor;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cloneObject = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const putil_isplainobject_1 = tslib_1.__importDefault(require("putil-isplainobject"));
|
|
6
|
+
const putil_merge_1 = tslib_1.__importDefault(require("putil-merge"));
|
|
7
|
+
function cloneObject(obj, jsonOnly) {
|
|
8
|
+
return (0, putil_merge_1.default)({}, obj, {
|
|
9
|
+
deep: true,
|
|
10
|
+
clone: true,
|
|
11
|
+
filter: (source, key) => {
|
|
12
|
+
const v = source[key];
|
|
13
|
+
return v != null &&
|
|
14
|
+
!jsonOnly || (typeof v !== 'function' &&
|
|
15
|
+
(typeof v !== 'object' || (0, putil_isplainobject_1.default)(v) || Array.isArray(v)));
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
exports.cloneObject = cloneObject;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.colorFgMagenta = exports.colorFgYellow = exports.colorReset = exports.nodeInspectCustom = void 0;
|
|
4
|
+
exports.nodeInspectCustom = Symbol.for('nodejs.util.inspect.custom');
|
|
5
|
+
exports.colorReset = "\x1b[0m";
|
|
6
|
+
exports.colorFgYellow = "\x1b[33m";
|
|
7
|
+
exports.colorFgMagenta = "\x1b[35m";
|