@opra/common 1.20.0 → 1.22.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/README.md +3 -0
- package/browser.js +12 -0
- package/{esm/document → document}/api-document.js +7 -7
- package/{esm/document → document}/common/api-base.js +2 -1
- package/{esm/document → document}/common/data-type-map.js +3 -6
- package/{esm/document → document}/common/document-init-context.js +4 -3
- package/{esm/document → document}/common/document-node.js +4 -0
- package/{esm/document → document}/common/opra-document-error.js +1 -1
- package/{esm/document → document}/common/value.js +4 -0
- package/{esm/document → document}/data-type/api-field.js +1 -0
- package/{types/document → document}/data-type/array-type.d.ts +1 -1
- package/{esm/document → document}/data-type/complex-type-base.js +3 -0
- package/{esm/document → document}/data-type/complex-type.js +1 -0
- package/{esm/document → document}/data-type/extended-types/base64.type.js +1 -0
- package/{esm/document → document}/data-type/extended-types/date-time-tz.type.js +2 -0
- package/{esm/document → document}/data-type/extended-types/date-time.type.js +3 -0
- package/{esm/document → document}/data-type/extended-types/date.type.js +3 -0
- package/{esm/document → document}/data-type/extended-types/email.type.js +9 -0
- package/{esm/document → document}/data-type/extended-types/field-path.type.js +2 -0
- package/{esm/document → document}/data-type/extended-types/filter.type.js +2 -0
- package/{esm/document → document}/data-type/extended-types/partial-date.type.js +2 -0
- package/{esm/document → document}/data-type/extended-types/time.type.js +2 -0
- package/{esm/document → document}/data-type/extended-types/uuid.type.js +1 -0
- package/{esm/document → document}/data-type/mapped-type.js +4 -0
- package/{esm/document → document}/data-type/primitive-types/number.type.js +2 -0
- package/{esm/document → document}/data-type/primitive-types/string.type.js +4 -0
- package/{esm/document → document}/data-type/simple-type.js +3 -0
- package/document/decorators/ws-param.decorator.d.ts +7 -0
- package/{esm/document → document}/decorators/ws-param.decorator.js +2 -2
- package/{esm/document → document}/factory/api-document.factory.js +1 -3
- package/{esm/document → document}/factory/ws-api.factory.js +14 -3
- package/{esm/document → document}/http/http-api.js +5 -4
- package/{esm/document → document}/http/http-multipart-field.js +3 -0
- package/{esm/document → document}/http/http-operation-response.js +3 -0
- package/{esm/document → document}/http/http-request-body.js +8 -1
- package/{esm/document → document}/http/http-status-range.js +2 -2
- package/{esm/document → document}/mq/mq-api.js +5 -4
- package/{esm/document → document}/mq/mq-operation-response.js +7 -1
- package/{esm/document → document}/ws/ws-api.js +4 -4
- package/{types/document → document}/ws/ws-operation.d.ts +15 -3
- package/{esm/document → document}/ws/ws-operation.js +10 -2
- package/{esm/exception → exception}/http-errors/bad-request.error.js +1 -4
- package/{esm/exception → exception}/http-errors/conflict.error.js +1 -4
- package/{esm/exception → exception}/http-errors/failed-dependency.error.js +1 -4
- package/{esm/exception → exception}/http-errors/forbidden.error.js +1 -4
- package/{esm/exception → exception}/http-errors/internal-server.error.js +1 -4
- package/{esm/exception → exception}/http-errors/method-not-allowed.error.js +1 -4
- package/{esm/exception → exception}/http-errors/not-acceptable.error.js +1 -4
- package/{esm/exception → exception}/http-errors/not-found.error.js +1 -4
- package/{esm/exception → exception}/http-errors/resource-conflict.error.js +1 -1
- package/{esm/exception → exception}/http-errors/unauthorized.error.js +1 -4
- package/{esm/exception → exception}/http-errors/unprocessable-entity.error.js +1 -4
- package/{esm/exception → exception}/opra-exception.js +5 -1
- package/{esm/exception → exception}/opra-http-error.js +1 -0
- package/filter/antlr/OpraFilterLexer.js +425 -0
- package/filter/antlr/OpraFilterListener.js +302 -0
- package/{esm/filter → filter}/antlr/OpraFilterParser.js +218 -214
- package/filter/antlr/OpraFilterVisitor.js +185 -0
- package/{esm/filter → filter}/ast/abstract/ast.js +1 -0
- package/{esm/filter → filter}/ast/expressions/arithmetic-expression.js +3 -1
- package/{esm/filter → filter}/ast/expressions/array-expression.js +1 -0
- package/{esm/filter → filter}/ast/expressions/comparison-expression.js +4 -0
- package/{esm/filter → filter}/ast/expressions/logical-expression.js +2 -0
- package/{esm/filter → filter}/ast/expressions/negative-expression.js +1 -0
- package/{esm/filter → filter}/ast/expressions/parenthesized-expression.js +1 -0
- package/{esm/filter → filter}/ast/terms/date-literal.js +1 -0
- package/{esm/filter → filter}/ast/terms/date-time-literal.js +1 -0
- package/{esm/filter → filter}/ast/terms/null-literal.js +1 -1
- package/{esm/filter → filter}/ast/terms/number-literal.js +1 -0
- package/{esm/filter → filter}/ast/terms/time-literal.js +1 -0
- package/{esm/filter → filter}/filter-rules.js +2 -2
- package/{esm/filter → filter}/filter-tree-visitor.js +1 -0
- package/{esm/filter → filter}/opra-error-listener.js +1 -0
- package/{esm/helpers → helpers}/parse-fields-projection.js +2 -0
- package/package.json +15 -35
- package/{types/schema → schema}/ws/ws-api.interface.d.ts +4 -0
- package/browser/index.cjs +0 -12
- package/browser/index.mjs +0 -12
- package/cjs/document/api-document.js +0 -182
- package/cjs/document/common/api-base.js +0 -31
- package/cjs/document/common/data-type-map.js +0 -77
- package/cjs/document/common/document-element.js +0 -34
- package/cjs/document/common/document-init-context.js +0 -69
- package/cjs/document/common/document-node.js +0 -145
- package/cjs/document/common/opra-document-error.js +0 -15
- package/cjs/document/common/value.js +0 -39
- package/cjs/document/constants.js +0 -18
- package/cjs/document/data-type/api-field.js +0 -124
- package/cjs/document/data-type/array-type.js +0 -78
- package/cjs/document/data-type/complex-type-base.js +0 -346
- package/cjs/document/data-type/complex-type.js +0 -127
- package/cjs/document/data-type/data-type.js +0 -67
- package/cjs/document/data-type/enum-type.js +0 -128
- package/cjs/document/data-type/extended-types/base64.type.js +0 -49
- package/cjs/document/data-type/extended-types/date-time-tz.type.js +0 -63
- package/cjs/document/data-type/extended-types/date-time.type.js +0 -76
- package/cjs/document/data-type/extended-types/date.type.js +0 -74
- package/cjs/document/data-type/extended-types/email.type.js +0 -95
- package/cjs/document/data-type/extended-types/field-path.type.js +0 -65
- package/cjs/document/data-type/extended-types/filter.type.js +0 -88
- package/cjs/document/data-type/extended-types/index.js +0 -16
- package/cjs/document/data-type/extended-types/object-id.type.js +0 -31
- package/cjs/document/data-type/extended-types/operation-result.type.js +0 -67
- package/cjs/document/data-type/extended-types/partial-date.type.js +0 -85
- package/cjs/document/data-type/extended-types/time.type.js +0 -55
- package/cjs/document/data-type/extended-types/url.type.js +0 -31
- package/cjs/document/data-type/extended-types/uuid.type.js +0 -37
- package/cjs/document/data-type/mapped-type.js +0 -120
- package/cjs/document/data-type/mixin-type.js +0 -123
- package/cjs/document/data-type/omit-type.js +0 -10
- package/cjs/document/data-type/partial-type.js +0 -12
- package/cjs/document/data-type/pick-type.js +0 -10
- package/cjs/document/data-type/primitive-types/any.type.js +0 -27
- package/cjs/document/data-type/primitive-types/bigint.type.js +0 -38
- package/cjs/document/data-type/primitive-types/boolean.type.js +0 -31
- package/cjs/document/data-type/primitive-types/index.js +0 -11
- package/cjs/document/data-type/primitive-types/integer.type.js +0 -38
- package/cjs/document/data-type/primitive-types/null.type.js +0 -31
- package/cjs/document/data-type/primitive-types/number.type.js +0 -50
- package/cjs/document/data-type/primitive-types/object.type.js +0 -20
- package/cjs/document/data-type/primitive-types/string.type.js +0 -70
- package/cjs/document/data-type/required-type.js +0 -12
- package/cjs/document/data-type/simple-type.js +0 -133
- package/cjs/document/data-type/union-type.js +0 -84
- package/cjs/document/data-type/utils/create-mapped-class.js +0 -56
- package/cjs/document/data-type/utils/get-is-inherited-predicate-fn.js +0 -14
- package/cjs/document/decorators/api-field-decorator.js +0 -50
- package/cjs/document/decorators/complex-type.decorator.js +0 -31
- package/cjs/document/decorators/http-controller.decorator.js +0 -145
- package/cjs/document/decorators/http-operation-entity-create.decorator.js +0 -58
- package/cjs/document/decorators/http-operation-entity-delete-many.decorator.js +0 -41
- package/cjs/document/decorators/http-operation-entity-delete.decorator.js +0 -41
- package/cjs/document/decorators/http-operation-entity-find-many.decorator.js +0 -85
- package/cjs/document/decorators/http-operation-entity-get.decorator.js +0 -56
- package/cjs/document/decorators/http-operation-entity-replace.decorator.js +0 -56
- package/cjs/document/decorators/http-operation-entity-update-many.decorator.js +0 -50
- package/cjs/document/decorators/http-operation-entity-update.decorator.js +0 -66
- package/cjs/document/decorators/http-operation-entity.decorator.js +0 -143
- package/cjs/document/decorators/http-operation.decorator.js +0 -213
- package/cjs/document/decorators/mq-controller.decorator.js +0 -67
- package/cjs/document/decorators/mq-operation.decorator.js +0 -82
- package/cjs/document/decorators/simple-type.decorator.js +0 -67
- package/cjs/document/decorators/ws-controller.decorator.js +0 -51
- package/cjs/document/decorators/ws-operation.decorator.js +0 -42
- package/cjs/document/decorators/ws-param.decorator.js +0 -22
- package/cjs/document/factory/api-document.factory.js +0 -192
- package/cjs/document/factory/data-type.factory.js +0 -647
- package/cjs/document/factory/http-api.factory.js +0 -302
- package/cjs/document/factory/mq-api.factory.js +0 -203
- package/cjs/document/factory/ws-api.factory.js +0 -145
- package/cjs/document/http/http-api.js +0 -40
- package/cjs/document/http/http-controller.js +0 -159
- package/cjs/document/http/http-media-type.js +0 -104
- package/cjs/document/http/http-multipart-field.js +0 -32
- package/cjs/document/http/http-operation-response.js +0 -47
- package/cjs/document/http/http-operation.js +0 -126
- package/cjs/document/http/http-parameter.js +0 -57
- package/cjs/document/http/http-request-body.js +0 -27
- package/cjs/document/http/http-status-range.js +0 -45
- package/cjs/document/index.js +0 -70
- package/cjs/document/mq/mq-api.js +0 -54
- package/cjs/document/mq/mq-controller.js +0 -101
- package/cjs/document/mq/mq-header.js +0 -48
- package/cjs/document/mq/mq-operation-response.js +0 -66
- package/cjs/document/mq/mq-operation.js +0 -101
- package/cjs/document/utils/inspect.util.js +0 -7
- package/cjs/document/utils/parse-regexp.util.js +0 -21
- package/cjs/document/utils/string-compare.util.js +0 -10
- package/cjs/document/utils/test-scope-match.js +0 -15
- package/cjs/document/ws/ws-api.js +0 -52
- package/cjs/document/ws/ws-controller.js +0 -78
- package/cjs/document/ws/ws-operation.js +0 -64
- package/cjs/enums/http-headers-codes.enum.js +0 -411
- package/cjs/enums/http-status-codes.enum.js +0 -300
- package/cjs/enums/http-status-messages.js +0 -68
- package/cjs/enums/index.js +0 -7
- package/cjs/enums/mime-types.enum.js +0 -17
- package/cjs/exception/error-issue.js +0 -2
- package/cjs/exception/http-errors/bad-request.error.js +0 -23
- package/cjs/exception/http-errors/conflict.error.js +0 -22
- package/cjs/exception/http-errors/failed-dependency.error.js +0 -22
- package/cjs/exception/http-errors/forbidden.error.js +0 -25
- package/cjs/exception/http-errors/internal-server.error.js +0 -23
- package/cjs/exception/http-errors/method-not-allowed.error.js +0 -23
- package/cjs/exception/http-errors/not-acceptable.error.js +0 -23
- package/cjs/exception/http-errors/not-found.error.js +0 -26
- package/cjs/exception/http-errors/permission.error.js +0 -20
- package/cjs/exception/http-errors/resource-conflict.error.js +0 -19
- package/cjs/exception/http-errors/resource-not.available.error.js +0 -23
- package/cjs/exception/http-errors/unauthorized.error.js +0 -23
- package/cjs/exception/http-errors/unprocessable-entity.error.js +0 -23
- package/cjs/exception/index.js +0 -20
- package/cjs/exception/issue-severity.enum.js +0 -23
- package/cjs/exception/opra-exception.js +0 -70
- package/cjs/exception/opra-http-error.js +0 -25
- package/cjs/filter/antlr/OpraFilterLexer.js +0 -427
- package/cjs/filter/antlr/OpraFilterListener.js +0 -11
- package/cjs/filter/antlr/OpraFilterParser.js +0 -1851
- package/cjs/filter/antlr/OpraFilterVisitor.js +0 -14
- package/cjs/filter/ast/abstract/ast.js +0 -9
- package/cjs/filter/ast/abstract/expression.js +0 -7
- package/cjs/filter/ast/abstract/literal.js +0 -14
- package/cjs/filter/ast/abstract/term.js +0 -7
- package/cjs/filter/ast/expressions/arithmetic-expression.js +0 -29
- package/cjs/filter/ast/expressions/array-expression.js +0 -14
- package/cjs/filter/ast/expressions/comparison-expression.js +0 -15
- package/cjs/filter/ast/expressions/logical-expression.js +0 -18
- package/cjs/filter/ast/expressions/negative-expression.js +0 -14
- package/cjs/filter/ast/expressions/parenthesized-expression.js +0 -14
- package/cjs/filter/ast/index.js +0 -21
- package/cjs/filter/ast/terms/boolean-literal.js +0 -10
- package/cjs/filter/ast/terms/date-literal.js +0 -28
- package/cjs/filter/ast/terms/date-time-literal.js +0 -27
- package/cjs/filter/ast/terms/external-constant.js +0 -13
- package/cjs/filter/ast/terms/null-literal.js +0 -11
- package/cjs/filter/ast/terms/number-literal.js +0 -39
- package/cjs/filter/ast/terms/qualified-identifier.js +0 -10
- package/cjs/filter/ast/terms/string-literal.js +0 -14
- package/cjs/filter/ast/terms/time-literal.js +0 -34
- package/cjs/filter/build.js +0 -126
- package/cjs/filter/errors.js +0 -21
- package/cjs/filter/filter-rules.js +0 -150
- package/cjs/filter/filter-tree-visitor.js +0 -97
- package/cjs/filter/index.js +0 -5
- package/cjs/filter/opra-error-listener.js +0 -21
- package/cjs/filter/opra-filter.ns.js +0 -8
- package/cjs/filter/parse.js +0 -38
- package/cjs/filter/utils.js +0 -25
- package/cjs/helpers/function-utils.js +0 -15
- package/cjs/helpers/get-stack-filename.js +0 -51
- package/cjs/helpers/index.js +0 -12
- package/cjs/helpers/mixin-utils.js +0 -35
- package/cjs/helpers/object-utils.js +0 -19
- package/cjs/helpers/parse-fields-projection.js +0 -67
- package/cjs/helpers/responsive-map.js +0 -155
- package/cjs/helpers/safe-json-stringify.js +0 -16
- package/cjs/helpers/type-guards.js +0 -46
- package/cjs/i18n/i18n.js +0 -139
- package/cjs/i18n/index.js +0 -10
- package/cjs/i18n/string-utils.js +0 -12
- package/cjs/i18n/translate.js +0 -16
- package/cjs/index.js +0 -14
- package/cjs/package.json +0 -3
- package/cjs/polifils/array-find-last.js +0 -22
- package/cjs/schema/api-document.interface.js +0 -2
- package/cjs/schema/api.interface.js +0 -2
- package/cjs/schema/constants.js +0 -4
- package/cjs/schema/data-type/array-type.interface.js +0 -7
- package/cjs/schema/data-type/complex-type.interface.js +0 -7
- package/cjs/schema/data-type/data-type.interface.js +0 -2
- package/cjs/schema/data-type/enum-type.interface.js +0 -7
- package/cjs/schema/data-type/field.interface.js +0 -2
- package/cjs/schema/data-type/mapped-type.interface.js +0 -7
- package/cjs/schema/data-type/mixin-type.interface.js +0 -7
- package/cjs/schema/data-type/simple-type.interface.js +0 -7
- package/cjs/schema/data-type/union-type.interface.js +0 -7
- package/cjs/schema/data-type-container.interface.js +0 -2
- package/cjs/schema/http/http-api.interface.js +0 -2
- package/cjs/schema/http/http-controller.interface.js +0 -11
- package/cjs/schema/http/http-media-type.interface.js +0 -2
- package/cjs/schema/http/http-multipart-field.interface.js +0 -2
- package/cjs/schema/http/http-operation-response.interface.js +0 -2
- package/cjs/schema/http/http-operation.interface.js +0 -7
- package/cjs/schema/http/http-parameter.interface.js +0 -2
- package/cjs/schema/http/http-request-body.interface.js +0 -2
- package/cjs/schema/http/http-status-range.interface.js +0 -2
- package/cjs/schema/index.js +0 -6
- package/cjs/schema/mq/mq-api.interface.js +0 -2
- package/cjs/schema/mq/mq-controller.interface.js +0 -11
- package/cjs/schema/mq/mq-header.interface.js +0 -2
- package/cjs/schema/mq/mq-operation.interface.js +0 -7
- package/cjs/schema/opra-schema.js +0 -35
- package/cjs/schema/type-guards.js +0 -54
- package/cjs/schema/types.js +0 -2
- package/cjs/schema/value.interface.js +0 -2
- package/cjs/schema/ws/ws-api.interface.js +0 -2
- package/cjs/schema/ws/ws-controller.interface.js +0 -11
- package/cjs/schema/ws/ws-operation.interface.js +0 -7
- package/cjs/types.js +0 -2
- package/esm/filter/antlr/OpraFilterLexer.js +0 -425
- package/esm/filter/antlr/OpraFilterListener.js +0 -8
- package/esm/filter/antlr/OpraFilterVisitor.js +0 -11
- package/esm/helpers/monkey-patches.js +0 -14
- package/esm/package.json +0 -3
- package/types/document/decorators/ws-param.decorator.d.ts +0 -2
- package/types/index.d.cts +0 -9
- /package/{types/document → document}/api-document.d.ts +0 -0
- /package/{types/document → document}/common/api-base.d.ts +0 -0
- /package/{types/document → document}/common/data-type-map.d.ts +0 -0
- /package/{types/document → document}/common/document-element.d.ts +0 -0
- /package/{esm/document → document}/common/document-element.js +0 -0
- /package/{types/document → document}/common/document-init-context.d.ts +0 -0
- /package/{types/document → document}/common/document-node.d.ts +0 -0
- /package/{types/document → document}/common/opra-document-error.d.ts +0 -0
- /package/{types/document → document}/common/value.d.ts +0 -0
- /package/{types/document → document}/constants.d.ts +0 -0
- /package/{esm/document → document}/constants.js +0 -0
- /package/{types/document → document}/data-type/api-field.d.ts +0 -0
- /package/{esm/document → document}/data-type/array-type.js +0 -0
- /package/{types/document → document}/data-type/complex-type-base.d.ts +0 -0
- /package/{types/document → document}/data-type/complex-type.d.ts +0 -0
- /package/{types/document → document}/data-type/data-type.d.ts +0 -0
- /package/{esm/document → document}/data-type/data-type.js +0 -0
- /package/{types/document → document}/data-type/enum-type.d.ts +0 -0
- /package/{esm/document → document}/data-type/enum-type.js +0 -0
- /package/{types/document → document}/data-type/extended-types/base64.type.d.ts +0 -0
- /package/{types/document → document}/data-type/extended-types/date-time-tz.type.d.ts +0 -0
- /package/{types/document → document}/data-type/extended-types/date-time.type.d.ts +0 -0
- /package/{types/document → document}/data-type/extended-types/date.type.d.ts +0 -0
- /package/{types/document → document}/data-type/extended-types/email.type.d.ts +0 -0
- /package/{types/document → document}/data-type/extended-types/field-path.type.d.ts +0 -0
- /package/{types/document → document}/data-type/extended-types/filter.type.d.ts +0 -0
- /package/{types/document → document}/data-type/extended-types/index.d.ts +0 -0
- /package/{esm/document → document}/data-type/extended-types/index.js +0 -0
- /package/{types/document → document}/data-type/extended-types/object-id.type.d.ts +0 -0
- /package/{esm/document → document}/data-type/extended-types/object-id.type.js +0 -0
- /package/{types/document → document}/data-type/extended-types/operation-result.type.d.ts +0 -0
- /package/{esm/document → document}/data-type/extended-types/operation-result.type.js +0 -0
- /package/{types/document → document}/data-type/extended-types/partial-date.type.d.ts +0 -0
- /package/{types/document → document}/data-type/extended-types/time.type.d.ts +0 -0
- /package/{types/document → document}/data-type/extended-types/url.type.d.ts +0 -0
- /package/{esm/document → document}/data-type/extended-types/url.type.js +0 -0
- /package/{types/document → document}/data-type/extended-types/uuid.type.d.ts +0 -0
- /package/{types/document → document}/data-type/mapped-type.d.ts +0 -0
- /package/{types/document → document}/data-type/mixin-type.d.ts +0 -0
- /package/{esm/document → document}/data-type/mixin-type.js +0 -0
- /package/{types/document → document}/data-type/omit-type.d.ts +0 -0
- /package/{esm/document → document}/data-type/omit-type.js +0 -0
- /package/{types/document → document}/data-type/partial-type.d.ts +0 -0
- /package/{esm/document → document}/data-type/partial-type.js +0 -0
- /package/{types/document → document}/data-type/pick-type.d.ts +0 -0
- /package/{esm/document → document}/data-type/pick-type.js +0 -0
- /package/{types/document → document}/data-type/primitive-types/any.type.d.ts +0 -0
- /package/{esm/document → document}/data-type/primitive-types/any.type.js +0 -0
- /package/{types/document → document}/data-type/primitive-types/bigint.type.d.ts +0 -0
- /package/{esm/document → document}/data-type/primitive-types/bigint.type.js +0 -0
- /package/{types/document → document}/data-type/primitive-types/boolean.type.d.ts +0 -0
- /package/{esm/document → document}/data-type/primitive-types/boolean.type.js +0 -0
- /package/{types/document → document}/data-type/primitive-types/index.d.ts +0 -0
- /package/{esm/document → document}/data-type/primitive-types/index.js +0 -0
- /package/{types/document → document}/data-type/primitive-types/integer.type.d.ts +0 -0
- /package/{esm/document → document}/data-type/primitive-types/integer.type.js +0 -0
- /package/{types/document → document}/data-type/primitive-types/null.type.d.ts +0 -0
- /package/{esm/document → document}/data-type/primitive-types/null.type.js +0 -0
- /package/{types/document → document}/data-type/primitive-types/number.type.d.ts +0 -0
- /package/{types/document → document}/data-type/primitive-types/object.type.d.ts +0 -0
- /package/{esm/document → document}/data-type/primitive-types/object.type.js +0 -0
- /package/{types/document → document}/data-type/primitive-types/string.type.d.ts +0 -0
- /package/{types/document → document}/data-type/required-type.d.ts +0 -0
- /package/{esm/document → document}/data-type/required-type.js +0 -0
- /package/{types/document → document}/data-type/simple-type.d.ts +0 -0
- /package/{types/document → document}/data-type/union-type.d.ts +0 -0
- /package/{esm/document → document}/data-type/union-type.js +0 -0
- /package/{types/document → document}/data-type/utils/create-mapped-class.d.ts +0 -0
- /package/{esm/document → document}/data-type/utils/create-mapped-class.js +0 -0
- /package/{types/document → document}/data-type/utils/get-is-inherited-predicate-fn.d.ts +0 -0
- /package/{esm/document → document}/data-type/utils/get-is-inherited-predicate-fn.js +0 -0
- /package/{types/document → document}/decorators/api-field-decorator.d.ts +0 -0
- /package/{esm/document → document}/decorators/api-field-decorator.js +0 -0
- /package/{types/document → document}/decorators/complex-type.decorator.d.ts +0 -0
- /package/{esm/document → document}/decorators/complex-type.decorator.js +0 -0
- /package/{types/document → document}/decorators/http-controller.decorator.d.ts +0 -0
- /package/{esm/document → document}/decorators/http-controller.decorator.js +0 -0
- /package/{types/document → document}/decorators/http-operation-entity-create.decorator.d.ts +0 -0
- /package/{esm/document → document}/decorators/http-operation-entity-create.decorator.js +0 -0
- /package/{types/document → document}/decorators/http-operation-entity-delete-many.decorator.d.ts +0 -0
- /package/{esm/document → document}/decorators/http-operation-entity-delete-many.decorator.js +0 -0
- /package/{types/document → document}/decorators/http-operation-entity-delete.decorator.d.ts +0 -0
- /package/{esm/document → document}/decorators/http-operation-entity-delete.decorator.js +0 -0
- /package/{types/document → document}/decorators/http-operation-entity-find-many.decorator.d.ts +0 -0
- /package/{esm/document → document}/decorators/http-operation-entity-find-many.decorator.js +0 -0
- /package/{types/document → document}/decorators/http-operation-entity-get.decorator.d.ts +0 -0
- /package/{esm/document → document}/decorators/http-operation-entity-get.decorator.js +0 -0
- /package/{types/document → document}/decorators/http-operation-entity-replace.decorator.d.ts +0 -0
- /package/{esm/document → document}/decorators/http-operation-entity-replace.decorator.js +0 -0
- /package/{types/document → document}/decorators/http-operation-entity-update-many.decorator.d.ts +0 -0
- /package/{esm/document → document}/decorators/http-operation-entity-update-many.decorator.js +0 -0
- /package/{types/document → document}/decorators/http-operation-entity-update.decorator.d.ts +0 -0
- /package/{esm/document → document}/decorators/http-operation-entity-update.decorator.js +0 -0
- /package/{types/document → document}/decorators/http-operation-entity.decorator.d.ts +0 -0
- /package/{esm/document → document}/decorators/http-operation-entity.decorator.js +0 -0
- /package/{types/document → document}/decorators/http-operation.decorator.d.ts +0 -0
- /package/{esm/document → document}/decorators/http-operation.decorator.js +0 -0
- /package/{types/document → document}/decorators/mq-controller.decorator.d.ts +0 -0
- /package/{esm/document → document}/decorators/mq-controller.decorator.js +0 -0
- /package/{types/document → document}/decorators/mq-operation.decorator.d.ts +0 -0
- /package/{esm/document → document}/decorators/mq-operation.decorator.js +0 -0
- /package/{types/document → document}/decorators/simple-type.decorator.d.ts +0 -0
- /package/{esm/document → document}/decorators/simple-type.decorator.js +0 -0
- /package/{types/document → document}/decorators/ws-controller.decorator.d.ts +0 -0
- /package/{esm/document → document}/decorators/ws-controller.decorator.js +0 -0
- /package/{types/document → document}/decorators/ws-operation.decorator.d.ts +0 -0
- /package/{esm/document → document}/decorators/ws-operation.decorator.js +0 -0
- /package/{types/document → document}/factory/api-document.factory.d.ts +0 -0
- /package/{types/document → document}/factory/data-type.factory.d.ts +0 -0
- /package/{esm/document → document}/factory/data-type.factory.js +0 -0
- /package/{types/document → document}/factory/http-api.factory.d.ts +0 -0
- /package/{esm/document → document}/factory/http-api.factory.js +0 -0
- /package/{types/document → document}/factory/mq-api.factory.d.ts +0 -0
- /package/{esm/document → document}/factory/mq-api.factory.js +0 -0
- /package/{types/document → document}/factory/ws-api.factory.d.ts +0 -0
- /package/{types/document → document}/http/http-api.d.ts +0 -0
- /package/{types/document → document}/http/http-controller.d.ts +0 -0
- /package/{esm/document → document}/http/http-controller.js +0 -0
- /package/{types/document → document}/http/http-media-type.d.ts +0 -0
- /package/{esm/document → document}/http/http-media-type.js +0 -0
- /package/{types/document → document}/http/http-multipart-field.d.ts +0 -0
- /package/{types/document → document}/http/http-operation-response.d.ts +0 -0
- /package/{types/document → document}/http/http-operation.d.ts +0 -0
- /package/{esm/document → document}/http/http-operation.js +0 -0
- /package/{types/document → document}/http/http-parameter.d.ts +0 -0
- /package/{esm/document → document}/http/http-parameter.js +0 -0
- /package/{types/document → document}/http/http-request-body.d.ts +0 -0
- /package/{types/document → document}/http/http-status-range.d.ts +0 -0
- /package/{types/document → document}/index.d.ts +0 -0
- /package/{esm/document → document}/index.js +0 -0
- /package/{types/document → document}/mq/mq-api.d.ts +0 -0
- /package/{types/document → document}/mq/mq-controller.d.ts +0 -0
- /package/{esm/document → document}/mq/mq-controller.js +0 -0
- /package/{types/document → document}/mq/mq-header.d.ts +0 -0
- /package/{esm/document → document}/mq/mq-header.js +0 -0
- /package/{types/document → document}/mq/mq-operation-response.d.ts +0 -0
- /package/{types/document → document}/mq/mq-operation.d.ts +0 -0
- /package/{esm/document → document}/mq/mq-operation.js +0 -0
- /package/{types/document → document}/utils/inspect.util.d.ts +0 -0
- /package/{esm/document → document}/utils/inspect.util.js +0 -0
- /package/{types/document → document}/utils/parse-regexp.util.d.ts +0 -0
- /package/{esm/document → document}/utils/parse-regexp.util.js +0 -0
- /package/{types/document → document}/utils/string-compare.util.d.ts +0 -0
- /package/{esm/document → document}/utils/string-compare.util.js +0 -0
- /package/{types/document → document}/utils/test-scope-match.d.ts +0 -0
- /package/{esm/document → document}/utils/test-scope-match.js +0 -0
- /package/{types/document → document}/ws/ws-api.d.ts +0 -0
- /package/{types/document → document}/ws/ws-controller.d.ts +0 -0
- /package/{esm/document → document}/ws/ws-controller.js +0 -0
- /package/{types/enums → enums}/http-headers-codes.enum.d.ts +0 -0
- /package/{esm/enums → enums}/http-headers-codes.enum.js +0 -0
- /package/{types/enums → enums}/http-status-codes.enum.d.ts +0 -0
- /package/{esm/enums → enums}/http-status-codes.enum.js +0 -0
- /package/{types/enums → enums}/http-status-messages.d.ts +0 -0
- /package/{esm/enums → enums}/http-status-messages.js +0 -0
- /package/{types/enums → enums}/index.d.ts +0 -0
- /package/{esm/enums → enums}/index.js +0 -0
- /package/{types/enums → enums}/mime-types.enum.d.ts +0 -0
- /package/{esm/enums → enums}/mime-types.enum.js +0 -0
- /package/{types/exception → exception}/error-issue.d.ts +0 -0
- /package/{esm/exception → exception}/error-issue.js +0 -0
- /package/{types/exception → exception}/http-errors/bad-request.error.d.ts +0 -0
- /package/{types/exception → exception}/http-errors/conflict.error.d.ts +0 -0
- /package/{types/exception → exception}/http-errors/failed-dependency.error.d.ts +0 -0
- /package/{types/exception → exception}/http-errors/forbidden.error.d.ts +0 -0
- /package/{types/exception → exception}/http-errors/internal-server.error.d.ts +0 -0
- /package/{types/exception → exception}/http-errors/method-not-allowed.error.d.ts +0 -0
- /package/{types/exception → exception}/http-errors/not-acceptable.error.d.ts +0 -0
- /package/{types/exception → exception}/http-errors/not-found.error.d.ts +0 -0
- /package/{types/exception → exception}/http-errors/permission.error.d.ts +0 -0
- /package/{esm/exception → exception}/http-errors/permission.error.js +0 -0
- /package/{types/exception → exception}/http-errors/resource-conflict.error.d.ts +0 -0
- /package/{types/exception → exception}/http-errors/resource-not.available.error.d.ts +0 -0
- /package/{esm/exception → exception}/http-errors/resource-not.available.error.js +0 -0
- /package/{types/exception → exception}/http-errors/unauthorized.error.d.ts +0 -0
- /package/{types/exception → exception}/http-errors/unprocessable-entity.error.d.ts +0 -0
- /package/{types/exception → exception}/index.d.ts +0 -0
- /package/{esm/exception → exception}/index.js +0 -0
- /package/{types/exception → exception}/issue-severity.enum.d.ts +0 -0
- /package/{esm/exception → exception}/issue-severity.enum.js +0 -0
- /package/{types/exception → exception}/opra-exception.d.ts +0 -0
- /package/{types/exception → exception}/opra-http-error.d.ts +0 -0
- /package/{types/filter → filter}/antlr/OpraFilterLexer.d.ts +0 -0
- /package/{types/filter → filter}/antlr/OpraFilterListener.d.ts +0 -0
- /package/{types/filter → filter}/antlr/OpraFilterParser.d.ts +0 -0
- /package/{types/filter → filter}/antlr/OpraFilterVisitor.d.ts +0 -0
- /package/{types/filter → filter}/ast/abstract/ast.d.ts +0 -0
- /package/{types/filter → filter}/ast/abstract/expression.d.ts +0 -0
- /package/{esm/filter → filter}/ast/abstract/expression.js +0 -0
- /package/{types/filter → filter}/ast/abstract/literal.d.ts +0 -0
- /package/{esm/filter → filter}/ast/abstract/literal.js +0 -0
- /package/{types/filter → filter}/ast/abstract/term.d.ts +0 -0
- /package/{esm/filter → filter}/ast/abstract/term.js +0 -0
- /package/{types/filter → filter}/ast/expressions/arithmetic-expression.d.ts +0 -0
- /package/{types/filter → filter}/ast/expressions/array-expression.d.ts +0 -0
- /package/{types/filter → filter}/ast/expressions/comparison-expression.d.ts +0 -0
- /package/{types/filter → filter}/ast/expressions/logical-expression.d.ts +0 -0
- /package/{types/filter → filter}/ast/expressions/negative-expression.d.ts +0 -0
- /package/{types/filter → filter}/ast/expressions/parenthesized-expression.d.ts +0 -0
- /package/{types/filter → filter}/ast/index.d.ts +0 -0
- /package/{esm/filter → filter}/ast/index.js +0 -0
- /package/{types/filter → filter}/ast/terms/boolean-literal.d.ts +0 -0
- /package/{esm/filter → filter}/ast/terms/boolean-literal.js +0 -0
- /package/{types/filter → filter}/ast/terms/date-literal.d.ts +0 -0
- /package/{types/filter → filter}/ast/terms/date-time-literal.d.ts +0 -0
- /package/{types/filter → filter}/ast/terms/external-constant.d.ts +0 -0
- /package/{esm/filter → filter}/ast/terms/external-constant.js +0 -0
- /package/{types/filter → filter}/ast/terms/null-literal.d.ts +0 -0
- /package/{types/filter → filter}/ast/terms/number-literal.d.ts +0 -0
- /package/{types/filter → filter}/ast/terms/qualified-identifier.d.ts +0 -0
- /package/{esm/filter → filter}/ast/terms/qualified-identifier.js +0 -0
- /package/{types/filter → filter}/ast/terms/string-literal.d.ts +0 -0
- /package/{esm/filter → filter}/ast/terms/string-literal.js +0 -0
- /package/{types/filter → filter}/ast/terms/time-literal.d.ts +0 -0
- /package/{types/filter → filter}/build.d.ts +0 -0
- /package/{esm/filter → filter}/build.js +0 -0
- /package/{types/filter → filter}/errors.d.ts +0 -0
- /package/{esm/filter → filter}/errors.js +0 -0
- /package/{types/filter → filter}/filter-rules.d.ts +0 -0
- /package/{types/filter → filter}/filter-tree-visitor.d.ts +0 -0
- /package/{types/filter → filter}/index.d.ts +0 -0
- /package/{esm/filter → filter}/index.js +0 -0
- /package/{types/filter → filter}/opra-error-listener.d.ts +0 -0
- /package/{types/filter → filter}/opra-filter.ns.d.ts +0 -0
- /package/{esm/filter → filter}/opra-filter.ns.js +0 -0
- /package/{types/filter → filter}/parse.d.ts +0 -0
- /package/{esm/filter → filter}/parse.js +0 -0
- /package/{types/filter → filter}/utils.d.ts +0 -0
- /package/{esm/filter → filter}/utils.js +0 -0
- /package/{types/helpers → helpers}/function-utils.d.ts +0 -0
- /package/{esm/helpers → helpers}/function-utils.js +0 -0
- /package/{types/helpers → helpers}/get-stack-filename.d.ts +0 -0
- /package/{esm/helpers → helpers}/get-stack-filename.js +0 -0
- /package/{types/helpers → helpers}/index.d.ts +0 -0
- /package/{esm/helpers → helpers}/index.js +0 -0
- /package/{types/helpers → helpers}/mixin-utils.d.ts +0 -0
- /package/{esm/helpers → helpers}/mixin-utils.js +0 -0
- /package/{types/helpers → helpers}/monkey-patches.d.ts +0 -0
- /package/{cjs/helpers → helpers}/monkey-patches.js +0 -0
- /package/{types/helpers → helpers}/object-utils.d.ts +0 -0
- /package/{esm/helpers → helpers}/object-utils.js +0 -0
- /package/{types/helpers → helpers}/parse-fields-projection.d.ts +0 -0
- /package/{types/helpers → helpers}/responsive-map.d.ts +0 -0
- /package/{esm/helpers → helpers}/responsive-map.js +0 -0
- /package/{types/helpers → helpers}/safe-json-stringify.d.ts +0 -0
- /package/{esm/helpers → helpers}/safe-json-stringify.js +0 -0
- /package/{types/helpers → helpers}/type-guards.d.ts +0 -0
- /package/{esm/helpers → helpers}/type-guards.js +0 -0
- /package/{types/i18n → i18n}/i18n.d.ts +0 -0
- /package/{esm/i18n → i18n}/i18n.js +0 -0
- /package/{types/i18n → i18n}/index.d.ts +0 -0
- /package/{esm/i18n → i18n}/index.js +0 -0
- /package/{types/i18n → i18n}/string-utils.d.ts +0 -0
- /package/{esm/i18n → i18n}/string-utils.js +0 -0
- /package/{types/i18n → i18n}/translate.d.ts +0 -0
- /package/{esm/i18n → i18n}/translate.js +0 -0
- /package/{types/index.d.ts → index.d.ts} +0 -0
- /package/{esm/index.js → index.js} +0 -0
- /package/{types/polifils → polifils}/array-find-last.d.ts +0 -0
- /package/{esm/polifils → polifils}/array-find-last.js +0 -0
- /package/{types/schema → schema}/api-document.interface.d.ts +0 -0
- /package/{esm/schema → schema}/api-document.interface.js +0 -0
- /package/{types/schema → schema}/api.interface.d.ts +0 -0
- /package/{esm/schema → schema}/api.interface.js +0 -0
- /package/{types/schema → schema}/constants.d.ts +0 -0
- /package/{esm/schema → schema}/constants.js +0 -0
- /package/{types/schema → schema}/data-type/array-type.interface.d.ts +0 -0
- /package/{esm/schema → schema}/data-type/array-type.interface.js +0 -0
- /package/{types/schema → schema}/data-type/complex-type.interface.d.ts +0 -0
- /package/{esm/schema → schema}/data-type/complex-type.interface.js +0 -0
- /package/{types/schema → schema}/data-type/data-type.interface.d.ts +0 -0
- /package/{esm/schema → schema}/data-type/data-type.interface.js +0 -0
- /package/{types/schema → schema}/data-type/enum-type.interface.d.ts +0 -0
- /package/{esm/schema → schema}/data-type/enum-type.interface.js +0 -0
- /package/{types/schema → schema}/data-type/field.interface.d.ts +0 -0
- /package/{esm/schema → schema}/data-type/field.interface.js +0 -0
- /package/{types/schema → schema}/data-type/mapped-type.interface.d.ts +0 -0
- /package/{esm/schema → schema}/data-type/mapped-type.interface.js +0 -0
- /package/{types/schema → schema}/data-type/mixin-type.interface.d.ts +0 -0
- /package/{esm/schema → schema}/data-type/mixin-type.interface.js +0 -0
- /package/{types/schema → schema}/data-type/simple-type.interface.d.ts +0 -0
- /package/{esm/schema → schema}/data-type/simple-type.interface.js +0 -0
- /package/{types/schema → schema}/data-type/union-type.interface.d.ts +0 -0
- /package/{esm/schema → schema}/data-type/union-type.interface.js +0 -0
- /package/{types/schema → schema}/data-type-container.interface.d.ts +0 -0
- /package/{esm/schema → schema}/data-type-container.interface.js +0 -0
- /package/{types/schema → schema}/http/http-api.interface.d.ts +0 -0
- /package/{esm/schema → schema}/http/http-api.interface.js +0 -0
- /package/{types/schema → schema}/http/http-controller.interface.d.ts +0 -0
- /package/{esm/schema → schema}/http/http-controller.interface.js +0 -0
- /package/{types/schema → schema}/http/http-media-type.interface.d.ts +0 -0
- /package/{esm/schema → schema}/http/http-media-type.interface.js +0 -0
- /package/{types/schema → schema}/http/http-multipart-field.interface.d.ts +0 -0
- /package/{esm/schema → schema}/http/http-multipart-field.interface.js +0 -0
- /package/{types/schema → schema}/http/http-operation-response.interface.d.ts +0 -0
- /package/{esm/schema → schema}/http/http-operation-response.interface.js +0 -0
- /package/{types/schema → schema}/http/http-operation.interface.d.ts +0 -0
- /package/{esm/schema → schema}/http/http-operation.interface.js +0 -0
- /package/{types/schema → schema}/http/http-parameter.interface.d.ts +0 -0
- /package/{esm/schema → schema}/http/http-parameter.interface.js +0 -0
- /package/{types/schema → schema}/http/http-request-body.interface.d.ts +0 -0
- /package/{esm/schema → schema}/http/http-request-body.interface.js +0 -0
- /package/{types/schema → schema}/http/http-status-range.interface.d.ts +0 -0
- /package/{esm/schema → schema}/http/http-status-range.interface.js +0 -0
- /package/{types/schema → schema}/index.d.ts +0 -0
- /package/{esm/schema → schema}/index.js +0 -0
- /package/{types/schema → schema}/mq/mq-api.interface.d.ts +0 -0
- /package/{esm/schema → schema}/mq/mq-api.interface.js +0 -0
- /package/{types/schema → schema}/mq/mq-controller.interface.d.ts +0 -0
- /package/{esm/schema → schema}/mq/mq-controller.interface.js +0 -0
- /package/{types/schema → schema}/mq/mq-header.interface.d.ts +0 -0
- /package/{esm/schema → schema}/mq/mq-header.interface.js +0 -0
- /package/{types/schema → schema}/mq/mq-operation.interface.d.ts +0 -0
- /package/{esm/schema → schema}/mq/mq-operation.interface.js +0 -0
- /package/{types/schema → schema}/opra-schema.d.ts +0 -0
- /package/{esm/schema → schema}/opra-schema.js +0 -0
- /package/{types/schema → schema}/type-guards.d.ts +0 -0
- /package/{esm/schema → schema}/type-guards.js +0 -0
- /package/{types/schema → schema}/types.d.ts +0 -0
- /package/{esm/schema → schema}/types.js +0 -0
- /package/{types/schema → schema}/value.interface.d.ts +0 -0
- /package/{esm/schema → schema}/value.interface.js +0 -0
- /package/{esm/schema → schema}/ws/ws-api.interface.js +0 -0
- /package/{types/schema → schema}/ws/ws-controller.interface.d.ts +0 -0
- /package/{esm/schema → schema}/ws/ws-controller.interface.js +0 -0
- /package/{types/schema → schema}/ws/ws-operation.interface.d.ts +0 -0
- /package/{esm/schema → schema}/ws/ws-operation.interface.js +0 -0
- /package/{types/types.d.ts → types.d.ts} +0 -0
- /package/{esm/types.js → types.js} +0 -0
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FilterRules = void 0;
|
|
4
|
-
require("../polifils/array-find-last.js");
|
|
5
|
-
const objects_1 = require("@jsopen/objects");
|
|
6
|
-
const valgen_1 = require("valgen");
|
|
7
|
-
const index_js_1 = require("../exception/index.js");
|
|
8
|
-
const index_js_2 = require("../helpers/index.js");
|
|
9
|
-
const index_js_3 = require("./ast/index.js");
|
|
10
|
-
const parse_js_1 = require("./parse.js");
|
|
11
|
-
class FilterRules {
|
|
12
|
-
constructor(rules, options) {
|
|
13
|
-
this._rules = new index_js_2.ResponsiveMap();
|
|
14
|
-
this._decoderCache = new WeakMap();
|
|
15
|
-
Object.defineProperty(this, '_rules', {
|
|
16
|
-
value: new index_js_2.ResponsiveMap(null, { caseSensitive: options?.caseSensitive }),
|
|
17
|
-
enumerable: false,
|
|
18
|
-
});
|
|
19
|
-
if (rules) {
|
|
20
|
-
for (const [k, v] of Object.entries(rules)) {
|
|
21
|
-
this.set(k, v);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
set(fieldName, options) {
|
|
26
|
-
const operators = typeof options?.operators === 'string'
|
|
27
|
-
? options.operators.split(/\s*[,| ]\s*/)
|
|
28
|
-
: options?.operators;
|
|
29
|
-
this._rules.set(fieldName, (0, objects_1.omitUndefined)({
|
|
30
|
-
...options,
|
|
31
|
-
operators,
|
|
32
|
-
}));
|
|
33
|
-
}
|
|
34
|
-
normalizeFilter(filter, currentType, scope) {
|
|
35
|
-
const ast = typeof filter === 'string' ? (0, parse_js_1.parse)(filter) : filter;
|
|
36
|
-
return this.normalizeFilterAst(ast, [], currentType, scope);
|
|
37
|
-
}
|
|
38
|
-
normalizeFilterAst(ast, stack, currentType, scope) {
|
|
39
|
-
if (ast instanceof index_js_3.ComparisonExpression) {
|
|
40
|
-
stack.push(ast);
|
|
41
|
-
this.normalizeFilterAst(ast.left, stack, currentType);
|
|
42
|
-
if (!(ast.left instanceof index_js_3.QualifiedIdentifier && ast.left.field)) {
|
|
43
|
-
throw new TypeError(`Invalid filter query. Left side should be a data field.`);
|
|
44
|
-
}
|
|
45
|
-
// Check if filtering accepted for given field
|
|
46
|
-
const rule = this._rules.get(ast.left.value);
|
|
47
|
-
if (!rule) {
|
|
48
|
-
throw new index_js_1.OpraException({
|
|
49
|
-
message: `Field '${ast.left.value}' is not available for filter operation`,
|
|
50
|
-
code: 'UNACCEPTED_FILTER_FIELD',
|
|
51
|
-
details: {
|
|
52
|
-
field: ast.left.value,
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
// Check if filtering endpoint accepted for given field
|
|
57
|
-
if (rule.operators && !rule.operators.includes(ast.op)) {
|
|
58
|
-
throw new index_js_1.OpraException({
|
|
59
|
-
message: `'${ast.left.value}' field do not accept '${ast.op}' filter operator`,
|
|
60
|
-
code: 'UNACCEPTED_FILTER_OPERATION',
|
|
61
|
-
details: {
|
|
62
|
-
field: ast.left.value,
|
|
63
|
-
operator: ast.op,
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
if (rule.mappedField)
|
|
68
|
-
ast.left.value = rule.mappedField;
|
|
69
|
-
if (rule.prepare)
|
|
70
|
-
ast.prepare = rule.prepare;
|
|
71
|
-
this.normalizeFilterAst(ast.right, stack, currentType);
|
|
72
|
-
stack.pop();
|
|
73
|
-
return ast;
|
|
74
|
-
}
|
|
75
|
-
if (ast instanceof index_js_3.LogicalExpression) {
|
|
76
|
-
stack.push(ast);
|
|
77
|
-
ast.items.forEach(item => this.normalizeFilterAst(item, stack, currentType));
|
|
78
|
-
stack.pop();
|
|
79
|
-
return ast;
|
|
80
|
-
}
|
|
81
|
-
if (ast instanceof index_js_3.ArithmeticExpression) {
|
|
82
|
-
stack.push(ast);
|
|
83
|
-
ast.items.forEach(item => this.normalizeFilterAst(item.expression, stack, currentType));
|
|
84
|
-
stack.pop();
|
|
85
|
-
return ast;
|
|
86
|
-
}
|
|
87
|
-
if (ast instanceof index_js_3.ArrayExpression) {
|
|
88
|
-
stack.push(ast);
|
|
89
|
-
ast.items.forEach(item => this.normalizeFilterAst(item, stack, currentType));
|
|
90
|
-
stack.pop();
|
|
91
|
-
return ast;
|
|
92
|
-
}
|
|
93
|
-
if (ast instanceof index_js_3.ParenthesizedExpression) {
|
|
94
|
-
stack.push(ast);
|
|
95
|
-
this.normalizeFilterAst(ast.expression, stack, currentType);
|
|
96
|
-
stack.pop();
|
|
97
|
-
return ast;
|
|
98
|
-
}
|
|
99
|
-
if (ast instanceof index_js_3.QualifiedIdentifier && currentType) {
|
|
100
|
-
ast.value = currentType.normalizeFieldPath(ast.value, { scope });
|
|
101
|
-
ast.field = currentType.getField(ast.value, scope);
|
|
102
|
-
ast.dataType = ast.field.type;
|
|
103
|
-
return ast;
|
|
104
|
-
}
|
|
105
|
-
if (ast instanceof index_js_3.Literal) {
|
|
106
|
-
/** Check if comparison expression has in stack */
|
|
107
|
-
const compIdx = stack.findLastIndex(x => x instanceof index_js_3.ComparisonExpression);
|
|
108
|
-
if (compIdx >= 0) {
|
|
109
|
-
const comp = stack[compIdx];
|
|
110
|
-
/** If calling for right side of comparison */
|
|
111
|
-
if (ast === comp.right || stack[compIdx + 1] === comp.right) {
|
|
112
|
-
/** Check if comparison expression left side is a field */
|
|
113
|
-
if (comp &&
|
|
114
|
-
comp.left instanceof index_js_3.QualifiedIdentifier &&
|
|
115
|
-
comp.left.field) {
|
|
116
|
-
if (ast.value == null && !comp.left.field.required)
|
|
117
|
-
return ast.value;
|
|
118
|
-
let decoder;
|
|
119
|
-
if (comp.op === 'like' ||
|
|
120
|
-
comp.op === '!like' ||
|
|
121
|
-
comp.op === 'ilike' ||
|
|
122
|
-
comp.op === '!ilike') {
|
|
123
|
-
decoder = valgen_1.isString;
|
|
124
|
-
}
|
|
125
|
-
else
|
|
126
|
-
decoder = this._decoderCache.get(comp.left.field);
|
|
127
|
-
if (!decoder) {
|
|
128
|
-
decoder = comp.left.field.generateCodec('decode', {
|
|
129
|
-
scope,
|
|
130
|
-
projection: '*',
|
|
131
|
-
ignoreReadonlyFields: true,
|
|
132
|
-
coerce: true,
|
|
133
|
-
});
|
|
134
|
-
this._decoderCache.set(comp.left.field, decoder);
|
|
135
|
-
}
|
|
136
|
-
ast.value = decoder(ast.value, { coerce: true });
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return ast;
|
|
142
|
-
}
|
|
143
|
-
toJSON() {
|
|
144
|
-
return this._rules.toObject();
|
|
145
|
-
}
|
|
146
|
-
[Symbol.iterator]() {
|
|
147
|
-
return this._rules.entries();
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
exports.FilterRules = FilterRules;
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FilterTreeVisitor = void 0;
|
|
4
|
-
const antlr4_1 = require("@browsery/antlr4");
|
|
5
|
-
const OpraFilterParser_js_1 = require("./antlr/OpraFilterParser.js");
|
|
6
|
-
const index_js_1 = require("./ast/index.js");
|
|
7
|
-
const external_constant_js_1 = require("./ast/terms/external-constant.js");
|
|
8
|
-
const utils_js_1 = require("./utils.js");
|
|
9
|
-
class FilterTreeVisitor extends antlr4_1.ParseTreeVisitor {
|
|
10
|
-
constructor(options) {
|
|
11
|
-
super();
|
|
12
|
-
this._timeZone = options?.timeZone;
|
|
13
|
-
}
|
|
14
|
-
visitChildren(node) {
|
|
15
|
-
const result = super.visitChildren(node);
|
|
16
|
-
if (Array.isArray(result) && result.length < 2)
|
|
17
|
-
return result[0];
|
|
18
|
-
return result ?? node.getText();
|
|
19
|
-
}
|
|
20
|
-
defaultResult() {
|
|
21
|
-
return undefined;
|
|
22
|
-
}
|
|
23
|
-
visitRoot(ctx) {
|
|
24
|
-
return this.visit(ctx.expression());
|
|
25
|
-
}
|
|
26
|
-
visitParenthesizedExpression(ctx) {
|
|
27
|
-
const expression = this.visit(ctx.parenthesizedItem());
|
|
28
|
-
return new index_js_1.ParenthesizedExpression(expression);
|
|
29
|
-
}
|
|
30
|
-
visitParenthesizedItem(ctx) {
|
|
31
|
-
return this.visit(ctx.expression());
|
|
32
|
-
}
|
|
33
|
-
visitNegativeExpression(ctx) {
|
|
34
|
-
const expression = this.visit(ctx.expression());
|
|
35
|
-
return new index_js_1.NegativeExpression(expression);
|
|
36
|
-
}
|
|
37
|
-
visitComparisonExpression(ctx) {
|
|
38
|
-
return new index_js_1.ComparisonExpression({
|
|
39
|
-
op: ctx.comparisonOperator().getText(),
|
|
40
|
-
left: this.visit(ctx.comparisonLeft()),
|
|
41
|
-
right: this.visit(ctx.comparisonRight()),
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
visitLogicalExpression(ctx) {
|
|
45
|
-
const items = [];
|
|
46
|
-
const wrapChildren = (arr, op) => {
|
|
47
|
-
for (const c of arr) {
|
|
48
|
-
if (c instanceof OpraFilterParser_js_1.LogicalExpressionContext &&
|
|
49
|
-
c.logicalOperator().getText() === op) {
|
|
50
|
-
wrapChildren(c.expression_list(), c.logicalOperator().getText());
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
const o = this.visit(c);
|
|
54
|
-
items.push(o);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
wrapChildren(ctx.expression_list(), ctx.logicalOperator().getText());
|
|
58
|
-
return new index_js_1.LogicalExpression({
|
|
59
|
-
op: ctx.logicalOperator().getText(),
|
|
60
|
-
items,
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
visitQualifiedIdentifier(ctx) {
|
|
64
|
-
return new index_js_1.QualifiedIdentifier(ctx.getText());
|
|
65
|
-
}
|
|
66
|
-
visitExternalConstant(ctx) {
|
|
67
|
-
return new external_constant_js_1.ExternalConstant(ctx.identifier().getText());
|
|
68
|
-
}
|
|
69
|
-
visitNullLiteral() {
|
|
70
|
-
return new index_js_1.NullLiteral();
|
|
71
|
-
}
|
|
72
|
-
visitBooleanLiteral(ctx) {
|
|
73
|
-
return new index_js_1.BooleanLiteral(ctx.getText() === 'true');
|
|
74
|
-
}
|
|
75
|
-
visitNumberLiteral(ctx) {
|
|
76
|
-
return new index_js_1.NumberLiteral(ctx.getText());
|
|
77
|
-
}
|
|
78
|
-
visitStringLiteral(ctx) {
|
|
79
|
-
return new index_js_1.StringLiteral((0, utils_js_1.unquoteFilterString)(ctx.getText()));
|
|
80
|
-
}
|
|
81
|
-
visitInfinityLiteral() {
|
|
82
|
-
return new index_js_1.NumberLiteral(Infinity);
|
|
83
|
-
}
|
|
84
|
-
visitDateLiteral(ctx) {
|
|
85
|
-
return new index_js_1.DateLiteral((0, utils_js_1.unquoteFilterString)(ctx.getText()));
|
|
86
|
-
}
|
|
87
|
-
visitDateTimeLiteral(ctx) {
|
|
88
|
-
return new index_js_1.DateTimeLiteral((0, utils_js_1.unquoteFilterString)(ctx.getText()));
|
|
89
|
-
}
|
|
90
|
-
visitTimeLiteral(ctx) {
|
|
91
|
-
return new index_js_1.TimeLiteral((0, utils_js_1.unquoteFilterString)(ctx.getText()));
|
|
92
|
-
}
|
|
93
|
-
visitArrayValue(ctx) {
|
|
94
|
-
return new index_js_1.ArrayExpression(ctx.value_list().map(child => this.visit(child)));
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
exports.FilterTreeVisitor = FilterTreeVisitor;
|
package/cjs/filter/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OpraErrorListener = void 0;
|
|
4
|
-
const antlr4_1 = require("@browsery/antlr4");
|
|
5
|
-
const errors_js_1 = require("./errors.js");
|
|
6
|
-
class OpraErrorListener extends antlr4_1.ErrorListener {
|
|
7
|
-
constructor(errors) {
|
|
8
|
-
super();
|
|
9
|
-
this.errors = errors;
|
|
10
|
-
}
|
|
11
|
-
syntaxError(recognizer, offendingSymbol, line, column, msg, e) {
|
|
12
|
-
this.errors.push(new errors_js_1.FilterParseError(msg, {
|
|
13
|
-
recognizer,
|
|
14
|
-
offendingSymbol,
|
|
15
|
-
line,
|
|
16
|
-
column,
|
|
17
|
-
e,
|
|
18
|
-
}));
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.OpraErrorListener = OpraErrorListener;
|
|
@@ -1,8 +0,0 @@
|
|
|
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("./build.js"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./filter-tree-visitor.js"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./opra-error-listener.js"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./parse.js"), exports);
|
package/cjs/filter/parse.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parse = parse;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const antlr4_1 = require("@browsery/antlr4");
|
|
6
|
-
const OpraFilterLexer_js_1 = tslib_1.__importDefault(require("./antlr/OpraFilterLexer.js"));
|
|
7
|
-
const OpraFilterParser_js_1 = tslib_1.__importDefault(require("./antlr/OpraFilterParser.js"));
|
|
8
|
-
const errors_js_1 = require("./errors.js");
|
|
9
|
-
const filter_tree_visitor_js_1 = require("./filter-tree-visitor.js");
|
|
10
|
-
const opra_error_listener_js_1 = require("./opra-error-listener.js");
|
|
11
|
-
function parse(text, visitor) {
|
|
12
|
-
const chars = new antlr4_1.CharStream(text);
|
|
13
|
-
const lexer = new OpraFilterLexer_js_1.default(chars);
|
|
14
|
-
const tokenStream = new antlr4_1.CommonTokenStream(lexer);
|
|
15
|
-
const parser = new OpraFilterParser_js_1.default(tokenStream);
|
|
16
|
-
parser.buildParseTrees = true;
|
|
17
|
-
const errors = [];
|
|
18
|
-
const errorListener = new opra_error_listener_js_1.OpraErrorListener(errors);
|
|
19
|
-
lexer.removeErrorListeners();
|
|
20
|
-
lexer.addErrorListener(errorListener);
|
|
21
|
-
parser.removeErrorListeners();
|
|
22
|
-
parser.addErrorListener(errorListener);
|
|
23
|
-
const tree = parser.root();
|
|
24
|
-
if (errors.length) {
|
|
25
|
-
const errMsgs = [];
|
|
26
|
-
for (const err of errors) {
|
|
27
|
-
errMsgs.push(err.message +
|
|
28
|
-
(text.includes('\n')
|
|
29
|
-
? ' at line: ' + err.line + ' column: ' + err.column
|
|
30
|
-
: ' at column: ' + err.column));
|
|
31
|
-
}
|
|
32
|
-
const e = new errors_js_1.SyntaxError(errMsgs.join('\n'));
|
|
33
|
-
e.errors = errors;
|
|
34
|
-
throw e;
|
|
35
|
-
}
|
|
36
|
-
visitor = visitor || new filter_tree_visitor_js_1.FilterTreeVisitor();
|
|
37
|
-
return visitor.visit(tree);
|
|
38
|
-
}
|
package/cjs/filter/utils.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.quoteFilterString = quoteFilterString;
|
|
4
|
-
exports.unquoteFilterString = unquoteFilterString;
|
|
5
|
-
const quotesRegEx = /'/g;
|
|
6
|
-
const escapeRegEx = /(\\)/g;
|
|
7
|
-
const unescapeRegEx = /\\(.)/g;
|
|
8
|
-
function escapeString(s) {
|
|
9
|
-
return s.replace(escapeRegEx, '\\\\');
|
|
10
|
-
}
|
|
11
|
-
function unescapeString(s) {
|
|
12
|
-
return s.replace(unescapeRegEx, '$1');
|
|
13
|
-
}
|
|
14
|
-
function quoteFilterString(s) {
|
|
15
|
-
return "'" + escapeString(s).replace(quotesRegEx, "\\'") + "'";
|
|
16
|
-
}
|
|
17
|
-
function unquoteFilterString(s) {
|
|
18
|
-
if (s &&
|
|
19
|
-
(s.startsWith("'") || s.startsWith('"')) &&
|
|
20
|
-
s.endsWith(s.charAt(0))) {
|
|
21
|
-
return unescapeString(s.substring(1, s.length - 1));
|
|
22
|
-
}
|
|
23
|
-
/* istanbul ignore next */
|
|
24
|
-
return s;
|
|
25
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveThunk = resolveThunk;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const objects_1 = require("@jsopen/objects");
|
|
6
|
-
const putil_promisify_1 = tslib_1.__importDefault(require("putil-promisify"));
|
|
7
|
-
async function resolveThunk(thunk) {
|
|
8
|
-
thunk = putil_promisify_1.default.isPromise(thunk) ? await thunk : thunk;
|
|
9
|
-
if (typeof thunk === 'function') {
|
|
10
|
-
if ((0, objects_1.isConstructor)(thunk))
|
|
11
|
-
return thunk;
|
|
12
|
-
return await thunk();
|
|
13
|
-
}
|
|
14
|
-
return thunk;
|
|
15
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getStackFileName = getStackFileName;
|
|
4
|
-
exports.getErrorStack = getErrorStack;
|
|
5
|
-
const PATH_PATTERN = /^(?:file:\/\/)?(.+)$/;
|
|
6
|
-
function getStackFileName(position = 1) {
|
|
7
|
-
if (position >= Error.stackTraceLimit) {
|
|
8
|
-
throw new TypeError('getCallerFile(position) requires position be less then Error.stackTraceLimit but position was: `' +
|
|
9
|
-
position +
|
|
10
|
-
'` and Error.stackTraceLimit was: `' +
|
|
11
|
-
Error.stackTraceLimit +
|
|
12
|
-
'`');
|
|
13
|
-
}
|
|
14
|
-
const oldPrepareStackTrace = Error.prepareStackTrace;
|
|
15
|
-
Error.prepareStackTrace = (_, stack) => stack;
|
|
16
|
-
const stack = new Error().stack;
|
|
17
|
-
Error.prepareStackTrace = oldPrepareStackTrace;
|
|
18
|
-
if (stack !== null && typeof stack === 'object') {
|
|
19
|
-
// stack[0] holds this file
|
|
20
|
-
// stack[1] holds where this function was called
|
|
21
|
-
const s = stack[position]
|
|
22
|
-
? stack[position].getFileName()
|
|
23
|
-
: undefined;
|
|
24
|
-
const m = s ? PATH_PATTERN.exec(s) : undefined;
|
|
25
|
-
return m ? m[1] : '';
|
|
26
|
-
}
|
|
27
|
-
return '';
|
|
28
|
-
}
|
|
29
|
-
function getErrorStack(position = 1) {
|
|
30
|
-
if (position >= Error.stackTraceLimit) {
|
|
31
|
-
throw new TypeError('getCallerFile(position) requires position be less then Error.stackTraceLimit but position was: `' +
|
|
32
|
-
position +
|
|
33
|
-
'` and Error.stackTraceLimit was: `' +
|
|
34
|
-
Error.stackTraceLimit +
|
|
35
|
-
'`');
|
|
36
|
-
}
|
|
37
|
-
const oldPrepareStackTrace = Error.prepareStackTrace;
|
|
38
|
-
Error.prepareStackTrace = (_, stack) => stack;
|
|
39
|
-
const stack = new Error().stack;
|
|
40
|
-
Error.prepareStackTrace = oldPrepareStackTrace;
|
|
41
|
-
if (stack !== null && typeof stack === 'object') {
|
|
42
|
-
// stack[0] holds this file
|
|
43
|
-
// stack[1] holds where this function was called
|
|
44
|
-
const s = stack[position]
|
|
45
|
-
? stack[position].getFileName()
|
|
46
|
-
: undefined;
|
|
47
|
-
const m = s ? PATH_PATTERN.exec(s) : undefined;
|
|
48
|
-
return m ? m[1] : '';
|
|
49
|
-
}
|
|
50
|
-
return '';
|
|
51
|
-
}
|
package/cjs/helpers/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
require("./monkey-patches.js");
|
|
5
|
-
tslib_1.__exportStar(require("./function-utils.js"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./get-stack-filename.js"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./mixin-utils.js"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./object-utils.js"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./parse-fields-projection.js"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./responsive-map.js"), exports);
|
|
11
|
-
tslib_1.__exportStar(require("./safe-json-stringify.js"), exports);
|
|
12
|
-
tslib_1.__exportStar(require("./type-guards.js"), exports);
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mergePrototype = mergePrototype;
|
|
4
|
-
exports.inheritPropertyInitializers = inheritPropertyInitializers;
|
|
5
|
-
function mergePrototype(targetProto, baseProto, filter) {
|
|
6
|
-
for (const k of Object.getOwnPropertyNames(baseProto)) {
|
|
7
|
-
if (k === 'constructor' ||
|
|
8
|
-
k === '__proto__' ||
|
|
9
|
-
k === 'toJSON' ||
|
|
10
|
-
k === 'toString' ||
|
|
11
|
-
(filter && !filter(k))) {
|
|
12
|
-
continue;
|
|
13
|
-
}
|
|
14
|
-
Object.defineProperty(targetProto, k, Object.getOwnPropertyDescriptor(baseProto, k) || Object.create(null));
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
// noinspection JSUnusedLocalSymbols
|
|
18
|
-
function inheritPropertyInitializers(target, clazz,
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
20
|
-
isPropertyInherited = (key) => true) {
|
|
21
|
-
try {
|
|
22
|
-
const tempInstance = new clazz();
|
|
23
|
-
const propertyNames = Object.getOwnPropertyNames(tempInstance);
|
|
24
|
-
propertyNames
|
|
25
|
-
.filter(propertyName => typeof tempInstance[propertyName] !== 'undefined' &&
|
|
26
|
-
typeof target[propertyName] === 'undefined')
|
|
27
|
-
.filter(propertyName => isPropertyInherited(propertyName))
|
|
28
|
-
.forEach(propertyName => {
|
|
29
|
-
target[propertyName] = tempInstance[propertyName];
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
catch {
|
|
33
|
-
//
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cloneObject = cloneObject;
|
|
4
|
-
const objects_1 = require("@jsopen/objects");
|
|
5
|
-
const constants_js_1 = require("../document/constants.js");
|
|
6
|
-
function cloneObject(obj, jsonOnly) {
|
|
7
|
-
return (0, objects_1.merge)({}, obj, {
|
|
8
|
-
deep: v => (0, objects_1.isPlainObject)(v) && !v[constants_js_1.DATATYPE_METADATA],
|
|
9
|
-
symbolKeys: true,
|
|
10
|
-
copyDescriptors: true,
|
|
11
|
-
ignoreUndefined: true,
|
|
12
|
-
filter(key, source) {
|
|
13
|
-
const v = source[key];
|
|
14
|
-
return (!jsonOnly ||
|
|
15
|
-
(typeof v !== 'function' &&
|
|
16
|
-
(typeof v !== 'object' || (0, objects_1.isPlainObject)(v) || Array.isArray(v))));
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FieldsProjection = void 0;
|
|
4
|
-
exports.parseFieldsProjection = parseFieldsProjection;
|
|
5
|
-
exports.parse = parse;
|
|
6
|
-
const fast_tokenizer_1 = require("fast-tokenizer");
|
|
7
|
-
const FIELD_PATTERN = /^([+-])?([a-z_$]\w*)$/i;
|
|
8
|
-
const NO_DOT_BRACKET_PATTERN = /[^.]\(/g;
|
|
9
|
-
class FieldsProjection {
|
|
10
|
-
}
|
|
11
|
-
exports.FieldsProjection = FieldsProjection;
|
|
12
|
-
(function (FieldsProjection) {
|
|
13
|
-
class Item {
|
|
14
|
-
}
|
|
15
|
-
FieldsProjection.Item = Item;
|
|
16
|
-
})(FieldsProjection || (exports.FieldsProjection = FieldsProjection = {}));
|
|
17
|
-
function parseFieldsProjection(projection, keepCase) {
|
|
18
|
-
const arr = Array.isArray(projection) ? projection : [projection];
|
|
19
|
-
if (!(arr && arr.length))
|
|
20
|
-
return;
|
|
21
|
-
const out = new FieldsProjection();
|
|
22
|
-
for (let s of arr) {
|
|
23
|
-
if (!keepCase)
|
|
24
|
-
s = s.toLowerCase();
|
|
25
|
-
parse(s, out);
|
|
26
|
-
}
|
|
27
|
-
return out;
|
|
28
|
-
}
|
|
29
|
-
function parse(input, target) {
|
|
30
|
-
/** Add dot before brackets which is required to split fields */
|
|
31
|
-
input = input.replace(NO_DOT_BRACKET_PATTERN, s => s.charAt(0) + '.' + s.substring(1));
|
|
32
|
-
const fields = (0, fast_tokenizer_1.splitString)(input, {
|
|
33
|
-
delimiters: '.',
|
|
34
|
-
brackets: true,
|
|
35
|
-
keepBrackets: false,
|
|
36
|
-
});
|
|
37
|
-
for (let i = 0; i < fields.length; i++) {
|
|
38
|
-
const f = fields[i];
|
|
39
|
-
if (f.includes(',')) {
|
|
40
|
-
const subFields = (0, fast_tokenizer_1.splitString)(f, {
|
|
41
|
-
delimiters: ',',
|
|
42
|
-
brackets: true,
|
|
43
|
-
keepBrackets: true,
|
|
44
|
-
});
|
|
45
|
-
for (const n of subFields) {
|
|
46
|
-
parse(n, target);
|
|
47
|
-
}
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
const m = FIELD_PATTERN.exec(f);
|
|
51
|
-
/* istanbul ignore next */
|
|
52
|
-
if (!m)
|
|
53
|
-
throw new TypeError(`Invalid field path (${input})`);
|
|
54
|
-
const fieldName = m[2];
|
|
55
|
-
const treeItem = (target[fieldName] =
|
|
56
|
-
target[fieldName] || new FieldsProjection.Item());
|
|
57
|
-
if (m[1])
|
|
58
|
-
treeItem.sign = m[1];
|
|
59
|
-
if (i === fields.length - 1) {
|
|
60
|
-
delete treeItem.projection;
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
target = treeItem.projection =
|
|
64
|
-
treeItem.projection || new FieldsProjection();
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|