@contember/engine-http 1.3.0-alpha.7 → 1.3.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/content/ContentApiControllerFactory.d.ts.map +1 -1
- package/dist/src/content/ContentApiControllerFactory.js +2 -0
- package/dist/src/content/ContentApiControllerFactory.js.map +1 -1
- package/dist/src/content/ContentGraphQLContextFactory.d.ts +3 -2
- package/dist/src/content/ContentGraphQLContextFactory.d.ts.map +1 -1
- package/dist/src/content/ContentGraphQLContextFactory.js +2 -1
- package/dist/src/content/ContentGraphQLContextFactory.js.map +1 -1
- package/dist/src/project/ProjectContainer.d.ts +7 -1
- package/dist/src/project/ProjectContainer.d.ts.map +1 -1
- package/dist/src/project/ProjectContainer.js +6 -3
- package/dist/src/project/ProjectContainer.js.map +1 -1
- package/dist/src/project/ProjectDatabaseMetadataResolver.d.ts +10 -0
- package/dist/src/project/ProjectDatabaseMetadataResolver.d.ts.map +1 -0
- package/dist/src/project/ProjectDatabaseMetadataResolver.js +25 -0
- package/dist/src/project/ProjectDatabaseMetadataResolver.js.map +1 -0
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/package.json +15 -15
- package/src/content/ContentApiControllerFactory.ts +4 -0
- package/src/content/ContentGraphQLContextFactory.ts +4 -2
- package/src/project/ProjectContainer.ts +10 -2
- package/src/project/ProjectDatabaseMetadataResolver.ts +29 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/engine-http",
|
|
3
|
-
"version": "1.3.0-alpha.
|
|
3
|
+
"version": "1.3.0-alpha.8",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"typings": "dist/src/index.d.ts",
|
|
@@ -13,20 +13,20 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@apollographql/graphql-playground-html": "^1.6.24",
|
|
16
|
-
"@contember/config-loader": "^1.3.0-alpha.
|
|
17
|
-
"@contember/database": "^1.3.0-alpha.
|
|
18
|
-
"@contember/database-migrations": "^1.3.0-alpha.
|
|
19
|
-
"@contember/dic": "^1.3.0-alpha.
|
|
20
|
-
"@contember/engine-common": "^1.3.0-alpha.
|
|
21
|
-
"@contember/engine-content-api": "^1.3.0-alpha.
|
|
22
|
-
"@contember/engine-system-api": "^1.3.0-alpha.
|
|
23
|
-
"@contember/engine-tenant-api": "^1.3.0-alpha.
|
|
24
|
-
"@contember/graphql-utils": "^1.3.0-alpha.
|
|
25
|
-
"@contember/logger": "^1.3.0-alpha.
|
|
26
|
-
"@contember/schema": "^1.3.0-alpha.
|
|
27
|
-
"@contember/schema-migrations": "^1.3.0-alpha.
|
|
28
|
-
"@contember/schema-utils": "^1.3.0-alpha.
|
|
29
|
-
"@contember/typesafe": "^1.3.0-alpha.
|
|
16
|
+
"@contember/config-loader": "^1.3.0-alpha.8",
|
|
17
|
+
"@contember/database": "^1.3.0-alpha.8",
|
|
18
|
+
"@contember/database-migrations": "^1.3.0-alpha.8",
|
|
19
|
+
"@contember/dic": "^1.3.0-alpha.8",
|
|
20
|
+
"@contember/engine-common": "^1.3.0-alpha.8",
|
|
21
|
+
"@contember/engine-content-api": "^1.3.0-alpha.8",
|
|
22
|
+
"@contember/engine-system-api": "^1.3.0-alpha.8",
|
|
23
|
+
"@contember/engine-tenant-api": "^1.3.0-alpha.8",
|
|
24
|
+
"@contember/graphql-utils": "^1.3.0-alpha.8",
|
|
25
|
+
"@contember/logger": "^1.3.0-alpha.8",
|
|
26
|
+
"@contember/schema": "^1.3.0-alpha.8",
|
|
27
|
+
"@contember/schema-migrations": "^1.3.0-alpha.8",
|
|
28
|
+
"@contember/schema-utils": "^1.3.0-alpha.8",
|
|
29
|
+
"@contember/typesafe": "^1.3.0-alpha.8",
|
|
30
30
|
"@graphql-tools/schema": "^8.3.5",
|
|
31
31
|
"@graphql-tools/merge": "^8.3.5",
|
|
32
32
|
"@sentry/node": "^7.1.1",
|
|
@@ -79,6 +79,9 @@ export class ContentApiControllerFactory {
|
|
|
79
79
|
}),
|
|
80
80
|
)
|
|
81
81
|
|
|
82
|
+
|
|
83
|
+
const schemaDatabaseMetadata = await projectContainer.projectDatabaseMetadataResolver.resolveDatabaseMetadata(systemDatabase, schema, stage.schema)
|
|
84
|
+
|
|
82
85
|
const handler = await (async () => {
|
|
83
86
|
const existingHandler = handlerCache.get(graphQlSchema)
|
|
84
87
|
if (existingHandler) {
|
|
@@ -104,6 +107,7 @@ export class ContentApiControllerFactory {
|
|
|
104
107
|
authResult,
|
|
105
108
|
memberships,
|
|
106
109
|
permissions,
|
|
110
|
+
schemaDatabaseMetadata,
|
|
107
111
|
schema,
|
|
108
112
|
timer,
|
|
109
113
|
koaContext: koa,
|
|
@@ -6,7 +6,7 @@ import { AuthResult } from '../common'
|
|
|
6
6
|
import { KoaContext, Timer } from '../application'
|
|
7
7
|
import { Providers } from '../providers'
|
|
8
8
|
import { GraphQLKoaState } from '../graphql'
|
|
9
|
-
import { ParsedMembership } from '@contember/schema-utils'
|
|
9
|
+
import { ParsedMembership, SchemaDatabaseMetadata } from '@contember/schema-utils'
|
|
10
10
|
import { Stage } from '@contember/engine-system-api'
|
|
11
11
|
import { ProjectConfig } from '../project/config'
|
|
12
12
|
|
|
@@ -23,9 +23,10 @@ export class ContentGraphQLContextFactory {
|
|
|
23
23
|
) {
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
create({ db, schema, authResult, memberships, permissions, timer, koaContext, requestDebug, systemSchema, stage, project }: {
|
|
26
|
+
create({ db, schema, schemaDatabaseMetadata, authResult, memberships, permissions, timer, koaContext, requestDebug, systemSchema, stage, project }: {
|
|
27
27
|
db: Client
|
|
28
28
|
schema: Schema & { id: number }
|
|
29
|
+
schemaDatabaseMetadata: SchemaDatabaseMetadata
|
|
29
30
|
permissions: Acl.Permissions
|
|
30
31
|
authResult: AuthResult
|
|
31
32
|
memberships: readonly ParsedMembership[]
|
|
@@ -50,6 +51,7 @@ export class ContentGraphQLContextFactory {
|
|
|
50
51
|
identityVariables,
|
|
51
52
|
identityId,
|
|
52
53
|
schema,
|
|
54
|
+
schemaDatabaseMetadata,
|
|
53
55
|
permissions,
|
|
54
56
|
systemSchema,
|
|
55
57
|
stage,
|
|
@@ -3,6 +3,7 @@ import { Connection } from '@contember/database'
|
|
|
3
3
|
import {
|
|
4
4
|
DatabaseContextFactory,
|
|
5
5
|
ProjectInitializer,
|
|
6
|
+
SchemaDatabaseMetadataResolver,
|
|
6
7
|
SchemaVersionBuilder,
|
|
7
8
|
StageCreator,
|
|
8
9
|
SystemMigrationsRunner,
|
|
@@ -21,6 +22,7 @@ import { Plugin } from '../plugin/Plugin'
|
|
|
21
22
|
import { ServerConfig } from '../config/config'
|
|
22
23
|
import { ContentApiSpecificCache } from '../content/ContentApiSpecificCache'
|
|
23
24
|
import { Schema } from '@contember/schema'
|
|
25
|
+
import { ProjectDatabaseMetadataResolver } from './ProjectDatabaseMetadataResolver'
|
|
24
26
|
|
|
25
27
|
export interface ProjectContainer {
|
|
26
28
|
systemDatabaseContextFactory: DatabaseContextFactory
|
|
@@ -31,6 +33,7 @@ export interface ProjectContainer {
|
|
|
31
33
|
graphQlSchemaFactory: GraphQlSchemaFactory
|
|
32
34
|
contentSchemaResolver: ContentSchemaResolver
|
|
33
35
|
projectInitializer: ProjectInitializer
|
|
36
|
+
projectDatabaseMetadataResolver: ProjectDatabaseMetadataResolver
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
export class ProjectContainerFactoryFactory {
|
|
@@ -80,6 +83,7 @@ export class ProjectContainerFactory {
|
|
|
80
83
|
'graphQlSchemaFactory',
|
|
81
84
|
'projectInitializer',
|
|
82
85
|
'logger',
|
|
86
|
+
'projectDatabaseMetadataResolver',
|
|
83
87
|
)
|
|
84
88
|
}
|
|
85
89
|
|
|
@@ -135,9 +139,13 @@ export class ProjectContainerFactory {
|
|
|
135
139
|
new DatabaseContextFactory(systemSchemaName, connection, providers))
|
|
136
140
|
.addService('systemMigrationGroups', () =>
|
|
137
141
|
Object.fromEntries(this.plugins.flatMap(it => it.getSystemMigrations ? [[it.name, it.getSystemMigrations()]] : [])))
|
|
138
|
-
.addService('
|
|
139
|
-
new
|
|
142
|
+
.addService('databaseMetadataResolver', () =>
|
|
143
|
+
new SchemaDatabaseMetadataResolver())
|
|
144
|
+
.addService('systemMigrationsRunner', ({ systemDatabaseContextFactory, project, systemSchemaName, systemMigrationGroups, databaseMetadataResolver }) =>
|
|
145
|
+
new SystemMigrationsRunner(systemDatabaseContextFactory, project, systemSchemaName, this.schemaVersionBuilder, systemMigrationGroups, databaseMetadataResolver))
|
|
140
146
|
.addService('projectInitializer', ({ systemMigrationsRunner, systemDatabaseContextFactory, project }) =>
|
|
141
147
|
new ProjectInitializer(new StageCreator(), systemMigrationsRunner, systemDatabaseContextFactory, project))
|
|
148
|
+
.addService('projectDatabaseMetadataResolver', ({ databaseMetadataResolver }) =>
|
|
149
|
+
new ProjectDatabaseMetadataResolver(databaseMetadataResolver))
|
|
142
150
|
}
|
|
143
151
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { DatabaseContext, SchemaDatabaseMetadataResolver } from '@contember/engine-system-api'
|
|
2
|
+
import { Schema } from '@contember/schema'
|
|
3
|
+
import { SchemaDatabaseMetadata } from '@contember/schema-utils'
|
|
4
|
+
|
|
5
|
+
export class ProjectDatabaseMetadataResolver {
|
|
6
|
+
|
|
7
|
+
private cache: WeakMap<Schema, Map<string, SchemaDatabaseMetadata>> = new WeakMap()
|
|
8
|
+
|
|
9
|
+
constructor(
|
|
10
|
+
private resolver: SchemaDatabaseMetadataResolver,
|
|
11
|
+
) {
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async resolveDatabaseMetadata(db: DatabaseContext, schema: Schema, stageSchema: string): Promise<SchemaDatabaseMetadata> {
|
|
15
|
+
let schemaCache = this.cache.get(schema)
|
|
16
|
+
if (!schemaCache) {
|
|
17
|
+
schemaCache = new Map()
|
|
18
|
+
this.cache.set(schema, schemaCache)
|
|
19
|
+
}
|
|
20
|
+
const cachedMeta = schemaCache.get(stageSchema)
|
|
21
|
+
if (cachedMeta) {
|
|
22
|
+
return cachedMeta
|
|
23
|
+
}
|
|
24
|
+
const metadata = await this.resolver.resolveMetadata(db, stageSchema)
|
|
25
|
+
schemaCache.set(stageSchema, metadata)
|
|
26
|
+
|
|
27
|
+
return metadata
|
|
28
|
+
}
|
|
29
|
+
}
|