@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,10 @@
|
|
|
1
|
+
import { quoteFilterString } from '../../utils.js';
|
|
2
|
+
import { Literal } from '../abstract/literal.js';
|
|
3
|
+
export class StringLiteral extends Literal {
|
|
4
|
+
constructor(value) {
|
|
5
|
+
super('' + value);
|
|
6
|
+
}
|
|
7
|
+
toString() {
|
|
8
|
+
return quoteFilterString(this.value);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ValidationError } from '../../errors.js';
|
|
2
|
+
import { quoteFilterString } from '../../utils.js';
|
|
3
|
+
import { Literal } from '../abstract/literal.js';
|
|
4
|
+
const TIME_PATTERN = /^([01]\d|2[0-3]):([0-5]\d)(:[0-5]\d)?(\.(\d+))?$/;
|
|
5
|
+
export class TimeLiteral extends Literal {
|
|
6
|
+
value;
|
|
7
|
+
constructor(value) {
|
|
8
|
+
super('');
|
|
9
|
+
if (value instanceof Date) {
|
|
10
|
+
this.value = pad(value.getHours()) + ':' +
|
|
11
|
+
pad(value.getMinutes()) +
|
|
12
|
+
(value.getSeconds() ? ':' + pad(value.getSeconds()) : '') +
|
|
13
|
+
(value.getMilliseconds() ? '.' + pad(value.getMilliseconds()) : '');
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
// noinspection SuspiciousTypeOfGuard
|
|
17
|
+
if (typeof value === 'string' && TIME_PATTERN.test(value)) {
|
|
18
|
+
this.value = value;
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
throw new ValidationError(`Invalid time value "${value}"`);
|
|
22
|
+
}
|
|
23
|
+
toString() {
|
|
24
|
+
return quoteFilterString(this.value);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function pad(n) {
|
|
28
|
+
return n <= 9 ? '0' + n : '' + n;
|
|
29
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ArithmeticExpression, ArrayExpression, ComparisonExpression, DateLiteral, Expression, LogicalExpression, NumberLiteral, ParenthesesExpression, QualifiedIdentifier, TimeLiteral } from './ast/index.js';
|
|
2
|
+
declare type _EntryValue = Expression | string | number | bigint | boolean | null | Date;
|
|
3
|
+
export declare type EntryValue = _EntryValue | _EntryValue[];
|
|
4
|
+
export declare function $or(...items: Expression[]): LogicalExpression;
|
|
5
|
+
export declare function $and(...items: Expression[]): LogicalExpression;
|
|
6
|
+
export declare function $date(v: string): DateLiteral;
|
|
7
|
+
export declare function $time(v: string): TimeLiteral;
|
|
8
|
+
export declare function $number(v: string | number | bigint): NumberLiteral;
|
|
9
|
+
export declare function $array(...items: EntryValue[]): ArrayExpression;
|
|
10
|
+
export declare function $field(v: string): QualifiedIdentifier;
|
|
11
|
+
export declare function $eq(left: EntryValue, right: EntryValue): ComparisonExpression;
|
|
12
|
+
export declare function $ne(left: EntryValue, right: EntryValue): ComparisonExpression;
|
|
13
|
+
export declare function $gt(left: EntryValue, right: EntryValue): ComparisonExpression;
|
|
14
|
+
export declare function $gte(left: EntryValue, right: EntryValue): ComparisonExpression;
|
|
15
|
+
export declare function $lt(left: EntryValue, right: EntryValue): ComparisonExpression;
|
|
16
|
+
export declare function $lte(left: EntryValue, right: EntryValue): ComparisonExpression;
|
|
17
|
+
export declare function $in(left: EntryValue, right: EntryValue): ComparisonExpression;
|
|
18
|
+
export declare function $notIn(left: EntryValue, right: EntryValue): ComparisonExpression;
|
|
19
|
+
export declare function $like(left: EntryValue, right: EntryValue): ComparisonExpression;
|
|
20
|
+
export declare function $notLike(left: _EntryValue, right: _EntryValue): ComparisonExpression;
|
|
21
|
+
export declare function $ilike(left: _EntryValue, right: _EntryValue): ComparisonExpression;
|
|
22
|
+
export declare function $notILike(left: _EntryValue, right: _EntryValue): ComparisonExpression;
|
|
23
|
+
export declare function $paren(expression: Expression): ParenthesesExpression;
|
|
24
|
+
declare type MathExpression = ArithmeticExpression & {
|
|
25
|
+
add(expression: EntryValue): MathExpression;
|
|
26
|
+
sub(expression: EntryValue): MathExpression;
|
|
27
|
+
mul(expression: EntryValue): MathExpression;
|
|
28
|
+
div(expression: EntryValue): MathExpression;
|
|
29
|
+
};
|
|
30
|
+
export declare function $arithmetic(n: EntryValue): MathExpression;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { ArithmeticExpression, ArrayExpression, BooleanLiteral, ComparisonExpression, DateLiteral, Expression, LogicalExpression, NullLiteral, NumberLiteral, ParenthesesExpression, QualifiedIdentifier, StringLiteral, TimeLiteral } from './ast/index.js';
|
|
2
|
+
export function $or(...items) {
|
|
3
|
+
return new LogicalExpression({ op: 'or', items });
|
|
4
|
+
}
|
|
5
|
+
export function $and(...items) {
|
|
6
|
+
return new LogicalExpression({ op: 'and', items });
|
|
7
|
+
}
|
|
8
|
+
export function $date(v) {
|
|
9
|
+
return new DateLiteral(v);
|
|
10
|
+
}
|
|
11
|
+
export function $time(v) {
|
|
12
|
+
return new TimeLiteral(v);
|
|
13
|
+
}
|
|
14
|
+
export function $number(v) {
|
|
15
|
+
return new NumberLiteral(v);
|
|
16
|
+
}
|
|
17
|
+
export function $array(...items) {
|
|
18
|
+
return new ArrayExpression(items.map(wrapEntryValue));
|
|
19
|
+
}
|
|
20
|
+
export function $field(v) {
|
|
21
|
+
return new QualifiedIdentifier(v);
|
|
22
|
+
}
|
|
23
|
+
export function $eq(left, right) {
|
|
24
|
+
return comparisonExpression('=', left, right);
|
|
25
|
+
}
|
|
26
|
+
export function $ne(left, right) {
|
|
27
|
+
return comparisonExpression('!=', left, right);
|
|
28
|
+
}
|
|
29
|
+
export function $gt(left, right) {
|
|
30
|
+
return comparisonExpression('>', left, right);
|
|
31
|
+
}
|
|
32
|
+
export function $gte(left, right) {
|
|
33
|
+
return comparisonExpression('>=', left, right);
|
|
34
|
+
}
|
|
35
|
+
export function $lt(left, right) {
|
|
36
|
+
return comparisonExpression('<', left, right);
|
|
37
|
+
}
|
|
38
|
+
export function $lte(left, right) {
|
|
39
|
+
return comparisonExpression('<=', left, right);
|
|
40
|
+
}
|
|
41
|
+
export function $in(left, right) {
|
|
42
|
+
return comparisonExpression('in', left, right);
|
|
43
|
+
}
|
|
44
|
+
export function $notIn(left, right) {
|
|
45
|
+
return comparisonExpression('!in', left, right);
|
|
46
|
+
}
|
|
47
|
+
export function $like(left, right) {
|
|
48
|
+
return comparisonExpression('like', left, right);
|
|
49
|
+
}
|
|
50
|
+
export function $notLike(left, right) {
|
|
51
|
+
return comparisonExpression('!like', left, right);
|
|
52
|
+
}
|
|
53
|
+
export function $ilike(left, right) {
|
|
54
|
+
return comparisonExpression('ilike', left, right);
|
|
55
|
+
}
|
|
56
|
+
export function $notILike(left, right) {
|
|
57
|
+
return comparisonExpression('!ilike', left, right);
|
|
58
|
+
}
|
|
59
|
+
export function $paren(expression) {
|
|
60
|
+
return new ParenthesesExpression(expression);
|
|
61
|
+
}
|
|
62
|
+
export function $arithmetic(n) {
|
|
63
|
+
const exp = new ArithmeticExpression();
|
|
64
|
+
exp.add = (expression) => {
|
|
65
|
+
exp.append('+', _wrapEntryValue(expression));
|
|
66
|
+
return exp;
|
|
67
|
+
};
|
|
68
|
+
exp.sub = (expression) => {
|
|
69
|
+
exp.append('-', _wrapEntryValue(expression));
|
|
70
|
+
return exp;
|
|
71
|
+
};
|
|
72
|
+
exp.mul = (expression) => {
|
|
73
|
+
exp.append('*', _wrapEntryValue(expression));
|
|
74
|
+
return exp;
|
|
75
|
+
};
|
|
76
|
+
exp.div = (expression) => {
|
|
77
|
+
exp.append('/', _wrapEntryValue(expression));
|
|
78
|
+
return exp;
|
|
79
|
+
};
|
|
80
|
+
exp.append('+', wrapEntryValue(n));
|
|
81
|
+
return exp;
|
|
82
|
+
}
|
|
83
|
+
function comparisonExpression(op, left, right) {
|
|
84
|
+
const lex = wrapEntryValue(left);
|
|
85
|
+
const rex = wrapEntryValue(right);
|
|
86
|
+
return new ComparisonExpression({ op, left: lex, right: rex });
|
|
87
|
+
}
|
|
88
|
+
const wrapEntryValue = (v) => {
|
|
89
|
+
return Array.isArray(v)
|
|
90
|
+
? $array(...v.map(_wrapEntryValue))
|
|
91
|
+
: _wrapEntryValue(v);
|
|
92
|
+
};
|
|
93
|
+
const _wrapEntryValue = (v) => {
|
|
94
|
+
if (v instanceof Expression)
|
|
95
|
+
return v;
|
|
96
|
+
if (typeof v === 'boolean')
|
|
97
|
+
return new BooleanLiteral(v);
|
|
98
|
+
if (typeof v === 'number' || typeof v === 'bigint')
|
|
99
|
+
return new NumberLiteral(v);
|
|
100
|
+
if (v == null)
|
|
101
|
+
return new NullLiteral();
|
|
102
|
+
if (v instanceof Date)
|
|
103
|
+
return new DateLiteral(v);
|
|
104
|
+
return new StringLiteral('' + v);
|
|
105
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ANTLRErrorListener, Recognizer } from 'antlr4ts';
|
|
2
|
+
import { RecognitionException } from 'antlr4ts/RecognitionException';
|
|
3
|
+
import { FilterParseError } from './errors.js';
|
|
4
|
+
export declare class ErrorListener implements ANTLRErrorListener<any> {
|
|
5
|
+
errors: FilterParseError[];
|
|
6
|
+
constructor(errors: FilterParseError[]);
|
|
7
|
+
syntaxError<T>(recognizer: Recognizer<T, any>, offendingSymbol: T | undefined, line: number, charPositionInLine: number, msg: string, e: RecognitionException | undefined): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FilterParseError } from './errors.js';
|
|
2
|
+
export class ErrorListener {
|
|
3
|
+
errors;
|
|
4
|
+
constructor(errors) {
|
|
5
|
+
this.errors = errors;
|
|
6
|
+
}
|
|
7
|
+
syntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e) {
|
|
8
|
+
this.errors.push(new FilterParseError(msg, { recognizer, offendingSymbol, line, charPositionInLine, e }));
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Recognizer } from 'antlr4ts';
|
|
2
|
+
import { RecognitionException } from 'antlr4ts/RecognitionException';
|
|
3
|
+
export declare class SyntaxError extends TypeError {
|
|
4
|
+
}
|
|
5
|
+
export declare class ValidationError extends TypeError {
|
|
6
|
+
}
|
|
7
|
+
export declare class FilterParseError extends Error {
|
|
8
|
+
recognizer: Recognizer<any, any>;
|
|
9
|
+
offendingSymbol: any | undefined;
|
|
10
|
+
line: number;
|
|
11
|
+
charPositionInLine: number;
|
|
12
|
+
e: RecognitionException | undefined;
|
|
13
|
+
constructor(message: string, args: {
|
|
14
|
+
recognizer: Recognizer<any, any>;
|
|
15
|
+
offendingSymbol: any | undefined;
|
|
16
|
+
line: number;
|
|
17
|
+
charPositionInLine: number;
|
|
18
|
+
e: RecognitionException | undefined;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class SyntaxError extends TypeError {
|
|
2
|
+
}
|
|
3
|
+
export class ValidationError extends TypeError {
|
|
4
|
+
}
|
|
5
|
+
export class FilterParseError extends Error {
|
|
6
|
+
recognizer;
|
|
7
|
+
offendingSymbol;
|
|
8
|
+
line;
|
|
9
|
+
charPositionInLine;
|
|
10
|
+
e;
|
|
11
|
+
constructor(message, args) {
|
|
12
|
+
super(message);
|
|
13
|
+
Object.assign(this, args);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AbstractParseTreeVisitor } from 'antlr4ts/tree/index.js';
|
|
2
|
+
import { ArithmeticExpressionContext, ArrayExpressionContext, BooleanLiteralContext, ComparisonExpressionContext, DateLiteralContext, DateTimeLiteralContext, ExternalConstantTermContext, IdentifierContext, LogicalExpressionContext, NumberLiteralContext, ParenthesizedExpressionContext, PolarityExpressionContext, QualifiedIdentifierTermContext, RootContext, StringLiteralContext, TimeLiteralContext } from './antlr/OpraFilterParser.js';
|
|
3
|
+
import { OpraFilterVisitor } from './antlr/OpraFilterVisitor.js';
|
|
4
|
+
import { ArithmeticExpression, ArrayExpression, BooleanLiteral, DateLiteral, LogicalExpression, NullLiteral, NumberLiteral, ParenthesesExpression, QualifiedIdentifier, StringLiteral, TimeLiteral } from './ast/index.js';
|
|
5
|
+
import { ExternalConstant } from './ast/terms/external-constant.js';
|
|
6
|
+
export declare class FilterTreeVisitor extends AbstractParseTreeVisitor<any> implements OpraFilterVisitor<any> {
|
|
7
|
+
private _timeZone?;
|
|
8
|
+
constructor(options?: {
|
|
9
|
+
timeZone?: string;
|
|
10
|
+
});
|
|
11
|
+
protected defaultResult(): any;
|
|
12
|
+
visitRoot(ctx: RootContext): any;
|
|
13
|
+
visitIdentifier(ctx: IdentifierContext): string;
|
|
14
|
+
visitNullLiteral(): NullLiteral;
|
|
15
|
+
visitBooleanLiteral(ctx: BooleanLiteralContext): BooleanLiteral;
|
|
16
|
+
visitNumberLiteral(ctx: NumberLiteralContext): NumberLiteral;
|
|
17
|
+
visitStringLiteral(ctx: StringLiteralContext): StringLiteral;
|
|
18
|
+
visitInfinityLiteral(): NumberLiteral;
|
|
19
|
+
visitDateLiteral(ctx: DateLiteralContext): DateLiteral;
|
|
20
|
+
visitDateTimeLiteral(ctx: DateTimeLiteralContext): DateLiteral;
|
|
21
|
+
visitTimeLiteral(ctx: TimeLiteralContext): TimeLiteral;
|
|
22
|
+
visitQualifiedIdentifierTerm(ctx: QualifiedIdentifierTermContext): QualifiedIdentifier;
|
|
23
|
+
visitPolarityExpression(ctx: PolarityExpressionContext): any;
|
|
24
|
+
visitExternalConstantTerm(ctx: ExternalConstantTermContext): ExternalConstant;
|
|
25
|
+
visitParenthesizedExpression(ctx: ParenthesizedExpressionContext): ParenthesesExpression;
|
|
26
|
+
visitArrayExpression(ctx: ArrayExpressionContext): ArrayExpression;
|
|
27
|
+
visitComparisonExpression(ctx: ComparisonExpressionContext): any;
|
|
28
|
+
visitLogicalExpression(ctx: LogicalExpressionContext): LogicalExpression;
|
|
29
|
+
visitArithmeticExpression(ctx: ArithmeticExpressionContext): ArithmeticExpression;
|
|
30
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { AbstractParseTreeVisitor } from 'antlr4ts/tree/index.js';
|
|
2
|
+
import { ArithmeticExpressionContext, LogicalExpressionContext, } from './antlr/OpraFilterParser.js';
|
|
3
|
+
import { ArithmeticExpression, ArrayExpression, BooleanLiteral, ComparisonExpression, DateLiteral, LogicalExpression, NullLiteral, NumberLiteral, ParenthesesExpression, QualifiedIdentifier, StringLiteral, TimeLiteral } from './ast/index.js';
|
|
4
|
+
import { ExternalConstant } from './ast/terms/external-constant.js';
|
|
5
|
+
import { SyntaxError } from './errors.js';
|
|
6
|
+
import { unquoteFilterString } from './utils.js';
|
|
7
|
+
export class FilterTreeVisitor extends AbstractParseTreeVisitor {
|
|
8
|
+
_timeZone;
|
|
9
|
+
constructor(options) {
|
|
10
|
+
super();
|
|
11
|
+
this._timeZone = options?.timeZone;
|
|
12
|
+
}
|
|
13
|
+
defaultResult() {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
visitRoot(ctx) {
|
|
17
|
+
return this.visit(ctx.expression());
|
|
18
|
+
}
|
|
19
|
+
visitIdentifier(ctx) {
|
|
20
|
+
return ctx.text;
|
|
21
|
+
}
|
|
22
|
+
visitNullLiteral() {
|
|
23
|
+
return new NullLiteral();
|
|
24
|
+
}
|
|
25
|
+
visitBooleanLiteral(ctx) {
|
|
26
|
+
return new BooleanLiteral(ctx.text === 'true');
|
|
27
|
+
}
|
|
28
|
+
visitNumberLiteral(ctx) {
|
|
29
|
+
return new NumberLiteral(ctx.text);
|
|
30
|
+
}
|
|
31
|
+
visitStringLiteral(ctx) {
|
|
32
|
+
return new StringLiteral(unquoteFilterString(ctx.text));
|
|
33
|
+
}
|
|
34
|
+
visitInfinityLiteral() {
|
|
35
|
+
return new NumberLiteral(Infinity);
|
|
36
|
+
}
|
|
37
|
+
visitDateLiteral(ctx) {
|
|
38
|
+
return new DateLiteral(unquoteFilterString(ctx.text));
|
|
39
|
+
}
|
|
40
|
+
visitDateTimeLiteral(ctx) {
|
|
41
|
+
return new DateLiteral(unquoteFilterString(ctx.text));
|
|
42
|
+
}
|
|
43
|
+
visitTimeLiteral(ctx) {
|
|
44
|
+
return new TimeLiteral(unquoteFilterString(ctx.text));
|
|
45
|
+
}
|
|
46
|
+
visitQualifiedIdentifierTerm(ctx) {
|
|
47
|
+
return new QualifiedIdentifier(ctx.text);
|
|
48
|
+
}
|
|
49
|
+
visitPolarityExpression(ctx) {
|
|
50
|
+
const x = this.visit(ctx.expression());
|
|
51
|
+
if (x.kind === 'NumberLiteral') {
|
|
52
|
+
if (ctx.polarOp().text === '-')
|
|
53
|
+
x.value *= -1;
|
|
54
|
+
return x;
|
|
55
|
+
}
|
|
56
|
+
throw new SyntaxError('Unexpected token "' + ctx.text + '"');
|
|
57
|
+
}
|
|
58
|
+
visitExternalConstantTerm(ctx) {
|
|
59
|
+
return new ExternalConstant(ctx.externalConstant().text.substring(1));
|
|
60
|
+
}
|
|
61
|
+
visitParenthesizedExpression(ctx) {
|
|
62
|
+
const expression = this.visit(ctx.expression());
|
|
63
|
+
return new ParenthesesExpression(expression);
|
|
64
|
+
}
|
|
65
|
+
visitArrayExpression(ctx) {
|
|
66
|
+
return new ArrayExpression(ctx.expression().map(child => this.visit(child)));
|
|
67
|
+
}
|
|
68
|
+
visitComparisonExpression(ctx) {
|
|
69
|
+
return new ComparisonExpression({
|
|
70
|
+
op: ctx.compOp().text,
|
|
71
|
+
left: this.visit(ctx.expression(0)),
|
|
72
|
+
right: this.visit(ctx.expression(1))
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
visitLogicalExpression(ctx) {
|
|
76
|
+
const items = [];
|
|
77
|
+
const wrapChildren = (arr, op) => {
|
|
78
|
+
for (const c of arr) {
|
|
79
|
+
if (c instanceof LogicalExpressionContext && c.logOp().text === op) {
|
|
80
|
+
wrapChildren(c.expression(), c.logOp().text);
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
const o = this.visit(c);
|
|
84
|
+
items.push(o);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
wrapChildren(ctx.expression(), ctx.logOp().text);
|
|
88
|
+
return new LogicalExpression({
|
|
89
|
+
op: ctx.logOp().text,
|
|
90
|
+
items
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
visitArithmeticExpression(ctx) {
|
|
94
|
+
const exp = new ArithmeticExpression();
|
|
95
|
+
const wrapChildren = (children, op) => {
|
|
96
|
+
for (let i = 0, len = children.length; i < len; i++) {
|
|
97
|
+
const child = children[i];
|
|
98
|
+
if (child instanceof ArithmeticExpressionContext) {
|
|
99
|
+
wrapChildren(child.expression(), child.arthOp().text);
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const value = this.visit(child);
|
|
103
|
+
exp.append(op || '+', value);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
wrapChildren(ctx.expression(), ctx.arthOp().text);
|
|
107
|
+
return exp;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { CharStreams, CommonTokenStream } from 'antlr4ts';
|
|
2
|
+
import { OpraFilterLexer } from './antlr/OpraFilterLexer.js';
|
|
3
|
+
import { OpraFilterParser } from './antlr/OpraFilterParser.js';
|
|
4
|
+
import { ErrorListener } from './error-listener.js';
|
|
5
|
+
import { SyntaxError } from './errors.js';
|
|
6
|
+
import { FilterTreeVisitor } from './filter-tree-visitor.js';
|
|
7
|
+
export function parseFilter(text, visitor) {
|
|
8
|
+
const inputStream = CharStreams.fromString(text);
|
|
9
|
+
const lexer = new OpraFilterLexer(inputStream);
|
|
10
|
+
const tokenStream = new CommonTokenStream(lexer);
|
|
11
|
+
const parser = new OpraFilterParser(tokenStream);
|
|
12
|
+
parser.buildParseTree = true;
|
|
13
|
+
const errors = [];
|
|
14
|
+
const errorListener = new ErrorListener(errors);
|
|
15
|
+
lexer.removeErrorListeners();
|
|
16
|
+
lexer.addErrorListener(errorListener);
|
|
17
|
+
parser.removeErrorListeners();
|
|
18
|
+
parser.addErrorListener(errorListener);
|
|
19
|
+
const tree = parser.root();
|
|
20
|
+
visitor = visitor || new FilterTreeVisitor();
|
|
21
|
+
const result = visitor.visit(tree);
|
|
22
|
+
if (errors.length) {
|
|
23
|
+
const errMsgs = [];
|
|
24
|
+
for (const err of errors) {
|
|
25
|
+
errMsgs.push(err.message +
|
|
26
|
+
' at (' + 'line: ' + err.line + ' column: ' + err.charPositionInLine + ')');
|
|
27
|
+
}
|
|
28
|
+
const e = new SyntaxError(errMsgs.join('\n'));
|
|
29
|
+
e.errors = errors;
|
|
30
|
+
throw e;
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const quotesRegEx = /'/g;
|
|
2
|
+
const escapeRegEx = /(\\)/g;
|
|
3
|
+
const unescapeRegEx = /\\(.)/g;
|
|
4
|
+
function escapeString(s) {
|
|
5
|
+
return s.replace(escapeRegEx, '\\\\');
|
|
6
|
+
}
|
|
7
|
+
function unescapeString(s) {
|
|
8
|
+
return s.replace(unescapeRegEx, '$1');
|
|
9
|
+
}
|
|
10
|
+
export function quoteFilterString(s) {
|
|
11
|
+
return "'" +
|
|
12
|
+
escapeString(s).replace(quotesRegEx, '\\\'') +
|
|
13
|
+
"'";
|
|
14
|
+
}
|
|
15
|
+
export function unquoteFilterString(s) {
|
|
16
|
+
if (s && (s.startsWith("'") || s.startsWith('"')) && s.endsWith(s.charAt(0))) {
|
|
17
|
+
return unescapeString(s.substring(1, s.length - 1));
|
|
18
|
+
}
|
|
19
|
+
/* istanbul ignore next */
|
|
20
|
+
return s;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './responsive-map.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './responsive-map.js';
|
|
File without changes
|
|
@@ -6,7 +6,7 @@ export class ResponsiveMap extends Map {
|
|
|
6
6
|
super();
|
|
7
7
|
if (wellKnownKeys)
|
|
8
8
|
wellKnownKeys.forEach(k => this._wellKnownKeyMap.set(k.toLowerCase(), k));
|
|
9
|
-
if (data
|
|
9
|
+
if (typeof data?.forEach === 'function') {
|
|
10
10
|
data.forEach((v, k) => this.set(k, v));
|
|
11
11
|
}
|
|
12
12
|
else if (data && typeof data === 'object')
|
|
@@ -164,6 +164,10 @@ export declare enum HttpHeaders {
|
|
|
164
164
|
* or if it should be handled like a download and the browser should present a "Save As" dialog.
|
|
165
165
|
*/
|
|
166
166
|
Content_Disposition = "Content-Disposition",
|
|
167
|
+
/**
|
|
168
|
+
* Indicates to uniquely identifies MIME entities in several contexts.
|
|
169
|
+
*/
|
|
170
|
+
Content_ID = "Content-ID",
|
|
167
171
|
/**
|
|
168
172
|
* The size of the resource, in decimal number of bytes.
|
|
169
173
|
*/
|
|
@@ -172,6 +176,11 @@ export declare enum HttpHeaders {
|
|
|
172
176
|
* Indicates the media type of the resource.
|
|
173
177
|
*/
|
|
174
178
|
Content_Type = "Content-Type",
|
|
179
|
+
/**
|
|
180
|
+
* Indicates to specify how a MIME message or body part has been encoded,
|
|
181
|
+
* so that it can be decoded by its recipient.
|
|
182
|
+
*/
|
|
183
|
+
Content_Transfer_Encoding = "Content-Transfer-Encoding",
|
|
175
184
|
/**
|
|
176
185
|
* Used to specify the compression algorithm.
|
|
177
186
|
*/
|
|
@@ -177,6 +177,10 @@ export var HttpHeaders;
|
|
|
177
177
|
*/
|
|
178
178
|
HttpHeaders["Content_Disposition"] = "Content-Disposition";
|
|
179
179
|
/* *** Message body information *** */
|
|
180
|
+
/**
|
|
181
|
+
* Indicates to uniquely identifies MIME entities in several contexts.
|
|
182
|
+
*/
|
|
183
|
+
HttpHeaders["Content_ID"] = "Content-ID";
|
|
180
184
|
/**
|
|
181
185
|
* The size of the resource, in decimal number of bytes.
|
|
182
186
|
*/
|
|
@@ -185,6 +189,11 @@ export var HttpHeaders;
|
|
|
185
189
|
* Indicates the media type of the resource.
|
|
186
190
|
*/
|
|
187
191
|
HttpHeaders["Content_Type"] = "Content-Type";
|
|
192
|
+
/**
|
|
193
|
+
* Indicates to specify how a MIME message or body part has been encoded,
|
|
194
|
+
* so that it can be decoded by its recipient.
|
|
195
|
+
*/
|
|
196
|
+
HttpHeaders["Content_Transfer_Encoding"] = "Content-Transfer-Encoding";
|
|
188
197
|
/**
|
|
189
198
|
* Used to specify the compression algorithm.
|
|
190
199
|
*/
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { Readable } from 'stream';
|
|
4
|
+
declare const kHeaders: unique symbol;
|
|
5
|
+
declare const kHeadersCount: unique symbol;
|
|
6
|
+
declare const kTrailers: unique symbol;
|
|
7
|
+
declare const kTrailersCount: unique symbol;
|
|
8
|
+
export declare class HttpRequest extends Readable {
|
|
9
|
+
httpVersionMajor: number;
|
|
10
|
+
httpVersionMinor: number;
|
|
11
|
+
httpVersion: string;
|
|
12
|
+
complete: boolean;
|
|
13
|
+
rawHeaders: string[];
|
|
14
|
+
rawTrailers: string[];
|
|
15
|
+
aborted: boolean;
|
|
16
|
+
upgrade: boolean;
|
|
17
|
+
url: string;
|
|
18
|
+
originalUrl: string;
|
|
19
|
+
method: string;
|
|
20
|
+
shouldKeepAlive: boolean;
|
|
21
|
+
data?: Buffer;
|
|
22
|
+
body?: any;
|
|
23
|
+
[kHeaders]: Record<string, string | string[]>;
|
|
24
|
+
[kHeadersCount]: number;
|
|
25
|
+
[kTrailers]: Record<string, string | string[]>;
|
|
26
|
+
[kTrailersCount]: number;
|
|
27
|
+
get headers(): Record<string, string | string[]>;
|
|
28
|
+
get headersCount(): number;
|
|
29
|
+
get trailers(): Record<string, string | string[]>;
|
|
30
|
+
get trailersCount(): number;
|
|
31
|
+
_read(): void;
|
|
32
|
+
static parse(input: Buffer): HttpRequest;
|
|
33
|
+
}
|
|
34
|
+
export {};
|