@opra/common 0.4.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/{responsive-map.js → helpers/responsive-map.js} +1 -1
- package/cjs/http/enums/http-headers.enum.js +404 -0
- package/cjs/http/enums/http-status.enum.js +300 -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 -2
- 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/{responsive-map.d.ts → helpers/responsive-map.d.ts} +0 -0
- package/esm/{responsive-map.js → helpers/responsive-map.js} +1 -1
- package/esm/http/enums/http-headers.enum.d.ts +379 -0
- package/esm/http/enums/http-headers.enum.js +401 -0
- package/esm/http/enums/http-status.enum.d.ts +290 -0
- package/esm/http/enums/http-status.enum.js +297 -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 -2
- package/esm/index.js +10 -2
- 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
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CollectionGetQuery = void 0;
|
|
4
|
+
const normalize_field_array_util_js_1 = require("../../utils/normalize-field-array.util.js");
|
|
5
|
+
class CollectionGetQuery {
|
|
6
|
+
resource;
|
|
7
|
+
kind = 'CollectionGetQuery';
|
|
8
|
+
method = 'get';
|
|
9
|
+
operation = 'read';
|
|
10
|
+
keyValue;
|
|
11
|
+
pick;
|
|
12
|
+
omit;
|
|
13
|
+
include;
|
|
14
|
+
child;
|
|
15
|
+
constructor(resource, keyValue, options) {
|
|
16
|
+
this.resource = resource;
|
|
17
|
+
if (resource.keyFields.length > 1) {
|
|
18
|
+
if (typeof keyValue !== 'object')
|
|
19
|
+
throw new Error(`You must provide an key/value object for all key fields (${resource.keyFields})`);
|
|
20
|
+
resource.keyFields.reduce((o, k) => {
|
|
21
|
+
o[k] = keyValue[k];
|
|
22
|
+
return o;
|
|
23
|
+
}, {});
|
|
24
|
+
}
|
|
25
|
+
else
|
|
26
|
+
this.keyValue = resource.dataType.getFieldType(resource.keyFields[0]).parse(keyValue);
|
|
27
|
+
if (options?.pick)
|
|
28
|
+
this.pick = (0, normalize_field_array_util_js_1.normalizeFieldArray)(resource.document, resource.dataType, options.pick);
|
|
29
|
+
if (options?.omit)
|
|
30
|
+
this.omit = (0, normalize_field_array_util_js_1.normalizeFieldArray)(resource.document, resource.dataType, options.omit);
|
|
31
|
+
if (options?.include)
|
|
32
|
+
this.include = (0, normalize_field_array_util_js_1.normalizeFieldArray)(resource.document, resource.dataType, options.include);
|
|
33
|
+
}
|
|
34
|
+
get dataType() {
|
|
35
|
+
return this.resource.dataType;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.CollectionGetQuery = CollectionGetQuery;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CollectionSearchQuery = void 0;
|
|
4
|
+
const index_js_1 = require("../../../exception/index.js");
|
|
5
|
+
const index_js_2 = require("../../../filter/index.js");
|
|
6
|
+
const index_js_3 = require("../../../i18n/index.js");
|
|
7
|
+
const normalize_field_array_util_js_1 = require("../../utils/normalize-field-array.util.js");
|
|
8
|
+
class CollectionSearchQuery {
|
|
9
|
+
resource;
|
|
10
|
+
kind = 'CollectionSearchQuery';
|
|
11
|
+
method = 'search';
|
|
12
|
+
operation = 'read';
|
|
13
|
+
pick;
|
|
14
|
+
omit;
|
|
15
|
+
include;
|
|
16
|
+
filter;
|
|
17
|
+
limit;
|
|
18
|
+
skip;
|
|
19
|
+
distinct;
|
|
20
|
+
count;
|
|
21
|
+
sort;
|
|
22
|
+
constructor(resource, options) {
|
|
23
|
+
this.resource = resource;
|
|
24
|
+
if (options?.pick)
|
|
25
|
+
this.pick = (0, normalize_field_array_util_js_1.normalizeFieldArray)(resource.document, resource.dataType, options.pick);
|
|
26
|
+
if (options?.omit)
|
|
27
|
+
this.omit = (0, normalize_field_array_util_js_1.normalizeFieldArray)(resource.document, resource.dataType, options.omit);
|
|
28
|
+
if (options?.include)
|
|
29
|
+
this.include = (0, normalize_field_array_util_js_1.normalizeFieldArray)(resource.document, resource.dataType, options.include);
|
|
30
|
+
this.filter = typeof options?.filter === 'string' ? (0, index_js_2.parseFilter)(options.filter) : options?.filter;
|
|
31
|
+
this.limit = options?.limit;
|
|
32
|
+
this.skip = options?.skip;
|
|
33
|
+
this.distinct = options?.distinct;
|
|
34
|
+
this.count = options?.count;
|
|
35
|
+
if (options?.sort) {
|
|
36
|
+
this.sort = (0, normalize_field_array_util_js_1.normalizeFieldArray)(resource.document, resource.dataType, options.sort);
|
|
37
|
+
const search = resource.search;
|
|
38
|
+
if (search && typeof search === 'object') {
|
|
39
|
+
const sortFields = search.sortFields;
|
|
40
|
+
if (sortFields) {
|
|
41
|
+
this.sort.forEach(field => {
|
|
42
|
+
if (!sortFields.find(x => x === field))
|
|
43
|
+
throw new index_js_1.BadRequestError({
|
|
44
|
+
message: (0, index_js_3.translate)('error:UNACCEPTED_SORT_FIELD', { field }, `Field '${field}' is not available for sort operation`),
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
get dataType() {
|
|
52
|
+
return this.resource.dataType;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.CollectionSearchQuery = CollectionSearchQuery;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CollectionUpdateManyQuery = void 0;
|
|
4
|
+
const index_js_1 = require("../../../filter/index.js");
|
|
5
|
+
class CollectionUpdateManyQuery {
|
|
6
|
+
resource;
|
|
7
|
+
data;
|
|
8
|
+
kind = 'CollectionUpdateManyQuery';
|
|
9
|
+
method = 'updateMany';
|
|
10
|
+
operation = 'update';
|
|
11
|
+
filter;
|
|
12
|
+
constructor(resource, data, options) {
|
|
13
|
+
this.resource = resource;
|
|
14
|
+
this.data = data;
|
|
15
|
+
this.filter = typeof options?.filter === 'string' ? (0, index_js_1.parseFilter)(options.filter) : options?.filter;
|
|
16
|
+
}
|
|
17
|
+
get dataType() {
|
|
18
|
+
return this.resource.dataType;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.CollectionUpdateManyQuery = CollectionUpdateManyQuery;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CollectionUpdateQuery = void 0;
|
|
4
|
+
const normalize_field_array_util_js_1 = require("../../utils/normalize-field-array.util.js");
|
|
5
|
+
class CollectionUpdateQuery {
|
|
6
|
+
resource;
|
|
7
|
+
data;
|
|
8
|
+
kind = 'CollectionUpdateQuery';
|
|
9
|
+
method = 'update';
|
|
10
|
+
operation = 'update';
|
|
11
|
+
keyValue;
|
|
12
|
+
pick;
|
|
13
|
+
omit;
|
|
14
|
+
include;
|
|
15
|
+
constructor(resource, keyValue, data, options) {
|
|
16
|
+
this.resource = resource;
|
|
17
|
+
this.data = data;
|
|
18
|
+
if (resource.keyFields.length > 1) {
|
|
19
|
+
if (typeof keyValue !== 'object')
|
|
20
|
+
throw new Error(`You must provide an key/value object for all key fields (${resource.keyFields})`);
|
|
21
|
+
resource.keyFields.reduce((o, k) => {
|
|
22
|
+
o[k] = keyValue[k];
|
|
23
|
+
return o;
|
|
24
|
+
}, {});
|
|
25
|
+
}
|
|
26
|
+
else
|
|
27
|
+
this.keyValue = resource.dataType.getFieldType(resource.keyFields[0]).parse(keyValue);
|
|
28
|
+
if (options?.pick)
|
|
29
|
+
this.pick = (0, normalize_field_array_util_js_1.normalizeFieldArray)(resource.document, resource.dataType, options.pick);
|
|
30
|
+
if (options?.omit)
|
|
31
|
+
this.omit = (0, normalize_field_array_util_js_1.normalizeFieldArray)(resource.document, resource.dataType, options.omit);
|
|
32
|
+
if (options?.include)
|
|
33
|
+
this.include = (0, normalize_field_array_util_js_1.normalizeFieldArray)(resource.document, resource.dataType, options.include);
|
|
34
|
+
}
|
|
35
|
+
get dataType() {
|
|
36
|
+
return this.resource.dataType;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.CollectionUpdateQuery = CollectionUpdateQuery;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FieldGetQuery = void 0;
|
|
4
|
+
const normalize_field_array_util_js_1 = require("../../utils/normalize-field-array.util.js");
|
|
5
|
+
const complex_type_js_1 = require("../data-type/complex-type.js");
|
|
6
|
+
class FieldGetQuery {
|
|
7
|
+
parent;
|
|
8
|
+
resource;
|
|
9
|
+
kind = 'FieldGetQuery';
|
|
10
|
+
method = 'get';
|
|
11
|
+
operation = 'read';
|
|
12
|
+
fieldName;
|
|
13
|
+
field;
|
|
14
|
+
path;
|
|
15
|
+
dataType;
|
|
16
|
+
parentType;
|
|
17
|
+
pick;
|
|
18
|
+
omit;
|
|
19
|
+
include;
|
|
20
|
+
child;
|
|
21
|
+
constructor(parent, fieldName, options) {
|
|
22
|
+
this.parent = parent;
|
|
23
|
+
this.resource = parent.resource;
|
|
24
|
+
const parentType = options?.castingType || parent.dataType;
|
|
25
|
+
if (!parentType || !(parentType instanceof complex_type_js_1.ComplexType))
|
|
26
|
+
throw new TypeError(`Data type of parent query is not a ComplexType`);
|
|
27
|
+
this.parentType = parentType;
|
|
28
|
+
this.field = parentType.additionalFields
|
|
29
|
+
? parentType.fields.get(fieldName)
|
|
30
|
+
: parentType.getField(fieldName);
|
|
31
|
+
this.fieldName = this.field ? this.field.name : fieldName;
|
|
32
|
+
this.dataType = this.resource.document.getDataType(this.field ? (this.field.type || 'string') : 'object');
|
|
33
|
+
this.path = (parent instanceof FieldGetQuery
|
|
34
|
+
? parent.path + '.' : '') + this.fieldName;
|
|
35
|
+
if (this.dataType instanceof complex_type_js_1.ComplexType) {
|
|
36
|
+
if (options?.pick)
|
|
37
|
+
this.pick = (0, normalize_field_array_util_js_1.normalizeFieldArray)(this.resource.document, this.dataType, options.pick, this.path);
|
|
38
|
+
if (options?.omit)
|
|
39
|
+
this.omit = (0, normalize_field_array_util_js_1.normalizeFieldArray)(this.resource.document, this.dataType, options.omit, this.path);
|
|
40
|
+
if (options?.include)
|
|
41
|
+
this.include = (0, normalize_field_array_util_js_1.normalizeFieldArray)(this.resource.document, this.dataType, options.include, this.path);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.FieldGetQuery = FieldGetQuery;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isChildFieldQuery = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
tslib_1.__exportStar(require("./collection-create-query.js"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./collection-count-query.js"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./collection-delete-many-query.js"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./collection-delete-query.js"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./collection-delete-many-query.js"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./collection-get-query.js"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./field-get-query.js"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./singleton-get-query.js"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./collection-search-query.js"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./collection-update-many-query.js"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./collection-update-query.js"), exports);
|
|
16
|
+
function isChildFieldQuery(query) {
|
|
17
|
+
return query &&
|
|
18
|
+
(query.kind === 'SingletonGetQuery' ||
|
|
19
|
+
query.kind === 'CollectionGetQuery' ||
|
|
20
|
+
query.kind === 'FieldGetQuery');
|
|
21
|
+
}
|
|
22
|
+
exports.isChildFieldQuery = isChildFieldQuery;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SingletonGetQuery = void 0;
|
|
4
|
+
const normalize_field_array_util_js_1 = require("../../utils/normalize-field-array.util.js");
|
|
5
|
+
class SingletonGetQuery {
|
|
6
|
+
resource;
|
|
7
|
+
kind = 'SingletonGetQuery';
|
|
8
|
+
method = 'get';
|
|
9
|
+
operation = 'read';
|
|
10
|
+
pick;
|
|
11
|
+
omit;
|
|
12
|
+
include;
|
|
13
|
+
child;
|
|
14
|
+
constructor(resource, options) {
|
|
15
|
+
this.resource = resource;
|
|
16
|
+
if (options?.pick)
|
|
17
|
+
this.pick = (0, normalize_field_array_util_js_1.normalizeFieldArray)(resource.document, resource.dataType, options.pick);
|
|
18
|
+
if (options?.omit)
|
|
19
|
+
this.omit = (0, normalize_field_array_util_js_1.normalizeFieldArray)(resource.document, resource.dataType, options.omit);
|
|
20
|
+
if (options?.include)
|
|
21
|
+
this.include = (0, normalize_field_array_util_js_1.normalizeFieldArray)(resource.document, resource.dataType, options.include);
|
|
22
|
+
}
|
|
23
|
+
get dataType() {
|
|
24
|
+
return this.resource.dataType;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.SingletonGetQuery = SingletonGetQuery;
|
|
@@ -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);
|