@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,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = isBlankDescription;
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
+
function isBlankDescription(obj) {
|
|
6
|
+
if (typeof obj !== 'object')
|
|
7
|
+
return false;
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
9
|
+
if (Object.keys(obj).length > 1)
|
|
10
|
+
return false;
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
12
|
+
return Object.keys(obj)[0] === 'description';
|
|
13
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = openapiRoute;
|
|
4
|
+
function openapiRoute(route) {
|
|
5
|
+
const sanitizedRoute = route.replace(/^\//, '').replace(/:([^/]*)(\/|$)/g, '{$1}$2');
|
|
6
|
+
return `/${sanitizedRoute}`;
|
|
7
|
+
}
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const dream_1 = require("@rvoh/dream");
|
|
4
|
+
const CannotFlattenMultiplePolymorphicRendersOneAssociations_js_1 = require("../error/openapi/CannotFlattenMultiplePolymorphicRendersOneAssociations.js");
|
|
5
|
+
const EnvInternal_js_1 = require("../helpers/EnvInternal.js");
|
|
6
|
+
const index_js_1 = require("../psychic-application/index.js");
|
|
7
|
+
const body_segment_js_1 = require("./body-segment.js");
|
|
8
|
+
class OpenapiSerializerRenderer {
|
|
9
|
+
openapiName;
|
|
10
|
+
controllerClass;
|
|
11
|
+
serializerClass;
|
|
12
|
+
serializers;
|
|
13
|
+
schemaDelimeter;
|
|
14
|
+
processedSchemas;
|
|
15
|
+
target;
|
|
16
|
+
/**
|
|
17
|
+
* @internal
|
|
18
|
+
*
|
|
19
|
+
* Used to recursively parse nested object structures
|
|
20
|
+
* within nested openapi objects
|
|
21
|
+
*/
|
|
22
|
+
constructor({ openapiName, controllerClass, serializerClass, serializers, schemaDelimeter, processedSchemas, target, }) {
|
|
23
|
+
this.openapiName = openapiName;
|
|
24
|
+
this.controllerClass = controllerClass;
|
|
25
|
+
this.serializerClass = serializerClass;
|
|
26
|
+
this.serializers = serializers;
|
|
27
|
+
this.schemaDelimeter = schemaDelimeter;
|
|
28
|
+
this.processedSchemas = processedSchemas;
|
|
29
|
+
this.target = target;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* converts the serializer to an openapi schema
|
|
33
|
+
*/
|
|
34
|
+
parse() {
|
|
35
|
+
if (this.processedSchemas[this.serializerClass.globalName])
|
|
36
|
+
return {};
|
|
37
|
+
this.processedSchemas[this.serializerClass.globalName] = true;
|
|
38
|
+
const attributes = this.serializerClass['attributeStatements'];
|
|
39
|
+
const serializerKey = this.serializerClass.openapiName;
|
|
40
|
+
const serializerObject = {
|
|
41
|
+
type: 'object',
|
|
42
|
+
required: [],
|
|
43
|
+
properties: {},
|
|
44
|
+
};
|
|
45
|
+
let componentsSchema = {};
|
|
46
|
+
attributes.forEach(attr => {
|
|
47
|
+
serializerObject.required.push(attr.field);
|
|
48
|
+
const { results, extraComponents } = this.recursivelyParseBody({ openApiShape: attr.openApiShape });
|
|
49
|
+
componentsSchema = { ...componentsSchema, ...extraComponents };
|
|
50
|
+
serializerObject.properties[attr.field] = results;
|
|
51
|
+
});
|
|
52
|
+
serializerObject.required = (0, dream_1.uniq)(serializerObject.required);
|
|
53
|
+
const serializerPayload = this.attachAssociationsToSerializerPayload({
|
|
54
|
+
serializerPayload: { [serializerKey]: serializerObject, ...componentsSchema },
|
|
55
|
+
serializerKey,
|
|
56
|
+
});
|
|
57
|
+
return { ...serializerPayload, ...componentsSchema };
|
|
58
|
+
}
|
|
59
|
+
recursivelyParseBody({ openApiShape, }) {
|
|
60
|
+
return new body_segment_js_1.default({
|
|
61
|
+
openapiName: this.openapiName,
|
|
62
|
+
controllerClass: this.controllerClass,
|
|
63
|
+
bodySegment: openApiShape,
|
|
64
|
+
serializers: this.serializers,
|
|
65
|
+
schemaDelimeter: this.schemaDelimeter,
|
|
66
|
+
processedSchemas: this.processedSchemas,
|
|
67
|
+
target: this.target,
|
|
68
|
+
}).parse();
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* @internal
|
|
72
|
+
*
|
|
73
|
+
* for each association existing on a given serializer,
|
|
74
|
+
* attach the association's schema to the component schema
|
|
75
|
+
* output, and also generate a $ref between the base
|
|
76
|
+
* serializer and the new one.
|
|
77
|
+
*/
|
|
78
|
+
attachAssociationsToSerializerPayload({ serializerPayload, serializerKey, }) {
|
|
79
|
+
const associations = this.serializerClass['associationStatements'];
|
|
80
|
+
let finalOutput = { ...serializerPayload };
|
|
81
|
+
let flattenedPolymorphicSchemas = [];
|
|
82
|
+
let flattenedPolymorphicAssociation;
|
|
83
|
+
associations.forEach(association => {
|
|
84
|
+
const associatedSerializers = dream_1.DreamSerializer.getAssociatedSerializersForOpenapi(association);
|
|
85
|
+
if (!associatedSerializers)
|
|
86
|
+
throw new Error(`
|
|
87
|
+
Error: ${this.serializerClass.name} missing explicit serializer definition for ${association.type} ${association.field}, using type: 'object'
|
|
88
|
+
`);
|
|
89
|
+
if (associatedSerializers.length === 1) {
|
|
90
|
+
// point the association directly to the schema
|
|
91
|
+
finalOutput = this.addSingleSerializerAssociationToOutput({
|
|
92
|
+
association,
|
|
93
|
+
serializerKey,
|
|
94
|
+
finalOutput,
|
|
95
|
+
associatedSerializers,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
// leverage anyOf to handle an array of serializers
|
|
100
|
+
const data = this.addMultiSerializerAssociationToOutput({
|
|
101
|
+
association,
|
|
102
|
+
serializerKey,
|
|
103
|
+
finalOutput,
|
|
104
|
+
associatedSerializers,
|
|
105
|
+
flattenedPolymorphicSchemas,
|
|
106
|
+
flattenedPolymorphicAssociation,
|
|
107
|
+
});
|
|
108
|
+
finalOutput = data.finalOutput;
|
|
109
|
+
flattenedPolymorphicSchemas = data.flattenedPolymorphicSchemas;
|
|
110
|
+
if (data.flattenedPolymorphicAssociation) {
|
|
111
|
+
flattenedPolymorphicAssociation = data.flattenedPolymorphicAssociation;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
if (flattenedPolymorphicSchemas.length && flattenedPolymorphicAssociation) {
|
|
116
|
+
if (flattenedPolymorphicAssociation.optional) {
|
|
117
|
+
return {
|
|
118
|
+
...finalOutput,
|
|
119
|
+
[serializerKey]: {
|
|
120
|
+
anyOf: [
|
|
121
|
+
{ ...finalOutput[serializerKey] },
|
|
122
|
+
{
|
|
123
|
+
allOf: [
|
|
124
|
+
{ ...finalOutput[serializerKey] },
|
|
125
|
+
{ anyOf: flattenedPolymorphicSchemas.map(schema => ({ $schema: schema })) },
|
|
126
|
+
],
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
return {
|
|
134
|
+
...finalOutput,
|
|
135
|
+
[serializerKey]: {
|
|
136
|
+
allOf: [
|
|
137
|
+
{ ...finalOutput[serializerKey] },
|
|
138
|
+
{ anyOf: flattenedPolymorphicSchemas.map(schema => ({ $schema: schema })) },
|
|
139
|
+
],
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
return finalOutput;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* @internal
|
|
150
|
+
*
|
|
151
|
+
* points an association directly to the $ref associated
|
|
152
|
+
* with the target serializer, and add target serializer
|
|
153
|
+
* to the schema
|
|
154
|
+
*/
|
|
155
|
+
addSingleSerializerAssociationToOutput({ associatedSerializers, finalOutput, serializerKey, association, }) {
|
|
156
|
+
const associatedSerializer = associatedSerializers[0];
|
|
157
|
+
const associatedSerializerKey = associatedSerializer.openapiName;
|
|
158
|
+
if (EnvInternal_js_1.default.isDebug)
|
|
159
|
+
index_js_1.default.log(`Processing serializer ${associatedSerializerKey}`);
|
|
160
|
+
let flattenedData;
|
|
161
|
+
switch (association.type) {
|
|
162
|
+
case 'RendersMany':
|
|
163
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
|
|
164
|
+
;
|
|
165
|
+
finalOutput[serializerKey].properties[association.field] = {
|
|
166
|
+
type: 'array',
|
|
167
|
+
items: {
|
|
168
|
+
$ref: `#/components/schemas/${associatedSerializerKey}`,
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
finalOutput[serializerKey].required = (0, dream_1.uniq)([
|
|
172
|
+
...(finalOutput[serializerKey].required || []),
|
|
173
|
+
association.field,
|
|
174
|
+
]);
|
|
175
|
+
break;
|
|
176
|
+
case 'RendersOne':
|
|
177
|
+
if (association.flatten) {
|
|
178
|
+
flattenedData = this.flattenRendersOneAssociation(associatedSerializer, {
|
|
179
|
+
finalOutput,
|
|
180
|
+
serializerKey,
|
|
181
|
+
});
|
|
182
|
+
finalOutput[serializerKey].properties = flattenedData;
|
|
183
|
+
if (!association.optional) {
|
|
184
|
+
finalOutput[serializerKey].required = (0, dream_1.uniq)([
|
|
185
|
+
...(finalOutput[serializerKey].required || []),
|
|
186
|
+
...Object.keys(flattenedData),
|
|
187
|
+
]);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
|
|
192
|
+
;
|
|
193
|
+
finalOutput[serializerKey].properties[association.field] = this.accountForNullableOption({
|
|
194
|
+
$ref: `#/components/schemas/${associatedSerializerKey}`,
|
|
195
|
+
}, association.optional);
|
|
196
|
+
finalOutput[serializerKey].required = (0, dream_1.uniq)([
|
|
197
|
+
...(finalOutput[serializerKey].required || []),
|
|
198
|
+
association.field,
|
|
199
|
+
]);
|
|
200
|
+
}
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
const associatedSchema = new OpenapiSerializerRenderer({
|
|
204
|
+
openapiName: this.openapiName,
|
|
205
|
+
controllerClass: this.controllerClass,
|
|
206
|
+
serializerClass: associatedSerializer,
|
|
207
|
+
serializers: this.serializers,
|
|
208
|
+
schemaDelimeter: this.schemaDelimeter,
|
|
209
|
+
processedSchemas: this.processedSchemas,
|
|
210
|
+
target: this.target,
|
|
211
|
+
}).parse();
|
|
212
|
+
finalOutput = { ...finalOutput, ...associatedSchema };
|
|
213
|
+
return finalOutput;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* @internal
|
|
217
|
+
*
|
|
218
|
+
* Takes an association and flattens each of it's child
|
|
219
|
+
* attributes into a new object. This is done whenever
|
|
220
|
+
* a serializer's @RendersOne options include `flatten: true`
|
|
221
|
+
*/
|
|
222
|
+
flattenRendersOneAssociation(associatedSerializer, { finalOutput, serializerKey, }) {
|
|
223
|
+
const serialized = new OpenapiSerializerRenderer({
|
|
224
|
+
openapiName: this.openapiName,
|
|
225
|
+
controllerClass: this.controllerClass,
|
|
226
|
+
serializerClass: associatedSerializer,
|
|
227
|
+
serializers: this.serializers,
|
|
228
|
+
schemaDelimeter: this.schemaDelimeter,
|
|
229
|
+
processedSchemas: {},
|
|
230
|
+
target: this.target,
|
|
231
|
+
}).parse();
|
|
232
|
+
const associatedProperties = serialized[associatedSerializer.openapiName]
|
|
233
|
+
.properties;
|
|
234
|
+
return {
|
|
235
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
|
|
236
|
+
...finalOutput[serializerKey].properties,
|
|
237
|
+
...associatedProperties,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* @internal
|
|
242
|
+
*
|
|
243
|
+
* leverages anyOf to cast multiple possible $ref values,
|
|
244
|
+
* each pointing to its respective target serializer.
|
|
245
|
+
*/
|
|
246
|
+
addMultiSerializerAssociationToOutput({ associatedSerializers, finalOutput, serializerKey, association, flattenedPolymorphicSchemas, flattenedPolymorphicAssociation, }) {
|
|
247
|
+
if (association.flatten) {
|
|
248
|
+
if (flattenedPolymorphicSchemas.length)
|
|
249
|
+
throw new CannotFlattenMultiplePolymorphicRendersOneAssociations_js_1.default(this.serializerClass, association.field);
|
|
250
|
+
associatedSerializers.forEach(associatedSerializer => {
|
|
251
|
+
const associatedSchema = new OpenapiSerializerRenderer({
|
|
252
|
+
openapiName: this.openapiName,
|
|
253
|
+
controllerClass: this.controllerClass,
|
|
254
|
+
serializerClass: associatedSerializer,
|
|
255
|
+
serializers: this.serializers,
|
|
256
|
+
schemaDelimeter: this.schemaDelimeter,
|
|
257
|
+
processedSchemas: this.processedSchemas,
|
|
258
|
+
target: this.target,
|
|
259
|
+
}).parse();
|
|
260
|
+
finalOutput = { ...finalOutput, ...associatedSchema };
|
|
261
|
+
});
|
|
262
|
+
return {
|
|
263
|
+
finalOutput,
|
|
264
|
+
flattenedPolymorphicSchemas: associatedSerializers.map(ser => ser.openapiName),
|
|
265
|
+
flattenedPolymorphicAssociation: association,
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
const anyOf = [];
|
|
270
|
+
associatedSerializers.forEach(associatedSerializer => {
|
|
271
|
+
const associatedSerializerKey = associatedSerializer.openapiName;
|
|
272
|
+
if (EnvInternal_js_1.default.isDebug)
|
|
273
|
+
index_js_1.default.log(`Processing serializer ${associatedSerializerKey}`);
|
|
274
|
+
finalOutput[serializerKey].required = (0, dream_1.uniq)([
|
|
275
|
+
...(finalOutput[serializerKey].required || []),
|
|
276
|
+
association.field,
|
|
277
|
+
]);
|
|
278
|
+
switch (association.type) {
|
|
279
|
+
case 'RendersMany':
|
|
280
|
+
anyOf.push({
|
|
281
|
+
type: 'array',
|
|
282
|
+
items: {
|
|
283
|
+
$ref: `#/components/schemas/${associatedSerializerKey}`,
|
|
284
|
+
},
|
|
285
|
+
});
|
|
286
|
+
break;
|
|
287
|
+
case 'RendersOne':
|
|
288
|
+
anyOf.push({
|
|
289
|
+
$ref: `#/components/schemas/${associatedSerializerKey}`,
|
|
290
|
+
});
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
const associatedSchema = new OpenapiSerializerRenderer({
|
|
294
|
+
openapiName: this.openapiName,
|
|
295
|
+
controllerClass: this.controllerClass,
|
|
296
|
+
serializerClass: associatedSerializer,
|
|
297
|
+
serializers: this.serializers,
|
|
298
|
+
schemaDelimeter: this.schemaDelimeter,
|
|
299
|
+
processedSchemas: this.processedSchemas,
|
|
300
|
+
target: this.target,
|
|
301
|
+
}).parse();
|
|
302
|
+
finalOutput = { ...finalOutput, ...associatedSchema };
|
|
303
|
+
});
|
|
304
|
+
finalOutput[serializerKey].properties[association.field] = {
|
|
305
|
+
anyOf,
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
return { finalOutput, flattenedPolymorphicSchemas, flattenedPolymorphicAssociation };
|
|
309
|
+
}
|
|
310
|
+
accountForNullableOption(bodySegment, nullable) {
|
|
311
|
+
if (nullable) {
|
|
312
|
+
return {
|
|
313
|
+
anyOf: [bodySegment, { type: 'null' }],
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
return bodySegment;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
exports.default = OpenapiSerializerRenderer;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cachePsychicApplication = cachePsychicApplication;
|
|
4
|
+
exports.getCachedPsychicApplication = getCachedPsychicApplication;
|
|
5
|
+
exports.getCachedPsychicApplicationOrFail = getCachedPsychicApplicationOrFail;
|
|
6
|
+
let _psychicApp = undefined;
|
|
7
|
+
function cachePsychicApplication(psychicApp) {
|
|
8
|
+
_psychicApp = psychicApp;
|
|
9
|
+
}
|
|
10
|
+
function getCachedPsychicApplication() {
|
|
11
|
+
return _psychicApp;
|
|
12
|
+
}
|
|
13
|
+
function getCachedPsychicApplicationOrFail() {
|
|
14
|
+
if (!_psychicApp)
|
|
15
|
+
throw new Error('must call `cachePsychicApplication` before loading cached psychic app');
|
|
16
|
+
return _psychicApp;
|
|
17
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const dream_1 = require("@rvoh/dream");
|
|
4
|
+
class PsychicImporter {
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
+
static async importControllers(controllersPath, importCb) {
|
|
7
|
+
const controllerPaths = await dream_1.DreamImporter.ls(controllersPath);
|
|
8
|
+
const controllerClasses = [];
|
|
9
|
+
for (const controllerPath of controllerPaths) {
|
|
10
|
+
controllerClasses.push([controllerPath, (await importCb(controllerPath))]);
|
|
11
|
+
}
|
|
12
|
+
return controllerClasses;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.default = PsychicImporter;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
function default_1(filepath, dirPath) {
|
|
5
|
+
const prefixPath = dirPath;
|
|
6
|
+
return ('controllers/' +
|
|
7
|
+
filepath
|
|
8
|
+
.replace(prefixPath, '')
|
|
9
|
+
.replace(/\.[jt]s$/, '')
|
|
10
|
+
.replace(/^\//, ''));
|
|
11
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = importControllers;
|
|
4
|
+
exports.getControllersOrFail = getControllersOrFail;
|
|
5
|
+
exports.getControllersOrBlank = getControllersOrBlank;
|
|
6
|
+
const index_js_1 = require("../../../controller/index.js");
|
|
7
|
+
const globalControllerKeyFromPath_js_1 = require("../globalControllerKeyFromPath.js");
|
|
8
|
+
const PsychicImporter_js_1 = require("../PsychicImporter.js");
|
|
9
|
+
let _controllers;
|
|
10
|
+
async function importControllers(psychicApp, controllersPath,
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
importCb) {
|
|
13
|
+
if (_controllers)
|
|
14
|
+
return _controllers;
|
|
15
|
+
/**
|
|
16
|
+
* Certain features (e.g. passing a Dream instance to `create` so that it automatically destructures polymorphic type and primary key)
|
|
17
|
+
* need static access to things set up by decorators (e.g. associations). Stage 3 Decorators change the context that is available
|
|
18
|
+
* at decoration time such that the class of a property being decorated is only avilable during instance instantiation. In order
|
|
19
|
+
* to only apply static values once, on boot, `globallyInitializingDecorators` is set to true on Dream, and all Dream models are instantiated.
|
|
20
|
+
*/
|
|
21
|
+
index_js_1.default['globallyInitializingDecorators'] = true;
|
|
22
|
+
_controllers = {};
|
|
23
|
+
const controllerClasses = await PsychicImporter_js_1.default.importControllers(controllersPath, importCb);
|
|
24
|
+
for (const [controllerPath, potentialControllerClass] of controllerClasses) {
|
|
25
|
+
if (potentialControllerClass?.isPsychicController) {
|
|
26
|
+
const controllerClass = potentialControllerClass;
|
|
27
|
+
const controllerKey = (0, globalControllerKeyFromPath_js_1.default)(controllerPath, controllersPath);
|
|
28
|
+
controllerClass['setGlobalName'](controllerKey);
|
|
29
|
+
_controllers[controllerKey] = controllerClass;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
for (const [, controllerClass] of controllerClasses) {
|
|
33
|
+
if (controllerClass?.isPsychicController) {
|
|
34
|
+
/**
|
|
35
|
+
* Certain features (e.g. passing a Dream instance to `create` so that it automatically destructures polymorphic type and primary key)
|
|
36
|
+
* need static access to things set up by decorators (e.g. associations). Stage 3 Decorators change the context that is available
|
|
37
|
+
* at decoration time such that the class of a property being decorated is only avilable during instance instantiation. In order
|
|
38
|
+
* to only apply static values once, on boot, `globallyInitializingDecorators` is set to true on Dream, and all Dream models are instantiated.
|
|
39
|
+
*/
|
|
40
|
+
new controllerClass({}, {}, {
|
|
41
|
+
action: 'a',
|
|
42
|
+
config: psychicApp,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
index_js_1.default['globallyInitializingDecorators'] = false;
|
|
47
|
+
return _controllers;
|
|
48
|
+
}
|
|
49
|
+
function getControllersOrFail() {
|
|
50
|
+
if (!_controllers)
|
|
51
|
+
throw new Error('Must call loadModels before calling getModelsOrFail');
|
|
52
|
+
return _controllers;
|
|
53
|
+
}
|
|
54
|
+
function getControllersOrBlank() {
|
|
55
|
+
return _controllers || {};
|
|
56
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const dotenv = require("dotenv");
|
|
4
|
+
const EnvInternal_js_1 = require("../../helpers/EnvInternal.js");
|
|
5
|
+
dotenv.config({ path: EnvInternal_js_1.default.isTest ? '../../.env.test' : '../../.env' });
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = lookupClassByGlobalName;
|
|
4
|
+
const dream_1 = require("@rvoh/dream");
|
|
5
|
+
const importControllers_js_1 = require("./import/importControllers.js");
|
|
6
|
+
function lookupClassByGlobalName(name) {
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
8
|
+
const lookup = (0, dream_1.lookupClassByGlobalName)(name);
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
10
|
+
if (lookup)
|
|
11
|
+
return lookup;
|
|
12
|
+
const combinedObj = {
|
|
13
|
+
...(0, importControllers_js_1.getControllersOrFail)(),
|
|
14
|
+
};
|
|
15
|
+
return combinedObj[name] || null;
|
|
16
|
+
}
|