@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,302 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpApiFactory = void 0;
|
|
4
|
-
const objects_1 = require("@jsopen/objects");
|
|
5
|
-
const index_js_1 = require("../../helpers/index.js");
|
|
6
|
-
const constants_js_1 = require("../constants.js");
|
|
7
|
-
const http_api_js_1 = require("../http/http-api.js");
|
|
8
|
-
const http_controller_js_1 = require("../http/http-controller.js");
|
|
9
|
-
const http_media_type_js_1 = require("../http/http-media-type.js");
|
|
10
|
-
const http_multipart_field_js_1 = require("../http/http-multipart-field.js");
|
|
11
|
-
const http_operation_js_1 = require("../http/http-operation.js");
|
|
12
|
-
const http_operation_response_js_1 = require("../http/http-operation-response.js");
|
|
13
|
-
const http_parameter_js_1 = require("../http/http-parameter.js");
|
|
14
|
-
const http_request_body_js_1 = require("../http/http-request-body.js");
|
|
15
|
-
const data_type_factory_js_1 = require("./data-type.factory.js");
|
|
16
|
-
/**
|
|
17
|
-
* @class HttpApiFactory
|
|
18
|
-
*/
|
|
19
|
-
class HttpApiFactory {
|
|
20
|
-
/**
|
|
21
|
-
* Generates HttpApi
|
|
22
|
-
* @param context
|
|
23
|
-
* @param init
|
|
24
|
-
*/
|
|
25
|
-
static async createApi(context, init) {
|
|
26
|
-
const api = new http_api_js_1.HttpApi(init);
|
|
27
|
-
if (init.controllers) {
|
|
28
|
-
await context.enterAsync('.controllers', async () => {
|
|
29
|
-
await this._createControllers(context, api, init.controllers);
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
return api;
|
|
33
|
-
}
|
|
34
|
-
static async _createControllers(context, parent, controllers) {
|
|
35
|
-
if (Array.isArray(controllers)) {
|
|
36
|
-
let i = 0;
|
|
37
|
-
for (const c of controllers) {
|
|
38
|
-
let r;
|
|
39
|
-
await context.enterAsync(`[${i++}]`, async () => {
|
|
40
|
-
r = await this._resolveControllerMetadata(context, parent, c);
|
|
41
|
-
});
|
|
42
|
-
if (!r)
|
|
43
|
-
continue;
|
|
44
|
-
await context.enterAsync(`[${r.metadata.name}]`, async () => {
|
|
45
|
-
const controller = await this._createController(context, parent, r.metadata, r.instance, r.ctor);
|
|
46
|
-
if (controller) {
|
|
47
|
-
if (parent.controllers.get(controller.name))
|
|
48
|
-
context.addError(`Duplicate controller name (${r.name})`);
|
|
49
|
-
parent.controllers.set(controller.name, controller);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
for (const [k, c] of Object.entries(controllers)) {
|
|
56
|
-
await context.enterAsync(`[${k}]`, async () => {
|
|
57
|
-
const r = await this._resolveControllerMetadata(context, parent, c);
|
|
58
|
-
if (!r)
|
|
59
|
-
return;
|
|
60
|
-
const controller = await this._createController(context, parent, {
|
|
61
|
-
...r.metadata,
|
|
62
|
-
name: k,
|
|
63
|
-
}, r.instance, r.ctor);
|
|
64
|
-
if (controller) {
|
|
65
|
-
if (parent.controllers.get(controller.name))
|
|
66
|
-
context.addError(`Duplicate controller name (${k})`);
|
|
67
|
-
parent.controllers.set(controller.name, controller);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
static async _resolveControllerMetadata(context, parent, thunk) {
|
|
73
|
-
if (typeof thunk === 'function' && !(0, objects_1.isConstructor)(thunk)) {
|
|
74
|
-
thunk =
|
|
75
|
-
parent instanceof http_controller_js_1.HttpController ? thunk(parent.instance) : thunk();
|
|
76
|
-
}
|
|
77
|
-
thunk = await (0, index_js_1.resolveThunk)(thunk);
|
|
78
|
-
let ctor;
|
|
79
|
-
let metadata;
|
|
80
|
-
let instance;
|
|
81
|
-
// If thunk is a class
|
|
82
|
-
if (typeof thunk === 'function') {
|
|
83
|
-
metadata = Reflect.getMetadata(constants_js_1.HTTP_CONTROLLER_METADATA, thunk);
|
|
84
|
-
if (!metadata)
|
|
85
|
-
return context.addError(`Class "${thunk.name}" doesn't have a valid HttpController metadata`);
|
|
86
|
-
ctor = thunk;
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
// If thunk is an instance of a class decorated with HttpController()
|
|
90
|
-
ctor = Object.getPrototypeOf(thunk).constructor;
|
|
91
|
-
metadata = Reflect.getMetadata(constants_js_1.HTTP_CONTROLLER_METADATA, ctor);
|
|
92
|
-
if (metadata)
|
|
93
|
-
instance = thunk;
|
|
94
|
-
else {
|
|
95
|
-
// If thunk is a DecoratorMetadata or InitArguments
|
|
96
|
-
metadata = thunk;
|
|
97
|
-
if (thunk.instance === 'object') {
|
|
98
|
-
instance = thunk.instance;
|
|
99
|
-
ctor = Object.getPrototypeOf(instance).constructor;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
if (!metadata)
|
|
104
|
-
return context.addError(`Class "${ctor.name}" is not decorated with HttpController()`);
|
|
105
|
-
return { metadata, instance, ctor };
|
|
106
|
-
}
|
|
107
|
-
static async _createController(context, parent, metadata, instance, ctor) {
|
|
108
|
-
if (!metadata.name)
|
|
109
|
-
throw new TypeError(`Controller name required`);
|
|
110
|
-
const controller = new http_controller_js_1.HttpController(parent, {
|
|
111
|
-
...metadata,
|
|
112
|
-
instance,
|
|
113
|
-
ctor,
|
|
114
|
-
});
|
|
115
|
-
if (metadata.types) {
|
|
116
|
-
await context.enterAsync('.types', async () => {
|
|
117
|
-
await data_type_factory_js_1.DataTypeFactory.addDataTypes(context, controller, metadata.types);
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
if (metadata.parameters) {
|
|
121
|
-
await context.enterAsync('.parameters', async () => {
|
|
122
|
-
let i = 0;
|
|
123
|
-
for (const v of metadata.parameters) {
|
|
124
|
-
await context.enterAsync(`[${i++}]`, async () => {
|
|
125
|
-
const prmArgs = { ...v };
|
|
126
|
-
await context.enterAsync('.type', async () => {
|
|
127
|
-
prmArgs.type = await data_type_factory_js_1.DataTypeFactory.resolveDataType(context, controller, v.type);
|
|
128
|
-
});
|
|
129
|
-
const prm = new http_parameter_js_1.HttpParameter(controller, prmArgs);
|
|
130
|
-
controller.parameters.push(prm);
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
if (metadata.operations) {
|
|
136
|
-
await context.enterAsync('.operations', async () => {
|
|
137
|
-
for (const [k, v] of Object.entries(metadata.operations)) {
|
|
138
|
-
await context.enterAsync(`[${k}]`, async () => {
|
|
139
|
-
const operation = new http_operation_js_1.HttpOperation(controller, {
|
|
140
|
-
name: k,
|
|
141
|
-
method: 'GET',
|
|
142
|
-
});
|
|
143
|
-
await this._initHttpOperation(context, operation, v);
|
|
144
|
-
controller.operations.set(k, operation);
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
if (metadata.controllers) {
|
|
150
|
-
await context.enterAsync('.controllers', async () => {
|
|
151
|
-
await this._createControllers(context, controller, metadata.controllers);
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
return controller;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Initializes HttpOperation
|
|
158
|
-
* @param context
|
|
159
|
-
* @param operation
|
|
160
|
-
* @param metadata
|
|
161
|
-
* @protected
|
|
162
|
-
*/
|
|
163
|
-
static async _initHttpOperation(context, operation, metadata) {
|
|
164
|
-
const initArgs = {
|
|
165
|
-
...metadata,
|
|
166
|
-
name: operation.name,
|
|
167
|
-
types: undefined,
|
|
168
|
-
};
|
|
169
|
-
http_operation_js_1.HttpOperation.apply(operation, [operation.owner, initArgs]);
|
|
170
|
-
if (metadata.types) {
|
|
171
|
-
await context.enterAsync('.types', async () => {
|
|
172
|
-
await data_type_factory_js_1.DataTypeFactory.addDataTypes(context, operation, metadata.types);
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
if (metadata.parameters) {
|
|
176
|
-
await context.enterAsync('.parameters', async () => {
|
|
177
|
-
let i = 0;
|
|
178
|
-
for (const v of metadata.parameters) {
|
|
179
|
-
await context.enterAsync(`[${i++}]`, async () => {
|
|
180
|
-
const prmArgs = { ...v };
|
|
181
|
-
await context.enterAsync('.type', async () => {
|
|
182
|
-
prmArgs.type = await data_type_factory_js_1.DataTypeFactory.resolveDataType(context, operation, v.type);
|
|
183
|
-
});
|
|
184
|
-
const prm = new http_parameter_js_1.HttpParameter(operation, prmArgs);
|
|
185
|
-
operation.parameters.push(prm);
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
if (metadata.responses) {
|
|
191
|
-
await context.enterAsync('.responses', async () => {
|
|
192
|
-
let i = 0;
|
|
193
|
-
for (const v of metadata.responses) {
|
|
194
|
-
await context.enterAsync(`[${i++}]`, async () => {
|
|
195
|
-
const response = new http_operation_response_js_1.HttpOperationResponse(operation, {
|
|
196
|
-
statusCode: v.statusCode,
|
|
197
|
-
});
|
|
198
|
-
await this._initHttpOperationResponse(context, response, v);
|
|
199
|
-
operation.responses.push(response);
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
if (metadata.requestBody) {
|
|
205
|
-
await context.enterAsync('.requestBody', async () => {
|
|
206
|
-
const requestBody = new http_request_body_js_1.HttpRequestBody(operation);
|
|
207
|
-
await this._initHttpRequestBody(context, requestBody, metadata.requestBody);
|
|
208
|
-
operation.requestBody = requestBody;
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
return operation;
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Initializes HttpMediaType
|
|
215
|
-
* @param context
|
|
216
|
-
* @param target
|
|
217
|
-
* @param metadata
|
|
218
|
-
* @protected
|
|
219
|
-
*/
|
|
220
|
-
static async _initHttpMediaType(context, target, metadata) {
|
|
221
|
-
http_media_type_js_1.HttpMediaType.call(target, target.owner, {
|
|
222
|
-
...metadata,
|
|
223
|
-
type: undefined,
|
|
224
|
-
multipartFields: undefined,
|
|
225
|
-
});
|
|
226
|
-
if (metadata.type) {
|
|
227
|
-
await context.enterAsync('.type', async () => {
|
|
228
|
-
target.type = await data_type_factory_js_1.DataTypeFactory.resolveDataType(context, target, metadata.type);
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
if (metadata.multipartFields) {
|
|
232
|
-
await context.enterAsync('.multipartFields', async () => {
|
|
233
|
-
for (let i = 0; i < metadata.multipartFields.length; i++) {
|
|
234
|
-
await context.enterAsync(`[${i}]`, async () => {
|
|
235
|
-
const src = metadata.multipartFields[i];
|
|
236
|
-
const field = new http_multipart_field_js_1.HttpMultipartField(target, {
|
|
237
|
-
fieldName: src.fieldName,
|
|
238
|
-
fieldType: src.fieldType,
|
|
239
|
-
});
|
|
240
|
-
await this._initHttpMediaType(context, field, src);
|
|
241
|
-
target.multipartFields.push(field);
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Initializes HttpOperationResponse
|
|
249
|
-
* @param context
|
|
250
|
-
* @param target
|
|
251
|
-
* @param metadata
|
|
252
|
-
* @protected
|
|
253
|
-
*/
|
|
254
|
-
static async _initHttpOperationResponse(context, target, metadata) {
|
|
255
|
-
await this._initHttpMediaType(context, target, metadata);
|
|
256
|
-
target.partial = metadata.partial;
|
|
257
|
-
if (metadata.parameters) {
|
|
258
|
-
await context.enterAsync('.parameters', async () => {
|
|
259
|
-
let i = 0;
|
|
260
|
-
for (const v of metadata.parameters) {
|
|
261
|
-
await context.enterAsync(`[${i++}]`, async () => {
|
|
262
|
-
const prmArgs = { ...v };
|
|
263
|
-
await context.enterAsync('.type', async () => {
|
|
264
|
-
prmArgs.type = await data_type_factory_js_1.DataTypeFactory.resolveDataType(context, target, v.type);
|
|
265
|
-
});
|
|
266
|
-
const prm = new http_parameter_js_1.HttpParameter(target, prmArgs);
|
|
267
|
-
target.parameters.push(prm);
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* Initializes HttpRequestBody
|
|
275
|
-
* @param context
|
|
276
|
-
* @param target
|
|
277
|
-
* @param metadata
|
|
278
|
-
* @protected
|
|
279
|
-
*/
|
|
280
|
-
static async _initHttpRequestBody(context, target, metadata) {
|
|
281
|
-
target.description = metadata.description;
|
|
282
|
-
target.required = metadata.required;
|
|
283
|
-
target.maxContentSize = metadata.maxContentSize;
|
|
284
|
-
target.immediateFetch = metadata.immediateFetch;
|
|
285
|
-
target.partial = metadata.partial;
|
|
286
|
-
target.allowPatchOperators = metadata.allowPatchOperators;
|
|
287
|
-
target.keepKeyFields = metadata.keepKeyFields;
|
|
288
|
-
if (metadata.content) {
|
|
289
|
-
await context.enterAsync('.content', async () => {
|
|
290
|
-
for (let i = 0; i < metadata.content.length; i++) {
|
|
291
|
-
await context.enterAsync(`[${i}]`, async () => {
|
|
292
|
-
const src = metadata.content[i];
|
|
293
|
-
const field = new http_media_type_js_1.HttpMediaType(target, String(i));
|
|
294
|
-
await this._initHttpMediaType(context, field, src);
|
|
295
|
-
target.content.push(field);
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
exports.HttpApiFactory = HttpApiFactory;
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MQApiFactory = void 0;
|
|
4
|
-
const objects_1 = require("@jsopen/objects");
|
|
5
|
-
const index_js_1 = require("../../helpers/index.js");
|
|
6
|
-
const constants_js_1 = require("../constants.js");
|
|
7
|
-
const mq_api_js_1 = require("../mq/mq-api.js");
|
|
8
|
-
const mq_controller_js_1 = require("../mq/mq-controller.js");
|
|
9
|
-
const mq_header_js_1 = require("../mq/mq-header.js");
|
|
10
|
-
const mq_operation_js_1 = require("../mq/mq-operation.js");
|
|
11
|
-
const mq_operation_response_js_1 = require("../mq/mq-operation-response.js");
|
|
12
|
-
const data_type_factory_js_1 = require("./data-type.factory.js");
|
|
13
|
-
/**
|
|
14
|
-
* @class MQApiFactory
|
|
15
|
-
*/
|
|
16
|
-
class MQApiFactory {
|
|
17
|
-
/**
|
|
18
|
-
* Generates MQApi
|
|
19
|
-
* @param context
|
|
20
|
-
* @param init
|
|
21
|
-
*/
|
|
22
|
-
static async createApi(context, init) {
|
|
23
|
-
const api = new mq_api_js_1.MQApi(init);
|
|
24
|
-
if (init.controllers) {
|
|
25
|
-
await context.enterAsync('.controllers', async () => {
|
|
26
|
-
if (Array.isArray(init.controllers)) {
|
|
27
|
-
for (const c of init.controllers) {
|
|
28
|
-
const controller = await this._createController(context, api, c);
|
|
29
|
-
if (controller)
|
|
30
|
-
api.controllers.set(controller.name, controller);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
for (const [k, v] of Object.entries(init.controllers)) {
|
|
35
|
-
const controller = await this._createController(context, api, v, k);
|
|
36
|
-
if (controller)
|
|
37
|
-
api.controllers.set(controller.name, controller);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
return api;
|
|
43
|
-
}
|
|
44
|
-
static async _createController(context, parent, thunk, name) {
|
|
45
|
-
if (typeof thunk === 'function' && !(0, objects_1.isConstructor)(thunk)) {
|
|
46
|
-
thunk = thunk();
|
|
47
|
-
}
|
|
48
|
-
thunk = await (0, index_js_1.resolveThunk)(thunk);
|
|
49
|
-
let ctor;
|
|
50
|
-
let metadata;
|
|
51
|
-
let instance;
|
|
52
|
-
// If thunk is a class
|
|
53
|
-
if (typeof thunk === 'function') {
|
|
54
|
-
metadata = Reflect.getMetadata(constants_js_1.MQ_CONTROLLER_METADATA, thunk);
|
|
55
|
-
if (!metadata)
|
|
56
|
-
return context.addError(`Class "${thunk.name}" doesn't have a valid MQController metadata`);
|
|
57
|
-
ctor = thunk;
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
// If thunk is an instance of a class decorated with MQController()
|
|
61
|
-
ctor = Object.getPrototypeOf(thunk).constructor;
|
|
62
|
-
metadata = Reflect.getMetadata(constants_js_1.MQ_CONTROLLER_METADATA, ctor);
|
|
63
|
-
if (metadata)
|
|
64
|
-
instance = thunk;
|
|
65
|
-
else {
|
|
66
|
-
// If thunk is a DecoratorMetadata or InitArguments
|
|
67
|
-
metadata = thunk;
|
|
68
|
-
if (thunk.instance === 'object') {
|
|
69
|
-
instance = thunk.instance;
|
|
70
|
-
ctor = Object.getPrototypeOf(instance).constructor;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
if (!metadata)
|
|
75
|
-
return context.addError(`Class "${ctor.name}" is not decorated with MQController()`);
|
|
76
|
-
name = name || metadata.name;
|
|
77
|
-
if (!name)
|
|
78
|
-
throw new TypeError(`Controller name required`);
|
|
79
|
-
const controller = new mq_controller_js_1.MQController(parent, {
|
|
80
|
-
...metadata,
|
|
81
|
-
name,
|
|
82
|
-
instance,
|
|
83
|
-
ctor,
|
|
84
|
-
});
|
|
85
|
-
if (metadata.types) {
|
|
86
|
-
await context.enterAsync('.types', async () => {
|
|
87
|
-
await data_type_factory_js_1.DataTypeFactory.addDataTypes(context, controller, metadata.types);
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
if (metadata.headers) {
|
|
91
|
-
await context.enterAsync('.headers', async () => {
|
|
92
|
-
let i = 0;
|
|
93
|
-
for (const v of metadata.headers) {
|
|
94
|
-
await context.enterAsync(`[${i++}]`, async () => {
|
|
95
|
-
const prmArgs = { ...v };
|
|
96
|
-
await context.enterAsync('.type', async () => {
|
|
97
|
-
if (v.type)
|
|
98
|
-
prmArgs.type = controller.node.findDataType(v.type);
|
|
99
|
-
if (!prmArgs.type && typeof v.type === 'object') {
|
|
100
|
-
prmArgs.type = await data_type_factory_js_1.DataTypeFactory.createDataType(context, controller, v.type);
|
|
101
|
-
}
|
|
102
|
-
if (!prmArgs.type)
|
|
103
|
-
prmArgs.type = controller.node.getDataType('any');
|
|
104
|
-
});
|
|
105
|
-
const prm = new mq_header_js_1.MQHeader(controller, prmArgs);
|
|
106
|
-
controller.headers.push(prm);
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
if (metadata.operations) {
|
|
112
|
-
await context.enterAsync('.operations', async () => {
|
|
113
|
-
for (const [operationName, operationMeta] of Object.entries(metadata.operations)) {
|
|
114
|
-
await context.enterAsync(`[${operationName}]`, async () => {
|
|
115
|
-
const operation = new mq_operation_js_1.MQOperation(controller, {
|
|
116
|
-
...operationMeta,
|
|
117
|
-
name: operationName,
|
|
118
|
-
types: undefined,
|
|
119
|
-
type: undefined,
|
|
120
|
-
keyType: undefined,
|
|
121
|
-
});
|
|
122
|
-
await this._initMQOperation(context, operation, operationMeta);
|
|
123
|
-
controller.operations.set(operation.name, operation);
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
return controller;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Initializes MQOperation
|
|
132
|
-
* @param context
|
|
133
|
-
* @param operation
|
|
134
|
-
* @param metadata
|
|
135
|
-
* @protected
|
|
136
|
-
*/
|
|
137
|
-
static async _initMQOperation(context, operation, metadata) {
|
|
138
|
-
if (metadata.types) {
|
|
139
|
-
await context.enterAsync('.types', async () => {
|
|
140
|
-
await data_type_factory_js_1.DataTypeFactory.addDataTypes(context, operation, metadata.types);
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
operation.type = await data_type_factory_js_1.DataTypeFactory.resolveDataType(context, operation, metadata.type);
|
|
144
|
-
if (metadata.keyType) {
|
|
145
|
-
operation.keyType = await data_type_factory_js_1.DataTypeFactory.resolveDataType(context, operation, metadata.keyType);
|
|
146
|
-
}
|
|
147
|
-
if (metadata.headers) {
|
|
148
|
-
await context.enterAsync('.headers', async () => {
|
|
149
|
-
let i = 0;
|
|
150
|
-
for (const v of metadata.headers) {
|
|
151
|
-
await context.enterAsync(`[${i++}]`, async () => {
|
|
152
|
-
const prmArgs = { ...v };
|
|
153
|
-
await context.enterAsync('.type', async () => {
|
|
154
|
-
prmArgs.type = await data_type_factory_js_1.DataTypeFactory.resolveDataType(context, operation, v.type);
|
|
155
|
-
});
|
|
156
|
-
const prm = new mq_header_js_1.MQHeader(operation, prmArgs);
|
|
157
|
-
operation.headers.push(prm);
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
if (metadata.response) {
|
|
163
|
-
await context.enterAsync('.response', async () => {
|
|
164
|
-
const response = new mq_operation_response_js_1.MQOperationResponse(operation, {
|
|
165
|
-
...metadata.response,
|
|
166
|
-
type: undefined,
|
|
167
|
-
keyType: undefined,
|
|
168
|
-
});
|
|
169
|
-
await this._initMQOperationResponse(context, response, metadata.response);
|
|
170
|
-
operation.response = response;
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Initializes MQOperationResponse
|
|
176
|
-
* @param context
|
|
177
|
-
* @param response
|
|
178
|
-
* @param metadata
|
|
179
|
-
* @protected
|
|
180
|
-
*/
|
|
181
|
-
static async _initMQOperationResponse(context, response, metadata) {
|
|
182
|
-
response.type = await data_type_factory_js_1.DataTypeFactory.resolveDataType(context, response, metadata.type);
|
|
183
|
-
if (metadata.keyType) {
|
|
184
|
-
response.keyType = await data_type_factory_js_1.DataTypeFactory.resolveDataType(context, response, metadata.keyType);
|
|
185
|
-
}
|
|
186
|
-
if (metadata.headers) {
|
|
187
|
-
await context.enterAsync('.headers', async () => {
|
|
188
|
-
let i = 0;
|
|
189
|
-
for (const v of metadata.headers) {
|
|
190
|
-
await context.enterAsync(`[${i++}]`, async () => {
|
|
191
|
-
const prmArgs = { ...v };
|
|
192
|
-
await context.enterAsync('.type', async () => {
|
|
193
|
-
prmArgs.type = await data_type_factory_js_1.DataTypeFactory.resolveDataType(context, response, v.type);
|
|
194
|
-
});
|
|
195
|
-
const prm = new mq_header_js_1.MQHeader(response, prmArgs);
|
|
196
|
-
response.headers.push(prm);
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
exports.MQApiFactory = MQApiFactory;
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WSApiFactory = void 0;
|
|
4
|
-
const objects_1 = require("@jsopen/objects");
|
|
5
|
-
const index_js_1 = require("../../helpers/index.js");
|
|
6
|
-
const constants_js_1 = require("../constants.js");
|
|
7
|
-
const ws_api_js_1 = require("../ws/ws-api.js");
|
|
8
|
-
const ws_controller_js_1 = require("../ws/ws-controller.js");
|
|
9
|
-
const ws_operation_js_1 = require("../ws/ws-operation.js");
|
|
10
|
-
const data_type_factory_js_1 = require("./data-type.factory.js");
|
|
11
|
-
/**
|
|
12
|
-
* @class WSApiFactory
|
|
13
|
-
*/
|
|
14
|
-
class WSApiFactory {
|
|
15
|
-
/**
|
|
16
|
-
* Generates MQApi
|
|
17
|
-
* @param context
|
|
18
|
-
* @param init
|
|
19
|
-
*/
|
|
20
|
-
static async createApi(context, init) {
|
|
21
|
-
const api = new ws_api_js_1.WSApi(init);
|
|
22
|
-
if (init.controllers) {
|
|
23
|
-
await context.enterAsync('.controllers', async () => {
|
|
24
|
-
if (Array.isArray(init.controllers)) {
|
|
25
|
-
for (const c of init.controllers) {
|
|
26
|
-
const controller = await this._createController(context, api, c);
|
|
27
|
-
if (controller)
|
|
28
|
-
api.controllers.set(controller.name, controller);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
for (const [k, v] of Object.entries(init.controllers)) {
|
|
33
|
-
const controller = await this._createController(context, api, v, k);
|
|
34
|
-
if (controller)
|
|
35
|
-
api.controllers.set(controller.name, controller);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
return api;
|
|
41
|
-
}
|
|
42
|
-
static async _createController(context, parent, thunk, name) {
|
|
43
|
-
if (typeof thunk === 'function' && !(0, objects_1.isConstructor)(thunk)) {
|
|
44
|
-
thunk = thunk();
|
|
45
|
-
}
|
|
46
|
-
thunk = await (0, index_js_1.resolveThunk)(thunk);
|
|
47
|
-
let ctor;
|
|
48
|
-
let metadata;
|
|
49
|
-
let instance;
|
|
50
|
-
// If thunk is a class
|
|
51
|
-
if (typeof thunk === 'function') {
|
|
52
|
-
metadata = Reflect.getMetadata(constants_js_1.WS_CONTROLLER_METADATA, thunk);
|
|
53
|
-
if (!metadata)
|
|
54
|
-
return context.addError(`Class "${thunk.name}" doesn't have a valid WSController metadata`);
|
|
55
|
-
ctor = thunk;
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
// If thunk is an instance of a class decorated with WSController()
|
|
59
|
-
ctor = Object.getPrototypeOf(thunk).constructor;
|
|
60
|
-
metadata = Reflect.getMetadata(constants_js_1.WS_CONTROLLER_METADATA, ctor);
|
|
61
|
-
if (metadata)
|
|
62
|
-
instance = thunk;
|
|
63
|
-
else {
|
|
64
|
-
// If thunk is a DecoratorMetadata or InitArguments
|
|
65
|
-
metadata = thunk;
|
|
66
|
-
if (thunk.instance === 'object') {
|
|
67
|
-
instance = thunk.instance;
|
|
68
|
-
ctor = Object.getPrototypeOf(instance).constructor;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (!metadata)
|
|
73
|
-
return context.addError(`Class "${ctor.name}" is not decorated with WSController()`);
|
|
74
|
-
name = name || metadata.name;
|
|
75
|
-
if (!name)
|
|
76
|
-
throw new TypeError(`Controller name required`);
|
|
77
|
-
const controller = new ws_controller_js_1.WSController(parent, {
|
|
78
|
-
...metadata,
|
|
79
|
-
name,
|
|
80
|
-
instance,
|
|
81
|
-
ctor,
|
|
82
|
-
});
|
|
83
|
-
if (metadata.types) {
|
|
84
|
-
await context.enterAsync('.types', async () => {
|
|
85
|
-
await data_type_factory_js_1.DataTypeFactory.addDataTypes(context, controller, metadata.types);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
if (metadata.operations) {
|
|
89
|
-
await context.enterAsync('.operations', async () => {
|
|
90
|
-
for (const [operationName, _operationMeta] of Object.entries(metadata.operations)) {
|
|
91
|
-
await context.enterAsync(`[${operationName}]`, async () => {
|
|
92
|
-
const argumentsMetadata = Reflect.getMetadata(constants_js_1.WS_PARAM_METADATA, ctor.prototype, operationName);
|
|
93
|
-
let operationMeta = _operationMeta;
|
|
94
|
-
if (argumentsMetadata) {
|
|
95
|
-
operationMeta = {
|
|
96
|
-
...operationMeta,
|
|
97
|
-
arguments: argumentsMetadata,
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
const operation = new ws_operation_js_1.WSOperation(controller, {
|
|
101
|
-
...operationMeta,
|
|
102
|
-
name: operationName,
|
|
103
|
-
types: undefined,
|
|
104
|
-
type: undefined,
|
|
105
|
-
keyType: undefined,
|
|
106
|
-
arguments: undefined,
|
|
107
|
-
});
|
|
108
|
-
await this._initWSOperation(context, operation, operationMeta);
|
|
109
|
-
controller.operations.set(operationName, operation);
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
return controller;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Initializes WSOperation
|
|
118
|
-
* @param context
|
|
119
|
-
* @param operation
|
|
120
|
-
* @param metadata
|
|
121
|
-
* @protected
|
|
122
|
-
*/
|
|
123
|
-
static async _initWSOperation(context, operation, metadata) {
|
|
124
|
-
if (metadata.types) {
|
|
125
|
-
await context.enterAsync('.types', async () => {
|
|
126
|
-
await data_type_factory_js_1.DataTypeFactory.addDataTypes(context, operation, metadata.types);
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
if (metadata.arguments?.length) {
|
|
130
|
-
await context.enterAsync('.arguments', async () => {
|
|
131
|
-
operation.arguments = [];
|
|
132
|
-
for (const x of metadata.arguments) {
|
|
133
|
-
const t = await data_type_factory_js_1.DataTypeFactory.resolveDataType(context, operation, x);
|
|
134
|
-
operation.arguments?.push(t);
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
if (metadata.response) {
|
|
139
|
-
await context.enterAsync('.response', async () => {
|
|
140
|
-
operation.response = await data_type_factory_js_1.DataTypeFactory.resolveDataType(context, operation, metadata.response);
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
exports.WSApiFactory = WSApiFactory;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpApi = void 0;
|
|
4
|
-
const index_js_1 = require("../../helpers/index.js");
|
|
5
|
-
const api_base_js_1 = require("../common/api-base.js");
|
|
6
|
-
const http_controller_js_1 = require("./http-controller.js");
|
|
7
|
-
/**
|
|
8
|
-
* @class HttpApi
|
|
9
|
-
*/
|
|
10
|
-
class HttpApi extends api_base_js_1.ApiBase {
|
|
11
|
-
constructor(init) {
|
|
12
|
-
super(init);
|
|
13
|
-
// noinspection JSUnusedGlobalSymbols
|
|
14
|
-
this._controllerReverseMap = new WeakMap();
|
|
15
|
-
this.transport = 'http';
|
|
16
|
-
this.controllers = new index_js_1.ResponsiveMap();
|
|
17
|
-
this.url = init.url;
|
|
18
|
-
}
|
|
19
|
-
findController(arg0) {
|
|
20
|
-
return http_controller_js_1.HttpController.prototype.findController.call(this, arg0);
|
|
21
|
-
}
|
|
22
|
-
findOperation(arg0, operationName) {
|
|
23
|
-
const controller = this.findController(arg0);
|
|
24
|
-
return controller?.operations.get(operationName);
|
|
25
|
-
}
|
|
26
|
-
toJSON(options) {
|
|
27
|
-
const schema = super.toJSON();
|
|
28
|
-
const out = {
|
|
29
|
-
...schema,
|
|
30
|
-
transport: this.transport,
|
|
31
|
-
url: this.url,
|
|
32
|
-
controllers: {},
|
|
33
|
-
};
|
|
34
|
-
for (const v of this.controllers.values()) {
|
|
35
|
-
out.controllers[v.name] = v.toJSON(options);
|
|
36
|
-
}
|
|
37
|
-
return out;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.HttpApi = HttpApi;
|