@rvoh/psychic 0.24.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/LICENSE +21 -0
- package/README.md +19 -0
- package/dist/cjs/src/bin/helpers/enumsAndTheirValues.js +17 -0
- package/dist/cjs/src/bin/helpers/enumsFileStr.js +21 -0
- package/dist/cjs/src/bin/helpers/generateRouteTypes.js +16 -0
- package/dist/cjs/src/bin/helpers/printRoutes.js +54 -0
- package/dist/cjs/src/bin/index.js +79 -0
- package/dist/cjs/src/cli/helpers/TypesBuilder.js +26 -0
- package/dist/cjs/src/cli/index.js +76 -0
- package/dist/cjs/src/controller/decorators.js +85 -0
- package/dist/cjs/src/controller/hooks.js +29 -0
- package/dist/cjs/src/controller/index.js +571 -0
- package/dist/cjs/src/encrypt/internal-encrypt.js +43 -0
- package/dist/cjs/src/env/Loader.js +26 -0
- package/dist/cjs/src/error/db/failed-to-connect.js +17 -0
- package/dist/cjs/src/error/db/index.js +16 -0
- package/dist/cjs/src/error/db/missing-options.js +17 -0
- package/dist/cjs/src/error/encrypt/missing-cookie-encryption-options.js +27 -0
- package/dist/cjs/src/error/http/BadGateway.js +9 -0
- package/dist/cjs/src/error/http/BadRequest.js +9 -0
- package/dist/cjs/src/error/http/Conflict.js +9 -0
- package/dist/cjs/src/error/http/ContentTooLarge.js +9 -0
- package/dist/cjs/src/error/http/ExpectationFailed.js +9 -0
- package/dist/cjs/src/error/http/FailedDependency.js +9 -0
- package/dist/cjs/src/error/http/Forbidden.js +9 -0
- package/dist/cjs/src/error/http/GatewayTimeout.js +9 -0
- package/dist/cjs/src/error/http/Gone.js +9 -0
- package/dist/cjs/src/error/http/ImATeapot.js +9 -0
- package/dist/cjs/src/error/http/InsufficientStorage.js +9 -0
- package/dist/cjs/src/error/http/InternalServerError.js +9 -0
- package/dist/cjs/src/error/http/Locked.js +9 -0
- package/dist/cjs/src/error/http/MethodNotAllowed.js +9 -0
- package/dist/cjs/src/error/http/MisdirectedRequest.js +9 -0
- package/dist/cjs/src/error/http/NotAcceptable.js +9 -0
- package/dist/cjs/src/error/http/NotExtended.js +9 -0
- package/dist/cjs/src/error/http/NotFound.js +9 -0
- package/dist/cjs/src/error/http/NotImplemented.js +9 -0
- package/dist/cjs/src/error/http/PaymentRequired.js +9 -0
- package/dist/cjs/src/error/http/PreconditionFailed.js +9 -0
- package/dist/cjs/src/error/http/PreconditionRequired.js +9 -0
- package/dist/cjs/src/error/http/ProxyAuthenticationRequired.js +9 -0
- package/dist/cjs/src/error/http/RequestHeaderFieldsTooLarge.js +9 -0
- package/dist/cjs/src/error/http/ServiceUnavailable.js +9 -0
- package/dist/cjs/src/error/http/TooManyRequests.js +9 -0
- package/dist/cjs/src/error/http/Unauthorized.js +9 -0
- package/dist/cjs/src/error/http/UnavailableForLegalReasons.js +9 -0
- package/dist/cjs/src/error/http/UnprocessableContent.js +9 -0
- package/dist/cjs/src/error/http/UnsupportedMediaType.js +9 -0
- package/dist/cjs/src/error/http/index.js +22 -0
- package/dist/cjs/src/error/http/router/index.js +18 -0
- package/dist/cjs/src/error/http/router/missing-controller-method.js +20 -0
- package/dist/cjs/src/error/http/router/missing-controller.js +17 -0
- package/dist/cjs/src/error/http/status-codes.js +311 -0
- package/dist/cjs/src/error/model/index.js +5 -0
- package/dist/cjs/src/error/openapi/CannotFlattenMultiplePolymorphicRendersOneAssociations.js +22 -0
- package/dist/cjs/src/error/psychic-application/init-missing-api-root.js +21 -0
- package/dist/cjs/src/error/psychic-application/init-missing-call-to-load-controllers.js +21 -0
- package/dist/cjs/src/error/psychic-application/init-missing-routes-callback.js +23 -0
- package/dist/cjs/src/error/psychic-application/invalid-encryption-key.js +20 -0
- package/dist/cjs/src/error/router/cannot-find-inferred-controller-from-provided-namespace.js +42 -0
- package/dist/cjs/src/error/router/cannot-infer-controller-from-top-level-route.js +39 -0
- package/dist/cjs/src/error/ws/MissingWsRedisConnection.js +32 -0
- package/dist/cjs/src/generate/controller.js +107 -0
- package/dist/cjs/src/generate/helpers/addResourceToRoutes.js +64 -0
- package/dist/cjs/src/generate/helpers/generateControllerContent.js +191 -0
- package/dist/cjs/src/generate/helpers/generateControllerSpecContent.js +9 -0
- package/dist/cjs/src/generate/helpers/generateResourceControllerSpecContent.js +199 -0
- package/dist/cjs/src/generate/helpers/migrationTimestamp.js +6 -0
- package/dist/cjs/src/generate/resource.js +19 -0
- package/dist/cjs/src/helpers/EnvInternal.js +5 -0
- package/dist/cjs/src/helpers/autogeneratedFileDisclaimer.js +71 -0
- package/dist/cjs/src/helpers/cookieMaxAgeFromCookieOpts.js +20 -0
- package/dist/cjs/src/helpers/error/errorIsRescuableHttpError.js +8 -0
- package/dist/cjs/src/helpers/error/httpErrorClasses.js +76 -0
- package/dist/cjs/src/helpers/importFileWithDefault.js +14 -0
- package/dist/cjs/src/helpers/importFileWithNamedExport.js +12 -0
- package/dist/cjs/src/helpers/isOpenapiError.js +6 -0
- package/dist/cjs/src/helpers/isUuid.js +8 -0
- package/dist/cjs/src/helpers/loadEnv.js +5 -0
- package/dist/cjs/src/helpers/openapiJsonPath.js +9 -0
- package/dist/cjs/src/helpers/pascalizeFileName.js +10 -0
- package/dist/cjs/src/helpers/path/psychicFileAndDirPaths.js +16 -0
- package/dist/cjs/src/helpers/path/psychicPath.js +18 -0
- package/dist/cjs/src/helpers/path/relativePsychicPath.js +43 -0
- package/dist/cjs/src/helpers/path/updirsFromPath.js +11 -0
- package/dist/cjs/src/helpers/path.js +11 -0
- package/dist/cjs/src/helpers/pathifyNestedObject.js +14 -0
- package/dist/cjs/src/helpers/sspawn.js +26 -0
- package/dist/cjs/src/helpers/typeHelpers.js +2 -0
- package/dist/cjs/src/helpers/typechecks.js +20 -0
- package/dist/cjs/src/i18n/conf/I18nDefaultLocales.js +31 -0
- package/dist/cjs/src/i18n/conf/types.js +2 -0
- package/dist/cjs/src/i18n/provider.js +96 -0
- package/dist/cjs/src/index.js +104 -0
- package/dist/cjs/src/openapi-renderer/app.js +153 -0
- package/dist/cjs/src/openapi-renderer/body-segment.js +514 -0
- package/dist/cjs/src/openapi-renderer/defaults.js +84 -0
- package/dist/cjs/src/openapi-renderer/endpoint.js +930 -0
- package/dist/cjs/src/openapi-renderer/helpers/isBlankDescription.js +13 -0
- package/dist/cjs/src/openapi-renderer/helpers/openapiRoute.js +7 -0
- package/dist/cjs/src/openapi-renderer/serializer.js +321 -0
- package/dist/cjs/src/psychic-application/cache.js +17 -0
- package/dist/cjs/src/psychic-application/helpers/PsychicImporter.js +15 -0
- package/dist/cjs/src/psychic-application/helpers/globalControllerKeyFromPath.js +11 -0
- package/dist/cjs/src/psychic-application/helpers/import/importControllers.js +56 -0
- package/dist/cjs/src/psychic-application/helpers/loadAppEnv.js +5 -0
- package/dist/cjs/src/psychic-application/helpers/lookupClassByGlobalName.js +16 -0
- package/dist/cjs/src/psychic-application/index.js +346 -0
- package/dist/cjs/src/psychic-application/logo.js +77 -0
- package/dist/cjs/src/psychic-application/types.js +2 -0
- package/dist/cjs/src/router/helpers.js +138 -0
- package/dist/cjs/src/router/index.js +282 -0
- package/dist/cjs/src/router/route-manager.js +14 -0
- package/dist/cjs/src/router/types.js +6 -0
- package/dist/cjs/src/server/front-end-client.js +15 -0
- package/dist/cjs/src/server/helpers/startPsychicServer.js +39 -0
- package/dist/cjs/src/server/index.js +192 -0
- package/dist/cjs/src/server/params.js +370 -0
- package/dist/cjs/src/session/index.js +38 -0
- package/dist/esm/src/bin/helpers/enumsAndTheirValues.js +14 -0
- package/dist/esm/src/bin/helpers/enumsFileStr.js +18 -0
- package/dist/esm/src/bin/helpers/generateRouteTypes.js +13 -0
- package/dist/esm/src/bin/helpers/printRoutes.js +51 -0
- package/dist/esm/src/bin/index.js +76 -0
- package/dist/esm/src/cli/helpers/TypesBuilder.js +23 -0
- package/dist/esm/src/cli/index.js +73 -0
- package/dist/esm/src/controller/decorators.js +81 -0
- package/dist/esm/src/controller/hooks.js +25 -0
- package/dist/esm/src/controller/index.js +566 -0
- package/dist/esm/src/encrypt/internal-encrypt.js +40 -0
- package/dist/esm/src/env/Loader.js +24 -0
- package/dist/esm/src/error/db/failed-to-connect.js +14 -0
- package/dist/esm/src/error/db/index.js +13 -0
- package/dist/esm/src/error/db/missing-options.js +14 -0
- package/dist/esm/src/error/encrypt/missing-cookie-encryption-options.js +24 -0
- package/dist/esm/src/error/http/BadGateway.js +6 -0
- package/dist/esm/src/error/http/BadRequest.js +6 -0
- package/dist/esm/src/error/http/Conflict.js +6 -0
- package/dist/esm/src/error/http/ContentTooLarge.js +6 -0
- package/dist/esm/src/error/http/ExpectationFailed.js +6 -0
- package/dist/esm/src/error/http/FailedDependency.js +6 -0
- package/dist/esm/src/error/http/Forbidden.js +6 -0
- package/dist/esm/src/error/http/GatewayTimeout.js +6 -0
- package/dist/esm/src/error/http/Gone.js +6 -0
- package/dist/esm/src/error/http/ImATeapot.js +6 -0
- package/dist/esm/src/error/http/InsufficientStorage.js +6 -0
- package/dist/esm/src/error/http/InternalServerError.js +6 -0
- package/dist/esm/src/error/http/Locked.js +6 -0
- package/dist/esm/src/error/http/MethodNotAllowed.js +6 -0
- package/dist/esm/src/error/http/MisdirectedRequest.js +6 -0
- package/dist/esm/src/error/http/NotAcceptable.js +6 -0
- package/dist/esm/src/error/http/NotExtended.js +6 -0
- package/dist/esm/src/error/http/NotFound.js +6 -0
- package/dist/esm/src/error/http/NotImplemented.js +6 -0
- package/dist/esm/src/error/http/PaymentRequired.js +6 -0
- package/dist/esm/src/error/http/PreconditionFailed.js +6 -0
- package/dist/esm/src/error/http/PreconditionRequired.js +6 -0
- package/dist/esm/src/error/http/ProxyAuthenticationRequired.js +6 -0
- package/dist/esm/src/error/http/RequestHeaderFieldsTooLarge.js +6 -0
- package/dist/esm/src/error/http/ServiceUnavailable.js +6 -0
- package/dist/esm/src/error/http/TooManyRequests.js +6 -0
- package/dist/esm/src/error/http/Unauthorized.js +6 -0
- package/dist/esm/src/error/http/UnavailableForLegalReasons.js +6 -0
- package/dist/esm/src/error/http/UnprocessableContent.js +6 -0
- package/dist/esm/src/error/http/UnsupportedMediaType.js +6 -0
- package/dist/esm/src/error/http/index.js +19 -0
- package/dist/esm/src/error/http/router/index.js +15 -0
- package/dist/esm/src/error/http/router/missing-controller-method.js +17 -0
- package/dist/esm/src/error/http/router/missing-controller.js +14 -0
- package/dist/esm/src/error/http/status-codes.js +309 -0
- package/dist/esm/src/error/model/index.js +2 -0
- package/dist/esm/src/error/openapi/CannotFlattenMultiplePolymorphicRendersOneAssociations.js +19 -0
- package/dist/esm/src/error/psychic-application/init-missing-api-root.js +18 -0
- package/dist/esm/src/error/psychic-application/init-missing-call-to-load-controllers.js +18 -0
- package/dist/esm/src/error/psychic-application/init-missing-routes-callback.js +20 -0
- package/dist/esm/src/error/psychic-application/invalid-encryption-key.js +17 -0
- package/dist/esm/src/error/router/cannot-find-inferred-controller-from-provided-namespace.js +39 -0
- package/dist/esm/src/error/router/cannot-infer-controller-from-top-level-route.js +36 -0
- package/dist/esm/src/error/ws/MissingWsRedisConnection.js +29 -0
- package/dist/esm/src/generate/controller.js +104 -0
- package/dist/esm/src/generate/helpers/addResourceToRoutes.js +60 -0
- package/dist/esm/src/generate/helpers/generateControllerContent.js +188 -0
- package/dist/esm/src/generate/helpers/generateControllerSpecContent.js +6 -0
- package/dist/esm/src/generate/helpers/generateResourceControllerSpecContent.js +196 -0
- package/dist/esm/src/generate/helpers/migrationTimestamp.js +3 -0
- package/dist/esm/src/generate/resource.js +16 -0
- package/dist/esm/src/helpers/EnvInternal.js +3 -0
- package/dist/esm/src/helpers/autogeneratedFileDisclaimer.js +68 -0
- package/dist/esm/src/helpers/cookieMaxAgeFromCookieOpts.js +17 -0
- package/dist/esm/src/helpers/error/errorIsRescuableHttpError.js +5 -0
- package/dist/esm/src/helpers/error/httpErrorClasses.js +72 -0
- package/dist/esm/src/helpers/importFileWithDefault.js +11 -0
- package/dist/esm/src/helpers/importFileWithNamedExport.js +9 -0
- package/dist/esm/src/helpers/isOpenapiError.js +3 -0
- package/dist/esm/src/helpers/isUuid.js +5 -0
- package/dist/esm/src/helpers/loadEnv.js +3 -0
- package/dist/esm/src/helpers/openapiJsonPath.js +6 -0
- package/dist/esm/src/helpers/pascalizeFileName.js +7 -0
- package/dist/esm/src/helpers/path/psychicFileAndDirPaths.js +13 -0
- package/dist/esm/src/helpers/path/psychicPath.js +15 -0
- package/dist/esm/src/helpers/path/relativePsychicPath.js +39 -0
- package/dist/esm/src/helpers/path/updirsFromPath.js +8 -0
- package/dist/esm/src/helpers/path.js +7 -0
- package/dist/esm/src/helpers/pathifyNestedObject.js +11 -0
- package/dist/esm/src/helpers/sspawn.js +22 -0
- package/dist/esm/src/helpers/typeHelpers.js +1 -0
- package/dist/esm/src/helpers/typechecks.js +16 -0
- package/dist/esm/src/i18n/conf/I18nDefaultLocales.js +29 -0
- package/dist/esm/src/i18n/conf/types.js +1 -0
- package/dist/esm/src/i18n/provider.js +89 -0
- package/dist/esm/src/index.js +50 -0
- package/dist/esm/src/openapi-renderer/app.js +150 -0
- package/dist/esm/src/openapi-renderer/body-segment.js +511 -0
- package/dist/esm/src/openapi-renderer/defaults.js +81 -0
- package/dist/esm/src/openapi-renderer/endpoint.js +925 -0
- package/dist/esm/src/openapi-renderer/helpers/isBlankDescription.js +10 -0
- package/dist/esm/src/openapi-renderer/helpers/openapiRoute.js +4 -0
- package/dist/esm/src/openapi-renderer/serializer.js +318 -0
- package/dist/esm/src/psychic-application/cache.js +12 -0
- package/dist/esm/src/psychic-application/helpers/PsychicImporter.js +12 -0
- package/dist/esm/src/psychic-application/helpers/globalControllerKeyFromPath.js +8 -0
- package/dist/esm/src/psychic-application/helpers/import/importControllers.js +51 -0
- package/dist/esm/src/psychic-application/helpers/loadAppEnv.js +3 -0
- package/dist/esm/src/psychic-application/helpers/lookupClassByGlobalName.js +13 -0
- package/dist/esm/src/psychic-application/index.js +343 -0
- package/dist/esm/src/psychic-application/logo.js +73 -0
- package/dist/esm/src/psychic-application/types.js +1 -0
- package/dist/esm/src/router/helpers.js +127 -0
- package/dist/esm/src/router/index.js +277 -0
- package/dist/esm/src/router/route-manager.js +11 -0
- package/dist/esm/src/router/types.js +3 -0
- package/dist/esm/src/server/front-end-client.js +12 -0
- package/dist/esm/src/server/helpers/startPsychicServer.js +35 -0
- package/dist/esm/src/server/index.js +189 -0
- package/dist/esm/src/server/params.js +365 -0
- package/dist/esm/src/session/index.js +35 -0
- package/dist/types/src/bin/helpers/enumsAndTheirValues.d.ts +1 -0
- package/dist/types/src/bin/helpers/enumsFileStr.d.ts +1 -0
- package/dist/types/src/bin/helpers/generateRouteTypes.d.ts +2 -0
- package/dist/types/src/bin/helpers/printRoutes.d.ts +1 -0
- package/dist/types/src/bin/index.d.ts +12 -0
- package/dist/types/src/cli/helpers/TypesBuilder.d.ts +7 -0
- package/dist/types/src/cli/index.d.ts +8 -0
- package/dist/types/src/controller/decorators.d.ts +28 -0
- package/dist/types/src/controller/hooks.d.ts +13 -0
- package/dist/types/src/controller/index.d.ts +209 -0
- package/dist/types/src/encrypt/internal-encrypt.d.ts +6 -0
- package/dist/types/src/env/Loader.d.ts +8 -0
- package/dist/types/src/error/db/failed-to-connect.d.ts +4 -0
- package/dist/types/src/error/db/index.d.ts +5 -0
- package/dist/types/src/error/db/missing-options.d.ts +4 -0
- package/dist/types/src/error/encrypt/missing-cookie-encryption-options.d.ts +3 -0
- package/dist/types/src/error/http/BadGateway.d.ts +4 -0
- package/dist/types/src/error/http/BadRequest.d.ts +4 -0
- package/dist/types/src/error/http/Conflict.d.ts +4 -0
- package/dist/types/src/error/http/ContentTooLarge.d.ts +4 -0
- package/dist/types/src/error/http/ExpectationFailed.d.ts +4 -0
- package/dist/types/src/error/http/FailedDependency.d.ts +4 -0
- package/dist/types/src/error/http/Forbidden.d.ts +4 -0
- package/dist/types/src/error/http/GatewayTimeout.d.ts +4 -0
- package/dist/types/src/error/http/Gone.d.ts +4 -0
- package/dist/types/src/error/http/ImATeapot.d.ts +4 -0
- package/dist/types/src/error/http/InsufficientStorage.d.ts +4 -0
- package/dist/types/src/error/http/InternalServerError.d.ts +4 -0
- package/dist/types/src/error/http/Locked.d.ts +4 -0
- package/dist/types/src/error/http/MethodNotAllowed.d.ts +4 -0
- package/dist/types/src/error/http/MisdirectedRequest.d.ts +4 -0
- package/dist/types/src/error/http/NotAcceptable.d.ts +4 -0
- package/dist/types/src/error/http/NotExtended.d.ts +4 -0
- package/dist/types/src/error/http/NotFound.d.ts +4 -0
- package/dist/types/src/error/http/NotImplemented.d.ts +4 -0
- package/dist/types/src/error/http/PaymentRequired.d.ts +4 -0
- package/dist/types/src/error/http/PreconditionFailed.d.ts +4 -0
- package/dist/types/src/error/http/PreconditionRequired.d.ts +4 -0
- package/dist/types/src/error/http/ProxyAuthenticationRequired.d.ts +4 -0
- package/dist/types/src/error/http/RequestHeaderFieldsTooLarge.d.ts +4 -0
- package/dist/types/src/error/http/ServiceUnavailable.d.ts +4 -0
- package/dist/types/src/error/http/TooManyRequests.d.ts +4 -0
- package/dist/types/src/error/http/Unauthorized.d.ts +4 -0
- package/dist/types/src/error/http/UnavailableForLegalReasons.d.ts +4 -0
- package/dist/types/src/error/http/UnprocessableContent.d.ts +4 -0
- package/dist/types/src/error/http/UnsupportedMediaType.d.ts +4 -0
- package/dist/types/src/error/http/index.d.ts +10 -0
- package/dist/types/src/error/http/router/index.d.ts +6 -0
- package/dist/types/src/error/http/router/missing-controller-method.d.ts +7 -0
- package/dist/types/src/error/http/router/missing-controller.d.ts +6 -0
- package/dist/types/src/error/http/status-codes.d.ts +312 -0
- package/dist/types/src/error/model/index.d.ts +2 -0
- package/dist/types/src/error/openapi/CannotFlattenMultiplePolymorphicRendersOneAssociations.d.ts +7 -0
- package/dist/types/src/error/psychic-application/init-missing-api-root.d.ts +4 -0
- package/dist/types/src/error/psychic-application/init-missing-call-to-load-controllers.d.ts +4 -0
- package/dist/types/src/error/psychic-application/init-missing-routes-callback.d.ts +4 -0
- package/dist/types/src/error/psychic-application/invalid-encryption-key.d.ts +4 -0
- package/dist/types/src/error/router/cannot-find-inferred-controller-from-provided-namespace.d.ts +15 -0
- package/dist/types/src/error/router/cannot-infer-controller-from-top-level-route.d.ts +8 -0
- package/dist/types/src/error/ws/MissingWsRedisConnection.d.ts +3 -0
- package/dist/types/src/generate/controller.d.ts +7 -0
- package/dist/types/src/generate/helpers/addResourceToRoutes.d.ts +7 -0
- package/dist/types/src/generate/helpers/generateControllerContent.d.ts +8 -0
- package/dist/types/src/generate/helpers/generateControllerSpecContent.d.ts +1 -0
- package/dist/types/src/generate/helpers/generateResourceControllerSpecContent.d.ts +6 -0
- package/dist/types/src/generate/helpers/migrationTimestamp.d.ts +1 -0
- package/dist/types/src/generate/resource.d.ts +5 -0
- package/dist/types/src/helpers/EnvInternal.d.ts +7 -0
- package/dist/types/src/helpers/autogeneratedFileDisclaimer.d.ts +1 -0
- package/dist/types/src/helpers/cookieMaxAgeFromCookieOpts.d.ts +2 -0
- package/dist/types/src/helpers/error/errorIsRescuableHttpError.d.ts +1 -0
- package/dist/types/src/helpers/error/httpErrorClasses.d.ts +3 -0
- package/dist/types/src/helpers/importFileWithDefault.d.ts +1 -0
- package/dist/types/src/helpers/importFileWithNamedExport.d.ts +1 -0
- package/dist/types/src/helpers/isOpenapiError.d.ts +8 -0
- package/dist/types/src/helpers/isUuid.d.ts +1 -0
- package/dist/types/src/helpers/loadEnv.d.ts +1 -0
- package/dist/types/src/helpers/openapiJsonPath.d.ts +1 -0
- package/dist/types/src/helpers/pascalizeFileName.d.ts +1 -0
- package/dist/types/src/helpers/path/psychicFileAndDirPaths.d.ts +5 -0
- package/dist/types/src/helpers/path/psychicPath.d.ts +4 -0
- package/dist/types/src/helpers/path/relativePsychicPath.d.ts +3 -0
- package/dist/types/src/helpers/path/updirsFromPath.d.ts +1 -0
- package/dist/types/src/helpers/path.d.ts +2 -0
- package/dist/types/src/helpers/pathifyNestedObject.d.ts +5 -0
- package/dist/types/src/helpers/sspawn.d.ts +2 -0
- package/dist/types/src/helpers/typeHelpers.d.ts +4 -0
- package/dist/types/src/helpers/typechecks.d.ts +2 -0
- package/dist/types/src/i18n/conf/I18nDefaultLocales.d.ts +2 -0
- package/dist/types/src/i18n/conf/types.d.ts +45 -0
- package/dist/types/src/i18n/provider.d.ts +26 -0
- package/dist/types/src/index.d.ts +61 -0
- package/dist/types/src/openapi-renderer/app.d.ts +21 -0
- package/dist/types/src/openapi-renderer/body-segment.d.ts +153 -0
- package/dist/types/src/openapi-renderer/defaults.d.ts +5 -0
- package/dist/types/src/openapi-renderer/endpoint.d.ts +410 -0
- package/dist/types/src/openapi-renderer/helpers/isBlankDescription.d.ts +1 -0
- package/dist/types/src/openapi-renderer/helpers/openapiRoute.d.ts +1 -0
- package/dist/types/src/openapi-renderer/serializer.d.ts +76 -0
- package/dist/types/src/psychic-application/cache.d.ts +4 -0
- package/dist/types/src/psychic-application/helpers/PsychicImporter.d.ts +4 -0
- package/dist/types/src/psychic-application/helpers/globalControllerKeyFromPath.d.ts +1 -0
- package/dist/types/src/psychic-application/helpers/import/importControllers.d.ts +5 -0
- package/dist/types/src/psychic-application/helpers/loadAppEnv.d.ts +1 -0
- package/dist/types/src/psychic-application/helpers/lookupClassByGlobalName.d.ts +1 -0
- package/dist/types/src/psychic-application/index.d.ts +164 -0
- package/dist/types/src/psychic-application/logo.d.ts +2 -0
- package/dist/types/src/psychic-application/types.d.ts +6 -0
- package/dist/types/src/router/helpers.d.ts +26 -0
- package/dist/types/src/router/index.d.ts +55 -0
- package/dist/types/src/router/route-manager.d.ts +17 -0
- package/dist/types/src/router/types.d.ts +11 -0
- package/dist/types/src/server/front-end-client.d.ts +5 -0
- package/dist/types/src/server/helpers/startPsychicServer.d.ts +14 -0
- package/dist/types/src/server/index.d.ts +34 -0
- package/dist/types/src/server/params.d.ts +80 -0
- package/dist/types/src/session/index.d.ts +12 -0
- package/package.json +98 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
const SUPPORTED_LOCALES = ['en-US'];
|
|
2
|
+
export function supportedLocales() {
|
|
3
|
+
return SUPPORTED_LOCALES;
|
|
4
|
+
}
|
|
5
|
+
class TranslationMissing extends Error {
|
|
6
|
+
}
|
|
7
|
+
export default class I18nProvider {
|
|
8
|
+
/**
|
|
9
|
+
* Leverages the arguments provided to return to you an
|
|
10
|
+
* i18n function, which will provide type completion based
|
|
11
|
+
* on the locales set up in your application.
|
|
12
|
+
*
|
|
13
|
+
* @param allLocales - the list of all locales in your app. something like `{ en: { ... }, ['en-UK']: { ... }, es: { ... }, ... }`
|
|
14
|
+
* @param singleLocaleKey - the key from the allLocales object that you want to use as your type base. i.e. 'en'
|
|
15
|
+
* */
|
|
16
|
+
static provide(allLocales, singleLocaleKey) {
|
|
17
|
+
return function i18n(locale, i18nPathString, interpolations) {
|
|
18
|
+
const language = locale?.split('-')?.[0];
|
|
19
|
+
const i18nPath = i18nPathString.split('.');
|
|
20
|
+
const localeI18nObject = (allLocales[language] ||
|
|
21
|
+
allLocales['en']);
|
|
22
|
+
try {
|
|
23
|
+
return applyInterpolations(i18nPathString, _i18n(localeI18nObject, i18nPath), interpolations);
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
const error = err;
|
|
27
|
+
if (error.constructor === TranslationMissing)
|
|
28
|
+
return i18nPathString;
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function applyInterpolations(i18nPathString, str, interpolations) {
|
|
35
|
+
if (!interpolations)
|
|
36
|
+
return str;
|
|
37
|
+
Object.keys(interpolations).forEach(key => {
|
|
38
|
+
const interpolationValue = interpolations[key];
|
|
39
|
+
if (interpolationValue === undefined)
|
|
40
|
+
throw new I18nInterpolationReceivedUndefined(i18nPathString, key);
|
|
41
|
+
if (interpolationValue === null)
|
|
42
|
+
throw new I18nInterpolationReceivedNull(i18nPathString, key);
|
|
43
|
+
const replacement = interpolationValue.toString();
|
|
44
|
+
str = str.replace(`%{${key}}`, replacement);
|
|
45
|
+
});
|
|
46
|
+
return str;
|
|
47
|
+
}
|
|
48
|
+
function _i18n(i18nHash, i18nPath) {
|
|
49
|
+
const translation = i18nHash[i18nPath[0]];
|
|
50
|
+
if (translation === undefined)
|
|
51
|
+
throw new TranslationMissing();
|
|
52
|
+
if (typeof translation === 'string')
|
|
53
|
+
return translation;
|
|
54
|
+
return _i18n(translation, i18nPath.slice(1));
|
|
55
|
+
}
|
|
56
|
+
export class I18nInterpolationReceivedUndefined extends Error {
|
|
57
|
+
i18nPathString;
|
|
58
|
+
interpolationKey;
|
|
59
|
+
constructor(i18nPathString, interpolationKey) {
|
|
60
|
+
super();
|
|
61
|
+
Object.setPrototypeOf(this, I18nInterpolationReceivedUndefined.prototype);
|
|
62
|
+
this.i18nPathString = i18nPathString;
|
|
63
|
+
this.interpolationKey = interpolationKey;
|
|
64
|
+
}
|
|
65
|
+
get message() {
|
|
66
|
+
return `
|
|
67
|
+
undefined interpolation value received:
|
|
68
|
+
i18n path string: ${this.i18nPathString}
|
|
69
|
+
interpolationKey: ${this.interpolationKey}
|
|
70
|
+
`;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export class I18nInterpolationReceivedNull extends Error {
|
|
74
|
+
i18nPathString;
|
|
75
|
+
interpolationKey;
|
|
76
|
+
constructor(i18nPathString, interpolationKey) {
|
|
77
|
+
super();
|
|
78
|
+
Object.setPrototypeOf(this, I18nInterpolationReceivedNull.prototype);
|
|
79
|
+
this.i18nPathString = i18nPathString;
|
|
80
|
+
this.interpolationKey = interpolationKey;
|
|
81
|
+
}
|
|
82
|
+
get message() {
|
|
83
|
+
return `
|
|
84
|
+
null interpolation value received:
|
|
85
|
+
i18n path string: ${this.i18nPathString}
|
|
86
|
+
interpolationKey: ${this.interpolationKey}
|
|
87
|
+
`;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import _pluralize from 'pluralize-esm';
|
|
2
|
+
export const pluralize = _pluralize;
|
|
3
|
+
export { default as PsychicBin } from './bin/index.js';
|
|
4
|
+
export { default as PsychicCLI } from './cli/index.js';
|
|
5
|
+
export { default as PsychicController, } from './controller/index.js';
|
|
6
|
+
export { BeforeAction, OpenAPI } from './controller/decorators.js';
|
|
7
|
+
export { default as envLoader } from './env/Loader.js';
|
|
8
|
+
export { default as I18nProvider } from './i18n/provider.js';
|
|
9
|
+
export { default as HttpStatusBadGateway } from './error/http/BadGateway.js';
|
|
10
|
+
export { default as HttpStatusBadRequest } from './error/http/BadRequest.js';
|
|
11
|
+
export { default as HttpStatusConflict } from './error/http/Conflict.js';
|
|
12
|
+
export { default as HttpStatusContentTooLarge } from './error/http/ContentTooLarge.js';
|
|
13
|
+
export { default as HttpStatusExpectationFailed } from './error/http/ExpectationFailed.js';
|
|
14
|
+
export { default as HttpStatusFailedDependency } from './error/http/FailedDependency.js';
|
|
15
|
+
export { default as HttpStatusForbidden } from './error/http/Forbidden.js';
|
|
16
|
+
export { default as HttpStatusGatewayTimeout } from './error/http/GatewayTimeout.js';
|
|
17
|
+
export { default as HttpStatusGone } from './error/http/Gone.js';
|
|
18
|
+
export { default as HttpStatusImATeapot } from './error/http/ImATeapot.js';
|
|
19
|
+
export { default as HttpStatusInsufficientStorage } from './error/http/InsufficientStorage.js';
|
|
20
|
+
export { default as HttpStatusInternalServerError } from './error/http/InternalServerError.js';
|
|
21
|
+
export { default as HttpStatusLocked } from './error/http/Locked.js';
|
|
22
|
+
export { default as HttpStatusMethodNotAllowed } from './error/http/MethodNotAllowed.js';
|
|
23
|
+
export { default as HttpStatusMisdirectedRequest } from './error/http/MisdirectedRequest.js';
|
|
24
|
+
export { default as HttpStatusNotAcceptable } from './error/http/NotAcceptable.js';
|
|
25
|
+
export { default as HttpStatusNotExtended } from './error/http/NotExtended.js';
|
|
26
|
+
export { default as HttpStatusNotFound } from './error/http/NotFound.js';
|
|
27
|
+
export { default as HttpStatusNotImplemented } from './error/http/NotImplemented.js';
|
|
28
|
+
export { default as HttpStatusPaymentRequired } from './error/http/PaymentRequired.js';
|
|
29
|
+
export { default as HttpStatusPreconditionFailed } from './error/http/PreconditionFailed.js';
|
|
30
|
+
export { default as HttpStatusPreconditionRequired } from './error/http/PreconditionRequired.js';
|
|
31
|
+
export { default as HttpStatusProxyAuthenticationRequired } from './error/http/ProxyAuthenticationRequired.js';
|
|
32
|
+
export { default as HttpStatusRequestHeaderFieldsTooLarge } from './error/http/RequestHeaderFieldsTooLarge.js';
|
|
33
|
+
export { default as HttpStatusServiceUnavailable } from './error/http/ServiceUnavailable.js';
|
|
34
|
+
export { default as HttpStatusTooManyRequests } from './error/http/TooManyRequests.js';
|
|
35
|
+
export { default as HttpStatusUnauthorized } from './error/http/Unauthorized.js';
|
|
36
|
+
export { default as HttpStatusUnavailableForLegalReasons } from './error/http/UnavailableForLegalReasons.js';
|
|
37
|
+
export { default as HttpStatusUnprocessableContent } from './error/http/UnprocessableContent.js';
|
|
38
|
+
export { default as HttpStatusUnsupportedMediaType } from './error/http/UnsupportedMediaType.js';
|
|
39
|
+
export { default as generateController } from './generate/controller.js';
|
|
40
|
+
export { default as generateResource } from './generate/resource.js';
|
|
41
|
+
export { default as cookieMaxAgeFromCookieOpts } from './helpers/cookieMaxAgeFromCookieOpts.js';
|
|
42
|
+
export { default as pathifyNestedObject } from './helpers/pathifyNestedObject.js';
|
|
43
|
+
export { MissingControllerActionPairingInRoutes, } from './openapi-renderer/endpoint.js';
|
|
44
|
+
export { default as PsychicApplication, } from './psychic-application/index.js';
|
|
45
|
+
export { default as PsychicImporter } from './psychic-application/helpers/PsychicImporter.js';
|
|
46
|
+
export { default as PsychicRouter } from './router/index.js';
|
|
47
|
+
export { default as PsychicServer } from './server/index.js';
|
|
48
|
+
export { createPsychicHttpInstance as getPsychicHttpInstance } from './server/helpers/startPsychicServer.js';
|
|
49
|
+
export { default as Params, ParamValidationError } from './server/params.js';
|
|
50
|
+
export { default as PsychicSession } from './session/index.js';
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import * as fs from 'fs/promises';
|
|
2
|
+
import { groupBy } from 'lodash-es';
|
|
3
|
+
import EnvInternal from '../helpers/EnvInternal.js';
|
|
4
|
+
import openapiJsonPath from '../helpers/openapiJsonPath.js';
|
|
5
|
+
import PsychicApplication from '../psychic-application/index.js';
|
|
6
|
+
import { HttpMethods } from '../router/types.js';
|
|
7
|
+
import PsychicServer from '../server/index.js';
|
|
8
|
+
import { DEFAULT_OPENAPI_COMPONENT_RESPONSES, DEFAULT_OPENAPI_COMPONENT_SCHEMAS } from './defaults.js';
|
|
9
|
+
export default class OpenapiAppRenderer {
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
*
|
|
13
|
+
* reads the lates openapi builds using buildOpenapiObject, and syncs
|
|
14
|
+
* the contents to the openapi.json file at the project root.
|
|
15
|
+
*/
|
|
16
|
+
static async sync() {
|
|
17
|
+
const openapiContents = await OpenapiAppRenderer.toObject();
|
|
18
|
+
const psychicApp = PsychicApplication.getOrFail();
|
|
19
|
+
const asyncWriteOpenapiFile = async (key) => {
|
|
20
|
+
const jsonPath = openapiJsonPath(key);
|
|
21
|
+
await fs.writeFile(jsonPath, JSON.stringify(openapiContents[key], null, 2), {
|
|
22
|
+
flag: 'w+',
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
await Promise.all(Object.keys(psychicApp.openapi).map(key => asyncWriteOpenapiFile(key)));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* @internal
|
|
29
|
+
*
|
|
30
|
+
* builds a new typescript object which contains the combined
|
|
31
|
+
* payloads of all `@Openapi` decorator calls used throughout
|
|
32
|
+
* the controller layer.
|
|
33
|
+
*/
|
|
34
|
+
static async toObject() {
|
|
35
|
+
const psychicApp = PsychicApplication.getOrFail();
|
|
36
|
+
const convertToObjectAndStoreInOutput = async (output, key) => {
|
|
37
|
+
output[key] = await this._toObject(key);
|
|
38
|
+
};
|
|
39
|
+
const output = {};
|
|
40
|
+
await Promise.all(Object.keys(psychicApp.openapi).map(key => convertToObjectAndStoreInOutput(output, key)));
|
|
41
|
+
return output;
|
|
42
|
+
}
|
|
43
|
+
static async _toObject(openapiName) {
|
|
44
|
+
const processedSchemas = {};
|
|
45
|
+
const psychicApp = PsychicApplication.getOrFail();
|
|
46
|
+
const controllers = psychicApp.controllers;
|
|
47
|
+
const server = new PsychicServer();
|
|
48
|
+
await server.boot();
|
|
49
|
+
const routes = await server.routes();
|
|
50
|
+
const openapiConfig = psychicApp.openapi?.[openapiName];
|
|
51
|
+
const finalOutput = {
|
|
52
|
+
openapi: '3.1.0',
|
|
53
|
+
info: {
|
|
54
|
+
version: openapiConfig?.info?.version || 'unknown version',
|
|
55
|
+
title: openapiConfig?.info?.title || 'unknown title',
|
|
56
|
+
description: openapiConfig?.info?.description || 'The autogenerated openapi spec for your app',
|
|
57
|
+
},
|
|
58
|
+
paths: {},
|
|
59
|
+
components: {
|
|
60
|
+
...(psychicApp.openapi?.[openapiName]?.defaults?.components || {}),
|
|
61
|
+
schemas: {
|
|
62
|
+
...DEFAULT_OPENAPI_COMPONENT_SCHEMAS,
|
|
63
|
+
...(psychicApp.openapi?.[openapiName]?.defaults?.components?.schemas ||
|
|
64
|
+
{}),
|
|
65
|
+
},
|
|
66
|
+
responses: {
|
|
67
|
+
...DEFAULT_OPENAPI_COMPONENT_RESPONSES,
|
|
68
|
+
...(psychicApp.openapi?.[openapiName]?.defaults?.components?.responses || {}),
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
if (psychicApp.openapi?.[openapiName]?.servers) {
|
|
73
|
+
finalOutput.servers = psychicApp.openapi?.[openapiName]?.servers;
|
|
74
|
+
}
|
|
75
|
+
if (psychicApp.openapi?.[openapiName]?.defaults?.securitySchemes) {
|
|
76
|
+
finalOutput.components = {
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment
|
|
78
|
+
securitySchemes: psychicApp.openapi?.[openapiName].defaults.securitySchemes,
|
|
79
|
+
...finalOutput.components,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
if (psychicApp.openapi?.[openapiName]?.defaults?.security) {
|
|
83
|
+
finalOutput.security = psychicApp.openapi?.[openapiName].defaults.security;
|
|
84
|
+
}
|
|
85
|
+
for (const [controllerName, controller] of Object.entries(controllers).filter(([, controller]) => controller.openapiNames.includes(openapiName))) {
|
|
86
|
+
for (const key of Object.keys(controller.openapi || {})) {
|
|
87
|
+
if (EnvInternal.isDebug)
|
|
88
|
+
console.log(`Processing OpenAPI key ${key} for controller ${controllerName}`);
|
|
89
|
+
const renderer = controller.openapi[key];
|
|
90
|
+
finalOutput.components.schemas = {
|
|
91
|
+
...finalOutput.components.schemas,
|
|
92
|
+
...renderer.toSchemaObject(openapiName, processedSchemas),
|
|
93
|
+
};
|
|
94
|
+
const endpointPayload = renderer.toPathObject(openapiName, processedSchemas, routes);
|
|
95
|
+
const path = Object.keys(endpointPayload)[0];
|
|
96
|
+
const method = Object.keys(endpointPayload[path]).find(key => HttpMethods.includes(key));
|
|
97
|
+
if (!finalOutput.paths[path]) {
|
|
98
|
+
finalOutput.paths[path] = { parameters: [] };
|
|
99
|
+
}
|
|
100
|
+
const pathObj = finalOutput.paths[path];
|
|
101
|
+
const otherPathObj = endpointPayload[path];
|
|
102
|
+
pathObj[method] = otherPathObj[method];
|
|
103
|
+
pathObj.parameters = this.combineParameters([
|
|
104
|
+
...pathObj.parameters,
|
|
105
|
+
...endpointPayload[path].parameters,
|
|
106
|
+
]);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return this.sortedSchemaPayload(finalOutput);
|
|
110
|
+
}
|
|
111
|
+
static combineParameters(parameters) {
|
|
112
|
+
const groupedParams = groupBy(parameters, 'name');
|
|
113
|
+
const result = Object.keys(groupedParams).map(paramName => {
|
|
114
|
+
const identicalParams = groupedParams[paramName];
|
|
115
|
+
return identicalParams.reduce((compositeParam, param) => {
|
|
116
|
+
compositeParam.description ||= param.description;
|
|
117
|
+
if (compositeParam.allowEmptyValue !== undefined)
|
|
118
|
+
compositeParam.allowEmptyValue = param.allowEmptyValue;
|
|
119
|
+
if (compositeParam.allowReserved !== undefined)
|
|
120
|
+
compositeParam.allowReserved = param.allowReserved;
|
|
121
|
+
if (compositeParam.required !== undefined)
|
|
122
|
+
compositeParam.required = param.required;
|
|
123
|
+
return compositeParam;
|
|
124
|
+
}, identicalParams[0]);
|
|
125
|
+
});
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
static sortedSchemaPayload(schema) {
|
|
129
|
+
const sortedPaths = Object.keys(schema.paths).sort();
|
|
130
|
+
const sortedSchemas = Object.keys(schema.components.schemas).sort();
|
|
131
|
+
const sortedSchema = { ...schema };
|
|
132
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
133
|
+
sortedSchema.paths = sortedPaths.reduce((agg, path) => {
|
|
134
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
135
|
+
agg[path] = schema.paths[path];
|
|
136
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
137
|
+
return agg;
|
|
138
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
139
|
+
}, {});
|
|
140
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
141
|
+
sortedSchema.components.schemas = sortedSchemas.reduce((agg, key) => {
|
|
142
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
143
|
+
agg[key] = schema.components.schemas[key];
|
|
144
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
145
|
+
return agg;
|
|
146
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
147
|
+
}, {});
|
|
148
|
+
return sortedSchema;
|
|
149
|
+
}
|
|
150
|
+
}
|