@contember/engine-http 2.1.0-alpha.8 → 2.1.0-beta.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/CLAUDE.md +45 -0
- package/dist/development/index.cjs +0 -4
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +0 -4
- package/dist/development/index.js.map +1 -1
- package/dist/development/src/MasterContainer.cjs +111 -42
- package/dist/development/src/MasterContainer.cjs.map +1 -1
- package/dist/development/src/MasterContainer.js +111 -42
- package/dist/development/src/MasterContainer.js.map +1 -1
- package/dist/development/src/application/application.cjs +17 -9
- package/dist/development/src/application/application.cjs.map +1 -1
- package/dist/development/src/application/application.js +17 -9
- package/dist/development/src/application/application.js.map +1 -1
- package/dist/development/src/bootstrap/Initializer.cjs.map +1 -1
- package/dist/development/src/bootstrap/Initializer.js.map +1 -1
- package/dist/development/src/common/Authorizator.cjs.map +1 -1
- package/dist/development/src/common/Authorizator.js.map +1 -1
- package/dist/development/src/common/HttpResponse.cjs.map +1 -1
- package/dist/development/src/common/HttpResponse.js.map +1 -1
- package/dist/development/src/common/ModuleInfoMiddleware.cjs.map +1 -1
- package/dist/development/src/common/ModuleInfoMiddleware.js.map +1 -1
- package/dist/development/src/config/config.cjs.map +1 -1
- package/dist/development/src/config/config.js.map +1 -1
- package/dist/development/src/config/configSchema.cjs +31 -24
- package/dist/development/src/config/configSchema.cjs.map +1 -1
- package/dist/development/src/config/configSchema.js +31 -24
- package/dist/development/src/config/configSchema.js.map +1 -1
- package/dist/development/src/config/configTemplate.cjs +5 -1
- package/dist/development/src/config/configTemplate.cjs.map +1 -1
- package/dist/development/src/config/configTemplate.js +5 -1
- package/dist/development/src/config/configTemplate.js.map +1 -1
- package/dist/development/src/config/projectConfigResolver.cjs.map +1 -1
- package/dist/development/src/config/projectConfigResolver.js.map +1 -1
- package/dist/development/src/config/tenantConfigResolver.cjs +4 -3
- package/dist/development/src/config/tenantConfigResolver.cjs.map +1 -1
- package/dist/development/src/config/tenantConfigResolver.js +4 -3
- package/dist/development/src/config/tenantConfigResolver.js.map +1 -1
- package/dist/development/src/content/ContentApiControllerFactory.cjs +29 -12
- package/dist/development/src/content/ContentApiControllerFactory.cjs.map +1 -1
- package/dist/development/src/content/ContentApiControllerFactory.js +29 -12
- package/dist/development/src/content/ContentApiControllerFactory.js.map +1 -1
- package/dist/development/src/content/ContentApiSpecificCache.cjs +1 -1
- package/dist/development/src/content/ContentApiSpecificCache.cjs.map +1 -1
- package/dist/development/src/content/ContentApiSpecificCache.js +1 -1
- package/dist/development/src/content/ContentApiSpecificCache.js.map +1 -1
- package/dist/development/src/content/ContentQueryHandlerFactory.cjs.map +1 -1
- package/dist/development/src/content/ContentQueryHandlerFactory.js.map +1 -1
- package/dist/development/src/content/ContentSchemaResolver.cjs.map +1 -1
- package/dist/development/src/content/ContentSchemaResolver.js.map +1 -1
- package/dist/development/src/content/GraphQlSchemaFactory.cjs.map +1 -1
- package/dist/development/src/content/GraphQlSchemaFactory.js.map +1 -1
- package/dist/development/src/content/NotModifiedChecker.cjs.map +1 -1
- package/dist/development/src/content/NotModifiedChecker.js.map +1 -1
- package/dist/development/src/content/ProjectMembershipFetcher.cjs.map +1 -1
- package/dist/development/src/content/ProjectMembershipFetcher.js.map +1 -1
- package/dist/development/src/content/ProjectMembershipResolver.cjs +2 -2
- package/dist/development/src/content/ProjectMembershipResolver.cjs.map +1 -1
- package/dist/development/src/content/ProjectMembershipResolver.js +2 -2
- package/dist/development/src/content/ProjectMembershipResolver.js.map +1 -1
- package/dist/development/src/graphql/dbQueriesListener.cjs +1 -1
- package/dist/development/src/graphql/dbQueriesListener.cjs.map +1 -1
- package/dist/development/src/graphql/dbQueriesListener.js +1 -1
- package/dist/development/src/graphql/dbQueriesListener.js.map +1 -1
- package/dist/development/src/graphql/execution.cjs.map +1 -1
- package/dist/development/src/graphql/execution.js.map +1 -1
- package/dist/development/src/misc/HomepageMiddlewareFactory.cjs.map +1 -1
- package/dist/development/src/misc/HomepageMiddlewareFactory.js.map +1 -1
- package/dist/development/src/project/ProjectContainer.cjs +16 -1
- package/dist/development/src/project/ProjectContainer.cjs.map +1 -1
- package/dist/development/src/project/ProjectContainer.js +16 -1
- package/dist/development/src/project/ProjectContainer.js.map +1 -1
- package/dist/development/src/project/ProjectContainerResolver.cjs.map +1 -1
- package/dist/development/src/project/ProjectContainerResolver.js.map +1 -1
- package/dist/development/src/project/ProjectContainerStore.cjs.map +1 -1
- package/dist/development/src/project/ProjectContainerStore.js.map +1 -1
- package/dist/development/src/project/ProjectDatabaseMetadataResolver.cjs.map +1 -1
- package/dist/development/src/project/ProjectDatabaseMetadataResolver.js.map +1 -1
- package/dist/development/src/project/ProjectInitializer.cjs.map +1 -1
- package/dist/development/src/project/ProjectInitializer.js.map +1 -1
- package/dist/development/src/project/ProjectSchemaResolver.cjs.map +1 -1
- package/dist/development/src/project/ProjectSchemaResolver.js.map +1 -1
- package/dist/development/src/project-common/ProjectContextResolver.cjs.map +1 -1
- package/dist/development/src/project-common/ProjectContextResolver.js.map +1 -1
- package/dist/development/src/projectGroup/ProjectGroupContainer.cjs +12 -3
- package/dist/development/src/projectGroup/ProjectGroupContainer.cjs.map +1 -1
- package/dist/development/src/projectGroup/ProjectGroupContainer.js +12 -3
- package/dist/development/src/projectGroup/ProjectGroupContainer.js.map +1 -1
- package/dist/development/src/projectGroup/ProjectGroupContainerResolver.cjs.map +1 -1
- package/dist/development/src/projectGroup/ProjectGroupContainerResolver.js.map +1 -1
- package/dist/development/src/projectGroup/ProjectGroupResolver.cjs +2 -2
- package/dist/development/src/projectGroup/ProjectGroupResolver.cjs.map +1 -1
- package/dist/development/src/projectGroup/ProjectGroupResolver.js +2 -2
- package/dist/development/src/projectGroup/ProjectGroupResolver.js.map +1 -1
- package/dist/development/src/prometheus/CollectHttpMetricsMiddelware.cjs.map +1 -1
- package/dist/development/src/prometheus/CollectHttpMetricsMiddelware.js.map +1 -1
- package/dist/development/src/prometheus/CustomMetric.cjs.map +1 -1
- package/dist/development/src/prometheus/CustomMetric.js.map +1 -1
- package/dist/development/src/prometheus/ProjectGroupContainerMetricsHook.cjs.map +1 -1
- package/dist/development/src/prometheus/ProjectGroupContainerMetricsHook.js.map +1 -1
- package/dist/development/src/prometheus/PrometheusRegistryFactory.cjs.map +1 -1
- package/dist/development/src/prometheus/PrometheusRegistryFactory.js.map +1 -1
- package/dist/development/src/prometheus/ShowMetricsMiddleware.cjs.map +1 -1
- package/dist/development/src/prometheus/ShowMetricsMiddleware.js.map +1 -1
- package/dist/development/src/prometheus/contemberEngineInfoMetric.cjs.map +1 -1
- package/dist/development/src/prometheus/contemberEngineInfoMetric.js.map +1 -1
- package/dist/development/src/prometheus/dbMetrics.cjs.map +1 -1
- package/dist/development/src/prometheus/dbMetrics.js.map +1 -1
- package/dist/development/src/providers.cjs.map +1 -1
- package/dist/development/src/providers.js.map +1 -1
- package/dist/development/src/system/ContentQueryExecutor.cjs +6 -2
- package/dist/development/src/system/ContentQueryExecutor.cjs.map +1 -1
- package/dist/development/src/system/ContentQueryExecutor.js +6 -2
- package/dist/development/src/system/ContentQueryExecutor.js.map +1 -1
- package/dist/development/src/system/SystemApiMiddlewareFactory.cjs +8 -11
- package/dist/development/src/system/SystemApiMiddlewareFactory.cjs.map +1 -1
- package/dist/development/src/system/SystemApiMiddlewareFactory.js +8 -11
- package/dist/development/src/system/SystemApiMiddlewareFactory.js.map +1 -1
- package/dist/development/src/system/SystemGraphQLContextFactory.cjs.map +1 -1
- package/dist/development/src/system/SystemGraphQLContextFactory.js.map +1 -1
- package/dist/development/src/system/SystemGraphQLHandlerFactory.cjs.map +1 -1
- package/dist/development/src/system/SystemGraphQLHandlerFactory.js.map +1 -1
- package/dist/development/src/tenant/TenantApiMiddlewareFactory.cjs +13 -7
- package/dist/development/src/tenant/TenantApiMiddlewareFactory.cjs.map +1 -1
- package/dist/development/src/tenant/TenantApiMiddlewareFactory.js +13 -7
- package/dist/development/src/tenant/TenantApiMiddlewareFactory.js.map +1 -1
- package/dist/development/src/tenant/TenantGraphQLHandlerFactory.cjs +0 -2
- package/dist/development/src/tenant/TenantGraphQLHandlerFactory.cjs.map +1 -1
- package/dist/development/src/tenant/TenantGraphQLHandlerFactory.js +0 -2
- package/dist/development/src/tenant/TenantGraphQLHandlerFactory.js.map +1 -1
- package/dist/development/src/transfer/Command.cjs.map +1 -1
- package/dist/development/src/transfer/Command.js.map +1 -1
- package/dist/development/src/transfer/CommandStream.cjs.map +1 -1
- package/dist/development/src/transfer/CommandStream.js.map +1 -1
- package/dist/development/src/transfer/ContentSchemaTransferMappingFactory.cjs.map +1 -1
- package/dist/development/src/transfer/ContentSchemaTransferMappingFactory.js.map +1 -1
- package/dist/development/src/transfer/ExportApiControllerFactory.cjs +2 -1
- package/dist/development/src/transfer/ExportApiControllerFactory.cjs.map +1 -1
- package/dist/development/src/transfer/ExportApiControllerFactory.js +2 -1
- package/dist/development/src/transfer/ExportApiControllerFactory.js.map +1 -1
- package/dist/development/src/transfer/ExportExecutor.cjs.map +1 -1
- package/dist/development/src/transfer/ExportExecutor.js.map +1 -1
- package/dist/development/src/transfer/ImportApiMiddlewareFactory.cjs.map +1 -1
- package/dist/development/src/transfer/ImportApiMiddlewareFactory.js.map +1 -1
- package/dist/development/src/transfer/ImportExecutor.cjs +3 -1
- package/dist/development/src/transfer/ImportExecutor.cjs.map +1 -1
- package/dist/development/src/transfer/ImportExecutor.js +3 -1
- package/dist/development/src/transfer/ImportExecutor.js.map +1 -1
- package/dist/development/src/transfer/SystemSchemaTransferMappingFactory.cjs.map +1 -1
- package/dist/development/src/transfer/SystemSchemaTransferMappingFactory.js +1 -1
- package/dist/development/src/transfer/SystemSchemaTransferMappingFactory.js.map +1 -1
- package/dist/development/src/utils/CryptoWrapper.cjs.map +1 -1
- package/dist/development/src/utils/CryptoWrapper.js.map +1 -1
- package/dist/development/src/utils/memoizeObject.cjs.map +1 -1
- package/dist/development/src/utils/memoizeObject.js.map +1 -1
- package/dist/development/src/utils/remoteAddress.cjs +56 -0
- package/dist/development/src/utils/remoteAddress.cjs.map +1 -0
- package/dist/development/src/utils/remoteAddress.js +56 -0
- package/dist/development/src/utils/remoteAddress.js.map +1 -0
- package/dist/development/src/utils/sentry.cjs.map +1 -1
- package/dist/development/src/utils/sentry.js.map +1 -1
- package/dist/development/src/utils/serverStartup.cjs.map +1 -1
- package/dist/development/src/utils/serverStartup.js.map +1 -1
- package/dist/development/src/utils/serverTermination.cjs.map +1 -1
- package/dist/development/src/utils/serverTermination.js.map +1 -1
- package/dist/development/src/utils/strings.cjs.map +1 -1
- package/dist/development/src/utils/strings.js.map +1 -1
- package/dist/development/src/workers/ApplicationWorkerManager.cjs.map +1 -1
- package/dist/development/src/workers/ApplicationWorkerManager.js.map +1 -1
- package/dist/production/index.cjs +0 -4
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.js +0 -4
- package/dist/production/index.js.map +1 -1
- package/dist/production/src/MasterContainer.cjs +111 -42
- package/dist/production/src/MasterContainer.cjs.map +1 -1
- package/dist/production/src/MasterContainer.js +111 -42
- package/dist/production/src/MasterContainer.js.map +1 -1
- package/dist/production/src/application/application.cjs +17 -9
- package/dist/production/src/application/application.cjs.map +1 -1
- package/dist/production/src/application/application.js +17 -9
- package/dist/production/src/application/application.js.map +1 -1
- package/dist/production/src/bootstrap/Initializer.cjs.map +1 -1
- package/dist/production/src/bootstrap/Initializer.js.map +1 -1
- package/dist/production/src/common/Authorizator.cjs.map +1 -1
- package/dist/production/src/common/Authorizator.js.map +1 -1
- package/dist/production/src/common/HttpResponse.cjs.map +1 -1
- package/dist/production/src/common/HttpResponse.js.map +1 -1
- package/dist/production/src/common/ModuleInfoMiddleware.cjs.map +1 -1
- package/dist/production/src/common/ModuleInfoMiddleware.js.map +1 -1
- package/dist/production/src/config/config.cjs.map +1 -1
- package/dist/production/src/config/config.js.map +1 -1
- package/dist/production/src/config/configSchema.cjs +31 -24
- package/dist/production/src/config/configSchema.cjs.map +1 -1
- package/dist/production/src/config/configSchema.js +31 -24
- package/dist/production/src/config/configSchema.js.map +1 -1
- package/dist/production/src/config/configTemplate.cjs +5 -1
- package/dist/production/src/config/configTemplate.cjs.map +1 -1
- package/dist/production/src/config/configTemplate.js +5 -1
- package/dist/production/src/config/configTemplate.js.map +1 -1
- package/dist/production/src/config/projectConfigResolver.cjs.map +1 -1
- package/dist/production/src/config/projectConfigResolver.js.map +1 -1
- package/dist/production/src/config/tenantConfigResolver.cjs +4 -3
- package/dist/production/src/config/tenantConfigResolver.cjs.map +1 -1
- package/dist/production/src/config/tenantConfigResolver.js +4 -3
- package/dist/production/src/config/tenantConfigResolver.js.map +1 -1
- package/dist/production/src/content/ContentApiControllerFactory.cjs +29 -12
- package/dist/production/src/content/ContentApiControllerFactory.cjs.map +1 -1
- package/dist/production/src/content/ContentApiControllerFactory.js +29 -12
- package/dist/production/src/content/ContentApiControllerFactory.js.map +1 -1
- package/dist/production/src/content/ContentApiSpecificCache.cjs +1 -1
- package/dist/production/src/content/ContentApiSpecificCache.cjs.map +1 -1
- package/dist/production/src/content/ContentApiSpecificCache.js +1 -1
- package/dist/production/src/content/ContentApiSpecificCache.js.map +1 -1
- package/dist/production/src/content/ContentQueryHandlerFactory.cjs.map +1 -1
- package/dist/production/src/content/ContentQueryHandlerFactory.js.map +1 -1
- package/dist/production/src/content/ContentSchemaResolver.cjs.map +1 -1
- package/dist/production/src/content/ContentSchemaResolver.js.map +1 -1
- package/dist/production/src/content/GraphQlSchemaFactory.cjs.map +1 -1
- package/dist/production/src/content/GraphQlSchemaFactory.js.map +1 -1
- package/dist/production/src/content/NotModifiedChecker.cjs.map +1 -1
- package/dist/production/src/content/NotModifiedChecker.js.map +1 -1
- package/dist/production/src/content/ProjectMembershipFetcher.cjs.map +1 -1
- package/dist/production/src/content/ProjectMembershipFetcher.js.map +1 -1
- package/dist/production/src/content/ProjectMembershipResolver.cjs +2 -2
- package/dist/production/src/content/ProjectMembershipResolver.cjs.map +1 -1
- package/dist/production/src/content/ProjectMembershipResolver.js +2 -2
- package/dist/production/src/content/ProjectMembershipResolver.js.map +1 -1
- package/dist/production/src/graphql/dbQueriesListener.cjs +1 -1
- package/dist/production/src/graphql/dbQueriesListener.cjs.map +1 -1
- package/dist/production/src/graphql/dbQueriesListener.js +1 -1
- package/dist/production/src/graphql/dbQueriesListener.js.map +1 -1
- package/dist/production/src/graphql/execution.cjs.map +1 -1
- package/dist/production/src/graphql/execution.js.map +1 -1
- package/dist/production/src/misc/HomepageMiddlewareFactory.cjs.map +1 -1
- package/dist/production/src/misc/HomepageMiddlewareFactory.js.map +1 -1
- package/dist/production/src/project/ProjectContainer.cjs +16 -1
- package/dist/production/src/project/ProjectContainer.cjs.map +1 -1
- package/dist/production/src/project/ProjectContainer.js +16 -1
- package/dist/production/src/project/ProjectContainer.js.map +1 -1
- package/dist/production/src/project/ProjectContainerResolver.cjs.map +1 -1
- package/dist/production/src/project/ProjectContainerResolver.js.map +1 -1
- package/dist/production/src/project/ProjectContainerStore.cjs.map +1 -1
- package/dist/production/src/project/ProjectContainerStore.js.map +1 -1
- package/dist/production/src/project/ProjectDatabaseMetadataResolver.cjs.map +1 -1
- package/dist/production/src/project/ProjectDatabaseMetadataResolver.js.map +1 -1
- package/dist/production/src/project/ProjectInitializer.cjs.map +1 -1
- package/dist/production/src/project/ProjectInitializer.js.map +1 -1
- package/dist/production/src/project/ProjectSchemaResolver.cjs.map +1 -1
- package/dist/production/src/project/ProjectSchemaResolver.js.map +1 -1
- package/dist/production/src/project-common/ProjectContextResolver.cjs.map +1 -1
- package/dist/production/src/project-common/ProjectContextResolver.js.map +1 -1
- package/dist/production/src/projectGroup/ProjectGroupContainer.cjs +12 -3
- package/dist/production/src/projectGroup/ProjectGroupContainer.cjs.map +1 -1
- package/dist/production/src/projectGroup/ProjectGroupContainer.js +12 -3
- package/dist/production/src/projectGroup/ProjectGroupContainer.js.map +1 -1
- package/dist/production/src/projectGroup/ProjectGroupContainerResolver.cjs.map +1 -1
- package/dist/production/src/projectGroup/ProjectGroupContainerResolver.js.map +1 -1
- package/dist/production/src/projectGroup/ProjectGroupResolver.cjs +2 -2
- package/dist/production/src/projectGroup/ProjectGroupResolver.cjs.map +1 -1
- package/dist/production/src/projectGroup/ProjectGroupResolver.js +2 -2
- package/dist/production/src/projectGroup/ProjectGroupResolver.js.map +1 -1
- package/dist/production/src/prometheus/CollectHttpMetricsMiddelware.cjs.map +1 -1
- package/dist/production/src/prometheus/CollectHttpMetricsMiddelware.js.map +1 -1
- package/dist/production/src/prometheus/CustomMetric.cjs.map +1 -1
- package/dist/production/src/prometheus/CustomMetric.js.map +1 -1
- package/dist/production/src/prometheus/ProjectGroupContainerMetricsHook.cjs.map +1 -1
- package/dist/production/src/prometheus/ProjectGroupContainerMetricsHook.js.map +1 -1
- package/dist/production/src/prometheus/PrometheusRegistryFactory.cjs.map +1 -1
- package/dist/production/src/prometheus/PrometheusRegistryFactory.js.map +1 -1
- package/dist/production/src/prometheus/ShowMetricsMiddleware.cjs.map +1 -1
- package/dist/production/src/prometheus/ShowMetricsMiddleware.js.map +1 -1
- package/dist/production/src/prometheus/contemberEngineInfoMetric.cjs.map +1 -1
- package/dist/production/src/prometheus/contemberEngineInfoMetric.js.map +1 -1
- package/dist/production/src/prometheus/dbMetrics.cjs.map +1 -1
- package/dist/production/src/prometheus/dbMetrics.js.map +1 -1
- package/dist/production/src/providers.cjs.map +1 -1
- package/dist/production/src/providers.js.map +1 -1
- package/dist/production/src/system/ContentQueryExecutor.cjs +6 -2
- package/dist/production/src/system/ContentQueryExecutor.cjs.map +1 -1
- package/dist/production/src/system/ContentQueryExecutor.js +6 -2
- package/dist/production/src/system/ContentQueryExecutor.js.map +1 -1
- package/dist/production/src/system/SystemApiMiddlewareFactory.cjs +8 -11
- package/dist/production/src/system/SystemApiMiddlewareFactory.cjs.map +1 -1
- package/dist/production/src/system/SystemApiMiddlewareFactory.js +8 -11
- package/dist/production/src/system/SystemApiMiddlewareFactory.js.map +1 -1
- package/dist/production/src/system/SystemGraphQLContextFactory.cjs.map +1 -1
- package/dist/production/src/system/SystemGraphQLContextFactory.js.map +1 -1
- package/dist/production/src/system/SystemGraphQLHandlerFactory.cjs.map +1 -1
- package/dist/production/src/system/SystemGraphQLHandlerFactory.js.map +1 -1
- package/dist/production/src/tenant/TenantApiMiddlewareFactory.cjs +13 -7
- package/dist/production/src/tenant/TenantApiMiddlewareFactory.cjs.map +1 -1
- package/dist/production/src/tenant/TenantApiMiddlewareFactory.js +13 -7
- package/dist/production/src/tenant/TenantApiMiddlewareFactory.js.map +1 -1
- package/dist/production/src/tenant/TenantGraphQLHandlerFactory.cjs +0 -2
- package/dist/production/src/tenant/TenantGraphQLHandlerFactory.cjs.map +1 -1
- package/dist/production/src/tenant/TenantGraphQLHandlerFactory.js +0 -2
- package/dist/production/src/tenant/TenantGraphQLHandlerFactory.js.map +1 -1
- package/dist/production/src/transfer/Command.cjs.map +1 -1
- package/dist/production/src/transfer/Command.js.map +1 -1
- package/dist/production/src/transfer/CommandStream.cjs.map +1 -1
- package/dist/production/src/transfer/CommandStream.js.map +1 -1
- package/dist/production/src/transfer/ContentSchemaTransferMappingFactory.cjs.map +1 -1
- package/dist/production/src/transfer/ContentSchemaTransferMappingFactory.js.map +1 -1
- package/dist/production/src/transfer/ExportApiControllerFactory.cjs +2 -1
- package/dist/production/src/transfer/ExportApiControllerFactory.cjs.map +1 -1
- package/dist/production/src/transfer/ExportApiControllerFactory.js +2 -1
- package/dist/production/src/transfer/ExportApiControllerFactory.js.map +1 -1
- package/dist/production/src/transfer/ExportExecutor.cjs.map +1 -1
- package/dist/production/src/transfer/ExportExecutor.js.map +1 -1
- package/dist/production/src/transfer/ImportApiMiddlewareFactory.cjs.map +1 -1
- package/dist/production/src/transfer/ImportApiMiddlewareFactory.js.map +1 -1
- package/dist/production/src/transfer/ImportExecutor.cjs +3 -1
- package/dist/production/src/transfer/ImportExecutor.cjs.map +1 -1
- package/dist/production/src/transfer/ImportExecutor.js +3 -1
- package/dist/production/src/transfer/ImportExecutor.js.map +1 -1
- package/dist/production/src/transfer/SystemSchemaTransferMappingFactory.cjs.map +1 -1
- package/dist/production/src/transfer/SystemSchemaTransferMappingFactory.js +1 -1
- package/dist/production/src/transfer/SystemSchemaTransferMappingFactory.js.map +1 -1
- package/dist/production/src/utils/CryptoWrapper.cjs.map +1 -1
- package/dist/production/src/utils/CryptoWrapper.js.map +1 -1
- package/dist/production/src/utils/memoizeObject.cjs.map +1 -1
- package/dist/production/src/utils/memoizeObject.js.map +1 -1
- package/dist/production/src/utils/remoteAddress.cjs +56 -0
- package/dist/production/src/utils/remoteAddress.cjs.map +1 -0
- package/dist/production/src/utils/remoteAddress.js +56 -0
- package/dist/production/src/utils/remoteAddress.js.map +1 -0
- package/dist/production/src/utils/sentry.cjs.map +1 -1
- package/dist/production/src/utils/sentry.js.map +1 -1
- package/dist/production/src/utils/serverStartup.cjs.map +1 -1
- package/dist/production/src/utils/serverStartup.js.map +1 -1
- package/dist/production/src/utils/serverTermination.cjs.map +1 -1
- package/dist/production/src/utils/serverTermination.js.map +1 -1
- package/dist/production/src/utils/strings.cjs.map +1 -1
- package/dist/production/src/utils/strings.js.map +1 -1
- package/dist/production/src/workers/ApplicationWorkerManager.cjs.map +1 -1
- package/dist/production/src/workers/ApplicationWorkerManager.js.map +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/dist/types/MasterContainer.d.ts +23 -23
- package/dist/types/MasterContainer.d.ts.map +1 -1
- package/dist/types/application/application.d.ts +1 -0
- package/dist/types/application/application.d.ts.map +1 -1
- package/dist/types/application/types.d.ts +0 -1
- package/dist/types/application/types.d.ts.map +1 -1
- package/dist/types/config/configSchema.d.ts +18 -0
- package/dist/types/config/configSchema.d.ts.map +1 -1
- package/dist/types/config/configTemplate.d.ts.map +1 -1
- package/dist/types/config/projectConfigResolver.d.ts.map +1 -1
- package/dist/types/config/tenantConfigResolver.d.ts +1 -1
- package/dist/types/config/tenantConfigResolver.d.ts.map +1 -1
- package/dist/types/content/ContentApiControllerFactory.d.ts +4 -4
- package/dist/types/content/ContentApiControllerFactory.d.ts.map +1 -1
- package/dist/types/content/ContentGraphqlContext.d.ts +9 -0
- package/dist/types/content/ContentGraphqlContext.d.ts.map +1 -0
- package/dist/types/content/ContentQueryHandlerFactory.d.ts +2 -2
- package/dist/types/content/ContentQueryHandlerFactory.d.ts.map +1 -1
- package/dist/types/content/GraphQlSchemaFactory.d.ts.map +1 -1
- package/dist/types/content/NotModifiedChecker.d.ts.map +1 -1
- package/dist/types/content/ProjectMembershipResolver.d.ts.map +1 -1
- package/dist/types/content/index.d.ts +0 -1
- package/dist/types/content/index.d.ts.map +1 -1
- package/dist/types/graphql/dbQueriesListener.d.ts.map +1 -1
- package/dist/types/graphql/execution.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/misc/HomepageMiddlewareFactory.d.ts.map +1 -1
- package/dist/types/project/ProjectContainer.d.ts.map +1 -1
- package/dist/types/project/ProjectContainerResolver.d.ts.map +1 -1
- package/dist/types/project/ProjectDatabaseMetadataResolver.d.ts.map +1 -1
- package/dist/types/project-common/ProjectContextResolver.d.ts.map +1 -1
- package/dist/types/projectGroup/ProjectGroupContainer.d.ts.map +1 -1
- package/dist/types/projectGroup/ProjectGroupContainerResolver.d.ts +2 -2
- package/dist/types/projectGroup/ProjectGroupContainerResolver.d.ts.map +1 -1
- package/dist/types/projectGroup/ProjectGroupResolver.d.ts.map +1 -1
- package/dist/types/prometheus/CollectHttpMetricsMiddelware.d.ts.map +1 -1
- package/dist/types/prometheus/CustomMetric.d.ts.map +1 -1
- package/dist/types/prometheus/ProjectGroupContainerMetricsHook.d.ts.map +1 -1
- package/dist/types/prometheus/contemberEngineInfoMetric.d.ts.map +1 -1
- package/dist/types/prometheus/dbMetrics.d.ts.map +1 -1
- package/dist/types/providers.d.ts.map +1 -1
- package/dist/types/system/ContentQueryExecutor.d.ts +1 -1
- package/dist/types/system/ContentQueryExecutor.d.ts.map +1 -1
- package/dist/types/system/SystemApiMiddlewareFactory.d.ts.map +1 -1
- package/dist/types/system/SystemGraphQLContextFactory.d.ts.map +1 -1
- package/dist/types/tenant/TenantApiMiddlewareFactory.d.ts +0 -6
- package/dist/types/tenant/TenantApiMiddlewareFactory.d.ts.map +1 -1
- package/dist/types/tenant/TenantGraphQLHandlerFactory.d.ts +0 -1
- package/dist/types/tenant/TenantGraphQLHandlerFactory.d.ts.map +1 -1
- package/dist/types/tenant/index.d.ts +0 -1
- package/dist/types/tenant/index.d.ts.map +1 -1
- package/dist/types/transfer/ContentSchemaTransferMappingFactory.d.ts.map +1 -1
- package/dist/types/transfer/ExportApiControllerFactory.d.ts.map +1 -1
- package/dist/types/transfer/ExportExecutor.d.ts.map +1 -1
- package/dist/types/transfer/ImportApiMiddlewareFactory.d.ts.map +1 -1
- package/dist/types/transfer/ImportExecutor.d.ts.map +1 -1
- package/dist/types/transfer/SystemSchemaTransferMappingFactory.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/types/utils/memoizeObject.d.ts.map +1 -1
- package/dist/types/utils/remoteAddress.d.ts +3 -0
- package/dist/types/utils/remoteAddress.d.ts.map +1 -0
- package/dist/types/utils/serverStartup.d.ts.map +1 -1
- package/package.json +40 -34
- package/src/MasterContainer.ts +163 -124
- package/src/application/application.ts +29 -26
- package/src/application/types.ts +1 -1
- package/src/config/config.ts +0 -4
- package/src/config/configSchema.ts +42 -35
- package/src/config/configTemplate.ts +4 -0
- package/src/config/projectConfigResolver.ts +22 -23
- package/src/config/tenantConfigResolver.ts +26 -32
- package/src/content/ContentApiControllerFactory.ts +72 -50
- package/src/content/ContentApiSpecificCache.ts +1 -1
- package/src/content/ContentGraphqlContext.ts +7 -0
- package/src/content/ContentQueryHandlerFactory.ts +4 -4
- package/src/content/ContentSchemaResolver.ts +0 -1
- package/src/content/GraphQlSchemaFactory.ts +0 -2
- package/src/content/NotModifiedChecker.ts +0 -1
- package/src/content/ProjectMembershipResolver.ts +4 -7
- package/src/content/index.ts +0 -1
- package/src/graphql/dbQueriesListener.ts +5 -2
- package/src/graphql/execution.ts +3 -5
- package/src/index.ts +1 -1
- package/src/misc/HomepageMiddlewareFactory.ts +1 -2
- package/src/project/ProjectContainer.ts +29 -26
- package/src/project/ProjectContainerResolver.ts +3 -4
- package/src/project/ProjectDatabaseMetadataResolver.ts +0 -1
- package/src/project/config.ts +0 -1
- package/src/project-common/ProjectContextResolver.ts +0 -1
- package/src/projectGroup/ProjectGroupContainer.ts +30 -42
- package/src/projectGroup/ProjectGroupContainerResolver.ts +3 -4
- package/src/projectGroup/ProjectGroupResolver.ts +9 -11
- package/src/prometheus/CollectHttpMetricsMiddelware.ts +4 -2
- package/src/prometheus/CustomMetric.ts +8 -6
- package/src/prometheus/ProjectGroupContainerMetricsHook.ts +0 -1
- package/src/prometheus/contemberEngineInfoMetric.ts +1 -1
- package/src/prometheus/dbMetrics.ts +5 -6
- package/src/providers.ts +0 -1
- package/src/system/ContentQueryExecutor.ts +16 -7
- package/src/system/SystemApiMiddlewareFactory.ts +12 -13
- package/src/system/SystemGraphQLContextFactory.ts +2 -2
- package/src/tenant/TenantApiMiddlewareFactory.ts +23 -20
- package/src/tenant/TenantGraphQLHandlerFactory.ts +0 -3
- package/src/tenant/index.ts +0 -1
- package/src/transfer/CommandStream.ts +0 -3
- package/src/transfer/ContentSchemaTransferMappingFactory.ts +0 -2
- package/src/transfer/ExportApiControllerFactory.ts +12 -11
- package/src/transfer/ExportExecutor.ts +9 -10
- package/src/transfer/ImportApiMiddlewareFactory.ts +0 -2
- package/src/transfer/ImportExecutor.ts +57 -21
- package/src/transfer/SystemSchemaTransferMappingFactory.ts +4 -8
- package/src/utils/memoizeObject.ts +0 -2
- package/src/utils/remoteAddress.ts +66 -0
- package/src/utils/sentry.ts +1 -1
- package/src/utils/serverStartup.ts +5 -3
- package/tests/cases/unit/configResolver.test.ts +74 -8
- package/tests/cases/unit/contentApiSpecificCache.tst.js +0 -7
- package/tests/cases/unit/crypto.test.ts +2 -5
- package/tests/cases/unit/projectMembershipResolver.test.ts +36 -25
- package/vitest.config.ts +0 -1
- package/dist/development/src/content/ContentGraphQLContextFactory.cjs +0 -39
- package/dist/development/src/content/ContentGraphQLContextFactory.cjs.map +0 -1
- package/dist/development/src/content/ContentGraphQLContextFactory.js +0 -39
- package/dist/development/src/content/ContentGraphQLContextFactory.js.map +0 -1
- package/dist/development/src/tenant/TenantGraphQLContextFactory.cjs +0 -19
- package/dist/development/src/tenant/TenantGraphQLContextFactory.cjs.map +0 -1
- package/dist/development/src/tenant/TenantGraphQLContextFactory.js +0 -19
- package/dist/development/src/tenant/TenantGraphQLContextFactory.js.map +0 -1
- package/dist/production/src/content/ContentGraphQLContextFactory.cjs +0 -39
- package/dist/production/src/content/ContentGraphQLContextFactory.cjs.map +0 -1
- package/dist/production/src/content/ContentGraphQLContextFactory.js +0 -39
- package/dist/production/src/content/ContentGraphQLContextFactory.js.map +0 -1
- package/dist/production/src/tenant/TenantGraphQLContextFactory.cjs +0 -19
- package/dist/production/src/tenant/TenantGraphQLContextFactory.cjs.map +0 -1
- package/dist/production/src/tenant/TenantGraphQLContextFactory.js +0 -19
- package/dist/production/src/tenant/TenantGraphQLContextFactory.js.map +0 -1
- package/dist/types/content/ContentGraphQLContextFactory.d.ts +0 -38
- package/dist/types/content/ContentGraphQLContextFactory.d.ts.map +0 -1
- package/dist/types/tenant/TenantGraphQLContextFactory.d.ts +0 -12
- package/dist/types/tenant/TenantGraphQLContextFactory.d.ts.map +0 -1
- package/src/content/ContentGraphQLContextFactory.ts +0 -70
- package/src/tenant/TenantGraphQLContextFactory.ts +0 -24
|
@@ -11,6 +11,7 @@ import { Readable } from "node:stream";
|
|
|
11
11
|
import { URL } from "node:url";
|
|
12
12
|
import { cpuUsage, memoryUsage } from "node:process";
|
|
13
13
|
import { performance } from "node:perf_hooks";
|
|
14
|
+
import { getClientIP } from "../utils/remoteAddress.js";
|
|
14
15
|
var __defProp = Object.defineProperty;
|
|
15
16
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
16
17
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
@@ -94,13 +95,14 @@ class Application {
|
|
|
94
95
|
let webSocketContext = null;
|
|
95
96
|
let requestLogger = this.logger;
|
|
96
97
|
const { timer, send: sendTimer } = this.createTimer();
|
|
98
|
+
const clientIp = getClientIP(req);
|
|
97
99
|
try {
|
|
98
100
|
const url = new URL(req.url ?? "/", `http://${req.headers.host}`);
|
|
99
101
|
const matchedRequest = this.matchRequest(this.websocketRoutes, url);
|
|
100
102
|
if (!matchedRequest) {
|
|
101
103
|
throw new HttpErrorResponse(404, "Route not found");
|
|
102
104
|
}
|
|
103
|
-
requestLogger = this.createRequestLogger(req, void 0, matchedRequest.module);
|
|
105
|
+
requestLogger = this.createRequestLogger(req, void 0, matchedRequest.module, clientIp);
|
|
104
106
|
const groupContainer = await this.projectGroupResolver.resolveContainer({ request: req });
|
|
105
107
|
requestLogger = requestLogger.child({
|
|
106
108
|
projectGroup: groupContainer.slug
|
|
@@ -110,9 +112,11 @@ class Application {
|
|
|
110
112
|
requestLogger = requestLogger.child({
|
|
111
113
|
user: authResult?.identityId
|
|
112
114
|
});
|
|
113
|
-
const ws = await new Promise(
|
|
114
|
-
resolve(ws2)
|
|
115
|
-
|
|
115
|
+
const ws = await new Promise(
|
|
116
|
+
(resolve) => wss.handleUpgrade(req, socket, head, (ws2, request) => {
|
|
117
|
+
resolve(ws2);
|
|
118
|
+
})
|
|
119
|
+
);
|
|
116
120
|
const wsEstablished = performance.now();
|
|
117
121
|
webSocketContext = {
|
|
118
122
|
ws,
|
|
@@ -121,6 +125,7 @@ class Application {
|
|
|
121
125
|
timer,
|
|
122
126
|
url,
|
|
123
127
|
request: req,
|
|
128
|
+
clientIp,
|
|
124
129
|
authResult,
|
|
125
130
|
params: matchedRequest.params,
|
|
126
131
|
projectGroup: groupContainer
|
|
@@ -165,7 +170,8 @@ class Application {
|
|
|
165
170
|
}
|
|
166
171
|
}
|
|
167
172
|
let httpContext = null;
|
|
168
|
-
|
|
173
|
+
const clientIp = getClientIP(ctx.req);
|
|
174
|
+
let requestLogger = this.createRequestLogger(ctx.req, ctx.request.body, matchedRequest?.module, clientIp);
|
|
169
175
|
const { timer, send: sendTimer } = this.createTimer();
|
|
170
176
|
try {
|
|
171
177
|
if (!matchedRequest) {
|
|
@@ -192,6 +198,7 @@ class Application {
|
|
|
192
198
|
koa: ctx,
|
|
193
199
|
body: ctx.request.body,
|
|
194
200
|
url: ctx.request.URL,
|
|
201
|
+
clientIp,
|
|
195
202
|
logger,
|
|
196
203
|
timer,
|
|
197
204
|
request: ctx.req,
|
|
@@ -229,6 +236,7 @@ class Application {
|
|
|
229
236
|
const response = await this.logger.scope(async (logger) => {
|
|
230
237
|
return await matchedRequest.controller({
|
|
231
238
|
koa: ctx,
|
|
239
|
+
clientIp: getClientIP(ctx.req),
|
|
232
240
|
body: ctx.request.body,
|
|
233
241
|
url: ctx.request.URL,
|
|
234
242
|
logger,
|
|
@@ -270,12 +278,13 @@ class Application {
|
|
|
270
278
|
` + Object.keys(headers).map((h) => `${h}: ${headers[h]}`).join("\r\n") + "\r\n\r\n" + (response.body ?? "")
|
|
271
279
|
);
|
|
272
280
|
}
|
|
273
|
-
createRequestLogger(request, body, module) {
|
|
281
|
+
createRequestLogger(request, body, module, remoteAddress) {
|
|
274
282
|
return this.logger.child({
|
|
275
283
|
method: request.method,
|
|
276
284
|
uri: request.url,
|
|
277
285
|
requestId: Math.random().toString().substring(2),
|
|
278
286
|
module,
|
|
287
|
+
remoteAddress,
|
|
279
288
|
[LoggerRequestBody]: body
|
|
280
289
|
}, {
|
|
281
290
|
handler: FingerCrossedLoggerHandler.factory()
|
|
@@ -353,8 +362,7 @@ class Application {
|
|
|
353
362
|
}
|
|
354
363
|
}
|
|
355
364
|
const createRequestMatcher = (mask) => {
|
|
356
|
-
const keys =
|
|
357
|
-
const regexp = pathToRegexp(mask, keys);
|
|
365
|
+
const { regexp, keys } = pathToRegexp(mask);
|
|
358
366
|
const match = function(url) {
|
|
359
367
|
const match2 = regexp.exec(url);
|
|
360
368
|
if (match2) {
|
|
@@ -366,7 +374,7 @@ const createRequestMatcher = (mask) => {
|
|
|
366
374
|
return match(request.url.pathname);
|
|
367
375
|
};
|
|
368
376
|
};
|
|
369
|
-
const LoggerRequestBody = Symbol("RequestBody");
|
|
377
|
+
const LoggerRequestBody = /* @__PURE__ */ Symbol("RequestBody");
|
|
370
378
|
export {
|
|
371
379
|
Application,
|
|
372
380
|
LoggerRequestBody
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.js","sources":["../../../../../packages/engine-http/src/application/application.ts"],"sourcesContent":["import { Key, pathToRegexp } from 'path-to-regexp'\nimport { KoaContext, KoaMiddleware } from './types'\nimport { AuthResult, HttpErrorResponse, HttpResponse } from '../common'\nimport Koa from 'koa'\nimport * as http from 'node:http'\nimport { IncomingMessage, Server, ServerResponse } from 'node:http'\nimport { WebSocket, WebSocketServer } from 'ws'\nimport { FingerCrossedLoggerHandler, Logger } from '@contember/logger'\nimport koaCompress from 'koa-compress'\nimport bodyParser from 'koa-bodyparser'\nimport { ServerConfig } from '../config/config'\nimport corsMiddleware from '@koa/cors'\nimport stream, { Duplex, Readable } from 'node:stream'\nimport { ProjectGroupResolver } from '../projectGroup/ProjectGroupResolver'\nimport { ProjectGroupContainer } from '../projectGroup/ProjectGroupContainer'\nimport { URL } from 'node:url'\nimport { cpuUsage, memoryUsage } from 'node:process'\nimport { performance } from 'node:perf_hooks'\n\ntype Route<C> = { match: RequestMatcher; controller: C; module: string }\nexport class Application {\n\n\tprivate middlewares: KoaMiddleware<any>[] = []\n\n\tprivate routes: Route<HttpController>[] = []\n\tprivate internalRoutes: Route<InternalHttpController>[] = []\n\tprivate websocketRoutes: Route<WebSocketController>[] = []\n\n\tprivate suppressAccessLog: boolean | RegExp\n\n\tconstructor(\n\t\tprivate readonly projectGroupResolver: ProjectGroupResolver,\n\t\tprivate readonly serverConfig: ServerConfig,\n\t\tprivate readonly debugMode: boolean,\n\t\tprivate readonly version: string | undefined,\n\t\tprivate readonly logger: Logger,\n\t) {\n\t\tconst suppressAccessLogRaw = serverConfig.http?.suppressAccessLog\n\t\tthis.suppressAccessLog = suppressAccessLogRaw === true ? true : suppressAccessLogRaw ? new RegExp(suppressAccessLogRaw) : false\n\t}\n\n\taddMiddleware(middleware: KoaMiddleware<any>) {\n\t\tthis.middlewares.push(middleware)\n\t}\n\n\tpublic addRoute(module: string, mask: string, controller: HttpController): void {\n\t\tthis.routes.push({\n\t\t\tmodule,\n\t\t\tcontroller,\n\t\t\tmatch: createRequestMatcher(mask),\n\t\t})\n\t}\n\n\tpublic addInternalRoute(module: string, mask: string, controller: InternalHttpController): void {\n\t\tthis.internalRoutes.push({\n\t\t\tmodule,\n\t\t\tcontroller,\n\t\t\tmatch: createRequestMatcher(mask),\n\t\t})\n\t}\n\n\tpublic addWebsocketRoute(module: string, mask: string, controller: WebSocketController): void {\n\t\tthis.websocketRoutes.push({\n\t\t\tmodule,\n\t\t\tcontroller,\n\t\t\tmatch: createRequestMatcher(mask),\n\t\t})\n\t}\n\n\tasync listen(): Promise<RunningApplication> {\n\t\tconst koa = new Koa()\n\t\tconst wss = new WebSocketServer({ noServer: true })\n\t\tfor (const middleware of this.middlewares) {\n\t\t\tkoa.use(middleware)\n\t\t}\n\t\tkoa.use(koaCompress({\n\t\t\tbr: false,\n\t\t}))\n\t\tkoa.use(bodyParser({\n\t\t\tjsonLimit: this.serverConfig.http?.requestBodySize || '1mb',\n\t\t}))\n\t\tkoa.use(corsMiddleware())\n\t\tconst versionMatch = this.version?.match(/^(0\\.\\d+|\\d+)/)\n\t\tconst versionSimplified = versionMatch?.[1] ?? 'unknown'\n\t\tkoa.use(async ctx => {\n\t\t\tctx.response.set('X-Powered-By', `Contember ${versionSimplified}` + (this.debugMode ? '-dev' : ''))\n\t\t\tawait this.handleHttpRequest(ctx)\n\t\t})\n\n\t\tconst server = http.createServer(koa.callback())\n\t\tconst abortController = new AbortController()\n\n\t\tconst wsRequests: (Promise<void>)[] = []\n\t\tserver.on('upgrade', (req, socket, head) => {\n\t\t\t wsRequests.push(this.handleWebsocketRequest(wss, abortController.signal, req, socket, head))\n\t\t})\n\t\tawait new Promise<void>(resolve => {\n\t\t\tserver.listen(this.serverConfig.port, () => resolve())\n\t\t})\n\n\t\treturn {\n\t\t\tserver,\n\t\t\tclose: async () => {\n\t\t\t\tabortController.abort()\n\t\t\t\tawait Promise.all(wsRequests)\n\t\t\t\tawait new Promise(resolve => server.close(resolve))\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate async handleWebsocketRequest(\n\t\twss: WebSocketServer,\n\t\tabortSignal: AbortSignal,\n\t\treq: IncomingMessage,\n\t\tsocket: stream.Duplex,\n\t\thead: Buffer,\n\t): Promise<void> {\n\t\tlet webSocketContext: WebSocketContext | null = null\n\t\tlet requestLogger = this.logger\n\t\tconst { timer, send: sendTimer } = this.createTimer()\n\t\ttry {\n\t\t\tconst url = new URL(req.url ?? '/', `http://${req.headers.host}`)\n\t\t\tconst matchedRequest = this.matchRequest(this.websocketRoutes, url)\n\t\t\tif (!matchedRequest) {\n\t\t\t\tthrow new HttpErrorResponse(404, 'Route not found')\n\t\t\t}\n\t\t\trequestLogger = this.createRequestLogger(req, undefined, matchedRequest.module)\n\n\t\t\tconst groupContainer = await this.projectGroupResolver.resolveContainer({ request: req })\n\n\t\t\trequestLogger = requestLogger.child({\n\t\t\t\tprojectGroup: groupContainer.slug,\n\t\t\t})\n\n\t\t\tconst authResult = await groupContainer.authenticator.authenticate({ request: req, timer })\n\t\t\trequestLogger.debug('User authenticated', { authResult })\n\t\t\trequestLogger = requestLogger.child({\n\t\t\t\tuser: authResult?.identityId,\n\t\t\t})\n\n\t\t\tconst ws = await new Promise<WebSocket>(resolve => wss.handleUpgrade(req, socket, head, (ws, request) => {\n\t\t\t\tresolve(ws)\n\t\t\t}))\n\t\t\tconst wsEstablished = performance.now()\n\t\t\twebSocketContext = {\n\t\t\t\tws,\n\t\t\t\tabortSignal,\n\t\t\t\tlogger: requestLogger,\n\t\t\t\ttimer,\n\t\t\t\turl,\n\t\t\t\trequest: req,\n\t\t\t\tauthResult,\n\t\t\t\tparams: matchedRequest.params,\n\t\t\t\tprojectGroup: groupContainer,\n\t\t\t}\n\t\t\tawait matchedRequest.controller(webSocketContext)\n\t\t\trequestLogger.debug('Websocket connection established')\n\t\t\tws.on('error', e => {\n\t\t\t\trequestLogger.error(e, {\n\t\t\t\t\twebsocketOpenMs: performance.now() - wsEstablished,\n\t\t\t\t})\n\t\t\t})\n\n\t\t\treturn new Promise<void>(resolve => {\n\t\t\t\tws.on('close', () => {\n\t\t\t\t\trequestLogger.debug('Websocket connection closed', {\n\t\t\t\t\t\twebsocketOpenMs: performance.now() - wsEstablished,\n\t\t\t\t\t})\n\t\t\t\t\tresolve()\n\t\t\t\t})\n\t\t\t})\n\t\t} catch (e) {\n\t\t\tif (e instanceof HttpResponse) {\n\t\t\t\tthis.sendRawHttpResponse(socket, e)\n\t\t\t} else {\n\t\t\t\tthis.sendRawHttpResponse(socket, new HttpErrorResponse(500, 'Internal server error'))\n\t\t\t\trequestLogger.error(e)\n\t\t\t}\n\t\t\trequestLogger.debug('Websocket connection failed')\n\t\t} finally {\n\t\t\tsendTimer({\n\t\t\t\treq,\n\t\t\t\trequestDebugMode: false,\n\t\t\t\tlogger: requestLogger,\n\t\t\t})\n\t\t}\n\t}\n\n\tprivate async handleHttpRequest(ctx: KoaContext<{ module?: string; projectGroup?: string; project?: string }>) {\n\t\tconst matchedRequest = this.matchRequest(this.routes, ctx.request.URL)\n\t\tif (!matchedRequest) {\n\t\t\tconst internalMatchedRequest = this.matchRequest(this.internalRoutes, ctx.request.URL)\n\t\t\tif (internalMatchedRequest) {\n\t\t\t\treturn await this.handleInternalRequest(internalMatchedRequest, ctx)\n\t\t\t}\n\t\t}\n\t\tlet httpContext: HttpContext | null = null\n\t\tlet requestLogger = this.createRequestLogger(ctx.req, ctx.request.body, matchedRequest?.module)\n\t\tconst { timer, send: sendTimer } = this.createTimer()\n\n\t\ttry {\n\t\t\tif (!matchedRequest) {\n\t\t\t\treturn this.sendHttpResponse(ctx, new HttpErrorResponse(404, 'Route not found'))\n\t\t\t}\n\t\t\trequestLogger.debug('Request processing started', {\n\t\t\t\tbody: ctx.request.body,\n\t\t\t\tquery: ctx.request.query,\n\t\t\t})\n\n\t\t\t// todo: solve without koa context (required by prom metrics)\n\t\t\tctx.state.module = matchedRequest.module\n\n\t\t\tconst groupContainer = await this.projectGroupResolver.resolveContainer({ request: ctx.req })\n\t\t\trequestLogger = requestLogger.child({\n\t\t\t\tprojectGroup: groupContainer.slug,\n\t\t\t})\n\t\t\tctx.state.projectGroup = groupContainer.slug\n\t\t\tctx.state.project = matchedRequest.params.projectSlug\n\n\t\t\tconst authResult = await groupContainer.authenticator.authenticate({ request: ctx.req, timer })\n\t\t\trequestLogger.debug('User authenticated', { authResult })\n\t\t\trequestLogger = requestLogger.child({\n\t\t\t\tuser: authResult?.identityId,\n\t\t\t})\n\n\n\t\t\tconst response = await requestLogger.scope(async logger => {\n\t\t\t\thttpContext = {\n\t\t\t\t\tkoa: ctx,\n\t\t\t\t\tbody: ctx.request.body,\n\t\t\t\t\turl: ctx.request.URL,\n\t\t\t\t\tlogger,\n\t\t\t\t\ttimer,\n\t\t\t\t\trequest: ctx.req,\n\t\t\t\t\tresponse: ctx.res,\n\t\t\t\t\trequestDebugMode: false,\n\t\t\t\t\tauthResult,\n\t\t\t\t\tparams: matchedRequest.params,\n\t\t\t\t\tprojectGroup: groupContainer,\n\t\t\t\t}\n\t\t\t\treturn await matchedRequest.controller(httpContext)\n\t\t\t})\n\t\t\tif (response) {\n\t\t\t\tthis.sendHttpResponse(ctx, response)\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tif (e instanceof HttpResponse) {\n\t\t\t\tthis.sendHttpResponse(ctx, e)\n\t\t\t} else {\n\t\t\t\tthis.sendHttpResponse(ctx, new HttpErrorResponse(500, 'Internal server error'))\n\t\t\t\trequestLogger.error(e)\n\t\t\t}\n\t\t} finally {\n\t\t\tsendTimer({\n\t\t\t\treq: ctx.req,\n\t\t\t\tresponse: ctx.res,\n\t\t\t\tbody: ctx.response.body,\n\t\t\t\trequestDebugMode: (httpContext as HttpContext | null)?.requestDebugMode ?? false,\n\t\t\t\tlogger: requestLogger,\n\t\t\t})\n\t\t\trequestLogger.debug('Request processing finished')\n\t\t}\n\t}\n\n\n\tprivate async handleInternalRequest(matchedRequest: MatchedRequest<InternalHttpController>, ctx: KoaContext<{ module?: string }>) {\n\t\ttry {\n\t\t\tconst response = await this.logger.scope(async logger => {\n\t\t\t\treturn await matchedRequest.controller({\n\t\t\t\t\tkoa: ctx,\n\t\t\t\t\tbody: ctx.request.body,\n\t\t\t\t\turl: ctx.request.URL,\n\t\t\t\t\tlogger,\n\t\t\t\t\trequest: ctx.req,\n\t\t\t\t\tresponse: ctx.res,\n\t\t\t\t\tparams: matchedRequest.params,\n\t\t\t\t})\n\t\t\t})\n\t\t\tif (response) {\n\t\t\t\tthis.sendHttpResponse(ctx, response)\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tif (e instanceof HttpResponse) {\n\t\t\t\tthis.sendHttpResponse(ctx, e)\n\t\t\t} else {\n\t\t\t\tthis.sendHttpResponse(ctx, new HttpErrorResponse(500, 'Internal server error'))\n\t\t\t\tthis.logger.error(e)\n\t\t\t}\n\t\t}\n\t}\n\n\n\tprivate sendHttpResponse(ctx: KoaContext<{}>, response: HttpResponse) {\n\t\tif (response.contentType) {\n\t\t\tctx.set('Content-type', response.contentType)\n\t\t}\n\t\tctx.status = response.code\n\t\tif (response.body !== undefined) {\n\t\t\tctx.body = response.body\n\t\t}\n\t}\n\n\tprivate sendRawHttpResponse(socket: Duplex, response: HttpResponse) {\n\t\tconst headers: Record<string, string> = {\n\t\t\t'Connection': 'close',\n\t\t\t'Content-Type': response.contentType ?? 'text/plain',\n\t\t\t'Content-Length': String(response.body?.length ?? 0),\n\t\t}\n\n\t\tsocket.once('finish', socket.destroy)\n\n\t\tsocket.end(\n\t\t\t`HTTP/1.1 ${response.code} ${http.STATUS_CODES[response.code]}\\r\\n` +\n\t\t\tObject.keys(headers)\n\t\t\t\t.map(h => `${h}: ${headers[h]}`)\n\t\t\t\t.join('\\r\\n') +\n\t\t\t'\\r\\n\\r\\n' +\n\t\t\t(response.body ?? ''),\n\t\t)\n\t}\n\n\tprivate createRequestLogger(request: IncomingMessage, body: any, module?: string): Logger {\n\t\treturn this.logger.child({\n\t\t\tmethod: request.method,\n\t\t\turi: request.url,\n\t\t\trequestId: Math.random().toString().substring(2),\n\t\t\tmodule,\n\t\t\t[LoggerRequestBody]: body,\n\t\t}, {\n\t\t\thandler: FingerCrossedLoggerHandler.factory(),\n\t\t})\n\t}\n\n\tprivate createTimer() {\n\t\tconst times: EventTime[] = []\n\t\tconst globalStart = performance.now()\n\t\tconst cpuUsageStart = cpuUsage()\n\t\tconst memoryUsageStart = memoryUsage()\n\t\tconst timer: Timer = (name: string, cb) => {\n\t\t\tconst start = performance.now()\n\t\t\tconst time: EventTime = { label: name, start: Math.round(start - globalStart) }\n\t\t\ttimes.push(time)\n\t\t\tconst res = cb()\n\n\t\t\tif (res instanceof Promise) {\n\t\t\t\t(async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait res\n\t\t\t\t\t} catch {\n\t\t\t\t\t} finally {\n\t\t\t\t\t\ttime.duration = Math.round(performance.now() - start)\n\t\t\t\t\t}\n\t\t\t\t})()\n\t\t\t}\n\t\t\treturn res\n\t\t}\n\n\t\tconst send = (ctx: { req: IncomingMessage; response?: ServerResponse; body?: unknown; requestDebugMode: boolean; logger: Logger }) => {\n\t\t\tif (ctx.response && !ctx.response.headersSent && (ctx.requestDebugMode || this.debugMode) && times.length) {\n\t\t\t\tctx.response.setHeader('server-timing', times.map(it => `${it.label};desc=\"${it.label} T+${it.start}\";dur=${it.duration ?? -1}`).join(', '))\n\t\t\t}\n\n\t\t\tconst emit = () => {\n\t\t\t\tconst total = performance.now() - globalStart\n\t\t\t\tconst timeLabel = total > 500 ? 'TIME_SLOW' : 'TIME_OK'\n\t\t\t\tconst shouldSuppress = this.suppressAccessLog === true || !ctx.req.url || (this.suppressAccessLog !== false && this.suppressAccessLog.test(ctx.req.url))\n\n\t\t\t\tconst cpuUsageEnd = cpuUsage()\n\t\t\t\tconst memoryUsageEnd = memoryUsage()\n\n\t\t\t\tconst cpuUsageDiffMs = (cpuUsageEnd.user - cpuUsageStart.user) / 1000\n\t\t\t\tconst memoryUsageDiff = memoryUsageEnd.heapUsed - memoryUsageStart.heapUsed\n\t\t\t\tconst level = shouldSuppress ? 'debug' : 'info'\n\t\t\t\tctx.logger.log(level, !ctx.response ? 'Connection established' : ctx.response.statusCode < 400 ? `Request successful` : 'Request failed', {\n\t\t\t\t\tstatus: ctx.response?.statusCode,\n\t\t\t\t\ttimeLabel: timeLabel,\n\t\t\t\t\ttotalTimeMs: Math.round(total),\n\t\t\t\t\tevents: times,\n\t\t\t\t\tcpuUsageDiffMs,\n\t\t\t\t\tmemoryUsageDiff,\n\t\t\t\t\tresponseBodySize: ctx.body && typeof ctx.body === 'string' ? ctx.body.length : undefined,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tif (ctx.body instanceof Readable) {\n\t\t\t\tconst body = ctx.body\n\t\t\t\tconst streamTimer = timer('Stream', () => {\n\t\t\t\t\treturn new Promise(resolve => {\n\t\t\t\t\t\tbody.addListener('close', () => {\n\t\t\t\t\t\t\tresolve(null)\n\t\t\t\t\t\t})\n\t\t\t\t\t})\n\t\t\t\t})\n\n\t\t\t\tstreamTimer.then(emit).catch(emit)\n\n\t\t\t} else {\n\t\t\t\temit()\n\t\t\t}\n\n\t\t}\n\t\treturn { timer, send }\n\t}\n\n\tprivate matchRequest<C>(routes: Route<C>[], url: URL): MatchedRequest<C> | null {\n\t\tfor (const route of routes) {\n\t\t\tconst params = route.match({ url })\n\t\t\tif (params !== null) {\n\t\t\t\treturn { params, controller: route.controller, module: route.module }\n\t\t\t}\n\t\t}\n\t\treturn null\n\t}\n}\n\n\ntype EventTime = { label: string; start: number; duration?: number }\n\nexport type Timer = <T>(event: string, cb: () => T) => T\n\nexport type MatchedRequest<C> = { params: Params; controller: C; module: string }\n\nexport type BaseRequestContext = {\n\tlogger: Logger\n\trequest: IncomingMessage\n\turl: URL\n\tparams: Params\n}\n\nexport type ApplicationContext =\n\t& BaseRequestContext\n\t& {\n\t\tprojectGroup: ProjectGroupContainer\n\t\tauthResult: AuthResult | null\n\t\ttimer: Timer\n\t}\n\nexport type BaseHttpRequestContext = {\n\tkoa: KoaContext<{}>\n\tbody: unknown\n\tresponse: ServerResponse\n}\n\nexport type HttpContext =\n\t& ApplicationContext\n\t& BaseHttpRequestContext\n\t& {\n\t\trequestDebugMode: boolean\n\t}\n\nexport type InternalHttpContext =\n\t& BaseRequestContext\n\t& BaseHttpRequestContext\n\nexport type WebSocketContext =\n\t& ApplicationContext\n\t& {\n\t\tws: WebSocket\n\t\tabortSignal: AbortSignal\n\t}\n\nexport type HttpControllerResponse = Promise<HttpErrorResponse | undefined | void> | HttpErrorResponse | undefined | void\nexport type HttpController = (context: HttpContext) => HttpControllerResponse\nexport type InternalHttpController = (context: InternalHttpContext) => HttpControllerResponse\n\nexport type WebSocketController = (context: WebSocketContext) => void\n\ntype Params = { [param: string]: string }\n\ntype RequestMatcher = (args: { url: URL }) => Params | null\nconst createRequestMatcher = (\n\tmask: string,\n): RequestMatcher => {\n\tconst keys: Key[] = []\n\tconst regexp: RegExp = pathToRegexp(mask, keys)\n\n\tconst match = function (url: string): Params | null {\n\t\tconst match = regexp.exec(url)\n\t\tif (match) {\n\t\t\treturn match.slice(1).reduce((acc, value, i) => ({ ...acc, [keys[i].name]: value }), {})\n\t\t}\n\t\treturn null\n\t}\n\n\treturn request => {\n\t\treturn match(request.url.pathname)\n\t}\n}\n\nexport const LoggerRequestBody = Symbol('RequestBody')\n\nexport interface RunningApplication {\n\tclose(): Promise<void>\n\treadonly server: Server\n}\n"],"names":["ws","match"],"mappings":";;;;;;;;;;;;;;;;AAoBO,MAAM,YAAY;AAAA,EAUxB,YACkB,sBACA,cACA,WACA,SACA,QAChB;AALgB,SAAA,uBAAA;AACA,SAAA,eAAA;AACA,SAAA,YAAA;AACA,SAAA,UAAA;AACA,SAAA,SAAA;AAblB,kBAAA,MAAQ,eAAoC,EAAC;AAE7C,kBAAA,MAAQ,UAAkC,EAAC;AAC3C,kBAAA,MAAQ,kBAAkD,EAAC;AAC3D,kBAAA,MAAQ,mBAAgD,EAAC;AAEjD,kBAAA,MAAA,mBAAA;AASD,UAAA,uBAAuB,aAAa,MAAM;AAC3C,SAAA,oBAAoB,yBAAyB,OAAO,OAAO,uBAAuB,IAAI,OAAO,oBAAoB,IAAI;AAAA,EAAA;AAAA,EAG3H,cAAc,YAAgC;AACxC,SAAA,YAAY,KAAK,UAAU;AAAA,EAAA;AAAA,EAG1B,SAAS,QAAgB,MAAc,YAAkC;AAC/E,SAAK,OAAO,KAAK;AAAA,MAChB;AAAA,MACA;AAAA,MACA,OAAO,qBAAqB,IAAI;AAAA,IAAA,CAChC;AAAA,EAAA;AAAA,EAGK,iBAAiB,QAAgB,MAAc,YAA0C;AAC/F,SAAK,eAAe,KAAK;AAAA,MACxB;AAAA,MACA;AAAA,MACA,OAAO,qBAAqB,IAAI;AAAA,IAAA,CAChC;AAAA,EAAA;AAAA,EAGK,kBAAkB,QAAgB,MAAc,YAAuC;AAC7F,SAAK,gBAAgB,KAAK;AAAA,MACzB;AAAA,MACA;AAAA,MACA,OAAO,qBAAqB,IAAI;AAAA,IAAA,CAChC;AAAA,EAAA;AAAA,EAGF,MAAM,SAAsC;AACrC,UAAA,MAAM,IAAI,IAAI;AACpB,UAAM,MAAM,IAAI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AAM,IAAI;AAExC,QAAA,QAAQ,SAAU,KAA4B;AAC7CC,UAAAA,SAAQ,OAAO,KAAK,GAAG;AAC7B,QAAIA,QAAO;AACHA,aAAAA,OAAM,MAAM,CAAC,EAAE,OAAO,CAAC,KAAK,OAAO,OAAO,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,IAAI,GAAG,MAAA,IAAU,EAAE;AAAA,IAAA;AAEjF,WAAA;AAAA,EACR;AAEA,SAAO,CAAW,YAAA;AACV,WAAA,MAAM,QAAQ,IAAI,QAAQ;AAAA,EAClC;AACD;AAEa,MAAA,oBAAoB,OAAO,aAAa;"}
|
|
1
|
+
{"version":3,"file":"application.js","sources":["../../../../../packages/engine-http/src/application/application.ts"],"sourcesContent":["import { pathToRegexp } from 'path-to-regexp'\nimport { KoaContext, KoaMiddleware } from './types'\nimport { AuthResult, HttpErrorResponse, HttpResponse } from '../common'\nimport Koa from 'koa'\nimport * as http from 'node:http'\nimport { IncomingMessage, Server, ServerResponse } from 'node:http'\nimport { WebSocket, WebSocketServer } from 'ws'\nimport { FingerCrossedLoggerHandler, Logger } from '@contember/logger'\nimport koaCompress from 'koa-compress'\nimport bodyParser from 'koa-bodyparser'\nimport { ServerConfig } from '../config/config'\nimport corsMiddleware from '@koa/cors'\nimport stream, { Duplex, Readable } from 'node:stream'\nimport { ProjectGroupResolver } from '../projectGroup/ProjectGroupResolver'\nimport { ProjectGroupContainer } from '../projectGroup/ProjectGroupContainer'\nimport { URL } from 'node:url'\nimport { cpuUsage, memoryUsage } from 'node:process'\nimport { performance } from 'node:perf_hooks'\nimport { getClientIP } from '../utils/remoteAddress'\n\ntype Route<C> = { match: RequestMatcher; controller: C; module: string }\nexport class Application {\n\tprivate middlewares: KoaMiddleware<any>[] = []\n\n\tprivate routes: Route<HttpController>[] = []\n\tprivate internalRoutes: Route<InternalHttpController>[] = []\n\tprivate websocketRoutes: Route<WebSocketController>[] = []\n\n\tprivate suppressAccessLog: boolean | RegExp\n\n\tconstructor(\n\t\tprivate readonly projectGroupResolver: ProjectGroupResolver,\n\t\tprivate readonly serverConfig: ServerConfig,\n\t\tprivate readonly debugMode: boolean,\n\t\tprivate readonly version: string | undefined,\n\t\tprivate readonly logger: Logger,\n\t) {\n\t\tconst suppressAccessLogRaw = serverConfig.http?.suppressAccessLog\n\t\tthis.suppressAccessLog = suppressAccessLogRaw === true ? true : suppressAccessLogRaw ? new RegExp(suppressAccessLogRaw) : false\n\t}\n\n\taddMiddleware(middleware: KoaMiddleware<any>) {\n\t\tthis.middlewares.push(middleware)\n\t}\n\n\tpublic addRoute(module: string, mask: string, controller: HttpController): void {\n\t\tthis.routes.push({\n\t\t\tmodule,\n\t\t\tcontroller,\n\t\t\tmatch: createRequestMatcher(mask),\n\t\t})\n\t}\n\n\tpublic addInternalRoute(module: string, mask: string, controller: InternalHttpController): void {\n\t\tthis.internalRoutes.push({\n\t\t\tmodule,\n\t\t\tcontroller,\n\t\t\tmatch: createRequestMatcher(mask),\n\t\t})\n\t}\n\n\tpublic addWebsocketRoute(module: string, mask: string, controller: WebSocketController): void {\n\t\tthis.websocketRoutes.push({\n\t\t\tmodule,\n\t\t\tcontroller,\n\t\t\tmatch: createRequestMatcher(mask),\n\t\t})\n\t}\n\n\tasync listen(): Promise<RunningApplication> {\n\t\tconst koa = new Koa()\n\t\tconst wss = new WebSocketServer({ noServer: true })\n\t\tfor (const middleware of this.middlewares) {\n\t\t\tkoa.use(middleware)\n\t\t}\n\t\tkoa.use(koaCompress({\n\t\t\tbr: false,\n\t\t}))\n\t\tkoa.use(bodyParser({\n\t\t\tjsonLimit: this.serverConfig.http?.requestBodySize || '1mb',\n\t\t}))\n\t\tkoa.use(corsMiddleware())\n\t\tconst versionMatch = this.version?.match(/^(0\\.\\d+|\\d+)/)\n\t\tconst versionSimplified = versionMatch?.[1] ?? 'unknown'\n\t\tkoa.use(async ctx => {\n\t\t\tctx.response.set('X-Powered-By', `Contember ${versionSimplified}` + (this.debugMode ? '-dev' : ''))\n\t\t\tawait this.handleHttpRequest(ctx)\n\t\t})\n\n\t\tconst server = http.createServer(koa.callback())\n\t\tconst abortController = new AbortController()\n\n\t\tconst wsRequests: (Promise<void>)[] = []\n\t\tserver.on('upgrade', (req, socket, head) => {\n\t\t\twsRequests.push(this.handleWebsocketRequest(wss, abortController.signal, req, socket, head))\n\t\t})\n\t\tawait new Promise<void>(resolve => {\n\t\t\tserver.listen(this.serverConfig.port, () => resolve())\n\t\t})\n\n\t\treturn {\n\t\t\tserver,\n\t\t\tclose: async () => {\n\t\t\t\tabortController.abort()\n\t\t\t\tawait Promise.all(wsRequests)\n\t\t\t\tawait new Promise(resolve => server.close(resolve))\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate async handleWebsocketRequest(\n\t\twss: WebSocketServer,\n\t\tabortSignal: AbortSignal,\n\t\treq: IncomingMessage,\n\t\tsocket: stream.Duplex,\n\t\thead: Buffer,\n\t): Promise<void> {\n\t\tlet webSocketContext: WebSocketContext | null = null\n\t\tlet requestLogger = this.logger\n\t\tconst { timer, send: sendTimer } = this.createTimer()\n\t\tconst clientIp = getClientIP(req)\n\t\ttry {\n\t\t\tconst url = new URL(req.url ?? '/', `http://${req.headers.host}`)\n\t\t\tconst matchedRequest = this.matchRequest(this.websocketRoutes, url)\n\t\t\tif (!matchedRequest) {\n\t\t\t\tthrow new HttpErrorResponse(404, 'Route not found')\n\t\t\t}\n\t\t\trequestLogger = this.createRequestLogger(req, undefined, matchedRequest.module, clientIp)\n\n\t\t\tconst groupContainer = await this.projectGroupResolver.resolveContainer({ request: req })\n\n\t\t\trequestLogger = requestLogger.child({\n\t\t\t\tprojectGroup: groupContainer.slug,\n\t\t\t})\n\n\t\t\tconst authResult = await groupContainer.authenticator.authenticate({ request: req, timer })\n\t\t\trequestLogger.debug('User authenticated', { authResult })\n\t\t\trequestLogger = requestLogger.child({\n\t\t\t\tuser: authResult?.identityId,\n\t\t\t})\n\n\t\t\tconst ws = await new Promise<WebSocket>(resolve =>\n\t\t\t\twss.handleUpgrade(req, socket, head, (ws, request) => {\n\t\t\t\t\tresolve(ws)\n\t\t\t\t})\n\t\t\t)\n\t\t\tconst wsEstablished = performance.now()\n\t\t\twebSocketContext = {\n\t\t\t\tws,\n\t\t\t\tabortSignal,\n\t\t\t\tlogger: requestLogger,\n\t\t\t\ttimer,\n\t\t\t\turl,\n\t\t\t\trequest: req,\n\t\t\t\tclientIp,\n\t\t\t\tauthResult,\n\t\t\t\tparams: matchedRequest.params,\n\t\t\t\tprojectGroup: groupContainer,\n\t\t\t}\n\t\t\tawait matchedRequest.controller(webSocketContext)\n\t\t\trequestLogger.debug('Websocket connection established')\n\t\t\tws.on('error', e => {\n\t\t\t\trequestLogger.error(e, {\n\t\t\t\t\twebsocketOpenMs: performance.now() - wsEstablished,\n\t\t\t\t})\n\t\t\t})\n\n\t\t\treturn new Promise<void>(resolve => {\n\t\t\t\tws.on('close', () => {\n\t\t\t\t\trequestLogger.debug('Websocket connection closed', {\n\t\t\t\t\t\twebsocketOpenMs: performance.now() - wsEstablished,\n\t\t\t\t\t})\n\t\t\t\t\tresolve()\n\t\t\t\t})\n\t\t\t})\n\t\t} catch (e) {\n\t\t\tif (e instanceof HttpResponse) {\n\t\t\t\tthis.sendRawHttpResponse(socket, e)\n\t\t\t} else {\n\t\t\t\tthis.sendRawHttpResponse(socket, new HttpErrorResponse(500, 'Internal server error'))\n\t\t\t\trequestLogger.error(e)\n\t\t\t}\n\t\t\trequestLogger.debug('Websocket connection failed')\n\t\t} finally {\n\t\t\tsendTimer({\n\t\t\t\treq,\n\t\t\t\trequestDebugMode: false,\n\t\t\t\tlogger: requestLogger,\n\t\t\t})\n\t\t}\n\t}\n\n\tprivate async handleHttpRequest(ctx: KoaContext<{ module?: string; projectGroup?: string; project?: string }>) {\n\t\tconst matchedRequest = this.matchRequest(this.routes, ctx.request.URL)\n\t\tif (!matchedRequest) {\n\t\t\tconst internalMatchedRequest = this.matchRequest(this.internalRoutes, ctx.request.URL)\n\t\t\tif (internalMatchedRequest) {\n\t\t\t\treturn await this.handleInternalRequest(internalMatchedRequest, ctx)\n\t\t\t}\n\t\t}\n\t\tlet httpContext: HttpContext | null = null\n\t\tconst clientIp = getClientIP(ctx.req)\n\t\tlet requestLogger = this.createRequestLogger(ctx.req, ctx.request.body, matchedRequest?.module, clientIp)\n\t\tconst { timer, send: sendTimer } = this.createTimer()\n\n\t\ttry {\n\t\t\tif (!matchedRequest) {\n\t\t\t\treturn this.sendHttpResponse(ctx, new HttpErrorResponse(404, 'Route not found'))\n\t\t\t}\n\t\t\trequestLogger.debug('Request processing started', {\n\t\t\t\tbody: ctx.request.body,\n\t\t\t\tquery: ctx.request.query,\n\t\t\t})\n\n\t\t\t// todo: solve without koa context (required by prom metrics)\n\t\t\tctx.state.module = matchedRequest.module\n\n\t\t\tconst groupContainer = await this.projectGroupResolver.resolveContainer({ request: ctx.req })\n\t\t\trequestLogger = requestLogger.child({\n\t\t\t\tprojectGroup: groupContainer.slug,\n\t\t\t})\n\t\t\tctx.state.projectGroup = groupContainer.slug\n\t\t\tctx.state.project = matchedRequest.params.projectSlug\n\n\t\t\tconst authResult = await groupContainer.authenticator.authenticate({ request: ctx.req, timer })\n\t\t\trequestLogger.debug('User authenticated', { authResult })\n\t\t\trequestLogger = requestLogger.child({\n\t\t\t\tuser: authResult?.identityId,\n\t\t\t})\n\n\t\t\tconst response = await requestLogger.scope(async logger => {\n\t\t\t\thttpContext = {\n\t\t\t\t\tkoa: ctx,\n\t\t\t\t\tbody: ctx.request.body,\n\t\t\t\t\turl: ctx.request.URL,\n\t\t\t\t\tclientIp,\n\t\t\t\t\tlogger,\n\t\t\t\t\ttimer,\n\t\t\t\t\trequest: ctx.req,\n\t\t\t\t\tresponse: ctx.res,\n\t\t\t\t\trequestDebugMode: false,\n\t\t\t\t\tauthResult,\n\t\t\t\t\tparams: matchedRequest.params,\n\t\t\t\t\tprojectGroup: groupContainer,\n\t\t\t\t}\n\t\t\t\treturn await matchedRequest.controller(httpContext)\n\t\t\t})\n\t\t\tif (response) {\n\t\t\t\tthis.sendHttpResponse(ctx, response)\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tif (e instanceof HttpResponse) {\n\t\t\t\tthis.sendHttpResponse(ctx, e)\n\t\t\t} else {\n\t\t\t\tthis.sendHttpResponse(ctx, new HttpErrorResponse(500, 'Internal server error'))\n\t\t\t\trequestLogger.error(e)\n\t\t\t}\n\t\t} finally {\n\t\t\tsendTimer({\n\t\t\t\treq: ctx.req,\n\t\t\t\tresponse: ctx.res,\n\t\t\t\tbody: ctx.response.body,\n\t\t\t\trequestDebugMode: (httpContext as HttpContext | null)?.requestDebugMode ?? false,\n\t\t\t\tlogger: requestLogger,\n\t\t\t})\n\t\t\trequestLogger.debug('Request processing finished')\n\t\t}\n\t}\n\n\tprivate async handleInternalRequest(matchedRequest: MatchedRequest<InternalHttpController>, ctx: KoaContext<{ module?: string }>) {\n\t\ttry {\n\t\t\tconst response = await this.logger.scope(async logger => {\n\t\t\t\treturn await matchedRequest.controller({\n\t\t\t\t\tkoa: ctx,\n\t\t\t\t\tclientIp: getClientIP(ctx.req),\n\t\t\t\t\tbody: ctx.request.body,\n\t\t\t\t\turl: ctx.request.URL,\n\t\t\t\t\tlogger,\n\t\t\t\t\trequest: ctx.req,\n\t\t\t\t\tresponse: ctx.res,\n\t\t\t\t\tparams: matchedRequest.params,\n\t\t\t\t})\n\t\t\t})\n\t\t\tif (response) {\n\t\t\t\tthis.sendHttpResponse(ctx, response)\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tif (e instanceof HttpResponse) {\n\t\t\t\tthis.sendHttpResponse(ctx, e)\n\t\t\t} else {\n\t\t\t\tthis.sendHttpResponse(ctx, new HttpErrorResponse(500, 'Internal server error'))\n\t\t\t\tthis.logger.error(e)\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate sendHttpResponse(ctx: KoaContext<{}>, response: HttpResponse) {\n\t\tif (response.contentType) {\n\t\t\tctx.set('Content-type', response.contentType)\n\t\t}\n\t\tctx.status = response.code\n\t\tif (response.body !== undefined) {\n\t\t\tctx.body = response.body\n\t\t}\n\t}\n\n\tprivate sendRawHttpResponse(socket: Duplex, response: HttpResponse) {\n\t\tconst headers: Record<string, string> = {\n\t\t\t'Connection': 'close',\n\t\t\t'Content-Type': response.contentType ?? 'text/plain',\n\t\t\t'Content-Length': String(response.body?.length ?? 0),\n\t\t}\n\n\t\tsocket.once('finish', socket.destroy)\n\n\t\tsocket.end(\n\t\t\t`HTTP/1.1 ${response.code} ${http.STATUS_CODES[response.code]}\\r\\n`\n\t\t\t\t+ Object.keys(headers)\n\t\t\t\t\t.map(h => `${h}: ${headers[h]}`)\n\t\t\t\t\t.join('\\r\\n')\n\t\t\t\t+ '\\r\\n\\r\\n'\n\t\t\t\t+ (response.body ?? ''),\n\t\t)\n\t}\n\n\tprivate createRequestLogger(request: IncomingMessage, body: any, module?: string, remoteAddress?: string): Logger {\n\t\treturn this.logger.child({\n\t\t\tmethod: request.method,\n\t\t\turi: request.url,\n\t\t\trequestId: Math.random().toString().substring(2),\n\t\t\tmodule,\n\t\t\tremoteAddress,\n\t\t\t[LoggerRequestBody]: body,\n\t\t}, {\n\t\t\thandler: FingerCrossedLoggerHandler.factory(),\n\t\t})\n\t}\n\n\tprivate createTimer() {\n\t\tconst times: EventTime[] = []\n\t\tconst globalStart = performance.now()\n\t\tconst cpuUsageStart = cpuUsage()\n\t\tconst memoryUsageStart = memoryUsage()\n\t\tconst timer: Timer = (name: string, cb) => {\n\t\t\tconst start = performance.now()\n\t\t\tconst time: EventTime = { label: name, start: Math.round(start - globalStart) }\n\t\t\ttimes.push(time)\n\t\t\tconst res = cb()\n\n\t\t\tif (res instanceof Promise) {\n\t\t\t\t;(async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait res\n\t\t\t\t\t} catch {\n\t\t\t\t\t} finally {\n\t\t\t\t\t\ttime.duration = Math.round(performance.now() - start)\n\t\t\t\t\t}\n\t\t\t\t})()\n\t\t\t}\n\t\t\treturn res\n\t\t}\n\n\t\tconst send = (ctx: { req: IncomingMessage; response?: ServerResponse; body?: unknown; requestDebugMode: boolean; logger: Logger }) => {\n\t\t\tif (ctx.response && !ctx.response.headersSent && (ctx.requestDebugMode || this.debugMode) && times.length) {\n\t\t\t\tctx.response.setHeader('server-timing', times.map(it => `${it.label};desc=\"${it.label} T+${it.start}\";dur=${it.duration ?? -1}`).join(', '))\n\t\t\t}\n\n\t\t\tconst emit = () => {\n\t\t\t\tconst total = performance.now() - globalStart\n\t\t\t\tconst timeLabel = total > 500 ? 'TIME_SLOW' : 'TIME_OK'\n\t\t\t\tconst shouldSuppress = this.suppressAccessLog === true || !ctx.req.url\n\t\t\t\t\t|| (this.suppressAccessLog !== false && this.suppressAccessLog.test(ctx.req.url))\n\n\t\t\t\tconst cpuUsageEnd = cpuUsage()\n\t\t\t\tconst memoryUsageEnd = memoryUsage()\n\n\t\t\t\tconst cpuUsageDiffMs = (cpuUsageEnd.user - cpuUsageStart.user) / 1000\n\t\t\t\tconst memoryUsageDiff = memoryUsageEnd.heapUsed - memoryUsageStart.heapUsed\n\t\t\t\tconst level = shouldSuppress ? 'debug' : 'info'\n\t\t\t\tctx.logger.log(level, !ctx.response ? 'Connection established' : ctx.response.statusCode < 400 ? `Request successful` : 'Request failed', {\n\t\t\t\t\tstatus: ctx.response?.statusCode,\n\t\t\t\t\ttimeLabel: timeLabel,\n\t\t\t\t\ttotalTimeMs: Math.round(total),\n\t\t\t\t\tevents: times,\n\t\t\t\t\tcpuUsageDiffMs,\n\t\t\t\t\tmemoryUsageDiff,\n\t\t\t\t\tresponseBodySize: ctx.body && typeof ctx.body === 'string' ? ctx.body.length : undefined,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tif (ctx.body instanceof Readable) {\n\t\t\t\tconst body = ctx.body\n\t\t\t\tconst streamTimer = timer('Stream', () => {\n\t\t\t\t\treturn new Promise(resolve => {\n\t\t\t\t\t\tbody.addListener('close', () => {\n\t\t\t\t\t\t\tresolve(null)\n\t\t\t\t\t\t})\n\t\t\t\t\t})\n\t\t\t\t})\n\n\t\t\t\tstreamTimer.then(emit).catch(emit)\n\t\t\t} else {\n\t\t\t\temit()\n\t\t\t}\n\t\t}\n\t\treturn { timer, send }\n\t}\n\n\tprivate matchRequest<C>(routes: Route<C>[], url: URL): MatchedRequest<C> | null {\n\t\tfor (const route of routes) {\n\t\t\tconst params = route.match({ url })\n\t\t\tif (params !== null) {\n\t\t\t\treturn { params, controller: route.controller, module: route.module }\n\t\t\t}\n\t\t}\n\t\treturn null\n\t}\n}\n\ntype EventTime = { label: string; start: number; duration?: number }\n\nexport type Timer = <T>(event: string, cb: () => T) => T\n\nexport type MatchedRequest<C> = { params: Params; controller: C; module: string }\n\nexport type BaseRequestContext = {\n\tlogger: Logger\n\trequest: IncomingMessage\n\turl: URL\n\tparams: Params\n\tclientIp: string\n}\n\nexport type ApplicationContext =\n\t& BaseRequestContext\n\t& {\n\t\tprojectGroup: ProjectGroupContainer\n\t\tauthResult: AuthResult | null\n\t\ttimer: Timer\n\t}\n\nexport type BaseHttpRequestContext = {\n\tkoa: KoaContext<{}>\n\tbody: unknown\n\tresponse: ServerResponse\n}\n\nexport type HttpContext =\n\t& ApplicationContext\n\t& BaseHttpRequestContext\n\t& {\n\t\trequestDebugMode: boolean\n\t}\n\nexport type InternalHttpContext =\n\t& BaseRequestContext\n\t& BaseHttpRequestContext\n\nexport type WebSocketContext =\n\t& ApplicationContext\n\t& {\n\t\tws: WebSocket\n\t\tabortSignal: AbortSignal\n\t}\n\nexport type HttpControllerResponse = Promise<HttpErrorResponse | undefined | void> | HttpErrorResponse | undefined | void\nexport type HttpController = (context: HttpContext) => HttpControllerResponse\nexport type InternalHttpController = (context: InternalHttpContext) => HttpControllerResponse\n\nexport type WebSocketController = (context: WebSocketContext) => void\n\ntype Params = { [param: string]: string }\n\ntype RequestMatcher = (args: { url: URL }) => Params | null\nconst createRequestMatcher = (\n\tmask: string,\n): RequestMatcher => {\n\tconst { regexp, keys } = pathToRegexp(mask)\n\n\tconst match = function(url: string): Params | null {\n\t\tconst match = regexp.exec(url)\n\t\tif (match) {\n\t\t\treturn match.slice(1).reduce((acc, value, i) => ({ ...acc, [keys[i].name]: value }), {})\n\t\t}\n\t\treturn null\n\t}\n\n\treturn request => {\n\t\treturn match(request.url.pathname)\n\t}\n}\n\nexport const LoggerRequestBody = Symbol('RequestBody')\n\nexport interface RunningApplication {\n\tclose(): Promise<void>\n\treadonly server: Server\n}\n"],"names":["ws","match"],"mappings":";;;;;;;;;;;;;;;;;AAqBO,MAAM,YAAY;AAAA,EASxB,YACkB,sBACA,cACA,WACA,SACA,QAChB;AALgB,SAAA,uBAAA;AACA,SAAA,eAAA;AACA,SAAA,YAAA;AACA,SAAA,UAAA;AACA,SAAA,SAAA;AAblB,kBAAA,MAAQ,eAAoC,EAAC;AAE7C,kBAAA,MAAQ,UAAkC,EAAC;AAC3C,kBAAA,MAAQ,kBAAkD,EAAC;AAC3D,kBAAA,MAAQ,mBAAgD,EAAC;AAEzD,kBAAA,MAAQ,mBAAA;AASP,UAAM,uBAAuB,aAAa,MAAM;AAChD,SAAK,oBAAoB,yBAAyB,OAAO,OAAO,uBAAuB,IAAI,OAAO,oBAAoB,IAAI;AAAA,EAC3H;AAAA,EAEA,cAAc,YAAgC;AAC7C,SAAK,YAAY,KAAK,UAAU;AAAA,EACjC;AAAA,EAEO,SAAS,QAAgB,MAAc,YAAkC;AAC/E,SAAK,OAAO,KAAK;AAAA,MAChB;AAAA,MACA;AAAA,MACA,OAAO,qBAAqB,IAAI;AAAA,IAAA,CAChC;AAAA,EACF;AAAA,EAEO,iBAAiB,QAAgB,MAAc,YAA0C;AAC/F,SAAK,eAAe,KAAK;AAAA,MACxB;AAAA,MACA;AAAA,MACA,OAAO,qBAAqB,IAAI;AAAA,IAAA,CAChC;AAAA,EACF;AAAA,EAEO,kBAAkB,QAAgB,MAAc,YAAuC;AAC7F,SAAK,gBAAgB,KAAK;AAAA,MACzB;AA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AAA,EAEQ,aAAgB,QAAoB,KAAoC;AAC/E,eAAW,SAAS,QAAQ;AAC3B,YAAM,SAAS,MAAM,MAAM,EAAE,KAAK;AAClC,UAAI,WAAW,MAAM;AACpB,eAAO,EAAE,QAAQ,YAAY,MAAM,YAAY,QAAQ,MAAM,OAAA;AAAA,MAC9D;AAAA,IACD;AACA,WAAO;AAAA,EACR;AACD;AAyDA,MAAM,uBAAuB,CAC5B,SACoB;AACpB,QAAM,EAAE,QAAQ,SAAS,aAAa,IAAI;AAE1C,QAAM,QAAQ,SAAS,KAA4B;AAClD,UAAMC,SAAQ,OAAO,KAAK,GAAG;AAC7B,QAAIA,QAAO;AACV,aAAOA,OAAM,MAAM,CAAC,EAAE,OAAO,CAAC,KAAK,OAAO,OAAO,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,IAAI,GAAG,MAAA,IAAU,EAAE;AAAA,IACxF;AACA,WAAO;AAAA,EACR;AAEA,SAAO,CAAA,YAAW;AACjB,WAAO,MAAM,QAAQ,IAAI,QAAQ;AAAA,EAClC;AACD;AAEO,MAAM,2CAA2B,aAAa;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Initializer.cjs","sources":["../../../../../packages/engine-http/src/bootstrap/Initializer.ts"],"sourcesContent":["import { ProjectGroupContainer } from '../projectGroup/ProjectGroupContainer'\n\nexport class Initializer {\n\tconstructor(\n\t\tprivate readonly projectGroupContainer: ProjectGroupContainer,\n\t) {}\n\n\tpublic async initialize(): Promise<string[]> {\n\t\tconst groupContainer = await this.projectGroupContainer\n\t\tconst tenantMigrationsLogger = groupContainer.logger.child()\n\t\tconst tenantContainer = groupContainer.tenantContainer\n\t\tawait tenantContainer.migrationsRunner.run(tenantMigrationsLogger)\n\n\t\tconst projects: string[] = []\n\n\t\tconst tenantProjects = await tenantContainer.projectManager.getProjects(tenantContainer.databaseContext)\n\t\tfor (const { slug: projectSlug } of tenantProjects) {\n\t\t\tconst projectContainer = await groupContainer.projectContainerResolver.getProjectContainer(projectSlug, { alias: false })\n\t\t\tif (!projectContainer) {\n\t\t\t\tthrow new Error()\n\t\t\t}\n\t\t\tconst project = projectContainer.project\n\t\t\tprojects.push(project.slug)\n\t\t}\n\t\treturn projects\n\t}\n}\n"],"names":[],"mappings":";;AAEO,MAAM,YAAY;AAAA,EACxB,YACkB,uBAChB;AADgB,SAAA,wBAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"Initializer.cjs","sources":["../../../../../packages/engine-http/src/bootstrap/Initializer.ts"],"sourcesContent":["import { ProjectGroupContainer } from '../projectGroup/ProjectGroupContainer'\n\nexport class Initializer {\n\tconstructor(\n\t\tprivate readonly projectGroupContainer: ProjectGroupContainer,\n\t) {}\n\n\tpublic async initialize(): Promise<string[]> {\n\t\tconst groupContainer = await this.projectGroupContainer\n\t\tconst tenantMigrationsLogger = groupContainer.logger.child()\n\t\tconst tenantContainer = groupContainer.tenantContainer\n\t\tawait tenantContainer.migrationsRunner.run(tenantMigrationsLogger)\n\n\t\tconst projects: string[] = []\n\n\t\tconst tenantProjects = await tenantContainer.projectManager.getProjects(tenantContainer.databaseContext)\n\t\tfor (const { slug: projectSlug } of tenantProjects) {\n\t\t\tconst projectContainer = await groupContainer.projectContainerResolver.getProjectContainer(projectSlug, { alias: false })\n\t\t\tif (!projectContainer) {\n\t\t\t\tthrow new Error()\n\t\t\t}\n\t\t\tconst project = projectContainer.project\n\t\t\tprojects.push(project.slug)\n\t\t}\n\t\treturn projects\n\t}\n}\n"],"names":[],"mappings":";;AAEO,MAAM,YAAY;AAAA,EACxB,YACkB,uBAChB;AADgB,SAAA,wBAAA;AAAA,EACf;AAAA,EAEH,MAAa,aAAgC;AAC5C,UAAM,iBAAiB,MAAM,KAAK;AAClC,UAAM,yBAAyB,eAAe,OAAO,MAAA;AACrD,UAAM,kBAAkB,eAAe;AACvC,UAAM,gBAAgB,iBAAiB,IAAI,sBAAsB;AAEjE,UAAM,WAAqB,CAAA;AAE3B,UAAM,iBAAiB,MAAM,gBAAgB,eAAe,YAAY,gBAAgB,eAAe;AACvG,eAAW,EAAE,MAAM,YAAA,KAAiB,gBAAgB;AACnD,YAAM,mBAAmB,MAAM,eAAe,yBAAyB,oBAAoB,aAAa,EAAE,OAAO,OAAO;AACxH,UAAI,CAAC,kBAAkB;AACtB,cAAM,IAAI,MAAA;AAAA,MACX;AACA,YAAM,UAAU,iBAAiB;AACjC,eAAS,KAAK,QAAQ,IAAI;AAAA,IAC3B;AACA,WAAO;AAAA,EACR;AACD;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Initializer.js","sources":["../../../../../packages/engine-http/src/bootstrap/Initializer.ts"],"sourcesContent":["import { ProjectGroupContainer } from '../projectGroup/ProjectGroupContainer'\n\nexport class Initializer {\n\tconstructor(\n\t\tprivate readonly projectGroupContainer: ProjectGroupContainer,\n\t) {}\n\n\tpublic async initialize(): Promise<string[]> {\n\t\tconst groupContainer = await this.projectGroupContainer\n\t\tconst tenantMigrationsLogger = groupContainer.logger.child()\n\t\tconst tenantContainer = groupContainer.tenantContainer\n\t\tawait tenantContainer.migrationsRunner.run(tenantMigrationsLogger)\n\n\t\tconst projects: string[] = []\n\n\t\tconst tenantProjects = await tenantContainer.projectManager.getProjects(tenantContainer.databaseContext)\n\t\tfor (const { slug: projectSlug } of tenantProjects) {\n\t\t\tconst projectContainer = await groupContainer.projectContainerResolver.getProjectContainer(projectSlug, { alias: false })\n\t\t\tif (!projectContainer) {\n\t\t\t\tthrow new Error()\n\t\t\t}\n\t\t\tconst project = projectContainer.project\n\t\t\tprojects.push(project.slug)\n\t\t}\n\t\treturn projects\n\t}\n}\n"],"names":[],"mappings":"AAEO,MAAM,YAAY;AAAA,EACxB,YACkB,uBAChB;AADgB,SAAA,wBAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"Initializer.js","sources":["../../../../../packages/engine-http/src/bootstrap/Initializer.ts"],"sourcesContent":["import { ProjectGroupContainer } from '../projectGroup/ProjectGroupContainer'\n\nexport class Initializer {\n\tconstructor(\n\t\tprivate readonly projectGroupContainer: ProjectGroupContainer,\n\t) {}\n\n\tpublic async initialize(): Promise<string[]> {\n\t\tconst groupContainer = await this.projectGroupContainer\n\t\tconst tenantMigrationsLogger = groupContainer.logger.child()\n\t\tconst tenantContainer = groupContainer.tenantContainer\n\t\tawait tenantContainer.migrationsRunner.run(tenantMigrationsLogger)\n\n\t\tconst projects: string[] = []\n\n\t\tconst tenantProjects = await tenantContainer.projectManager.getProjects(tenantContainer.databaseContext)\n\t\tfor (const { slug: projectSlug } of tenantProjects) {\n\t\t\tconst projectContainer = await groupContainer.projectContainerResolver.getProjectContainer(projectSlug, { alias: false })\n\t\t\tif (!projectContainer) {\n\t\t\t\tthrow new Error()\n\t\t\t}\n\t\t\tconst project = projectContainer.project\n\t\t\tprojects.push(project.slug)\n\t\t}\n\t\treturn projects\n\t}\n}\n"],"names":[],"mappings":"AAEO,MAAM,YAAY;AAAA,EACxB,YACkB,uBAChB;AADgB,SAAA,wBAAA;AAAA,EACf;AAAA,EAEH,MAAa,aAAgC;AAC5C,UAAM,iBAAiB,MAAM,KAAK;AAClC,UAAM,yBAAyB,eAAe,OAAO,MAAA;AACrD,UAAM,kBAAkB,eAAe;AACvC,UAAM,gBAAgB,iBAAiB,IAAI,sBAAsB;AAEjE,UAAM,WAAqB,CAAA;AAE3B,UAAM,iBAAiB,MAAM,gBAAgB,eAAe,YAAY,gBAAgB,eAAe;AACvG,eAAW,EAAE,MAAM,YAAA,KAAiB,gBAAgB;AACnD,YAAM,mBAAmB,MAAM,eAAe,yBAAyB,oBAAoB,aAAa,EAAE,OAAO,OAAO;AACxH,UAAI,CAAC,kBAAkB;AACtB,cAAM,IAAI,MAAA;AAAA,MACX;AACA,YAAM,UAAU,iBAAiB;AACjC,eAAS,KAAK,QAAQ,IAAI;AAAA,IAC3B;AACA,WAAO;AAAA,EACR;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Authorizator.cjs","sources":["../../../../../packages/engine-http/src/common/Authorizator.ts"],"sourcesContent":["import { ApiKeyManager, DatabaseContext, VerifyResult } from '@contember/engine-tenant-api'\nimport { HttpErrorResponse } from './HttpResponse'\nimport { Timer } from '../application'\nimport { IncomingMessage } from 'node:http'\n\nexport type AuthResult =\n\t& VerifyResult\n\t& { assumedIdentityId?: string }\n\nconst assumeIdentityHeader = 'x-contember-assume-identity'\n\nexport class Authenticator {\n\tprivate createAuthError = (message: string) => new HttpErrorResponse(401, `Authorization failure: ${message}`)\n\n\tconstructor(\n\t\tprivate readonly tenantDatabase: DatabaseContext,\n\t\tprivate readonly tenantReadDatabase: DatabaseContext,\n\t\tprivate readonly apiKeyManager: ApiKeyManager,\n\t) {\n\t}\n\n\tpublic async authenticate({ request, timer }: { request: IncomingMessage; timer: Timer }): Promise<AuthResult | null> {\n\t\tconst authHeader = request.headers.authorization\n\t\tif (!authHeader) {\n\t\t\treturn null\n\t\t}\n\n\t\tconst authHeaderPattern = /^Bearer\\s+(\\w+)$/i\n\n\t\tconst match = authHeader.match(authHeaderPattern)\n\t\tif (match === null) {\n\t\t\tthrow this.createAuthError(`invalid Authorization header format`)\n\t\t}\n\t\tconst [, token] = match\n\t\tconst authResult = await timer('Auth', () => this.apiKeyManager.verifyAndProlong(this.tenantDatabase, this.tenantReadDatabase, token))\n\t\tif (!authResult.ok) {\n\t\t\tthrow this.createAuthError(authResult.errorMessage)\n\t\t}\n\t\tconst assumedIdentityId = request.headers[assumeIdentityHeader] ?? undefined\n\t\tif (Array.isArray(assumedIdentityId)) {\n\t\t\tthrow new HttpErrorResponse(400, `Invalid ${assumedIdentityId} header format`)\n\t\t}\n\t\treturn {\n\t\t\t...authResult.result,\n\t\t\tassumedIdentityId,\n\t\t}\n\t}\n}\n"],"names":["HttpErrorResponse"],"mappings":";;;;;;AASA,MAAM,uBAAuB;AAEtB,MAAM,cAAc;AAAA,EAG1B,YACkB,gBACA,oBACA,eAChB;AAHgB,SAAA,iBAAA;AACA,SAAA,qBAAA;AACA,SAAA,gBAAA;
|
|
1
|
+
{"version":3,"file":"Authorizator.cjs","sources":["../../../../../packages/engine-http/src/common/Authorizator.ts"],"sourcesContent":["import { ApiKeyManager, DatabaseContext, VerifyResult } from '@contember/engine-tenant-api'\nimport { HttpErrorResponse } from './HttpResponse'\nimport { Timer } from '../application'\nimport { IncomingMessage } from 'node:http'\n\nexport type AuthResult =\n\t& VerifyResult\n\t& { assumedIdentityId?: string }\n\nconst assumeIdentityHeader = 'x-contember-assume-identity'\n\nexport class Authenticator {\n\tprivate createAuthError = (message: string) => new HttpErrorResponse(401, `Authorization failure: ${message}`)\n\n\tconstructor(\n\t\tprivate readonly tenantDatabase: DatabaseContext,\n\t\tprivate readonly tenantReadDatabase: DatabaseContext,\n\t\tprivate readonly apiKeyManager: ApiKeyManager,\n\t) {\n\t}\n\n\tpublic async authenticate({ request, timer }: { request: IncomingMessage; timer: Timer }): Promise<AuthResult | null> {\n\t\tconst authHeader = request.headers.authorization\n\t\tif (!authHeader) {\n\t\t\treturn null\n\t\t}\n\n\t\tconst authHeaderPattern = /^Bearer\\s+(\\w+)$/i\n\n\t\tconst match = authHeader.match(authHeaderPattern)\n\t\tif (match === null) {\n\t\t\tthrow this.createAuthError(`invalid Authorization header format`)\n\t\t}\n\t\tconst [, token] = match\n\t\tconst authResult = await timer('Auth', () => this.apiKeyManager.verifyAndProlong(this.tenantDatabase, this.tenantReadDatabase, token))\n\t\tif (!authResult.ok) {\n\t\t\tthrow this.createAuthError(authResult.errorMessage)\n\t\t}\n\t\tconst assumedIdentityId = request.headers[assumeIdentityHeader] ?? undefined\n\t\tif (Array.isArray(assumedIdentityId)) {\n\t\t\tthrow new HttpErrorResponse(400, `Invalid ${assumedIdentityId} header format`)\n\t\t}\n\t\treturn {\n\t\t\t...authResult.result,\n\t\t\tassumedIdentityId,\n\t\t}\n\t}\n}\n"],"names":["HttpErrorResponse"],"mappings":";;;;;;AASA,MAAM,uBAAuB;AAEtB,MAAM,cAAc;AAAA,EAG1B,YACkB,gBACA,oBACA,eAChB;AAHgB,SAAA,iBAAA;AACA,SAAA,qBAAA;AACA,SAAA,gBAAA;AALlB,kBAAA,MAAQ,mBAAkB,CAAC,YAAoB,IAAIA,+BAAkB,KAAK,0BAA0B,OAAO,EAAE,CAAA;AAAA,EAO7G;AAAA,EAEA,MAAa,aAAa,EAAE,SAAS,SAAiF;AACrH,UAAM,aAAa,QAAQ,QAAQ;AACnC,QAAI,CAAC,YAAY;AAChB,aAAO;AAAA,IACR;AAEA,UAAM,oBAAoB;AAE1B,UAAM,QAAQ,WAAW,MAAM,iBAAiB;AAChD,QAAI,UAAU,MAAM;AACnB,YAAM,KAAK,gBAAgB,qCAAqC;AAAA,IACjE;AACA,UAAM,CAAA,EAAG,KAAK,IAAI;AAClB,UAAM,aAAa,MAAM,MAAM,QAAQ,MAAM,KAAK,cAAc,iBAAiB,KAAK,gBAAgB,KAAK,oBAAoB,KAAK,CAAC;AACrI,QAAI,CAAC,WAAW,IAAI;AACnB,YAAM,KAAK,gBAAgB,WAAW,YAAY;AAAA,IACnD;AACA,UAAM,oBAAoB,QAAQ,QAAQ,oBAAoB,KAAK;AACnE,QAAI,MAAM,QAAQ,iBAAiB,GAAG;AACrC,YAAM,IAAIA,aAAAA,kBAAkB,KAAK,WAAW,iBAAiB,gBAAgB;AAAA,IAC9E;AACA,WAAO;AAAA,MACN,GAAG,WAAW;AAAA,MACd;AAAA,IAAA;AAAA,EAEF;AACD;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Authorizator.js","sources":["../../../../../packages/engine-http/src/common/Authorizator.ts"],"sourcesContent":["import { ApiKeyManager, DatabaseContext, VerifyResult } from '@contember/engine-tenant-api'\nimport { HttpErrorResponse } from './HttpResponse'\nimport { Timer } from '../application'\nimport { IncomingMessage } from 'node:http'\n\nexport type AuthResult =\n\t& VerifyResult\n\t& { assumedIdentityId?: string }\n\nconst assumeIdentityHeader = 'x-contember-assume-identity'\n\nexport class Authenticator {\n\tprivate createAuthError = (message: string) => new HttpErrorResponse(401, `Authorization failure: ${message}`)\n\n\tconstructor(\n\t\tprivate readonly tenantDatabase: DatabaseContext,\n\t\tprivate readonly tenantReadDatabase: DatabaseContext,\n\t\tprivate readonly apiKeyManager: ApiKeyManager,\n\t) {\n\t}\n\n\tpublic async authenticate({ request, timer }: { request: IncomingMessage; timer: Timer }): Promise<AuthResult | null> {\n\t\tconst authHeader = request.headers.authorization\n\t\tif (!authHeader) {\n\t\t\treturn null\n\t\t}\n\n\t\tconst authHeaderPattern = /^Bearer\\s+(\\w+)$/i\n\n\t\tconst match = authHeader.match(authHeaderPattern)\n\t\tif (match === null) {\n\t\t\tthrow this.createAuthError(`invalid Authorization header format`)\n\t\t}\n\t\tconst [, token] = match\n\t\tconst authResult = await timer('Auth', () => this.apiKeyManager.verifyAndProlong(this.tenantDatabase, this.tenantReadDatabase, token))\n\t\tif (!authResult.ok) {\n\t\t\tthrow this.createAuthError(authResult.errorMessage)\n\t\t}\n\t\tconst assumedIdentityId = request.headers[assumeIdentityHeader] ?? undefined\n\t\tif (Array.isArray(assumedIdentityId)) {\n\t\t\tthrow new HttpErrorResponse(400, `Invalid ${assumedIdentityId} header format`)\n\t\t}\n\t\treturn {\n\t\t\t...authResult.result,\n\t\t\tassumedIdentityId,\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;AASA,MAAM,uBAAuB;AAEtB,MAAM,cAAc;AAAA,EAG1B,YACkB,gBACA,oBACA,eAChB;AAHgB,SAAA,iBAAA;AACA,SAAA,qBAAA;AACA,SAAA,gBAAA;
|
|
1
|
+
{"version":3,"file":"Authorizator.js","sources":["../../../../../packages/engine-http/src/common/Authorizator.ts"],"sourcesContent":["import { ApiKeyManager, DatabaseContext, VerifyResult } from '@contember/engine-tenant-api'\nimport { HttpErrorResponse } from './HttpResponse'\nimport { Timer } from '../application'\nimport { IncomingMessage } from 'node:http'\n\nexport type AuthResult =\n\t& VerifyResult\n\t& { assumedIdentityId?: string }\n\nconst assumeIdentityHeader = 'x-contember-assume-identity'\n\nexport class Authenticator {\n\tprivate createAuthError = (message: string) => new HttpErrorResponse(401, `Authorization failure: ${message}`)\n\n\tconstructor(\n\t\tprivate readonly tenantDatabase: DatabaseContext,\n\t\tprivate readonly tenantReadDatabase: DatabaseContext,\n\t\tprivate readonly apiKeyManager: ApiKeyManager,\n\t) {\n\t}\n\n\tpublic async authenticate({ request, timer }: { request: IncomingMessage; timer: Timer }): Promise<AuthResult | null> {\n\t\tconst authHeader = request.headers.authorization\n\t\tif (!authHeader) {\n\t\t\treturn null\n\t\t}\n\n\t\tconst authHeaderPattern = /^Bearer\\s+(\\w+)$/i\n\n\t\tconst match = authHeader.match(authHeaderPattern)\n\t\tif (match === null) {\n\t\t\tthrow this.createAuthError(`invalid Authorization header format`)\n\t\t}\n\t\tconst [, token] = match\n\t\tconst authResult = await timer('Auth', () => this.apiKeyManager.verifyAndProlong(this.tenantDatabase, this.tenantReadDatabase, token))\n\t\tif (!authResult.ok) {\n\t\t\tthrow this.createAuthError(authResult.errorMessage)\n\t\t}\n\t\tconst assumedIdentityId = request.headers[assumeIdentityHeader] ?? undefined\n\t\tif (Array.isArray(assumedIdentityId)) {\n\t\t\tthrow new HttpErrorResponse(400, `Invalid ${assumedIdentityId} header format`)\n\t\t}\n\t\treturn {\n\t\t\t...authResult.result,\n\t\t\tassumedIdentityId,\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;AASA,MAAM,uBAAuB;AAEtB,MAAM,cAAc;AAAA,EAG1B,YACkB,gBACA,oBACA,eAChB;AAHgB,SAAA,iBAAA;AACA,SAAA,qBAAA;AACA,SAAA,gBAAA;AALlB,kBAAA,MAAQ,mBAAkB,CAAC,YAAoB,IAAI,kBAAkB,KAAK,0BAA0B,OAAO,EAAE,CAAA;AAAA,EAO7G;AAAA,EAEA,MAAa,aAAa,EAAE,SAAS,SAAiF;AACrH,UAAM,aAAa,QAAQ,QAAQ;AACnC,QAAI,CAAC,YAAY;AAChB,aAAO;AAAA,IACR;AAEA,UAAM,oBAAoB;AAE1B,UAAM,QAAQ,WAAW,MAAM,iBAAiB;AAChD,QAAI,UAAU,MAAM;AACnB,YAAM,KAAK,gBAAgB,qCAAqC;AAAA,IACjE;AACA,UAAM,CAAA,EAAG,KAAK,IAAI;AAClB,UAAM,aAAa,MAAM,MAAM,QAAQ,MAAM,KAAK,cAAc,iBAAiB,KAAK,gBAAgB,KAAK,oBAAoB,KAAK,CAAC;AACrI,QAAI,CAAC,WAAW,IAAI;AACnB,YAAM,KAAK,gBAAgB,WAAW,YAAY;AAAA,IACnD;AACA,UAAM,oBAAoB,QAAQ,QAAQ,oBAAoB,KAAK;AACnE,QAAI,MAAM,QAAQ,iBAAiB,GAAG;AACrC,YAAM,IAAI,kBAAkB,KAAK,WAAW,iBAAiB,gBAAgB;AAAA,IAC9E;AACA,WAAO;AAAA,MACN,GAAG,WAAW;AAAA,MACd;AAAA,IAAA;AAAA,EAEF;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpResponse.cjs","sources":["../../../../../packages/engine-http/src/common/HttpResponse.ts"],"sourcesContent":["export class HttpResponse {\n\tconstructor(\n\t\tpublic readonly code: number,\n\t\tpublic readonly body?: string,\n\t\tpublic readonly contentType?: string,\n\t) {\n\t}\n}\n\nexport class HttpErrorResponse extends HttpResponse {\n\tconstructor(\n\t\tcode: number,\n\t\tpublic readonly message?: string,\n\t) {\n\t\tsuper(\n\t\t\tcode,\n\t\t\tmessage ? JSON.stringify({ errors: [{ code, message }] }) : undefined,\n\t\t\t'application/json',\n\t\t)\n\t}\n}\n"],"names":[],"mappings":";;AAAO,MAAM,aAAa;AAAA,EACzB,YACiB,MACA,MACA,aACf;AAHe,SAAA,OAAA;AACA,SAAA,OAAA;AACA,SAAA,cAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"HttpResponse.cjs","sources":["../../../../../packages/engine-http/src/common/HttpResponse.ts"],"sourcesContent":["export class HttpResponse {\n\tconstructor(\n\t\tpublic readonly code: number,\n\t\tpublic readonly body?: string,\n\t\tpublic readonly contentType?: string,\n\t) {\n\t}\n}\n\nexport class HttpErrorResponse extends HttpResponse {\n\tconstructor(\n\t\tcode: number,\n\t\tpublic readonly message?: string,\n\t) {\n\t\tsuper(\n\t\t\tcode,\n\t\t\tmessage ? JSON.stringify({ errors: [{ code, message }] }) : undefined,\n\t\t\t'application/json',\n\t\t)\n\t}\n}\n"],"names":[],"mappings":";;AAAO,MAAM,aAAa;AAAA,EACzB,YACiB,MACA,MACA,aACf;AAHe,SAAA,OAAA;AACA,SAAA,OAAA;AACA,SAAA,cAAA;AAAA,EAEjB;AACD;AAEO,MAAM,0BAA0B,aAAa;AAAA,EACnD,YACC,MACgB,SACf;AACD;AAAA,MACC;AAAA,MACA,UAAU,KAAK,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,QAAA,CAAS,EAAA,CAAG,IAAI;AAAA,MAC5D;AAAA,IAAA;AALe,SAAA,UAAA;AAAA,EAOjB;AACD;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpResponse.js","sources":["../../../../../packages/engine-http/src/common/HttpResponse.ts"],"sourcesContent":["export class HttpResponse {\n\tconstructor(\n\t\tpublic readonly code: number,\n\t\tpublic readonly body?: string,\n\t\tpublic readonly contentType?: string,\n\t) {\n\t}\n}\n\nexport class HttpErrorResponse extends HttpResponse {\n\tconstructor(\n\t\tcode: number,\n\t\tpublic readonly message?: string,\n\t) {\n\t\tsuper(\n\t\t\tcode,\n\t\t\tmessage ? JSON.stringify({ errors: [{ code, message }] }) : undefined,\n\t\t\t'application/json',\n\t\t)\n\t}\n}\n"],"names":[],"mappings":"AAAO,MAAM,aAAa;AAAA,EACzB,YACiB,MACA,MACA,aACf;AAHe,SAAA,OAAA;AACA,SAAA,OAAA;AACA,SAAA,cAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"HttpResponse.js","sources":["../../../../../packages/engine-http/src/common/HttpResponse.ts"],"sourcesContent":["export class HttpResponse {\n\tconstructor(\n\t\tpublic readonly code: number,\n\t\tpublic readonly body?: string,\n\t\tpublic readonly contentType?: string,\n\t) {\n\t}\n}\n\nexport class HttpErrorResponse extends HttpResponse {\n\tconstructor(\n\t\tcode: number,\n\t\tpublic readonly message?: string,\n\t) {\n\t\tsuper(\n\t\t\tcode,\n\t\t\tmessage ? JSON.stringify({ errors: [{ code, message }] }) : undefined,\n\t\t\t'application/json',\n\t\t)\n\t}\n}\n"],"names":[],"mappings":"AAAO,MAAM,aAAa;AAAA,EACzB,YACiB,MACA,MACA,aACf;AAHe,SAAA,OAAA;AACA,SAAA,OAAA;AACA,SAAA,cAAA;AAAA,EAEjB;AACD;AAEO,MAAM,0BAA0B,aAAa;AAAA,EACnD,YACC,MACgB,SACf;AACD;AAAA,MACC;AAAA,MACA,UAAU,KAAK,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,QAAA,CAAS,EAAA,CAAG,IAAI;AAAA,MAC5D;AAAA,IAAA;AALe,SAAA,UAAA;AAAA,EAOjB;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModuleInfoMiddleware.cjs","sources":["../../../../../packages/engine-http/src/common/ModuleInfoMiddleware.ts"],"sourcesContent":["import { KoaMiddleware } from '../application'\n\nexport interface ModuleInfoMiddlewareState {\n\tmodule: string\n}\n\nexport const createModuleInfoMiddleware = (module: string): KoaMiddleware<ModuleInfoMiddlewareState> => {\n\treturn (ctx, next) => {\n\t\tctx.state.module = module\n\t\treturn next()\n\t}\n}\n"],"names":["module"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"ModuleInfoMiddleware.cjs","sources":["../../../../../packages/engine-http/src/common/ModuleInfoMiddleware.ts"],"sourcesContent":["import { KoaMiddleware } from '../application'\n\nexport interface ModuleInfoMiddlewareState {\n\tmodule: string\n}\n\nexport const createModuleInfoMiddleware = (module: string): KoaMiddleware<ModuleInfoMiddlewareState> => {\n\treturn (ctx, next) => {\n\t\tctx.state.module = module\n\t\treturn next()\n\t}\n}\n"],"names":["module"],"mappings":";;AAMO,MAAM,6BAA6B,CAACA,YAA6D;AACvG,SAAO,CAAC,KAAK,SAAS;AACrB,QAAI,MAAM,SAASA;AACnB,WAAO,KAAA;AAAA,EACR;AACD;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModuleInfoMiddleware.js","sources":["../../../../../packages/engine-http/src/common/ModuleInfoMiddleware.ts"],"sourcesContent":["import { KoaMiddleware } from '../application'\n\nexport interface ModuleInfoMiddlewareState {\n\tmodule: string\n}\n\nexport const createModuleInfoMiddleware = (module: string): KoaMiddleware<ModuleInfoMiddlewareState> => {\n\treturn (ctx, next) => {\n\t\tctx.state.module = module\n\t\treturn next()\n\t}\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ModuleInfoMiddleware.js","sources":["../../../../../packages/engine-http/src/common/ModuleInfoMiddleware.ts"],"sourcesContent":["import { KoaMiddleware } from '../application'\n\nexport interface ModuleInfoMiddlewareState {\n\tmodule: string\n}\n\nexport const createModuleInfoMiddleware = (module: string): KoaMiddleware<ModuleInfoMiddlewareState> => {\n\treturn (ctx, next) => {\n\t\tctx.state.module = module\n\t\treturn next()\n\t}\n}\n"],"names":[],"mappings":"AAMO,MAAM,6BAA6B,CAAC,WAA6D;AACvG,SAAO,CAAC,KAAK,SAAS;AACrB,QAAI,MAAM,SAAS;AACnB,WAAO,KAAA;AAAA,EACR;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.cjs","sources":["../../../../../packages/engine-http/src/config/config.ts"],"sourcesContent":["import { ConfigLoader, createObjectParametersResolver, Merger, resolveParameters } from '@contember/config-loader'\n\nimport { serverConfigSchema as defaultServerConfigSchema, tenantConfigSchema } from './configSchema'\nimport { configTemplate } from './configTemplate'\nimport { createProjectConfigResolver, ProjectConfigResolver } from './projectConfigResolver'\nimport { createTenantConfigResolver, TenantConfigResolver } from './tenantConfigResolver'\nimport { Type } from '@contember/typesafe'\nimport { ConfigProcessor } from './ConfigProcessor'\n\nexport type ServerConfig = ReturnType<typeof defaultServerConfigSchema>\nexport type TenantConfig = ReturnType<typeof tenantConfigSchema>\n\nexport type ConfigSource = { data: string; type: 'file' | 'json' | 'yaml' }\n\nexport type Env = Record<string, string>\n\nexport async function readConfig<T extends ServerConfig>(\n\tconfigSources: ConfigSource[] = [],\n\tconfigProcessors: ConfigProcessor<any>[] = [],\n\tserverConfigSchema: Type<T> = defaultServerConfigSchema as Type<T>,\n): Promise<{\n\tserverConfig: T\n\tprojectConfigResolver: ProjectConfigResolver\n\ttenantConfigResolver: TenantConfigResolver\n}> {\n\tconst loader = new ConfigLoader()\n\tconst configs = await Promise.all(\n\t\tconfigSources.map(it => (it.type === 'file' ? loader.load(it.data) : loader.loadString(it.data, it.type))),\n\t)\n\tconst env: Env = {\n\t\t...configProcessors.reduce((acc, curr) => ({ ...acc, ...(curr.getDefaultEnv?.() || {}) }), {\n\t\t\tDEFAULT_DB_PORT: '5432',\n\t\t}),\n\t\t...Object.fromEntries(Object.entries(process.env).filter((it): it is [string, string] => it[1] !== undefined)),\n\t}\n\n\tconst template = configProcessors.reduce(\n\t\t(tpl, processor) => processor.prepareConfigTemplate?.(tpl, { env }) || tpl,\n\t\tconfigTemplate,\n\t)\n\n\tconst rawConfig = Merger.merge(template, ...configs)\n\n\tconst parametersResolver = createObjectParametersResolver({ env })\n\tconst config = resolveParameters(rawConfig.server, parametersResolver)\n\n\tconst serverConfig = serverConfigSchema(config)\n\treturn {\n\t\tserverConfig,\n\t\tprojectConfigResolver: createProjectConfigResolver(env, rawConfig, configProcessors),\n\t\ttenantConfigResolver: createTenantConfigResolver(env, rawConfig.tenant),\n\t}\n}\n
|
|
1
|
+
{"version":3,"file":"config.cjs","sources":["../../../../../packages/engine-http/src/config/config.ts"],"sourcesContent":["import { ConfigLoader, createObjectParametersResolver, Merger, resolveParameters } from '@contember/config-loader'\n\nimport { serverConfigSchema as defaultServerConfigSchema, tenantConfigSchema } from './configSchema'\nimport { configTemplate } from './configTemplate'\nimport { createProjectConfigResolver, ProjectConfigResolver } from './projectConfigResolver'\nimport { createTenantConfigResolver, TenantConfigResolver } from './tenantConfigResolver'\nimport { Type } from '@contember/typesafe'\nimport { ConfigProcessor } from './ConfigProcessor'\n\nexport type ServerConfig = ReturnType<typeof defaultServerConfigSchema>\nexport type TenantConfig = ReturnType<typeof tenantConfigSchema>\n\nexport type ConfigSource = { data: string; type: 'file' | 'json' | 'yaml' }\n\nexport type Env = Record<string, string>\n\nexport async function readConfig<T extends ServerConfig>(\n\tconfigSources: ConfigSource[] = [],\n\tconfigProcessors: ConfigProcessor<any>[] = [],\n\tserverConfigSchema: Type<T> = defaultServerConfigSchema as Type<T>,\n): Promise<{\n\tserverConfig: T\n\tprojectConfigResolver: ProjectConfigResolver\n\ttenantConfigResolver: TenantConfigResolver\n}> {\n\tconst loader = new ConfigLoader()\n\tconst configs = await Promise.all(\n\t\tconfigSources.map(it => (it.type === 'file' ? loader.load(it.data) : loader.loadString(it.data, it.type))),\n\t)\n\tconst env: Env = {\n\t\t...configProcessors.reduce((acc, curr) => ({ ...acc, ...(curr.getDefaultEnv?.() || {}) }), {\n\t\t\tDEFAULT_DB_PORT: '5432',\n\t\t}),\n\t\t...Object.fromEntries(Object.entries(process.env).filter((it): it is [string, string] => it[1] !== undefined)),\n\t}\n\n\tconst template = configProcessors.reduce(\n\t\t(tpl, processor) => processor.prepareConfigTemplate?.(tpl, { env }) || tpl,\n\t\tconfigTemplate,\n\t)\n\n\tconst rawConfig = Merger.merge(template, ...configs)\n\n\tconst parametersResolver = createObjectParametersResolver({ env })\n\tconst config = resolveParameters(rawConfig.server, parametersResolver)\n\n\tconst serverConfig = serverConfigSchema(config)\n\treturn {\n\t\tserverConfig,\n\t\tprojectConfigResolver: createProjectConfigResolver(env, rawConfig, configProcessors),\n\t\ttenantConfigResolver: createTenantConfigResolver(env, rawConfig.tenant),\n\t}\n}\n"],"names":["defaultServerConfigSchema","ConfigLoader","configTemplate","Merger","createObjectParametersResolver","resolveParameters","createProjectConfigResolver","createTenantConfigResolver"],"mappings":";;;;;;;AAgBA,eAAsB,WACrB,gBAAgC,CAAA,GAChC,mBAA2C,CAAA,GAC3C,qBAA8BA,iCAK5B;AACF,QAAM,SAAS,IAAIC,0BAAA;AACnB,QAAM,UAAU,MAAM,QAAQ;AAAA,IAC7B,cAAc,IAAI,CAAA,OAAO,GAAG,SAAS,SAAS,OAAO,KAAK,GAAG,IAAI,IAAI,OAAO,WAAW,GAAG,MAAM,GAAG,IAAI,CAAE;AAAA,EAAA;AAE1G,QAAM,MAAW;AAAA,IAChB,GAAG,iBAAiB,OAAO,CAAC,KAAK,UAAU,EAAE,GAAG,KAAK,GAAI,KAAK,qBAAqB,CAAA,MAAQ;AAAA,MAC1F,iBAAiB;AAAA,IAAA,CACjB;AAAA,IACD,GAAG,OAAO,YAAY,OAAO,QAAQ,QAAQ,GAAG,EAAE,OAAO,CAAC,OAA+B,GAAG,CAAC,MAAM,MAAS,CAAC;AAAA,EAAA;AAG9G,QAAM,WAAW,iBAAiB;AAAA,IACjC,CAAC,KAAK,cAAc,UAAU,wBAAwB,KAAK,EAAE,IAAA,CAAK,KAAK;AAAA,IACvEC,eAAAA;AAAAA,EAAA;AAGD,QAAM,YAAYC,aAAAA,OAAO,MAAM,UAAU,GAAG,OAAO;AAEnD,QAAM,qBAAqBC,aAAAA,+BAA+B,EAAE,KAAK;AACjE,QAAM,SAASC,aAAAA,kBAAkB,UAAU,QAAQ,kBAAkB;AAErE,QAAM,eAAe,mBAAmB,MAAM;AAC9C,SAAO;AAAA,IACN;AAAA,IACA,uBAAuBC,sBAAAA,4BAA4B,KAAK,WAAW,gBAAgB;AAAA,IACnF,sBAAsBC,qBAAAA,2BAA2B,KAAK,UAAU,MAAM;AAAA,EAAA;AAExE;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../../../../packages/engine-http/src/config/config.ts"],"sourcesContent":["import { ConfigLoader, createObjectParametersResolver, Merger, resolveParameters } from '@contember/config-loader'\n\nimport { serverConfigSchema as defaultServerConfigSchema, tenantConfigSchema } from './configSchema'\nimport { configTemplate } from './configTemplate'\nimport { createProjectConfigResolver, ProjectConfigResolver } from './projectConfigResolver'\nimport { createTenantConfigResolver, TenantConfigResolver } from './tenantConfigResolver'\nimport { Type } from '@contember/typesafe'\nimport { ConfigProcessor } from './ConfigProcessor'\n\nexport type ServerConfig = ReturnType<typeof defaultServerConfigSchema>\nexport type TenantConfig = ReturnType<typeof tenantConfigSchema>\n\nexport type ConfigSource = { data: string; type: 'file' | 'json' | 'yaml' }\n\nexport type Env = Record<string, string>\n\nexport async function readConfig<T extends ServerConfig>(\n\tconfigSources: ConfigSource[] = [],\n\tconfigProcessors: ConfigProcessor<any>[] = [],\n\tserverConfigSchema: Type<T> = defaultServerConfigSchema as Type<T>,\n): Promise<{\n\tserverConfig: T\n\tprojectConfigResolver: ProjectConfigResolver\n\ttenantConfigResolver: TenantConfigResolver\n}> {\n\tconst loader = new ConfigLoader()\n\tconst configs = await Promise.all(\n\t\tconfigSources.map(it => (it.type === 'file' ? loader.load(it.data) : loader.loadString(it.data, it.type))),\n\t)\n\tconst env: Env = {\n\t\t...configProcessors.reduce((acc, curr) => ({ ...acc, ...(curr.getDefaultEnv?.() || {}) }), {\n\t\t\tDEFAULT_DB_PORT: '5432',\n\t\t}),\n\t\t...Object.fromEntries(Object.entries(process.env).filter((it): it is [string, string] => it[1] !== undefined)),\n\t}\n\n\tconst template = configProcessors.reduce(\n\t\t(tpl, processor) => processor.prepareConfigTemplate?.(tpl, { env }) || tpl,\n\t\tconfigTemplate,\n\t)\n\n\tconst rawConfig = Merger.merge(template, ...configs)\n\n\tconst parametersResolver = createObjectParametersResolver({ env })\n\tconst config = resolveParameters(rawConfig.server, parametersResolver)\n\n\tconst serverConfig = serverConfigSchema(config)\n\treturn {\n\t\tserverConfig,\n\t\tprojectConfigResolver: createProjectConfigResolver(env, rawConfig, configProcessors),\n\t\ttenantConfigResolver: createTenantConfigResolver(env, rawConfig.tenant),\n\t}\n}\n
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../../../packages/engine-http/src/config/config.ts"],"sourcesContent":["import { ConfigLoader, createObjectParametersResolver, Merger, resolveParameters } from '@contember/config-loader'\n\nimport { serverConfigSchema as defaultServerConfigSchema, tenantConfigSchema } from './configSchema'\nimport { configTemplate } from './configTemplate'\nimport { createProjectConfigResolver, ProjectConfigResolver } from './projectConfigResolver'\nimport { createTenantConfigResolver, TenantConfigResolver } from './tenantConfigResolver'\nimport { Type } from '@contember/typesafe'\nimport { ConfigProcessor } from './ConfigProcessor'\n\nexport type ServerConfig = ReturnType<typeof defaultServerConfigSchema>\nexport type TenantConfig = ReturnType<typeof tenantConfigSchema>\n\nexport type ConfigSource = { data: string; type: 'file' | 'json' | 'yaml' }\n\nexport type Env = Record<string, string>\n\nexport async function readConfig<T extends ServerConfig>(\n\tconfigSources: ConfigSource[] = [],\n\tconfigProcessors: ConfigProcessor<any>[] = [],\n\tserverConfigSchema: Type<T> = defaultServerConfigSchema as Type<T>,\n): Promise<{\n\tserverConfig: T\n\tprojectConfigResolver: ProjectConfigResolver\n\ttenantConfigResolver: TenantConfigResolver\n}> {\n\tconst loader = new ConfigLoader()\n\tconst configs = await Promise.all(\n\t\tconfigSources.map(it => (it.type === 'file' ? loader.load(it.data) : loader.loadString(it.data, it.type))),\n\t)\n\tconst env: Env = {\n\t\t...configProcessors.reduce((acc, curr) => ({ ...acc, ...(curr.getDefaultEnv?.() || {}) }), {\n\t\t\tDEFAULT_DB_PORT: '5432',\n\t\t}),\n\t\t...Object.fromEntries(Object.entries(process.env).filter((it): it is [string, string] => it[1] !== undefined)),\n\t}\n\n\tconst template = configProcessors.reduce(\n\t\t(tpl, processor) => processor.prepareConfigTemplate?.(tpl, { env }) || tpl,\n\t\tconfigTemplate,\n\t)\n\n\tconst rawConfig = Merger.merge(template, ...configs)\n\n\tconst parametersResolver = createObjectParametersResolver({ env })\n\tconst config = resolveParameters(rawConfig.server, parametersResolver)\n\n\tconst serverConfig = serverConfigSchema(config)\n\treturn {\n\t\tserverConfig,\n\t\tprojectConfigResolver: createProjectConfigResolver(env, rawConfig, configProcessors),\n\t\ttenantConfigResolver: createTenantConfigResolver(env, rawConfig.tenant),\n\t}\n}\n"],"names":["serverConfigSchema","defaultServerConfigSchema"],"mappings":";;;;;AAgBA,eAAsB,WACrB,gBAAgC,CAAA,GAChC,mBAA2C,CAAA,GAC3CA,uBAA8BC,oBAK5B;AACF,QAAM,SAAS,IAAI,aAAA;AACnB,QAAM,UAAU,MAAM,QAAQ;AAAA,IAC7B,cAAc,IAAI,CAAA,OAAO,GAAG,SAAS,SAAS,OAAO,KAAK,GAAG,IAAI,IAAI,OAAO,WAAW,GAAG,MAAM,GAAG,IAAI,CAAE;AAAA,EAAA;AAE1G,QAAM,MAAW;AAAA,IAChB,GAAG,iBAAiB,OAAO,CAAC,KAAK,UAAU,EAAE,GAAG,KAAK,GAAI,KAAK,qBAAqB,CAAA,MAAQ;AAAA,MAC1F,iBAAiB;AAAA,IAAA,CACjB;AAAA,IACD,GAAG,OAAO,YAAY,OAAO,QAAQ,QAAQ,GAAG,EAAE,OAAO,CAAC,OAA+B,GAAG,CAAC,MAAM,MAAS,CAAC;AAAA,EAAA;AAG9G,QAAM,WAAW,iBAAiB;AAAA,IACjC,CAAC,KAAK,cAAc,UAAU,wBAAwB,KAAK,EAAE,IAAA,CAAK,KAAK;AAAA,IACvE;AAAA,EAAA;AAGD,QAAM,YAAY,OAAO,MAAM,UAAU,GAAG,OAAO;AAEnD,QAAM,qBAAqB,+BAA+B,EAAE,KAAK;AACjE,QAAM,SAAS,kBAAkB,UAAU,QAAQ,kBAAkB;AAErE,QAAM,eAAeD,qBAAmB,MAAM;AAC9C,SAAO;AAAA,IACN;AAAA,IACA,uBAAuB,4BAA4B,KAAK,WAAW,gBAAgB;AAAA,IACnF,sBAAsB,2BAA2B,KAAK,UAAU,MAAM;AAAA,EAAA;AAExE;"}
|
|
@@ -67,30 +67,33 @@ const dbConfigSchema = Typesafe__namespace.intersection(
|
|
|
67
67
|
const tenantConfigSchema = Typesafe__namespace.intersection(
|
|
68
68
|
Typesafe__namespace.object({
|
|
69
69
|
db: dbConfigSchema,
|
|
70
|
-
mailer: Typesafe__namespace.transform(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
Typesafe__namespace.
|
|
78
|
-
|
|
79
|
-
Typesafe__namespace.
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
70
|
+
mailer: Typesafe__namespace.transform(
|
|
71
|
+
Typesafe__namespace.partial({
|
|
72
|
+
from: Typesafe__namespace.string,
|
|
73
|
+
host: Typesafe__namespace.string,
|
|
74
|
+
port: Typesafe__namespace.number,
|
|
75
|
+
user: Typesafe__namespace.string,
|
|
76
|
+
password: Typesafe__namespace.string,
|
|
77
|
+
webhook: Typesafe__namespace.union(
|
|
78
|
+
Typesafe__namespace.string,
|
|
79
|
+
Typesafe__namespace.intersection(
|
|
80
|
+
Typesafe__namespace.object({
|
|
81
|
+
url: Typesafe__namespace.string
|
|
82
|
+
}),
|
|
83
|
+
Typesafe__namespace.partial({
|
|
84
|
+
headers: Typesafe__namespace.record(Typesafe__namespace.string, Typesafe__namespace.string)
|
|
85
|
+
})
|
|
86
|
+
)
|
|
85
87
|
)
|
|
86
|
-
)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
}),
|
|
89
|
+
(value, input) => {
|
|
90
|
+
return {
|
|
91
|
+
...input,
|
|
92
|
+
...value,
|
|
93
|
+
...value.user ? { auth: { user: value.user, pass: value.password } } : {}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
),
|
|
94
97
|
credentials: Typesafe__namespace.partial({
|
|
95
98
|
rootToken: Typesafe__namespace.string,
|
|
96
99
|
rootTokenHash: Typesafe__namespace.string,
|
|
@@ -126,7 +129,11 @@ const serverConfigSchema = Typesafe__namespace.partial({
|
|
|
126
129
|
}
|
|
127
130
|
}),
|
|
128
131
|
contentApi: Typesafe__namespace.partial({
|
|
129
|
-
schemaCacheTtlSeconds: Typesafe__namespace.integer
|
|
132
|
+
schemaCacheTtlSeconds: Typesafe__namespace.integer,
|
|
133
|
+
whereOptimizer: Typesafe__namespace.partial({
|
|
134
|
+
disable: Typesafe__namespace.boolean,
|
|
135
|
+
maxCrossOptimizationInput: Typesafe__namespace.number
|
|
136
|
+
})
|
|
130
137
|
}),
|
|
131
138
|
logging: Typesafe__namespace.union(
|
|
132
139
|
(val) => Typesafe__namespace.valueAt(val, ["sentry", "dsn"]) === void 0 ? {} : Typesafe__namespace.fail([]),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configSchema.cjs","sources":["../../../../../packages/engine-http/src/config/configSchema.ts"],"sourcesContent":["import * as Typesafe from '@contember/typesafe'\nimport { MailerOptions } from '@contember/engine-tenant-api'\nimport { upperCaseFirst } from '../utils/strings'\n\
|
|
1
|
+
{"version":3,"file":"configSchema.cjs","sources":["../../../../../packages/engine-http/src/config/configSchema.ts"],"sourcesContent":["import * as Typesafe from '@contember/typesafe'\nimport { MailerOptions } from '@contember/engine-tenant-api'\nimport { upperCaseFirst } from '../utils/strings'\n\nconst dbConfigRequired = {\n\thost: Typesafe.string,\n\tport: Typesafe.number,\n\tuser: Typesafe.string,\n\tpassword: Typesafe.string,\n\tdatabase: Typesafe.string,\n}\nconst dbConfigOptional = {\n\tssl: Typesafe.boolean,\n\tqueryTimeoutMs: Typesafe.number,\n\tstatementTimeoutMs: Typesafe.number,\n\tconnectionTimeoutMs: Typesafe.number,\n\tpool: Typesafe.partial({\n\t\tmaxConnections: Typesafe.number,\n\t\tmaxConnecting: Typesafe.number,\n\t\tmaxIdle: Typesafe.number,\n\t\treconnectIntervalMs: Typesafe.number,\n\t\trateLimitCount: Typesafe.number,\n\t\trateLimitPeriodMs: Typesafe.number,\n\t\tidleTimeoutMs: Typesafe.number,\n\t\tacquireTimeoutMs: Typesafe.number,\n\t\tmaxUses: Typesafe.number,\n\t\tmaxAgeMs: Typesafe.number,\n\t}),\n}\n\nconst dbConfigSchemaInner = Typesafe.intersection(\n\tTypesafe.object(dbConfigRequired),\n\tTypesafe.partial(dbConfigOptional),\n)\n\nconst readDbSchema = Typesafe.intersection(\n\tTypesafe.partial(dbConfigRequired),\n\tTypesafe.partial(dbConfigOptional),\n)\n\nexport const dbConfigSchema = Typesafe.intersection(\n\tdbConfigSchemaInner,\n\tTypesafe.partial({\n\t\tread: (val: unknown) => {\n\t\t\tconst readDb = readDbSchema(val)\n\t\t\tif ('host' in readDb) {\n\t\t\t\treturn readDb\n\t\t\t}\n\t\t\treturn undefined\n\t\t},\n\t}),\n)\n\nexport const tenantConfigSchema = Typesafe.intersection(\n\tTypesafe.object({\n\t\tdb: dbConfigSchema,\n\t\tmailer: Typesafe.transform(\n\t\t\tTypesafe.partial({\n\t\t\t\tfrom: Typesafe.string,\n\t\t\t\thost: Typesafe.string,\n\t\t\t\tport: Typesafe.number,\n\t\t\t\tuser: Typesafe.string,\n\t\t\t\tpassword: Typesafe.string,\n\n\t\t\t\twebhook: Typesafe.union(\n\t\t\t\t\tTypesafe.string,\n\t\t\t\t\tTypesafe.intersection(\n\t\t\t\t\t\tTypesafe.object({\n\t\t\t\t\t\t\turl: Typesafe.string,\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tTypesafe.partial({\n\t\t\t\t\t\t\theaders: Typesafe.record(Typesafe.string, Typesafe.string),\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t}),\n\t\t\t(value, input): MailerOptions & Typesafe.JsonObject => {\n\t\t\t\treturn {\n\t\t\t\t\t...(input as any),\n\t\t\t\t\t...value,\n\t\t\t\t\t...(value.user ? { auth: { user: value.user, pass: value.password } } : {}),\n\t\t\t\t}\n\t\t\t},\n\t\t),\n\t\tcredentials: Typesafe.partial({\n\t\t\trootToken: Typesafe.string,\n\t\t\trootTokenHash: Typesafe.string,\n\t\t\trootPassword: Typesafe.string,\n\t\t\trootEmail: Typesafe.string,\n\t\t\tloginToken: Typesafe.string,\n\t\t}),\n\t}),\n\tTypesafe.object({\n\t\tsecrets: Typesafe.partial({\n\t\t\tencryptionKey: Typesafe.string,\n\t\t}),\n\t}),\n)\n\nexport const serverConfigSchema = Typesafe.partial({\n\tport: Typesafe.number,\n\thttp: Typesafe.partial({\n\t\trequestBodySize: Typesafe.string,\n\t\tsuppressAccessLog: (val: unknown) => {\n\t\t\tif (!val) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tif (val === 'true' || val === '1' || val === 'on') {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif (val === 'false' || val === '0' || val === 'off') {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif (typeof val === 'string') {\n\t\t\t\treturn val\n\t\t\t}\n\t\t\tTypesafe.fail([])\n\t\t},\n\t}),\n\tcontentApi: Typesafe.partial({\n\t\tschemaCacheTtlSeconds: Typesafe.integer,\n\t\twhereOptimizer: Typesafe.partial({\n\t\t\tdisable: Typesafe.boolean,\n\t\t\tmaxCrossOptimizationInput: Typesafe.number,\n\t\t}),\n\t}),\n\tlogging: Typesafe.union(\n\t\t(val): { sentry?: { dsn: string } } => Typesafe.valueAt(val, ['sentry', 'dsn']) === undefined ? {} : Typesafe.fail([]),\n\t\tTypesafe.partial({\n\t\t\tsentry: Typesafe.object({\n\t\t\t\tdsn: Typesafe.string,\n\t\t\t}),\n\t\t}),\n\t),\n\tprojectGroup: (val: unknown, path: PropertyKey[] = []) =>\n\t\tTypesafe.valueAt(val, ['domainMapping']) === undefined\n\t\t\t? undefined\n\t\t\t: Typesafe.intersection(\n\t\t\t\tTypesafe.object({\n\t\t\t\t\tdomainMapping: Typesafe.string,\n\t\t\t\t}),\n\t\t\t\tTypesafe.partial({\n\t\t\t\t\tconfigHeader: Typesafe.string,\n\t\t\t\t\tconfigEncryptionKey: Typesafe.string,\n\t\t\t\t}),\n\t\t\t)(val, path),\n\tmonitoringPort: Typesafe.number,\n\tworkerCount: Typesafe.union(Typesafe.number, Typesafe.string),\n\tapplicationWorker: Typesafe.string,\n})\n\nexport const stageConfig = Typesafe.record(\n\tTypesafe.string,\n\tTypesafe.intersection(\n\t\tTypesafe.object({\n\t\t\tname: Typesafe.union(\n\t\t\t\tTypesafe.string,\n\t\t\t\t(_: unknown, path: PropertyKey[] = []) => upperCaseFirst(String(path[path.length - 2])),\n\t\t\t),\n\t\t\tslug: (_: unknown, path: PropertyKey[] = []) => String(path[path.length - 2]),\n\t\t}),\n\t\tTypesafe.partial({\n\t\t\tschema: Typesafe.string,\n\t\t}),\n\t),\n)\n\nexport const projectConfigSchema = Typesafe.object({\n\tname: Typesafe.union(\n\t\tTypesafe.string,\n\t\t(_: unknown, path: PropertyKey[] = []) => upperCaseFirst(String(path[path.length - 2])).replace(/-/g, ' '),\n\t),\n\tslug: (_, path = []) => String(path[path.length - 2]),\n\tstages: (input, path = []) => Object.values(stageConfig(input, path)),\n\tdb: Typesafe.intersection(\n\t\tTypesafe.union(\n\t\t\tTypesafe.object({\n\t\t\t\tuseTenantDb: Typesafe.literal(true),\n\t\t\t}),\n\t\t\tdbConfigSchema,\n\t\t),\n\t\tTypesafe.partial({\n\t\t\tsystemSchema: Typesafe.string,\n\t\t}),\n\t),\n})\n"],"names":["Typesafe","upperCaseFirst"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAIA,MAAM,mBAAmB;AAAA,EACxB,MAAMA,oBAAS;AAAA,EACf,MAAMA,oBAAS;AAAA,EACf,MAAMA,oBAAS;AAAA,EACf,UAAUA,oBAAS;AAAA,EACnB,UAAUA,oBAAS;AACpB;AACA,MAAM,mBAAm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S,QAAQ;AAAA,MAChB,QAAQA,oBAAS;AAAA,IAAA,CACjB;AAAA,EAAA;AAEH;AAEO,MAAM,sBAAsBA,oBAAS,OAAO;AAAA,EAClD,MAAMA,oBAAS;AAAA,IACdA,oBAAS;AAAA,IACT,CAAC,GAAY,OAAsB,CAAA,MAAOC,QAAAA,eAAe,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,MAAM,GAAG;AAAA,EAAA;AAAA,EAE1G,MAAM,CAAC,GAAG,OAAO,CAAA,MAAO,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC;AAAA,EACpD,QAAQ,CAAC,OAAO,OAAO,CAAA,MAAO,OAAO,OAAO,YAAY,OAAO,IAAI,CAAC;AAAA,EACpE,IAAID,oBAAS;AAAA,IACZA,oBAAS;AAAA,MACRA,oBAAS,OAAO;AAAA,QACf,aAAaA,oBAAS,QAAQ,IAAI;AAAA,MAAA,CAClC;AAAA,MACD;AAAA,IAAA;AAAA,IAEDA,oBAAS,QAAQ;AAAA,MAChB,cAAcA,oBAAS;AAAA,IAAA,CACvB;AAAA,EAAA;AAEH,CAAC;;;;;;"}
|
|
@@ -48,30 +48,33 @@ const dbConfigSchema = Typesafe.intersection(
|
|
|
48
48
|
const tenantConfigSchema = Typesafe.intersection(
|
|
49
49
|
Typesafe.object({
|
|
50
50
|
db: dbConfigSchema,
|
|
51
|
-
mailer: Typesafe.transform(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
Typesafe.
|
|
59
|
-
|
|
60
|
-
Typesafe.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
51
|
+
mailer: Typesafe.transform(
|
|
52
|
+
Typesafe.partial({
|
|
53
|
+
from: Typesafe.string,
|
|
54
|
+
host: Typesafe.string,
|
|
55
|
+
port: Typesafe.number,
|
|
56
|
+
user: Typesafe.string,
|
|
57
|
+
password: Typesafe.string,
|
|
58
|
+
webhook: Typesafe.union(
|
|
59
|
+
Typesafe.string,
|
|
60
|
+
Typesafe.intersection(
|
|
61
|
+
Typesafe.object({
|
|
62
|
+
url: Typesafe.string
|
|
63
|
+
}),
|
|
64
|
+
Typesafe.partial({
|
|
65
|
+
headers: Typesafe.record(Typesafe.string, Typesafe.string)
|
|
66
|
+
})
|
|
67
|
+
)
|
|
66
68
|
)
|
|
67
|
-
)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
}),
|
|
70
|
+
(value, input) => {
|
|
71
|
+
return {
|
|
72
|
+
...input,
|
|
73
|
+
...value,
|
|
74
|
+
...value.user ? { auth: { user: value.user, pass: value.password } } : {}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
),
|
|
75
78
|
credentials: Typesafe.partial({
|
|
76
79
|
rootToken: Typesafe.string,
|
|
77
80
|
rootTokenHash: Typesafe.string,
|
|
@@ -107,7 +110,11 @@ const serverConfigSchema = Typesafe.partial({
|
|
|
107
110
|
}
|
|
108
111
|
}),
|
|
109
112
|
contentApi: Typesafe.partial({
|
|
110
|
-
schemaCacheTtlSeconds: Typesafe.integer
|
|
113
|
+
schemaCacheTtlSeconds: Typesafe.integer,
|
|
114
|
+
whereOptimizer: Typesafe.partial({
|
|
115
|
+
disable: Typesafe.boolean,
|
|
116
|
+
maxCrossOptimizationInput: Typesafe.number
|
|
117
|
+
})
|
|
111
118
|
}),
|
|
112
119
|
logging: Typesafe.union(
|
|
113
120
|
(val) => Typesafe.valueAt(val, ["sentry", "dsn"]) === void 0 ? {} : Typesafe.fail([]),
|