@kravc/dos 1.12.6 → 2.0.0-alpha.1
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 +31 -994
- package/dist/Component/Component.d.ts +43 -0
- package/dist/Component/Component.d.ts.map +1 -0
- package/dist/Component/Component.js +99 -0
- package/dist/Component/Component.js.map +1 -0
- package/dist/Component/index.d.ts +4 -0
- package/dist/Component/index.d.ts.map +1 -0
- package/dist/Component/index.js +10 -0
- package/dist/Component/index.js.map +1 -0
- package/dist/Context/Context.d.ts +86 -0
- package/dist/Context/Context.d.ts.map +1 -0
- package/dist/Context/Context.js +148 -0
- package/dist/Context/Context.js.map +1 -0
- package/dist/Context/Request.d.ts +35 -0
- package/dist/Context/Request.d.ts.map +1 -0
- package/dist/Context/Request.js +3 -0
- package/dist/Context/Request.js.map +1 -0
- package/dist/Context/__tests__/__helpers.d.ts +14 -0
- package/dist/Context/__tests__/__helpers.d.ts.map +1 -0
- package/dist/Context/__tests__/__helpers.js +69 -0
- package/dist/Context/__tests__/__helpers.js.map +1 -0
- package/dist/Context/getHttpMethod.d.ts +6 -0
- package/dist/Context/getHttpMethod.d.ts.map +1 -0
- package/dist/Context/getHttpMethod.js +16 -0
- package/dist/Context/getHttpMethod.js.map +1 -0
- package/dist/Context/getHttpPath.d.ts +6 -0
- package/dist/Context/getHttpPath.d.ts.map +1 -0
- package/dist/Context/getHttpPath.js +25 -0
- package/dist/Context/getHttpPath.js.map +1 -0
- package/dist/Context/getMutationParameters.d.ts +8 -0
- package/dist/Context/getMutationParameters.d.ts.map +1 -0
- package/dist/Context/getMutationParameters.js +25 -0
- package/dist/Context/getMutationParameters.js.map +1 -0
- package/dist/Context/getOperationId.d.ts +6 -0
- package/dist/Context/getOperationId.d.ts.map +1 -0
- package/dist/Context/getOperationId.js +21 -0
- package/dist/Context/getOperationId.js.map +1 -0
- package/dist/Context/getQueryParameters.d.ts +5 -0
- package/dist/Context/getQueryParameters.d.ts.map +1 -0
- package/dist/Context/getQueryParameters.js +33 -0
- package/dist/Context/getQueryParameters.js.map +1 -0
- package/dist/Context/index.d.ts +7 -0
- package/dist/Context/index.d.ts.map +1 -0
- package/dist/Context/index.js +12 -0
- package/dist/Context/index.js.map +1 -0
- package/dist/Context/withSafeAttributes.d.ts +23 -0
- package/dist/Context/withSafeAttributes.d.ts.map +1 -0
- package/dist/Context/withSafeAttributes.js +39 -0
- package/dist/Context/withSafeAttributes.js.map +1 -0
- package/dist/Document/Document.d.ts +114 -0
- package/dist/Document/Document.d.ts.map +1 -0
- package/dist/Document/Document.js +285 -0
- package/dist/Document/Document.js.map +1 -0
- package/dist/Document/MemoryDocument.d.ts +34 -0
- package/dist/Document/MemoryDocument.d.ts.map +1 -0
- package/dist/Document/MemoryDocument.js +103 -0
- package/dist/Document/MemoryDocument.js.map +1 -0
- package/dist/Document/__tests__/__helpers.d.ts +18 -0
- package/dist/Document/__tests__/__helpers.d.ts.map +1 -0
- package/dist/Document/__tests__/__helpers.js +28 -0
- package/dist/Document/__tests__/__helpers.js.map +1 -0
- package/dist/Document/index.d.ts +5 -0
- package/dist/Document/index.d.ts.map +1 -0
- package/dist/Document/index.js +11 -0
- package/dist/Document/index.js.map +1 -0
- package/dist/Operation/Operation.d.ts +95 -0
- package/dist/Operation/Operation.d.ts.map +1 -0
- package/dist/Operation/Operation.js +301 -0
- package/dist/Operation/Operation.js.map +1 -0
- package/dist/Operation/errors/AccessDeniedError.d.ts +22 -0
- package/dist/Operation/errors/AccessDeniedError.d.ts.map +1 -0
- package/dist/Operation/errors/AccessDeniedError.js +29 -0
- package/dist/Operation/errors/AccessDeniedError.js.map +1 -0
- package/dist/Operation/errors/CommonError.d.ts +30 -0
- package/dist/Operation/errors/CommonError.d.ts.map +1 -0
- package/dist/Operation/errors/CommonError.js +39 -0
- package/dist/Operation/errors/CommonError.js.map +1 -0
- package/dist/Operation/errors/DocumentExistsError.d.ts +27 -0
- package/dist/Operation/errors/DocumentExistsError.d.ts.map +1 -0
- package/dist/Operation/errors/DocumentExistsError.js +35 -0
- package/dist/Operation/errors/DocumentExistsError.js.map +1 -0
- package/dist/Operation/errors/DocumentNotFoundError.d.ts +28 -0
- package/dist/Operation/errors/DocumentNotFoundError.d.ts.map +1 -0
- package/dist/Operation/errors/DocumentNotFoundError.js +36 -0
- package/dist/Operation/errors/DocumentNotFoundError.js.map +1 -0
- package/dist/Operation/errors/InvalidParametersError.d.ts +27 -0
- package/dist/Operation/errors/InvalidParametersError.d.ts.map +1 -0
- package/dist/Operation/errors/InvalidParametersError.js +34 -0
- package/dist/Operation/errors/InvalidParametersError.js.map +1 -0
- package/dist/Operation/errors/UnauthorizedError.d.ts +25 -0
- package/dist/Operation/errors/UnauthorizedError.d.ts.map +1 -0
- package/dist/Operation/errors/UnauthorizedError.js +32 -0
- package/dist/Operation/errors/UnauthorizedError.js.map +1 -0
- package/dist/Operation/errors/UnprocessibleConditionError.d.ts +29 -0
- package/dist/Operation/errors/UnprocessibleConditionError.d.ts.map +1 -0
- package/dist/Operation/errors/UnprocessibleConditionError.js +36 -0
- package/dist/Operation/errors/UnprocessibleConditionError.js.map +1 -0
- package/dist/Operation/errors/index.d.ts +9 -0
- package/dist/Operation/errors/index.d.ts.map +1 -0
- package/dist/Operation/errors/index.js +21 -0
- package/dist/Operation/errors/index.js.map +1 -0
- package/dist/Operation/helpers/index.d.ts +4 -0
- package/dist/Operation/helpers/index.d.ts.map +1 -0
- package/dist/Operation/helpers/index.js +9 -0
- package/dist/Operation/helpers/index.js.map +1 -0
- package/dist/Operation/helpers/withActivity.d.ts +16 -0
- package/dist/Operation/helpers/withActivity.d.ts.map +1 -0
- package/dist/Operation/helpers/withActivity.js +23 -0
- package/dist/Operation/helpers/withActivity.js.map +1 -0
- package/dist/Operation/index.d.ts +14 -0
- package/dist/Operation/index.d.ts.map +1 -0
- package/dist/Operation/index.js +40 -0
- package/dist/Operation/index.js.map +1 -0
- package/dist/Operation/operations/Create.d.ts +5 -0
- package/dist/Operation/operations/Create.d.ts.map +1 -0
- package/dist/Operation/operations/Create.js +44 -0
- package/dist/Operation/operations/Create.js.map +1 -0
- package/dist/Operation/operations/Delete.d.ts +5 -0
- package/dist/Operation/operations/Delete.d.ts.map +1 -0
- package/dist/Operation/operations/Delete.js +58 -0
- package/dist/Operation/operations/Delete.js.map +1 -0
- package/dist/Operation/operations/Index.d.ts +11 -0
- package/dist/Operation/operations/Index.d.ts.map +1 -0
- package/dist/Operation/operations/Index.js +128 -0
- package/dist/Operation/operations/Index.js.map +1 -0
- package/dist/Operation/operations/List.d.ts +5 -0
- package/dist/Operation/operations/List.d.ts.map +1 -0
- package/dist/Operation/operations/List.js +48 -0
- package/dist/Operation/operations/List.js.map +1 -0
- package/dist/Operation/operations/Read.d.ts +5 -0
- package/dist/Operation/operations/Read.d.ts.map +1 -0
- package/dist/Operation/operations/Read.js +50 -0
- package/dist/Operation/operations/Read.js.map +1 -0
- package/dist/Operation/operations/Update.d.ts +5 -0
- package/dist/Operation/operations/Update.d.ts.map +1 -0
- package/dist/Operation/operations/Update.js +54 -0
- package/dist/Operation/operations/Update.js.map +1 -0
- package/dist/Operation/security/JwtAuthorization.d.ts +67 -0
- package/dist/Operation/security/JwtAuthorization.d.ts.map +1 -0
- package/dist/Operation/security/JwtAuthorization.js +148 -0
- package/dist/Operation/security/JwtAuthorization.js.map +1 -0
- package/dist/Operation/security/LambdaAuthorization.d.ts +30 -0
- package/dist/Operation/security/LambdaAuthorization.d.ts.map +1 -0
- package/dist/Operation/security/LambdaAuthorization.js +77 -0
- package/dist/Operation/security/LambdaAuthorization.js.map +1 -0
- package/dist/Operation/security/index.d.ts +8 -0
- package/dist/Operation/security/index.d.ts.map +1 -0
- package/dist/Operation/security/index.js +17 -0
- package/dist/Operation/security/index.js.map +1 -0
- package/dist/Operation/security/systemAuthorization.d.ts +5 -0
- package/dist/Operation/security/systemAuthorization.d.ts.map +1 -0
- package/dist/Operation/security/systemAuthorization.js +24 -0
- package/dist/Operation/security/systemAuthorization.js.map +1 -0
- package/dist/Operation/security/userAuthorization.d.ts +11 -0
- package/dist/Operation/security/userAuthorization.d.ts.map +1 -0
- package/dist/Operation/security/userAuthorization.js +36 -0
- package/dist/Operation/security/userAuthorization.js.map +1 -0
- package/dist/Operation/security/verifyToken.d.ts +6 -0
- package/dist/Operation/security/verifyToken.d.ts.map +1 -0
- package/dist/Operation/security/verifyToken.js +15 -0
- package/dist/Operation/security/verifyToken.js.map +1 -0
- package/dist/Service/Service.d.ts +62 -0
- package/dist/Service/Service.d.ts.map +1 -0
- package/dist/Service/Service.js +213 -0
- package/dist/Service/Service.js.map +1 -0
- package/dist/Service/authorize.d.ts +26 -0
- package/dist/Service/authorize.d.ts.map +1 -0
- package/dist/Service/authorize.js +40 -0
- package/dist/Service/authorize.js.map +1 -0
- package/dist/Service/errors/InvalidInputError.d.ts +29 -0
- package/dist/Service/errors/InvalidInputError.d.ts.map +1 -0
- package/dist/Service/errors/InvalidInputError.js +36 -0
- package/dist/Service/errors/InvalidInputError.js.map +1 -0
- package/dist/Service/errors/InvalidOutputError.d.ts +29 -0
- package/dist/Service/errors/InvalidOutputError.d.ts.map +1 -0
- package/dist/Service/errors/InvalidOutputError.js +36 -0
- package/dist/Service/errors/InvalidOutputError.js.map +1 -0
- package/dist/Service/errors/OperationError.d.ts +30 -0
- package/dist/Service/errors/OperationError.d.ts.map +1 -0
- package/dist/Service/errors/OperationError.js +61 -0
- package/dist/Service/errors/OperationError.js.map +1 -0
- package/{src → dist/Service}/errors/OperationError.yaml +7 -10
- package/dist/Service/errors/OperationNotFoundError.d.ts +38 -0
- package/dist/Service/errors/OperationNotFoundError.d.ts.map +1 -0
- package/dist/Service/errors/OperationNotFoundError.js +45 -0
- package/dist/Service/errors/OperationNotFoundError.js.map +1 -0
- package/dist/Service/errors/index.d.ts +8 -0
- package/dist/Service/errors/index.d.ts.map +1 -0
- package/dist/Service/errors/index.js +15 -0
- package/dist/Service/errors/index.js.map +1 -0
- package/dist/Service/errors/logOperationError.d.ts +35 -0
- package/dist/Service/errors/logOperationError.d.ts.map +1 -0
- package/dist/Service/errors/logOperationError.js +47 -0
- package/dist/Service/errors/logOperationError.js.map +1 -0
- package/dist/Service/errors/maskSecrets.d.ts +13 -0
- package/dist/Service/errors/maskSecrets.d.ts.map +1 -0
- package/dist/Service/errors/maskSecrets.js +57 -0
- package/dist/Service/errors/maskSecrets.js.map +1 -0
- package/dist/Service/index.d.ts +5 -0
- package/dist/Service/index.d.ts.map +1 -0
- package/dist/Service/index.js +25 -0
- package/dist/Service/index.js.map +1 -0
- package/dist/Service/logRequest.d.ts +5 -0
- package/dist/Service/logRequest.d.ts.map +1 -0
- package/dist/Service/logRequest.js +26 -0
- package/dist/Service/logRequest.js.map +1 -0
- package/dist/Service/spec/createSpec.d.ts +7 -0
- package/dist/Service/spec/createSpec.d.ts.map +1 -0
- package/dist/Service/spec/createSpec.js +56 -0
- package/dist/Service/spec/createSpec.js.map +1 -0
- package/dist/Service/spec/getErrorResponseDescription.d.ts +8 -0
- package/dist/Service/spec/getErrorResponseDescription.d.ts.map +1 -0
- package/dist/Service/spec/getErrorResponseDescription.js +15 -0
- package/dist/Service/spec/getErrorResponseDescription.js.map +1 -0
- package/dist/Service/spec/getHttpMethod.d.ts +4 -0
- package/dist/Service/spec/getHttpMethod.d.ts.map +1 -0
- package/dist/Service/spec/getHttpMethod.js +21 -0
- package/dist/Service/spec/getHttpMethod.js.map +1 -0
- package/dist/Service/spec/getOperation.d.ts +6 -0
- package/dist/Service/spec/getOperation.d.ts.map +1 -0
- package/dist/Service/spec/getOperation.js +71 -0
- package/dist/Service/spec/getOperation.js.map +1 -0
- package/dist/Service/spec/getOperationParameters.d.ts +6 -0
- package/dist/Service/spec/getOperationParameters.d.ts.map +1 -0
- package/dist/Service/spec/getOperationParameters.js +32 -0
- package/dist/Service/spec/getOperationParameters.js.map +1 -0
- package/dist/Service/spec/getServiceDefinitions.d.ts +6 -0
- package/dist/Service/spec/getServiceDefinitions.d.ts.map +1 -0
- package/dist/Service/spec/getServiceDefinitions.js +18 -0
- package/dist/Service/spec/getServiceDefinitions.js.map +1 -0
- package/dist/Service/spec/getServiceInfo.d.ts +7 -0
- package/dist/Service/spec/getServiceInfo.d.ts.map +1 -0
- package/dist/Service/spec/getServiceInfo.js +15 -0
- package/dist/Service/spec/getServiceInfo.js.map +1 -0
- package/dist/Service/spec/getServiceSecurityDefinitions.d.ts +6 -0
- package/dist/Service/spec/getServiceSecurityDefinitions.d.ts.map +1 -0
- package/dist/Service/spec/getServiceSecurityDefinitions.js +21 -0
- package/dist/Service/spec/getServiceSecurityDefinitions.js.map +1 -0
- package/dist/Service/spec/getServiceTags.d.ts +7 -0
- package/dist/Service/spec/getServiceTags.d.ts.map +1 -0
- package/dist/Service/spec/getServiceTags.js +19 -0
- package/dist/Service/spec/getServiceTags.js.map +1 -0
- package/dist/Service/spec/getSuccessStatusCode.d.ts +4 -0
- package/dist/Service/spec/getSuccessStatusCode.d.ts.map +1 -0
- package/dist/Service/spec/getSuccessStatusCode.js +14 -0
- package/dist/Service/spec/getSuccessStatusCode.js.map +1 -0
- package/dist/Service/spec/index.d.ts +3 -0
- package/dist/Service/spec/index.d.ts.map +1 -0
- package/dist/Service/spec/index.js +9 -0
- package/dist/Service/spec/index.js.map +1 -0
- package/dist/Service/spec/validateSpec.d.ts +5 -0
- package/dist/Service/spec/validateSpec.d.ts.map +1 -0
- package/dist/Service/spec/validateSpec.js +21 -0
- package/dist/Service/spec/validateSpec.js.map +1 -0
- package/dist/Service/test/createAccessToken.d.ts +9 -0
- package/dist/Service/test/createAccessToken.d.ts.map +1 -0
- package/dist/Service/test/createAccessToken.js +16 -0
- package/dist/Service/test/createAccessToken.js.map +1 -0
- package/dist/Service/test/ensureItem.d.ts +5 -0
- package/dist/Service/test/ensureItem.d.ts.map +1 -0
- package/dist/Service/test/ensureItem.js +13 -0
- package/dist/Service/test/ensureItem.js.map +1 -0
- package/dist/Service/test/ensureNoItem.d.ts +5 -0
- package/dist/Service/test/ensureNoItem.d.ts.map +1 -0
- package/dist/Service/test/ensureNoItem.js +13 -0
- package/dist/Service/test/ensureNoItem.js.map +1 -0
- package/dist/Service/test/execute.d.ts +44 -0
- package/dist/Service/test/execute.d.ts.map +1 -0
- package/dist/Service/test/execute.js +65 -0
- package/dist/Service/test/execute.js.map +1 -0
- package/dist/Service/test/findItem.d.ts +7 -0
- package/dist/Service/test/findItem.d.ts.map +1 -0
- package/dist/Service/test/findItem.js +16 -0
- package/dist/Service/test/findItem.js.map +1 -0
- package/dist/Service/test/firstItemGet.d.ts +5 -0
- package/dist/Service/test/firstItemGet.d.ts.map +1 -0
- package/dist/Service/test/firstItemGet.js +15 -0
- package/dist/Service/test/firstItemGet.js.map +1 -0
- package/dist/Service/test/index.d.ts +10 -0
- package/dist/Service/test/index.d.ts.map +1 -0
- package/dist/Service/test/index.js +36 -0
- package/dist/Service/test/index.js.map +1 -0
- package/dist/Service/test/keys.d.ts +5 -0
- package/dist/Service/test/keys.d.ts.map +1 -0
- package/dist/Service/test/keys.js +74 -0
- package/dist/Service/test/keys.js.map +1 -0
- package/dist/Service/test/wait.d.ts +4 -0
- package/dist/Service/test/wait.d.ts.map +1 -0
- package/dist/Service/test/wait.js +6 -0
- package/dist/Service/test/wait.js.map +1 -0
- package/dist/Service/useComposerMiddleware.d.ts +11 -0
- package/dist/Service/useComposerMiddleware.d.ts.map +1 -0
- package/dist/Service/useComposerMiddleware.js +41 -0
- package/dist/Service/useComposerMiddleware.js.map +1 -0
- package/dist/Service/useOasMiddleware.d.ts +16 -0
- package/dist/Service/useOasMiddleware.d.ts.map +1 -0
- package/dist/Service/useOasMiddleware.js +53 -0
- package/dist/Service/useOasMiddleware.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/eslint.config.mjs +32 -52
- package/example/documents/Profile/Profile.ts +8 -0
- package/example/documents/Profile/Profile.yaml +6 -0
- package/example/documents/Profile/ProfileAttributes.d.ts +5 -0
- package/example/documents/Profile/index.ts +3 -0
- package/example/documents/index.ts +5 -0
- package/example/index.ts +38 -0
- package/example/lib/createActivity.ts +28 -0
- package/example/lib/index.ts +24 -0
- package/example/operations/Profile/CreateProfile.ts +9 -0
- package/example/operations/Profile/DeleteProfile.ts +9 -0
- package/example/operations/Profile/IndexProfiles.ts +9 -0
- package/example/operations/Profile/ReadProfile.ts +9 -0
- package/example/operations/Profile/ReadProfileSystem.ts +9 -0
- package/example/operations/Profile/UpdateProfile.ts +9 -0
- package/example/operations/Service/Health.ts +11 -0
- package/example/operations/index.ts +22 -0
- package/example/security/index.ts +25 -0
- package/jest.config.mjs +7 -0
- package/package.json +35 -24
- package/src/Component/Component.ts +120 -0
- package/src/Component/__tests__/Component.test.ts +161 -0
- package/src/Component/index.ts +7 -0
- package/src/Context/Context.ts +217 -0
- package/src/Context/Request.ts +41 -0
- package/src/Context/__tests__/Context.test.ts +271 -0
- package/src/Context/__tests__/__helpers.ts +86 -0
- package/src/Context/getHttpMethod.ts +21 -0
- package/src/Context/getHttpPath.ts +34 -0
- package/src/Context/getMutationParameters.ts +35 -0
- package/src/Context/getOperationId.ts +23 -0
- package/src/Context/getQueryParameters.ts +45 -0
- package/src/Context/index.ts +12 -0
- package/src/Context/withSafeAttributes.ts +39 -0
- package/src/Document/Document.ts +448 -0
- package/src/Document/MemoryDocument.ts +152 -0
- package/src/Document/__tests__/MemoryDocument.test.ts +406 -0
- package/src/Document/__tests__/__helpers.ts +40 -0
- package/src/Document/index.ts +9 -0
- package/src/Operation/Operation.ts +401 -0
- package/src/Operation/__tests__/Operation.test.ts +142 -0
- package/src/Operation/errors/AccessDeniedError.ts +25 -0
- package/src/Operation/errors/CommonError.ts +41 -0
- package/src/Operation/errors/DocumentExistsError.ts +33 -0
- package/src/Operation/errors/DocumentNotFoundError.ts +34 -0
- package/src/Operation/errors/InvalidParametersError.ts +30 -0
- package/src/Operation/errors/UnauthorizedError.ts +28 -0
- package/src/Operation/errors/UnprocessibleConditionError.ts +32 -0
- package/src/Operation/errors/__tests__/InvalidParametersError.test.ts +20 -0
- package/src/Operation/errors/__tests__/UnprocessibleConditionError.test.ts +20 -0
- package/src/Operation/errors/index.ts +17 -0
- package/src/Operation/helpers/index.ts +9 -0
- package/src/Operation/helpers/withActivity.ts +43 -0
- package/src/Operation/index.ts +29 -0
- package/src/Operation/operations/Create.ts +49 -0
- package/src/Operation/operations/Delete.ts +65 -0
- package/src/Operation/operations/Index.ts +164 -0
- package/src/Operation/operations/List.ts +62 -0
- package/src/Operation/operations/Read.ts +55 -0
- package/src/Operation/operations/Update.ts +60 -0
- package/src/Operation/operations/__tests__/Create.test.ts +153 -0
- package/src/Operation/operations/__tests__/Delete.test.ts +163 -0
- package/src/Operation/operations/__tests__/Index.test.ts +209 -0
- package/src/Operation/operations/__tests__/List.test.ts +146 -0
- package/src/Operation/operations/__tests__/Read.test.ts +152 -0
- package/src/Operation/operations/__tests__/Update.test.ts +158 -0
- package/src/Operation/security/JwtAuthorization.ts +247 -0
- package/src/Operation/security/LambdaAuthorization.ts +103 -0
- package/src/Operation/security/__tests__/JwtAuthorization.test.ts +230 -0
- package/src/Operation/security/__tests__/LambdaAuthorization.test.ts +63 -0
- package/src/Operation/security/__tests__/userAuthorization.test.ts +42 -0
- package/src/Operation/security/index.ts +15 -0
- package/src/Operation/security/systemAuthorization.ts +23 -0
- package/src/Operation/security/userAuthorization.ts +47 -0
- package/src/Operation/security/verifyToken.ts +22 -0
- package/src/Service/Service.ts +317 -0
- package/src/Service/__tests__/Service.test.ts +229 -0
- package/src/Service/authorize.ts +80 -0
- package/src/Service/errors/InvalidInputError.ts +40 -0
- package/src/Service/errors/InvalidOutputError.ts +40 -0
- package/src/Service/errors/OperationError.ts +74 -0
- package/src/Service/errors/OperationError.yaml +29 -0
- package/src/Service/errors/OperationErrorAttributes.d.ts +12 -0
- package/src/Service/errors/OperationNotFoundError.ts +45 -0
- package/src/Service/errors/__tests__/OperationError.test.ts +17 -0
- package/src/Service/errors/__tests__/maskSecrets.test.ts +92 -0
- package/src/Service/errors/index.ts +18 -0
- package/src/Service/errors/logOperationError.ts +72 -0
- package/src/Service/errors/maskSecrets.ts +65 -0
- package/src/Service/index.ts +9 -0
- package/src/Service/logRequest.ts +50 -0
- package/src/Service/spec/__tests__/validateSpec.test.ts +10 -0
- package/src/Service/spec/createSpec.ts +68 -0
- package/src/Service/spec/getErrorResponseDescription.ts +20 -0
- package/src/Service/spec/getHttpMethod.ts +20 -0
- package/src/Service/spec/getOperation.ts +99 -0
- package/src/Service/spec/getOperationParameters.ts +43 -0
- package/src/Service/spec/getServiceDefinitions.ts +23 -0
- package/src/Service/spec/getServiceInfo.ts +18 -0
- package/src/Service/spec/getServiceSecurityDefinitions.ts +26 -0
- package/src/Service/spec/getServiceTags.ts +23 -0
- package/src/Service/spec/getSuccessStatusCode.ts +15 -0
- package/src/Service/spec/index.ts +5 -0
- package/src/Service/spec/validateSpec.ts +22 -0
- package/src/Service/test/__tests__/createAccessToken.test.ts +104 -0
- package/src/Service/test/__tests__/ensureItem.test.ts +41 -0
- package/src/Service/test/__tests__/ensureNoItem.test.ts +49 -0
- package/src/Service/test/__tests__/execute.test.ts +125 -0
- package/src/Service/test/__tests__/findItem.test.ts +45 -0
- package/src/Service/test/__tests__/firstItemGet.test.ts +50 -0
- package/src/Service/test/__tests__/wait.test.ts +66 -0
- package/src/Service/test/createAccessToken.ts +28 -0
- package/src/Service/test/ensureItem.ts +9 -0
- package/src/Service/test/ensureNoItem.ts +9 -0
- package/src/Service/test/execute.ts +112 -0
- package/src/Service/test/findItem.ts +22 -0
- package/src/Service/test/firstItemGet.ts +18 -0
- package/src/Service/test/index.ts +19 -0
- package/src/Service/test/keys.ts +75 -0
- package/src/Service/test/wait.ts +5 -0
- package/src/Service/useComposerMiddleware.ts +56 -0
- package/src/Service/useOasMiddleware.ts +69 -0
- package/src/index.ts +12 -0
- package/tsconfig.json +26 -0
- package/examples/CreateProfile.js +0 -40
- package/examples/DeleteProfile.js +0 -6
- package/examples/Health.js +0 -8
- package/examples/IndexProfiles.js +0 -6
- package/examples/Profile.js +0 -8
- package/examples/Profile.yaml +0 -4
- package/examples/ReadProfile.js +0 -18
- package/examples/UpdateProfile.js +0 -25
- package/examples/index.js +0 -29
- package/src/Component.js +0 -59
- package/src/Component.spec.js +0 -65
- package/src/Document.js +0 -310
- package/src/Document.spec.js +0 -331
- package/src/Operation.js +0 -258
- package/src/Operation.spec.js +0 -474
- package/src/Service.js +0 -207
- package/src/Service.spec.js +0 -388
- package/src/errors/AccessDeniedError.js +0 -11
- package/src/errors/CommonError.js +0 -19
- package/src/errors/DocumentExistsError.js +0 -15
- package/src/errors/DocumentNotFoundError.js +0 -15
- package/src/errors/InvalidInputError.js +0 -19
- package/src/errors/InvalidOutputError.js +0 -20
- package/src/errors/InvalidParametersError.js +0 -11
- package/src/errors/OperationError.js +0 -44
- package/src/errors/OperationNotFoundError.js +0 -16
- package/src/errors/UnauthorizedError.js +0 -11
- package/src/errors/UnprocessibleConditionError.js +0 -11
- package/src/errors/index.js +0 -11
- package/src/helpers/asSafeClass.js +0 -22
- package/src/helpers/authorize.js +0 -44
- package/src/helpers/createContext.js +0 -96
- package/src/helpers/createSchemasMap.js +0 -37
- package/src/helpers/createSpec.js +0 -196
- package/src/helpers/defaultId.js +0 -30
- package/src/helpers/defaultSummary.js +0 -15
- package/src/helpers/defaultTags.js +0 -16
- package/src/helpers/getComponentTitle.js +0 -22
- package/src/helpers/getDefaultSchemaAttributes.js +0 -32
- package/src/helpers/getHttpMethod.js +0 -19
- package/src/helpers/getIdPrefix.js +0 -7
- package/src/helpers/getOrFail.js +0 -24
- package/src/helpers/getOrFail.spec.js +0 -17
- package/src/helpers/getSuccessStatusCode.js +0 -15
- package/src/helpers/handler.js +0 -21
- package/src/helpers/loadSync.js +0 -14
- package/src/helpers/logError.js +0 -33
- package/src/helpers/logRequest.js +0 -36
- package/src/helpers/maskSecrets.js +0 -42
- package/src/helpers/specMiddleware.js +0 -81
- package/src/index.d.ts +0 -352
- package/src/index.js +0 -35
- package/src/operations/Create.js +0 -39
- package/src/operations/Delete.js +0 -54
- package/src/operations/Index.js +0 -107
- package/src/operations/Read.js +0 -46
- package/src/operations/Update.js +0 -50
- package/src/security/JwtAuthorization.js +0 -125
- package/src/security/SystemAuthorization.js +0 -73
- package/src/security/index.js +0 -9
- package/src/security/verifyToken.js +0 -17
- package/src/test/createAccessToken.js +0 -23
- package/src/test/execute.js +0 -84
- package/src/test/index.js +0 -11
- package/src/test/keys.js +0 -39
- package/src/test/wait.js +0 -5
- /package/{specs → .composer}/Documents.yaml +0 -0
- /package/{specs → .composer}/Enums.yaml +0 -0
- /package/{specs → .composer}/Operations.yaml +0 -0
- /package/{specs → .composer}/Parameters.yaml +0 -0
- /package/{specs → .composer}/Scenarios.yaml +0 -0
- /package/{specs → .composer}/Schemas.yaml +0 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const Operation_1 = require("../../Operation");
|
|
4
|
+
/**
|
|
5
|
+
* Operation Not Found Error
|
|
6
|
+
*
|
|
7
|
+
* `OperationNotFoundError` represents a **404 Not Found** error that occurs when a requested
|
|
8
|
+
* operation cannot be found in the service. This error is thrown by `Service.process()` when
|
|
9
|
+
* no operation matches the provided `operationId`, `httpMethod`, and `httpPath` combination.
|
|
10
|
+
*
|
|
11
|
+
* This error signals that:
|
|
12
|
+
*
|
|
13
|
+
* - The requested operation does not exist in the service's operations map
|
|
14
|
+
* - The operation may have been removed, renamed, or the request is using incorrect identifiers
|
|
15
|
+
* - The client should verify the operation ID, HTTP method, and path
|
|
16
|
+
*
|
|
17
|
+
* The error message includes the parameters used to search for the operation (operationId,
|
|
18
|
+
* httpMethod, httpPath) formatted as JSON, which helps with debugging incorrect operation
|
|
19
|
+
* requests or routing issues.
|
|
20
|
+
*/
|
|
21
|
+
class OperationNotFoundError extends Operation_1.CommonError {
|
|
22
|
+
/**
|
|
23
|
+
* Creates an instance of operation not found error.
|
|
24
|
+
*
|
|
25
|
+
* @param parameters - Record containing the operation search parameters:
|
|
26
|
+
* - `operationId`: The operation identifier that was requested
|
|
27
|
+
* - `httpMethod`: The HTTP method (GET, POST, PUT, DELETE, etc.)
|
|
28
|
+
* - `httpPath`: The HTTP path that was requested
|
|
29
|
+
* These are included in the error message as formatted JSON for debugging.
|
|
30
|
+
*/
|
|
31
|
+
constructor(parameters) {
|
|
32
|
+
const parametersJson = JSON.stringify(parameters, null, 2);
|
|
33
|
+
super('OperationNotFoundError', `Operation not found, ${parametersJson}`);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Returns the HTTP status code for this error (404 Not Found).
|
|
37
|
+
*
|
|
38
|
+
* @returns 404
|
|
39
|
+
*/
|
|
40
|
+
get statusCode() {
|
|
41
|
+
return 404;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.default = OperationNotFoundError;
|
|
45
|
+
//# sourceMappingURL=OperationNotFoundError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OperationNotFoundError.js","sourceRoot":"","sources":["../../../src/Service/errors/OperationNotFoundError.ts"],"names":[],"mappings":";;AAAA,+CAA8C;AAE9C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,sBAAuB,SAAQ,uBAAW;IAC9C;;;;;;;;OAQG;IACH,YAAY,UAAmC;QAC7C,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC3D,KAAK,CAAC,wBAAwB,EAAE,wBAAwB,cAAc,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED;;;;OAIG;IACH,IAAI,UAAU;QACZ,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAED,kBAAe,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import OperationError from './OperationError';
|
|
2
|
+
import InvalidInputError from './InvalidInputError';
|
|
3
|
+
import InvalidOutputError from './InvalidOutputError';
|
|
4
|
+
import OperationNotFoundError from './OperationNotFoundError';
|
|
5
|
+
import type { OriginalError, ErrorAttributes } from './logOperationError';
|
|
6
|
+
export { OperationError, InvalidInputError, InvalidOutputError, OperationNotFoundError, };
|
|
7
|
+
export type { OriginalError, ErrorAttributes };
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Service/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,sBAAsB,MAAM,0BAA0B,CAAC;AAE9D,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE1E,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,GACvB,CAAC;AAEF,YAAY,EACV,aAAa,EACb,eAAe,EAChB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.OperationNotFoundError = exports.InvalidOutputError = exports.InvalidInputError = exports.OperationError = void 0;
|
|
7
|
+
const OperationError_1 = __importDefault(require("./OperationError"));
|
|
8
|
+
exports.OperationError = OperationError_1.default;
|
|
9
|
+
const InvalidInputError_1 = __importDefault(require("./InvalidInputError"));
|
|
10
|
+
exports.InvalidInputError = InvalidInputError_1.default;
|
|
11
|
+
const InvalidOutputError_1 = __importDefault(require("./InvalidOutputError"));
|
|
12
|
+
exports.InvalidOutputError = InvalidOutputError_1.default;
|
|
13
|
+
const OperationNotFoundError_1 = __importDefault(require("./OperationNotFoundError"));
|
|
14
|
+
exports.OperationNotFoundError = OperationNotFoundError_1.default;
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Service/errors/index.ts"],"names":[],"mappings":";;;;;;AAAA,sEAA8C;AAQ5C,yBARK,wBAAc,CAQL;AAPhB,4EAAoD;AAQlD,4BARK,2BAAiB,CAQL;AAPnB,8EAAsD;AAQpD,6BARK,4BAAkB,CAQL;AAPpB,sFAA8D;AAQ5D,iCARK,gCAAsB,CAQL"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import Context from '../../Context';
|
|
2
|
+
import { ValidationError } from '@kravc/schema';
|
|
3
|
+
export type OriginalError = {
|
|
4
|
+
code?: string;
|
|
5
|
+
stack?: string;
|
|
6
|
+
message: string;
|
|
7
|
+
isCommonError?: boolean;
|
|
8
|
+
validationErrors?: ValidationError[];
|
|
9
|
+
};
|
|
10
|
+
export type ErrorAttributes = {
|
|
11
|
+
code: string;
|
|
12
|
+
message: string;
|
|
13
|
+
context: Record<string, unknown>;
|
|
14
|
+
statusCode: number;
|
|
15
|
+
validationErrors?: ValidationError[];
|
|
16
|
+
originalError?: OriginalError;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Logs operation internal error with sanitized context and structured error information.
|
|
20
|
+
*
|
|
21
|
+
* Provides centralized, secure error logging for operation failures. Extracts relevant
|
|
22
|
+
* context fields from the operation context, masks any secrets (passwords, tokens, etc.),
|
|
23
|
+
* and logs structured error information. Distinguishes between expected/common errors
|
|
24
|
+
* (which include full error details) and unexpected errors (which append stack traces
|
|
25
|
+
* for debugging).
|
|
26
|
+
*
|
|
27
|
+
* This ensures that:
|
|
28
|
+
* - Sensitive information is never logged in plain text
|
|
29
|
+
* - Error logs contain sufficient context for debugging (request ID, operation ID, etc.)
|
|
30
|
+
* - Unexpected errors are clearly marked with stack traces
|
|
31
|
+
* - Common errors preserve their original error structure for analysis
|
|
32
|
+
*/
|
|
33
|
+
declare const logOperationError: (context: Context, errorAttributes: ErrorAttributes, originalError: OriginalError) => void;
|
|
34
|
+
export default logOperationError;
|
|
35
|
+
//# sourceMappingURL=logOperationError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logOperationError.d.ts","sourceRoot":"","sources":["../../../src/Service/errors/logOperationError.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,eAAe,CAAC;AAGpC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;CACtC,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;IACrC,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B,CAAA;AAWD;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,iBAAiB,GACrB,SAAS,OAAO,EAChB,iBAAiB,eAAe,EAChC,eAAe,aAAa,SAoB7B,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const lodash_1 = require("lodash");
|
|
7
|
+
const maskSecrets_1 = __importDefault(require("./maskSecrets"));
|
|
8
|
+
const ERROR_CONTEXT_FIELDS = [
|
|
9
|
+
'query',
|
|
10
|
+
'mutation',
|
|
11
|
+
'identity',
|
|
12
|
+
'requestId',
|
|
13
|
+
'operationId',
|
|
14
|
+
'requestReceivedAt'
|
|
15
|
+
];
|
|
16
|
+
/**
|
|
17
|
+
* Logs operation internal error with sanitized context and structured error information.
|
|
18
|
+
*
|
|
19
|
+
* Provides centralized, secure error logging for operation failures. Extracts relevant
|
|
20
|
+
* context fields from the operation context, masks any secrets (passwords, tokens, etc.),
|
|
21
|
+
* and logs structured error information. Distinguishes between expected/common errors
|
|
22
|
+
* (which include full error details) and unexpected errors (which append stack traces
|
|
23
|
+
* for debugging).
|
|
24
|
+
*
|
|
25
|
+
* This ensures that:
|
|
26
|
+
* - Sensitive information is never logged in plain text
|
|
27
|
+
* - Error logs contain sufficient context for debugging (request ID, operation ID, etc.)
|
|
28
|
+
* - Unexpected errors are clearly marked with stack traces
|
|
29
|
+
* - Common errors preserve their original error structure for analysis
|
|
30
|
+
*/
|
|
31
|
+
const logOperationError = (context, errorAttributes, originalError) => {
|
|
32
|
+
const { logger } = context;
|
|
33
|
+
const unmaskedContext = (0, lodash_1.pick)(context, ERROR_CONTEXT_FIELDS);
|
|
34
|
+
errorAttributes.context = (0, maskSecrets_1.default)(unmaskedContext);
|
|
35
|
+
let unexpectedErrorMessage = '';
|
|
36
|
+
const { isCommonError } = originalError;
|
|
37
|
+
if (isCommonError) {
|
|
38
|
+
errorAttributes.originalError = originalError;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
unexpectedErrorMessage = `, Unexpected ${originalError.stack}`;
|
|
42
|
+
}
|
|
43
|
+
const errorAttributesJson = JSON.stringify(errorAttributes, null, 2);
|
|
44
|
+
logger.error(`OperationError ${errorAttributesJson}${unexpectedErrorMessage}`);
|
|
45
|
+
};
|
|
46
|
+
exports.default = logOperationError;
|
|
47
|
+
//# sourceMappingURL=logOperationError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logOperationError.js","sourceRoot":"","sources":["../../../src/Service/errors/logOperationError.ts"],"names":[],"mappings":";;;;;AACA,mCAA8B;AAC9B,gEAAwC;AAoBxC,MAAM,oBAAoB,GAAG;IAC3B,OAAO;IACP,UAAU;IACV,UAAU;IACV,WAAW;IACX,aAAa;IACb,mBAAmB;CACpB,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,iBAAiB,GAAG,CACxB,OAAgB,EAChB,eAAgC,EAChC,aAA4B,EAC5B,EAAE;IACF,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAE3B,MAAM,eAAe,GAAG,IAAA,aAAI,EAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;IAC5D,eAAe,CAAC,OAAO,GAAG,IAAA,qBAAW,EAAC,eAAe,CAAC,CAAC;IAEvD,IAAI,sBAAsB,GAAG,EAAE,CAAC;IAEhC,MAAM,EAAE,aAAa,EAAE,GAAG,aAAa,CAAC;IAExC,IAAI,aAAa,EAAE,CAAC;QAClB,eAAe,CAAC,aAAa,GAAG,aAAa,CAAC;IAEhD,CAAC;SAAM,CAAC;QACN,sBAAsB,GAAG,gBAAgB,aAAa,CAAC,KAAK,EAAE,CAAC;IACjE,CAAC;IAED,MAAM,mBAAmB,GAAG,IAAI,CAAC,SAAS,CAAC,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACrE,MAAM,CAAC,KAAK,CAAC,kBAAkB,mBAAmB,GAAG,sBAAsB,EAAE,CAAC,CAAC;AACjF,CAAC,CAAC;AAEF,kBAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clones an object and recursively masks its secret attributes.
|
|
3
|
+
*
|
|
4
|
+
* Produces a deep copy of the input with sensitive values replaced by `[MASKED]`.
|
|
5
|
+
* Keys matching `password`, `code`, `token`, `authorization`, `authentication`, or
|
|
6
|
+
* `cookie` (case‑insensitive, including substrings like `authToken` or `reset_code`)
|
|
7
|
+
* are masked regardless of value type. The original object is never mutated.
|
|
8
|
+
*
|
|
9
|
+
* This enables safe logging and serialization of context, request payloads, or
|
|
10
|
+
* config that may contain credentials, tokens, or other secrets.
|
|
11
|
+
*/
|
|
12
|
+
export default function maskSecrets(input: Record<string, unknown>): Record<string, unknown>;
|
|
13
|
+
//# sourceMappingURL=maskSecrets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maskSecrets.d.ts","sourceRoot":"","sources":["../../../src/Service/errors/maskSecrets.ts"],"names":[],"mappings":"AA+CA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CACjC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAIzB"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = maskSecrets;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const { isArray } = Array;
|
|
6
|
+
const SECRET_REGEXP = /(password|code|token|authorization|authentication|cookie)/i;
|
|
7
|
+
const MASK_VALUE = '[MASKED]';
|
|
8
|
+
/** Recursively masks secret attributes in objects and arrays. */
|
|
9
|
+
function applyMasking(value) {
|
|
10
|
+
if (!(0, lodash_1.isObject)(value)) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (isArray(value)) {
|
|
14
|
+
for (const item of value) {
|
|
15
|
+
if ((0, lodash_1.isObject)(item)) {
|
|
16
|
+
applyMasking(item);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const object = value;
|
|
22
|
+
for (const key of Object.keys(object)) {
|
|
23
|
+
if (SECRET_REGEXP.test(key)) {
|
|
24
|
+
object[key] = MASK_VALUE;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const val = object[key];
|
|
28
|
+
if (isArray(val)) {
|
|
29
|
+
for (const item of val) {
|
|
30
|
+
if ((0, lodash_1.isObject)(item)) {
|
|
31
|
+
applyMasking(item);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if ((0, lodash_1.isObject)(val)) {
|
|
37
|
+
applyMasking(val);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Clones an object and recursively masks its secret attributes.
|
|
43
|
+
*
|
|
44
|
+
* Produces a deep copy of the input with sensitive values replaced by `[MASKED]`.
|
|
45
|
+
* Keys matching `password`, `code`, `token`, `authorization`, `authentication`, or
|
|
46
|
+
* `cookie` (case‑insensitive, including substrings like `authToken` or `reset_code`)
|
|
47
|
+
* are masked regardless of value type. The original object is never mutated.
|
|
48
|
+
*
|
|
49
|
+
* This enables safe logging and serialization of context, request payloads, or
|
|
50
|
+
* config that may contain credentials, tokens, or other secrets.
|
|
51
|
+
*/
|
|
52
|
+
function maskSecrets(input) {
|
|
53
|
+
const object = (0, lodash_1.cloneDeep)(input);
|
|
54
|
+
applyMasking(object);
|
|
55
|
+
return object;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=maskSecrets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maskSecrets.js","sourceRoot":"","sources":["../../../src/Service/errors/maskSecrets.ts"],"names":[],"mappings":";;AA0DA,8BAMC;AAhED,mCAA6C;AAE7C,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;AAE1B,MAAM,aAAa,GAAG,4DAA4D,CAAC;AACnF,MAAM,UAAU,GAAG,UAAU,CAAC;AAE9B,iEAAiE;AACjE,SAAS,YAAY,CAAC,KAAc;IAClC,IAAI,CAAC,IAAA,iBAAQ,EAAC,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO;IACT,CAAC;IAED,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACnB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,IAAA,iBAAQ,EAAC,IAAI,CAAC,EAAE,CAAC;gBACnB,YAAY,CAAC,IAAI,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;QACD,OAAO;IACT,CAAC;IAED,MAAM,MAAM,GAAG,KAAgC,CAAC;IAEhD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,IAAI,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YAC5B,MAAM,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC;YACzB,SAAS;QACX,CAAC;QAED,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAExB,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YACjB,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE,CAAC;gBACvB,IAAI,IAAA,iBAAQ,EAAC,IAAI,CAAC,EAAE,CAAC;oBACnB,YAAY,CAAC,IAAI,CAAC,CAAC;gBACrB,CAAC;YACH,CAAC;YACD,SAAS;QACX,CAAC;QAED,IAAI,IAAA,iBAAQ,EAAC,GAAG,CAAC,EAAE,CAAC;YAClB,YAAY,CAAC,GAAG,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAwB,WAAW,CACjC,KAA8B;IAE9B,MAAM,MAAM,GAAG,IAAA,kBAAS,EAAC,KAAK,CAAC,CAAC;IAChC,YAAY,CAAC,MAAM,CAAC,CAAC;IACrB,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Service/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC,eAAe,OAAO,CAAC;AAEvB,OAAO,EACL,OAAO,GACR,CAAC;AAEF,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.Service = void 0;
|
|
21
|
+
const Service_1 = __importDefault(require("./Service"));
|
|
22
|
+
exports.Service = Service_1.default;
|
|
23
|
+
exports.default = Service_1.default;
|
|
24
|
+
__exportStar(require("./test"), exports);
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Service/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,wDAAgC;AAK9B,kBALK,iBAAO,CAKL;AAHT,kBAAe,iBAAO,CAAC;AAMvB,yCAAuB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logRequest.d.ts","sourceRoot":"","sources":["../../src/Service/logRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAyB,MAAM,YAAY,CAAC;AAUjE,yDAAyD;AACzD,QAAA,MAAM,UAAU,GAAI,SAAS,OAAO,SAoCnC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/** Logs request metadata in the non test environment. */
|
|
4
|
+
const logRequest = (context) => {
|
|
5
|
+
const { isTest } = context;
|
|
6
|
+
if (isTest) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const { operationId, query, logger, mutation, httpPath, requestId, headers, requestReceivedAt } = context;
|
|
10
|
+
const { host } = headers;
|
|
11
|
+
const metadata = {
|
|
12
|
+
host,
|
|
13
|
+
requestId,
|
|
14
|
+
requestReceivedAt,
|
|
15
|
+
query,
|
|
16
|
+
};
|
|
17
|
+
if (mutation) {
|
|
18
|
+
metadata.mutation = mutation;
|
|
19
|
+
}
|
|
20
|
+
const prefix = operationId === 'undefined'
|
|
21
|
+
? httpPath
|
|
22
|
+
: operationId;
|
|
23
|
+
logger.info(`${prefix}: ${JSON.stringify(metadata, null, 2)}`);
|
|
24
|
+
};
|
|
25
|
+
exports.default = logRequest;
|
|
26
|
+
//# sourceMappingURL=logRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logRequest.js","sourceRoot":"","sources":["../../src/Service/logRequest.ts"],"names":[],"mappings":";;AAUA,yDAAyD;AACzD,MAAM,UAAU,GAAG,CAAC,OAAgB,EAAE,EAAE;IACtC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAE3B,IAAI,MAAM,EAAE,CAAC;QACX,OAAO;IACT,CAAC;IAED,MAAM,EACJ,WAAW,EACX,KAAK,EACL,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,OAAO,EACP,iBAAiB,EAClB,GAAG,OAAO,CAAC;IAEZ,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IAEzB,MAAM,QAAQ,GAAG;QACf,IAAI;QACJ,SAAS;QACT,iBAAiB;QACjB,KAAK;KACa,CAAC;IAErB,IAAI,QAAQ,EAAE,CAAC;QACb,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC/B,CAAC;IAED,MAAM,MAAM,GAAG,WAAW,KAAK,WAAW;QACxC,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,WAAW,CAAC;IAEhB,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,KAAK,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AACjE,CAAC,CAAC;AAEF,kBAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import Operation from '../../Operation';
|
|
2
|
+
import { Schema } from '@kravc/schema';
|
|
3
|
+
import { OpenAPIV2 } from 'openapi-types';
|
|
4
|
+
/** Creates a specification for a service. */
|
|
5
|
+
declare const createSpec: (operations: (typeof Operation)[], schemasMap: Record<string, Schema>, url: string) => OpenAPIV2.Document;
|
|
6
|
+
export default createSpec;
|
|
7
|
+
//# sourceMappingURL=createSpec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createSpec.d.ts","sourceRoot":"","sources":["../../../src/Service/spec/createSpec.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGvC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAO1C,6CAA6C;AAC7C,QAAA,MAAM,UAAU,GACd,YAAY,CAAC,OAAO,SAAS,CAAC,EAAE,EAChC,YAAY,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAClC,KAAK,MAAM,KACV,SAAS,CAAC,QAgDZ,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const lodash_1 = require("lodash");
|
|
7
|
+
const getOperation_1 = __importDefault(require("./getOperation"));
|
|
8
|
+
const validateSpec_1 = __importDefault(require("./validateSpec"));
|
|
9
|
+
const getHttpMethod_1 = __importDefault(require("./getHttpMethod"));
|
|
10
|
+
const getServiceInfo_1 = __importDefault(require("./getServiceInfo"));
|
|
11
|
+
const getServiceTags_1 = __importDefault(require("./getServiceTags"));
|
|
12
|
+
const getServiceDefinitions_1 = __importDefault(require("./getServiceDefinitions"));
|
|
13
|
+
const getServiceSecurityDefinitions_1 = __importDefault(require("./getServiceSecurityDefinitions"));
|
|
14
|
+
/** Creates a specification for a service. */
|
|
15
|
+
const createSpec = (operations, schemasMap, url) => {
|
|
16
|
+
const _url = new URL(url);
|
|
17
|
+
const host = _url.host;
|
|
18
|
+
const basePath = (0, lodash_1.get)(_url, 'pathname', '/');
|
|
19
|
+
const protocol = _url.protocol.replace(':', '');
|
|
20
|
+
const info = (0, getServiceInfo_1.default)();
|
|
21
|
+
const tags = (0, getServiceTags_1.default)(operations);
|
|
22
|
+
const swagger = '2.0';
|
|
23
|
+
const schemes = [protocol];
|
|
24
|
+
const consumes = ['application/json'];
|
|
25
|
+
const produces = ['application/json'];
|
|
26
|
+
const definitions = (0, getServiceDefinitions_1.default)(schemasMap);
|
|
27
|
+
const securityDefinitions = (0, getServiceSecurityDefinitions_1.default)(operations);
|
|
28
|
+
const paths = {};
|
|
29
|
+
for (const OperationClass of operations) {
|
|
30
|
+
const httpPath = `/${OperationClass.id}`;
|
|
31
|
+
const httpMethod = (0, getHttpMethod_1.default)(OperationClass.type);
|
|
32
|
+
paths[httpPath] = {
|
|
33
|
+
[httpMethod]: (0, getOperation_1.default)(OperationClass)
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const spec = {
|
|
37
|
+
swagger,
|
|
38
|
+
info,
|
|
39
|
+
host,
|
|
40
|
+
basePath,
|
|
41
|
+
consumes,
|
|
42
|
+
produces,
|
|
43
|
+
tags,
|
|
44
|
+
paths,
|
|
45
|
+
schemes,
|
|
46
|
+
definitions,
|
|
47
|
+
securityDefinitions,
|
|
48
|
+
};
|
|
49
|
+
const specJson = JSON
|
|
50
|
+
.stringify(spec, null, 2)
|
|
51
|
+
.replace(/"\$ref": "/g, '"$ref": "#/definitions/');
|
|
52
|
+
const result = (0, validateSpec_1.default)(specJson);
|
|
53
|
+
return result;
|
|
54
|
+
};
|
|
55
|
+
exports.default = createSpec;
|
|
56
|
+
//# sourceMappingURL=createSpec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createSpec.js","sourceRoot":"","sources":["../../../src/Service/spec/createSpec.ts"],"names":[],"mappings":";;;;;AAAA,mCAA6B;AAG7B,kEAA0C;AAC1C,kEAA0C;AAE1C,oEAA4C;AAC5C,sEAA8C;AAC9C,sEAA8C;AAC9C,oFAA4D;AAC5D,oGAA4E;AAE5E,6CAA6C;AAC7C,MAAM,UAAU,GAAG,CACjB,UAAgC,EAChC,UAAkC,EAClC,GAAW,EACS,EAAE;IACtB,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IAE1B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IACvB,MAAM,QAAQ,GAAG,IAAA,YAAG,EAAC,IAAI,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;IAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAEhD,MAAM,IAAI,GAAG,IAAA,wBAAc,GAAE,CAAC;IAC9B,MAAM,IAAI,GAAG,IAAA,wBAAc,EAAC,UAAU,CAAC,CAAC;IACxC,MAAM,OAAO,GAAG,KAAK,CAAC;IACtB,MAAM,OAAO,GAAG,CAAE,QAAQ,CAAE,CAAC;IAC7B,MAAM,QAAQ,GAAG,CAAE,kBAAkB,CAAE,CAAC;IACxC,MAAM,QAAQ,GAAG,CAAE,kBAAkB,CAAE,CAAC;IACxC,MAAM,WAAW,GAAG,IAAA,+BAAqB,EAAC,UAAU,CAAC,CAAC;IACtD,MAAM,mBAAmB,GAAG,IAAA,uCAA6B,EAAC,UAAU,CAAC,CAAC;IAEtE,MAAM,KAAK,GAAG,EAA2B,CAAC;IAE1C,KAAK,MAAM,cAAc,IAAI,UAAU,EAAE,CAAC;QACxC,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAC,EAAE,EAAE,CAAC;QACzC,MAAM,UAAU,GAAG,IAAA,uBAAa,EAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAEtD,KAAK,CAAC,QAAQ,CAAC,GAAG;YAChB,CAAC,UAAU,CAAC,EAAE,IAAA,sBAAY,EAAC,cAAc,CAAC;SAC3C,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG;QACX,OAAO;QACP,IAAI;QACJ,IAAI;QACJ,QAAQ;QACR,QAAQ;QACR,QAAQ;QACR,IAAI;QACJ,KAAK;QACL,OAAO;QACP,WAAW;QACX,mBAAmB;KACE,CAAC;IAExB,MAAM,QAAQ,GAAG,IAAI;SAClB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;SACxB,OAAO,CAAC,aAAa,EAAE,yBAAyB,CAAC,CAAC;IAErD,MAAM,MAAM,GAAG,IAAA,sBAAY,EAAC,QAAQ,CAAC,CAAC;IAEtC,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,kBAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type Error = {
|
|
2
|
+
code: string;
|
|
3
|
+
description: string;
|
|
4
|
+
};
|
|
5
|
+
/** Returns description for a number of error responses. */
|
|
6
|
+
declare const getErrorResponseDescription: (errors: Error[]) => string;
|
|
7
|
+
export default getErrorResponseDescription;
|
|
8
|
+
//# sourceMappingURL=getErrorResponseDescription.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getErrorResponseDescription.d.ts","sourceRoot":"","sources":["../../../src/Service/spec/getErrorResponseDescription.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,KAAK,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB,CAAA;AAED,2DAA2D;AAC3D,QAAA,MAAM,2BAA2B,GAAI,QAAQ,KAAK,EAAE,WASnD,CAAC;AAEF,eAAe,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const lodash_1 = require("lodash");
|
|
4
|
+
/** Returns description for a number of error responses. */
|
|
5
|
+
const getErrorResponseDescription = (errors) => {
|
|
6
|
+
return errors
|
|
7
|
+
.map(error => {
|
|
8
|
+
const code = (0, lodash_1.get)(error, 'code');
|
|
9
|
+
const description = (0, lodash_1.get)(error, 'description', 'No error description');
|
|
10
|
+
return `\`${code}\` — ${description}`;
|
|
11
|
+
})
|
|
12
|
+
.join('\n');
|
|
13
|
+
};
|
|
14
|
+
exports.default = getErrorResponseDescription;
|
|
15
|
+
//# sourceMappingURL=getErrorResponseDescription.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getErrorResponseDescription.js","sourceRoot":"","sources":["../../../src/Service/spec/getErrorResponseDescription.ts"],"names":[],"mappings":";;AAAA,mCAA6B;AAO7B,2DAA2D;AAC3D,MAAM,2BAA2B,GAAG,CAAC,MAAe,EAAE,EAAE;IACtD,OAAO,MAAM;SACV,GAAG,CAAC,KAAK,CAAC,EAAE;QACX,MAAM,IAAI,GAAG,IAAA,YAAG,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAChC,MAAM,WAAW,GAAG,IAAA,YAAG,EAAC,KAAK,EAAE,aAAa,EAAE,sBAAsB,CAAC,CAAC;QAEtE,OAAO,KAAK,IAAI,QAAQ,WAAW,EAAE,CAAC;IACxC,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC,CAAC;AAEF,kBAAe,2BAA2B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getHttpMethod.d.ts","sourceRoot":"","sources":["../../../src/Service/spec/getHttpMethod.ts"],"names":[],"mappings":"AAEA,iDAAiD;AACjD,QAAA,MAAM,aAAa,GAAI,MAAM,MAAM,wCAclC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const Operation_1 = __importDefault(require("../../Operation"));
|
|
7
|
+
/** Returns HTTP method for an operation type. */
|
|
8
|
+
const getHttpMethod = (type) => {
|
|
9
|
+
switch (type) {
|
|
10
|
+
case Operation_1.default.types.CREATE:
|
|
11
|
+
return 'post';
|
|
12
|
+
case Operation_1.default.types.DELETE:
|
|
13
|
+
return 'delete';
|
|
14
|
+
case Operation_1.default.types.UPDATE:
|
|
15
|
+
return 'patch';
|
|
16
|
+
default:
|
|
17
|
+
return 'get';
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
exports.default = getHttpMethod;
|
|
21
|
+
//# sourceMappingURL=getHttpMethod.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getHttpMethod.js","sourceRoot":"","sources":["../../../src/Service/spec/getHttpMethod.ts"],"names":[],"mappings":";;;;;AAAA,gEAAwC;AAExC,iDAAiD;AACjD,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,EAAE;IACrC,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,mBAAS,CAAC,KAAK,CAAC,MAAM;YACzB,OAAO,MAAM,CAAC;QAEhB,KAAK,mBAAS,CAAC,KAAK,CAAC,MAAM;YACzB,OAAO,QAAQ,CAAC;QAElB,KAAK,mBAAS,CAAC,KAAK,CAAC,MAAM;YACzB,OAAO,OAAO,CAAC;QAEjB;YACE,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC,CAAC;AAEF,kBAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import Operation from '../../Operation';
|
|
2
|
+
import { OpenAPIV2 } from 'openapi-types';
|
|
3
|
+
/** Returns operation specification for an operation class. */
|
|
4
|
+
declare const getOperation: (OperationClass: typeof Operation) => OpenAPIV2.OperationObject;
|
|
5
|
+
export default getOperation;
|
|
6
|
+
//# sourceMappingURL=getOperation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOperation.d.ts","sourceRoot":"","sources":["../../../src/Service/spec/getOperation.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAM1C,8DAA8D;AAC9D,QAAA,MAAM,YAAY,GAAI,gBAAgB,OAAO,SAAS,KAAG,SAAS,CAAC,eAwFlE,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const getServiceTags_1 = __importDefault(require("./getServiceTags"));
|
|
7
|
+
const getSuccessStatusCode_1 = __importDefault(require("./getSuccessStatusCode"));
|
|
8
|
+
const getOperationParameters_1 = __importDefault(require("./getOperationParameters"));
|
|
9
|
+
const getErrorResponseDescription_1 = __importDefault(require("./getErrorResponseDescription"));
|
|
10
|
+
/** Returns operation specification for an operation class. */
|
|
11
|
+
const getOperation = (OperationClass) => {
|
|
12
|
+
const operationId = OperationClass.id;
|
|
13
|
+
const operationTags = (0, getServiceTags_1.default)([OperationClass]).map(({ name }) => name);
|
|
14
|
+
const { errors, summary, security, isCreate, hasOutput, description, permissions, outputSchema, } = OperationClass;
|
|
15
|
+
const operationSummary = permissions
|
|
16
|
+
? `[${permissions.join(',')}] ${summary}`
|
|
17
|
+
: summary;
|
|
18
|
+
const operationSpec = {
|
|
19
|
+
tags: operationTags,
|
|
20
|
+
summary: operationSummary,
|
|
21
|
+
description,
|
|
22
|
+
operationId,
|
|
23
|
+
};
|
|
24
|
+
const parameters = (0, getOperationParameters_1.default)(OperationClass);
|
|
25
|
+
const hasParameters = parameters.length > 0;
|
|
26
|
+
if (hasParameters) {
|
|
27
|
+
operationSpec.parameters = parameters;
|
|
28
|
+
}
|
|
29
|
+
const successStatusCode = (0, getSuccessStatusCode_1.default)(isCreate, hasOutput);
|
|
30
|
+
const success = {
|
|
31
|
+
description: 'Successful operation execution response'
|
|
32
|
+
};
|
|
33
|
+
if (outputSchema) {
|
|
34
|
+
success.schema = { $ref: outputSchema.id };
|
|
35
|
+
}
|
|
36
|
+
const responses = {
|
|
37
|
+
[successStatusCode]: success,
|
|
38
|
+
default: {
|
|
39
|
+
description: '`OperationError` — Default operation error',
|
|
40
|
+
schema: { $ref: 'OperationError' }
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const errorsMap = {};
|
|
44
|
+
for (const code in errors) {
|
|
45
|
+
const { statusCode, description } = errors[code];
|
|
46
|
+
errorsMap[`${statusCode}`] = errorsMap[`${statusCode}`] || [];
|
|
47
|
+
errorsMap[`${statusCode}`].push({ code, description });
|
|
48
|
+
}
|
|
49
|
+
for (const statusCode in errorsMap) {
|
|
50
|
+
const description = (0, getErrorResponseDescription_1.default)(errorsMap[statusCode]);
|
|
51
|
+
responses[`${statusCode}`] = {
|
|
52
|
+
schema: { $ref: 'OperationError' },
|
|
53
|
+
description
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
operationSpec.responses = responses;
|
|
57
|
+
const hasSecurityRequirements = security.length > 0;
|
|
58
|
+
if (hasSecurityRequirements) {
|
|
59
|
+
operationSpec.security = [];
|
|
60
|
+
for (const requirements of security) {
|
|
61
|
+
const config = {};
|
|
62
|
+
for (const name in requirements) {
|
|
63
|
+
config[name] = [];
|
|
64
|
+
}
|
|
65
|
+
operationSpec.security.push(config);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return operationSpec;
|
|
69
|
+
};
|
|
70
|
+
exports.default = getOperation;
|
|
71
|
+
//# sourceMappingURL=getOperation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOperation.js","sourceRoot":"","sources":["../../../src/Service/spec/getOperation.ts"],"names":[],"mappings":";;;;;AAEA,sEAA8C;AAC9C,kFAA0D;AAC1D,sFAA8D;AAC9D,gGAAwF;AAExF,8DAA8D;AAC9D,MAAM,YAAY,GAAG,CAAC,cAAgC,EAA6B,EAAE;IACnF,MAAM,WAAW,GAAG,cAAc,CAAC,EAAE,CAAC;IACtC,MAAM,aAAa,GAAG,IAAA,wBAAc,EAAC,CAAE,cAAc,CAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;IAEjF,MAAM,EACJ,MAAM,EACN,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,WAAW,EACX,WAAW,EACX,YAAY,GACb,GAAG,cAAc,CAAC;IAEnB,MAAM,gBAAgB,GAAG,WAAW;QAClC,CAAC,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,OAAO,EAAE;QACzC,CAAC,CAAC,OAAO,CAAC;IAEZ,MAAM,aAAa,GAAG;QACpB,IAAI,EAAE,aAAa;QACnB,OAAO,EAAE,gBAAgB;QACzB,WAAW;QACX,WAAW;KACiB,CAAC;IAE/B,MAAM,UAAU,GAAG,IAAA,gCAAsB,EAAC,cAAc,CAAC,CAAC;IAC1D,MAAM,aAAa,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;IAE5C,IAAI,aAAa,EAAE,CAAC;QAClB,aAAa,CAAC,UAAU,GAAG,UAAU,CAAC;IACxC,CAAC;IAED,MAAM,iBAAiB,GAAG,IAAA,8BAAoB,EAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAEpE,MAAM,OAAO,GAAG;QACd,WAAW,EAAE,yCAAyC;KAC3B,CAAC;IAE9B,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,CAAC,MAAM,GAAG,EAAE,IAAI,EAAE,YAAY,CAAC,EAAE,EAAE,CAAC;IAC7C,CAAC;IAED,MAAM,SAAS,GAAG;QAChB,CAAC,iBAAiB,CAAC,EAAE,OAAO;QAC5B,OAAO,EAAE;YACP,WAAW,EAAE,4CAA4C;YACzD,MAAM,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE;SACnC;KACF,CAAC;IAEF,MAAM,SAAS,GAAG,EAA6B,CAAC;IAEhD,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;QAC1B,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QAEjD,SAAS,CAAC,GAAG,UAAU,EAAE,CAAC,GAAG,SAAS,CAAC,GAAG,UAAU,EAAE,CAAC,IAAI,EAAE,CAAC;QAC9D,SAAS,CAAC,GAAG,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,MAAM,UAAU,IAAI,SAAS,EAAE,CAAC;QACnC,MAAM,WAAW,GAAG,IAAA,qCAA2B,EAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;QAEvE,SAAS,CAAC,GAAG,UAAU,EAAE,CAAC,GAAG;YAC3B,MAAM,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE;YAClC,WAAW;SACZ,CAAC;IACJ,CAAC;IAED,aAAa,CAAC,SAAS,GAAG,SAAS,CAAC;IAEpC,MAAM,uBAAuB,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;IAEpD,IAAI,uBAAuB,EAAE,CAAC;QAC5B,aAAa,CAAC,QAAQ,GAAG,EAAE,CAAC;QAE5B,KAAK,MAAM,YAAY,IAAI,QAAQ,EAAE,CAAC;YACpC,MAAM,MAAM,GAAG,EAAyC,CAAC;YAEzD,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;gBAChC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;YACpB,CAAC;YAED,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC;AAEF,kBAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import Operation from '../../Operation';
|
|
2
|
+
import { OpenAPIV2 } from 'openapi-types';
|
|
3
|
+
/** Returns operation parameters. */
|
|
4
|
+
declare const getOperationParameters: (OperationClass: typeof Operation) => OpenAPIV2.Parameter[];
|
|
5
|
+
export default getOperationParameters;
|
|
6
|
+
//# sourceMappingURL=getOperationParameters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOperationParameters.d.ts","sourceRoot":"","sources":["../../../src/Service/spec/getOperationParameters.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,oCAAoC;AACpC,QAAA,MAAM,sBAAsB,GAAI,gBAAgB,OAAO,SAAS,0BAoC/D,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/** Returns operation parameters. */
|
|
4
|
+
const getOperationParameters = (OperationClass) => {
|
|
5
|
+
const parameters = [];
|
|
6
|
+
const { query, mutationSchema } = OperationClass;
|
|
7
|
+
for (const name in query) {
|
|
8
|
+
const _queryParameter = query[name];
|
|
9
|
+
const queryParameter = {
|
|
10
|
+
in: 'query',
|
|
11
|
+
type: 'string',
|
|
12
|
+
name,
|
|
13
|
+
..._queryParameter
|
|
14
|
+
};
|
|
15
|
+
if (queryParameter.example) {
|
|
16
|
+
queryParameter['x-example'] = queryParameter.example;
|
|
17
|
+
delete queryParameter.example;
|
|
18
|
+
}
|
|
19
|
+
parameters.push(queryParameter);
|
|
20
|
+
}
|
|
21
|
+
if (mutationSchema) {
|
|
22
|
+
parameters.push({
|
|
23
|
+
in: 'body',
|
|
24
|
+
name: 'mutation',
|
|
25
|
+
schema: { $ref: mutationSchema.id },
|
|
26
|
+
required: true
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return parameters;
|
|
30
|
+
};
|
|
31
|
+
exports.default = getOperationParameters;
|
|
32
|
+
//# sourceMappingURL=getOperationParameters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOperationParameters.js","sourceRoot":"","sources":["../../../src/Service/spec/getOperationParameters.ts"],"names":[],"mappings":";;AAGA,oCAAoC;AACpC,MAAM,sBAAsB,GAAG,CAAC,cAAgC,EAAE,EAAE;IAClE,MAAM,UAAU,GAAG,EAA2B,CAAC;IAE/C,MAAM,EACJ,KAAK,EACL,cAAc,EACf,GAAG,cAAc,CAAC;IAEnB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;QAEpC,MAAM,cAAc,GAAG;YACrB,EAAE,EAAE,OAAO;YACX,IAAI,EAAE,QAAQ;YACd,IAAI;YACJ,GAAG,eAAe;SACiB,CAAC;QAEtC,IAAI,cAAc,CAAC,OAAO,EAAE,CAAC;YAC3B,cAAc,CAAC,WAAW,CAAC,GAAG,cAAc,CAAC,OAAO,CAAC;YACrD,OAAO,cAAc,CAAC,OAAO,CAAC;QAChC,CAAC;QAED,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAClC,CAAC;IAED,IAAI,cAAc,EAAE,CAAC;QACnB,UAAU,CAAC,IAAI,CAAC;YACd,EAAE,EAAE,MAAM;YACV,IAAI,EAAE,UAAU;YAChB,MAAM,EAAE,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,EAAE;YACnC,QAAQ,EAAE,IAAI;SACoB,CAAC,CAAC;IACxC,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAEF,kBAAe,sBAAsB,CAAC"}
|