@opra/common 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/constants.js +1 -0
- package/cjs/exception/enums/issue-severity.enum.js +23 -0
- package/cjs/{types.js → exception/error-issue.js} +0 -0
- package/cjs/exception/http-errors/bad-request.error.js +22 -0
- package/cjs/exception/http-errors/failed-dependency.error.js +21 -0
- package/cjs/exception/http-errors/forbidden.error.js +23 -0
- package/cjs/exception/http-errors/internal-server.error.js +21 -0
- package/cjs/exception/http-errors/method-not-allowed.error.js +22 -0
- package/cjs/exception/http-errors/not-acceptable.error.js +22 -0
- package/cjs/exception/http-errors/not-found.error.js +25 -0
- package/cjs/exception/http-errors/unauthorized.error.js +22 -0
- package/cjs/exception/http-errors/unprocessable-entity.error.js +21 -0
- package/cjs/exception/index.js +18 -0
- package/cjs/exception/opra-exception.js +56 -0
- package/cjs/exception/resource-errors/resource-conflict.error.js +20 -0
- package/cjs/exception/resource-errors/resource-not-found.error.js +20 -0
- package/cjs/exception/wrap-exception.js +42 -0
- package/cjs/filter/antlr/OpraFilterLexer.js +386 -0
- package/cjs/filter/antlr/OpraFilterParser.js +2070 -0
- package/cjs/filter/antlr/OpraFilterVisitor.js +3 -0
- package/cjs/filter/ast/abstract/ast.js +10 -0
- package/cjs/filter/ast/abstract/expression.js +7 -0
- package/cjs/filter/ast/abstract/literal.js +14 -0
- package/cjs/filter/ast/abstract/term.js +7 -0
- package/cjs/filter/ast/expressions/arithmetic-expression.js +29 -0
- package/cjs/filter/ast/expressions/array-expression.js +15 -0
- package/cjs/filter/ast/expressions/comparison-expression.js +18 -0
- package/cjs/filter/ast/expressions/logical-expression.js +18 -0
- package/cjs/filter/ast/expressions/parentheses-expression.js +15 -0
- package/cjs/filter/ast/index.js +19 -0
- package/cjs/filter/ast/terms/boolean-literal.js +10 -0
- package/cjs/filter/ast/terms/date-literal.js +28 -0
- package/cjs/filter/ast/terms/external-constant.js +13 -0
- package/cjs/filter/ast/terms/null-literal.js +11 -0
- package/cjs/filter/ast/terms/number-literal.js +40 -0
- package/cjs/filter/ast/terms/qualified-identifier.js +10 -0
- package/cjs/filter/ast/terms/string-literal.js +14 -0
- package/cjs/filter/ast/terms/time-literal.js +33 -0
- package/cjs/filter/build.js +129 -0
- package/cjs/filter/error-listener.js +14 -0
- package/cjs/filter/errors.js +21 -0
- package/cjs/filter/filter-tree-visitor.js +113 -0
- package/cjs/filter/index.js +8 -0
- package/cjs/filter/parse.js +37 -0
- package/cjs/filter/utils.js +26 -0
- package/cjs/helpers/index.js +4 -0
- package/cjs/{classes → helpers}/responsive-map.js +1 -1
- package/cjs/{enums → http/enums}/http-headers.enum.js +9 -0
- package/cjs/{enums → http/enums}/http-status.enum.js +0 -0
- package/cjs/http/http-request.js +118 -0
- package/cjs/http/index.js +9 -0
- package/cjs/http/interfaces/client-http-headers.interface.js +2 -0
- package/cjs/http/interfaces/server-http-headers.interface.js +2 -0
- package/cjs/http/multipart/batch-multipart.js +155 -0
- package/cjs/http/multipart/http-request-content.js +16 -0
- package/cjs/http/multipart/http-response-content.js +14 -0
- package/cjs/http/multipart/index.js +4 -0
- package/cjs/http/utils/normalize-headers.js +28 -0
- package/cjs/i18n/i18n.js +175 -0
- package/cjs/i18n/index.js +10 -0
- package/cjs/i18n/string-utils.js +13 -0
- package/cjs/i18n/translate.js +15 -0
- package/cjs/index.js +12 -5
- package/cjs/schema/constants.js +11 -0
- package/cjs/schema/decorators/opr-collection-resource.decorator.js +23 -0
- package/cjs/schema/decorators/opr-complex-type.decorator.js +27 -0
- package/cjs/schema/decorators/opr-field.decorator.js +28 -0
- package/cjs/schema/decorators/opr-resolver.decorator.js +81 -0
- package/cjs/schema/decorators/opr-simple-type.decorator.js +18 -0
- package/cjs/schema/decorators/opr-singleton-resource.decorator.js +23 -0
- package/cjs/schema/implementation/data-type/builtin/any.type.js +9 -0
- package/cjs/schema/implementation/data-type/builtin/base64-binary.type.js +15 -0
- package/cjs/schema/implementation/data-type/builtin/bigint.type.js +15 -0
- package/cjs/schema/implementation/data-type/builtin/boolean.type.js +15 -0
- package/cjs/schema/implementation/data-type/builtin/date-string.type.js +15 -0
- package/cjs/schema/implementation/data-type/builtin/date.type.js +15 -0
- package/cjs/schema/implementation/data-type/builtin/guid.type.js +15 -0
- package/cjs/schema/implementation/data-type/builtin/integer.type.js +15 -0
- package/cjs/schema/implementation/data-type/builtin/number.type.js +15 -0
- package/cjs/schema/implementation/data-type/builtin/object.type.js +15 -0
- package/cjs/schema/implementation/data-type/builtin/string.type.js +15 -0
- package/cjs/schema/implementation/data-type/builtin-data-types.js +37 -0
- package/cjs/schema/implementation/data-type/complex-type.js +111 -0
- package/cjs/schema/implementation/data-type/data-type.js +36 -0
- package/cjs/schema/implementation/data-type/simple-type.js +21 -0
- package/cjs/schema/implementation/data-type/union-type.js +25 -0
- package/cjs/schema/implementation/document-builder.js +140 -0
- package/cjs/schema/implementation/opra-document.js +181 -0
- package/cjs/schema/implementation/query/collection-count-query.js +19 -0
- package/cjs/schema/implementation/query/collection-create-query.js +28 -0
- package/cjs/schema/implementation/query/collection-delete-many-query.js +19 -0
- package/cjs/schema/implementation/query/collection-delete-query.js +27 -0
- package/cjs/schema/implementation/query/collection-get-query.js +38 -0
- package/cjs/schema/implementation/query/collection-search-query.js +55 -0
- package/cjs/schema/implementation/query/collection-update-many-query.js +21 -0
- package/cjs/schema/implementation/query/collection-update-query.js +39 -0
- package/cjs/schema/implementation/query/field-get-query.js +45 -0
- package/cjs/schema/implementation/query/index.js +22 -0
- package/cjs/schema/implementation/query/singleton-get-query.js +27 -0
- package/cjs/schema/implementation/resource/collection-resource-info.js +58 -0
- package/cjs/schema/implementation/resource/container-resource-info.js +30 -0
- package/cjs/schema/implementation/resource/resource-info.js +39 -0
- package/cjs/schema/implementation/resource/singleton-resource-info.js +37 -0
- package/cjs/schema/implementation/schema-builder/extract-resource-metadata.util.js +84 -0
- package/cjs/schema/implementation/schema-builder/extract-type-metadata.util.js +94 -0
- package/cjs/schema/index.js +28 -0
- package/cjs/schema/interfaces/child-field-query.interface.js +2 -0
- package/cjs/schema/interfaces/data-type.metadata.js +2 -0
- package/cjs/schema/interfaces/resource-container.interface.js +2 -0
- package/cjs/schema/interfaces/resource.metadata.js +2 -0
- package/cjs/schema/opra-schema.definition.js +49 -0
- package/cjs/schema/type-helpers/extend-type.helper.js +65 -0
- package/cjs/schema/type-helpers/mixin-type.helper.js +46 -0
- package/cjs/schema/type-helpers/mixin.utils.js +32 -0
- package/cjs/schema/types.js +2 -0
- package/cjs/schema/utils/class.utils.js +8 -0
- package/cjs/schema/utils/clone-object.util.js +19 -0
- package/cjs/schema/utils/inspect.util.js +7 -0
- package/cjs/schema/utils/normalize-field-array.util.js +44 -0
- package/cjs/schema/utils/path-to-tree.util.js +26 -0
- package/cjs/schema/utils/string-compare.util.js +11 -0
- package/cjs/url/formats/boolean-format.js +25 -0
- package/cjs/url/formats/date-format.js +48 -0
- package/cjs/url/formats/filter-format.js +18 -0
- package/cjs/url/formats/format.js +6 -0
- package/cjs/url/formats/integer-format.js +20 -0
- package/cjs/url/formats/number-format.js +28 -0
- package/cjs/url/formats/string-format.js +28 -0
- package/cjs/url/index.js +8 -0
- package/cjs/url/opra-url-path-component.js +33 -0
- package/cjs/url/opra-url-path.js +128 -0
- package/cjs/url/opra-url-search-params.js +247 -0
- package/cjs/url/opra-url.js +299 -0
- package/cjs/url/utils/path-utils.js +86 -0
- package/cjs/utils/index.js +6 -0
- package/cjs/utils/is-url.js +8 -0
- package/cjs/utils/path-to-tree.js +28 -0
- package/cjs/utils/type-guards.js +46 -0
- package/esm/constants.d.ts +0 -0
- package/esm/constants.js +1 -0
- package/esm/exception/enums/issue-severity.enum.d.ts +13 -0
- package/esm/exception/enums/issue-severity.enum.js +20 -0
- package/esm/exception/error-issue.d.ts +9 -0
- package/esm/{types.js → exception/error-issue.js} +0 -0
- package/esm/exception/http-errors/bad-request.error.d.ts +10 -0
- package/esm/exception/http-errors/bad-request.error.js +18 -0
- package/esm/exception/http-errors/failed-dependency.error.d.ts +9 -0
- package/esm/exception/http-errors/failed-dependency.error.js +17 -0
- package/esm/exception/http-errors/forbidden.error.d.ts +11 -0
- package/esm/exception/http-errors/forbidden.error.js +19 -0
- package/esm/exception/http-errors/internal-server.error.d.ts +9 -0
- package/esm/exception/http-errors/internal-server.error.js +17 -0
- package/esm/exception/http-errors/method-not-allowed.error.d.ts +10 -0
- package/esm/exception/http-errors/method-not-allowed.error.js +18 -0
- package/esm/exception/http-errors/not-acceptable.error.d.ts +10 -0
- package/esm/exception/http-errors/not-acceptable.error.js +18 -0
- package/esm/exception/http-errors/not-found.error.d.ts +13 -0
- package/esm/exception/http-errors/not-found.error.js +21 -0
- package/esm/exception/http-errors/unauthorized.error.d.ts +10 -0
- package/esm/exception/http-errors/unauthorized.error.js +18 -0
- package/esm/exception/http-errors/unprocessable-entity.error.d.ts +9 -0
- package/esm/exception/http-errors/unprocessable-entity.error.js +17 -0
- package/esm/exception/index.d.ts +15 -0
- package/esm/exception/index.js +15 -0
- package/esm/exception/opra-exception.d.ts +15 -0
- package/esm/exception/opra-exception.js +52 -0
- package/esm/exception/resource-errors/resource-conflict.error.d.ts +5 -0
- package/esm/exception/resource-errors/resource-conflict.error.js +16 -0
- package/esm/exception/resource-errors/resource-not-found.error.d.ts +4 -0
- package/esm/exception/resource-errors/resource-not-found.error.js +16 -0
- package/esm/exception/wrap-exception.d.ts +2 -0
- package/esm/exception/wrap-exception.js +38 -0
- package/esm/filter/antlr/OpraFilterLexer.d.ts +78 -0
- package/esm/filter/antlr/OpraFilterLexer.js +381 -0
- package/esm/filter/antlr/OpraFilterParser.d.ts +365 -0
- package/esm/filter/antlr/OpraFilterParser.js +2022 -0
- package/esm/filter/antlr/OpraFilterVisitor.d.ts +290 -0
- package/esm/filter/antlr/OpraFilterVisitor.js +2 -0
- package/esm/filter/ast/abstract/ast.d.ts +5 -0
- package/esm/filter/ast/abstract/ast.js +6 -0
- package/esm/filter/ast/abstract/expression.d.ts +3 -0
- package/esm/filter/ast/abstract/expression.js +3 -0
- package/esm/filter/ast/abstract/literal.d.ts +6 -0
- package/esm/filter/ast/abstract/literal.js +10 -0
- package/esm/filter/ast/abstract/term.d.ts +3 -0
- package/esm/filter/ast/abstract/term.js +3 -0
- package/esm/filter/ast/expressions/arithmetic-expression.d.ts +13 -0
- package/esm/filter/ast/expressions/arithmetic-expression.js +24 -0
- package/esm/filter/ast/expressions/array-expression.d.ts +7 -0
- package/esm/filter/ast/expressions/array-expression.js +11 -0
- package/esm/filter/ast/expressions/comparison-expression.d.ts +10 -0
- package/esm/filter/ast/expressions/comparison-expression.js +14 -0
- package/esm/filter/ast/expressions/logical-expression.d.ts +8 -0
- package/esm/filter/ast/expressions/logical-expression.js +14 -0
- package/esm/filter/ast/expressions/parentheses-expression.d.ts +6 -0
- package/esm/filter/ast/expressions/parentheses-expression.js +11 -0
- package/esm/filter/ast/index.d.ts +16 -0
- package/esm/filter/ast/index.js +16 -0
- package/esm/filter/ast/terms/boolean-literal.d.ts +5 -0
- package/esm/filter/ast/terms/boolean-literal.js +6 -0
- package/esm/filter/ast/terms/date-literal.d.ts +6 -0
- package/esm/filter/ast/terms/date-literal.js +24 -0
- package/esm/filter/ast/terms/external-constant.d.ts +5 -0
- package/esm/filter/ast/terms/external-constant.js +9 -0
- package/esm/filter/ast/terms/null-literal.d.ts +5 -0
- package/esm/filter/ast/terms/null-literal.js +7 -0
- package/esm/filter/ast/terms/number-literal.d.ts +6 -0
- package/esm/filter/ast/terms/number-literal.js +36 -0
- package/esm/filter/ast/terms/qualified-identifier.d.ts +4 -0
- package/esm/filter/ast/terms/qualified-identifier.js +6 -0
- package/esm/filter/ast/terms/string-literal.d.ts +5 -0
- package/esm/filter/ast/terms/string-literal.js +10 -0
- package/esm/filter/ast/terms/time-literal.d.ts +6 -0
- package/esm/filter/ast/terms/time-literal.js +29 -0
- package/esm/filter/build.d.ts +31 -0
- package/esm/filter/build.js +105 -0
- package/esm/filter/error-listener.d.ts +8 -0
- package/esm/filter/error-listener.js +10 -0
- package/esm/filter/errors.d.ts +20 -0
- package/esm/filter/errors.js +15 -0
- package/esm/filter/filter-tree-visitor.d.ts +30 -0
- package/esm/filter/filter-tree-visitor.js +109 -0
- package/esm/filter/index.d.ts +5 -0
- package/esm/filter/index.js +5 -0
- package/esm/filter/parse.d.ts +2 -0
- package/esm/filter/parse.js +33 -0
- package/esm/filter/utils.d.ts +2 -0
- package/esm/filter/utils.js +21 -0
- package/esm/helpers/index.d.ts +1 -0
- package/esm/helpers/index.js +1 -0
- package/esm/{classes → helpers}/responsive-map.d.ts +0 -0
- package/esm/{classes → helpers}/responsive-map.js +1 -1
- package/esm/{enums → http/enums}/http-headers.enum.d.ts +9 -0
- package/esm/{enums → http/enums}/http-headers.enum.js +9 -0
- package/esm/{enums → http/enums}/http-status.enum.d.ts +0 -0
- package/esm/{enums → http/enums}/http-status.enum.js +0 -0
- package/esm/http/http-request.d.ts +34 -0
- package/esm/http/http-request.js +114 -0
- package/esm/http/index.d.ts +6 -0
- package/esm/http/index.js +6 -0
- package/esm/http/interfaces/client-http-headers.interface.d.ts +65 -0
- package/esm/http/interfaces/client-http-headers.interface.js +1 -0
- package/esm/http/interfaces/server-http-headers.interface.d.ts +1 -0
- package/esm/http/interfaces/server-http-headers.interface.js +1 -0
- package/esm/http/multipart/batch-multipart.d.ts +30 -0
- package/esm/http/multipart/batch-multipart.js +150 -0
- package/esm/http/multipart/http-request-content.d.ts +8 -0
- package/esm/http/multipart/http-request-content.js +12 -0
- package/esm/http/multipart/http-response-content.d.ts +7 -0
- package/esm/http/multipart/http-response-content.js +10 -0
- package/esm/http/multipart/index.d.ts +1 -0
- package/esm/http/multipart/index.js +1 -0
- package/esm/http/utils/normalize-headers.d.ts +1 -0
- package/esm/http/utils/normalize-headers.js +24 -0
- package/esm/i18n/i18n.d.ts +28 -0
- package/esm/i18n/i18n.js +170 -0
- package/esm/i18n/index.d.ts +5 -0
- package/esm/i18n/index.js +6 -0
- package/esm/i18n/string-utils.d.ts +2 -0
- package/esm/i18n/string-utils.js +8 -0
- package/esm/i18n/translate.d.ts +4 -0
- package/esm/i18n/translate.js +11 -0
- package/esm/index.d.ts +10 -5
- package/esm/index.js +10 -5
- package/esm/schema/constants.d.ts +8 -0
- package/esm/schema/constants.js +8 -0
- package/esm/schema/decorators/opr-collection-resource.decorator.d.ts +8 -0
- package/esm/schema/decorators/opr-collection-resource.decorator.js +19 -0
- package/esm/schema/decorators/opr-complex-type.decorator.d.ts +6 -0
- package/esm/schema/decorators/opr-complex-type.decorator.js +23 -0
- package/esm/schema/decorators/opr-field.decorator.d.ts +3 -0
- package/esm/schema/decorators/opr-field.decorator.js +24 -0
- package/esm/schema/decorators/opr-resolver.decorator.d.ts +8 -0
- package/esm/schema/decorators/opr-resolver.decorator.js +71 -0
- package/esm/schema/decorators/opr-simple-type.decorator.d.ts +6 -0
- package/esm/schema/decorators/opr-simple-type.decorator.js +14 -0
- package/esm/schema/decorators/opr-singleton-resource.decorator.d.ts +8 -0
- package/esm/schema/decorators/opr-singleton-resource.decorator.js +19 -0
- package/esm/schema/implementation/data-type/builtin/any.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/any.type.js +6 -0
- package/esm/schema/implementation/data-type/builtin/base64-binary.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/base64-binary.type.js +12 -0
- package/esm/schema/implementation/data-type/builtin/bigint.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/bigint.type.js +12 -0
- package/esm/schema/implementation/data-type/builtin/boolean.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/boolean.type.js +12 -0
- package/esm/schema/implementation/data-type/builtin/date-string.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/date-string.type.js +12 -0
- package/esm/schema/implementation/data-type/builtin/date.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/date.type.js +12 -0
- package/esm/schema/implementation/data-type/builtin/guid.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/guid.type.js +12 -0
- package/esm/schema/implementation/data-type/builtin/integer.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/integer.type.js +12 -0
- package/esm/schema/implementation/data-type/builtin/number.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/number.type.js +12 -0
- package/esm/schema/implementation/data-type/builtin/object.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/object.type.js +12 -0
- package/esm/schema/implementation/data-type/builtin/string.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/string.type.js +12 -0
- package/esm/schema/implementation/data-type/builtin-data-types.d.ts +4 -0
- package/esm/schema/implementation/data-type/builtin-data-types.js +34 -0
- package/esm/schema/implementation/data-type/complex-type.d.ts +29 -0
- package/esm/schema/implementation/data-type/complex-type.js +107 -0
- package/esm/schema/implementation/data-type/data-type.d.ts +16 -0
- package/esm/schema/implementation/data-type/data-type.js +32 -0
- package/esm/schema/implementation/data-type/simple-type.d.ts +12 -0
- package/esm/schema/implementation/data-type/simple-type.js +17 -0
- package/esm/schema/implementation/data-type/union-type.d.ts +16 -0
- package/esm/schema/implementation/data-type/union-type.js +21 -0
- package/esm/schema/implementation/document-builder.d.ts +16 -0
- package/esm/schema/implementation/document-builder.js +135 -0
- package/esm/schema/implementation/opra-document.d.ts +44 -0
- package/esm/schema/implementation/opra-document.js +177 -0
- package/esm/schema/implementation/query/collection-count-query.d.ts +14 -0
- package/esm/schema/implementation/query/collection-count-query.js +15 -0
- package/esm/schema/implementation/query/collection-create-query.d.ts +18 -0
- package/esm/schema/implementation/query/collection-create-query.js +24 -0
- package/esm/schema/implementation/query/collection-delete-many-query.d.ts +14 -0
- package/esm/schema/implementation/query/collection-delete-many-query.js +15 -0
- package/esm/schema/implementation/query/collection-delete-query.d.ts +10 -0
- package/esm/schema/implementation/query/collection-delete-query.js +23 -0
- package/esm/schema/implementation/query/collection-get-query.d.ts +21 -0
- package/esm/schema/implementation/query/collection-get-query.js +34 -0
- package/esm/schema/implementation/query/collection-search-query.d.ts +30 -0
- package/esm/schema/implementation/query/collection-search-query.js +51 -0
- package/esm/schema/implementation/query/collection-update-many-query.d.ts +15 -0
- package/esm/schema/implementation/query/collection-update-many-query.js +17 -0
- package/esm/schema/implementation/query/collection-update-query.d.ts +19 -0
- package/esm/schema/implementation/query/collection-update-query.js +35 -0
- package/esm/schema/implementation/query/field-get-query.d.ts +30 -0
- package/esm/schema/implementation/query/field-get-query.js +41 -0
- package/esm/schema/implementation/query/index.d.ts +27 -0
- package/esm/schema/implementation/query/index.js +17 -0
- package/esm/schema/implementation/query/singleton-get-query.d.ts +20 -0
- package/esm/schema/implementation/query/singleton-get-query.js +23 -0
- package/esm/schema/implementation/resource/collection-resource-info.d.ts +19 -0
- package/esm/schema/implementation/resource/collection-resource-info.js +54 -0
- package/esm/schema/implementation/resource/container-resource-info.d.ts +13 -0
- package/esm/schema/implementation/resource/container-resource-info.js +26 -0
- package/esm/schema/implementation/resource/resource-info.d.ts +17 -0
- package/esm/schema/implementation/resource/resource-info.js +35 -0
- package/esm/schema/implementation/resource/singleton-resource-info.d.ts +14 -0
- package/esm/schema/implementation/resource/singleton-resource-info.js +33 -0
- package/esm/schema/implementation/schema-builder/extract-resource-metadata.util.d.ts +3 -0
- package/esm/schema/implementation/schema-builder/extract-resource-metadata.util.js +80 -0
- package/esm/schema/implementation/schema-builder/extract-type-metadata.util.d.ts +4 -0
- package/esm/schema/implementation/schema-builder/extract-type-metadata.util.js +89 -0
- package/esm/schema/index.d.ts +25 -0
- package/esm/schema/index.js +25 -0
- package/esm/schema/interfaces/child-field-query.interface.d.ts +4 -0
- package/esm/schema/interfaces/child-field-query.interface.js +1 -0
- package/esm/schema/interfaces/data-type.metadata.d.ts +18 -0
- package/esm/schema/interfaces/data-type.metadata.js +1 -0
- package/esm/schema/interfaces/resource-container.interface.d.ts +8 -0
- package/esm/schema/interfaces/resource-container.interface.js +1 -0
- package/esm/schema/interfaces/resource.metadata.d.ts +18 -0
- package/esm/schema/interfaces/resource.metadata.js +1 -0
- package/esm/schema/opra-schema.definition.d.ts +178 -0
- package/esm/schema/opra-schema.definition.js +46 -0
- package/esm/schema/type-helpers/extend-type.helper.d.ts +3 -0
- package/esm/schema/type-helpers/extend-type.helper.js +59 -0
- package/esm/schema/type-helpers/mixin-type.helper.d.ts +2 -0
- package/esm/schema/type-helpers/mixin-type.helper.js +41 -0
- package/esm/schema/type-helpers/mixin.utils.d.ts +3 -0
- package/esm/schema/type-helpers/mixin.utils.js +27 -0
- package/esm/{types.d.ts → schema/types.d.ts} +8 -1
- package/esm/schema/types.js +1 -0
- package/esm/schema/utils/class.utils.d.ts +2 -0
- package/esm/schema/utils/class.utils.js +4 -0
- package/esm/schema/utils/clone-object.util.d.ts +1 -0
- package/esm/schema/utils/clone-object.util.js +14 -0
- package/esm/schema/utils/inspect.util.d.ts +4 -0
- package/esm/schema/utils/inspect.util.js +4 -0
- package/esm/schema/utils/normalize-field-array.util.d.ts +3 -0
- package/esm/schema/utils/normalize-field-array.util.js +40 -0
- package/esm/schema/utils/path-to-tree.util.d.ts +4 -0
- package/esm/schema/utils/path-to-tree.util.js +22 -0
- package/esm/schema/utils/string-compare.util.d.ts +1 -0
- package/esm/schema/utils/string-compare.util.js +7 -0
- package/esm/url/formats/boolean-format.d.ts +5 -0
- package/esm/url/formats/boolean-format.js +21 -0
- package/esm/url/formats/date-format.d.ts +16 -0
- package/esm/url/formats/date-format.js +44 -0
- package/esm/url/formats/filter-format.d.ts +6 -0
- package/esm/url/formats/filter-format.js +14 -0
- package/esm/url/formats/format.d.ts +4 -0
- package/esm/url/formats/format.js +2 -0
- package/esm/url/formats/integer-format.d.ts +9 -0
- package/esm/url/formats/integer-format.js +16 -0
- package/esm/url/formats/number-format.d.ts +12 -0
- package/esm/url/formats/number-format.js +24 -0
- package/esm/url/formats/string-format.d.ts +14 -0
- package/esm/url/formats/string-format.js +24 -0
- package/esm/url/index.d.ts +5 -0
- package/esm/url/index.js +5 -0
- package/esm/url/opra-url-path-component.d.ts +15 -0
- package/esm/url/opra-url-path-component.js +29 -0
- package/esm/url/opra-url-path.d.ts +30 -0
- package/esm/url/opra-url-path.js +124 -0
- package/esm/url/opra-url-search-params.d.ts +46 -0
- package/esm/url/opra-url-search-params.js +243 -0
- package/esm/url/opra-url.d.ts +79 -0
- package/esm/url/opra-url.js +295 -0
- package/esm/url/utils/path-utils.d.ts +8 -0
- package/esm/url/utils/path-utils.js +78 -0
- package/esm/utils/index.d.ts +3 -0
- package/esm/utils/index.js +3 -0
- package/esm/utils/is-url.d.ts +1 -0
- package/esm/utils/is-url.js +4 -0
- package/esm/utils/path-to-tree.d.ts +4 -0
- package/esm/utils/path-to-tree.js +24 -0
- package/esm/utils/type-guards.d.ts +9 -0
- package/esm/utils/type-guards.js +37 -0
- package/package.json +30 -10
- package/umd/opra-common.umd.min.js +1 -0
- package/cjs/classes/headers-map.js +0 -18
- package/esm/classes/headers-map.d.ts +0 -5
- package/esm/classes/headers-map.js +0 -14
|
@@ -0,0 +1,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
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.primitiveClasses = exports.builtInTypes = void 0;
|
|
4
|
+
const responsive_map_js_1 = require("../../../helpers/responsive-map.js");
|
|
5
|
+
const any_type_js_1 = require("./builtin/any.type.js");
|
|
6
|
+
const base64_binary_type_js_1 = require("./builtin/base64-binary.type.js");
|
|
7
|
+
const bigint_type_js_1 = require("./builtin/bigint.type.js");
|
|
8
|
+
const boolean_type_js_1 = require("./builtin/boolean.type.js");
|
|
9
|
+
const date_type_js_1 = require("./builtin/date.type.js");
|
|
10
|
+
const date_string_type_js_1 = require("./builtin/date-string.type.js");
|
|
11
|
+
const guid_type_js_1 = require("./builtin/guid.type.js");
|
|
12
|
+
const integer_type_js_1 = require("./builtin/integer.type.js");
|
|
13
|
+
const number_type_js_1 = require("./builtin/number.type.js");
|
|
14
|
+
const object_type_js_1 = require("./builtin/object.type.js");
|
|
15
|
+
const string_type_js_1 = require("./builtin/string.type.js");
|
|
16
|
+
const BigIntConstructor = Object.getPrototypeOf(BigInt(0)).constructor;
|
|
17
|
+
const BufferConstructor = Object.getPrototypeOf(Buffer.from('')).constructor;
|
|
18
|
+
exports.builtInTypes = new responsive_map_js_1.ResponsiveMap();
|
|
19
|
+
exports.builtInTypes.set('any', any_type_js_1.AnyType);
|
|
20
|
+
exports.builtInTypes.set('base64Binary', base64_binary_type_js_1.Base64BinaryType);
|
|
21
|
+
exports.builtInTypes.set('bigint', bigint_type_js_1.BigIntType);
|
|
22
|
+
exports.builtInTypes.set('boolean', boolean_type_js_1.BooleanType);
|
|
23
|
+
exports.builtInTypes.set('date', date_type_js_1.DateType);
|
|
24
|
+
exports.builtInTypes.set('dateString', date_string_type_js_1.DateStringType);
|
|
25
|
+
exports.builtInTypes.set('guid', guid_type_js_1.GuidType);
|
|
26
|
+
exports.builtInTypes.set('integer', integer_type_js_1.IntegerType);
|
|
27
|
+
exports.builtInTypes.set('number', number_type_js_1.NumberType);
|
|
28
|
+
exports.builtInTypes.set('object', object_type_js_1.ObjectType);
|
|
29
|
+
exports.builtInTypes.set('string', string_type_js_1.StringType);
|
|
30
|
+
exports.primitiveClasses = new Map();
|
|
31
|
+
exports.primitiveClasses.set(Boolean, 'boolean');
|
|
32
|
+
exports.primitiveClasses.set(String, 'string');
|
|
33
|
+
exports.primitiveClasses.set(Number, 'number');
|
|
34
|
+
exports.primitiveClasses.set(Date, 'date');
|
|
35
|
+
exports.primitiveClasses.set(BigIntConstructor, 'bigint');
|
|
36
|
+
exports.primitiveClasses.set(BufferConstructor, 'base64Binary');
|
|
37
|
+
exports.primitiveClasses.set(Object, 'object');
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ComplexType = void 0;
|
|
4
|
+
const responsive_map_js_1 = require("../../../helpers/responsive-map.js");
|
|
5
|
+
const clone_object_util_js_1 = require("../../utils/clone-object.util.js");
|
|
6
|
+
const inspect_util_js_1 = require("../../utils/inspect.util.js");
|
|
7
|
+
const data_type_js_1 = require("./data-type.js");
|
|
8
|
+
class ComplexType extends data_type_js_1.DataType {
|
|
9
|
+
_initialized = false;
|
|
10
|
+
_mixinAdditionalFields;
|
|
11
|
+
ownFields = new responsive_map_js_1.ResponsiveMap();
|
|
12
|
+
fields = new responsive_map_js_1.ResponsiveMap();
|
|
13
|
+
constructor(owner, name, args) {
|
|
14
|
+
super(owner, name, {
|
|
15
|
+
kind: 'ComplexType',
|
|
16
|
+
...args
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
get abstract() {
|
|
20
|
+
return !!this._metadata.abstract;
|
|
21
|
+
}
|
|
22
|
+
get additionalFields() {
|
|
23
|
+
return this._metadata.additionalFields || this._mixinAdditionalFields;
|
|
24
|
+
}
|
|
25
|
+
get extends() {
|
|
26
|
+
return this._metadata.extends;
|
|
27
|
+
}
|
|
28
|
+
getField(fieldName) {
|
|
29
|
+
if (fieldName.includes('.')) {
|
|
30
|
+
let dt = this;
|
|
31
|
+
const arr = fieldName.split('.');
|
|
32
|
+
let field;
|
|
33
|
+
for (const a of arr) {
|
|
34
|
+
field = dt.getField(a);
|
|
35
|
+
dt = dt.document.getDataType(field.type || 'string');
|
|
36
|
+
}
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
return field;
|
|
39
|
+
}
|
|
40
|
+
const t = this.fields.get(fieldName);
|
|
41
|
+
if (!t)
|
|
42
|
+
throw new Error(`"${this.name}" type doesn't have a field named "${fieldName}"`);
|
|
43
|
+
return t;
|
|
44
|
+
}
|
|
45
|
+
getFieldType(fieldName) {
|
|
46
|
+
const field = this.getField(fieldName);
|
|
47
|
+
return this.document.getDataType(field.type || 'string');
|
|
48
|
+
}
|
|
49
|
+
getOwnField(name) {
|
|
50
|
+
const t = this.ownFields.get(name);
|
|
51
|
+
if (!t)
|
|
52
|
+
throw new Error(`"${this.name}" type doesn't have an own field named "${name}"`);
|
|
53
|
+
return t;
|
|
54
|
+
}
|
|
55
|
+
getSchema() {
|
|
56
|
+
const out = super.getSchema();
|
|
57
|
+
if (this.additionalFields)
|
|
58
|
+
out.additionalFields = this.additionalFields;
|
|
59
|
+
if (this.ownFields.size) {
|
|
60
|
+
out.fields = {};
|
|
61
|
+
for (const [k, prop] of this.ownFields) {
|
|
62
|
+
out.fields[k] = (0, clone_object_util_js_1.cloneObject)(prop);
|
|
63
|
+
delete out.fields[k].name;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
toString() {
|
|
69
|
+
return `[${Object.getPrototypeOf(this).constructor.name} ${this.name}]`;
|
|
70
|
+
}
|
|
71
|
+
[inspect_util_js_1.nodeInspectCustom]() {
|
|
72
|
+
return `[${inspect_util_js_1.colorFgYellow + Object.getPrototypeOf(this).constructor.name + inspect_util_js_1.colorReset}` +
|
|
73
|
+
` ${inspect_util_js_1.colorFgMagenta + this.name + inspect_util_js_1.colorReset}]`;
|
|
74
|
+
}
|
|
75
|
+
init() {
|
|
76
|
+
if (this._initialized)
|
|
77
|
+
return;
|
|
78
|
+
this._initialized = true;
|
|
79
|
+
const metadata = this._metadata;
|
|
80
|
+
if (metadata.extends) {
|
|
81
|
+
for (const ext of metadata.extends) {
|
|
82
|
+
const baseType = this.document.types.get(ext.type);
|
|
83
|
+
if (!baseType)
|
|
84
|
+
throw new TypeError(`Extending schema (${ext.type}) of data type "${this.name}" does not exists`);
|
|
85
|
+
if (!(baseType instanceof ComplexType))
|
|
86
|
+
throw new TypeError(`Cannot extend ${this.name} from a "${baseType.kind}"`);
|
|
87
|
+
baseType.init();
|
|
88
|
+
if (baseType.additionalFields)
|
|
89
|
+
this._mixinAdditionalFields = true;
|
|
90
|
+
for (const [k, prop] of baseType.fields) {
|
|
91
|
+
const f = (0, clone_object_util_js_1.cloneObject)(prop);
|
|
92
|
+
f.name = k;
|
|
93
|
+
f.parent = this;
|
|
94
|
+
this.fields.set(k, f);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (metadata.fields) {
|
|
99
|
+
for (const [k, prop] of Object.entries(metadata.fields)) {
|
|
100
|
+
const t = this.document.types.get(prop.type);
|
|
101
|
+
if (!t)
|
|
102
|
+
throw new TypeError(`Type "${prop.type}" defined for "${this.name}.${k}" does not exists`);
|
|
103
|
+
const f = (0, clone_object_util_js_1.cloneObject)(prop);
|
|
104
|
+
f.name = k;
|
|
105
|
+
this.fields.set(k, f);
|
|
106
|
+
this.ownFields.set(k, f);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
exports.ComplexType = ComplexType;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DataType = void 0;
|
|
4
|
+
const clone_object_util_js_1 = require("../../utils/clone-object.util.js");
|
|
5
|
+
class DataType {
|
|
6
|
+
_document;
|
|
7
|
+
_metadata;
|
|
8
|
+
_name;
|
|
9
|
+
constructor(document, name, metadata) {
|
|
10
|
+
this._document = document;
|
|
11
|
+
this._name = name;
|
|
12
|
+
this._metadata = metadata;
|
|
13
|
+
}
|
|
14
|
+
get document() {
|
|
15
|
+
return this._document;
|
|
16
|
+
}
|
|
17
|
+
get kind() {
|
|
18
|
+
return this._metadata.kind;
|
|
19
|
+
}
|
|
20
|
+
get name() {
|
|
21
|
+
return this._name;
|
|
22
|
+
}
|
|
23
|
+
get description() {
|
|
24
|
+
return this._metadata.description;
|
|
25
|
+
}
|
|
26
|
+
get ctor() {
|
|
27
|
+
return this._metadata.ctor;
|
|
28
|
+
}
|
|
29
|
+
parse(value) {
|
|
30
|
+
return this._metadata.parse ? this._metadata.parse(value) : value;
|
|
31
|
+
}
|
|
32
|
+
getSchema(jsonOnly) {
|
|
33
|
+
return (0, clone_object_util_js_1.cloneObject)(this._metadata, jsonOnly);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.DataType = DataType;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SimpleType = void 0;
|
|
4
|
+
const inspect_util_js_1 = require("../../utils/inspect.util.js");
|
|
5
|
+
const data_type_js_1 = require("./data-type.js");
|
|
6
|
+
class SimpleType extends data_type_js_1.DataType {
|
|
7
|
+
constructor(owner, name, args) {
|
|
8
|
+
super(owner, name, {
|
|
9
|
+
kind: 'SimpleType',
|
|
10
|
+
...args
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
toString() {
|
|
14
|
+
return `[${Object.getPrototypeOf(this).constructor.name} ${this.name}]`;
|
|
15
|
+
}
|
|
16
|
+
[inspect_util_js_1.nodeInspectCustom]() {
|
|
17
|
+
return `[${inspect_util_js_1.colorFgYellow + Object.getPrototypeOf(this).constructor.name + inspect_util_js_1.colorReset}` +
|
|
18
|
+
` ${inspect_util_js_1.colorFgMagenta + this.name + inspect_util_js_1.colorReset}]`;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.SimpleType = SimpleType;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnionType = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const inspect_util_js_1 = require("../../utils/inspect.util.js");
|
|
6
|
+
const complex_type_js_1 = require("./complex-type.js");
|
|
7
|
+
const data_type_js_1 = require("./data-type.js");
|
|
8
|
+
class UnionType extends data_type_js_1.DataType {
|
|
9
|
+
types;
|
|
10
|
+
hasAdditionalFields;
|
|
11
|
+
constructor(owner, name, args) {
|
|
12
|
+
super(owner, name, (0, lodash_1.omit)({ kind: 'UnionType', ...args }, ['types']));
|
|
13
|
+
this.types = args.types;
|
|
14
|
+
this.hasAdditionalFields = name === 'any' ||
|
|
15
|
+
!!this.types.find(t => t instanceof complex_type_js_1.ComplexType && t.additionalFields);
|
|
16
|
+
}
|
|
17
|
+
toString() {
|
|
18
|
+
return `[${Object.getPrototypeOf(this).constructor.name} ${this.name}]`;
|
|
19
|
+
}
|
|
20
|
+
[inspect_util_js_1.nodeInspectCustom]() {
|
|
21
|
+
return `[${inspect_util_js_1.colorFgYellow + Object.getPrototypeOf(this).constructor.name + inspect_util_js_1.colorReset}` +
|
|
22
|
+
` ${inspect_util_js_1.colorFgMagenta + this.name + inspect_util_js_1.colorReset}]`;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.UnionType = UnionType;
|