@contember/engine-http 2.1.0-beta.2 → 2.2.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +2 -0
- package/dist/development/index.cjs +11 -0
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +12 -1
- package/dist/development/index.js.map +1 -1
- package/dist/development/src/MasterContainer.cjs +48 -7
- package/dist/development/src/MasterContainer.cjs.map +1 -1
- package/dist/development/src/MasterContainer.js +48 -7
- package/dist/development/src/MasterContainer.js.map +1 -1
- package/dist/development/src/application/application.cjs +36 -7
- package/dist/development/src/application/application.cjs.map +1 -1
- package/dist/development/src/application/application.js +36 -7
- package/dist/development/src/application/application.js.map +1 -1
- package/dist/development/src/application/forceHttpOk.cjs +34 -0
- package/dist/development/src/application/forceHttpOk.cjs.map +1 -0
- package/dist/development/src/application/forceHttpOk.js +34 -0
- package/dist/development/src/application/forceHttpOk.js.map +1 -0
- 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 +61 -4
- package/dist/development/src/common/Authorizator.cjs.map +1 -1
- package/dist/development/src/common/Authorizator.js +61 -4
- package/dist/development/src/common/Authorizator.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/common/NotFoundMiddleware.cjs +15 -0
- package/dist/development/src/common/NotFoundMiddleware.cjs.map +1 -0
- package/dist/development/src/common/NotFoundMiddleware.js +15 -0
- package/dist/development/src/common/NotFoundMiddleware.js.map +1 -0
- 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 +64 -2
- package/dist/development/src/config/configSchema.cjs.map +1 -1
- package/dist/development/src/config/configSchema.js +64 -2
- package/dist/development/src/config/configSchema.js.map +1 -1
- package/dist/development/src/config/configTemplate.cjs +13 -2
- package/dist/development/src/config/configTemplate.cjs.map +1 -1
- package/dist/development/src/config/configTemplate.js +13 -2
- 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.map +1 -1
- package/dist/development/src/config/tenantConfigResolver.js.map +1 -1
- package/dist/development/src/content/ContentApiControllerFactory.cjs +26 -4
- package/dist/development/src/content/ContentApiControllerFactory.cjs.map +1 -1
- package/dist/development/src/content/ContentApiControllerFactory.js +26 -4
- package/dist/development/src/content/ContentApiControllerFactory.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/ProjectMembershipResolver.cjs +1 -0
- package/dist/development/src/content/ProjectMembershipResolver.cjs.map +1 -1
- package/dist/development/src/content/ProjectMembershipResolver.js +1 -0
- package/dist/development/src/content/ProjectMembershipResolver.js.map +1 -1
- package/dist/development/src/content/triggeredActionsListener.cjs.map +1 -1
- package/dist/development/src/content/triggeredActionsListener.js.map +1 -1
- package/dist/development/src/graphql/dbQueriesListener.cjs.map +1 -1
- package/dist/development/src/graphql/dbQueriesListener.js.map +1 -1
- package/dist/development/src/misc/HomepageMiddlewareFactory.cjs +1 -0
- package/dist/development/src/misc/HomepageMiddlewareFactory.cjs.map +1 -1
- package/dist/development/src/misc/HomepageMiddlewareFactory.js +1 -0
- package/dist/development/src/misc/HomepageMiddlewareFactory.js.map +1 -1
- package/dist/development/src/project/ProjectContainer.cjs +1 -0
- package/dist/development/src/project/ProjectContainer.cjs.map +1 -1
- package/dist/development/src/project/ProjectContainer.js +1 -0
- 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/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 +1 -0
- package/dist/development/src/project-common/ProjectContextResolver.cjs.map +1 -1
- package/dist/development/src/project-common/ProjectContextResolver.js +1 -0
- package/dist/development/src/project-common/ProjectContextResolver.js.map +1 -1
- package/dist/development/src/projectGroup/ProjectGroupContainer.cjs +17 -4
- package/dist/development/src/projectGroup/ProjectGroupContainer.cjs.map +1 -1
- package/dist/development/src/projectGroup/ProjectGroupContainer.js +17 -4
- 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 +1 -0
- package/dist/development/src/projectGroup/ProjectGroupResolver.cjs.map +1 -1
- package/dist/development/src/projectGroup/ProjectGroupResolver.js +1 -0
- 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/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/dbMetrics.cjs.map +1 -1
- package/dist/development/src/prometheus/dbMetrics.js.map +1 -1
- package/dist/development/src/system/ContentQueryExecutor.cjs.map +1 -1
- package/dist/development/src/system/ContentQueryExecutor.js.map +1 -1
- package/dist/development/src/system/SystemApiMiddlewareFactory.cjs +1 -0
- package/dist/development/src/system/SystemApiMiddlewareFactory.cjs.map +1 -1
- package/dist/development/src/system/SystemApiMiddlewareFactory.js +1 -0
- 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/OidcBackchannelLogoutMiddlewareFactory.cjs +46 -0
- package/dist/development/src/tenant/OidcBackchannelLogoutMiddlewareFactory.cjs.map +1 -0
- package/dist/development/src/tenant/OidcBackchannelLogoutMiddlewareFactory.js +46 -0
- package/dist/development/src/tenant/OidcBackchannelLogoutMiddlewareFactory.js.map +1 -0
- package/dist/development/src/tenant/TenantApiMiddlewareFactory.cjs +8 -1
- package/dist/development/src/tenant/TenantApiMiddlewareFactory.cjs.map +1 -1
- package/dist/development/src/tenant/TenantApiMiddlewareFactory.js +8 -1
- package/dist/development/src/tenant/TenantApiMiddlewareFactory.js.map +1 -1
- package/dist/development/src/tenant/TenantGraphQLHandlerFactory.cjs.map +1 -1
- package/dist/development/src/tenant/TenantGraphQLHandlerFactory.js.map +1 -1
- package/dist/development/src/testing/TestTransactions.cjs +144 -0
- package/dist/development/src/testing/TestTransactions.cjs.map +1 -0
- package/dist/development/src/testing/TestTransactions.js +144 -0
- package/dist/development/src/testing/TestTransactions.js.map +1 -0
- 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 +1 -0
- package/dist/development/src/transfer/ExportApiControllerFactory.cjs.map +1 -1
- package/dist/development/src/transfer/ExportApiControllerFactory.js +1 -0
- package/dist/development/src/transfer/ExportApiControllerFactory.js.map +1 -1
- package/dist/development/src/transfer/ExportExecutor.cjs +4 -1
- package/dist/development/src/transfer/ExportExecutor.cjs.map +1 -1
- package/dist/development/src/transfer/ExportExecutor.js +4 -1
- package/dist/development/src/transfer/ExportExecutor.js.map +1 -1
- package/dist/development/src/transfer/ImportApiMiddlewareFactory.cjs +1 -0
- package/dist/development/src/transfer/ImportApiMiddlewareFactory.cjs.map +1 -1
- package/dist/development/src/transfer/ImportApiMiddlewareFactory.js +1 -0
- package/dist/development/src/transfer/ImportApiMiddlewareFactory.js.map +1 -1
- package/dist/development/src/transfer/ImportExecutor.cjs +7 -3
- package/dist/development/src/transfer/ImportExecutor.cjs.map +1 -1
- package/dist/development/src/transfer/ImportExecutor.js +7 -3
- 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.map +1 -1
- package/dist/development/src/utils/CryptoWrapper.cjs +4 -0
- package/dist/development/src/utils/CryptoWrapper.cjs.map +1 -1
- package/dist/development/src/utils/CryptoWrapper.js +4 -0
- package/dist/development/src/utils/CryptoWrapper.js.map +1 -1
- package/dist/development/src/utils/remoteAddress.cjs +5 -4
- package/dist/development/src/utils/remoteAddress.cjs.map +1 -1
- package/dist/development/src/utils/remoteAddress.js +5 -4
- package/dist/development/src/utils/remoteAddress.js.map +1 -1
- 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 +2 -2
- package/dist/development/src/utils/serverStartup.cjs.map +1 -1
- package/dist/development/src/utils/serverStartup.js.map +1 -1
- package/dist/production/index.cjs +11 -0
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.js +12 -1
- package/dist/production/index.js.map +1 -1
- package/dist/production/src/MasterContainer.cjs +48 -7
- package/dist/production/src/MasterContainer.cjs.map +1 -1
- package/dist/production/src/MasterContainer.js +48 -7
- package/dist/production/src/MasterContainer.js.map +1 -1
- package/dist/production/src/application/application.cjs +36 -7
- package/dist/production/src/application/application.cjs.map +1 -1
- package/dist/production/src/application/application.js +36 -7
- package/dist/production/src/application/application.js.map +1 -1
- package/dist/production/src/application/forceHttpOk.cjs +34 -0
- package/dist/production/src/application/forceHttpOk.cjs.map +1 -0
- package/dist/production/src/application/forceHttpOk.js +34 -0
- package/dist/production/src/application/forceHttpOk.js.map +1 -0
- 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 +61 -4
- package/dist/production/src/common/Authorizator.cjs.map +1 -1
- package/dist/production/src/common/Authorizator.js +61 -4
- package/dist/production/src/common/Authorizator.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/common/NotFoundMiddleware.cjs +15 -0
- package/dist/production/src/common/NotFoundMiddleware.cjs.map +1 -0
- package/dist/production/src/common/NotFoundMiddleware.js +15 -0
- package/dist/production/src/common/NotFoundMiddleware.js.map +1 -0
- 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 +64 -2
- package/dist/production/src/config/configSchema.cjs.map +1 -1
- package/dist/production/src/config/configSchema.js +64 -2
- package/dist/production/src/config/configSchema.js.map +1 -1
- package/dist/production/src/config/configTemplate.cjs +13 -2
- package/dist/production/src/config/configTemplate.cjs.map +1 -1
- package/dist/production/src/config/configTemplate.js +13 -2
- 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.map +1 -1
- package/dist/production/src/config/tenantConfigResolver.js.map +1 -1
- package/dist/production/src/content/ContentApiControllerFactory.cjs +26 -4
- package/dist/production/src/content/ContentApiControllerFactory.cjs.map +1 -1
- package/dist/production/src/content/ContentApiControllerFactory.js +26 -4
- package/dist/production/src/content/ContentApiControllerFactory.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/ProjectMembershipResolver.cjs +1 -0
- package/dist/production/src/content/ProjectMembershipResolver.cjs.map +1 -1
- package/dist/production/src/content/ProjectMembershipResolver.js +1 -0
- package/dist/production/src/content/ProjectMembershipResolver.js.map +1 -1
- package/dist/production/src/content/triggeredActionsListener.cjs.map +1 -1
- package/dist/production/src/content/triggeredActionsListener.js.map +1 -1
- package/dist/production/src/graphql/dbQueriesListener.cjs.map +1 -1
- package/dist/production/src/graphql/dbQueriesListener.js.map +1 -1
- package/dist/production/src/misc/HomepageMiddlewareFactory.cjs +1 -0
- package/dist/production/src/misc/HomepageMiddlewareFactory.cjs.map +1 -1
- package/dist/production/src/misc/HomepageMiddlewareFactory.js +1 -0
- package/dist/production/src/misc/HomepageMiddlewareFactory.js.map +1 -1
- package/dist/production/src/project/ProjectContainer.cjs +1 -0
- package/dist/production/src/project/ProjectContainer.cjs.map +1 -1
- package/dist/production/src/project/ProjectContainer.js +1 -0
- 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/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 +1 -0
- package/dist/production/src/project-common/ProjectContextResolver.cjs.map +1 -1
- package/dist/production/src/project-common/ProjectContextResolver.js +1 -0
- package/dist/production/src/project-common/ProjectContextResolver.js.map +1 -1
- package/dist/production/src/projectGroup/ProjectGroupContainer.cjs +17 -4
- package/dist/production/src/projectGroup/ProjectGroupContainer.cjs.map +1 -1
- package/dist/production/src/projectGroup/ProjectGroupContainer.js +17 -4
- 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 +1 -0
- package/dist/production/src/projectGroup/ProjectGroupResolver.cjs.map +1 -1
- package/dist/production/src/projectGroup/ProjectGroupResolver.js +1 -0
- 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/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/dbMetrics.cjs.map +1 -1
- package/dist/production/src/prometheus/dbMetrics.js.map +1 -1
- package/dist/production/src/system/ContentQueryExecutor.cjs.map +1 -1
- package/dist/production/src/system/ContentQueryExecutor.js.map +1 -1
- package/dist/production/src/system/SystemApiMiddlewareFactory.cjs +1 -0
- package/dist/production/src/system/SystemApiMiddlewareFactory.cjs.map +1 -1
- package/dist/production/src/system/SystemApiMiddlewareFactory.js +1 -0
- 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/OidcBackchannelLogoutMiddlewareFactory.cjs +46 -0
- package/dist/production/src/tenant/OidcBackchannelLogoutMiddlewareFactory.cjs.map +1 -0
- package/dist/production/src/tenant/OidcBackchannelLogoutMiddlewareFactory.js +46 -0
- package/dist/production/src/tenant/OidcBackchannelLogoutMiddlewareFactory.js.map +1 -0
- package/dist/production/src/tenant/TenantApiMiddlewareFactory.cjs +8 -1
- package/dist/production/src/tenant/TenantApiMiddlewareFactory.cjs.map +1 -1
- package/dist/production/src/tenant/TenantApiMiddlewareFactory.js +8 -1
- package/dist/production/src/tenant/TenantApiMiddlewareFactory.js.map +1 -1
- package/dist/production/src/tenant/TenantGraphQLHandlerFactory.cjs.map +1 -1
- package/dist/production/src/tenant/TenantGraphQLHandlerFactory.js.map +1 -1
- package/dist/production/src/testing/TestTransactions.cjs +144 -0
- package/dist/production/src/testing/TestTransactions.cjs.map +1 -0
- package/dist/production/src/testing/TestTransactions.js +144 -0
- package/dist/production/src/testing/TestTransactions.js.map +1 -0
- 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 +1 -0
- package/dist/production/src/transfer/ExportApiControllerFactory.cjs.map +1 -1
- package/dist/production/src/transfer/ExportApiControllerFactory.js +1 -0
- package/dist/production/src/transfer/ExportApiControllerFactory.js.map +1 -1
- package/dist/production/src/transfer/ExportExecutor.cjs +4 -1
- package/dist/production/src/transfer/ExportExecutor.cjs.map +1 -1
- package/dist/production/src/transfer/ExportExecutor.js +4 -1
- package/dist/production/src/transfer/ExportExecutor.js.map +1 -1
- package/dist/production/src/transfer/ImportApiMiddlewareFactory.cjs +1 -0
- package/dist/production/src/transfer/ImportApiMiddlewareFactory.cjs.map +1 -1
- package/dist/production/src/transfer/ImportApiMiddlewareFactory.js +1 -0
- package/dist/production/src/transfer/ImportApiMiddlewareFactory.js.map +1 -1
- package/dist/production/src/transfer/ImportExecutor.cjs +7 -3
- package/dist/production/src/transfer/ImportExecutor.cjs.map +1 -1
- package/dist/production/src/transfer/ImportExecutor.js +7 -3
- 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.map +1 -1
- package/dist/production/src/utils/CryptoWrapper.cjs +4 -0
- package/dist/production/src/utils/CryptoWrapper.cjs.map +1 -1
- package/dist/production/src/utils/CryptoWrapper.js +4 -0
- package/dist/production/src/utils/CryptoWrapper.js.map +1 -1
- package/dist/production/src/utils/remoteAddress.cjs +5 -4
- package/dist/production/src/utils/remoteAddress.cjs.map +1 -1
- package/dist/production/src/utils/remoteAddress.js +5 -4
- package/dist/production/src/utils/remoteAddress.js.map +1 -1
- 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 +2 -2
- package/dist/production/src/utils/serverStartup.cjs.map +1 -1
- package/dist/production/src/utils/serverStartup.js.map +1 -1
- package/dist/tests/cases/unit/authenticatorGeoCountry.test.d.ts +2 -0
- package/dist/tests/cases/unit/authenticatorGeoCountry.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/forceHttpOk.test.d.ts +2 -0
- package/dist/tests/cases/unit/forceHttpOk.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/notFoundResponse.test.d.ts +2 -0
- package/dist/tests/cases/unit/notFoundResponse.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/oidcBackchannelLogout.test.d.ts +2 -0
- package/dist/tests/cases/unit/oidcBackchannelLogout.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/remoteAddress.test.d.ts +2 -0
- package/dist/tests/cases/unit/remoteAddress.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/serverConfig.test.d.ts +2 -0
- package/dist/tests/cases/unit/serverConfig.test.d.ts.map +1 -0
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/dist/types/MasterContainer.d.ts +34 -22
- package/dist/types/MasterContainer.d.ts.map +1 -1
- package/dist/types/application/application.d.ts +14 -5
- package/dist/types/application/application.d.ts.map +1 -1
- package/dist/types/application/forceHttpOk.d.ts +41 -0
- package/dist/types/application/forceHttpOk.d.ts.map +1 -0
- package/dist/types/application/index.d.ts +3 -2
- package/dist/types/application/index.d.ts.map +1 -1
- package/dist/types/bootstrap/Initializer.d.ts +1 -1
- package/dist/types/bootstrap/Initializer.d.ts.map +1 -1
- package/dist/types/bootstrap/index.d.ts +1 -1
- package/dist/types/bootstrap/index.d.ts.map +1 -1
- package/dist/types/common/Authorizator.d.ts +14 -3
- package/dist/types/common/Authorizator.d.ts.map +1 -1
- package/dist/types/common/ModuleInfoMiddleware.d.ts +1 -1
- package/dist/types/common/ModuleInfoMiddleware.d.ts.map +1 -1
- package/dist/types/common/NotFoundMiddleware.d.ts +8 -0
- package/dist/types/common/NotFoundMiddleware.d.ts.map +1 -0
- package/dist/types/common/index.d.ts +4 -3
- package/dist/types/common/index.d.ts.map +1 -1
- package/dist/types/config/ConfigProcessor.d.ts +1 -1
- package/dist/types/config/ConfigProcessor.d.ts.map +1 -1
- package/dist/types/config/config.d.ts +4 -4
- package/dist/types/config/config.d.ts.map +1 -1
- package/dist/types/config/configSchema.d.ts +37 -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 +3 -3
- 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 +8 -6
- package/dist/types/content/ContentApiControllerFactory.d.ts.map +1 -1
- package/dist/types/content/ContentQueryHandlerFactory.d.ts +2 -2
- package/dist/types/content/ContentQueryHandlerFactory.d.ts.map +1 -1
- package/dist/types/content/GraphQLSchemaContributor.d.ts +2 -2
- package/dist/types/content/GraphQLSchemaContributor.d.ts.map +1 -1
- package/dist/types/content/GraphQlSchemaFactory.d.ts +4 -4
- package/dist/types/content/GraphQlSchemaFactory.d.ts.map +1 -1
- package/dist/types/content/NotModifiedChecker.d.ts +1 -1
- package/dist/types/content/NotModifiedChecker.d.ts.map +1 -1
- package/dist/types/content/ProjectMembershipResolver.d.ts +1 -1
- package/dist/types/content/ProjectMembershipResolver.d.ts.map +1 -1
- package/dist/types/content/index.d.ts +9 -9
- package/dist/types/content/index.d.ts.map +1 -1
- package/dist/types/content/triggeredActionsListener.d.ts +2 -2
- package/dist/types/content/triggeredActionsListener.d.ts.map +1 -1
- package/dist/types/graphql/dbQueriesListener.d.ts +1 -1
- package/dist/types/graphql/dbQueriesListener.d.ts.map +1 -1
- package/dist/types/graphql/index.d.ts +3 -3
- package/dist/types/graphql/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +29 -28
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/misc/HomepageMiddlewareFactory.d.ts +1 -1
- package/dist/types/misc/HomepageMiddlewareFactory.d.ts.map +1 -1
- package/dist/types/misc/index.d.ts +1 -1
- package/dist/types/misc/index.d.ts.map +1 -1
- package/dist/types/plugin/Plugin.d.ts +4 -4
- package/dist/types/plugin/Plugin.d.ts.map +1 -1
- package/dist/types/project/ProjectContainer.d.ts +5 -5
- package/dist/types/project/ProjectContainer.d.ts.map +1 -1
- package/dist/types/project/ProjectContainerResolver.d.ts +3 -3
- package/dist/types/project/ProjectContainerResolver.d.ts.map +1 -1
- package/dist/types/project/ProjectContainerStore.d.ts +1 -1
- package/dist/types/project/ProjectContainerStore.d.ts.map +1 -1
- package/dist/types/project/ProjectInitializer.d.ts +1 -1
- package/dist/types/project/ProjectInitializer.d.ts.map +1 -1
- package/dist/types/project/ProjectSchemaResolver.d.ts +1 -1
- package/dist/types/project/ProjectSchemaResolver.d.ts.map +1 -1
- package/dist/types/project/config.d.ts +6 -0
- package/dist/types/project/config.d.ts.map +1 -1
- package/dist/types/project/index.d.ts +4 -4
- package/dist/types/project/index.d.ts.map +1 -1
- package/dist/types/project-common/ProjectContextResolver.d.ts +3 -3
- package/dist/types/project-common/ProjectContextResolver.d.ts.map +1 -1
- package/dist/types/project-common/index.d.ts +2 -2
- package/dist/types/project-common/index.d.ts.map +1 -1
- package/dist/types/projectGroup/ProjectGroupContainer.d.ts +13 -9
- 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 +3 -3
- package/dist/types/projectGroup/ProjectGroupResolver.d.ts.map +1 -1
- package/dist/types/prometheus/CollectHttpMetricsMiddelware.d.ts +4 -4
- package/dist/types/prometheus/CollectHttpMetricsMiddelware.d.ts.map +1 -1
- package/dist/types/prometheus/ProjectGroupContainerMetricsHook.d.ts +1 -1
- package/dist/types/prometheus/ProjectGroupContainerMetricsHook.d.ts.map +1 -1
- package/dist/types/prometheus/PrometheusRegistryFactory.d.ts +1 -1
- package/dist/types/prometheus/PrometheusRegistryFactory.d.ts.map +1 -1
- package/dist/types/prometheus/ShowMetricsMiddleware.d.ts +1 -1
- package/dist/types/prometheus/ShowMetricsMiddleware.d.ts.map +1 -1
- package/dist/types/prometheus/index.d.ts +2 -2
- package/dist/types/prometheus/index.d.ts.map +1 -1
- package/dist/types/system/SystemApiMiddlewareFactory.d.ts +3 -3
- package/dist/types/system/SystemApiMiddlewareFactory.d.ts.map +1 -1
- package/dist/types/system/SystemGraphQLContextFactory.d.ts +3 -3
- package/dist/types/system/SystemGraphQLContextFactory.d.ts.map +1 -1
- package/dist/types/system/SystemGraphQLHandlerFactory.d.ts +1 -1
- package/dist/types/system/SystemGraphQLHandlerFactory.d.ts.map +1 -1
- package/dist/types/system/index.d.ts +3 -3
- package/dist/types/system/index.d.ts.map +1 -1
- package/dist/types/tenant/OidcBackchannelLogoutMiddlewareFactory.d.ts +18 -0
- package/dist/types/tenant/OidcBackchannelLogoutMiddlewareFactory.d.ts.map +1 -0
- package/dist/types/tenant/TenantApiMiddlewareFactory.d.ts +1 -1
- package/dist/types/tenant/TenantApiMiddlewareFactory.d.ts.map +1 -1
- package/dist/types/tenant/TenantGraphQLHandlerFactory.d.ts +1 -1
- package/dist/types/tenant/TenantGraphQLHandlerFactory.d.ts.map +1 -1
- package/dist/types/tenant/index.d.ts +3 -2
- package/dist/types/tenant/index.d.ts.map +1 -1
- package/dist/types/testing/TestTransactions.d.ts +22 -0
- package/dist/types/testing/TestTransactions.d.ts.map +1 -0
- package/dist/types/testing/index.d.ts +2 -0
- package/dist/types/testing/index.d.ts.map +1 -0
- package/dist/types/transfer/CommandStream.d.ts +1 -1
- package/dist/types/transfer/CommandStream.d.ts.map +1 -1
- package/dist/types/transfer/ContentSchemaTransferMappingFactory.d.ts +1 -1
- package/dist/types/transfer/ContentSchemaTransferMappingFactory.d.ts.map +1 -1
- package/dist/types/transfer/ExportApiControllerFactory.d.ts +3 -3
- package/dist/types/transfer/ExportApiControllerFactory.d.ts.map +1 -1
- package/dist/types/transfer/ExportExecutor.d.ts +4 -4
- package/dist/types/transfer/ExportExecutor.d.ts.map +1 -1
- package/dist/types/transfer/ImportApiMiddlewareFactory.d.ts +3 -3
- package/dist/types/transfer/ImportApiMiddlewareFactory.d.ts.map +1 -1
- package/dist/types/transfer/ImportExecutor.d.ts +6 -6
- package/dist/types/transfer/ImportExecutor.d.ts.map +1 -1
- package/dist/types/transfer/SystemSchemaTransferMappingFactory.d.ts +1 -1
- package/dist/types/transfer/SystemSchemaTransferMappingFactory.d.ts.map +1 -1
- package/dist/types/transfer/index.d.ts +6 -6
- package/dist/types/transfer/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/types/utils/CryptoWrapper.d.ts +2 -0
- package/dist/types/utils/CryptoWrapper.d.ts.map +1 -1
- package/dist/types/utils/remoteAddress.d.ts.map +1 -1
- package/dist/types/utils/serverStartup.d.ts +4 -4
- package/dist/types/utils/serverStartup.d.ts.map +1 -1
- package/dist/types/workers/index.d.ts +1 -1
- package/dist/types/workers/index.d.ts.map +1 -1
- package/package.json +15 -15
- package/src/MasterContainer.ts +75 -27
- package/src/application/application.ts +44 -13
- package/src/application/forceHttpOk.ts +70 -0
- package/src/application/index.ts +3 -2
- package/src/bootstrap/Initializer.ts +1 -1
- package/src/bootstrap/index.ts +1 -1
- package/src/common/Authorizator.ts +93 -5
- package/src/common/ModuleInfoMiddleware.ts +1 -1
- package/src/common/NotFoundMiddleware.ts +18 -0
- package/src/common/index.ts +4 -3
- package/src/config/ConfigProcessor.ts +1 -1
- package/src/config/config.ts +5 -5
- package/src/config/configSchema.ts +67 -1
- package/src/config/configTemplate.ts +11 -0
- package/src/config/projectConfigResolver.ts +4 -4
- package/src/config/tenantConfigResolver.ts +2 -2
- package/src/content/ContentApiControllerFactory.ts +43 -10
- package/src/content/ContentQueryHandlerFactory.ts +3 -3
- package/src/content/ContentSchemaResolver.ts +2 -2
- package/src/content/GraphQLSchemaContributor.ts +2 -2
- package/src/content/GraphQlSchemaFactory.ts +4 -4
- package/src/content/NotModifiedChecker.ts +1 -1
- package/src/content/ProjectMembershipResolver.ts +2 -2
- package/src/content/index.ts +9 -9
- package/src/content/triggeredActionsListener.ts +2 -2
- package/src/graphql/dbQueriesListener.ts +1 -1
- package/src/graphql/index.ts +3 -3
- package/src/index.ts +28 -27
- package/src/misc/HomepageMiddlewareFactory.ts +2 -2
- package/src/misc/index.ts +1 -1
- package/src/plugin/Plugin.ts +4 -4
- package/src/project/ProjectContainer.ts +6 -6
- package/src/project/ProjectContainerResolver.ts +4 -4
- package/src/project/ProjectContainerStore.ts +1 -1
- package/src/project/ProjectInitializer.ts +1 -1
- package/src/project/ProjectSchemaResolver.ts +1 -1
- package/src/project/config.ts +6 -0
- package/src/project/index.ts +4 -4
- package/src/project-common/ProjectContextResolver.ts +2 -2
- package/src/project-common/index.ts +2 -2
- package/src/projectGroup/ProjectGroupContainer.ts +34 -11
- package/src/projectGroup/ProjectGroupContainerResolver.ts +2 -2
- package/src/projectGroup/ProjectGroupResolver.ts +4 -4
- package/src/prometheus/CollectHttpMetricsMiddelware.ts +4 -4
- package/src/prometheus/ProjectGroupContainerMetricsHook.ts +2 -2
- package/src/prometheus/PrometheusRegistryFactory.ts +2 -2
- package/src/prometheus/ShowMetricsMiddleware.ts +1 -1
- package/src/prometheus/dbMetrics.ts +1 -1
- package/src/prometheus/index.ts +2 -2
- package/src/system/ContentQueryExecutor.ts +2 -2
- package/src/system/SystemApiMiddlewareFactory.ts +5 -5
- package/src/system/SystemGraphQLContextFactory.ts +3 -3
- package/src/system/SystemGraphQLHandlerFactory.ts +1 -1
- package/src/system/index.ts +3 -3
- package/src/tenant/OidcBackchannelLogoutMiddlewareFactory.ts +63 -0
- package/src/tenant/TenantApiMiddlewareFactory.ts +10 -4
- package/src/tenant/TenantGraphQLHandlerFactory.ts +1 -1
- package/src/tenant/index.ts +3 -2
- package/src/testing/TestTransactions.ts +237 -0
- package/src/testing/index.ts +1 -0
- package/src/transfer/CommandStream.ts +2 -2
- package/src/transfer/ContentSchemaTransferMappingFactory.ts +1 -1
- package/src/transfer/ExportApiControllerFactory.ts +6 -6
- package/src/transfer/ExportExecutor.ts +12 -6
- package/src/transfer/ImportApiMiddlewareFactory.ts +5 -5
- package/src/transfer/ImportExecutor.ts +12 -9
- package/src/transfer/SystemSchemaTransferMappingFactory.ts +2 -2
- package/src/transfer/index.ts +6 -6
- package/src/utils/CryptoWrapper.ts +5 -0
- package/src/utils/remoteAddress.ts +3 -1
- package/src/utils/sentry.ts +1 -1
- package/src/utils/serverStartup.ts +3 -3
- package/src/workers/index.ts +1 -1
- package/tests/cases/unit/authenticatorGeoCountry.test.ts +100 -0
- package/tests/cases/unit/configResolver.test.ts +33 -3
- package/tests/cases/unit/crypto.test.ts +1 -1
- package/tests/cases/unit/forceHttpOk.test.ts +92 -0
- package/tests/cases/unit/notFoundResponse.test.ts +39 -0
- package/tests/cases/unit/oidcBackchannelLogout.test.ts +113 -0
- package/tests/cases/unit/projectMembershipResolver.test.ts +2 -2
- package/tests/cases/unit/remoteAddress.test.ts +90 -0
- package/tests/cases/unit/serverConfig.test.ts +70 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImportExecutor.js","sources":["../../../../../packages/engine-http/src/transfer/ImportExecutor.ts"],"sourcesContent":["import { Client, Connection, ConstraintHelper, DatabaseMetadataResolver, wrapIdentifier } from '@contember/database'\nimport { Model, Schema } from '@contember/schema'\nimport * as Typesafe from '@contember/typesafe'\nimport { ParseError } from '@contember/typesafe'\nimport { Command, CommandArgsMap, CommandName } from './Command'\nimport { DatabaseContext, StageBySlugQuery } from '@contember/engine-system-api'\nimport { DbColumnSchema, TransferMapping, TransferTableMapping } from './TransferMapping'\nimport { ContentSchemaTransferMappingFactory } from './ContentSchemaTransferMappingFactory'\nimport { SystemSchemaTransferMappingFactory } from './SystemSchemaTransferMappingFactory'\nimport { AuthResult, HttpErrorResponse } from '../common'\nimport { ProjectGroupContainer } from '../projectGroup/ProjectGroupContainer'\n\ntype Cell = boolean | number | string | readonly string[] | readonly number[] | readonly boolean[] | null\ntype Row = readonly Cell[]\n\ntype InsertContext = {\n\ttableName: string\n\tinsertStartFragment: string\n\trowFragment: string\n\trowParser: Typesafe.Type<Row>\n\trows: Array<Row>\n\tinsertedRowCount: number\n}\n\nexport class ImportError extends Error {\n}\n\nconst parsePgTextArray = (value: string): string[] => {\n\tif (value === '{}') return []\n\tif (!value.startsWith('{') || !value.endsWith('}')) {\n\t\tthrow new ParseError([], `invalid PostgreSQL array literal: ${value}`)\n\t}\n\tconst inner = value.slice(1, -1)\n\tconst result: string[] = []\n\tlet current = ''\n\tlet inQuotes = false\n\tlet escaped = false\n\tfor (const ch of inner) {\n\t\tif (escaped) {\n\t\t\tcurrent += ch\n\t\t\tescaped = false\n\t\t} else if (ch === '\\\\') {\n\t\t\tescaped = true\n\t\t} else if (ch === '\"') {\n\t\t\tinQuotes = !inQuotes\n\t\t} else if (ch === ',' && !inQuotes) {\n\t\t\tresult.push(current)\n\t\t\tcurrent = ''\n\t\t} else {\n\t\t\tcurrent += ch\n\t\t}\n\t}\n\tresult.push(current)\n\treturn result\n}\n\nconst listType = <T extends Typesafe.Json>(arrayType: Typesafe.Type<T>): Typesafe.Type<T> => {\n\treturn (input: unknown, path: PropertyKey[] = []) => {\n\t\tif (Array.isArray(input)) {\n\t\t\treturn arrayType(input, path)\n\t\t}\n\t\tif (typeof input === 'string' && input.startsWith('{')) {\n\t\t\treturn arrayType(parsePgTextArray(input), path)\n\t\t}\n\t\treturn arrayType(input, path)\n\t}\n}\n\ntype CommandProcessor<T extends CommandName> = (it: CommandIterator<T>) => Promise<CommandIterator | null>\ntype CommandProcessorMap<T extends CommandName> = { [N in CommandName]?: N extends T ? CommandProcessor<N> : undefined }\n\nclass CommandIterator<T extends CommandName = CommandName> {\n\tprivate constructor(\n\t\tpublic readonly commandName: T,\n\t\tpublic readonly commandArgs: CommandArgsMap[T],\n\t\tprivate readonly commandIterator: AsyncIterator<Command>,\n\t) {\n\t}\n\n\tpublic static async create(commands: AsyncIterable<Command>): Promise<CommandIterator | null> {\n\t\tconst commandIterator = commands[Symbol.asyncIterator]()\n\t\tconst result = await commandIterator.next()\n\n\t\tif (result.done) {\n\t\t\treturn null\n\t\t}\n\n\t\tconst [name, ...args] = result.value\n\t\treturn new CommandIterator(name, args, commandIterator)\n\t}\n\n\tasync next(): Promise<CommandIterator | null> {\n\t\tconst result = await this.commandIterator.next()\n\n\t\tif (result.done) {\n\t\t\treturn null\n\t\t}\n\n\t\tconst [name, ...args] = result.value\n\t\treturn new CommandIterator(name, args, this.commandIterator)\n\t}\n}\n\nexport class ImportExecutor {\n\tconstructor(\n\t\tprivate readonly contentSchemaTransferMappingFactory: ContentSchemaTransferMappingFactory,\n\t\tprivate readonly systemSchemaTransferMappingFactory: SystemSchemaTransferMappingFactory,\n\t\tprivate readonly databaseMetadataResolver: DatabaseMetadataResolver,\n\t) {\n\t}\n\n\tasync import(groupContainer: ProjectGroupContainer, authResult: AuthResult, commands: AsyncIterable<Command>) {\n\t\tconst it = await CommandIterator.create(commands)\n\n\t\tconst final = await this.match(it, {\n\t\t\timportContentSchemaBegin: it => this.importContentSchemaBegin(groupContainer, authResult, it),\n\t\t\timportSystemSchemaBegin: it => this.importSystemSchemaBegin(groupContainer, authResult, it),\n\t\t})\n\n\t\tif (final !== null) {\n\t\t\tthrow new ImportError(`Unexpected ${final.commandName}`)\n\t\t}\n\t}\n\n\tprivate async match<T extends CommandName>(it: CommandIterator<T> | null, processors: CommandProcessorMap<T>) {\n\t\tlet next: CommandIterator | null = it\n\n\t\twhile (next !== null) {\n\t\t\tconst processor = processors[next.commandName]\n\n\t\t\tif (processor) {\n\t\t\t\tnext = await processor(next as any)\n\t\t\t} else {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\treturn next\n\t}\n\n\tprivate async importContentSchemaBegin(\n\t\tgroupContainer: ProjectGroupContainer,\n\t\tauthResult: AuthResult,\n\t\tit: CommandIterator<'importContentSchemaBegin'>,\n\t) {\n\t\tconst [options] = it.commandArgs\n\t\tconst projectContainer = await this.createProjectContainer(groupContainer, options.project)\n\t\tconst systemDatabaseContext = projectContainer.systemDatabaseContext\n\t\tconst stage = await this.fetchStageBySlug(systemDatabaseContext, options.project, options.stage)\n\n\t\tconst contentSchema = await projectContainer.contentSchemaResolver.getSchema({ db: systemDatabaseContext, stage: stage.slug, normalize: true })\n\n\t\tif (contentSchema.meta.version !== options.schemaVersion) {\n\t\t\tthrow new ImportError(\n\t\t\t\t`Incompatible schema version (import version ${options.schemaVersion} does not match server version ${contentSchema.meta.version})`,\n\t\t\t)\n\t\t}\n\n\t\tawait this.requireImportAccess(groupContainer, contentSchema.schema, authResult, options.project, 'content')\n\t\tconst contentDatabaseClient = projectContainer.connection.createClient(stage.schema, {})\n\t\tconst mapping = this.contentSchemaTransferMappingFactory.createContentSchemaMapping(contentSchema.schema)\n\n\t\treturn await contentDatabaseClient.transaction(async db => {\n\t\t\tawait this.disableStatementTimeout(db)\n\t\t\tawait this.disableTriggers(db, options.tables)\n\t\t\tawait this.lockTables(db, options.tables)\n\t\t\tawait this.truncateTables(db, options.tables)\n\n\t\t\tconst metadata = await this.databaseMetadataResolver.resolveMetadata(db, db.schema)\n\t\t\tconst constraintHelper = new ConstraintHelper(db, metadata)\n\t\t\tawait constraintHelper.setConstraintsDeferred('foreignKey')\n\n\t\t\tconst result = await this.match(await it.next(), {\n\t\t\t\timportSequence: it => this.importSequence(db, mapping, it),\n\t\t\t\tinsertBegin: it => this.insertBegin(db, mapping, it),\n\t\t\t})\n\n\t\t\tawait constraintHelper.setConstraintsImmediate('foreignKey')\n\t\t\tawait this.enableTriggers(db, options.tables)\n\n\t\t\treturn result\n\t\t})\n\t}\n\n\tprivate async importSystemSchemaBegin(\n\t\tgroupContainer: ProjectGroupContainer,\n\t\tauthResult: AuthResult,\n\t\tit: CommandIterator<'importSystemSchemaBegin'>,\n\t) {\n\t\tconst [options] = it.commandArgs\n\t\tconst projectContainer = await this.createProjectContainer(groupContainer, options.project)\n\t\tconst schema = await groupContainer.projectSchemaResolver.getSchema(options.project)\n\n\t\tif (schema === undefined) {\n\t\t\tthrow new ImportError(`Project ${options.project} does not have schema`)\n\t\t}\n\n\t\tawait this.requireImportAccess(groupContainer, schema, authResult, options.project, 'system')\n\t\tconst systemDatabaseContext = projectContainer.systemDatabaseContext\n\t\tconst mapping = this.systemSchemaTransferMappingFactory.build()\n\n\t\treturn await systemDatabaseContext.client.transaction(async db => {\n\t\t\tawait this.disableStatementTimeout(db)\n\t\t\tawait this.truncateTables(db, options.tables)\n\n\t\t\tconst metadata = await this.databaseMetadataResolver.resolveMetadata(db, db.schema)\n\t\t\tconst constraintHelper = new ConstraintHelper(db, metadata)\n\t\t\tawait constraintHelper.setConstraintsDeferred('foreignKey')\n\n\t\t\treturn await this.match(await it.next(), {\n\t\t\t\tinsertBegin: it => this.insertBegin(db, mapping, it),\n\t\t\t})\n\t\t})\n\t}\n\n\tprivate async importSequence(\n\t\tdb: Client<Connection.TransactionLike>,\n\t\tmapping: TransferMapping,\n\t\tit: CommandIterator<'importSequence'>,\n\t): Promise<CommandIterator | null> {\n\t\tconst [options] = it.commandArgs\n\n\t\tawait db.query(\n\t\t\t'SELECT setval(pg_get_serial_sequence(?, ?), ?)',\n\t\t\t[`${db.schema}.${options.table}`, options.column, options.value],\n\t\t)\n\n\t\treturn it.next()\n\t}\n\n\tprivate async insertBegin(\n\t\tdb: Client<Connection.TransactionLike>,\n\t\tmapping: TransferMapping,\n\t\tit: CommandIterator<'insertBegin'>,\n\t): Promise<CommandIterator | null> {\n\t\tconst [options] = it.commandArgs\n\t\tconst insertContext = await this.buildInsertContext(db, mapping, db.schema, options.table, options.columns)\n\t\tlet insertRowsPromise: Promise<Connection.Result> | null = null\n\n\t\t// postgresql has a limit of 65535 parameters per query\n\t\tconst batchSize = Math.max(1, Math.min(1000, Math.floor(65500 / options.columns.length)))\n\n\t\tconst result = await this.match(await it.next(), {\n\t\t\tinsertRow: async it => {\n\t\t\t\tconst [values] = it.commandArgs\n\n\t\t\t\ttry {\n\t\t\t\t\tinsertContext.rows.push(insertContext.rowParser(values))\n\t\t\t\t} catch (e) {\n\t\t\t\t\tif (e instanceof ParseError) {\n\t\t\t\t\t\tthrow new ImportError(`Invalid row ${JSON.stringify(values)} for table ${options.table}: ${e.message}`)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow e\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (insertContext.rows.length === batchSize) {\n\t\t\t\t\tawait insertRowsPromise\n\t\t\t\t\tinsertRowsPromise = this.insertRows(db, insertContext)\n\t\t\t\t\tinsertContext.insertedRowCount += insertContext.rows.length\n\t\t\t\t\tinsertContext.rows = []\n\t\t\t\t}\n\n\t\t\t\treturn await it.next()\n\t\t\t},\n\t\t})\n\n\t\tif (insertContext.rows.length > 0) {\n\t\t\tawait insertRowsPromise\n\t\t\tawait this.insertRows(db, insertContext)\n\t\t\tinsertContext.insertedRowCount += insertContext.rows.length\n\t\t\tinsertContext.rows = []\n\t\t}\n\n\t\tif (result === null || result.commandName !== 'insertEnd') {\n\t\t\tthrow new ImportError(`Missing insertEnd command`)\n\t\t}\n\n\t\treturn await result.next()\n\t}\n\n\tprivate async createProjectContainer(groupContainer: ProjectGroupContainer, projectSlug: string) {\n\t\tconst projectContainerResolver = groupContainer.projectContainerResolver\n\t\tconst projectContainer = await projectContainerResolver.getProjectContainer(projectSlug, { alias: true })\n\n\t\tif (projectContainer === undefined) {\n\t\t\tthrow new ImportError(`Project ${projectSlug} does not exists.`)\n\t\t}\n\n\t\treturn projectContainer\n\t}\n\n\tprivate async requireImportAccess(\n\t\tgroupContainer: ProjectGroupContainer,\n\t\tschema: Schema,\n\t\tauthResult: AuthResult,\n\t\tprojectSlug: string,\n\t\tkind: 'content' | 'system',\n\t) {\n\t\tconst { effective: memberships } = await groupContainer.projectMembershipResolver.resolveMemberships({\n\t\t\trequest: { get: () => '' },\n\t\t\tacl: schema.acl,\n\t\t\tprojectSlug: projectSlug,\n\t\t\tidentity: {\n\t\t\t\tidentityId: authResult.identityId,\n\t\t\t\troles: authResult.roles,\n\t\t\t},\n\t\t})\n\n\t\tconst projectRoles = memberships.map(it => it.role)\n\n\t\tif (!projectRoles.some(role => schema.acl.roles[role]?.[kind]?.import)) {\n\t\t\tthrow new HttpErrorResponse(403, `You are not allowed to import ${kind} in ${projectSlug}`)\n\t\t}\n\t}\n\n\tprivate async fetchStageBySlug(systemDatabaseContext: DatabaseContext, projectSlug: string, stageSlug: string) {\n\t\tconst stage = await systemDatabaseContext.queryHandler.fetch(new StageBySlugQuery(stageSlug))\n\n\t\tif (stage === null) {\n\t\t\tthrow new ImportError(`Project ${projectSlug} does not have stage ${stageSlug}.`)\n\t\t}\n\n\t\treturn stage\n\t}\n\n\tprivate async disableTriggers(db: Client, tableNames: readonly string[]) {\n\t\tfor (const tableName of tableNames) {\n\t\t\tconst tableNameQuoted = `${wrapIdentifier(db.schema)}.${wrapIdentifier(tableName)}`\n\t\t\tawait db.query(`ALTER TABLE ${tableNameQuoted} DISABLE TRIGGER USER`)\n\t\t}\n\t}\n\n\tprivate async enableTriggers(db: Client, tableNames: readonly string[]) {\n\t\tfor (const tableName of tableNames) {\n\t\t\tconst tableNameQuoted = `${wrapIdentifier(db.schema)}.${wrapIdentifier(tableName)}`\n\t\t\tawait db.query(`ALTER TABLE ${tableNameQuoted} ENABLE TRIGGER USER`)\n\t\t}\n\t}\n\n\tprivate async lockTables(db: Client, tableNames: readonly string[]) {\n\t\tconst tableNamesQuoted = tableNames.map(it => `${wrapIdentifier(db.schema)}.${wrapIdentifier(it)}`)\n\t\tawait db.query(`LOCK ${tableNamesQuoted.join(', ')} IN EXCLUSIVE MODE`)\n\t}\n\n\tprivate async truncateTables(db: Client, tableNames: readonly string[]) {\n\t\tconst tableNamesQuoted = tableNames.map(it => `${wrapIdentifier(db.schema)}.${wrapIdentifier(it)}`)\n\t\tawait db.query(`TRUNCATE ${tableNamesQuoted.join(', ')}`)\n\t}\n\n\tprivate async disableStatementTimeout(db: Client) {\n\t\tawait db.query('SET LOCAL statement_timeout = 0')\n\t}\n\n\tprivate async insertRows(db: Client, context: InsertContext) {\n\t\tconst rowsFragment = context.rows.map(_ => context.rowFragment).join(',\\n')\n\t\tconst sql = context.insertStartFragment + rowsFragment\n\t\tconst parameters: Cell[] = []\n\n\t\tfor (const row of context.rows) {\n\t\t\tfor (const cell of row) {\n\t\t\t\tparameters.push(cell)\n\t\t\t}\n\t\t}\n\n\t\treturn await db.query(sql, parameters)\n\t}\n\n\tprivate async buildInsertContext(\n\t\tdb: Client,\n\t\tmapping: TransferMapping,\n\t\tschema: string,\n\t\ttableName: string,\n\t\tcolumnNames: readonly string[],\n\t): Promise<InsertContext> {\n\t\tconst tableMapping = mapping.tables[tableName]\n\t\tconst columns = []\n\n\t\tif (tableMapping === undefined) {\n\t\t\tthrow new ImportError(`Unknown table ${tableName}`)\n\t\t}\n\n\t\tfor (const columnName of columnNames) {\n\t\t\tconst column = tableMapping.columns[columnName]\n\n\t\t\tif (column === undefined) {\n\t\t\t\tthrow new ImportError(`Unknown column ${tableName}.${columnName}`)\n\t\t\t}\n\n\t\t\tcolumns.push(column)\n\t\t}\n\n\t\tconst insertStartFragment = (tableMapping.createInsertStartFragment ?? this.createInsertStartFragment)(schema, tableName, columnNames)\n\t\tconst rowFragment = '(' + columns.map(_ => '?').join(', ') + ')'\n\t\tconst rowParser = await this.buildRowParser(db, tableMapping, columns)\n\n\t\treturn {\n\t\t\ttableName,\n\t\t\tinsertStartFragment,\n\t\t\trowFragment,\n\t\t\trowParser,\n\t\t\trows: [],\n\t\t\tinsertedRowCount: 0,\n\t\t}\n\t}\n\n\tprivate createInsertStartFragment(schema: string, tableName: string, columnNames: readonly string[]): string {\n\t\tconst tableQuoted = `${wrapIdentifier(schema)}.${wrapIdentifier(tableName)}`\n\t\tconst columnsQuoted = '(' + columnNames.map(it => wrapIdentifier(it)).join(', ') + ')'\n\t\treturn `INSERT INTO ${tableQuoted} ${columnsQuoted} VALUES\\n`\n\t}\n\n\tprivate async buildRowParser(db: Client, tableMapping: TransferTableMapping, columns: DbColumnSchema[]): Promise<Typesafe.Type<readonly Cell[]>> {\n\t\tconst baseType = Typesafe.tuple(...columns.map(it => {\n\t\t\tconst base = this.buildColumnRuntimeType(it)\n\t\t\treturn it.nullable ? Typesafe.nullable(base) : base\n\t\t}))\n\n\t\tif (tableMapping.createRowParser === undefined) {\n\t\t\treturn baseType\n\t\t}\n\n\t\treturn await tableMapping.createRowParser(db, columns.map(it => it.name), baseType)\n\t}\n\n\tprivate buildColumnRuntimeType(column: DbColumnSchema): Typesafe.Type<Exclude<Cell, null>> {\n\t\tswitch (column.type) {\n\t\t\tcase Model.ColumnType.Uuid:\n\t\t\tcase Model.ColumnType.String:\n\t\t\tcase Model.ColumnType.Enum:\n\t\t\tcase Model.ColumnType.DateTime:\n\t\t\tcase Model.ColumnType.Time:\n\t\t\tcase Model.ColumnType.Date:\n\t\t\tcase Model.ColumnType.Json:\n\t\t\t\treturn column.list ? listType(Typesafe.array(Typesafe.string)) : Typesafe.string\n\t\t\tcase Model.ColumnType.Int:\n\t\t\tcase Model.ColumnType.Double:\n\t\t\t\treturn column.list ? listType(Typesafe.array(Typesafe.number)) : Typesafe.number\n\t\t\tcase Model.ColumnType.Bool:\n\t\t\t\treturn column.list ? listType(Typesafe.array(Typesafe.boolean)) : Typesafe.boolean\n\t\t}\n\t}\n}\n"],"names":["it"],"mappings":";;;;;;AAwBO,MAAM,oBAAoB,MAAM;AACvC;AAEA,MAAM,mBAAmB,CAAC,UAA4B;AACrD,MAAI,UAAU,KAAM,QAAO,CAAA;AAC3B,MAAI,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,SAAS,GAAG,GAAG;AACnD,UAAM,IAAI,WAAW,CAAA,GAAI,qCAAqC,KAAK,EAAE;AAAA,EACtE;AACA,QAAM,QAAQ,MAAM,MAAM,GAAG,EAAE;AAC/B,QAAM,SAAmB,CAAA;AACzB,MAAI,UAAU;AACd,MAAI,WAAW;AACf,MAAI,UAAU;AACd,aAAW,MAAM,OAAO;AACvB,QAAI,SAAS;AACZ,iBAAW;AACX,gBAAU;AAAA,IACX,WAAW,OAAO,MAAM;AACvB,gBAAU;AAAA,IACX,WAAW,OAAO,KAAK;AACtB,iBAAW,CAAC;AAAA,IACb,WAAW,OAAO,OAAO,CAAC,UAAU;AACnC,aAAO,KAAK,OAAO;AACnB,gBAAU;AAAA,IACX,OAAO;AACN,iBAAW;AAAA,IACZ;AAAA,EACD;AACA,SAAO,KAAK,OAAO;AACnB,SAAO;AACR;AAEA,MAAM,WAAW,CAA0B,cAAkD;AAC5F,SAAO,CAAC,OAAgB,OAAsB,OAAO;AACpD,QAAI,MAAM,QAAQ,KAAK,GAAG;AACzB,aAAO,UAAU,OAAO,IAAI;AAAA,IAC7B;AACA,QAAI,OAAO,UAAU,YAAY,MAAM,WAAW,GAAG,GAAG;AACvD,aAAO,UAAU,iBAAiB,KAAK,GAAG,IAAI;AAAA,IAC/C;AACA,WAAO,UAAU,OAAO,IAAI;AAAA,EAC7B;AACD;AAKA,MAAM,gBA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EQ,uBAAuB,QAA4D;AAC1F,YAAQ,OAAO,MAAA;AAAA,MACd,KAAK,MAAM,WAAW;AAAA,MACtB,KAAK,MAAM,WAAW;AAAA,MACtB,KAAK,MAAM,WAAW;AAAA,MACtB,KAAK,MAAM,WAAW;AAAA,MACtB,KAAK,MAAM,WAAW;AAAA,MACtB,KAAK,MAAM,WAAW;AAAA,MACtB,KAAK,MAAM,WAAW;AACrB,eAAO,OAAO,OAAO,SAAS,SAAS,MAAM,SAAS,MAAM,CAAC,IAAI,SAAS;AAAA,MAC3E,KAAK,MAAM,WAAW;AAAA,MACtB,KAAK,MAAM,WAAW;AACrB,eAAO,OAAO,OAAO,SAAS,SAAS,MAAM,SAAS,MAAM,CAAC,IAAI,SAAS;AAAA,MAC3E,KAAK,MAAM,WAAW;AACrB,eAAO,OAAO,OAAO,SAAS,SAAS,MAAM,SAAS,OAAO,CAAC,IAAI,SAAS;AAAA,IAAA;AAAA,EAE9E;AACD;"}
|
|
1
|
+
{"version":3,"file":"ImportExecutor.js","sources":["../../../../../packages/engine-http/src/transfer/ImportExecutor.ts"],"sourcesContent":["import { Client, Connection, ConstraintHelper, DatabaseMetadataResolver, wrapIdentifier } from '@contember/database'\nimport { Model, Schema } from '@contember/schema'\nimport * as Typesafe from '@contember/typesafe'\nimport { ParseError } from '@contember/typesafe'\nimport { Command, CommandArgsMap, CommandName } from './Command.js'\nimport { DatabaseContext, StageBySlugQuery } from '@contember/engine-system-api'\nimport { DbColumnSchema, TransferMapping, TransferTableMapping } from './TransferMapping.js'\nimport { ContentSchemaTransferMappingFactory } from './ContentSchemaTransferMappingFactory.js'\nimport { SystemSchemaTransferMappingFactory } from './SystemSchemaTransferMappingFactory.js'\nimport { AuthResult, HttpErrorResponse } from '../common/index.js'\nimport { ProjectGroupContainer } from '../projectGroup/ProjectGroupContainer.js'\n\ntype Cell = boolean | number | string | readonly string[] | readonly number[] | readonly boolean[] | null\ntype Row = readonly Cell[]\n\ntype InsertContext = {\n\ttableName: string\n\tinsertStartFragment: string\n\trowFragment: string\n\trowParser: Typesafe.Type<Row>\n\trows: Array<Row>\n\tinsertedRowCount: number\n}\n\nexport class ImportError extends Error {\n}\n\nconst parsePgTextArray = (value: string): string[] => {\n\tif (value === '{}') return []\n\tif (!value.startsWith('{') || !value.endsWith('}')) {\n\t\tthrow new ParseError([], `invalid PostgreSQL array literal: ${value}`)\n\t}\n\tconst inner = value.slice(1, -1)\n\tconst result: string[] = []\n\tlet current = ''\n\tlet inQuotes = false\n\tlet escaped = false\n\tfor (const ch of inner) {\n\t\tif (escaped) {\n\t\t\tcurrent += ch\n\t\t\tescaped = false\n\t\t} else if (ch === '\\\\') {\n\t\t\tescaped = true\n\t\t} else if (ch === '\"') {\n\t\t\tinQuotes = !inQuotes\n\t\t} else if (ch === ',' && !inQuotes) {\n\t\t\tresult.push(current)\n\t\t\tcurrent = ''\n\t\t} else {\n\t\t\tcurrent += ch\n\t\t}\n\t}\n\tresult.push(current)\n\treturn result\n}\n\nconst listType = <T extends Typesafe.Json>(arrayType: Typesafe.Type<T>): Typesafe.Type<T> => {\n\treturn (input: unknown, path: PropertyKey[] = []) => {\n\t\tif (Array.isArray(input)) {\n\t\t\treturn arrayType(input, path)\n\t\t}\n\t\tif (typeof input === 'string' && input.startsWith('{')) {\n\t\t\treturn arrayType(parsePgTextArray(input), path)\n\t\t}\n\t\treturn arrayType(input, path)\n\t}\n}\n\ntype CommandProcessor<T extends CommandName> = (it: CommandIterator<T>) => Promise<CommandIterator | null>\ntype CommandProcessorMap<T extends CommandName> = { [N in CommandName]?: N extends T ? CommandProcessor<N> : undefined }\n\nclass CommandIterator<T extends CommandName = CommandName> {\n\tprivate constructor(\n\t\tpublic readonly commandName: T,\n\t\tpublic readonly commandArgs: CommandArgsMap[T],\n\t\tprivate readonly commandIterator: AsyncIterator<Command>,\n\t) {\n\t}\n\n\tpublic static async create(commands: AsyncIterable<Command>): Promise<CommandIterator | null> {\n\t\tconst commandIterator = commands[Symbol.asyncIterator]()\n\t\tconst result = await commandIterator.next()\n\n\t\tif (result.done) {\n\t\t\treturn null\n\t\t}\n\n\t\tconst [name, ...args] = result.value\n\t\treturn new CommandIterator(name, args, commandIterator)\n\t}\n\n\tasync next(): Promise<CommandIterator | null> {\n\t\tconst result = await this.commandIterator.next()\n\n\t\tif (result.done) {\n\t\t\treturn null\n\t\t}\n\n\t\tconst [name, ...args] = result.value\n\t\treturn new CommandIterator(name, args, this.commandIterator)\n\t}\n}\n\nexport class ImportExecutor {\n\tconstructor(\n\t\tprivate readonly contentSchemaTransferMappingFactory: ContentSchemaTransferMappingFactory,\n\t\tprivate readonly systemSchemaTransferMappingFactory: SystemSchemaTransferMappingFactory,\n\t\tprivate readonly databaseMetadataResolver: DatabaseMetadataResolver,\n\t) {\n\t}\n\n\tasync import(groupContainer: ProjectGroupContainer, authResult: AuthResult, commands: AsyncIterable<Command>) {\n\t\tconst it = await CommandIterator.create(commands)\n\n\t\tconst final = await this.match(it, {\n\t\t\timportContentSchemaBegin: it => this.importContentSchemaBegin(groupContainer, authResult, it),\n\t\t\timportSystemSchemaBegin: it => this.importSystemSchemaBegin(groupContainer, authResult, it),\n\t\t})\n\n\t\tif (final !== null) {\n\t\t\tthrow new ImportError(`Unexpected ${final.commandName}`)\n\t\t}\n\t}\n\n\tprivate async match<T extends CommandName>(it: CommandIterator<T> | null, processors: CommandProcessorMap<T>) {\n\t\tlet next: CommandIterator | null = it\n\n\t\twhile (next !== null) {\n\t\t\tconst processor = processors[next.commandName]\n\n\t\t\tif (processor) {\n\t\t\t\tnext = await processor(next as any)\n\t\t\t} else {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\treturn next\n\t}\n\n\tprivate async importContentSchemaBegin(\n\t\tgroupContainer: ProjectGroupContainer,\n\t\tauthResult: AuthResult,\n\t\tit: CommandIterator<'importContentSchemaBegin'>,\n\t) {\n\t\tconst [options] = it.commandArgs\n\t\tconst projectContainer = await this.createProjectContainer(groupContainer, options.project)\n\t\tconst systemDatabaseContext = projectContainer.systemDatabaseContext\n\t\tconst stage = await this.fetchStageBySlug(systemDatabaseContext, options.project, options.stage)\n\n\t\tconst contentSchema = await projectContainer.contentSchemaResolver.getSchema({ db: systemDatabaseContext, stage: stage.slug, normalize: true })\n\n\t\tif (contentSchema.meta.version !== options.schemaVersion) {\n\t\t\tthrow new ImportError(\n\t\t\t\t`Incompatible schema version (import version ${options.schemaVersion} does not match server version ${contentSchema.meta.version})`,\n\t\t\t)\n\t\t}\n\n\t\tawait this.requireImportAccess(groupContainer, contentSchema.schema, authResult, options.project, 'content')\n\t\tconst contentDatabaseClient = projectContainer.connection.createClient(stage.schema, {})\n\t\tconst mapping = this.contentSchemaTransferMappingFactory.createContentSchemaMapping(contentSchema.schema)\n\n\t\treturn await contentDatabaseClient.transaction(async db => {\n\t\t\tawait this.disableTimeouts(db)\n\t\t\tawait this.disableTriggers(db, options.tables)\n\t\t\tawait this.lockTables(db, options.tables)\n\t\t\tawait this.truncateTables(db, options.tables)\n\n\t\t\tconst metadata = await this.databaseMetadataResolver.resolveMetadata(db, db.schema)\n\t\t\tconst constraintHelper = new ConstraintHelper(db, metadata)\n\t\t\tawait constraintHelper.setConstraintsDeferred('foreignKey')\n\n\t\t\tconst result = await this.match(await it.next(), {\n\t\t\t\timportSequence: it => this.importSequence(db, mapping, it),\n\t\t\t\tinsertBegin: it => this.insertBegin(db, mapping, it),\n\t\t\t})\n\n\t\t\tawait constraintHelper.setConstraintsImmediate('foreignKey')\n\t\t\tawait this.enableTriggers(db, options.tables)\n\n\t\t\treturn result\n\t\t})\n\t}\n\n\tprivate async importSystemSchemaBegin(\n\t\tgroupContainer: ProjectGroupContainer,\n\t\tauthResult: AuthResult,\n\t\tit: CommandIterator<'importSystemSchemaBegin'>,\n\t) {\n\t\tconst [options] = it.commandArgs\n\t\tconst projectContainer = await this.createProjectContainer(groupContainer, options.project)\n\t\tconst schema = await groupContainer.projectSchemaResolver.getSchema(options.project)\n\n\t\tif (schema === undefined) {\n\t\t\tthrow new ImportError(`Project ${options.project} does not have schema`)\n\t\t}\n\n\t\tawait this.requireImportAccess(groupContainer, schema, authResult, options.project, 'system')\n\t\tconst systemDatabaseContext = projectContainer.systemDatabaseContext\n\t\tconst mapping = this.systemSchemaTransferMappingFactory.build()\n\n\t\treturn await systemDatabaseContext.client.transaction(async db => {\n\t\t\tawait this.disableTimeouts(db)\n\t\t\tawait this.truncateTables(db, options.tables)\n\n\t\t\tconst metadata = await this.databaseMetadataResolver.resolveMetadata(db, db.schema)\n\t\t\tconst constraintHelper = new ConstraintHelper(db, metadata)\n\t\t\tawait constraintHelper.setConstraintsDeferred('foreignKey')\n\n\t\t\treturn await this.match(await it.next(), {\n\t\t\t\tinsertBegin: it => this.insertBegin(db, mapping, it),\n\t\t\t})\n\t\t})\n\t}\n\n\tprivate async importSequence(\n\t\tdb: Client<Connection.TransactionLike>,\n\t\tmapping: TransferMapping,\n\t\tit: CommandIterator<'importSequence'>,\n\t): Promise<CommandIterator | null> {\n\t\tconst [options] = it.commandArgs\n\n\t\tawait db.query(\n\t\t\t'SELECT setval(pg_get_serial_sequence(?, ?), ?)',\n\t\t\t[`${db.schema}.${options.table}`, options.column, options.value],\n\t\t)\n\n\t\treturn it.next()\n\t}\n\n\tprivate async insertBegin(\n\t\tdb: Client<Connection.TransactionLike>,\n\t\tmapping: TransferMapping,\n\t\tit: CommandIterator<'insertBegin'>,\n\t): Promise<CommandIterator | null> {\n\t\tconst [options] = it.commandArgs\n\t\tconst insertContext = await this.buildInsertContext(db, mapping, db.schema, options.table, options.columns)\n\t\tlet insertRowsPromise: Promise<Connection.Result> | null = null\n\n\t\t// postgresql has a limit of 65535 parameters per query\n\t\tconst batchSize = Math.max(1, Math.min(1000, Math.floor(65500 / options.columns.length)))\n\n\t\tconst result = await this.match(await it.next(), {\n\t\t\tinsertRow: async it => {\n\t\t\t\tconst [values] = it.commandArgs\n\n\t\t\t\ttry {\n\t\t\t\t\tinsertContext.rows.push(insertContext.rowParser(values))\n\t\t\t\t} catch (e) {\n\t\t\t\t\tif (e instanceof ParseError) {\n\t\t\t\t\t\tthrow new ImportError(`Invalid row ${JSON.stringify(values)} for table ${options.table}: ${e.message}`)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow e\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (insertContext.rows.length === batchSize) {\n\t\t\t\t\tawait insertRowsPromise\n\t\t\t\t\tinsertRowsPromise = this.insertRows(db, insertContext)\n\t\t\t\t\tinsertContext.insertedRowCount += insertContext.rows.length\n\t\t\t\t\tinsertContext.rows = []\n\t\t\t\t}\n\n\t\t\t\treturn await it.next()\n\t\t\t},\n\t\t})\n\n\t\tif (insertContext.rows.length > 0) {\n\t\t\tawait insertRowsPromise\n\t\t\tawait this.insertRows(db, insertContext)\n\t\t\tinsertContext.insertedRowCount += insertContext.rows.length\n\t\t\tinsertContext.rows = []\n\t\t}\n\n\t\tif (result === null || result.commandName !== 'insertEnd') {\n\t\t\tthrow new ImportError(`Missing insertEnd command`)\n\t\t}\n\n\t\treturn await result.next()\n\t}\n\n\tprivate async createProjectContainer(groupContainer: ProjectGroupContainer, projectSlug: string) {\n\t\tconst projectContainerResolver = groupContainer.projectContainerResolver\n\t\tconst projectContainer = await projectContainerResolver.getProjectContainer(projectSlug, { alias: true })\n\n\t\tif (projectContainer === undefined) {\n\t\t\tthrow new ImportError(`Project ${projectSlug} does not exists.`)\n\t\t}\n\n\t\treturn projectContainer\n\t}\n\n\tprivate async requireImportAccess(\n\t\tgroupContainer: ProjectGroupContainer,\n\t\tschema: Schema,\n\t\tauthResult: AuthResult,\n\t\tprojectSlug: string,\n\t\tkind: 'content' | 'system',\n\t) {\n\t\tconst { effective: memberships } = await groupContainer.projectMembershipResolver.resolveMemberships({\n\t\t\trequest: { get: () => '' },\n\t\t\tacl: schema.acl,\n\t\t\tprojectSlug: projectSlug,\n\t\t\tidentity: {\n\t\t\t\tidentityId: authResult.identityId,\n\t\t\t\troles: authResult.roles,\n\t\t\t},\n\t\t})\n\n\t\tconst projectRoles = memberships.map(it => it.role)\n\n\t\tif (!projectRoles.some(role => schema.acl.roles[role]?.[kind]?.import)) {\n\t\t\tthrow new HttpErrorResponse(403, `You are not allowed to import ${kind} in ${projectSlug}`)\n\t\t}\n\t}\n\n\tprivate async fetchStageBySlug(systemDatabaseContext: DatabaseContext, projectSlug: string, stageSlug: string) {\n\t\tconst stage = await systemDatabaseContext.queryHandler.fetch(new StageBySlugQuery(stageSlug))\n\n\t\tif (stage === null) {\n\t\t\tthrow new ImportError(`Project ${projectSlug} does not have stage ${stageSlug}.`)\n\t\t}\n\n\t\treturn stage\n\t}\n\n\tprivate async disableTriggers(db: Client, tableNames: readonly string[]) {\n\t\tfor (const tableName of tableNames) {\n\t\t\tconst tableNameQuoted = `${wrapIdentifier(db.schema)}.${wrapIdentifier(tableName)}`\n\t\t\tawait db.query(`ALTER TABLE ${tableNameQuoted} DISABLE TRIGGER USER`)\n\t\t}\n\t}\n\n\tprivate async enableTriggers(db: Client, tableNames: readonly string[]) {\n\t\tfor (const tableName of tableNames) {\n\t\t\tconst tableNameQuoted = `${wrapIdentifier(db.schema)}.${wrapIdentifier(tableName)}`\n\t\t\tawait db.query(`ALTER TABLE ${tableNameQuoted} ENABLE TRIGGER USER`)\n\t\t}\n\t}\n\n\tprivate async lockTables(db: Client, tableNames: readonly string[]) {\n\t\tconst tableNamesQuoted = tableNames.map(it => `${wrapIdentifier(db.schema)}.${wrapIdentifier(it)}`)\n\t\tawait db.query(`LOCK ${tableNamesQuoted.join(', ')} IN EXCLUSIVE MODE`)\n\t}\n\n\tprivate async truncateTables(db: Client, tableNames: readonly string[]) {\n\t\tconst tableNamesQuoted = tableNames.map(it => `${wrapIdentifier(db.schema)}.${wrapIdentifier(it)}`)\n\t\tawait db.query(`TRUNCATE ${tableNamesQuoted.join(', ')}`)\n\t}\n\n\tprivate async disableTimeouts(db: Client) {\n\t\tawait db.query('SET LOCAL statement_timeout = 0')\n\t\tawait db.query('SET LOCAL lock_timeout = 0')\n\t}\n\n\tprivate async insertRows(db: Client, context: InsertContext) {\n\t\tconst rowsFragment = context.rows.map(_ => context.rowFragment).join(',\\n')\n\t\tconst sql = context.insertStartFragment + rowsFragment\n\t\tconst parameters: Cell[] = []\n\n\t\tfor (const row of context.rows) {\n\t\t\tfor (const cell of row) {\n\t\t\t\tparameters.push(cell)\n\t\t\t}\n\t\t}\n\n\t\treturn await db.query(sql, parameters)\n\t}\n\n\tprivate async buildInsertContext(\n\t\tdb: Client,\n\t\tmapping: TransferMapping,\n\t\tschema: string,\n\t\ttableName: string,\n\t\tcolumnNames: readonly string[],\n\t): Promise<InsertContext> {\n\t\tconst tableMapping = mapping.tables[tableName]\n\t\tconst columns = []\n\n\t\tif (tableMapping === undefined) {\n\t\t\tthrow new ImportError(`Unknown table ${tableName}`)\n\t\t}\n\n\t\tfor (const columnName of columnNames) {\n\t\t\tconst column = tableMapping.columns[columnName]\n\n\t\t\tif (column === undefined) {\n\t\t\t\tthrow new ImportError(`Unknown column ${tableName}.${columnName}`)\n\t\t\t}\n\n\t\t\tcolumns.push(column)\n\t\t}\n\n\t\tconst insertStartFragment = (tableMapping.createInsertStartFragment ?? this.createInsertStartFragment)(schema, tableName, columnNames)\n\t\tconst rowFragment = '(' + columns.map(_ => '?').join(', ') + ')'\n\t\tconst rowParser = await this.buildRowParser(db, tableMapping, columns)\n\n\t\treturn {\n\t\t\ttableName,\n\t\t\tinsertStartFragment,\n\t\t\trowFragment,\n\t\t\trowParser,\n\t\t\trows: [],\n\t\t\tinsertedRowCount: 0,\n\t\t}\n\t}\n\n\tprivate createInsertStartFragment(schema: string, tableName: string, columnNames: readonly string[]): string {\n\t\tconst tableQuoted = `${wrapIdentifier(schema)}.${wrapIdentifier(tableName)}`\n\t\tconst columnsQuoted = '(' + columnNames.map(it => wrapIdentifier(it)).join(', ') + ')'\n\t\treturn `INSERT INTO ${tableQuoted} ${columnsQuoted} VALUES\\n`\n\t}\n\n\tprivate async buildRowParser(db: Client, tableMapping: TransferTableMapping, columns: DbColumnSchema[]): Promise<Typesafe.Type<readonly Cell[]>> {\n\t\tconst baseType = Typesafe.tuple(...columns.map(it => {\n\t\t\tconst base = this.buildColumnRuntimeType(it)\n\t\t\treturn it.nullable ? Typesafe.nullable(base) : base\n\t\t}))\n\n\t\tif (tableMapping.createRowParser === undefined) {\n\t\t\treturn baseType\n\t\t}\n\n\t\treturn await tableMapping.createRowParser(db, columns.map(it => it.name), baseType)\n\t}\n\n\tprivate buildColumnRuntimeType(column: DbColumnSchema): Typesafe.Type<Exclude<Cell, null>> {\n\t\tswitch (column.type) {\n\t\t\tcase Model.ColumnType.Uuid:\n\t\t\tcase Model.ColumnType.String:\n\t\t\tcase Model.ColumnType.Enum:\n\t\t\tcase Model.ColumnType.DateTime:\n\t\t\tcase Model.ColumnType.Time:\n\t\t\tcase Model.ColumnType.Date:\n\t\t\tcase Model.ColumnType.Json:\n\t\t\t// Numeric is transferred as a string to avoid JS float precision loss.\n\t\t\tcase Model.ColumnType.Numeric:\n\t\t\t\treturn column.list ? listType(Typesafe.array(Typesafe.string)) : Typesafe.string\n\t\t\tcase Model.ColumnType.Int:\n\t\t\tcase Model.ColumnType.Double:\n\t\t\t\treturn column.list ? listType(Typesafe.array(Typesafe.number)) : Typesafe.number\n\t\t\tcase Model.ColumnType.Bool:\n\t\t\t\treturn column.list ? listType(Typesafe.array(Typesafe.boolean)) : Typesafe.boolean\n\t\t}\n\t}\n}\n"],"names":["it"],"mappings":";;;;;;;AAwBO,MAAM,oBAAoB,MAAM;AACvC;AAEA,MAAM,mBAAmB,CAAC,UAA4B;AACrD,MAAI,UAAU,KAAM,QAAO,CAAA;AAC3B,MAAI,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,SAAS,GAAG,GAAG;AACnD,UAAM,IAAI,WAAW,CAAA,GAAI,qCAAqC,KAAK,EAAE;AAAA,EACtE;AACA,QAAM,QAAQ,MAAM,MAAM,GAAG,EAAE;AAC/B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AS,MAAM,CAAC,IAAI,SAAS;AAAA,MAC3E,KAAK,MAAM,WAAW;AACrB,eAAO,OAAO,OAAO,SAAS,SAAS,MAAM,SAAS,OAAO,CAAC,IAAI,SAAS;AAAA,IAAA;AAAA,EAE9E;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SystemSchemaTransferMappingFactory.cjs","sources":["../../../../../packages/engine-http/src/transfer/SystemSchemaTransferMappingFactory.ts"],"sourcesContent":["import { TransferMapping, TransferTableMapping } from './TransferMapping'\nimport { Model } from '@contember/schema'\nimport * as Typesafe from '@contember/typesafe'\nimport { Compiler, Operator, wrapIdentifier } from '@contember/database'\nimport { ImportError } from './ImportExecutor'\n\nexport class SystemSchemaTransferMappingFactory {\n\tbuild(args: {\n\t\texcludeTables?: readonly string[]\n\t} = {}): TransferMapping {\n\t\treturn {\n\t\t\ttables: this.associateByName([\n\t\t\t\tthis.buildEventDataMapping(args),\n\t\t\t\tthis.buildStageTransactionDataMapping(),\n\t\t\t]),\n\t\t}\n\t}\n\n\tprivate buildStageTransactionDataMapping(): TransferTableMapping {\n\t\treturn {\n\t\t\tname: 'stage_transaction',\n\n\t\t\tcolumns: this.associateByName([\n\t\t\t\t{ name: 'transaction_id', type: Model.ColumnType.Uuid },\n\t\t\t\t{ name: 'stage_slug', type: Model.ColumnType.String },\n\t\t\t\t{ name: 'applied_at', type: Model.ColumnType.DateTime },\n\t\t\t]),\n\n\t\t\tcreateSelect: (db, table) => {\n\t\t\t\tconst namespaceContext = new Compiler.Context(db.schema, new Set())\n\n\t\t\t\tlet builder = db.selectBuilder()\n\n\t\t\t\tfor (const column of Object.values(table.columns)) {\n\t\t\t\t\tif (column.name === 'stage_slug') {\n\t\t\t\t\t\tbuilder = builder.select(['stage', 'slug'], 'stage_slug')\n\t\t\t\t\t} else if (column.type === Model.ColumnType.Json || column.type === Model.ColumnType.Date || column.type === Model.ColumnType.DateTime) {\n\t\t\t\t\t\tbuilder = builder.select(expr => expr.raw(`${wrapIdentifier('stage_transaction')}.${wrapIdentifier(column.name)}::text`))\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbuilder = builder.select(['stage_transaction', column.name])\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn builder\n\t\t\t\t\t.from('stage_transaction')\n\t\t\t\t\t.join(\n\t\t\t\t\t\t'stage',\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\texpr => expr.compareColumns(['stage', 'id'], Operator.eq, ['stage_transaction', 'stage_id']),\n\t\t\t\t\t)\n\t\t\t\t\t.createQuery(namespaceContext)\n\t\t\t},\n\n\t\t\tcreateInsertStartFragment: (schema, tableName, columnNames) => {\n\t\t\t\tconst columnNames2 = columnNames.map(name => name === 'stage_slug' ? 'stage_id' : name)\n\t\t\t\tconst tableQuoted = `${wrapIdentifier(schema)}.${wrapIdentifier(tableName)}`\n\t\t\t\tconst columnsQuoted = '(' + columnNames2.map(it => wrapIdentifier(it)).join(', ') + ')'\n\t\t\t\treturn `INSERT INTO ${tableQuoted} ${columnsQuoted} VALUES\\n`\n\t\t\t},\n\n\t\t\tcreateRowParser: async (db, columns, baseType) => {\n\t\t\t\tconst stages = await db.selectBuilder<{ id: string; slug: string }>()\n\t\t\t\t\t.select('id')\n\t\t\t\t\t.select('slug')\n\t\t\t\t\t.from('stage')\n\t\t\t\t\t.getResult(db)\n\n\t\t\t\tconst stageSlugToId = new Map(stages.map(row => [row.slug, row.id]))\n\t\t\t\tconst stageSlugColumnIndex = columns.indexOf('stage_slug')\n\n\t\t\t\tif (stageSlugColumnIndex < 0) {\n\t\t\t\t\treturn baseType\n\t\t\t\t}\n\n\t\t\t\treturn (input, path) => {\n\t\t\t\t\tconst row = baseType(input, path)\n\t\t\t\t\tconst stageSlug = Typesafe.string(row[stageSlugColumnIndex])\n\t\t\t\t\tconst stageSlugId = stageSlugToId.get(stageSlug)\n\n\t\t\t\t\tif (stageSlugId === undefined) {\n\t\t\t\t\t\tthrow new ImportError(`Unknown stage slug ${stageSlug}`)\n\t\t\t\t\t}\n\n\t\t\t\t\tconst newRow = [...row]\n\t\t\t\t\tnewRow[stageSlugColumnIndex] = stageSlugId\n\n\t\t\t\t\treturn newRow\n\t\t\t\t}\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate buildEventDataMapping({ excludeTables = [] }: {\n\t\texcludeTables?: readonly string[]\n\t}): TransferTableMapping {\n\t\treturn {\n\t\t\tname: 'event_data',\n\n\t\t\tcolumns: this.associateByName([\n\t\t\t\t{ name: 'id', type: Model.ColumnType.Uuid },\n\t\t\t\t{ name: 'type', type: Model.ColumnType.Enum, values: ['create', 'update', 'delete'] },\n\t\t\t\t{ name: 'table_name', type: Model.ColumnType.String },\n\t\t\t\t{ name: 'row_ids', type: Model.ColumnType.Json, schema: Typesafe.array(Typesafe.string) },\n\t\t\t\t{ name: 'values', type: Model.ColumnType.Json, nullable: true, schema: Typesafe.object({}) },\n\t\t\t\t{ name: 'created_at', type: Model.ColumnType.DateTime },\n\t\t\t\t{ name: 'schema_version', type: Model.ColumnType.String },\n\t\t\t\t{ name: 'identity_id', type: Model.ColumnType.Uuid },\n\t\t\t\t{ name: 'transaction_id', type: Model.ColumnType.Uuid },\n\t\t\t]),\n\n\t\t\tcreateSelect: (db, table) => {\n\t\t\t\tconst namespaceContext = new Compiler.Context(db.schema, new Set())\n\n\t\t\t\tlet builder = db.selectBuilder()\n\n\t\t\t\tfor (const column of Object.values(table.columns)) {\n\t\t\t\t\tif (column.name === 'schema_version') {\n\t\t\t\t\t\tbuilder = builder.select(['schema_migration', 'version'], 'schema_version')\n\t\t\t\t\t} else if (column.type === Model.ColumnType.Json || column.type === Model.ColumnType.Date || column.type === Model.ColumnType.DateTime) {\n\t\t\t\t\t\tbuilder = builder.select(expr => expr.raw(`${wrapIdentifier('event_data')}.${wrapIdentifier(column.name)}::text`))\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbuilder = builder.select(['event_data', column.name])\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn builder\n\t\t\t\t\t.from('event_data')\n\t\t\t\t\t.join(\n\t\t\t\t\t\t'schema_migration',\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\texpr => expr.compareColumns(['schema_migration', 'id'], Operator.eq, ['event_data', 'schema_id']),\n\t\t\t\t\t)\n\t\t\t\t\t.match(it => {\n\t\t\t\t\t\tif (excludeTables.length === 0) {\n\t\t\t\t\t\t\treturn it\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn it.where(expr => expr.not(it => it.in('table_name', excludeTables)))\n\t\t\t\t\t})\n\t\t\t\t\t.createQuery(namespaceContext)\n\t\t\t},\n\n\t\t\tcreateInsertStartFragment: (schema, tableName, columnNames) => {\n\t\t\t\tconst columnNames2 = columnNames.map(name => name === 'schema_version' ? 'schema_id' : name)\n\t\t\t\tconst tableQuoted = `${wrapIdentifier(schema)}.${wrapIdentifier(tableName)}`\n\t\t\t\tconst columnsQuoted = '(' + columnNames2.map(it => wrapIdentifier(it)).join(', ') + ')'\n\t\t\t\treturn `INSERT INTO ${tableQuoted} ${columnsQuoted} VALUES\\n`\n\t\t\t},\n\n\t\t\tcreateRowParser: async (db, columns, baseType) => {\n\t\t\t\tconst schemaMigrations = await db.selectBuilder<{ id: string; version: string }>()\n\t\t\t\t\t.select('id')\n\t\t\t\t\t.select('version')\n\t\t\t\t\t.from('schema_migration')\n\t\t\t\t\t.getResult(db)\n\n\t\t\t\tconst versionToId = new Map(schemaMigrations.map(row => [row.version, row.id]))\n\t\t\t\tconst schemaVersionColumnIndex = columns.indexOf('schema_version')\n\n\t\t\t\tif (schemaVersionColumnIndex < 0) {\n\t\t\t\t\treturn baseType\n\t\t\t\t}\n\n\t\t\t\treturn (input, path) => {\n\t\t\t\t\tconst row = baseType(input, path)\n\t\t\t\t\tconst schemaVersion = Typesafe.string(row[schemaVersionColumnIndex])\n\t\t\t\t\tconst schemaVersionId = versionToId.get(schemaVersion)\n\n\t\t\t\t\tif (schemaVersionId === undefined) {\n\t\t\t\t\t\tthrow new ImportError(`Unknown schema version ${schemaVersion}`)\n\t\t\t\t\t}\n\n\t\t\t\t\tconst newRow = [...row]\n\t\t\t\t\tnewRow[schemaVersionColumnIndex] = schemaVersionId\n\n\t\t\t\t\treturn newRow\n\t\t\t\t}\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate associateByName<T extends { name: string }>(items: T[]): Record<string, T> {\n\t\treturn Object.fromEntries(items.map(item => [item.name, item]))\n\t}\n}\n"],"names":["Model","Compiler","wrapIdentifier","Operator","schema","Typesafe","ImportError","it"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAMO,MAAM,mCAAmC;AAAA,EAC/C,MAAM,OAEF,IAAqB;AACxB,WAAO;AAAA,MACN,QAAQ,KAAK,gBAAgB;AAAA,QAC5B,KAAK,sBAAsB,IAAI;AAAA,QAC/B,KAAK,iCAAA;AAAA,MAAiC,CACtC;AAAA,IAAA;AAAA,EAEH;AAAA,EAEQ,mCAAyD;AAChE,WAAO;AAAA,MACN,MAAM;AAAA,MAEN,SAAS,KAAK,gBAAgB;AAAA,QAC7B,EAAE,MAAM,kBAAkB,MAAMA,OAAAA,MAAM,WAAW,KAAA;AAAA,QACjD,EAAE,MAAM,cAAc,MAAMA,OAAAA,MAAM,WAAW,OAAA;AAAA,QAC7C,EAAE,MAAM,cAAc,MAAMA,OAAAA,MAAM,WAAW,SAAA;AAAA,MAAS,CACtD;AAAA,MAED,cAAc,CAAC,IAAI,UAAU;AAC5B,cAAM,mBAAmB,IAAIC,kBAAS,QAAQ,GAAG,QAAQ,oBAAI,KAAK;AAElE,YAAI,UAAU,GAAG,cAAA;AAEjB,mBAAW,UAAU,OAAO,OAAO,MAAM,OAAO,GAAG;AAClD,cAAI,OAAO,SAAS,cAAc;AACjC,sBAAU,QAAQ,OAAO,CAAC,SAAS,MAAM,GAAG,YAAY;AAAA,UACzD,WAAW,OAAO,SAASD,OAAAA,MAAM,WAAW,QAAQ,OAAO,SAASA,OAAAA,MAAM,WAA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EAAE,KAAK,IAAI,IAAI;AACpF,eAAO,eAAe,WAAW,IAAI,aAAa;AAAA;AAAA,MACnD;AAAA,MAEA,iBAAiB,OAAO,IAAI,SAAS,aAAa;AACjD,cAAM,mBAAmB,MAAM,GAAG,cAAA,EAChC,OAAO,IAAI,EACX,OAAO,SAAS,EAChB,KAAK,kBAAkB,EACvB,UAAU,EAAE;AAEd,cAAM,cAAc,IAAI,IAAI,iBAAiB,IAAI,CAAA,QAAO,CAAC,IAAI,SAAS,IAAI,EAAE,CAAC,CAAC;AAC9E,cAAM,2BAA2B,QAAQ,QAAQ,gBAAgB;AAEjE,YAAI,2BAA2B,GAAG;AACjC,iBAAO;AAAA,QACR;AAEA,eAAO,CAAC,OAAO,SAAS;AACvB,gBAAM,MAAM,SAAS,OAAO,IAAI;AAChC,gBAAM,gBAAgBG,oBAAS,OAAO,IAAI,wBAAwB,CAAC;AACnE,gBAAM,kBAAkB,YAAY,IAAI,aAAa;AAErD,cAAI,oBAAoB,QAAW;AAClC,kBAAM,IAAIC,eAAAA,YAAY,0BAA0B,aAAa,EAAE;AAAA,UAChE;AAEA,gBAAM,SAAS,CAAC,GAAG,GAAG;AACtB,iBAAO,wBAAwB,IAAI;AAEnC,iBAAO;AAAA,QACR;AAAA,MACD;AAAA,IAAA;AAAA,EAEF;AAAA,EAEQ,gBAA4C,OAA+B;AAClF,WAAO,OAAO,YAAY,MAAM,IAAI,CAAA,SAAQ,CAAC,KAAK,MAAM,IAAI,CAAC,CAAC;AAAA,EAC/D;AACD;;"}
|
|
1
|
+
{"version":3,"file":"SystemSchemaTransferMappingFactory.cjs","sources":["../../../../../packages/engine-http/src/transfer/SystemSchemaTransferMappingFactory.ts"],"sourcesContent":["import { TransferMapping, TransferTableMapping } from './TransferMapping.js'\nimport { Model } from '@contember/schema'\nimport * as Typesafe from '@contember/typesafe'\nimport { Compiler, Operator, wrapIdentifier } from '@contember/database'\nimport { ImportError } from './ImportExecutor.js'\n\nexport class SystemSchemaTransferMappingFactory {\n\tbuild(args: {\n\t\texcludeTables?: readonly string[]\n\t} = {}): TransferMapping {\n\t\treturn {\n\t\t\ttables: this.associateByName([\n\t\t\t\tthis.buildEventDataMapping(args),\n\t\t\t\tthis.buildStageTransactionDataMapping(),\n\t\t\t]),\n\t\t}\n\t}\n\n\tprivate buildStageTransactionDataMapping(): TransferTableMapping {\n\t\treturn {\n\t\t\tname: 'stage_transaction',\n\n\t\t\tcolumns: this.associateByName([\n\t\t\t\t{ name: 'transaction_id', type: Model.ColumnType.Uuid },\n\t\t\t\t{ name: 'stage_slug', type: Model.ColumnType.String },\n\t\t\t\t{ name: 'applied_at', type: Model.ColumnType.DateTime },\n\t\t\t]),\n\n\t\t\tcreateSelect: (db, table) => {\n\t\t\t\tconst namespaceContext = new Compiler.Context(db.schema, new Set())\n\n\t\t\t\tlet builder = db.selectBuilder()\n\n\t\t\t\tfor (const column of Object.values(table.columns)) {\n\t\t\t\t\tif (column.name === 'stage_slug') {\n\t\t\t\t\t\tbuilder = builder.select(['stage', 'slug'], 'stage_slug')\n\t\t\t\t\t} else if (column.type === Model.ColumnType.Json || column.type === Model.ColumnType.Date || column.type === Model.ColumnType.DateTime) {\n\t\t\t\t\t\tbuilder = builder.select(expr => expr.raw(`${wrapIdentifier('stage_transaction')}.${wrapIdentifier(column.name)}::text`))\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbuilder = builder.select(['stage_transaction', column.name])\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn builder\n\t\t\t\t\t.from('stage_transaction')\n\t\t\t\t\t.join(\n\t\t\t\t\t\t'stage',\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\texpr => expr.compareColumns(['stage', 'id'], Operator.eq, ['stage_transaction', 'stage_id']),\n\t\t\t\t\t)\n\t\t\t\t\t.createQuery(namespaceContext)\n\t\t\t},\n\n\t\t\tcreateInsertStartFragment: (schema, tableName, columnNames) => {\n\t\t\t\tconst columnNames2 = columnNames.map(name => name === 'stage_slug' ? 'stage_id' : name)\n\t\t\t\tconst tableQuoted = `${wrapIdentifier(schema)}.${wrapIdentifier(tableName)}`\n\t\t\t\tconst columnsQuoted = '(' + columnNames2.map(it => wrapIdentifier(it)).join(', ') + ')'\n\t\t\t\treturn `INSERT INTO ${tableQuoted} ${columnsQuoted} VALUES\\n`\n\t\t\t},\n\n\t\t\tcreateRowParser: async (db, columns, baseType) => {\n\t\t\t\tconst stages = await db.selectBuilder<{ id: string; slug: string }>()\n\t\t\t\t\t.select('id')\n\t\t\t\t\t.select('slug')\n\t\t\t\t\t.from('stage')\n\t\t\t\t\t.getResult(db)\n\n\t\t\t\tconst stageSlugToId = new Map(stages.map(row => [row.slug, row.id]))\n\t\t\t\tconst stageSlugColumnIndex = columns.indexOf('stage_slug')\n\n\t\t\t\tif (stageSlugColumnIndex < 0) {\n\t\t\t\t\treturn baseType\n\t\t\t\t}\n\n\t\t\t\treturn (input, path) => {\n\t\t\t\t\tconst row = baseType(input, path)\n\t\t\t\t\tconst stageSlug = Typesafe.string(row[stageSlugColumnIndex])\n\t\t\t\t\tconst stageSlugId = stageSlugToId.get(stageSlug)\n\n\t\t\t\t\tif (stageSlugId === undefined) {\n\t\t\t\t\t\tthrow new ImportError(`Unknown stage slug ${stageSlug}`)\n\t\t\t\t\t}\n\n\t\t\t\t\tconst newRow = [...row]\n\t\t\t\t\tnewRow[stageSlugColumnIndex] = stageSlugId\n\n\t\t\t\t\treturn newRow\n\t\t\t\t}\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate buildEventDataMapping({ excludeTables = [] }: {\n\t\texcludeTables?: readonly string[]\n\t}): TransferTableMapping {\n\t\treturn {\n\t\t\tname: 'event_data',\n\n\t\t\tcolumns: this.associateByName([\n\t\t\t\t{ name: 'id', type: Model.ColumnType.Uuid },\n\t\t\t\t{ name: 'type', type: Model.ColumnType.Enum, values: ['create', 'update', 'delete'] },\n\t\t\t\t{ name: 'table_name', type: Model.ColumnType.String },\n\t\t\t\t{ name: 'row_ids', type: Model.ColumnType.Json, schema: Typesafe.array(Typesafe.string) },\n\t\t\t\t{ name: 'values', type: Model.ColumnType.Json, nullable: true, schema: Typesafe.object({}) },\n\t\t\t\t{ name: 'created_at', type: Model.ColumnType.DateTime },\n\t\t\t\t{ name: 'schema_version', type: Model.ColumnType.String },\n\t\t\t\t{ name: 'identity_id', type: Model.ColumnType.Uuid },\n\t\t\t\t{ name: 'transaction_id', type: Model.ColumnType.Uuid },\n\t\t\t]),\n\n\t\t\tcreateSelect: (db, table) => {\n\t\t\t\tconst namespaceContext = new Compiler.Context(db.schema, new Set())\n\n\t\t\t\tlet builder = db.selectBuilder()\n\n\t\t\t\tfor (const column of Object.values(table.columns)) {\n\t\t\t\t\tif (column.name === 'schema_version') {\n\t\t\t\t\t\tbuilder = builder.select(['schema_migration', 'version'], 'schema_version')\n\t\t\t\t\t} else if (column.type === Model.ColumnType.Json || column.type === Model.ColumnType.Date || column.type === Model.ColumnType.DateTime) {\n\t\t\t\t\t\tbuilder = builder.select(expr => expr.raw(`${wrapIdentifier('event_data')}.${wrapIdentifier(column.name)}::text`))\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbuilder = builder.select(['event_data', column.name])\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn builder\n\t\t\t\t\t.from('event_data')\n\t\t\t\t\t.join(\n\t\t\t\t\t\t'schema_migration',\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\texpr => expr.compareColumns(['schema_migration', 'id'], Operator.eq, ['event_data', 'schema_id']),\n\t\t\t\t\t)\n\t\t\t\t\t.match(it => {\n\t\t\t\t\t\tif (excludeTables.length === 0) {\n\t\t\t\t\t\t\treturn it\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn it.where(expr => expr.not(it => it.in('table_name', excludeTables)))\n\t\t\t\t\t})\n\t\t\t\t\t.createQuery(namespaceContext)\n\t\t\t},\n\n\t\t\tcreateInsertStartFragment: (schema, tableName, columnNames) => {\n\t\t\t\tconst columnNames2 = columnNames.map(name => name === 'schema_version' ? 'schema_id' : name)\n\t\t\t\tconst tableQuoted = `${wrapIdentifier(schema)}.${wrapIdentifier(tableName)}`\n\t\t\t\tconst columnsQuoted = '(' + columnNames2.map(it => wrapIdentifier(it)).join(', ') + ')'\n\t\t\t\treturn `INSERT INTO ${tableQuoted} ${columnsQuoted} VALUES\\n`\n\t\t\t},\n\n\t\t\tcreateRowParser: async (db, columns, baseType) => {\n\t\t\t\tconst schemaMigrations = await db.selectBuilder<{ id: string; version: string }>()\n\t\t\t\t\t.select('id')\n\t\t\t\t\t.select('version')\n\t\t\t\t\t.from('schema_migration')\n\t\t\t\t\t.getResult(db)\n\n\t\t\t\tconst versionToId = new Map(schemaMigrations.map(row => [row.version, row.id]))\n\t\t\t\tconst schemaVersionColumnIndex = columns.indexOf('schema_version')\n\n\t\t\t\tif (schemaVersionColumnIndex < 0) {\n\t\t\t\t\treturn baseType\n\t\t\t\t}\n\n\t\t\t\treturn (input, path) => {\n\t\t\t\t\tconst row = baseType(input, path)\n\t\t\t\t\tconst schemaVersion = Typesafe.string(row[schemaVersionColumnIndex])\n\t\t\t\t\tconst schemaVersionId = versionToId.get(schemaVersion)\n\n\t\t\t\t\tif (schemaVersionId === undefined) {\n\t\t\t\t\t\tthrow new ImportError(`Unknown schema version ${schemaVersion}`)\n\t\t\t\t\t}\n\n\t\t\t\t\tconst newRow = [...row]\n\t\t\t\t\tnewRow[schemaVersionColumnIndex] = schemaVersionId\n\n\t\t\t\t\treturn newRow\n\t\t\t\t}\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate associateByName<T extends { name: string }>(items: T[]): Record<string, T> {\n\t\treturn Object.fromEntries(items.map(item => [item.name, item]))\n\t}\n}\n"],"names":["Model","Compiler","wrapIdentifier","Operator","schema","Typesafe","ImportError","it"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAMO,MAAM,mCAAmC;AAAA,EAC/C,MAAM,OAEF,IAAqB;AACxB,WAAO;AAAA,MACN,QAAQ,KA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gBAAM,MAAM,SAAS,OAAO,IAAI;AAChC,gBAAM,gBAAgBG,oBAAS,OAAO,IAAI,wBAAwB,CAAC;AACnE,gBAAM,kBAAkB,YAAY,IAAI,aAAa;AAErD,cAAI,oBAAoB,QAAW;AAClC,kBAAM,IAAIC,eAAAA,YAAY,0BAA0B,aAAa,EAAE;AAAA,UAChE;AAEA,gBAAM,SAAS,CAAC,GAAG,GAAG;AACtB,iBAAO,wBAAwB,IAAI;AAEnC,iBAAO;AAAA,QACR;AAAA,MACD;AAAA,IAAA;AAAA,EAEF;AAAA,EAEQ,gBAA4C,OAA+B;AAClF,WAAO,OAAO,YAAY,MAAM,IAAI,CAAA,SAAQ,CAAC,KAAK,MAAM,IAAI,CAAC,CAAC;AAAA,EAC/D;AACD;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SystemSchemaTransferMappingFactory.js","sources":["../../../../../packages/engine-http/src/transfer/SystemSchemaTransferMappingFactory.ts"],"sourcesContent":["import { TransferMapping, TransferTableMapping } from './TransferMapping'\nimport { Model } from '@contember/schema'\nimport * as Typesafe from '@contember/typesafe'\nimport { Compiler, Operator, wrapIdentifier } from '@contember/database'\nimport { ImportError } from './ImportExecutor'\n\nexport class SystemSchemaTransferMappingFactory {\n\tbuild(args: {\n\t\texcludeTables?: readonly string[]\n\t} = {}): TransferMapping {\n\t\treturn {\n\t\t\ttables: this.associateByName([\n\t\t\t\tthis.buildEventDataMapping(args),\n\t\t\t\tthis.buildStageTransactionDataMapping(),\n\t\t\t]),\n\t\t}\n\t}\n\n\tprivate buildStageTransactionDataMapping(): TransferTableMapping {\n\t\treturn {\n\t\t\tname: 'stage_transaction',\n\n\t\t\tcolumns: this.associateByName([\n\t\t\t\t{ name: 'transaction_id', type: Model.ColumnType.Uuid },\n\t\t\t\t{ name: 'stage_slug', type: Model.ColumnType.String },\n\t\t\t\t{ name: 'applied_at', type: Model.ColumnType.DateTime },\n\t\t\t]),\n\n\t\t\tcreateSelect: (db, table) => {\n\t\t\t\tconst namespaceContext = new Compiler.Context(db.schema, new Set())\n\n\t\t\t\tlet builder = db.selectBuilder()\n\n\t\t\t\tfor (const column of Object.values(table.columns)) {\n\t\t\t\t\tif (column.name === 'stage_slug') {\n\t\t\t\t\t\tbuilder = builder.select(['stage', 'slug'], 'stage_slug')\n\t\t\t\t\t} else if (column.type === Model.ColumnType.Json || column.type === Model.ColumnType.Date || column.type === Model.ColumnType.DateTime) {\n\t\t\t\t\t\tbuilder = builder.select(expr => expr.raw(`${wrapIdentifier('stage_transaction')}.${wrapIdentifier(column.name)}::text`))\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbuilder = builder.select(['stage_transaction', column.name])\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn builder\n\t\t\t\t\t.from('stage_transaction')\n\t\t\t\t\t.join(\n\t\t\t\t\t\t'stage',\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\texpr => expr.compareColumns(['stage', 'id'], Operator.eq, ['stage_transaction', 'stage_id']),\n\t\t\t\t\t)\n\t\t\t\t\t.createQuery(namespaceContext)\n\t\t\t},\n\n\t\t\tcreateInsertStartFragment: (schema, tableName, columnNames) => {\n\t\t\t\tconst columnNames2 = columnNames.map(name => name === 'stage_slug' ? 'stage_id' : name)\n\t\t\t\tconst tableQuoted = `${wrapIdentifier(schema)}.${wrapIdentifier(tableName)}`\n\t\t\t\tconst columnsQuoted = '(' + columnNames2.map(it => wrapIdentifier(it)).join(', ') + ')'\n\t\t\t\treturn `INSERT INTO ${tableQuoted} ${columnsQuoted} VALUES\\n`\n\t\t\t},\n\n\t\t\tcreateRowParser: async (db, columns, baseType) => {\n\t\t\t\tconst stages = await db.selectBuilder<{ id: string; slug: string }>()\n\t\t\t\t\t.select('id')\n\t\t\t\t\t.select('slug')\n\t\t\t\t\t.from('stage')\n\t\t\t\t\t.getResult(db)\n\n\t\t\t\tconst stageSlugToId = new Map(stages.map(row => [row.slug, row.id]))\n\t\t\t\tconst stageSlugColumnIndex = columns.indexOf('stage_slug')\n\n\t\t\t\tif (stageSlugColumnIndex < 0) {\n\t\t\t\t\treturn baseType\n\t\t\t\t}\n\n\t\t\t\treturn (input, path) => {\n\t\t\t\t\tconst row = baseType(input, path)\n\t\t\t\t\tconst stageSlug = Typesafe.string(row[stageSlugColumnIndex])\n\t\t\t\t\tconst stageSlugId = stageSlugToId.get(stageSlug)\n\n\t\t\t\t\tif (stageSlugId === undefined) {\n\t\t\t\t\t\tthrow new ImportError(`Unknown stage slug ${stageSlug}`)\n\t\t\t\t\t}\n\n\t\t\t\t\tconst newRow = [...row]\n\t\t\t\t\tnewRow[stageSlugColumnIndex] = stageSlugId\n\n\t\t\t\t\treturn newRow\n\t\t\t\t}\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate buildEventDataMapping({ excludeTables = [] }: {\n\t\texcludeTables?: readonly string[]\n\t}): TransferTableMapping {\n\t\treturn {\n\t\t\tname: 'event_data',\n\n\t\t\tcolumns: this.associateByName([\n\t\t\t\t{ name: 'id', type: Model.ColumnType.Uuid },\n\t\t\t\t{ name: 'type', type: Model.ColumnType.Enum, values: ['create', 'update', 'delete'] },\n\t\t\t\t{ name: 'table_name', type: Model.ColumnType.String },\n\t\t\t\t{ name: 'row_ids', type: Model.ColumnType.Json, schema: Typesafe.array(Typesafe.string) },\n\t\t\t\t{ name: 'values', type: Model.ColumnType.Json, nullable: true, schema: Typesafe.object({}) },\n\t\t\t\t{ name: 'created_at', type: Model.ColumnType.DateTime },\n\t\t\t\t{ name: 'schema_version', type: Model.ColumnType.String },\n\t\t\t\t{ name: 'identity_id', type: Model.ColumnType.Uuid },\n\t\t\t\t{ name: 'transaction_id', type: Model.ColumnType.Uuid },\n\t\t\t]),\n\n\t\t\tcreateSelect: (db, table) => {\n\t\t\t\tconst namespaceContext = new Compiler.Context(db.schema, new Set())\n\n\t\t\t\tlet builder = db.selectBuilder()\n\n\t\t\t\tfor (const column of Object.values(table.columns)) {\n\t\t\t\t\tif (column.name === 'schema_version') {\n\t\t\t\t\t\tbuilder = builder.select(['schema_migration', 'version'], 'schema_version')\n\t\t\t\t\t} else if (column.type === Model.ColumnType.Json || column.type === Model.ColumnType.Date || column.type === Model.ColumnType.DateTime) {\n\t\t\t\t\t\tbuilder = builder.select(expr => expr.raw(`${wrapIdentifier('event_data')}.${wrapIdentifier(column.name)}::text`))\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbuilder = builder.select(['event_data', column.name])\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn builder\n\t\t\t\t\t.from('event_data')\n\t\t\t\t\t.join(\n\t\t\t\t\t\t'schema_migration',\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\texpr => expr.compareColumns(['schema_migration', 'id'], Operator.eq, ['event_data', 'schema_id']),\n\t\t\t\t\t)\n\t\t\t\t\t.match(it => {\n\t\t\t\t\t\tif (excludeTables.length === 0) {\n\t\t\t\t\t\t\treturn it\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn it.where(expr => expr.not(it => it.in('table_name', excludeTables)))\n\t\t\t\t\t})\n\t\t\t\t\t.createQuery(namespaceContext)\n\t\t\t},\n\n\t\t\tcreateInsertStartFragment: (schema, tableName, columnNames) => {\n\t\t\t\tconst columnNames2 = columnNames.map(name => name === 'schema_version' ? 'schema_id' : name)\n\t\t\t\tconst tableQuoted = `${wrapIdentifier(schema)}.${wrapIdentifier(tableName)}`\n\t\t\t\tconst columnsQuoted = '(' + columnNames2.map(it => wrapIdentifier(it)).join(', ') + ')'\n\t\t\t\treturn `INSERT INTO ${tableQuoted} ${columnsQuoted} VALUES\\n`\n\t\t\t},\n\n\t\t\tcreateRowParser: async (db, columns, baseType) => {\n\t\t\t\tconst schemaMigrations = await db.selectBuilder<{ id: string; version: string }>()\n\t\t\t\t\t.select('id')\n\t\t\t\t\t.select('version')\n\t\t\t\t\t.from('schema_migration')\n\t\t\t\t\t.getResult(db)\n\n\t\t\t\tconst versionToId = new Map(schemaMigrations.map(row => [row.version, row.id]))\n\t\t\t\tconst schemaVersionColumnIndex = columns.indexOf('schema_version')\n\n\t\t\t\tif (schemaVersionColumnIndex < 0) {\n\t\t\t\t\treturn baseType\n\t\t\t\t}\n\n\t\t\t\treturn (input, path) => {\n\t\t\t\t\tconst row = baseType(input, path)\n\t\t\t\t\tconst schemaVersion = Typesafe.string(row[schemaVersionColumnIndex])\n\t\t\t\t\tconst schemaVersionId = versionToId.get(schemaVersion)\n\n\t\t\t\t\tif (schemaVersionId === undefined) {\n\t\t\t\t\t\tthrow new ImportError(`Unknown schema version ${schemaVersion}`)\n\t\t\t\t\t}\n\n\t\t\t\t\tconst newRow = [...row]\n\t\t\t\t\tnewRow[schemaVersionColumnIndex] = schemaVersionId\n\n\t\t\t\t\treturn newRow\n\t\t\t\t}\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate associateByName<T extends { name: string }>(items: T[]): Record<string, T> {\n\t\treturn Object.fromEntries(items.map(item => [item.name, item]))\n\t}\n}\n"],"names":["it"],"mappings":";;;;AAMO,MAAM,mCAAmC;AAAA,EAC/C,MAAM,OAEF,IAAqB;AACxB,WAAO;AAAA,MACN,QAAQ,KAAK,gBAAgB;AAAA,QAC5B,KAAK,sBAAsB,IAAI;AAAA,QAC/B,KAAK,iCAAA;AAAA,MAAiC,CACtC;AAAA,IAAA;AAAA,EAEH;AAAA,EAEQ,mCAAyD;AAChE,WAAO;AAAA,MACN,MAAM;AAAA,MAEN,SAAS,KAAK,gBAAgB;AAAA,QAC7B,EAAE,MAAM,kBAAkB,MAAM,MAAM,WAAW,KAAA;AAAA,QACjD,EAAE,MAAM,cAAc,MAAM,MAAM,WAAW,OAAA;AAAA,QAC7C,EAAE,MAAM,cAAc,MAAM,MAAM,WAAW,SAAA;AAAA,MAAS,CACtD;AAAA,MAED,cAAc,CAAC,IAAI,UAAU;AAC5B,cAAM,mBAAmB,IAAI,SAAS,QAAQ,GAAG,QAAQ,oBAAI,KAAK;AAElE,YAAI,UAAU,GAAG,cAAA;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M,eAAe,EAAE,CAAC,EAAE,KAAK,IAAI,IAAI;AACpF,eAAO,eAAe,WAAW,IAAI,aAAa;AAAA;AAAA,MACnD;AAAA,MAEA,iBAAiB,OAAO,IAAI,SAAS,aAAa;AACjD,cAAM,mBAAmB,MAAM,GAAG,cAAA,EAChC,OAAO,IAAI,EACX,OAAO,SAAS,EAChB,KAAK,kBAAkB,EACvB,UAAU,EAAE;AAEd,cAAM,cAAc,IAAI,IAAI,iBAAiB,IAAI,CAAA,QAAO,CAAC,IAAI,SAAS,IAAI,EAAE,CAAC,CAAC;AAC9E,cAAM,2BAA2B,QAAQ,QAAQ,gBAAgB;AAEjE,YAAI,2BAA2B,GAAG;AACjC,iBAAO;AAAA,QACR;AAEA,eAAO,CAAC,OAAO,SAAS;AACvB,gBAAM,MAAM,SAAS,OAAO,IAAI;AAChC,gBAAM,gBAAgB,SAAS,OAAO,IAAI,wBAAwB,CAAC;AACnE,gBAAM,kBAAkB,YAAY,IAAI,aAAa;AAErD,cAAI,oBAAoB,QAAW;AAClC,kBAAM,IAAI,YAAY,0BAA0B,aAAa,EAAE;AAAA,UAChE;AAEA,gBAAM,SAAS,CAAC,GAAG,GAAG;AACtB,iBAAO,wBAAwB,IAAI;AAEnC,iBAAO;AAAA,QACR;AAAA,MACD;AAAA,IAAA;AAAA,EAEF;AAAA,EAEQ,gBAA4C,OAA+B;AAClF,WAAO,OAAO,YAAY,MAAM,IAAI,CAAA,SAAQ,CAAC,KAAK,MAAM,IAAI,CAAC,CAAC;AAAA,EAC/D;AACD;"}
|
|
1
|
+
{"version":3,"file":"SystemSchemaTransferMappingFactory.js","sources":["../../../../../packages/engine-http/src/transfer/SystemSchemaTransferMappingFactory.ts"],"sourcesContent":["import { TransferMapping, TransferTableMapping } from './TransferMapping.js'\nimport { Model } from '@contember/schema'\nimport * as Typesafe from '@contember/typesafe'\nimport { Compiler, Operator, wrapIdentifier } from '@contember/database'\nimport { ImportError } from './ImportExecutor.js'\n\nexport class SystemSchemaTransferMappingFactory {\n\tbuild(args: {\n\t\texcludeTables?: readonly string[]\n\t} = {}): TransferMapping {\n\t\treturn {\n\t\t\ttables: this.associateByName([\n\t\t\t\tthis.buildEventDataMapping(args),\n\t\t\t\tthis.buildStageTransactionDataMapping(),\n\t\t\t]),\n\t\t}\n\t}\n\n\tprivate buildStageTransactionDataMapping(): TransferTableMapping {\n\t\treturn {\n\t\t\tname: 'stage_transaction',\n\n\t\t\tcolumns: this.associateByName([\n\t\t\t\t{ name: 'transaction_id', type: Model.ColumnType.Uuid },\n\t\t\t\t{ name: 'stage_slug', type: Model.ColumnType.String },\n\t\t\t\t{ name: 'applied_at', type: Model.ColumnType.DateTime },\n\t\t\t]),\n\n\t\t\tcreateSelect: (db, table) => {\n\t\t\t\tconst namespaceContext = new Compiler.Context(db.schema, new Set())\n\n\t\t\t\tlet builder = db.selectBuilder()\n\n\t\t\t\tfor (const column of Object.values(table.columns)) {\n\t\t\t\t\tif (column.name === 'stage_slug') {\n\t\t\t\t\t\tbuilder = builder.select(['stage', 'slug'], 'stage_slug')\n\t\t\t\t\t} else if (column.type === Model.ColumnType.Json || column.type === Model.ColumnType.Date || column.type === Model.ColumnType.DateTime) {\n\t\t\t\t\t\tbuilder = builder.select(expr => expr.raw(`${wrapIdentifier('stage_transaction')}.${wrapIdentifier(column.name)}::text`))\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbuilder = builder.select(['stage_transaction', column.name])\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn builder\n\t\t\t\t\t.from('stage_transaction')\n\t\t\t\t\t.join(\n\t\t\t\t\t\t'stage',\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\texpr => expr.compareColumns(['stage', 'id'], Operator.eq, ['stage_transaction', 'stage_id']),\n\t\t\t\t\t)\n\t\t\t\t\t.createQuery(namespaceContext)\n\t\t\t},\n\n\t\t\tcreateInsertStartFragment: (schema, tableName, columnNames) => {\n\t\t\t\tconst columnNames2 = columnNames.map(name => name === 'stage_slug' ? 'stage_id' : name)\n\t\t\t\tconst tableQuoted = `${wrapIdentifier(schema)}.${wrapIdentifier(tableName)}`\n\t\t\t\tconst columnsQuoted = '(' + columnNames2.map(it => wrapIdentifier(it)).join(', ') + ')'\n\t\t\t\treturn `INSERT INTO ${tableQuoted} ${columnsQuoted} VALUES\\n`\n\t\t\t},\n\n\t\t\tcreateRowParser: async (db, columns, baseType) => {\n\t\t\t\tconst stages = await db.selectBuilder<{ id: string; slug: string }>()\n\t\t\t\t\t.select('id')\n\t\t\t\t\t.select('slug')\n\t\t\t\t\t.from('stage')\n\t\t\t\t\t.getResult(db)\n\n\t\t\t\tconst stageSlugToId = new Map(stages.map(row => [row.slug, row.id]))\n\t\t\t\tconst stageSlugColumnIndex = columns.indexOf('stage_slug')\n\n\t\t\t\tif (stageSlugColumnIndex < 0) {\n\t\t\t\t\treturn baseType\n\t\t\t\t}\n\n\t\t\t\treturn (input, path) => {\n\t\t\t\t\tconst row = baseType(input, path)\n\t\t\t\t\tconst stageSlug = Typesafe.string(row[stageSlugColumnIndex])\n\t\t\t\t\tconst stageSlugId = stageSlugToId.get(stageSlug)\n\n\t\t\t\t\tif (stageSlugId === undefined) {\n\t\t\t\t\t\tthrow new ImportError(`Unknown stage slug ${stageSlug}`)\n\t\t\t\t\t}\n\n\t\t\t\t\tconst newRow = [...row]\n\t\t\t\t\tnewRow[stageSlugColumnIndex] = stageSlugId\n\n\t\t\t\t\treturn newRow\n\t\t\t\t}\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate buildEventDataMapping({ excludeTables = [] }: {\n\t\texcludeTables?: readonly string[]\n\t}): TransferTableMapping {\n\t\treturn {\n\t\t\tname: 'event_data',\n\n\t\t\tcolumns: this.associateByName([\n\t\t\t\t{ name: 'id', type: Model.ColumnType.Uuid },\n\t\t\t\t{ name: 'type', type: Model.ColumnType.Enum, values: ['create', 'update', 'delete'] },\n\t\t\t\t{ name: 'table_name', type: Model.ColumnType.String },\n\t\t\t\t{ name: 'row_ids', type: Model.ColumnType.Json, schema: Typesafe.array(Typesafe.string) },\n\t\t\t\t{ name: 'values', type: Model.ColumnType.Json, nullable: true, schema: Typesafe.object({}) },\n\t\t\t\t{ name: 'created_at', type: Model.ColumnType.DateTime },\n\t\t\t\t{ name: 'schema_version', type: Model.ColumnType.String },\n\t\t\t\t{ name: 'identity_id', type: Model.ColumnType.Uuid },\n\t\t\t\t{ name: 'transaction_id', type: Model.ColumnType.Uuid },\n\t\t\t]),\n\n\t\t\tcreateSelect: (db, table) => {\n\t\t\t\tconst namespaceContext = new Compiler.Context(db.schema, new Set())\n\n\t\t\t\tlet builder = db.selectBuilder()\n\n\t\t\t\tfor (const column of Object.values(table.columns)) {\n\t\t\t\t\tif (column.name === 'schema_version') {\n\t\t\t\t\t\tbuilder = builder.select(['schema_migration', 'version'], 'schema_version')\n\t\t\t\t\t} else if (column.type === Model.ColumnType.Json || column.type === Model.ColumnType.Date || column.type === Model.ColumnType.DateTime) {\n\t\t\t\t\t\tbuilder = builder.select(expr => expr.raw(`${wrapIdentifier('event_data')}.${wrapIdentifier(column.name)}::text`))\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbuilder = builder.select(['event_data', column.name])\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn builder\n\t\t\t\t\t.from('event_data')\n\t\t\t\t\t.join(\n\t\t\t\t\t\t'schema_migration',\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\texpr => expr.compareColumns(['schema_migration', 'id'], Operator.eq, ['event_data', 'schema_id']),\n\t\t\t\t\t)\n\t\t\t\t\t.match(it => {\n\t\t\t\t\t\tif (excludeTables.length === 0) {\n\t\t\t\t\t\t\treturn it\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn it.where(expr => expr.not(it => it.in('table_name', excludeTables)))\n\t\t\t\t\t})\n\t\t\t\t\t.createQuery(namespaceContext)\n\t\t\t},\n\n\t\t\tcreateInsertStartFragment: (schema, tableName, columnNames) => {\n\t\t\t\tconst columnNames2 = columnNames.map(name => name === 'schema_version' ? 'schema_id' : name)\n\t\t\t\tconst tableQuoted = `${wrapIdentifier(schema)}.${wrapIdentifier(tableName)}`\n\t\t\t\tconst columnsQuoted = '(' + columnNames2.map(it => wrapIdentifier(it)).join(', ') + ')'\n\t\t\t\treturn `INSERT INTO ${tableQuoted} ${columnsQuoted} VALUES\\n`\n\t\t\t},\n\n\t\t\tcreateRowParser: async (db, columns, baseType) => {\n\t\t\t\tconst schemaMigrations = await db.selectBuilder<{ id: string; version: string }>()\n\t\t\t\t\t.select('id')\n\t\t\t\t\t.select('version')\n\t\t\t\t\t.from('schema_migration')\n\t\t\t\t\t.getResult(db)\n\n\t\t\t\tconst versionToId = new Map(schemaMigrations.map(row => [row.version, row.id]))\n\t\t\t\tconst schemaVersionColumnIndex = columns.indexOf('schema_version')\n\n\t\t\t\tif (schemaVersionColumnIndex < 0) {\n\t\t\t\t\treturn baseType\n\t\t\t\t}\n\n\t\t\t\treturn (input, path) => {\n\t\t\t\t\tconst row = baseType(input, path)\n\t\t\t\t\tconst schemaVersion = Typesafe.string(row[schemaVersionColumnIndex])\n\t\t\t\t\tconst schemaVersionId = versionToId.get(schemaVersion)\n\n\t\t\t\t\tif (schemaVersionId === undefined) {\n\t\t\t\t\t\tthrow new ImportError(`Unknown schema version ${schemaVersion}`)\n\t\t\t\t\t}\n\n\t\t\t\t\tconst newRow = [...row]\n\t\t\t\t\tnewRow[schemaVersionColumnIndex] = schemaVersionId\n\n\t\t\t\t\treturn newRow\n\t\t\t\t}\n\t\t\t},\n\t\t}\n\t}\n\n\tprivate associateByName<T extends { name: string }>(items: T[]): Record<string, T> {\n\t\treturn Object.fromEntries(items.map(item => [item.name, item]))\n\t}\n}\n"],"names":["it"],"mappings":";;;;AAMO,MAAM,mCAAmC;AAAA,EAC/C,MAAM,OAEF,IAAqB;AACxB,WAAO;AAAA,MACN,QAAQ,KAAK,gBAAgB;AAAA,QAC5B,KAAK,sBAAsB,IAAI;AAAA,QAC/B,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AAAA,QACR;AAAA,MACD;AAAA,IAAA;AAAA,EAEF;AAAA,EAEQ,gBAA4C,OAA+B;AAClF,WAAO,OAAO,YAAY,MAAM,IAAI,CAAA,SAAQ,CAAC,KAAK,MAAM,IAAI,CAAC,CAAC;AAAA,EAC/D;AACD;"}
|
|
@@ -25,6 +25,10 @@ const _CryptoWrapper = class _CryptoWrapper2 {
|
|
|
25
25
|
constructor(encryptionKey) {
|
|
26
26
|
this.encryptionKey = encryptionKey;
|
|
27
27
|
}
|
|
28
|
+
/** Whether an encryption key is configured (i.e. `encrypt`/`decrypt` will work). */
|
|
29
|
+
get enabled() {
|
|
30
|
+
return this.encryptionKey !== void 0;
|
|
31
|
+
}
|
|
28
32
|
async encrypt(value) {
|
|
29
33
|
if (!this.encryptionKey) {
|
|
30
34
|
throw new Error("encryption key not provided");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CryptoWrapper.cjs","sources":["../../../../../packages/engine-http/src/utils/CryptoWrapper.ts"],"sourcesContent":["import * as crypto from 'node:crypto'\n\nexport class CryptoWrapper {\n\tpublic static cryptoAlgo = 'aes-256-gcm' as const\n\tpublic static cryptoVersion = 2\n\n\tconstructor(\n\t\tprivate readonly encryptionKey?: crypto.KeyObject,\n\t) {\n\t}\n\n\tasync encrypt(value: Buffer): Promise<{ value: Buffer; version: number }> {\n\t\tif (!this.encryptionKey) {\n\t\t\tthrow new Error('encryption key not provided')\n\t\t}\n\n\t\tconst iv = crypto.randomBytes(16)\n\t\tconst cipher = crypto.createCipheriv(CryptoWrapper.cryptoAlgo, this.encryptionKey, iv)\n\t\treturn {\n\t\t\tvalue: Buffer.concat([cipher.update(value), cipher.final(), iv, cipher.getAuthTag()]),\n\t\t\tversion: CryptoWrapper.cryptoVersion,\n\t\t}\n\t}\n\n\tasync decrypt(value: Buffer, version: number): Promise<{ value: Buffer; needsReEncrypt: boolean }> {\n\t\tif (!this.encryptionKey) {\n\t\t\tthrow new Error('encryption key not provided')\n\t\t}\n\t\tif (version === 1) {\n\t\t\tconst decipher = crypto.createDecipheriv(CryptoWrapper.cryptoAlgo, this.encryptionKey, value.subarray(-16))\n\t\t\treturn {\n\t\t\t\tvalue: decipher.update(value.subarray(0, -16)),\n\t\t\t\tneedsReEncrypt: true,\n\t\t\t}\n\t\t} else if (version === 2) {\n\t\t\tconst decipher = crypto.createDecipheriv(CryptoWrapper.cryptoAlgo, this.encryptionKey, value.subarray(-32, -16))\n\t\t\tdecipher.setAuthTag(value.subarray(-16))\n\t\t\treturn {\n\t\t\t\tvalue: Buffer.concat([decipher.update(value.subarray(0, -32)), decipher.final()]),\n\t\t\t\tneedsReEncrypt: false,\n\t\t\t}\n\t\t}\n\t\tthrow new Error('unsupported version')\n\t}\n}\n"],"names":["_CryptoWrapper","crypto"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAEO,MAAM,iBAAN,MAAMA,gBAAc;AAAA,EAI1B,YACkB,eAChB;AADgB,SAAA,gBAAA;AAAA,EAElB;AAAA,EAEA,MAAM,QAAQ,OAA4D;AACzE,QAAI,CAAC,KAAK,eAAe;AACxB,YAAM,IAAI,MAAM,6BAA6B;AAAA,IAC9C;AAEA,UAAM,KAAKC,kBAAO,YAAY,EAAE;AAChC,UAAM,SAASA,kBAAO,eAAeD,gBAAc,YAAY,KAAK,eAAe,EAAE;AACrF,WAAO;AAAA,MACN,OAAO,OAAO,OAAO,CAAC,OAAO,OAAO,KAAK,GAAG,OAAO,SAAS,IAAI,OAAO,WAAA,CAAY,CAAC;AAAA,MACpF,SAASA,gBAAc;AAAA,IAAA;AAAA,EAEzB;AAAA,EAEA,MAAM,QAAQ,OAAe,SAAsE;AAClG,QAAI,CAAC,KAAK,eAAe;AACxB,YAAM,IAAI,MAAM,6BAA6B;AAAA,IAC9C;AACA,QAAI,YAAY,GAAG;AAClB,YAAM,WAAWC,kBAAO,iBAAiBD,gBAAc,YAAY,KAAK,eAAe,MAAM,SAAS,GAAG,CAAC;AAC1G,aAAO;AAAA,QACN,OAAO,SAAS,OAAO,MAAM,SAAS,GAAG,GAAG,CAAC;AAAA,QAC7C,gBAAgB;AAAA,MAAA;AAAA,IAElB,WAAW,YAAY,GAAG;AACzB,YAAM,WAAWC,kBAAO,iBAAiBD,gBAAc,YAAY,KAAK,eAAe,MAAM,SAAS,KAAK,GAAG,CAAC;AAC/G,eAAS,WAAW,MAAM,SAAS,GAAG,CAAC;AACvC,aAAO;AAAA,QACN,OAAO,OAAO,OAAO,CAAC,SAAS,OAAO,MAAM,SAAS,GAAG,GAAG,CAAC,GAAG,SAAS,MAAA,CAAO,CAAC;AAAA,QAChF,gBAAgB;AAAA,MAAA;AAAA,IAElB;AACA,UAAM,IAAI,MAAM,qBAAqB;AAAA,EACtC;AACD;
|
|
1
|
+
{"version":3,"file":"CryptoWrapper.cjs","sources":["../../../../../packages/engine-http/src/utils/CryptoWrapper.ts"],"sourcesContent":["import * as crypto from 'node:crypto'\n\nexport class CryptoWrapper {\n\tpublic static cryptoAlgo = 'aes-256-gcm' as const\n\tpublic static cryptoVersion = 2\n\n\tconstructor(\n\t\tprivate readonly encryptionKey?: crypto.KeyObject,\n\t) {\n\t}\n\n\t/** Whether an encryption key is configured (i.e. `encrypt`/`decrypt` will work). */\n\tget enabled(): boolean {\n\t\treturn this.encryptionKey !== undefined\n\t}\n\n\tasync encrypt(value: Buffer): Promise<{ value: Buffer; version: number }> {\n\t\tif (!this.encryptionKey) {\n\t\t\tthrow new Error('encryption key not provided')\n\t\t}\n\n\t\tconst iv = crypto.randomBytes(16)\n\t\tconst cipher = crypto.createCipheriv(CryptoWrapper.cryptoAlgo, this.encryptionKey, iv)\n\t\treturn {\n\t\t\tvalue: Buffer.concat([cipher.update(value), cipher.final(), iv, cipher.getAuthTag()]),\n\t\t\tversion: CryptoWrapper.cryptoVersion,\n\t\t}\n\t}\n\n\tasync decrypt(value: Buffer, version: number): Promise<{ value: Buffer; needsReEncrypt: boolean }> {\n\t\tif (!this.encryptionKey) {\n\t\t\tthrow new Error('encryption key not provided')\n\t\t}\n\t\tif (version === 1) {\n\t\t\tconst decipher = crypto.createDecipheriv(CryptoWrapper.cryptoAlgo, this.encryptionKey, value.subarray(-16))\n\t\t\treturn {\n\t\t\t\tvalue: decipher.update(value.subarray(0, -16)),\n\t\t\t\tneedsReEncrypt: true,\n\t\t\t}\n\t\t} else if (version === 2) {\n\t\t\tconst decipher = crypto.createDecipheriv(CryptoWrapper.cryptoAlgo, this.encryptionKey, value.subarray(-32, -16))\n\t\t\tdecipher.setAuthTag(value.subarray(-16))\n\t\t\treturn {\n\t\t\t\tvalue: Buffer.concat([decipher.update(value.subarray(0, -32)), decipher.final()]),\n\t\t\t\tneedsReEncrypt: false,\n\t\t\t}\n\t\t}\n\t\tthrow new Error('unsupported version')\n\t}\n}\n"],"names":["_CryptoWrapper","crypto"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAEO,MAAM,iBAAN,MAAMA,gBAAc;AAAA,EAI1B,YACkB,eAChB;AADgB,SAAA,gBAAA;AAAA,EAElB;AAAA;AAAA,EAGA,IAAI,UAAmB;AACtB,WAAO,KAAK,kBAAkB;AAAA,EAC/B;AAAA,EAEA,MAAM,QAAQ,OAA4D;AACzE,QAAI,CAAC,KAAK,eAAe;AACxB,YAAM,IAAI,MAAM,6BAA6B;AAAA,IAC9C;AAEA,UAAM,KAAKC,kBAAO,YAAY,EAAE;AAChC,UAAM,SAASA,kBAAO,eAAeD,gBAAc,YAAY,KAAK,eAAe,EAAE;AACrF,WAAO;AAAA,MACN,OAAO,OAAO,OAAO,CAAC,OAAO,OAAO,KAAK,GAAG,OAAO,SAAS,IAAI,OAAO,WAAA,CAAY,CAAC;AAAA,MACpF,SAASA,gBAAc;AAAA,IAAA;AAAA,EAEzB;AAAA,EAEA,MAAM,QAAQ,OAAe,SAAsE;AAClG,QAAI,CAAC,KAAK,eAAe;AACxB,YAAM,IAAI,MAAM,6BAA6B;AAAA,IAC9C;AACA,QAAI,YAAY,GAAG;AAClB,YAAM,WAAWC,kBAAO,iBAAiBD,gBAAc,YAAY,KAAK,eAAe,MAAM,SAAS,GAAG,CAAC;AAC1G,aAAO;AAAA,QACN,OAAO,SAAS,OAAO,MAAM,SAAS,GAAG,GAAG,CAAC;AAAA,QAC7C,gBAAgB;AAAA,MAAA;AAAA,IAElB,WAAW,YAAY,GAAG;AACzB,YAAM,WAAWC,kBAAO,iBAAiBD,gBAAc,YAAY,KAAK,eAAe,MAAM,SAAS,KAAK,GAAG,CAAC;AAC/G,eAAS,WAAW,MAAM,SAAS,GAAG,CAAC;AACvC,aAAO;AAAA,QACN,OAAO,OAAO,OAAO,CAAC,SAAS,OAAO,MAAM,SAAS,GAAG,GAAG,CAAC,GAAG,SAAS,MAAA,CAAO,CAAC;AAAA,QAChF,gBAAgB;AAAA,MAAA;AAAA,IAElB;AACA,UAAM,IAAI,MAAM,qBAAqB;AAAA,EACtC;AACD;AA9CC,cADY,gBACE,cAAa,aAAA;AAC3B,cAFY,gBAEE,iBAAgB,CAAA;AAFxB,IAAM,gBAAN;;"}
|
|
@@ -6,6 +6,10 @@ const _CryptoWrapper = class _CryptoWrapper2 {
|
|
|
6
6
|
constructor(encryptionKey) {
|
|
7
7
|
this.encryptionKey = encryptionKey;
|
|
8
8
|
}
|
|
9
|
+
/** Whether an encryption key is configured (i.e. `encrypt`/`decrypt` will work). */
|
|
10
|
+
get enabled() {
|
|
11
|
+
return this.encryptionKey !== void 0;
|
|
12
|
+
}
|
|
9
13
|
async encrypt(value) {
|
|
10
14
|
if (!this.encryptionKey) {
|
|
11
15
|
throw new Error("encryption key not provided");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CryptoWrapper.js","sources":["../../../../../packages/engine-http/src/utils/CryptoWrapper.ts"],"sourcesContent":["import * as crypto from 'node:crypto'\n\nexport class CryptoWrapper {\n\tpublic static cryptoAlgo = 'aes-256-gcm' as const\n\tpublic static cryptoVersion = 2\n\n\tconstructor(\n\t\tprivate readonly encryptionKey?: crypto.KeyObject,\n\t) {\n\t}\n\n\tasync encrypt(value: Buffer): Promise<{ value: Buffer; version: number }> {\n\t\tif (!this.encryptionKey) {\n\t\t\tthrow new Error('encryption key not provided')\n\t\t}\n\n\t\tconst iv = crypto.randomBytes(16)\n\t\tconst cipher = crypto.createCipheriv(CryptoWrapper.cryptoAlgo, this.encryptionKey, iv)\n\t\treturn {\n\t\t\tvalue: Buffer.concat([cipher.update(value), cipher.final(), iv, cipher.getAuthTag()]),\n\t\t\tversion: CryptoWrapper.cryptoVersion,\n\t\t}\n\t}\n\n\tasync decrypt(value: Buffer, version: number): Promise<{ value: Buffer; needsReEncrypt: boolean }> {\n\t\tif (!this.encryptionKey) {\n\t\t\tthrow new Error('encryption key not provided')\n\t\t}\n\t\tif (version === 1) {\n\t\t\tconst decipher = crypto.createDecipheriv(CryptoWrapper.cryptoAlgo, this.encryptionKey, value.subarray(-16))\n\t\t\treturn {\n\t\t\t\tvalue: decipher.update(value.subarray(0, -16)),\n\t\t\t\tneedsReEncrypt: true,\n\t\t\t}\n\t\t} else if (version === 2) {\n\t\t\tconst decipher = crypto.createDecipheriv(CryptoWrapper.cryptoAlgo, this.encryptionKey, value.subarray(-32, -16))\n\t\t\tdecipher.setAuthTag(value.subarray(-16))\n\t\t\treturn {\n\t\t\t\tvalue: Buffer.concat([decipher.update(value.subarray(0, -32)), decipher.final()]),\n\t\t\t\tneedsReEncrypt: false,\n\t\t\t}\n\t\t}\n\t\tthrow new Error('unsupported version')\n\t}\n}\n"],"names":["_CryptoWrapper"],"mappings":";;;;AAEO,MAAM,iBAAN,MAAMA,gBAAc;AAAA,EAI1B,YACkB,eAChB;AADgB,SAAA,gBAAA;AAAA,EAElB;AAAA,EAEA,MAAM,QAAQ,OAA4D;AACzE,QAAI,CAAC,KAAK,eAAe;AACxB,YAAM,IAAI,MAAM,6BAA6B;AAAA,IAC9C;AAEA,UAAM,KAAK,OAAO,YAAY,EAAE;AAChC,UAAM,SAAS,OAAO,eAAeA,gBAAc,YAAY,KAAK,eAAe,EAAE;AACrF,WAAO;AAAA,MACN,OAAO,OAAO,OAAO,CAAC,OAAO,OAAO,KAAK,GAAG,OAAO,SAAS,IAAI,OAAO,WAAA,CAAY,CAAC;AAAA,MACpF,SAASA,gBAAc;AAAA,IAAA;AAAA,EAEzB;AAAA,EAEA,MAAM,QAAQ,OAAe,SAAsE;AAClG,QAAI,CAAC,KAAK,eAAe;AACxB,YAAM,IAAI,MAAM,6BAA6B;AAAA,IAC9C;AACA,QAAI,YAAY,GAAG;AAClB,YAAM,WAAW,OAAO,iBAAiBA,gBAAc,YAAY,KAAK,eAAe,MAAM,SAAS,GAAG,CAAC;AAC1G,aAAO;AAAA,QACN,OAAO,SAAS,OAAO,MAAM,SAAS,GAAG,GAAG,CAAC;AAAA,QAC7C,gBAAgB;AAAA,MAAA;AAAA,IAElB,WAAW,YAAY,GAAG;AACzB,YAAM,WAAW,OAAO,iBAAiBA,gBAAc,YAAY,KAAK,eAAe,MAAM,SAAS,KAAK,GAAG,CAAC;AAC/G,eAAS,WAAW,MAAM,SAAS,GAAG,CAAC;AACvC,aAAO;AAAA,QACN,OAAO,OAAO,OAAO,CAAC,SAAS,OAAO,MAAM,SAAS,GAAG,GAAG,CAAC,GAAG,SAAS,MAAA,CAAO,CAAC;AAAA,QAChF,gBAAgB;AAAA,MAAA;AAAA,IAElB;AACA,UAAM,IAAI,MAAM,qBAAqB;AAAA,EACtC;AACD;
|
|
1
|
+
{"version":3,"file":"CryptoWrapper.js","sources":["../../../../../packages/engine-http/src/utils/CryptoWrapper.ts"],"sourcesContent":["import * as crypto from 'node:crypto'\n\nexport class CryptoWrapper {\n\tpublic static cryptoAlgo = 'aes-256-gcm' as const\n\tpublic static cryptoVersion = 2\n\n\tconstructor(\n\t\tprivate readonly encryptionKey?: crypto.KeyObject,\n\t) {\n\t}\n\n\t/** Whether an encryption key is configured (i.e. `encrypt`/`decrypt` will work). */\n\tget enabled(): boolean {\n\t\treturn this.encryptionKey !== undefined\n\t}\n\n\tasync encrypt(value: Buffer): Promise<{ value: Buffer; version: number }> {\n\t\tif (!this.encryptionKey) {\n\t\t\tthrow new Error('encryption key not provided')\n\t\t}\n\n\t\tconst iv = crypto.randomBytes(16)\n\t\tconst cipher = crypto.createCipheriv(CryptoWrapper.cryptoAlgo, this.encryptionKey, iv)\n\t\treturn {\n\t\t\tvalue: Buffer.concat([cipher.update(value), cipher.final(), iv, cipher.getAuthTag()]),\n\t\t\tversion: CryptoWrapper.cryptoVersion,\n\t\t}\n\t}\n\n\tasync decrypt(value: Buffer, version: number): Promise<{ value: Buffer; needsReEncrypt: boolean }> {\n\t\tif (!this.encryptionKey) {\n\t\t\tthrow new Error('encryption key not provided')\n\t\t}\n\t\tif (version === 1) {\n\t\t\tconst decipher = crypto.createDecipheriv(CryptoWrapper.cryptoAlgo, this.encryptionKey, value.subarray(-16))\n\t\t\treturn {\n\t\t\t\tvalue: decipher.update(value.subarray(0, -16)),\n\t\t\t\tneedsReEncrypt: true,\n\t\t\t}\n\t\t} else if (version === 2) {\n\t\t\tconst decipher = crypto.createDecipheriv(CryptoWrapper.cryptoAlgo, this.encryptionKey, value.subarray(-32, -16))\n\t\t\tdecipher.setAuthTag(value.subarray(-16))\n\t\t\treturn {\n\t\t\t\tvalue: Buffer.concat([decipher.update(value.subarray(0, -32)), decipher.final()]),\n\t\t\t\tneedsReEncrypt: false,\n\t\t\t}\n\t\t}\n\t\tthrow new Error('unsupported version')\n\t}\n}\n"],"names":["_CryptoWrapper"],"mappings":";;;;AAEO,MAAM,iBAAN,MAAMA,gBAAc;AAAA,EAI1B,YACkB,eAChB;AADgB,SAAA,gBAAA;AAAA,EAElB;AAAA;AAAA,EAGA,IAAI,UAAmB;AACtB,WAAO,KAAK,kBAAkB;AAAA,EAC/B;AAAA,EAEA,MAAM,QAAQ,OAA4D;AACzE,QAAI,CAAC,KAAK,eAAe;AACxB,YAAM,IAAI,MAAM,6BAA6B;AAAA,IAC9C;AAEA,UAAM,KAAK,OAAO,YAAY,EAAE;AAChC,UAAM,SAAS,OAAO,eAAeA,gBAAc,YAAY,KAAK,eAAe,EAAE;AACrF,WAAO;AAAA,MACN,OAAO,OAAO,OAAO,CAAC,OAAO,OAAO,KAAK,GAAG,OAAO,SAAS,IAAI,OAAO,WAAA,CAAY,CAAC;AAAA,MACpF,SAASA,gBAAc;AAAA,IAAA;AAAA,EAEzB;AAAA,EAEA,MAAM,QAAQ,OAAe,SAAsE;AAClG,QAAI,CAAC,KAAK,eAAe;AACxB,YAAM,IAAI,MAAM,6BAA6B;AAAA,IAC9C;AACA,QAAI,YAAY,GAAG;AAClB,YAAM,WAAW,OAAO,iBAAiBA,gBAAc,YAAY,KAAK,eAAe,MAAM,SAAS,GAAG,CAAC;AAC1G,aAAO;AAAA,QACN,OAAO,SAAS,OAAO,MAAM,SAAS,GAAG,GAAG,CAAC;AAAA,QAC7C,gBAAgB;AAAA,MAAA;AAAA,IAElB,WAAW,YAAY,GAAG;AACzB,YAAM,WAAW,OAAO,iBAAiBA,gBAAc,YAAY,KAAK,eAAe,MAAM,SAAS,KAAK,GAAG,CAAC;AAC/G,eAAS,WAAW,MAAM,SAAS,GAAG,CAAC;AACvC,aAAO;AAAA,QACN,OAAO,OAAO,OAAO,CAAC,SAAS,OAAO,MAAM,SAAS,GAAG,GAAG,CAAC,GAAG,SAAS,MAAA,CAAO,CAAC;AAAA,QAChF,gBAAgB;AAAA,MAAA;AAAA,IAElB;AACA,UAAM,IAAI,MAAM,qBAAqB;AAAA,EACtC;AACD;AA9CC,cADY,gBACE,cAAa,aAAA;AAC3B,cAFY,gBAEE,iBAAgB,CAAA;AAFxB,IAAM,gBAAN;"}
|
|
@@ -10,9 +10,10 @@ function isPrivate(ip) {
|
|
|
10
10
|
}
|
|
11
11
|
const r = addr.range();
|
|
12
12
|
if (r === "ipv4Mapped") {
|
|
13
|
-
|
|
13
|
+
const mapped = addr.toIPv4Address().range();
|
|
14
|
+
return mapped === "private" || mapped === "loopback";
|
|
14
15
|
}
|
|
15
|
-
return r === "private" || r === "uniqueLocal" || r === "linkLocal";
|
|
16
|
+
return r === "private" || r === "loopback" || r === "uniqueLocal" || r === "linkLocal";
|
|
16
17
|
}
|
|
17
18
|
function isInCIDR(ip, cidrs) {
|
|
18
19
|
if (!cidrs || cidrs.length === 0) {
|
|
@@ -34,7 +35,7 @@ function isInCIDR(ip, cidrs) {
|
|
|
34
35
|
}
|
|
35
36
|
function getClientIP(req, trustedProxies) {
|
|
36
37
|
const remote = req.socket.remoteAddress || "";
|
|
37
|
-
if (!isPrivate(remote) && !isInCIDR(remote, [])) {
|
|
38
|
+
if (!isPrivate(remote) && !isInCIDR(remote, trustedProxies || [])) {
|
|
38
39
|
return remote;
|
|
39
40
|
}
|
|
40
41
|
const xffHeader = req.headers["x-forwarded-for"];
|
|
@@ -46,7 +47,7 @@ function getClientIP(req, trustedProxies) {
|
|
|
46
47
|
}
|
|
47
48
|
for (let i = xffList.length - 1; i >= 0; i--) {
|
|
48
49
|
const ip = xffList[i];
|
|
49
|
-
if (!isPrivate(ip) && !isInCIDR(ip, [])) {
|
|
50
|
+
if (!isPrivate(ip) && !isInCIDR(ip, trustedProxies || [])) {
|
|
50
51
|
return ip;
|
|
51
52
|
}
|
|
52
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remoteAddress.cjs","sources":["../../../../../packages/engine-http/src/utils/remoteAddress.ts"],"sourcesContent":["import { IncomingMessage } from 'node:http'\nimport ipaddr from 'ipaddr.js'\n\nfunction isPrivate(ip: string): boolean {\n\tlet addr: ipaddr.IPv4 | ipaddr.IPv6\n\ttry {\n\t\taddr = ipaddr.parse(ip)\n\t} catch {\n\t\treturn false\n\t}\n\n\tconst r = addr.range()\n\tif (r === 'ipv4Mapped') {\n\t\
|
|
1
|
+
{"version":3,"file":"remoteAddress.cjs","sources":["../../../../../packages/engine-http/src/utils/remoteAddress.ts"],"sourcesContent":["import { IncomingMessage } from 'node:http'\nimport ipaddr from 'ipaddr.js'\n\nfunction isPrivate(ip: string): boolean {\n\tlet addr: ipaddr.IPv4 | ipaddr.IPv6\n\ttry {\n\t\taddr = ipaddr.parse(ip)\n\t} catch {\n\t\treturn false\n\t}\n\n\tconst r = addr.range()\n\tif (r === 'ipv4Mapped') {\n\t\tconst mapped = (addr as ipaddr.IPv6).toIPv4Address().range()\n\t\treturn mapped === 'private' || mapped === 'loopback'\n\t}\n\n\treturn r === 'private' // IPv4 RFC1918\n\t\t|| r === 'loopback' // 127.0.0.0/8, ::1\n\t\t|| r === 'uniqueLocal' // IPv6 fc00::/7\n\t\t|| r === 'linkLocal' // IPv6 fe80::/10\n}\n\nfunction isInCIDR(ip: string, cidrs: string[]): boolean {\n\tif (!cidrs || cidrs.length === 0) {\n\t\treturn false\n\t}\n\n\tlet addr: ipaddr.IPv4 | ipaddr.IPv6\n\ttry {\n\t\taddr = ipaddr.parse(ip)\n\t} catch {\n\t\treturn false\n\t}\n\treturn cidrs.some(c => {\n\t\ttry {\n\t\t\treturn addr.match(ipaddr.parseCIDR(c))\n\t\t} catch {\n\t\t\treturn false\n\t\t}\n\t})\n}\n\nexport function getClientIP(req: IncomingMessage, trustedProxies?: string[]): string {\n\tconst remote = req.socket.remoteAddress || ''\n\n\tif (!isPrivate(remote) && !isInCIDR(remote, trustedProxies || [])) {\n\t\treturn remote\n\t}\n\n\tconst xffHeader = req.headers['x-forwarded-for']\n\tlet xffList: string[] = []\n\n\tif (Array.isArray(xffHeader)) {\n\t\txffHeader.forEach(h => xffList.push(...h.split(',').map(ip => ip.trim()).filter(Boolean)))\n\t} else if (typeof xffHeader === 'string') {\n\t\txffList = xffHeader.split(',').map(ip => ip.trim()).filter(Boolean)\n\t}\n\n\tfor (let i = xffList.length - 1; i >= 0; i--) {\n\t\tconst ip = xffList[i]\n\t\tif (!isPrivate(ip) && !isInCIDR(ip, trustedProxies || [])) {\n\t\t\treturn ip\n\t\t}\n\t}\n\n\treturn remote\n}\n"],"names":[],"mappings":";;;AAGA,SAAS,UAAU,I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SAAS,GAAG,KAAK,GAAG,KAAK;AAC7C,UAAM,KAAK,QAAQ,CAAC;AACpB,QAAI,CAAC,UAAU,EAAE,KAAK,CAAC,SAAS,IAAI,kBAAkB,CAAA,CAAE,GAAG;AAC1D,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;;"}
|
|
@@ -8,9 +8,10 @@ function isPrivate(ip) {
|
|
|
8
8
|
}
|
|
9
9
|
const r = addr.range();
|
|
10
10
|
if (r === "ipv4Mapped") {
|
|
11
|
-
|
|
11
|
+
const mapped = addr.toIPv4Address().range();
|
|
12
|
+
return mapped === "private" || mapped === "loopback";
|
|
12
13
|
}
|
|
13
|
-
return r === "private" || r === "uniqueLocal" || r === "linkLocal";
|
|
14
|
+
return r === "private" || r === "loopback" || r === "uniqueLocal" || r === "linkLocal";
|
|
14
15
|
}
|
|
15
16
|
function isInCIDR(ip, cidrs) {
|
|
16
17
|
if (!cidrs || cidrs.length === 0) {
|
|
@@ -32,7 +33,7 @@ function isInCIDR(ip, cidrs) {
|
|
|
32
33
|
}
|
|
33
34
|
function getClientIP(req, trustedProxies) {
|
|
34
35
|
const remote = req.socket.remoteAddress || "";
|
|
35
|
-
if (!isPrivate(remote) && !isInCIDR(remote, [])) {
|
|
36
|
+
if (!isPrivate(remote) && !isInCIDR(remote, trustedProxies || [])) {
|
|
36
37
|
return remote;
|
|
37
38
|
}
|
|
38
39
|
const xffHeader = req.headers["x-forwarded-for"];
|
|
@@ -44,7 +45,7 @@ function getClientIP(req, trustedProxies) {
|
|
|
44
45
|
}
|
|
45
46
|
for (let i = xffList.length - 1; i >= 0; i--) {
|
|
46
47
|
const ip = xffList[i];
|
|
47
|
-
if (!isPrivate(ip) && !isInCIDR(ip, [])) {
|
|
48
|
+
if (!isPrivate(ip) && !isInCIDR(ip, trustedProxies || [])) {
|
|
48
49
|
return ip;
|
|
49
50
|
}
|
|
50
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remoteAddress.js","sources":["../../../../../packages/engine-http/src/utils/remoteAddress.ts"],"sourcesContent":["import { IncomingMessage } from 'node:http'\nimport ipaddr from 'ipaddr.js'\n\nfunction isPrivate(ip: string): boolean {\n\tlet addr: ipaddr.IPv4 | ipaddr.IPv6\n\ttry {\n\t\taddr = ipaddr.parse(ip)\n\t} catch {\n\t\treturn false\n\t}\n\n\tconst r = addr.range()\n\tif (r === 'ipv4Mapped') {\n\t\
|
|
1
|
+
{"version":3,"file":"remoteAddress.js","sources":["../../../../../packages/engine-http/src/utils/remoteAddress.ts"],"sourcesContent":["import { IncomingMessage } from 'node:http'\nimport ipaddr from 'ipaddr.js'\n\nfunction isPrivate(ip: string): boolean {\n\tlet addr: ipaddr.IPv4 | ipaddr.IPv6\n\ttry {\n\t\taddr = ipaddr.parse(ip)\n\t} catch {\n\t\treturn false\n\t}\n\n\tconst r = addr.range()\n\tif (r === 'ipv4Mapped') {\n\t\tconst mapped = (addr as ipaddr.IPv6).toIPv4Address().range()\n\t\treturn mapped === 'private' || mapped === 'loopback'\n\t}\n\n\treturn r === 'private' // IPv4 RFC1918\n\t\t|| r === 'loopback' // 127.0.0.0/8, ::1\n\t\t|| r === 'uniqueLocal' // IPv6 fc00::/7\n\t\t|| r === 'linkLocal' // IPv6 fe80::/10\n}\n\nfunction isInCIDR(ip: string, cidrs: string[]): boolean {\n\tif (!cidrs || cidrs.length === 0) {\n\t\treturn false\n\t}\n\n\tlet addr: ipaddr.IPv4 | ipaddr.IPv6\n\ttry {\n\t\taddr = ipaddr.parse(ip)\n\t} catch {\n\t\treturn false\n\t}\n\treturn cidrs.some(c => {\n\t\ttry {\n\t\t\treturn addr.match(ipaddr.parseCIDR(c))\n\t\t} catch {\n\t\t\treturn false\n\t\t}\n\t})\n}\n\nexport function getClientIP(req: IncomingMessage, trustedProxies?: string[]): string {\n\tconst remote = req.socket.remoteAddress || ''\n\n\tif (!isPrivate(remote) && !isInCIDR(remote, trustedProxies || [])) {\n\t\treturn remote\n\t}\n\n\tconst xffHeader = req.headers['x-forwarded-for']\n\tlet xffList: string[] = []\n\n\tif (Array.isArray(xffHeader)) {\n\t\txffHeader.forEach(h => xffList.push(...h.split(',').map(ip => ip.trim()).filter(Boolean)))\n\t} else if (typeof xffHeader === 'string') {\n\t\txffList = xffHeader.split(',').map(ip => ip.trim()).filter(Boolean)\n\t}\n\n\tfor (let i = xffList.length - 1; i >= 0; i--) {\n\t\tconst ip = xffList[i]\n\t\tif (!isPrivate(ip) && !isInCIDR(ip, trustedProxies || [])) {\n\t\t\treturn ip\n\t\t}\n\t}\n\n\treturn remote\n}\n"],"names":[],"mappings":";AAGA,SAAS,UAAU,IAAqB;AACvC,MAAI;AACJ,MAAI;AACH,WAAO,OAAO,MAAM,EAAE;AAAA,EACvB,QAAQ;AACP,WAAO;AAAA,EACR;AAEA,QAAM,IAAI,KAAK,MAAA;AACf,MAAI,MAAM,cAAc;AACvB,UAAM,SAAU,KAAqB,cAAA,EAAgB,MAAA;AACrD,WAAO,WAAW,aAAa,WAAW;AAAA,EAC3C;AAEA,SAAO,MAAM,aACT,MAAM,cACN,MAAM,iBACN,MAAM;AACX;AAEA,SAAS,SAAS,IAAY,OAA0B;AACvD,MAAI,CAAC,SAAS,MAAM,WAAW,GAAG;AACjC,WAAO;AAAA,EACR;AAEA,MAAI;AACJ,MAAI;AACH,WAAO,OAAO,MAAM,EAAE;AAAA,EACvB,QAAQ;AACP,WAAO;AAAA,EACR;AACA,SAAO,MAAM,KAAK,CAAA,MAAK;AACtB,QAAI;AACH,aAAO,KAAK,MAAM,OAAO,UAAU,CAAC,CAAC;AAAA,IACtC,QAAQ;AACP,aAAO;AAAA,IACR;AAAA,EACD,CAAC;AACF;AAEO,SAAS,YAAY,KAAsB,gBAAmC;AACpF,QAAM,SAAS,IAAI,OAAO,iBAAiB;AAE3C,MAAI,CAAC,UAAU,MAAM,KAAK,CAAC,SAAS,QAAQ,kBAAkB,CAAA,CAAE,GAAG;AAClE,WAAO;AAAA,EACR;AAEA,QAAM,YAAY,IAAI,QAAQ,iBAAiB;AAC/C,MAAI,UAAoB,CAAA;AAExB,MAAI,MAAM,QAAQ,SAAS,GAAG;AAC7B,cAAU,QAAQ,CAAA,MAAK,QAAQ,KAAK,GAAG,EAAE,MAAM,GAAG,EAAE,IAAI,CAAA,OAAM,GAAG,KAAA,CAAM,EAAE,OAAO,OAAO,CAAC,CAAC;AAAA,EAC1F,WAAW,OAAO,cAAc,UAAU;AACzC,cAAU,UAAU,MAAM,GAAG,EAAE,IAAI,CAAA,OAAM,GAAG,KAAA,CAAM,EAAE,OAAO,OAAO;AAAA,EACnE;AAEA,WAAS,IAAI,QAAQ,SAAS,GAAG,KAAK,GAAG,KAAK;AAC7C,UAAM,KAAK,QAAQ,CAAC;AACpB,QAAI,CAAC,UAAU,EAAE,KAAK,CAAC,SAAS,IAAI,kBAAkB,CAAA,CAAE,GAAG;AAC1D,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sentry.cjs","sources":["../../../../../packages/engine-http/src/utils/sentry.ts"],"sourcesContent":["import * as Sentry from '@sentry/node'\nimport { LogEntry, LoggerHandler, LogLevel, LogLevelName, LogLevels } from '@contember/logger'\nimport { LoggerRequestBody } from '../application'\n\nconst logLevelMapping: Record<LogLevelName, Sentry.SeverityLevel> = {\n\tcrit: 'fatal',\n\terror: 'error',\n\twarn: 'warning',\n\tdebug: 'debug',\n\tinfo: 'info',\n}\n\nexport class SentryLoggerHandler implements LoggerHandler {\n\tconstructor(\n\t\tprivate readonly logLevel: LogLevel,\n\t) {\n\t}\n\n\tgetMinLevel(): number {\n\t\treturn this.logLevel.value\n\t}\n\n\thandle(entry: LogEntry) {\n\t\tif (!entry.error || entry.level.value < this.logLevel.value) {\n\t\t\treturn\n\t\t}\n\t\tSentry.captureException(entry.error, scope => {\n\t\t\tscope.setTag('project', entry.loggerAttributes.project ?? entry.ownAttributes.project)\n\t\t\tscope.setTag('module', entry.loggerAttributes.module ?? entry.ownAttributes.module)\n\t\t\tscope.setLevel(logLevelMapping[entry.level.name])\n\t\t\tscope.setUser({\n\t\t\t\tid: entry.loggerAttributes.user ?? entry.ownAttributes.user,\n\t\t\t})\n\t\t\tscope.setExtra('requestId', entry.loggerAttributes.requestId)\n\n\t\t\tscope.addEventProcessor(event => {\n\t\t\t\treturn {\n\t\t\t\t\t...event,\n\t\t\t\t\trequest: {\n\t\t\t\t\t\turl: entry.loggerAttributes.url ?? entry.ownAttributes.url,\n\t\t\t\t\t\tdata: entry.loggerAttributes[LoggerRequestBody],\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t})\n\t\t\treturn scope\n\t\t})\n\t}\n\n\tclose(): void {\n\t}\n}\n\nexport const createSentryLoggerHandler = (dsn?: string): null | LoggerHandler => {\n\tif (!dsn) {\n\t\treturn null\n\t}\n\tSentry.init({\n\t\tdsn: dsn,\n\t\tintegrations: integrations => {\n\t\t\treturn integrations.filter(integration => integration.name !== 'Console' && integration.name !== 'Http')\n\t\t},\n\t})\n\treturn new SentryLoggerHandler(LogLevels.warn)\n}\n"],"names":["Sentry","LoggerRequestBody","LogLevels"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAIA,MAAM,kBAA8D;AAAA,EACnE,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AACP;AAEO,MAAM,oBAA6C;AAAA,EACzD,YACkB,UAChB;AADgB,SAAA,WAAA;AAAA,EAElB;AAAA,EAEA,cAAsB;AACrB,WAAO,KAAK,SAAS;AAAA,EACtB;AAAA,EAEA,OAAO,OAAiB;AACvB,QAAI,CAAC,MAAM,SAAS,MAAM,MAAM,QAAQ,KAAK,SAAS,OAAO;AAC5D;AAAA,IACD;AACAA,sBAAO,iBAAiB,MAAM,OAAO,CAAA,UAAS;AAC7C,YAAM,OAAO,WAAW,MAAM,iBAAiB,WAAW,MAAM,cAAc,OAAO;AACrF,YAAM,OAAO,UAAU,MAAM,iBAAiB,UAAU,MAAM,cAAc,MAAM;AAClF,YAAM,SAAS,gBAAgB,MAAM,MAAM,IAAI,CAAC;AAChD,YAAM,QAAQ;AAAA,QACb,IAAI,MAAM,iBAAiB,QAAQ,MAAM,cAAc;AAAA,MAAA,CACvD;AACD,YAAM,SAAS,aAAa,MAAM,iBAAiB,SAAS;AAE5D,YAAM,kBAAkB,CAAA,UAAS;AAChC,eAAO;AAAA,UACN,GAAG;AAAA,UACH,SAAS;AAAA,YACR,KAAK,MAAM,iBAAiB,OAAO,MAAM,cAAc;AAAA,YACvD,MAAM,MAAM,iBAAiBC,YAAAA,iBAAiB;AAAA,UAAA;AAAA,QAC/C;AAAA,MAEF,CAAC;AACD,aAAO;AAAA,IACR,CAAC;AAAA,EACF;AAAA,EAEA,QAAc;AAAA,EACd;AACD;AAEO,MAAM,4BAA4B,CAAC,QAAuC;AAChF,MAAI,CAAC,KAAK;AACT,WAAO;AAAA,EACR;AACAD,oBAAO,KAAK;AAAA,IACX;AAAA,IACA,cAAc,CAAA,iBAAgB;AAC7B,aAAO,aAAa,OAAO,CAAA,gBAAe,YAAY,SAAS,aAAa,YAAY,SAAS,MAAM;AAAA,IACxG;AAAA,EAAA,CACA;AACD,SAAO,IAAI,oBAAoBE,OAAAA,UAAU,IAAI;AAC9C;;;"}
|
|
1
|
+
{"version":3,"file":"sentry.cjs","sources":["../../../../../packages/engine-http/src/utils/sentry.ts"],"sourcesContent":["import * as Sentry from '@sentry/node'\nimport { LogEntry, LoggerHandler, LogLevel, LogLevelName, LogLevels } from '@contember/logger'\nimport { LoggerRequestBody } from '../application/index.js'\n\nconst logLevelMapping: Record<LogLevelName, Sentry.SeverityLevel> = {\n\tcrit: 'fatal',\n\terror: 'error',\n\twarn: 'warning',\n\tdebug: 'debug',\n\tinfo: 'info',\n}\n\nexport class SentryLoggerHandler implements LoggerHandler {\n\tconstructor(\n\t\tprivate readonly logLevel: LogLevel,\n\t) {\n\t}\n\n\tgetMinLevel(): number {\n\t\treturn this.logLevel.value\n\t}\n\n\thandle(entry: LogEntry) {\n\t\tif (!entry.error || entry.level.value < this.logLevel.value) {\n\t\t\treturn\n\t\t}\n\t\tSentry.captureException(entry.error, scope => {\n\t\t\tscope.setTag('project', entry.loggerAttributes.project ?? entry.ownAttributes.project)\n\t\t\tscope.setTag('module', entry.loggerAttributes.module ?? entry.ownAttributes.module)\n\t\t\tscope.setLevel(logLevelMapping[entry.level.name])\n\t\t\tscope.setUser({\n\t\t\t\tid: entry.loggerAttributes.user ?? entry.ownAttributes.user,\n\t\t\t})\n\t\t\tscope.setExtra('requestId', entry.loggerAttributes.requestId)\n\n\t\t\tscope.addEventProcessor(event => {\n\t\t\t\treturn {\n\t\t\t\t\t...event,\n\t\t\t\t\trequest: {\n\t\t\t\t\t\turl: entry.loggerAttributes.url ?? entry.ownAttributes.url,\n\t\t\t\t\t\tdata: entry.loggerAttributes[LoggerRequestBody],\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t})\n\t\t\treturn scope\n\t\t})\n\t}\n\n\tclose(): void {\n\t}\n}\n\nexport const createSentryLoggerHandler = (dsn?: string): null | LoggerHandler => {\n\tif (!dsn) {\n\t\treturn null\n\t}\n\tSentry.init({\n\t\tdsn: dsn,\n\t\tintegrations: integrations => {\n\t\t\treturn integrations.filter(integration => integration.name !== 'Console' && integration.name !== 'Http')\n\t\t},\n\t})\n\treturn new SentryLoggerHandler(LogLevels.warn)\n}\n"],"names":["Sentry","LoggerRequestBody","LogLevels"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAIA,MAAM,kBAA8D;AAAA,EACnE,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AACP;AAEO,MAAM,oBAA6C;AAAA,EACzD,YACkB,UAChB;AADgB,SAAA,WAAA;AAAA,EAElB;AAAA,EAEA,cAAsB;AACrB,WAAO,KAAK,SAAS;AAAA,EACtB;AAAA,EAEA,OAAO,OAAiB;AACvB,QAAI,CAAC,MAAM,SAAS,MAAM,MAAM,QAAQ,KAAK,SAAS,OAAO;AAC5D;AAAA,IACD;AACAA,sBAAO,iBAAiB,MAAM,OAAO,CAAA,UAAS;AAC7C,YAAM,OAAO,WAAW,MAAM,iBAAiB,WAAW,MAAM,cAAc,OAAO;AACrF,YAAM,OAAO,UAAU,MAAM,iBAAiB,UAAU,MAAM,cAAc,MAAM;AAClF,YAAM,SAAS,gBAAgB,MAAM,MAAM,IAAI,CAAC;AAChD,YAAM,QAAQ;AAAA,QACb,IAAI,MAAM,iBAAiB,QAAQ,MAAM,cAAc;AAAA,MAAA,CACvD;AACD,YAAM,SAAS,aAAa,MAAM,iBAAiB,SAAS;AAE5D,YAAM,kBAAkB,CAAA,UAAS;AAChC,eAAO;AAAA,UACN,GAAG;AAAA,UACH,SAAS;AAAA,YACR,KAAK,MAAM,iBAAiB,OAAO,MAAM,cAAc;AAAA,YACvD,MAAM,MAAM,iBAAiBC,YAAAA,iBAAiB;AAAA,UAAA;AAAA,QAC/C;AAAA,MAEF,CAAC;AACD,aAAO;AAAA,IACR,CAAC;AAAA,EACF;AAAA,EAEA,QAAc;AAAA,EACd;AACD;AAEO,MAAM,4BAA4B,CAAC,QAAuC;AAChF,MAAI,CAAC,KAAK;AACT,WAAO;AAAA,EACR;AACAD,oBAAO,KAAK;AAAA,IACX;AAAA,IACA,cAAc,CAAA,iBAAgB;AAC7B,aAAO,aAAa,OAAO,CAAA,gBAAe,YAAY,SAAS,aAAa,YAAY,SAAS,MAAM;AAAA,IACxG;AAAA,EAAA,CACA;AACD,SAAO,IAAI,oBAAoBE,OAAAA,UAAU,IAAI;AAC9C;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sentry.js","sources":["../../../../../packages/engine-http/src/utils/sentry.ts"],"sourcesContent":["import * as Sentry from '@sentry/node'\nimport { LogEntry, LoggerHandler, LogLevel, LogLevelName, LogLevels } from '@contember/logger'\nimport { LoggerRequestBody } from '../application'\n\nconst logLevelMapping: Record<LogLevelName, Sentry.SeverityLevel> = {\n\tcrit: 'fatal',\n\terror: 'error',\n\twarn: 'warning',\n\tdebug: 'debug',\n\tinfo: 'info',\n}\n\nexport class SentryLoggerHandler implements LoggerHandler {\n\tconstructor(\n\t\tprivate readonly logLevel: LogLevel,\n\t) {\n\t}\n\n\tgetMinLevel(): number {\n\t\treturn this.logLevel.value\n\t}\n\n\thandle(entry: LogEntry) {\n\t\tif (!entry.error || entry.level.value < this.logLevel.value) {\n\t\t\treturn\n\t\t}\n\t\tSentry.captureException(entry.error, scope => {\n\t\t\tscope.setTag('project', entry.loggerAttributes.project ?? entry.ownAttributes.project)\n\t\t\tscope.setTag('module', entry.loggerAttributes.module ?? entry.ownAttributes.module)\n\t\t\tscope.setLevel(logLevelMapping[entry.level.name])\n\t\t\tscope.setUser({\n\t\t\t\tid: entry.loggerAttributes.user ?? entry.ownAttributes.user,\n\t\t\t})\n\t\t\tscope.setExtra('requestId', entry.loggerAttributes.requestId)\n\n\t\t\tscope.addEventProcessor(event => {\n\t\t\t\treturn {\n\t\t\t\t\t...event,\n\t\t\t\t\trequest: {\n\t\t\t\t\t\turl: entry.loggerAttributes.url ?? entry.ownAttributes.url,\n\t\t\t\t\t\tdata: entry.loggerAttributes[LoggerRequestBody],\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t})\n\t\t\treturn scope\n\t\t})\n\t}\n\n\tclose(): void {\n\t}\n}\n\nexport const createSentryLoggerHandler = (dsn?: string): null | LoggerHandler => {\n\tif (!dsn) {\n\t\treturn null\n\t}\n\tSentry.init({\n\t\tdsn: dsn,\n\t\tintegrations: integrations => {\n\t\t\treturn integrations.filter(integration => integration.name !== 'Console' && integration.name !== 'Http')\n\t\t},\n\t})\n\treturn new SentryLoggerHandler(LogLevels.warn)\n}\n"],"names":[],"mappings":";;;AAIA,MAAM,kBAA8D;AAAA,EACnE,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;A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.js","sources":["../../../../../packages/engine-http/src/utils/sentry.ts"],"sourcesContent":["import * as Sentry from '@sentry/node'\nimport { LogEntry, LoggerHandler, LogLevel, LogLevelName, LogLevels } from '@contember/logger'\nimport { LoggerRequestBody } from '../application/index.js'\n\nconst logLevelMapping: Record<LogLevelName, Sentry.SeverityLevel> = {\n\tcrit: 'fatal',\n\terror: 'error',\n\twarn: 'warning',\n\tdebug: 'debug',\n\tinfo: 'info',\n}\n\nexport class SentryLoggerHandler implements LoggerHandler {\n\tconstructor(\n\t\tprivate readonly logLevel: LogLevel,\n\t) {\n\t}\n\n\tgetMinLevel(): number {\n\t\treturn this.logLevel.value\n\t}\n\n\thandle(entry: LogEntry) {\n\t\tif (!entry.error || entry.level.value < this.logLevel.value) {\n\t\t\treturn\n\t\t}\n\t\tSentry.captureException(entry.error, scope => {\n\t\t\tscope.setTag('project', entry.loggerAttributes.project ?? entry.ownAttributes.project)\n\t\t\tscope.setTag('module', entry.loggerAttributes.module ?? entry.ownAttributes.module)\n\t\t\tscope.setLevel(logLevelMapping[entry.level.name])\n\t\t\tscope.setUser({\n\t\t\t\tid: entry.loggerAttributes.user ?? entry.ownAttributes.user,\n\t\t\t})\n\t\t\tscope.setExtra('requestId', entry.loggerAttributes.requestId)\n\n\t\t\tscope.addEventProcessor(event => {\n\t\t\t\treturn {\n\t\t\t\t\t...event,\n\t\t\t\t\trequest: {\n\t\t\t\t\t\turl: entry.loggerAttributes.url ?? entry.ownAttributes.url,\n\t\t\t\t\t\tdata: entry.loggerAttributes[LoggerRequestBody],\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t})\n\t\t\treturn scope\n\t\t})\n\t}\n\n\tclose(): void {\n\t}\n}\n\nexport const createSentryLoggerHandler = (dsn?: string): null | LoggerHandler => {\n\tif (!dsn) {\n\t\treturn null\n\t}\n\tSentry.init({\n\t\tdsn: dsn,\n\t\tintegrations: integrations => {\n\t\t\treturn integrations.filter(integration => integration.name !== 'Console' && integration.name !== 'Http')\n\t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AAY,SAAS,aAAa,YAAY,SAAS,MAAM;AAAA,IACxG;AAAA,EAAA,CACA;AACD,SAAO,IAAI,oBAAoB,UAAU,IAAI;AAC9C;"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
3
|
+
const path = require("node:path");
|
|
4
4
|
const config = require("../config/config.cjs");
|
|
5
5
|
const logger = require("@contember/logger");
|
|
6
6
|
const fs = require("node:fs/promises");
|
|
7
7
|
const getServerVersion = async () => {
|
|
8
|
-
const packageJsonFile = process.env.CONTEMBER_PACKAGE_JSON ||
|
|
8
|
+
const packageJsonFile = process.env.CONTEMBER_PACKAGE_JSON || path.join(process.cwd(), "package.json");
|
|
9
9
|
const version = JSON.parse(await fs.readFile(packageJsonFile, "utf-8")).version;
|
|
10
10
|
return version;
|
|
11
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverStartup.cjs","sources":["../../../../../packages/engine-http/src/utils/serverStartup.ts"],"sourcesContent":["import { join } from 'node:path'\nimport { ConfigSource, readConfig, ServerConfig } from '../config/config'\nimport { Type } from '@contember/typesafe'\nimport { createLogger, JsonStreamLoggerHandler, Logger, LogLevels, PrettyPrintLoggerHandler } from '@contember/logger'\nimport { ConfigProcessor } from '../config/ConfigProcessor'\nimport { Plugin } from '../plugin/Plugin'\nimport { readFile } from 'node:fs/promises'\n\nexport const getServerVersion = async (): Promise<string> => {\n\tconst packageJsonFile = process.env.CONTEMBER_PACKAGE_JSON || join(process.cwd(), 'package.json')\n\tconst version = JSON.parse(await readFile(packageJsonFile, 'utf-8')).version\n\treturn version\n}\n\nexport const isDebugMode = (): boolean => process.env.NODE_ENV === 'development'\n\nexport const printStartInfo = ({ version, isDebug }: { version: string; isDebug: boolean }, logger: Logger) => {\n\tlogger.info(`Starting Contember ${version}`)\n\tlogger.info(`NODE_ENV is set to ${process.env.NODE_ENV}`)\n\tif (isDebug) {\n\t\tlogger.warn('Starting Contember in debug mode')\n\t\tlogger.warn('NEVER USE debug mode in production environment')\n\t}\n}\n\nexport const resolveServerConfig = async <T extends ServerConfig>(\n\t{ plugins, serverConfigSchema }: { plugins: Plugin[]; serverConfigSchema: Type<T> },\n) => {\n\tconst configProcessors = plugins\n\t\t.map(it => (it.getConfigProcessor ? it.getConfigProcessor() : null))\n\t\t.filter((it): it is ConfigProcessor<any> => it !== null)\n\n\tconst configSources: ConfigSource[] = []\n\tfor (const configType of ['file', 'yaml', 'json'] as const) {\n\t\tconst envValue = process.env['CONTEMBER_CONFIG_' + configType.toUpperCase()]\n\t\tif (envValue) {\n\t\t\tconfigSources.push({ type: configType, data: envValue })\n\t\t}\n\t}\n\n\treturn await readConfig(configSources, configProcessors, serverConfigSchema)\n}\n\nexport const createDefaultLogger = (): Logger => {\n\tconst isDebug = isDebugMode()\n\tconst loggerType = process.env.CONTEMBER_LOGGER_FORMAT ?? (isDebug ? 'pretty' : 'json')\n\tconst stream = process.stderr\n\tconst handler = loggerType === 'pretty'\n\t\t? new PrettyPrintLoggerHandler(stream, {\n\t\t\tformatters: {\n\t\t\t\tpid: () => undefined,\n\t\t\t\tloggerId: () => undefined,\n\t\t\t\turi: ({ attributes, chalk }) => {\n\t\t\t\t\tconst color = attributes.status === undefined\n\t\t\t\t\t\t? chalk.cyan\n\t\t\t\t\t\t: attributes.status < 300\n\t\t\t\t\t\t? chalk.green\n\t\t\t\t\t\t: chalk.yellowBright\n\t\t\t\t\tconst timeInfo = attributes.totalTimeMs !== undefined ? ` ${attributes.totalTimeMs}ms` : ''\n\t\t\t\t\tconst statusInfo = attributes.status !== undefined ? ` [${attributes.status}]` : ''\n\t\t\t\t\treturn { line: color(`${attributes.method}${statusInfo} ${attributes.uri}${timeInfo} ${chalk.white.dim('#' + attributes.requestId)}`) }\n\t\t\t\t},\n\t\t\t\tmethod: () => undefined,\n\t\t\t\trequestId: () => undefined,\n\t\t\t\ttimeLabel: () => undefined,\n\t\t\t\tstatus: () => undefined,\n\t\t\t\ttotalTimeMs: () => undefined,\n\t\t\t\tevents: ({ formattedValue }) => formattedValue === '[]' ? undefined : formattedValue,\n\t\t\t},\n\t\t})\n\t\t: new JsonStreamLoggerHandler(stream)\n\tconst logLevel = (process.env.CONTEMBER_LOGGER_LEVEL as keyof typeof LogLevels) ?? 'info'\n\treturn createLogger(handler, {\n\t\tpid: process.pid,\n\t\tloggerId: Math.random().toString().substring(2),\n\t}, {\n\t\tfingerCrossedOptions: {\n\t\t\tlogAlwaysLevel: LogLevels[logLevel],\n\t\t},\n\t})\n}\n"],"names":["join","readFile","logger","readConfig","PrettyPrintLoggerHandler","JsonStreamLoggerHandler","createLogger","LogLevels"],"mappings":";;;;;;AAQO,MAAM,mBAAmB,YAA6B;AAC5D,QAAM,kBAAkB,QAAQ,IAAI,0BAA0BA,
|
|
1
|
+
{"version":3,"file":"serverStartup.cjs","sources":["../../../../../packages/engine-http/src/utils/serverStartup.ts"],"sourcesContent":["import { join } from 'node:path'\nimport { ConfigSource, readConfig, ServerConfig } from '../config/config.js'\nimport { Type } from '@contember/typesafe'\nimport { createLogger, JsonStreamLoggerHandler, Logger, LogLevels, PrettyPrintLoggerHandler } from '@contember/logger'\nimport { ConfigProcessor } from '../config/ConfigProcessor.js'\nimport { Plugin } from '../plugin/Plugin.js'\nimport { readFile } from 'node:fs/promises'\n\nexport const getServerVersion = async (): Promise<string> => {\n\tconst packageJsonFile = process.env.CONTEMBER_PACKAGE_JSON || join(process.cwd(), 'package.json')\n\tconst version = JSON.parse(await readFile(packageJsonFile, 'utf-8')).version\n\treturn version\n}\n\nexport const isDebugMode = (): boolean => process.env.NODE_ENV === 'development'\n\nexport const printStartInfo = ({ version, isDebug }: { version: string; isDebug: boolean }, logger: Logger) => {\n\tlogger.info(`Starting Contember ${version}`)\n\tlogger.info(`NODE_ENV is set to ${process.env.NODE_ENV}`)\n\tif (isDebug) {\n\t\tlogger.warn('Starting Contember in debug mode')\n\t\tlogger.warn('NEVER USE debug mode in production environment')\n\t}\n}\n\nexport const resolveServerConfig = async <T extends ServerConfig>(\n\t{ plugins, serverConfigSchema }: { plugins: Plugin[]; serverConfigSchema: Type<T> },\n) => {\n\tconst configProcessors = plugins\n\t\t.map(it => (it.getConfigProcessor ? it.getConfigProcessor() : null))\n\t\t.filter((it): it is ConfigProcessor<any> => it !== null)\n\n\tconst configSources: ConfigSource[] = []\n\tfor (const configType of ['file', 'yaml', 'json'] as const) {\n\t\tconst envValue = process.env['CONTEMBER_CONFIG_' + configType.toUpperCase()]\n\t\tif (envValue) {\n\t\t\tconfigSources.push({ type: configType, data: envValue })\n\t\t}\n\t}\n\n\treturn await readConfig(configSources, configProcessors, serverConfigSchema)\n}\n\nexport const createDefaultLogger = (): Logger => {\n\tconst isDebug = isDebugMode()\n\tconst loggerType = process.env.CONTEMBER_LOGGER_FORMAT ?? (isDebug ? 'pretty' : 'json')\n\tconst stream = process.stderr\n\tconst handler = loggerType === 'pretty'\n\t\t? new PrettyPrintLoggerHandler(stream, {\n\t\t\tformatters: {\n\t\t\t\tpid: () => undefined,\n\t\t\t\tloggerId: () => undefined,\n\t\t\t\turi: ({ attributes, chalk }) => {\n\t\t\t\t\tconst color = attributes.status === undefined\n\t\t\t\t\t\t? chalk.cyan\n\t\t\t\t\t\t: attributes.status < 300\n\t\t\t\t\t\t? chalk.green\n\t\t\t\t\t\t: chalk.yellowBright\n\t\t\t\t\tconst timeInfo = attributes.totalTimeMs !== undefined ? ` ${attributes.totalTimeMs}ms` : ''\n\t\t\t\t\tconst statusInfo = attributes.status !== undefined ? ` [${attributes.status}]` : ''\n\t\t\t\t\treturn { line: color(`${attributes.method}${statusInfo} ${attributes.uri}${timeInfo} ${chalk.white.dim('#' + attributes.requestId)}`) }\n\t\t\t\t},\n\t\t\t\tmethod: () => undefined,\n\t\t\t\trequestId: () => undefined,\n\t\t\t\ttimeLabel: () => undefined,\n\t\t\t\tstatus: () => undefined,\n\t\t\t\ttotalTimeMs: () => undefined,\n\t\t\t\tevents: ({ formattedValue }) => formattedValue === '[]' ? undefined : formattedValue,\n\t\t\t},\n\t\t})\n\t\t: new JsonStreamLoggerHandler(stream)\n\tconst logLevel = (process.env.CONTEMBER_LOGGER_LEVEL as keyof typeof LogLevels) ?? 'info'\n\treturn createLogger(handler, {\n\t\tpid: process.pid,\n\t\tloggerId: Math.random().toString().substring(2),\n\t}, {\n\t\tfingerCrossedOptions: {\n\t\t\tlogAlwaysLevel: LogLevels[logLevel],\n\t\t},\n\t})\n}\n"],"names":["join","readFile","logger","readConfig","PrettyPrintLoggerHandler","JsonStreamLoggerHandler","createLogger","LogLevels"],"mappings":";;;;;;AAQO,MAAM,mBAAmB,YAA6B;AAC5D,QAAM,kBAAkB,QAAQ,IAAI,0BAA0BA,KAAAA,KAAK,QAAQ,IAAA,GAAO,cAAc;AAChG,QAAM,UAAU,KAAK,MAAM,MAAMC,GAAAA,SAAS,iBAAiB,OAAO,CAAC,EAAE;AACrE,SAAO;AACR;AAEO,MAAM,cAAc,MAAe,QAAQ,IAAI,aAAa;AAE5D,MAAM,iBAAiB,CAAC,EAAE,SAAS,QAAA,GAAkDC,YAAmB;AAC9G,EAAAA,QAAO,KAAK,sBAAsB,OAAO,EAAE;AAC3C,EAAAA,QAAO,KAAK,sBAAsB,QAAQ,IAAI,QAAQ,EAAE;AACxD,MAAI,SAAS;AACZ,IAAAA,QAAO,KAAK,kCAAkC;AAC9C,IAAAA,QAAO,KAAK,gDAAgD;AAAA,EAC7D;AACD;AAEO,MAAM,sBAAsB,OAClC,EAAE,SAAS,yBACP;AACJ,QAAM,mBAAmB,QACvB,IAAI,CAAA,OAAO,GAAG,qBAAqB,GAAG,mBAAA,IAAuB,IAAK,EAClE,OAAO,CAAC,OAAmC,OAAO,IAAI;AAExD,QAAM,gBAAgC,CAAA;AACtC,aAAW,cAAc,CAAC,QAAQ,QAAQ,MAAM,GAAY;AAC3D,UAAM,WAAW,QAAQ,IAAI,sBAAsB,WAA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AAA,GAC5C;AAAA,IACF,sBAAsB;AAAA,MACrB,gBAAgBC,OAAAA,UAAU,QAAQ;AAAA,IAAA;AAAA,EACnC,CACA;AACF;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverStartup.js","sources":["../../../../../packages/engine-http/src/utils/serverStartup.ts"],"sourcesContent":["import { join } from 'node:path'\nimport { ConfigSource, readConfig, ServerConfig } from '../config/config'\nimport { Type } from '@contember/typesafe'\nimport { createLogger, JsonStreamLoggerHandler, Logger, LogLevels, PrettyPrintLoggerHandler } from '@contember/logger'\nimport { ConfigProcessor } from '../config/ConfigProcessor'\nimport { Plugin } from '../plugin/Plugin'\nimport { readFile } from 'node:fs/promises'\n\nexport const getServerVersion = async (): Promise<string> => {\n\tconst packageJsonFile = process.env.CONTEMBER_PACKAGE_JSON || join(process.cwd(), 'package.json')\n\tconst version = JSON.parse(await readFile(packageJsonFile, 'utf-8')).version\n\treturn version\n}\n\nexport const isDebugMode = (): boolean => process.env.NODE_ENV === 'development'\n\nexport const printStartInfo = ({ version, isDebug }: { version: string; isDebug: boolean }, logger: Logger) => {\n\tlogger.info(`Starting Contember ${version}`)\n\tlogger.info(`NODE_ENV is set to ${process.env.NODE_ENV}`)\n\tif (isDebug) {\n\t\tlogger.warn('Starting Contember in debug mode')\n\t\tlogger.warn('NEVER USE debug mode in production environment')\n\t}\n}\n\nexport const resolveServerConfig = async <T extends ServerConfig>(\n\t{ plugins, serverConfigSchema }: { plugins: Plugin[]; serverConfigSchema: Type<T> },\n) => {\n\tconst configProcessors = plugins\n\t\t.map(it => (it.getConfigProcessor ? it.getConfigProcessor() : null))\n\t\t.filter((it): it is ConfigProcessor<any> => it !== null)\n\n\tconst configSources: ConfigSource[] = []\n\tfor (const configType of ['file', 'yaml', 'json'] as const) {\n\t\tconst envValue = process.env['CONTEMBER_CONFIG_' + configType.toUpperCase()]\n\t\tif (envValue) {\n\t\t\tconfigSources.push({ type: configType, data: envValue })\n\t\t}\n\t}\n\n\treturn await readConfig(configSources, configProcessors, serverConfigSchema)\n}\n\nexport const createDefaultLogger = (): Logger => {\n\tconst isDebug = isDebugMode()\n\tconst loggerType = process.env.CONTEMBER_LOGGER_FORMAT ?? (isDebug ? 'pretty' : 'json')\n\tconst stream = process.stderr\n\tconst handler = loggerType === 'pretty'\n\t\t? new PrettyPrintLoggerHandler(stream, {\n\t\t\tformatters: {\n\t\t\t\tpid: () => undefined,\n\t\t\t\tloggerId: () => undefined,\n\t\t\t\turi: ({ attributes, chalk }) => {\n\t\t\t\t\tconst color = attributes.status === undefined\n\t\t\t\t\t\t? chalk.cyan\n\t\t\t\t\t\t: attributes.status < 300\n\t\t\t\t\t\t? chalk.green\n\t\t\t\t\t\t: chalk.yellowBright\n\t\t\t\t\tconst timeInfo = attributes.totalTimeMs !== undefined ? ` ${attributes.totalTimeMs}ms` : ''\n\t\t\t\t\tconst statusInfo = attributes.status !== undefined ? ` [${attributes.status}]` : ''\n\t\t\t\t\treturn { line: color(`${attributes.method}${statusInfo} ${attributes.uri}${timeInfo} ${chalk.white.dim('#' + attributes.requestId)}`) }\n\t\t\t\t},\n\t\t\t\tmethod: () => undefined,\n\t\t\t\trequestId: () => undefined,\n\t\t\t\ttimeLabel: () => undefined,\n\t\t\t\tstatus: () => undefined,\n\t\t\t\ttotalTimeMs: () => undefined,\n\t\t\t\tevents: ({ formattedValue }) => formattedValue === '[]' ? undefined : formattedValue,\n\t\t\t},\n\t\t})\n\t\t: new JsonStreamLoggerHandler(stream)\n\tconst logLevel = (process.env.CONTEMBER_LOGGER_LEVEL as keyof typeof LogLevels) ?? 'info'\n\treturn createLogger(handler, {\n\t\tpid: process.pid,\n\t\tloggerId: Math.random().toString().substring(2),\n\t}, {\n\t\tfingerCrossedOptions: {\n\t\t\tlogAlwaysLevel: LogLevels[logLevel],\n\t\t},\n\t})\n}\n"],"names":[],"mappings":";;;;AAQO,MAAM,mBAAmB,YAA6B;AAC5D,QAAM,kBAAkB,QAAQ,IA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,cAAM,WAAW,WAAW,gBAAgB,SAAY,IAAI,WAAW,WAAW,OAAO;AACzF,cAAM,aAAa,WAAW,WAAW,SAAY,KAAK,WAAW,MAAM,MAAM;AACjF,eAAO,EAAE,MAAM,MAAM,GAAG,WAAW,MAAM,GAAG,UAAU,IAAI,WAAW,GAAG,GAAG,QAAQ,IAAI,MAAM,MAAM,IAAI,MAAM,WAAW,SAAS,CAAC,EAAE,EAAA;AAAA,MACrI;AAAA,MACA,QAAQ,MAAM;AAAA,MACd,WAAW,MAAM;AAAA,MACjB,WAAW,MAAM;AAAA,MACjB,QAAQ,MAAM;AAAA,MACd,aAAa,MAAM;AAAA,MACnB,QAAQ,CAAC,EAAE,qBAAqB,mBAAmB,OAAO,SAAY;AAAA,IAAA;AAAA,EACvE,CACA,IACC,IAAI,wBAAwB,MAAM;AACrC,QAAM,WAAY,QAAQ,IAAI,0BAAqD;AACnF,SAAO,aAAa,SAAS;AAAA,IAC5B,KAAK,QAAQ;AAAA,IACb,UAAU,KAAK,OAAA,EAAS,SAAA,EAAW,UAAU,CAAC;AAAA,EAAA,GAC5C;AAAA,IACF,sBAAsB;AAAA,MACrB,gBAAgB,UAAU,QAAQ;AAAA,IAAA;AAAA,EACnC,CACA;AACF;"}
|
|
1
|
+
{"version":3,"file":"serverStartup.js","sources":["../../../../../packages/engine-http/src/utils/serverStartup.ts"],"sourcesContent":["import { join } from 'node:path'\nimport { ConfigSource, readConfig, ServerConfig } from '../config/config.js'\nimport { Type } from '@contember/typesafe'\nimport { createLogger, JsonStreamLoggerHandler, Logger, LogLevels, PrettyPrintLoggerHandler } from '@contember/logger'\nimport { ConfigProcessor } from '../config/ConfigProcessor.js'\nimport { Plugin } from '../plugin/Plugin.js'\nimport { readFile } from 'node:fs/promises'\n\nexport const getServerVersion = async (): Promise<string> => {\n\tconst packageJsonFile = process.env.CONTEMBER_PACKAGE_JSON || join(process.cwd(), 'package.json')\n\tconst version = JSON.parse(await readFile(packageJsonFile, 'utf-8')).version\n\treturn version\n}\n\nexport const isDebugMode = (): boolean => process.env.NODE_ENV === 'development'\n\nexport const printStartInfo = ({ version, isDebug }: { version: string; isDebug: boolean }, logger: Logger) => {\n\tlogger.info(`Starting Contember ${version}`)\n\tlogger.info(`NODE_ENV is set to ${process.env.NODE_ENV}`)\n\tif (isDebug) {\n\t\tlogger.warn('Starting Contember in debug mode')\n\t\tlogger.warn('NEVER USE debug mode in production environment')\n\t}\n}\n\nexport const resolveServerConfig = async <T extends ServerConfig>(\n\t{ plugins, serverConfigSchema }: { plugins: Plugin[]; serverConfigSchema: Type<T> },\n) => {\n\tconst configProcessors = plugins\n\t\t.map(it => (it.getConfigProcessor ? it.getConfigProcessor() : null))\n\t\t.filter((it): it is ConfigProcessor<any> => it !== null)\n\n\tconst configSources: ConfigSource[] = []\n\tfor (const configType of ['file', 'yaml', 'json'] as const) {\n\t\tconst envValue = process.env['CONTEMBER_CONFIG_' + configType.toUpperCase()]\n\t\tif (envValue) {\n\t\t\tconfigSources.push({ type: configType, data: envValue })\n\t\t}\n\t}\n\n\treturn await readConfig(configSources, configProcessors, serverConfigSchema)\n}\n\nexport const createDefaultLogger = (): Logger => {\n\tconst isDebug = isDebugMode()\n\tconst loggerType = process.env.CONTEMBER_LOGGER_FORMAT ?? (isDebug ? 'pretty' : 'json')\n\tconst stream = process.stderr\n\tconst handler = loggerType === 'pretty'\n\t\t? new PrettyPrintLoggerHandler(stream, {\n\t\t\tformatters: {\n\t\t\t\tpid: () => undefined,\n\t\t\t\tloggerId: () => undefined,\n\t\t\t\turi: ({ attributes, chalk }) => {\n\t\t\t\t\tconst color = attributes.status === undefined\n\t\t\t\t\t\t? chalk.cyan\n\t\t\t\t\t\t: attributes.status < 300\n\t\t\t\t\t\t? chalk.green\n\t\t\t\t\t\t: chalk.yellowBright\n\t\t\t\t\tconst timeInfo = attributes.totalTimeMs !== undefined ? ` ${attributes.totalTimeMs}ms` : ''\n\t\t\t\t\tconst statusInfo = attributes.status !== undefined ? ` [${attributes.status}]` : ''\n\t\t\t\t\treturn { line: color(`${attributes.method}${statusInfo} ${attributes.uri}${timeInfo} ${chalk.white.dim('#' + attributes.requestId)}`) }\n\t\t\t\t},\n\t\t\t\tmethod: () => undefined,\n\t\t\t\trequestId: () => undefined,\n\t\t\t\ttimeLabel: () => undefined,\n\t\t\t\tstatus: () => undefined,\n\t\t\t\ttotalTimeMs: () => undefined,\n\t\t\t\tevents: ({ formattedValue }) => formattedValue === '[]' ? undefined : formattedValue,\n\t\t\t},\n\t\t})\n\t\t: new JsonStreamLoggerHandler(stream)\n\tconst logLevel = (process.env.CONTEMBER_LOGGER_LEVEL as keyof typeof LogLevels) ?? 'info'\n\treturn createLogger(handler, {\n\t\tpid: process.pid,\n\t\tloggerId: Math.random().toString().substring(2),\n\t}, {\n\t\tfingerCrossedOptions: {\n\t\t\tlogAlwaysLevel: LogLevels[logLevel],\n\t\t},\n\t})\n}\n"],"names":[],"mappings":";;;;AAQO,MAAM,mBAAmB,YAA6B;AAC5D,QAAM,kBAAkB,QAAQ,IAAI,0BAA0B,KAAK,QAAQ,IAAA,GAAO,cAAc;AAChG,QAAM,UAAU,KAAK,MAAM,MAAM,SAAS,iBAAiB,OAAO,CAAC,EAAE;AACrE,SAAO;AACR;AAEO,MAAM,cAAc,MAAe,QAAQ,IAAI,aAAa;AAE5D,MAAM,iBAAiB,CAAC,EAAE,SAAS,QAAA,GAAkD,WAAmB;AAC9G,SAAO,KAAK,sBAAsB,OAAO,EAAE;AAC3C,SAAO,KAAK,sBAAsB,QAAQ,IAAI,QAAQ,EAAE;AACxD,MAAI,SAAS;AACZ,WAAO,KAAK,kCAAkC;AAC9C,WAAO,KAAK,gDAAgD;AAAA,EAC7D;AACD;AAEO,MAAM,sBAAsB,OAClC,EAAE,SAAS,yBACP;AACJ,QAAM,mBAAmB,QACvB,IAAI,CAAA,OAAO,GAAG,qBAAqB,GAAG,mBAAA,IAAuB,IAAK,EAClE,OAAO,CAAC,OAAmC,OAAO,IAAI;AAExD,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B,KAAK,QAAQ;AAAA,IACb,UAAU,KAAK,OAAA,EAAS,SAAA,EAAW,UAAU,CAAC;AAAA,EAAA,GAC5C;AAAA,IACF,sBAAsB;AAAA,MACrB,gBAAgB,UAAU,QAAQ;AAAA,IAAA;AAAA,EACnC,CACA;AACF;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticatorGeoCountry.test.d.ts","sourceRoot":"","sources":["../../../../tests/cases/unit/authenticatorGeoCountry.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forceHttpOk.test.d.ts","sourceRoot":"","sources":["../../../../tests/cases/unit/forceHttpOk.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notFoundResponse.test.d.ts","sourceRoot":"","sources":["../../../../tests/cases/unit/notFoundResponse.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oidcBackchannelLogout.test.d.ts","sourceRoot":"","sources":["../../../../tests/cases/unit/oidcBackchannelLogout.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remoteAddress.test.d.ts","sourceRoot":"","sources":["../../../../tests/cases/unit/remoteAddress.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serverConfig.test.d.ts","sourceRoot":"","sources":["../../../../tests/cases/unit/serverConfig.test.ts"],"names":[],"mappings":""}
|