@contember/engine-http 2.0.0-alpha.12 → 2.0.0-alpha.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/development/src/MasterContainer.cjs +1 -1
- package/dist/development/src/MasterContainer.js +1 -1
- package/dist/development/src/content/ContentApiControllerFactory.cjs +3 -1
- package/dist/development/src/content/ContentApiControllerFactory.cjs.map +1 -1
- package/dist/development/src/content/ContentApiControllerFactory.js +3 -1
- 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 +27 -17
- package/dist/development/src/content/ContentSchemaResolver.cjs.map +1 -1
- package/dist/development/src/content/ContentSchemaResolver.js +28 -18
- package/dist/development/src/content/ContentSchemaResolver.js.map +1 -1
- package/dist/development/src/project/ProjectContainer.cjs +5 -5
- package/dist/development/src/project/ProjectContainer.cjs.map +1 -1
- package/dist/development/src/project/ProjectContainer.js +5 -5
- package/dist/development/src/project/ProjectContainer.js.map +1 -1
- package/dist/development/src/project/ProjectSchemaResolver.cjs +2 -2
- package/dist/development/src/project/ProjectSchemaResolver.cjs.map +1 -1
- package/dist/development/src/project/ProjectSchemaResolver.js +2 -2
- package/dist/development/src/project/ProjectSchemaResolver.js.map +1 -1
- package/dist/development/src/projectGroup/ProjectGroupContainer.cjs +2 -2
- package/dist/development/src/projectGroup/ProjectGroupContainer.cjs.map +1 -1
- package/dist/development/src/projectGroup/ProjectGroupContainer.js +2 -2
- package/dist/development/src/projectGroup/ProjectGroupContainer.js.map +1 -1
- package/dist/development/src/system/ContentQueryExecutor.cjs +2 -1
- package/dist/development/src/system/ContentQueryExecutor.cjs.map +1 -1
- package/dist/development/src/system/ContentQueryExecutor.js +2 -1
- package/dist/development/src/system/ContentQueryExecutor.js.map +1 -1
- package/dist/development/src/system/SystemGraphQLContextFactory.cjs +9 -8
- package/dist/development/src/system/SystemGraphQLContextFactory.cjs.map +1 -1
- package/dist/development/src/system/SystemGraphQLContextFactory.js +9 -8
- package/dist/development/src/system/SystemGraphQLContextFactory.js.map +1 -1
- package/dist/development/src/transfer/ContentSchemaTransferMappingFactory.cjs.map +1 -1
- package/dist/development/src/transfer/ContentSchemaTransferMappingFactory.js.map +1 -1
- package/dist/development/src/transfer/ExportApiControllerFactory.cjs +3 -1
- package/dist/development/src/transfer/ExportApiControllerFactory.cjs.map +1 -1
- package/dist/development/src/transfer/ExportApiControllerFactory.js +3 -1
- package/dist/development/src/transfer/ExportApiControllerFactory.js.map +1 -1
- package/dist/development/src/transfer/ExportExecutor.cjs +3 -3
- package/dist/development/src/transfer/ExportExecutor.cjs.map +1 -1
- package/dist/development/src/transfer/ExportExecutor.js +3 -3
- package/dist/development/src/transfer/ExportExecutor.js.map +1 -1
- package/dist/development/src/transfer/ImportExecutor.cjs +5 -5
- package/dist/development/src/transfer/ImportExecutor.cjs.map +1 -1
- package/dist/development/src/transfer/ImportExecutor.js +5 -5
- package/dist/development/src/transfer/ImportExecutor.js.map +1 -1
- package/dist/production/src/MasterContainer.cjs +1 -1
- package/dist/production/src/MasterContainer.js +1 -1
- package/dist/production/src/content/ContentApiControllerFactory.cjs +3 -1
- package/dist/production/src/content/ContentApiControllerFactory.cjs.map +1 -1
- package/dist/production/src/content/ContentApiControllerFactory.js +3 -1
- 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 +27 -17
- package/dist/production/src/content/ContentSchemaResolver.cjs.map +1 -1
- package/dist/production/src/content/ContentSchemaResolver.js +28 -18
- package/dist/production/src/content/ContentSchemaResolver.js.map +1 -1
- package/dist/production/src/project/ProjectContainer.cjs +5 -5
- package/dist/production/src/project/ProjectContainer.cjs.map +1 -1
- package/dist/production/src/project/ProjectContainer.js +5 -5
- package/dist/production/src/project/ProjectContainer.js.map +1 -1
- package/dist/production/src/project/ProjectSchemaResolver.cjs +2 -2
- package/dist/production/src/project/ProjectSchemaResolver.cjs.map +1 -1
- package/dist/production/src/project/ProjectSchemaResolver.js +2 -2
- package/dist/production/src/project/ProjectSchemaResolver.js.map +1 -1
- package/dist/production/src/projectGroup/ProjectGroupContainer.cjs +2 -2
- package/dist/production/src/projectGroup/ProjectGroupContainer.cjs.map +1 -1
- package/dist/production/src/projectGroup/ProjectGroupContainer.js +2 -2
- package/dist/production/src/projectGroup/ProjectGroupContainer.js.map +1 -1
- package/dist/production/src/system/ContentQueryExecutor.cjs +2 -1
- package/dist/production/src/system/ContentQueryExecutor.cjs.map +1 -1
- package/dist/production/src/system/ContentQueryExecutor.js +2 -1
- package/dist/production/src/system/ContentQueryExecutor.js.map +1 -1
- package/dist/production/src/system/SystemGraphQLContextFactory.cjs +9 -8
- package/dist/production/src/system/SystemGraphQLContextFactory.cjs.map +1 -1
- package/dist/production/src/system/SystemGraphQLContextFactory.js +9 -8
- package/dist/production/src/system/SystemGraphQLContextFactory.js.map +1 -1
- package/dist/production/src/transfer/ContentSchemaTransferMappingFactory.cjs.map +1 -1
- package/dist/production/src/transfer/ContentSchemaTransferMappingFactory.js.map +1 -1
- package/dist/production/src/transfer/ExportApiControllerFactory.cjs +3 -1
- package/dist/production/src/transfer/ExportApiControllerFactory.cjs.map +1 -1
- package/dist/production/src/transfer/ExportApiControllerFactory.js +3 -1
- package/dist/production/src/transfer/ExportApiControllerFactory.js.map +1 -1
- package/dist/production/src/transfer/ExportExecutor.cjs +3 -3
- package/dist/production/src/transfer/ExportExecutor.cjs.map +1 -1
- package/dist/production/src/transfer/ExportExecutor.js +3 -3
- package/dist/production/src/transfer/ExportExecutor.js.map +1 -1
- package/dist/production/src/transfer/ImportExecutor.cjs +5 -5
- package/dist/production/src/transfer/ImportExecutor.cjs.map +1 -1
- package/dist/production/src/transfer/ImportExecutor.js +5 -5
- package/dist/production/src/transfer/ImportExecutor.js.map +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/dist/types/content/ContentApiControllerFactory.d.ts.map +1 -1
- package/dist/types/content/ContentGraphQLContextFactory.d.ts +4 -3
- package/dist/types/content/ContentGraphQLContextFactory.d.ts.map +1 -1
- package/dist/types/content/ContentSchemaResolver.d.ts +8 -5
- package/dist/types/content/ContentSchemaResolver.d.ts.map +1 -1
- package/dist/types/project/ProjectContainer.d.ts +4 -4
- package/dist/types/project/ProjectContainer.d.ts.map +1 -1
- package/dist/types/project/ProjectSchemaResolver.d.ts +1 -1
- package/dist/types/project/ProjectSchemaResolver.d.ts.map +1 -1
- package/dist/types/projectGroup/ProjectGroupContainer.d.ts +1 -1
- package/dist/types/projectGroup/ProjectGroupContainer.d.ts.map +1 -1
- package/dist/types/system/ContentQueryExecutor.d.ts +1 -1
- package/dist/types/system/ContentQueryExecutor.d.ts.map +1 -1
- package/dist/types/system/SystemGraphQLContextFactory.d.ts.map +1 -1
- package/dist/types/transfer/ContentSchemaTransferMappingFactory.d.ts +2 -2
- package/dist/types/transfer/ContentSchemaTransferMappingFactory.d.ts.map +1 -1
- package/dist/types/transfer/ExportApiControllerFactory.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +15 -15
- package/src/content/ContentApiControllerFactory.ts +3 -2
- package/src/content/ContentGraphQLContextFactory.ts +4 -2
- package/src/content/ContentSchemaResolver.ts +32 -16
- package/src/project/ProjectContainer.ts +6 -6
- package/src/project/ProjectSchemaResolver.ts +3 -3
- package/src/projectGroup/ProjectGroupContainer.ts +15 -7
- package/src/system/ContentQueryExecutor.ts +2 -1
- package/src/system/SystemGraphQLContextFactory.ts +8 -7
- package/src/transfer/ContentSchemaTransferMappingFactory.ts +2 -3
- package/src/transfer/ExportApiControllerFactory.ts +3 -1
- package/src/transfer/ExportExecutor.ts +3 -3
- package/src/transfer/ImportExecutor.ts +5 -5
|
@@ -20,7 +20,7 @@ const SystemGraphQLHandlerFactory = require("./system/SystemGraphQLHandlerFactor
|
|
|
20
20
|
const ContentApiControllerFactory = require("./content/ContentApiControllerFactory.cjs");
|
|
21
21
|
const ContentGraphQLContextFactory = require("./content/ContentGraphQLContextFactory.cjs");
|
|
22
22
|
const ContentQueryHandlerFactory = require("./content/ContentQueryHandlerFactory.cjs");
|
|
23
|
-
require("
|
|
23
|
+
require("./content/ContentSchemaResolver.cjs");
|
|
24
24
|
require("graphql");
|
|
25
25
|
const NotModifiedChecker = require("./content/NotModifiedChecker.cjs");
|
|
26
26
|
require("./content/ProjectMembershipResolver.cjs");
|
|
@@ -18,7 +18,7 @@ import { SystemGraphQLHandlerFactory } from "./system/SystemGraphQLHandlerFactor
|
|
|
18
18
|
import { ContentApiControllerFactory } from "./content/ContentApiControllerFactory.js";
|
|
19
19
|
import { ContentGraphQLContextFactory } from "./content/ContentGraphQLContextFactory.js";
|
|
20
20
|
import { ContentQueryHandlerFactory } from "./content/ContentQueryHandlerFactory.js";
|
|
21
|
-
import "
|
|
21
|
+
import "./content/ContentSchemaResolver.js";
|
|
22
22
|
import "graphql";
|
|
23
23
|
import { NotModifiedChecker } from "./content/NotModifiedChecker.js";
|
|
24
24
|
import "./content/ProjectMembershipResolver.js";
|
|
@@ -36,7 +36,8 @@ class ContentApiControllerFactory {
|
|
|
36
36
|
if (notModifiedRes?.isModified === false) {
|
|
37
37
|
return new HttpResponse.HttpResponse(304);
|
|
38
38
|
}
|
|
39
|
-
const
|
|
39
|
+
const schemaWithMeta = await projectContainer.contentSchemaResolver.getSchema({ db: systemDatabase, stage: stage.slug, normalize: true });
|
|
40
|
+
const schema = schemaWithMeta.schema;
|
|
40
41
|
const { effective: memberships, fetched: fetchedMemberships } = await timer(
|
|
41
42
|
"MembershipFetch",
|
|
42
43
|
() => projectGroup.projectMembershipResolver.resolveMemberships({
|
|
@@ -94,6 +95,7 @@ class ContentApiControllerFactory {
|
|
|
94
95
|
permissions,
|
|
95
96
|
schemaDatabaseMetadata,
|
|
96
97
|
schema,
|
|
98
|
+
schemaMeta: { id: schemaWithMeta.meta.id },
|
|
97
99
|
timer,
|
|
98
100
|
requestDebug,
|
|
99
101
|
systemSchema: projectContainer.systemDatabaseContextFactory.schemaName,
|
|
@@ -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
|
|
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() => projectContainer.graphQlSchemaFactory.create(schema, {\n\t\t\t\t\tprojectRoles: projectRoles,\n\t\t\t\t}),\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":";;;;AAUA,MAAM,cAAc;AAEb,MAAM,4BAA4B;AAAA,EACxC,YACkB,oBACA,8BACA,gBACA,wBAChB;AAJgB,SAAA,qBAAA;AACA,SAAA,+BAAA;AACA,SAAA,iBAAA;AACA,SAAA,yBAAA;AAAA,EAElB;AAAA,EAEA,SAAyB;AAClB,UAAA,mCAAmB;AACzB,WAAO,OAAM,YAAW;AACvB,YAAM,EAAE,QAAQ,OAAO,cAAc,YAAY,SAAS,IAAQ,IAAA;AAClE,UAAI,CAAC,YAAY;AACT,eAAA,IAAIA,aAAkB,kBAAA,KAAK,yBAAyB;AAAA,MAC5D;AACM,YAAA,EAAE,kBAAkB,YAAY,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,iCAAiB,OAAO,SAAS,CAAC;AAC5F,UAAI,CAAC,OAAO;AACX,eAAO,IAAID,aAAAA,kBAAkB,KAAK,SAAS,OAAO,SAAS,YAAY;AAAA,MACxE;AACA,YAAM,iBAAiB,MAAM,KAAK,mBAAmB,iBAAiB;AAAA,QACrE,SAAS,QAAQ;AAAA,QACjB,MAAM,QAAQ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,MAAM;AAE5I,YAAA,UAAU,OAAO,YAAY;AAC5B,cAAA,kBAAkB,aAAa,IAAI,aAAa;AACtD,YAAI,iBAAiB;AACb,iBAAA;AAAA,QACR;AACA,cAAM,aAAa,MAAM,KAAK,eAAe,OAAO,aAAa;AACpD,qBAAA,IAAI,eAAe,UAAU;AACnC,eAAA;AAAA,MAAA;AAGF,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,YAAA;AAGhB,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,UACF;AAAA,QACA,CAAA,CAAC;AACFA,gBAAO,MAAM,wBAAwB;AAAA,MAAA,CACrC;AAGe,sBAAA,kBAAkB,QAAQ,QAAQ;AAAA,IAAA;AAAA,EAEpD;AACD;;"}
|
|
@@ -34,7 +34,8 @@ class ContentApiControllerFactory {
|
|
|
34
34
|
if (notModifiedRes?.isModified === false) {
|
|
35
35
|
return new HttpResponse(304);
|
|
36
36
|
}
|
|
37
|
-
const
|
|
37
|
+
const schemaWithMeta = await projectContainer.contentSchemaResolver.getSchema({ db: systemDatabase, stage: stage.slug, normalize: true });
|
|
38
|
+
const schema = schemaWithMeta.schema;
|
|
38
39
|
const { effective: memberships, fetched: fetchedMemberships } = await timer(
|
|
39
40
|
"MembershipFetch",
|
|
40
41
|
() => projectGroup.projectMembershipResolver.resolveMemberships({
|
|
@@ -92,6 +93,7 @@ class ContentApiControllerFactory {
|
|
|
92
93
|
permissions,
|
|
93
94
|
schemaDatabaseMetadata,
|
|
94
95
|
schema,
|
|
96
|
+
schemaMeta: { id: schemaWithMeta.meta.id },
|
|
95
97
|
timer,
|
|
96
98
|
requestDebug,
|
|
97
99
|
systemSchema: projectContainer.systemDatabaseContextFactory.schemaName,
|
|
@@ -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
|
|
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() => projectContainer.graphQlSchemaFactory.create(schema, {\n\t\t\t\t\tprojectRoles: projectRoles,\n\t\t\t\t}),\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":";;AAUA,MAAM,cAAc;AAEb,MAAM,4BAA4B;AAAA,EACxC,YACkB,oBACA,8BACA,gBACA,wBAChB;AAJgB,SAAA,qBAAA;AACA,SAAA,+BAAA;AACA,SAAA,iBAAA;AACA,SAAA,yBAAA;AAAA,EAElB;AAAA,EAEA,SAAyB;AAClB,UAAA,mCAAmB;AACzB,WAAO,OAAM,YAAW;AACvB,YAAM,EAAE,QAAQ,OAAO,cAAc,YAAY,SAAS,IAAQ,IAAA;AAClE,UAAI,CAAC,YAAY;AACT,eAAA,IAAI,kBAAkB,KAAK,yBAAyB;AAAA,MAC5D;AACM,YAAA,EAAE,kBAAkB,YAAY,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,MACxE;AACA,YAAM,iBAAiB,MAAM,KAAK,mBAAmB,iBAAiB;AAAA,QACrE,SAAS,QAAQ;AAAA,QACjB,MAAM,QAAQ;AAAA,QACd,OAAO,QAAQ;AAAA,QACf;AAAA,Q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,aAAa,IAAI,aAAa;AACtD,YAAI,iBAAiB;AACb,iBAAA;AAAA,QACR;AACA,cAAM,aAAa,MAAM,KAAK,eAAe,OAAO,aAAa;AACpD,qBAAA,IAAI,eAAe,UAAU;AACnC,eAAA;AAAA,MAAA;AAGF,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,YAAA;AAGhB,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,UACF;AAAA,QACA,CAAA,CAAC;AACFA,gBAAO,MAAM,wBAAwB;AAAA,MAAA,CACrC;AAGe,sBAAA,kBAAkB,QAAQ,QAAQ;AAAA,IAAA;AAAA,EAEpD;AACD;"}
|
|
@@ -6,7 +6,7 @@ class ContentGraphQLContextFactory {
|
|
|
6
6
|
this.providers = providers;
|
|
7
7
|
this.executionContainerFactory = executionContainerFactory;
|
|
8
8
|
}
|
|
9
|
-
create({ db, schema, schemaDatabaseMetadata, authResult, memberships, permissions, timer, requestDebug, systemSchema, stage, project }) {
|
|
9
|
+
create({ db, schema, schemaMeta, schemaDatabaseMetadata, authResult, memberships, permissions, timer, requestDebug, systemSchema, stage, project }) {
|
|
10
10
|
const identityVariables = engineContentApi.createAclVariables(schema.acl, memberships);
|
|
11
11
|
let identityId = authResult.identityId;
|
|
12
12
|
if (authResult.assumedIdentityId && memberships.some((it) => schema.acl.roles[it.role].system?.assumeIdentity)) {
|
|
@@ -17,6 +17,7 @@ class ContentGraphQLContextFactory {
|
|
|
17
17
|
identityVariables,
|
|
18
18
|
identityId,
|
|
19
19
|
schema,
|
|
20
|
+
schemaMeta,
|
|
20
21
|
schemaDatabaseMetadata,
|
|
21
22
|
permissions,
|
|
22
23
|
systemSchema,
|
|
@@ -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, schemaDatabaseMetadata, authResult, memberships, permissions, timer, requestDebug, systemSchema, stage, project }: {\n\t\tdb: Client\n\t\tschema: Schema
|
|
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":";;;AAeO,MAAM,6BAA6B;AAAA,EACzC,YACS,WACA,2BACP;AAFO,SAAA,YAAA;AACA,SAAA,4BAAA;AAAA,EAET;AAAA,EAEA,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,IACzB;AAEM,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,IAAA;AAAA,EAEF;AACD;;"}
|
|
@@ -4,7 +4,7 @@ class ContentGraphQLContextFactory {
|
|
|
4
4
|
this.providers = providers;
|
|
5
5
|
this.executionContainerFactory = executionContainerFactory;
|
|
6
6
|
}
|
|
7
|
-
create({ db, schema, schemaDatabaseMetadata, authResult, memberships, permissions, timer, requestDebug, systemSchema, stage, project }) {
|
|
7
|
+
create({ db, schema, schemaMeta, schemaDatabaseMetadata, authResult, memberships, permissions, timer, requestDebug, systemSchema, stage, project }) {
|
|
8
8
|
const identityVariables = createAclVariables(schema.acl, memberships);
|
|
9
9
|
let identityId = authResult.identityId;
|
|
10
10
|
if (authResult.assumedIdentityId && memberships.some((it) => schema.acl.roles[it.role].system?.assumeIdentity)) {
|
|
@@ -15,6 +15,7 @@ class ContentGraphQLContextFactory {
|
|
|
15
15
|
identityVariables,
|
|
16
16
|
identityId,
|
|
17
17
|
schema,
|
|
18
|
+
schemaMeta,
|
|
18
19
|
schemaDatabaseMetadata,
|
|
19
20
|
permissions,
|
|
20
21
|
systemSchema,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentGraphQLContextFactory.js","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, schemaDatabaseMetadata, authResult, memberships, permissions, timer, requestDebug, systemSchema, stage, project }: {\n\t\tdb: Client\n\t\tschema: Schema
|
|
1
|
+
{"version":3,"file":"ContentGraphQLContextFactory.js","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":[],"mappings":";AAeO,MAAM,6BAA6B;AAAA,EACzC,YACS,WACA,2BACP;AAFO,SAAA,YAAA;AACA,SAAA,4BAAA;AAAA,EAET;AAAA,EAEA,OAAO,EAAE,IAAI,QAAQ,YAAY,wBAAwB,YAAY,aAAa,aAAa,OAAO,cAAc,cAAc,OAAO,WAa9G;AAC1B,UAAM,oBAAoB,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,IACzB;AAEM,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,IAAA;AAAA,EAEF;AACD;"}
|
|
@@ -1,31 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const schemaUtils = require("@contember/schema-utils");
|
|
4
|
+
const ContentApiSpecificCache = require("./ContentApiSpecificCache.cjs");
|
|
4
5
|
var __defProp = Object.defineProperty;
|
|
5
6
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj,
|
|
7
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, key + "", value);
|
|
7
8
|
class ContentSchemaResolver {
|
|
8
|
-
constructor(
|
|
9
|
-
this.
|
|
10
|
-
__publicField(this, "baseSchemaCache");
|
|
11
|
-
__publicField(this, "stageSchemaCache", {});
|
|
9
|
+
constructor(schemaProvider) {
|
|
10
|
+
this.schemaProvider = schemaProvider;
|
|
11
|
+
__publicField(this, "baseSchemaCache", null);
|
|
12
12
|
}
|
|
13
13
|
clearCache() {
|
|
14
|
-
this.baseSchemaCache =
|
|
15
|
-
this.stageSchemaCache = {};
|
|
14
|
+
this.baseSchemaCache = null;
|
|
16
15
|
}
|
|
17
|
-
async getSchema(db, stage) {
|
|
18
|
-
var _a;
|
|
16
|
+
async getSchema({ db, stage, normalize }) {
|
|
19
17
|
const prevBaseSchema = this.baseSchemaCache;
|
|
20
|
-
this.baseSchemaCache = await this.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
return (_a = this.stageSchemaCache)[stage] ?? (_a[stage] = schemaUtils.filterSchemaByStage(this.baseSchemaCache, stage));
|
|
18
|
+
this.baseSchemaCache = await this.schemaProvider.fetch({ db, currentSchema: prevBaseSchema });
|
|
19
|
+
const finalSchema = getSchema(this.baseSchemaCache.schema, { stage, normalize });
|
|
20
|
+
return {
|
|
21
|
+
schema: finalSchema,
|
|
22
|
+
meta: this.baseSchemaCache.meta
|
|
23
|
+
};
|
|
28
24
|
}
|
|
29
25
|
}
|
|
26
|
+
const cache = new ContentApiSpecificCache.ContentApiSpecificCache({});
|
|
27
|
+
const getSchema = (schema, options) => {
|
|
28
|
+
const cacheKey = [options.stage, options.normalize].join("ÿ");
|
|
29
|
+
return cache.fetch(schema, cacheKey, () => {
|
|
30
|
+
const result = schema;
|
|
31
|
+
if (options.normalize) {
|
|
32
|
+
return schemaUtils.normalizeSchema(result);
|
|
33
|
+
}
|
|
34
|
+
if (options.stage) {
|
|
35
|
+
return schemaUtils.filterSchemaByStage(result, options.stage);
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
});
|
|
39
|
+
};
|
|
30
40
|
exports.ContentSchemaResolver = ContentSchemaResolver;
|
|
31
41
|
//# sourceMappingURL=ContentSchemaResolver.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentSchemaResolver.cjs","sources":["../../../../../packages/engine-http/src/content/ContentSchemaResolver.ts"],"sourcesContent":["import { DatabaseContext,
|
|
1
|
+
{"version":3,"file":"ContentSchemaResolver.cjs","sources":["../../../../../packages/engine-http/src/content/ContentSchemaResolver.ts"],"sourcesContent":["import { DatabaseContext, SchemaProvider, SchemaWithMeta } from '@contember/engine-system-api'\nimport { filterSchemaByStage, normalizeSchema } from '@contember/schema-utils'\nimport { Schema } from '@contember/schema'\nimport { ContentApiSpecificCache } from './ContentApiSpecificCache'\n\nexport class ContentSchemaResolver {\n\tprivate baseSchemaCache: SchemaWithMeta | null = null\n\n\tconstructor(private readonly schemaProvider: SchemaProvider) {\n\t}\n\n\tpublic clearCache() {\n\t\tthis.baseSchemaCache = null\n\t}\n\n\tpublic async getSchema({ db, stage, normalize }: {\n\t\tdb: DatabaseContext\n\t\tnormalize?: boolean\n\t\tstage?: string\n\t}): Promise<SchemaWithMeta> {\n\t\tconst prevBaseSchema = this.baseSchemaCache\n\t\tthis.baseSchemaCache = await this.schemaProvider.fetch({ db, currentSchema: prevBaseSchema })\n\t\tconst finalSchema = getSchema(this.baseSchemaCache.schema, { stage, normalize })\n\t\treturn {\n\t\t\tschema: finalSchema,\n\t\t\tmeta: this.baseSchemaCache.meta,\n\t\t}\n\t}\n}\n\nconst cache = new ContentApiSpecificCache<Schema, Schema>({})\nconst getSchema = (schema: Schema, options: { stage?: string; normalize?: boolean }) => {\n\tconst cacheKey = [options.stage, options.normalize].join('\\xff')\n\treturn cache.fetch(schema, cacheKey, () => {\n\t\tconst result = schema\n\t\tif (options.normalize) {\n\t\t\treturn normalizeSchema(result)\n\t\t}\n\t\tif (options.stage) {\n\t\t\treturn filterSchemaByStage(result, options.stage)\n\t\t}\n\t\treturn result\n\t})\n}\n"],"names":["ContentApiSpecificCache","normalizeSchema","filterSchemaByStage"],"mappings":";;;;;;;AAKO,MAAM,sBAAsB;AAAA,EAGlC,YAA6B,gBAAgC;AAAhC,SAAA,iBAAA;AAF7B,kBAAA,MAAQ,mBAAyC,IAAA;AAAA,EAGjD;AAAA,EAEO,aAAa;AACnB,SAAK,kBAAkB;AAAA,EACxB;AAAA,EAEA,MAAa,UAAU,EAAE,IAAI,OAAO,aAIR;AAC3B,UAAM,iBAAiB,KAAK;AACvB,SAAA,kBAAkB,MAAM,KAAK,eAAe,MAAM,EAAE,IAAI,eAAe,eAAA,CAAgB;AACtF,UAAA,cAAc,UAAU,KAAK,gBAAgB,QAAQ,EAAE,OAAO,WAAW;AACxE,WAAA;AAAA,MACN,QAAQ;AAAA,MACR,MAAM,KAAK,gBAAgB;AAAA,IAAA;AAAA,EAE7B;AACD;AAEA,MAAM,QAAQ,IAAIA,gDAAwC,CAAA,CAAE;AAC5D,MAAM,YAAY,CAAC,QAAgB,YAAqD;AACjF,QAAA,WAAW,CAAC,QAAQ,OAAO,QAAQ,SAAS,EAAE,KAAK,GAAM;AAC/D,SAAO,MAAM,MAAM,QAAQ,UAAU,MAAM;AAC1C,UAAM,SAAS;AACf,QAAI,QAAQ,WAAW;AACtB,aAAOC,YAAAA,gBAAgB,MAAM;AAAA,IAC9B;AACA,QAAI,QAAQ,OAAO;AACX,aAAAC,gCAAoB,QAAQ,QAAQ,KAAK;AAAA,IACjD;AACO,WAAA;AAAA,EAAA,CACP;AACF;;"}
|
|
@@ -1,30 +1,40 @@
|
|
|
1
|
-
import { filterSchemaByStage } from "@contember/schema-utils";
|
|
1
|
+
import { normalizeSchema, filterSchemaByStage } from "@contember/schema-utils";
|
|
2
|
+
import { ContentApiSpecificCache } from "./ContentApiSpecificCache.js";
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj,
|
|
5
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, key + "", value);
|
|
5
6
|
class ContentSchemaResolver {
|
|
6
|
-
constructor(
|
|
7
|
-
this.
|
|
8
|
-
__publicField(this, "baseSchemaCache");
|
|
9
|
-
__publicField(this, "stageSchemaCache", {});
|
|
7
|
+
constructor(schemaProvider) {
|
|
8
|
+
this.schemaProvider = schemaProvider;
|
|
9
|
+
__publicField(this, "baseSchemaCache", null);
|
|
10
10
|
}
|
|
11
11
|
clearCache() {
|
|
12
|
-
this.baseSchemaCache =
|
|
13
|
-
this.stageSchemaCache = {};
|
|
12
|
+
this.baseSchemaCache = null;
|
|
14
13
|
}
|
|
15
|
-
async getSchema(db, stage) {
|
|
16
|
-
var _a;
|
|
14
|
+
async getSchema({ db, stage, normalize }) {
|
|
17
15
|
const prevBaseSchema = this.baseSchemaCache;
|
|
18
|
-
this.baseSchemaCache = await this.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
return (_a = this.stageSchemaCache)[stage] ?? (_a[stage] = filterSchemaByStage(this.baseSchemaCache, stage));
|
|
16
|
+
this.baseSchemaCache = await this.schemaProvider.fetch({ db, currentSchema: prevBaseSchema });
|
|
17
|
+
const finalSchema = getSchema(this.baseSchemaCache.schema, { stage, normalize });
|
|
18
|
+
return {
|
|
19
|
+
schema: finalSchema,
|
|
20
|
+
meta: this.baseSchemaCache.meta
|
|
21
|
+
};
|
|
26
22
|
}
|
|
27
23
|
}
|
|
24
|
+
const cache = new ContentApiSpecificCache({});
|
|
25
|
+
const getSchema = (schema, options) => {
|
|
26
|
+
const cacheKey = [options.stage, options.normalize].join("ÿ");
|
|
27
|
+
return cache.fetch(schema, cacheKey, () => {
|
|
28
|
+
const result = schema;
|
|
29
|
+
if (options.normalize) {
|
|
30
|
+
return normalizeSchema(result);
|
|
31
|
+
}
|
|
32
|
+
if (options.stage) {
|
|
33
|
+
return filterSchemaByStage(result, options.stage);
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
});
|
|
37
|
+
};
|
|
28
38
|
export {
|
|
29
39
|
ContentSchemaResolver
|
|
30
40
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentSchemaResolver.js","sources":["../../../../../packages/engine-http/src/content/ContentSchemaResolver.ts"],"sourcesContent":["import { DatabaseContext,
|
|
1
|
+
{"version":3,"file":"ContentSchemaResolver.js","sources":["../../../../../packages/engine-http/src/content/ContentSchemaResolver.ts"],"sourcesContent":["import { DatabaseContext, SchemaProvider, SchemaWithMeta } from '@contember/engine-system-api'\nimport { filterSchemaByStage, normalizeSchema } from '@contember/schema-utils'\nimport { Schema } from '@contember/schema'\nimport { ContentApiSpecificCache } from './ContentApiSpecificCache'\n\nexport class ContentSchemaResolver {\n\tprivate baseSchemaCache: SchemaWithMeta | null = null\n\n\tconstructor(private readonly schemaProvider: SchemaProvider) {\n\t}\n\n\tpublic clearCache() {\n\t\tthis.baseSchemaCache = null\n\t}\n\n\tpublic async getSchema({ db, stage, normalize }: {\n\t\tdb: DatabaseContext\n\t\tnormalize?: boolean\n\t\tstage?: string\n\t}): Promise<SchemaWithMeta> {\n\t\tconst prevBaseSchema = this.baseSchemaCache\n\t\tthis.baseSchemaCache = await this.schemaProvider.fetch({ db, currentSchema: prevBaseSchema })\n\t\tconst finalSchema = getSchema(this.baseSchemaCache.schema, { stage, normalize })\n\t\treturn {\n\t\t\tschema: finalSchema,\n\t\t\tmeta: this.baseSchemaCache.meta,\n\t\t}\n\t}\n}\n\nconst cache = new ContentApiSpecificCache<Schema, Schema>({})\nconst getSchema = (schema: Schema, options: { stage?: string; normalize?: boolean }) => {\n\tconst cacheKey = [options.stage, options.normalize].join('\\xff')\n\treturn cache.fetch(schema, cacheKey, () => {\n\t\tconst result = schema\n\t\tif (options.normalize) {\n\t\t\treturn normalizeSchema(result)\n\t\t}\n\t\tif (options.stage) {\n\t\t\treturn filterSchemaByStage(result, options.stage)\n\t\t}\n\t\treturn result\n\t})\n}\n"],"names":[],"mappings":";;;;;AAKO,MAAM,sBAAsB;AAAA,EAGlC,YAA6B,gBAAgC;AAAhC,SAAA,iBAAA;AAF7B,kBAAA,MAAQ,mBAAyC,IAAA;AAAA,EAGjD;AAAA,EAEO,aAAa;AACnB,SAAK,kBAAkB;AAAA,EACxB;AAAA,EAEA,MAAa,UAAU,EAAE,IAAI,OAAO,aAIR;AAC3B,UAAM,iBAAiB,KAAK;AACvB,SAAA,kBAAkB,MAAM,KAAK,eAAe,MAAM,EAAE,IAAI,eAAe,eAAA,CAAgB;AACtF,UAAA,cAAc,UAAU,KAAK,gBAAgB,QAAQ,EAAE,OAAO,WAAW;AACxE,WAAA;AAAA,MACN,QAAQ;AAAA,MACR,MAAM,KAAK,gBAAgB;AAAA,IAAA;AAAA,EAE7B;AACD;AAEA,MAAM,QAAQ,IAAI,wBAAwC,CAAA,CAAE;AAC5D,MAAM,YAAY,CAAC,QAAgB,YAAqD;AACjF,QAAA,WAAW,CAAC,QAAQ,OAAO,QAAQ,SAAS,EAAE,KAAK,GAAM;AAC/D,SAAO,MAAM,MAAM,QAAQ,UAAU,MAAM;AAC1C,UAAM,SAAS;AACf,QAAI,QAAQ,WAAW;AACtB,aAAO,gBAAgB,MAAM;AAAA,IAC9B;AACA,QAAI,QAAQ,OAAO;AACX,aAAA,oBAAoB,QAAQ,QAAQ,KAAK;AAAA,IACjD;AACO,WAAA;AAAA,EAAA,CACP;AACF;"}
|
|
@@ -23,10 +23,10 @@ class ProjectContainerFactoryFactory {
|
|
|
23
23
|
this.permissionFactory = permissionFactory;
|
|
24
24
|
this.databaseMetadataResolver = databaseMetadataResolver;
|
|
25
25
|
}
|
|
26
|
-
create(
|
|
26
|
+
create(schemaProvider, logger) {
|
|
27
27
|
return new ProjectContainerFactory(
|
|
28
28
|
this.plugins,
|
|
29
|
-
|
|
29
|
+
schemaProvider,
|
|
30
30
|
this.providers,
|
|
31
31
|
logger,
|
|
32
32
|
this.serverConfig,
|
|
@@ -37,9 +37,9 @@ class ProjectContainerFactoryFactory {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
class ProjectContainerFactory {
|
|
40
|
-
constructor(plugins,
|
|
40
|
+
constructor(plugins, schemaProvider, providers, logger, serverConfig, graphQlSchemaBuilderFactory, permissionFactory, databaseMetadataResolver) {
|
|
41
41
|
this.plugins = plugins;
|
|
42
|
-
this.
|
|
42
|
+
this.schemaProvider = schemaProvider;
|
|
43
43
|
this.providers = providers;
|
|
44
44
|
this.logger = logger;
|
|
45
45
|
this.serverConfig = serverConfig;
|
|
@@ -85,7 +85,7 @@ class ProjectContainerFactory {
|
|
|
85
85
|
this.permissionFactory,
|
|
86
86
|
contributors
|
|
87
87
|
);
|
|
88
|
-
}).addService("contentSchemaResolver", () => new ContentSchemaResolver.ContentSchemaResolver(this.
|
|
88
|
+
}).addService("contentSchemaResolver", () => new ContentSchemaResolver.ContentSchemaResolver(this.schemaProvider)).addService("systemSchemaName", ({ project: project2 }) => project2.db.systemSchema ?? "system").addService("systemDatabaseContextFactory", ({ systemSchemaName }) => new engineSystemApi.DatabaseContextFactory(systemSchemaName, this.providers)).addService("systemDatabaseContext", ({ connection, systemDatabaseContextFactory }) => systemDatabaseContextFactory.create(connection)).addService("systemReadDatabaseContext", ({ readConnection, systemDatabaseContextFactory }) => systemDatabaseContextFactory.create(readConnection)).addService("systemMigrationGroups", () => Object.fromEntries(this.plugins.flatMap((it) => it.getSystemMigrations ? [[it.name, it.getSystemMigrations()]] : []))).addService("systemMigrationsRunner", ({ systemDatabaseContextFactory, project: project2, systemSchemaName, systemMigrationGroups }) => new engineSystemApi.SystemMigrationsRunner(systemDatabaseContextFactory, { ...project2, systemSchema: systemSchemaName }, this.schemaProvider, systemMigrationGroups, this.databaseMetadataResolver)).addService("projectInitializer", ({ systemMigrationsRunner, systemDatabaseContext, project: project2, systemSchemaName }) => new engineSystemApi.ProjectInitializer(new engineSystemApi.StageCreator(), systemMigrationsRunner, systemDatabaseContext, { ...project2, systemSchema: systemSchemaName })).addService("projectDatabaseMetadataResolver", () => new ProjectDatabaseMetadataResolver.ProjectDatabaseMetadataResolver(this.databaseMetadataResolver));
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
exports.ProjectContainerFactory = ProjectContainerFactory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProjectContainer.cjs","sources":["../../../../../packages/engine-http/src/project/ProjectContainer.ts"],"sourcesContent":["import { Builder } from '@contember/dic'\nimport { Connection, DatabaseMetadataResolver } from '@contember/database'\nimport {\n\tDatabaseContextFactory,\n\tProjectInitializer,\n\
|
|
1
|
+
{"version":3,"file":"ProjectContainer.cjs","sources":["../../../../../packages/engine-http/src/project/ProjectContainer.ts"],"sourcesContent":["import { Builder } from '@contember/dic'\nimport { Connection, DatabaseMetadataResolver } from '@contember/database'\nimport {\n\tDatabaseContextFactory,\n\tProjectInitializer,\n\tSchemaProvider,\n\tStageCreator,\n\tSystemMigrationsRunner,\n\tDatabaseContext,\n} from '@contember/engine-system-api'\nimport { GraphQlSchemaBuilderFactory, PermissionFactory } from '@contember/engine-content-api'\nimport { Logger } from '@contember/logger'\nimport { ProjectConfig } from './config'\nimport { ContentSchemaResolver, GraphQLSchemaContributor, GraphQlSchemaFactory, GraphQLSchemaFactoryResult } from '../content'\nimport { Providers } from '../providers'\nimport { Plugin } from '../plugin/Plugin'\nimport { ServerConfig } from '../config/config'\nimport { ContentApiSpecificCache } from '../content/ContentApiSpecificCache'\nimport { Schema } from '@contember/schema'\nimport { ProjectDatabaseMetadataResolver } from './ProjectDatabaseMetadataResolver'\n\nexport interface ProjectContainer {\n\tsystemDatabaseContextFactory: DatabaseContextFactory\n\tsystemDatabaseContext: DatabaseContext\n\tsystemReadDatabaseContext: DatabaseContext\n\tproject: ProjectConfig\n\tlogger: Logger\n\tconnection: Connection\n\treadConnection: Connection\n\tgraphQlSchemaFactory: GraphQlSchemaFactory\n\tcontentSchemaResolver: ContentSchemaResolver\n\tprojectInitializer: ProjectInitializer\n\tprojectDatabaseMetadataResolver: ProjectDatabaseMetadataResolver\n}\n\nexport class ProjectContainerFactoryFactory {\n\tconstructor(\n\t\tprivate readonly plugins: Plugin[],\n\t\tprivate readonly providers: Providers,\n\t\tprivate readonly serverConfig: ServerConfig,\n\t\tprivate readonly graphQlSchemaBuilderFactory: GraphQlSchemaBuilderFactory,\n\t\tprivate readonly permissionFactory: PermissionFactory,\n\t\tprivate readonly databaseMetadataResolver: DatabaseMetadataResolver,\n\t) {\n\t}\n\n\tcreate(schemaProvider: SchemaProvider, logger: Logger): ProjectContainerFactory {\n\t\treturn new ProjectContainerFactory(\n\t\t\tthis.plugins,\n\t\t\tschemaProvider,\n\t\t\tthis.providers,\n\t\t\tlogger,\n\t\t\tthis.serverConfig,\n\t\t\tthis.graphQlSchemaBuilderFactory,\n\t\t\tthis.permissionFactory,\n\t\t\tthis.databaseMetadataResolver,\n\t\t)\n\t}\n}\n\ninterface ProjectContainerFactoryArgs {\n\tproject: ProjectConfig\n}\n\nexport class ProjectContainerFactory {\n\tconstructor(\n\t\tprivate readonly plugins: Plugin<any>[],\n\t\tprivate readonly schemaProvider: SchemaProvider,\n\t\tprivate readonly providers: Providers,\n\t\tprivate readonly logger: Logger,\n\t\tprivate readonly serverConfig: ServerConfig,\n\t\tprivate readonly graphQlSchemaBuilderFactory: GraphQlSchemaBuilderFactory,\n\t\tprivate readonly permissionFactory: PermissionFactory,\n\t\tprivate readonly databaseMetadataResolver: DatabaseMetadataResolver,\n\t) {}\n\n\tpublic createContainer(args: ProjectContainerFactoryArgs): ProjectContainer {\n\t\treturn this.createBuilder(args)\n\t\t\t.build()\n\t\t\t.pick(\n\t\t\t\t'project',\n\t\t\t\t'connection',\n\t\t\t\t'readConnection',\n\t\t\t\t'systemDatabaseContextFactory',\n\t\t\t\t'systemDatabaseContext',\n\t\t\t\t'systemReadDatabaseContext',\n\t\t\t\t'contentSchemaResolver',\n\t\t\t\t'graphQlSchemaFactory',\n\t\t\t\t'projectInitializer',\n\t\t\t\t'logger',\n\t\t\t\t'projectDatabaseMetadataResolver',\n\t\t\t)\n\t}\n\n\tprotected createBuilder({ project }: ProjectContainerFactoryArgs) {\n\t\treturn new Builder({})\n\t\t\t.addService('logger', () =>\n\t\t\t\tthis.logger.child({ project: project.slug }))\n\t\t\t.addService('project', () =>\n\t\t\t\tproject)\n\t\t\t.addService('connection', ({ project, logger }) =>\n\t\t\t\tConnection.create(project.db, err => logger.error(err)))\n\t\t\t.addService('readConnection', ({ project, logger, connection }) => {\n\t\t\t\tif (!project.db.read) {\n\t\t\t\t\treturn connection\n\t\t\t\t}\n\t\t\t\treturn Connection.create({\n\t\t\t\t\t...project.db,\n\t\t\t\t\t...project.db.read,\n\t\t\t\t\tpool: {\n\t\t\t\t\t\t...project.db.pool,\n\t\t\t\t\t\t...project.db.read.pool,\n\t\t\t\t\t},\n\t\t\t\t}, err => logger.error(err))\n\t\t\t})\n\n\t\t\t.addService('graphqlSchemaCache', () =>\n\t\t\t\tnew ContentApiSpecificCache<Schema, GraphQLSchemaFactoryResult>({\n\t\t\t\t\tttlSeconds: this.serverConfig.contentApi?.schemaCacheTtlSeconds,\n\t\t\t\t}))\n\t\t\t.addService('graphQlSchemaFactory', ({ project, graphqlSchemaCache }) => {\n\t\t\t\tconst contributors = this.plugins\n\t\t\t\t\t.map(it => (it.getSchemaContributor ? it.getSchemaContributor({ project, providers: this.providers }) : null))\n\t\t\t\t\t.filter((it): it is GraphQLSchemaContributor => !!it)\n\t\t\t\treturn new GraphQlSchemaFactory(\n\t\t\t\t\tgraphqlSchemaCache,\n\t\t\t\t\tthis.graphQlSchemaBuilderFactory,\n\t\t\t\t\tthis.permissionFactory,\n\t\t\t\t\tcontributors,\n\t\t\t\t)\n\t\t\t})\n\t\t\t.addService('contentSchemaResolver', () =>\n\t\t\t\tnew ContentSchemaResolver(this.schemaProvider))\n\t\t\t.addService('systemSchemaName', ({ project }) =>\n\t\t\t\tproject.db.systemSchema ?? 'system')\n\t\t\t.addService('systemDatabaseContextFactory', ({ systemSchemaName }) =>\n\t\t\t\tnew DatabaseContextFactory(systemSchemaName, this.providers))\n\t\t\t.addService('systemDatabaseContext', ({ connection, systemDatabaseContextFactory }) =>\n\t\t\t\tsystemDatabaseContextFactory.create(connection))\n\t\t\t.addService('systemReadDatabaseContext', ({ readConnection, systemDatabaseContextFactory }) =>\n\t\t\t\tsystemDatabaseContextFactory.create(readConnection))\n\t\t\t.addService('systemMigrationGroups', () =>\n\t\t\t\tObject.fromEntries(this.plugins.flatMap(it => it.getSystemMigrations ? [[it.name, it.getSystemMigrations()]] : [])))\n\t\t\t.addService('systemMigrationsRunner', ({ systemDatabaseContextFactory, project, systemSchemaName, systemMigrationGroups }) =>\n\t\t\t\tnew SystemMigrationsRunner(systemDatabaseContextFactory, { ...project, systemSchema: systemSchemaName }, this.schemaProvider, systemMigrationGroups, this.databaseMetadataResolver))\n\t\t\t.addService('projectInitializer', ({ systemMigrationsRunner, systemDatabaseContext, project, systemSchemaName }) =>\n\t\t\t\tnew ProjectInitializer(new StageCreator(), systemMigrationsRunner, systemDatabaseContext, { ...project, systemSchema: systemSchemaName }))\n\t\t\t.addService('projectDatabaseMetadataResolver', () =>\n\t\t\t\tnew ProjectDatabaseMetadataResolver(this.databaseMetadataResolver))\n\t}\n}\n"],"names":["Builder","project","Connection","ContentApiSpecificCache","GraphQlSchemaFactory","ContentSchemaResolver","DatabaseContextFactory","SystemMigrationsRunner","ProjectInitializer","StageCreator","ProjectDatabaseMetadataResolver"],"mappings":";;;;;;;;;;;;;;;;AAmCO,MAAM,+BAA+B;AAAA,EAC3C,YACkB,SACA,WACA,cACA,6BACA,mBACA,0BAChB;AANgB,SAAA,UAAA;AACA,SAAA,YAAA;AACA,SAAA,eAAA;AACA,SAAA,8BAAA;AACA,SAAA,oBAAA;AACA,SAAA,2BAAA;AAAA,EAElB;AAAA,EAEA,OAAO,gBAAgC,QAAyC;AAC/E,WAAO,IAAI;AAAA,MACV,KAAK;AAAA,MACL;AAAA,MACA,KAAK;AAAA,MACL;AAAA,MACA,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,IAAA;AAAA,EAEP;AACD;AAMO,MAAM,wBAAwB;AAAA,EACpC,YACkB,SACA,gBACA,WACA,QACA,cACA,6BACA,mBACA,0BAChB;AARgB,SAAA,UAAA;AACA,SAAA,iBAAA;AACA,SAAA,YAAA;AACA,SAAA,SAAA;AACA,SAAA,eAAA;AACA,SAAA,8BAAA;AACA,SAAA,oBAAA;AACA,SAAA,2BAAA;AAAA,EACf;AAAA,EAEI,gBAAgB,MAAqD;AAC3E,WAAO,KAAK,cAAc,IAAI,EAC5B,MACA,EAAA;AAAA,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|
}
|
|
24
|
-
create(
|
|
24
|
+
create(schemaProvider, logger) {
|
|
25
25
|
return new ProjectContainerFactory(
|
|
26
26
|
this.plugins,
|
|
27
|
-
|
|
27
|
+
schemaProvider,
|
|
28
28
|
this.providers,
|
|
29
29
|
logger,
|
|
30
30
|
this.serverConfig,
|
|
@@ -35,9 +35,9 @@ class ProjectContainerFactoryFactory {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
class ProjectContainerFactory {
|
|
38
|
-
constructor(plugins,
|
|
38
|
+
constructor(plugins, schemaProvider, providers, logger, serverConfig, graphQlSchemaBuilderFactory, permissionFactory, databaseMetadataResolver) {
|
|
39
39
|
this.plugins = plugins;
|
|
40
|
-
this.
|
|
40
|
+
this.schemaProvider = schemaProvider;
|
|
41
41
|
this.providers = providers;
|
|
42
42
|
this.logger = logger;
|
|
43
43
|
this.serverConfig = serverConfig;
|
|
@@ -83,7 +83,7 @@ class ProjectContainerFactory {
|
|
|
83
83
|
this.permissionFactory,
|
|
84
84
|
contributors
|
|
85
85
|
);
|
|
86
|
-
}).addService("contentSchemaResolver", () => new ContentSchemaResolver(this.
|
|
86
|
+
}).addService("contentSchemaResolver", () => new ContentSchemaResolver(this.schemaProvider)).addService("systemSchemaName", ({ project: project2 }) => project2.db.systemSchema ?? "system").addService("systemDatabaseContextFactory", ({ systemSchemaName }) => new DatabaseContextFactory(systemSchemaName, this.providers)).addService("systemDatabaseContext", ({ connection, systemDatabaseContextFactory }) => systemDatabaseContextFactory.create(connection)).addService("systemReadDatabaseContext", ({ readConnection, systemDatabaseContextFactory }) => systemDatabaseContextFactory.create(readConnection)).addService("systemMigrationGroups", () => Object.fromEntries(this.plugins.flatMap((it) => it.getSystemMigrations ? [[it.name, it.getSystemMigrations()]] : []))).addService("systemMigrationsRunner", ({ systemDatabaseContextFactory, project: project2, systemSchemaName, systemMigrationGroups }) => new SystemMigrationsRunner(systemDatabaseContextFactory, { ...project2, systemSchema: systemSchemaName }, this.schemaProvider, systemMigrationGroups, this.databaseMetadataResolver)).addService("projectInitializer", ({ systemMigrationsRunner, systemDatabaseContext, project: project2, systemSchemaName }) => new ProjectInitializer(new StageCreator(), systemMigrationsRunner, systemDatabaseContext, { ...project2, systemSchema: systemSchemaName })).addService("projectDatabaseMetadataResolver", () => new ProjectDatabaseMetadataResolver(this.databaseMetadataResolver));
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProjectContainer.js","sources":["../../../../../packages/engine-http/src/project/ProjectContainer.ts"],"sourcesContent":["import { Builder } from '@contember/dic'\nimport { Connection, DatabaseMetadataResolver } from '@contember/database'\nimport {\n\tDatabaseContextFactory,\n\tProjectInitializer,\n\
|
|
1
|
+
{"version":3,"file":"ProjectContainer.js","sources":["../../../../../packages/engine-http/src/project/ProjectContainer.ts"],"sourcesContent":["import { Builder } from '@contember/dic'\nimport { Connection, DatabaseMetadataResolver } from '@contember/database'\nimport {\n\tDatabaseContextFactory,\n\tProjectInitializer,\n\tSchemaProvider,\n\tStageCreator,\n\tSystemMigrationsRunner,\n\tDatabaseContext,\n} from '@contember/engine-system-api'\nimport { GraphQlSchemaBuilderFactory, PermissionFactory } from '@contember/engine-content-api'\nimport { Logger } from '@contember/logger'\nimport { ProjectConfig } from './config'\nimport { ContentSchemaResolver, GraphQLSchemaContributor, GraphQlSchemaFactory, GraphQLSchemaFactoryResult } from '../content'\nimport { Providers } from '../providers'\nimport { Plugin } from '../plugin/Plugin'\nimport { ServerConfig } from '../config/config'\nimport { ContentApiSpecificCache } from '../content/ContentApiSpecificCache'\nimport { Schema } from '@contember/schema'\nimport { ProjectDatabaseMetadataResolver } from './ProjectDatabaseMetadataResolver'\n\nexport interface ProjectContainer {\n\tsystemDatabaseContextFactory: DatabaseContextFactory\n\tsystemDatabaseContext: DatabaseContext\n\tsystemReadDatabaseContext: DatabaseContext\n\tproject: ProjectConfig\n\tlogger: Logger\n\tconnection: Connection\n\treadConnection: Connection\n\tgraphQlSchemaFactory: GraphQlSchemaFactory\n\tcontentSchemaResolver: ContentSchemaResolver\n\tprojectInitializer: ProjectInitializer\n\tprojectDatabaseMetadataResolver: ProjectDatabaseMetadataResolver\n}\n\nexport class ProjectContainerFactoryFactory {\n\tconstructor(\n\t\tprivate readonly plugins: Plugin[],\n\t\tprivate readonly providers: Providers,\n\t\tprivate readonly serverConfig: ServerConfig,\n\t\tprivate readonly graphQlSchemaBuilderFactory: GraphQlSchemaBuilderFactory,\n\t\tprivate readonly permissionFactory: PermissionFactory,\n\t\tprivate readonly databaseMetadataResolver: DatabaseMetadataResolver,\n\t) {\n\t}\n\n\tcreate(schemaProvider: SchemaProvider, logger: Logger): ProjectContainerFactory {\n\t\treturn new ProjectContainerFactory(\n\t\t\tthis.plugins,\n\t\t\tschemaProvider,\n\t\t\tthis.providers,\n\t\t\tlogger,\n\t\t\tthis.serverConfig,\n\t\t\tthis.graphQlSchemaBuilderFactory,\n\t\t\tthis.permissionFactory,\n\t\t\tthis.databaseMetadataResolver,\n\t\t)\n\t}\n}\n\ninterface ProjectContainerFactoryArgs {\n\tproject: ProjectConfig\n}\n\nexport class ProjectContainerFactory {\n\tconstructor(\n\t\tprivate readonly plugins: Plugin<any>[],\n\t\tprivate readonly schemaProvider: SchemaProvider,\n\t\tprivate readonly providers: Providers,\n\t\tprivate readonly logger: Logger,\n\t\tprivate readonly serverConfig: ServerConfig,\n\t\tprivate readonly graphQlSchemaBuilderFactory: GraphQlSchemaBuilderFactory,\n\t\tprivate readonly permissionFactory: PermissionFactory,\n\t\tprivate readonly databaseMetadataResolver: DatabaseMetadataResolver,\n\t) {}\n\n\tpublic createContainer(args: ProjectContainerFactoryArgs): ProjectContainer {\n\t\treturn this.createBuilder(args)\n\t\t\t.build()\n\t\t\t.pick(\n\t\t\t\t'project',\n\t\t\t\t'connection',\n\t\t\t\t'readConnection',\n\t\t\t\t'systemDatabaseContextFactory',\n\t\t\t\t'systemDatabaseContext',\n\t\t\t\t'systemReadDatabaseContext',\n\t\t\t\t'contentSchemaResolver',\n\t\t\t\t'graphQlSchemaFactory',\n\t\t\t\t'projectInitializer',\n\t\t\t\t'logger',\n\t\t\t\t'projectDatabaseMetadataResolver',\n\t\t\t)\n\t}\n\n\tprotected createBuilder({ project }: ProjectContainerFactoryArgs) {\n\t\treturn new Builder({})\n\t\t\t.addService('logger', () =>\n\t\t\t\tthis.logger.child({ project: project.slug }))\n\t\t\t.addService('project', () =>\n\t\t\t\tproject)\n\t\t\t.addService('connection', ({ project, logger }) =>\n\t\t\t\tConnection.create(project.db, err => logger.error(err)))\n\t\t\t.addService('readConnection', ({ project, logger, connection }) => {\n\t\t\t\tif (!project.db.read) {\n\t\t\t\t\treturn connection\n\t\t\t\t}\n\t\t\t\treturn Connection.create({\n\t\t\t\t\t...project.db,\n\t\t\t\t\t...project.db.read,\n\t\t\t\t\tpool: {\n\t\t\t\t\t\t...project.db.pool,\n\t\t\t\t\t\t...project.db.read.pool,\n\t\t\t\t\t},\n\t\t\t\t}, err => logger.error(err))\n\t\t\t})\n\n\t\t\t.addService('graphqlSchemaCache', () =>\n\t\t\t\tnew ContentApiSpecificCache<Schema, GraphQLSchemaFactoryResult>({\n\t\t\t\t\tttlSeconds: this.serverConfig.contentApi?.schemaCacheTtlSeconds,\n\t\t\t\t}))\n\t\t\t.addService('graphQlSchemaFactory', ({ project, graphqlSchemaCache }) => {\n\t\t\t\tconst contributors = this.plugins\n\t\t\t\t\t.map(it => (it.getSchemaContributor ? it.getSchemaContributor({ project, providers: this.providers }) : null))\n\t\t\t\t\t.filter((it): it is GraphQLSchemaContributor => !!it)\n\t\t\t\treturn new GraphQlSchemaFactory(\n\t\t\t\t\tgraphqlSchemaCache,\n\t\t\t\t\tthis.graphQlSchemaBuilderFactory,\n\t\t\t\t\tthis.permissionFactory,\n\t\t\t\t\tcontributors,\n\t\t\t\t)\n\t\t\t})\n\t\t\t.addService('contentSchemaResolver', () =>\n\t\t\t\tnew ContentSchemaResolver(this.schemaProvider))\n\t\t\t.addService('systemSchemaName', ({ project }) =>\n\t\t\t\tproject.db.systemSchema ?? 'system')\n\t\t\t.addService('systemDatabaseContextFactory', ({ systemSchemaName }) =>\n\t\t\t\tnew DatabaseContextFactory(systemSchemaName, this.providers))\n\t\t\t.addService('systemDatabaseContext', ({ connection, systemDatabaseContextFactory }) =>\n\t\t\t\tsystemDatabaseContextFactory.create(connection))\n\t\t\t.addService('systemReadDatabaseContext', ({ readConnection, systemDatabaseContextFactory }) =>\n\t\t\t\tsystemDatabaseContextFactory.create(readConnection))\n\t\t\t.addService('systemMigrationGroups', () =>\n\t\t\t\tObject.fromEntries(this.plugins.flatMap(it => it.getSystemMigrations ? [[it.name, it.getSystemMigrations()]] : [])))\n\t\t\t.addService('systemMigrationsRunner', ({ systemDatabaseContextFactory, project, systemSchemaName, systemMigrationGroups }) =>\n\t\t\t\tnew SystemMigrationsRunner(systemDatabaseContextFactory, { ...project, systemSchema: systemSchemaName }, this.schemaProvider, systemMigrationGroups, this.databaseMetadataResolver))\n\t\t\t.addService('projectInitializer', ({ systemMigrationsRunner, systemDatabaseContext, project, systemSchemaName }) =>\n\t\t\t\tnew ProjectInitializer(new StageCreator(), systemMigrationsRunner, systemDatabaseContext, { ...project, systemSchema: systemSchemaName }))\n\t\t\t.addService('projectDatabaseMetadataResolver', () =>\n\t\t\t\tnew ProjectDatabaseMetadataResolver(this.databaseMetadataResolver))\n\t}\n}\n"],"names":["project"],"mappings":";;;;;;;;;;;;;;AAmCO,MAAM,+BAA+B;AAAA,EAC3C,YACkB,SACA,WACA,cACA,6BACA,mBACA,0BAChB;AANgB,SAAA,UAAA;AACA,SAAA,YAAA;AACA,SAAA,eAAA;AACA,SAAA,8BAAA;AACA,SAAA,oBAAA;AACA,SAAA,2BAAA;AAAA,EAElB;AAAA,EAEA,OAAO,gBAAgC,QAAyC;AAC/E,WAAO,IAAI;AAAA,MACV,KAAK;AAAA,MACL;AAAA,MACA,KAAK;AAAA,MAC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AiB,MAC7G,IAAI,mBAAmB,IAAI,aAAa,GAAG,wBAAwB,uBAAuB,EAAE,GAAGA,UAAS,cAAc,iBAAkB,CAAA,CAAC,EACzI,WAAW,mCAAmC,MAC9C,IAAI,gCAAgC,KAAK,wBAAwB,CAAC;AAAA,EACrE;AACD;"}
|
|
@@ -13,7 +13,7 @@ class ProjectSchemaResolver {
|
|
|
13
13
|
return void 0;
|
|
14
14
|
}
|
|
15
15
|
const db = container.systemReadDatabaseContext;
|
|
16
|
-
return container.contentSchemaResolver.getSchema(db);
|
|
16
|
+
return (await container.contentSchemaResolver.getSchema({ db, normalize: true }))?.schema;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
class ProjectSchemaResolverProxy {
|
|
@@ -23,7 +23,7 @@ class ProjectSchemaResolverProxy {
|
|
|
23
23
|
setResolver(resolver) {
|
|
24
24
|
this.resolver = resolver;
|
|
25
25
|
}
|
|
26
|
-
getSchema(projectSlug) {
|
|
26
|
+
async getSchema(projectSlug) {
|
|
27
27
|
if (!this.resolver) {
|
|
28
28
|
throw new Error("Resolved is not set");
|
|
29
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProjectSchemaResolver.cjs","sources":["../../../../../packages/engine-http/src/project/ProjectSchemaResolver.ts"],"sourcesContent":["import { ProjectSchemaResolver as ProjectSchemaResolverInterface } from '@contember/engine-tenant-api'\nimport { Schema } from '@contember/schema'\nimport { ProjectContainerResolver } from './ProjectContainerResolver'\n\nexport class ProjectSchemaResolver implements ProjectSchemaResolverInterface {\n\tconstructor(\n\t\tprivate readonly projectContainerResolver: ProjectContainerResolver,\n\t) {}\n\n\tasync getSchema(slug: string) {\n\t\tconst container = await this.projectContainerResolver.getProjectContainer(slug)\n\t\tif (!container) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst db = container.systemReadDatabaseContext\n\t\treturn container.contentSchemaResolver.getSchema(db)\n\t}\n}\n\nexport class ProjectSchemaResolverProxy implements ProjectSchemaResolverInterface {\n\tprivate resolver: ProjectSchemaResolver | undefined\n\n\tsetResolver(resolver: ProjectSchemaResolver): void {\n\t\tthis.resolver = resolver\n\t}\n\n\
|
|
1
|
+
{"version":3,"file":"ProjectSchemaResolver.cjs","sources":["../../../../../packages/engine-http/src/project/ProjectSchemaResolver.ts"],"sourcesContent":["import { ProjectSchemaResolver as ProjectSchemaResolverInterface } from '@contember/engine-tenant-api'\nimport { Schema } from '@contember/schema'\nimport { ProjectContainerResolver } from './ProjectContainerResolver'\n\nexport class ProjectSchemaResolver implements ProjectSchemaResolverInterface {\n\tconstructor(\n\t\tprivate readonly projectContainerResolver: ProjectContainerResolver,\n\t) {}\n\n\tasync getSchema(slug: string): Promise<Schema | undefined> {\n\t\tconst container = await this.projectContainerResolver.getProjectContainer(slug)\n\t\tif (!container) {\n\t\t\treturn undefined\n\t\t}\n\t\tconst db = container.systemReadDatabaseContext\n\t\treturn (await container.contentSchemaResolver.getSchema({ db, normalize: true }))?.schema\n\t}\n}\n\nexport class ProjectSchemaResolverProxy implements ProjectSchemaResolverInterface {\n\tprivate resolver: ProjectSchemaResolver | undefined\n\n\tsetResolver(resolver: ProjectSchemaResolver): void {\n\t\tthis.resolver = resolver\n\t}\n\n\tasync getSchema(projectSlug: string): Promise<Schema | undefined> {\n\t\tif (!this.resolver) {\n\t\t\tthrow new Error('Resolved is not set')\n\t\t}\n\t\treturn this.resolver.getSchema(projectSlug)\n\t}\n}\n"],"names":[],"mappings":";;;;;AAIO,MAAM,sBAAgE;AAAA,EAC5E,YACkB,0BAChB;AADgB,SAAA,2BAAA;AAAA,EACf;AAAA,EAEH,MAAM,UAAU,MAA2C;AAC1D,UAAM,YAAY,MAAM,KAAK,yBAAyB,oBAAoB,IAAI;AAC9E,QAAI,CAAC,WAAW;AACR,aAAA;AAAA,IACR;AACA,UAAM,KAAK,UAAU;AACb,YAAA,MAAM,UAAU,sBAAsB,UAAU,EAAE,IAAI,WAAW,MAAM,IAAI;AAAA,EACpF;AACD;AAEO,MAAM,2BAAqE;AAAA,EAA3E,cAAA;AACE,kBAAA,MAAA,UAAA;AAAA,EAAA;AAAA,EAER,YAAY,UAAuC;AAClD,SAAK,WAAW;AAAA,EACjB;AAAA,EAEA,MAAM,UAAU,aAAkD;AAC7D,QAAA,CAAC,KAAK,UAAU;AACb,YAAA,IAAI,MAAM,qBAAqB;AAAA,IACtC;AACO,WAAA,KAAK,SAAS,UAAU,WAAW;AAAA,EAC3C;AACD;;;"}
|
|
@@ -11,7 +11,7 @@ class ProjectSchemaResolver {
|
|
|
11
11
|
return void 0;
|
|
12
12
|
}
|
|
13
13
|
const db = container.systemReadDatabaseContext;
|
|
14
|
-
return container.contentSchemaResolver.getSchema(db);
|
|
14
|
+
return (await container.contentSchemaResolver.getSchema({ db, normalize: true }))?.schema;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
class ProjectSchemaResolverProxy {
|
|
@@ -21,7 +21,7 @@ class ProjectSchemaResolverProxy {
|
|
|
21
21
|
setResolver(resolver) {
|
|
22
22
|
this.resolver = resolver;
|
|
23
23
|
}
|
|
24
|
-
getSchema(projectSlug) {
|
|
24
|
+
async getSchema(projectSlug) {
|
|
25
25
|
if (!this.resolver) {
|
|
26
26
|
throw new Error("Resolved is not set");
|
|
27
27
|
}
|