@contember/engine-http 2.2.0-alpha.19 → 2.2.0-alpha.20
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/CLAUDE.md +2 -0
- package/dist/development/index.cjs +8 -0
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +9 -1
- package/dist/development/index.js.map +1 -1
- package/dist/development/src/MasterContainer.cjs +28 -14
- package/dist/development/src/MasterContainer.cjs.map +1 -1
- package/dist/development/src/MasterContainer.js +28 -14
- package/dist/development/src/MasterContainer.js.map +1 -1
- package/dist/development/src/config/configSchema.cjs +50 -0
- package/dist/development/src/config/configSchema.cjs.map +1 -1
- package/dist/development/src/config/configSchema.js +50 -0
- package/dist/development/src/config/configSchema.js.map +1 -1
- package/dist/development/src/config/configTemplate.cjs +8 -0
- package/dist/development/src/config/configTemplate.cjs.map +1 -1
- package/dist/development/src/config/configTemplate.js +8 -0
- package/dist/development/src/config/configTemplate.js.map +1 -1
- package/dist/development/src/content/ContentApiControllerFactory.cjs +12 -1
- package/dist/development/src/content/ContentApiControllerFactory.cjs.map +1 -1
- package/dist/development/src/content/ContentApiControllerFactory.js +12 -1
- package/dist/development/src/content/ContentApiControllerFactory.js.map +1 -1
- package/dist/development/src/content/ContentApiSpecificCache.cjs +20 -5
- package/dist/development/src/content/ContentApiSpecificCache.cjs.map +1 -1
- package/dist/development/src/content/ContentApiSpecificCache.js +20 -5
- package/dist/development/src/content/ContentApiSpecificCache.js.map +1 -1
- package/dist/development/src/content/ContentGraphQLEngine.cjs +17 -0
- package/dist/development/src/content/ContentGraphQLEngine.cjs.map +1 -0
- package/dist/development/src/content/ContentGraphQLEngine.js +17 -0
- package/dist/development/src/content/ContentGraphQLEngine.js.map +1 -0
- package/dist/development/src/content/ContentQueryHandlerFactory.cjs +4 -1
- package/dist/development/src/content/ContentQueryHandlerFactory.cjs.map +1 -1
- package/dist/development/src/content/ContentQueryHandlerFactory.js +5 -2
- package/dist/development/src/content/ContentQueryHandlerFactory.js.map +1 -1
- package/dist/development/src/content/ContentRequestLog.cjs +97 -0
- package/dist/development/src/content/ContentRequestLog.cjs.map +1 -0
- package/dist/development/src/content/ContentRequestLog.js +97 -0
- package/dist/development/src/content/ContentRequestLog.js.map +1 -0
- package/dist/development/src/content/GraphQlSchemaFactory.cjs +121 -45
- package/dist/development/src/content/GraphQlSchemaFactory.cjs.map +1 -1
- package/dist/development/src/content/GraphQlSchemaFactory.js +122 -46
- package/dist/development/src/content/GraphQlSchemaFactory.js.map +1 -1
- package/dist/development/src/graphql/execution.cjs +18 -5
- package/dist/development/src/graphql/execution.cjs.map +1 -1
- package/dist/development/src/graphql/execution.js +19 -6
- package/dist/development/src/graphql/execution.js.map +1 -1
- package/dist/development/src/project/ProjectContainer.cjs +2 -0
- package/dist/development/src/project/ProjectContainer.cjs.map +1 -1
- package/dist/development/src/project/ProjectContainer.js +2 -0
- package/dist/development/src/project/ProjectContainer.js.map +1 -1
- package/dist/development/src/projectGroup/ProjectGroupContainer.cjs +2 -0
- package/dist/development/src/projectGroup/ProjectGroupContainer.cjs.map +1 -1
- package/dist/development/src/projectGroup/ProjectGroupContainer.js +2 -0
- package/dist/development/src/projectGroup/ProjectGroupContainer.js.map +1 -1
- package/dist/development/src/system/ContentQueryExecutor.cjs +23 -6
- package/dist/development/src/system/ContentQueryExecutor.cjs.map +1 -1
- package/dist/development/src/system/ContentQueryExecutor.js +25 -8
- package/dist/development/src/system/ContentQueryExecutor.js.map +1 -1
- package/dist/development/src/system/SystemGraphQLHandlerFactory.cjs +1 -1
- package/dist/development/src/system/SystemGraphQLHandlerFactory.cjs.map +1 -1
- package/dist/development/src/system/SystemGraphQLHandlerFactory.js +2 -2
- package/dist/development/src/system/SystemGraphQLHandlerFactory.js.map +1 -1
- package/dist/development/src/tenant/TenantGraphQLHandlerFactory.cjs +1 -1
- package/dist/development/src/tenant/TenantGraphQLHandlerFactory.cjs.map +1 -1
- package/dist/development/src/tenant/TenantGraphQLHandlerFactory.js +2 -2
- package/dist/development/src/tenant/TenantGraphQLHandlerFactory.js.map +1 -1
- package/dist/production/index.cjs +8 -0
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.js +9 -1
- package/dist/production/index.js.map +1 -1
- package/dist/production/src/MasterContainer.cjs +28 -14
- package/dist/production/src/MasterContainer.cjs.map +1 -1
- package/dist/production/src/MasterContainer.js +28 -14
- package/dist/production/src/MasterContainer.js.map +1 -1
- package/dist/production/src/config/configSchema.cjs +50 -0
- package/dist/production/src/config/configSchema.cjs.map +1 -1
- package/dist/production/src/config/configSchema.js +50 -0
- package/dist/production/src/config/configSchema.js.map +1 -1
- package/dist/production/src/config/configTemplate.cjs +8 -0
- package/dist/production/src/config/configTemplate.cjs.map +1 -1
- package/dist/production/src/config/configTemplate.js +8 -0
- package/dist/production/src/config/configTemplate.js.map +1 -1
- package/dist/production/src/content/ContentApiControllerFactory.cjs +12 -1
- package/dist/production/src/content/ContentApiControllerFactory.cjs.map +1 -1
- package/dist/production/src/content/ContentApiControllerFactory.js +12 -1
- package/dist/production/src/content/ContentApiControllerFactory.js.map +1 -1
- package/dist/production/src/content/ContentApiSpecificCache.cjs +20 -5
- package/dist/production/src/content/ContentApiSpecificCache.cjs.map +1 -1
- package/dist/production/src/content/ContentApiSpecificCache.js +20 -5
- package/dist/production/src/content/ContentApiSpecificCache.js.map +1 -1
- package/dist/production/src/content/ContentGraphQLEngine.cjs +17 -0
- package/dist/production/src/content/ContentGraphQLEngine.cjs.map +1 -0
- package/dist/production/src/content/ContentGraphQLEngine.js +17 -0
- package/dist/production/src/content/ContentGraphQLEngine.js.map +1 -0
- package/dist/production/src/content/ContentQueryHandlerFactory.cjs +4 -1
- package/dist/production/src/content/ContentQueryHandlerFactory.cjs.map +1 -1
- package/dist/production/src/content/ContentQueryHandlerFactory.js +5 -2
- package/dist/production/src/content/ContentQueryHandlerFactory.js.map +1 -1
- package/dist/production/src/content/ContentRequestLog.cjs +97 -0
- package/dist/production/src/content/ContentRequestLog.cjs.map +1 -0
- package/dist/production/src/content/ContentRequestLog.js +97 -0
- package/dist/production/src/content/ContentRequestLog.js.map +1 -0
- package/dist/production/src/content/GraphQlSchemaFactory.cjs +121 -45
- package/dist/production/src/content/GraphQlSchemaFactory.cjs.map +1 -1
- package/dist/production/src/content/GraphQlSchemaFactory.js +122 -46
- package/dist/production/src/content/GraphQlSchemaFactory.js.map +1 -1
- package/dist/production/src/graphql/execution.cjs +18 -5
- package/dist/production/src/graphql/execution.cjs.map +1 -1
- package/dist/production/src/graphql/execution.js +19 -6
- package/dist/production/src/graphql/execution.js.map +1 -1
- package/dist/production/src/project/ProjectContainer.cjs +2 -0
- package/dist/production/src/project/ProjectContainer.cjs.map +1 -1
- package/dist/production/src/project/ProjectContainer.js +2 -0
- package/dist/production/src/project/ProjectContainer.js.map +1 -1
- package/dist/production/src/projectGroup/ProjectGroupContainer.cjs +2 -0
- package/dist/production/src/projectGroup/ProjectGroupContainer.cjs.map +1 -1
- package/dist/production/src/projectGroup/ProjectGroupContainer.js +2 -0
- package/dist/production/src/projectGroup/ProjectGroupContainer.js.map +1 -1
- package/dist/production/src/system/ContentQueryExecutor.cjs +23 -6
- package/dist/production/src/system/ContentQueryExecutor.cjs.map +1 -1
- package/dist/production/src/system/ContentQueryExecutor.js +25 -8
- package/dist/production/src/system/ContentQueryExecutor.js.map +1 -1
- package/dist/production/src/system/SystemGraphQLHandlerFactory.cjs +1 -1
- package/dist/production/src/system/SystemGraphQLHandlerFactory.cjs.map +1 -1
- package/dist/production/src/system/SystemGraphQLHandlerFactory.js +2 -2
- package/dist/production/src/system/SystemGraphQLHandlerFactory.js.map +1 -1
- package/dist/production/src/tenant/TenantGraphQLHandlerFactory.cjs +1 -1
- package/dist/production/src/tenant/TenantGraphQLHandlerFactory.cjs.map +1 -1
- package/dist/production/src/tenant/TenantGraphQLHandlerFactory.js +2 -2
- package/dist/production/src/tenant/TenantGraphQLHandlerFactory.js.map +1 -1
- package/dist/tests/cases/unit/contentGraphqlCompat.test.d.ts +2 -0
- package/dist/tests/cases/unit/contentGraphqlCompat.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/contentRequestLog.test.d.ts +2 -0
- package/dist/tests/cases/unit/contentRequestLog.test.d.ts.map +1 -0
- package/dist/tests/contentControllerHarness.d.ts +29 -0
- package/dist/tests/contentControllerHarness.d.ts.map +1 -0
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/dist/types/MasterContainer.d.ts +10 -1
- package/dist/types/MasterContainer.d.ts.map +1 -1
- package/dist/types/config/configSchema.d.ts +10 -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 +3 -1
- package/dist/types/content/ContentApiControllerFactory.d.ts.map +1 -1
- package/dist/types/content/ContentApiSpecificCache.d.ts +2 -0
- package/dist/types/content/ContentApiSpecificCache.d.ts.map +1 -1
- package/dist/types/content/ContentGraphQLEngine.d.ts +18 -0
- package/dist/types/content/ContentGraphQLEngine.d.ts.map +1 -0
- package/dist/types/content/ContentQueryHandlerFactory.d.ts +3 -2
- package/dist/types/content/ContentQueryHandlerFactory.d.ts.map +1 -1
- package/dist/types/content/ContentRequestLog.d.ts +49 -0
- package/dist/types/content/ContentRequestLog.d.ts.map +1 -0
- package/dist/types/content/GraphQlSchemaFactory.d.ts +14 -4
- package/dist/types/content/GraphQlSchemaFactory.d.ts.map +1 -1
- package/dist/types/content/index.d.ts +2 -0
- package/dist/types/content/index.d.ts.map +1 -1
- package/dist/types/graphql/execution.d.ts +21 -3
- package/dist/types/graphql/execution.d.ts.map +1 -1
- package/dist/types/system/ContentQueryExecutor.d.ts +4 -1
- package/dist/types/system/ContentQueryExecutor.d.ts.map +1 -1
- package/dist/types/system/SystemGraphQLHandlerFactory.d.ts.map +1 -1
- package/dist/types/tenant/TenantGraphQLHandlerFactory.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +21 -18
- package/src/MasterContainer.ts +31 -14
- package/src/config/configSchema.ts +63 -0
- package/src/config/configTemplate.ts +8 -0
- package/src/content/ContentApiControllerFactory.ts +15 -2
- package/src/content/ContentApiSpecificCache.ts +22 -7
- package/src/content/ContentGraphQLEngine.ts +24 -0
- package/src/content/ContentQueryHandlerFactory.ts +16 -4
- package/src/content/ContentRequestLog.ts +138 -0
- package/src/content/GraphQlSchemaFactory.ts +173 -54
- package/src/content/index.ts +2 -0
- package/src/graphql/execution.ts +35 -7
- package/src/project/ProjectContainer.ts +1 -1
- package/src/system/ContentQueryExecutor.ts +43 -10
- package/src/system/SystemGraphQLHandlerFactory.ts +8 -2
- package/src/tenant/TenantGraphQLHandlerFactory.ts +2 -2
- package/src/tsconfig.json +1 -0
- package/tests/cases/unit/__snapshots__/contentGraphqlCompat.test.ts.snap +14295 -0
- package/tests/cases/unit/contentGraphqlCompat.test.ts +372 -0
- package/tests/cases/unit/contentRequestLog.test.ts +141 -0
- package/tests/cases/unit/forcePrimary.test.ts +93 -284
- package/tests/cases/unit/graphQlSchemaFactory.test.ts +227 -35
- package/tests/cases/unit/requestMemoryBudget.test.ts +96 -78
- package/tests/cases/unit/serverConfig.test.ts +133 -0
- package/tests/contentControllerHarness.ts +222 -0
- package/tests/tsconfig.json +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/engine-http",
|
|
3
|
-
"version": "2.2.0-alpha.
|
|
3
|
+
"version": "2.2.0-alpha.20",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/production/index.js",
|
|
6
6
|
"typings": "./dist/types/index.d.ts",
|
|
@@ -26,23 +26,24 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@contember/config-loader": "2.2.0-alpha.
|
|
30
|
-
"@contember/database": "2.2.0-alpha.
|
|
31
|
-
"@contember/database-migrations": "2.2.0-alpha.
|
|
32
|
-
"@contember/dic": "2.2.0-alpha.
|
|
33
|
-
"@contember/engine-common": "2.2.0-alpha.
|
|
34
|
-
"@contember/engine-content-api": "2.2.0-alpha.
|
|
35
|
-
"@contember/engine-system-api": "2.2.0-alpha.
|
|
36
|
-
"@contember/engine-tenant-api": "2.2.0-alpha.
|
|
37
|
-
"@contember/graphql-
|
|
38
|
-
"@contember/
|
|
39
|
-
"@contember/
|
|
40
|
-
"@contember/schema
|
|
41
|
-
"@contember/schema-
|
|
42
|
-
"@contember/
|
|
43
|
-
"@contember/
|
|
44
|
-
"@contember/
|
|
45
|
-
"@contember/
|
|
29
|
+
"@contember/config-loader": "2.2.0-alpha.20",
|
|
30
|
+
"@contember/database": "2.2.0-alpha.20",
|
|
31
|
+
"@contember/database-migrations": "2.2.0-alpha.20",
|
|
32
|
+
"@contember/dic": "2.2.0-alpha.20",
|
|
33
|
+
"@contember/engine-common": "2.2.0-alpha.20",
|
|
34
|
+
"@contember/engine-content-api": "2.2.0-alpha.20",
|
|
35
|
+
"@contember/engine-system-api": "2.2.0-alpha.20",
|
|
36
|
+
"@contember/engine-tenant-api": "2.2.0-alpha.20",
|
|
37
|
+
"@contember/graphql-json": "2.2.0-alpha.20",
|
|
38
|
+
"@contember/graphql-utils": "2.2.0-alpha.20",
|
|
39
|
+
"@contember/logger": "2.2.0-alpha.20",
|
|
40
|
+
"@contember/schema": "2.2.0-alpha.20",
|
|
41
|
+
"@contember/schema-migrations": "2.2.0-alpha.20",
|
|
42
|
+
"@contember/schema-utils": "2.2.0-alpha.20",
|
|
43
|
+
"@contember/sentry-client": "2.2.0-alpha.20",
|
|
44
|
+
"@contember/telemetry": "2.2.0-alpha.20",
|
|
45
|
+
"@contember/typesafe": "2.2.0-alpha.20",
|
|
46
|
+
"@contember/utilities": "2.2.0-alpha.20",
|
|
46
47
|
"@graphql-tools/merge": "^9.1.7",
|
|
47
48
|
"@graphql-tools/schema": "^10.0.31",
|
|
48
49
|
"bcryptjs": "^3.0.3",
|
|
@@ -53,6 +54,8 @@
|
|
|
53
54
|
"ws": "^8.19.0"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
57
|
+
"@contember/database-tester": "2.2.0-alpha.20",
|
|
58
|
+
"@contember/schema-definition": "2.2.0-alpha.20",
|
|
56
59
|
"@types/koa": "^2.15.0",
|
|
57
60
|
"@types/node": "^24.12.0",
|
|
58
61
|
"@types/ws": "^8.18.1",
|
package/src/MasterContainer.ts
CHANGED
|
@@ -19,6 +19,7 @@ import { ProjectConfigResolver } from './config/projectConfigResolver.js'
|
|
|
19
19
|
import { TenantConfigResolver } from './config/tenantConfigResolver.js'
|
|
20
20
|
import {
|
|
21
21
|
ContentApiControllerFactory,
|
|
22
|
+
ContentGraphQLEngineResolver,
|
|
22
23
|
ContentQueryHandlerFactory,
|
|
23
24
|
GraphQLSchemaContributor,
|
|
24
25
|
GraphQlSchemaFactory,
|
|
@@ -26,6 +27,7 @@ import {
|
|
|
26
27
|
NotModifiedChecker,
|
|
27
28
|
} from './content/index.js'
|
|
28
29
|
import { ContentApiSpecificCache } from './content/ContentApiSpecificCache.js'
|
|
30
|
+
import { ContentRequestLog } from './content/ContentRequestLog.js'
|
|
29
31
|
import { homepageController } from './misc/index.js'
|
|
30
32
|
import { Plugin } from './plugin/Plugin.js'
|
|
31
33
|
import { ProjectContainerFactoryFactory } from './project/index.js'
|
|
@@ -65,6 +67,7 @@ export interface MasterContainer {
|
|
|
65
67
|
providers: Providers
|
|
66
68
|
applicationWorkers: ApplicationWorkerManager
|
|
67
69
|
monitoringKoa: Koa
|
|
70
|
+
contentRequestLog: ContentRequestLog | undefined
|
|
68
71
|
}
|
|
69
72
|
|
|
70
73
|
export interface MasterContainerArgs {
|
|
@@ -124,10 +127,14 @@ export class MasterContainerFactory {
|
|
|
124
127
|
({ providers, serverConfig }) => new ExecutionContainerFactory(providers, serverConfig.contentApi?.whereOptimizer),
|
|
125
128
|
)
|
|
126
129
|
.addService('graphQlSchemaBuilderFactory', () => new GraphQlSchemaBuilderFactory())
|
|
130
|
+
.addService(
|
|
131
|
+
'contentGraphQLEngineResolver',
|
|
132
|
+
({ serverConfig }) => new ContentGraphQLEngineResolver(serverConfig.contentApi?.graphqlEngine, serverConfig.contentApi?.graphqlJsonProjects),
|
|
133
|
+
)
|
|
127
134
|
.addService(
|
|
128
135
|
'contentQueryExecutor',
|
|
129
|
-
({ executionContainerFactory, graphQlSchemaBuilderFactory }) =>
|
|
130
|
-
new ContentQueryExecutorImpl(executionContainerFactory, graphQlSchemaBuilderFactory),
|
|
136
|
+
({ executionContainerFactory, graphQlSchemaBuilderFactory, contentGraphQLEngineResolver }) =>
|
|
137
|
+
new ContentQueryExecutorImpl(executionContainerFactory, graphQlSchemaBuilderFactory, contentGraphQLEngineResolver),
|
|
131
138
|
)
|
|
132
139
|
.addService(
|
|
133
140
|
'systemContainerFactory',
|
|
@@ -141,18 +148,22 @@ export class MasterContainerFactory {
|
|
|
141
148
|
ttlSeconds: serverConfig.contentApi?.schemaCacheTtlSeconds,
|
|
142
149
|
maxEntries: serverConfig.contentApi?.schemaCacheMaxEntries,
|
|
143
150
|
}))
|
|
144
|
-
.addService(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
151
|
+
.addService(
|
|
152
|
+
'graphQlSchemaFactory',
|
|
153
|
+
({ plugins, providers, graphqlSchemaCache, contentPermissionFactory, graphQlSchemaBuilderFactory, contentGraphQLEngineResolver }) => {
|
|
154
|
+
const contributors = plugins
|
|
155
|
+
.map(it => (it.getSchemaContributor ? it.getSchemaContributor({ providers }) : null))
|
|
156
|
+
.filter((it): it is GraphQLSchemaContributor => !!it)
|
|
148
157
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
158
|
+
return new GraphQlSchemaFactory(
|
|
159
|
+
graphqlSchemaCache,
|
|
160
|
+
graphQlSchemaBuilderFactory,
|
|
161
|
+
contentPermissionFactory,
|
|
162
|
+
contributors,
|
|
163
|
+
contentGraphQLEngineResolver,
|
|
164
|
+
)
|
|
165
|
+
},
|
|
166
|
+
)
|
|
156
167
|
.addService(
|
|
157
168
|
'projectContainerFactoryFactory',
|
|
158
169
|
({ plugins, providers, databaseMetadataResolver }) => new ProjectContainerFactoryFactory(plugins, providers, databaseMetadataResolver),
|
|
@@ -235,6 +246,10 @@ export class MasterContainerFactory {
|
|
|
235
246
|
.addService('notModifiedChecker', () => new NotModifiedChecker())
|
|
236
247
|
.addService('contentQueryHandlerFactory', ({ debugMode }) => new ContentQueryHandlerFactory(debugMode))
|
|
237
248
|
.addService('projectContextResolver', () => new ProjectContextResolver())
|
|
249
|
+
.addService('contentRequestLog', ({ serverConfig, logger }) => {
|
|
250
|
+
const options = serverConfig.contentApi?.requestLog
|
|
251
|
+
return options ? new ContentRequestLog(options, logger) : undefined
|
|
252
|
+
})
|
|
238
253
|
.addService(
|
|
239
254
|
'contentApiMiddlewareFactory',
|
|
240
255
|
(
|
|
@@ -246,6 +261,7 @@ export class MasterContainerFactory {
|
|
|
246
261
|
graphQlSchemaFactory,
|
|
247
262
|
testTransactionService,
|
|
248
263
|
serverConfig,
|
|
264
|
+
contentRequestLog,
|
|
249
265
|
},
|
|
250
266
|
) =>
|
|
251
267
|
new ContentApiControllerFactory(
|
|
@@ -257,6 +273,7 @@ export class MasterContainerFactory {
|
|
|
257
273
|
testTransactionService,
|
|
258
274
|
serverConfig.contentApi?.forcePrimaryHeader ?? false,
|
|
259
275
|
serverConfig.http?.requestMemoryBudget,
|
|
276
|
+
contentRequestLog,
|
|
260
277
|
),
|
|
261
278
|
)
|
|
262
279
|
.addService('tenantApiMiddlewareFactory', () => new TenantApiMiddlewareFactory())
|
|
@@ -376,6 +393,6 @@ export class MasterContainerFactory {
|
|
|
376
393
|
|
|
377
394
|
create(args: MasterContainerArgs): MasterContainer {
|
|
378
395
|
const container = this.createBuilder(args).build()
|
|
379
|
-
return container.pick('initializer', 'application', 'providers', 'applicationWorkers', 'monitoringKoa')
|
|
396
|
+
return container.pick('initializer', 'application', 'providers', 'applicationWorkers', 'monitoringKoa', 'contentRequestLog')
|
|
380
397
|
}
|
|
381
398
|
}
|
|
@@ -5,6 +5,7 @@ import { upperCaseFirst } from '../utils/strings.js'
|
|
|
5
5
|
import ipaddr from 'ipaddr.js'
|
|
6
6
|
import { EgressError, EgressPolicy } from '@contember/engine-common'
|
|
7
7
|
import { parseByteSize } from '../application/requestBody.js'
|
|
8
|
+
import { contentRequestLogMaxRequestsCeiling, contentRequestLogMaxUntilDays, ContentRequestLogOptions } from '../content/ContentRequestLog.js'
|
|
8
9
|
|
|
9
10
|
const dbConfigRequired = {
|
|
10
11
|
host: Typesafe.string,
|
|
@@ -179,6 +180,63 @@ const egressConfigSchema = Typesafe.transform(
|
|
|
179
180
|
},
|
|
180
181
|
)
|
|
181
182
|
|
|
183
|
+
/** A comma-separated string or a list of project slugs; empty means unset. */
|
|
184
|
+
const projectSlugList = (val: unknown, path: PropertyKey[] = []): string[] | undefined => {
|
|
185
|
+
if (val === undefined || val === null || val === '') {
|
|
186
|
+
return undefined
|
|
187
|
+
}
|
|
188
|
+
const raw = typeof val === 'string' ? val.split(',') : Typesafe.array(Typesafe.string)(val, path)
|
|
189
|
+
return raw.map(it => it.trim()).filter(Boolean)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const contentRequestLogProjectsSchema = Typesafe.partial({ projects: projectSlugList })
|
|
193
|
+
|
|
194
|
+
const contentRequestLogSchema = Typesafe.object({
|
|
195
|
+
file: Typesafe.string,
|
|
196
|
+
maxRequests: positiveInteger,
|
|
197
|
+
until: Typesafe.string,
|
|
198
|
+
})
|
|
199
|
+
|
|
200
|
+
// Date.parse accepts implementation-defined formats too; only ISO 8601 is allowed, so Bun and Node agree
|
|
201
|
+
const isoTimestampWithZone = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})$/
|
|
202
|
+
|
|
203
|
+
const requestLogEnv = { file: 'FILE', maxRequests: 'MAX_REQUESTS', until: 'UNTIL' }
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Off unless projects are listed; only then are the other options read, so empty variables of an unused log are fine.
|
|
207
|
+
* `until` is absolute, so that no restart or cluster worker extends the recording.
|
|
208
|
+
*/
|
|
209
|
+
const contentRequestLog = (input: unknown, path: PropertyKey[] = []): ContentRequestLogOptions | undefined => {
|
|
210
|
+
if (input === undefined) {
|
|
211
|
+
return undefined
|
|
212
|
+
}
|
|
213
|
+
const { projects } = contentRequestLogProjectsSchema(input, path)
|
|
214
|
+
if (!projects?.length) {
|
|
215
|
+
return undefined
|
|
216
|
+
}
|
|
217
|
+
for (const [key, env] of Object.entries(requestLogEnv)) {
|
|
218
|
+
const value = Typesafe.valueAt(input, [key])
|
|
219
|
+
if (value === undefined || value === '') {
|
|
220
|
+
return Typesafe.fail([...path, key], `is required when projects are listed (CONTEMBER_CONTENT_API_REQUEST_LOG_${env})`)
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (typeof Typesafe.valueAt(input, ['until']) !== 'string') {
|
|
224
|
+
return Typesafe.fail([...path, 'until'], 'must be a string; quote it in YAML, which otherwise reads a timestamp as a date')
|
|
225
|
+
}
|
|
226
|
+
const { file, maxRequests, until } = contentRequestLogSchema(input, path)
|
|
227
|
+
if (maxRequests > contentRequestLogMaxRequestsCeiling) {
|
|
228
|
+
return Typesafe.fail([...path, 'maxRequests'], `must be at most ${contentRequestLogMaxRequestsCeiling}`)
|
|
229
|
+
}
|
|
230
|
+
const untilTime = isoTimestampWithZone.test(until) ? Date.parse(until) : Number.NaN
|
|
231
|
+
if (Number.isNaN(untilTime)) {
|
|
232
|
+
return Typesafe.fail([...path, 'until'], 'must be an ISO timestamp with a time zone, e.g. 2026-01-02T18:00:00Z')
|
|
233
|
+
}
|
|
234
|
+
if (untilTime > Date.now() + contentRequestLogMaxUntilDays * 24 * 3600 * 1000) {
|
|
235
|
+
return Typesafe.fail([...path, 'until'], `must be at most ${contentRequestLogMaxUntilDays} days ahead`)
|
|
236
|
+
}
|
|
237
|
+
return { projects, file, maxRequests, until: new Date(untilTime).toISOString() }
|
|
238
|
+
}
|
|
239
|
+
|
|
182
240
|
export const serverConfigSchema = Typesafe.partial({
|
|
183
241
|
port: Typesafe.number,
|
|
184
242
|
http: Typesafe.partial({
|
|
@@ -302,6 +360,11 @@ export const serverConfigSchema = Typesafe.partial({
|
|
|
302
360
|
return maxEntries > 0 ? maxEntries : Typesafe.fail(path, 'must be a positive integer')
|
|
303
361
|
},
|
|
304
362
|
forcePrimaryHeader: Typesafe.boolean,
|
|
363
|
+
// an empty variable means unset, as for graphqlJsonProjects
|
|
364
|
+
graphqlEngine: (val: unknown, path: PropertyKey[] = []): 'graphql-js' | 'graphql-json' | undefined =>
|
|
365
|
+
val === undefined || val === '' ? undefined : Typesafe.enumeration('graphql-js', 'graphql-json')(val, path),
|
|
366
|
+
graphqlJsonProjects: projectSlugList,
|
|
367
|
+
requestLog: contentRequestLog,
|
|
305
368
|
whereOptimizer: Typesafe.partial({
|
|
306
369
|
disable: Typesafe.boolean,
|
|
307
370
|
maxCrossOptimizationInput: Typesafe.number,
|
|
@@ -112,6 +112,14 @@ export const configTemplate: any = {
|
|
|
112
112
|
schemaCacheTtlSeconds: '%?env.CONTEMBER_CONTENT_API_SCHEMA_CACHE_TTL_SECONDS::number%',
|
|
113
113
|
schemaCacheMaxEntries: '%?env.CONTEMBER_CONTENT_API_SCHEMA_CACHE_MAX_ENTRIES::number%',
|
|
114
114
|
forcePrimaryHeader: '%?env.CONTEMBER_CONTENT_API_FORCE_PRIMARY_HEADER::bool%',
|
|
115
|
+
graphqlEngine: '%?env.CONTEMBER_CONTENT_API_GRAPHQL_ENGINE%',
|
|
116
|
+
graphqlJsonProjects: '%?env.CONTEMBER_CONTENT_API_GRAPHQL_JSON_PROJECTS%',
|
|
117
|
+
requestLog: {
|
|
118
|
+
projects: '%?env.CONTEMBER_CONTENT_API_REQUEST_LOG_PROJECTS%',
|
|
119
|
+
file: '%?env.CONTEMBER_CONTENT_API_REQUEST_LOG_FILE%',
|
|
120
|
+
maxRequests: '%?env.CONTEMBER_CONTENT_API_REQUEST_LOG_MAX_REQUESTS::number%',
|
|
121
|
+
until: '%?env.CONTEMBER_CONTENT_API_REQUEST_LOG_UNTIL%',
|
|
122
|
+
},
|
|
115
123
|
whereOptimizer: {
|
|
116
124
|
disable: '%?env.CONTEMBER_CONTENT_API_WHERE_OPTIMIZER_DISABLE::bool%',
|
|
117
125
|
maxCrossOptimizationInput: '%?env.CONTEMBER_CONTENT_API_MAX_CROSS_OPTIMIZATION_INPUT::number%',
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { createAclVariables, ExecutionContainerFactory } from '@contember/engine-content-api'
|
|
2
2
|
import { StageBySlugQuery } from '@contember/engine-system-api'
|
|
3
3
|
import { Client, RequestMemoryBudget, RequestMemoryBudgetOptions } from '@contember/database'
|
|
4
|
-
import { GraphQLSchema } from 'graphql'
|
|
5
4
|
import { HttpController } from '../application/index.js'
|
|
6
5
|
import { HttpErrorResponse, HttpResponse } from '../common/index.js'
|
|
7
6
|
import { GraphQLKoaState } from '../graphql/index.js'
|
|
8
7
|
import { ProjectContextResolver } from '../project-common/index.js'
|
|
9
8
|
import { ContentQueryHandler, ContentQueryHandlerFactory } from './ContentQueryHandlerFactory.js'
|
|
10
9
|
import { GraphQlSchemaFactory } from './GraphQlSchemaFactory.js'
|
|
10
|
+
import { ContentGraphQLSchema } from './ContentGraphQLEngine.js'
|
|
11
11
|
import { NotModifiedChecker } from './NotModifiedChecker.js'
|
|
12
|
+
import { ContentRequestLog } from './ContentRequestLog.js'
|
|
12
13
|
import { TestTransactionService } from '../testing/index.js'
|
|
13
14
|
import { isTruthyHeader } from '../utils/truthyHeader.js'
|
|
14
15
|
|
|
@@ -26,11 +27,12 @@ export class ContentApiControllerFactory {
|
|
|
26
27
|
private readonly testTransactionService: TestTransactionService,
|
|
27
28
|
private readonly forcePrimaryHeaderEnabled: boolean,
|
|
28
29
|
private readonly memoryBudgetOptions?: RequestMemoryBudgetOptions,
|
|
30
|
+
private readonly requestLog?: ContentRequestLog,
|
|
29
31
|
) {
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
create(): HttpController {
|
|
33
|
-
const handlerCache = new WeakMap<
|
|
35
|
+
const handlerCache = new WeakMap<ContentGraphQLSchema, ContentQueryHandler>()
|
|
34
36
|
return async context => {
|
|
35
37
|
const { params, timer, projectGroup, authResult, request, koa, clientIp } = context
|
|
36
38
|
if (!authResult) {
|
|
@@ -217,6 +219,17 @@ export class ContentApiControllerFactory {
|
|
|
217
219
|
logger.debug('Content query finished')
|
|
218
220
|
})
|
|
219
221
|
|
|
222
|
+
this.requestLog?.record({
|
|
223
|
+
projectGroup: projectGroup.slug,
|
|
224
|
+
project: project.slug,
|
|
225
|
+
stage: stage.slug,
|
|
226
|
+
roles: projectRoles,
|
|
227
|
+
method: koa.request.method,
|
|
228
|
+
// what the GraphQL handler executed: the POST body, or the query string of a GET
|
|
229
|
+
request: koa.request.method === 'POST' ? koa.request.body : koa.request.query,
|
|
230
|
+
status: koa.response.status,
|
|
231
|
+
})
|
|
232
|
+
|
|
220
233
|
notModifiedRes?.setResponseHeader(context.response)
|
|
221
234
|
}
|
|
222
235
|
}
|
|
@@ -28,21 +28,36 @@ export class ContentApiSpecificCache<ObjectKey extends object, Value> {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
public fetch(objectKey: ObjectKey, scalarKey: string, createValue: () => Value): Value {
|
|
31
|
-
|
|
31
|
+
const entry = this.cache.get(objectKey)?.get(scalarKey)
|
|
32
|
+
if (entry) {
|
|
33
|
+
this.markUsed(entry)
|
|
34
|
+
return entry.value
|
|
35
|
+
}
|
|
36
|
+
return this.set(objectKey, scalarKey, createValue())
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public get(objectKey: ObjectKey, scalarKey: string): Value | undefined {
|
|
40
|
+
const entry = this.cache.get(objectKey)?.get(scalarKey)
|
|
41
|
+
if (!entry) {
|
|
42
|
+
return undefined
|
|
43
|
+
}
|
|
44
|
+
this.markUsed(entry)
|
|
45
|
+
return entry.value
|
|
46
|
+
}
|
|
32
47
|
|
|
48
|
+
public set(objectKey: ObjectKey, scalarKey: string, value: Value): Value {
|
|
49
|
+
let cacheMap = this.cache.get(objectKey)
|
|
33
50
|
if (!cacheMap) {
|
|
34
51
|
cacheMap = new Map()
|
|
35
52
|
this.cache.set(objectKey, cacheMap)
|
|
36
53
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
this.markUsed(cacheValue)
|
|
41
|
-
return cacheValue.value
|
|
54
|
+
const existing = cacheMap.get(scalarKey)
|
|
55
|
+
if (existing) {
|
|
56
|
+
this.remove(existing.recency)
|
|
42
57
|
}
|
|
43
58
|
|
|
44
59
|
const entry: Entry<Value> = {
|
|
45
|
-
value
|
|
60
|
+
value,
|
|
46
61
|
recency: { cacheMapRef: new WeakRef(cacheMap), scalarKey },
|
|
47
62
|
}
|
|
48
63
|
cacheMap.set(scalarKey, entry)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { JsonContentSchema } from '@contember/engine-content-api'
|
|
2
|
+
import { GraphQLSchema } from 'graphql'
|
|
3
|
+
|
|
4
|
+
export type ContentGraphQLEngine = 'graphql-js' | 'graphql-json'
|
|
5
|
+
|
|
6
|
+
export type ContentGraphQLSchema =
|
|
7
|
+
| { engine: 'graphql-js'; schema: GraphQLSchema }
|
|
8
|
+
| { engine: 'graphql-json'; schema: JsonContentSchema }
|
|
9
|
+
|
|
10
|
+
/** The engine that serves a project's content API: the listed projects run on graphql-json, the others on the default. */
|
|
11
|
+
export class ContentGraphQLEngineResolver {
|
|
12
|
+
private readonly graphqlJsonProjects: ReadonlySet<string>
|
|
13
|
+
|
|
14
|
+
constructor(
|
|
15
|
+
private readonly defaultEngine: ContentGraphQLEngine = 'graphql-js',
|
|
16
|
+
graphqlJsonProjects: readonly string[] = [],
|
|
17
|
+
) {
|
|
18
|
+
this.graphqlJsonProjects = new Set(graphqlJsonProjects)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public resolve(projectSlug: string): ContentGraphQLEngine {
|
|
22
|
+
return this.graphqlJsonProjects.has(projectSlug) ? 'graphql-json' : this.defaultEngine
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
createDbQueriesListener,
|
|
3
|
+
createGraphQLJsExecutor,
|
|
4
|
+
createGraphQLJsonExecutor,
|
|
5
|
+
createGraphQLQueryHandler,
|
|
6
|
+
GraphQLExecutor,
|
|
7
|
+
GraphQLListener,
|
|
8
|
+
GraphQLQueryHandler,
|
|
9
|
+
} from '../graphql/index.js'
|
|
10
|
+
import { ContentGraphQLSchema } from './ContentGraphQLEngine.js'
|
|
3
11
|
import { ContentGraphqlContext } from './ContentGraphqlContext.js'
|
|
4
12
|
import { createTriggeredActionsListener } from './triggeredActionsListener.js'
|
|
5
13
|
|
|
@@ -8,15 +16,19 @@ export type ContentQueryHandler = GraphQLQueryHandler<ContentGraphqlContext>
|
|
|
8
16
|
export class ContentQueryHandlerFactory {
|
|
9
17
|
constructor(private readonly debug: boolean) {}
|
|
10
18
|
|
|
11
|
-
public create(graphQlSchema:
|
|
19
|
+
public create(graphQlSchema: ContentGraphQLSchema): ContentQueryHandler {
|
|
12
20
|
const listeners: GraphQLListener<ContentGraphqlContext>[] = []
|
|
13
21
|
listeners.push(createDbQueriesListener(context => context.db, this.debug))
|
|
14
22
|
listeners.push(createTriggeredActionsListener())
|
|
15
23
|
|
|
16
24
|
return createGraphQLQueryHandler<ContentGraphqlContext>({
|
|
17
|
-
|
|
25
|
+
executor: this.createExecutor(graphQlSchema),
|
|
18
26
|
listeners,
|
|
19
27
|
getMemoryBudget: context => context.memoryBudget,
|
|
20
28
|
})
|
|
21
29
|
}
|
|
30
|
+
|
|
31
|
+
private createExecutor(graphQlSchema: ContentGraphQLSchema): GraphQLExecutor<ContentGraphqlContext> {
|
|
32
|
+
return graphQlSchema.engine === 'graphql-js' ? createGraphQLJsExecutor(graphQlSchema.schema) : createGraphQLJsonExecutor(graphQlSchema.schema)
|
|
33
|
+
}
|
|
22
34
|
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { createWriteStream, WriteStream } from 'node:fs'
|
|
2
|
+
import { Logger } from '@contember/logger'
|
|
3
|
+
|
|
4
|
+
// a type, not an interface, so that it fits the config schema's JSON types
|
|
5
|
+
export type ContentRequestLogOptions = {
|
|
6
|
+
/** Only these projects are recorded; there is no wildcard. */
|
|
7
|
+
readonly projects: readonly string[]
|
|
8
|
+
/** A JSON-lines file; the engine appends to it and creates it readable by its owner only. */
|
|
9
|
+
readonly file: string
|
|
10
|
+
/** Requests recorded per project slug by one engine process. */
|
|
11
|
+
readonly maxRequests: number
|
|
12
|
+
/** An ISO timestamp; nothing is recorded after it, in any process and after any restart. */
|
|
13
|
+
readonly until: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ContentRequestLogEntry {
|
|
17
|
+
/** Undefined for an engine that serves a single project group. */
|
|
18
|
+
readonly projectGroup: string | undefined
|
|
19
|
+
readonly project: string
|
|
20
|
+
readonly stage: string
|
|
21
|
+
readonly roles: readonly string[]
|
|
22
|
+
readonly method: string
|
|
23
|
+
/** The GraphQL request as the client sent it (the POST body or the GET query string). */
|
|
24
|
+
readonly request: unknown
|
|
25
|
+
/** The status the GraphQL handler produced, before `X-Contember-Force-Ok` coerces it. */
|
|
26
|
+
readonly status: number
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Ceiling of `maxRequests`, so that a typo cannot turn the sample into a full copy of the traffic. */
|
|
30
|
+
export const contentRequestLogMaxRequestsCeiling = 100_000
|
|
31
|
+
|
|
32
|
+
/** How far ahead `until` may lie when the engine starts, so that a forgotten configuration expires. */
|
|
33
|
+
export const contentRequestLogMaxUntilDays = 7
|
|
34
|
+
|
|
35
|
+
const closeTimeoutMs = 5000
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Records content API requests of selected projects, to replay them against a copy of the database before the
|
|
39
|
+
* project changes its GraphQL engine. The variables carry client data, so the log is bounded by an absolute time
|
|
40
|
+
* and by a count per process.
|
|
41
|
+
*/
|
|
42
|
+
export class ContentRequestLog {
|
|
43
|
+
private readonly projects: ReadonlySet<string>
|
|
44
|
+
private readonly counts = new Map<string, number>()
|
|
45
|
+
private readonly until: number
|
|
46
|
+
private stream: WriteStream | undefined
|
|
47
|
+
private failed = false
|
|
48
|
+
|
|
49
|
+
constructor(
|
|
50
|
+
private readonly options: ContentRequestLogOptions,
|
|
51
|
+
private readonly logger: Logger,
|
|
52
|
+
private readonly now: () => number = Date.now,
|
|
53
|
+
) {
|
|
54
|
+
this.projects = new Set(options.projects)
|
|
55
|
+
this.until = Date.parse(options.until)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public accepts(project: string): boolean {
|
|
59
|
+
return !this.failed
|
|
60
|
+
&& this.projects.has(project)
|
|
61
|
+
&& (this.counts.get(project) ?? 0) < this.options.maxRequests
|
|
62
|
+
&& this.now() < this.until
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public record(entry: ContentRequestLogEntry): void {
|
|
66
|
+
if (!this.accepts(entry.project)) {
|
|
67
|
+
return
|
|
68
|
+
}
|
|
69
|
+
const count = (this.counts.get(entry.project) ?? 0) + 1
|
|
70
|
+
this.counts.set(entry.project, count)
|
|
71
|
+
const { request } = entry
|
|
72
|
+
this.getStream().write(
|
|
73
|
+
JSON.stringify({
|
|
74
|
+
time: new Date(this.now()).toISOString(),
|
|
75
|
+
projectGroup: entry.projectGroup ?? null,
|
|
76
|
+
project: entry.project,
|
|
77
|
+
stage: entry.stage,
|
|
78
|
+
roles: entry.roles,
|
|
79
|
+
method: entry.method,
|
|
80
|
+
operationName: readField(request, 'operationName'),
|
|
81
|
+
query: readField(request, 'query'),
|
|
82
|
+
variables: readField(request, 'variables'),
|
|
83
|
+
status: entry.status,
|
|
84
|
+
}) + '\n',
|
|
85
|
+
)
|
|
86
|
+
if (count === this.options.maxRequests) {
|
|
87
|
+
this.logger.warn('Content API request log reached its cap for a project', { project: entry.project, maxRequests: count })
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Flushes the recorded requests; called when the engine shuts down. */
|
|
92
|
+
public async close(): Promise<void> {
|
|
93
|
+
const stream = this.stream
|
|
94
|
+
this.stream = undefined
|
|
95
|
+
if (!stream) {
|
|
96
|
+
return
|
|
97
|
+
}
|
|
98
|
+
if (this.failed) {
|
|
99
|
+
stream.destroy()
|
|
100
|
+
return
|
|
101
|
+
}
|
|
102
|
+
// a destination that stopped accepting data must not hold up the shutdown
|
|
103
|
+
let timer: ReturnType<typeof setTimeout> | undefined
|
|
104
|
+
const flushed = await Promise.race([
|
|
105
|
+
new Promise<boolean>(resolve => stream.end(() => resolve(true))),
|
|
106
|
+
new Promise<boolean>(resolve => {
|
|
107
|
+
timer = setTimeout(() => resolve(false), closeTimeoutMs)
|
|
108
|
+
}),
|
|
109
|
+
])
|
|
110
|
+
clearTimeout(timer)
|
|
111
|
+
if (!flushed) {
|
|
112
|
+
stream.destroy()
|
|
113
|
+
this.logger.warn('Content API request log was not flushed in time; the last entries may be missing', { file: this.options.file })
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private getStream(): WriteStream {
|
|
118
|
+
if (!this.stream) {
|
|
119
|
+
this.logger.warn('Content API request log started recording request variables', {
|
|
120
|
+
projects: this.options.projects,
|
|
121
|
+
file: this.options.file,
|
|
122
|
+
maxRequests: this.options.maxRequests,
|
|
123
|
+
until: this.options.until,
|
|
124
|
+
})
|
|
125
|
+
const stream = createWriteStream(this.options.file, { flags: 'a', mode: 0o600 })
|
|
126
|
+
stream.on('error', error => {
|
|
127
|
+
// Recording must never fail a request; a broken destination stops the log instead.
|
|
128
|
+
this.failed = true
|
|
129
|
+
this.logger.error('Content API request log failed and is stopped', { error, file: this.options.file })
|
|
130
|
+
})
|
|
131
|
+
this.stream = stream
|
|
132
|
+
}
|
|
133
|
+
return this.stream
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const readField = (request: unknown, key: string): unknown =>
|
|
138
|
+
typeof request === 'object' && request !== null && Object.hasOwn(request, key) ? Reflect.get(request, key) : undefined
|