@opra/common 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/constants.js +1 -0
- package/cjs/exception/enums/issue-severity.enum.js +23 -0
- package/cjs/{types.js → exception/error-issue.js} +0 -0
- package/cjs/exception/http-errors/bad-request.error.js +22 -0
- package/cjs/exception/http-errors/failed-dependency.error.js +21 -0
- package/cjs/exception/http-errors/forbidden.error.js +23 -0
- package/cjs/exception/http-errors/internal-server.error.js +21 -0
- package/cjs/exception/http-errors/method-not-allowed.error.js +22 -0
- package/cjs/exception/http-errors/not-acceptable.error.js +22 -0
- package/cjs/exception/http-errors/not-found.error.js +25 -0
- package/cjs/exception/http-errors/unauthorized.error.js +22 -0
- package/cjs/exception/http-errors/unprocessable-entity.error.js +21 -0
- package/cjs/exception/index.js +18 -0
- package/cjs/exception/opra-exception.js +56 -0
- package/cjs/exception/resource-errors/resource-conflict.error.js +20 -0
- package/cjs/exception/resource-errors/resource-not-found.error.js +20 -0
- package/cjs/exception/wrap-exception.js +42 -0
- package/cjs/filter/antlr/OpraFilterLexer.js +386 -0
- package/cjs/filter/antlr/OpraFilterParser.js +2070 -0
- package/cjs/filter/antlr/OpraFilterVisitor.js +3 -0
- package/cjs/filter/ast/abstract/ast.js +10 -0
- package/cjs/filter/ast/abstract/expression.js +7 -0
- package/cjs/filter/ast/abstract/literal.js +14 -0
- package/cjs/filter/ast/abstract/term.js +7 -0
- package/cjs/filter/ast/expressions/arithmetic-expression.js +29 -0
- package/cjs/filter/ast/expressions/array-expression.js +15 -0
- package/cjs/filter/ast/expressions/comparison-expression.js +18 -0
- package/cjs/filter/ast/expressions/logical-expression.js +18 -0
- package/cjs/filter/ast/expressions/parentheses-expression.js +15 -0
- package/cjs/filter/ast/index.js +19 -0
- package/cjs/filter/ast/terms/boolean-literal.js +10 -0
- package/cjs/filter/ast/terms/date-literal.js +28 -0
- package/cjs/filter/ast/terms/external-constant.js +13 -0
- package/cjs/filter/ast/terms/null-literal.js +11 -0
- package/cjs/filter/ast/terms/number-literal.js +40 -0
- package/cjs/filter/ast/terms/qualified-identifier.js +10 -0
- package/cjs/filter/ast/terms/string-literal.js +14 -0
- package/cjs/filter/ast/terms/time-literal.js +33 -0
- package/cjs/filter/build.js +129 -0
- package/cjs/filter/error-listener.js +14 -0
- package/cjs/filter/errors.js +21 -0
- package/cjs/filter/filter-tree-visitor.js +113 -0
- package/cjs/filter/index.js +8 -0
- package/cjs/filter/parse.js +37 -0
- package/cjs/filter/utils.js +26 -0
- package/cjs/helpers/index.js +4 -0
- package/cjs/{classes → helpers}/responsive-map.js +1 -1
- package/cjs/{enums → http/enums}/http-headers.enum.js +9 -0
- package/cjs/{enums → http/enums}/http-status.enum.js +0 -0
- package/cjs/http/http-request.js +118 -0
- package/cjs/http/index.js +9 -0
- package/cjs/http/interfaces/client-http-headers.interface.js +2 -0
- package/cjs/http/interfaces/server-http-headers.interface.js +2 -0
- package/cjs/http/multipart/batch-multipart.js +155 -0
- package/cjs/http/multipart/http-request-content.js +16 -0
- package/cjs/http/multipart/http-response-content.js +14 -0
- package/cjs/http/multipart/index.js +4 -0
- package/cjs/http/utils/normalize-headers.js +28 -0
- package/cjs/i18n/i18n.js +175 -0
- package/cjs/i18n/index.js +10 -0
- package/cjs/i18n/string-utils.js +13 -0
- package/cjs/i18n/translate.js +15 -0
- package/cjs/index.js +12 -5
- package/cjs/schema/constants.js +11 -0
- package/cjs/schema/decorators/opr-collection-resource.decorator.js +23 -0
- package/cjs/schema/decorators/opr-complex-type.decorator.js +27 -0
- package/cjs/schema/decorators/opr-field.decorator.js +28 -0
- package/cjs/schema/decorators/opr-resolver.decorator.js +81 -0
- package/cjs/schema/decorators/opr-simple-type.decorator.js +18 -0
- package/cjs/schema/decorators/opr-singleton-resource.decorator.js +23 -0
- package/cjs/schema/implementation/data-type/builtin/any.type.js +9 -0
- package/cjs/schema/implementation/data-type/builtin/base64-binary.type.js +15 -0
- package/cjs/schema/implementation/data-type/builtin/bigint.type.js +15 -0
- package/cjs/schema/implementation/data-type/builtin/boolean.type.js +15 -0
- package/cjs/schema/implementation/data-type/builtin/date-string.type.js +15 -0
- package/cjs/schema/implementation/data-type/builtin/date.type.js +15 -0
- package/cjs/schema/implementation/data-type/builtin/guid.type.js +15 -0
- package/cjs/schema/implementation/data-type/builtin/integer.type.js +15 -0
- package/cjs/schema/implementation/data-type/builtin/number.type.js +15 -0
- package/cjs/schema/implementation/data-type/builtin/object.type.js +15 -0
- package/cjs/schema/implementation/data-type/builtin/string.type.js +15 -0
- package/cjs/schema/implementation/data-type/builtin-data-types.js +37 -0
- package/cjs/schema/implementation/data-type/complex-type.js +111 -0
- package/cjs/schema/implementation/data-type/data-type.js +36 -0
- package/cjs/schema/implementation/data-type/simple-type.js +21 -0
- package/cjs/schema/implementation/data-type/union-type.js +25 -0
- package/cjs/schema/implementation/document-builder.js +140 -0
- package/cjs/schema/implementation/opra-document.js +181 -0
- package/cjs/schema/implementation/query/collection-count-query.js +19 -0
- package/cjs/schema/implementation/query/collection-create-query.js +28 -0
- package/cjs/schema/implementation/query/collection-delete-many-query.js +19 -0
- package/cjs/schema/implementation/query/collection-delete-query.js +27 -0
- package/cjs/schema/implementation/query/collection-get-query.js +38 -0
- package/cjs/schema/implementation/query/collection-search-query.js +55 -0
- package/cjs/schema/implementation/query/collection-update-many-query.js +21 -0
- package/cjs/schema/implementation/query/collection-update-query.js +39 -0
- package/cjs/schema/implementation/query/field-get-query.js +45 -0
- package/cjs/schema/implementation/query/index.js +22 -0
- package/cjs/schema/implementation/query/singleton-get-query.js +27 -0
- package/cjs/schema/implementation/resource/collection-resource-info.js +58 -0
- package/cjs/schema/implementation/resource/container-resource-info.js +30 -0
- package/cjs/schema/implementation/resource/resource-info.js +39 -0
- package/cjs/schema/implementation/resource/singleton-resource-info.js +37 -0
- package/cjs/schema/implementation/schema-builder/extract-resource-metadata.util.js +84 -0
- package/cjs/schema/implementation/schema-builder/extract-type-metadata.util.js +94 -0
- package/cjs/schema/index.js +28 -0
- package/cjs/schema/interfaces/child-field-query.interface.js +2 -0
- package/cjs/schema/interfaces/data-type.metadata.js +2 -0
- package/cjs/schema/interfaces/resource-container.interface.js +2 -0
- package/cjs/schema/interfaces/resource.metadata.js +2 -0
- package/cjs/schema/opra-schema.definition.js +49 -0
- package/cjs/schema/type-helpers/extend-type.helper.js +65 -0
- package/cjs/schema/type-helpers/mixin-type.helper.js +46 -0
- package/cjs/schema/type-helpers/mixin.utils.js +32 -0
- package/cjs/schema/types.js +2 -0
- package/cjs/schema/utils/class.utils.js +8 -0
- package/cjs/schema/utils/clone-object.util.js +19 -0
- package/cjs/schema/utils/inspect.util.js +7 -0
- package/cjs/schema/utils/normalize-field-array.util.js +44 -0
- package/cjs/schema/utils/path-to-tree.util.js +26 -0
- package/cjs/schema/utils/string-compare.util.js +11 -0
- package/cjs/url/formats/boolean-format.js +25 -0
- package/cjs/url/formats/date-format.js +48 -0
- package/cjs/url/formats/filter-format.js +18 -0
- package/cjs/url/formats/format.js +6 -0
- package/cjs/url/formats/integer-format.js +20 -0
- package/cjs/url/formats/number-format.js +28 -0
- package/cjs/url/formats/string-format.js +28 -0
- package/cjs/url/index.js +8 -0
- package/cjs/url/opra-url-path-component.js +33 -0
- package/cjs/url/opra-url-path.js +128 -0
- package/cjs/url/opra-url-search-params.js +247 -0
- package/cjs/url/opra-url.js +299 -0
- package/cjs/url/utils/path-utils.js +86 -0
- package/cjs/utils/index.js +6 -0
- package/cjs/utils/is-url.js +8 -0
- package/cjs/utils/path-to-tree.js +28 -0
- package/cjs/utils/type-guards.js +46 -0
- package/esm/constants.d.ts +0 -0
- package/esm/constants.js +1 -0
- package/esm/exception/enums/issue-severity.enum.d.ts +13 -0
- package/esm/exception/enums/issue-severity.enum.js +20 -0
- package/esm/exception/error-issue.d.ts +9 -0
- package/esm/{types.js → exception/error-issue.js} +0 -0
- package/esm/exception/http-errors/bad-request.error.d.ts +10 -0
- package/esm/exception/http-errors/bad-request.error.js +18 -0
- package/esm/exception/http-errors/failed-dependency.error.d.ts +9 -0
- package/esm/exception/http-errors/failed-dependency.error.js +17 -0
- package/esm/exception/http-errors/forbidden.error.d.ts +11 -0
- package/esm/exception/http-errors/forbidden.error.js +19 -0
- package/esm/exception/http-errors/internal-server.error.d.ts +9 -0
- package/esm/exception/http-errors/internal-server.error.js +17 -0
- package/esm/exception/http-errors/method-not-allowed.error.d.ts +10 -0
- package/esm/exception/http-errors/method-not-allowed.error.js +18 -0
- package/esm/exception/http-errors/not-acceptable.error.d.ts +10 -0
- package/esm/exception/http-errors/not-acceptable.error.js +18 -0
- package/esm/exception/http-errors/not-found.error.d.ts +13 -0
- package/esm/exception/http-errors/not-found.error.js +21 -0
- package/esm/exception/http-errors/unauthorized.error.d.ts +10 -0
- package/esm/exception/http-errors/unauthorized.error.js +18 -0
- package/esm/exception/http-errors/unprocessable-entity.error.d.ts +9 -0
- package/esm/exception/http-errors/unprocessable-entity.error.js +17 -0
- package/esm/exception/index.d.ts +15 -0
- package/esm/exception/index.js +15 -0
- package/esm/exception/opra-exception.d.ts +15 -0
- package/esm/exception/opra-exception.js +52 -0
- package/esm/exception/resource-errors/resource-conflict.error.d.ts +5 -0
- package/esm/exception/resource-errors/resource-conflict.error.js +16 -0
- package/esm/exception/resource-errors/resource-not-found.error.d.ts +4 -0
- package/esm/exception/resource-errors/resource-not-found.error.js +16 -0
- package/esm/exception/wrap-exception.d.ts +2 -0
- package/esm/exception/wrap-exception.js +38 -0
- package/esm/filter/antlr/OpraFilterLexer.d.ts +78 -0
- package/esm/filter/antlr/OpraFilterLexer.js +381 -0
- package/esm/filter/antlr/OpraFilterParser.d.ts +365 -0
- package/esm/filter/antlr/OpraFilterParser.js +2022 -0
- package/esm/filter/antlr/OpraFilterVisitor.d.ts +290 -0
- package/esm/filter/antlr/OpraFilterVisitor.js +2 -0
- package/esm/filter/ast/abstract/ast.d.ts +5 -0
- package/esm/filter/ast/abstract/ast.js +6 -0
- package/esm/filter/ast/abstract/expression.d.ts +3 -0
- package/esm/filter/ast/abstract/expression.js +3 -0
- package/esm/filter/ast/abstract/literal.d.ts +6 -0
- package/esm/filter/ast/abstract/literal.js +10 -0
- package/esm/filter/ast/abstract/term.d.ts +3 -0
- package/esm/filter/ast/abstract/term.js +3 -0
- package/esm/filter/ast/expressions/arithmetic-expression.d.ts +13 -0
- package/esm/filter/ast/expressions/arithmetic-expression.js +24 -0
- package/esm/filter/ast/expressions/array-expression.d.ts +7 -0
- package/esm/filter/ast/expressions/array-expression.js +11 -0
- package/esm/filter/ast/expressions/comparison-expression.d.ts +10 -0
- package/esm/filter/ast/expressions/comparison-expression.js +14 -0
- package/esm/filter/ast/expressions/logical-expression.d.ts +8 -0
- package/esm/filter/ast/expressions/logical-expression.js +14 -0
- package/esm/filter/ast/expressions/parentheses-expression.d.ts +6 -0
- package/esm/filter/ast/expressions/parentheses-expression.js +11 -0
- package/esm/filter/ast/index.d.ts +16 -0
- package/esm/filter/ast/index.js +16 -0
- package/esm/filter/ast/terms/boolean-literal.d.ts +5 -0
- package/esm/filter/ast/terms/boolean-literal.js +6 -0
- package/esm/filter/ast/terms/date-literal.d.ts +6 -0
- package/esm/filter/ast/terms/date-literal.js +24 -0
- package/esm/filter/ast/terms/external-constant.d.ts +5 -0
- package/esm/filter/ast/terms/external-constant.js +9 -0
- package/esm/filter/ast/terms/null-literal.d.ts +5 -0
- package/esm/filter/ast/terms/null-literal.js +7 -0
- package/esm/filter/ast/terms/number-literal.d.ts +6 -0
- package/esm/filter/ast/terms/number-literal.js +36 -0
- package/esm/filter/ast/terms/qualified-identifier.d.ts +4 -0
- package/esm/filter/ast/terms/qualified-identifier.js +6 -0
- package/esm/filter/ast/terms/string-literal.d.ts +5 -0
- package/esm/filter/ast/terms/string-literal.js +10 -0
- package/esm/filter/ast/terms/time-literal.d.ts +6 -0
- package/esm/filter/ast/terms/time-literal.js +29 -0
- package/esm/filter/build.d.ts +31 -0
- package/esm/filter/build.js +105 -0
- package/esm/filter/error-listener.d.ts +8 -0
- package/esm/filter/error-listener.js +10 -0
- package/esm/filter/errors.d.ts +20 -0
- package/esm/filter/errors.js +15 -0
- package/esm/filter/filter-tree-visitor.d.ts +30 -0
- package/esm/filter/filter-tree-visitor.js +109 -0
- package/esm/filter/index.d.ts +5 -0
- package/esm/filter/index.js +5 -0
- package/esm/filter/parse.d.ts +2 -0
- package/esm/filter/parse.js +33 -0
- package/esm/filter/utils.d.ts +2 -0
- package/esm/filter/utils.js +21 -0
- package/esm/helpers/index.d.ts +1 -0
- package/esm/helpers/index.js +1 -0
- package/esm/{classes → helpers}/responsive-map.d.ts +0 -0
- package/esm/{classes → helpers}/responsive-map.js +1 -1
- package/esm/{enums → http/enums}/http-headers.enum.d.ts +9 -0
- package/esm/{enums → http/enums}/http-headers.enum.js +9 -0
- package/esm/{enums → http/enums}/http-status.enum.d.ts +0 -0
- package/esm/{enums → http/enums}/http-status.enum.js +0 -0
- package/esm/http/http-request.d.ts +34 -0
- package/esm/http/http-request.js +114 -0
- package/esm/http/index.d.ts +6 -0
- package/esm/http/index.js +6 -0
- package/esm/http/interfaces/client-http-headers.interface.d.ts +65 -0
- package/esm/http/interfaces/client-http-headers.interface.js +1 -0
- package/esm/http/interfaces/server-http-headers.interface.d.ts +1 -0
- package/esm/http/interfaces/server-http-headers.interface.js +1 -0
- package/esm/http/multipart/batch-multipart.d.ts +30 -0
- package/esm/http/multipart/batch-multipart.js +150 -0
- package/esm/http/multipart/http-request-content.d.ts +8 -0
- package/esm/http/multipart/http-request-content.js +12 -0
- package/esm/http/multipart/http-response-content.d.ts +7 -0
- package/esm/http/multipart/http-response-content.js +10 -0
- package/esm/http/multipart/index.d.ts +1 -0
- package/esm/http/multipart/index.js +1 -0
- package/esm/http/utils/normalize-headers.d.ts +1 -0
- package/esm/http/utils/normalize-headers.js +24 -0
- package/esm/i18n/i18n.d.ts +28 -0
- package/esm/i18n/i18n.js +170 -0
- package/esm/i18n/index.d.ts +5 -0
- package/esm/i18n/index.js +6 -0
- package/esm/i18n/string-utils.d.ts +2 -0
- package/esm/i18n/string-utils.js +8 -0
- package/esm/i18n/translate.d.ts +4 -0
- package/esm/i18n/translate.js +11 -0
- package/esm/index.d.ts +10 -5
- package/esm/index.js +10 -5
- package/esm/schema/constants.d.ts +8 -0
- package/esm/schema/constants.js +8 -0
- package/esm/schema/decorators/opr-collection-resource.decorator.d.ts +8 -0
- package/esm/schema/decorators/opr-collection-resource.decorator.js +19 -0
- package/esm/schema/decorators/opr-complex-type.decorator.d.ts +6 -0
- package/esm/schema/decorators/opr-complex-type.decorator.js +23 -0
- package/esm/schema/decorators/opr-field.decorator.d.ts +3 -0
- package/esm/schema/decorators/opr-field.decorator.js +24 -0
- package/esm/schema/decorators/opr-resolver.decorator.d.ts +8 -0
- package/esm/schema/decorators/opr-resolver.decorator.js +71 -0
- package/esm/schema/decorators/opr-simple-type.decorator.d.ts +6 -0
- package/esm/schema/decorators/opr-simple-type.decorator.js +14 -0
- package/esm/schema/decorators/opr-singleton-resource.decorator.d.ts +8 -0
- package/esm/schema/decorators/opr-singleton-resource.decorator.js +19 -0
- package/esm/schema/implementation/data-type/builtin/any.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/any.type.js +6 -0
- package/esm/schema/implementation/data-type/builtin/base64-binary.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/base64-binary.type.js +12 -0
- package/esm/schema/implementation/data-type/builtin/bigint.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/bigint.type.js +12 -0
- package/esm/schema/implementation/data-type/builtin/boolean.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/boolean.type.js +12 -0
- package/esm/schema/implementation/data-type/builtin/date-string.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/date-string.type.js +12 -0
- package/esm/schema/implementation/data-type/builtin/date.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/date.type.js +12 -0
- package/esm/schema/implementation/data-type/builtin/guid.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/guid.type.js +12 -0
- package/esm/schema/implementation/data-type/builtin/integer.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/integer.type.js +12 -0
- package/esm/schema/implementation/data-type/builtin/number.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/number.type.js +12 -0
- package/esm/schema/implementation/data-type/builtin/object.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/object.type.js +12 -0
- package/esm/schema/implementation/data-type/builtin/string.type.d.ts +2 -0
- package/esm/schema/implementation/data-type/builtin/string.type.js +12 -0
- package/esm/schema/implementation/data-type/builtin-data-types.d.ts +4 -0
- package/esm/schema/implementation/data-type/builtin-data-types.js +34 -0
- package/esm/schema/implementation/data-type/complex-type.d.ts +29 -0
- package/esm/schema/implementation/data-type/complex-type.js +107 -0
- package/esm/schema/implementation/data-type/data-type.d.ts +16 -0
- package/esm/schema/implementation/data-type/data-type.js +32 -0
- package/esm/schema/implementation/data-type/simple-type.d.ts +12 -0
- package/esm/schema/implementation/data-type/simple-type.js +17 -0
- package/esm/schema/implementation/data-type/union-type.d.ts +16 -0
- package/esm/schema/implementation/data-type/union-type.js +21 -0
- package/esm/schema/implementation/document-builder.d.ts +16 -0
- package/esm/schema/implementation/document-builder.js +135 -0
- package/esm/schema/implementation/opra-document.d.ts +44 -0
- package/esm/schema/implementation/opra-document.js +177 -0
- package/esm/schema/implementation/query/collection-count-query.d.ts +14 -0
- package/esm/schema/implementation/query/collection-count-query.js +15 -0
- package/esm/schema/implementation/query/collection-create-query.d.ts +18 -0
- package/esm/schema/implementation/query/collection-create-query.js +24 -0
- package/esm/schema/implementation/query/collection-delete-many-query.d.ts +14 -0
- package/esm/schema/implementation/query/collection-delete-many-query.js +15 -0
- package/esm/schema/implementation/query/collection-delete-query.d.ts +10 -0
- package/esm/schema/implementation/query/collection-delete-query.js +23 -0
- package/esm/schema/implementation/query/collection-get-query.d.ts +21 -0
- package/esm/schema/implementation/query/collection-get-query.js +34 -0
- package/esm/schema/implementation/query/collection-search-query.d.ts +30 -0
- package/esm/schema/implementation/query/collection-search-query.js +51 -0
- package/esm/schema/implementation/query/collection-update-many-query.d.ts +15 -0
- package/esm/schema/implementation/query/collection-update-many-query.js +17 -0
- package/esm/schema/implementation/query/collection-update-query.d.ts +19 -0
- package/esm/schema/implementation/query/collection-update-query.js +35 -0
- package/esm/schema/implementation/query/field-get-query.d.ts +30 -0
- package/esm/schema/implementation/query/field-get-query.js +41 -0
- package/esm/schema/implementation/query/index.d.ts +27 -0
- package/esm/schema/implementation/query/index.js +17 -0
- package/esm/schema/implementation/query/singleton-get-query.d.ts +20 -0
- package/esm/schema/implementation/query/singleton-get-query.js +23 -0
- package/esm/schema/implementation/resource/collection-resource-info.d.ts +19 -0
- package/esm/schema/implementation/resource/collection-resource-info.js +54 -0
- package/esm/schema/implementation/resource/container-resource-info.d.ts +13 -0
- package/esm/schema/implementation/resource/container-resource-info.js +26 -0
- package/esm/schema/implementation/resource/resource-info.d.ts +17 -0
- package/esm/schema/implementation/resource/resource-info.js +35 -0
- package/esm/schema/implementation/resource/singleton-resource-info.d.ts +14 -0
- package/esm/schema/implementation/resource/singleton-resource-info.js +33 -0
- package/esm/schema/implementation/schema-builder/extract-resource-metadata.util.d.ts +3 -0
- package/esm/schema/implementation/schema-builder/extract-resource-metadata.util.js +80 -0
- package/esm/schema/implementation/schema-builder/extract-type-metadata.util.d.ts +4 -0
- package/esm/schema/implementation/schema-builder/extract-type-metadata.util.js +89 -0
- package/esm/schema/index.d.ts +25 -0
- package/esm/schema/index.js +25 -0
- package/esm/schema/interfaces/child-field-query.interface.d.ts +4 -0
- package/esm/schema/interfaces/child-field-query.interface.js +1 -0
- package/esm/schema/interfaces/data-type.metadata.d.ts +18 -0
- package/esm/schema/interfaces/data-type.metadata.js +1 -0
- package/esm/schema/interfaces/resource-container.interface.d.ts +8 -0
- package/esm/schema/interfaces/resource-container.interface.js +1 -0
- package/esm/schema/interfaces/resource.metadata.d.ts +18 -0
- package/esm/schema/interfaces/resource.metadata.js +1 -0
- package/esm/schema/opra-schema.definition.d.ts +178 -0
- package/esm/schema/opra-schema.definition.js +46 -0
- package/esm/schema/type-helpers/extend-type.helper.d.ts +3 -0
- package/esm/schema/type-helpers/extend-type.helper.js +59 -0
- package/esm/schema/type-helpers/mixin-type.helper.d.ts +2 -0
- package/esm/schema/type-helpers/mixin-type.helper.js +41 -0
- package/esm/schema/type-helpers/mixin.utils.d.ts +3 -0
- package/esm/schema/type-helpers/mixin.utils.js +27 -0
- package/esm/{types.d.ts → schema/types.d.ts} +8 -1
- package/esm/schema/types.js +1 -0
- package/esm/schema/utils/class.utils.d.ts +2 -0
- package/esm/schema/utils/class.utils.js +4 -0
- package/esm/schema/utils/clone-object.util.d.ts +1 -0
- package/esm/schema/utils/clone-object.util.js +14 -0
- package/esm/schema/utils/inspect.util.d.ts +4 -0
- package/esm/schema/utils/inspect.util.js +4 -0
- package/esm/schema/utils/normalize-field-array.util.d.ts +3 -0
- package/esm/schema/utils/normalize-field-array.util.js +40 -0
- package/esm/schema/utils/path-to-tree.util.d.ts +4 -0
- package/esm/schema/utils/path-to-tree.util.js +22 -0
- package/esm/schema/utils/string-compare.util.d.ts +1 -0
- package/esm/schema/utils/string-compare.util.js +7 -0
- package/esm/url/formats/boolean-format.d.ts +5 -0
- package/esm/url/formats/boolean-format.js +21 -0
- package/esm/url/formats/date-format.d.ts +16 -0
- package/esm/url/formats/date-format.js +44 -0
- package/esm/url/formats/filter-format.d.ts +6 -0
- package/esm/url/formats/filter-format.js +14 -0
- package/esm/url/formats/format.d.ts +4 -0
- package/esm/url/formats/format.js +2 -0
- package/esm/url/formats/integer-format.d.ts +9 -0
- package/esm/url/formats/integer-format.js +16 -0
- package/esm/url/formats/number-format.d.ts +12 -0
- package/esm/url/formats/number-format.js +24 -0
- package/esm/url/formats/string-format.d.ts +14 -0
- package/esm/url/formats/string-format.js +24 -0
- package/esm/url/index.d.ts +5 -0
- package/esm/url/index.js +5 -0
- package/esm/url/opra-url-path-component.d.ts +15 -0
- package/esm/url/opra-url-path-component.js +29 -0
- package/esm/url/opra-url-path.d.ts +30 -0
- package/esm/url/opra-url-path.js +124 -0
- package/esm/url/opra-url-search-params.d.ts +46 -0
- package/esm/url/opra-url-search-params.js +243 -0
- package/esm/url/opra-url.d.ts +79 -0
- package/esm/url/opra-url.js +295 -0
- package/esm/url/utils/path-utils.d.ts +8 -0
- package/esm/url/utils/path-utils.js +78 -0
- package/esm/utils/index.d.ts +3 -0
- package/esm/utils/index.js +3 -0
- package/esm/utils/is-url.d.ts +1 -0
- package/esm/utils/is-url.js +4 -0
- package/esm/utils/path-to-tree.d.ts +4 -0
- package/esm/utils/path-to-tree.js +24 -0
- package/esm/utils/type-guards.d.ts +9 -0
- package/esm/utils/type-guards.js +37 -0
- package/package.json +30 -10
- package/umd/opra-common.umd.min.js +1 -0
- package/cjs/classes/headers-map.js +0 -18
- package/esm/classes/headers-map.d.ts +0 -5
- package/esm/classes/headers-map.js +0 -14
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Literal = void 0;
|
|
4
|
+
const term_js_1 = require("./term.js");
|
|
5
|
+
class Literal extends term_js_1.Term {
|
|
6
|
+
constructor(value) {
|
|
7
|
+
super();
|
|
8
|
+
this.value = value;
|
|
9
|
+
}
|
|
10
|
+
toString() {
|
|
11
|
+
return '' + this.value;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.Literal = Literal;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArithmeticExpressionItem = exports.ArithmeticExpression = void 0;
|
|
4
|
+
const expression_js_1 = require("../abstract/expression.js");
|
|
5
|
+
class ArithmeticExpression extends expression_js_1.Expression {
|
|
6
|
+
items = [];
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
}
|
|
10
|
+
append(op, expression) {
|
|
11
|
+
this.items.push(new ArithmeticExpressionItem({
|
|
12
|
+
op,
|
|
13
|
+
expression
|
|
14
|
+
}));
|
|
15
|
+
return this;
|
|
16
|
+
}
|
|
17
|
+
toString() {
|
|
18
|
+
return this.items.map((child, i) => (i > 0 ? child.op : '') + child.expression).join('');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.ArithmeticExpression = ArithmeticExpression;
|
|
22
|
+
class ArithmeticExpressionItem {
|
|
23
|
+
op;
|
|
24
|
+
expression;
|
|
25
|
+
constructor(o) {
|
|
26
|
+
Object.assign(this, o);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.ArithmeticExpressionItem = ArithmeticExpressionItem;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArrayExpression = void 0;
|
|
4
|
+
const term_js_1 = require("../abstract/term.js");
|
|
5
|
+
class ArrayExpression extends term_js_1.Term {
|
|
6
|
+
items;
|
|
7
|
+
constructor(items) {
|
|
8
|
+
super();
|
|
9
|
+
this.items = items;
|
|
10
|
+
}
|
|
11
|
+
toString() {
|
|
12
|
+
return '[' + this.items.map(child => '' + child).join(',') + ']';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.ArrayExpression = ArrayExpression;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ComparisonExpression = void 0;
|
|
4
|
+
const expression_js_1 = require("../abstract/expression.js");
|
|
5
|
+
const WORD_PATTERN = /\w/;
|
|
6
|
+
class ComparisonExpression extends expression_js_1.Expression {
|
|
7
|
+
op;
|
|
8
|
+
left;
|
|
9
|
+
right;
|
|
10
|
+
constructor(o) {
|
|
11
|
+
super();
|
|
12
|
+
Object.assign(this, o);
|
|
13
|
+
}
|
|
14
|
+
toString() {
|
|
15
|
+
return `${this.left}${WORD_PATTERN.test(this.op) ? ' ' + this.op + ' ' : this.op}${this.right}`;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.ComparisonExpression = ComparisonExpression;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LogicalExpression = void 0;
|
|
4
|
+
const expression_js_1 = require("../abstract/expression.js");
|
|
5
|
+
class LogicalExpression extends expression_js_1.Expression {
|
|
6
|
+
op;
|
|
7
|
+
items;
|
|
8
|
+
constructor(o) {
|
|
9
|
+
super();
|
|
10
|
+
Object.assign(this, o);
|
|
11
|
+
}
|
|
12
|
+
toString() {
|
|
13
|
+
return this.items
|
|
14
|
+
.map(child => '' + child)
|
|
15
|
+
.join(' ' + this.op + ' ');
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.LogicalExpression = LogicalExpression;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ParenthesesExpression = void 0;
|
|
4
|
+
const expression_js_1 = require("../abstract/expression.js");
|
|
5
|
+
class ParenthesesExpression extends expression_js_1.Expression {
|
|
6
|
+
expression;
|
|
7
|
+
constructor(expression) {
|
|
8
|
+
super();
|
|
9
|
+
this.expression = expression;
|
|
10
|
+
}
|
|
11
|
+
toString() {
|
|
12
|
+
return `(${this.expression})`;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.ParenthesesExpression = ParenthesesExpression;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./abstract/ast.js"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./abstract/expression.js"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./abstract/literal.js"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./abstract/term.js"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./expressions/arithmetic-expression.js"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./expressions/array-expression.js"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./expressions/comparison-expression.js"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./expressions/logical-expression.js"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./expressions/parentheses-expression.js"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./terms/boolean-literal.js"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./terms/date-literal.js"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./terms/null-literal.js"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./terms/number-literal.js"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./terms/qualified-identifier.js"), exports);
|
|
18
|
+
tslib_1.__exportStar(require("./terms/string-literal.js"), exports);
|
|
19
|
+
tslib_1.__exportStar(require("./terms/time-literal.js"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BooleanLiteral = void 0;
|
|
4
|
+
const literal_js_1 = require("../abstract/literal.js");
|
|
5
|
+
class BooleanLiteral extends literal_js_1.Literal {
|
|
6
|
+
constructor(value) {
|
|
7
|
+
super(value);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.BooleanLiteral = BooleanLiteral;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DateLiteral = void 0;
|
|
4
|
+
const luxon_1 = require("luxon"); // todo dont use luxon. it has circular deps!
|
|
5
|
+
const errors_js_1 = require("../../errors.js");
|
|
6
|
+
const utils_js_1 = require("../../utils.js");
|
|
7
|
+
const literal_js_1 = require("../abstract/literal.js");
|
|
8
|
+
const DATE_PATTERN = /^(\d{4})-(0[1-9]|1[012])-([123]0|[012][1-9]|31)/;
|
|
9
|
+
class DateLiteral extends literal_js_1.Literal {
|
|
10
|
+
value;
|
|
11
|
+
constructor(value) {
|
|
12
|
+
super('');
|
|
13
|
+
if (value instanceof Date) {
|
|
14
|
+
this.value = value.toISOString();
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
// noinspection SuspiciousTypeOfGuard
|
|
18
|
+
if (typeof value === 'string' && DATE_PATTERN.test(value) && luxon_1.DateTime.fromISO(value).isValid) {
|
|
19
|
+
this.value = value;
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
throw new errors_js_1.ValidationError(`Invalid date value "${value}"`);
|
|
23
|
+
}
|
|
24
|
+
toString() {
|
|
25
|
+
return (0, utils_js_1.quoteFilterString)(this.value);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.DateLiteral = DateLiteral;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExternalConstant = void 0;
|
|
4
|
+
const literal_js_1 = require("../abstract/literal.js");
|
|
5
|
+
class ExternalConstant extends literal_js_1.Literal {
|
|
6
|
+
constructor(value) {
|
|
7
|
+
super('' + value);
|
|
8
|
+
}
|
|
9
|
+
toString() {
|
|
10
|
+
return '@' + super.toString();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.ExternalConstant = ExternalConstant;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NullLiteral = void 0;
|
|
4
|
+
const literal_js_1 = require("../abstract/literal.js");
|
|
5
|
+
class NullLiteral extends literal_js_1.Literal {
|
|
6
|
+
value = null;
|
|
7
|
+
constructor() {
|
|
8
|
+
super(null);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.NullLiteral = NullLiteral;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NumberLiteral = void 0;
|
|
4
|
+
const errors_js_1 = require("../../errors.js");
|
|
5
|
+
const literal_js_1 = require("../abstract/literal.js");
|
|
6
|
+
class NumberLiteral extends literal_js_1.Literal {
|
|
7
|
+
value;
|
|
8
|
+
constructor(value) {
|
|
9
|
+
super(0);
|
|
10
|
+
if (typeof value === 'number' || typeof value === 'bigint') {
|
|
11
|
+
this.value = value;
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
// noinspection SuspiciousTypeOfGuard
|
|
16
|
+
if (typeof value === 'string') {
|
|
17
|
+
if (value.includes('.')) {
|
|
18
|
+
this.value = parseFloat(value);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const n = Number(value);
|
|
22
|
+
if ('' + n === value)
|
|
23
|
+
this.value = n;
|
|
24
|
+
else
|
|
25
|
+
this.value = BigInt(value);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
//
|
|
31
|
+
}
|
|
32
|
+
throw new errors_js_1.ValidationError(`Invalid number literal ${value}`);
|
|
33
|
+
}
|
|
34
|
+
toString() {
|
|
35
|
+
return typeof this.value === 'bigint'
|
|
36
|
+
? ('' + this.value).replace(/n$/, '')
|
|
37
|
+
: ('' + this.value);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.NumberLiteral = NumberLiteral;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QualifiedIdentifier = void 0;
|
|
4
|
+
const literal_js_1 = require("../abstract/literal.js");
|
|
5
|
+
class QualifiedIdentifier extends literal_js_1.Literal {
|
|
6
|
+
constructor(value) {
|
|
7
|
+
super('' + value);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.QualifiedIdentifier = QualifiedIdentifier;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StringLiteral = void 0;
|
|
4
|
+
const utils_js_1 = require("../../utils.js");
|
|
5
|
+
const literal_js_1 = require("../abstract/literal.js");
|
|
6
|
+
class StringLiteral extends literal_js_1.Literal {
|
|
7
|
+
constructor(value) {
|
|
8
|
+
super('' + value);
|
|
9
|
+
}
|
|
10
|
+
toString() {
|
|
11
|
+
return (0, utils_js_1.quoteFilterString)(this.value);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.StringLiteral = StringLiteral;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TimeLiteral = void 0;
|
|
4
|
+
const errors_js_1 = require("../../errors.js");
|
|
5
|
+
const utils_js_1 = require("../../utils.js");
|
|
6
|
+
const literal_js_1 = require("../abstract/literal.js");
|
|
7
|
+
const TIME_PATTERN = /^([01]\d|2[0-3]):([0-5]\d)(:[0-5]\d)?(\.(\d+))?$/;
|
|
8
|
+
class TimeLiteral extends literal_js_1.Literal {
|
|
9
|
+
value;
|
|
10
|
+
constructor(value) {
|
|
11
|
+
super('');
|
|
12
|
+
if (value instanceof Date) {
|
|
13
|
+
this.value = pad(value.getHours()) + ':' +
|
|
14
|
+
pad(value.getMinutes()) +
|
|
15
|
+
(value.getSeconds() ? ':' + pad(value.getSeconds()) : '') +
|
|
16
|
+
(value.getMilliseconds() ? '.' + pad(value.getMilliseconds()) : '');
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
// noinspection SuspiciousTypeOfGuard
|
|
20
|
+
if (typeof value === 'string' && TIME_PATTERN.test(value)) {
|
|
21
|
+
this.value = value;
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
throw new errors_js_1.ValidationError(`Invalid time value "${value}"`);
|
|
25
|
+
}
|
|
26
|
+
toString() {
|
|
27
|
+
return (0, utils_js_1.quoteFilterString)(this.value);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.TimeLiteral = TimeLiteral;
|
|
31
|
+
function pad(n) {
|
|
32
|
+
return n <= 9 ? '0' + n : '' + n;
|
|
33
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.$arithmetic = exports.$paren = exports.$notILike = exports.$ilike = exports.$notLike = exports.$like = exports.$notIn = exports.$in = exports.$lte = exports.$lt = exports.$gte = exports.$gt = exports.$ne = exports.$eq = exports.$field = exports.$array = exports.$number = exports.$time = exports.$date = exports.$and = exports.$or = void 0;
|
|
4
|
+
const index_js_1 = require("./ast/index.js");
|
|
5
|
+
function $or(...items) {
|
|
6
|
+
return new index_js_1.LogicalExpression({ op: 'or', items });
|
|
7
|
+
}
|
|
8
|
+
exports.$or = $or;
|
|
9
|
+
function $and(...items) {
|
|
10
|
+
return new index_js_1.LogicalExpression({ op: 'and', items });
|
|
11
|
+
}
|
|
12
|
+
exports.$and = $and;
|
|
13
|
+
function $date(v) {
|
|
14
|
+
return new index_js_1.DateLiteral(v);
|
|
15
|
+
}
|
|
16
|
+
exports.$date = $date;
|
|
17
|
+
function $time(v) {
|
|
18
|
+
return new index_js_1.TimeLiteral(v);
|
|
19
|
+
}
|
|
20
|
+
exports.$time = $time;
|
|
21
|
+
function $number(v) {
|
|
22
|
+
return new index_js_1.NumberLiteral(v);
|
|
23
|
+
}
|
|
24
|
+
exports.$number = $number;
|
|
25
|
+
function $array(...items) {
|
|
26
|
+
return new index_js_1.ArrayExpression(items.map(wrapEntryValue));
|
|
27
|
+
}
|
|
28
|
+
exports.$array = $array;
|
|
29
|
+
function $field(v) {
|
|
30
|
+
return new index_js_1.QualifiedIdentifier(v);
|
|
31
|
+
}
|
|
32
|
+
exports.$field = $field;
|
|
33
|
+
function $eq(left, right) {
|
|
34
|
+
return comparisonExpression('=', left, right);
|
|
35
|
+
}
|
|
36
|
+
exports.$eq = $eq;
|
|
37
|
+
function $ne(left, right) {
|
|
38
|
+
return comparisonExpression('!=', left, right);
|
|
39
|
+
}
|
|
40
|
+
exports.$ne = $ne;
|
|
41
|
+
function $gt(left, right) {
|
|
42
|
+
return comparisonExpression('>', left, right);
|
|
43
|
+
}
|
|
44
|
+
exports.$gt = $gt;
|
|
45
|
+
function $gte(left, right) {
|
|
46
|
+
return comparisonExpression('>=', left, right);
|
|
47
|
+
}
|
|
48
|
+
exports.$gte = $gte;
|
|
49
|
+
function $lt(left, right) {
|
|
50
|
+
return comparisonExpression('<', left, right);
|
|
51
|
+
}
|
|
52
|
+
exports.$lt = $lt;
|
|
53
|
+
function $lte(left, right) {
|
|
54
|
+
return comparisonExpression('<=', left, right);
|
|
55
|
+
}
|
|
56
|
+
exports.$lte = $lte;
|
|
57
|
+
function $in(left, right) {
|
|
58
|
+
return comparisonExpression('in', left, right);
|
|
59
|
+
}
|
|
60
|
+
exports.$in = $in;
|
|
61
|
+
function $notIn(left, right) {
|
|
62
|
+
return comparisonExpression('!in', left, right);
|
|
63
|
+
}
|
|
64
|
+
exports.$notIn = $notIn;
|
|
65
|
+
function $like(left, right) {
|
|
66
|
+
return comparisonExpression('like', left, right);
|
|
67
|
+
}
|
|
68
|
+
exports.$like = $like;
|
|
69
|
+
function $notLike(left, right) {
|
|
70
|
+
return comparisonExpression('!like', left, right);
|
|
71
|
+
}
|
|
72
|
+
exports.$notLike = $notLike;
|
|
73
|
+
function $ilike(left, right) {
|
|
74
|
+
return comparisonExpression('ilike', left, right);
|
|
75
|
+
}
|
|
76
|
+
exports.$ilike = $ilike;
|
|
77
|
+
function $notILike(left, right) {
|
|
78
|
+
return comparisonExpression('!ilike', left, right);
|
|
79
|
+
}
|
|
80
|
+
exports.$notILike = $notILike;
|
|
81
|
+
function $paren(expression) {
|
|
82
|
+
return new index_js_1.ParenthesesExpression(expression);
|
|
83
|
+
}
|
|
84
|
+
exports.$paren = $paren;
|
|
85
|
+
function $arithmetic(n) {
|
|
86
|
+
const exp = new index_js_1.ArithmeticExpression();
|
|
87
|
+
exp.add = (expression) => {
|
|
88
|
+
exp.append('+', _wrapEntryValue(expression));
|
|
89
|
+
return exp;
|
|
90
|
+
};
|
|
91
|
+
exp.sub = (expression) => {
|
|
92
|
+
exp.append('-', _wrapEntryValue(expression));
|
|
93
|
+
return exp;
|
|
94
|
+
};
|
|
95
|
+
exp.mul = (expression) => {
|
|
96
|
+
exp.append('*', _wrapEntryValue(expression));
|
|
97
|
+
return exp;
|
|
98
|
+
};
|
|
99
|
+
exp.div = (expression) => {
|
|
100
|
+
exp.append('/', _wrapEntryValue(expression));
|
|
101
|
+
return exp;
|
|
102
|
+
};
|
|
103
|
+
exp.append('+', wrapEntryValue(n));
|
|
104
|
+
return exp;
|
|
105
|
+
}
|
|
106
|
+
exports.$arithmetic = $arithmetic;
|
|
107
|
+
function comparisonExpression(op, left, right) {
|
|
108
|
+
const lex = wrapEntryValue(left);
|
|
109
|
+
const rex = wrapEntryValue(right);
|
|
110
|
+
return new index_js_1.ComparisonExpression({ op, left: lex, right: rex });
|
|
111
|
+
}
|
|
112
|
+
const wrapEntryValue = (v) => {
|
|
113
|
+
return Array.isArray(v)
|
|
114
|
+
? $array(...v.map(_wrapEntryValue))
|
|
115
|
+
: _wrapEntryValue(v);
|
|
116
|
+
};
|
|
117
|
+
const _wrapEntryValue = (v) => {
|
|
118
|
+
if (v instanceof index_js_1.Expression)
|
|
119
|
+
return v;
|
|
120
|
+
if (typeof v === 'boolean')
|
|
121
|
+
return new index_js_1.BooleanLiteral(v);
|
|
122
|
+
if (typeof v === 'number' || typeof v === 'bigint')
|
|
123
|
+
return new index_js_1.NumberLiteral(v);
|
|
124
|
+
if (v == null)
|
|
125
|
+
return new index_js_1.NullLiteral();
|
|
126
|
+
if (v instanceof Date)
|
|
127
|
+
return new index_js_1.DateLiteral(v);
|
|
128
|
+
return new index_js_1.StringLiteral('' + v);
|
|
129
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ErrorListener = void 0;
|
|
4
|
+
const errors_js_1 = require("./errors.js");
|
|
5
|
+
class ErrorListener {
|
|
6
|
+
errors;
|
|
7
|
+
constructor(errors) {
|
|
8
|
+
this.errors = errors;
|
|
9
|
+
}
|
|
10
|
+
syntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e) {
|
|
11
|
+
this.errors.push(new errors_js_1.FilterParseError(msg, { recognizer, offendingSymbol, line, charPositionInLine, e }));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.ErrorListener = ErrorListener;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FilterParseError = exports.ValidationError = exports.SyntaxError = void 0;
|
|
4
|
+
class SyntaxError extends TypeError {
|
|
5
|
+
}
|
|
6
|
+
exports.SyntaxError = SyntaxError;
|
|
7
|
+
class ValidationError extends TypeError {
|
|
8
|
+
}
|
|
9
|
+
exports.ValidationError = ValidationError;
|
|
10
|
+
class FilterParseError extends Error {
|
|
11
|
+
recognizer;
|
|
12
|
+
offendingSymbol;
|
|
13
|
+
line;
|
|
14
|
+
charPositionInLine;
|
|
15
|
+
e;
|
|
16
|
+
constructor(message, args) {
|
|
17
|
+
super(message);
|
|
18
|
+
Object.assign(this, args);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.FilterParseError = FilterParseError;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FilterTreeVisitor = void 0;
|
|
4
|
+
const index_js_1 = require("antlr4ts/tree/index.js");
|
|
5
|
+
const OpraFilterParser_js_1 = require("./antlr/OpraFilterParser.js");
|
|
6
|
+
const index_js_2 = require("./ast/index.js");
|
|
7
|
+
const external_constant_js_1 = require("./ast/terms/external-constant.js");
|
|
8
|
+
const errors_js_1 = require("./errors.js");
|
|
9
|
+
const utils_js_1 = require("./utils.js");
|
|
10
|
+
class FilterTreeVisitor extends index_js_1.AbstractParseTreeVisitor {
|
|
11
|
+
_timeZone;
|
|
12
|
+
constructor(options) {
|
|
13
|
+
super();
|
|
14
|
+
this._timeZone = options?.timeZone;
|
|
15
|
+
}
|
|
16
|
+
defaultResult() {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
visitRoot(ctx) {
|
|
20
|
+
return this.visit(ctx.expression());
|
|
21
|
+
}
|
|
22
|
+
visitIdentifier(ctx) {
|
|
23
|
+
return ctx.text;
|
|
24
|
+
}
|
|
25
|
+
visitNullLiteral() {
|
|
26
|
+
return new index_js_2.NullLiteral();
|
|
27
|
+
}
|
|
28
|
+
visitBooleanLiteral(ctx) {
|
|
29
|
+
return new index_js_2.BooleanLiteral(ctx.text === 'true');
|
|
30
|
+
}
|
|
31
|
+
visitNumberLiteral(ctx) {
|
|
32
|
+
return new index_js_2.NumberLiteral(ctx.text);
|
|
33
|
+
}
|
|
34
|
+
visitStringLiteral(ctx) {
|
|
35
|
+
return new index_js_2.StringLiteral((0, utils_js_1.unquoteFilterString)(ctx.text));
|
|
36
|
+
}
|
|
37
|
+
visitInfinityLiteral() {
|
|
38
|
+
return new index_js_2.NumberLiteral(Infinity);
|
|
39
|
+
}
|
|
40
|
+
visitDateLiteral(ctx) {
|
|
41
|
+
return new index_js_2.DateLiteral((0, utils_js_1.unquoteFilterString)(ctx.text));
|
|
42
|
+
}
|
|
43
|
+
visitDateTimeLiteral(ctx) {
|
|
44
|
+
return new index_js_2.DateLiteral((0, utils_js_1.unquoteFilterString)(ctx.text));
|
|
45
|
+
}
|
|
46
|
+
visitTimeLiteral(ctx) {
|
|
47
|
+
return new index_js_2.TimeLiteral((0, utils_js_1.unquoteFilterString)(ctx.text));
|
|
48
|
+
}
|
|
49
|
+
visitQualifiedIdentifierTerm(ctx) {
|
|
50
|
+
return new index_js_2.QualifiedIdentifier(ctx.text);
|
|
51
|
+
}
|
|
52
|
+
visitPolarityExpression(ctx) {
|
|
53
|
+
const x = this.visit(ctx.expression());
|
|
54
|
+
if (x.kind === 'NumberLiteral') {
|
|
55
|
+
if (ctx.polarOp().text === '-')
|
|
56
|
+
x.value *= -1;
|
|
57
|
+
return x;
|
|
58
|
+
}
|
|
59
|
+
throw new errors_js_1.SyntaxError('Unexpected token "' + ctx.text + '"');
|
|
60
|
+
}
|
|
61
|
+
visitExternalConstantTerm(ctx) {
|
|
62
|
+
return new external_constant_js_1.ExternalConstant(ctx.externalConstant().text.substring(1));
|
|
63
|
+
}
|
|
64
|
+
visitParenthesizedExpression(ctx) {
|
|
65
|
+
const expression = this.visit(ctx.expression());
|
|
66
|
+
return new index_js_2.ParenthesesExpression(expression);
|
|
67
|
+
}
|
|
68
|
+
visitArrayExpression(ctx) {
|
|
69
|
+
return new index_js_2.ArrayExpression(ctx.expression().map(child => this.visit(child)));
|
|
70
|
+
}
|
|
71
|
+
visitComparisonExpression(ctx) {
|
|
72
|
+
return new index_js_2.ComparisonExpression({
|
|
73
|
+
op: ctx.compOp().text,
|
|
74
|
+
left: this.visit(ctx.expression(0)),
|
|
75
|
+
right: this.visit(ctx.expression(1))
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
visitLogicalExpression(ctx) {
|
|
79
|
+
const items = [];
|
|
80
|
+
const wrapChildren = (arr, op) => {
|
|
81
|
+
for (const c of arr) {
|
|
82
|
+
if (c instanceof OpraFilterParser_js_1.LogicalExpressionContext && c.logOp().text === op) {
|
|
83
|
+
wrapChildren(c.expression(), c.logOp().text);
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const o = this.visit(c);
|
|
87
|
+
items.push(o);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
wrapChildren(ctx.expression(), ctx.logOp().text);
|
|
91
|
+
return new index_js_2.LogicalExpression({
|
|
92
|
+
op: ctx.logOp().text,
|
|
93
|
+
items
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
visitArithmeticExpression(ctx) {
|
|
97
|
+
const exp = new index_js_2.ArithmeticExpression();
|
|
98
|
+
const wrapChildren = (children, op) => {
|
|
99
|
+
for (let i = 0, len = children.length; i < len; i++) {
|
|
100
|
+
const child = children[i];
|
|
101
|
+
if (child instanceof OpraFilterParser_js_1.ArithmeticExpressionContext) {
|
|
102
|
+
wrapChildren(child.expression(), child.arthOp().text);
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
const value = this.visit(child);
|
|
106
|
+
exp.append(op || '+', value);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
wrapChildren(ctx.expression(), ctx.arthOp().text);
|
|
110
|
+
return exp;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
exports.FilterTreeVisitor = FilterTreeVisitor;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./ast/index.js"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./parse.js"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./build.js"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./error-listener.js"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./filter-tree-visitor.js"), exports);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseFilter = void 0;
|
|
4
|
+
const antlr4ts_1 = require("antlr4ts");
|
|
5
|
+
const OpraFilterLexer_js_1 = require("./antlr/OpraFilterLexer.js");
|
|
6
|
+
const OpraFilterParser_js_1 = require("./antlr/OpraFilterParser.js");
|
|
7
|
+
const error_listener_js_1 = require("./error-listener.js");
|
|
8
|
+
const errors_js_1 = require("./errors.js");
|
|
9
|
+
const filter_tree_visitor_js_1 = require("./filter-tree-visitor.js");
|
|
10
|
+
function parseFilter(text, visitor) {
|
|
11
|
+
const inputStream = antlr4ts_1.CharStreams.fromString(text);
|
|
12
|
+
const lexer = new OpraFilterLexer_js_1.OpraFilterLexer(inputStream);
|
|
13
|
+
const tokenStream = new antlr4ts_1.CommonTokenStream(lexer);
|
|
14
|
+
const parser = new OpraFilterParser_js_1.OpraFilterParser(tokenStream);
|
|
15
|
+
parser.buildParseTree = true;
|
|
16
|
+
const errors = [];
|
|
17
|
+
const errorListener = new error_listener_js_1.ErrorListener(errors);
|
|
18
|
+
lexer.removeErrorListeners();
|
|
19
|
+
lexer.addErrorListener(errorListener);
|
|
20
|
+
parser.removeErrorListeners();
|
|
21
|
+
parser.addErrorListener(errorListener);
|
|
22
|
+
const tree = parser.root();
|
|
23
|
+
visitor = visitor || new filter_tree_visitor_js_1.FilterTreeVisitor();
|
|
24
|
+
const result = visitor.visit(tree);
|
|
25
|
+
if (errors.length) {
|
|
26
|
+
const errMsgs = [];
|
|
27
|
+
for (const err of errors) {
|
|
28
|
+
errMsgs.push(err.message +
|
|
29
|
+
' at (' + 'line: ' + err.line + ' column: ' + err.charPositionInLine + ')');
|
|
30
|
+
}
|
|
31
|
+
const e = new errors_js_1.SyntaxError(errMsgs.join('\n'));
|
|
32
|
+
e.errors = errors;
|
|
33
|
+
throw e;
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
exports.parseFilter = parseFilter;
|