@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,124 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ApiField = void 0;
|
|
4
|
-
const objects_1 = require("@jsopen/objects");
|
|
5
|
-
const ts_gems_1 = require("ts-gems");
|
|
6
|
-
const document_element_js_1 = require("../common/document-element.js");
|
|
7
|
-
const constants_js_1 = require("../constants.js");
|
|
8
|
-
const api_field_decorator_js_1 = require("../decorators/api-field-decorator.js");
|
|
9
|
-
const test_scope_match_js_1 = require("../utils/test-scope-match.js");
|
|
10
|
-
const complex_type_base_js_1 = require("./complex-type-base.js");
|
|
11
|
-
/**
|
|
12
|
-
* @decorator ApiField
|
|
13
|
-
*/
|
|
14
|
-
exports.ApiField = function (...args) {
|
|
15
|
-
// Decorator
|
|
16
|
-
if (!this) {
|
|
17
|
-
const [options] = args;
|
|
18
|
-
return exports.ApiField[constants_js_1.DECORATOR](options);
|
|
19
|
-
}
|
|
20
|
-
// Constructor
|
|
21
|
-
const [owner, initArgs] = args;
|
|
22
|
-
document_element_js_1.DocumentElement.call(this, owner);
|
|
23
|
-
const _this = (0, ts_gems_1.asMutable)(this);
|
|
24
|
-
_this.name = initArgs.name;
|
|
25
|
-
const origin = initArgs.origin || owner;
|
|
26
|
-
/* istanbul ignore next */
|
|
27
|
-
if (!(origin instanceof complex_type_base_js_1.ComplexTypeBase)) {
|
|
28
|
-
throw new Error('Field origin should be one of ComplexType, MappedType or MixinType');
|
|
29
|
-
}
|
|
30
|
-
_this.origin = origin;
|
|
31
|
-
_this.type = initArgs.type || owner.node.getDataType('any');
|
|
32
|
-
_this.description = initArgs.description;
|
|
33
|
-
_this.isArray = initArgs.isArray;
|
|
34
|
-
_this.isNestedEntity = initArgs.isNestedEntity;
|
|
35
|
-
_this.default = initArgs.default;
|
|
36
|
-
_this.fixed = initArgs.fixed;
|
|
37
|
-
_this.required = initArgs.required;
|
|
38
|
-
_this.exclusive = initArgs.exclusive;
|
|
39
|
-
_this.localization = initArgs.localization;
|
|
40
|
-
_this.keyField = initArgs.keyField;
|
|
41
|
-
_this.deprecated = initArgs.deprecated;
|
|
42
|
-
_this.readonly = initArgs.readonly;
|
|
43
|
-
_this.writeonly = initArgs.writeonly;
|
|
44
|
-
_this.examples = initArgs.examples;
|
|
45
|
-
_this.override = initArgs.override;
|
|
46
|
-
_this.scopePattern = initArgs.scopePattern
|
|
47
|
-
? Array.isArray(initArgs.scopePattern)
|
|
48
|
-
? initArgs.scopePattern
|
|
49
|
-
: [initArgs.scopePattern]
|
|
50
|
-
: undefined;
|
|
51
|
-
_this.designType = initArgs.designType;
|
|
52
|
-
_this.override = initArgs.override;
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* The ApiFieldClass represents a descriptive metadata structure for API fields,
|
|
56
|
-
* supporting features like data type definition, scoping, localization, and constraints.
|
|
57
|
-
* This class extends DocumentElement, inheriting base document structure capabilities.
|
|
58
|
-
*/
|
|
59
|
-
class ApiFieldClass extends document_element_js_1.DocumentElement {
|
|
60
|
-
inScope(scope) {
|
|
61
|
-
return (0, test_scope_match_js_1.testScopeMatch)(scope, this.scopePattern);
|
|
62
|
-
}
|
|
63
|
-
forScope(scope) {
|
|
64
|
-
if (!(scope && this.override))
|
|
65
|
-
return this;
|
|
66
|
-
this._overrideCache = this._overrideCache || {};
|
|
67
|
-
let field = this._overrideCache[scope];
|
|
68
|
-
if (field)
|
|
69
|
-
return field;
|
|
70
|
-
if (scope !== '*') {
|
|
71
|
-
for (const o of this.override) {
|
|
72
|
-
if ((0, test_scope_match_js_1.testScopeMatch)(scope, o.scopePattern)) {
|
|
73
|
-
field = (0, objects_1.omitUndefined)({
|
|
74
|
-
...o,
|
|
75
|
-
id: undefined,
|
|
76
|
-
owner: undefined,
|
|
77
|
-
node: undefined,
|
|
78
|
-
origin: undefined,
|
|
79
|
-
name: undefined,
|
|
80
|
-
type: undefined,
|
|
81
|
-
override: undefined,
|
|
82
|
-
_overrideCache: undefined,
|
|
83
|
-
scopePattern: o.scopePattern,
|
|
84
|
-
});
|
|
85
|
-
Object.setPrototypeOf(field, this);
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
field = field || this;
|
|
91
|
-
this._overrideCache[scope] = field;
|
|
92
|
-
return field;
|
|
93
|
-
}
|
|
94
|
-
toJSON(options) {
|
|
95
|
-
const typeName = this.type
|
|
96
|
-
? this.node.getDataTypeNameWithNs(this.type)
|
|
97
|
-
: undefined;
|
|
98
|
-
return (0, objects_1.omitUndefined)({
|
|
99
|
-
type: typeName ? typeName : this.type?.toJSON(options),
|
|
100
|
-
description: this.description,
|
|
101
|
-
isArray: this.isArray || undefined,
|
|
102
|
-
isNestedEntity: this.isNestedEntity || undefined,
|
|
103
|
-
default: this.default,
|
|
104
|
-
fixed: this.fixed,
|
|
105
|
-
required: this.required || undefined,
|
|
106
|
-
exclusive: this.exclusive || undefined,
|
|
107
|
-
localization: this.localization || undefined,
|
|
108
|
-
keyField: this.keyField || undefined,
|
|
109
|
-
deprecated: this.deprecated || undefined,
|
|
110
|
-
readonly: this.readonly || undefined,
|
|
111
|
-
writeonly: this.writeonly || undefined,
|
|
112
|
-
examples: this.examples,
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
generateCodec(codec, options, properties) {
|
|
116
|
-
return this.type.generateCodec(codec, options, {
|
|
117
|
-
...properties,
|
|
118
|
-
designType: this.designType,
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
exports.ApiField.prototype = ApiFieldClass.prototype;
|
|
123
|
-
Object.assign(exports.ApiField, api_field_decorator_js_1.ApiFieldDecoratorFactory);
|
|
124
|
-
exports.ApiField[constants_js_1.DECORATOR] = api_field_decorator_js_1.ApiFieldDecoratorFactory;
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ArrayType = void 0;
|
|
4
|
-
require("reflect-metadata");
|
|
5
|
-
const objects_1 = require("@jsopen/objects");
|
|
6
|
-
const ts_gems_1 = require("ts-gems");
|
|
7
|
-
const valgen_1 = require("valgen");
|
|
8
|
-
const index_js_1 = require("../../schema/index.js");
|
|
9
|
-
const constants_js_1 = require("../constants.js");
|
|
10
|
-
const data_type_js_1 = require("./data-type.js");
|
|
11
|
-
/**
|
|
12
|
-
* @class ArrayType
|
|
13
|
-
*/
|
|
14
|
-
exports.ArrayType = function (...args) {
|
|
15
|
-
// ArrayType factory
|
|
16
|
-
if (!this) {
|
|
17
|
-
return exports.ArrayType[constants_js_1.DECORATOR].apply(undefined, args);
|
|
18
|
-
}
|
|
19
|
-
// Constructor
|
|
20
|
-
const [owner, initArgs, context] = args;
|
|
21
|
-
data_type_js_1.DataType.call(this, owner, initArgs, context);
|
|
22
|
-
const _this = (0, ts_gems_1.asMutable)(this);
|
|
23
|
-
_this.kind = index_js_1.OpraSchema.ArrayType.Kind;
|
|
24
|
-
_this.type = initArgs.type;
|
|
25
|
-
_this.minOccurs = initArgs.minOccurs;
|
|
26
|
-
_this.maxOccurs = initArgs.maxOccurs;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
*
|
|
30
|
-
* @class ArrayType
|
|
31
|
-
*/
|
|
32
|
-
class ArrayTypeClass extends data_type_js_1.DataType {
|
|
33
|
-
toJSON(options) {
|
|
34
|
-
const superJson = super.toJSON(options);
|
|
35
|
-
const typeName = this.node.getDataTypeNameWithNs(this.type);
|
|
36
|
-
return (0, objects_1.omitUndefined)({
|
|
37
|
-
...superJson,
|
|
38
|
-
kind: this.kind,
|
|
39
|
-
type: typeName ? typeName : this.type.toJSON(options),
|
|
40
|
-
minOccurs: this.minOccurs,
|
|
41
|
-
maxOccurs: this.maxOccurs,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
generateCodec(codec, options, properties) {
|
|
45
|
-
let fn = this.type.generateCodec(codec, options, properties);
|
|
46
|
-
fn = valgen_1.vg.isArray(fn);
|
|
47
|
-
const fns = [];
|
|
48
|
-
if (this.minOccurs)
|
|
49
|
-
fns.push(valgen_1.vg.lengthMin(this.minOccurs));
|
|
50
|
-
if (this.maxOccurs)
|
|
51
|
-
fns.push(valgen_1.vg.lengthMax(this.maxOccurs));
|
|
52
|
-
if (fns.length > 0)
|
|
53
|
-
return valgen_1.vg.pipe([fn, ...fns], { returnIndex: 0 });
|
|
54
|
-
return fn;
|
|
55
|
-
}
|
|
56
|
-
extendsFrom() {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
_locateBase() {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
exports.ArrayType.prototype = ArrayTypeClass.prototype;
|
|
64
|
-
exports.ArrayType[constants_js_1.DECORATOR] = ArrayTypeFactory;
|
|
65
|
-
/**
|
|
66
|
-
*
|
|
67
|
-
*/
|
|
68
|
-
function ArrayTypeFactory(clasRefs, options) {
|
|
69
|
-
class ArrayClass {
|
|
70
|
-
}
|
|
71
|
-
const metadata = {
|
|
72
|
-
...options,
|
|
73
|
-
kind: index_js_1.OpraSchema.ArrayType.Kind,
|
|
74
|
-
type: clasRefs,
|
|
75
|
-
};
|
|
76
|
-
Reflect.defineMetadata(constants_js_1.DATATYPE_METADATA, metadata, ArrayClass);
|
|
77
|
-
return ArrayClass;
|
|
78
|
-
}
|
|
@@ -1,346 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ComplexTypeBase = exports.FIELD_PATH_PATTERN = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const object_hash_1 = tslib_1.__importDefault(require("object-hash"));
|
|
6
|
-
const ts_gems_1 = require("ts-gems");
|
|
7
|
-
const valgen_1 = require("valgen");
|
|
8
|
-
const index_js_1 = require("../../helpers/index.js");
|
|
9
|
-
const array_type_js_1 = require("./array-type.js");
|
|
10
|
-
const data_type_js_1 = require("./data-type.js");
|
|
11
|
-
exports.FIELD_PATH_PATTERN = /^([+-])?([a-z$_][\w.]*)$/i;
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* @constructor
|
|
15
|
-
*/
|
|
16
|
-
exports.ComplexTypeBase = function (...args) {
|
|
17
|
-
if (!this)
|
|
18
|
-
throw new TypeError('"this" should be passed to call class constructor');
|
|
19
|
-
// Constructor
|
|
20
|
-
const [owner, initArgs, context] = args;
|
|
21
|
-
data_type_js_1.DataType.call(this, owner, initArgs, context);
|
|
22
|
-
const _this = (0, ts_gems_1.asMutable)(this);
|
|
23
|
-
_this._fields = new index_js_1.ResponsiveMap();
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
*
|
|
27
|
-
*/
|
|
28
|
-
class ComplexTypeBaseClass extends data_type_js_1.DataType {
|
|
29
|
-
fieldCount(scope) {
|
|
30
|
-
if (scope === '*')
|
|
31
|
-
return this._fields.size;
|
|
32
|
-
let count = 0;
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
34
|
-
for (const i of this.fields(scope))
|
|
35
|
-
count++;
|
|
36
|
-
return count;
|
|
37
|
-
}
|
|
38
|
-
fieldEntries(scope) {
|
|
39
|
-
let iterator = this._fields.entries();
|
|
40
|
-
if (scope === '*')
|
|
41
|
-
return iterator;
|
|
42
|
-
let r;
|
|
43
|
-
return {
|
|
44
|
-
next() {
|
|
45
|
-
while (iterator) {
|
|
46
|
-
r = iterator.next();
|
|
47
|
-
if (r.done)
|
|
48
|
-
break;
|
|
49
|
-
if (r.value && r.value[1].inScope(scope))
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
if (r.done)
|
|
53
|
-
return { done: r.done, value: undefined };
|
|
54
|
-
return {
|
|
55
|
-
done: r.done,
|
|
56
|
-
value: [r.value[0], r.value[1].forScope(scope)],
|
|
57
|
-
};
|
|
58
|
-
},
|
|
59
|
-
return(value) {
|
|
60
|
-
iterator = undefined;
|
|
61
|
-
return { done: true, value };
|
|
62
|
-
},
|
|
63
|
-
[Symbol.iterator]() {
|
|
64
|
-
return this;
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
fields(scope) {
|
|
69
|
-
let iterator = this.fieldEntries(scope);
|
|
70
|
-
let r;
|
|
71
|
-
return {
|
|
72
|
-
next() {
|
|
73
|
-
if (!iterator)
|
|
74
|
-
return { done: true, value: undefined };
|
|
75
|
-
r = iterator.next();
|
|
76
|
-
return { done: r.done, value: r.value?.[1] };
|
|
77
|
-
},
|
|
78
|
-
return(value) {
|
|
79
|
-
iterator = undefined;
|
|
80
|
-
return { done: true, value };
|
|
81
|
-
},
|
|
82
|
-
[Symbol.iterator]() {
|
|
83
|
-
return this;
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
fieldNames(scope) {
|
|
88
|
-
if (scope === '*')
|
|
89
|
-
return this._fields.keys();
|
|
90
|
-
let iterator = this.fieldEntries(scope);
|
|
91
|
-
let r;
|
|
92
|
-
return {
|
|
93
|
-
next() {
|
|
94
|
-
if (!iterator)
|
|
95
|
-
return { done: true, value: undefined };
|
|
96
|
-
r = iterator.next();
|
|
97
|
-
return { done: r.done, value: r.value?.[0] };
|
|
98
|
-
},
|
|
99
|
-
return(value) {
|
|
100
|
-
iterator = undefined;
|
|
101
|
-
return { done: true, value };
|
|
102
|
-
},
|
|
103
|
-
[Symbol.iterator]() {
|
|
104
|
-
return this;
|
|
105
|
-
},
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
*
|
|
110
|
-
*/
|
|
111
|
-
findField(nameOrPath, scope) {
|
|
112
|
-
if (nameOrPath.includes('.')) {
|
|
113
|
-
const fieldPath = this.parseFieldPath(nameOrPath, { scope });
|
|
114
|
-
if (fieldPath.length === 0)
|
|
115
|
-
throw new Error(`Field "${nameOrPath}" does not exist in scope "${scope}"`);
|
|
116
|
-
const lastItem = fieldPath.pop();
|
|
117
|
-
return lastItem?.field;
|
|
118
|
-
}
|
|
119
|
-
const field = this._fields.get(nameOrPath);
|
|
120
|
-
if (field && field.inScope(scope))
|
|
121
|
-
return field.forScope(scope);
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
*
|
|
125
|
-
*/
|
|
126
|
-
getField(nameOrPath, scope) {
|
|
127
|
-
const field = this.findField(nameOrPath, '*');
|
|
128
|
-
if (field && !field.inScope(scope))
|
|
129
|
-
throw new Error(`Field "${nameOrPath}" does not exist in scope "${scope || 'null'}"`);
|
|
130
|
-
if (!field) {
|
|
131
|
-
throw new Error(`Field (${nameOrPath}) does not exist`);
|
|
132
|
-
}
|
|
133
|
-
return field.forScope(scope);
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
*
|
|
137
|
-
*/
|
|
138
|
-
parseFieldPath(fieldPath, options) {
|
|
139
|
-
let dataType = this;
|
|
140
|
-
let field;
|
|
141
|
-
const arr = fieldPath.split('.');
|
|
142
|
-
const len = arr.length;
|
|
143
|
-
const out = [];
|
|
144
|
-
const objectType = this.owner.node.getDataType('object');
|
|
145
|
-
const allowSigns = options?.allowSigns;
|
|
146
|
-
const getStrPath = () => out.map(x => x.fieldName).join('.');
|
|
147
|
-
for (let i = 0; i < len; i++) {
|
|
148
|
-
const item = {
|
|
149
|
-
fieldName: arr[i],
|
|
150
|
-
dataType: objectType,
|
|
151
|
-
};
|
|
152
|
-
out.push(item);
|
|
153
|
-
const m = exports.FIELD_PATH_PATTERN.exec(arr[i]);
|
|
154
|
-
if (!m)
|
|
155
|
-
throw new TypeError(`Invalid field name (${getStrPath()})`);
|
|
156
|
-
if (m[1]) {
|
|
157
|
-
if ((i === 0 && allowSigns === 'first') || allowSigns === 'each')
|
|
158
|
-
item.sign = m[1];
|
|
159
|
-
item.fieldName = m[2];
|
|
160
|
-
}
|
|
161
|
-
if (dataType) {
|
|
162
|
-
if (dataType instanceof exports.ComplexTypeBase) {
|
|
163
|
-
field = dataType.findField(item.fieldName, options?.scope);
|
|
164
|
-
if (field) {
|
|
165
|
-
item.fieldName = field.name;
|
|
166
|
-
item.field = field;
|
|
167
|
-
item.dataType = field.type;
|
|
168
|
-
dataType = field.type;
|
|
169
|
-
continue;
|
|
170
|
-
}
|
|
171
|
-
if (dataType.additionalFields?.[0] === true) {
|
|
172
|
-
item.additionalField = true;
|
|
173
|
-
item.dataType = objectType;
|
|
174
|
-
dataType = undefined;
|
|
175
|
-
continue;
|
|
176
|
-
}
|
|
177
|
-
if (dataType.additionalFields?.[0] === 'type' &&
|
|
178
|
-
dataType.additionalFields?.[1] instanceof data_type_js_1.DataType) {
|
|
179
|
-
item.additionalField = true;
|
|
180
|
-
item.dataType = dataType.additionalFields[1];
|
|
181
|
-
dataType = dataType.additionalFields[1];
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
throw new Error(`Unknown field (${out.map(x => x.fieldName).join('.')})`);
|
|
185
|
-
}
|
|
186
|
-
throw new TypeError(`"${out.map(x => x.fieldName).join('.')}" field is not a complex type and has no child fields`);
|
|
187
|
-
}
|
|
188
|
-
item.additionalField = true;
|
|
189
|
-
item.dataType = objectType;
|
|
190
|
-
}
|
|
191
|
-
return out;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
*
|
|
195
|
-
*/
|
|
196
|
-
normalizeFieldPath(fieldPath, options) {
|
|
197
|
-
return this.parseFieldPath(fieldPath, options)
|
|
198
|
-
.map(x => (x.sign || '') + x.fieldName)
|
|
199
|
-
.join('.');
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
*
|
|
203
|
-
*/
|
|
204
|
-
generateCodec(codec, options) {
|
|
205
|
-
const context = options?.cache
|
|
206
|
-
? options
|
|
207
|
-
: {
|
|
208
|
-
...options,
|
|
209
|
-
projection: Array.isArray(options?.projection)
|
|
210
|
-
? (0, index_js_1.parseFieldsProjection)(options.projection)
|
|
211
|
-
: options?.projection,
|
|
212
|
-
currentPath: '',
|
|
213
|
-
};
|
|
214
|
-
const schema = this._generateSchema(codec, context);
|
|
215
|
-
let additionalFields;
|
|
216
|
-
if (this.additionalFields instanceof data_type_js_1.DataType) {
|
|
217
|
-
additionalFields = this.additionalFields.generateCodec(codec, options);
|
|
218
|
-
}
|
|
219
|
-
else if (typeof this.additionalFields === 'boolean')
|
|
220
|
-
additionalFields = this.additionalFields;
|
|
221
|
-
else if (Array.isArray(this.additionalFields)) {
|
|
222
|
-
if (this.additionalFields.length < 2)
|
|
223
|
-
additionalFields = 'error';
|
|
224
|
-
else {
|
|
225
|
-
const message = additionalFields[1];
|
|
226
|
-
additionalFields = (0, valgen_1.validator)((input, ctx, _this) => ctx.fail(_this, message, input));
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
const fn = valgen_1.vg.isObject(schema, {
|
|
230
|
-
ctor: this.name === 'object' ? Object : this.ctor,
|
|
231
|
-
additionalFields,
|
|
232
|
-
name: this.name,
|
|
233
|
-
coerce: true,
|
|
234
|
-
caseInSensitive: options?.caseInSensitive,
|
|
235
|
-
onFail: options?.onFail,
|
|
236
|
-
});
|
|
237
|
-
if (context.level === 0 && context.forwardCallbacks?.size) {
|
|
238
|
-
for (const cb of context.forwardCallbacks) {
|
|
239
|
-
cb();
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
return fn;
|
|
243
|
-
}
|
|
244
|
-
_generateSchema(codec, context) {
|
|
245
|
-
context.fieldCache = context.fieldCache || new Map();
|
|
246
|
-
context.level = context.level || 0;
|
|
247
|
-
context.forwardCallbacks = context.forwardCallbacks || new Set();
|
|
248
|
-
const schema = {};
|
|
249
|
-
const { currentPath, projection } = context;
|
|
250
|
-
const pickList = !!(projection && Object.values(projection).find(p => !p.sign));
|
|
251
|
-
// Process fields
|
|
252
|
-
let fieldName;
|
|
253
|
-
for (const field of this.fields('*')) {
|
|
254
|
-
if (
|
|
255
|
-
/** Ignore field if required scope(s) do not match field scopes */
|
|
256
|
-
!field.inScope(context.scope) ||
|
|
257
|
-
(!(context.keepKeyFields && this.keyField) &&
|
|
258
|
-
/** Ignore field if readonly and ignoreReadonlyFields option true */
|
|
259
|
-
((context.ignoreReadonlyFields && field.readonly) ||
|
|
260
|
-
/** Ignore field if writeonly and ignoreWriteonlyFields option true */
|
|
261
|
-
(context.ignoreWriteonlyFields && field.writeonly)))) {
|
|
262
|
-
schema[field.name] = valgen_1.vg.isUndefined({ coerce: true });
|
|
263
|
-
continue;
|
|
264
|
-
}
|
|
265
|
-
fieldName = field.name;
|
|
266
|
-
let p;
|
|
267
|
-
if (projection !== '*') {
|
|
268
|
-
p = projection?.[fieldName.toLowerCase()];
|
|
269
|
-
if (
|
|
270
|
-
/** Ignore if field is omitted */
|
|
271
|
-
p?.sign === '-' ||
|
|
272
|
-
/** Ignore if default fields ignored and field is not in projection */
|
|
273
|
-
(pickList && !p) ||
|
|
274
|
-
/** Ignore if default fields enabled and fields is exclusive */
|
|
275
|
-
(!pickList && field.exclusive && !p)) {
|
|
276
|
-
schema[field.name] = valgen_1.vg.isUndefined({ coerce: true });
|
|
277
|
-
continue;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
const subProjection = typeof projection === 'object'
|
|
281
|
-
? projection[fieldName]?.projection || '*'
|
|
282
|
-
: projection;
|
|
283
|
-
let cacheItem = context.fieldCache.get(field);
|
|
284
|
-
const cacheKey = typeof subProjection === 'string'
|
|
285
|
-
? subProjection
|
|
286
|
-
: (0, object_hash_1.default)(subProjection || {});
|
|
287
|
-
if (!cacheItem) {
|
|
288
|
-
cacheItem = {};
|
|
289
|
-
context.fieldCache.set(field, cacheItem);
|
|
290
|
-
}
|
|
291
|
-
let fn = cacheItem[cacheKey];
|
|
292
|
-
/** If in progress (circular) */
|
|
293
|
-
if (fn === null) {
|
|
294
|
-
// Temporary set any
|
|
295
|
-
fn = valgen_1.vg.isAny();
|
|
296
|
-
context.forwardCallbacks.add(() => {
|
|
297
|
-
fn = cacheItem[cacheKey];
|
|
298
|
-
schema[fieldName] =
|
|
299
|
-
context.partial || !field.required
|
|
300
|
-
? valgen_1.vg.optional(fn)
|
|
301
|
-
: valgen_1.vg.required(fn);
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
else if (!fn) {
|
|
305
|
-
const defaultGenerator = () => {
|
|
306
|
-
cacheItem[cacheKey] = null;
|
|
307
|
-
const xfn = this._generateFieldCodec(codec, field, {
|
|
308
|
-
...context,
|
|
309
|
-
partial: context.partial === 'deep' ? context.partial : undefined,
|
|
310
|
-
projection: subProjection,
|
|
311
|
-
currentPath: currentPath + (currentPath ? '.' : '') + fieldName,
|
|
312
|
-
});
|
|
313
|
-
cacheItem[cacheKey] = xfn;
|
|
314
|
-
return xfn;
|
|
315
|
-
};
|
|
316
|
-
if (context.fieldHook)
|
|
317
|
-
fn = context.fieldHook(field, context.currentPath, defaultGenerator);
|
|
318
|
-
else
|
|
319
|
-
fn = defaultGenerator();
|
|
320
|
-
}
|
|
321
|
-
schema[fieldName] =
|
|
322
|
-
context.partial || !(field.required || fn.id === 'required')
|
|
323
|
-
? valgen_1.vg.optional(fn)
|
|
324
|
-
: fn.id === 'required'
|
|
325
|
-
? fn
|
|
326
|
-
: valgen_1.vg.required(fn);
|
|
327
|
-
}
|
|
328
|
-
if (context.allowPatchOperators) {
|
|
329
|
-
schema._$pull = valgen_1.vg.optional(valgen_1.vg.isAny());
|
|
330
|
-
schema._$push = valgen_1.vg.optional(valgen_1.vg.isAny());
|
|
331
|
-
}
|
|
332
|
-
return schema;
|
|
333
|
-
}
|
|
334
|
-
_generateFieldCodec(codec, field, context) {
|
|
335
|
-
let fn = field.generateCodec(codec, {
|
|
336
|
-
...context,
|
|
337
|
-
level: context.level + 1,
|
|
338
|
-
});
|
|
339
|
-
if (field.fixed)
|
|
340
|
-
fn = valgen_1.vg.isEqual(field.fixed);
|
|
341
|
-
if (field.isArray && !(field.type instanceof array_type_js_1.ArrayType))
|
|
342
|
-
fn = valgen_1.vg.isArray(fn);
|
|
343
|
-
return fn;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
exports.ComplexTypeBase.prototype = ComplexTypeBaseClass.prototype;
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ComplexType = void 0;
|
|
4
|
-
require("reflect-metadata");
|
|
5
|
-
const objects_1 = require("@jsopen/objects");
|
|
6
|
-
const ts_gems_1 = require("ts-gems");
|
|
7
|
-
const index_js_1 = require("../../schema/index.js");
|
|
8
|
-
const document_init_context_js_1 = require("../common/document-init-context.js");
|
|
9
|
-
const constants_js_1 = require("../constants.js");
|
|
10
|
-
const complex_type_decorator_js_1 = require("../decorators/complex-type.decorator.js");
|
|
11
|
-
const api_field_js_1 = require("./api-field.js");
|
|
12
|
-
const complex_type_base_js_1 = require("./complex-type-base.js");
|
|
13
|
-
const data_type_js_1 = require("./data-type.js");
|
|
14
|
-
/**
|
|
15
|
-
* ComplexType constructor
|
|
16
|
-
*/
|
|
17
|
-
exports.ComplexType = function (...args) {
|
|
18
|
-
// Decorator
|
|
19
|
-
if (!this)
|
|
20
|
-
return exports.ComplexType[constants_js_1.DECORATOR].apply(undefined, args);
|
|
21
|
-
// Constructor
|
|
22
|
-
const [owner, initArgs] = args;
|
|
23
|
-
const context = args[2] || new document_init_context_js_1.DocumentInitContext({ maxErrors: 0 });
|
|
24
|
-
complex_type_base_js_1.ComplexTypeBase.call(this, owner, initArgs, context);
|
|
25
|
-
const _this = (0, ts_gems_1.asMutable)(this);
|
|
26
|
-
_this.kind = index_js_1.OpraSchema.ComplexType.Kind;
|
|
27
|
-
_this.discriminatorField = initArgs.discriminatorField;
|
|
28
|
-
_this.discriminatorValue = initArgs.discriminatorValue;
|
|
29
|
-
if (initArgs.base) {
|
|
30
|
-
context.enter('.base', () => {
|
|
31
|
-
// noinspection SuspiciousTypeOfGuard
|
|
32
|
-
if (!(initArgs.base instanceof complex_type_base_js_1.ComplexTypeBase)) {
|
|
33
|
-
throw new TypeError(`"${initArgs.base.kind}" can't be set as base for a "${this.kind}"`);
|
|
34
|
-
}
|
|
35
|
-
_this.base = initArgs.base;
|
|
36
|
-
_this.additionalFields = _this.base.additionalFields;
|
|
37
|
-
_this.keyField = _this.base.keyField;
|
|
38
|
-
/** Copy fields from base */
|
|
39
|
-
for (const v of _this.base.fields('*')) {
|
|
40
|
-
_this._fields.set(v.name, new api_field_js_1.ApiField(this, v));
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
if (initArgs.additionalFields !== undefined)
|
|
45
|
-
_this.additionalFields = initArgs.additionalFields;
|
|
46
|
-
if (initArgs.keyField !== undefined)
|
|
47
|
-
_this.keyField = initArgs.keyField;
|
|
48
|
-
_this.ctor = initArgs.ctor || _this.base?.ctor;
|
|
49
|
-
/** Add own fields */
|
|
50
|
-
if (initArgs.fields) {
|
|
51
|
-
context.enter('.fields', () => {
|
|
52
|
-
for (const [k, v] of Object.entries(initArgs.fields)) {
|
|
53
|
-
const field = new api_field_js_1.ApiField(this, {
|
|
54
|
-
...v,
|
|
55
|
-
name: k,
|
|
56
|
-
});
|
|
57
|
-
this._fields.set(field.name, field);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
*
|
|
64
|
-
* @class ComplexType
|
|
65
|
-
*/
|
|
66
|
-
class ComplexTypeClass extends complex_type_base_js_1.ComplexTypeBase {
|
|
67
|
-
extendsFrom(baseType) {
|
|
68
|
-
if (!(baseType instanceof data_type_js_1.DataType))
|
|
69
|
-
baseType = this.node.getDataType(baseType);
|
|
70
|
-
if (!(baseType instanceof complex_type_base_js_1.ComplexTypeBase))
|
|
71
|
-
return false;
|
|
72
|
-
if (baseType === this)
|
|
73
|
-
return true;
|
|
74
|
-
return !!this.base?.extendsFrom(baseType);
|
|
75
|
-
}
|
|
76
|
-
toJSON(options) {
|
|
77
|
-
const superJson = super.toJSON(options);
|
|
78
|
-
const baseName = this.base
|
|
79
|
-
? this.node.getDataTypeNameWithNs(this.base)
|
|
80
|
-
: undefined;
|
|
81
|
-
const out = {
|
|
82
|
-
...superJson,
|
|
83
|
-
kind: this.kind,
|
|
84
|
-
base: this.base
|
|
85
|
-
? baseName
|
|
86
|
-
? baseName
|
|
87
|
-
: this.base.toJSON(options)
|
|
88
|
-
: undefined,
|
|
89
|
-
discriminatorField: this.discriminatorField,
|
|
90
|
-
discriminatorValue: this.discriminatorValue,
|
|
91
|
-
};
|
|
92
|
-
if (this.additionalFields) {
|
|
93
|
-
if (this.additionalFields instanceof data_type_js_1.DataType) {
|
|
94
|
-
const typeName = this.node.getDataTypeNameWithNs(this.additionalFields);
|
|
95
|
-
out.additionalFields = typeName
|
|
96
|
-
? typeName
|
|
97
|
-
: this.additionalFields.toJSON(options);
|
|
98
|
-
}
|
|
99
|
-
else
|
|
100
|
-
out.additionalFields = this.additionalFields;
|
|
101
|
-
}
|
|
102
|
-
if (this._fields.size) {
|
|
103
|
-
const fields = {};
|
|
104
|
-
let i = 0;
|
|
105
|
-
for (const field of this._fields.values()) {
|
|
106
|
-
if (field.origin === this && field.inScope(options?.scope)) {
|
|
107
|
-
fields[field.name] = field.toJSON(options);
|
|
108
|
-
i++;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
if (i)
|
|
112
|
-
out.fields = fields;
|
|
113
|
-
}
|
|
114
|
-
return (0, objects_1.omitUndefined)(out);
|
|
115
|
-
}
|
|
116
|
-
_locateBase(callback) {
|
|
117
|
-
if (!this.base)
|
|
118
|
-
return;
|
|
119
|
-
if (callback(this.base))
|
|
120
|
-
return this.base;
|
|
121
|
-
if (this.base._locateBase)
|
|
122
|
-
return this.base._locateBase(callback);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
exports.ComplexType.prototype = ComplexTypeClass.prototype;
|
|
126
|
-
Object.assign(exports.ComplexType, complex_type_decorator_js_1.ComplexTypeDecorator);
|
|
127
|
-
exports.ComplexType[constants_js_1.DECORATOR] = complex_type_decorator_js_1.ComplexTypeDecorator;
|