@contember/engine-http 1.3.0-alpha.1 → 1.3.0-alpha.13
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/dist/src/MasterContainer.d.ts +141 -0
- package/dist/src/MasterContainer.d.ts.map +1 -0
- package/dist/src/MasterContainer.js +94 -0
- package/dist/src/MasterContainer.js.map +1 -0
- package/dist/src/application/application.d.ts +63 -0
- package/dist/src/application/application.d.ts.map +1 -0
- package/dist/src/application/application.js +350 -0
- package/dist/src/application/application.js.map +1 -0
- package/dist/src/application/index.d.ts +3 -0
- package/dist/src/application/index.d.ts.map +1 -0
- package/dist/src/{koa → application}/index.js +1 -2
- package/dist/src/application/index.js.map +1 -0
- package/dist/src/application/types.d.ts.map +1 -0
- package/dist/src/{koa → application}/types.js.map +1 -1
- package/dist/src/bootstrap/Initializer.d.ts +7 -0
- package/dist/src/bootstrap/Initializer.d.ts.map +1 -0
- package/dist/src/bootstrap/Initializer.js +27 -0
- package/dist/src/bootstrap/Initializer.js.map +1 -0
- package/dist/src/bootstrap/index.d.ts +2 -0
- package/dist/src/bootstrap/index.d.ts.map +1 -0
- package/dist/src/bootstrap/index.js +18 -0
- package/dist/src/bootstrap/index.js.map +1 -0
- package/dist/src/common/Authorizator.d.ts +5 -8
- package/dist/src/common/Authorizator.d.ts.map +1 -1
- package/dist/src/common/Authorizator.js +11 -6
- package/dist/src/common/Authorizator.js.map +1 -1
- package/dist/src/common/HttpResponse.d.ts +12 -0
- package/dist/src/common/HttpResponse.d.ts.map +1 -0
- package/dist/src/common/HttpResponse.js +20 -0
- package/dist/src/common/HttpResponse.js.map +1 -0
- package/dist/src/common/ModuleInfoMiddleware.d.ts +1 -1
- package/dist/src/common/ModuleInfoMiddleware.d.ts.map +1 -1
- package/dist/src/common/index.d.ts +1 -5
- package/dist/src/common/index.d.ts.map +1 -1
- package/dist/src/common/index.js +1 -5
- package/dist/src/common/index.js.map +1 -1
- package/dist/src/config/ConfigProcessor.d.ts +13 -0
- package/dist/src/config/ConfigProcessor.d.ts.map +1 -0
- package/dist/src/{ProjectContainer.js → config/ConfigProcessor.js} +1 -1
- package/dist/src/config/ConfigProcessor.js.map +1 -0
- package/dist/src/config/config.d.ts +18 -0
- package/dist/src/config/config.d.ts.map +1 -0
- package/dist/src/config/config.js +30 -0
- package/dist/src/config/config.js.map +1 -0
- package/dist/src/config/configSchema.d.ts +204 -0
- package/dist/src/config/configSchema.d.ts.map +1 -0
- package/dist/src/config/configSchema.js +122 -0
- package/dist/src/config/configSchema.js.map +1 -0
- package/dist/src/config/configTemplate.d.ts +2 -0
- package/dist/src/config/configTemplate.d.ts.map +1 -0
- package/dist/src/config/configTemplate.js +94 -0
- package/dist/src/config/configTemplate.js.map +1 -0
- package/dist/src/config/projectConfigResolver.d.ts +8 -0
- package/dist/src/config/projectConfigResolver.d.ts.map +1 -0
- package/dist/src/config/projectConfigResolver.js +91 -0
- package/dist/src/config/projectConfigResolver.js.map +1 -0
- package/dist/src/config/tenantConfigResolver.d.ts +8 -0
- package/dist/src/config/tenantConfigResolver.d.ts.map +1 -0
- package/dist/src/config/tenantConfigResolver.js +31 -0
- package/dist/src/config/tenantConfigResolver.js.map +1 -0
- package/dist/src/content/ContentApiControllerFactory.d.ts +14 -0
- package/dist/src/content/ContentApiControllerFactory.d.ts.map +1 -0
- package/dist/src/content/{ContentApiMiddlewareFactory.js → ContentApiControllerFactory.js} +35 -42
- package/dist/src/content/ContentApiControllerFactory.js.map +1 -0
- package/dist/src/content/ContentApiSpecificCache.d.ts +9 -0
- package/dist/src/content/ContentApiSpecificCache.d.ts.map +1 -0
- package/dist/src/content/ContentApiSpecificCache.js +40 -0
- package/dist/src/content/ContentApiSpecificCache.js.map +1 -0
- package/dist/src/content/ContentGraphQLContextFactory.d.ts +16 -7
- package/dist/src/content/ContentGraphQLContextFactory.d.ts.map +1 -1
- package/dist/src/content/ContentGraphQLContextFactory.js +18 -11
- package/dist/src/content/ContentGraphQLContextFactory.js.map +1 -1
- package/dist/src/content/GraphQLSchemaContributor.d.ts +11 -0
- package/dist/src/content/GraphQLSchemaContributor.d.ts.map +1 -0
- package/dist/src/{ProjectGroupContainer.js → content/GraphQLSchemaContributor.js} +1 -1
- package/dist/src/content/GraphQLSchemaContributor.js.map +1 -0
- package/dist/src/content/GraphQlSchemaFactory.d.ts +11 -6
- package/dist/src/content/GraphQlSchemaFactory.d.ts.map +1 -1
- package/dist/src/content/GraphQlSchemaFactory.js +26 -39
- package/dist/src/content/GraphQlSchemaFactory.js.map +1 -1
- package/dist/src/content/Identity.d.ts +4 -0
- package/dist/src/content/Identity.d.ts.map +1 -0
- package/dist/src/{project-common/ProjectGroupResolver.js → content/Identity.js} +1 -1
- package/dist/src/content/Identity.js.map +1 -0
- package/dist/src/content/NotModifiedChecker.d.ts +7 -6
- package/dist/src/content/NotModifiedChecker.d.ts.map +1 -1
- package/dist/src/content/NotModifiedChecker.js +5 -6
- package/dist/src/content/NotModifiedChecker.js.map +1 -1
- package/dist/src/content/ProjectMembershipResolver.js +5 -5
- package/dist/src/content/ProjectMembershipResolver.js.map +1 -1
- package/dist/src/content/index.d.ts +3 -1
- package/dist/src/content/index.d.ts.map +1 -1
- package/dist/src/content/index.js +3 -1
- package/dist/src/content/index.js.map +1 -1
- package/dist/src/graphql/state.d.ts +1 -1
- package/dist/src/graphql/state.d.ts.map +1 -1
- package/dist/src/index.d.ts +18 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +24 -7
- package/dist/src/index.js.map +1 -1
- package/dist/src/misc/HomepageMiddlewareFactory.d.ts +2 -1
- package/dist/src/misc/HomepageMiddlewareFactory.d.ts.map +1 -1
- package/dist/src/misc/HomepageMiddlewareFactory.js +4 -8
- package/dist/src/misc/HomepageMiddlewareFactory.js.map +1 -1
- package/dist/src/misc/PlaygroundMiddlewareFactory.d.ts +2 -2
- package/dist/src/misc/PlaygroundMiddlewareFactory.d.ts.map +1 -1
- package/dist/src/misc/PlaygroundMiddlewareFactory.js +6 -22
- package/dist/src/misc/PlaygroundMiddlewareFactory.js.map +1 -1
- package/dist/src/plugin/Plugin.d.ts +21 -0
- package/dist/src/plugin/Plugin.d.ts.map +1 -0
- package/dist/src/plugin/Plugin.js +3 -0
- package/dist/src/plugin/Plugin.js.map +1 -0
- package/dist/src/project/ProjectContainer.d.ts +93 -0
- package/dist/src/project/ProjectContainer.d.ts.map +1 -0
- package/dist/src/project/ProjectContainer.js +79 -0
- package/dist/src/project/ProjectContainer.js.map +1 -0
- package/dist/src/project/ProjectContainerResolver.d.ts +31 -0
- package/dist/src/project/ProjectContainerResolver.d.ts.map +1 -0
- package/dist/src/project/ProjectContainerResolver.js +77 -0
- package/dist/src/project/ProjectContainerResolver.js.map +1 -0
- package/dist/src/project/ProjectContainerStore.d.ts +18 -0
- package/dist/src/project/ProjectContainerStore.d.ts.map +1 -0
- package/dist/src/project/ProjectContainerStore.js +30 -0
- package/dist/src/project/ProjectContainerStore.js.map +1 -0
- package/dist/src/project/ProjectDatabaseMetadataResolver.d.ts +10 -0
- package/dist/src/project/ProjectDatabaseMetadataResolver.d.ts.map +1 -0
- package/dist/src/project/ProjectDatabaseMetadataResolver.js +25 -0
- package/dist/src/project/ProjectDatabaseMetadataResolver.js.map +1 -0
- package/dist/src/project/ProjectInitializer.d.ts +14 -0
- package/dist/src/project/ProjectInitializer.d.ts.map +1 -0
- package/dist/src/project/ProjectInitializer.js +28 -0
- package/dist/src/project/ProjectInitializer.js.map +1 -0
- package/dist/src/project/ProjectSchemaResolver.d.ts +14 -0
- package/dist/src/project/ProjectSchemaResolver.d.ts.map +1 -0
- package/dist/src/project/ProjectSchemaResolver.js +30 -0
- package/dist/src/project/ProjectSchemaResolver.js.map +1 -0
- package/dist/src/project/config.d.ts.map +1 -0
- package/dist/src/{config.js.map → project/config.js.map} +1 -1
- package/dist/src/project/index.d.ts +5 -0
- package/dist/src/project/index.d.ts.map +1 -0
- package/dist/src/project/index.js +21 -0
- package/dist/src/project/index.js.map +1 -0
- package/dist/src/project-common/ProjectContextResolver.d.ts +8 -0
- package/dist/src/project-common/ProjectContextResolver.d.ts.map +1 -0
- package/dist/src/project-common/ProjectContextResolver.js +17 -0
- package/dist/src/project-common/ProjectContextResolver.js.map +1 -0
- package/dist/src/project-common/index.d.ts +1 -1
- package/dist/src/project-common/index.d.ts.map +1 -1
- package/dist/src/project-common/index.js +1 -1
- package/dist/src/project-common/index.js.map +1 -1
- package/dist/src/projectGroup/ProjectGroupContainer.d.ts +44 -0
- package/dist/src/projectGroup/ProjectGroupContainer.d.ts.map +1 -0
- package/dist/src/projectGroup/ProjectGroupContainer.js +72 -0
- package/dist/src/projectGroup/ProjectGroupContainer.js.map +1 -0
- package/dist/src/projectGroup/ProjectGroupResolver.d.ts +14 -0
- package/dist/src/projectGroup/ProjectGroupResolver.d.ts.map +1 -0
- package/dist/src/projectGroup/ProjectGroupResolver.js +13 -0
- package/dist/src/projectGroup/ProjectGroupResolver.js.map +1 -0
- package/dist/src/providers.js +3 -3
- package/dist/src/providers.js.map +1 -1
- package/dist/src/system/SystemApiMiddlewareFactory.d.ts +5 -11
- package/dist/src/system/SystemApiMiddlewareFactory.d.ts.map +1 -1
- package/dist/src/system/SystemApiMiddlewareFactory.js +28 -44
- package/dist/src/system/SystemApiMiddlewareFactory.js.map +1 -1
- package/dist/src/system/SystemGraphQLContextFactory.d.ts +4 -4
- package/dist/src/system/SystemGraphQLContextFactory.d.ts.map +1 -1
- package/dist/src/system/SystemGraphQLHandlerFactory.d.ts +1 -1
- package/dist/src/system/SystemGraphQLHandlerFactory.d.ts.map +1 -1
- package/dist/src/tenant/TenantApiMiddlewareFactory.d.ts +3 -9
- package/dist/src/tenant/TenantApiMiddlewareFactory.d.ts.map +1 -1
- package/dist/src/tenant/TenantApiMiddlewareFactory.js +15 -24
- package/dist/src/tenant/TenantApiMiddlewareFactory.js.map +1 -1
- package/dist/src/tenant/TenantGraphQLContextFactory.d.ts +1 -1
- package/dist/src/tenant/TenantGraphQLContextFactory.d.ts.map +1 -1
- package/dist/src/tenant/TenantGraphQLHandlerFactory.d.ts +1 -1
- package/dist/src/tenant/TenantGraphQLHandlerFactory.d.ts.map +1 -1
- package/dist/src/transfer/ExportApiControllerFactory.d.ts +10 -0
- package/dist/src/transfer/ExportApiControllerFactory.d.ts.map +1 -0
- package/dist/src/transfer/{ExportApiMiddlewareFactory.js → ExportApiControllerFactory.js} +16 -20
- package/dist/src/transfer/ExportApiControllerFactory.js.map +1 -0
- package/dist/src/transfer/ExportExecutor.d.ts +1 -1
- package/dist/src/transfer/ExportExecutor.d.ts.map +1 -1
- package/dist/src/transfer/ImportApiMiddlewareFactory.d.ts +3 -8
- package/dist/src/transfer/ImportApiMiddlewareFactory.d.ts.map +1 -1
- package/dist/src/transfer/ImportApiMiddlewareFactory.js +9 -9
- package/dist/src/transfer/ImportApiMiddlewareFactory.js.map +1 -1
- package/dist/src/transfer/ImportExecutor.d.ts +2 -2
- package/dist/src/transfer/ImportExecutor.d.ts.map +1 -1
- package/dist/src/transfer/ImportExecutor.js +2 -2
- package/dist/src/transfer/ImportExecutor.js.map +1 -1
- package/dist/src/transfer/index.d.ts +1 -1
- package/dist/src/transfer/index.js +1 -1
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/dist/src/utils/sentry.d.ts +10 -0
- package/dist/src/utils/sentry.d.ts.map +1 -0
- package/dist/src/utils/sentry.js +80 -0
- package/dist/src/utils/sentry.js.map +1 -0
- package/dist/src/utils/serverStartup.d.ts +36 -0
- package/dist/src/utils/serverStartup.d.ts.map +1 -0
- package/dist/src/utils/serverStartup.js +79 -0
- package/dist/src/utils/serverStartup.js.map +1 -0
- package/dist/src/utils/serverTermination.d.ts +13 -0
- package/dist/src/utils/serverTermination.d.ts.map +1 -0
- package/dist/src/utils/serverTermination.js +24 -0
- package/dist/src/utils/serverTermination.js.map +1 -0
- package/dist/src/utils/strings.d.ts +2 -0
- package/dist/src/utils/strings.d.ts.map +1 -0
- package/dist/src/utils/strings.js +6 -0
- package/dist/src/utils/strings.js.map +1 -0
- package/dist/src/workers/ApplicationWorkerManager.d.ts +9 -0
- package/dist/src/workers/ApplicationWorkerManager.d.ts.map +1 -0
- package/dist/src/workers/ApplicationWorkerManager.js +28 -0
- package/dist/src/workers/ApplicationWorkerManager.js.map +1 -0
- package/dist/src/workers/index.d.ts +2 -0
- package/dist/src/workers/index.d.ts.map +1 -0
- package/dist/src/workers/index.js +18 -0
- package/dist/src/workers/index.js.map +1 -0
- package/dist/tests/cases/unit/configResolver.test.d.ts +2 -0
- package/dist/tests/cases/unit/configResolver.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/configResolver.test.js +67 -0
- package/dist/tests/cases/unit/configResolver.test.js.map +1 -0
- package/dist/tests/cases/unit/contentApiSpecificCache.tst.d.ts +2 -0
- package/dist/tests/cases/unit/contentApiSpecificCache.tst.d.ts.map +1 -0
- package/dist/tests/cases/unit/contentApiSpecificCache.tst.js +132 -0
- package/dist/tests/cases/unit/contentApiSpecificCache.tst.js.map +1 -0
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/package.json +31 -18
- package/src/MasterContainer.ts +182 -0
- package/src/application/application.ts +401 -0
- package/src/application/index.ts +2 -0
- package/src/bootstrap/Initializer.ts +27 -0
- package/src/bootstrap/index.ts +1 -0
- package/src/common/Authorizator.ts +13 -13
- package/src/common/HttpResponse.ts +21 -0
- package/src/common/ModuleInfoMiddleware.ts +1 -1
- package/src/common/index.ts +1 -5
- package/src/config/ConfigProcessor.ts +17 -0
- package/src/config/config.ts +57 -0
- package/src/config/configSchema.ts +138 -0
- package/src/config/configTemplate.ts +90 -0
- package/src/config/projectConfigResolver.ts +86 -0
- package/src/config/tenantConfigResolver.ts +41 -0
- package/src/content/{ContentApiMiddlewareFactory.ts → ContentApiControllerFactory.ts} +42 -62
- package/src/content/ContentApiSpecificCache.ts +51 -0
- package/src/content/ContentGraphQLContextFactory.ts +32 -18
- package/src/content/GraphQLSchemaContributor.ts +9 -0
- package/src/content/GraphQlSchemaFactory.ts +41 -55
- package/src/content/Identity.ts +3 -0
- package/src/content/NotModifiedChecker.ts +10 -10
- package/src/content/ProjectMembershipResolver.ts +6 -6
- package/src/content/index.ts +3 -1
- package/src/graphql/state.ts +1 -1
- package/src/index.ts +22 -5
- package/src/misc/HomepageMiddlewareFactory.ts +4 -7
- package/src/misc/PlaygroundMiddlewareFactory.ts +11 -22
- package/src/plugin/Plugin.ts +27 -0
- package/src/project/ProjectContainer.ts +151 -0
- package/src/project/ProjectContainerResolver.ts +89 -0
- package/src/project/ProjectContainerStore.ts +33 -0
- package/src/project/ProjectDatabaseMetadataResolver.ts +29 -0
- package/src/project/ProjectInitializer.ts +28 -0
- package/src/project/ProjectSchemaResolver.ts +33 -0
- package/src/project/index.ts +4 -0
- package/src/project-common/ProjectContextResolver.ts +17 -0
- package/src/project-common/index.ts +1 -1
- package/src/projectGroup/ProjectGroupContainer.ts +146 -0
- package/src/projectGroup/ProjectGroupResolver.ts +17 -0
- package/src/providers.ts +1 -1
- package/src/system/SystemApiMiddlewareFactory.ts +32 -61
- package/src/system/SystemGraphQLContextFactory.ts +4 -4
- package/src/system/SystemGraphQLHandlerFactory.ts +1 -1
- package/src/tenant/TenantApiMiddlewareFactory.ts +18 -39
- package/src/tenant/TenantGraphQLContextFactory.ts +1 -1
- package/src/tenant/TenantGraphQLHandlerFactory.ts +1 -1
- package/src/transfer/{ExportApiMiddlewareFactory.ts → ExportApiControllerFactory.ts} +18 -31
- package/src/transfer/ExportExecutor.ts +1 -1
- package/src/transfer/ImportApiMiddlewareFactory.ts +13 -21
- package/src/transfer/ImportExecutor.ts +3 -3
- package/src/transfer/index.ts +1 -1
- package/src/tsconfig.json +17 -34
- package/src/utils/sentry.ts +56 -0
- package/src/utils/serverStartup.ts +79 -0
- package/src/utils/serverTermination.ts +19 -0
- package/src/utils/strings.ts +1 -0
- package/src/workers/ApplicationWorkerManager.ts +27 -0
- package/src/workers/index.ts +1 -0
- package/tests/cases/unit/configResolver.test.ts +67 -0
- package/tests/cases/unit/contentApiSpecificCache.tst.ts +129 -0
- package/tests/tsconfig.json +1 -3
- package/tsconfig.json +2 -6
- package/dist/src/ProjectContainer.d.ts +0 -21
- package/dist/src/ProjectContainer.d.ts.map +0 -1
- package/dist/src/ProjectContainer.js.map +0 -1
- package/dist/src/ProjectGroupContainer.d.ts +0 -23
- package/dist/src/ProjectGroupContainer.d.ts.map +0 -1
- package/dist/src/ProjectGroupContainer.js.map +0 -1
- package/dist/src/common/ErrorMiddleware.d.ts +0 -11
- package/dist/src/common/ErrorMiddleware.d.ts.map +0 -1
- package/dist/src/common/ErrorMiddleware.js +0 -36
- package/dist/src/common/ErrorMiddleware.js.map +0 -1
- package/dist/src/common/HttpError.d.ts +0 -5
- package/dist/src/common/HttpError.d.ts.map +0 -1
- package/dist/src/common/HttpError.js +0 -11
- package/dist/src/common/HttpError.js.map +0 -1
- package/dist/src/common/LoggerMiddleware.d.ts +0 -8
- package/dist/src/common/LoggerMiddleware.d.ts.map +0 -1
- package/dist/src/common/LoggerMiddleware.js +0 -32
- package/dist/src/common/LoggerMiddleware.js.map +0 -1
- package/dist/src/common/PoweredByHeaderMiddleware.d.ts +0 -3
- package/dist/src/common/PoweredByHeaderMiddleware.d.ts.map +0 -1
- package/dist/src/common/PoweredByHeaderMiddleware.js +0 -15
- package/dist/src/common/PoweredByHeaderMiddleware.js.map +0 -1
- package/dist/src/common/TimerMiddleware.d.ts +0 -11
- package/dist/src/common/TimerMiddleware.d.ts.map +0 -1
- package/dist/src/common/TimerMiddleware.js +0 -53
- package/dist/src/common/TimerMiddleware.js.map +0 -1
- package/dist/src/config.d.ts.map +0 -1
- package/dist/src/content/ContentApiMiddlewareFactory.d.ts +0 -20
- package/dist/src/content/ContentApiMiddlewareFactory.d.ts.map +0 -1
- package/dist/src/content/ContentApiMiddlewareFactory.js.map +0 -1
- package/dist/src/koa/compose.d.ts +0 -4
- package/dist/src/koa/compose.d.ts.map +0 -1
- package/dist/src/koa/compose.js +0 -18
- package/dist/src/koa/compose.js.map +0 -1
- package/dist/src/koa/index.d.ts +0 -4
- package/dist/src/koa/index.d.ts.map +0 -1
- package/dist/src/koa/index.js.map +0 -1
- package/dist/src/koa/router.d.ts +0 -14
- package/dist/src/koa/router.d.ts.map +0 -1
- package/dist/src/koa/router.js +0 -54
- package/dist/src/koa/router.js.map +0 -1
- package/dist/src/koa/types.d.ts.map +0 -1
- package/dist/src/project-common/ProjectGroupResolver.d.ts +0 -9
- package/dist/src/project-common/ProjectGroupResolver.d.ts.map +0 -1
- package/dist/src/project-common/ProjectGroupResolver.js.map +0 -1
- package/dist/src/transfer/ExportApiMiddlewareFactory.d.ts +0 -15
- package/dist/src/transfer/ExportApiMiddlewareFactory.d.ts.map +0 -1
- package/dist/src/transfer/ExportApiMiddlewareFactory.js.map +0 -1
- package/src/ProjectContainer.ts +0 -22
- package/src/ProjectGroupContainer.ts +0 -32
- package/src/common/ErrorMiddleware.ts +0 -35
- package/src/common/HttpError.ts +0 -8
- package/src/common/LoggerMiddleware.ts +0 -33
- package/src/common/PoweredByHeaderMiddleware.ts +0 -12
- package/src/common/TimerMiddleware.ts +0 -67
- package/src/koa/compose.ts +0 -16
- package/src/koa/index.ts +0 -3
- package/src/koa/router.ts +0 -72
- package/src/project-common/ProjectGroupResolver.ts +0 -6
- /package/dist/src/{koa → application}/types.d.ts +0 -0
- /package/dist/src/{koa → application}/types.js +0 -0
- /package/dist/src/{config.d.ts → project/config.d.ts} +0 -0
- /package/dist/src/{config.js → project/config.js} +0 -0
- /package/src/{koa → application}/types.ts +0 -0
- /package/src/{config.ts → project/config.ts} +0 -0
|
@@ -1,87 +1,54 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { HttpController } from '../application'
|
|
2
|
+
import { ProjectContextResolver } from '../project-common'
|
|
3
|
+
import { HttpErrorResponse, HttpResponse } from '../common'
|
|
4
4
|
import { StageBySlugQuery } from '@contember/engine-system-api'
|
|
5
5
|
import { NotModifiedChecker } from './NotModifiedChecker'
|
|
6
6
|
import { ContentGraphQLContextFactory } from './ContentGraphQLContextFactory'
|
|
7
7
|
import { ContentQueryHandler, ContentQueryHandlerFactory } from './ContentQueryHandlerFactory'
|
|
8
8
|
import { GraphQLSchema } from 'graphql'
|
|
9
|
-
import { GraphQLKoaState } from '../graphql'
|
|
10
|
-
|
|
11
|
-
type ContentApiMiddlewareKoaState =
|
|
12
|
-
& TimerMiddlewareState
|
|
13
|
-
& KoaRequestState
|
|
14
|
-
& GraphQLKoaState
|
|
15
|
-
& ProjectInfoMiddlewareState
|
|
16
|
-
& LoggerMiddlewareState
|
|
17
|
-
& {
|
|
18
|
-
authResult: AuthResult
|
|
19
|
-
}
|
|
20
|
-
|
|
21
9
|
|
|
22
10
|
const debugHeader = 'x-contember-debug'
|
|
23
11
|
|
|
24
|
-
export class
|
|
12
|
+
export class ContentApiControllerFactory {
|
|
25
13
|
constructor(
|
|
26
|
-
private readonly projectGroupResolver: ProjectGroupResolver,
|
|
27
14
|
private readonly notModifiedChecker: NotModifiedChecker,
|
|
28
15
|
private readonly contentGraphqlContextFactory: ContentGraphQLContextFactory,
|
|
29
16
|
private readonly handlerFactory: ContentQueryHandlerFactory,
|
|
17
|
+
private readonly projectContextResolver: ProjectContextResolver,
|
|
30
18
|
) {
|
|
31
19
|
}
|
|
32
20
|
|
|
33
|
-
create():
|
|
21
|
+
create(): HttpController {
|
|
34
22
|
const handlerCache = new WeakMap<GraphQLSchema, ContentQueryHandler>()
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
koaContext.state.projectGroup = groupContainer.slug
|
|
40
|
-
|
|
41
|
-
const authResult = await groupContainer.authenticator.authenticate({ request, timer })
|
|
42
|
-
koaContext.state.logger.debug('User authenticated', { authResult })
|
|
43
|
-
koaContext.state.authResult = authResult
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const projectContainer = await groupContainer.projectContainerResolver.getProjectContainer(params.projectSlug, {
|
|
47
|
-
alias: true,
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
if (projectContainer === undefined) {
|
|
51
|
-
throw new HttpError(`Project ${params.projectSlug} NOT found`, 404)
|
|
23
|
+
return async context => {
|
|
24
|
+
const { params, timer, projectGroup, authResult, request, logger, koa } = context
|
|
25
|
+
if (!authResult) {
|
|
26
|
+
return new HttpErrorResponse(401, 'Authentication required')
|
|
52
27
|
}
|
|
53
|
-
const
|
|
54
|
-
...projectContainer.logger.attributes,
|
|
55
|
-
module: 'content',
|
|
56
|
-
user: authResult.identityId,
|
|
57
|
-
})
|
|
58
|
-
koaContext.state.logger = requestLogger
|
|
59
|
-
|
|
60
|
-
const project = projectContainer.project
|
|
61
|
-
koaContext.state.project = project.slug
|
|
28
|
+
const { projectContainer, project } = await this.projectContextResolver.resolve(context)
|
|
62
29
|
|
|
63
30
|
const systemDatabase = projectContainer.systemDatabaseContextFactory.create()
|
|
64
31
|
const stage = await systemDatabase.queryHandler.fetch(new StageBySlugQuery(params.stageSlug))
|
|
65
32
|
if (!stage) {
|
|
66
|
-
|
|
33
|
+
return new HttpErrorResponse(404, `Stage ${params.stageSlug} NOT found`)
|
|
67
34
|
}
|
|
68
35
|
const notModifiedRes = await this.notModifiedChecker.checkNotModified({
|
|
69
|
-
request,
|
|
70
|
-
|
|
36
|
+
request: context.request,
|
|
37
|
+
body: context.body,
|
|
38
|
+
timer: context.timer,
|
|
71
39
|
systemDatabase,
|
|
72
40
|
stageId: stage.id,
|
|
73
41
|
})
|
|
74
42
|
if (notModifiedRes?.isModified === false) {
|
|
75
|
-
|
|
76
|
-
return
|
|
43
|
+
return new HttpResponse(304)
|
|
77
44
|
}
|
|
78
45
|
|
|
79
46
|
const schema = await projectContainer.contentSchemaResolver.getSchema(systemDatabase, stage.slug)
|
|
80
47
|
|
|
81
48
|
const { effective: memberships, fetched: fetchedMemberships } = await timer(
|
|
82
49
|
'MembershipFetch',
|
|
83
|
-
() =>
|
|
84
|
-
request,
|
|
50
|
+
() => projectGroup.projectMembershipResolver.resolveMemberships({
|
|
51
|
+
request: koa,
|
|
85
52
|
acl: schema.acl,
|
|
86
53
|
projectSlug: project.slug,
|
|
87
54
|
identity: {
|
|
@@ -91,20 +58,29 @@ export class ContentApiMiddlewareFactory {
|
|
|
91
58
|
},
|
|
92
59
|
}),
|
|
93
60
|
)
|
|
94
|
-
requestLogger.debug('Memberships fetched', { memberships })
|
|
95
61
|
|
|
96
|
-
|
|
62
|
+
logger.debug('Memberships fetched', { memberships })
|
|
63
|
+
|
|
64
|
+
const debugHeaderValue = request.headers[debugHeader]
|
|
65
|
+
if (Array.isArray(debugHeaderValue)) {
|
|
66
|
+
return new HttpErrorResponse(400, `Invalid format of ${debugHeader}`)
|
|
67
|
+
}
|
|
97
68
|
const requestDebug = debugHeaderValue === '1' && fetchedMemberships.some(it => schema.acl.roles[it.role]?.debug)
|
|
98
69
|
if (requestDebug) {
|
|
99
|
-
|
|
70
|
+
context.requestDebugMode = true
|
|
100
71
|
}
|
|
101
72
|
|
|
102
73
|
const projectRoles = memberships.map(it => it.role)
|
|
103
74
|
|
|
75
|
+
const { schema: graphQlSchema, permissions } = await timer(
|
|
76
|
+
'GraphQLSchemaCreate',
|
|
77
|
+
() => projectContainer.graphQlSchemaFactory.create(schema, {
|
|
78
|
+
projectRoles: projectRoles,
|
|
79
|
+
}),
|
|
80
|
+
)
|
|
81
|
+
|
|
104
82
|
|
|
105
|
-
const
|
|
106
|
-
projectRoles: projectRoles,
|
|
107
|
-
}))
|
|
83
|
+
const schemaDatabaseMetadata = await projectContainer.projectDatabaseMetadataResolver.resolveDatabaseMetadata(systemDatabase, schema, stage.schema)
|
|
108
84
|
|
|
109
85
|
const handler = await (async () => {
|
|
110
86
|
const existingHandler = handlerCache.get(graphQlSchema)
|
|
@@ -116,12 +92,12 @@ export class ContentApiMiddlewareFactory {
|
|
|
116
92
|
return newHandler
|
|
117
93
|
})()
|
|
118
94
|
|
|
119
|
-
await
|
|
95
|
+
await logger.scope(async logger => {
|
|
120
96
|
logger.debug('Content query processing started')
|
|
121
97
|
|
|
122
98
|
await timer('GraphQL', () => handler({
|
|
123
|
-
request,
|
|
124
|
-
response,
|
|
99
|
+
request: koa.request,
|
|
100
|
+
response: koa.response,
|
|
125
101
|
createContext: ({ operation }) => {
|
|
126
102
|
const connection = operation === 'query' ? projectContainer.readConnection : projectContainer.connection
|
|
127
103
|
const contentDatabase = connection.createClient(stage.schema, { module: 'content' })
|
|
@@ -131,10 +107,14 @@ export class ContentApiMiddlewareFactory {
|
|
|
131
107
|
authResult,
|
|
132
108
|
memberships,
|
|
133
109
|
permissions,
|
|
110
|
+
schemaDatabaseMetadata,
|
|
134
111
|
schema,
|
|
135
112
|
timer,
|
|
136
|
-
koaContext,
|
|
113
|
+
koaContext: koa,
|
|
137
114
|
requestDebug,
|
|
115
|
+
systemSchema: projectContainer.systemDatabaseContextFactory.schemaName,
|
|
116
|
+
stage,
|
|
117
|
+
project,
|
|
138
118
|
})
|
|
139
119
|
},
|
|
140
120
|
}))
|
|
@@ -142,7 +122,7 @@ export class ContentApiMiddlewareFactory {
|
|
|
142
122
|
})
|
|
143
123
|
|
|
144
124
|
|
|
145
|
-
notModifiedRes?.setResponseHeader(response)
|
|
125
|
+
notModifiedRes?.setResponseHeader(context.response)
|
|
146
126
|
}
|
|
147
127
|
}
|
|
148
128
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { clearTimeout } from 'node:timers'
|
|
2
|
+
|
|
3
|
+
type Entry<V> = {
|
|
4
|
+
timer?: ReturnType<typeof setTimeout>
|
|
5
|
+
value: V
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export class ContentApiSpecificCache<ObjectKey extends object, Value> {
|
|
9
|
+
private cache = new WeakMap<ObjectKey, Map<string, Entry<Value>>>()
|
|
10
|
+
|
|
11
|
+
constructor(
|
|
12
|
+
private options: {
|
|
13
|
+
ttlSeconds?: number
|
|
14
|
+
},
|
|
15
|
+
) {
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public fetch(objectKey: ObjectKey, scalarKey: string, createValue: () => Value): Value {
|
|
19
|
+
let cacheMap = this.cache.get(objectKey)
|
|
20
|
+
|
|
21
|
+
if (!cacheMap) {
|
|
22
|
+
cacheMap = new Map()
|
|
23
|
+
this.cache.set(objectKey, cacheMap)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const cacheValue = cacheMap.get(scalarKey)
|
|
27
|
+
|
|
28
|
+
let timer: ReturnType<typeof setTimeout> | undefined = undefined
|
|
29
|
+
if (this.options.ttlSeconds) {
|
|
30
|
+
// wrap to WeakRef so the Map can be garbage-collected, when ObjectKey is garbage collected
|
|
31
|
+
const cacheMapRef = new WeakRef(cacheMap)
|
|
32
|
+
timer = setTimeout(() => {
|
|
33
|
+
cacheMapRef.deref()?.delete(scalarKey)
|
|
34
|
+
}, this.options.ttlSeconds * 1000)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (cacheValue) {
|
|
38
|
+
clearTimeout(cacheValue.timer)
|
|
39
|
+
cacheValue.timer = timer
|
|
40
|
+
return cacheValue.value
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const value = createValue()
|
|
44
|
+
cacheMap.set(scalarKey, {
|
|
45
|
+
timer,
|
|
46
|
+
value,
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
return value
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -1,39 +1,43 @@
|
|
|
1
|
-
import { getArgumentValues } from 'graphql'
|
|
2
|
-
|
|
3
1
|
import { Context, createAclVariables, ExecutionContainerFactory } from '@contember/engine-content-api'
|
|
4
|
-
import { setupSystemVariables } from '@contember/engine-system-api'
|
|
5
2
|
import { Client } from '@contember/database'
|
|
6
3
|
import { Acl, Schema } from '@contember/schema'
|
|
7
4
|
|
|
8
|
-
import { AuthResult
|
|
9
|
-
import { KoaContext } from '../
|
|
5
|
+
import { AuthResult } from '../common'
|
|
6
|
+
import { KoaContext, Timer } from '../application'
|
|
10
7
|
import { Providers } from '../providers'
|
|
11
8
|
import { GraphQLKoaState } from '../graphql'
|
|
12
|
-
import { ParsedMembership } from '@contember/schema-utils'
|
|
9
|
+
import { ParsedMembership, SchemaDatabaseMetadata } from '@contember/schema-utils'
|
|
10
|
+
import { Stage } from '@contember/engine-system-api'
|
|
11
|
+
import { ProjectConfig } from '../project/config'
|
|
13
12
|
|
|
14
|
-
export type ExtendedGraphqlContext = Context & {
|
|
13
|
+
export type ExtendedGraphqlContext = Context & {
|
|
14
|
+
identityId: string
|
|
15
|
+
koaContext: KoaContext<GraphQLKoaState>
|
|
16
|
+
requestDebug: boolean
|
|
17
|
+
}
|
|
15
18
|
|
|
16
19
|
export class ContentGraphQLContextFactory {
|
|
17
20
|
constructor(
|
|
18
21
|
private providers: Providers,
|
|
22
|
+
private executionContainerFactory: ExecutionContainerFactory,
|
|
19
23
|
) {
|
|
20
24
|
}
|
|
21
25
|
|
|
22
|
-
create({ db, schema, authResult, memberships, permissions, timer, koaContext, requestDebug }: {
|
|
26
|
+
create({ db, schema, schemaDatabaseMetadata, authResult, memberships, permissions, timer, koaContext, requestDebug, systemSchema, stage, project }: {
|
|
23
27
|
db: Client
|
|
24
|
-
schema: Schema
|
|
28
|
+
schema: Schema & { id: number }
|
|
29
|
+
schemaDatabaseMetadata: SchemaDatabaseMetadata
|
|
25
30
|
permissions: Acl.Permissions
|
|
26
31
|
authResult: AuthResult
|
|
27
32
|
memberships: readonly ParsedMembership[]
|
|
28
33
|
timer: Timer
|
|
29
34
|
koaContext: KoaContext<GraphQLKoaState>
|
|
30
35
|
requestDebug: boolean
|
|
36
|
+
systemSchema: string
|
|
37
|
+
stage: Stage
|
|
38
|
+
project: ProjectConfig
|
|
31
39
|
}): ExtendedGraphqlContext {
|
|
32
|
-
const
|
|
33
|
-
db,
|
|
34
|
-
identityId: authResult.identityId,
|
|
35
|
-
identityVariables: createAclVariables(schema.acl, memberships),
|
|
36
|
-
}
|
|
40
|
+
const identityVariables = createAclVariables(schema.acl, memberships)
|
|
37
41
|
let identityId = authResult.identityId
|
|
38
42
|
if (
|
|
39
43
|
authResult.assumedIdentityId &&
|
|
@@ -42,12 +46,22 @@ export class ContentGraphQLContextFactory {
|
|
|
42
46
|
identityId = authResult.assumedIdentityId
|
|
43
47
|
}
|
|
44
48
|
|
|
45
|
-
const executionContainer =
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
const executionContainer = this.executionContainerFactory.create({
|
|
50
|
+
db,
|
|
51
|
+
identityVariables,
|
|
52
|
+
identityId,
|
|
53
|
+
schema,
|
|
54
|
+
schemaDatabaseMetadata,
|
|
55
|
+
permissions,
|
|
56
|
+
systemSchema,
|
|
57
|
+
stage,
|
|
58
|
+
project,
|
|
59
|
+
})
|
|
48
60
|
|
|
49
61
|
return {
|
|
50
|
-
|
|
62
|
+
db,
|
|
63
|
+
identityVariables,
|
|
64
|
+
identityId,
|
|
51
65
|
executionContainer,
|
|
52
66
|
timer,
|
|
53
67
|
koaContext,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Schema } from '@contember/schema'
|
|
2
|
+
import { GraphQLSchema } from 'graphql'
|
|
3
|
+
import { Identity } from './Identity'
|
|
4
|
+
|
|
5
|
+
export type GraphQLSchemaContributorContext = { schema: Schema; identity: Identity }
|
|
6
|
+
|
|
7
|
+
export interface GraphQLSchemaContributor {
|
|
8
|
+
createSchema(context: GraphQLSchemaContributorContext): undefined | GraphQLSchema
|
|
9
|
+
}
|
|
@@ -1,82 +1,68 @@
|
|
|
1
1
|
import {
|
|
2
|
+
Authorizator,
|
|
2
3
|
EntityRulesResolver,
|
|
3
4
|
GraphQlSchemaBuilderFactory,
|
|
4
|
-
Identity,
|
|
5
5
|
IntrospectionSchemaDefinitionFactory,
|
|
6
6
|
IntrospectionSchemaFactory,
|
|
7
|
-
|
|
8
|
-
Authorizator,
|
|
7
|
+
PermissionFactory,
|
|
9
8
|
} from '@contember/engine-content-api'
|
|
10
9
|
import { Acl, Schema } from '@contember/schema'
|
|
11
10
|
import { GraphQLSchema } from 'graphql'
|
|
12
11
|
import { makeExecutableSchema, mergeSchemas } from '@graphql-tools/schema'
|
|
13
|
-
import { GraphQLSchemaContributor } from '
|
|
12
|
+
import { GraphQLSchemaContributor } from './GraphQLSchemaContributor'
|
|
14
13
|
import { JSONType } from '@contember/graphql-utils'
|
|
14
|
+
import { Identity } from './Identity'
|
|
15
|
+
import { ContentApiSpecificCache } from './ContentApiSpecificCache'
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
type CacheEntry = {
|
|
19
|
-
graphQlSchema: GraphQLSchema
|
|
17
|
+
export interface GraphQLSchemaFactoryResult {
|
|
20
18
|
permissions: Acl.Permissions
|
|
21
|
-
|
|
22
|
-
verifier: (identity: Identity) => boolean
|
|
19
|
+
schema: GraphQLSchema
|
|
23
20
|
}
|
|
24
21
|
|
|
25
22
|
export class GraphQlSchemaFactory {
|
|
26
|
-
private cache = new WeakMap<Schema, CacheEntry[]>()
|
|
27
23
|
|
|
28
24
|
constructor(
|
|
25
|
+
private readonly cache: ContentApiSpecificCache<Schema, GraphQLSchemaFactoryResult>,
|
|
29
26
|
private readonly graphqlSchemaBuilderFactory: GraphQlSchemaBuilderFactory,
|
|
30
|
-
private readonly permissionFactory:
|
|
27
|
+
private readonly permissionFactory: PermissionFactory,
|
|
31
28
|
private readonly schemaContributors: GraphQLSchemaContributor[],
|
|
32
29
|
) {}
|
|
33
30
|
|
|
34
|
-
public create(schema: Schema, identity: Identity):
|
|
35
|
-
|
|
36
|
-
const contributorsCacheKey = this.getContributorsCacheKey({ schema, identity })
|
|
37
|
-
if (cacheEntries !== undefined) {
|
|
38
|
-
const entry = cacheEntries.find(it => it.contributorsCacheKey === contributorsCacheKey && it.verifier(identity))
|
|
39
|
-
if (entry !== undefined) {
|
|
40
|
-
return [entry.graphQlSchema, entry.permissions]
|
|
41
|
-
}
|
|
42
|
-
} else {
|
|
43
|
-
cacheEntries = []
|
|
44
|
-
this.cache.set(schema, cacheEntries)
|
|
45
|
-
}
|
|
46
|
-
const { permissions, verifier } = this.permissionFactory.createPermissions(schema, identity)
|
|
31
|
+
public create(schema: Schema, identity: Identity): GraphQLSchemaFactoryResult {
|
|
32
|
+
const rolesKey = [...identity.projectRoles].sort().join('\xff')
|
|
47
33
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const contentSchemaFactory = new IntrospectionSchemaDefinitionFactory(
|
|
51
|
-
new IntrospectionSchemaFactory(
|
|
52
|
-
schema.model,
|
|
53
|
-
new EntityRulesResolver(schema.validation, schema.model),
|
|
54
|
-
authorizator,
|
|
55
|
-
),
|
|
56
|
-
)
|
|
57
|
-
const dataSchema: GraphQLSchema = dataSchemaBuilder.build()
|
|
58
|
-
const contentSchema = makeExecutableSchema({
|
|
59
|
-
...contentSchemaFactory.create(),
|
|
60
|
-
resolverValidationOptions: {
|
|
61
|
-
requireResolversForResolveType: 'ignore',
|
|
62
|
-
},
|
|
63
|
-
})
|
|
34
|
+
return this.cache.fetch(schema, rolesKey, () => {
|
|
35
|
+
const permissions = this.permissionFactory.create(schema, identity.projectRoles)
|
|
64
36
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
37
|
+
const authorizator = new Authorizator(permissions, schema.acl.customPrimary ?? false)
|
|
38
|
+
const dataSchemaBuilder = this.graphqlSchemaBuilderFactory.create(schema.model, authorizator)
|
|
39
|
+
const contentSchemaFactory = new IntrospectionSchemaDefinitionFactory(
|
|
40
|
+
new IntrospectionSchemaFactory(
|
|
41
|
+
schema.model,
|
|
42
|
+
new EntityRulesResolver(schema.validation, schema.model),
|
|
43
|
+
authorizator,
|
|
44
|
+
),
|
|
45
|
+
)
|
|
46
|
+
const dataSchema: GraphQLSchema = dataSchemaBuilder.build()
|
|
47
|
+
const contentSchema = makeExecutableSchema({
|
|
48
|
+
...contentSchemaFactory.create(),
|
|
49
|
+
resolverValidationOptions: {
|
|
50
|
+
requireResolversForResolveType: 'ignore',
|
|
51
|
+
},
|
|
52
|
+
})
|
|
75
53
|
|
|
76
|
-
|
|
77
|
-
|
|
54
|
+
const otherSchemas = this.schemaContributors
|
|
55
|
+
.map(it => it.createSchema({ schema, identity }))
|
|
56
|
+
.filter((it): it is GraphQLSchema => it !== undefined)
|
|
57
|
+
const graphQlSchema = mergeSchemas({
|
|
58
|
+
schemas: [dataSchema, contentSchema, ...otherSchemas],
|
|
59
|
+
resolvers: {
|
|
60
|
+
Json: JSONType,
|
|
61
|
+
},
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
return { schema: graphQlSchema, permissions }
|
|
65
|
+
})
|
|
78
66
|
|
|
79
|
-
private getContributorsCacheKey(ctx: Context): string {
|
|
80
|
-
return JSON.stringify(this.schemaContributors.map(it => it.getCacheKey(ctx)))
|
|
81
67
|
}
|
|
82
68
|
}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { DatabaseContext, LatestTransactionIdByStageQuery } from '@contember/engine-system-api'
|
|
2
|
-
import { Timer } from '../
|
|
3
|
-
import {
|
|
2
|
+
import { Timer } from '../application'
|
|
3
|
+
import { IncomingMessage, ServerResponse } from 'node:http'
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
const NotModifiedHeaderName = 'x-contember-ref'
|
|
7
7
|
|
|
8
8
|
export interface NotModifiedCheckResult {
|
|
9
9
|
isModified: boolean
|
|
10
|
-
setResponseHeader: (response:
|
|
10
|
+
setResponseHeader: (response: ServerResponse) => void
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export class NotModifiedChecker {
|
|
14
|
-
public async checkNotModified({ request, timer, systemDatabase, stageId }: {
|
|
15
|
-
|
|
14
|
+
public async checkNotModified({ request, body, timer, systemDatabase, stageId }: {
|
|
15
|
+
body: any
|
|
16
|
+
request: IncomingMessage
|
|
16
17
|
timer: Timer
|
|
17
18
|
systemDatabase: DatabaseContext
|
|
18
19
|
stageId: string
|
|
@@ -20,9 +21,8 @@ export class NotModifiedChecker {
|
|
|
20
21
|
if (request.headers[NotModifiedHeaderName] === undefined) {
|
|
21
22
|
return null
|
|
22
23
|
}
|
|
23
|
-
const requestRef = request.
|
|
24
|
-
const
|
|
25
|
-
const isMutation = typeof body === 'object' && 'query' in body && String(body.query).includes('mutation')
|
|
24
|
+
const requestRef = request.headers[NotModifiedHeaderName]
|
|
25
|
+
const isMutation = typeof body === 'object' && body !== null && 'query' in body && String(body.query).includes('mutation')
|
|
26
26
|
if (isMutation) {
|
|
27
27
|
return null
|
|
28
28
|
}
|
|
@@ -34,8 +34,8 @@ export class NotModifiedChecker {
|
|
|
34
34
|
return {
|
|
35
35
|
isModified: latestRef !== requestRef,
|
|
36
36
|
setResponseHeader: res => {
|
|
37
|
-
if (res.
|
|
38
|
-
res.
|
|
37
|
+
if (res.statusCode === 200) {
|
|
38
|
+
res.setHeader(NotModifiedHeaderName, latestRef)
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MembershipMatcher } from '@contember/engine-tenant-api'
|
|
2
2
|
import * as Typesafe from '@contember/typesafe'
|
|
3
3
|
import { Acl } from '@contember/schema'
|
|
4
|
-
import {
|
|
4
|
+
import { HttpErrorResponse } from '../common'
|
|
5
5
|
import { ProjectMembershipFetcher } from './ProjectMembershipFetcher'
|
|
6
6
|
import { MembershipResolver, ParsedMembership } from '@contember/schema-utils'
|
|
7
7
|
|
|
@@ -37,7 +37,7 @@ export class ProjectMembershipResolver {
|
|
|
37
37
|
const errorMessage = this.debug
|
|
38
38
|
? `You are not allowed to access project ${projectSlug}`
|
|
39
39
|
: `Project ${projectSlug} NOT found`
|
|
40
|
-
throw new
|
|
40
|
+
throw new HttpErrorResponse(404, errorMessage)
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
if (explicitMemberships.length === 0 && implicitRoles.length === 0) {
|
|
@@ -55,10 +55,10 @@ export class ProjectMembershipResolver {
|
|
|
55
55
|
|
|
56
56
|
const parsedMemberships = membershipResolver.resolve(acl, assumedMemberships, identity)
|
|
57
57
|
if (parsedMemberships.errors.length > 0) {
|
|
58
|
-
throw new
|
|
58
|
+
throw new HttpErrorResponse(
|
|
59
|
+
400,
|
|
59
60
|
`Invalid memberships in ${assumeMembershipHeader} header:\n` +
|
|
60
61
|
parsedMemberships.errors.map(it => JSON.stringify(it)).join('\n'),
|
|
61
|
-
400,
|
|
62
62
|
)
|
|
63
63
|
}
|
|
64
64
|
this.verifyAssumedRoles(explicitMemberships, acl, assumedMemberships)
|
|
@@ -88,7 +88,7 @@ export class ProjectMembershipResolver {
|
|
|
88
88
|
try {
|
|
89
89
|
return assumeMembershipValueType(value).memberships
|
|
90
90
|
} catch (e: any) {
|
|
91
|
-
throw new
|
|
91
|
+
throw new HttpErrorResponse(400, `Invalid format of "assume membership": ${e.message}`)
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
@@ -108,7 +108,7 @@ export class ProjectMembershipResolver {
|
|
|
108
108
|
|
|
109
109
|
for (const assumed of assumedMemberships) {
|
|
110
110
|
if (!membershipMatcher.matches(assumed)) {
|
|
111
|
-
throw new
|
|
111
|
+
throw new HttpErrorResponse(403, `You are not allow to assume membership ${JSON.stringify(assumed)}`)
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
}
|
package/src/content/index.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './ContentApiControllerFactory'
|
|
2
2
|
export * from './ContentGraphQLContextFactory'
|
|
3
3
|
export * from './ContentQueryHandlerFactory'
|
|
4
|
+
export * from './GraphQLSchemaContributor'
|
|
4
5
|
export * from './ContentSchemaResolver'
|
|
5
6
|
export * from './GraphQlSchemaFactory'
|
|
7
|
+
export * from './Identity'
|
|
6
8
|
export * from './NotModifiedChecker'
|
|
7
9
|
export * from './ProjectMembershipFetcher'
|
|
8
10
|
export * from './ProjectMembershipResolver'
|
package/src/graphql/state.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,18 +1,35 @@
|
|
|
1
|
+
import { MasterContainerArgs, MasterContainerFactory } from './MasterContainer'
|
|
2
|
+
import Koa from 'koa'
|
|
3
|
+
|
|
4
|
+
export * from './config/config'
|
|
5
|
+
export * from './config/ConfigProcessor'
|
|
6
|
+
export * from './config/tenantConfigResolver'
|
|
1
7
|
export * from './common'
|
|
2
8
|
export * from './content'
|
|
9
|
+
export * from './plugin/Plugin'
|
|
3
10
|
export * from './misc'
|
|
4
11
|
export * from './project-common'
|
|
5
12
|
export * from './system'
|
|
6
13
|
export * from './tenant'
|
|
7
14
|
export * from './transfer'
|
|
8
|
-
export * from './
|
|
15
|
+
export * from './application'
|
|
9
16
|
export * from './providers'
|
|
10
|
-
export * from './ProjectContainer'
|
|
11
|
-
export * from './ProjectGroupContainer'
|
|
12
17
|
export * from './graphql'
|
|
13
|
-
export * from './config'
|
|
18
|
+
export * from './project/config'
|
|
14
19
|
export * from './utils/CryptoWrapper'
|
|
20
|
+
export * from './project/ProjectContainer'
|
|
21
|
+
export * from './project/ProjectContainerResolver'
|
|
22
|
+
export * from './projectGroup/ProjectGroupContainer'
|
|
23
|
+
export * from './projectGroup/ProjectGroupResolver'
|
|
15
24
|
|
|
16
|
-
|
|
25
|
+
export * from './utils/serverStartup'
|
|
26
|
+
export * from './utils/serverTermination'
|
|
27
|
+
export * from './utils/sentry'
|
|
28
|
+
export * from './MasterContainer'
|
|
29
|
+
export { serverConfigSchema } from './config/configSchema'
|
|
30
|
+
|
|
31
|
+
export const createContainer = (args: MasterContainerArgs) => {
|
|
32
|
+
return new MasterContainerFactory().create(args)
|
|
33
|
+
}
|
|
17
34
|
|
|
18
35
|
export { Koa }
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { HttpController } from '../application'
|
|
2
|
+
import { HttpResponse } from '../common'
|
|
3
3
|
|
|
4
|
-
export const
|
|
5
|
-
|
|
6
|
-
ctx.body = 'App is running'
|
|
7
|
-
})
|
|
8
|
-
}
|
|
4
|
+
export const homepageController: HttpController = () =>
|
|
5
|
+
Promise.resolve(new HttpResponse(200, 'App is running'))
|
|
@@ -1,23 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from '@apollographql/graphql-playground-html'
|
|
5
|
-
import accepts from 'accepts'
|
|
6
|
-
import { get, KoaContext, KoaMiddleware, KoaRequestState } from '../koa'
|
|
1
|
+
import { renderPlaygroundPage } from '@apollographql/graphql-playground-html'
|
|
2
|
+
import { HttpController } from '../application'
|
|
3
|
+
import { HttpResponse } from '../common'
|
|
7
4
|
|
|
8
|
-
export const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const playgroundRenderPageOptions: PlaygroundRenderPageOptions = {
|
|
17
|
-
endpoint: ctx.originalUrl,
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
ctx.set('Content-Type', 'text/html')
|
|
21
|
-
ctx.body = renderPlaygroundPage(playgroundRenderPageOptions)
|
|
22
|
-
})
|
|
23
|
-
}
|
|
5
|
+
export const playgroundController: HttpController = ctx =>
|
|
6
|
+
new HttpResponse(
|
|
7
|
+
200,
|
|
8
|
+
renderPlaygroundPage({
|
|
9
|
+
endpoint: ctx.url.pathname,
|
|
10
|
+
}),
|
|
11
|
+
'text/html',
|
|
12
|
+
)
|