@contember/engine-http 2.0.0-alpha.35 → 2.0.0-alpha.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/development/src/MasterContainer.cjs +14 -3
- package/dist/development/src/MasterContainer.cjs.map +1 -1
- package/dist/development/src/MasterContainer.js +14 -3
- package/dist/development/src/MasterContainer.js.map +1 -1
- package/dist/development/src/content/ContentApiControllerFactory.cjs +4 -3
- package/dist/development/src/content/ContentApiControllerFactory.cjs.map +1 -1
- package/dist/development/src/content/ContentApiControllerFactory.js +4 -3
- package/dist/development/src/content/ContentApiControllerFactory.js.map +1 -1
- package/dist/development/src/content/ContentGraphQLContextFactory.cjs +2 -1
- package/dist/development/src/content/ContentGraphQLContextFactory.cjs.map +1 -1
- package/dist/development/src/content/ContentGraphQLContextFactory.js +2 -1
- package/dist/development/src/content/ContentGraphQLContextFactory.js.map +1 -1
- package/dist/development/src/content/ContentSchemaResolver.cjs +10 -4
- package/dist/development/src/content/ContentSchemaResolver.cjs.map +1 -1
- package/dist/development/src/content/ContentSchemaResolver.js +11 -5
- package/dist/development/src/content/ContentSchemaResolver.js.map +1 -1
- package/dist/development/src/content/GraphQlSchemaFactory.cjs +5 -3
- package/dist/development/src/content/GraphQlSchemaFactory.cjs.map +1 -1
- package/dist/development/src/content/GraphQlSchemaFactory.js +5 -3
- package/dist/development/src/content/GraphQlSchemaFactory.js.map +1 -1
- package/dist/development/src/project/ProjectContainer.cjs +2 -24
- package/dist/development/src/project/ProjectContainer.cjs.map +1 -1
- package/dist/development/src/project/ProjectContainer.js +2 -24
- package/dist/development/src/project/ProjectContainer.js.map +1 -1
- package/dist/development/src/projectGroup/ProjectGroupContainer.cjs +0 -1
- package/dist/development/src/projectGroup/ProjectGroupContainer.cjs.map +1 -1
- package/dist/development/src/projectGroup/ProjectGroupContainer.js +0 -1
- package/dist/development/src/projectGroup/ProjectGroupContainer.js.map +1 -1
- package/dist/development/src/system/ContentQueryExecutor.cjs +1 -0
- package/dist/development/src/system/ContentQueryExecutor.cjs.map +1 -1
- package/dist/development/src/system/ContentQueryExecutor.js +1 -0
- package/dist/development/src/system/ContentQueryExecutor.js.map +1 -1
- package/dist/development/src/utils/memoizeObject.cjs +33 -0
- package/dist/development/src/utils/memoizeObject.cjs.map +1 -0
- package/dist/development/src/utils/memoizeObject.js +33 -0
- package/dist/development/src/utils/memoizeObject.js.map +1 -0
- package/dist/production/src/MasterContainer.cjs +14 -3
- package/dist/production/src/MasterContainer.cjs.map +1 -1
- package/dist/production/src/MasterContainer.js +14 -3
- package/dist/production/src/MasterContainer.js.map +1 -1
- package/dist/production/src/content/ContentApiControllerFactory.cjs +4 -3
- package/dist/production/src/content/ContentApiControllerFactory.cjs.map +1 -1
- package/dist/production/src/content/ContentApiControllerFactory.js +4 -3
- package/dist/production/src/content/ContentApiControllerFactory.js.map +1 -1
- package/dist/production/src/content/ContentGraphQLContextFactory.cjs +2 -1
- package/dist/production/src/content/ContentGraphQLContextFactory.cjs.map +1 -1
- package/dist/production/src/content/ContentGraphQLContextFactory.js +2 -1
- package/dist/production/src/content/ContentGraphQLContextFactory.js.map +1 -1
- package/dist/production/src/content/ContentSchemaResolver.cjs +10 -4
- package/dist/production/src/content/ContentSchemaResolver.cjs.map +1 -1
- package/dist/production/src/content/ContentSchemaResolver.js +11 -5
- package/dist/production/src/content/ContentSchemaResolver.js.map +1 -1
- package/dist/production/src/content/GraphQlSchemaFactory.cjs +5 -3
- package/dist/production/src/content/GraphQlSchemaFactory.cjs.map +1 -1
- package/dist/production/src/content/GraphQlSchemaFactory.js +5 -3
- package/dist/production/src/content/GraphQlSchemaFactory.js.map +1 -1
- package/dist/production/src/project/ProjectContainer.cjs +2 -24
- package/dist/production/src/project/ProjectContainer.cjs.map +1 -1
- package/dist/production/src/project/ProjectContainer.js +2 -24
- package/dist/production/src/project/ProjectContainer.js.map +1 -1
- package/dist/production/src/projectGroup/ProjectGroupContainer.cjs +0 -1
- package/dist/production/src/projectGroup/ProjectGroupContainer.cjs.map +1 -1
- package/dist/production/src/projectGroup/ProjectGroupContainer.js +0 -1
- package/dist/production/src/projectGroup/ProjectGroupContainer.js.map +1 -1
- package/dist/production/src/system/ContentQueryExecutor.cjs +1 -0
- package/dist/production/src/system/ContentQueryExecutor.cjs.map +1 -1
- package/dist/production/src/system/ContentQueryExecutor.js +1 -0
- package/dist/production/src/system/ContentQueryExecutor.js.map +1 -1
- package/dist/production/src/utils/memoizeObject.cjs +33 -0
- package/dist/production/src/utils/memoizeObject.cjs.map +1 -0
- package/dist/production/src/utils/memoizeObject.js +33 -0
- package/dist/production/src/utils/memoizeObject.js.map +1 -0
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/dist/types/MasterContainer.d.ts +7 -1
- package/dist/types/MasterContainer.d.ts.map +1 -1
- package/dist/types/content/ContentApiControllerFactory.d.ts +3 -1
- package/dist/types/content/ContentApiControllerFactory.d.ts.map +1 -1
- package/dist/types/content/ContentGraphQLContextFactory.d.ts +3 -0
- package/dist/types/content/ContentGraphQLContextFactory.d.ts.map +1 -1
- package/dist/types/content/ContentSchemaResolver.d.ts.map +1 -1
- package/dist/types/content/GraphQLSchemaContributor.d.ts +3 -0
- package/dist/types/content/GraphQLSchemaContributor.d.ts.map +1 -1
- package/dist/types/content/GraphQlSchemaFactory.d.ts +2 -1
- package/dist/types/content/GraphQlSchemaFactory.d.ts.map +1 -1
- package/dist/types/plugin/Plugin.d.ts +2 -4
- package/dist/types/plugin/Plugin.d.ts.map +1 -1
- package/dist/types/project/ProjectContainer.d.ts +4 -19
- package/dist/types/project/ProjectContainer.d.ts.map +1 -1
- package/dist/types/system/ContentQueryExecutor.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/types/utils/memoizeObject.d.ts +2 -0
- package/dist/types/utils/memoizeObject.d.ts.map +1 -0
- package/package.json +15 -15
- package/src/MasterContainer.ts +26 -5
- package/src/content/ContentApiControllerFactory.ts +4 -2
- package/src/content/ContentGraphQLContextFactory.ts +2 -0
- package/src/content/ContentSchemaResolver.ts +13 -5
- package/src/content/GraphQLSchemaContributor.ts +7 -1
- package/src/content/GraphQlSchemaFactory.ts +6 -3
- package/src/plugin/Plugin.ts +2 -4
- package/src/project/ProjectContainer.ts +3 -30
- package/src/system/ContentQueryExecutor.ts +1 -0
- package/src/utils/memoizeObject.ts +38 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const createMemoizer = (canonicalizeValue) => {
|
|
4
|
+
const cache = /* @__PURE__ */ new Map();
|
|
5
|
+
const canonicalValueCache = /* @__PURE__ */ new WeakMap();
|
|
6
|
+
const finalizer = new FinalizationRegistry((key) => {
|
|
7
|
+
cache.delete(key);
|
|
8
|
+
});
|
|
9
|
+
return (value) => {
|
|
10
|
+
if (typeof value !== "object" || value === null) {
|
|
11
|
+
throw new TypeError("Value must be a non-null object");
|
|
12
|
+
}
|
|
13
|
+
let key = canonicalValueCache.get(value);
|
|
14
|
+
if (!key) {
|
|
15
|
+
key = canonicalizeValue(value);
|
|
16
|
+
canonicalValueCache.set(value, key);
|
|
17
|
+
}
|
|
18
|
+
const entry = cache.get(key);
|
|
19
|
+
if (entry) {
|
|
20
|
+
const obj = entry.deref();
|
|
21
|
+
if (obj !== void 0) {
|
|
22
|
+
return obj;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const stableObj = value;
|
|
26
|
+
const weakRef = new WeakRef(stableObj);
|
|
27
|
+
finalizer.register(stableObj, key);
|
|
28
|
+
cache.set(key, weakRef);
|
|
29
|
+
return stableObj;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
exports.createMemoizer = createMemoizer;
|
|
33
|
+
//# sourceMappingURL=memoizeObject.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memoizeObject.cjs","sources":["../../../../../packages/engine-http/src/utils/memoizeObject.ts"],"sourcesContent":["\nexport const createMemoizer = <T extends object>(canonicalizeValue: (value: T) => string) => {\n\tconst cache = new Map<string, WeakRef<T>>()\n\tconst canonicalValueCache = new WeakMap<T, string>()\n\n\tconst finalizer = new FinalizationRegistry<string>(key => {\n\t\tcache.delete(key)\n\t})\n\n\treturn (value: T): T => {\n\t\tif (typeof value !== 'object' || value === null) {\n\t\t\tthrow new TypeError('Value must be a non-null object')\n\t\t}\n\t\tlet key = canonicalValueCache.get(value)\n\t\tif (!key) {\n\t\t\tkey = canonicalizeValue(value)\n\t\t\tcanonicalValueCache.set(value, key)\n\t\t}\n\n\t\tconst entry = cache.get(key)\n\t\tif (entry) {\n\t\t\tconst obj = entry.deref()\n\t\t\tif (obj !== undefined) {\n\t\t\t\treturn obj as T\n\t\t\t}\n\t\t}\n\n\t\tconst stableObj = value\n\t\tconst weakRef = new WeakRef(stableObj)\n\n\t\tfinalizer.register(stableObj, key)\n\n\t\tcache.set(key, weakRef)\n\n\t\treturn stableObj\n\t}\n\n}\n"],"names":[],"mappings":";;AACa,MAAA,iBAAiB,CAAmB,sBAA4C;AACtF,QAAA,4BAAY,IAAwB;AACpC,QAAA,0CAA0B,QAAmB;AAE7C,QAAA,YAAY,IAAI,qBAA6B,CAAO,QAAA;AACzD,UAAM,OAAO,GAAG;AAAA,EAAA,CAChB;AAED,SAAO,CAAC,UAAgB;AACvB,QAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAC1C,YAAA,IAAI,UAAU,iCAAiC;AAAA,IAAA;AAElD,QAAA,MAAM,oBAAoB,IAAI,KAAK;AACvC,QAAI,CAAC,KAAK;AACT,YAAM,kBAAkB,KAAK;AACT,0BAAA,IAAI,OAAO,GAAG;AAAA,IAAA;AAG7B,UAAA,QAAQ,MAAM,IAAI,GAAG;AAC3B,QAAI,OAAO;AACJ,YAAA,MAAM,MAAM,MAAM;AACxB,UAAI,QAAQ,QAAW;AACf,eAAA;AAAA,MAAA;AAAA,IACR;AAGD,UAAM,YAAY;AACZ,UAAA,UAAU,IAAI,QAAQ,SAAS;AAE3B,cAAA,SAAS,WAAW,GAAG;AAE3B,UAAA,IAAI,KAAK,OAAO;AAEf,WAAA;AAAA,EACR;AAED;;"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const createMemoizer = (canonicalizeValue) => {
|
|
2
|
+
const cache = /* @__PURE__ */ new Map();
|
|
3
|
+
const canonicalValueCache = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
const finalizer = new FinalizationRegistry((key) => {
|
|
5
|
+
cache.delete(key);
|
|
6
|
+
});
|
|
7
|
+
return (value) => {
|
|
8
|
+
if (typeof value !== "object" || value === null) {
|
|
9
|
+
throw new TypeError("Value must be a non-null object");
|
|
10
|
+
}
|
|
11
|
+
let key = canonicalValueCache.get(value);
|
|
12
|
+
if (!key) {
|
|
13
|
+
key = canonicalizeValue(value);
|
|
14
|
+
canonicalValueCache.set(value, key);
|
|
15
|
+
}
|
|
16
|
+
const entry = cache.get(key);
|
|
17
|
+
if (entry) {
|
|
18
|
+
const obj = entry.deref();
|
|
19
|
+
if (obj !== void 0) {
|
|
20
|
+
return obj;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const stableObj = value;
|
|
24
|
+
const weakRef = new WeakRef(stableObj);
|
|
25
|
+
finalizer.register(stableObj, key);
|
|
26
|
+
cache.set(key, weakRef);
|
|
27
|
+
return stableObj;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
createMemoizer
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=memoizeObject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memoizeObject.js","sources":["../../../../../packages/engine-http/src/utils/memoizeObject.ts"],"sourcesContent":["\nexport const createMemoizer = <T extends object>(canonicalizeValue: (value: T) => string) => {\n\tconst cache = new Map<string, WeakRef<T>>()\n\tconst canonicalValueCache = new WeakMap<T, string>()\n\n\tconst finalizer = new FinalizationRegistry<string>(key => {\n\t\tcache.delete(key)\n\t})\n\n\treturn (value: T): T => {\n\t\tif (typeof value !== 'object' || value === null) {\n\t\t\tthrow new TypeError('Value must be a non-null object')\n\t\t}\n\t\tlet key = canonicalValueCache.get(value)\n\t\tif (!key) {\n\t\t\tkey = canonicalizeValue(value)\n\t\t\tcanonicalValueCache.set(value, key)\n\t\t}\n\n\t\tconst entry = cache.get(key)\n\t\tif (entry) {\n\t\t\tconst obj = entry.deref()\n\t\t\tif (obj !== undefined) {\n\t\t\t\treturn obj as T\n\t\t\t}\n\t\t}\n\n\t\tconst stableObj = value\n\t\tconst weakRef = new WeakRef(stableObj)\n\n\t\tfinalizer.register(stableObj, key)\n\n\t\tcache.set(key, weakRef)\n\n\t\treturn stableObj\n\t}\n\n}\n"],"names":[],"mappings":"AACa,MAAA,iBAAiB,CAAmB,sBAA4C;AACtF,QAAA,4BAAY,IAAwB;AACpC,QAAA,0CAA0B,QAAmB;AAE7C,QAAA,YAAY,IAAI,qBAA6B,CAAO,QAAA;AACzD,UAAM,OAAO,GAAG;AAAA,EAAA,CAChB;AAED,SAAO,CAAC,UAAgB;AACvB,QAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAC1C,YAAA,IAAI,UAAU,iCAAiC;AAAA,IAAA;AAElD,QAAA,MAAM,oBAAoB,IAAI,KAAK;AACvC,QAAI,CAAC,KAAK;AACT,YAAM,kBAAkB,KAAK;AACT,0BAAA,IAAI,OAAO,GAAG;AAAA,IAAA;AAG7B,UAAA,QAAQ,MAAM,IAAI,GAAG;AAC3B,QAAI,OAAO;AACJ,YAAA,MAAM,MAAM,MAAM;AACxB,UAAI,QAAQ,QAAW;AACf,eAAA;AAAA,MAAA;AAAA,IACR;AAGD,UAAM,YAAY;AACZ,UAAA,UAAU,IAAI,QAAQ,SAAS;AAE3B,cAAA,SAAS,WAAW,GAAG;AAE3B,UAAA,IAAI,KAAK,OAAO;AAEf,WAAA;AAAA,EACR;AAED;"}
|
|
@@ -21,7 +21,7 @@ const ContentApiControllerFactory = require("./content/ContentApiControllerFacto
|
|
|
21
21
|
const ContentGraphQLContextFactory = require("./content/ContentGraphQLContextFactory.cjs");
|
|
22
22
|
const ContentQueryHandlerFactory = require("./content/ContentQueryHandlerFactory.cjs");
|
|
23
23
|
require("./content/ContentSchemaResolver.cjs");
|
|
24
|
-
require("
|
|
24
|
+
const GraphQlSchemaFactory = require("./content/GraphQlSchemaFactory.cjs");
|
|
25
25
|
const NotModifiedChecker = require("./content/NotModifiedChecker.cjs");
|
|
26
26
|
require("./content/ProjectMembershipResolver.cjs");
|
|
27
27
|
const ProjectContextResolver = require("./project-common/ProjectContextResolver.cjs");
|
|
@@ -45,6 +45,7 @@ const CollectHttpMetricsMiddelware = require("./prometheus/CollectHttpMetricsMid
|
|
|
45
45
|
const ShowMetricsMiddleware = require("./prometheus/ShowMetricsMiddleware.cjs");
|
|
46
46
|
const crypto = require("node:crypto");
|
|
47
47
|
const CryptoWrapper = require("./utils/CryptoWrapper.cjs");
|
|
48
|
+
const ContentApiSpecificCache = require("./content/ContentApiSpecificCache.cjs");
|
|
48
49
|
class MasterContainerFactory {
|
|
49
50
|
createBuilder(args) {
|
|
50
51
|
const builder = this.createBuilderInternal(args);
|
|
@@ -61,7 +62,17 @@ class MasterContainerFactory {
|
|
|
61
62
|
logger,
|
|
62
63
|
processType
|
|
63
64
|
}) {
|
|
64
|
-
return new dic.Builder({}).addService("serverConfig", () => serverConfig).addService("debugMode", () => debugMode).addService("version", () => version).addService("processType", () => processType).addService("projectConfigResolver", () => projectConfigResolver).addService("tenantConfigResolver", () => tenantConfigResolver).addService("plugins", () => plugins).addService("providers", () => providers.createProviders()).addService("tenantContainerFactory", ({ providers: providers2 }) => new engineTenantApi.TenantContainerFactory(providers2)).addService("modificationHandlerFactory", () => new schemaMigrations.ModificationHandlerFactory(schemaMigrations.ModificationHandlerFactory.defaultFactoryMap)).addService("executionContainerFactory", ({ providers: providers2 }) => new engineContentApi.ExecutionContainerFactory(providers2)).addService("graphQlSchemaBuilderFactory", () => new engineContentApi.GraphQlSchemaBuilderFactory()).addService("contentQueryExecutor", ({ executionContainerFactory, graphQlSchemaBuilderFactory }) => new ContentQueryExecutor.ContentQueryExecutorImpl(executionContainerFactory, graphQlSchemaBuilderFactory)).addService("systemContainerFactory", ({ providers: providers2, modificationHandlerFactory, contentQueryExecutor }) => new engineSystemApi.SystemContainerFactory(providers2, modificationHandlerFactory, contentQueryExecutor)).addService("contentPermissionFactory", ({}) => new engineContentApi.PermissionFactory()).addService("databaseMetadataResolver", () => new Database.DatabaseMetadataResolver()).addService("
|
|
65
|
+
return new dic.Builder({}).addService("serverConfig", () => serverConfig).addService("debugMode", () => debugMode).addService("version", () => version).addService("processType", () => processType).addService("projectConfigResolver", () => projectConfigResolver).addService("tenantConfigResolver", () => tenantConfigResolver).addService("plugins", () => plugins).addService("providers", () => providers.createProviders()).addService("tenantContainerFactory", ({ providers: providers2 }) => new engineTenantApi.TenantContainerFactory(providers2)).addService("modificationHandlerFactory", () => new schemaMigrations.ModificationHandlerFactory(schemaMigrations.ModificationHandlerFactory.defaultFactoryMap)).addService("executionContainerFactory", ({ providers: providers2 }) => new engineContentApi.ExecutionContainerFactory(providers2)).addService("graphQlSchemaBuilderFactory", () => new engineContentApi.GraphQlSchemaBuilderFactory()).addService("contentQueryExecutor", ({ executionContainerFactory, graphQlSchemaBuilderFactory }) => new ContentQueryExecutor.ContentQueryExecutorImpl(executionContainerFactory, graphQlSchemaBuilderFactory)).addService("systemContainerFactory", ({ providers: providers2, modificationHandlerFactory, contentQueryExecutor }) => new engineSystemApi.SystemContainerFactory(providers2, modificationHandlerFactory, contentQueryExecutor)).addService("contentPermissionFactory", ({}) => new engineContentApi.PermissionFactory()).addService("databaseMetadataResolver", () => new Database.DatabaseMetadataResolver()).addService("graphqlSchemaCache", ({ serverConfig: serverConfig2 }) => new ContentApiSpecificCache.ContentApiSpecificCache({
|
|
66
|
+
ttlSeconds: serverConfig2.contentApi?.schemaCacheTtlSeconds
|
|
67
|
+
})).addService("graphQlSchemaFactory", ({ plugins: plugins2, providers: providers2, graphqlSchemaCache, contentPermissionFactory, graphQlSchemaBuilderFactory }) => {
|
|
68
|
+
const contributors = plugins2.map((it) => it.getSchemaContributor ? it.getSchemaContributor({ providers: providers2 }) : null).filter((it) => !!it);
|
|
69
|
+
return new GraphQlSchemaFactory.GraphQlSchemaFactory(
|
|
70
|
+
graphqlSchemaCache,
|
|
71
|
+
graphQlSchemaBuilderFactory,
|
|
72
|
+
contentPermissionFactory,
|
|
73
|
+
contributors
|
|
74
|
+
);
|
|
75
|
+
}).addService("projectContainerFactoryFactory", ({ plugins: plugins2, providers: providers2, databaseMetadataResolver }) => new ProjectContainer.ProjectContainerFactoryFactory(plugins2, providers2, databaseMetadataResolver)).addService("tenantGraphQLHandlerFactory", () => new TenantGraphQLHandlerFactory.TenantGraphQLHandlerFactory()).addService("systemGraphQLHandlerFactory", ({ debugMode: debugMode2 }) => new SystemGraphQLHandlerFactory.SystemGraphQLHandlerFactory(debugMode2)).addService("logger", () => logger).addService("projectGroupContainerFactory", ({ debugMode: debugMode2, providers: providers2, systemContainerFactory, tenantContainerFactory, projectContainerFactoryFactory, projectConfigResolver: projectConfigResolver2, tenantGraphQLHandlerFactory, systemGraphQLHandlerFactory, logger: logger2 }) => new ProjectGroupContainer.ProjectGroupContainerFactory(debugMode2, providers2, systemContainerFactory, tenantContainerFactory, projectContainerFactoryFactory, projectConfigResolver2, tenantGraphQLHandlerFactory, systemGraphQLHandlerFactory, logger2)).addService("projectGroupContainerResolver", ({ tenantConfigResolver: tenantConfigResolver2, projectGroupContainerFactory }) => new ProjectGroupContainerResolver.ProjectGroupContainerResolver(tenantConfigResolver2, projectGroupContainerFactory)).addService("promRegistryFactory", ({ processType: processType2, version: version2 }) => new PrometheusRegistryFactory.PrometheusRegistryFactory(processType2, { version: version2 })).addService("projectGroupContainerMetricsHook", ({ projectGroupContainerResolver }) => new ProjectGroupContainerMetricsHook.ProjectGroupContainerMetricsHook(projectGroupContainerResolver)).addService("promRegistry", ({ promRegistryFactory, projectGroupContainerMetricsHook }) => {
|
|
65
76
|
const registry = promRegistryFactory.create();
|
|
66
77
|
projectGroupContainerMetricsHook.register(registry);
|
|
67
78
|
return registry;
|
|
@@ -73,7 +84,7 @@ class MasterContainerFactory {
|
|
|
73
84
|
serverConfig2.projectGroup?.configEncryptionKey ? new CryptoWrapper.CryptoWrapper(encryptionKey) : void 0,
|
|
74
85
|
projectGroupContainerResolver
|
|
75
86
|
);
|
|
76
|
-
}).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 }) => new ContentApiControllerFactory.ContentApiControllerFactory(notModifiedChecker, contentGraphqlContextFactory, contentQueryHandlerFactory, projectContextResolver)).addService("tenantGraphQLContextFactory", () => new TenantGraphQLContextFactory.TenantGraphQLContextFactory()).addService("tenantApiMiddlewareFactory", ({ debugMode: debugMode2, projectGroupResolver, tenantGraphQLContextFactory }) => new TenantApiMiddlewareFactory.TenantApiMiddlewareFactory(debugMode2, projectGroupResolver, tenantGraphQLContextFactory)).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
|
+
}).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("tenantGraphQLContextFactory", () => new TenantGraphQLContextFactory.TenantGraphQLContextFactory()).addService("tenantApiMiddlewareFactory", ({ debugMode: debugMode2, projectGroupResolver, tenantGraphQLContextFactory }) => new TenantApiMiddlewareFactory.TenantApiMiddlewareFactory(debugMode2, projectGroupResolver, tenantGraphQLContextFactory)).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 }) => {
|
|
77
88
|
const app = new application.Application(
|
|
78
89
|
projectGroupResolver,
|
|
79
90
|
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, TenantGraphQLContextFactory, TenantGraphQLHandlerFactory } from './tenant'\nimport { SystemApiMiddlewareFactory, SystemGraphQLContextFactory, SystemGraphQLHandlerFactory } from './system'\nimport { ContentApiControllerFactory, ContentGraphQLContextFactory, ContentQueryHandlerFactory, NotModifiedChecker } 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'\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('projectContainerFactoryFactory', ({ plugins, providers, serverConfig, graphQlSchemaBuilderFactory, contentPermissionFactory, databaseMetadataResolver }) =>\n\t\t\t\tnew ProjectContainerFactoryFactory(plugins, providers, serverConfig, graphQlSchemaBuilderFactory, contentPermissionFactory, 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 }) =>\n\t\t\t\tnew ContentApiControllerFactory(notModifiedChecker, contentGraphqlContextFactory, contentQueryHandlerFactory, projectContextResolver))\n\t\t\t.addService('tenantGraphQLContextFactory', () =>\n\t\t\t\tnew TenantGraphQLContextFactory())\n\t\t\t.addService('tenantApiMiddlewareFactory', ({ debugMode, projectGroupResolver, tenantGraphQLContextFactory }) =>\n\t\t\t\tnew TenantApiMiddlewareFactory(debugMode, projectGroupResolver, tenantGraphQLContextFactory))\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","plugins","serverConfig","ProjectContainerFactoryFactory","TenantGraphQLHandlerFactory","debugMode","SystemGraphQLHandlerFactory","projectConfigResolver","logger","ProjectGroupContainerFactory","tenantConfigResolver","ProjectGroupContainerResolver","processType","version","PrometheusRegistryFactory","ProjectGroupContainerMetricsHook","createSecretKey","ProjectGroupResolver","CryptoWrapper","NotModifiedChecker","ContentGraphQLContextFactory","ContentQueryHandlerFactory","ProjectContextResolver","ContentApiControllerFactory","TenantGraphQLContextFactory","TenantApiMiddlewareFactory","SystemGraphQLContextFactory","SystemApiMiddlewareFactory","ContentSchemaTransferMappingFactory","SystemSchemaTransferMappingFactory","ImportExecutor","ExportExecutor","ImportApiMiddlewareFactory","ExportApiControllerFactory","Application","createColllectHttpMetricsMiddleware","homepageController","HttpResponse","Initializer","ApplicationWorkerManager","createShowMetricsMiddleware"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqEO,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;AAA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AAI,IAAI;AAChB,UAAA,IAAIuC,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 { 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, TenantGraphQLContextFactory, 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('tenantGraphQLContextFactory', () =>\n\t\t\t\tnew TenantGraphQLContextFactory())\n\t\t\t.addService('tenantApiMiddlewareFactory', ({ debugMode, projectGroupResolver, tenantGraphQLContextFactory }) =>\n\t\t\t\tnew TenantApiMiddlewareFactory(debugMode, projectGroupResolver, tenantGraphQLContextFactory))\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","TenantGraphQLContextFactory","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,Y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ACtC,WAAW,sBAAsB,MACjC,IAAIC,yBAAAA,0BAA0B,EAC9B,aAAa,6BAA6B,CAAC,IAAI,EAAE,SAAAtC,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,IAAIuC,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;;"}
|
|
@@ -19,7 +19,7 @@ import { ContentApiControllerFactory } from "./content/ContentApiControllerFacto
|
|
|
19
19
|
import { ContentGraphQLContextFactory } from "./content/ContentGraphQLContextFactory.js";
|
|
20
20
|
import { ContentQueryHandlerFactory } from "./content/ContentQueryHandlerFactory.js";
|
|
21
21
|
import "./content/ContentSchemaResolver.js";
|
|
22
|
-
import "
|
|
22
|
+
import { GraphQlSchemaFactory } from "./content/GraphQlSchemaFactory.js";
|
|
23
23
|
import { NotModifiedChecker } from "./content/NotModifiedChecker.js";
|
|
24
24
|
import "./content/ProjectMembershipResolver.js";
|
|
25
25
|
import { ProjectContextResolver } from "./project-common/ProjectContextResolver.js";
|
|
@@ -43,6 +43,7 @@ import { createColllectHttpMetricsMiddleware } from "./prometheus/CollectHttpMet
|
|
|
43
43
|
import { createShowMetricsMiddleware } from "./prometheus/ShowMetricsMiddleware.js";
|
|
44
44
|
import { createSecretKey } from "node:crypto";
|
|
45
45
|
import { CryptoWrapper } from "./utils/CryptoWrapper.js";
|
|
46
|
+
import { ContentApiSpecificCache } from "./content/ContentApiSpecificCache.js";
|
|
46
47
|
class MasterContainerFactory {
|
|
47
48
|
createBuilder(args) {
|
|
48
49
|
const builder = this.createBuilderInternal(args);
|
|
@@ -59,7 +60,17 @@ class MasterContainerFactory {
|
|
|
59
60
|
logger,
|
|
60
61
|
processType
|
|
61
62
|
}) {
|
|
62
|
-
return new Builder({}).addService("serverConfig", () => serverConfig).addService("debugMode", () => debugMode).addService("version", () => version).addService("processType", () => processType).addService("projectConfigResolver", () => projectConfigResolver).addService("tenantConfigResolver", () => tenantConfigResolver).addService("plugins", () => plugins).addService("providers", () => createProviders()).addService("tenantContainerFactory", ({ providers }) => new TenantContainerFactory(providers)).addService("modificationHandlerFactory", () => new ModificationHandlerFactory(ModificationHandlerFactory.defaultFactoryMap)).addService("executionContainerFactory", ({ providers }) => new ExecutionContainerFactory(providers)).addService("graphQlSchemaBuilderFactory", () => new GraphQlSchemaBuilderFactory()).addService("contentQueryExecutor", ({ executionContainerFactory, graphQlSchemaBuilderFactory }) => new ContentQueryExecutorImpl(executionContainerFactory, graphQlSchemaBuilderFactory)).addService("systemContainerFactory", ({ providers, modificationHandlerFactory, contentQueryExecutor }) => new SystemContainerFactory(providers, modificationHandlerFactory, contentQueryExecutor)).addService("contentPermissionFactory", ({}) => new PermissionFactory()).addService("databaseMetadataResolver", () => new DatabaseMetadataResolver()).addService("
|
|
63
|
+
return new Builder({}).addService("serverConfig", () => serverConfig).addService("debugMode", () => debugMode).addService("version", () => version).addService("processType", () => processType).addService("projectConfigResolver", () => projectConfigResolver).addService("tenantConfigResolver", () => tenantConfigResolver).addService("plugins", () => plugins).addService("providers", () => createProviders()).addService("tenantContainerFactory", ({ providers }) => new TenantContainerFactory(providers)).addService("modificationHandlerFactory", () => new ModificationHandlerFactory(ModificationHandlerFactory.defaultFactoryMap)).addService("executionContainerFactory", ({ providers }) => new ExecutionContainerFactory(providers)).addService("graphQlSchemaBuilderFactory", () => new GraphQlSchemaBuilderFactory()).addService("contentQueryExecutor", ({ executionContainerFactory, graphQlSchemaBuilderFactory }) => new ContentQueryExecutorImpl(executionContainerFactory, graphQlSchemaBuilderFactory)).addService("systemContainerFactory", ({ providers, modificationHandlerFactory, contentQueryExecutor }) => new SystemContainerFactory(providers, modificationHandlerFactory, contentQueryExecutor)).addService("contentPermissionFactory", ({}) => new PermissionFactory()).addService("databaseMetadataResolver", () => new DatabaseMetadataResolver()).addService("graphqlSchemaCache", ({ serverConfig: serverConfig2 }) => new ContentApiSpecificCache({
|
|
64
|
+
ttlSeconds: serverConfig2.contentApi?.schemaCacheTtlSeconds
|
|
65
|
+
})).addService("graphQlSchemaFactory", ({ plugins: plugins2, providers, graphqlSchemaCache, contentPermissionFactory, graphQlSchemaBuilderFactory }) => {
|
|
66
|
+
const contributors = plugins2.map((it) => it.getSchemaContributor ? it.getSchemaContributor({ providers }) : null).filter((it) => !!it);
|
|
67
|
+
return new GraphQlSchemaFactory(
|
|
68
|
+
graphqlSchemaCache,
|
|
69
|
+
graphQlSchemaBuilderFactory,
|
|
70
|
+
contentPermissionFactory,
|
|
71
|
+
contributors
|
|
72
|
+
);
|
|
73
|
+
}).addService("projectContainerFactoryFactory", ({ plugins: plugins2, providers, databaseMetadataResolver }) => new ProjectContainerFactoryFactory(plugins2, providers, databaseMetadataResolver)).addService("tenantGraphQLHandlerFactory", () => new TenantGraphQLHandlerFactory()).addService("systemGraphQLHandlerFactory", ({ debugMode: debugMode2 }) => new SystemGraphQLHandlerFactory(debugMode2)).addService("logger", () => logger).addService("projectGroupContainerFactory", ({ debugMode: debugMode2, providers, systemContainerFactory, tenantContainerFactory, projectContainerFactoryFactory, projectConfigResolver: projectConfigResolver2, tenantGraphQLHandlerFactory, systemGraphQLHandlerFactory, logger: logger2 }) => new ProjectGroupContainerFactory(debugMode2, providers, systemContainerFactory, tenantContainerFactory, projectContainerFactoryFactory, projectConfigResolver2, tenantGraphQLHandlerFactory, systemGraphQLHandlerFactory, logger2)).addService("projectGroupContainerResolver", ({ tenantConfigResolver: tenantConfigResolver2, projectGroupContainerFactory }) => new ProjectGroupContainerResolver(tenantConfigResolver2, projectGroupContainerFactory)).addService("promRegistryFactory", ({ processType: processType2, version: version2 }) => new PrometheusRegistryFactory(processType2, { version: version2 })).addService("projectGroupContainerMetricsHook", ({ projectGroupContainerResolver }) => new ProjectGroupContainerMetricsHook(projectGroupContainerResolver)).addService("promRegistry", ({ promRegistryFactory, projectGroupContainerMetricsHook }) => {
|
|
63
74
|
const registry = promRegistryFactory.create();
|
|
64
75
|
projectGroupContainerMetricsHook.register(registry);
|
|
65
76
|
return registry;
|
|
@@ -71,7 +82,7 @@ class MasterContainerFactory {
|
|
|
71
82
|
serverConfig2.projectGroup?.configEncryptionKey ? new CryptoWrapper(encryptionKey) : void 0,
|
|
72
83
|
projectGroupContainerResolver
|
|
73
84
|
);
|
|
74
|
-
}).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 }) => new ContentApiControllerFactory(notModifiedChecker, contentGraphqlContextFactory, contentQueryHandlerFactory, projectContextResolver)).addService("tenantGraphQLContextFactory", () => new TenantGraphQLContextFactory()).addService("tenantApiMiddlewareFactory", ({ debugMode: debugMode2, projectGroupResolver, tenantGraphQLContextFactory }) => new TenantApiMiddlewareFactory(debugMode2, projectGroupResolver, tenantGraphQLContextFactory)).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
|
+
}).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("tenantGraphQLContextFactory", () => new TenantGraphQLContextFactory()).addService("tenantApiMiddlewareFactory", ({ debugMode: debugMode2, projectGroupResolver, tenantGraphQLContextFactory }) => new TenantApiMiddlewareFactory(debugMode2, projectGroupResolver, tenantGraphQLContextFactory)).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 }) => {
|
|
75
86
|
const app = new Application(
|
|
76
87
|
projectGroupResolver,
|
|
77
88
|
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, TenantGraphQLContextFactory, TenantGraphQLHandlerFactory } from './tenant'\nimport { SystemApiMiddlewareFactory, SystemGraphQLContextFactory, SystemGraphQLHandlerFactory } from './system'\nimport { ContentApiControllerFactory, ContentGraphQLContextFactory, ContentQueryHandlerFactory, NotModifiedChecker } 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'\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('projectContainerFactoryFactory', ({ plugins, providers, serverConfig, graphQlSchemaBuilderFactory, contentPermissionFactory, databaseMetadataResolver }) =>\n\t\t\t\tnew ProjectContainerFactoryFactory(plugins, providers, serverConfig, graphQlSchemaBuilderFactory, contentPermissionFactory, 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 }) =>\n\t\t\t\tnew ContentApiControllerFactory(notModifiedChecker, contentGraphqlContextFactory, contentQueryHandlerFactory, projectContextResolver))\n\t\t\t.addService('tenantGraphQLContextFactory', () =>\n\t\t\t\tnew TenantGraphQLContextFactory())\n\t\t\t.addService('tenantApiMiddlewareFactory', ({ debugMode, projectGroupResolver, tenantGraphQLContextFactory }) =>\n\t\t\t\tnew TenantApiMiddlewareFactory(debugMode, projectGroupResolver, tenantGraphQLContextFactory))\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":["plugins","serverConfig","debugMode","projectConfigResolver","logger","tenantConfigResolver","processType","version"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqEO,MAAM,uBAAuB;AAAA,EAEnC,cAAc,MAAmD;AAC1D,UAAA,UAAU,KAAK,sBAAs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ACP;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 { 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, TenantGraphQLContextFactory, 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('tenantGraphQLContextFactory', () =>\n\t\t\t\tnew TenantGraphQLContextFactory())\n\t\t\t.addService('tenantApiMiddlewareFactory', ({ debugMode, projectGroupResolver, tenantGraphQLContextFactory }) =>\n\t\t\t\tnew TenantApiMiddlewareFactory(debugMode, projectGroupResolver, tenantGraphQLContextFactory))\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":";;;;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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;"}
|
|
@@ -4,11 +4,12 @@ const HttpResponse = require("../common/HttpResponse.cjs");
|
|
|
4
4
|
const engineSystemApi = require("@contember/engine-system-api");
|
|
5
5
|
const debugHeader = "x-contember-debug";
|
|
6
6
|
class ContentApiControllerFactory {
|
|
7
|
-
constructor(notModifiedChecker, contentGraphqlContextFactory, handlerFactory, projectContextResolver) {
|
|
7
|
+
constructor(notModifiedChecker, contentGraphqlContextFactory, handlerFactory, projectContextResolver, graphQlSchemaFactory) {
|
|
8
8
|
this.notModifiedChecker = notModifiedChecker;
|
|
9
9
|
this.contentGraphqlContextFactory = contentGraphqlContextFactory;
|
|
10
10
|
this.handlerFactory = handlerFactory;
|
|
11
11
|
this.projectContextResolver = projectContextResolver;
|
|
12
|
+
this.graphQlSchemaFactory = graphQlSchemaFactory;
|
|
12
13
|
}
|
|
13
14
|
create() {
|
|
14
15
|
const handlerCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -63,9 +64,9 @@ class ContentApiControllerFactory {
|
|
|
63
64
|
const projectRoles = memberships.map((it) => it.role);
|
|
64
65
|
const { schema: graphQlSchema, permissions } = await timer(
|
|
65
66
|
"GraphQLSchemaCreate",
|
|
66
|
-
() =>
|
|
67
|
+
() => this.graphQlSchemaFactory.create(schema, {
|
|
67
68
|
projectRoles
|
|
68
|
-
})
|
|
69
|
+
}, project)
|
|
69
70
|
);
|
|
70
71
|
const schemaDatabaseMetadata = await projectContainer.projectDatabaseMetadataResolver.resolveDatabaseMetadata(systemDatabase, schema, stage.schema);
|
|
71
72
|
const handler = await (async () => {
|
|
@@ -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'\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) {\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() =>
|
|
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;AAG5B,YAAM,iBAAiB,MAAM,iBAAiB,sBAAsB,UAAU,EAAE,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AAA,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;;"}
|
|
@@ -2,11 +2,12 @@ import { HttpErrorResponse, HttpResponse } from "../common/HttpResponse.js";
|
|
|
2
2
|
import { StageBySlugQuery } from "@contember/engine-system-api";
|
|
3
3
|
const debugHeader = "x-contember-debug";
|
|
4
4
|
class ContentApiControllerFactory {
|
|
5
|
-
constructor(notModifiedChecker, contentGraphqlContextFactory, handlerFactory, projectContextResolver) {
|
|
5
|
+
constructor(notModifiedChecker, contentGraphqlContextFactory, handlerFactory, projectContextResolver, graphQlSchemaFactory) {
|
|
6
6
|
this.notModifiedChecker = notModifiedChecker;
|
|
7
7
|
this.contentGraphqlContextFactory = contentGraphqlContextFactory;
|
|
8
8
|
this.handlerFactory = handlerFactory;
|
|
9
9
|
this.projectContextResolver = projectContextResolver;
|
|
10
|
+
this.graphQlSchemaFactory = graphQlSchemaFactory;
|
|
10
11
|
}
|
|
11
12
|
create() {
|
|
12
13
|
const handlerCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -61,9 +62,9 @@ class ContentApiControllerFactory {
|
|
|
61
62
|
const projectRoles = memberships.map((it) => it.role);
|
|
62
63
|
const { schema: graphQlSchema, permissions } = await timer(
|
|
63
64
|
"GraphQLSchemaCreate",
|
|
64
|
-
() =>
|
|
65
|
+
() => this.graphQlSchemaFactory.create(schema, {
|
|
65
66
|
projectRoles
|
|
66
|
-
})
|
|
67
|
+
}, project)
|
|
67
68
|
);
|
|
68
69
|
const schemaDatabaseMetadata = await projectContainer.projectDatabaseMetadataResolver.resolveDatabaseMetadata(systemDatabase, schema, stage.schema);
|
|
69
70
|
const handler = await (async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentApiControllerFactory.js","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'\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) {\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() =>
|
|
1
|
+
{"version":3,"file":"ContentApiControllerFactory.js","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":["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,IAAI,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,IAAI,iBAAiB,OAAO,SAAS,CAAC;AAC5F,UAAI,CAAC,OAAO;AACX,eAAO,IAAI,kBAAkB,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,IAAI,aAA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,KAAK,eAAe,OAAO,aAAa;AACpD,qBAAA,IAAI,eAAe,UAAU;AACnC,eAAA;AAAA,MAAA,GACL;AAEG,YAAA,OAAO,MAAM,OAAMA,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentGraphQLContextFactory.cjs","sources":["../../../../../packages/engine-http/src/content/ContentGraphQLContextFactory.ts"],"sourcesContent":["import { Context, createAclVariables, ExecutionContainerFactory } from '@contember/engine-content-api'\nimport { Client, DatabaseMetadata } from '@contember/database'\nimport { Acl, Schema } from '@contember/schema'\nimport { AuthResult } from '../common'\nimport { Timer } from '../application'\nimport { Providers } from '../providers'\nimport { ParsedMembership } from '@contember/schema-utils'\nimport { Stage } from '@contember/engine-system-api'\nimport { ProjectConfig } from '../project/config'\n\nexport type ExtendedGraphqlContext = Context & {\n\tidentityId: string\n\trequestDebug: boolean\n}\n\nexport class ContentGraphQLContextFactory {\n\tconstructor(\n\t\tprivate providers: Providers,\n\t\tprivate executionContainerFactory: ExecutionContainerFactory,\n\t) {\n\t}\n\n\tcreate({ db, schema, schemaMeta, schemaDatabaseMetadata, authResult, memberships, permissions, timer, requestDebug, systemSchema, stage, project }: {\n\t\tdb: Client\n\t\tschema: Schema\n\t\tschemaMeta: { id?: number }\n\t\tschemaDatabaseMetadata: DatabaseMetadata\n\t\tpermissions: Acl.Permissions\n\t\tauthResult: AuthResult\n\t\tmemberships: readonly ParsedMembership[]\n\t\ttimer: Timer\n\t\trequestDebug: boolean\n\t\tsystemSchema: string\n\t\tstage: Stage\n\t\tproject: ProjectConfig\n\t}): ExtendedGraphqlContext {\n\t\tconst identityVariables = createAclVariables(schema.acl, memberships)\n\t\tlet identityId = authResult.identityId\n\t\tif (\n\t\t\tauthResult.assumedIdentityId &&\n\t\t\tmemberships.some(it => schema.acl.roles[it.role].system?.assumeIdentity)\n\t\t) {\n\t\t\tidentityId = authResult.assumedIdentityId\n\t\t}\n\n\t\tconst executionContainer = this.executionContainerFactory.create({\n\t\t\tdb,\n\t\t\tidentityVariables,\n\t\t\tidentityId,\n\t\t\tschema,\n\t\t\tschemaMeta,\n\t\t\tschemaDatabaseMetadata,\n\t\t\tpermissions,\n\t\t\tsystemSchema,\n\t\t\tstage,\n\t\t\tproject,\n\t\t})\n\n\t\treturn {\n\t\t\tdb,\n\t\t\tidentityVariables,\n\t\t\tidentityId,\n\t\t\texecutionContainer,\n\t\t\ttimer,\n\t\t\trequestDebug,\n\t\t}\n\t}\n}\n"],"names":["createAclVariables"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ContentGraphQLContextFactory.cjs","sources":["../../../../../packages/engine-http/src/content/ContentGraphQLContextFactory.ts"],"sourcesContent":["import { Context, createAclVariables, ExecutionContainerFactory } from '@contember/engine-content-api'\nimport { Client, DatabaseMetadata } from '@contember/database'\nimport { Acl, Schema } from '@contember/schema'\nimport { AuthResult } from '../common'\nimport { Timer } from '../application'\nimport { Providers } from '../providers'\nimport { ParsedMembership } from '@contember/schema-utils'\nimport { Stage } from '@contember/engine-system-api'\nimport { ProjectConfig } from '../project/config'\n\nexport type ExtendedGraphqlContext = Context & {\n\tidentityId: string\n\trequestDebug: boolean\n\tproject: { slug: string }\n}\n\nexport class ContentGraphQLContextFactory {\n\tconstructor(\n\t\tprivate providers: Providers,\n\t\tprivate executionContainerFactory: ExecutionContainerFactory,\n\t) {\n\t}\n\n\tcreate({ db, schema, schemaMeta, schemaDatabaseMetadata, authResult, memberships, permissions, timer, requestDebug, systemSchema, stage, project }: {\n\t\tdb: Client\n\t\tschema: Schema\n\t\tschemaMeta: { id?: number }\n\t\tschemaDatabaseMetadata: DatabaseMetadata\n\t\tpermissions: Acl.Permissions\n\t\tauthResult: AuthResult\n\t\tmemberships: readonly ParsedMembership[]\n\t\ttimer: Timer\n\t\trequestDebug: boolean\n\t\tsystemSchema: string\n\t\tstage: Stage\n\t\tproject: ProjectConfig\n\t}): ExtendedGraphqlContext {\n\t\tconst identityVariables = createAclVariables(schema.acl, memberships)\n\t\tlet identityId = authResult.identityId\n\t\tif (\n\t\t\tauthResult.assumedIdentityId &&\n\t\t\tmemberships.some(it => schema.acl.roles[it.role].system?.assumeIdentity)\n\t\t) {\n\t\t\tidentityId = authResult.assumedIdentityId\n\t\t}\n\n\t\tconst executionContainer = this.executionContainerFactory.create({\n\t\t\tdb,\n\t\t\tidentityVariables,\n\t\t\tidentityId,\n\t\t\tschema,\n\t\t\tschemaMeta,\n\t\t\tschemaDatabaseMetadata,\n\t\t\tpermissions,\n\t\t\tsystemSchema,\n\t\t\tstage,\n\t\t\tproject,\n\t\t})\n\n\t\treturn {\n\t\t\tdb,\n\t\t\tidentityVariables,\n\t\t\tidentityId,\n\t\t\texecutionContainer,\n\t\t\ttimer,\n\t\t\trequestDebug,\n\t\t\tproject,\n\t\t}\n\t}\n}\n"],"names":["createAclVariables"],"mappings":";;;AAgBO,MAAM,6BAA6B;AAAA,EACzC,YACS,WACA,2BACP;AAFO,SAAA,YAAA;AACA,SAAA,4BAAA;AAAA,EAAA;AAAA,EAIT,OAAO,EAAE,IAAI,QAAQ,YAAY,wBAAwB,YAAY,aAAa,aAAa,OAAO,cAAc,cAAc,OAAO,WAa9G;AAC1B,UAAM,oBAAoBA,iBAAA,mBAAmB,OAAO,KAAK,WAAW;AACpE,QAAI,aAAa,WAAW;AAC5B,QACC,WAAW,qBACX,YAAY,KAAK,CAAM,OAAA,OAAO,IAAI,MAAM,GAAG,IAAI,EAAE,QAAQ,cAAc,GACtE;AACD,mBAAa,WAAW;AAAA,IAAA;AAGnB,UAAA,qBAAqB,KAAK,0BAA0B,OAAO;AAAA,MAChE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,CACA;AAEM,WAAA;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EAAA;AAEF;;"}
|