@contember/engine-http 2.1.0-alpha.23 → 2.1.0-alpha.25

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.
Files changed (72) hide show
  1. package/dist/development/index.cjs +0 -2
  2. package/dist/development/index.cjs.map +1 -1
  3. package/dist/development/index.js +0 -2
  4. package/dist/development/index.js.map +1 -1
  5. package/dist/development/src/MasterContainer.cjs +26 -27
  6. package/dist/development/src/MasterContainer.cjs.map +1 -1
  7. package/dist/development/src/MasterContainer.js +26 -27
  8. package/dist/development/src/MasterContainer.js.map +1 -1
  9. package/dist/development/src/content/ContentApiControllerFactory.cjs +29 -12
  10. package/dist/development/src/content/ContentApiControllerFactory.cjs.map +1 -1
  11. package/dist/development/src/content/ContentApiControllerFactory.js +29 -12
  12. package/dist/development/src/content/ContentApiControllerFactory.js.map +1 -1
  13. package/dist/development/src/content/ContentQueryHandlerFactory.cjs.map +1 -1
  14. package/dist/development/src/content/ContentQueryHandlerFactory.js.map +1 -1
  15. package/dist/development/src/projectGroup/ProjectGroupContainer.cjs +1 -1
  16. package/dist/development/src/projectGroup/ProjectGroupContainer.js +1 -1
  17. package/dist/development/src/system/ContentQueryExecutor.cjs +6 -2
  18. package/dist/development/src/system/ContentQueryExecutor.cjs.map +1 -1
  19. package/dist/development/src/system/ContentQueryExecutor.js +6 -2
  20. package/dist/development/src/system/ContentQueryExecutor.js.map +1 -1
  21. package/dist/production/index.cjs +0 -2
  22. package/dist/production/index.cjs.map +1 -1
  23. package/dist/production/index.js +0 -2
  24. package/dist/production/index.js.map +1 -1
  25. package/dist/production/src/MasterContainer.cjs +26 -27
  26. package/dist/production/src/MasterContainer.cjs.map +1 -1
  27. package/dist/production/src/MasterContainer.js +26 -27
  28. package/dist/production/src/MasterContainer.js.map +1 -1
  29. package/dist/production/src/content/ContentApiControllerFactory.cjs +29 -12
  30. package/dist/production/src/content/ContentApiControllerFactory.cjs.map +1 -1
  31. package/dist/production/src/content/ContentApiControllerFactory.js +29 -12
  32. package/dist/production/src/content/ContentApiControllerFactory.js.map +1 -1
  33. package/dist/production/src/content/ContentQueryHandlerFactory.cjs.map +1 -1
  34. package/dist/production/src/content/ContentQueryHandlerFactory.js.map +1 -1
  35. package/dist/production/src/projectGroup/ProjectGroupContainer.cjs +1 -1
  36. package/dist/production/src/projectGroup/ProjectGroupContainer.js +1 -1
  37. package/dist/production/src/system/ContentQueryExecutor.cjs +6 -2
  38. package/dist/production/src/system/ContentQueryExecutor.cjs.map +1 -1
  39. package/dist/production/src/system/ContentQueryExecutor.js +6 -2
  40. package/dist/production/src/system/ContentQueryExecutor.js.map +1 -1
  41. package/dist/tests/tsconfig.tsbuildinfo +1 -1
  42. package/dist/types/MasterContainer.d.ts +18 -20
  43. package/dist/types/MasterContainer.d.ts.map +1 -1
  44. package/dist/types/content/ContentApiControllerFactory.d.ts +4 -4
  45. package/dist/types/content/ContentApiControllerFactory.d.ts.map +1 -1
  46. package/dist/types/content/ContentGraphqlContext.d.ts +9 -0
  47. package/dist/types/content/ContentGraphqlContext.d.ts.map +1 -0
  48. package/dist/types/content/ContentQueryHandlerFactory.d.ts +2 -2
  49. package/dist/types/content/ContentQueryHandlerFactory.d.ts.map +1 -1
  50. package/dist/types/content/index.d.ts +0 -1
  51. package/dist/types/content/index.d.ts.map +1 -1
  52. package/dist/types/system/ContentQueryExecutor.d.ts +1 -1
  53. package/dist/types/system/ContentQueryExecutor.d.ts.map +1 -1
  54. package/dist/types/tsconfig.tsbuildinfo +1 -1
  55. package/package.json +15 -15
  56. package/src/MasterContainer.ts +29 -30
  57. package/src/content/ContentApiControllerFactory.ts +37 -15
  58. package/src/content/ContentGraphqlContext.ts +7 -0
  59. package/src/content/ContentQueryHandlerFactory.ts +4 -4
  60. package/src/content/index.ts +0 -1
  61. package/src/system/ContentQueryExecutor.ts +8 -4
  62. package/dist/development/src/content/ContentGraphQLContextFactory.cjs +0 -39
  63. package/dist/development/src/content/ContentGraphQLContextFactory.cjs.map +0 -1
  64. package/dist/development/src/content/ContentGraphQLContextFactory.js +0 -39
  65. package/dist/development/src/content/ContentGraphQLContextFactory.js.map +0 -1
  66. package/dist/production/src/content/ContentGraphQLContextFactory.cjs +0 -39
  67. package/dist/production/src/content/ContentGraphQLContextFactory.cjs.map +0 -1
  68. package/dist/production/src/content/ContentGraphQLContextFactory.js +0 -39
  69. package/dist/production/src/content/ContentGraphQLContextFactory.js.map +0 -1
  70. package/dist/types/content/ContentGraphQLContextFactory.d.ts +0 -38
  71. package/dist/types/content/ContentGraphQLContextFactory.d.ts.map +0 -1
  72. package/src/content/ContentGraphQLContextFactory.ts +0 -70
@@ -8,7 +8,6 @@ const Authorizator = require("./src/common/Authorizator.cjs");
8
8
  const HttpResponse = require("./src/common/HttpResponse.cjs");
9
9
  const ModuleInfoMiddleware = require("./src/common/ModuleInfoMiddleware.cjs");
10
10
  const ContentApiControllerFactory = require("./src/content/ContentApiControllerFactory.cjs");
11
- const ContentGraphQLContextFactory = require("./src/content/ContentGraphQLContextFactory.cjs");
12
11
  const ContentQueryHandlerFactory = require("./src/content/ContentQueryHandlerFactory.cjs");
13
12
  const ContentSchemaResolver = require("./src/content/ContentSchemaResolver.cjs");
14
13
  const GraphQlSchemaFactory = require("./src/content/GraphQlSchemaFactory.cjs");
@@ -54,7 +53,6 @@ exports.HttpErrorResponse = HttpResponse.HttpErrorResponse;
54
53
  exports.HttpResponse = HttpResponse.HttpResponse;
55
54
  exports.createModuleInfoMiddleware = ModuleInfoMiddleware.createModuleInfoMiddleware;
56
55
  exports.ContentApiControllerFactory = ContentApiControllerFactory.ContentApiControllerFactory;
57
- exports.ContentGraphQLContextFactory = ContentGraphQLContextFactory.ContentGraphQLContextFactory;
58
56
  exports.ContentQueryHandlerFactory = ContentQueryHandlerFactory.ContentQueryHandlerFactory;
59
57
  exports.ContentSchemaResolver = ContentSchemaResolver.ContentSchemaResolver;
