@contember/engine-http 2.1.0-alpha.24 → 2.1.0-alpha.26
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/index.cjs +0 -2
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +0 -2
- package/dist/development/index.js.map +1 -1
- package/dist/development/src/MasterContainer.cjs +27 -28
- package/dist/development/src/MasterContainer.cjs.map +1 -1
- package/dist/development/src/MasterContainer.js +27 -28
- package/dist/development/src/MasterContainer.js.map +1 -1
- package/dist/development/src/config/configSchema.cjs +5 -1
- package/dist/development/src/config/configSchema.cjs.map +1 -1
- package/dist/development/src/config/configSchema.js +5 -1
- package/dist/development/src/config/configSchema.js.map +1 -1
- package/dist/development/src/config/configTemplate.cjs +5 -1
- package/dist/development/src/config/configTemplate.cjs.map +1 -1
- package/dist/development/src/config/configTemplate.js +5 -1
- package/dist/development/src/config/configTemplate.js.map +1 -1
- package/dist/development/src/content/ContentApiControllerFactory.cjs +29 -12
- package/dist/development/src/content/ContentApiControllerFactory.cjs.map +1 -1
- package/dist/development/src/content/ContentApiControllerFactory.js +29 -12
- package/dist/development/src/content/ContentApiControllerFactory.js.map +1 -1
- package/dist/development/src/content/ContentQueryHandlerFactory.cjs.map +1 -1
- package/dist/development/src/content/ContentQueryHandlerFactory.js.map +1 -1
- package/dist/development/src/projectGroup/ProjectGroupContainer.cjs +1 -1
- package/dist/development/src/projectGroup/ProjectGroupContainer.js +1 -1
- package/dist/development/src/system/ContentQueryExecutor.cjs +6 -2
- package/dist/development/src/system/ContentQueryExecutor.cjs.map +1 -1
- package/dist/development/src/system/ContentQueryExecutor.js +6 -2
- package/dist/development/src/system/ContentQueryExecutor.js.map +1 -1
- package/dist/production/index.cjs +0 -2
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.js +0 -2
- package/dist/production/index.js.map +1 -1
- package/dist/production/src/MasterContainer.cjs +27 -28
- package/dist/production/src/MasterContainer.cjs.map +1 -1
- package/dist/production/src/MasterContainer.js +27 -28
- package/dist/production/src/MasterContainer.js.map +1 -1
- package/dist/production/src/config/configSchema.cjs +5 -1
- package/dist/production/src/config/configSchema.cjs.map +1 -1
- package/dist/production/src/config/configSchema.js +5 -1
- package/dist/production/src/config/configSchema.js.map +1 -1
- package/dist/production/src/config/configTemplate.cjs +5 -1
- package/dist/production/src/config/configTemplate.cjs.map +1 -1
- package/dist/production/src/config/configTemplate.js +5 -1
- package/dist/production/src/config/configTemplate.js.map +1 -1
- package/dist/production/src/content/ContentApiControllerFactory.cjs +29 -12
- package/dist/production/src/content/ContentApiControllerFactory.cjs.map +1 -1
- package/dist/production/src/content/ContentApiControllerFactory.js +29 -12
- package/dist/production/src/content/ContentApiControllerFactory.js.map +1 -1
- package/dist/production/src/content/ContentQueryHandlerFactory.cjs.map +1 -1
- package/dist/production/src/content/ContentQueryHandlerFactory.js.map +1 -1
- package/dist/production/src/projectGroup/ProjectGroupContainer.cjs +1 -1
- package/dist/production/src/projectGroup/ProjectGroupContainer.js +1 -1
- package/dist/production/src/system/ContentQueryExecutor.cjs +6 -2
- package/dist/production/src/system/ContentQueryExecutor.cjs.map +1 -1
- package/dist/production/src/system/ContentQueryExecutor.js +6 -2
- package/dist/production/src/system/ContentQueryExecutor.js.map +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/dist/types/MasterContainer.d.ts +22 -20
- package/dist/types/MasterContainer.d.ts.map +1 -1
- package/dist/types/config/configSchema.d.ts +18 -0
- package/dist/types/config/configSchema.d.ts.map +1 -1
- package/dist/types/config/configTemplate.d.ts.map +1 -1
- package/dist/types/content/ContentApiControllerFactory.d.ts +4 -4
- package/dist/types/content/ContentApiControllerFactory.d.ts.map +1 -1
- package/dist/types/content/ContentGraphqlContext.d.ts +9 -0
- package/dist/types/content/ContentGraphqlContext.d.ts.map +1 -0
- package/dist/types/content/ContentQueryHandlerFactory.d.ts +2 -2
- package/dist/types/content/ContentQueryHandlerFactory.d.ts.map +1 -1
- package/dist/types/content/index.d.ts +0 -1
- package/dist/types/content/index.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/tsconfig.tsbuildinfo +1 -1
- package/package.json +15 -15
- package/src/MasterContainer.ts +31 -32
- package/src/config/configSchema.ts +4 -0
- package/src/config/configTemplate.ts +4 -0
- package/src/content/ContentApiControllerFactory.ts +37 -15
- package/src/content/ContentGraphqlContext.ts +7 -0
- package/src/content/ContentQueryHandlerFactory.ts +4 -4
- package/src/content/index.ts +0 -1
- package/src/system/ContentQueryExecutor.ts +8 -4
- package/dist/development/src/content/ContentGraphQLContextFactory.cjs +0 -39
- package/dist/development/src/content/ContentGraphQLContextFactory.cjs.map +0 -1
- package/dist/development/src/content/ContentGraphQLContextFactory.js +0 -39
- package/dist/development/src/content/ContentGraphQLContextFactory.js.map +0 -1
- package/dist/production/src/content/ContentGraphQLContextFactory.cjs +0 -39
- package/dist/production/src/content/ContentGraphQLContextFactory.cjs.map +0 -1
- package/dist/production/src/content/ContentGraphQLContextFactory.js +0 -39
- package/dist/production/src/content/ContentGraphQLContextFactory.js.map +0 -1
- package/dist/types/content/ContentGraphQLContextFactory.d.ts +0 -38
- package/dist/types/content/ContentGraphQLContextFactory.d.ts.map +0 -1
- package/src/content/ContentGraphQLContextFactory.ts +0 -70
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/engine-http",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.26",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/production/index.js",
|
|
6
6
|
"typings": "./dist/types/index.d.ts",
|
|
@@ -26,20 +26,20 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@contember/config-loader": "2.1.0-alpha.
|
|
30
|
-
"@contember/database": "2.1.0-alpha.
|
|
31
|
-
"@contember/database-migrations": "2.1.0-alpha.
|
|
32
|
-
"@contember/dic": "2.1.0-alpha.
|
|
33
|
-
"@contember/engine-common": "2.1.0-alpha.
|
|
34
|
-
"@contember/engine-content-api": "2.1.0-alpha.
|
|
35
|
-
"@contember/engine-system-api": "2.1.0-alpha.
|
|
36
|
-
"@contember/engine-tenant-api": "2.1.0-alpha.
|
|
37
|
-
"@contember/graphql-utils": "2.1.0-alpha.
|
|
38
|
-
"@contember/logger": "2.1.0-alpha.
|
|
39
|
-
"@contember/schema": "2.1.0-alpha.
|
|
40
|
-
"@contember/schema-migrations": "2.1.0-alpha.
|
|
41
|
-
"@contember/schema-utils": "2.1.0-alpha.
|
|
42
|
-
"@contember/typesafe": "2.1.0-alpha.
|
|
29
|
+
"@contember/config-loader": "2.1.0-alpha.26",
|
|
30
|
+
"@contember/database": "2.1.0-alpha.26",
|
|
31
|
+
"@contember/database-migrations": "2.1.0-alpha.26",
|
|
32
|
+
"@contember/dic": "2.1.0-alpha.26",
|
|
33
|
+
"@contember/engine-common": "2.1.0-alpha.26",
|
|
34
|
+
"@contember/engine-content-api": "2.1.0-alpha.26",
|
|
35
|
+
"@contember/engine-system-api": "2.1.0-alpha.26",
|
|
36
|
+
"@contember/engine-tenant-api": "2.1.0-alpha.26",
|
|
37
|
+
"@contember/graphql-utils": "2.1.0-alpha.26",
|
|
38
|
+
"@contember/logger": "2.1.0-alpha.26",
|
|
39
|
+
"@contember/schema": "2.1.0-alpha.26",
|
|
40
|
+
"@contember/schema-migrations": "2.1.0-alpha.26",
|
|
41
|
+
"@contember/schema-utils": "2.1.0-alpha.26",
|
|
42
|
+
"@contember/typesafe": "2.1.0-alpha.26",
|
|
43
43
|
"@graphql-tools/merge": "^9.0.8",
|
|
44
44
|
"@graphql-tools/schema": "^10.0.7",
|
|
45
45
|
"@koa/cors": "^5.0.0",
|
package/src/MasterContainer.ts
CHANGED
|
@@ -1,25 +1,40 @@
|
|
|
1
|
+
import { Builder } from '@contember/dic'
|
|
1
2
|
import { SystemContainerFactory } from '@contember/engine-system-api'
|
|
2
3
|
import { TenantContainerFactory } from '@contember/engine-tenant-api'
|
|
3
|
-
import { Builder } from '@contember/dic'
|
|
4
|
-
import { ServerConfig } from './config/config'
|
|
5
4
|
import { ModificationHandlerFactory } from '@contember/schema-migrations'
|
|
6
5
|
import { Initializer } from './bootstrap'
|
|
6
|
+
import { ServerConfig } from './config/config'
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { DatabaseMetadataResolver } from '@contember/database'
|
|
9
|
+
import { ExecutionContainerFactory, GraphQlSchemaBuilderFactory, PermissionFactory } from '@contember/engine-content-api'
|
|
10
|
+
import { Logger } from '@contember/logger'
|
|
11
|
+
import { Schema } from '@contember/schema'
|
|
12
|
+
import Koa from 'koa'
|
|
13
|
+
import { createSecretKey } from 'node:crypto'
|
|
14
|
+
import { Application } from './application'
|
|
15
|
+
import { HttpResponse } from './common'
|
|
9
16
|
import { ProjectConfigResolver } from './config/projectConfigResolver'
|
|
10
17
|
import { TenantConfigResolver } from './config/tenantConfigResolver'
|
|
11
|
-
import { ProjectGroupContainerFactory } from './projectGroup/ProjectGroupContainer'
|
|
12
|
-
import { ProjectGroupResolver } from './projectGroup/ProjectGroupResolver'
|
|
13
|
-
import { Logger } from '@contember/logger'
|
|
14
|
-
import { ExecutionContainerFactory, GraphQlSchemaBuilderFactory, PermissionFactory } from '@contember/engine-content-api'
|
|
15
|
-
import { createProviders, Providers } from './providers'
|
|
16
|
-
import { TenantApiMiddlewareFactory, TenantGraphQLHandlerFactory } from './tenant'
|
|
17
|
-
import { SystemApiMiddlewareFactory, SystemGraphQLContextFactory, SystemGraphQLHandlerFactory } from './system'
|
|
18
18
|
import {
|
|
19
|
-
ContentApiControllerFactory,
|
|
19
|
+
ContentApiControllerFactory,
|
|
20
|
+
ContentQueryHandlerFactory, GraphQLSchemaContributor, GraphQlSchemaFactory,
|
|
20
21
|
GraphQLSchemaFactoryResult, NotModifiedChecker,
|
|
21
22
|
} from './content'
|
|
23
|
+
import { ContentApiSpecificCache } from './content/ContentApiSpecificCache'
|
|
24
|
+
import { homepageController } from './misc'
|
|
25
|
+
import { Plugin } from './plugin/Plugin'
|
|
26
|
+
import { ProjectContainerFactoryFactory } from './project'
|
|
22
27
|
import { ProjectContextResolver } from './project-common'
|
|
28
|
+
import { ProjectGroupContainerFactory } from './projectGroup/ProjectGroupContainer'
|
|
29
|
+
import { ProjectGroupContainerResolver } from './projectGroup/ProjectGroupContainerResolver'
|
|
30
|
+
import { ProjectGroupResolver } from './projectGroup/ProjectGroupResolver'
|
|
31
|
+
import { createColllectHttpMetricsMiddleware, createShowMetricsMiddleware } from './prometheus'
|
|
32
|
+
import { ProjectGroupContainerMetricsHook } from './prometheus/ProjectGroupContainerMetricsHook'
|
|
33
|
+
import { PrometheusRegistryFactory } from './prometheus/PrometheusRegistryFactory'
|
|
34
|
+
import { createProviders, Providers } from './providers'
|
|
35
|
+
import { SystemApiMiddlewareFactory, SystemGraphQLContextFactory, SystemGraphQLHandlerFactory } from './system'
|
|
36
|
+
import { ContentQueryExecutorImpl } from './system/ContentQueryExecutor'
|
|
37
|
+
import { TenantApiMiddlewareFactory, TenantGraphQLHandlerFactory } from './tenant'
|
|
23
38
|
import {
|
|
24
39
|
ContentSchemaTransferMappingFactory,
|
|
25
40
|
ExportApiControllerFactory,
|
|
@@ -28,22 +43,8 @@ import {
|
|
|
28
43
|
ImportExecutor,
|
|
29
44
|
SystemSchemaTransferMappingFactory,
|
|
30
45
|
} from './transfer'
|
|
31
|
-
import { homepageController } from './misc'
|
|
32
|
-
import { Plugin } from './plugin/Plugin'
|
|
33
|
-
import { Application } from './application'
|
|
34
|
-
import { ApplicationWorkerManager } from './workers'
|
|
35
|
-
import { HttpResponse } from './common'
|
|
36
|
-
import { ContentQueryExecutorImpl } from './system/ContentQueryExecutor'
|
|
37
|
-
import { DatabaseMetadataResolver } from '@contember/database'
|
|
38
|
-
import Koa from 'koa'
|
|
39
|
-
import { ProjectGroupContainerResolver } from './projectGroup/ProjectGroupContainerResolver'
|
|
40
|
-
import { PrometheusRegistryFactory } from './prometheus/PrometheusRegistryFactory'
|
|
41
|
-
import { ProjectGroupContainerMetricsHook } from './prometheus/ProjectGroupContainerMetricsHook'
|
|
42
|
-
import { createColllectHttpMetricsMiddleware, createShowMetricsMiddleware } from './prometheus'
|
|
43
|
-
import { createSecretKey } from 'node:crypto'
|
|
44
46
|
import { CryptoWrapper } from './utils/CryptoWrapper'
|
|
45
|
-
import {
|
|
46
|
-
import { Schema } from '@contember/schema'
|
|
47
|
+
import { ApplicationWorkerManager } from './workers'
|
|
47
48
|
|
|
48
49
|
export type ProcessType =
|
|
49
50
|
| 'singleNode'
|
|
@@ -113,8 +114,8 @@ export class MasterContainerFactory {
|
|
|
113
114
|
new TenantContainerFactory(providers))
|
|
114
115
|
.addService('modificationHandlerFactory', () =>
|
|
115
116
|
new ModificationHandlerFactory(ModificationHandlerFactory.defaultFactoryMap))
|
|
116
|
-
.addService('executionContainerFactory', ({ providers }) =>
|
|
117
|
-
new ExecutionContainerFactory(providers))
|
|
117
|
+
.addService('executionContainerFactory', ({ providers, serverConfig }) =>
|
|
118
|
+
new ExecutionContainerFactory(providers, serverConfig.contentApi?.whereOptimizer))
|
|
118
119
|
.addService('graphQlSchemaBuilderFactory', () =>
|
|
119
120
|
new GraphQlSchemaBuilderFactory())
|
|
120
121
|
.addService('contentQueryExecutor', ({ executionContainerFactory, graphQlSchemaBuilderFactory }) =>
|
|
@@ -178,14 +179,12 @@ export class MasterContainerFactory {
|
|
|
178
179
|
})
|
|
179
180
|
.addService('notModifiedChecker', () =>
|
|
180
181
|
new NotModifiedChecker())
|
|
181
|
-
.addService('contentGraphqlContextFactory', ({ providers, executionContainerFactory }) =>
|
|
182
|
-
new ContentGraphQLContextFactory(providers, executionContainerFactory))
|
|
183
182
|
.addService('contentQueryHandlerFactory', ({ debugMode }) =>
|
|
184
183
|
new ContentQueryHandlerFactory(debugMode))
|
|
185
184
|
.addService('projectContextResolver', () =>
|
|
186
185
|
new ProjectContextResolver())
|
|
187
|
-
.addService('contentApiMiddlewareFactory', ({ projectContextResolver, notModifiedChecker,
|
|
188
|
-
new ContentApiControllerFactory(notModifiedChecker,
|
|
186
|
+
.addService('contentApiMiddlewareFactory', ({ projectContextResolver, notModifiedChecker, executionContainerFactory, contentQueryHandlerFactory, graphQlSchemaFactory }) =>
|
|
187
|
+
new ContentApiControllerFactory(notModifiedChecker, executionContainerFactory, contentQueryHandlerFactory, projectContextResolver, graphQlSchemaFactory))
|
|
189
188
|
.addService('tenantApiMiddlewareFactory', () =>
|
|
190
189
|
new TenantApiMiddlewareFactory())
|
|
191
190
|
.addService('systemGraphQLContextFactory', () =>
|
|
@@ -117,6 +117,10 @@ export const serverConfigSchema = Typesafe.partial({
|
|
|
117
117
|
}),
|
|
118
118
|
contentApi: Typesafe.partial({
|
|
119
119
|
schemaCacheTtlSeconds: Typesafe.integer,
|
|
120
|
+
whereOptimizer: Typesafe.partial({
|
|
121
|
+
disable: Typesafe.boolean,
|
|
122
|
+
maxCrossOptimizationInput: Typesafe.number,
|
|
123
|
+
}),
|
|
120
124
|
}),
|
|
121
125
|
logging: Typesafe.union(
|
|
122
126
|
(val): { sentry?: { dsn: string } } => Typesafe.valueAt(val, ['sentry', 'dsn']) === undefined ? {} : Typesafe.fail([]),
|
|
@@ -87,6 +87,10 @@ export const configTemplate: any = {
|
|
|
87
87
|
},
|
|
88
88
|
contentApi: {
|
|
89
89
|
schemaCacheTtlSeconds: '%?env.CONTEMBER_CONTENT_API_SCHEMA_CACHE_TTL_SECONDS::number%',
|
|
90
|
+
whereOptimizer: {
|
|
91
|
+
disable: '%?env.CONTEMBER_CONTENT_API_WHERE_OPTIMIZER_DISABLE::bool%',
|
|
92
|
+
maxCrossOptimizationInput: '%?env.CONTEMBER_CONTENT_API_MAX_CROSS_OPTIMIZATION_INPUT::number%',
|
|
93
|
+
},
|
|
90
94
|
},
|
|
91
95
|
projectGroup: {
|
|
92
96
|
domainMapping: '%?env.CONTEMBER_PROJECT_GROUP_DOMAIN_MAPPING%',
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ProjectContextResolver } from '../project-common'
|
|
3
|
-
import { HttpErrorResponse, HttpResponse } from '../common'
|
|
1
|
+
import { createAclVariables, ExecutionContainerFactory } from '@contember/engine-content-api'
|
|
4
2
|
import { StageBySlugQuery } from '@contember/engine-system-api'
|
|
5
|
-
import { NotModifiedChecker } from './NotModifiedChecker'
|
|
6
|
-
import { ContentGraphQLContextFactory } from './ContentGraphQLContextFactory'
|
|
7
|
-
import { ContentQueryHandler, ContentQueryHandlerFactory } from './ContentQueryHandlerFactory'
|
|
8
3
|
import { GraphQLSchema } from 'graphql'
|
|
4
|
+
import { HttpController } from '../application'
|
|
5
|
+
import { HttpErrorResponse, HttpResponse } from '../common'
|
|
9
6
|
import { GraphQLKoaState } from '../graphql'
|
|
7
|
+
import { ProjectContextResolver } from '../project-common'
|
|
8
|
+
import { ContentQueryHandler, ContentQueryHandlerFactory } from './ContentQueryHandlerFactory'
|
|
10
9
|
import { GraphQlSchemaFactory } from './GraphQlSchemaFactory'
|
|
10
|
+
import { NotModifiedChecker } from './NotModifiedChecker'
|
|
11
11
|
|
|
12
12
|
const debugHeader = 'x-contember-debug'
|
|
13
13
|
|
|
14
14
|
export class ContentApiControllerFactory {
|
|
15
15
|
constructor(
|
|
16
16
|
private readonly notModifiedChecker: NotModifiedChecker,
|
|
17
|
-
private readonly
|
|
17
|
+
private readonly executionContainerFactory: ExecutionContainerFactory,
|
|
18
18
|
private readonly handlerFactory: ContentQueryHandlerFactory,
|
|
19
19
|
private readonly projectContextResolver: ProjectContextResolver,
|
|
20
20
|
private readonly graphQlSchemaFactory: GraphQlSchemaFactory,
|
|
@@ -24,7 +24,7 @@ export class ContentApiControllerFactory {
|
|
|
24
24
|
create(): HttpController {
|
|
25
25
|
const handlerCache = new WeakMap<GraphQLSchema, ContentQueryHandler>()
|
|
26
26
|
return async context => {
|
|
27
|
-
const { params, timer, projectGroup, authResult, request, koa } = context
|
|
27
|
+
const { params, timer, projectGroup, authResult, request, koa, clientIp } = context
|
|
28
28
|
if (!authResult) {
|
|
29
29
|
return new HttpErrorResponse(401, 'Authentication required')
|
|
30
30
|
}
|
|
@@ -113,20 +113,42 @@ export class ContentApiControllerFactory {
|
|
|
113
113
|
const connection = operation === 'query' ? projectContainer.readConnection : projectContainer.connection
|
|
114
114
|
const contentDatabase = connection.createClient(stage.schema, { module: 'content' })
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
|
|
117
|
+
const identityVariables = createAclVariables(schema.acl, memberships)
|
|
118
|
+
let identityId = authResult.identityId
|
|
119
|
+
if (
|
|
120
|
+
authResult.assumedIdentityId &&
|
|
121
|
+
memberships.some(it => schema.acl.roles[it.role].system?.assumeIdentity)
|
|
122
|
+
) {
|
|
123
|
+
identityId = authResult.assumedIdentityId
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const executionContainer = this.executionContainerFactory.create({
|
|
117
127
|
db: contentDatabase,
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
permissions,
|
|
121
|
-
schemaDatabaseMetadata,
|
|
128
|
+
identityVariables,
|
|
129
|
+
identityId,
|
|
122
130
|
schema,
|
|
123
131
|
schemaMeta: { id: schemaWithMeta.meta.id },
|
|
124
|
-
|
|
125
|
-
|
|
132
|
+
schemaDatabaseMetadata,
|
|
133
|
+
permissions,
|
|
126
134
|
systemSchema: projectContainer.systemDatabaseContextFactory.schemaName,
|
|
127
135
|
stage,
|
|
128
136
|
project,
|
|
137
|
+
userInfo: {
|
|
138
|
+
ipAddress: clientIp,
|
|
139
|
+
userAgent: koa.request.headers['user-agent'] ?? null,
|
|
140
|
+
},
|
|
129
141
|
})
|
|
142
|
+
|
|
143
|
+
return {
|
|
144
|
+
db: contentDatabase,
|
|
145
|
+
identityVariables,
|
|
146
|
+
identityId,
|
|
147
|
+
executionContainer,
|
|
148
|
+
timer,
|
|
149
|
+
requestDebug,
|
|
150
|
+
project,
|
|
151
|
+
}
|
|
130
152
|
},
|
|
131
153
|
}))
|
|
132
154
|
logger.debug('Content query finished')
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { GraphQLSchema } from 'graphql'
|
|
2
2
|
import { createDbQueriesListener, createGraphQLQueryHandler, GraphQLListener, GraphQLQueryHandler } from '../graphql'
|
|
3
|
-
import {
|
|
3
|
+
import { ContentGraphqlContext } from './ContentGraphqlContext'
|
|
4
4
|
|
|
5
|
-
export type ContentQueryHandler = GraphQLQueryHandler<
|
|
5
|
+
export type ContentQueryHandler = GraphQLQueryHandler<ContentGraphqlContext>
|
|
6
6
|
|
|
7
7
|
export class ContentQueryHandlerFactory {
|
|
8
8
|
constructor(private readonly debug: boolean) {}
|
|
9
9
|
|
|
10
10
|
public create(graphQlSchema: GraphQLSchema): ContentQueryHandler {
|
|
11
|
-
const listeners: GraphQLListener<
|
|
11
|
+
const listeners: GraphQLListener<ContentGraphqlContext>[] = []
|
|
12
12
|
listeners.push(createDbQueriesListener(context => context.db, this.debug))
|
|
13
13
|
|
|
14
|
-
return createGraphQLQueryHandler<
|
|
14
|
+
return createGraphQLQueryHandler<ContentGraphqlContext>({
|
|
15
15
|
schema: graphQlSchema,
|
|
16
16
|
listeners,
|
|
17
17
|
})
|
package/src/content/index.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
import { Authorizator, ExecutionContainerFactory, GraphQlSchemaBuilderFactory } from '@contember/engine-content-api'
|
|
1
2
|
import {
|
|
2
3
|
ContentQueryExecutor,
|
|
3
4
|
ContentQueryExecutorContext,
|
|
4
5
|
ContentQueryExecutorQuery,
|
|
5
6
|
ContentQueryExecutorResult,
|
|
6
7
|
} from '@contember/engine-system-api'
|
|
7
|
-
import {
|
|
8
|
+
import { logger } from '@contember/logger'
|
|
8
9
|
import { AllowAllPermissionFactory } from '@contember/schema-utils'
|
|
9
10
|
import { graphql, GraphQLError } from 'graphql'
|
|
10
|
-
import {
|
|
11
|
+
import { ContentGraphqlContext } from '../content/ContentGraphqlContext'
|
|
11
12
|
import { extractOriginalError } from '../graphql'
|
|
12
|
-
import { logger } from '@contember/logger'
|
|
13
13
|
|
|
14
14
|
export class ContentQueryExecutorImpl implements ContentQueryExecutor {
|
|
15
15
|
constructor(
|
|
@@ -37,9 +37,13 @@ export class ContentQueryExecutorImpl implements ContentQueryExecutor {
|
|
|
37
37
|
systemSchema: project.systemSchema,
|
|
38
38
|
stage,
|
|
39
39
|
project: project,
|
|
40
|
+
userInfo: {
|
|
41
|
+
ipAddress: null,
|
|
42
|
+
userAgent: null,
|
|
43
|
+
},
|
|
40
44
|
})
|
|
41
45
|
|
|
42
|
-
const ctx:
|
|
46
|
+
const ctx: ContentGraphqlContext = {
|
|
43
47
|
project,
|
|
44
48
|
db: db.client.forSchema(stage.schema),
|
|
45
49
|
identityVariables: {},
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const engineContentApi = require("@contember/engine-content-api");
|
|
4
|
-
class ContentGraphQLContextFactory {
|
|
5
|
-
constructor(providers, executionContainerFactory) {
|
|
6
|
-
this.providers = providers;
|
|
7
|
-
this.executionContainerFactory = executionContainerFactory;
|
|
8
|
-
}
|
|
9
|
-
create({ db, schema, schemaMeta, schemaDatabaseMetadata, authResult, memberships, permissions, timer, requestDebug, systemSchema, stage, project }) {
|
|
10
|
-
const identityVariables = engineContentApi.createAclVariables(schema.acl, memberships);
|
|
11
|
-
let identityId = authResult.identityId;
|
|
12
|
-
if (authResult.assumedIdentityId && memberships.some((it) => schema.acl.roles[it.role].system?.assumeIdentity)) {
|
|
13
|
-
identityId = authResult.assumedIdentityId;
|
|
14
|
-
}
|
|
15
|
-
const executionContainer = this.executionContainerFactory.create({
|
|
16
|
-
db,
|
|
17
|
-
identityVariables,
|
|
18
|
-
identityId,
|
|
19
|
-
schema,
|
|
20
|
-
schemaMeta,
|
|
21
|
-
schemaDatabaseMetadata,
|
|
22
|
-
permissions,
|
|
23
|
-
systemSchema,
|
|
24
|
-
stage,
|
|
25
|
-
project
|
|
26
|
-
});
|
|
27
|
-
return {
|
|
28
|
-
db,
|
|
29
|
-
identityVariables,
|
|
30
|
-
identityId,
|
|
31
|
-
executionContainer,
|
|
32
|
-
timer,
|
|
33
|
-
requestDebug,
|
|
34
|
-
project
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
exports.ContentGraphQLContextFactory = ContentGraphQLContextFactory;
|
|
39
|
-
//# sourceMappingURL=ContentGraphQLContextFactory.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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;;"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { createAclVariables } from "@contember/engine-content-api";
|
|
2
|
-
class ContentGraphQLContextFactory {
|
|
3
|
-
constructor(providers, executionContainerFactory) {
|
|
4
|
-
this.providers = providers;
|
|
5
|
-
this.executionContainerFactory = executionContainerFactory;
|
|
6
|
-
}
|
|
7
|
-
create({ db, schema, schemaMeta, schemaDatabaseMetadata, authResult, memberships, permissions, timer, requestDebug, systemSchema, stage, project }) {
|
|
8
|
-
const identityVariables = createAclVariables(schema.acl, memberships);
|
|
9
|
-
let identityId = authResult.identityId;
|
|
10
|
-
if (authResult.assumedIdentityId && memberships.some((it) => schema.acl.roles[it.role].system?.assumeIdentity)) {
|
|
11
|
-
identityId = authResult.assumedIdentityId;
|
|
12
|
-
}
|
|
13
|
-
const executionContainer = this.executionContainerFactory.create({
|
|
14
|
-
db,
|
|
15
|
-
identityVariables,
|
|
16
|
-
identityId,
|
|
17
|
-
schema,
|
|
18
|
-
schemaMeta,
|
|
19
|
-
schemaDatabaseMetadata,
|
|
20
|
-
permissions,
|
|
21
|
-
systemSchema,
|
|
22
|
-
stage,
|
|
23
|
-
project
|
|
24
|
-
});
|
|
25
|
-
return {
|
|
26
|
-
db,
|
|
27
|
-
identityVariables,
|
|
28
|
-
identityId,
|
|
29
|
-
executionContainer,
|
|
30
|
-
timer,
|
|
31
|
-
requestDebug,
|
|
32
|
-
project
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
export {
|
|
37
|
-
ContentGraphQLContextFactory
|
|
38
|
-
};
|
|
39
|
-
//# sourceMappingURL=ContentGraphQLContextFactory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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\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":[],"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,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,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;"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const engineContentApi = require("@contember/engine-content-api");
|
|
4
|
-
class ContentGraphQLContextFactory {
|
|
5
|
-
constructor(providers, executionContainerFactory) {
|
|
6
|
-
this.providers = providers;
|
|
7
|
-
this.executionContainerFactory = executionContainerFactory;
|
|
8
|
-
}
|
|
9
|
-
create({ db, schema, schemaMeta, schemaDatabaseMetadata, authResult, memberships, permissions, timer, requestDebug, systemSchema, stage, project }) {
|
|
10
|
-
const identityVariables = engineContentApi.createAclVariables(schema.acl, memberships);
|
|
11
|
-
let identityId = authResult.identityId;
|
|
12
|
-
if (authResult.assumedIdentityId && memberships.some((it) => schema.acl.roles[it.role].system?.assumeIdentity)) {
|
|
13
|
-
identityId = authResult.assumedIdentityId;
|
|
14
|
-
}
|
|
15
|
-
const executionContainer = this.executionContainerFactory.create({
|
|
16
|
-
db,
|
|
17
|
-
identityVariables,
|
|
18
|
-
identityId,
|
|
19
|
-
schema,
|
|
20
|
-
schemaMeta,
|
|
21
|
-
schemaDatabaseMetadata,
|
|
22
|
-
permissions,
|
|
23
|
-
systemSchema,
|
|
24
|
-
stage,
|
|
25
|
-
project
|
|
26
|
-
});
|
|
27
|
-
return {
|
|
28
|
-
db,
|
|
29
|
-
identityVariables,
|
|
30
|
-
identityId,
|
|
31
|
-
executionContainer,
|
|
32
|
-
timer,
|
|
33
|
-
requestDebug,
|
|
34
|
-
project
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
exports.ContentGraphQLContextFactory = ContentGraphQLContextFactory;
|
|
39
|
-
//# sourceMappingURL=ContentGraphQLContextFactory.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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;;"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { createAclVariables } from "@contember/engine-content-api";
|
|
2
|
-
class ContentGraphQLContextFactory {
|
|
3
|
-
constructor(providers, executionContainerFactory) {
|
|
4
|
-
this.providers = providers;
|
|
5
|
-
this.executionContainerFactory = executionContainerFactory;
|
|
6
|
-
}
|
|
7
|
-
create({ db, schema, schemaMeta, schemaDatabaseMetadata, authResult, memberships, permissions, timer, requestDebug, systemSchema, stage, project }) {
|
|
8
|
-
const identityVariables = createAclVariables(schema.acl, memberships);
|
|
9
|
-
let identityId = authResult.identityId;
|
|
10
|
-
if (authResult.assumedIdentityId && memberships.some((it) => schema.acl.roles[it.role].system?.assumeIdentity)) {
|
|
11
|
-
identityId = authResult.assumedIdentityId;
|
|
12
|
-
}
|
|
13
|
-
const executionContainer = this.executionContainerFactory.create({
|
|
14
|
-
db,
|
|
15
|
-
identityVariables,
|
|
16
|
-
identityId,
|
|
17
|
-
schema,
|
|
18
|
-
schemaMeta,
|
|
19
|
-
schemaDatabaseMetadata,
|
|
20
|
-
permissions,
|
|
21
|
-
systemSchema,
|
|
22
|
-
stage,
|
|
23
|
-
project
|
|
24
|
-
});
|
|
25
|
-
return {
|
|
26
|
-
db,
|
|
27
|
-
identityVariables,
|
|
28
|
-
identityId,
|
|
29
|
-
executionContainer,
|
|
30
|
-
timer,
|
|
31
|
-
requestDebug,
|
|
32
|
-
project
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
export {
|
|
37
|
-
ContentGraphQLContextFactory
|
|
38
|
-
};
|
|
39
|
-
//# sourceMappingURL=ContentGraphQLContextFactory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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\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":[],"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,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,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;"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Context, ExecutionContainerFactory } from '@contember/engine-content-api';
|
|
2
|
-
import { Client, DatabaseMetadata } from '@contember/database';
|
|
3
|
-
import { Acl, Schema } from '@contember/schema';
|
|
4
|
-
import { AuthResult } from '../common';
|
|
5
|
-
import { Timer } from '../application';
|
|
6
|
-
import { Providers } from '../providers';
|
|
7
|
-
import { ParsedMembership } from '@contember/schema-utils';
|
|
8
|
-
import { Stage } from '@contember/engine-system-api';
|
|
9
|
-
import { ProjectConfig } from '../project/config';
|
|
10
|
-
export type ExtendedGraphqlContext = Context & {
|
|
11
|
-
identityId: string;
|
|
12
|
-
requestDebug: boolean;
|
|
13
|
-
project: {
|
|
14
|
-
slug: string;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
export declare class ContentGraphQLContextFactory {
|
|
18
|
-
private providers;
|
|
19
|
-
private executionContainerFactory;
|
|
20
|
-
constructor(providers: Providers, executionContainerFactory: ExecutionContainerFactory);
|
|
21
|
-
create({ db, schema, schemaMeta, schemaDatabaseMetadata, authResult, memberships, permissions, timer, requestDebug, systemSchema, stage, project }: {
|
|
22
|
-
db: Client;
|
|
23
|
-
schema: Schema;
|
|
24
|
-
schemaMeta: {
|
|
25
|
-
id?: number;
|
|
26
|
-
};
|
|
27
|
-
schemaDatabaseMetadata: DatabaseMetadata;
|
|
28
|
-
permissions: Acl.Permissions;
|
|
29
|
-
authResult: AuthResult;
|
|
30
|
-
memberships: readonly ParsedMembership[];
|
|
31
|
-
timer: Timer;
|
|
32
|
-
requestDebug: boolean;
|
|
33
|
-
systemSchema: string;
|
|
34
|
-
stage: Stage;
|
|
35
|
-
project: ProjectConfig;
|
|
36
|
-
}): ExtendedGraphqlContext;
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=ContentGraphQLContextFactory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContentGraphQLContextFactory.d.ts","sourceRoot":"","sources":["../../../src/content/ContentGraphQLContextFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAsB,yBAAyB,EAAE,MAAM,+BAA+B,CAAA;AACtG,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEjD,MAAM,MAAM,sBAAsB,GAAG,OAAO,GAAG;IAC9C,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,OAAO,CAAA;IACrB,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CACzB,CAAA;AAED,qBAAa,4BAA4B;IAEvC,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,yBAAyB;gBADzB,SAAS,EAAE,SAAS,EACpB,yBAAyB,EAAE,yBAAyB;IAI7D,MAAM,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,sBAAsB,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QACnJ,EAAE,EAAE,MAAM,CAAA;QACV,MAAM,EAAE,MAAM,CAAA;QACd,UAAU,EAAE;YAAE,EAAE,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;QAC3B,sBAAsB,EAAE,gBAAgB,CAAA;QACxC,WAAW,EAAE,GAAG,CAAC,WAAW,CAAA;QAC5B,UAAU,EAAE,UAAU,CAAA;QACtB,WAAW,EAAE,SAAS,gBAAgB,EAAE,CAAA;QACxC,KAAK,EAAE,KAAK,CAAA;QACZ,YAAY,EAAE,OAAO,CAAA;QACrB,YAAY,EAAE,MAAM,CAAA;QACpB,KAAK,EAAE,KAAK,CAAA;QACZ,OAAO,EAAE,aAAa,CAAA;KACtB,GAAG,sBAAsB;CAiC1B"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { Context, createAclVariables, ExecutionContainerFactory } from '@contember/engine-content-api'
|
|
2
|
-
import { Client, DatabaseMetadata } from '@contember/database'
|
|
3
|
-
import { Acl, Schema } from '@contember/schema'
|
|
4
|
-
import { AuthResult } from '../common'
|
|
5
|
-
import { Timer } from '../application'
|
|
6
|
-
import { Providers } from '../providers'
|
|
7
|
-
import { ParsedMembership } from '@contember/schema-utils'
|
|
8
|
-
import { Stage } from '@contember/engine-system-api'
|
|
9
|
-
import { ProjectConfig } from '../project/config'
|
|
10
|
-
|
|
11
|
-
export type ExtendedGraphqlContext = Context & {
|
|
12
|
-
identityId: string
|
|
13
|
-
requestDebug: boolean
|
|
14
|
-
project: { slug: string }
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class ContentGraphQLContextFactory {
|
|
18
|
-
constructor(
|
|
19
|
-
private providers: Providers,
|
|
20
|
-
private executionContainerFactory: ExecutionContainerFactory,
|
|
21
|
-
) {
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
create({ db, schema, schemaMeta, schemaDatabaseMetadata, authResult, memberships, permissions, timer, requestDebug, systemSchema, stage, project }: {
|
|
25
|
-
db: Client
|
|
26
|
-
schema: Schema
|
|
27
|
-
schemaMeta: { id?: number }
|
|
28
|
-
schemaDatabaseMetadata: DatabaseMetadata
|
|
29
|
-
permissions: Acl.Permissions
|
|
30
|
-
authResult: AuthResult
|
|
31
|
-
memberships: readonly ParsedMembership[]
|
|
32
|
-
timer: Timer
|
|
33
|
-
requestDebug: boolean
|
|
34
|
-
systemSchema: string
|
|
35
|
-
stage: Stage
|
|
36
|
-
project: ProjectConfig
|
|
37
|
-
}): ExtendedGraphqlContext {
|
|
38
|
-
const identityVariables = createAclVariables(schema.acl, memberships)
|
|
39
|
-
let identityId = authResult.identityId
|
|
40
|
-
if (
|
|
41
|
-
authResult.assumedIdentityId &&
|
|
42
|
-
memberships.some(it => schema.acl.roles[it.role].system?.assumeIdentity)
|
|
43
|
-
) {
|
|
44
|
-
identityId = authResult.assumedIdentityId
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const executionContainer = this.executionContainerFactory.create({
|
|
48
|
-
db,
|
|
49
|
-
identityVariables,
|
|
50
|
-
identityId,
|
|
51
|
-
schema,
|
|
52
|
-
schemaMeta,
|
|
53
|
-
schemaDatabaseMetadata,
|
|
54
|
-
permissions,
|
|
55
|
-
systemSchema,
|
|
56
|
-
stage,
|
|
57
|
-
project,
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
db,
|
|
62
|
-
identityVariables,
|
|
63
|
-
identityId,
|
|
64
|
-
executionContainer,
|
|
65
|
-
timer,
|
|
66
|
-
requestDebug,
|
|
67
|
-
project,
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|