@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
package/cjs/i18n/i18n.js
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.I18n = exports.BaseI18n = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fast_tokenizer_1 = require("fast-tokenizer");
|
|
6
|
+
const i18next_1 = tslib_1.__importDefault(require("i18next"));
|
|
7
|
+
const index_js_1 = require("../utils/index.js");
|
|
8
|
+
const string_utils_js_1 = require("./string-utils.js");
|
|
9
|
+
exports.BaseI18n = Object.getPrototypeOf(i18next_1.default).constructor;
|
|
10
|
+
const globalLocaleDirs = [];
|
|
11
|
+
class I18n extends exports.BaseI18n {
|
|
12
|
+
async init(arg0, arg1) {
|
|
13
|
+
const options = typeof arg0 === 'object' ? arg0 : {};
|
|
14
|
+
const callback = typeof arg0 === 'function' ? arg0 : arg1;
|
|
15
|
+
try {
|
|
16
|
+
const t = await super.init(options);
|
|
17
|
+
// Add formatters
|
|
18
|
+
const formatter = this.services.formatter;
|
|
19
|
+
formatter.add('lowercase', (value, lng) => value.toLocaleLowerCase(lng));
|
|
20
|
+
formatter.add('uppercase', (value, lng) => value.toLocaleUpperCase(lng));
|
|
21
|
+
formatter.add('upperFirst', (value, lng) => value.charAt(0).toLocaleUpperCase(lng) + value.substring(1));
|
|
22
|
+
// Load globally registered resources
|
|
23
|
+
if (globalLocaleDirs.length)
|
|
24
|
+
await this.loadResourceDir(globalLocaleDirs, false, true);
|
|
25
|
+
// Load resource dirs and overwrite existing
|
|
26
|
+
if (options?.resourceDirs?.length) {
|
|
27
|
+
await this.loadResourceDir(options.resourceDirs, false, true);
|
|
28
|
+
}
|
|
29
|
+
// overwrite existing resources with options.resources
|
|
30
|
+
if (options?.resources) {
|
|
31
|
+
for (const lang of Object.keys(options.resources)) {
|
|
32
|
+
const langObj = options.resources[lang];
|
|
33
|
+
for (const ns of Object.keys(langObj)) {
|
|
34
|
+
this.addResourceBundle(lang, ns, langObj[ns], false, true);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (callback)
|
|
39
|
+
callback(null, t);
|
|
40
|
+
return t;
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
if (callback)
|
|
44
|
+
callback(err, this.t);
|
|
45
|
+
throw err;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
deep(input, options) {
|
|
49
|
+
if (input == null)
|
|
50
|
+
return input;
|
|
51
|
+
const objectStack = new WeakMap();
|
|
52
|
+
return this._deepTranslate(input, objectStack, options);
|
|
53
|
+
}
|
|
54
|
+
registerLocaleDir(...dirname) {
|
|
55
|
+
globalLocaleDirs.push(...dirname);
|
|
56
|
+
}
|
|
57
|
+
async loadResourceBundle(lang, ns, filePath, deep, overwrite) {
|
|
58
|
+
let obj;
|
|
59
|
+
if ((0, index_js_1.isUrl)(filePath)) {
|
|
60
|
+
obj = (await fetch(filePath, { headers: { accept: 'application/json' } })).json();
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
const fs = await Promise.resolve().then(() => tslib_1.__importStar(require('fs/promises')));
|
|
64
|
+
const content = await fs.readFile(filePath, 'utf8');
|
|
65
|
+
obj = JSON.parse(content);
|
|
66
|
+
}
|
|
67
|
+
this.addResourceBundle(lang, ns, obj, deep, overwrite);
|
|
68
|
+
}
|
|
69
|
+
async loadResourceDir(dirnames, deep, overwrite) {
|
|
70
|
+
const fs = await Promise.resolve().then(() => tslib_1.__importStar(require('fs/promises')));
|
|
71
|
+
const path = await Promise.resolve().then(() => tslib_1.__importStar(require('path')));
|
|
72
|
+
for (const dirname of Array.isArray(dirnames) ? dirnames : [dirnames]) {
|
|
73
|
+
/* istanbul ignore next */
|
|
74
|
+
if (!(await fs.stat(dirname)).isDirectory()) {
|
|
75
|
+
// eslint-disable-next-line no-console
|
|
76
|
+
console.warn(`Locale directory does not exists. (${dirname})`);
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const languageDirs = await fs.readdir(dirname);
|
|
80
|
+
for (const lang of languageDirs) {
|
|
81
|
+
const langDir = path.join(dirname, lang);
|
|
82
|
+
if ((await fs.stat(langDir)).isDirectory()) {
|
|
83
|
+
const nsDirs = await fs.readdir(langDir);
|
|
84
|
+
for (const nsfile of nsDirs) {
|
|
85
|
+
const nsFilePath = path.join(langDir, nsfile);
|
|
86
|
+
const ext = path.extname(nsfile);
|
|
87
|
+
if (ext === '.json' && (await fs.stat(nsFilePath)).isFile()) {
|
|
88
|
+
const ns = path.basename(nsfile, ext);
|
|
89
|
+
await this.loadResourceBundle(lang, ns, nsFilePath, deep, overwrite);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
createInstance(options = {}, callback) {
|
|
97
|
+
return new I18n(options, callback);
|
|
98
|
+
}
|
|
99
|
+
static createInstance(options, callback) {
|
|
100
|
+
return new I18n(options, callback);
|
|
101
|
+
}
|
|
102
|
+
_deepTranslate(input, objectStack, options) {
|
|
103
|
+
if (input == null)
|
|
104
|
+
return input;
|
|
105
|
+
if (options?.ignore && options.ignore(input, this))
|
|
106
|
+
return input;
|
|
107
|
+
if (typeof input === 'object' && objectStack.has(input))
|
|
108
|
+
return objectStack.get(input);
|
|
109
|
+
if (typeof input === 'string') {
|
|
110
|
+
let s = '';
|
|
111
|
+
for (let token of (0, fast_tokenizer_1.tokenize)(input, {
|
|
112
|
+
brackets: { '$t(': ')' },
|
|
113
|
+
quotes: true,
|
|
114
|
+
keepQuotes: true,
|
|
115
|
+
keepBrackets: true,
|
|
116
|
+
keepDelimiters: true,
|
|
117
|
+
})) {
|
|
118
|
+
if (token.startsWith('$t(') && token.endsWith(')')) {
|
|
119
|
+
token = token.substring(3, token.length - 1);
|
|
120
|
+
const a = (0, fast_tokenizer_1.splitString)(token, { delimiters: '?', quotes: true, brackets: { '{': '}' } });
|
|
121
|
+
const fallback = (0, string_utils_js_1.unescapeString)(token.substring((a[0] || '').length + 1));
|
|
122
|
+
token = a[0] || '';
|
|
123
|
+
const keys = [];
|
|
124
|
+
let opts = null;
|
|
125
|
+
for (const token2 of (0, fast_tokenizer_1.tokenize)(token, { delimiters: ',', quotes: true, brackets: { '{': '}' } })) {
|
|
126
|
+
if (token2.startsWith('{')) {
|
|
127
|
+
opts = JSON.parse(token2);
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
keys.push(token2);
|
|
131
|
+
}
|
|
132
|
+
const k = keys.length > 1 ? '$t(' + keys.join(',') + ')' : keys[0];
|
|
133
|
+
s += fallback
|
|
134
|
+
? this.t(k, fallback, { ...options, ...opts })
|
|
135
|
+
: this.t(k, { ...options, ...opts });
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
s += token;
|
|
139
|
+
}
|
|
140
|
+
return s;
|
|
141
|
+
}
|
|
142
|
+
if (Array.isArray(input)) {
|
|
143
|
+
const out = Array(input.length);
|
|
144
|
+
objectStack.set(input, out);
|
|
145
|
+
for (let i = 0, l = input.length; i < l; i++) {
|
|
146
|
+
out[i] = this._deepTranslate(input[i], objectStack, options);
|
|
147
|
+
}
|
|
148
|
+
objectStack.delete(input);
|
|
149
|
+
return out;
|
|
150
|
+
}
|
|
151
|
+
if (typeof input === 'object') {
|
|
152
|
+
if (Buffer.isBuffer(input))
|
|
153
|
+
return input;
|
|
154
|
+
if (Buffer.isBuffer(input) || input instanceof Symbol ||
|
|
155
|
+
input instanceof RegExp || input instanceof Map || input instanceof Set ||
|
|
156
|
+
input instanceof WeakMap || input instanceof WeakSet)
|
|
157
|
+
return input;
|
|
158
|
+
const out = {};
|
|
159
|
+
objectStack.set(input, out);
|
|
160
|
+
const keys = Object.keys(input);
|
|
161
|
+
for (let i = 0, l = keys.length; i < l; i++) {
|
|
162
|
+
const k = keys[i];
|
|
163
|
+
out[k] = this._deepTranslate(input[k], objectStack, options);
|
|
164
|
+
}
|
|
165
|
+
objectStack.delete(input);
|
|
166
|
+
return out;
|
|
167
|
+
}
|
|
168
|
+
return input;
|
|
169
|
+
}
|
|
170
|
+
static get defaultInstance() {
|
|
171
|
+
return defaultInstance;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
exports.I18n = I18n;
|
|
175
|
+
const defaultInstance = I18n.createInstance();
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.i18n = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const i18n_js_1 = require("./i18n.js");
|
|
6
|
+
tslib_1.__exportStar(require("./i18n.js"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./translate.js"), exports);
|
|
8
|
+
const i18n = i18n_js_1.I18n.createInstance();
|
|
9
|
+
exports.i18n = i18n;
|
|
10
|
+
i18n.init().catch(() => void 0);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.unescapeString = exports.escapeString = void 0;
|
|
4
|
+
const unescapeRegEx = /\\(.)/g;
|
|
5
|
+
const escapeRegEx = /(\\)/g;
|
|
6
|
+
function escapeString(s) {
|
|
7
|
+
return s.replace(escapeRegEx, '\\\\');
|
|
8
|
+
}
|
|
9
|
+
exports.escapeString = escapeString;
|
|
10
|
+
function unescapeString(s) {
|
|
11
|
+
return s.replace(unescapeRegEx, '$1');
|
|
12
|
+
}
|
|
13
|
+
exports.unescapeString = unescapeString;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.translate = void 0;
|
|
4
|
+
const string_utils_js_1 = require("./string-utils.js");
|
|
5
|
+
const bracketRegEx = /(\))/g;
|
|
6
|
+
function translate(key, arg0, arg1) {
|
|
7
|
+
const options = arg0 && typeof arg0 === 'object' ? arg0 : undefined;
|
|
8
|
+
const fallback = typeof arg0 === 'string' ? arg0 : arg1;
|
|
9
|
+
return '$t(' +
|
|
10
|
+
key +
|
|
11
|
+
(options ? ',' + JSON.stringify(options) : '') +
|
|
12
|
+
(fallback ? '?' + (0, string_utils_js_1.escapeString)(fallback).replace(bracketRegEx, '\\$1') : '') +
|
|
13
|
+
')';
|
|
14
|
+
}
|
|
15
|
+
exports.translate = translate;
|
package/cjs/index.js
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uid = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./
|
|
5
|
-
tslib_1.__exportStar(require("./
|
|
5
|
+
tslib_1.__exportStar(require("./exception/index.js"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./i18n/index.js"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./filter/index.js"), exports); // todo. review
|
|
8
|
+
tslib_1.__exportStar(require("./http/multipart/index.js"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./schema/index.js"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./url/index.js"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./http/index.js"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./helpers/index.js"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./utils/index.js"), exports);
|
|
14
|
+
var uid_1 = require("uid");
|
|
15
|
+
Object.defineProperty(exports, "uid", { enumerable: true, get: function () { return uid_1.uid; } });
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.collectionMethods = exports.singletonMethods = exports.MAPPED_TYPE_METADATA = exports.IGNORE_RESOLVER_METHOD = exports.RESOLVER_METADATA = exports.RESOURCE_METADATA = exports.COMPLEXTYPE_FIELDS = exports.DATATYPE_METADATA = void 0;
|
|
4
|
+
exports.DATATYPE_METADATA = 'opra:data_type.metadata';
|
|
5
|
+
exports.COMPLEXTYPE_FIELDS = 'opra:complex_type.fields';
|
|
6
|
+
exports.RESOURCE_METADATA = 'opra:resource.metadata';
|
|
7
|
+
exports.RESOLVER_METADATA = 'opra:resolver.metadata';
|
|
8
|
+
exports.IGNORE_RESOLVER_METHOD = 'opra:ignore_resolver-method';
|
|
9
|
+
exports.MAPPED_TYPE_METADATA = 'opra:mapped_type.metadata';
|
|
10
|
+
exports.singletonMethods = ['create', 'delete', 'get', 'update'];
|
|
11
|
+
exports.collectionMethods = [...exports.singletonMethods, 'count', 'deleteMany', 'updateMany', 'search'];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OprCollectionResource = void 0;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const lodash_1 = require("lodash");
|
|
6
|
+
const constants_js_1 = require("../constants.js");
|
|
7
|
+
const NESTJS_INJECTABLE_WATERMARK = '__injectable__';
|
|
8
|
+
const NAME_PATTERN = /^(.*)Resource$/;
|
|
9
|
+
function OprCollectionResource(entityFunc, options) {
|
|
10
|
+
return function (target) {
|
|
11
|
+
const name = options?.name || target.name.match(NAME_PATTERN)?.[1] || target.name;
|
|
12
|
+
const meta = {
|
|
13
|
+
kind: 'CollectionResource',
|
|
14
|
+
type: entityFunc,
|
|
15
|
+
name
|
|
16
|
+
};
|
|
17
|
+
Object.assign(meta, (0, lodash_1.omit)(options, Object.keys(meta)));
|
|
18
|
+
Reflect.defineMetadata(constants_js_1.RESOURCE_METADATA, meta, target);
|
|
19
|
+
/* Define Injectable metadata for NestJS support*/
|
|
20
|
+
Reflect.defineMetadata(NESTJS_INJECTABLE_WATERMARK, true, target);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
exports.OprCollectionResource = OprCollectionResource;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OprComplexType = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const constants_js_1 = require("../constants.js");
|
|
6
|
+
const NAME_PATTERN = /^(.*)Type$/;
|
|
7
|
+
function OprComplexType(options) {
|
|
8
|
+
return (target) => {
|
|
9
|
+
const name = options?.name || target.name.match(NAME_PATTERN)?.[1] || target.name;
|
|
10
|
+
const meta = {
|
|
11
|
+
kind: 'ComplexType',
|
|
12
|
+
name,
|
|
13
|
+
};
|
|
14
|
+
Object.assign(meta, (0, lodash_1.omit)(options, Object.keys(meta)));
|
|
15
|
+
const base = Object.getPrototypeOf(target);
|
|
16
|
+
const baseMeta = Reflect.getMetadata(constants_js_1.DATATYPE_METADATA, base);
|
|
17
|
+
if (baseMeta) {
|
|
18
|
+
if (baseMeta.additionalFields && meta.additionalFields == null)
|
|
19
|
+
meta.additionalFields = true;
|
|
20
|
+
meta.extends = [{
|
|
21
|
+
type: base
|
|
22
|
+
}];
|
|
23
|
+
}
|
|
24
|
+
Reflect.defineMetadata(constants_js_1.DATATYPE_METADATA, meta, target);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
exports.OprComplexType = OprComplexType;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OprField = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const constants_js_1 = require("../constants.js");
|
|
6
|
+
function OprField(args) {
|
|
7
|
+
return (target, propertyKey) => {
|
|
8
|
+
if (typeof propertyKey !== 'string')
|
|
9
|
+
throw new TypeError(`Symbol properties can't be used as field`);
|
|
10
|
+
const designType = Reflect.getMetadata('design:type', target, propertyKey);
|
|
11
|
+
const metadata = {
|
|
12
|
+
type: args?.type
|
|
13
|
+
};
|
|
14
|
+
Object.assign(metadata, (0, lodash_1.omit)(args, Object.keys(metadata)));
|
|
15
|
+
if (designType === Array) {
|
|
16
|
+
metadata.isArray = true;
|
|
17
|
+
metadata.type = metadata.type || 'any';
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
delete metadata.isArray;
|
|
21
|
+
metadata.type = metadata.type || designType;
|
|
22
|
+
}
|
|
23
|
+
const fields = Reflect.getOwnMetadata(constants_js_1.COMPLEXTYPE_FIELDS, target.constructor) || {};
|
|
24
|
+
fields[propertyKey] = metadata;
|
|
25
|
+
Reflect.defineMetadata(constants_js_1.COMPLEXTYPE_FIELDS, fields, target.constructor);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
exports.OprField = OprField;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OprSearchResolver = exports.OprGetResolver = exports.OprUpdateManyResolver = exports.OprUpdateResolver = exports.OprDeleteManyResolver = exports.OprDeleteResolver = exports.OprCreateResolver = void 0;
|
|
4
|
+
const constants_js_1 = require("../constants.js");
|
|
5
|
+
function OprCreateResolver(options) {
|
|
6
|
+
return (target, propertyKey) => {
|
|
7
|
+
if (propertyKey !== 'create')
|
|
8
|
+
throw new TypeError('This decorator can only be applied for the "create" property');
|
|
9
|
+
const metadata = {
|
|
10
|
+
...options
|
|
11
|
+
};
|
|
12
|
+
Reflect.defineMetadata(constants_js_1.RESOLVER_METADATA, metadata, target, propertyKey);
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
exports.OprCreateResolver = OprCreateResolver;
|
|
16
|
+
function OprDeleteResolver(options) {
|
|
17
|
+
return (target, propertyKey) => {
|
|
18
|
+
if (propertyKey !== 'delete')
|
|
19
|
+
throw new TypeError('This decorator can only be applied for the "delete" property');
|
|
20
|
+
const metadata = {
|
|
21
|
+
...options
|
|
22
|
+
};
|
|
23
|
+
Reflect.defineMetadata(constants_js_1.RESOLVER_METADATA, metadata, target, propertyKey);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
exports.OprDeleteResolver = OprDeleteResolver;
|
|
27
|
+
function OprDeleteManyResolver(options) {
|
|
28
|
+
return (target, propertyKey) => {
|
|
29
|
+
if (propertyKey !== 'deleteMany')
|
|
30
|
+
throw new TypeError('This decorator can only be applied for the "deleteMany" property');
|
|
31
|
+
const metadata = {
|
|
32
|
+
...options
|
|
33
|
+
};
|
|
34
|
+
Reflect.defineMetadata(constants_js_1.RESOLVER_METADATA, metadata, target, propertyKey);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
exports.OprDeleteManyResolver = OprDeleteManyResolver;
|
|
38
|
+
function OprUpdateResolver(options) {
|
|
39
|
+
return (target, propertyKey) => {
|
|
40
|
+
if (propertyKey !== 'update')
|
|
41
|
+
throw new TypeError('This decorator can only be applied for the "update" property');
|
|
42
|
+
const metadata = {
|
|
43
|
+
...options
|
|
44
|
+
};
|
|
45
|
+
Reflect.defineMetadata(constants_js_1.RESOLVER_METADATA, metadata, target, propertyKey);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
exports.OprUpdateResolver = OprUpdateResolver;
|
|
49
|
+
function OprUpdateManyResolver(options) {
|
|
50
|
+
return (target, propertyKey) => {
|
|
51
|
+
if (propertyKey !== 'updateMany')
|
|
52
|
+
throw new TypeError('This decorator can only be applied for the "updateMany" property');
|
|
53
|
+
const metadata = {
|
|
54
|
+
...options
|
|
55
|
+
};
|
|
56
|
+
Reflect.defineMetadata(constants_js_1.RESOLVER_METADATA, metadata, target, propertyKey);
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
exports.OprUpdateManyResolver = OprUpdateManyResolver;
|
|
60
|
+
function OprGetResolver(options) {
|
|
61
|
+
return (target, propertyKey) => {
|
|
62
|
+
if (propertyKey !== 'get')
|
|
63
|
+
throw new TypeError('This decorator can only be applied for the "get" property');
|
|
64
|
+
const metadata = {
|
|
65
|
+
...options
|
|
66
|
+
};
|
|
67
|
+
Reflect.defineMetadata(constants_js_1.RESOLVER_METADATA, metadata, target, propertyKey);
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
exports.OprGetResolver = OprGetResolver;
|
|
71
|
+
function OprSearchResolver(options) {
|
|
72
|
+
return (target, propertyKey) => {
|
|
73
|
+
if (propertyKey !== 'search')
|
|
74
|
+
throw new TypeError('This decorator can only be applied for the "search" property');
|
|
75
|
+
const metadata = {
|
|
76
|
+
...options
|
|
77
|
+
};
|
|
78
|
+
Reflect.defineMetadata(constants_js_1.RESOLVER_METADATA, metadata, target, propertyKey);
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
exports.OprSearchResolver = OprSearchResolver;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OprSimpleType = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const constants_js_1 = require("../constants.js");
|
|
6
|
+
const NAME_PATTERN = /^(.*)Type$/;
|
|
7
|
+
function OprSimpleType(options) {
|
|
8
|
+
return (target) => {
|
|
9
|
+
const name = options?.name || target.name.match(NAME_PATTERN)?.[1] || target.name;
|
|
10
|
+
const meta = {
|
|
11
|
+
kind: 'SimpleType',
|
|
12
|
+
name
|
|
13
|
+
};
|
|
14
|
+
Object.assign(meta, (0, lodash_1.omit)(options, Object.keys(meta)));
|
|
15
|
+
Reflect.defineMetadata(constants_js_1.DATATYPE_METADATA, meta, target);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.OprSimpleType = OprSimpleType;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OprSingletonResource = void 0;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const lodash_1 = require("lodash");
|
|
6
|
+
const constants_js_1 = require("../constants.js");
|
|
7
|
+
const NESTJS_INJECTABLE_WATERMARK = '__injectable__';
|
|
8
|
+
const NAME_PATTERN = /^(.*)Resource$/;
|
|
9
|
+
function OprSingletonResource(type, options) {
|
|
10
|
+
return function (target) {
|
|
11
|
+
const name = options?.name || target.name.match(NAME_PATTERN)?.[1] || target.name;
|
|
12
|
+
const meta = {
|
|
13
|
+
kind: 'SingletonResource',
|
|
14
|
+
type,
|
|
15
|
+
name
|
|
16
|
+
};
|
|
17
|
+
Object.assign(meta, (0, lodash_1.omit)(options, Object.keys(meta)));
|
|
18
|
+
Reflect.defineMetadata(constants_js_1.RESOURCE_METADATA, meta, target);
|
|
19
|
+
/* Define Injectable metadata for NestJS support*/
|
|
20
|
+
Reflect.defineMetadata(NESTJS_INJECTABLE_WATERMARK, true, target);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
exports.OprSingletonResource = OprSingletonResource;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Base64BinaryType = void 0;
|
|
4
|
+
const BufferConstructor = Object.getPrototypeOf(Buffer.from('')).constructor;
|
|
5
|
+
exports.Base64BinaryType = {
|
|
6
|
+
kind: 'SimpleType',
|
|
7
|
+
description: 'A stream of bytes, base64 encoded',
|
|
8
|
+
ctor: BufferConstructor,
|
|
9
|
+
parse(v) {
|
|
10
|
+
return Buffer.from(v);
|
|
11
|
+
},
|
|
12
|
+
serialize(v) {
|
|
13
|
+
return Buffer.isBuffer(v) ? v.toString('base64') : undefined;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BigIntType = void 0;
|
|
4
|
+
const BigIntConstructor = Object.getPrototypeOf(BigInt(0)).constructor;
|
|
5
|
+
exports.BigIntType = {
|
|
6
|
+
kind: 'SimpleType',
|
|
7
|
+
description: 'BigInt number',
|
|
8
|
+
ctor: BigIntConstructor,
|
|
9
|
+
parse(v) {
|
|
10
|
+
return BigInt(v);
|
|
11
|
+
},
|
|
12
|
+
serialize(v) {
|
|
13
|
+
return String(v);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BooleanType = void 0;
|
|
4
|
+
const putil_varhelpers_1 = require("putil-varhelpers");
|
|
5
|
+
exports.BooleanType = {
|
|
6
|
+
kind: 'SimpleType',
|
|
7
|
+
description: 'Simple true/false value',
|
|
8
|
+
ctor: Boolean,
|
|
9
|
+
parse(v) {
|
|
10
|
+
return (0, putil_varhelpers_1.toBoolean)(v);
|
|
11
|
+
},
|
|
12
|
+
serialize(v) {
|
|
13
|
+
return (0, putil_varhelpers_1.toBoolean)(v);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DateStringType = void 0;
|
|
4
|
+
const putil_varhelpers_1 = require("putil-varhelpers");
|
|
5
|
+
exports.DateStringType = {
|
|
6
|
+
kind: 'SimpleType',
|
|
7
|
+
description: 'A date, date-time or partial date in string format',
|
|
8
|
+
ctor: String,
|
|
9
|
+
parse(v) {
|
|
10
|
+
return (0, putil_varhelpers_1.toString)(v);
|
|
11
|
+
},
|
|
12
|
+
serialize(v) {
|
|
13
|
+
return (0, putil_varhelpers_1.toString)(v);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DateType = void 0;
|
|
4
|
+
const putil_varhelpers_1 = require("putil-varhelpers");
|
|
5
|
+
exports.DateType = {
|
|
6
|
+
kind: 'SimpleType',
|
|
7
|
+
description: 'A date, date-time or partial date',
|
|
8
|
+
ctor: String,
|
|
9
|
+
parse(v) {
|
|
10
|
+
return (0, putil_varhelpers_1.toDate)(v);
|
|
11
|
+
},
|
|
12
|
+
serialize(v) {
|
|
13
|
+
return String(v);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GuidType = void 0;
|
|
4
|
+
const putil_varhelpers_1 = require("putil-varhelpers");
|
|
5
|
+
exports.GuidType = {
|
|
6
|
+
kind: 'SimpleType',
|
|
7
|
+
description: 'A guid value',
|
|
8
|
+
ctor: String,
|
|
9
|
+
parse(v) {
|
|
10
|
+
return (0, putil_varhelpers_1.toString)(v);
|
|
11
|
+
},
|
|
12
|
+
serialize(v) {
|
|
13
|
+
return (0, putil_varhelpers_1.toString)(v);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IntegerType = void 0;
|
|
4
|
+
const putil_varhelpers_1 = require("putil-varhelpers");
|
|
5
|
+
exports.IntegerType = {
|
|
6
|
+
kind: 'SimpleType',
|
|
7
|
+
description: 'An integer number',
|
|
8
|
+
ctor: Number,
|
|
9
|
+
parse(v) {
|
|
10
|
+
return (0, putil_varhelpers_1.toInt)(v);
|
|
11
|
+
},
|
|
12
|
+
serialize(v) {
|
|
13
|
+
return (0, putil_varhelpers_1.toInt)(v);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NumberType = void 0;
|
|
4
|
+
const putil_varhelpers_1 = require("putil-varhelpers");
|
|
5
|
+
exports.NumberType = {
|
|
6
|
+
kind: 'SimpleType',
|
|
7
|
+
description: 'Both Integer as well as Floating-Point numbers',
|
|
8
|
+
ctor: Number,
|
|
9
|
+
parse(v) {
|
|
10
|
+
return (0, putil_varhelpers_1.toNumber)(v);
|
|
11
|
+
},
|
|
12
|
+
serialize(v) {
|
|
13
|
+
return (0, putil_varhelpers_1.toNumber)(v);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ObjectType = void 0;
|
|
4
|
+
exports.ObjectType = {
|
|
5
|
+
kind: 'ComplexType',
|
|
6
|
+
description: 'A non modelled object',
|
|
7
|
+
ctor: Object,
|
|
8
|
+
additionalFields: true,
|
|
9
|
+
parse(v) {
|
|
10
|
+
return v;
|
|
11
|
+
},
|
|
12
|
+
serialize(v) {
|
|
13
|
+
return v;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StringType = void 0;
|
|
4
|
+
const putil_varhelpers_1 = require("putil-varhelpers");
|
|
5
|
+
exports.StringType = {
|
|
6
|
+
kind: 'SimpleType',
|
|
7
|
+
description: 'A sequence of characters',
|
|
8
|
+
ctor: String,
|
|
9
|
+
parse(v) {
|
|
10
|
+
return (0, putil_varhelpers_1.toString)(v);
|
|
11
|
+
},
|
|
12
|
+
serialize(v) {
|
|
13
|
+
return (0, putil_varhelpers_1.toString)(v);
|
|
14
|
+
}
|
|
15
|
+
};
|