60
58
  exports.GraphQlSchemaFactory = GraphQlSchemaFactory.GraphQlSchemaFactory;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../packages/engine-http/src/index.ts"],"sourcesContent":["import { MasterContainerArgs, MasterContainerFactory } from './MasterContainer'\nimport Koa from 'koa'\n\nexport * from './config/config'\nexport * from './config/ConfigProcessor'\nexport * from './config/tenantConfigResolver'\nexport * from './common'\nexport * from './content'\nexport * from './plugin/Plugin'\nexport * from './misc'\nexport * from './project-common'\nexport * from './system'\nexport * from './tenant'\nexport * from './transfer'\nexport * from './application'\nexport * from './providers'\nexport * from './graphql'\nexport * from './project/config'\nexport * from './utils/CryptoWrapper'\nexport * from './project/ProjectContainer'\nexport * from './project/ProjectContainerResolver'\nexport * from './projectGroup/ProjectGroupContainer'\nexport * from './projectGroup/ProjectGroupResolver'\nexport { type ProjectGroupContainerResolver } from './projectGroup/ProjectGroupContainerResolver'\n\nexport * from './utils/serverStartup'\nexport * from './utils/serverTermination'\nexport * from './utils/sentry'\nexport * from './MasterContainer'\nexport { serverConfigSchema } from './config/configSchema'\n\nexport const createContainer = (args: MasterContainerArgs) => {\n\treturn new MasterContainerFactory().create(args)\n}\n\nexport { Koa }\n"],"names":["MasterContainerFactory"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+Ba,MAAA,kBAAkB,CAAC,SAA8B;AAC7D,SAAO,IAAIA,gBAAA,uBAAA,EAAyB,OAAO,IAAI;AAChD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../packages/engine-http/src/index.ts"],"sourcesContent":["import { MasterContainerArgs, MasterContainerFactory } from './MasterContainer'\nimport Koa from 'koa'\n\nexport * from './config/config'\nexport * from './config/ConfigProcessor'\nexport * from './config/tenantConfigResolver'\nexport * from './common'\nexport * from './content'\nexport * from './plugin/Plugin'\nexport * from './misc'\nexport * from './project-common'\nexport * from './system'\nexport * from './tenant'\nexport * from './transfer'\nexport * from './application'\nexport * from './providers'\nexport * from './graphql'\nexport * from './project/config'\nexport * from './utils/CryptoWrapper'\nexport * from './project/ProjectContainer'\nexport * from './project/ProjectContainerResolver'\nexport * from './projectGroup/ProjectGroupContainer'\nexport * from './projectGroup/ProjectGroupResolver'\nexport { type ProjectGroupContainerResolver } from './projectGroup/ProjectGroupContainerResolver'\n\nexport * from './utils/serverStartup'\nexport * from './utils/serverTermination'\nexport * from './utils/sentry'\nexport * from './MasterContainer'\nexport { serverConfigSchema } from './config/configSchema'\n\nexport const createContainer = (args: MasterContainerArgs) => {\n\treturn new MasterContainerFactory().create(args)\n}\n\nexport { Koa }\n"],"names":["MasterContainerFactory"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+Ba,MAAA,kBAAkB,CAAC,SAA8B;AAC7D,SAAO,IAAIA,gBAAA,uBAAA,EAAyB,OAAO,IAAI;AAChD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -6,7 +6,6 @@ import { Authenticator } from "./src/common/Authorizator.js";
6
6
  import { HttpErrorResponse, HttpResponse } from "./src/common/HttpResponse.js";
7
7
  import { createModuleInfoMiddleware } from "./src/common/ModuleInfoMiddleware.js";
8
8
  import { ContentApiControllerFactory } from "./src/content/ContentApiControllerFactory.js";
9
- import { ContentGraphQLContextFactory } from "./src/content/ContentGraphQLContextFactory.js";
10
9
  import { ContentQueryHandlerFactory } from "./src/content/ContentQueryHandlerFactory.js";
11
10
  import { ContentSchemaResolver } from "./src/content/ContentSchemaResolver.js";
12
11
  import { GraphQlSchemaFactory } from "./src/content/GraphQlSchemaFactory.js";
@@ -46,7 +45,6 @@ export {
46
45
  Application,
47
46
  Authenticator,
48
47
  ContentApiControllerFactory,
49
- ContentGraphQLContextFactory,
50
48
  ContentQueryHandlerFactory,
51
49
  ContentSchemaResolver,
52
50
  ContentSchemaTransferMappingFactory,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../packages/engine-http/src/index.ts"],"sourcesContent":["import { MasterContainerArgs, MasterContainerFactory } from './MasterContainer'\nimport Koa from 'koa'\n\nexport * from './config/config'\nexport * from './config/ConfigProcessor'\nexport * from './config/tenantConfigResolver'\nexport * from './common'\nexport * from './content'\nexport * from './plugin/Plugin'\nexport * from './misc'\nexport * from './project-common'\nexport * from './system'\nexport * from './tenant'\nexport * from './transfer'\nexport * from './application'\nexport * from './providers'\nexport * from './graphql'\nexport * from './project/config'\nexport * from './utils/CryptoWrapper'\nexport * from './project/ProjectContainer'\nexport * from './project/ProjectContainerResolver'\nexport * from './projectGroup/ProjectGroupContainer'\nexport * from './projectGroup/ProjectGroupResolver'\nexport { type ProjectGroupContainerResolver } from './projectGroup/ProjectGroupContainerResolver'\n\nexport * from './utils/serverStartup'\nexport * from './utils/serverTermination'\nexport * from './utils/sentry'\nexport * from './MasterContainer'\nexport { serverConfigSchema } from './config/configSchema'\n\nexport const createContainer = (args: MasterContainerArgs) => {\n\treturn new MasterContainerFactory().create(args)\n}\n\nexport { Koa }\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+Ba,MAAA,kBAAkB,CAAC,SAA8B;AAC7D,SAAO,IAAI,uBAAA,EAAyB,OAAO,IAAI;AAChD;"}
1
+ {"version":3,"file":"index.js","sources":["../../../packages/engine-http/src/index.ts"],"sourcesContent":["import { MasterContainerArgs, MasterContainerFactory } from './MasterContainer'\nimport Koa from 'koa'\n\nexport * from './config/config'\nexport * from './config/ConfigProcessor'\nexport * from './config/tenantConfigResolver'\nexport * from './common'\nexport * from './content'\nexport * from './plugin/Plugin'\nexport * from './misc'\nexport * from './project-common'\nexport * from './system'\nexport * from './tenant'\nexport * from './transfer'\nexport * from './application'\nexport * from './providers'\nexport * from './graphql'\nexport * from './project/config'\nexport * from './utils/CryptoWrapper'\nexport * from './project/ProjectContainer'\nexport * from './project/ProjectContainerResolver'\nexport * from './projectGroup/ProjectGroupContainer'\nexport * from './projectGroup/ProjectGroupResolver'\nexport { type ProjectGroupContainerResolver } from './projectGroup/ProjectGroupContainerResolver'\n\nexport * from './utils/serverStartup'\nexport * from './utils/serverTermination'\nexport * from './utils/sentry'\nexport * from './MasterContainer'\nexport { serverConfigSchema } from './config/configSchema'\n\nexport const createContainer = (args: MasterContainerArgs) => {\n\treturn new MasterContainerFactory().create(args)\n}\n\nexport { Koa }\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+Ba,MAAA,kBAAkB,CAAC,SAA8B;AAC7D,SAAO,IAAI,uBAAA,EAAyB,OAAO,IAAI;AAChD;"}
@@ -1,50 +1,49 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const dic = require("@contember/dic");
3
4
  const engineSystemApi = require("@contember/engine-system-api");
4
5
  const engineTenantApi = require("@contember/engine-tenant-api");
5
- const dic = require("@contember/dic");
6
6
  const schemaMigrations = require("@contember/schema-migrations");
7
7
  const Initializer = require("./bootstrap/Initializer.cjs");
8
- const ProjectContainer = require("./project/ProjectContainer.cjs");
9
- require("@contember/engine-common");
10
- const ProjectGroupContainer = require("./projectGroup/ProjectGroupContainer.cjs");
11
- const ProjectGroupResolver = require("./projectGroup/ProjectGroupResolver.cjs");
8
+ const Database = require("@contember/database");
12
9
  const engineContentApi = require("@contember/engine-content-api");
13
- const providers = require("./providers.cjs");
14
- const TenantApiMiddlewareFactory = require("./tenant/TenantApiMiddlewareFactory.cjs");
15
- const TenantGraphQLHandlerFactory = require("./tenant/TenantGraphQLHandlerFactory.cjs");
16
- const SystemApiMiddlewareFactory = require("./system/SystemApiMiddlewareFactory.cjs");
17
- const SystemGraphQLContextFactory = require("./system/SystemGraphQLContextFactory.cjs");
18
- const SystemGraphQLHandlerFactory = require("./system/SystemGraphQLHandlerFactory.cjs");
10
+ const Koa = require("koa");
11
+ const crypto = require("node:crypto");
12
+ const application = require("./application/application.cjs");
13
+ const HttpResponse = require("./common/HttpResponse.cjs");
19
14
  const ContentApiControllerFactory = require("./content/ContentApiControllerFactory.cjs");
20
- const ContentGraphQLContextFactory = require("./content/ContentGraphQLContextFactory.cjs");
21
15
  const ContentQueryHandlerFactory = require("./content/ContentQueryHandlerFactory.cjs");
22
16
  require("./content/ContentSchemaResolver.cjs");
23
17
  const GraphQlSchemaFactory = require("./content/GraphQlSchemaFactory.cjs");
24
18
  const NotModifiedChecker = require("./content/NotModifiedChecker.cjs");
25
19
  require("./content/ProjectMembershipResolver.cjs");
20
+ const ContentApiSpecificCache = require("./content/ContentApiSpecificCache.cjs");
21
+ const HomepageMiddlewareFactory = require("./misc/HomepageMiddlewareFactory.cjs");
22
+ const ProjectContainer = require("./project/ProjectContainer.cjs");
23
+ require("@contember/engine-common");
26
24
  const ProjectContextResolver = require("./project-common/ProjectContextResolver.cjs");
25
+ const ProjectGroupContainer = require("./projectGroup/ProjectGroupContainer.cjs");
26
+ const ProjectGroupContainerResolver = require("./projectGroup/ProjectGroupContainerResolver.cjs");
27
+ const ProjectGroupResolver = require("./projectGroup/ProjectGroupResolver.cjs");
28
+ const CollectHttpMetricsMiddelware = require("./prometheus/CollectHttpMetricsMiddelware.cjs");
29
+ const ShowMetricsMiddleware = require("./prometheus/ShowMetricsMiddleware.cjs");
30
+ const ProjectGroupContainerMetricsHook = require("./prometheus/ProjectGroupContainerMetricsHook.cjs");
31
+ const PrometheusRegistryFactory = require("./prometheus/PrometheusRegistryFactory.cjs");
32
+ const providers = require("./providers.cjs");
33
+ const SystemApiMiddlewareFactory = require("./system/SystemApiMiddlewareFactory.cjs");
34
+ const SystemGraphQLContextFactory = require("./system/SystemGraphQLContextFactory.cjs");
35
+ const SystemGraphQLHandlerFactory = require("./system/SystemGraphQLHandlerFactory.cjs");
36
+ const ContentQueryExecutor = require("./system/ContentQueryExecutor.cjs");
37
+ const TenantApiMiddlewareFactory = require("./tenant/TenantApiMiddlewareFactory.cjs");
38
+ const TenantGraphQLHandlerFactory = require("./tenant/TenantGraphQLHandlerFactory.cjs");
27
39
  const ImportApiMiddlewareFactory = require("./transfer/ImportApiMiddlewareFactory.cjs");
28
40
  const ExportApiControllerFactory = require("./transfer/ExportApiControllerFactory.cjs");
29
41
  const ImportExecutor = require("./transfer/ImportExecutor.cjs");
30
42
  const ExportExecutor = require("./transfer/ExportExecutor.cjs");
31
43
  const ContentSchemaTransferMappingFactory = require("./transfer/ContentSchemaTransferMappingFactory.cjs");
32
44
  const SystemSchemaTransferMappingFactory = require("./transfer/SystemSchemaTransferMappingFactory.cjs");
33
- const HomepageMiddlewareFactory = require("./misc/HomepageMiddlewareFactory.cjs");
34
- const application = require("./application/application.cjs");
35
- const ApplicationWorkerManager = require("./workers/ApplicationWorkerManager.cjs");
36
- const HttpResponse = require("./common/HttpResponse.cjs");
37
- const ContentQueryExecutor = require("./system/ContentQueryExecutor.cjs");
38
- const Database = require("@contember/database");
39
- const Koa = require("koa");
40
- const ProjectGroupContainerResolver = require("./projectGroup/ProjectGroupContainerResolver.cjs");
41
- const PrometheusRegistryFactory = require("./prometheus/PrometheusRegistryFactory.cjs");
42
- const ProjectGroupContainerMetricsHook = require("./prometheus/ProjectGroupContainerMetricsHook.cjs");
43
- const CollectHttpMetricsMiddelware = require("./prometheus/CollectHttpMetricsMiddelware.cjs");
44
- const ShowMetricsMiddleware = require("./prometheus/ShowMetricsMiddleware.cjs");
45
- const crypto = require("node:crypto");
46
45
  const CryptoWrapper = require("./utils/CryptoWrapper.cjs");
47
- const ContentApiSpecificCache = require("./content/ContentApiSpecificCache.cjs");
46
+ const ApplicationWorkerManager = require("./workers/ApplicationWorkerManager.cjs");
48
47
  class MasterContainerFactory {
49
48
  createBuilder(args) {
50
49
  const builder = this.createBuilderInternal(args);
@@ -83,7 +82,7 @@ class MasterContainerFactory {
83
82
  serverConfig2.projectGroup?.configEncryptionKey ? new CryptoWrapper.CryptoWrapper(encryptionKey) : void 0,
84
83
  projectGroupContainerResolver
85
84
  );
86
- }).addService("notModifiedChecker", () => new NotModifiedChecker.NotModifiedChecker()).addService("contentGraphqlContextFactory", ({ providers: providers2, executionContainerFactory }) => new ContentGraphQLContextFactory.ContentGraphQLContextFactory(providers2, executionContainerFactory)).addService("contentQueryHandlerFactory", ({ debugMode: debugMode2 }) => new ContentQueryHandlerFactory.ContentQueryHandlerFactory(debugMode2)).addService("projectContextResolver", () => new ProjectContextResolver.ProjectContextResolver()).addService("contentApiMiddlewareFactory", ({ projectContextResolver, notModifiedChecker, contentGraphqlContextFactory, contentQueryHandlerFactory, graphQlSchemaFactory }) => new ContentApiControllerFactory.ContentApiControllerFactory(notModifiedChecker, contentGraphqlContextFactory, contentQueryHandlerFactory, projectContextResolver, graphQlSchemaFactory)).addService("tenantApiMiddlewareFactory", () => new TenantApiMiddlewareFactory.TenantApiMiddlewareFactory()).addService("systemGraphQLContextFactory", () => new SystemGraphQLContextFactory.SystemGraphQLContextFactory()).addService("systemApiMiddlewareFactory", ({ debugMode: debugMode2, systemGraphQLContextFactory, projectContextResolver }) => new SystemApiMiddlewareFactory.SystemApiMiddlewareFactory(debugMode2, systemGraphQLContextFactory, projectContextResolver)).addService("contentSchemaTransferMappingFactory", () => new ContentSchemaTransferMappingFactory.ContentSchemaTransferMappingFactory()).addService("systemSchemaTransferMappingFactory", () => new SystemSchemaTransferMappingFactory.SystemSchemaTransferMappingFactory()).addService("importExecutor", ({ contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory, databaseMetadataResolver }) => new ImportExecutor.ImportExecutor(contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory, databaseMetadataResolver)).addService("exportExecutor", ({ contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory }) => new ExportExecutor.ExportExecutor(contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory)).addService("importApiMiddlewareFactory", ({ projectGroupResolver, importExecutor }) => new ImportApiMiddlewareFactory.ImportApiMiddlewareFactory(projectGroupResolver, importExecutor)).addService("exportApiMiddlewareFactory", ({ projectGroupResolver, exportExecutor }) => new ExportApiControllerFactory.ExportApiControllerFactory(projectGroupResolver, exportExecutor)).addService("application", ({ projectGroupResolver, serverConfig: serverConfig2, logger: logger2, debugMode: debugMode2, version: version2, promRegistry }) => {
85
+ }).addService("notModifiedChecker", () => new NotModifiedChecker.NotModifiedChecker()).addService("contentQueryHandlerFactory", ({ debugMode: debugMode2 }) => new ContentQueryHandlerFactory.ContentQueryHandlerFactory(debugMode2)).addService("projectContextResolver", () => new ProjectContextResolver.ProjectContextResolver()).addService("contentApiMiddlewareFactory", ({ projectContextResolver, notModifiedChecker, executionContainerFactory, contentQueryHandlerFactory, graphQlSchemaFactory }) => new ContentApiControllerFactory.ContentApiControllerFactory(notModifiedChecker, executionContainerFactory, contentQueryHandlerFactory, projectContextResolver, graphQlSchemaFactory)).addService("tenantApiMiddlewareFactory", () => new TenantApiMiddlewareFactory.TenantApiMiddlewareFactory()).addService("systemGraphQLContextFactory", () => new SystemGraphQLContextFactory.SystemGraphQLContextFactory()).addService("systemApiMiddlewareFactory", ({ debugMode: debugMode2, systemGraphQLContextFactory, projectContextResolver }) => new SystemApiMiddlewareFactory.SystemApiMiddlewareFactory(debugMode2, systemGraphQLContextFactory, projectContextResolver)).addService("contentSchemaTransferMappingFactory", () => new ContentSchemaTransferMappingFactory.ContentSchemaTransferMappingFactory()).addService("systemSchemaTransferMappingFactory", () => new SystemSchemaTransferMappingFactory.SystemSchemaTransferMappingFactory()).addService("importExecutor", ({ contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory, databaseMetadataResolver }) => new ImportExecutor.ImportExecutor(contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory, databaseMetadataResolver)).addService("exportExecutor", ({ contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory }) => new ExportExecutor.ExportExecutor(contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory)).addService("importApiMiddlewareFactory", ({ projectGroupResolver, importExecutor }) => new ImportApiMiddlewareFactory.ImportApiMiddlewareFactory(projectGroupResolver, importExecutor)).addService("exportApiMiddlewareFactory", ({ projectGroupResolver, exportExecutor }) => new ExportApiControllerFactory.ExportApiControllerFactory(projectGroupResolver, exportExecutor)).addService("application", ({ projectGroupResolver, serverConfig: serverConfig2, logger: logger2, debugMode: debugMode2, version: version2, promRegistry }) => {
87
86
  const app = new application.Application(
88
87
  projectGroupResolver,
89
88
  serverConfig2,
@@ -1 +1 @@
1
- {"version":3,"file":"MasterContainer.cjs","sources":["../../../../packages/engine-http/src/MasterContainer.ts"],"sourcesContent":["import { SystemContainerFactory } from '@contember/engine-system-api'\nimport { TenantContainerFactory } from '@contember/engine-tenant-api'\nimport { Builder } from '@contember/dic'\nimport { ServerConfig } from './config/config'\nimport { ModificationHandlerFactory } from '@contember/schema-migrations'\nimport { Initializer } from './bootstrap'\n\nimport { ProjectContainerFactoryFactory } from './project'\nimport { ProjectConfigResolver } from './config/projectConfigResolver'\nimport { TenantConfigResolver } from './config/tenantConfigResolver'\nimport { ProjectGroupContainerFactory } from './projectGroup/ProjectGroupContainer'\nimport { ProjectGroupResolver } from './projectGroup/ProjectGroupResolver'\nimport { Logger } from '@contember/logger'\nimport { ExecutionContainerFactory, GraphQlSchemaBuilderFactory, PermissionFactory } from '@contember/engine-content-api'\nimport { createProviders, Providers } from './providers'\nimport { TenantApiMiddlewareFactory, TenantGraphQLHandlerFactory } from './tenant'\nimport { SystemApiMiddlewareFactory, SystemGraphQLContextFactory, SystemGraphQLHandlerFactory } from './system'\nimport {\n\tContentApiControllerFactory, ContentGraphQLContextFactory, ContentQueryHandlerFactory, GraphQLSchemaContributor, GraphQlSchemaFactory,\n\tGraphQLSchemaFactoryResult, NotModifiedChecker,\n} from './content'\nimport { ProjectContextResolver } from './project-common'\nimport {\n\tContentSchemaTransferMappingFactory,\n\tExportApiControllerFactory,\n\tExportExecutor,\n\tImportApiMiddlewareFactory,\n\tImportExecutor,\n\tSystemSchemaTransferMappingFactory,\n} from './transfer'\nimport { homepageController } from './misc'\nimport { Plugin } from './plugin/Plugin'\nimport { Application } from './application'\nimport { ApplicationWorkerManager } from './workers'\nimport { HttpResponse } from './common'\nimport { ContentQueryExecutorImpl } from './system/ContentQueryExecutor'\nimport { DatabaseMetadataResolver } from '@contember/database'\nimport Koa from 'koa'\nimport { ProjectGroupContainerResolver } from './projectGroup/ProjectGroupContainerResolver'\nimport { PrometheusRegistryFactory } from './prometheus/PrometheusRegistryFactory'\nimport { ProjectGroupContainerMetricsHook } from './prometheus/ProjectGroupContainerMetricsHook'\nimport { createColllectHttpMetricsMiddleware, createShowMetricsMiddleware } from './prometheus'\nimport { createSecretKey } from 'node:crypto'\nimport { CryptoWrapper } from './utils/CryptoWrapper'\nimport { ContentApiSpecificCache } from './content/ContentApiSpecificCache'\nimport { Schema } from '@contember/schema'\n\nexport type ProcessType =\n\t| 'singleNode'\n\t| 'clusterMaster'\n\t| 'clusterWorker'\n\nexport interface MasterContainer {\n\tinitializer: Initializer\n\tapplication: Application\n\tproviders: Providers\n\tapplicationWorkers: ApplicationWorkerManager\n\tmonitoringKoa: Koa\n}\n\nexport interface MasterContainerArgs {\n\tdebugMode: boolean\n\tserverConfig: ServerConfig\n\tprojectConfigResolver: ProjectConfigResolver\n\ttenantConfigResolver: TenantConfigResolver\n\tplugins: Plugin[]\n\tlogger: Logger\n\tversion?: string\n\tprocessType: ProcessType\n}\n\nexport type MasterContainerBuilder = ReturnType<MasterContainerFactory['createBuilderInternal']>\nexport type MasterContainerHook = (builder: MasterContainerBuilder) => MasterContainerBuilder\n\nexport class MasterContainerFactory {\n\n\tcreateBuilder(args: MasterContainerArgs): MasterContainerBuilder {\n\t\tconst builder = this.createBuilderInternal(args)\n\t\tconst hooks = args.plugins\n\t\t\t.map(it => it.getMasterContainerHook?.())\n\t\t\t.filter((it): it is MasterContainerHook => it !== undefined)\n\t\treturn hooks.reduce((acc, cb) => cb(acc), builder)\n\t}\n\n\tcreateBuilderInternal({\n\t\tserverConfig,\n\t\tdebugMode,\n\t\tplugins,\n\t\tprojectConfigResolver,\n\t\ttenantConfigResolver,\n\t\tversion,\n\t\tlogger,\n\t\tprocessType,\n\t}: MasterContainerArgs) {\n\t\treturn new Builder({})\n\t\t\t.addService('serverConfig', () =>\n\t\t\t\tserverConfig)\n\t\t\t.addService('debugMode', () =>\n\t\t\t\tdebugMode)\n\t\t\t.addService('version', () =>\n\t\t\t\tversion)\n\t\t\t.addService('processType', () =>\n\t\t\t\tprocessType)\n\t\t\t.addService('projectConfigResolver', () =>\n\t\t\t\tprojectConfigResolver)\n\t\t\t.addService('tenantConfigResolver', () =>\n\t\t\t\ttenantConfigResolver)\n\t\t\t.addService('plugins', () =>\n\t\t\t\tplugins)\n\t\t\t.addService('providers', () =>\n\t\t\t\tcreateProviders())\n\t\t\t.addService('tenantContainerFactory', ({ providers }) =>\n\t\t\t\tnew TenantContainerFactory(providers))\n\t\t\t.addService('modificationHandlerFactory', () =>\n\t\t\t\tnew ModificationHandlerFactory(ModificationHandlerFactory.defaultFactoryMap))\n\t\t\t.addService('executionContainerFactory', ({ providers }) =>\n\t\t\t\tnew ExecutionContainerFactory(providers))\n\t\t\t.addService('graphQlSchemaBuilderFactory', () =>\n\t\t\t\tnew GraphQlSchemaBuilderFactory())\n\t\t\t.addService('contentQueryExecutor', ({ executionContainerFactory, graphQlSchemaBuilderFactory }) =>\n\t\t\t\tnew ContentQueryExecutorImpl(executionContainerFactory, graphQlSchemaBuilderFactory))\n\t\t\t.addService('systemContainerFactory', ({ providers, modificationHandlerFactory, contentQueryExecutor }) =>\n\t\t\t\tnew SystemContainerFactory(providers, modificationHandlerFactory, contentQueryExecutor))\n\t\t\t.addService('contentPermissionFactory', ({}) =>\n\t\t\t\tnew PermissionFactory())\n\t\t\t.addService('databaseMetadataResolver', () =>\n\t\t\t\tnew DatabaseMetadataResolver())\n\t\t\t.addService('graphqlSchemaCache', ({ serverConfig }) =>\n\t\t\t\tnew ContentApiSpecificCache<Schema, GraphQLSchemaFactoryResult>({\n\t\t\t\t\tttlSeconds: serverConfig.contentApi?.schemaCacheTtlSeconds,\n\t\t\t\t}))\n\t\t\t.addService('graphQlSchemaFactory', ({ plugins, providers, graphqlSchemaCache, contentPermissionFactory, graphQlSchemaBuilderFactory }) => {\n\t\t\t\tconst contributors = plugins\n\t\t\t\t\t.map(it => (it.getSchemaContributor ? it.getSchemaContributor({ providers }) : null))\n\t\t\t\t\t.filter((it): it is GraphQLSchemaContributor => !!it)\n\n\t\t\t\treturn new GraphQlSchemaFactory(\n\t\t\t\t\tgraphqlSchemaCache,\n\t\t\t\t\tgraphQlSchemaBuilderFactory,\n\t\t\t\t\tcontentPermissionFactory,\n\t\t\t\t\tcontributors,\n\t\t\t\t)\n\t\t\t})\n\t\t\t.addService('projectContainerFactoryFactory', ({ plugins, providers, databaseMetadataResolver }) =>\n\t\t\t\tnew ProjectContainerFactoryFactory(plugins, providers, databaseMetadataResolver))\n\t\t\t.addService('tenantGraphQLHandlerFactory', () =>\n\t\t\t\tnew TenantGraphQLHandlerFactory())\n\t\t\t.addService('systemGraphQLHandlerFactory', ({ debugMode }) =>\n\t\t\t\tnew SystemGraphQLHandlerFactory(debugMode))\n\t\t\t.addService('logger', () =>\n\t\t\t\tlogger)\n\t\t\t.addService('projectGroupContainerFactory', ({ debugMode, providers, systemContainerFactory, tenantContainerFactory, projectContainerFactoryFactory, projectConfigResolver, tenantGraphQLHandlerFactory, systemGraphQLHandlerFactory, logger }) =>\n\t\t\t\tnew ProjectGroupContainerFactory(debugMode, providers, systemContainerFactory, tenantContainerFactory, projectContainerFactoryFactory, projectConfigResolver, tenantGraphQLHandlerFactory, systemGraphQLHandlerFactory, logger))\n\t\t\t.addService('projectGroupContainerResolver', ({ tenantConfigResolver, projectGroupContainerFactory }) =>\n\t\t\t\tnew ProjectGroupContainerResolver(tenantConfigResolver, projectGroupContainerFactory))\n\t\t\t.addService('promRegistryFactory', ({ processType, version }) =>\n\t\t\t\tnew PrometheusRegistryFactory(processType, { version }))\n\t\t\t.addService('projectGroupContainerMetricsHook', ({ projectGroupContainerResolver }) =>\n\t\t\t\tnew ProjectGroupContainerMetricsHook(projectGroupContainerResolver))\n\t\t\t.addService('promRegistry', ({ promRegistryFactory, projectGroupContainerMetricsHook }) => {\n\t\t\t\tconst registry = promRegistryFactory.create()\n\t\t\t\tprojectGroupContainerMetricsHook.register(registry)\n\t\t\t\treturn registry\n\t\t\t})\n\t\t\t.addService('projectGroupContainer', ({ tenantConfigResolver, projectGroupContainerFactory }) =>\n\t\t\t\tprojectGroupContainerFactory.create({ slug: undefined, config: tenantConfigResolver(undefined, {}) }))\n\t\t\t.addService('projectGroupResolver', ({ serverConfig, projectGroupContainerResolver }): ProjectGroupResolver => {\n\t\t\t\tconst encryptionKey = serverConfig.projectGroup?.configEncryptionKey\n\t\t\t\t\t? createSecretKey(Buffer.from(serverConfig.projectGroup?.configEncryptionKey, 'hex'))\n\t\t\t\t\t: undefined\n\t\t\t\treturn new ProjectGroupResolver(\n\t\t\t\t\tserverConfig.projectGroup?.domainMapping,\n\t\t\t\t\tserverConfig.projectGroup?.configHeader,\n\t\t\t\t\tserverConfig.projectGroup?.configEncryptionKey ? new CryptoWrapper(encryptionKey) : undefined,\n\t\t\t\t\tprojectGroupContainerResolver,\n\t\t\t\t)\n\n\t\t\t})\n\t\t\t.addService('notModifiedChecker', () =>\n\t\t\t\tnew NotModifiedChecker())\n\t\t\t.addService('contentGraphqlContextFactory', ({ providers, executionContainerFactory }) =>\n\t\t\t\tnew ContentGraphQLContextFactory(providers, executionContainerFactory))\n\t\t\t.addService('contentQueryHandlerFactory', ({ debugMode }) =>\n\t\t\t\tnew ContentQueryHandlerFactory(debugMode))\n\t\t\t.addService('projectContextResolver', () =>\n\t\t\t\tnew ProjectContextResolver())\n\t\t\t.addService('contentApiMiddlewareFactory', ({ projectContextResolver, notModifiedChecker, contentGraphqlContextFactory, contentQueryHandlerFactory, graphQlSchemaFactory }) =>\n\t\t\t\tnew ContentApiControllerFactory(notModifiedChecker, contentGraphqlContextFactory, contentQueryHandlerFactory, projectContextResolver, graphQlSchemaFactory))\n\t\t\t.addService('tenantApiMiddlewareFactory', () =>\n\t\t\t\tnew TenantApiMiddlewareFactory())\n\t\t\t.addService('systemGraphQLContextFactory', () =>\n\t\t\t\tnew SystemGraphQLContextFactory())\n\t\t\t.addService('systemApiMiddlewareFactory', ({ debugMode, systemGraphQLContextFactory, projectContextResolver }) =>\n\t\t\t\tnew SystemApiMiddlewareFactory(debugMode, systemGraphQLContextFactory, projectContextResolver))\n\t\t\t.addService('contentSchemaTransferMappingFactory', () =>\n\t\t\t\tnew ContentSchemaTransferMappingFactory())\n\t\t\t.addService('systemSchemaTransferMappingFactory', () =>\n\t\t\t\tnew SystemSchemaTransferMappingFactory())\n\t\t\t.addService('importExecutor', ({ contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory, databaseMetadataResolver }) =>\n\t\t\t\tnew ImportExecutor(contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory, databaseMetadataResolver))\n\t\t\t.addService('exportExecutor', ({ contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory }) =>\n\t\t\t\tnew ExportExecutor(contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory))\n\t\t\t.addService('importApiMiddlewareFactory', ({ projectGroupResolver, importExecutor }) =>\n\t\t\t\tnew ImportApiMiddlewareFactory(projectGroupResolver, importExecutor))\n\t\t\t.addService('exportApiMiddlewareFactory', ({ projectGroupResolver, exportExecutor }) =>\n\t\t\t\tnew ExportApiControllerFactory(projectGroupResolver, exportExecutor))\n\t\t\t.addService('application', ({ projectGroupResolver, serverConfig, logger, debugMode, version, promRegistry }) => {\n\t\t\t\tconst app = new Application(\n\t\t\t\t\tprojectGroupResolver,\n\t\t\t\t\tserverConfig,\n\t\t\t\t\tdebugMode,\n\t\t\t\t\tversion,\n\t\t\t\t\tlogger,\n\t\t\t\t)\n\t\t\t\tapp.addMiddleware(createColllectHttpMetricsMiddleware(promRegistry))\n\n\t\t\t\treturn app\n\t\t\t})\n\t\t\t.setupService('application', (it, { contentApiMiddlewareFactory, tenantApiMiddlewareFactory, systemApiMiddlewareFactory, importApiMiddlewareFactory, exportApiMiddlewareFactory }) => {\n\t\t\t\tit.addRoute('content', '/content/:projectSlug/:stageSlug', contentApiMiddlewareFactory.create())\n\t\t\t\tit.addRoute('tenant', '/tenant', tenantApiMiddlewareFactory.create())\n\t\t\t\tit.addRoute('system', '/system/:projectSlug', systemApiMiddlewareFactory.create())\n\t\t\t\tit.addRoute('transfer', '/import', importApiMiddlewareFactory.create())\n\t\t\t\tit.addRoute('transfer', '/export', exportApiMiddlewareFactory.create())\n\t\t\t\tit.addRoute('misc', '/', homepageController)\n\n\t\t\t\tit.addInternalRoute('internal', '/health', () => {\n\t\t\t\t\treturn new HttpResponse(200, 'OK')\n\t\t\t\t})\n\t\t\t})\n\t\t\t.addService('initializer', ({ projectGroupContainer }) =>\n\t\t\t\tnew Initializer(projectGroupContainer))\n\t\t\t.addService('applicationWorkers', () =>\n\t\t\t\tnew ApplicationWorkerManager())\n\t\t\t.setupService('executionContainerFactory', (it, { plugins }) => {\n\t\t\t\tfor (const plugin of plugins) {\n\t\t\t\t\tif (plugin.getExecutionContainerHook) {\n\t\t\t\t\t\tit.hooks.push(plugin.getExecutionContainerHook())\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\t\t\t.addService('monitoringKoa', ({ promRegistry }) => {\n\t\t\t\tconst app = new Koa()\n\t\t\t\tapp.use(createShowMetricsMiddleware(promRegistry))\n\n\t\t\t\treturn app\n\t\t\t})\n\n\t}\n\n\tcreate(args: MasterContainerArgs): MasterContainer {\n\t\tconst container = this.createBuilder(args).build()\n\t\treturn container.pick('initializer', 'application', 'providers', 'applicationWorkers', 'monitoringKoa')\n\t}\n}\n"],"names":["Builder","createProviders","providers","TenantContainerFactory","ModificationHandlerFactory","ExecutionContainerFactory","GraphQlSchemaBuilderFactory","ContentQueryExecutorImpl","SystemContainerFactory","PermissionFactory","DatabaseMetadataResolver","serverConfig","ContentApiSpecificCache","plugins","GraphQlSchemaFactory","ProjectContainerFactoryFactory","TenantGraphQLHandlerFactory","debugMode","SystemGraphQLHandlerFactory","projectConfigResolver","logger","ProjectGroupContainerFactory","tenantConfigResolver","ProjectGroupContainerResolver","processType","version","PrometheusRegistryFactory","ProjectGroupContainerMetricsHook","createSecretKey","ProjectGroupResolver","CryptoWrapper","NotModifiedChecker","ContentGraphQLContextFactory","ContentQueryHandlerFactory","ProjectContextResolver","ContentApiControllerFactory","TenantApiMiddlewareFactory","SystemGraphQLContextFactory","SystemApiMiddlewareFactory","ContentSchemaTransferMappingFactory","SystemSchemaTransferMappingFactory","ImportExecutor","ExportExecutor","ImportApiMiddlewareFactory","ExportApiControllerFactory","Application","createColllectHttpMetricsMiddleware","homepageController","HttpResponse","Initializer","ApplicationWorkerManager","createShowMetricsMiddleware"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0EO,MAAM,uBAAuB;AAAA,EAEnC,cAAc,MAAmD;AAC1D,UAAA,UAAU,KAAK,sBAAsB,IAAI;AAC/C,UAAM,QAAQ,KAAK,QACjB,IAAI,CAAM,OAAA,GAAG,yBAA0B,CAAA,EACvC,OAAO,CAAC,OAAkC,OAAO,MAAS;AACrD,WAAA,MAAM,OAAO,CAAC,KAAK,OAAO,GAAG,GAAG,GAAG,OAAO;AAAA,EAAA;AAAA,EAGlD,sBAAsB;AAAA,IACrB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,GACuB;AACvB,WAAO,IAAIA,IAAA,QAAQ,EAAE,EACnB,WAAW,gBAAgB,MAC3B,YAAY,EACZ,WAAW,aAAa,MACxB,SAAS,EACT,WAAW,WAAW,MACtB,OAAO,EACP,WAAW,eAAe,MAC1B,WAAW,EACX,WAAW,yBAAyB,MACpC,qBAAqB,EACrB,WAAW,wBAAwB,MACnC,oBAA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AAiB,CAAC,EAAE,mBAAmB;AAC5C,YAAA,MAAM,IAAI,IAAI;AAChB,UAAA,IAAIsC,kDAA4B,YAAY,CAAC;AAE1C,aAAA;AAAA,IAAA,CACP;AAAA,EAAA;AAAA,EAIH,OAAO,MAA4C;AAClD,UAAM,YAAY,KAAK,cAAc,IAAI,EAAE,MAAM;AACjD,WAAO,UAAU,KAAK,eAAe,eAAe,aAAa,sBAAsB,eAAe;AAAA,EAAA;AAExG;;"}
1
+ {"version":3,"file":"MasterContainer.cjs","sources":["../../../../packages/engine-http/src/MasterContainer.ts"],"sourcesContent":["import { Builder } from '@contember/dic'\nimport { SystemContainerFactory } from '@contember/engine-system-api'\nimport { TenantContainerFactory } from '@contember/engine-tenant-api'\nimport { ModificationHandlerFactory } from '@contember/schema-migrations'\nimport { Initializer } from './bootstrap'\nimport { ServerConfig } from './config/config'\n\nimport { DatabaseMetadataResolver } from '@contember/database'\nimport { ExecutionContainerFactory, GraphQlSchemaBuilderFactory, PermissionFactory } from '@contember/engine-content-api'\nimport { Logger } from '@contember/logger'\nimport { Schema } from '@contember/schema'\nimport Koa from 'koa'\nimport { createSecretKey } from 'node:crypto'\nimport { Application } from './application'\nimport { HttpResponse } from './common'\nimport { ProjectConfigResolver } from './config/projectConfigResolver'\nimport { TenantConfigResolver } from './config/tenantConfigResolver'\nimport {\n\tContentApiControllerFactory,\n\tContentQueryHandlerFactory, GraphQLSchemaContributor, GraphQlSchemaFactory,\n\tGraphQLSchemaFactoryResult, NotModifiedChecker,\n} from './content'\nimport { ContentApiSpecificCache } from './content/ContentApiSpecificCache'\nimport { homepageController } from './misc'\nimport { Plugin } from './plugin/Plugin'\nimport { ProjectContainerFactoryFactory } from './project'\nimport { ProjectContextResolver } from './project-common'\nimport { ProjectGroupContainerFactory } from './projectGroup/ProjectGroupContainer'\nimport { ProjectGroupContainerResolver } from './projectGroup/ProjectGroupContainerResolver'\nimport { ProjectGroupResolver } from './projectGroup/ProjectGroupResolver'\nimport { createColllectHttpMetricsMiddleware, createShowMetricsMiddleware } from './prometheus'\nimport { ProjectGroupContainerMetricsHook } from './prometheus/ProjectGroupContainerMetricsHook'\nimport { PrometheusRegistryFactory } from './prometheus/PrometheusRegistryFactory'\nimport { createProviders, Providers } from './providers'\nimport { SystemApiMiddlewareFactory, SystemGraphQLContextFactory, SystemGraphQLHandlerFactory } from './system'\nimport { ContentQueryExecutorImpl } from './system/ContentQueryExecutor'\nimport { TenantApiMiddlewareFactory, TenantGraphQLHandlerFactory } from './tenant'\nimport {\n\tContentSchemaTransferMappingFactory,\n\tExportApiControllerFactory,\n\tExportExecutor,\n\tImportApiMiddlewareFactory,\n\tImportExecutor,\n\tSystemSchemaTransferMappingFactory,\n} from './transfer'\nimport { CryptoWrapper } from './utils/CryptoWrapper'\nimport { ApplicationWorkerManager } from './workers'\n\nexport type ProcessType =\n\t| 'singleNode'\n\t| 'clusterMaster'\n\t| 'clusterWorker'\n\nexport interface MasterContainer {\n\tinitializer: Initializer\n\tapplication: Application\n\tproviders: Providers\n\tapplicationWorkers: ApplicationWorkerManager\n\tmonitoringKoa: Koa\n}\n\nexport interface MasterContainerArgs {\n\tdebugMode: boolean\n\tserverConfig: ServerConfig\n\tprojectConfigResolver: ProjectConfigResolver\n\ttenantConfigResolver: TenantConfigResolver\n\tplugins: Plugin[]\n\tlogger: Logger\n\tversion?: string\n\tprocessType: ProcessType\n}\n\nexport type MasterContainerBuilder = ReturnType<MasterContainerFactory['createBuilderInternal']>\nexport type MasterContainerHook = (builder: MasterContainerBuilder) => MasterContainerBuilder\n\nexport class MasterContainerFactory {\n\n\tcreateBuilder(args: MasterContainerArgs): MasterContainerBuilder {\n\t\tconst builder = this.createBuilderInternal(args)\n\t\tconst hooks = args.plugins\n\t\t\t.map(it => it.getMasterContainerHook?.())\n\t\t\t.filter((it): it is MasterContainerHook => it !== undefined)\n\t\treturn hooks.reduce((acc, cb) => cb(acc), builder)\n\t}\n\n\tcreateBuilderInternal({\n\t\tserverConfig,\n\t\tdebugMode,\n\t\tplugins,\n\t\tprojectConfigResolver,\n\t\ttenantConfigResolver,\n\t\tversion,\n\t\tlogger,\n\t\tprocessType,\n\t}: MasterContainerArgs) {\n\t\treturn new Builder({})\n\t\t\t.addService('serverConfig', () =>\n\t\t\t\tserverConfig)\n\t\t\t.addService('debugMode', () =>\n\t\t\t\tdebugMode)\n\t\t\t.addService('version', () =>\n\t\t\t\tversion)\n\t\t\t.addService('processType', () =>\n\t\t\t\tprocessType)\n\t\t\t.addService('projectConfigResolver', () =>\n\t\t\t\tprojectConfigResolver)\n\t\t\t.addService('tenantConfigResolver', () =>\n\t\t\t\ttenantConfigResolver)\n\t\t\t.addService('plugins', () =>\n\t\t\t\tplugins)\n\t\t\t.addService('providers', () =>\n\t\t\t\tcreateProviders())\n\t\t\t.addService('tenantContainerFactory', ({ providers }) =>\n\t\t\t\tnew TenantContainerFactory(providers))\n\t\t\t.addService('modificationHandlerFactory', () =>\n\t\t\t\tnew ModificationHandlerFactory(ModificationHandlerFactory.defaultFactoryMap))\n\t\t\t.addService('executionContainerFactory', ({ providers }) =>\n\t\t\t\tnew ExecutionContainerFactory(providers))\n\t\t\t.addService('graphQlSchemaBuilderFactory', () =>\n\t\t\t\tnew GraphQlSchemaBuilderFactory())\n\t\t\t.addService('contentQueryExecutor', ({ executionContainerFactory, graphQlSchemaBuilderFactory }) =>\n\t\t\t\tnew ContentQueryExecutorImpl(executionContainerFactory, graphQlSchemaBuilderFactory))\n\t\t\t.addService('systemContainerFactory', ({ providers, modificationHandlerFactory, contentQueryExecutor }) =>\n\t\t\t\tnew SystemContainerFactory(providers, modificationHandlerFactory, contentQueryExecutor))\n\t\t\t.addService('contentPermissionFactory', ({}) =>\n\t\t\t\tnew PermissionFactory())\n\t\t\t.addService('databaseMetadataResolver', () =>\n\t\t\t\tnew DatabaseMetadataResolver())\n\t\t\t.addService('graphqlSchemaCache', ({ serverConfig }) =>\n\t\t\t\tnew ContentApiSpecificCache<Schema, GraphQLSchemaFactoryResult>({\n\t\t\t\t\tttlSeconds: serverConfig.contentApi?.schemaCacheTtlSeconds,\n\t\t\t\t}))\n\t\t\t.addService('graphQlSchemaFactory', ({ plugins, providers, graphqlSchemaCache, contentPermissionFactory, graphQlSchemaBuilderFactory }) => {\n\t\t\t\tconst contributors = plugins\n\t\t\t\t\t.map(it => (it.getSchemaContributor ? it.getSchemaContributor({ providers }) : null))\n\t\t\t\t\t.filter((it): it is GraphQLSchemaContributor => !!it)\n\n\t\t\t\treturn new GraphQlSchemaFactory(\n\t\t\t\t\tgraphqlSchemaCache,\n\t\t\t\t\tgraphQlSchemaBuilderFactory,\n\t\t\t\t\tcontentPermissionFactory,\n\t\t\t\t\tcontributors,\n\t\t\t\t)\n\t\t\t})\n\t\t\t.addService('projectContainerFactoryFactory', ({ plugins, providers, databaseMetadataResolver }) =>\n\t\t\t\tnew ProjectContainerFactoryFactory(plugins, providers, databaseMetadataResolver))\n\t\t\t.addService('tenantGraphQLHandlerFactory', () =>\n\t\t\t\tnew TenantGraphQLHandlerFactory())\n\t\t\t.addService('systemGraphQLHandlerFactory', ({ debugMode }) =>\n\t\t\t\tnew SystemGraphQLHandlerFactory(debugMode))\n\t\t\t.addService('logger', () =>\n\t\t\t\tlogger)\n\t\t\t.addService('projectGroupContainerFactory', ({ debugMode, providers, systemContainerFactory, tenantContainerFactory, projectContainerFactoryFactory, projectConfigResolver, tenantGraphQLHandlerFactory, systemGraphQLHandlerFactory, logger }) =>\n\t\t\t\tnew ProjectGroupContainerFactory(debugMode, providers, systemContainerFactory, tenantContainerFactory, projectContainerFactoryFactory, projectConfigResolver, tenantGraphQLHandlerFactory, systemGraphQLHandlerFactory, logger))\n\t\t\t.addService('projectGroupContainerResolver', ({ tenantConfigResolver, projectGroupContainerFactory }) =>\n\t\t\t\tnew ProjectGroupContainerResolver(tenantConfigResolver, projectGroupContainerFactory))\n\t\t\t.addService('promRegistryFactory', ({ processType, version }) =>\n\t\t\t\tnew PrometheusRegistryFactory(processType, { version }))\n\t\t\t.addService('projectGroupContainerMetricsHook', ({ projectGroupContainerResolver }) =>\n\t\t\t\tnew ProjectGroupContainerMetricsHook(projectGroupContainerResolver))\n\t\t\t.addService('promRegistry', ({ promRegistryFactory, projectGroupContainerMetricsHook }) => {\n\t\t\t\tconst registry = promRegistryFactory.create()\n\t\t\t\tprojectGroupContainerMetricsHook.register(registry)\n\t\t\t\treturn registry\n\t\t\t})\n\t\t\t.addService('projectGroupContainer', ({ tenantConfigResolver, projectGroupContainerFactory }) =>\n\t\t\t\tprojectGroupContainerFactory.create({ slug: undefined, config: tenantConfigResolver(undefined, {}) }))\n\t\t\t.addService('projectGroupResolver', ({ serverConfig, projectGroupContainerResolver }): ProjectGroupResolver => {\n\t\t\t\tconst encryptionKey = serverConfig.projectGroup?.configEncryptionKey\n\t\t\t\t\t? createSecretKey(Buffer.from(serverConfig.projectGroup?.configEncryptionKey, 'hex'))\n\t\t\t\t\t: undefined\n\t\t\t\treturn new ProjectGroupResolver(\n\t\t\t\t\tserverConfig.projectGroup?.domainMapping,\n\t\t\t\t\tserverConfig.projectGroup?.configHeader,\n\t\t\t\t\tserverConfig.projectGroup?.configEncryptionKey ? new CryptoWrapper(encryptionKey) : undefined,\n\t\t\t\t\tprojectGroupContainerResolver,\n\t\t\t\t)\n\n\t\t\t})\n\t\t\t.addService('notModifiedChecker', () =>\n\t\t\t\tnew NotModifiedChecker())\n\t\t\t.addService('contentQueryHandlerFactory', ({ debugMode }) =>\n\t\t\t\tnew ContentQueryHandlerFactory(debugMode))\n\t\t\t.addService('projectContextResolver', () =>\n\t\t\t\tnew ProjectContextResolver())\n\t\t\t.addService('contentApiMiddlewareFactory', ({ projectContextResolver, notModifiedChecker, executionContainerFactory, contentQueryHandlerFactory, graphQlSchemaFactory }) =>\n\t\t\t\tnew ContentApiControllerFactory(notModifiedChecker, executionContainerFactory, contentQueryHandlerFactory, projectContextResolver, graphQlSchemaFactory))\n\t\t\t.addService('tenantApiMiddlewareFactory', () =>\n\t\t\t\tnew TenantApiMiddlewareFactory())\n\t\t\t.addService('systemGraphQLContextFactory', () =>\n\t\t\t\tnew SystemGraphQLContextFactory())\n\t\t\t.addService('systemApiMiddlewareFactory', ({ debugMode, systemGraphQLContextFactory, projectContextResolver }) =>\n\t\t\t\tnew SystemApiMiddlewareFactory(debugMode, systemGraphQLContextFactory, projectContextResolver))\n\t\t\t.addService('contentSchemaTransferMappingFactory', () =>\n\t\t\t\tnew ContentSchemaTransferMappingFactory())\n\t\t\t.addService('systemSchemaTransferMappingFactory', () =>\n\t\t\t\tnew SystemSchemaTransferMappingFactory())\n\t\t\t.addService('importExecutor', ({ contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory, databaseMetadataResolver }) =>\n\t\t\t\tnew ImportExecutor(contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory, databaseMetadataResolver))\n\t\t\t.addService('exportExecutor', ({ contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory }) =>\n\t\t\t\tnew ExportExecutor(contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory))\n\t\t\t.addService('importApiMiddlewareFactory', ({ projectGroupResolver, importExecutor }) =>\n\t\t\t\tnew ImportApiMiddlewareFactory(projectGroupResolver, importExecutor))\n\t\t\t.addService('exportApiMiddlewareFactory', ({ projectGroupResolver, exportExecutor }) =>\n\t\t\t\tnew ExportApiControllerFactory(projectGroupResolver, exportExecutor))\n\t\t\t.addService('application', ({ projectGroupResolver, serverConfig, logger, debugMode, version, promRegistry }) => {\n\t\t\t\tconst app = new Application(\n\t\t\t\t\tprojectGroupResolver,\n\t\t\t\t\tserverConfig,\n\t\t\t\t\tdebugMode,\n\t\t\t\t\tversion,\n\t\t\t\t\tlogger,\n\t\t\t\t)\n\t\t\t\tapp.addMiddleware(createColllectHttpMetricsMiddleware(promRegistry))\n\n\t\t\t\treturn app\n\t\t\t})\n\t\t\t.setupService('application', (it, { contentApiMiddlewareFactory, tenantApiMiddlewareFactory, systemApiMiddlewareFactory, importApiMiddlewareFactory, exportApiMiddlewareFactory }) => {\n\t\t\t\tit.addRoute('content', '/content/:projectSlug/:stageSlug', contentApiMiddlewareFactory.create())\n\t\t\t\tit.addRoute('tenant', '/tenant', tenantApiMiddlewareFactory.create())\n\t\t\t\tit.addRoute('system', '/system/:projectSlug', systemApiMiddlewareFactory.create())\n\t\t\t\tit.addRoute('transfer', '/import', importApiMiddlewareFactory.create())\n\t\t\t\tit.addRoute('transfer', '/export', exportApiMiddlewareFactory.create())\n\t\t\t\tit.addRoute('misc', '/', homepageController)\n\n\t\t\t\tit.addInternalRoute('internal', '/health', () => {\n\t\t\t\t\treturn new HttpResponse(200, 'OK')\n\t\t\t\t})\n\t\t\t})\n\t\t\t.addService('initializer', ({ projectGroupContainer }) =>\n\t\t\t\tnew Initializer(projectGroupContainer))\n\t\t\t.addService('applicationWorkers', () =>\n\t\t\t\tnew ApplicationWorkerManager())\n\t\t\t.setupService('executionContainerFactory', (it, { plugins }) => {\n\t\t\t\tfor (const plugin of plugins) {\n\t\t\t\t\tif (plugin.getExecutionContainerHook) {\n\t\t\t\t\t\tit.hooks.push(plugin.getExecutionContainerHook())\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\t\t\t.addService('monitoringKoa', ({ promRegistry }) => {\n\t\t\t\tconst app = new Koa()\n\t\t\t\tapp.use(createShowMetricsMiddleware(promRegistry))\n\n\t\t\t\treturn app\n\t\t\t})\n\n\t}\n\n\tcreate(args: MasterContainerArgs): MasterContainer {\n\t\tconst container = this.createBuilder(args).build()\n\t\treturn container.pick('initializer', 'application', 'providers', 'applicationWorkers', 'monitoringKoa')\n\t}\n}\n"],"names":["Builder","createProviders","providers","TenantContainerFactory","ModificationHandlerFactory","ExecutionContainerFactory","GraphQlSchemaBuilderFactory","ContentQueryExecutorImpl","SystemContainerFactory","PermissionFactory","DatabaseMetadataResolver","serverConfig","ContentApiSpecificCache","plugins","GraphQlSchemaFactory","ProjectContainerFactoryFactory","TenantGraphQLHandlerFactory","debugMode","SystemGraphQLHandlerFactory","projectConfigResolver","logger","ProjectGroupContainerFactory","tenantConfigResolver","ProjectGroupContainerResolver","processType","version","PrometheusRegistryFactory","ProjectGroupContainerMetricsHook","createSecretKey","ProjectGroupResolver","CryptoWrapper","NotModifiedChecker","ContentQueryHandlerFactory","ProjectContextResolver","ContentApiControllerFactory","TenantApiMiddlewareFactory","SystemGraphQLContextFactory","SystemApiMiddlewareFactory","ContentSchemaTransferMappingFactory","SystemSchemaTransferMappingFactory","ImportExecutor","ExportExecutor","ImportApiMiddlewareFactory","ExportApiControllerFactory","Application","createColllectHttpMetricsMiddleware","homepageController","HttpResponse","Initializer","ApplicationWorkerManager","createShowMetricsMiddleware"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EO,MAAM,uBAAuB;AAAA,EAEnC,cAAc,MAAmD;AAC1D,UAAA,UAAU,KAAK,sBAAsB,IAAI;AAC/C,UAAM,QAAQ,KAAK,QACjB,IAAI,CAAM,OAAA,GAAG,yBAA0B,CAAA,EACvC,OAAO,CAAC,OAAkC,OAAO,MAAS;AACrD,WAAA,MAAM,OAAO,CAAC,KAAK,OAAO,GAAG,GAAG,GAAG,OAAO;AAAA,EAAA;AAAA,EAGlD,sBAAsB;AAAA,IACrB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,GACuB;AACvB,WAAO,IAAIA,IAAA,QAAQ,EAAE,EACnB,WAAW,gBAAgB,MAC3B,YAAY,EACZ,WAAW,aAAa,MACxB,SAAS,EACT,WAAW,WAAW,MACtB,OAAO,EACP,WAAW,eAAe,MAC1B,WAAW,EACX,WAAW,yBAAyB,MACpC,qBAAqB,EACrB,WAAW,wBAAwB,MACnC,oBAAoB,EACpB,WAAW,WAAW,MACtB,OAAO,EACP,WAAW,aAAa,MACxBC,UAAAA,iBAAiB,EACjB,WAAW,0BAA0B,CAAC,EAAE,WAAAC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AAE,MAAM;AACjD,WAAO,UAAU,KAAK,eAAe,eAAe,aAAa,sBAAsB,eAAe;AAAA,EAAA;AAExG;;"}
@@ -1,48 +1,47 @@
1
+ import { Builder } from "@contember/dic";
1
2
  import { SystemContainerFactory } from "@contember/engine-system-api";
2
3
  import { TenantContainerFactory } from "@contember/engine-tenant-api";
3
- import { Builder } from "@contember/dic";
4
4
  import { ModificationHandlerFactory } from "@contember/schema-migrations";
5
5
  import { Initializer } from "./bootstrap/Initializer.js";
6
- import { ProjectContainerFactoryFactory } from "./project/ProjectContainer.js";
7
- import "@contember/engine-common";
8
- import { ProjectGroupContainerFactory } from "./projectGroup/ProjectGroupContainer.js";
9
- import { ProjectGroupResolver } from "./projectGroup/ProjectGroupResolver.js";
6
+ import { DatabaseMetadataResolver } from "@contember/database";
10
7
  import { ExecutionContainerFactory, GraphQlSchemaBuilderFactory, PermissionFactory } from "@contember/engine-content-api";
11
- import { createProviders } from "./providers.js";
12
- import { TenantApiMiddlewareFactory } from "./tenant/TenantApiMiddlewareFactory.js";
13
- import { TenantGraphQLHandlerFactory } from "./tenant/TenantGraphQLHandlerFactory.js";
14
- import { SystemApiMiddlewareFactory } from "./system/SystemApiMiddlewareFactory.js";
15
- import { SystemGraphQLContextFactory } from "./system/SystemGraphQLContextFactory.js";
16
- import { SystemGraphQLHandlerFactory } from "./system/SystemGraphQLHandlerFactory.js";
8
+ import Koa from "koa";
9
+ import { createSecretKey } from "node:crypto";
10
+ import { Application } from "./application/application.js";
11
+ import { HttpResponse } from "./common/HttpResponse.js";
17
12
  import { ContentApiControllerFactory } from "./content/ContentApiControllerFactory.js";
18
- import { ContentGraphQLContextFactory } from "./content/ContentGraphQLContextFactory.js";
19
13
  import { ContentQueryHandlerFactory } from "./content/ContentQueryHandlerFactory.js";
20
14
  import "./content/ContentSchemaResolver.js";
21
15
  import { GraphQlSchemaFactory } from "./content/GraphQlSchemaFactory.js";
22
16
  import { NotModifiedChecker } from "./content/NotModifiedChecker.js";
23
17
  import "./content/ProjectMembershipResolver.js";
18
+ import { ContentApiSpecificCache } from "./content/ContentApiSpecificCache.js";
19
+ import { homepageController } from "./misc/HomepageMiddlewareFactory.js";
20
+ import { ProjectContainerFactoryFactory } from "./project/ProjectContainer.js";
21
+ import "@contember/engine-common";
24
22
  import { ProjectContextResolver } from "./project-common/ProjectContextResolver.js";
23
+ import { ProjectGroupContainerFactory } from "./projectGroup/ProjectGroupContainer.js";
24
+ import { ProjectGroupContainerResolver } from "./projectGroup/ProjectGroupContainerResolver.js";
25
+ import { ProjectGroupResolver } from "./projectGroup/ProjectGroupResolver.js";
26
+ import { createColllectHttpMetricsMiddleware } from "./prometheus/CollectHttpMetricsMiddelware.js";
27
+ import { createShowMetricsMiddleware } from "./prometheus/ShowMetricsMiddleware.js";
28
+ import { ProjectGroupContainerMetricsHook } from "./prometheus/ProjectGroupContainerMetricsHook.js";
29
+ import { PrometheusRegistryFactory } from "./prometheus/PrometheusRegistryFactory.js";
30
+ import { createProviders } from "./providers.js";
31
+ import { SystemApiMiddlewareFactory } from "./system/SystemApiMiddlewareFactory.js";
32
+ import { SystemGraphQLContextFactory } from "./system/SystemGraphQLContextFactory.js";
33
+ import { SystemGraphQLHandlerFactory } from "./system/SystemGraphQLHandlerFactory.js";
34
+ import { ContentQueryExecutorImpl } from "./system/ContentQueryExecutor.js";
35
+ import { TenantApiMiddlewareFactory } from "./tenant/TenantApiMiddlewareFactory.js";
36
+ import { TenantGraphQLHandlerFactory } from "./tenant/TenantGraphQLHandlerFactory.js";
25
37
  import { ImportApiMiddlewareFactory } from "./transfer/ImportApiMiddlewareFactory.js";
26
38
  import { ExportApiControllerFactory } from "./transfer/ExportApiControllerFactory.js";
27
39
  import { ImportExecutor } from "./transfer/ImportExecutor.js";
28
40
  import { ExportExecutor } from "./transfer/ExportExecutor.js";
29
41
  import { ContentSchemaTransferMappingFactory } from "./transfer/ContentSchemaTransferMappingFactory.js";
30
42
  import { SystemSchemaTransferMappingFactory } from "./transfer/SystemSchemaTransferMappingFactory.js";
31
- import { homepageController } from "./misc/HomepageMiddlewareFactory.js";
32
- import { Application } from "./application/application.js";
33
- import { ApplicationWorkerManager } from "./workers/ApplicationWorkerManager.js";
34
- import { HttpResponse } from "./common/HttpResponse.js";
35
- import { ContentQueryExecutorImpl } from "./system/ContentQueryExecutor.js";
36
- import { DatabaseMetadataResolver } from "@contember/database";
37
- import Koa from "koa";
38
- import { ProjectGroupContainerResolver } from "./projectGroup/ProjectGroupContainerResolver.js";
39
- import { PrometheusRegistryFactory } from "./prometheus/PrometheusRegistryFactory.js";
40
- import { ProjectGroupContainerMetricsHook } from "./prometheus/ProjectGroupContainerMetricsHook.js";
41
- import { createColllectHttpMetricsMiddleware } from "./prometheus/CollectHttpMetricsMiddelware.js";
42
- import { createShowMetricsMiddleware } from "./prometheus/ShowMetricsMiddleware.js";
43
- import { createSecretKey } from "node:crypto";
44
43
  import { CryptoWrapper } from "./utils/CryptoWrapper.js";
45
- import { ContentApiSpecificCache } from "./content/ContentApiSpecificCache.js";
44
+ import { ApplicationWorkerManager } from "./workers/ApplicationWorkerManager.js";
46
45
  class MasterContainerFactory {
47
46
  createBuilder(args) {
48
47
  const builder = this.createBuilderInternal(args);
@@ -81,7 +80,7 @@ class MasterContainerFactory {
81
80
  serverConfig2.projectGroup?.configEncryptionKey ? new CryptoWrapper(encryptionKey) : void 0,
82
81
  projectGroupContainerResolver
83
82
  );
84
- }).addService("notModifiedChecker", () => new NotModifiedChecker()).addService("contentGraphqlContextFactory", ({ providers, executionContainerFactory }) => new ContentGraphQLContextFactory(providers, executionContainerFactory)).addService("contentQueryHandlerFactory", ({ debugMode: debugMode2 }) => new ContentQueryHandlerFactory(debugMode2)).addService("projectContextResolver", () => new ProjectContextResolver()).addService("contentApiMiddlewareFactory", ({ projectContextResolver, notModifiedChecker, contentGraphqlContextFactory, contentQueryHandlerFactory, graphQlSchemaFactory }) => new ContentApiControllerFactory(notModifiedChecker, contentGraphqlContextFactory, contentQueryHandlerFactory, projectContextResolver, graphQlSchemaFactory)).addService("tenantApiMiddlewareFactory", () => new TenantApiMiddlewareFactory()).addService("systemGraphQLContextFactory", () => new SystemGraphQLContextFactory()).addService("systemApiMiddlewareFactory", ({ debugMode: debugMode2, systemGraphQLContextFactory, projectContextResolver }) => new SystemApiMiddlewareFactory(debugMode2, systemGraphQLContextFactory, projectContextResolver)).addService("contentSchemaTransferMappingFactory", () => new ContentSchemaTransferMappingFactory()).addService("systemSchemaTransferMappingFactory", () => new SystemSchemaTransferMappingFactory()).addService("importExecutor", ({ contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory, databaseMetadataResolver }) => new ImportExecutor(contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory, databaseMetadataResolver)).addService("exportExecutor", ({ contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory }) => new ExportExecutor(contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory)).addService("importApiMiddlewareFactory", ({ projectGroupResolver, importExecutor }) => new ImportApiMiddlewareFactory(projectGroupResolver, importExecutor)).addService("exportApiMiddlewareFactory", ({ projectGroupResolver, exportExecutor }) => new ExportApiControllerFactory(projectGroupResolver, exportExecutor)).addService("application", ({ projectGroupResolver, serverConfig: serverConfig2, logger: logger2, debugMode: debugMode2, version: version2, promRegistry }) => {
83
+ }).addService("notModifiedChecker", () => new NotModifiedChecker()).addService("contentQueryHandlerFactory", ({ debugMode: debugMode2 }) => new ContentQueryHandlerFactory(debugMode2)).addService("projectContextResolver", () => new ProjectContextResolver()).addService("contentApiMiddlewareFactory", ({ projectContextResolver, notModifiedChecker, executionContainerFactory, contentQueryHandlerFactory, graphQlSchemaFactory }) => new ContentApiControllerFactory(notModifiedChecker, executionContainerFactory, contentQueryHandlerFactory, projectContextResolver, graphQlSchemaFactory)).addService("tenantApiMiddlewareFactory", () => new TenantApiMiddlewareFactory()).addService("systemGraphQLContextFactory", () => new SystemGraphQLContextFactory()).addService("systemApiMiddlewareFactory", ({ debugMode: debugMode2, systemGraphQLContextFactory, projectContextResolver }) => new SystemApiMiddlewareFactory(debugMode2, systemGraphQLContextFactory, projectContextResolver)).addService("contentSchemaTransferMappingFactory", () => new ContentSchemaTransferMappingFactory()).addService("systemSchemaTransferMappingFactory", () => new SystemSchemaTransferMappingFactory()).addService("importExecutor", ({ contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory, databaseMetadataResolver }) => new ImportExecutor(contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory, databaseMetadataResolver)).addService("exportExecutor", ({ contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory }) => new ExportExecutor(contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory)).addService("importApiMiddlewareFactory", ({ projectGroupResolver, importExecutor }) => new ImportApiMiddlewareFactory(projectGroupResolver, importExecutor)).addService("exportApiMiddlewareFactory", ({ projectGroupResolver, exportExecutor }) => new ExportApiControllerFactory(projectGroupResolver, exportExecutor)).addService("application", ({ projectGroupResolver, serverConfig: serverConfig2, logger: logger2, debugMode: debugMode2, version: version2, promRegistry }) => {
85
84
  const app = new Application(
86
85
  projectGroupResolver,
87
86
  serverConfig2,
@@ -1 +1 @@
1
- {"version":3,"file":"MasterContainer.js","sources":["../../../../packages/engine-http/src/MasterContainer.ts"],"sourcesContent":["import { SystemContainerFactory } from '@contember/engine-system-api'\nimport { TenantContainerFactory } from '@contember/engine-tenant-api'\nimport { Builder } from '@contember/dic'\nimport { ServerConfig } from './config/config'\nimport { ModificationHandlerFactory } from '@contember/schema-migrations'\nimport { Initializer } from './bootstrap'\n\nimport { ProjectContainerFactoryFactory } from './project'\nimport { ProjectConfigResolver } from './config/projectConfigResolver'\nimport { TenantConfigResolver } from './config/tenantConfigResolver'\nimport { ProjectGroupContainerFactory } from './projectGroup/ProjectGroupContainer'\nimport { ProjectGroupResolver } from './projectGroup/ProjectGroupResolver'\nimport { Logger } from '@contember/logger'\nimport { ExecutionContainerFactory, GraphQlSchemaBuilderFactory, PermissionFactory } from '@contember/engine-content-api'\nimport { createProviders, Providers } from './providers'\nimport { TenantApiMiddlewareFactory, TenantGraphQLHandlerFactory } from './tenant'\nimport { SystemApiMiddlewareFactory, SystemGraphQLContextFactory, SystemGraphQLHandlerFactory } from './system'\nimport {\n\tContentApiControllerFactory, ContentGraphQLContextFactory, ContentQueryHandlerFactory, GraphQLSchemaContributor, GraphQlSchemaFactory,\n\tGraphQLSchemaFactoryResult, NotModifiedChecker,\n} from './content'\nimport { ProjectContextResolver } from './project-common'\nimport {\n\tContentSchemaTransferMappingFactory,\n\tExportApiControllerFactory,\n\tExportExecutor,\n\tImportApiMiddlewareFactory,\n\tImportExecutor,\n\tSystemSchemaTransferMappingFactory,\n} from './transfer'\nimport { homepageController } from './misc'\nimport { Plugin } from './plugin/Plugin'\nimport { Application } from './application'\nimport { ApplicationWorkerManager } from './workers'\nimport { HttpResponse } from './common'\nimport { ContentQueryExecutorImpl } from './system/ContentQueryExecutor'\nimport { DatabaseMetadataResolver } from '@contember/database'\nimport Koa from 'koa'\nimport { ProjectGroupContainerResolver } from './projectGroup/ProjectGroupContainerResolver'\nimport { PrometheusRegistryFactory } from './prometheus/PrometheusRegistryFactory'\nimport { ProjectGroupContainerMetricsHook } from './prometheus/ProjectGroupContainerMetricsHook'\nimport { createColllectHttpMetricsMiddleware, createShowMetricsMiddleware } from './prometheus'\nimport { createSecretKey } from 'node:crypto'\nimport { CryptoWrapper } from './utils/CryptoWrapper'\nimport { ContentApiSpecificCache } from './content/ContentApiSpecificCache'\nimport { Schema } from '@contember/schema'\n\nexport type ProcessType =\n\t| 'singleNode'\n\t| 'clusterMaster'\n\t| 'clusterWorker'\n\nexport interface MasterContainer {\n\tinitializer: Initializer\n\tapplication: Application\n\tproviders: Providers\n\tapplicationWorkers: ApplicationWorkerManager\n\tmonitoringKoa: Koa\n}\n\nexport interface MasterContainerArgs {\n\tdebugMode: boolean\n\tserverConfig: ServerConfig\n\tprojectConfigResolver: ProjectConfigResolver\n\ttenantConfigResolver: TenantConfigResolver\n\tplugins: Plugin[]\n\tlogger: Logger\n\tversion?: string\n\tprocessType: ProcessType\n}\n\nexport type MasterContainerBuilder = ReturnType<MasterContainerFactory['createBuilderInternal']>\nexport type MasterContainerHook = (builder: MasterContainerBuilder) => MasterContainerBuilder\n\nexport class MasterContainerFactory {\n\n\tcreateBuilder(args: MasterContainerArgs): MasterContainerBuilder {\n\t\tconst builder = this.createBuilderInternal(args)\n\t\tconst hooks = args.plugins\n\t\t\t.map(it => it.getMasterContainerHook?.())\n\t\t\t.filter((it): it is MasterContainerHook => it !== undefined)\n\t\treturn hooks.reduce((acc, cb) => cb(acc), builder)\n\t}\n\n\tcreateBuilderInternal({\n\t\tserverConfig,\n\t\tdebugMode,\n\t\tplugins,\n\t\tprojectConfigResolver,\n\t\ttenantConfigResolver,\n\t\tversion,\n\t\tlogger,\n\t\tprocessType,\n\t}: MasterContainerArgs) {\n\t\treturn new Builder({})\n\t\t\t.addService('serverConfig', () =>\n\t\t\t\tserverConfig)\n\t\t\t.addService('debugMode', () =>\n\t\t\t\tdebugMode)\n\t\t\t.addService('version', () =>\n\t\t\t\tversion)\n\t\t\t.addService('processType', () =>\n\t\t\t\tprocessType)\n\t\t\t.addService('projectConfigResolver', () =>\n\t\t\t\tprojectConfigResolver)\n\t\t\t.addService('tenantConfigResolver', () =>\n\t\t\t\ttenantConfigResolver)\n\t\t\t.addService('plugins', () =>\n\t\t\t\tplugins)\n\t\t\t.addService('providers', () =>\n\t\t\t\tcreateProviders())\n\t\t\t.addService('tenantContainerFactory', ({ providers }) =>\n\t\t\t\tnew TenantContainerFactory(providers))\n\t\t\t.addService('modificationHandlerFactory', () =>\n\t\t\t\tnew ModificationHandlerFactory(ModificationHandlerFactory.defaultFactoryMap))\n\t\t\t.addService('executionContainerFactory', ({ providers }) =>\n\t\t\t\tnew ExecutionContainerFactory(providers))\n\t\t\t.addService('graphQlSchemaBuilderFactory', () =>\n\t\t\t\tnew GraphQlSchemaBuilderFactory())\n\t\t\t.addService('contentQueryExecutor', ({ executionContainerFactory, graphQlSchemaBuilderFactory }) =>\n\t\t\t\tnew ContentQueryExecutorImpl(executionContainerFactory, graphQlSchemaBuilderFactory))\n\t\t\t.addService('systemContainerFactory', ({ providers, modificationHandlerFactory, contentQueryExecutor }) =>\n\t\t\t\tnew SystemContainerFactory(providers, modificationHandlerFactory, contentQueryExecutor))\n\t\t\t.addService('contentPermissionFactory', ({}) =>\n\t\t\t\tnew PermissionFactory())\n\t\t\t.addService('databaseMetadataResolver', () =>\n\t\t\t\tnew DatabaseMetadataResolver())\n\t\t\t.addService('graphqlSchemaCache', ({ serverConfig }) =>\n\t\t\t\tnew ContentApiSpecificCache<Schema, GraphQLSchemaFactoryResult>({\n\t\t\t\t\tttlSeconds: serverConfig.contentApi?.schemaCacheTtlSeconds,\n\t\t\t\t}))\n\t\t\t.addService('graphQlSchemaFactory', ({ plugins, providers, graphqlSchemaCache, contentPermissionFactory, graphQlSchemaBuilderFactory }) => {\n\t\t\t\tconst contributors = plugins\n\t\t\t\t\t.map(it => (it.getSchemaContributor ? it.getSchemaContributor({ providers }) : null))\n\t\t\t\t\t.filter((it): it is GraphQLSchemaContributor => !!it)\n\n\t\t\t\treturn new GraphQlSchemaFactory(\n\t\t\t\t\tgraphqlSchemaCache,\n\t\t\t\t\tgraphQlSchemaBuilderFactory,\n\t\t\t\t\tcontentPermissionFactory,\n\t\t\t\t\tcontributors,\n\t\t\t\t)\n\t\t\t})\n\t\t\t.addService('projectContainerFactoryFactory', ({ plugins, providers, databaseMetadataResolver }) =>\n\t\t\t\tnew ProjectContainerFactoryFactory(plugins, providers, databaseMetadataResolver))\n\t\t\t.addService('tenantGraphQLHandlerFactory', () =>\n\t\t\t\tnew TenantGraphQLHandlerFactory())\n\t\t\t.addService('systemGraphQLHandlerFactory', ({ debugMode }) =>\n\t\t\t\tnew SystemGraphQLHandlerFactory(debugMode))\n\t\t\t.addService('logger', () =>\n\t\t\t\tlogger)\n\t\t\t.addService('projectGroupContainerFactory', ({ debugMode, providers, systemContainerFactory, tenantContainerFactory, projectContainerFactoryFactory, projectConfigResolver, tenantGraphQLHandlerFactory, systemGraphQLHandlerFactory, logger }) =>\n\t\t\t\tnew ProjectGroupContainerFactory(debugMode, providers, systemContainerFactory, tenantContainerFactory, projectContainerFactoryFactory, projectConfigResolver, tenantGraphQLHandlerFactory, systemGraphQLHandlerFactory, logger))\n\t\t\t.addService('projectGroupContainerResolver', ({ tenantConfigResolver, projectGroupContainerFactory }) =>\n\t\t\t\tnew ProjectGroupContainerResolver(tenantConfigResolver, projectGroupContainerFactory))\n\t\t\t.addService('promRegistryFactory', ({ processType, version }) =>\n\t\t\t\tnew PrometheusRegistryFactory(processType, { version }))\n\t\t\t.addService('projectGroupContainerMetricsHook', ({ projectGroupContainerResolver }) =>\n\t\t\t\tnew ProjectGroupContainerMetricsHook(projectGroupContainerResolver))\n\t\t\t.addService('promRegistry', ({ promRegistryFactory, projectGroupContainerMetricsHook }) => {\n\t\t\t\tconst registry = promRegistryFactory.create()\n\t\t\t\tprojectGroupContainerMetricsHook.register(registry)\n\t\t\t\treturn registry\n\t\t\t})\n\t\t\t.addService('projectGroupContainer', ({ tenantConfigResolver, projectGroupContainerFactory }) =>\n\t\t\t\tprojectGroupContainerFactory.create({ slug: undefined, config: tenantConfigResolver(undefined, {}) }))\n\t\t\t.addService('projectGroupResolver', ({ serverConfig, projectGroupContainerResolver }): ProjectGroupResolver => {\n\t\t\t\tconst encryptionKey = serverConfig.projectGroup?.configEncryptionKey\n\t\t\t\t\t? createSecretKey(Buffer.from(serverConfig.projectGroup?.configEncryptionKey, 'hex'))\n\t\t\t\t\t: undefined\n\t\t\t\treturn new ProjectGroupResolver(\n\t\t\t\t\tserverConfig.projectGroup?.domainMapping,\n\t\t\t\t\tserverConfig.projectGroup?.configHeader,\n\t\t\t\t\tserverConfig.projectGroup?.configEncryptionKey ? new CryptoWrapper(encryptionKey) : undefined,\n\t\t\t\t\tprojectGroupContainerResolver,\n\t\t\t\t)\n\n\t\t\t})\n\t\t\t.addService('notModifiedChecker', () =>\n\t\t\t\tnew NotModifiedChecker())\n\t\t\t.addService('contentGraphqlContextFactory', ({ providers, executionContainerFactory }) =>\n\t\t\t\tnew ContentGraphQLContextFactory(providers, executionContainerFactory))\n\t\t\t.addService('contentQueryHandlerFactory', ({ debugMode }) =>\n\t\t\t\tnew ContentQueryHandlerFactory(debugMode))\n\t\t\t.addService('projectContextResolver', () =>\n\t\t\t\tnew ProjectContextResolver())\n\t\t\t.addService('contentApiMiddlewareFactory', ({ projectContextResolver, notModifiedChecker, contentGraphqlContextFactory, contentQueryHandlerFactory, graphQlSchemaFactory }) =>\n\t\t\t\tnew ContentApiControllerFactory(notModifiedChecker, contentGraphqlContextFactory, contentQueryHandlerFactory, projectContextResolver, graphQlSchemaFactory))\n\t\t\t.addService('tenantApiMiddlewareFactory', () =>\n\t\t\t\tnew TenantApiMiddlewareFactory())\n\t\t\t.addService('systemGraphQLContextFactory', () =>\n\t\t\t\tnew SystemGraphQLContextFactory())\n\t\t\t.addService('systemApiMiddlewareFactory', ({ debugMode, systemGraphQLContextFactory, projectContextResolver }) =>\n\t\t\t\tnew SystemApiMiddlewareFactory(debugMode, systemGraphQLContextFactory, projectContextResolver))\n\t\t\t.addService('contentSchemaTransferMappingFactory', () =>\n\t\t\t\tnew ContentSchemaTransferMappingFactory())\n\t\t\t.addService('systemSchemaTransferMappingFactory', () =>\n\t\t\t\tnew SystemSchemaTransferMappingFactory())\n\t\t\t.addService('importExecutor', ({ contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory, databaseMetadataResolver }) =>\n\t\t\t\tnew ImportExecutor(contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory, databaseMetadataResolver))\n\t\t\t.addService('exportExecutor', ({ contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory }) =>\n\t\t\t\tnew ExportExecutor(contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory))\n\t\t\t.addService('importApiMiddlewareFactory', ({ projectGroupResolver, importExecutor }) =>\n\t\t\t\tnew ImportApiMiddlewareFactory(projectGroupResolver, importExecutor))\n\t\t\t.addService('exportApiMiddlewareFactory', ({ projectGroupResolver, exportExecutor }) =>\n\t\t\t\tnew ExportApiControllerFactory(projectGroupResolver, exportExecutor))\n\t\t\t.addService('application', ({ projectGroupResolver, serverConfig, logger, debugMode, version, promRegistry }) => {\n\t\t\t\tconst app = new Application(\n\t\t\t\t\tprojectGroupResolver,\n\t\t\t\t\tserverConfig,\n\t\t\t\t\tdebugMode,\n\t\t\t\t\tversion,\n\t\t\t\t\tlogger,\n\t\t\t\t)\n\t\t\t\tapp.addMiddleware(createColllectHttpMetricsMiddleware(promRegistry))\n\n\t\t\t\treturn app\n\t\t\t})\n\t\t\t.setupService('application', (it, { contentApiMiddlewareFactory, tenantApiMiddlewareFactory, systemApiMiddlewareFactory, importApiMiddlewareFactory, exportApiMiddlewareFactory }) => {\n\t\t\t\tit.addRoute('content', '/content/:projectSlug/:stageSlug', contentApiMiddlewareFactory.create())\n\t\t\t\tit.addRoute('tenant', '/tenant', tenantApiMiddlewareFactory.create())\n\t\t\t\tit.addRoute('system', '/system/:projectSlug', systemApiMiddlewareFactory.create())\n\t\t\t\tit.addRoute('transfer', '/import', importApiMiddlewareFactory.create())\n\t\t\t\tit.addRoute('transfer', '/export', exportApiMiddlewareFactory.create())\n\t\t\t\tit.addRoute('misc', '/', homepageController)\n\n\t\t\t\tit.addInternalRoute('internal', '/health', () => {\n\t\t\t\t\treturn new HttpResponse(200, 'OK')\n\t\t\t\t})\n\t\t\t})\n\t\t\t.addService('initializer', ({ projectGroupContainer }) =>\n\t\t\t\tnew Initializer(projectGroupContainer))\n\t\t\t.addService('applicationWorkers', () =>\n\t\t\t\tnew ApplicationWorkerManager())\n\t\t\t.setupService('executionContainerFactory', (it, { plugins }) => {\n\t\t\t\tfor (const plugin of plugins) {\n\t\t\t\t\tif (plugin.getExecutionContainerHook) {\n\t\t\t\t\t\tit.hooks.push(plugin.getExecutionContainerHook())\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\t\t\t.addService('monitoringKoa', ({ promRegistry }) => {\n\t\t\t\tconst app = new Koa()\n\t\t\t\tapp.use(createShowMetricsMiddleware(promRegistry))\n\n\t\t\t\treturn app\n\t\t\t})\n\n\t}\n\n\tcreate(args: MasterContainerArgs): MasterContainer {\n\t\tconst container = this.createBuilder(args).build()\n\t\treturn container.pick('initializer', 'application', 'providers', 'applicationWorkers', 'monitoringKoa')\n\t}\n}\n"],"names":["serverConfig","plugins","debugMode","projectConfigResolver","logger","tenantConfigResolver","processType","version"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0EO,MAAM,uBAAuB;AAAA,EAEnC,cAAc,MAAmD;AAC1D,UAAA,UAAU,KAAK,sBAAsB,IAAI;AAC/C,UAAM,QAAQ,KAAK,QACjB,IAAI,CAAM,OAAA,GAAG,yBAA0B,CAAA,EACvC,OAAO,CAAC,OAAkC,OAAO,MAAS;AACrD,WAAA,MAAM,OAAO,CAAC,KAAK,OAAO,GAAG,GAAG,GAAG,OAAO;AAAA,EAAA;AAAA,EAGlD,sBAAsB;AAAA,IACrB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,GACuB;AACvB,WAAO,IAAI,QAAQ,EAAE,EACnB,WAAW,gBAAgB,MAC3B,YAAY,EACZ,WAAW,aAAa,MACxB,SAAS,EACT,WAAW,WAAW,MACtB,OAAO,EACP,WAAW,eAAe,MAC1B,WAAW,EACX,WAAW,yBAAyB,MACpC,qBAAqB,EACrB,WAAW,wBAAwB,MACnC,oBAAoB,EACpB,WAAW,WAAW,MACtB,OAAO,EACP,WAAW,aAAa,MACxB,iBAAiB,EACjB,WAAW,0BAA0B,CAAC,EAAE,gBACxC,IAAI,uBAAuB,SAAS,CAAC,EACrC,WAAW,8BAA8B,MACzC,IAAI,2BAA2B,2BA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BAA4B,QAAQ;AAC/F,SAAG,SAAS,UAAU,WAAW,2BAA2B,QAAQ;AACpE,SAAG,SAAS,UAAU,wBAAwB,2BAA2B,QAAQ;AACjF,SAAG,SAAS,YAAY,WAAW,2BAA2B,QAAQ;AACtE,SAAG,SAAS,YAAY,WAAW,2BAA2B,QAAQ;AACnE,SAAA,SAAS,QAAQ,KAAK,kBAAkB;AAExC,SAAA,iBAAiB,YAAY,WAAW,MAAM;AACzC,eAAA,IAAI,aAAa,KAAK,IAAI;AAAA,MAAA,CACjC;AAAA,IAAA,CACD,EACA,WAAW,eAAe,CAAC,EAAE,sBAC7B,MAAA,IAAI,YAAY,qBAAqB,CAAC,EACtC,WAAW,sBAAsB,MACjC,IAAI,0BAA0B,EAC9B,aAAa,6BAA6B,CAAC,IAAI,EAAE,SAAAH,eAAc;AAC/D,iBAAW,UAAUA,UAAS;AAC7B,YAAI,OAAO,2BAA2B;AACrC,aAAG,MAAM,KAAK,OAAO,0BAAA,CAA2B;AAAA,QAAA;AAAA,MACjD;AAAA,IAED,CAAA,EACA,WAAW,iBAAiB,CAAC,EAAE,mBAAmB;AAC5C,YAAA,MAAM,IAAI,IAAI;AAChB,UAAA,IAAI,4BAA4B,YAAY,CAAC;AAE1C,aAAA;AAAA,IAAA,CACP;AAAA,EAAA;AAAA,EAIH,OAAO,MAA4C;AAClD,UAAM,YAAY,KAAK,cAAc,IAAI,EAAE,MAAM;AACjD,WAAO,UAAU,KAAK,eAAe,eAAe,aAAa,sBAAsB,eAAe;AAAA,EAAA;AAExG;"}
1
+ {"version":3,"file":"MasterContainer.js","sources":["../../../../packages/engine-http/src/MasterContainer.ts"],"sourcesContent":["import { Builder } from '@contember/dic'\nimport { SystemContainerFactory } from '@contember/engine-system-api'\nimport { TenantContainerFactory } from '@contember/engine-tenant-api'\nimport { ModificationHandlerFactory } from '@contember/schema-migrations'\nimport { Initializer } from './bootstrap'\nimport { ServerConfig } from './config/config'\n\nimport { DatabaseMetadataResolver } from '@contember/database'\nimport { ExecutionContainerFactory, GraphQlSchemaBuilderFactory, PermissionFactory } from '@contember/engine-content-api'\nimport { Logger } from '@contember/logger'\nimport { Schema } from '@contember/schema'\nimport Koa from 'koa'\nimport { createSecretKey } from 'node:crypto'\nimport { Application } from './application'\nimport { HttpResponse } from './common'\nimport { ProjectConfigResolver } from './config/projectConfigResolver'\nimport { TenantConfigResolver } from './config/tenantConfigResolver'\nimport {\n\tContentApiControllerFactory,\n\tContentQueryHandlerFactory, GraphQLSchemaContributor, GraphQlSchemaFactory,\n\tGraphQLSchemaFactoryResult, NotModifiedChecker,\n} from './content'\nimport { ContentApiSpecificCache } from './content/ContentApiSpecificCache'\nimport { homepageController } from './misc'\nimport { Plugin } from './plugin/Plugin'\nimport { ProjectContainerFactoryFactory } from './project'\nimport { ProjectContextResolver } from './project-common'\nimport { ProjectGroupContainerFactory } from './projectGroup/ProjectGroupContainer'\nimport { ProjectGroupContainerResolver } from './projectGroup/ProjectGroupContainerResolver'\nimport { ProjectGroupResolver } from './projectGroup/ProjectGroupResolver'\nimport { createColllectHttpMetricsMiddleware, createShowMetricsMiddleware } from './prometheus'\nimport { ProjectGroupContainerMetricsHook } from './prometheus/ProjectGroupContainerMetricsHook'\nimport { PrometheusRegistryFactory } from './prometheus/PrometheusRegistryFactory'\nimport { createProviders, Providers } from './providers'\nimport { SystemApiMiddlewareFactory, SystemGraphQLContextFactory, SystemGraphQLHandlerFactory } from './system'\nimport { ContentQueryExecutorImpl } from './system/ContentQueryExecutor'\nimport { TenantApiMiddlewareFactory, TenantGraphQLHandlerFactory } from './tenant'\nimport {\n\tContentSchemaTransferMappingFactory,\n\tExportApiControllerFactory,\n\tExportExecutor,\n\tImportApiMiddlewareFactory,\n\tImportExecutor,\n\tSystemSchemaTransferMappingFactory,\n} from './transfer'\nimport { CryptoWrapper } from './utils/CryptoWrapper'\nimport { ApplicationWorkerManager } from './workers'\n\nexport type ProcessType =\n\t| 'singleNode'\n\t| 'clusterMaster'\n\t| 'clusterWorker'\n\nexport interface MasterContainer {\n\tinitializer: Initializer\n\tapplication: Application\n\tproviders: Providers\n\tapplicationWorkers: ApplicationWorkerManager\n\tmonitoringKoa: Koa\n}\n\nexport interface MasterContainerArgs {\n\tdebugMode: boolean\n\tserverConfig: ServerConfig\n\tprojectConfigResolver: ProjectConfigResolver\n\ttenantConfigResolver: TenantConfigResolver\n\tplugins: Plugin[]\n\tlogger: Logger\n\tversion?: string\n\tprocessType: ProcessType\n}\n\nexport type MasterContainerBuilder = ReturnType<MasterContainerFactory['createBuilderInternal']>\nexport type MasterContainerHook = (builder: MasterContainerBuilder) => MasterContainerBuilder\n\nexport class MasterContainerFactory {\n\n\tcreateBuilder(args: MasterContainerArgs): MasterContainerBuilder {\n\t\tconst builder = this.createBuilderInternal(args)\n\t\tconst hooks = args.plugins\n\t\t\t.map(it => it.getMasterContainerHook?.())\n\t\t\t.filter((it): it is MasterContainerHook => it !== undefined)\n\t\treturn hooks.reduce((acc, cb) => cb(acc), builder)\n\t}\n\n\tcreateBuilderInternal({\n\t\tserverConfig,\n\t\tdebugMode,\n\t\tplugins,\n\t\tprojectConfigResolver,\n\t\ttenantConfigResolver,\n\t\tversion,\n\t\tlogger,\n\t\tprocessType,\n\t}: MasterContainerArgs) {\n\t\treturn new Builder({})\n\t\t\t.addService('serverConfig', () =>\n\t\t\t\tserverConfig)\n\t\t\t.addService('debugMode', () =>\n\t\t\t\tdebugMode)\n\t\t\t.addService('version', () =>\n\t\t\t\tversion)\n\t\t\t.addService('processType', () =>\n\t\t\t\tprocessType)\n\t\t\t.addService('projectConfigResolver', () =>\n\t\t\t\tprojectConfigResolver)\n\t\t\t.addService('tenantConfigResolver', () =>\n\t\t\t\ttenantConfigResolver)\n\t\t\t.addService('plugins', () =>\n\t\t\t\tplugins)\n\t\t\t.addService('providers', () =>\n\t\t\t\tcreateProviders())\n\t\t\t.addService('tenantContainerFactory', ({ providers }) =>\n\t\t\t\tnew TenantContainerFactory(providers))\n\t\t\t.addService('modificationHandlerFactory', () =>\n\t\t\t\tnew ModificationHandlerFactory(ModificationHandlerFactory.defaultFactoryMap))\n\t\t\t.addService('executionContainerFactory', ({ providers }) =>\n\t\t\t\tnew ExecutionContainerFactory(providers))\n\t\t\t.addService('graphQlSchemaBuilderFactory', () =>\n\t\t\t\tnew GraphQlSchemaBuilderFactory())\n\t\t\t.addService('contentQueryExecutor', ({ executionContainerFactory, graphQlSchemaBuilderFactory }) =>\n\t\t\t\tnew ContentQueryExecutorImpl(executionContainerFactory, graphQlSchemaBuilderFactory))\n\t\t\t.addService('systemContainerFactory', ({ providers, modificationHandlerFactory, contentQueryExecutor }) =>\n\t\t\t\tnew SystemContainerFactory(providers, modificationHandlerFactory, contentQueryExecutor))\n\t\t\t.addService('contentPermissionFactory', ({}) =>\n\t\t\t\tnew PermissionFactory())\n\t\t\t.addService('databaseMetadataResolver', () =>\n\t\t\t\tnew DatabaseMetadataResolver())\n\t\t\t.addService('graphqlSchemaCache', ({ serverConfig }) =>\n\t\t\t\tnew ContentApiSpecificCache<Schema, GraphQLSchemaFactoryResult>({\n\t\t\t\t\tttlSeconds: serverConfig.contentApi?.schemaCacheTtlSeconds,\n\t\t\t\t}))\n\t\t\t.addService('graphQlSchemaFactory', ({ plugins, providers, graphqlSchemaCache, contentPermissionFactory, graphQlSchemaBuilderFactory }) => {\n\t\t\t\tconst contributors = plugins\n\t\t\t\t\t.map(it => (it.getSchemaContributor ? it.getSchemaContributor({ providers }) : null))\n\t\t\t\t\t.filter((it): it is GraphQLSchemaContributor => !!it)\n\n\t\t\t\treturn new GraphQlSchemaFactory(\n\t\t\t\t\tgraphqlSchemaCache,\n\t\t\t\t\tgraphQlSchemaBuilderFactory,\n\t\t\t\t\tcontentPermissionFactory,\n\t\t\t\t\tcontributors,\n\t\t\t\t)\n\t\t\t})\n\t\t\t.addService('projectContainerFactoryFactory', ({ plugins, providers, databaseMetadataResolver }) =>\n\t\t\t\tnew ProjectContainerFactoryFactory(plugins, providers, databaseMetadataResolver))\n\t\t\t.addService('tenantGraphQLHandlerFactory', () =>\n\t\t\t\tnew TenantGraphQLHandlerFactory())\n\t\t\t.addService('systemGraphQLHandlerFactory', ({ debugMode }) =>\n\t\t\t\tnew SystemGraphQLHandlerFactory(debugMode))\n\t\t\t.addService('logger', () =>\n\t\t\t\tlogger)\n\t\t\t.addService('projectGroupContainerFactory', ({ debugMode, providers, systemContainerFactory, tenantContainerFactory, projectContainerFactoryFactory, projectConfigResolver, tenantGraphQLHandlerFactory, systemGraphQLHandlerFactory, logger }) =>\n\t\t\t\tnew ProjectGroupContainerFactory(debugMode, providers, systemContainerFactory, tenantContainerFactory, projectContainerFactoryFactory, projectConfigResolver, tenantGraphQLHandlerFactory, systemGraphQLHandlerFactory, logger))\n\t\t\t.addService('projectGroupContainerResolver', ({ tenantConfigResolver, projectGroupContainerFactory }) =>\n\t\t\t\tnew ProjectGroupContainerResolver(tenantConfigResolver, projectGroupContainerFactory))\n\t\t\t.addService('promRegistryFactory', ({ processType, version }) =>\n\t\t\t\tnew PrometheusRegistryFactory(processType, { version }))\n\t\t\t.addService('projectGroupContainerMetricsHook', ({ projectGroupContainerResolver }) =>\n\t\t\t\tnew ProjectGroupContainerMetricsHook(projectGroupContainerResolver))\n\t\t\t.addService('promRegistry', ({ promRegistryFactory, projectGroupContainerMetricsHook }) => {\n\t\t\t\tconst registry = promRegistryFactory.create()\n\t\t\t\tprojectGroupContainerMetricsHook.register(registry)\n\t\t\t\treturn registry\n\t\t\t})\n\t\t\t.addService('projectGroupContainer', ({ tenantConfigResolver, projectGroupContainerFactory }) =>\n\t\t\t\tprojectGroupContainerFactory.create({ slug: undefined, config: tenantConfigResolver(undefined, {}) }))\n\t\t\t.addService('projectGroupResolver', ({ serverConfig, projectGroupContainerResolver }): ProjectGroupResolver => {\n\t\t\t\tconst encryptionKey = serverConfig.projectGroup?.configEncryptionKey\n\t\t\t\t\t? createSecretKey(Buffer.from(serverConfig.projectGroup?.configEncryptionKey, 'hex'))\n\t\t\t\t\t: undefined\n\t\t\t\treturn new ProjectGroupResolver(\n\t\t\t\t\tserverConfig.projectGroup?.domainMapping,\n\t\t\t\t\tserverConfig.projectGroup?.configHeader,\n\t\t\t\t\tserverConfig.projectGroup?.configEncryptionKey ? new CryptoWrapper(encryptionKey) : undefined,\n\t\t\t\t\tprojectGroupContainerResolver,\n\t\t\t\t)\n\n\t\t\t})\n\t\t\t.addService('notModifiedChecker', () =>\n\t\t\t\tnew NotModifiedChecker())\n\t\t\t.addService('contentQueryHandlerFactory', ({ debugMode }) =>\n\t\t\t\tnew ContentQueryHandlerFactory(debugMode))\n\t\t\t.addService('projectContextResolver', () =>\n\t\t\t\tnew ProjectContextResolver())\n\t\t\t.addService('contentApiMiddlewareFactory', ({ projectContextResolver, notModifiedChecker, executionContainerFactory, contentQueryHandlerFactory, graphQlSchemaFactory }) =>\n\t\t\t\tnew ContentApiControllerFactory(notModifiedChecker, executionContainerFactory, contentQueryHandlerFactory, projectContextResolver, graphQlSchemaFactory))\n\t\t\t.addService('tenantApiMiddlewareFactory', () =>\n\t\t\t\tnew TenantApiMiddlewareFactory())\n\t\t\t.addService('systemGraphQLContextFactory', () =>\n\t\t\t\tnew SystemGraphQLContextFactory())\n\t\t\t.addService('systemApiMiddlewareFactory', ({ debugMode, systemGraphQLContextFactory, projectContextResolver }) =>\n\t\t\t\tnew SystemApiMiddlewareFactory(debugMode, systemGraphQLContextFactory, projectContextResolver))\n\t\t\t.addService('contentSchemaTransferMappingFactory', () =>\n\t\t\t\tnew ContentSchemaTransferMappingFactory())\n\t\t\t.addService('systemSchemaTransferMappingFactory', () =>\n\t\t\t\tnew SystemSchemaTransferMappingFactory())\n\t\t\t.addService('importExecutor', ({ contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory, databaseMetadataResolver }) =>\n\t\t\t\tnew ImportExecutor(contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory, databaseMetadataResolver))\n\t\t\t.addService('exportExecutor', ({ contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory }) =>\n\t\t\t\tnew ExportExecutor(contentSchemaTransferMappingFactory, systemSchemaTransferMappingFactory))\n\t\t\t.addService('importApiMiddlewareFactory', ({ projectGroupResolver, importExecutor }) =>\n\t\t\t\tnew ImportApiMiddlewareFactory(projectGroupResolver, importExecutor))\n\t\t\t.addService('exportApiMiddlewareFactory', ({ projectGroupResolver, exportExecutor }) =>\n\t\t\t\tnew ExportApiControllerFactory(projectGroupResolver, exportExecutor))\n\t\t\t.addService('application', ({ projectGroupResolver, serverConfig, logger, debugMode, version, promRegistry }) => {\n\t\t\t\tconst app = new Application(\n\t\t\t\t\tprojectGroupResolver,\n\t\t\t\t\tserverConfig,\n\t\t\t\t\tdebugMode,\n\t\t\t\t\tversion,\n\t\t\t\t\tlogger,\n\t\t\t\t)\n\t\t\t\tapp.addMiddleware(createColllectHttpMetricsMiddleware(promRegistry))\n\n\t\t\t\treturn app\n\t\t\t})\n\t\t\t.setupService('application', (it, { contentApiMiddlewareFactory, tenantApiMiddlewareFactory, systemApiMiddlewareFactory, importApiMiddlewareFactory, exportApiMiddlewareFactory }) => {\n\t\t\t\tit.addRoute('content', '/content/:projectSlug/:stageSlug', contentApiMiddlewareFactory.create())\n\t\t\t\tit.addRoute('tenant', '/tenant', tenantApiMiddlewareFactory.create())\n\t\t\t\tit.addRoute('system', '/system/:projectSlug', systemApiMiddlewareFactory.create())\n\t\t\t\tit.addRoute('transfer', '/import', importApiMiddlewareFactory.create())\n\t\t\t\tit.addRoute('transfer', '/export', exportApiMiddlewareFactory.create())\n\t\t\t\tit.addRoute('misc', '/', homepageController)\n\n\t\t\t\tit.addInternalRoute('internal', '/health', () => {\n\t\t\t\t\treturn new HttpResponse(200, 'OK')\n\t\t\t\t})\n\t\t\t})\n\t\t\t.addService('initializer', ({ projectGroupContainer }) =>\n\t\t\t\tnew Initializer(projectGroupContainer))\n\t\t\t.addService('applicationWorkers', () =>\n\t\t\t\tnew ApplicationWorkerManager())\n\t\t\t.setupService('executionContainerFactory', (it, { plugins }) => {\n\t\t\t\tfor (const plugin of plugins) {\n\t\t\t\t\tif (plugin.getExecutionContainerHook) {\n\t\t\t\t\t\tit.hooks.push(plugin.getExecutionContainerHook())\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\t\t\t.addService('monitoringKoa', ({ promRegistry }) => {\n\t\t\t\tconst app = new Koa()\n\t\t\t\tapp.use(createShowMetricsMiddleware(promRegistry))\n\n\t\t\t\treturn app\n\t\t\t})\n\n\t}\n\n\tcreate(args: MasterContainerArgs): MasterContainer {\n\t\tconst container = this.createBuilder(args).build()\n\t\treturn container.pick('initializer', 'application', 'providers', 'applicationWorkers', 'monitoringKoa')\n\t}\n}\n"],"names":["serverConfig","plugins","debugMode","projectConfigResolver","logger","tenantConfigResolver","processType","version"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EO,MAAM,uBAAuB;AAAA,EAEnC,cAAc,MAAmD;AAC1D,UAAA,UAAU,KAAK,sBAAsB,IAAI;AAC/C,UAAM,QAAQ,KAAK,QACjB,IAAI,CAAM,OAAA,GAAG,yBAA0B,CAAA,EACvC,OAAO,CAAC,OAAkC,OAAO,MAAS;AACrD,WAAA,MAAM,OAAO,CAAC,KAAK,OAAO,GAAG,GAAG,GAAG,OAAO;AAAA,EAAA;AAAA,EAGlD,sBAAsB;AAAA,IACrB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,GACuB;AACvB,WAAO,IAAI,QAAQ,EAAE,EACnB,WAAW,gBAAgB,MAC3B,YAAY,EACZ,WAAW,aAAa,MACxB,SAAS,EACT,WAAW,WAAW,MACtB,OAAO,EACP,WAAW,eAAe,MAC1B,WAAW,EACX,WAAW,yBAAyB,MACpC,qBAAqB,EACrB,WAAW,wBAAwB,MACnC,oBAAoB,EACpB,WAAW,WAAW,MACtB,OAAO,EACP,WAAW,aAAa,MACx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,iCAAiC;AACrL,SAAG,SAAS,WAAW,oCAAoC,4BAA4B,QAAQ;AAC/F,SAAG,SAAS,UAAU,WAAW,2BAA2B,QAAQ;AACpE,SAAG,SAAS,UAAU,wBAAwB,2BAA2B,QAAQ;AACjF,SAAG,SAAS,YAAY,WAAW,2BAA2B,QAAQ;AACtE,SAAG,SAAS,YAAY,WAAW,2BAA2B,QAAQ;AACnE,SAAA,SAAS,QAAQ,KAAK,kBAAkB;AAExC,SAAA,iBAAiB,YAAY,WAAW,MAAM;AACzC,eAAA,IAAI,aAAa,KAAK,IAAI;AAAA,MAAA,CACjC;AAAA,IAAA,CACD,EACA,WAAW,eAAe,CAAC,EAAE,sBAC7B,MAAA,IAAI,YAAY,qBAAqB,CAAC,EACtC,WAAW,sBAAsB,MACjC,IAAI,0BAA0B,EAC9B,aAAa,6BAA6B,CAAC,IAAI,EAAE,SAAAH,eAAc;AAC/D,iBAAW,UAAUA,UAAS;AAC7B,YAAI,OAAO,2BAA2B;AACrC,aAAG,MAAM,KAAK,OAAO,0BAAA,CAA2B;AAAA,QAAA;AAAA,MACjD;AAAA,IAED,CAAA,EACA,WAAW,iBAAiB,CAAC,EAAE,mBAAmB;AAC5C,YAAA,MAAM,IAAI,IAAI;AAChB,UAAA,IAAI,4BAA4B,YAAY,CAAC;AAE1C,aAAA;AAAA,IAAA,CACP;AAAA,EAAA;AAAA,EAIH,OAAO,MAA4C;AAClD,UAAM,YAAY,KAAK,cAAc,IAAI,EAAE,MAAM;AACjD,WAAO,UAAU,KAAK,eAAe,eAAe,aAAa,sBAAsB,eAAe;AAAA,EAAA;AAExG;"}
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const HttpResponse = require("../common/HttpResponse.cjs");
3
+ const engineContentApi = require("@contember/engine-content-api");
4
4
  const engineSystemApi = require("@contember/engine-system-api");
5
+ const HttpResponse = require("../common/HttpResponse.cjs");
5
6
  const debugHeader = "x-contember-debug";
6
7
  class ContentApiControllerFactory {
7
- constructor(notModifiedChecker, contentGraphqlContextFactory, handlerFactory, projectContextResolver, graphQlSchemaFactory) {
8
+ constructor(notModifiedChecker, executionContainerFactory, handlerFactory, projectContextResolver, graphQlSchemaFactory) {
8
9
  this.notModifiedChecker = notModifiedChecker;
9
- this.contentGraphqlContextFactory = contentGraphqlContextFactory;
10
+ this.executionContainerFactory = executionContainerFactory;
10
11
  this.handlerFactory = handlerFactory;
11
12
  this.projectContextResolver = projectContextResolver;
12
13
  this.graphQlSchemaFactory = graphQlSchemaFactory;
@@ -14,7 +15,7 @@ class ContentApiControllerFactory {
14
15
  create() {
15
16
  const handlerCache = /* @__PURE__ */ new WeakMap();
16
17
  return async (context) => {
17
- const { params, timer, projectGroup, authResult, request, koa } = context;
18
+ const { params, timer, projectGroup, authResult, request, koa, clientIp } = context;
18
19
  if (!authResult) {
19
20
  return new HttpResponse.HttpErrorResponse(401, "Authentication required");
20
21
  }
@@ -89,20 +90,36 @@ class ContentApiControllerFactory {
89
90
  };
90
91
  const connection = operation === "query" ? projectContainer.readConnection : projectContainer.connection;
91
92
  const contentDatabase = connection.createClient(stage.schema, { module: "content" });
92
- return this.contentGraphqlContextFactory.create({
93
+ const identityVariables = engineContentApi.createAclVariables(schema.acl, memberships);
94
+ let identityId = authResult.identityId;
95
+ if (authResult.assumedIdentityId && memberships.some((it) => schema.acl.roles[it.role].system?.assumeIdentity)) {
96
+ identityId = authResult.assumedIdentityId;
97
+ }
98
+ const executionContainer = this.executionContainerFactory.create({
93
99
  db: contentDatabase,
94
- authResult,
95
- memberships,
96
- permissions,
97
- schemaDatabaseMetadata,
100
+ identityVariables,
101
+ identityId,
98
102
  schema,
99
103
  schemaMeta: { id: schemaWithMeta.meta.id },
100
- timer,
101
- requestDebug,
104
+ schemaDatabaseMetadata,
105
+ permissions,
102
106
  systemSchema: projectContainer.systemDatabaseContextFactory.schemaName,
103
107
  stage,
104
- project
108
+ project,
109
+ userInfo: {
110
+ ipAddress: clientIp,
111
+ userAgent: koa.request.headers["user-agent"] ?? null
112
+ }
105
113
  });
114
+ return {
115
+ db: contentDatabase,
116
+ identityVariables,
117
+ identityId,
118
+ executionContainer,
119
+ timer,
120
+ requestDebug,
121
+ project
122
+ };
106
123
  }
107
124
  }));
108
125
  logger2.debug("Content query finished");
@@ -1 +1 @@
1
- {"version":3,"file":"ContentApiControllerFactory.cjs","sources":["../../../../../packages/engine-http/src/content/ContentApiControllerFactory.ts"],"sourcesContent":["import { HttpController } from '../application'\nimport { ProjectContextResolver } from '../project-common'\nimport { HttpErrorResponse, HttpResponse } from '../common'\nimport { StageBySlugQuery } from '@contember/engine-system-api'\nimport { NotModifiedChecker } from './NotModifiedChecker'\nimport { ContentGraphQLContextFactory } from './ContentGraphQLContextFactory'\nimport { ContentQueryHandler, ContentQueryHandlerFactory } from './ContentQueryHandlerFactory'\nimport { GraphQLSchema } from 'graphql'\nimport { GraphQLKoaState } from '../graphql'\nimport { GraphQlSchemaFactory } from './GraphQlSchemaFactory'\n\nconst debugHeader = 'x-contember-debug'\n\nexport class ContentApiControllerFactory {\n\tconstructor(\n\t\tprivate readonly notModifiedChecker: NotModifiedChecker,\n\t\tprivate readonly contentGraphqlContextFactory: ContentGraphQLContextFactory,\n\t\tprivate readonly handlerFactory: ContentQueryHandlerFactory,\n\t\tprivate readonly projectContextResolver: ProjectContextResolver,\n\t\tprivate readonly graphQlSchemaFactory: GraphQlSchemaFactory,\n\t) {\n\t}\n\n\tcreate(): HttpController {\n\t\tconst handlerCache = new WeakMap<GraphQLSchema, ContentQueryHandler>()\n\t\treturn async context => {\n\t\t\tconst { params, timer, projectGroup, authResult, request, koa } = context\n\t\t\tif (!authResult) {\n\t\t\t\treturn new HttpErrorResponse(401, 'Authentication required')\n\t\t\t}\n\t\t\tconst { projectContainer, project } = await this.projectContextResolver.resolve(context)\n\n\t\t\tconst logger = context.logger.child({\n\t\t\t\tproject: project.slug,\n\t\t\t})\n\n\t\t\tconst systemDatabase = projectContainer.systemReadDatabaseContext\n\t\t\tconst stage = await systemDatabase.queryHandler.fetch(new StageBySlugQuery(params.stageSlug))\n\t\t\tif (!stage) {\n\t\t\t\treturn new HttpErrorResponse(404, `Stage ${params.stageSlug} NOT found`)\n\t\t\t}\n\t\t\tconst notModifiedRes = await this.notModifiedChecker.checkNotModified({\n\t\t\t\trequest: context.request,\n\t\t\t\tbody: context.body,\n\t\t\t\ttimer: context.timer,\n\t\t\t\tsystemDatabase,\n\t\t\t\tstageId: stage.id,\n\t\t\t})\n\t\t\tif (notModifiedRes?.isModified === false) {\n\t\t\t\treturn new HttpResponse(304)\n\t\t\t}\n\n\t\t\tconst schemaWithMeta = await projectContainer.contentSchemaResolver.getSchema({ db: systemDatabase, stage: stage.slug, normalize: true })\n\t\t\tconst schema = schemaWithMeta.schema\n\t\t\tconst { effective: memberships, fetched: fetchedMemberships } = await timer(\n\t\t\t\t'MembershipFetch',\n\t\t\t\t() => projectGroup.projectMembershipResolver.resolveMemberships({\n\t\t\t\t\trequest: koa,\n\t\t\t\t\tacl: schema.acl,\n\t\t\t\t\tprojectSlug: project.slug,\n\t\t\t\t\tidentity: {\n\t\t\t\t\t\tidentityId: authResult.identityId,\n\t\t\t\t\t\tpersonId: authResult.personId ?? undefined,\n\t\t\t\t\t\troles: authResult.roles,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t)\n\n\t\t\tlogger.debug('Memberships fetched', { memberships })\n\n\t\t\tconst debugHeaderValue = request.headers[debugHeader]\n\t\t\tif (Array.isArray(debugHeaderValue)) {\n\t\t\t\treturn new HttpErrorResponse(400, `Invalid format of ${debugHeader}`)\n\t\t\t}\n\t\t\tconst requestDebug = debugHeaderValue === '1' && fetchedMemberships.some(it => schema.acl.roles[it.role]?.debug)\n\t\t\tif (requestDebug) {\n\t\t\t\tcontext.requestDebugMode = true\n\t\t\t}\n\n\t\t\tconst projectRoles = memberships.map(it => it.role)\n\n\t\t\tconst { schema: graphQlSchema, permissions } = await timer(\n\t\t\t\t'GraphQLSchemaCreate',\n\t\t\t\t() => this.graphQlSchemaFactory.create(schema, {\n\t\t\t\t\tprojectRoles: projectRoles,\n\t\t\t\t}, project),\n\t\t\t)\n\n\n\t\t\tconst schemaDatabaseMetadata = await projectContainer.projectDatabaseMetadataResolver.resolveDatabaseMetadata(systemDatabase, schema, stage.schema)\n\n\t\t\tconst handler = await (async () => {\n\t\t\t\tconst existingHandler = handlerCache.get(graphQlSchema)\n\t\t\t\tif (existingHandler) {\n\t\t\t\t\treturn existingHandler\n\t\t\t\t}\n\t\t\t\tconst newHandler = await this.handlerFactory.create(graphQlSchema)\n\t\t\t\thandlerCache.set(graphQlSchema, newHandler)\n\t\t\t\treturn newHandler\n\t\t\t})()\n\n\t\t\tawait logger.scope(async logger => {\n\t\t\t\tlogger.debug('Content query processing started')\n\n\t\t\t\tawait timer('GraphQL', () => handler({\n\t\t\t\t\trequest: koa.request,\n\t\t\t\t\tresponse: koa.response,\n\t\t\t\t\tcreateContext: ({ operation }) => {\n\t\t\t\t\t\t(koa.state as GraphQLKoaState).graphql = {\n\t\t\t\t\t\t\toperationName: operation,\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst connection = operation === 'query' ? projectContainer.readConnection : projectContainer.connection\n\t\t\t\t\t\tconst contentDatabase = connection.createClient(stage.schema, { module: 'content' })\n\n\t\t\t\t\t\treturn this.contentGraphqlContextFactory.create({\n\t\t\t\t\t\t\tdb: contentDatabase,\n\t\t\t\t\t\t\tauthResult,\n\t\t\t\t\t\t\tmemberships,\n\t\t\t\t\t\t\tpermissions,\n\t\t\t\t\t\t\tschemaDatabaseMetadata,\n\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\tschemaMeta: { id: schemaWithMeta.meta.id },\n\t\t\t\t\t\t\ttimer,\n\t\t\t\t\t\t\trequestDebug,\n\t\t\t\t\t\t\tsystemSchema: projectContainer.systemDatabaseContextFactory.schemaName,\n\t\t\t\t\t\t\tstage,\n\t\t\t\t\t\t\tproject,\n\t\t\t\t\t\t})\n\t\t\t\t\t},\n\t\t\t\t}))\n\t\t\t\tlogger.debug('Content query finished')\n\t\t\t})\n\n\n\t\t\tnotModifiedRes?.setResponseHeader(context.response)\n\t\t}\n\t}\n}\n"],"names":["HttpErrorResponse","StageBySlugQuery","HttpResponse","logger"],"mappings":";;;;AAWA,MAAM,cAAc;AAEb,MAAM,4BAA4B;AAAA,EACxC,YACkB,oBACA,8BACA,gBACA,wBACA,sBAChB;AALgB,SAAA,qBAAA;AACA,SAAA,+BAAA;AACA,SAAA,iBAAA;AACA,SAAA,yBAAA;AACA,SAAA,uBAAA;AAAA,EAAA;AAAA,EAIlB,SAAyB;AAClB,UAAA,mCAAmB,QAA4C;AACrE,WAAO,OAAM,YAAW;AACvB,YAAM,EAAE,QAAQ,OAAO,cAAc,YAAY,SAAS,QAAQ;AAClE,UAAI,CAAC,YAAY;AACT,eAAA,IAAIA,aAAAA,kBAAkB,KAAK,yBAAyB;AAAA,MAAA;AAEtD,YAAA,EAAE,kBAAkB,QAAQ,IAAI,MAAM,KAAK,uBAAuB,QAAQ,OAAO;AAEjF,YAAA,SAAS,QAAQ,OAAO,MAAM;AAAA,QACnC,SAAS,QAAQ;AAAA,MAAA,CACjB;AAED,YAAM,iBAAiB,iBAAiB;AAClC,YAAA,QAAQ,MAAM,eAAe,aAAa,MAAM,IAAIC,gBAAA,iBAAiB,OAAO,SAAS,CAAC;AAC5F,UAAI,CAAC,OAAO;AACX,eAAO,IAAID,aAAkB,kBAAA,KAAK,SAAS,OAAO,SAAS,YAAY;AAAA,MAAA;AAExE,YAAM,iBAAiB,MAAM,KAAK,mBAAmB,iBAAiB;AAAA,QACrE,SAAS,QAAQ;AAAA,QACjB,MAAM,QAAQ;AAAA,QACd,OAAO,QAAQ;AAAA,QACf;AAAA,QACA,SAAS,MAAM;AAAA,MAAA,CACf;AACG,UAAA,gBAAgB,eAAe,OAAO;AAClC,eAAA,IAAIE,0BAAa,GAAG;AAAA,MAAA;AAG5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,aAAa;AACpD,qBAAA,IAAI,eAAe,UAAU;AACnC,eAAA;AAAA,MAAA,GACL;AAEG,YAAA,OAAO,MAAM,OAAMG,YAAU;AAClCA,gBAAO,MAAM,kCAAkC;AAEzC,cAAA,MAAM,WAAW,MAAM,QAAQ;AAAA,UACpC,SAAS,IAAI;AAAA,UACb,UAAU,IAAI;AAAA,UACd,eAAe,CAAC,EAAE,gBAAgB;AAChC,gBAAI,MAA0B,UAAU;AAAA,cACxC,eAAe;AAAA,YAChB;AAEA,kBAAM,aAAa,cAAc,UAAU,iBAAiB,iBAAiB,iBAAiB;AACxF,kBAAA,kBAAkB,WAAW,aAAa,MAAM,QAAQ,EAAE,QAAQ,WAAW;AAE5E,mBAAA,KAAK,6BAA6B,OAAO;AAAA,cAC/C,IAAI;AAAA,cACJ;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA,YAAY,EAAE,IAAI,eAAe,KAAK,GAAG;AAAA,cACzC;AAAA,cACA;AAAA,cACA,cAAc,iBAAiB,6BAA6B;AAAA,cAC5D;AAAA,cACA;AAAA,YAAA,CACA;AAAA,UAAA;AAAA,QACF,CACA,CAAC;AACFA,gBAAO,MAAM,wBAAwB;AAAA,MAAA,CACrC;AAGe,sBAAA,kBAAkB,QAAQ,QAAQ;AAAA,IACnD;AAAA,EAAA;AAEF;;"}
1
+ {"version":3,"file":"ContentApiControllerFactory.cjs","sources":["../../../../../packages/engine-http/src/content/ContentApiControllerFactory.ts"],"sourcesContent":["import { createAclVariables, ExecutionContainerFactory } from '@contember/engine-content-api'\nimport { StageBySlugQuery } from '@contember/engine-system-api'\nimport { GraphQLSchema } from 'graphql'\nimport { HttpController } from '../application'\nimport { HttpErrorResponse, HttpResponse } from '../common'\nimport { GraphQLKoaState } from '../graphql'\nimport { ProjectContextResolver } from '../project-common'\nimport { ContentQueryHandler, ContentQueryHandlerFactory } from './ContentQueryHandlerFactory'\nimport { GraphQlSchemaFactory } from './GraphQlSchemaFactory'\nimport { NotModifiedChecker } from './NotModifiedChecker'\n\nconst debugHeader = 'x-contember-debug'\n\nexport class ContentApiControllerFactory {\n\tconstructor(\n\t\tprivate readonly notModifiedChecker: NotModifiedChecker,\n\t\tprivate readonly executionContainerFactory: ExecutionContainerFactory,\n\t\tprivate readonly handlerFactory: ContentQueryHandlerFactory,\n\t\tprivate readonly projectContextResolver: ProjectContextResolver,\n\t\tprivate readonly graphQlSchemaFactory: GraphQlSchemaFactory,\n\t) {\n\t}\n\n\tcreate(): HttpController {\n\t\tconst handlerCache = new WeakMap<GraphQLSchema, ContentQueryHandler>()\n\t\treturn async context => {\n\t\t\tconst { params, timer, projectGroup, authResult, request, koa, clientIp } = context\n\t\t\tif (!authResult) {\n\t\t\t\treturn new HttpErrorResponse(401, 'Authentication required')\n\t\t\t}\n\t\t\tconst { projectContainer, project } = await this.projectContextResolver.resolve(context)\n\n\t\t\tconst logger = context.logger.child({\n\t\t\t\tproject: project.slug,\n\t\t\t})\n\n\t\t\tconst systemDatabase = projectContainer.systemReadDatabaseContext\n\t\t\tconst stage = await systemDatabase.queryHandler.fetch(new StageBySlugQuery(params.stageSlug))\n\t\t\tif (!stage) {\n\t\t\t\treturn new HttpErrorResponse(404, `Stage ${params.stageSlug} NOT found`)\n\t\t\t}\n\t\t\tconst notModifiedRes = await this.notModifiedChecker.checkNotModified({\n\t\t\t\trequest: context.request,\n\t\t\t\tbody: context.body,\n\t\t\t\ttimer: context.timer,\n\t\t\t\tsystemDatabase,\n\t\t\t\tstageId: stage.id,\n\t\t\t})\n\t\t\tif (notModifiedRes?.isModified === false) {\n\t\t\t\treturn new HttpResponse(304)\n\t\t\t}\n\n\t\t\tconst schemaWithMeta = await projectContainer.contentSchemaResolver.getSchema({ db: systemDatabase, stage: stage.slug, normalize: true })\n\t\t\tconst schema = schemaWithMeta.schema\n\t\t\tconst { effective: memberships, fetched: fetchedMemberships } = await timer(\n\t\t\t\t'MembershipFetch',\n\t\t\t\t() => projectGroup.projectMembershipResolver.resolveMemberships({\n\t\t\t\t\trequest: koa,\n\t\t\t\t\tacl: schema.acl,\n\t\t\t\t\tprojectSlug: project.slug,\n\t\t\t\t\tidentity: {\n\t\t\t\t\t\tidentityId: authResult.identityId,\n\t\t\t\t\t\tpersonId: authResult.personId ?? undefined,\n\t\t\t\t\t\troles: authResult.roles,\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t)\n\n\t\t\tlogger.debug('Memberships fetched', { memberships })\n\n\t\t\tconst debugHeaderValue = request.headers[debugHeader]\n\t\t\tif (Array.isArray(debugHeaderValue)) {\n\t\t\t\treturn new HttpErrorResponse(400, `Invalid format of ${debugHeader}`)\n\t\t\t}\n\t\t\tconst requestDebug = debugHeaderValue === '1' && fetchedMemberships.some(it => schema.acl.roles[it.role]?.debug)\n\t\t\tif (requestDebug) {\n\t\t\t\tcontext.requestDebugMode = true\n\t\t\t}\n\n\t\t\tconst projectRoles = memberships.map(it => it.role)\n\n\t\t\tconst { schema: graphQlSchema, permissions } = await timer(\n\t\t\t\t'GraphQLSchemaCreate',\n\t\t\t\t() => this.graphQlSchemaFactory.create(schema, {\n\t\t\t\t\tprojectRoles: projectRoles,\n\t\t\t\t}, project),\n\t\t\t)\n\n\n\t\t\tconst schemaDatabaseMetadata = await projectContainer.projectDatabaseMetadataResolver.resolveDatabaseMetadata(systemDatabase, schema, stage.schema)\n\n\t\t\tconst handler = await (async () => {\n\t\t\t\tconst existingHandler = handlerCache.get(graphQlSchema)\n\t\t\t\tif (existingHandler) {\n\t\t\t\t\treturn existingHandler\n\t\t\t\t}\n\t\t\t\tconst newHandler = await this.handlerFactory.create(graphQlSchema)\n\t\t\t\thandlerCache.set(graphQlSchema, newHandler)\n\t\t\t\treturn newHandler\n\t\t\t})()\n\n\t\t\tawait logger.scope(async logger => {\n\t\t\t\tlogger.debug('Content query processing started')\n\n\t\t\t\tawait timer('GraphQL', () => handler({\n\t\t\t\t\trequest: koa.request,\n\t\t\t\t\tresponse: koa.response,\n\t\t\t\t\tcreateContext: ({ operation }) => {\n\t\t\t\t\t\t(koa.state as GraphQLKoaState).graphql = {\n\t\t\t\t\t\t\toperationName: operation,\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst connection = operation === 'query' ? projectContainer.readConnection : projectContainer.connection\n\t\t\t\t\t\tconst contentDatabase = connection.createClient(stage.schema, { module: 'content' })\n\n\n\t\t\t\t\t\tconst identityVariables = createAclVariables(schema.acl, memberships)\n\t\t\t\t\t\tlet identityId = authResult.identityId\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tauthResult.assumedIdentityId &&\n\t\t\t\t\t\t\tmemberships.some(it => schema.acl.roles[it.role].system?.assumeIdentity)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tidentityId = authResult.assumedIdentityId\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst executionContainer = this.executionContainerFactory.create({\n\t\t\t\t\t\t\tdb: contentDatabase,\n\t\t\t\t\t\t\tidentityVariables,\n\t\t\t\t\t\t\tidentityId,\n\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\tschemaMeta: { id: schemaWithMeta.meta.id },\n\t\t\t\t\t\t\tschemaDatabaseMetadata,\n\t\t\t\t\t\t\tpermissions,\n\t\t\t\t\t\t\tsystemSchema: projectContainer.systemDatabaseContextFactory.schemaName,\n\t\t\t\t\t\t\tstage,\n\t\t\t\t\t\t\tproject,\n\t\t\t\t\t\t\tuserInfo: {\n\t\t\t\t\t\t\t\tipAddress: clientIp,\n\t\t\t\t\t\t\t\tuserAgent: koa.request.headers['user-agent'] ?? null,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t})\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tdb: contentDatabase,\n\t\t\t\t\t\t\tidentityVariables,\n\t\t\t\t\t\t\tidentityId,\n\t\t\t\t\t\t\texecutionContainer,\n\t\t\t\t\t\t\ttimer,\n\t\t\t\t\t\t\trequestDebug,\n\t\t\t\t\t\t\tproject,\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t}))\n\t\t\t\tlogger.debug('Content query finished')\n\t\t\t})\n\n\n\t\t\tnotModifiedRes?.setResponseHeader(context.response)\n\t\t}\n\t}\n}\n"],"names":["HttpErrorResponse","StageBySlugQuery","HttpResponse","logger","createAclVariables"],"mappings":";;;;;AAWA,MAAM,cAAc;AAEb,MAAM,4BAA4B;AAAA,EACxC,YACkB,oBACA,2BACA,gBACA,wBACA,sBAChB;AALgB,SAAA,qBAAA;AACA,SAAA,4BAAA;AACA,SAAA,iBAAA;AACA,SAAA,yBAAA;AACA,SAAA,uBAAA;AAAA,EAAA;AAAA,EAIlB,SAAyB;AAClB,UAAA,mCAAmB,QAA4C;AACrE,WAAO,OAAM,YAAW;AACjB,YAAA,EAAE,QAAQ,OAAO,cAAc,YAAY,SAAS,KAAK,aAAa;AAC5E,UAAI,CAAC,YAAY;AACT,eAAA,IAAIA,aAAAA,kBAAkB,KAAK,yBAAyB;AAAA,MAAA;AAEtD,YAAA,EAAE,kBAAkB,QAAQ,IAAI,MAAM,KAAK,uBAAuB,QAAQ,OAAO;AAEjF,YAAA,SAAS,QAAQ,OAAO,MAAM;AAAA,QACnC,SAAS,QAAQ;AAAA,MAAA,CACjB;AAED,YAAM,iBAAiB,iBAAiB;AAClC,YAAA,QAAQ,MAAM,eAAe,aAAa,MAAM,IAAIC,gBAAA,iBAAiB,OAAO,SAAS,CAAC;AAC5F,UAAI,CAAC,OAAO;AACX,eAAO,IAAID,aAAkB,kBAAA,KAAK,SAAS,OAAO,SAAS,YAAY;AAAA,MAAA;AAExE,YAAM,iBAAiB,MAAM,KAAK,mBAAmB,iBAAiB;AAAA,QACrE,SAAS,QAAQ;AAAA,QACjB,MAAM,QAAQ;AAAA,QACd,OAAO,QAAQ;AAAA,QACf;AAAA,QACA,SAAS,MAAM;AAAA,MAAA,CACf;AACG,UAAA,gBAAgB,eAAe,OAAO;AAClC,eAAA,IAAIE,0BAAa,GAAG;AAAA,MAAA;AAG5B,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