@contember/engine-http 2.0.0-alpha.8 → 2.0.0-beta.1

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.
Files changed (416) hide show
  1. package/dist/development/index.cjs +1 -4
  2. package/dist/development/index.cjs.map +1 -1
  3. package/dist/development/index.js +2 -5
  4. package/dist/development/index.js.map +1 -1
  5. package/dist/development/src/MasterContainer.cjs +17 -11
  6. package/dist/development/src/MasterContainer.cjs.map +1 -1
  7. package/dist/development/src/MasterContainer.js +18 -12
  8. package/dist/development/src/MasterContainer.js.map +1 -1
  9. package/dist/development/src/application/application.cjs +2 -1
  10. package/dist/development/src/application/application.cjs.map +1 -1
  11. package/dist/development/src/application/application.js +1 -0
  12. package/dist/development/src/application/application.js.map +1 -1
  13. package/dist/development/src/bootstrap/Initializer.cjs.map +1 -1
  14. package/dist/development/src/bootstrap/Initializer.js.map +1 -1
  15. package/dist/development/src/common/Authorizator.cjs.map +1 -1
  16. package/dist/development/src/common/Authorizator.js.map +1 -1
  17. package/dist/development/src/common/HttpResponse.cjs.map +1 -1
  18. package/dist/development/src/common/HttpResponse.js.map +1 -1
  19. package/dist/development/src/common/ModuleInfoMiddleware.cjs.map +1 -1
  20. package/dist/development/src/common/ModuleInfoMiddleware.js.map +1 -1
  21. package/dist/development/src/config/config.cjs.map +1 -1
  22. package/dist/development/src/config/config.js.map +1 -1
  23. package/dist/development/src/config/configSchema.cjs.map +1 -1
  24. package/dist/development/src/config/configSchema.js.map +1 -1
  25. package/dist/development/src/config/configTemplate.cjs.map +1 -1
  26. package/dist/development/src/config/configTemplate.js.map +1 -1
  27. package/dist/development/src/config/projectConfigResolver.cjs.map +1 -1
  28. package/dist/development/src/config/projectConfigResolver.js.map +1 -1
  29. package/dist/development/src/config/tenantConfigResolver.cjs.map +1 -1
  30. package/dist/development/src/config/tenantConfigResolver.js.map +1 -1
  31. package/dist/development/src/content/ContentApiControllerFactory.cjs +7 -4
  32. package/dist/development/src/content/ContentApiControllerFactory.cjs.map +1 -1
  33. package/dist/development/src/content/ContentApiControllerFactory.js +7 -4
  34. package/dist/development/src/content/ContentApiControllerFactory.js.map +1 -1
  35. package/dist/development/src/content/ContentApiSpecificCache.cjs.map +1 -1
  36. package/dist/development/src/content/ContentApiSpecificCache.js.map +1 -1
  37. package/dist/development/src/content/ContentGraphQLContextFactory.cjs +4 -2
  38. package/dist/development/src/content/ContentGraphQLContextFactory.cjs.map +1 -1
  39. package/dist/development/src/content/ContentGraphQLContextFactory.js +4 -2
  40. package/dist/development/src/content/ContentGraphQLContextFactory.js.map +1 -1
  41. package/dist/development/src/content/ContentQueryHandlerFactory.cjs.map +1 -1
  42. package/dist/development/src/content/ContentQueryHandlerFactory.js.map +1 -1
  43. package/dist/development/src/content/ContentSchemaResolver.cjs +33 -17
  44. package/dist/development/src/content/ContentSchemaResolver.cjs.map +1 -1
  45. package/dist/development/src/content/ContentSchemaResolver.js +34 -18
  46. package/dist/development/src/content/ContentSchemaResolver.js.map +1 -1
  47. package/dist/development/src/content/GraphQlSchemaFactory.cjs +5 -3
  48. package/dist/development/src/content/GraphQlSchemaFactory.cjs.map +1 -1
  49. package/dist/development/src/content/GraphQlSchemaFactory.js +5 -3
  50. package/dist/development/src/content/GraphQlSchemaFactory.js.map +1 -1
  51. package/dist/development/src/content/NotModifiedChecker.cjs.map +1 -1
  52. package/dist/development/src/content/NotModifiedChecker.js.map +1 -1
  53. package/dist/development/src/content/ProjectMembershipFetcher.cjs.map +1 -1
  54. package/dist/development/src/content/ProjectMembershipFetcher.js.map +1 -1
  55. package/dist/development/src/content/ProjectMembershipResolver.cjs.map +1 -1
  56. package/dist/development/src/content/ProjectMembershipResolver.js.map +1 -1
  57. package/dist/development/src/graphql/dbQueriesListener.cjs +1 -1
  58. package/dist/development/src/graphql/dbQueriesListener.cjs.map +1 -1
  59. package/dist/development/src/graphql/dbQueriesListener.js +1 -1
  60. package/dist/development/src/graphql/dbQueriesListener.js.map +1 -1
  61. package/dist/development/src/graphql/execution.cjs +1 -0
  62. package/dist/development/src/graphql/execution.cjs.map +1 -1
  63. package/dist/development/src/graphql/execution.js +1 -0
  64. package/dist/development/src/graphql/execution.js.map +1 -1
  65. package/dist/development/src/project/ProjectContainer.cjs +6 -28
  66. package/dist/development/src/project/ProjectContainer.cjs.map +1 -1
  67. package/dist/development/src/project/ProjectContainer.js +6 -28
  68. package/dist/development/src/project/ProjectContainer.js.map +1 -1
  69. package/dist/development/src/project/ProjectContainerResolver.cjs.map +1 -1
  70. package/dist/development/src/project/ProjectContainerResolver.js.map +1 -1
  71. package/dist/development/src/project/ProjectContainerStore.cjs.map +1 -1
  72. package/dist/development/src/project/ProjectContainerStore.js.map +1 -1
  73. package/dist/development/src/project/ProjectDatabaseMetadataResolver.cjs.map +1 -1
  74. package/dist/development/src/project/ProjectDatabaseMetadataResolver.js.map +1 -1
  75. package/dist/development/src/project/ProjectInitializer.cjs.map +1 -1
  76. package/dist/development/src/project/ProjectInitializer.js.map +1 -1
  77. package/dist/development/src/project/ProjectSchemaResolver.cjs +2 -2
  78. package/dist/development/src/project/ProjectSchemaResolver.cjs.map +1 -1
  79. package/dist/development/src/project/ProjectSchemaResolver.js +2 -2
  80. package/dist/development/src/project/ProjectSchemaResolver.js.map +1 -1
  81. package/dist/development/src/project-common/ProjectContextResolver.cjs.map +1 -1
  82. package/dist/development/src/project-common/ProjectContextResolver.js.map +1 -1
  83. package/dist/development/src/projectGroup/ProjectGroupContainer.cjs +2 -3
  84. package/dist/development/src/projectGroup/ProjectGroupContainer.cjs.map +1 -1
  85. package/dist/development/src/projectGroup/ProjectGroupContainer.js +2 -3
  86. package/dist/development/src/projectGroup/ProjectGroupContainer.js.map +1 -1
  87. package/dist/development/src/projectGroup/ProjectGroupContainerResolver.cjs.map +1 -1
  88. package/dist/development/src/projectGroup/ProjectGroupContainerResolver.js.map +1 -1
  89. package/dist/development/src/projectGroup/ProjectGroupResolver.cjs +2 -11
  90. package/dist/development/src/projectGroup/ProjectGroupResolver.cjs.map +1 -1
  91. package/dist/development/src/projectGroup/ProjectGroupResolver.js +2 -11
  92. package/dist/development/src/projectGroup/ProjectGroupResolver.js.map +1 -1
  93. package/dist/development/src/prometheus/CollectHttpMetricsMiddelware.cjs.map +1 -1
  94. package/dist/development/src/prometheus/CollectHttpMetricsMiddelware.js.map +1 -1
  95. package/dist/development/src/prometheus/CustomMetric.cjs.map +1 -1
  96. package/dist/development/src/prometheus/CustomMetric.js.map +1 -1
  97. package/dist/development/src/prometheus/ProjectGroupContainerMetricsHook.cjs.map +1 -1
  98. package/dist/development/src/prometheus/ProjectGroupContainerMetricsHook.js.map +1 -1
  99. package/dist/development/src/prometheus/PrometheusRegistryFactory.cjs.map +1 -1
  100. package/dist/development/src/prometheus/PrometheusRegistryFactory.js.map +1 -1
  101. package/dist/development/src/prometheus/ShowMetricsMiddleware.cjs.map +1 -1
  102. package/dist/development/src/prometheus/ShowMetricsMiddleware.js.map +1 -1
  103. package/dist/development/src/prometheus/dbMetrics.cjs.map +1 -1
  104. package/dist/development/src/prometheus/dbMetrics.js.map +1 -1
  105. package/dist/development/src/providers.cjs.map +1 -1
  106. package/dist/development/src/providers.js.map +1 -1
  107. package/dist/development/src/system/ContentQueryExecutor.cjs +3 -1
  108. package/dist/development/src/system/ContentQueryExecutor.cjs.map +1 -1
  109. package/dist/development/src/system/ContentQueryExecutor.js +3 -1
  110. package/dist/development/src/system/ContentQueryExecutor.js.map +1 -1
  111. package/dist/development/src/system/SystemApiMiddlewareFactory.cjs.map +1 -1
  112. package/dist/development/src/system/SystemApiMiddlewareFactory.js.map +1 -1
  113. package/dist/development/src/system/SystemGraphQLContextFactory.cjs +9 -8
  114. package/dist/development/src/system/SystemGraphQLContextFactory.cjs.map +1 -1
  115. package/dist/development/src/system/SystemGraphQLContextFactory.js +9 -8
  116. package/dist/development/src/system/SystemGraphQLContextFactory.js.map +1 -1
  117. package/dist/development/src/system/SystemGraphQLHandlerFactory.cjs.map +1 -1
  118. package/dist/development/src/system/SystemGraphQLHandlerFactory.js.map +1 -1
  119. package/dist/development/src/tenant/TenantApiMiddlewareFactory.cjs.map +1 -1
  120. package/dist/development/src/tenant/TenantApiMiddlewareFactory.js.map +1 -1
  121. package/dist/development/src/tenant/TenantGraphQLContextFactory.cjs.map +1 -1
  122. package/dist/development/src/tenant/TenantGraphQLContextFactory.js.map +1 -1
  123. package/dist/development/src/tenant/TenantGraphQLHandlerFactory.cjs.map +1 -1
  124. package/dist/development/src/tenant/TenantGraphQLHandlerFactory.js.map +1 -1
  125. package/dist/development/src/transfer/Command.cjs.map +1 -1
  126. package/dist/development/src/transfer/Command.js.map +1 -1
  127. package/dist/development/src/transfer/CommandStream.cjs.map +1 -1
  128. package/dist/development/src/transfer/CommandStream.js.map +1 -1
  129. package/dist/development/src/transfer/ContentSchemaTransferMappingFactory.cjs +5 -3
  130. package/dist/development/src/transfer/ContentSchemaTransferMappingFactory.cjs.map +1 -1
  131. package/dist/development/src/transfer/ContentSchemaTransferMappingFactory.js +5 -3
  132. package/dist/development/src/transfer/ContentSchemaTransferMappingFactory.js.map +1 -1
  133. package/dist/development/src/transfer/ExportApiControllerFactory.cjs +3 -1
  134. package/dist/development/src/transfer/ExportApiControllerFactory.cjs.map +1 -1
  135. package/dist/development/src/transfer/ExportApiControllerFactory.js +3 -1
  136. package/dist/development/src/transfer/ExportApiControllerFactory.js.map +1 -1
  137. package/dist/development/src/transfer/ExportExecutor.cjs +11 -6
  138. package/dist/development/src/transfer/ExportExecutor.cjs.map +1 -1
  139. package/dist/development/src/transfer/ExportExecutor.js +11 -6
  140. package/dist/development/src/transfer/ExportExecutor.js.map +1 -1
  141. package/dist/development/src/transfer/ImportApiMiddlewareFactory.cjs.map +1 -1
  142. package/dist/development/src/transfer/ImportApiMiddlewareFactory.js.map +1 -1
  143. package/dist/development/src/transfer/ImportExecutor.cjs +5 -5
  144. package/dist/development/src/transfer/ImportExecutor.cjs.map +1 -1
  145. package/dist/development/src/transfer/ImportExecutor.js +5 -5
  146. package/dist/development/src/transfer/ImportExecutor.js.map +1 -1
  147. package/dist/development/src/transfer/SystemSchemaTransferMappingFactory.cjs +9 -4
  148. package/dist/development/src/transfer/SystemSchemaTransferMappingFactory.cjs.map +1 -1
  149. package/dist/development/src/transfer/SystemSchemaTransferMappingFactory.js +9 -4
  150. package/dist/development/src/transfer/SystemSchemaTransferMappingFactory.js.map +1 -1
  151. package/dist/development/src/utils/CryptoWrapper.cjs.map +1 -1
  152. package/dist/development/src/utils/CryptoWrapper.js.map +1 -1
  153. package/dist/development/src/utils/memoizeObject.cjs +33 -0
  154. package/dist/development/src/utils/memoizeObject.cjs.map +1 -0
  155. package/dist/development/src/utils/memoizeObject.js +33 -0
  156. package/dist/development/src/utils/memoizeObject.js.map +1 -0
  157. package/dist/development/src/utils/sentry.cjs.map +1 -1
  158. package/dist/development/src/utils/sentry.js.map +1 -1
  159. package/dist/development/src/utils/serverStartup.cjs.map +1 -1
  160. package/dist/development/src/utils/serverStartup.js.map +1 -1
  161. package/dist/development/src/utils/serverTermination.cjs.map +1 -1
  162. package/dist/development/src/utils/serverTermination.js.map +1 -1
  163. package/dist/development/src/workers/ApplicationWorkerManager.cjs.map +1 -1
  164. package/dist/development/src/workers/ApplicationWorkerManager.js.map +1 -1
  165. package/dist/production/index.cjs +1 -4
  166. package/dist/production/index.cjs.map +1 -1
  167. package/dist/production/index.js +2 -5
  168. package/dist/production/index.js.map +1 -1
  169. package/dist/production/src/MasterContainer.cjs +17 -11
  170. package/dist/production/src/MasterContainer.cjs.map +1 -1
  171. package/dist/production/src/MasterContainer.js +18 -12
  172. package/dist/production/src/MasterContainer.js.map +1 -1
  173. package/dist/production/src/application/application.cjs +2 -1
  174. package/dist/production/src/application/application.cjs.map +1 -1
  175. package/dist/production/src/application/application.js +1 -0
  176. package/dist/production/src/application/application.js.map +1 -1
  177. package/dist/production/src/bootstrap/Initializer.cjs.map +1 -1
  178. package/dist/production/src/bootstrap/Initializer.js.map +1 -1
  179. package/dist/production/src/common/Authorizator.cjs.map +1 -1
  180. package/dist/production/src/common/Authorizator.js.map +1 -1
  181. package/dist/production/src/common/HttpResponse.cjs.map +1 -1
  182. package/dist/production/src/common/HttpResponse.js.map +1 -1
  183. package/dist/production/src/common/ModuleInfoMiddleware.cjs.map +1 -1
  184. package/dist/production/src/common/ModuleInfoMiddleware.js.map +1 -1
  185. package/dist/production/src/config/config.cjs.map +1 -1
  186. package/dist/production/src/config/config.js.map +1 -1
  187. package/dist/production/src/config/configSchema.cjs.map +1 -1
  188. package/dist/production/src/config/configSchema.js.map +1 -1
  189. package/dist/production/src/config/configTemplate.cjs.map +1 -1
  190. package/dist/production/src/config/configTemplate.js.map +1 -1
  191. package/dist/production/src/config/projectConfigResolver.cjs.map +1 -1
  192. package/dist/production/src/config/projectConfigResolver.js.map +1 -1
  193. package/dist/production/src/config/tenantConfigResolver.cjs.map +1 -1
  194. package/dist/production/src/config/tenantConfigResolver.js.map +1 -1
  195. package/dist/production/src/content/ContentApiControllerFactory.cjs +7 -4
  196. package/dist/production/src/content/ContentApiControllerFactory.cjs.map +1 -1
  197. package/dist/production/src/content/ContentApiControllerFactory.js +7 -4
  198. package/dist/production/src/content/ContentApiControllerFactory.js.map +1 -1
  199. package/dist/production/src/content/ContentApiSpecificCache.cjs.map +1 -1
  200. package/dist/production/src/content/ContentApiSpecificCache.js.map +1 -1
  201. package/dist/production/src/content/ContentGraphQLContextFactory.cjs +4 -2
  202. package/dist/production/src/content/ContentGraphQLContextFactory.cjs.map +1 -1
  203. package/dist/production/src/content/ContentGraphQLContextFactory.js +4 -2
  204. package/dist/production/src/content/ContentGraphQLContextFactory.js.map +1 -1
  205. package/dist/production/src/content/ContentQueryHandlerFactory.cjs.map +1 -1
  206. package/dist/production/src/content/ContentQueryHandlerFactory.js.map +1 -1
  207. package/dist/production/src/content/ContentSchemaResolver.cjs +33 -17
  208. package/dist/production/src/content/ContentSchemaResolver.cjs.map +1 -1
  209. package/dist/production/src/content/ContentSchemaResolver.js +34 -18
  210. package/dist/production/src/content/ContentSchemaResolver.js.map +1 -1
  211. package/dist/production/src/content/GraphQlSchemaFactory.cjs +5 -3
  212. package/dist/production/src/content/GraphQlSchemaFactory.cjs.map +1 -1
  213. package/dist/production/src/content/GraphQlSchemaFactory.js +5 -3
  214. package/dist/production/src/content/GraphQlSchemaFactory.js.map +1 -1
  215. package/dist/production/src/content/NotModifiedChecker.cjs.map +1 -1
  216. package/dist/production/src/content/NotModifiedChecker.js.map +1 -1
  217. package/dist/production/src/content/ProjectMembershipFetcher.cjs.map +1 -1
  218. package/dist/production/src/content/ProjectMembershipFetcher.js.map +1 -1
  219. package/dist/production/src/content/ProjectMembershipResolver.cjs.map +1 -1
  220. package/dist/production/src/content/ProjectMembershipResolver.js.map +1 -1
  221. package/dist/production/src/graphql/dbQueriesListener.cjs +1 -1
  222. package/dist/production/src/graphql/dbQueriesListener.cjs.map +1 -1
  223. package/dist/production/src/graphql/dbQueriesListener.js +1 -1
  224. package/dist/production/src/graphql/dbQueriesListener.js.map +1 -1
  225. package/dist/production/src/graphql/execution.cjs +1 -0
  226. package/dist/production/src/graphql/execution.cjs.map +1 -1
  227. package/dist/production/src/graphql/execution.js +1 -0
  228. package/dist/production/src/graphql/execution.js.map +1 -1
  229. package/dist/production/src/project/ProjectContainer.cjs +6 -28
  230. package/dist/production/src/project/ProjectContainer.cjs.map +1 -1
  231. package/dist/production/src/project/ProjectContainer.js +6 -28
  232. package/dist/production/src/project/ProjectContainer.js.map +1 -1
  233. package/dist/production/src/project/ProjectContainerResolver.cjs.map +1 -1
  234. package/dist/production/src/project/ProjectContainerResolver.js.map +1 -1
  235. package/dist/production/src/project/ProjectContainerStore.cjs.map +1 -1
  236. package/dist/production/src/project/ProjectContainerStore.js.map +1 -1
  237. package/dist/production/src/project/ProjectDatabaseMetadataResolver.cjs.map +1 -1
  238. package/dist/production/src/project/ProjectDatabaseMetadataResolver.js.map +1 -1
  239. package/dist/production/src/project/ProjectInitializer.cjs.map +1 -1
  240. package/dist/production/src/project/ProjectInitializer.js.map +1 -1
  241. package/dist/production/src/project/ProjectSchemaResolver.cjs +2 -2
  242. package/dist/production/src/project/ProjectSchemaResolver.cjs.map +1 -1
  243. package/dist/production/src/project/ProjectSchemaResolver.js +2 -2
  244. package/dist/production/src/project/ProjectSchemaResolver.js.map +1 -1
  245. package/dist/production/src/project-common/ProjectContextResolver.cjs.map +1 -1
  246. package/dist/production/src/project-common/ProjectContextResolver.js.map +1 -1
  247. package/dist/production/src/projectGroup/ProjectGroupContainer.cjs +2 -3
  248. package/dist/production/src/projectGroup/ProjectGroupContainer.cjs.map +1 -1
  249. package/dist/production/src/projectGroup/ProjectGroupContainer.js +2 -3
  250. package/dist/production/src/projectGroup/ProjectGroupContainer.js.map +1 -1
  251. package/dist/production/src/projectGroup/ProjectGroupContainerResolver.cjs.map +1 -1
  252. package/dist/production/src/projectGroup/ProjectGroupContainerResolver.js.map +1 -1
  253. package/dist/production/src/projectGroup/ProjectGroupResolver.cjs +2 -11
  254. package/dist/production/src/projectGroup/ProjectGroupResolver.cjs.map +1 -1
  255. package/dist/production/src/projectGroup/ProjectGroupResolver.js +2 -11
  256. package/dist/production/src/projectGroup/ProjectGroupResolver.js.map +1 -1
  257. package/dist/production/src/prometheus/CollectHttpMetricsMiddelware.cjs.map +1 -1
  258. package/dist/production/src/prometheus/CollectHttpMetricsMiddelware.js.map +1 -1
  259. package/dist/production/src/prometheus/CustomMetric.cjs.map +1 -1
  260. package/dist/production/src/prometheus/CustomMetric.js.map +1 -1
  261. package/dist/production/src/prometheus/ProjectGroupContainerMetricsHook.cjs.map +1 -1
  262. package/dist/production/src/prometheus/ProjectGroupContainerMetricsHook.js.map +1 -1
  263. package/dist/production/src/prometheus/PrometheusRegistryFactory.cjs.map +1 -1
  264. package/dist/production/src/prometheus/PrometheusRegistryFactory.js.map +1 -1
  265. package/dist/production/src/prometheus/ShowMetricsMiddleware.cjs.map +1 -1
  266. package/dist/production/src/prometheus/ShowMetricsMiddleware.js.map +1 -1
  267. package/dist/production/src/prometheus/dbMetrics.cjs.map +1 -1
  268. package/dist/production/src/prometheus/dbMetrics.js.map +1 -1
  269. package/dist/production/src/providers.cjs.map +1 -1
  270. package/dist/production/src/providers.js.map +1 -1
  271. package/dist/production/src/system/ContentQueryExecutor.cjs +3 -1
  272. package/dist/production/src/system/ContentQueryExecutor.cjs.map +1 -1
  273. package/dist/production/src/system/ContentQueryExecutor.js +3 -1
  274. package/dist/production/src/system/ContentQueryExecutor.js.map +1 -1
  275. package/dist/production/src/system/SystemApiMiddlewareFactory.cjs.map +1 -1
  276. package/dist/production/src/system/SystemApiMiddlewareFactory.js.map +1 -1
  277. package/dist/production/src/system/SystemGraphQLContextFactory.cjs +9 -8
  278. package/dist/production/src/system/SystemGraphQLContextFactory.cjs.map +1 -1
  279. package/dist/production/src/system/SystemGraphQLContextFactory.js +9 -8
  280. package/dist/production/src/system/SystemGraphQLContextFactory.js.map +1 -1
  281. package/dist/production/src/system/SystemGraphQLHandlerFactory.cjs.map +1 -1
  282. package/dist/production/src/system/SystemGraphQLHandlerFactory.js.map +1 -1
  283. package/dist/production/src/tenant/TenantApiMiddlewareFactory.cjs.map +1 -1
  284. package/dist/production/src/tenant/TenantApiMiddlewareFactory.js.map +1 -1
  285. package/dist/production/src/tenant/TenantGraphQLContextFactory.cjs.map +1 -1
  286. package/dist/production/src/tenant/TenantGraphQLContextFactory.js.map +1 -1
  287. package/dist/production/src/tenant/TenantGraphQLHandlerFactory.cjs.map +1 -1
  288. package/dist/production/src/tenant/TenantGraphQLHandlerFactory.js.map +1 -1
  289. package/dist/production/src/transfer/Command.cjs.map +1 -1
  290. package/dist/production/src/transfer/Command.js.map +1 -1
  291. package/dist/production/src/transfer/CommandStream.cjs.map +1 -1
  292. package/dist/production/src/transfer/CommandStream.js.map +1 -1
  293. package/dist/production/src/transfer/ContentSchemaTransferMappingFactory.cjs +5 -3
  294. package/dist/production/src/transfer/ContentSchemaTransferMappingFactory.cjs.map +1 -1
  295. package/dist/production/src/transfer/ContentSchemaTransferMappingFactory.js +5 -3
  296. package/dist/production/src/transfer/ContentSchemaTransferMappingFactory.js.map +1 -1
  297. package/dist/production/src/transfer/ExportApiControllerFactory.cjs +3 -1
  298. package/dist/production/src/transfer/ExportApiControllerFactory.cjs.map +1 -1
  299. package/dist/production/src/transfer/ExportApiControllerFactory.js +3 -1
  300. package/dist/production/src/transfer/ExportApiControllerFactory.js.map +1 -1
  301. package/dist/production/src/transfer/ExportExecutor.cjs +11 -6
  302. package/dist/production/src/transfer/ExportExecutor.cjs.map +1 -1
  303. package/dist/production/src/transfer/ExportExecutor.js +11 -6
  304. package/dist/production/src/transfer/ExportExecutor.js.map +1 -1
  305. package/dist/production/src/transfer/ImportApiMiddlewareFactory.cjs.map +1 -1
  306. package/dist/production/src/transfer/ImportApiMiddlewareFactory.js.map +1 -1
  307. package/dist/production/src/transfer/ImportExecutor.cjs +5 -5
  308. package/dist/production/src/transfer/ImportExecutor.cjs.map +1 -1
  309. package/dist/production/src/transfer/ImportExecutor.js +5 -5
  310. package/dist/production/src/transfer/ImportExecutor.js.map +1 -1
  311. package/dist/production/src/transfer/SystemSchemaTransferMappingFactory.cjs +9 -4
  312. package/dist/production/src/transfer/SystemSchemaTransferMappingFactory.cjs.map +1 -1
  313. package/dist/production/src/transfer/SystemSchemaTransferMappingFactory.js +9 -4
  314. package/dist/production/src/transfer/SystemSchemaTransferMappingFactory.js.map +1 -1
  315. package/dist/production/src/utils/CryptoWrapper.cjs.map +1 -1
  316. package/dist/production/src/utils/CryptoWrapper.js.map +1 -1
  317. package/dist/production/src/utils/memoizeObject.cjs +33 -0
  318. package/dist/production/src/utils/memoizeObject.cjs.map +1 -0
  319. package/dist/production/src/utils/memoizeObject.js +33 -0
  320. package/dist/production/src/utils/memoizeObject.js.map +1 -0
  321. package/dist/production/src/utils/sentry.cjs.map +1 -1
  322. package/dist/production/src/utils/sentry.js.map +1 -1
  323. package/dist/production/src/utils/serverStartup.cjs.map +1 -1
  324. package/dist/production/src/utils/serverStartup.js.map +1 -1
  325. package/dist/production/src/utils/serverTermination.cjs.map +1 -1
  326. package/dist/production/src/utils/serverTermination.js.map +1 -1
  327. package/dist/production/src/workers/ApplicationWorkerManager.cjs.map +1 -1
  328. package/dist/production/src/workers/ApplicationWorkerManager.js.map +1 -1
  329. package/dist/tests/tsconfig.tsbuildinfo +1 -1
  330. package/dist/types/MasterContainer.d.ts +7 -1
  331. package/dist/types/MasterContainer.d.ts.map +1 -1
  332. package/dist/types/application/application.d.ts +1 -0
  333. package/dist/types/application/application.d.ts.map +1 -1
  334. package/dist/types/config/configSchema.d.ts +23 -34
  335. package/dist/types/config/configSchema.d.ts.map +1 -1
  336. package/dist/types/content/ContentApiControllerFactory.d.ts +3 -1
  337. package/dist/types/content/ContentApiControllerFactory.d.ts.map +1 -1
  338. package/dist/types/content/ContentGraphQLContextFactory.d.ts +7 -3
  339. package/dist/types/content/ContentGraphQLContextFactory.d.ts.map +1 -1
  340. package/dist/types/content/ContentSchemaResolver.d.ts +8 -5
  341. package/dist/types/content/ContentSchemaResolver.d.ts.map +1 -1
  342. package/dist/types/content/GraphQLSchemaContributor.d.ts +3 -0
  343. package/dist/types/content/GraphQLSchemaContributor.d.ts.map +1 -1
  344. package/dist/types/content/GraphQlSchemaFactory.d.ts +2 -1
  345. package/dist/types/content/GraphQlSchemaFactory.d.ts.map +1 -1
  346. package/dist/types/graphql/execution.d.ts.map +1 -1
  347. package/dist/types/index.d.ts +1 -0
  348. package/dist/types/index.d.ts.map +1 -1
  349. package/dist/types/misc/index.d.ts +0 -1
  350. package/dist/types/misc/index.d.ts.map +1 -1
  351. package/dist/types/plugin/Plugin.d.ts +2 -4
  352. package/dist/types/plugin/Plugin.d.ts.map +1 -1
  353. package/dist/types/project/ProjectContainer.d.ts +6 -21
  354. package/dist/types/project/ProjectContainer.d.ts.map +1 -1
  355. package/dist/types/project/ProjectSchemaResolver.d.ts +1 -1
  356. package/dist/types/project/ProjectSchemaResolver.d.ts.map +1 -1
  357. package/dist/types/projectGroup/ProjectGroupContainer.d.ts +1 -1
  358. package/dist/types/projectGroup/ProjectGroupContainer.d.ts.map +1 -1
  359. package/dist/types/projectGroup/ProjectGroupResolver.d.ts +1 -11
  360. package/dist/types/projectGroup/ProjectGroupResolver.d.ts.map +1 -1
  361. package/dist/types/prometheus/dbMetrics.d.ts.map +1 -1
  362. package/dist/types/system/ContentQueryExecutor.d.ts +1 -1
  363. package/dist/types/system/ContentQueryExecutor.d.ts.map +1 -1
  364. package/dist/types/system/SystemGraphQLContextFactory.d.ts.map +1 -1
  365. package/dist/types/transfer/ContentSchemaTransferMappingFactory.d.ts +4 -2
  366. package/dist/types/transfer/ContentSchemaTransferMappingFactory.d.ts.map +1 -1
  367. package/dist/types/transfer/ExportApiControllerFactory.d.ts.map +1 -1
  368. package/dist/types/transfer/ExportExecutor.d.ts +1 -0
  369. package/dist/types/transfer/ExportExecutor.d.ts.map +1 -1
  370. package/dist/types/transfer/SystemSchemaTransferMappingFactory.d.ts +3 -1
  371. package/dist/types/transfer/SystemSchemaTransferMappingFactory.d.ts.map +1 -1
  372. package/dist/types/tsconfig.tsbuildinfo +1 -1
  373. package/dist/types/utils/memoizeObject.d.ts +2 -0
  374. package/dist/types/utils/memoizeObject.d.ts.map +1 -0
  375. package/package.json +31 -32
  376. package/src/MasterContainer.ts +28 -17
  377. package/src/application/application.ts +1 -0
  378. package/src/content/ContentApiControllerFactory.ts +7 -4
  379. package/src/content/ContentGraphQLContextFactory.ts +6 -2
  380. package/src/content/ContentSchemaResolver.ts +38 -14
  381. package/src/content/GraphQLSchemaContributor.ts +7 -1
  382. package/src/content/GraphQlSchemaFactory.ts +6 -3
  383. package/src/graphql/dbQueriesListener.ts +1 -1
  384. package/src/graphql/execution.ts +1 -0
  385. package/src/index.ts +1 -0
  386. package/src/misc/index.ts +0 -1
  387. package/src/plugin/Plugin.ts +2 -4
  388. package/src/project/ProjectContainer.ts +9 -36
  389. package/src/project/ProjectSchemaResolver.ts +3 -3
  390. package/src/projectGroup/ProjectGroupContainer.ts +15 -7
  391. package/src/projectGroup/ProjectGroupResolver.ts +1 -16
  392. package/src/prometheus/dbMetrics.ts +3 -0
  393. package/src/system/ContentQueryExecutor.ts +3 -1
  394. package/src/system/SystemGraphQLContextFactory.ts +8 -7
  395. package/src/transfer/ContentSchemaTransferMappingFactory.ts +8 -5
  396. package/src/transfer/ExportApiControllerFactory.ts +3 -1
  397. package/src/transfer/ExportExecutor.ts +10 -5
  398. package/src/transfer/ImportExecutor.ts +5 -5
  399. package/src/transfer/SystemSchemaTransferMappingFactory.ts +13 -3
  400. package/src/tsconfig.json +1 -1
  401. package/src/utils/memoizeObject.ts +38 -0
  402. package/tests/cases/unit/configResolver.test.ts +4 -1
  403. package/tests/cases/unit/crypto.test.ts +6 -2
  404. package/tests/cases/unit/projectMembershipResolver.test.ts +5 -5
  405. package/tsconfig.settings.json +1 -4
  406. package/dist/development/src/misc/PlaygroundMiddlewareFactory.cjs +0 -13
  407. package/dist/development/src/misc/PlaygroundMiddlewareFactory.cjs.map +0 -1
  408. package/dist/development/src/misc/PlaygroundMiddlewareFactory.js +0 -13
  409. package/dist/development/src/misc/PlaygroundMiddlewareFactory.js.map +0 -1
  410. package/dist/production/src/misc/PlaygroundMiddlewareFactory.cjs +0 -13
  411. package/dist/production/src/misc/PlaygroundMiddlewareFactory.cjs.map +0 -1
  412. package/dist/production/src/misc/PlaygroundMiddlewareFactory.js +0 -13
  413. package/dist/production/src/misc/PlaygroundMiddlewareFactory.js.map +0 -1
  414. package/dist/types/misc/PlaygroundMiddlewareFactory.d.ts +0 -3
  415. package/dist/types/misc/PlaygroundMiddlewareFactory.d.ts.map +0 -1
  416. package/src/misc/PlaygroundMiddlewareFactory.ts +0 -12
@@ -1 +1 @@
1
- {"version":3,"file":"ProjectGroupContainer.js","sources":["../../../../../packages/engine-http/src/projectGroup/ProjectGroupContainer.ts"],"sourcesContent":["import { Builder } from '@contember/dic'\nimport { Connection } from '@contember/database'\nimport { DatabaseContext, TenantContainer, TenantContainerFactory, ProjectSchemaResolver as ProjectSchemaResolverInterface, ProjectInitializer as ProjectInitializerInterface } from '@contember/engine-tenant-api'\nimport { TenantConfig } from '../config/config'\nimport {\n\tProjectContainerFactoryFactory, ProjectContainerResolver, ProjectInitializer,\n\tProjectInitializerProxy, ProjectSchemaResolver,\n\tProjectSchemaResolverProxy,\n} from '../project'\nimport { SystemContainer, SystemContainerFactory } from '@contember/engine-system-api'\nimport { ProjectConfigResolver } from '../config/projectConfigResolver'\nimport { createSecretKey } from 'node:crypto'\nimport { Logger } from '@contember/logger'\nimport { TenantGraphQLHandler, TenantGraphQLHandlerFactory } from '../tenant'\nimport { SystemGraphQLHandler, SystemGraphQLHandlerFactory } from '../system'\nimport { Authenticator } from '../common'\nimport { ProjectMembershipFetcher, ProjectMembershipResolver } from '../content'\nimport { Providers } from '../providers'\nimport { CryptoWrapper } from '../utils/CryptoWrapper'\n\nexport interface ProjectGroupContainer {\n\tslug: string | undefined\n\n\tlogger: Logger\n\tauthenticator: Authenticator\n\tprojectMembershipResolver: ProjectMembershipResolver\n\n\tprojectContainerResolver: ProjectContainerResolver\n\tprojectSchemaResolver: ProjectSchemaResolverInterface\n\tprojectInitializer: ProjectInitializerInterface\n\n\ttenantContainer: TenantContainer\n\ttenantGraphQLHandler: TenantGraphQLHandler\n\n\tsystemContainer: SystemContainer\n\tsystemGraphQLHandler: SystemGraphQLHandler\n}\n\n\ninterface ProjectGroupContainerFactoryArgs\n{\n\tconfig: TenantConfig\n\tslug: string | undefined\n}\n\nexport class ProjectGroupContainerFactory {\n\tconstructor(\n\t\tprivate readonly debug: boolean,\n\t\tprivate readonly providers: Providers,\n\t\tprivate readonly systemContainerFactory: SystemContainerFactory,\n\t\tprivate readonly tenantContainerFactory: TenantContainerFactory,\n\t\tprivate readonly projectContainerFactoryFactory: ProjectContainerFactoryFactory,\n\t\tprivate readonly projectConfigResolver: ProjectConfigResolver,\n\t\tprivate readonly tenantGraphQLHandlerFactory: TenantGraphQLHandlerFactory,\n\t\tprivate readonly systemGraphQLHandlerFactory: SystemGraphQLHandlerFactory,\n\t\tprivate readonly logger: Logger,\n\t) {}\n\n\tpublic create({ config, slug }: ProjectGroupContainerFactoryArgs): ProjectGroupContainer {\n\t\treturn new Builder({})\n\t\t\t.addService('slug', () =>\n\t\t\t\tslug)\n\t\t\t.addService('logger', ({ slug }) =>\n\t\t\t\tthis.logger.child({ projectGroup: slug }))\n\t\t\t.addService('providers', () =>\n\t\t\t\tthis.providers)\n\t\t\t.addService('tenantDbCredentials', () =>\n\t\t\t\tconfig.db)\n\t\t\t.addService('tenantConnection', ({ tenantDbCredentials, logger }): Connection.ConnectionType =>\n\t\t\t\tConnection.create(tenantDbCredentials, err => logger.error(err)))\n\t\t\t.addService('tenantReadConnection', ({ tenantDbCredentials, logger, tenantConnection }) => {\n\t\t\t\tif (!tenantDbCredentials.read) {\n\t\t\t\t\treturn tenantConnection\n\t\t\t\t}\n\t\t\t\treturn Connection.create({\n\t\t\t\t\t...tenantDbCredentials,\n\t\t\t\t\t...tenantDbCredentials.read,\n\t\t\t\t\tpool: {\n\t\t\t\t\t\t...tenantDbCredentials.pool,\n\t\t\t\t\t\t...tenantDbCredentials.read.pool,\n\t\t\t\t\t},\n\t\t\t\t}, err => logger.error(err))\n\t\t\t})\n\t\t\t.addService('projectSchemaResolver', () =>\n\t\t\t\tnew ProjectSchemaResolverProxy())\n\t\t\t.addService('projectInitializer', () =>\n\t\t\t\tnew ProjectInitializerProxy())\n\t\t\t.addService('tenantContainer', ({ tenantConnection, tenantReadConnection, tenantDbCredentials, projectSchemaResolver, projectInitializer }) => {\n\t\t\t\tconst encryptionKey = config.secrets.encryptionKey\n\t\t\t\t\t? createSecretKey(Buffer.from(config.secrets.encryptionKey, 'hex'))\n\t\t\t\t\t: undefined\n\n\t\t\t\tconst cryptoWrapper = new CryptoWrapper(encryptionKey)\n\t\t\t\treturn this.tenantContainerFactory.create({\n\t\t\t\t\tconnection: tenantConnection,\n\t\t\t\t\treadConnection: tenantReadConnection,\n\t\t\t\t\tdbCredentials: tenantDbCredentials,\n\t\t\t\t\tmailOptions: config.mailer,\n\t\t\t\t\ttenantCredentials: config.credentials,\n\t\t\t\t\tprojectInitializer,\n\t\t\t\t\tprojectSchemaResolver,\n\t\t\t\t\tcryptoProviders: {\n\t\t\t\t\t\tdecrypt: cryptoWrapper.decrypt.bind(cryptoWrapper),\n\t\t\t\t\t\tencrypt: cryptoWrapper.encrypt.bind(cryptoWrapper),\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t})\n\t\t\t.addService('tenantDatabase', ({ tenantContainer }) =>\n\t\t\t\ttenantContainer.databaseContext)\n\t\t\t.addService('tenantReadDatabase', ({ tenantContainer }) =>\n\t\t\t\ttenantContainer.readDatabaseContext)\n\t\t\t.addService('identityFetcher', ({ tenantContainer: { identityFetcher } }) =>\n\t\t\t\tidentityFetcher)\n\t\t\t.addService('systemContainer', ({ identityFetcher }) =>\n\t\t\t\tthis.systemContainerFactory.create({ identityFetcher }))\n\t\t\t.addService('schemaVersionBuilder', ({ systemContainer }) =>\n\t\t\t\tsystemContainer.schemaVersionBuilder)\n\t\t\t.addService('projectContainerFactory', ({ schemaVersionBuilder, logger }) =>\n\t\t\t\tthis.projectContainerFactoryFactory.create(schemaVersionBuilder, logger))\n\t\t\t.addService('tenantProjectManager', ({ tenantContainer }) =>\n\t\t\t\ttenantContainer.projectManager)\n\t\t\t.addService('tenantProjectMemberManager', ({ tenantContainer }) =>\n\t\t\t\ttenantContainer.projectMemberManager)\n\t\t\t.addService('projectContainerResolver', ({ projectContainerFactory, tenantProjectManager, tenantReadDatabase }) =>\n\t\t\t\tnew ProjectContainerResolver(\n\t\t\t\t\tprojectContainerFactory,\n\t\t\t\t\tthis.projectConfigResolver,\n\t\t\t\t\ttenantProjectManager,\n\t\t\t\t\ttenantReadDatabase,\n\t\t\t\t\tconfig,\n\t\t\t\t))\n\n\t\t\t.setupService('projectSchemaResolver', (it, { projectContainerResolver }) => {\n\t\t\t\tit.setResolver(new ProjectSchemaResolver(projectContainerResolver))\n\t\t\t})\n\t\t\t.setupService('projectInitializer', (it, { projectContainerResolver }) => {\n\t\t\t\tit.setInitializer(new ProjectInitializer(projectContainerResolver))\n\t\t\t})\n\t\t\t.addService('tenantGraphQLHandler', ({ tenantContainer }) =>\n\t\t\t\tthis.tenantGraphQLHandlerFactory.create(tenantContainer.resolvers))\n\t\t\t.addService('systemGraphQLHandler', ({ systemContainer }) =>\n\t\t\t\tthis.systemGraphQLHandlerFactory.create(systemContainer.systemResolversFactory))\n\t\t\t.addService('authenticator', ({ tenantDatabase, tenantReadDatabase, tenantContainer }) =>\n\t\t\t\tnew Authenticator(tenantDatabase, tenantReadDatabase, tenantContainer.apiKeyManager))\n\t\t\t.addService('projectMembershipResolver', ({ tenantProjectMemberManager, tenantReadDatabase }) =>\n\t\t\t\tnew ProjectMembershipResolver(this.debug, new ProjectMembershipFetcher(tenantProjectMemberManager, tenantReadDatabase)))\n\t\t\t.build()\n\t\t\t.pick(\n\t\t\t\t'projectContainerResolver',\n\t\t\t\t'projectSchemaResolver',\n\t\t\t\t'projectInitializer',\n\t\t\t\t'systemContainer',\n\t\t\t\t'systemGraphQLHandler',\n\t\t\t\t'tenantContainer',\n\t\t\t\t'authenticator',\n\t\t\t\t'projectMembershipResolver',\n\t\t\t\t'tenantGraphQLHandler',\n\t\t\t\t'slug',\n\t\t\t\t'logger',\n\t\t\t)\n\t}\n}\n"],"names":["slug"],"mappings":";;;;;;;;;;;;;;;;;;AA6CO,MAAM,6BAA6B;AAAA,EACzC,YACkB,OACA,WACA,wBACA,wBACA,gCACA,uBACA,6BACA,6BACA,QAChB;AATgB,SAAA,QAAA;AACA,SAAA,YAAA;AACA,SAAA,yBAAA;AACA,SAAA,yBAAA;AACA,SAAA,iCAAA;AACA,SAAA,wBAAA;AACA,SAAA,8BAAA;AACA,SAAA,8BAAA;AACA,SAAA,SAAA;AAAA,EACf;AAA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oBAAoB,gBAAA,MACnE,IAAI,cAAc,gBAAgB,oBAAoB,gBAAgB,aAAa,CAAC,EACpF,WAAW,6BAA6B,CAAC,EAAE,4BAA4B,yBACvE,IAAI,0BAA0B,KAAK,OAAO,IAAI,yBAAyB,4BAA4B,kBAAkB,CAAC,CAAC,EACvH,MACA,EAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EAEH;AACD;"}
1
+ {"version":3,"file":"ProjectGroupContainer.js","sources":["../../../../../packages/engine-http/src/projectGroup/ProjectGroupContainer.ts"],"sourcesContent":["import { Builder } from '@contember/dic'\nimport { Connection } from '@contember/database'\nimport {\n\tProjectInitializer as ProjectInitializerInterface,\n\tProjectSchemaResolver as ProjectSchemaResolverInterface,\n\tTenantContainer,\n\tTenantContainerFactory,\n} from '@contember/engine-tenant-api'\nimport { TenantConfig } from '../config/config'\nimport {\n\tProjectContainerFactoryFactory,\n\tProjectContainerResolver,\n\tProjectInitializer,\n\tProjectInitializerProxy,\n\tProjectSchemaResolver,\n\tProjectSchemaResolverProxy,\n} from '../project'\nimport { SystemContainer, SystemContainerFactory } from '@contember/engine-system-api'\nimport { ProjectConfigResolver } from '../config/projectConfigResolver'\nimport { createSecretKey } from 'node:crypto'\nimport { Logger } from '@contember/logger'\nimport { TenantGraphQLHandler, TenantGraphQLHandlerFactory } from '../tenant'\nimport { SystemGraphQLHandler, SystemGraphQLHandlerFactory } from '../system'\nimport { Authenticator } from '../common'\nimport { ProjectMembershipFetcher, ProjectMembershipResolver } from '../content'\nimport { Providers } from '../providers'\nimport { CryptoWrapper } from '../utils/CryptoWrapper'\n\nexport interface ProjectGroupContainer {\n\tslug: string | undefined\n\n\tlogger: Logger\n\tauthenticator: Authenticator\n\tprojectMembershipResolver: ProjectMembershipResolver\n\n\tprojectContainerResolver: ProjectContainerResolver\n\tprojectSchemaResolver: ProjectSchemaResolverInterface\n\tprojectInitializer: ProjectInitializerInterface\n\n\ttenantContainer: TenantContainer\n\ttenantGraphQLHandler: TenantGraphQLHandler\n\n\tsystemContainer: SystemContainer\n\tsystemGraphQLHandler: SystemGraphQLHandler\n}\n\n\ninterface ProjectGroupContainerFactoryArgs\n{\n\tconfig: TenantConfig\n\tslug: string | undefined\n}\n\nexport class ProjectGroupContainerFactory {\n\tconstructor(\n\t\tprivate readonly debug: boolean,\n\t\tprivate readonly providers: Providers,\n\t\tprivate readonly systemContainerFactory: SystemContainerFactory,\n\t\tprivate readonly tenantContainerFactory: TenantContainerFactory,\n\t\tprivate readonly projectContainerFactoryFactory: ProjectContainerFactoryFactory,\n\t\tprivate readonly projectConfigResolver: ProjectConfigResolver,\n\t\tprivate readonly tenantGraphQLHandlerFactory: TenantGraphQLHandlerFactory,\n\t\tprivate readonly systemGraphQLHandlerFactory: SystemGraphQLHandlerFactory,\n\t\tprivate readonly logger: Logger,\n\t) {}\n\n\tpublic create({ config, slug }: ProjectGroupContainerFactoryArgs): ProjectGroupContainer {\n\t\treturn new Builder({})\n\t\t\t.addService('slug', () =>\n\t\t\t\tslug)\n\t\t\t.addService('logger', ({ slug }) =>\n\t\t\t\tthis.logger.child({ projectGroup: slug }))\n\t\t\t.addService('providers', () =>\n\t\t\t\tthis.providers)\n\t\t\t.addService('tenantDbCredentials', () =>\n\t\t\t\tconfig.db)\n\t\t\t.addService('tenantConnection', ({ tenantDbCredentials, logger }): Connection.ConnectionType =>\n\t\t\t\tConnection.create(tenantDbCredentials, err => logger.error(err)))\n\t\t\t.addService('tenantReadConnection', ({ tenantDbCredentials, logger, tenantConnection }) => {\n\t\t\t\tif (!tenantDbCredentials.read) {\n\t\t\t\t\treturn tenantConnection\n\t\t\t\t}\n\t\t\t\treturn Connection.create({\n\t\t\t\t\t...tenantDbCredentials,\n\t\t\t\t\t...tenantDbCredentials.read,\n\t\t\t\t\tpool: {\n\t\t\t\t\t\t...tenantDbCredentials.pool,\n\t\t\t\t\t\t...tenantDbCredentials.read.pool,\n\t\t\t\t\t},\n\t\t\t\t}, err => logger.error(err))\n\t\t\t})\n\t\t\t.addService('projectSchemaResolver', () =>\n\t\t\t\tnew ProjectSchemaResolverProxy())\n\t\t\t.addService('projectInitializer', () =>\n\t\t\t\tnew ProjectInitializerProxy())\n\t\t\t.addService('tenantContainer', ({ tenantConnection, tenantReadConnection, tenantDbCredentials, projectSchemaResolver, projectInitializer }) => {\n\t\t\t\tconst encryptionKey = config.secrets.encryptionKey\n\t\t\t\t\t? createSecretKey(Buffer.from(config.secrets.encryptionKey, 'hex'))\n\t\t\t\t\t: undefined\n\n\t\t\t\tconst cryptoWrapper = new CryptoWrapper(encryptionKey)\n\t\t\t\treturn this.tenantContainerFactory.create({\n\t\t\t\t\tconnection: tenantConnection,\n\t\t\t\t\treadConnection: tenantReadConnection,\n\t\t\t\t\tdbCredentials: tenantDbCredentials,\n\t\t\t\t\tmailOptions: config.mailer,\n\t\t\t\t\ttenantCredentials: config.credentials,\n\t\t\t\t\tprojectInitializer,\n\t\t\t\t\tprojectSchemaResolver,\n\t\t\t\t\tcryptoProviders: {\n\t\t\t\t\t\tdecrypt: cryptoWrapper.decrypt.bind(cryptoWrapper),\n\t\t\t\t\t\tencrypt: cryptoWrapper.encrypt.bind(cryptoWrapper),\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t})\n\t\t\t.addService('tenantDatabase', ({ tenantContainer }) =>\n\t\t\t\ttenantContainer.databaseContext)\n\t\t\t.addService('tenantReadDatabase', ({ tenantContainer }) =>\n\t\t\t\ttenantContainer.readDatabaseContext)\n\t\t\t.addService('identityFetcher', ({ tenantContainer: { identityFetcher } }) =>\n\t\t\t\tidentityFetcher)\n\t\t\t.addService('systemContainer', ({ identityFetcher }) =>\n\t\t\t\tthis.systemContainerFactory.create({ identityFetcher }))\n\t\t\t.addService('schemaProvider', ({ systemContainer }) =>\n\t\t\t\tsystemContainer.schemaProvider)\n\t\t\t.addService('projectContainerFactory', ({ schemaProvider, logger }) =>\n\t\t\t\tthis.projectContainerFactoryFactory.create(schemaProvider, logger))\n\t\t\t.addService('tenantProjectManager', ({ tenantContainer }) =>\n\t\t\t\ttenantContainer.projectManager)\n\t\t\t.addService('tenantProjectMemberManager', ({ tenantContainer }) =>\n\t\t\t\ttenantContainer.projectMemberManager)\n\t\t\t.addService('projectContainerResolver', ({ projectContainerFactory, tenantProjectManager, tenantReadDatabase }) =>\n\t\t\t\tnew ProjectContainerResolver(\n\t\t\t\t\tprojectContainerFactory,\n\t\t\t\t\tthis.projectConfigResolver,\n\t\t\t\t\ttenantProjectManager,\n\t\t\t\t\ttenantReadDatabase,\n\t\t\t\t\tconfig,\n\t\t\t\t))\n\n\t\t\t.setupService('projectSchemaResolver', (it, { projectContainerResolver }) => {\n\t\t\t\tit.setResolver(new ProjectSchemaResolver(projectContainerResolver))\n\t\t\t})\n\t\t\t.setupService('projectInitializer', (it, { projectContainerResolver }) => {\n\t\t\t\tit.setInitializer(new ProjectInitializer(projectContainerResolver))\n\t\t\t})\n\t\t\t.addService('tenantGraphQLHandler', ({ tenantContainer }) =>\n\t\t\t\tthis.tenantGraphQLHandlerFactory.create(tenantContainer.resolvers))\n\t\t\t.addService('systemGraphQLHandler', ({ systemContainer }) =>\n\t\t\t\tthis.systemGraphQLHandlerFactory.create(systemContainer.systemResolversFactory))\n\t\t\t.addService('authenticator', ({ tenantDatabase, tenantReadDatabase, tenantContainer }) =>\n\t\t\t\tnew Authenticator(tenantDatabase, tenantReadDatabase, tenantContainer.apiKeyManager))\n\t\t\t.addService('projectMembershipResolver', ({ tenantProjectMemberManager, tenantReadDatabase }) =>\n\t\t\t\tnew ProjectMembershipResolver(this.debug, new ProjectMembershipFetcher(tenantProjectMemberManager, tenantReadDatabase)))\n\t\t\t.build()\n\t\t\t.pick(\n\t\t\t\t'projectContainerResolver',\n\t\t\t\t'projectSchemaResolver',\n\t\t\t\t'projectInitializer',\n\t\t\t\t'systemContainer',\n\t\t\t\t'systemGraphQLHandler',\n\t\t\t\t'tenantContainer',\n\t\t\t\t'authenticator',\n\t\t\t\t'projectMembershipResolver',\n\t\t\t\t'tenantGraphQLHandler',\n\t\t\t\t'slug',\n\t\t\t\t'logger',\n\t\t\t)\n\t}\n}\n"],"names":["slug"],"mappings":";;;;;;;;;;;;;;;;;AAqDO,MAAM,6BAA6B;AAAA,EACzC,YACkB,OACA,WACA,wBACA,wBACA,gCACA,uBACA,6BACA,6BACA,QAChB;AATgB,SAAA,QAAA;AACA,SAAA,YAAA;AACA,SAAA,yBAAA;AACA,SAAA,yBAAA;AACA,SAAA,iCAAA;AACA,SAAA,wBAAA;AACA,SAAA,8BAAA;AACA,SAAA,8BAAA;AACA,SAAA,SAAA;AAAA,EAAA;AAAA,EAGX,OAAO,EAAE,QAAQ,QAAiE;AACxF,WAAO,IAAI,QAAQ,EAAE,EACnB,WAAW,QAAQ,MACnB,IAAI,EACJ,WAAW,UAAU,CAAC,EAAE,MAAAA,YACxB,KAAK,OAAO,MAAM,EAAE,cAAcA,MAAK,CAAC,CAAC,EACzC,WAAW,aAAa,MACxB,KAAK,SAAS,EACd,WAAW,uBAAuB,MAClC,OAAO,EAAE,EACT,WAAW,oBAAoB,CAAC,EAAE,qBAAqB,aACvD,WAAW,OAAO,qBAAqB,CAAA,QAAO,OAAO,MAAM,GAAG,CAAC,CAAC,EAChE,WAAW,wBAAwB,CAAC,EAAE,qBAAqB,QAAQ,uBAAuB;AACtF,UAAA,CAAC,oBAAoB,MAAM;AACvB,eAAA;AAAA,MAAA;AAER,aAAO,WAAW,OAAO;AAAA,QACxB,GAAG;AAAA,QACH,GAAG,oBAAoB;AAAA,QACvB,MAAM;AAAA,UACL,GAAG,oBAAoB;AAAA,UACvB,GAAG,oBAAoB,KAAK;AAAA,QAAA;AAAA,MAE3B,GAAA,CAAA,QAAO,OAAO,MAAM,GAAG,CAAC;AAAA,IAAA,CAC3B,EACA,WAAW,yBAAyB,MACpC,IAAI,2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AK;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IAAA,CACA,EAED,aAAa,yBAAyB,CAAC,IAAI,EAAE,+BAA+B;AAC5E,SAAG,YAAY,IAAI,sBAAsB,wBAAwB,CAAC;AAAA,IAAA,CAClE,EACA,aAAa,sBAAsB,CAAC,IAAI,EAAE,+BAA+B;AACzE,SAAG,eAAe,IAAI,mBAAmB,wBAAwB,CAAC;AAAA,IAClE,CAAA,EACA,WAAW,wBAAwB,CAAC,EAAE,gBAAgB,MACtD,KAAK,4BAA4B,OAAO,gBAAgB,SAAS,CAAC,EAClE,WAAW,wBAAwB,CAAC,EAAE,sBACtC,KAAK,4BAA4B,OAAO,gBAAgB,sBAAsB,CAAC,EAC/E,WAAW,iBAAiB,CAAC,EAAE,gBAAgB,oBAAoB,gBAAA,MACnE,IAAI,cAAc,gBAAgB,oBAAoB,gBAAgB,aAAa,CAAC,EACpF,WAAW,6BAA6B,CAAC,EAAE,4BAA4B,yBACvE,IAAI,0BAA0B,KAAK,OAAO,IAAI,yBAAyB,4BAA4B,kBAAkB,CAAC,CAAC,EACvH,MACA,EAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EAAA;AAEH;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ProjectGroupContainerResolver.cjs","sources":["../../../../../packages/engine-http/src/projectGroup/ProjectGroupContainerResolver.ts"],"sourcesContent":["import { PromiseMap, EventEmitter, EventManager } from '@contember/engine-common'\nimport { isDeepStrictEqual } from 'node:util'\nimport { ProjectGroupContainer, ProjectGroupContainerFactory } from './ProjectGroupContainer'\nimport { TenantConfigResolver } from '../config/tenantConfigResolver'\n\ninterface ContainerWithMeta {\n\tcontainer: ProjectGroupContainer\n\tcleanups: (() => void)[]\n\tinputConfig: any\n}\nexport type ProjectGroupContainerResolverEvents = {\n\tcreate: (args: ({ container: ProjectGroupContainer; slug: string | undefined})) => void | (() => void)\n}\n\n\nexport class ProjectGroupContainerResolver implements EventEmitter<ProjectGroupContainerResolverEvents> {\n\tprivate containers = new PromiseMap<string | undefined, ContainerWithMeta>()\n\tprivate eventManager = new EventManager< ProjectGroupContainerResolverEvents>()\n\n\tpublic readonly on = this.eventManager.on.bind(this.eventManager)\n\n\tconstructor(\n\t\tprivate readonly configResolver: TenantConfigResolver,\n\t\tprivate readonly containerFactory: ProjectGroupContainerFactory,\n\t) {}\n\n\tpublic async getProjectGroupContainer(slug: string | undefined, config: any = {}): Promise<ProjectGroupContainer> {\n\t\tconst existing = this.containers.get(slug)\n\t\tif (existing) {\n\t\t\tconst existingAwaited = await existing\n\t\t\tif (isDeepStrictEqual(config, existingAwaited.inputConfig)) {\n\t\t\t\treturn existingAwaited.container\n\t\t\t}\n\t\t\texistingAwaited.cleanups.forEach(it => it())\n\t\t\tthis.containers.delete(slug)\n\t\t}\n\t\treturn (await this.containers.fetch(slug, async slug => {\n\t\t\tconst container = this.containerFactory.create({\n\t\t\t\tconfig: this.configResolver(slug, config),\n\t\t\t\tslug,\n\t\t\t})\n\t\t\tconst cleanups = this.eventManager.fire('create', { container, slug }).map(it => it ?? (() => null))\n\n\t\t\tcontainer.projectContainerResolver.on('create', ({ container: projectContainer }) => {\n\t\t\t\tcleanups.push(() => container.projectContainerResolver.destroyContainer(projectContainer.project.slug))\n\t\t\t})\n\n\t\t\tawait container.tenantContainer.migrationsRunner.run(container.logger.child())\n\t\t\treturn { container, inputConfig: config, cleanups }\n\t\t})).container\n\t}\n}\n"],"names":["PromiseMap","EventManager","isDeepStrictEqual","slug"],"mappings":";;;;;;;AAeO,MAAM,8BAA2F;AAAA,EAMvG,YACkB,gBACA,kBAChB;AAFgB,SAAA,iBAAA;AACA,SAAA,mBAAA;AAPV,kBAAA,MAAA,cAAa,IAAIA,aAAAA,WAAkD,CAAA;AACnE,kBAAA,MAAA,gBAAe,IAAIC,aAAAA,aAAmD,CAAA;AAE9E,kBAAA,MAAgB,MAAK,KAAK,aAAa,GAAG,KAAK,KAAK,YAAY,CAAA;AAAA,EAK7D;AAAA,EAEH,MAAa,yBAAyB,MAA0B,SAAc,IAAoC;AACjH,UAAM,WAAW,KAAK,WAAW,IAAI,IAAI;AACzC,QAAI,UAAU;AACb,YAAM,kBAAkB,MAAM;AAC9B,UAAIC,4BAAkB,QAAQ,gBAAgB,WAAW,GAAG;AAC3D,eAAO,gBAAgB;AAAA,MACxB;AACA,sBAAgB,SAAS,QAAQ,CAAM,OAAA,GAAI,CAAA;AACtC,WAAA,WAAW,OAAO,IAAI;AAAA,IAC5B;AACA,YAAQ,MAAM,KAAK,WAAW,MAAM,MAAM,OAAMC,UAAQ;AACjD,YAAA,YAAY,KAAK,iBAAiB,OAAO;AAAA,QAC9C,QAAQ,KAAK,eAAeA,OAAM,MAAM;AAAA,QACxC,MAAAA;AAAAA,MAAA,CACA;AACD,YAAM,WAAW,KAAK,aAAa,KAAK,UAAU,EAAE,WAAW,MAAAA,MAAM,CAAA,EAAE,IAAI,CAAM,OAAA,OAAO,MAAM,KAAK;AAEnG,gBAAU,yBAAyB,GAAG,UAAU,CAAC,EAAE,WAAW,uBAAuB;AAC3E,iBAAA,KAAK,MAAM,UAAU,yBAAyB,iBAAiB,iBAAiB,QAAQ,IAAI,CAAC;AAAA,MAAA,CACtG;AAED,YAAM,UAAU,gBAAgB,iBAAiB,IAAI,UAAU,OAAO,OAAO;AAC7E,aAAO,EAAE,WAAW,aAAa,QAAQ,SAAS;AAAA,IAClD,CAAA,GAAG;AAAA,EACL;AACD;;"}
1
+ {"version":3,"file":"ProjectGroupContainerResolver.cjs","sources":["../../../../../packages/engine-http/src/projectGroup/ProjectGroupContainerResolver.ts"],"sourcesContent":["import { PromiseMap, EventEmitter, EventManager } from '@contember/engine-common'\nimport { isDeepStrictEqual } from 'node:util'\nimport { ProjectGroupContainer, ProjectGroupContainerFactory } from './ProjectGroupContainer'\nimport { TenantConfigResolver } from '../config/tenantConfigResolver'\n\ninterface ContainerWithMeta {\n\tcontainer: ProjectGroupContainer\n\tcleanups: (() => void)[]\n\tinputConfig: any\n}\nexport type ProjectGroupContainerResolverEvents = {\n\tcreate: (args: ({ container: ProjectGroupContainer; slug: string | undefined})) => void | (() => void)\n}\n\n\nexport class ProjectGroupContainerResolver implements EventEmitter<ProjectGroupContainerResolverEvents> {\n\tprivate containers = new PromiseMap<string | undefined, ContainerWithMeta>()\n\tprivate eventManager = new EventManager< ProjectGroupContainerResolverEvents>()\n\n\tpublic readonly on = this.eventManager.on.bind(this.eventManager)\n\n\tconstructor(\n\t\tprivate readonly configResolver: TenantConfigResolver,\n\t\tprivate readonly containerFactory: ProjectGroupContainerFactory,\n\t) {}\n\n\tpublic async getProjectGroupContainer(slug: string | undefined, config: any = {}): Promise<ProjectGroupContainer> {\n\t\tconst existing = this.containers.get(slug)\n\t\tif (existing) {\n\t\t\tconst existingAwaited = await existing\n\t\t\tif (isDeepStrictEqual(config, existingAwaited.inputConfig)) {\n\t\t\t\treturn existingAwaited.container\n\t\t\t}\n\t\t\texistingAwaited.cleanups.forEach(it => it())\n\t\t\tthis.containers.delete(slug)\n\t\t}\n\t\treturn (await this.containers.fetch(slug, async slug => {\n\t\t\tconst container = this.containerFactory.create({\n\t\t\t\tconfig: this.configResolver(slug, config),\n\t\t\t\tslug,\n\t\t\t})\n\t\t\tconst cleanups = this.eventManager.fire('create', { container, slug }).map(it => it ?? (() => null))\n\n\t\t\tcontainer.projectContainerResolver.on('create', ({ container: projectContainer }) => {\n\t\t\t\tcleanups.push(() => container.projectContainerResolver.destroyContainer(projectContainer.project.slug))\n\t\t\t})\n\n\t\t\tawait container.tenantContainer.migrationsRunner.run(container.logger.child())\n\t\t\treturn { container, inputConfig: config, cleanups }\n\t\t})).container\n\t}\n}\n"],"names":["PromiseMap","EventManager","isDeepStrictEqual","slug"],"mappings":";;;;;;;AAeO,MAAM,8BAA2F;AAAA,EAMvG,YACkB,gBACA,kB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erResolver.ts"],"sourcesContent":["import { PromiseMap, EventEmitter, EventManager } from '@contember/engine-common'\nimport { isDeepStrictEqual } from 'node:util'\nimport { ProjectGroupContainer, ProjectGroupContainerFactory } from './ProjectGroupContainer'\nimport { TenantConfigResolver } from '../config/tenantConfigResolver'\n\ninterface ContainerWithMeta {\n\tcontainer: ProjectGroupContainer\n\tcleanups: (() => void)[]\n\tinputConfig: any\n}\nexport type ProjectGroupContainerResolverEvents = {\n\tcreate: (args: ({ container: ProjectGroupContainer; slug: string | undefined})) => void | (() => void)\n}\n\n\nexport class ProjectGroupContainerResolver implements EventEmitter<ProjectGroupContainerResolverEvents> {\n\tprivate containers = new PromiseMap<string | undefined, ContainerWithMeta>()\n\tprivate eventManager = new EventManager< ProjectGroupContainerResolverEvents>()\n\n\tpublic readonly on = this.eventManager.on.bind(this.eventManager)\n\n\tconstructor(\n\t\tprivate readonly configResolver: TenantConfigResolver,\n\t\tprivate readonly containerFactory: ProjectGroupContainerFactory,\n\t) {}\n\n\tpublic async getProjectGroupContainer(slug: string | undefined, config: any = {}): Promise<ProjectGroupContainer> {\n\t\tconst existing = this.containers.get(slug)\n\t\tif (existing) {\n\t\t\tconst existingAwaited = await existing\n\t\t\tif (isDeepStrictEqual(config, existingAwaited.inputConfig)) {\n\t\t\t\treturn existingAwaited.container\n\t\t\t}\n\t\t\texistingAwaited.cleanups.forEach(it => it())\n\t\t\tthis.containers.delete(slug)\n\t\t}\n\t\treturn (await this.containers.fetch(slug, async slug => {\n\t\t\tconst container = this.containerFactory.create({\n\t\t\t\tconfig: this.configResolver(slug, config),\n\t\t\t\tslug,\n\t\t\t})\n\t\t\tconst cleanups = this.eventManager.fire('create', { container, slug }).map(it => it ?? (() => null))\n\n\t\t\tcontainer.projectContainerResolver.on('create', ({ container: projectContainer }) => {\n\t\t\t\tcleanups.push(() => container.projectContainerResolver.destroyContainer(projectContainer.project.slug))\n\t\t\t})\n\n\t\t\tawait container.tenantContainer.migrationsRunner.run(container.logger.child())\n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ACL;AACD;"}
1
+ {"version":3,"file":"ProjectGroupContainerResolver.js","sources":["../../../../../packages/engine-http/src/projectGroup/ProjectGroupContainerResolver.ts"],"sourcesContent":["import { PromiseMap, EventEmitter, EventManager } from '@contember/engine-common'\nimport { isDeepStrictEqual } from 'node:util'\nimport { ProjectGroupContainer, ProjectGroupContainerFactory } from './ProjectGroupContainer'\nimport { TenantConfigResolver } from '../config/tenantConfigResolver'\n\ninterface ContainerWithMeta {\n\tcontainer: ProjectGroupContainer\n\tcleanups: (() => void)[]\n\tinputConfig: any\n}\nexport type ProjectGroupContainerResolverEvents = {\n\tcreate: (args: ({ container: ProjectGroupContainer; slug: string | undefined})) => void | (() => void)\n}\n\n\nexport class ProjectGroupContainerResolver implements EventEmitter<ProjectGroupContainerResolverEvents> {\n\tprivate containers = new PromiseMap<string | undefined, ContainerWithMeta>()\n\tprivate eventManager = new EventManager< ProjectGroupContainerResolverEvents>()\n\n\tpublic readonly on = this.eventManager.on.bind(this.eventManager)\n\n\tconstructor(\n\t\tprivate readonly configResolver: TenantConfigResolver,\n\t\tprivate readonly containerFactory: ProjectGroupContainerFactory,\n\t) {}\n\n\tpublic async getProjectGroupContainer(slug: string | undefined, config: any = {}): Promise<ProjectGroupContainer> {\n\t\tconst existing = this.containers.get(slug)\n\t\tif (existing) {\n\t\t\tconst existingAwaited = await existing\n\t\t\tif (isDeepStrictEqual(config, existingAwaited.inputConfig)) {\n\t\t\t\treturn existingAwaited.container\n\t\t\t}\n\t\t\texistingAwaited.cleanups.forEach(it => it())\n\t\t\tthis.containers.delete(slug)\n\t\t}\n\t\treturn (await this.containers.fetch(slug, async slug => {\n\t\t\tconst container = this.containerFactory.create({\n\t\t\t\tconfig: this.configResolver(slug, config),\n\t\t\t\tslug,\n\t\t\t})\n\t\t\tconst cleanups = this.eventManager.fire('create', { container, slug }).map(it => it ?? (() => null))\n\n\t\t\tcontainer.projectContainerResolver.on('create', ({ container: projectContainer }) => {\n\t\t\t\tcleanups.push(() => container.projectContainerResolver.destroyContainer(projectContainer.project.slug))\n\t\t\t})\n\n\t\t\tawait container.tenantContainer.migrationsRunner.run(container.logger.child())\n\t\t\treturn { container, inputConfig: config, cleanups }\n\t\t})).container\n\t}\n}\n"],"names":["slug"],"mappings":";;;;;AAeO,MAAM,8BAA2F;AAAA,EAMvG,YACkB,gBACA,kBAChB;AAFgB,SAAA,iBAAA;AACA,SAAA,mBAAA;AAPV,kBAAA,MAAA,cAAa,IAAI,WAAkD,CAAA;AACnE,kBAAA,MAAA,gBAAe,IAAI,aAAmD,CAAA;AAE9E,kBAAA,MAAgB,MAAK,KAAK,aAAa,GAAG,KAAK,KAAK,YAAY,CAAA;AAAA,EAAA;AAAA,EAOhE,MAAa,yBAAyB,MAA0B,SAAc,IAAoC;AACjH,UAAM,WAAW,KAAK,WAAW,IAAI,IAAI;AACzC,QAAI,UAAU;AACb,YAAM,kBAAkB,MAAM;AAC9B,UAAI,kBAAkB,QAAQ,gBAAgB,WAAW,GAAG;AAC3D,eAAO,gBAAgB;AAAA,MAAA;AAExB,sBAAgB,SAAS,QAAQ,CAAM,OAAA,GAAA,CAAI;AACtC,WAAA,WAAW,OAAO,IAAI;AAAA,IAAA;AAE5B,YAAQ,MAAM,KAAK,WAAW,MAAM,MAAM,OAAMA,UAAQ;AACjD,YAAA,YAAY,KAAK,iBAAiB,OAAO;AAAA,QAC9C,QAAQ,KAAK,eAAeA,OAAM,MAAM;AAAA,QACxC,MAAAA;AAAAA,MAAA,CACA;AACD,YAAM,WAAW,KAAK,aAAa,KAAK,UAAU,EAAE,WAAW,MAAAA,MAAM,CAAA,EAAE,IAAI,CAAM,OAAA,OAAO,MAAM,KAAK;AAEnG,gBAAU,yBAAyB,GAAG,UAAU,CAAC,EAAE,WAAW,uBAAuB;AAC3E,iBAAA,KAAK,MAAM,UAAU,yBAAyB,iBAAiB,iBAAiB,QAAQ,IAAI,CAAC;AAAA,MAAA,CACtG;AAED,YAAM,UAAU,gBAAgB,iBAAiB,IAAI,UAAU,OAAO,OAAO;AAC7E,aAAO,EAAE,WAAW,aAAa,QAAQ,SAAS;AAAA,IAClD,CAAA,GAAG;AAAA,EAAA;AAEN;"}
@@ -5,15 +5,7 @@ const HttpResponse = require("../common/HttpResponse.cjs");
5
5
  var __defProp = Object.defineProperty;
6
6
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
7
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
8
- class SingleProjectGroupResolver {
9
- constructor(projectGroupContainer) {
10
- this.projectGroupContainer = projectGroupContainer;
11
- }
12
- resolveContainer() {
13
- return Promise.resolve(this.projectGroupContainer);
14
- }
15
- }
16
- class MultiProjectGroupResolver {
8
+ class ProjectGroupResolver {
17
9
  constructor(projectGroupDomainMapping, projectGroupConfigHeader, projectGroupConfigCrypto, projectGroupContainerResolver) {
18
10
  this.projectGroupDomainMapping = projectGroupDomainMapping;
19
11
  this.projectGroupConfigCrypto = projectGroupConfigCrypto;
@@ -53,6 +45,5 @@ class MultiProjectGroupResolver {
53
45
  }
54
46
  }
55
47
  const regexpQuote = (regexp) => regexp.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
56
- exports.MultiProjectGroupResolver = MultiProjectGroupResolver;
57
- exports.SingleProjectGroupResolver = SingleProjectGroupResolver;
48
+ exports.ProjectGroupResolver = ProjectGroupResolver;
58
49
  //# sourceMappingURL=ProjectGroupResolver.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProjectGroupResolver.cjs","sources":["../../../../../packages/engine-http/src/projectGroup/ProjectGroupResolver.ts"],"sourcesContent":["import { CryptoWrapper } from '../utils/CryptoWrapper'\nimport { ProjectGroupContainer } from './ProjectGroupContainer'\nimport { IncomingMessage } from 'node:http'\nimport { ProjectGroupContainerResolver } from './ProjectGroupContainerResolver'\nimport { HttpErrorResponse } from '../common'\n\nexport interface ProjectGroupResolver {\n\tresolveContainer({ request }: { request: IncomingMessage }): Promise<ProjectGroupContainer>\n}\n\nexport class SingleProjectGroupResolver {\n\tconstructor(\n\t\tprivate readonly projectGroupContainer: ProjectGroupContainer,\n\t) {\n\t}\n\n\tresolveContainer(): Promise<ProjectGroupContainer> {\n\t\treturn Promise.resolve(this.projectGroupContainer)\n\t}\n}\n\nexport class MultiProjectGroupResolver implements ProjectGroupResolver {\n\tprivate groupRegex\n\tprivate projectGroupConfigHeader\n\n\tconstructor(\n\t\tprivate projectGroupDomainMapping: string | undefined,\n\t\tprojectGroupConfigHeader: string | undefined,\n\t\tprivate projectGroupConfigCrypto: CryptoWrapper | undefined,\n\t\tprivate projectGroupContainerResolver: ProjectGroupContainerResolver,\n\t) {\n\t\tthis.projectGroupConfigHeader = projectGroupConfigHeader?.toLowerCase()\n\t\tthis.groupRegex = (\n\t\t\tthis.projectGroupDomainMapping\n\t\t\t\t? new RegExp(\n\t\t\t\t\tthis.projectGroupDomainMapping.includes('{group}')\n\t\t\t\t\t\t? regexpQuote(this.projectGroupDomainMapping).replace(regexpQuote('{group}'), '([^.]+)')\n\t\t\t\t\t\t: this.projectGroupDomainMapping,\n\t\t\t\t)\n\t\t\t\t: undefined\n\t\t)\n\t}\n\n\tasync resolveContainer({ request }: { request: IncomingMessage }): Promise<ProjectGroupContainer> {\n\t\tlet group: string | undefined = undefined\n\t\tlet config = {}\n\t\tif (this.groupRegex) {\n\t\t\tconst host = request.headers.host\n\t\t\tconst match = host?.match(this.groupRegex)\n\t\t\tif (!match) {\n\t\t\t\tthrow new HttpErrorResponse(404, 'Project group not found')\n\t\t\t}\n\t\t\tgroup = match[1]\n\t\t\tif (this.projectGroupConfigHeader) {\n\t\t\t\tconst configHeader = request.headers[this.projectGroupConfigHeader.toLowerCase()]\n\t\t\t\tif (typeof configHeader !== 'string' || configHeader === '') {\n\t\t\t\t\tthrow new HttpErrorResponse(400, `${this.projectGroupConfigHeader} header is missing`)\n\t\t\t\t}\n\t\t\t\tconst configValue = Buffer.from(configHeader, 'base64')\n\t\t\t\tconst decryptedValue = this.projectGroupConfigCrypto\n\t\t\t\t\t? (await this.projectGroupConfigCrypto?.decrypt(configValue, CryptoWrapper.cryptoVersion)).value\n\t\t\t\t\t: configValue\n\t\t\t\ttry {\n\t\t\t\t\tconfig = JSON.parse(decryptedValue.toString())\n\t\t\t\t} catch (e: any) {\n\t\t\t\t\tthrow new HttpErrorResponse(400, `Cannot parse config: ${e.message}`)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn await this.projectGroupContainerResolver.getProjectGroupContainer(group, config)\n\t}\n}\n\nconst regexpQuote = (regexp: string) => regexp.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n"],"names":["HttpErrorResponse","CryptoWrapper"],"mappings":";;;;;;;AAUO,MAAM,2BAA2B;AAAA,EACvC,YACkB,uBAChB;AADgB,SAAA,wBAAA;AAAA,EAElB;AAAA,EAEA,mBAAmD;AAC3C,WAAA,QAAQ,QAAQ,KAAK,qBAAqB;AAAA,EAClD;AACD;AAEO,MAAM,0BAA0D;AAAA,EAItE,YACS,2BACR,0BACQ,0BACA,+BACP;AAJO,SAAA,4BAAA;AAEA,SAAA,2BAAA;AACA,SAAA,gCAAA;AAPD,kBAAA,MAAA,YAAA;AACA,kBAAA,MAAA,0BAAA;AAQF,SAAA,2BAA2B,0BAA0B;AACrD,SAAA,aACJ,KAAK,4BACF,IAAI;AAAA,MACL,KAAK,0BAA0B,SAAS,SAAS,IAC9C,YAAY,KAAK,yBAAyB,EAAE,QAAQ,YAAY,SAAS,GAAG,SAAS,IACrF,KAAK;AAAA,IAEP,IAAA;AAAA,EAEL;AAAA,EAEA,MAAM,iBAAiB,EAAE,WAAyE;AACjG,QAAI,QAA4B;AAChC,QAAI,SAAS,CAAA;AACb,QAAI,KAAK,YAAY;AACd,YAAA,OAAO,QAAQ,QAAQ;AAC7B,YAAM,QAAQ,MAAM,MAAM,KAAK,UAAU;AACzC,UAAI,CAAC,OAAO;AACL,cAAA,IAAIA,aAAkB,kBAAA,KAAK,yBAAyB;AAAA,MAC3D;AACA,cAAQ,MAAM,CAAC;AACf,UAAI,KAAK,0BAA0B;AAClC,cAAM,eAAe,QAAQ,QAAQ,KAAK,yBAAyB,aAAa;AAChF,YAAI,OAAO,iBAAiB,YAAY,iBAAiB,IAAI;AAC5D,gBAAM,IAAIA,aAAkB,kBAAA,KAAK,GAAG,KAAK,wBAAwB,oBAAoB;AAAA,QACtF;AACA,cAAM,cAAc,OAAO,KAAK,cAAc,QAAQ;AAChD,cAAA,iBAAiB,KAAK,4BACxB,MAAM,KAAK,0BAA0B,QAAQ,aAAaC,cAAA,cAAc,aAAa,GAAG,QACzF;AACC,YAAA;AACH,mBAAS,KAAK,MAAM,eAAe,SAAU,CAAA;AAAA,iBACrC,GAAQ;AAChB,gBAAM,IAAID,aAAkB,kBAAA,KAAK,wBAAwB,EAAE,OAAO,EAAE;AAAA,QACrE;AAAA,MACD;AAAA,IACD;AACA,WAAO,MAAM,KAAK,8BAA8B,yBAAyB,OAAO,MAAM;AAAA,EACvF;AACD;AAEA,MAAM,cAAc,CAAC,WAAmB,OAAO,QAAQ,uBAAuB,MAAM;;;"}
1
+ {"version":3,"file":"ProjectGroupResolver.cjs","sources":["../../../../../packages/engine-http/src/projectGroup/ProjectGroupResolver.ts"],"sourcesContent":["import { CryptoWrapper } from '../utils/CryptoWrapper'\nimport { ProjectGroupContainer } from './ProjectGroupContainer'\nimport { IncomingMessage } from 'node:http'\nimport { ProjectGroupContainerResolver } from './ProjectGroupContainerResolver'\nimport { HttpErrorResponse } from '../common'\n\nexport class ProjectGroupResolver {\n\tprivate groupRegex\n\tprivate projectGroupConfigHeader\n\n\tconstructor(\n\t\tprivate projectGroupDomainMapping: string | undefined,\n\t\tprojectGroupConfigHeader: string | undefined,\n\t\tprivate projectGroupConfigCrypto: CryptoWrapper | undefined,\n\t\tprivate projectGroupContainerResolver: ProjectGroupContainerResolver,\n\t) {\n\t\tthis.projectGroupConfigHeader = projectGroupConfigHeader?.toLowerCase()\n\t\tthis.groupRegex = (\n\t\t\tthis.projectGroupDomainMapping\n\t\t\t\t? new RegExp(\n\t\t\t\t\tthis.projectGroupDomainMapping.includes('{group}')\n\t\t\t\t\t\t? regexpQuote(this.projectGroupDomainMapping).replace(regexpQuote('{group}'), '([^.]+)')\n\t\t\t\t\t\t: this.projectGroupDomainMapping,\n\t\t\t\t)\n\t\t\t\t: undefined\n\t\t)\n\t}\n\n\tasync resolveContainer({ request }: { request: IncomingMessage }): Promise<ProjectGroupContainer> {\n\t\tlet group: string | undefined = undefined\n\t\tlet config = {}\n\t\tif (this.groupRegex) {\n\t\t\tconst host = request.headers.host\n\t\t\tconst match = host?.match(this.groupRegex)\n\t\t\tif (!match) {\n\t\t\t\tthrow new HttpErrorResponse(404, 'Project group not found')\n\t\t\t}\n\t\t\tgroup = match[1]\n\t\t\tif (this.projectGroupConfigHeader) {\n\t\t\t\tconst configHeader = request.headers[this.projectGroupConfigHeader.toLowerCase()]\n\t\t\t\tif (typeof configHeader !== 'string' || configHeader === '') {\n\t\t\t\t\tthrow new HttpErrorResponse(400, `${this.projectGroupConfigHeader} header is missing`)\n\t\t\t\t}\n\t\t\t\tconst configValue = Buffer.from(configHeader, 'base64')\n\t\t\t\tconst decryptedValue = this.projectGroupConfigCrypto\n\t\t\t\t\t? (await this.projectGroupConfigCrypto?.decrypt(configValue, CryptoWrapper.cryptoVersion)).value\n\t\t\t\t\t: configValue\n\t\t\t\ttry {\n\t\t\t\t\tconfig = JSON.parse(decryptedValue.toString())\n\t\t\t\t} catch (e: any) {\n\t\t\t\t\tthrow new HttpErrorResponse(400, `Cannot parse config: ${e.message}`)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn await this.projectGroupContainerResolver.getProjectGroupContainer(group, config)\n\t}\n}\n\nconst regexpQuote = (regexp: string) => regexp.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n"],"names":["HttpErrorResponse","CryptoWrapper"],"mappings":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AK,8BAA8B,yBAAyB,OAAO,MAAM;AAAA,EAAA;AAExF;AAEA,MAAM,cAAc,CAAC,WAAmB,OAAO,QAAQ,uBAAuB,MAAM;;"}
@@ -3,15 +3,7 @@ import { HttpErrorResponse } from "../common/HttpResponse.js";
3
3
  var __defProp = Object.defineProperty;
4
4
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5
5
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
6
- class SingleProjectGroupResolver {
7
- constructor(projectGroupContainer) {
8
- this.projectGroupContainer = projectGroupContainer;
9
- }
10
- resolveContainer() {
11
- return Promise.resolve(this.projectGroupContainer);
12
- }
13
- }
14
- class MultiProjectGroupResolver {
6
+ class ProjectGroupResolver {
15
7
  constructor(projectGroupDomainMapping, projectGroupConfigHeader, projectGroupConfigCrypto, projectGroupContainerResolver) {
16
8
  this.projectGroupDomainMapping = projectGroupDomainMapping;
17
9
  this.projectGroupConfigCrypto = projectGroupConfigCrypto;
@@ -52,7 +44,6 @@ class MultiProjectGroupResolver {
52
44
  }
53
45
  const regexpQuote = (regexp) => regexp.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
54
46
  export {
55
- MultiProjectGroupResolver,
56
- SingleProjectGroupResolver
47
+ ProjectGroupResolver
57
48
  };
58
49
  //# sourceMappingURL=ProjectGroupResolver.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProjectGroupResolver.js","sources":["../../../../../packages/engine-http/src/projectGroup/ProjectGroupResolver.ts"],"sourcesContent":["import { CryptoWrapper } from '../utils/CryptoWrapper'\nimport { ProjectGroupContainer } from './ProjectGroupContainer'\nimport { IncomingMessage } from 'node:http'\nimport { ProjectGroupContainerResolver } from './ProjectGroupContainerResolver'\nimport { HttpErrorResponse } from '../common'\n\nexport interface ProjectGroupResolver {\n\tresolveContainer({ request }: { request: IncomingMessage }): Promise<ProjectGroupContainer>\n}\n\nexport class SingleProjectGroupResolver {\n\tconstructor(\n\t\tprivate readonly projectGroupContainer: ProjectGroupContainer,\n\t) {\n\t}\n\n\tresolveContainer(): Promise<ProjectGroupContainer> {\n\t\treturn Promise.resolve(this.projectGroupContainer)\n\t}\n}\n\nexport class MultiProjectGroupResolver implements ProjectGroupResolver {\n\tprivate groupRegex\n\tprivate projectGroupConfigHeader\n\n\tconstructor(\n\t\tprivate projectGroupDomainMapping: string | undefined,\n\t\tprojectGroupConfigHeader: string | undefined,\n\t\tprivate projectGroupConfigCrypto: CryptoWrapper | undefined,\n\t\tprivate projectGroupContainerResolver: ProjectGroupContainerResolver,\n\t) {\n\t\tthis.projectGroupConfigHeader = projectGroupConfigHeader?.toLowerCase()\n\t\tthis.groupRegex = (\n\t\t\tthis.projectGroupDomainMapping\n\t\t\t\t? new RegExp(\n\t\t\t\t\tthis.projectGroupDomainMapping.includes('{group}')\n\t\t\t\t\t\t? regexpQuote(this.projectGroupDomainMapping).replace(regexpQuote('{group}'), '([^.]+)')\n\t\t\t\t\t\t: this.projectGroupDomainMapping,\n\t\t\t\t)\n\t\t\t\t: undefined\n\t\t)\n\t}\n\n\tasync resolveContainer({ request }: { request: IncomingMessage }): Promise<ProjectGroupContainer> {\n\t\tlet group: string | undefined = undefined\n\t\tlet config = {}\n\t\tif (this.groupRegex) {\n\t\t\tconst host = request.headers.host\n\t\t\tconst match = host?.match(this.groupRegex)\n\t\t\tif (!match) {\n\t\t\t\tthrow new HttpErrorResponse(404, 'Project group not found')\n\t\t\t}\n\t\t\tgroup = match[1]\n\t\t\tif (this.projectGroupConfigHeader) {\n\t\t\t\tconst configHeader = request.headers[this.projectGroupConfigHeader.toLowerCase()]\n\t\t\t\tif (typeof configHeader !== 'string' || configHeader === '') {\n\t\t\t\t\tthrow new HttpErrorResponse(400, `${this.projectGroupConfigHeader} header is missing`)\n\t\t\t\t}\n\t\t\t\tconst configValue = Buffer.from(configHeader, 'base64')\n\t\t\t\tconst decryptedValue = this.projectGroupConfigCrypto\n\t\t\t\t\t? (await this.projectGroupConfigCrypto?.decrypt(configValue, CryptoWrapper.cryptoVersion)).value\n\t\t\t\t\t: configValue\n\t\t\t\ttry {\n\t\t\t\t\tconfig = JSON.parse(decryptedValue.toString())\n\t\t\t\t} catch (e: any) {\n\t\t\t\t\tthrow new HttpErrorResponse(400, `Cannot parse config: ${e.message}`)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn await this.projectGroupContainerResolver.getProjectGroupContainer(group, config)\n\t}\n}\n\nconst regexpQuote = (regexp: string) => regexp.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n"],"names":[],"mappings":";;;;;AAUO,MAAM,2BAA2B;AAAA,EACvC,YACkB,uBAChB;AADgB,SAAA,wBAAA;AAAA,EAElB;AAAA,EAEA,mBAAmD;AAC3C,WAAA,QAAQ,QAAQ,KAAK,qBAAqB;AAAA,EAClD;AACD;AAEO,MAAM,0BAA0D;AAAA,EAItE,YACS,2BACR,0BACQ,0BACA,+BACP;AAJO,SAAA,4BAAA;AAEA,SAAA,2BAAA;AACA,SAAA,gCAAA;AAPD,kBAAA,MAAA,YAAA;AACA,kBAAA,MAAA,0BAAA;AAQF,SAAA,2BAA2B,0BAA0B;AACrD,SAAA,aACJ,KAAK,4BACF,IAAI;AAAA,MACL,KAAK,0BAA0B,SAAS,SAAS,IAC9C,YAAY,KAAK,yBAAyB,EAAE,QAAQ,YAAY,SAAS,GAAG,SAAS,IACrF,KAAK;AAAA,IAEP,IAAA;AAAA,EAEL;AAAA,EAEA,MAAM,iBAAiB,EAAE,WAAyE;AACjG,QAAI,QAA4B;AAChC,QAAI,SAAS,CAAA;AACb,QAAI,KAAK,YAAY;AACd,YAAA,OAAO,QAAQ,QAAQ;AAC7B,YAAM,QAAQ,MAAM,MAAM,KAAK,UAAU;AACzC,UAAI,CAAC,OAAO;AACL,cAAA,IAAI,kBAAkB,KAAK,yBAAyB;AAAA,MAC3D;AACA,cAAQ,MAAM,CAAC;AACf,UAAI,KAAK,0BAA0B;AAClC,cAAM,eAAe,QAAQ,QAAQ,KAAK,yBAAyB,aAAa;AAChF,YAAI,OAAO,iBAAiB,YAAY,iBAAiB,IAAI;AAC5D,gBAAM,IAAI,kBAAkB,KAAK,GAAG,KAAK,wBAAwB,oBAAoB;AAAA,QACtF;AACA,cAAM,cAAc,OAAO,KAAK,cAAc,QAAQ;AAChD,cAAA,iBAAiB,KAAK,4BACxB,MAAM,KAAK,0BAA0B,QAAQ,aAAa,cAAc,aAAa,GAAG,QACzF;AACC,YAAA;AACH,mBAAS,KAAK,MAAM,eAAe,SAAU,CAAA;AAAA,iBACrC,GAAQ;AAChB,gBAAM,IAAI,kBAAkB,KAAK,wBAAwB,EAAE,OAAO,EAAE;AAAA,QACrE;AAAA,MACD;AAAA,IACD;AACA,WAAO,MAAM,KAAK,8BAA8B,yBAAyB,OAAO,MAAM;AAAA,EACvF;AACD;AAEA,MAAM,cAAc,CAAC,WAAmB,OAAO,QAAQ,uBAAuB,MAAM;"}
1
+ {"version":3,"file":"ProjectGroupResolver.js","sources":["../../../../../packages/engine-http/src/projectGroup/ProjectGroupResolver.ts"],"sourcesContent":["import { CryptoWrapper } from '../utils/CryptoWrapper'\nimport { ProjectGroupContainer } from './ProjectGroupContainer'\nimport { IncomingMessage } from 'node:http'\nimport { ProjectGroupContainerResolver } from './ProjectGroupContainerResolver'\nimport { HttpErrorResponse } from '../common'\n\nexport class ProjectGroupResolver {\n\tprivate groupRegex\n\tprivate projectGroupConfigHeader\n\n\tconstructor(\n\t\tprivate projectGroupDomainMapping: string | undefined,\n\t\tprojectGroupConfigHeader: string | undefined,\n\t\tprivate projectGroupConfigCrypto: CryptoWrapper | undefined,\n\t\tprivate projectGroupContainerResolver: ProjectGroupContainerResolver,\n\t) {\n\t\tthis.projectGroupConfigHeader = projectGroupConfigHeader?.toLowerCase()\n\t\tthis.groupRegex = (\n\t\t\tthis.projectGroupDomainMapping\n\t\t\t\t? new RegExp(\n\t\t\t\t\tthis.projectGroupDomainMapping.includes('{group}')\n\t\t\t\t\t\t? regexpQuote(this.projectGroupDomainMapping).replace(regexpQuote('{group}'), '([^.]+)')\n\t\t\t\t\t\t: this.projectGroupDomainMapping,\n\t\t\t\t)\n\t\t\t\t: undefined\n\t\t)\n\t}\n\n\tasync resolveContainer({ request }: { request: IncomingMessage }): Promise<ProjectGroupContainer> {\n\t\tlet group: string | undefined = undefined\n\t\tlet config = {}\n\t\tif (this.groupRegex) {\n\t\t\tconst host = request.headers.host\n\t\t\tconst match = host?.match(this.groupRegex)\n\t\t\tif (!match) {\n\t\t\t\tthrow new HttpErrorResponse(404, 'Project group not found')\n\t\t\t}\n\t\t\tgroup = match[1]\n\t\t\tif (this.projectGroupConfigHeader) {\n\t\t\t\tconst configHeader = request.headers[this.projectGroupConfigHeader.toLowerCase()]\n\t\t\t\tif (typeof configHeader !== 'string' || configHeader === '') {\n\t\t\t\t\tthrow new HttpErrorResponse(400, `${this.projectGroupConfigHeader} header is missing`)\n\t\t\t\t}\n\t\t\t\tconst configValue = Buffer.from(configHeader, 'base64')\n\t\t\t\tconst decryptedValue = this.projectGroupConfigCrypto\n\t\t\t\t\t? (await this.projectGroupConfigCrypto?.decrypt(configValue, CryptoWrapper.cryptoVersion)).value\n\t\t\t\t\t: configValue\n\t\t\t\ttry {\n\t\t\t\t\tconfig = JSON.parse(decryptedValue.toString())\n\t\t\t\t} catch (e: any) {\n\t\t\t\t\tthrow new HttpErrorResponse(400, `Cannot parse config: ${e.message}`)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn await this.projectGroupContainerResolver.getProjectGroupContainer(group, config)\n\t}\n}\n\nconst regexpQuote = (regexp: string) => regexp.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n"],"names":[],"mappings":";;;;;AAMO,MAAM,qBAAqB;AAAA,EAIjC,YACS,2BACR,0BACQ,0BACA,+BACP;AAJO,SAAA,4BAAA;AAEA,SAAA,2BAAA;AACA,SAAA,gCA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sMiddelware.cjs","sources":["../../../../../packages/engine-http/src/prometheus/CollectHttpMetricsMiddelware.ts"],"sourcesContent":["import prom from 'prom-client'\nimport { ProjectInfoMiddlewareState } from '../project-common'\nimport { KoaMiddleware } from '../application'\nimport { ModuleInfoMiddlewareState } from '../common'\nimport { GraphQLKoaState } from '../graphql'\n\nexport const createColllectHttpMetricsMiddleware = (\n\tregistry: prom.Registry,\n): KoaMiddleware<Partial<ProjectInfoMiddlewareState & ModuleInfoMiddlewareState & GraphQLKoaState>> => {\n\tconst requestSummary = new prom.Histogram({\n\t\tname: 'contember_http_duration_seconds',\n\t\thelp: '[DEPRECATED] Incoming HTTP requests statistics by http_method (OPTIONS requests are ignored), http_code, contember_project (or \"unknown\" for undefined project), contember_project_group (or \"unknown\" for undefined project group), contember_module (system, tenant, content, unknown) and graphql_operation (query, mutation, unknown)',\n\t\tregisters: [registry],\n\t\tlabelNames: ['http_method', 'http_code', 'contember_project', 'contember_project_group', 'contember_module', 'graphql_operation'],\n\t\tbuckets: [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10],\n\t})\n\n\tconst requestSummaryMs = new prom.Histogram({\n\t\tname: 'contember_http_duration_ms',\n\t\thelp: '[DEPRECATED] Incoming HTTP requests statistics by http_method (OPTIONS requests are ignored), http_code, contember_project (or \"unknown\" for undefined project), contember_project_group (or \"unknown\" for undefined project group), contember_module (system, tenant, content, unknown) and graphql_operation (query, mutation, unknown)',\n\t\tregisters: [registry],\n\t\tlabelNames: ['http_method', 'http_code', 'contember_project', 'contember_project_group', 'contember_module', 'graphql_operation'],\n\t\tbuckets: [5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000, 10000],\n\t})\n\n\treturn async (ctx, next) => {\n\t\tconst start = Date.now()\n\t\ttry {\n\t\t\tawait next()\n\t\t} finally {\n\t\t\tconst labels = {\n\t\t\t\thttp_method: ctx.method,\n\t\t\t\thttp_code: ctx.status,\n\t\t\t\tcontember_project: ctx.state.project || 'unknown',\n\t\t\t\tcontember_project_group: ctx.state.projectGroup || 'unknown',\n\t\t\t\tcontember_module: ctx.state.module || 'unknown',\n\t\t\t\tgraphql_operation: ctx.state.graphql?.operationName || 'unknown',\n\t\t\t}\n\t\t\tif (ctx.method !== 'OPTIONS') {\n\t\t\t\trequestSummary.observe(labels, (Date.now() - start) / 1000)\n\t\t\t\trequestSummaryMs.observe(labels, Date.now() - start)\n\t\t\t}\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;AAMa,MAAA,sCAAsC,CAClD,aACsG;AAChG,QAAA,iBAAiB,IAAI,KAAK,UAAU;AAAA,IACzC,MAAM;AAAA,IACN,MAAM;AAAA,IACN,WAAW,CAAC,QAAQ;AAAA,IACpB,YAAY,CAAC,eAAe,aAAa,qBAAqB,2BAA2B,oBAAoB,mBAAmB;AAAA,IAChI,SAAS,CAAC,MAAO,MAAM,OAAO,MAAM,KAAK,MAAM,KAAK,GAAG,KAAK,GAAG,EAAE;AAAA,EAAA,CACjE;AAEK,QAAA,mBAAmB,IAAI,KAAK,UAAU;AAAA,IAC3C,MAAM;AAAA,IACN,MAAM;AAAA,IACN,WAAW,CAAC,QAAQ;AAAA,IACpB,YAAY,CAAC,eAAe,aAAa,qBAAqB,2BAA2B,oBAAoB,mBAAmB;AAAA,IAChI,SAAS,CAAC,GAAG,IAAI,IAAI,IAAI,KAAK,KAAK,KAAK,KAAM,MAAM,KAAM,GAAK;AAAA,EAAA,CAC/D;AAEM,SAAA,OAAO,KAAK,SAAS;AACrB,UAAA,QAAQ,KAAK;AACf,QAAA;AACH,YAAM,KAAK;AAAA,IAAA,UACV;AACD,YAAM,SAAS;AAAA,QACd,aAAa,IAAI;AAAA,QACjB,WAAW,IAAI;AAAA,QACf,mBAAmB,IAAI,MAAM,WAAW;AAAA,QACxC,yBAAyB,IAAI,MAAM,gBAAgB;AAAA,QACnD,kBAAkB,IAAI,MAAM,UAAU;AAAA,QACtC,mBAAmB,IAAI,MAAM,SAAS,iBAAiB;AAAA,MAAA;AAEpD,UAAA,IAAI,WAAW,WAAW;AAC7B,uBAAe,QAAQ,SAAS,KAAK,QAAQ,SAAS,GAAI;AAC1D,yBAAiB,QAAQ,QAAQ,KAAK,IAAA,IAAQ,KAAK;AAAA,MACpD;AAAA,IACD;AAAA,EAAA;AAEF;;"}
1
+ {"version":3,"file":"CollectHttpMetricsMiddelware.cjs","sources":["../../../../../packages/engine-http/src/prometheus/CollectHttpMetricsMiddelware.ts"],"sourcesContent":["import prom from 'prom-client'\nimport { ProjectInfoMiddlewareState } from '../project-common'\nimport { KoaMiddleware } from '../application'\nimport { ModuleInfoMiddlewareState } from '../common'\nimport { GraphQLKoaState } from '../graphql'\n\nexport const createColllectHttpMetricsMiddleware = (\n\tregistry: prom.Registry,\n): KoaMiddleware<Partial<ProjectInfoMiddlewareState & ModuleInfoMiddlewareState & GraphQLKoaState>> => {\n\tconst requestSummary = new prom.Histogram({\n\t\tname: 'contember_http_duration_seconds',\n\t\thelp: '[DEPRECATED] Incoming HTTP requests statistics by http_method (OPTIONS requests are ignored), http_code, contember_project (or \"unknown\" for undefined project), contember_project_group (or \"unknown\" for undefined project group), contember_module (system, tenant, content, unknown) and graphql_operation (query, mutation, unknown)',\n\t\tregisters: [registry],\n\t\tlabelNames: ['http_method', 'http_code', 'contember_project', 'contember_project_group', 'contember_module', 'graphql_operation'],\n\t\tbuckets: [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10],\n\t})\n\n\tconst requestSummaryMs = new prom.Histogram({\n\t\tname: 'contember_http_duration_ms',\n\t\thelp: '[DEPRECATED] Incoming HTTP requests statistics by http_method (OPTIONS requests are ignored), http_code, contember_project (or \"unknown\" for undefined project), contember_project_group (or \"unknown\" for undefined project group), contember_module (system, tenant, content, unknown) and graphql_operation (query, mutation, unknown)',\n\t\tregisters: [registry],\n\t\tlabelNames: ['http_method', 'http_code', 'contember_project', 'contember_project_group', 'contember_module', 'graphql_operation'],\n\t\tbuckets: [5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000, 10000],\n\t})\n\n\treturn async (ctx, next) => {\n\t\tconst start = Date.now()\n\t\ttry {\n\t\t\tawait next()\n\t\t} finally {\n\t\t\tconst labels = {\n\t\t\t\thttp_method: ctx.method,\n\t\t\t\thttp_code: ctx.status,\n\t\t\t\tcontember_project: ctx.state.project || 'unknown',\n\t\t\t\tcontember_project_group: ctx.state.projectGroup || 'unknown',\n\t\t\t\tcontember_module: ctx.state.module || 'unknown',\n\t\t\t\tgraphql_operation: ctx.state.graphql?.operationName || 'unknown',\n\t\t\t}\n\t\t\tif (ctx.method !== 'OPTIONS') {\n\t\t\t\trequestSummary.observe(labels, (Date.now() - start) / 1000)\n\t\t\t\trequestSummaryMs.observe(labels, Date.now() - start)\n\t\t\t}\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;AAMa,MAAA,sCAAsC,CAClD,aACsG;AAChG,QAAA,iBAAiB,IAAI,KAAK,UAAU;AAAA,IACzC,MAAM;AAAA,IACN,MAAM;AAAA,IACN,WAAW,CAAC,QAAQ;AAAA,IACpB,YAAY,CAAC,eAAe,aAAa,qBAAqB,2BAA2B,oBAAoB,mBAAmB;AAAA,IAChI,SAAS,CAAC,MAAO,MAAM,OAAO,MAAM,KAAK,MAAM,KAAK,GAAG,KAAK,GAAG,EAAE;AAAA,EAAA,CACjE;AAEK,QAAA,mBAAmB,IAAI,KAAK,UAAU;AAAA,IAC3C,MAAM;AAAA,IACN,MAAM;AAAA,IACN,WAAW,CAAC,QAAQ;AAAA,IACpB,YAAY,CAAC,eAAe,aAAa,qBAAqB,2BAA2B,oBAAoB,mBAAmB;AAAA,IAChI,SAAS,CAAC,GAAG,IAAI,IAAI,IAAI,KAAK,KAAK,KAAK,KAAM,MAAM,KAAM,GAAK;AAAA,EAAA,CAC/D;AAEM,SAAA,OAAO,KAAK,SAAS;AACrB,UAAA,QAAQ,KAAK,IAAI;AACnB,QAAA;AACH,YAAM,KAAK;AAAA,IAAA,UACV;AACD,YAAM,SAAS;AAAA,QACd,aAAa,IAAI;AAAA,QACjB,WAAW,IAAI;AAAA,QACf,mBAAmB,IAAI,MAAM,WAAW;AAAA,QACxC,yBAAyB,IAAI,MAAM,gBAAgB;AAAA,QACnD,kBAAkB,IAAI,MAAM,UAAU;AAAA,QACtC,mBAAmB,IAAI,MAAM,SAAS,iBAAiB;AAAA,MACxD;AACI,UAAA,IAAI,WAAW,WAAW;AAC7B,uBAAe,QAAQ,SAAS,KAAK,IAAI,IAAI,SAAS,GAAI;AAC1D,yBAAiB,QAAQ,QAAQ,KAAK,IAAA,IAAQ,KAAK;AAAA,MAAA;AAAA,IACpD;AAAA,EAEF;AACD;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"CollectHttpMetricsMiddelware.js","sources":["../../../../../packages/engine-http/src/prometheus/CollectHttpMetricsMiddelware.ts"],"sourcesContent":["import prom from 'prom-client'\nimport { ProjectInfoMiddlewareState } from '../project-common'\nimport { KoaMiddleware } from '../application'\nimport { ModuleInfoMiddlewareState } from '../common'\nimport { GraphQLKoaState } from '../graphql'\n\nexport const createColllectHttpMetricsMiddleware = (\n\tregistry: prom.Registry,\n): KoaMiddleware<Partial<ProjectInfoMiddlewareState & ModuleInfoMiddlewareState & GraphQLKoaState>> => {\n\tconst requestSummary = new prom.Histogram({\n\t\tname: 'contember_http_duration_seconds',\n\t\thelp: '[DEPRECATED] Incoming HTTP requests statistics by http_method (OPTIONS requests are ignored), http_code, contember_project (or \"unknown\" for undefined project), contember_project_group (or \"unknown\" for undefined project group), contember_module (system, tenant, content, unknown) and graphql_operation (query, mutation, unknown)',\n\t\tregisters: [registry],\n\t\tlabelNames: ['http_method', 'http_code', 'contember_project', 'contember_project_group', 'contember_module', 'graphql_operation'],\n\t\tbuckets: [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10],\n\t})\n\n\tconst requestSummaryMs = new prom.Histogram({\n\t\tname: 'contember_http_duration_ms',\n\t\thelp: '[DEPRECATED] Incoming HTTP requests statistics by http_method (OPTIONS requests are ignored), http_code, contember_project (or \"unknown\" for undefined project), contember_project_group (or \"unknown\" for undefined project group), contember_module (system, tenant, content, unknown) and graphql_operation (query, mutation, unknown)',\n\t\tregisters: [registry],\n\t\tlabelNames: ['http_method', 'http_code', 'contember_project', 'contember_project_group', 'contember_module', 'graphql_operation'],\n\t\tbuckets: [5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000, 10000],\n\t})\n\n\treturn async (ctx, next) => {\n\t\tconst start = Date.now()\n\t\ttry {\n\t\t\tawait next()\n\t\t} finally {\n\t\t\tconst labels = {\n\t\t\t\thttp_method: ctx.method,\n\t\t\t\thttp_code: ctx.status,\n\t\t\t\tcontember_project: ctx.state.project || 'unknown',\n\t\t\t\tcontember_project_group: ctx.state.projectGroup || 'unknown',\n\t\t\t\tcontember_module: ctx.state.module || 'unknown',\n\t\t\t\tgraphql_operation: ctx.state.graphql?.operationName || 'unknown',\n\t\t\t}\n\t\t\tif (ctx.method !== 'OPTIONS') {\n\t\t\t\trequestSummary.observe(labels, (Date.now() - start) / 1000)\n\t\t\t\trequestSummaryMs.observe(labels, Date.now() - start)\n\t\t\t}\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";AAMa,MAAA,sCAAsC,CAClD,aACsG;AAChG,QAAA,iBAAiB,IAAI,KAAK,UAAU;AAAA,IACzC,MAAM;AAAA,IACN,MAAM;AAAA,IACN,WAAW,CAAC,QAAQ;AAAA,IACpB,YAAY,CAAC,eAAe,aAAa,qBAAqB,2BAA2B,oBAAoB,mBAAmB;AAAA,IAChI,SAAS,CAAC,MAAO,MAAM,OAAO,MAAM,KAAK,MAAM,KAAK,GAAG,KAAK,GAAG,EAAE;AAAA,EAAA,CACjE;AAEK,QAAA,mBAAmB,IAAI,KAAK,UAAU;AAAA,IAC3C,MAAM;AAAA,IACN,MAAM;AAAA,IACN,WAAW,CAAC,QAAQ;AAAA,IACpB,YAAY,CAAC,eAAe,aAAa,qBAAqB,2BAA2B,oBAAoB,mBAAmB;AAAA,IAChI,SAAS,CAAC,GAAG,IAAI,IAAI,IAAI,KAAK,KAAK,KAAK,KAAM,MAAM,KAAM,GAAK;AAAA,EAAA,CAC/D;AAEM,SAAA,OAAO,KAAK,SAAS;AACrB,UAAA,QAAQ,KAAK;AACf,QAAA;AACH,YAAM,KAAK;AAAA,IAAA,UACV;AACD,YAAM,SAAS;AAAA,QACd,aAAa,IAAI;AAAA,QACjB,WAAW,IAAI;AAAA,QACf,mBAAmB,IAAI,MAAM,WAAW;AAAA,QACxC,yBAAyB,IAAI,MAAM,gBAAgB;AAAA,QACnD,kBAAkB,IAAI,MAAM,UAAU;AAAA,QACtC,mBAAmB,IAAI,MAAM,SAAS,iBAAiB;AAAA,MAAA;AAEpD,UAAA,IAAI,WAAW,WAAW;AAC7B,uBAAe,QAAQ,SAAS,KAAK,QAAQ,SAAS,GAAI;AAC1D,yBAAiB,QAAQ,QAAQ,KAAK,IAAA,IAAQ,KAAK;AAAA,MACpD;AAAA,IACD;AAAA,EAAA;AAEF;"}
1
+ {"version":3,"file":"CollectHttpMetricsMiddelware.js","sources":["../../../../../packages/engine-http/src/prometheus/CollectHttpMetricsMiddelware.ts"],"sourcesContent":["import prom from 'prom-client'\nimport { ProjectInfoMiddlewareState } from '../project-common'\nimport { KoaMiddleware } from '../application'\nimport { ModuleInfoMiddlewareState } from '../common'\nimport { GraphQLKoaState } from '../graphql'\n\nexport const createColllectHttpMetricsMiddleware = (\n\tregistry: prom.Registry,\n): KoaMiddleware<Partial<ProjectInfoMiddlewareState & ModuleInfoMiddlewareState & GraphQLKoaState>> => {\n\tconst requestSummary = new prom.Histogram({\n\t\tname: 'contember_http_duration_seconds',\n\t\thelp: '[DEPRECATED] Incoming HTTP requests statistics by http_method (OPTIONS requests are ignored), http_code, contember_project (or \"unknown\" for undefined project), contember_project_group (or \"unknown\" for undefined project group), contember_module (system, tenant, content, unknown) and graphql_operation (query, mutation, unknown)',\n\t\tregisters: [registry],\n\t\tlabelNames: ['http_method', 'http_code', 'contember_project', 'contember_project_group', 'contember_module', 'graphql_operation'],\n\t\tbuckets: [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10],\n\t})\n\n\tconst requestSummaryMs = new prom.Histogram({\n\t\tname: 'contember_http_duration_ms',\n\t\thelp: '[DEPRECATED] Incoming HTTP requests statistics by http_method (OPTIONS requests are ignored), http_code, contember_project (or \"unknown\" for undefined project), contember_project_group (or \"unknown\" for undefined project group), contember_module (system, tenant, content, unknown) and graphql_operation (query, mutation, unknown)',\n\t\tregisters: [registry],\n\t\tlabelNames: ['http_method', 'http_code', 'contember_project', 'contember_project_group', 'contember_module', 'graphql_operation'],\n\t\tbuckets: [5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000, 10000],\n\t})\n\n\treturn async (ctx, next) => {\n\t\tconst start = Date.now()\n\t\ttry {\n\t\t\tawait next()\n\t\t} finally {\n\t\t\tconst labels = {\n\t\t\t\thttp_method: ctx.method,\n\t\t\t\thttp_code: ctx.status,\n\t\t\t\tcontember_project: ctx.state.project || 'unknown',\n\t\t\t\tcontember_project_group: ctx.state.projectGroup || 'unknown',\n\t\t\t\tcontember_module: ctx.state.module || 'unknown',\n\t\t\t\tgraphql_operation: ctx.state.graphql?.operationName || 'unknown',\n\t\t\t}\n\t\t\tif (ctx.method !== 'OPTIONS') {\n\t\t\t\trequestSummary.observe(labels, (Date.now() - start) / 1000)\n\t\t\t\trequestSummaryMs.observe(labels, Date.now() - start)\n\t\t\t}\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";AAMa,MAAA,sCAAsC,CAClD,aACsG;AAChG,QAAA,iBAAiB,IAAI,KAAK,UAAU;AAAA,IACzC,MAAM;AAAA,IACN,MAAM;AAAA,IACN,WAAW,CAAC,QAAQ;AAAA,IACpB,YAAY,CAAC,eAAe,aAAa,qBAAqB,2BAA2B,oBAAoB,mBAAmB;AAAA,IAChI,SAAS,CAAC,MAAO,MAAM,OAAO,MAAM,KAAK,MAAM,KAAK,GAAG,KAAK,GAAG,EAAE;AAAA,EAAA,CACjE;AAEK,QAAA,mBAAmB,IAAI,KAAK,UAAU;AAAA,IAC3C,MAAM;AAAA,IACN,MAAM;AAAA,IACN,WAAW,CAAC,QAAQ;AAAA,IACpB,YAAY,CAAC,eAAe,aAAa,qBAAqB,2BAA2B,oBAAoB,mBAAmB;AAAA,IAChI,SAAS,CAAC,GAAG,IAAI,IAAI,IAAI,KAAK,KAAK,KAAK,KAAM,MAAM,KAAM,GAAK;AAAA,EAAA,CAC/D;AAEM,SAAA,OAAO,KAAK,SAAS;AACrB,UAAA,QAAQ,KAAK,IAAI;AACnB,QAAA;AACH,YAAM,KAAK;AAAA,IAAA,UACV;AACD,YAAM,SAAS;AAAA,QACd,aAAa,IAAI;AAAA,QACjB,WAAW,IAAI;AAAA,QACf,mBAAmB,IAAI,MAAM,WAAW;AAAA,QACxC,yBAAyB,IAAI,MAAM,gBAAgB;AAAA,QACnD,kBAAkB,IAAI,MAAM,UAAU;AAAA,QACtC,mBAAmB,IAAI,MAAM,SAAS,iBAAiB;AAAA,MACxD;AACI,UAAA,IAAI,WAAW,WAAW;AAC7B,uBAAe,QAAQ,SAAS,KAAK,IAAI,IAAI,SAAS,GAAI;AAC1D,yBAAiB,QAAQ,QAAQ,KAAK,IAAA,IAAQ,KAAK;AAAA,MAAA;AAAA,IACpD;AAAA,EAEF;AACD;"}
@@ -1 +1 @@
1
- {"version":3,"file":"CustomMetric.cjs","sources":["../../../../../packages/engine-http/src/prometheus/CustomMetric.ts"],"sourcesContent":["type LabelValues<T extends string> = Partial<Record<T, string | number>>\n\nexport class CustomMetric<T extends string> {\n\tprivate values: { labels: LabelValues<T>; value: number }[] = []\n\n\tconstructor(private readonly options: {\n\t\tname: string\n\t\thelp: string\n\t\ttype: string\n\t\tlabelNames: T[]\n\t}) {\n\t}\n\n\treset() {\n\t\tthis.values = []\n\t}\n\n\tadd(labels: LabelValues<T>, value: number) {\n\t\tthis.values.push({ labels, value })\n\t}\n\n\tget name() {\n\t\treturn this.options.name\n\t}\n\n\tget() {\n\t\treturn {\n\t\t\thelp: this.options.help,\n\t\t\tname: this.options.name,\n\t\t\ttype: this.options.type,\n\t\t\tvalues: this.values,\n\t\t\taggregator: 'sum',\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;;AAEO,MAAM,aAA+B;AAAA,EAG3C,YAA6B,SAK1B;AAL0B,SAAA,UAAA;AAF7B,kBAAA,MAAQ,UAAsD,CAAA,CAAC;AAAA,EAQ/D;AAAA,EAEA,QAAQ;AACP,SAAK,SAAS;EACf;AAAA,EAEA,IAAI,QAAwB,OAAe;AAC1C,SAAK,OAAO,KAAK,EAAE,QAAQ,MAAO,CAAA;AAAA,EACnC;AAAA,EAEA,IAAI,OAAO;AACV,WAAO,KAAK,QAAQ;AAAA,EACrB;AAAA,EAEA,MAAM;AACE,WAAA;AAAA,MACN,MAAM,KAAK,QAAQ;AAAA,MACnB,MAAM,KAAK,QAAQ;AAAA,MACnB,MAAM,KAAK,QAAQ;AAAA,MACnB,QAAQ,KAAK;AAAA,MACb,YAAY;AAAA,IAAA;AAAA,EAEd;AACD;;"}
1
+ {"version":3,"file":"CustomMetric.cjs","sources":["../../../../../packages/engine-http/src/prometheus/CustomMetric.ts"],"sourcesContent":["type LabelValues<T extends string> = Partial<Record<T, string | number>>\n\nexport class CustomMetric<T extends string> {\n\tprivate values: { labels: LabelValues<T>; value: number }[] = []\n\n\tconstructor(private readonly options: {\n\t\tname: string\n\t\thelp: string\n\t\ttype: string\n\t\tlabelNames: T[]\n\t}) {\n\t}\n\n\treset() {\n\t\tthis.values = []\n\t}\n\n\tadd(labels: LabelValues<T>, value: number) {\n\t\tthis.values.push({ labels, value })\n\t}\n\n\tget name() {\n\t\treturn this.options.name\n\t}\n\n\tget() {\n\t\treturn {\n\t\t\thelp: this.options.help,\n\t\t\tname: this.options.name,\n\t\t\ttype: this.options.type,\n\t\t\tvalues: this.values,\n\t\t\taggregator: 'sum',\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;;AAEO,MAAM,aAA+B;AAAA,EAG3C,YAA6B,SAK1B;AAL0B,SAAA,UAAA;AAF7B,kBAAA,MAAQ,UAAsD,EAAC;AAAA,EAAA;AAAA,EAU/D,QAAQ;AACP,SAAK,SAAS,CAAC;AAAA,EAAA;AAAA,EAGhB,IAAI,QAAwB,OAAe;AAC1C,SAAK,OAAO,KAAK,EAAE,QAAQ,OAAO;AAAA,EAAA;AAAA,EAGnC,IAAI,OAAO;AACV,WAAO,KAAK,QAAQ;AAAA,EAAA;AAAA,EAGrB,MAAM;AACE,WAAA;AAAA,MACN,MAAM,KAAK,QAAQ;AAAA,MACnB,MAAM,KAAK,QAAQ;AAAA,MACnB,MAAM,KAAK,QAAQ;AAAA,MACnB,QAAQ,KAAK;AAAA,MACb,YAAY;AAAA,IACb;AAAA,EAAA;AAEF;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"CustomMetric.js","sources":["../../../../../packages/engine-http/src/prometheus/CustomMetric.ts"],"sourcesContent":["type LabelValues<T extends string> = Partial<Record<T, string | number>>\n\nexport class CustomMetric<T extends string> {\n\tprivate values: { labels: LabelValues<T>; value: number }[] = []\n\n\tconstructor(private readonly options: {\n\t\tname: string\n\t\thelp: string\n\t\ttype: string\n\t\tlabelNames: T[]\n\t}) {\n\t}\n\n\treset() {\n\t\tthis.values = []\n\t}\n\n\tadd(labels: LabelValues<T>, value: number) {\n\t\tthis.values.push({ labels, value })\n\t}\n\n\tget name() {\n\t\treturn this.options.name\n\t}\n\n\tget() {\n\t\treturn {\n\t\t\thelp: this.options.help,\n\t\t\tname: this.options.name,\n\t\t\ttype: this.options.type,\n\t\t\tvalues: this.values,\n\t\t\taggregator: 'sum',\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;AAEO,MAAM,aAA+B;AAAA,EAG3C,YAA6B,SAK1B;AAL0B,SAAA,UAAA;AAF7B,kBAAA,MAAQ,UAAsD,CAAA,CAAC;AAAA,EAQ/D;AAAA,EAEA,QAAQ;AACP,SAAK,SAAS;EACf;AAAA,EAEA,IAAI,QAAwB,OAAe;AAC1C,SAAK,OAAO,KAAK,EAAE,QAAQ,MAAO,CAAA;AAAA,EACnC;AAAA,EAEA,IAAI,OAAO;AACV,WAAO,KAAK,QAAQ;AAAA,EACrB;AAAA,EAEA,MAAM;AACE,WAAA;AAAA,MACN,MAAM,KAAK,QAAQ;AAAA,MACnB,MAAM,KAAK,QAAQ;AAAA,MACnB,MAAM,KAAK,QAAQ;AAAA,MACnB,QAAQ,KAAK;AAAA,MACb,YAAY;AAAA,IAAA;AAAA,EAEd;AACD;"}
1
+ {"version":3,"file":"CustomMetric.js","sources":["../../../../../packages/engine-http/src/prometheus/CustomMetric.ts"],"sourcesContent":["type LabelValues<T extends string> = Partial<Record<T, string | number>>\n\nexport class CustomMetric<T extends string> {\n\tprivate values: { labels: LabelValues<T>; value: number }[] = []\n\n\tconstructor(private readonly options: {\n\t\tname: string\n\t\thelp: string\n\t\ttype: string\n\t\tlabelNames: T[]\n\t}) {\n\t}\n\n\treset() {\n\t\tthis.values = []\n\t}\n\n\tadd(labels: LabelValues<T>, value: number) {\n\t\tthis.values.push({ labels, value })\n\t}\n\n\tget name() {\n\t\treturn this.options.name\n\t}\n\n\tget() {\n\t\treturn {\n\t\t\thelp: this.options.help,\n\t\t\tname: this.options.name,\n\t\t\ttype: this.options.type,\n\t\t\tvalues: this.values,\n\t\t\taggregator: 'sum',\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;AAEO,MAAM,aAA+B;AAAA,EAG3C,YAA6B,SAK1B;AAL0B,SAAA,UAAA;AAF7B,kBAAA,MAAQ,UAAsD,EAAC;AAAA,EAAA;AAAA,EAU/D,QAAQ;AACP,SAAK,SAAS,CAAC;AAAA,EAAA;AAAA,EAGhB,IAAI,QAAwB,OAAe;AAC1C,SAAK,OAAO,KAAK,EAAE,QAAQ,OAAO;AAAA,EAAA;AAAA,EAGnC,IAAI,OAAO;AACV,WAAO,KAAK,QAAQ;AAAA,EAAA;AAAA,EAGrB,MAAM;AACE,WAAA;AAAA,MACN,MAAM,KAAK,QAAQ;AAAA,MACnB,MAAM,KAAK,QAAQ;AAAA,MACnB,MAAM,KAAK,QAAQ;AAAA,MACnB,QAAQ,KAAK;AAAA,MACb,YAAY;AAAA,IACb;AAAA,EAAA;AAEF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ProjectGroupContainerMetricsHook.cjs","sources":["../../../../../packages/engine-http/src/prometheus/ProjectGroupContainerMetricsHook.ts"],"sourcesContent":["import { Registry } from 'prom-client'\nimport { ProjectGroupContainerResolver } from '../projectGroup/ProjectGroupContainerResolver'\nimport { createDbMetricsRegistrar } from './dbMetrics'\n\nexport class ProjectGroupContainerMetricsHook {\n\tconstructor(\n\t\tprivate containerResolver: ProjectGroupContainerResolver,\n\t) {\n\t}\n\n\tpublic register(promRegistry: Registry) {\n\t\tconst registrar = createDbMetricsRegistrar(promRegistry)\n\t\tthis.containerResolver.on('create', ({ container: groupContainer, slug }) => {\n\t\t\tgroupContainer.projectContainerResolver.on('create', ({ container: projectContainer }) => {\n\t\t\t\tconst primaryConnection = projectContainer.connection\n\t\t\t\tconst readConnection = projectContainer.readConnection\n\t\t\t\tconst hasDifferentReadConnection = primaryConnection !== readConnection\n\t\t\t\tconst unregister: (() => void)[] = []\n\t\t\t\tunregister.push(registrar({\n\t\t\t\t\tconnection: primaryConnection,\n\t\t\t\t\tlabels: {\n\t\t\t\t\t\tcontember_module: 'content',\n\t\t\t\t\t\tcontember_project: projectContainer.project.slug,\n\t\t\t\t\t\tcontember_project_group: slug ?? 'unknown',\n\t\t\t\t\t\tdatabase_instance: hasDifferentReadConnection ? 'primary' : 'single',\n\t\t\t\t\t},\n\t\t\t\t}))\n\t\t\t\tif (hasDifferentReadConnection) {\n\t\t\t\t\tunregister.push(registrar({\n\t\t\t\t\t\tconnection: readConnection,\n\t\t\t\t\t\tlabels: {\n\t\t\t\t\t\t\tcontember_module: 'content',\n\t\t\t\t\t\t\tcontember_project: projectContainer.project.slug,\n\t\t\t\t\t\t\tcontember_project_group: slug ?? 'unknown',\n\t\t\t\t\t\t\tdatabase_instance: 'replica',\n\t\t\t\t\t\t},\n\t\t\t\t\t}))\n\t\t\t\t}\n\t\t\t\treturn () => unregister.forEach(it => it())\n\t\t\t})\n\n\n\t\t\tconst primaryConnection = groupContainer.tenantContainer.connection\n\t\t\tconst readConnection = groupContainer.tenantContainer.readConnection\n\t\t\tconst hasDifferentReadConnection = primaryConnection !== readConnection\n\t\t\tconst unregister: (() => void)[] = []\n\t\t\tunregister.push(registrar({\n\t\t\t\tconnection: primaryConnection,\n\t\t\t\tlabels: {\n\t\t\t\t\tcontember_module: 'tenant',\n\t\t\t\t\tcontember_project_group: slug ?? 'unknown',\n\t\t\t\t\tcontember_project: 'unknown',\n\t\t\t\t\tdatabase_instance: hasDifferentReadConnection ? 'primary' : 'single',\n\t\t\t\t},\n\t\t\t}))\n\t\t\tif (hasDifferentReadConnection) {\n\t\t\t\tunregister.push(registrar({\n\t\t\t\t\tconnection: readConnection,\n\t\t\t\t\tlabels: {\n\t\t\t\t\t\tcontember_module: 'tenant',\n\t\t\t\t\t\tcontember_project_group: slug ?? 'unknown',\n\t\t\t\t\t\tcontember_project: 'unknown',\n\t\t\t\t\t\tdatabase_instance: 'replica',\n\t\t\t\t\t},\n\t\t\t\t}))\n\t\t\t}\n\n\t\t\treturn () => unregister.forEach(it => it())\n\t\t})\n\t}\n}\n"],"names":["createDbMetricsRegistrar","primaryConnection","readConnection","hasDifferentReadConnection","unregister"],"mappings":";;;AAIO,MAAM,iCAAiC;AAAA,EAC7C,YACS,mBACP;AADO,SAAA,oBAAA;AAAA,EAET;AAAA,EAEO,SAAS,cAAwB;AACjC,UAAA,YAAYA,mCAAyB,YAAY;AAClD,SAAA,kBAAkB,GAAG,UAAU,CAAC,EAAE,WAAW,gBAAgB,WAAW;AAC5E,qBAAe,yBAAy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ACH;AAEA,aAAO,MAAM,WAAW,QAAQ,CAAA,OAAM,GAAI,CAAA;AAAA,IAAA,CAC1C;AAAA,EACF;AACD;;"}
1
+ {"version":3,"file":"ProjectGroupContainerMetricsHook.cjs","sources":["../../../../../packages/engine-http/src/prometheus/ProjectGroupContainerMetricsHook.ts"],"sourcesContent":["import { Registry } from 'prom-client'\nimport { ProjectGroupContainerResolver } from '../projectGroup/ProjectGroupContainerResolver'\nimport { createDbMetricsRegistrar } from './dbMetrics'\n\nexport class ProjectGroupContainerMetricsHook {\n\tconstructor(\n\t\tprivate containerResolver: ProjectGroupContainerResolver,\n\t) {\n\t}\n\n\tpublic register(promRegistry: Registry) {\n\t\tconst registrar = createDbMetricsRegistrar(promRegistry)\n\t\tthis.containerResolver.on('create', ({ container: groupContainer, slug }) => {\n\t\t\tgroupContainer.projectContainerResolver.on('create', ({ container: projectContainer }) => {\n\t\t\t\tconst primaryConnection = projectContainer.connection\n\t\t\t\tconst readConnection = projectContainer.readConnection\n\t\t\t\tconst hasDifferentReadConnection = primaryConnection !== readConnection\n\t\t\t\tconst unregister: (() => void)[] = []\n\t\t\t\tunregister.push(registrar({\n\t\t\t\t\tconnection: primaryConnection,\n\t\t\t\t\tlabels: {\n\t\t\t\t\t\tcontember_module: 'content',\n\t\t\t\t\t\tcontember_project: projectContainer.project.slug,\n\t\t\t\t\t\tcontember_project_group: slug ?? 'unknown',\n\t\t\t\t\t\tdatabase_instance: hasDifferentReadConnection ? 'primary' : 'single',\n\t\t\t\t\t},\n\t\t\t\t}))\n\t\t\t\tif (hasDifferentReadConnection) {\n\t\t\t\t\tunregister.push(registrar({\n\t\t\t\t\t\tconnection: readConnection,\n\t\t\t\t\t\tlabels: {\n\t\t\t\t\t\t\tcontember_module: 'content',\n\t\t\t\t\t\t\tcontember_project: projectContainer.project.slug,\n\t\t\t\t\t\t\tcontember_project_group: slug ?? 'unknown',\n\t\t\t\t\t\t\tdatabase_instance: 'replica',\n\t\t\t\t\t\t},\n\t\t\t\t\t}))\n\t\t\t\t}\n\t\t\t\treturn () => unregister.forEach(it => it())\n\t\t\t})\n\n\n\t\t\tconst primaryConnection = groupContainer.tenantContainer.connection\n\t\t\tconst readConnection = groupContainer.tenantContainer.readConnection\n\t\t\tconst hasDifferentReadConnection = primaryConnection !== readConnection\n\t\t\tconst unregister: (() => void)[] = []\n\t\t\tunregister.push(registrar({\n\t\t\t\tconnection: primaryConnection,\n\t\t\t\tlabels: {\n\t\t\t\t\tcontember_module: 'tenant',\n\t\t\t\t\tcontember_project_group: slug ?? 'unknown',\n\t\t\t\t\tcontember_project: 'unknown',\n\t\t\t\t\tdatabase_instance: hasDifferentReadConnection ? 'primary' : 'single',\n\t\t\t\t},\n\t\t\t}))\n\t\t\tif (hasDifferentReadConnection) {\n\t\t\t\tunregister.push(registrar({\n\t\t\t\t\tconnection: readConnection,\n\t\t\t\t\tlabels: {\n\t\t\t\t\t\tcontember_module: 'tenant',\n\t\t\t\t\t\tcontember_project_group: slug ?? 'unknown',\n\t\t\t\t\t\tcontember_project: 'unknown',\n\t\t\t\t\t\tdatabase_instance: 'replica',\n\t\t\t\t\t},\n\t\t\t\t}))\n\t\t\t}\n\n\t\t\treturn () => unregister.forEach(it => it())\n\t\t})\n\t}\n}\n"],"names":["createDbMetricsRegistrar","primaryConnection","readConnection","hasDifferentReadConnection","unregister"],"mappings":";;;AAIO,MAAM,iCAAiC;AAAA,EAC7C,YACS,mBACP;AADO,SAAA,oBAAA;AAAA,EAAA;AAAA,EAIF,SAAS,cAAwB;AACjC,UAAA,YAAYA,mCAAyB,YAAY;AAClD,SAAA,kBAAkB,GAAG,UAAU,CAAC,EAAE,WAAW,gBAAgB,WAAW;AAC5E,qBAAe,yBAAyB,GAAG,UAAU,CAAC,EAAE,WAAW,uBAAuB;AACzF,cAAMC,qBAAoB,iBAAiB;AAC3C,cAAMC,kBAAiB,iBAAiB;AACxC,cAAMC,8BAA6BF,uBAAsBC;AACzD,cAAME,cAA6B,CAAC;AACpCA,o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prometheus/ProjectGroupContainerMetricsHook.ts"],"sourcesContent":["import { Registry } from 'prom-client'\nimport { ProjectGroupContainerResolver } from '../projectGroup/ProjectGroupContainerResolver'\nimport { createDbMetricsRegistrar } from './dbMetrics'\n\nexport class ProjectGroupContainerMetricsHook {\n\tconstructor(\n\t\tprivate containerResolver: ProjectGroupContainerResolver,\n\t) {\n\t}\n\n\tpublic register(promRegistry: Registry) {\n\t\tconst registrar = createDbMetricsRegistrar(promRegistry)\n\t\tthis.containerResolver.on('create', ({ container: groupContainer, slug }) => {\n\t\t\tgroupContainer.projectContainerResolver.on('create', ({ container: projectContainer }) => {\n\t\t\t\tconst primaryConnection = projectContainer.connection\n\t\t\t\tconst readConnection = projectContainer.readConnection\n\t\t\t\tconst hasDifferentReadConnection = primaryConnection !== readConnection\n\t\t\t\tconst unregister: (() => void)[] = []\n\t\t\t\tunregister.push(registrar({\n\t\t\t\t\tconnection: primaryConnection,\n\t\t\t\t\tlabels: {\n\t\t\t\t\t\tcontember_module: 'content',\n\t\t\t\t\t\tcontember_project: projectContainer.project.slug,\n\t\t\t\t\t\tcontember_project_group: slug ?? 'unknown',\n\t\t\t\t\t\tdatabase_instance: hasDifferentReadConnection ? 'primary' : 'single',\n\t\t\t\t\t},\n\t\t\t\t}))\n\t\t\t\tif (hasDifferentReadConnection) {\n\t\t\t\t\tunregister.push(registrar({\n\t\t\t\t\t\tconnection: readConnection,\n\t\t\t\t\t\tlabels: {\n\t\t\t\t\t\t\tcontember_module: 'content',\n\t\t\t\t\t\t\tcontember_project: projectContainer.project.slug,\n\t\t\t\t\t\t\tcontember_project_group: slug ?? 'unknown',\n\t\t\t\t\t\t\tdatabase_instance: 'replica',\n\t\t\t\t\t\t},\n\t\t\t\t\t}))\n\t\t\t\t}\n\t\t\t\treturn () => unregister.forEach(it => it())\n\t\t\t})\n\n\n\t\t\tconst primaryConnection = groupContainer.tenantContainer.connection\n\t\t\tconst readConnection = groupContainer.tenantContainer.readConnection\n\t\t\tconst hasDifferentReadConnection = primaryConnection !== readConnection\n\t\t\tconst unregister: (() => void)[] = []\n\t\t\tunregister.push(registrar({\n\t\t\t\tconnection: primaryConnection,\n\t\t\t\tlabels: {\n\t\t\t\t\tcontember_module: 'tenant',\n\t\t\t\t\tcontember_project_group: slug ?? 'unknown',\n\t\t\t\t\tcontember_project: 'unknown',\n\t\t\t\t\tdatabase_instance: hasDifferentReadConnection ? 'primary' : 'single',\n\t\t\t\t},\n\t\t\t}))\n\t\t\tif (hasDifferentReadConnection) {\n\t\t\t\tunregister.push(registrar({\n\t\t\t\t\tconnection: readConnection,\n\t\t\t\t\tlabels: {\n\t\t\t\t\t\tcontember_module: 'tenant',\n\t\t\t\t\t\tcontember_project_group: slug ?? 'unknown',\n\t\t\t\t\t\tcontember_project: 'unknown',\n\t\t\t\t\t\tdatabase_instance: 'replica',\n\t\t\t\t\t},\n\t\t\t\t}))\n\t\t\t}\n\n\t\t\treturn () => unregister.forEach(it => it())\n\t\t})\n\t}\n}\n"],"names":["primaryConnection","readConnection","hasDifferentReadConnection","unregister"],"mappings":";AAIO,MAAM,iCAAiC;AAAA,EAC7C,YACS,mBACP;AADO,SAAA,oBAAA;AAAA,EAET;AAAA,EAEO,SAAS,cAAwB;AACjC,UAAA,YAAY,yBAAyB,YAAY;AAClD,SAAA,kBAAkB,GAAG,UAAU,CAAC,EAAE,WAAW,gBAAgB,WAAW;AAC5E,qBAAe,yBAAyB,GAAG,UAAU,CAAC,EAAE,WAAW,uBAAuB;AACzF,cAAMA,qBAAoB,iBAAiB;AAC3C,cAAMC,kBAAiB,iBAAiB;AACxC,cAAMC,8BAA6BF,uBAAsBC;AACzD,cAAME,cAA6B,CAAA;AACnCA,oBAAW,KAAK,UAAU;AAAA,UACzB,YAAYH;AAAAA,UACZ,QAAQ;AAAA,YACP,kBAAkB;AAAA,YAClB,mBAAmB,iBAAiB,QAAQ;AAAA,YAC5C,yBAAyB,QAAQ;AAAA,YACjC,mBAAmBE,8BAA6B,YAAY;AAAA,UAC7D;AAAA,QACA,CAAA,CAAC;AACF,YAAIA,6BAA4B;AAC/BC,sBAAW,KAAK,UAAU;AAAA,YACzB,YAAYF;AAAAA,YACZ,QAAQ;AAAA,cACP,kBAAkB;AAAA,cAClB,mBAAmB,iBAAiB,QAAQ;AAAA,cAC5C,yBAAyB,QAAQ;AAAA,cACjC,mBAAmB;AAAA,YACpB;AAAA,UACA,CAAA,CAAC;AAAA,QACH;AACA,eAAO,MAAME,YAAW,QAAQ,CAAA,OAAM,GAAI,CAAA;AAAA,MAAA,CAC1C;AAGK,YAAA,oBAAoB,eAAe,gBAAgB;AACnD,YAAA,iBAAiB,eAAe,gBAAgB;AACtD,YAAM,6BAA6B,sBAAsB;AACzD,YAAM,aAA6B,CAAA;AACnC,iBAAW,KAAK,UAAU;AAAA,QACzB,YAAY;AAAA,QACZ,QAAQ;AAAA,UACP,kBAAkB;AAAA,UAClB,yBAAyB,QAAQ;AAAA,UACjC,mBAAmB;AAAA,UACnB,mBAAmB,6BAA6B,YAAY;AAAA,QAC7D;AAAA,MACA,CAAA,CAAC;AACF,UAAI,4BAA4B;AAC/B,mBAAW,KAAK,UAAU;AAAA,UACzB,YAAY;AAAA,UACZ,QAAQ;AAAA,YACP,kBAAkB;AAAA,YAClB,yBAAyB,QAAQ;AAAA,YACjC,mBAAmB;AAAA,YACnB,mBAAmB;AAAA,UACpB;AAAA,QACA,CAAA,CAAC;AAAA,MACH;AAEA,aAAO,MAAM,WAAW,QAAQ,CAAA,OAAM,GAAI,CAAA;AAAA,IAAA,CAC1C;AAAA,EACF;AACD;"}
1
+ {"version":3,"file":"ProjectGroupContainerMetricsHook.js","sources":["../../../../../packages/engine-http/src/prometheus/ProjectGroupContainerMetricsHook.ts"],"sourcesContent":["import { Registry } from 'prom-client'\nimport { ProjectGroupContainerResolver } from '../projectGroup/ProjectGroupContainerResolver'\nimport { createDbMetricsRegistrar } from './dbMetrics'\n\nexport class ProjectGroupContainerMetricsHook {\n\tconstructor(\n\t\tprivate containerResolver: ProjectGroupContainerResolver,\n\t) {\n\t}\n\n\tpublic register(promRegistry: Registry) {\n\t\tconst registrar = createDbMetricsRegistrar(promRegistry)\n\t\tthis.containerResolver.on('create', ({ container: groupContainer, slug }) => {\n\t\t\tgroupContainer.projectContainerResolver.on('create', ({ container: projectContainer }) => {\n\t\t\t\tconst primaryConnection = projectContainer.connection\n\t\t\t\tconst readConnection = projectContainer.readConnection\n\t\t\t\tconst hasDifferentReadConnection = primaryConnection !== readConnection\n\t\t\t\tconst unregister: (() => void)[] = []\n\t\t\t\tunregister.push(registrar({\n\t\t\t\t\tconnection: primaryConnection,\n\t\t\t\t\tlabels: {\n\t\t\t\t\t\tcontember_module: 'content',\n\t\t\t\t\t\tcontember_project: projectContainer.project.slug,\n\t\t\t\t\t\tcontember_project_group: slug ?? 'unknown',\n\t\t\t\t\t\tdatabase_instance: hasDifferentReadConnection ? 'primary' : 'single',\n\t\t\t\t\t},\n\t\t\t\t}))\n\t\t\t\tif (hasDifferentReadConnection) {\n\t\t\t\t\tunregister.push(registrar({\n\t\t\t\t\t\tconnection: readConnection,\n\t\t\t\t\t\tlabels: {\n\t\t\t\t\t\t\tcontember_module: 'content',\n\t\t\t\t\t\t\tcontember_project: projectContainer.project.slug,\n\t\t\t\t\t\t\tcontember_project_group: slug ?? 'unknown',\n\t\t\t\t\t\t\tdatabase_instance: 'replica',\n\t\t\t\t\t\t},\n\t\t\t\t\t}))\n\t\t\t\t}\n\t\t\t\treturn () => unregister.forEach(it => it())\n\t\t\t})\n\n\n\t\t\tconst primaryConnection = groupContainer.tenantContainer.connection\n\t\t\tconst readConnection = groupContainer.tenantContainer.readConnection\n\t\t\tconst hasDifferentReadConnection = primaryConnection !== readConnection\n\t\t\tconst unregister: (() => void)[] = []\n\t\t\tunregister.push(registrar({\n\t\t\t\tconnection: primaryConnection,\n\t\t\t\tlabels: {\n\t\t\t\t\tcontember_module: 'tenant',\n\t\t\t\t\tcontember_project_group: slug ?? 'unknown',\n\t\t\t\t\tcontember_project: 'unknown',\n\t\t\t\t\tdatabase_instance: hasDifferentReadConnection ? 'primary' : 'single',\n\t\t\t\t},\n\t\t\t}))\n\t\t\tif (hasDifferentReadConnection) {\n\t\t\t\tunregister.push(registrar({\n\t\t\t\t\tconnection: readConnection,\n\t\t\t\t\tlabels: {\n\t\t\t\t\t\tcontember_module: 'tenant',\n\t\t\t\t\t\tcontember_project_group: slug ?? 'unknown',\n\t\t\t\t\t\tcontember_project: 'unknown',\n\t\t\t\t\t\tdatabase_instance: 'replica',\n\t\t\t\t\t},\n\t\t\t\t}))\n\t\t\t}\n\n\t\t\treturn () => unregister.forEach(it => it())\n\t\t})\n\t}\n}\n"],"names":["primaryConnection","readConnection","hasDifferentReadConnection","unregister"],"mappings":";AAIO,MAAM,iCAAiC;AAAA,EAC7C,YACS,mBACP;AADO,SAAA,oBAAA;AAAA,EAAA;AAAA,EAIF,SAAS,cAAwB;AACjC,UAAA,YAAY,yBAAyB,YAAY;AAClD,SAAA,kBAAkB,GAAG,UAAU,CAAC,EAAE,WAAW,gBAAgB,WAAW;AAC5E,qBAAe,yBAAyB,GAAG,UAAU,CAAC,EAAE,WAAW,uBAAuB;AACzF,cAAMA,qBAAoB,iBAAiB;AAC3C,cAAMC,kBAAiB,iBAAiB;AACxC,cAAMC,8BAA6BF,uBAAsBC;AACzD,cAAME,cAA6B,CAAC;AACpCA,oBAAW,KAAK,UAAU;AAAA,UACzB,YAAYH;AAAAA,UACZ,QAAQ;AAAA,YACP,kBAAkB;AAAA,YAClB,mBAAmB,iBAAiB,QAAQ;AAAA,YAC5C,yBAAyB,QAAQ;AAAA,YACjC,mBAAmBE,8BAA6B,YAAY;AAAA,UAAA;AAAA,QAC7D,CACA,CAAC;AACF,YAAIA,6BAA4B;AAC/BC,sBAAW,KAAK,UAAU;AAAA,YACzB,YAAYF;AAAAA,YACZ,QAAQ;AAAA,cACP,kBAAkB;AAAA,cAClB,mBAAmB,iBAAiB,QAAQ;AAAA,cAC5C,yBAAyB,QAAQ;AAAA,cACjC,mBAAmB;AAAA,YAAA;AAAA,UACpB,CACA,CAAC;AAAA,QAAA;AAEH,eAAO,MAAME,YAAW,QAAQ,CAAA,OAAM,IAAI;AAAA,MAAA,CAC1C;AAGK,YAAA,oBAAoB,eAAe,gBAAgB;AACnD,YAAA,iBAAiB,eAAe,gBAAgB;AACtD,YAAM,6BAA6B,sBAAsB;AACzD,YAAM,aAA6B,CAAC;AACpC,iBAAW,KAAK,UAAU;AAAA,QACzB,YAAY;AAAA,QACZ,QAAQ;AAAA,UACP,kBAAkB;AAAA,UAClB,yBAAyB,QAAQ;AAAA,UACjC,mBAAmB;AAAA,UACnB,mBAAmB,6BAA6B,YAAY;AAAA,QAAA;AAAA,MAC7D,CACA,CAAC;AACF,UAAI,4BAA4B;AAC/B,mBAAW,KAAK,UAAU;AAAA,UACzB,YAAY;AAAA,UACZ,QAAQ;AAAA,YACP,kBAAkB;AAAA,YAClB,yBAAyB,QAAQ;AAAA,YACjC,mBAAmB;AAAA,YACnB,mBAAmB;AAAA,UAAA;AAAA,QACpB,CACA,CAAC;AAAA,MAAA;AAGH,aAAO,MAAM,WAAW,QAAQ,CAAA,OAAM,IAAI;AAAA,IAAA,CAC1C;AAAA,EAAA;AAEH;"}
@@ -1 +1 @@
1
- {"version":3,"file":"PrometheusRegistryFactory.cjs","sources":["../../../../../packages/engine-http/src/prometheus/PrometheusRegistryFactory.ts"],"sourcesContent":["import prom, { Registry } from 'prom-client'\nimport { createContemberEngineInfoMetric } from './contemberEngineInfoMetric'\nimport { ProcessType } from '../MasterContainer'\n\nexport class PrometheusRegistryFactory {\n\tconstructor(\n\t\tprivate processType: ProcessType,\n\t\tprivate readonly contemberEngineInfo: { version?: string },\n\t) {\n\t}\n\n\tpublic create(): Registry {\n\t\tif (this.processType === 'clusterMaster') {\n\t\t\tconst register = new prom.AggregatorRegistry()\n\t\t\tprom.collectDefaultMetrics({ register })\n\t\t\treturn register\n\t\t}\n\t\tconst register = prom.register\n\t\tregister.registerMetric(createContemberEngineInfoMetric(this.contemberEngineInfo))\n\t\tif (!('Bun' in global)) {\n\t\t\tprom.collectDefaultMetrics({ register })\n\t\t}\n\n\t\treturn register\n\t}\n}\n"],"names":["register","createContemberEngineInfoMetric"],"mappings":";;;;AAIO,MAAM,0BAA0B;AAAA,EACtC,YACS,aACS,qBAChB;AAFO,SAAA,cAAA;AACS,SAAA,sBAAA;AAAA,EAElB;AAAA,EAEO,SAAmB;AACrB,QAAA,KAAK,gBAAgB,iBAAiB;AACnCA,YAAAA,YAAW,IAAI,KAAK;AAC1B,WAAK,sBAAsB,EAAE,UAAAA,UAAU,CAAA;AAChCA,aAAAA;AAAAA,IACR;AACA,UAAM,WAAW,KAAK;AACtB,aAAS,eAAeC,0BAAAA,gCAAgC,KAAK,mBAAmB,CAAC;AAC7E,QAAA,EAAE,SAAS,SAAS;AAClB,WAAA,sBAAsB,EAAE,SAAA,CAAU;AAAA,IACxC;AAEO,WAAA;AAAA,EACR;AACD;;"}
1
+ {"version":3,"file":"PrometheusRegistryFactory.cjs","sources":["../../../../../packages/engine-http/src/prometheus/PrometheusRegistryFactory.ts"],"sourcesContent":["import prom, { Registry } from 'prom-client'\nimport { createContemberEngineInfoMetric } from './contemberEngineInfoMetric'\nimport { ProcessType } from '../MasterContainer'\n\nexport class PrometheusRegistryFactory {\n\tconstructor(\n\t\tprivate processType: ProcessType,\n\t\tprivate readonly contemberEngineInfo: { version?: string },\n\t) {\n\t}\n\n\tpublic create(): Registry {\n\t\tif (this.processType === 'clusterMaster') {\n\t\t\tconst register = new prom.AggregatorRegistry()\n\t\t\tprom.collectDefaultMetrics({ register })\n\t\t\treturn register\n\t\t}\n\t\tconst register = prom.register\n\t\tregister.registerMetric(createContemberEngineInfoMetric(this.contemberEngineInfo))\n\t\tif (!('Bun' in global)) {\n\t\t\tprom.collectDefaultMetrics({ register })\n\t\t}\n\n\t\treturn register\n\t}\n}\n"],"names":["register","createContemberEngineInfoMetric"],"mappings":";;;;AAIO,MAAM,0BAA0B;AAAA,EACtC,YACS,aACS,qBAChB;AAFO,SAAA,cAAA;AACS,SAAA,sBAAA;AAAA,EAAA;AAAA,EAIX,SAAmB;AACrB,QAAA,KAAK,gBAAgB,iBAAiB;AACnCA,YAAAA,YAAW,IAAI,KAAK,mBAAmB;AAC7C,WAAK,sBAAsB,EAAE,UAAAA,UAAAA,CAAU;AAChCA,aAAAA;AAAAA,IAAA;AAER,UAAM,WAAW,KAAK;AACtB,aAAS,eAAeC,0BAAAA,gCAAgC,KAAK,mBAAmB,CAAC;AAC7E,QAAA,EAAE,SAAS,SAAS;AAClB,WAAA,sBAAsB,EAAE,UAAU;AAAA,IAAA;AAGjC,WAAA;AAAA,EAAA;AAET;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"PrometheusRegistryFactory.js","sources":["../../../../../packages/engine-http/src/prometheus/PrometheusRegistryFactory.ts"],"sourcesContent":["import prom, { Registry } from 'prom-client'\nimport { createContemberEngineInfoMetric } from './contemberEngineInfoMetric'\nimport { ProcessType } from '../MasterContainer'\n\nexport class PrometheusRegistryFactory {\n\tconstructor(\n\t\tprivate processType: ProcessType,\n\t\tprivate readonly contemberEngineInfo: { version?: string },\n\t) {\n\t}\n\n\tpublic create(): Registry {\n\t\tif (this.processType === 'clusterMaster') {\n\t\t\tconst register = new prom.AggregatorRegistry()\n\t\t\tprom.collectDefaultMetrics({ register })\n\t\t\treturn register\n\t\t}\n\t\tconst register = prom.register\n\t\tregister.registerMetric(createContemberEngineInfoMetric(this.contemberEngineInfo))\n\t\tif (!('Bun' in global)) {\n\t\t\tprom.collectDefaultMetrics({ register })\n\t\t}\n\n\t\treturn register\n\t}\n}\n"],"names":["register"],"mappings":";;AAIO,MAAM,0BAA0B;AAAA,EACtC,YACS,aACS,qBAChB;AAFO,SAAA,cAAA;AACS,SAAA,sBAAA;AAAA,EAElB;AAAA,EAEO,SAAmB;AACrB,QAAA,KAAK,gBAAgB,iBAAiB;AACnCA,YAAAA,YAAW,IAAI,KAAK;AAC1B,WAAK,sBAAsB,EAAE,UAAAA,UAAU,CAAA;AAChCA,aAAAA;AAAAA,IACR;AACA,UAAM,WAAW,KAAK;AACtB,aAAS,eAAe,gCAAgC,KAAK,mBAAmB,CAAC;AAC7E,QAAA,EAAE,SAAS,SAAS;AAClB,WAAA,sBAAsB,EAAE,SAAA,CAAU;AAAA,IACxC;AAEO,WAAA;AAAA,EACR;AACD;"}
1
+ {"version":3,"file":"PrometheusRegistryFactory.js","sources":["../../../../../packages/engine-http/src/prometheus/PrometheusRegistryFactory.ts"],"sourcesContent":["import prom, { Registry } from 'prom-client'\nimport { createContemberEngineInfoMetric } from './contemberEngineInfoMetric'\nimport { ProcessType } from '../MasterContainer'\n\nexport class PrometheusRegistryFactory {\n\tconstructor(\n\t\tprivate processType: ProcessType,\n\t\tprivate readonly contemberEngineInfo: { version?: string },\n\t) {\n\t}\n\n\tpublic create(): Registry {\n\t\tif (this.processType === 'clusterMaster') {\n\t\t\tconst register = new prom.AggregatorRegistry()\n\t\t\tprom.collectDefaultMetrics({ register })\n\t\t\treturn register\n\t\t}\n\t\tconst register = prom.register\n\t\tregister.registerMetric(createContemberEngineInfoMetric(this.contemberEngineInfo))\n\t\tif (!('Bun' in global)) {\n\t\t\tprom.collectDefaultMetrics({ register })\n\t\t}\n\n\t\treturn register\n\t}\n}\n"],"names":["register"],"mappings":";;AAIO,MAAM,0BAA0B;AAAA,EACtC,YACS,aACS,qBAChB;AAFO,SAAA,cAAA;AACS,SAAA,sBAAA;AAAA,EAAA;AAAA,EAIX,SAAmB;AACrB,QAAA,KAAK,gBAAgB,iBAAiB;AACnCA,YAAAA,YAAW,IAAI,KAAK,mBAAmB;AAC7C,WAAK,sBAAsB,EAAE,UAAAA,UAAAA,CAAU;AAChCA,aAAAA;AAAAA,IAAA;AAER,UAAM,WAAW,KAAK;AACtB,aAAS,eAAe,gCAAgC,KAAK,mBAAmB,CAAC;AAC7E,QAAA,EAAE,SAAS,SAAS;AAClB,WAAA,sBAAsB,EAAE,UAAU;AAAA,IAAA;AAGjC,WAAA;AAAA,EAAA;AAET;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ShowMetricsMiddleware.cjs","sources":["../../../../../packages/engine-http/src/prometheus/ShowMetricsMiddleware.ts"],"sourcesContent":["import prom from 'prom-client'\nimport { KoaMiddleware } from '../application'\n\nexport const createShowMetricsMiddleware = (registry: prom.Registry): KoaMiddleware<any> => {\n\treturn async (ctx, next) => {\n\t\tif (ctx.path !== '/metrics') {\n\t\t\treturn next()\n\t\t}\n\t\tif (registry instanceof prom.AggregatorRegistry) {\n\t\t\tctx.body = await registry.clusterMetrics()\n\t\t} else {\n\t\t\tctx.body = registry.metrics()\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;AAGa,MAAA,8BAA8B,CAAC,aAAgD;AACpF,SAAA,OAAO,KAAK,SAAS;AACvB,QAAA,IAAI,SAAS,YAAY;AAC5B,aAAO,KAAK;AAAA,IACb;AACI,QAAA,oBAAoB,KAAK,oBAAoB;AAC5C,UAAA,OAAO,MAAM,SAAS,eAAe;AAAA,IAAA,OACnC;AACF,UAAA,OAAO,SAAS;IACrB;AAAA,EAAA;AAEF;;"}
1
+ {"version":3,"file":"ShowMetricsMiddleware.cjs","sources":["../../../../../packages/engine-http/src/prometheus/ShowMetricsMiddleware.ts"],"sourcesContent":["import prom from 'prom-client'\nimport { KoaMiddleware } from '../application'\n\nexport const createShowMetricsMiddleware = (registry: prom.Registry): KoaMiddleware<any> => {\n\treturn async (ctx, next) => {\n\t\tif (ctx.path !== '/metrics') {\n\t\t\treturn next()\n\t\t}\n\t\tif (registry instanceof prom.AggregatorRegistry) {\n\t\t\tctx.body = await registry.clusterMetrics()\n\t\t} else {\n\t\t\tctx.body = registry.metrics()\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;AAGa,MAAA,8BAA8B,CAAC,aAAgD;AACpF,SAAA,OAAO,KAAK,SAAS;AACvB,QAAA,IAAI,SAAS,YAAY;AAC5B,aAAO,KAAK;AAAA,IAAA;AAET,QAAA,oBAAoB,KAAK,oBAAoB;AAC5C,UAAA,OAAO,MAAM,SAAS,eAAe;AAAA,IAAA,OACnC;AACF,UAAA,OAAO,SAAS,QAAQ;AAAA,IAAA;AAAA,EAE9B;AACD;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ShowMetricsMiddleware.js","sources":["../../../../../packages/engine-http/src/prometheus/ShowMetricsMiddleware.ts"],"sourcesContent":["import prom from 'prom-client'\nimport { KoaMiddleware } from '../application'\n\nexport const createShowMetricsMiddleware = (registry: prom.Registry): KoaMiddleware<any> => {\n\treturn async (ctx, next) => {\n\t\tif (ctx.path !== '/metrics') {\n\t\t\treturn next()\n\t\t}\n\t\tif (registry instanceof prom.AggregatorRegistry) {\n\t\t\tctx.body = await registry.clusterMetrics()\n\t\t} else {\n\t\t\tctx.body = registry.metrics()\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";AAGa,MAAA,8BAA8B,CAAC,aAAgD;AACpF,SAAA,OAAO,KAAK,SAAS;AACvB,QAAA,IAAI,SAAS,YAAY;AAC5B,aAAO,KAAK;AAAA,IACb;AACI,QAAA,oBAAoB,KAAK,oBAAoB;AAC5C,UAAA,OAAO,MAAM,SAAS,eAAe;AAAA,IAAA,OACnC;AACF,UAAA,OAAO,SAAS;IACrB;AAAA,EAAA;AAEF;"}
1
+ {"version":3,"file":"ShowMetricsMiddleware.js","sources":["../../../../../packages/engine-http/src/prometheus/ShowMetricsMiddleware.ts"],"sourcesContent":["import prom from 'prom-client'\nimport { KoaMiddleware } from '../application'\n\nexport const createShowMetricsMiddleware = (registry: prom.Registry): KoaMiddleware<any> => {\n\treturn async (ctx, next) => {\n\t\tif (ctx.path !== '/metrics') {\n\t\t\treturn next()\n\t\t}\n\t\tif (registry instanceof prom.AggregatorRegistry) {\n\t\t\tctx.body = await registry.clusterMetrics()\n\t\t} else {\n\t\t\tctx.body = registry.metrics()\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";AAGa,MAAA,8BAA8B,CAAC,aAAgD;AACpF,SAAA,OAAO,KAAK,SAAS;AACvB,QAAA,IAAI,SAAS,YAAY;AAC5B,aAAO,KAAK;AAAA,IAAA;AAET,QAAA,oBAAoB,KAAK,oBAAoB;AAC5C,UAAA,OAAO,MAAM,SAAS,eAAe;AAAA,IAAA,OACnC;AACF,UAAA,OAAO,SAAS,QAAQ;AAAA,IAAA;AAAA,EAE9B;AACD;"}
@@ -1 +1 @@
1
- {"version":3,"file":"dbMetrics.cjs","sources":["../../../../../packages/engine-http/src/prometheus/dbMetrics.ts"],"sourcesContent":["import prom from 'prom-client'\nimport { Connection, EventManager, PoolStats, poolStatsDescription } from '@contember/database'\nimport { CustomMetric } from './CustomMetric'\n\nconst labelNames = ['contember_project' as const, 'contember_module' as const, 'contember_project_group' as const, 'database_instance']\ntype LabelNames = typeof labelNames[number]\ntype Labels = { [K in LabelNames]: string }\ntype DatabaseMetricsEntry = {\n\tconnection: Connection.PoolStatusProvider & Connection.Queryable\n\tlabels: Labels\n}\ntype Unregistrar = () => void\ntype DatabaseMetricsRegistrar = (entry: DatabaseMetricsEntry) => Unregistrar\n\nexport const createDbMetricsRegistrar = (registry: prom.Registry): DatabaseMetricsRegistrar => {\n\tconst dbPoolCollectorInner = createDbPoolMetricsCollector(registry)\n\tconst entries = new Set<DatabaseMetricsEntry>()\n\tconst collector = () => {\n\t\tdbPoolCollectorInner(entries)\n\t}\n\tregistry.registerCollector(collector)\n\tconst sqlMetricsRegistrar = createSqlMetricsRegistrar(registry)\n\treturn entry => {\n\t\tentries.add(entry)\n\t\tconst sqlMetricsUnregistrar = sqlMetricsRegistrar(entry.connection, entry.labels)\n\t\treturn () => {\n\t\t\tentries.delete(entry)\n\t\t\tsqlMetricsUnregistrar()\n\t\t}\n\t}\n}\n\nconst createDbPoolMetricsCollector = (registry: prom.Registry) => {\n\n\tconst descriptionSuffix = 'Dimensions: contember_module (tenant or content; system is not used since it uses the same connection), contember_project_group, contember_project for contember_module=content, database_instance (single, primary, replica).'\n\tconst totalCount = new prom.Gauge({\n\t\tregisters: [registry],\n\t\tname: `contember_db_pool_total_count`,\n\t\thelp: `The total number of clients existing within the pool: ${descriptionSuffix}`,\n\t\tlabelNames,\n\t})\n\tconst idleCount = new prom.Gauge({\n\t\tregisters: [registry],\n\t\tname: `contember_db_pool_idle_count`,\n\t\thelp: `The number of clients which are not checked out but are currently idle in the pool. ${descriptionSuffix}`,\n\t\tlabelNames,\n\t})\n\tconst waitingCount = new prom.Gauge({\n\t\tregisters: [registry],\n\t\tname: `contember_db_pool_waiting_count`,\n\t\thelp: `The number of queued requests waiting on a client when all clients are checked out. It can be helpful to monitor this number to see if you need to adjust the size of the pool. ${descriptionSuffix}`,\n\t\tlabelNames,\n\t})\n\tconst maxCount = new prom.Gauge({\n\t\tregisters: [registry],\n\t\tname: `contember_db_pool_max_count`,\n\t\thelp: `Maximum number of clients the pool should contain. ${descriptionSuffix}`,\n\t\tlabelNames,\n\t})\n\tconst connectingCount = new prom.Gauge({\n\t\tregisters: [registry],\n\t\tname: `contember_db_pool_connecting_count`,\n\t\thelp: `Current value of clients establishing connection. ${descriptionSuffix}`,\n\t\tlabelNames,\n\t})\n\tconst activeCount = new prom.Gauge({\n\t\tregisters: [registry],\n\t\tname: `contember_db_pool_active_count`,\n\t\thelp: `Number of connections that are checked out. ${descriptionSuffix}`,\n\t\tlabelNames,\n\t})\n\tconst statCounters: {[K in keyof PoolStats]: CustomMetric<LabelNames>} = {} as any\n\tfor (const [key, description] of Object.entries(poolStatsDescription)) {\n\t\tconst customMetric = new CustomMetric<LabelNames>({\n\t\t\tname: `contember_db_pool_${key}`,\n\t\t\thelp: `${description} ${descriptionSuffix}`,\n\t\t\ttype: 'counter',\n\t\t\tlabelNames,\n\t\t})\n\t\tstatCounters[key as keyof PoolStats] = customMetric\n\t\tregistry.registerMetric(customMetric as unknown as prom.Counter<LabelNames>)\n\t}\n\n\treturn (entries: Set<DatabaseMetricsEntry>) => {\n\t\tfor (const counter of Object.values(statCounters)) {\n\t\t\tcounter.reset()\n\t\t}\n\t\tfor (const entry of entries) {\n\t\t\tconst db = entry.connection\n\t\t\tconst labels = entry.labels\n\t\t\tconst poolInfo = db.getPoolStatus()\n\t\t\tif (!poolInfo) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\ttotalCount.set(labels, poolInfo.active + poolInfo.idle + poolInfo.connecting)\n\t\t\tidleCount.set(labels, poolInfo.idle)\n\t\t\twaitingCount.set(labels, poolInfo.pending)\n\t\t\tmaxCount.set(labels, poolInfo.max)\n\t\t\tconnectingCount.set(labels, poolInfo.connecting)\n\t\t\tactiveCount.set(labels, poolInfo.active)\n\n\t\t\tfor (const [key, value] of Object.entries(poolInfo.stats)) {\n\t\t\t\tstatCounters[key as keyof PoolStats].add(labels, value)\n\t\t\t}\n\t\t}\n\t}\n}\ntype SqlMetricsRegistrar = (\n\tconnection: Connection.Queryable,\n\tlabels: Labels,\n) => Unregistrar\nconst createSqlMetricsRegistrar = (registry: prom.Registry): SqlMetricsRegistrar => {\n\tconst sqlDuration = new prom.Histogram({\n\t\tname: 'contember_sql_duration_ms',\n\t\thelp: 'Executed SQL queries by contember_module (system, tenant, content or unknown) and contember_project (or \"unknown\" for unknown project)',\n\t\tregisters: [registry],\n\t\tlabelNames,\n\t\tbuckets: [1, 2, 5, 10, 25, 50, 100, 250, 500, 1000],\n\t})\n\tconst sqlErrorRate = new prom.Counter({\n\t\tname: 'contember_sql_error_count',\n\t\thelp: 'Failed SQL queries by contember_module (system, tenant, content or unknown) and contember_project (or \"unknown\" for unknown project)',\n\t\tlabelNames,\n\t\tregisters: [registry],\n\t})\n\n\treturn (connection, labels) => {\n\t\tconst queryEndCallback: EventManager.ListenerTypes[EventManager.Event.queryEnd] = ({ meta }, { timing }) => {\n\t\t\tsqlDuration.observe(\n\t\t\t\t{\n\t\t\t\t\t...labels,\n\t\t\t\t\tcontember_module: meta.module || labels.contember_module,\n\t\t\t\t},\n\t\t\t\ttiming ? Math.round(timing.selfDuration / 1000) : 0,\n\t\t\t)\n\t\t}\n\t\tconst queryErrorCallback: EventManager.ListenerTypes[EventManager.Event.queryError] = ({ meta }) => {\n\t\t\tsqlErrorRate.inc({\n\t\t\t\t...labels,\n\t\t\t\tcontember_module: meta.module || labels.contember_module,\n\t\t\t})\n\t\t}\n\t\tconnection.eventManager.on(EventManager.Event.queryEnd, queryEndCallback)\n\t\tconnection.eventManager.on(EventManager.Event.queryError, queryErrorCallback)\n\t\treturn () => {\n\t\t\tconnection.eventManager.removeListener(EventManager.Event.queryEnd, queryEndCallback)\n\t\t\tconnection.eventManager.removeListener(EventManager.Event.queryError, queryErrorCallback)\n\t\t}\n\t}\n}\n"],"names":["poolStatsDescription","CustomMetric","EventManager"],"mappings":";;;;;AAIA,MAAM,aAAa,CAAC,qBAA8B,oBAA6B,2BAAoC,mBAAmB;AAUzH,MAAA,2BAA2B,CAAC,aAAsD;AACxF,QAAA,uBAAuB,6BAA6B,QAAQ;AAC5D,QAAA,8BAAc;AACpB,QAAM,YAAY,MAAM;AACvB,yBAAqB,OAAO;AAAA,EAAA;AAE7B,WAAS,kBAAkB,SAAS;AAC9B,QAAA,sBAAsB,0BAA0B,QAAQ;AAC9D,SAAO,CAAS,UAAA;AACf,YAAQ,IAAI,KAAK;AACjB,UAAM,wBAAwB,oBAAoB,MAAM,YAAY,MAAM,MAAM;AAChF,WAAO,MAAM;AACZ,cAAQ,OAAO,KAAK;AACE;IAAA;AAAA,EACvB;AAEF;AAEA,MAAM,+BAA+B,CAAC,aAA4B;AAEjE,QAAM,oBAAoB;AACpB,QAAA,aAAa,IAAI,KAAK,MAAM;AAAA,IACjC,WAAW,CAAC,QAAQ;AAAA,IACpB,MAAM;AAAA,IACN,MAAM,yDAAyD,iBAAiB;AAAA,IAChF;AAAA,EAAA,CACA;AACK,QAAA,YAAY,IAAI,KAAK,MAAM;AAAA,IAChC,WAAW,CAAC,QAAQ;AAAA,IACpB,MAAM;AAAA,IACN,MAAM,uFAAuF,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AAM,YAAY,kBAAkB;AAC5E,WAAO,MAAM;AACZ,iBAAW,aAAa,eAAeA,SAAAA,aAAa,MAAM,UAAU,gBAAgB;AACpF,iBAAW,aAAa,eAAeA,SAAAA,aAAa,MAAM,YAAY,kBAAkB;AAAA,IAAA;AAAA,EACzF;AAEF;;"}
1
+ {"version":3,"file":"dbMetrics.cjs","sources":["../../../../../packages/engine-http/src/prometheus/dbMetrics.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/triple-slash-reference\n/// <reference path=\"../../types/prom-client/index.d.ts\" />\nimport prom from 'prom-client'\nimport { Connection, EventManager, PoolStats, poolStatsDescription } from '@contember/database'\nimport { CustomMetric } from './CustomMetric'\n\n\nconst labelNames = ['contember_project' as const, 'contember_module' as const, 'contember_project_group' as const, 'database_instance']\ntype LabelNames = typeof labelNames[number]\ntype Labels = { [K in LabelNames]: string }\ntype DatabaseMetricsEntry = {\n\tconnection: Connection.PoolStatusProvider & Connection.Queryable\n\tlabels: Labels\n}\ntype Unregistrar = () => void\ntype DatabaseMetricsRegistrar = (entry: DatabaseMetricsEntry) => Unregistrar\n\nexport const createDbMetricsRegistrar = (registry: prom.Registry): DatabaseMetricsRegistrar => {\n\tconst dbPoolCollectorInner = createDbPoolMetricsCollector(registry)\n\tconst entries = new Set<DatabaseMetricsEntry>()\n\tconst collector = () => {\n\t\tdbPoolCollectorInner(entries)\n\t}\n\tregistry.registerCollector(collector)\n\tconst sqlMetricsRegistrar = createSqlMetricsRegistrar(registry)\n\treturn entry => {\n\t\tentries.add(entry)\n\t\tconst sqlMetricsUnregistrar = sqlMetricsRegistrar(entry.connection, entry.labels)\n\t\treturn () => {\n\t\t\tentries.delete(entry)\n\t\t\tsqlMetricsUnregistrar()\n\t\t}\n\t}\n}\n\nconst createDbPoolMetricsCollector = (registry: prom.Registry) => {\n\n\tconst descriptionSuffix = 'Dimensions: contember_module (tenant or content; system is not used since it uses the same connection), contember_project_group, contember_project for contember_module=content, database_instance (single, primary, replica).'\n\tconst totalCount = new prom.Gauge({\n\t\tregisters: [registry],\n\t\tname: `contember_db_pool_total_count`,\n\t\thelp: `The total number of clients existing within the pool: ${descriptionSuffix}`,\n\t\tlabelNames,\n\t})\n\tconst idleCount = new prom.Gauge({\n\t\tregisters: [registry],\n\t\tname: `contember_db_pool_idle_count`,\n\t\thelp: `The number of clients which are not checked out but are currently idle in the pool. ${descriptionSuffix}`,\n\t\tlabelNames,\n\t})\n\tconst waitingCount = new prom.Gauge({\n\t\tregisters: [registry],\n\t\tname: `contember_db_pool_waiting_count`,\n\t\thelp: `The number of queued requests waiting on a client when all clients are checked out. It can be helpful to monitor this number to see if you need to adjust the size of the pool. ${descriptionSuffix}`,\n\t\tlabelNames,\n\t})\n\tconst maxCount = new prom.Gauge({\n\t\tregisters: [registry],\n\t\tname: `contember_db_pool_max_count`,\n\t\thelp: `Maximum number of clients the pool should contain. ${descriptionSuffix}`,\n\t\tlabelNames,\n\t})\n\tconst connectingCount = new prom.Gauge({\n\t\tregisters: [registry],\n\t\tname: `contember_db_pool_connecting_count`,\n\t\thelp: `Current value of clients establishing connection. ${descriptionSuffix}`,\n\t\tlabelNames,\n\t})\n\tconst activeCount = new prom.Gauge({\n\t\tregisters: [registry],\n\t\tname: `contember_db_pool_active_count`,\n\t\thelp: `Number of connections that are checked out. ${descriptionSuffix}`,\n\t\tlabelNames,\n\t})\n\tconst statCounters: {[K in keyof PoolStats]: CustomMetric<LabelNames>} = {} as any\n\tfor (const [key, description] of Object.entries(poolStatsDescription)) {\n\t\tconst customMetric = new CustomMetric<LabelNames>({\n\t\t\tname: `contember_db_pool_${key}`,\n\t\t\thelp: `${description} ${descriptionSuffix}`,\n\t\t\ttype: 'counter',\n\t\t\tlabelNames,\n\t\t})\n\t\tstatCounters[key as keyof PoolStats] = customMetric\n\t\tregistry.registerMetric(customMetric as unknown as prom.Counter<LabelNames>)\n\t}\n\n\treturn (entries: Set<DatabaseMetricsEntry>) => {\n\t\tfor (const counter of Object.values(statCounters)) {\n\t\t\tcounter.reset()\n\t\t}\n\t\tfor (const entry of entries) {\n\t\t\tconst db = entry.connection\n\t\t\tconst labels = entry.labels\n\t\t\tconst poolInfo = db.getPoolStatus()\n\t\t\tif (!poolInfo) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\ttotalCount.set(labels, poolInfo.active + poolInfo.idle + poolInfo.connecting)\n\t\t\tidleCount.set(labels, poolInfo.idle)\n\t\t\twaitingCount.set(labels, poolInfo.pending)\n\t\t\tmaxCount.set(labels, poolInfo.max)\n\t\t\tconnectingCount.set(labels, poolInfo.connecting)\n\t\t\tactiveCount.set(labels, poolInfo.active)\n\n\t\t\tfor (const [key, value] of Object.entries(poolInfo.stats)) {\n\t\t\t\tstatCounters[key as keyof PoolStats].add(labels, value)\n\t\t\t}\n\t\t}\n\t}\n}\ntype SqlMetricsRegistrar = (\n\tconnection: Connection.Queryable,\n\tlabels: Labels,\n) => Unregistrar\nconst createSqlMetricsRegistrar = (registry: prom.Registry): SqlMetricsRegistrar => {\n\tconst sqlDuration = new prom.Histogram({\n\t\tname: 'contember_sql_duration_ms',\n\t\thelp: 'Executed SQL queries by contember_module (system, tenant, content or unknown) and contember_project (or \"unknown\" for unknown project)',\n\t\tregisters: [registry],\n\t\tlabelNames,\n\t\tbuckets: [1, 2, 5, 10, 25, 50, 100, 250, 500, 1000],\n\t})\n\tconst sqlErrorRate = new prom.Counter({\n\t\tname: 'contember_sql_error_count',\n\t\thelp: 'Failed SQL queries by contember_module (system, tenant, content or unknown) and contember_project (or \"unknown\" for unknown project)',\n\t\tlabelNames,\n\t\tregisters: [registry],\n\t})\n\n\treturn (connection, labels) => {\n\t\tconst queryEndCallback: EventManager.ListenerTypes[EventManager.Event.queryEnd] = ({ meta }, { timing }) => {\n\t\t\tsqlDuration.observe(\n\t\t\t\t{\n\t\t\t\t\t...labels,\n\t\t\t\t\tcontember_module: meta.module || labels.contember_module,\n\t\t\t\t},\n\t\t\t\ttiming ? Math.round(timing.selfDuration / 1000) : 0,\n\t\t\t)\n\t\t}\n\t\tconst queryErrorCallback: EventManager.ListenerTypes[EventManager.Event.queryError] = ({ meta }) => {\n\t\t\tsqlErrorRate.inc({\n\t\t\t\t...labels,\n\t\t\t\tcontember_module: meta.module || labels.contember_module,\n\t\t\t})\n\t\t}\n\t\tconnection.eventManager.on(EventManager.Event.queryEnd, queryEndCallback)\n\t\tconnection.eventManager.on(EventManager.Event.queryError, queryErrorCallback)\n\t\treturn () => {\n\t\t\tconnection.eventManager.removeListener(EventManager.Event.queryEnd, queryEndCallback)\n\t\t\tconnection.eventManager.removeListener(EventManager.Event.queryError, queryErrorCallback)\n\t\t}\n\t}\n}\n"],"names":["poolStatsDescription","CustomMetric","EventManager"],"mappings":";;;;;AAOA,MAAM,aAAa,CAAC,qBAA8B,oBAA6B,2BAAoC,mBAAmB;AAUzH,MAAA,2BAA2B,CAAC,aAAsD;AACxF,QAAA,uBAAuB,6BAA6B,QAAQ;AAC5D,QAAA,8BAAc,IAA0B;AAC9C,QAAM,YAAY,MAAM;AACvB,yBAAqB,OAAO;AAAA,EAC7B;AACA,WAAS,kBAAkB,SAAS;AAC9B,QAAA,sBAAsB,0BAA0B,QAAQ;AAC9D,SAAO,CAAS,UAAA;AACf,YAAQ,IAAI,KAAK;AACjB,UAAM,wBAAwB,oBAAoB,MAAM,YAAY,MAAM,MAAM;AAChF,WAAO,MAAM;AACZ,cAAQ,OAAO,KAAK;AACE,4BAAA;AAAA,IACvB;AAAA,EACD;AACD;AAEA,MAAM,+BAA+B,CAAC,aAA4B;AAEjE,QAAM,oBAAoB;AACpB,QAAA,aAAa,IAAI,KAAK,MAAM;AAAA,IACjC,WAAW,CAAC,QAAQ;AAAA,IACpB,MAAM;AAAA,IACN,MAAM,yDAAyD,iBAAiB;AAAA,IAChF;AAAA,EAAA,CACA;AACK,QAAA,YAAY,IAAI,KAAK,MAAM;AAAA,IAChC,WAAW,CAAC,QAAQ;AAAA,IACpB,MAAM;AAAA,IACN,MAAM,uFAAuF,i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A,MAAM,YAAY,kBAAkB;AAC5E,WAAO,MAAM;AACZ,iBAAW,aAAa,eAAeA,SAAa,aAAA,MAAM,UAAU,gBAAgB;AACpF,iBAAW,aAAa,eAAeA,SAAa,aAAA,MAAM,YAAY,kBAAkB;AAAA,IACzF;AAAA,EACD;AACD;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"dbMetrics.js","sources":["../../../../../packages/engine-http/src/prometheus/dbMetrics.ts"],"sourcesContent":["import prom from 'prom-client'\nimport { Connection, EventManager, PoolStats, poolStatsDescription } from '@contember/database'\nimport { CustomMetric } from './CustomMetric'\n\nconst labelNames = ['contember_project' as const, 'contember_module' as const, 'contember_project_group' as const, 'database_instance']\ntype LabelNames = typeof labelNames[number]\ntype Labels = { [K in LabelNames]: string }\ntype DatabaseMetricsEntry = {\n\tconnection: Connection.PoolStatusProvider & Connection.Queryable\n\tlabels: Labels\n}\ntype Unregistrar = () => void\ntype DatabaseMetricsRegistrar = (entry: DatabaseMetricsEntry) => Unregistrar\n\nexport const createDbMetricsRegistrar = (registry: prom.Registry): DatabaseMetricsRegistrar => {\n\tconst dbPoolCollectorInner = createDbPoolMetricsCollector(registry)\n\tconst entries = new Set<DatabaseMetricsEntry>()\n\tconst collector = () => {\n\t\tdbPoolCollectorInner(entries)\n\t}\n\tregistry.registerCollector(collector)\n\tconst sqlMetricsRegistrar = createSqlMetricsRegistrar(registry)\n\treturn entry => {\n\t\tentries.add(entry)\n\t\tconst sqlMetricsUnregistrar = sqlMetricsRegistrar(entry.connection, entry.labels)\n\t\treturn () => {\n\t\t\tentries.delete(entry)\n\t\t\tsqlMetricsUnregistrar()\n\t\t}\n\t}\n}\n\nconst createDbPoolMetricsCollector = (registry: prom.Registry) => {\n\n\tconst descriptionSuffix = 'Dimensions: contember_module (tenant or content; system is not used since it uses the same connection), contember_project_group, contember_project for contember_module=content, database_instance (single, primary, replica).'\n\tconst totalCount = new prom.Gauge({\n\t\tregisters: [registry],\n\t\tname: `contember_db_pool_total_count`,\n\t\thelp: `The total number of clients existing within the pool: ${descriptionSuffix}`,\n\t\tlabelNames,\n\t})\n\tconst idleCount = new prom.Gauge({\n\t\tregisters: [registry],\n\t\tname: `contember_db_pool_idle_count`,\n\t\thelp: `The number of clients which are not checked out but are currently idle in the pool. ${descriptionSuffix}`,\n\t\tlabelNames,\n\t})\n\tconst waitingCount = new prom.Gauge({\n\t\tregisters: [registry],\n\t\tname: `contember_db_pool_waiting_count`,\n\t\thelp: `The number of queued requests waiting on a client when all clients are checked out. It can be helpful to monitor this number to see if you need to adjust the size of the pool. ${descriptionSuffix}`,\n\t\tlabelNames,\n\t})\n\tconst maxCount = new prom.Gauge({\n\t\tregisters: [registry],\n\t\tname: `contember_db_pool_max_count`,\n\t\thelp: `Maximum number of clients the pool should contain. ${descriptionSuffix}`,\n\t\tlabelNames,\n\t})\n\tconst connectingCount = new prom.Gauge({\n\t\tregisters: [registry],\n\t\tname: `contember_db_pool_connecting_count`,\n\t\thelp: `Current value of clients establishing connection. ${descriptionSuffix}`,\n\t\tlabelNames,\n\t})\n\tconst activeCount = new prom.Gauge({\n\t\tregisters: [registry],\n\t\tname: `contember_db_pool_active_count`,\n\t\thelp: `Number of connections that are checked out. ${descriptionSuffix}`,\n\t\tlabelNames,\n\t})\n\tconst statCounters: {[K in keyof PoolStats]: CustomMetric<LabelNames>} = {} as any\n\tfor (const [key, description] of Object.entries(poolStatsDescription)) {\n\t\tconst customMetric = new CustomMetric<LabelNames>({\n\t\t\tname: `contember_db_pool_${key}`,\n\t\t\thelp: `${description} ${descriptionSuffix}`,\n\t\t\ttype: 'counter',\n\t\t\tlabelNames,\n\t\t})\n\t\tstatCounters[key as keyof PoolStats] = customMetric\n\t\tregistry.registerMetric(customMetric as unknown as prom.Counter<LabelNames>)\n\t}\n\n\treturn (entries: Set<DatabaseMetricsEntry>) => {\n\t\tfor (const counter of Object.values(statCounters)) {\n\t\t\tcounter.reset()\n\t\t}\n\t\tfor (const entry of entries) {\n\t\t\tconst db = entry.connection\n\t\t\tconst labels = entry.labels\n\t\t\tconst poolInfo = db.getPoolStatus()\n\t\t\tif (!poolInfo) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\ttotalCount.set(labels, poolInfo.active + poolInfo.idle + poolInfo.connecting)\n\t\t\tidleCount.set(labels, poolInfo.idle)\n\t\t\twaitingCount.set(labels, poolInfo.pending)\n\t\t\tmaxCount.set(labels, poolInfo.max)\n\t\t\tconnectingCount.set(labels, poolInfo.connecting)\n\t\t\tactiveCount.set(labels, poolInfo.active)\n\n\t\t\tfor (const [key, value] of Object.entries(poolInfo.stats)) {\n\t\t\t\tstatCounters[key as keyof PoolStats].add(labels, value)\n\t\t\t}\n\t\t}\n\t}\n}\ntype SqlMetricsRegistrar = (\n\tconnection: Connection.Queryable,\n\tlabels: Labels,\n) => Unregistrar\nconst createSqlMetricsRegistrar = (registry: prom.Registry): SqlMetricsRegistrar => {\n\tconst sqlDuration = new prom.Histogram({\n\t\tname: 'contember_sql_duration_ms',\n\t\thelp: 'Executed SQL queries by contember_module (system, tenant, content or unknown) and contember_project (or \"unknown\" for unknown project)',\n\t\tregisters: [registry],\n\t\tlabelNames,\n\t\tbuckets: [1, 2, 5, 10, 25, 50, 100, 250, 500, 1000],\n\t})\n\tconst sqlErrorRate = new prom.Counter({\n\t\tname: 'contember_sql_error_count',\n\t\thelp: 'Failed SQL queries by contember_module (system, tenant, content or unknown) and contember_project (or \"unknown\" for unknown project)',\n\t\tlabelNames,\n\t\tregisters: [registry],\n\t})\n\n\treturn (connection, labels) => {\n\t\tconst queryEndCallback: EventManager.ListenerTypes[EventManager.Event.queryEnd] = ({ meta }, { timing }) => {\n\t\t\tsqlDuration.observe(\n\t\t\t\t{\n\t\t\t\t\t...labels,\n\t\t\t\t\tcontember_module: meta.module || labels.contember_module,\n\t\t\t\t},\n\t\t\t\ttiming ? Math.round(timing.selfDuration / 1000) : 0,\n\t\t\t)\n\t\t}\n\t\tconst queryErrorCallback: EventManager.ListenerTypes[EventManager.Event.queryError] = ({ meta }) => {\n\t\t\tsqlErrorRate.inc({\n\t\t\t\t...labels,\n\t\t\t\tcontember_module: meta.module || labels.contember_module,\n\t\t\t})\n\t\t}\n\t\tconnection.eventManager.on(EventManager.Event.queryEnd, queryEndCallback)\n\t\tconnection.eventManager.on(EventManager.Event.queryError, queryErrorCallback)\n\t\treturn () => {\n\t\t\tconnection.eventManager.removeListener(EventManager.Event.queryEnd, queryEndCallback)\n\t\t\tconnection.eventManager.removeListener(EventManager.Event.queryError, queryErrorCallback)\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;AAIA,MAAM,aAAa,CAAC,qBAA8B,oBAA6B,2BAAoC,mBAAmB;AAUzH,MAAA,2BAA2B,CAAC,aAAsD;AACxF,QAAA,uBAAuB,6BAA6B,QAAQ;AAC5D,QAAA,8BAAc;AACpB,QAAM,YAAY,MAAM;AACvB,yBAAqB,OAAO;AAAA,EAAA;AAE7B,WAAS,kBAAkB,SAAS;AAC9B,QAAA,sBAAsB,0BAA0B,QAAQ;AAC9D,SAAO,CAAS,UAAA;AACf,YAAQ,IAAI,KAAK;AACjB,UAAM,wBAAwB,oBAAoB,MAAM,YAAY,MAAM,MAAM;AAChF,WAAO,MAAM;AACZ,cAAQ,OAAO,KAAK;AACE;IAAA;AAAA,EACvB;AAEF;AAEA,MAAM,+BAA+B,CAAC,aAA4B;AAEjE,QAAM,oBAAoB;AACpB,QAAA,aAAa,IAAI,KAAK,MAAM;AAAA,IACjC,WAAW,CAAC,QAAQ;AAAA,IACpB,MAAM;AAAA,IACN,MAAM,yDAAyD,iBAAiB;AAAA,IAChF;AAAA,EAAA,CACA;AACK,QAAA,YAAY,IAAI,KAAK,MAAM;AAAA,IAChC,WAAW,CAAC,QAAQ;AAAA,IACpB,MAAM;AAAA,IACN,MAAM,uFAAuF,iBAAiB;AAAA,IAC9G;AAAA,EAAA,CACA;AACK,QAAA,eAAe,IAAI,KAAK,MAAM;AAAA,IACnC,WAAW,CAAC,QAAQ;AAAA,I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kB;AAAA,IAAA;AAAA,EACzF;AAEF;"}
1
+ {"version":3,"file":"dbMetrics.js","sources":["../../../../../packages/engine-http/src/prometheus/dbMetrics.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/triple-slash-reference\n/// <reference path=\"../../types/prom-client/index.d.ts\" />\nimport prom from 'prom-client'\nimport { Connection, EventManager, PoolStats, poolStatsDescription } from '@contember/database'\nimport { CustomMetric } from './CustomMetric'\n\n\nconst labelNames = ['contember_project' as const, 'contember_module' as const, 'contember_project_group' as const, 'database_instance']\ntype LabelNames = typeof labelNames[number]\ntype Labels = { [K in LabelNames]: string }\ntype DatabaseMetricsEntry = {\n\tconnection: Connection.PoolStatusProvider & Connection.Queryable\n\tlabels: Labels\n}\ntype Unregistrar = () => void\ntype DatabaseMetricsRegistrar = (entry: DatabaseMetricsEntry) => Unregistrar\n\nexport const createDbMetricsRegistrar = (registry: prom.Registry): DatabaseMetricsRegistrar => {\n\tconst dbPoolCollectorInner = createDbPoolMetricsCollector(registry)\n\tconst entries = new Set<DatabaseMetricsEntry>()\n\tconst collector = () => {\n\t\tdbPoolCollectorInner(entries)\n\t}\n\tregistry.registerCollector(collector)\n\tconst sqlMetricsRegistrar = createSqlMetricsRegistrar(registry)\n\treturn entry => {\n\t\tentries.add(entry)\n\t\tconst sqlMetricsUnregistrar = sqlMetricsRegistrar(entry.connection, entry.labels)\n\t\treturn () => {\n\t\t\tentries.delete(entry)\n\t\t\tsqlMetricsUnregistrar()\n\t\t}\n\t}\n}\n\nconst createDbPoolMetricsCollector = (registry: prom.Registry) => {\n\n\tconst descriptionSuffix = 'Dimensions: contember_module (tenant or content; system is not used since it uses the same connection), contember_project_group, contember_project for contember_module=content, database_instance (single, primary, replica).'\n\tconst totalCount = new prom.Gauge({\n\t\tregisters: [registry],\n\t\tname: `contember_db_pool_total_count`,\n\t\thelp: `The total number of clients existing within the pool: ${descriptionSuffix}`,\n\t\tlabelNames,\n\t})\n\tconst idleCount = new prom.Gauge({\n\t\tregisters: [registry],\n\t\tname: `contember_db_pool_idle_count`,\n\t\thelp: `The number of clients which are not checked out but are currently idle in the pool. ${descriptionSuffix}`,\n\t\tlabelNames,\n\t})\n\tconst waitingCount = new prom.Gauge({\n\t\tregisters: [registry],\n\t\tname: `contember_db_pool_waiting_count`,\n\t\thelp: `The number of queued requests waiting on a client when all clients are checked out. It can be helpful to monitor this number to see if you need to adjust the size of the pool. ${descriptionSuffix}`,\n\t\tlabelNames,\n\t})\n\tconst maxCount = new prom.Gauge({\n\t\tregisters: [registry],\n\t\tname: `contember_db_pool_max_count`,\n\t\thelp: `Maximum number of clients the pool should contain. ${descriptionSuffix}`,\n\t\tlabelNames,\n\t})\n\tconst connectingCount = new prom.Gauge({\n\t\tregisters: [registry],\n\t\tname: `contember_db_pool_connecting_count`,\n\t\thelp: `Current value of clients establishing connection. ${descriptionSuffix}`,\n\t\tlabelNames,\n\t})\n\tconst activeCount = new prom.Gauge({\n\t\tregisters: [registry],\n\t\tname: `contember_db_pool_active_count`,\n\t\thelp: `Number of connections that are checked out. ${descriptionSuffix}`,\n\t\tlabelNames,\n\t})\n\tconst statCounters: {[K in keyof PoolStats]: CustomMetric<LabelNames>} = {} as any\n\tfor (const [key, description] of Object.entries(poolStatsDescription)) {\n\t\tconst customMetric = new CustomMetric<LabelNames>({\n\t\t\tname: `contember_db_pool_${key}`,\n\t\t\thelp: `${description} ${descriptionSuffix}`,\n\t\t\ttype: 'counter',\n\t\t\tlabelNames,\n\t\t})\n\t\tstatCounters[key as keyof PoolStats] = customMetric\n\t\tregistry.registerMetric(customMetric as unknown as prom.Counter<LabelNames>)\n\t}\n\n\treturn (entries: Set<DatabaseMetricsEntry>) => {\n\t\tfor (const counter of Object.values(statCounters)) {\n\t\t\tcounter.reset()\n\t\t}\n\t\tfor (const entry of entries) {\n\t\t\tconst db = entry.connection\n\t\t\tconst labels = entry.labels\n\t\t\tconst poolInfo = db.getPoolStatus()\n\t\t\tif (!poolInfo) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\ttotalCount.set(labels, poolInfo.active + poolInfo.idle + poolInfo.connecting)\n\t\t\tidleCount.set(labels, poolInfo.idle)\n\t\t\twaitingCount.set(labels, poolInfo.pending)\n\t\t\tmaxCount.set(labels, poolInfo.max)\n\t\t\tconnectingCount.set(labels, poolInfo.connecting)\n\t\t\tactiveCount.set(labels, poolInfo.active)\n\n\t\t\tfor (const [key, value] of Object.entries(poolInfo.stats)) {\n\t\t\t\tstatCounters[key as keyof PoolStats].add(labels, value)\n\t\t\t}\n\t\t}\n\t}\n}\ntype SqlMetricsRegistrar = (\n\tconnection: Connection.Queryable,\n\tlabels: Labels,\n) => Unregistrar\nconst createSqlMetricsRegistrar = (registry: prom.Registry): SqlMetricsRegistrar => {\n\tconst sqlDuration = new prom.Histogram({\n\t\tname: 'contember_sql_duration_ms',\n\t\thelp: 'Executed SQL queries by contember_module (system, tenant, content or unknown) and contember_project (or \"unknown\" for unknown project)',\n\t\tregisters: [registry],\n\t\tlabelNames,\n\t\tbuckets: [1, 2, 5, 10, 25, 50, 100, 250, 500, 1000],\n\t})\n\tconst sqlErrorRate = new prom.Counter({\n\t\tname: 'contember_sql_error_count',\n\t\thelp: 'Failed SQL queries by contember_module (system, tenant, content or unknown) and contember_project (or \"unknown\" for unknown project)',\n\t\tlabelNames,\n\t\tregisters: [registry],\n\t})\n\n\treturn (connection, labels) => {\n\t\tconst queryEndCallback: EventManager.ListenerTypes[EventManager.Event.queryEnd] = ({ meta }, { timing }) => {\n\t\t\tsqlDuration.observe(\n\t\t\t\t{\n\t\t\t\t\t...labels,\n\t\t\t\t\tcontember_module: meta.module || labels.contember_module,\n\t\t\t\t},\n\t\t\t\ttiming ? Math.round(timing.selfDuration / 1000) : 0,\n\t\t\t)\n\t\t}\n\t\tconst queryErrorCallback: EventManager.ListenerTypes[EventManager.Event.queryError] = ({ meta }) => {\n\t\t\tsqlErrorRate.inc({\n\t\t\t\t...labels,\n\t\t\t\tcontember_module: meta.module || labels.contember_module,\n\t\t\t})\n\t\t}\n\t\tconnection.eventManager.on(EventManager.Event.queryEnd, queryEndCallback)\n\t\tconnection.eventManager.on(EventManager.Event.queryError, queryErrorCallback)\n\t\treturn () => {\n\t\t\tconnection.eventManager.removeListener(EventManager.Event.queryEnd, queryEndCallback)\n\t\t\tconnection.eventManager.removeListener(EventManager.Event.queryError, queryErrorCallback)\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;AAOA,MAAM,aAAa,CAAC,qBAA8B,oBAA6B,2BAAoC,mBAAmB;AAUzH,MAAA,2BAA2B,CAAC,aAAsD;AACxF,QAAA,uBAAuB,6BAA6B,QAAQ;AAC5D,QAAA,8BAAc,IAA0B;AAC9C,QAAM,YAAY,MAAM;AACvB,yBAAqB,OAAO;AAAA,EAC7B;AACA,WAAS,kBAAkB,SAAS;AAC9B,QAAA,sBAAsB,0BAA0B,QAAQ;AAC9D,SAAO,CAAS,UAAA;AACf,YAAQ,IAAI,KAAK;AACjB,UAAM,wBAAwB,oBAAoB,MAAM,YAAY,MAAM,MAAM;AAChF,WAAO,MAAM;AACZ,cAAQ,OAAO,KAAK;AACE,4BAAA;AAAA,IACvB;AAAA,EACD;AACD;AAEA,MAAM,+BAA+B,CAAC,aAA4B;AAEjE,QAAM,oBAAoB;AACpB,QAAA,aAAa,IAAI,KAAK,MAAM;AAAA,IACjC,WAAW,CAAC,QAAQ;AAAA,IACpB,MAAM;AAAA,IACN,MAAM,yDAAyD,iBAAiB;AAAA,IAChF;AAAA,EAAA,CACA;AACK,QAAA,YAAY,IAAI,KAAK,MAAM;AAAA,IAChC,WAAW,CAAC,QAAQ;AAAA,IACpB,MAAM;AAAA,IACN,MAAM,uFAAuF,iBAAiB;AAAA,IAC9G;AAAA,EAAA,CACA;AACK,QAAA,eAAe,IAAI,KAAK,MAAM;AAAA,IACnC,WAAW,CAAC,QAAQ;AAAA,IACpB,MAAM;AAAA,IACN,MAAM,mLAAmL,iBAAiB;AAAA,IAC1M;AAAA,EAAA,CACA;A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cjs","sources":["../../../../packages/engine-http/src/providers.ts"],"sourcesContent":["import { v4 as uuidv4 } from 'uuid'\nimport bcrypt from 'bcryptjs'\nimport crypto, { BinaryLike } from 'node:crypto'\n\n\nexport const createProviders = () => ({\n\tuuid: () => uuidv4(),\n\tnow: () => new Date(),\n\tbcrypt: async (value: string) => await bcrypt.hash(value, 10),\n\tbcryptCompare: (data: any, hash: string) => bcrypt.compare(data, hash),\n\trandomBytes: async (bytes: number) =>\n\t\tawait new Promise<Buffer>((resolve, reject) => {\n\t\t\tcrypto.randomBytes(bytes, (error, buffer) => {\n\t\t\t\tif (error) {\n\t\t\t\t\treject(error)\n\t\t\t\t} else {\n\t\t\t\t\tresolve(buffer)\n\t\t\t\t}\n\t\t\t})\n\t\t}),\n\thash: (value: BinaryLike, algo: string): Buffer => (\n\t\tcrypto.createHash(algo).update(value).digest()\n\t),\n})\n\nexport type Providers = ReturnType<typeof createProviders>\n"],"names":["uuidv4"],"mappings":";;;;;AAKO,MAAM,kBAAkB,OAAO;AAAA,EACrC,MAAM,MAAMA,KAAAA,GAAO;AAAA,EACnB,KAAK,MAAM,oBAAI,KAAK;AAAA,EACpB,QAAQ,OAAO,UAAkB,MAAM,OAAO,KAAK,OAAO,EAAE;AAAA,EAC5D,eAAe,CAAC,MAAW,SAAiB,OAAO,QAAQ,MAAM,IAAI;AAAA,EACrE,aAAa,OAAO,UACnB,MAAM,IAAI,QAAgB,CAAC,SAAS,WAAW;AAC9C,WAAO,YAAY,OAAO,CAAC,OAAO,WAAW;AAC5C,UAAI,OAAO;AACV,eAAO,KAAK;AAAA,MAAA,OACN;AACN,gBAAQ,MAAM;AAAA,MACf;AAAA,IAAA,CACA;AAAA,EAAA,CACD;AAAA,EACF,MAAM,CAAC,OAAmB,SACzB,OAAO,WAAW,IAAI,EAAE,OAAO,KAAK,EAAE,OAAO;AAE/C;;"}
1
+ {"version":3,"file":"providers.cjs","sources":["../../../../packages/engine-http/src/providers.ts"],"sourcesContent":["import { v4 as uuidv4 } from 'uuid'\nimport bcrypt from 'bcryptjs'\nimport crypto, { BinaryLike } from 'node:crypto'\n\n\nexport const createProviders = () => ({\n\tuuid: () => uuidv4(),\n\tnow: () => new Date(),\n\tbcrypt: async (value: string) => await bcrypt.hash(value, 10),\n\tbcryptCompare: (data: any, hash: string) => bcrypt.compare(data, hash),\n\trandomBytes: async (bytes: number) =>\n\t\tawait new Promise<Buffer>((resolve, reject) => {\n\t\t\tcrypto.randomBytes(bytes, (error, buffer) => {\n\t\t\t\tif (error) {\n\t\t\t\t\treject(error)\n\t\t\t\t} else {\n\t\t\t\t\tresolve(buffer)\n\t\t\t\t}\n\t\t\t})\n\t\t}),\n\thash: (value: BinaryLike, algo: string): Buffer => (\n\t\tcrypto.createHash(algo).update(value).digest()\n\t),\n})\n\nexport type Providers = ReturnType<typeof createProviders>\n"],"names":["uuidv4"],"mappings":";;;;;AAKO,MAAM,kBAAkB,OAAO;AAAA,EACrC,MAAM,MAAMA,KAAAA,GAAO;AAAA,EACnB,KAAK,MAAM,oBAAI,KAAK;AAAA,EACpB,QAAQ,OAAO,UAAkB,MAAM,OAAO,KAAK,OAAO,EAAE;AAAA,EAC5D,eAAe,CAAC,MAAW,SAAiB,OAAO,QAAQ,MAAM,IAAI;AAAA,EACrE,aAAa,OAAO,UACnB,MAAM,IAAI,QAAgB,CAAC,SAAS,WAAW;AAC9C,WAAO,YAAY,OAAO,CAAC,OAAO,WAAW;AAC5C,UAAI,OAAO;AACV,eAAO,KAAK;AAAA,MAAA,OACN;AACN,gBAAQ,MAAM;AAAA,MAAA;AAAA,IACf,CACA;AAAA,EAAA,CACD;AAAA,EACF,MAAM,CAAC,OAAmB,SACzB,OAAO,WAAW,IAAI,EAAE,OAAO,KAAK,EAAE,OAAO;AAE/C;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"providers.js","sources":["../../../../packages/engine-http/src/providers.ts"],"sourcesContent":["import { v4 as uuidv4 } from 'uuid'\nimport bcrypt from 'bcryptjs'\nimport crypto, { BinaryLike } from 'node:crypto'\n\n\nexport const createProviders = () => ({\n\tuuid: () => uuidv4(),\n\tnow: () => new Date(),\n\tbcrypt: async (value: string) => await bcrypt.hash(value, 10),\n\tbcryptCompare: (data: any, hash: string) => bcrypt.compare(data, hash),\n\trandomBytes: async (bytes: number) =>\n\t\tawait new Promise<Buffer>((resolve, reject) => {\n\t\t\tcrypto.randomBytes(bytes, (error, buffer) => {\n\t\t\t\tif (error) {\n\t\t\t\t\treject(error)\n\t\t\t\t} else {\n\t\t\t\t\tresolve(buffer)\n\t\t\t\t}\n\t\t\t})\n\t\t}),\n\thash: (value: BinaryLike, algo: string): Buffer => (\n\t\tcrypto.createHash(algo).update(value).digest()\n\t),\n})\n\nexport type Providers = ReturnType<typeof createProviders>\n"],"names":["uuidv4","crypto"],"mappings":";;;AAKO,MAAM,kBAAkB,OAAO;AAAA,EACrC,MAAM,MAAMA,GAAO;AAAA,EACnB,KAAK,MAAM,oBAAI,KAAK;AAAA,EACpB,QAAQ,OAAO,UAAkB,MAAM,OAAO,KAAK,OAAO,EAAE;AAAA,EAC5D,eAAe,CAAC,MAAW,SAAiB,OAAO,QAAQ,MAAM,IAAI;AAAA,EACrE,aAAa,OAAO,UACnB,MAAM,IAAI,QAAgB,CAAC,SAAS,WAAW;AAC9CC,oBAAO,YAAY,OAAO,CAAC,OAAO,WAAW;AAC5C,UAAI,OAAO;AACV,eAAO,KAAK;AAAA,MAAA,OACN;AACN,gBAAQ,MAAM;AAAA,MACf;AAAA,IAAA,CACA;AAAA,EAAA,CACD;AAAA,EACF,MAAM,CAAC,OAAmB,SACzBA,gBAAO,WAAW,IAAI,EAAE,OAAO,KAAK,EAAE,OAAO;AAE/C;"}
1
+ {"version":3,"file":"providers.js","sources":["../../../../packages/engine-http/src/providers.ts"],"sourcesContent":["import { v4 as uuidv4 } from 'uuid'\nimport bcrypt from 'bcryptjs'\nimport crypto, { BinaryLike } from 'node:crypto'\n\n\nexport const createProviders = () => ({\n\tuuid: () => uuidv4(),\n\tnow: () => new Date(),\n\tbcrypt: async (value: string) => await bcrypt.hash(value, 10),\n\tbcryptCompare: (data: any, hash: string) => bcrypt.compare(data, hash),\n\trandomBytes: async (bytes: number) =>\n\t\tawait new Promise<Buffer>((resolve, reject) => {\n\t\t\tcrypto.randomBytes(bytes, (error, buffer) => {\n\t\t\t\tif (error) {\n\t\t\t\t\treject(error)\n\t\t\t\t} else {\n\t\t\t\t\tresolve(buffer)\n\t\t\t\t}\n\t\t\t})\n\t\t}),\n\thash: (value: BinaryLike, algo: string): Buffer => (\n\t\tcrypto.createHash(algo).update(value).digest()\n\t),\n})\n\nexport type Providers = ReturnType<typeof createProviders>\n"],"names":["uuidv4","crypto"],"mappings":";;;AAKO,MAAM,kBAAkB,OAAO;AAAA,EACrC,MAAM,MAAMA,GAAO;AAAA,EACnB,KAAK,MAAM,oBAAI,KAAK;AAAA,EACpB,QAAQ,OAAO,UAAkB,MAAM,OAAO,KAAK,OAAO,EAAE;AAAA,EAC5D,eAAe,CAAC,MAAW,SAAiB,OAAO,QAAQ,MAAM,IAAI;AAAA,EACrE,aAAa,OAAO,UACnB,MAAM,IAAI,QAAgB,CAAC,SAAS,WAAW;AAC9CC,oBAAO,YAAY,OAAO,CAAC,OAAO,WAAW;AAC5C,UAAI,OAAO;AACV,eAAO,KAAK;AAAA,MAAA,OACN;AACN,gBAAQ,MAAM;AAAA,MAAA;AAAA,IACf,CACA;AAAA,EAAA,CACD;AAAA,EACF,MAAM,CAAC,OAAmB,SACzBA,gBAAO,WAAW,IAAI,EAAE,OAAO,KAAK,EAAE,OAAO;AAE/C;"}
@@ -11,7 +11,7 @@ class ContentQueryExecutorImpl {
11
11
  this.executionContainerFactory = executionContainerFactory;
12
12
  this.graphqlSchemaBuilderFactory = graphqlSchemaBuilderFactory;
13
13
  }
14
- async execute({ db, schema, databaseMetadata, stage, project, identity }, { query, variables }) {
14
+ async execute({ db, schema, schemaMeta, databaseMetadata, stage, project, identity }, { query, variables }) {
15
15
  const permissions = new schemaUtils.AllowAllPermissionFactory().create(schema.model, true);
16
16
  const authorizator = new engineContentApi.Authorizator(permissions, true);
17
17
  const dataSchemaBuilder = this.graphqlSchemaBuilderFactory.create(schema.model, authorizator);
@@ -22,6 +22,7 @@ class ContentQueryExecutorImpl {
22
22
  identityVariables: {},
23
23
  identityId,
24
24
  schema,
25
+ schemaMeta,
25
26
  schemaDatabaseMetadata: databaseMetadata,
26
27
  permissions,
27
28
  systemSchema: project.systemSchema,
@@ -29,6 +30,7 @@ class ContentQueryExecutorImpl {
29
30
  project
30
31
  });
31
32
  const ctx = {
33
+ project,
32
34
  db: db.client.forSchema(stage.schema),
33
35
  identityVariables: {},
34
36
  identityId,
@@ -1 +1 @@
1
- {"version":3,"file":"ContentQueryExecutor.cjs","sources":["../../../../../packages/engine-http/src/system/ContentQueryExecutor.ts"],"sourcesContent":["import {\n\tContentQueryExecutor,\n\tContentQueryExecutorContext,\n\tContentQueryExecutorQuery,\n\tContentQueryExecutorResult,\n} from '@contember/engine-system-api'\nimport { Authorizator, ExecutionContainerFactory, GraphQlSchemaBuilderFactory } from '@contember/engine-content-api'\nimport { AllowAllPermissionFactory } from '@contember/schema-utils'\nimport { graphql, GraphQLError } from 'graphql'\nimport { ExtendedGraphqlContext } from '../content'\nimport { extractOriginalError } from '../graphql'\nimport { logger } from '@contember/logger'\n\nexport class ContentQueryExecutorImpl implements ContentQueryExecutor {\n\tconstructor(\n\t\tprivate readonly executionContainerFactory: ExecutionContainerFactory,\n\t\tprivate readonly graphqlSchemaBuilderFactory: GraphQlSchemaBuilderFactory,\n\t) {\n\t}\n\n\tpublic async execute({ db, schema, databaseMetadata, stage, project, identity }: ContentQueryExecutorContext, { query, variables }: ContentQueryExecutorQuery): Promise<ContentQueryExecutorResult> {\n\t\tconst permissions = new AllowAllPermissionFactory().create(schema.model, true)\n\t\tconst authorizator = new Authorizator(permissions, true)\n\t\tconst dataSchemaBuilder = this.graphqlSchemaBuilderFactory.create(schema.model, authorizator)\n\t\tconst dataSchema = dataSchemaBuilder.build()\n\n\t\tconst identityId = identity.id\n\n\t\tconst executionContainer = this.executionContainerFactory.create({\n\t\t\tdb: db.client.forSchema(stage.schema),\n\t\t\tidentityVariables: {},\n\t\t\tidentityId,\n\t\t\tschema,\n\t\t\tschemaDatabaseMetadata: databaseMetadata,\n\t\t\tpermissions,\n\t\t\tsystemSchema: project.systemSchema,\n\t\t\tstage,\n\t\t\tproject: project,\n\t\t})\n\n\t\tconst ctx: ExtendedGraphqlContext = {\n\t\t\tdb: db.client.forSchema(stage.schema),\n\t\t\tidentityVariables: {},\n\t\t\tidentityId,\n\t\t\trequestDebug: false,\n\t\t\texecutionContainer,\n\t\t\ttimer: (label, cb) => cb(),\n\t\t}\n\n\t\ttry {\n\t\t\tconst result = await graphql({\n\t\t\t\tschema: dataSchema,\n\t\t\t\tsource: query,\n\t\t\t\tvariableValues: variables,\n\t\t\t\tcontextValue: ctx,\n\t\t\t})\n\t\t\tif (result.errors?.length) {\n\t\t\t\treturn { ok: false, errors: result.errors.map(formatErrorMessage) }\n\t\t\t}\n\t\t\treturn { ok: true, result }\n\t\t} catch (e) {\n\t\t\treturn { ok: false, errors: [formatErrorMessage(e)] }\n\t\t}\n\t}\n}\n\nconst formatErrorMessage = (e: any): string => {\n\tconst originalError = extractOriginalError(e)\n\tif (originalError instanceof GraphQLError) {\n\t\treturn originalError.message\n\t}\n\tconst errorDetails = typeof originalError === 'object'\n\t\t&& originalError !== null\n\t\t&& 'message' in originalError ? `: ${originalError.message}` : ''\n\n\tlogger.error(e)\n\n\treturn `Internal error${errorDetails}`\n}\n"],"names":["AllowAllPermissionFactory","Authorizator","graphql","extractOriginalError","GraphQLError","logger"],"mappings":";;;;;;;;AAaO,MAAM,yBAAyD;AAAA,EACrE,YACkB,2BACA,6BAChB;AAFgB,SAAA,4BAAA;AACA,SAAA,8BAAA;AAAA,EAElB;AAAA,EAEA,MAAa,QAAQ,EAAE,IAAI,QAAQ,kBAAkB,OAAO,SA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AAa,gBAAgB,KAAK,cAAc,OAAO,KAAK;AAEhEC,gBAAO,MAAM,CAAC;AAEd,SAAO,iBAAiB,YAAY;AACrC;;"}
1
+ {"version":3,"file":"ContentQueryExecutor.cjs","sources":["../../../../../packages/engine-http/src/system/ContentQueryExecutor.ts"],"sourcesContent":["import {\n\tContentQueryExecutor,\n\tContentQueryExecutorContext,\n\tContentQueryExecutorQuery,\n\tContentQueryExecutorResult,\n} from '@contember/engine-system-api'\nimport { Authorizator, ExecutionContainerFactory, GraphQlSchemaBuilderFactory } from '@contember/engine-content-api'\nimport { AllowAllPermissionFactory } from '@contember/schema-utils'\nimport { graphql, GraphQLError } from 'graphql'\nimport { ExtendedGraphqlContext } from '../content'\nimport { extractOriginalError } from '../graphql'\nimport { logger } from '@contember/logger'\n\nexport class ContentQueryExecutorImpl implements ContentQueryExecutor {\n\tconstructor(\n\t\tprivate readonly executionContainerFactory: ExecutionContainerFactory,\n\t\tprivate readonly graphqlSchemaBuilderFactory: GraphQlSchemaBuilderFactory,\n\t) {\n\t}\n\n\tpublic async execute({ db, schema, schemaMeta, databaseMetadata, stage, project, identity }: ContentQueryExecutorContext, { query, variables }: ContentQueryExecutorQuery): Promise<ContentQueryExecutorResult> {\n\t\tconst permissions = new AllowAllPermissionFactory().create(schema.model, true)\n\t\tconst authorizator = new Authorizator(permissions, true)\n\t\tconst dataSchemaBuilder = this.graphqlSchemaBuilderFactory.create(schema.model, authorizator)\n\t\tconst dataSchema = dataSchemaBuilder.build()\n\n\t\tconst identityId = identity.id\n\n\t\tconst executionContainer = this.executionContainerFactory.create({\n\t\t\tdb: db.client.forSchema(stage.schema),\n\t\t\tidentityVariables: {},\n\t\t\tidentityId,\n\t\t\tschema,\n\t\t\tschemaMeta,\n\t\t\tschemaDatabaseMetadata: databaseMetadata,\n\t\t\tpermissions,\n\t\t\tsystemSchema: project.systemSchema,\n\t\t\tstage,\n\t\t\tproject: project,\n\t\t})\n\n\t\tconst ctx: ExtendedGraphqlContext = {\n\t\t\tproject,\n\t\t\tdb: db.client.forSchema(stage.schema),\n\t\t\tidentityVariables: {},\n\t\t\tidentityId,\n\t\t\trequestDebug: false,\n\t\t\texecutionContainer,\n\t\t\ttimer: (label, cb) => cb(),\n\t\t}\n\n\t\ttry {\n\t\t\tconst result = await graphql({\n\t\t\t\tschema: dataSchema,\n\t\t\t\tsource: query,\n\t\t\t\tvariableValues: variables,\n\t\t\t\tcontextValue: ctx,\n\t\t\t})\n\t\t\tif (result.errors?.length) {\n\t\t\t\treturn { ok: false, errors: result.errors.map(formatErrorMessage) }\n\t\t\t}\n\t\t\treturn { ok: true, result }\n\t\t} catch (e) {\n\t\t\treturn { ok: false, errors: [formatErrorMessage(e)] }\n\t\t}\n\t}\n}\n\nconst formatErrorMessage = (e: any): string => {\n\tconst originalError = extractOriginalError(e)\n\tif (originalError instanceof GraphQLError) {\n\t\treturn originalError.message\n\t}\n\tconst errorDetails = typeof originalError === 'object'\n\t\t&& originalError !== null\n\t\t&& 'message' in originalError ? `: ${originalError.message}` : ''\n\n\tlogger.error(e)\n\n\treturn `Internal error${errorDetails}`\n}\n"],"names":["AllowAllPermissionFactory","Authorizator","graphql","extractOriginalError","GraphQLError","logger"],"mappings":";;;;;;;;AAaO,MAAM,yBAAyD;AAAA,EACrE,YACkB,2BACA,6BAChB;AAFgB,SAAA,4BAAA;AACA,SAAA,8BAAA;AAAA,EAAA;AAAA,EAIlB,MAAa,QAAQ,EAAE,IAAI,QAAQ,YAAY,kBAAkB,OAAO,SAAS,SAAS,GAAgC,EAAE,OAAO,aAA6E;AAC/M,UAAM,cAAc,IAAIA,wCAA4B,OAAO,OAAO,OAAO,IAAI;AAC7E,UAAM,eAAe,IAAIC,8BAAa,aAAa,IAAI;AACvD,UAAM,oBAAoB,KAAK,4BAA4B,OAAO,OAAO,OAAO,YAAY;AACtF,UAAA,aAAa,kBAAkB,MAAM;AAE3C,UAAM,aAAa,SAAS;AAEtB,UAAA,qBAAqB,KAAK,0BAA0B,OAAO;AAAA,MAChE,IAAI,GAAG,OAAO,UAAU,MAAM,MAAM;AAAA,MACpC,mBAAmB,CAAC;AAAA,MACpB;AAAA,MACA;AAAA,MACA;AAAA,MACA,wBAAwB;AAAA,MACxB;AAAA,MACA,cAAc,QAAQ;AAAA,MACtB;AAAA,MACA;AAAA,IAAA,CACA;AAED,UAAM,MAA8B;AAAA,MACnC;AAAA,MACA,IAAI,GAAG,OAAO,UAAU,MAAM,MAAM;AAAA,MACpC,mBAAmB,CAAC;AAAA,MACpB;AAAA,MACA,cAAc;AAAA,MACd;AAAA,MACA,OAAO,CAAC,OAAO,OAAO,GAAG;AAAA,IAC1B;AAEI,QAAA;AACG,YAAA,SAAS,MAAMC,gBAAQ;AAAA,QAC5B,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,gBAAgB;AAAA,QAChB,cAAc;AAAA,MAAA,CACd;AACG,UAAA,OAAO,QAAQ,QAAQ;AACnB,eAAA,EAAE,IAAI,OAAO,QAAQ,OAAO,OAAO,IAAI,kBAAkB,EAAE;AAAA,MAAA;AAE5D,aAAA,EAAE,IAAI,MAAM,OAAO;AAAA,aAClB,GAAG;AACJ,aAAA,EAAE,IAAI,OAAO,QAAQ,CAAC,mBAAmB,CAAC,CAAC,EAAE;AAAA,IAAA;AAAA,EACrD;AAEF;AAEA,MAAM,qBAAqB,CAAC,MAAmB;AACxC,QAAA,gBAAgBC,+BAAqB,CAAC;AAC5C,MAAI,yBAAyBC,QAAAA,cAAc;AAC1C,WAAO,cAAc;AAAA,EAAA;AAEhB,QAAA,eAAe,OAAO,kBAAkB,YAC1C,kBAAkB,QAClB,aAAa,gBAAgB,KAAK,cAAc,OAAO,KAAK;AAEhEC,SAAA,OAAO,MAAM,CAAC;AAEd,SAAO,iBAAiB,YAAY;AACrC;;"}
@@ -9,7 +9,7 @@ class ContentQueryExecutorImpl {
9
9
  this.executionContainerFactory = executionContainerFactory;
10
10
  this.graphqlSchemaBuilderFactory = graphqlSchemaBuilderFactory;
11
11
  }
12
- async execute({ db, schema, databaseMetadata, stage, project, identity }, { query, variables }) {
12
+ async execute({ db, schema, schemaMeta, databaseMetadata, stage, project, identity }, { query, variables }) {
13
13
  const permissions = new AllowAllPermissionFactory().create(schema.model, true);
14
14
  const authorizator = new Authorizator(permissions, true);
15
15
  const dataSchemaBuilder = this.graphqlSchemaBuilderFactory.create(schema.model, authorizator);
@@ -20,6 +20,7 @@ class ContentQueryExecutorImpl {
20
20
  identityVariables: {},
21
21
  identityId,
22
22
  schema,
23
+ schemaMeta,
23
24
  schemaDatabaseMetadata: databaseMetadata,
24
25
  permissions,
25
26
  systemSchema: project.systemSchema,
@@ -27,6 +28,7 @@ class ContentQueryExecutorImpl {
27
28
  project
28
29
  });
29
30
  const ctx = {
31
+ project,
30
32
  db: db.client.forSchema(stage.schema),
31
33
  identityVariables: {},
32
34
  identityId,
@@ -1 +1 @@
1
- {"version":3,"file":"ContentQueryExecutor.js","sources":["../../../../../packages/engine-http/src/system/ContentQueryExecutor.ts"],"sourcesContent":["import {\n\tContentQueryExecutor,\n\tContentQueryExecutorContext,\n\tContentQueryExecutorQuery,\n\tContentQueryExecutorResult,\n} from '@contember/engine-system-api'\nimport { Authorizator, ExecutionContainerFactory, GraphQlSchemaBuilderFactory } from '@contember/engine-content-api'\nimport { AllowAllPermissionFactory } from '@contember/schema-utils'\nimport { graphql, GraphQLError } from 'graphql'\nimport { ExtendedGraphqlContext } from '../content'\nimport { extractOriginalError } from '../graphql'\nimport { logger } from '@contember/logger'\n\nexport class ContentQueryExecutorImpl implements ContentQueryExecutor {\n\tconstructor(\n\t\tprivate readonly executionContainerFactory: ExecutionContainerFactory,\n\t\tprivate readonly graphqlSchemaBuilderFactory: GraphQlSchemaBuilderFactory,\n\t) {\n\t}\n\n\tpublic async execute({ db, schema, databaseMetadata, stage, project, identity }: ContentQueryExecutorContext, { query, variables }: ContentQueryExecutorQuery): Promise<ContentQueryExecutorResult> {\n\t\tconst permissions = new AllowAllPermissionFactory().create(schema.model, true)\n\t\tconst authorizator = new Authorizator(permissions, true)\n\t\tconst dataSchemaBuilder = this.graphqlSchemaBuilderFactory.create(schema.model, authorizator)\n\t\tconst dataSchema = dataSchemaBuilder.build()\n\n\t\tconst identityId = identity.id\n\n\t\tconst executionContainer = this.executionContainerFactory.create({\n\t\t\tdb: db.client.forSchema(stage.schema),\n\t\t\tidentityVariables: {},\n\t\t\tidentityId,\n\t\t\tschema,\n\t\t\tschemaDatabaseMetadata: databaseMetadata,\n\t\t\tpermissions,\n\t\t\tsystemSchema: project.systemSchema,\n\t\t\tstage,\n\t\t\tproject: project,\n\t\t})\n\n\t\tconst ctx: ExtendedGraphqlContext = {\n\t\t\tdb: db.client.forSchema(stage.schema),\n\t\t\tidentityVariables: {},\n\t\t\tidentityId,\n\t\t\trequestDebug: false,\n\t\t\texecutionContainer,\n\t\t\ttimer: (label, cb) => cb(),\n\t\t}\n\n\t\ttry {\n\t\t\tconst result = await graphql({\n\t\t\t\tschema: dataSchema,\n\t\t\t\tsource: query,\n\t\t\t\tvariableValues: variables,\n\t\t\t\tcontextValue: ctx,\n\t\t\t})\n\t\t\tif (result.errors?.length) {\n\t\t\t\treturn { ok: false, errors: result.errors.map(formatErrorMessage) }\n\t\t\t}\n\t\t\treturn { ok: true, result }\n\t\t} catch (e) {\n\t\t\treturn { ok: false, errors: [formatErrorMessage(e)] }\n\t\t}\n\t}\n}\n\nconst formatErrorMessage = (e: any): string => {\n\tconst originalError = extractOriginalError(e)\n\tif (originalError instanceof GraphQLError) {\n\t\treturn originalError.message\n\t}\n\tconst errorDetails = typeof originalError === 'object'\n\t\t&& originalError !== null\n\t\t&& 'message' in originalError ? `: ${originalError.message}` : ''\n\n\tlogger.error(e)\n\n\treturn `Internal error${errorDetails}`\n}\n"],"names":[],"mappings":";;;;;;AAaO,MAAM,yBAAyD;AAAA,EACrE,YACkB,2BACA,6BAChB;AAFgB,SAAA,4BAAA;AACA,SAAA,8BAAA;AAAA,EAElB;AAAA,EAEA,MAAa,QAA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,kBAAkB,QAClB,aAAa,gBAAgB,KAAK,cAAc,OAAO,KAAK;AAEhE,SAAO,MAAM,CAAC;AAEd,SAAO,iBAAiB,YAAY;AACrC;"}
1
+ {"version":3,"file":"ContentQueryExecutor.js","sources":["../../../../../packages/engine-http/src/system/ContentQueryExecutor.ts"],"sourcesContent":["import {\n\tContentQueryExecutor,\n\tContentQueryExecutorContext,\n\tContentQueryExecutorQuery,\n\tContentQueryExecutorResult,\n} from '@contember/engine-system-api'\nimport { Authorizator, ExecutionContainerFactory, GraphQlSchemaBuilderFactory } from '@contember/engine-content-api'\nimport { AllowAllPermissionFactory } from '@contember/schema-utils'\nimport { graphql, GraphQLError } from 'graphql'\nimport { ExtendedGraphqlContext } from '../content'\nimport { extractOriginalError } from '../graphql'\nimport { logger } from '@contember/logger'\n\nexport class ContentQueryExecutorImpl implements ContentQueryExecutor {\n\tconstructor(\n\t\tprivate readonly executionContainerFactory: ExecutionContainerFactory,\n\t\tprivate readonly graphqlSchemaBuilderFactory: GraphQlSchemaBuilderFactory,\n\t) {\n\t}\n\n\tpublic async execute({ db, schema, schemaMeta, databaseMetadata, stage, project, identity }: ContentQueryExecutorContext, { query, variables }: ContentQueryExecutorQuery): Promise<ContentQueryExecutorResult> {\n\t\tconst permissions = new AllowAllPermissionFactory().create(schema.model, true)\n\t\tconst authorizator = new Authorizator(permissions, true)\n\t\tconst dataSchemaBuilder = this.graphqlSchemaBuilderFactory.create(schema.model, authorizator)\n\t\tconst dataSchema = dataSchemaBuilder.build()\n\n\t\tconst identityId = identity.id\n\n\t\tconst executionContainer = this.executionContainerFactory.create({\n\t\t\tdb: db.client.forSchema(stage.schema),\n\t\t\tidentityVariables: {},\n\t\t\tidentityId,\n\t\t\tschema,\n\t\t\tschemaMeta,\n\t\t\tschemaDatabaseMetadata: databaseMetadata,\n\t\t\tpermissions,\n\t\t\tsystemSchema: project.systemSchema,\n\t\t\tstage,\n\t\t\tproject: project,\n\t\t})\n\n\t\tconst ctx: ExtendedGraphqlContext = {\n\t\t\tproject,\n\t\t\tdb: db.client.forSchema(stage.schema),\n\t\t\tidentityVariables: {},\n\t\t\tidentityId,\n\t\t\trequestDebug: false,\n\t\t\texecutionContainer,\n\t\t\ttimer: (label, cb) => cb(),\n\t\t}\n\n\t\ttry {\n\t\t\tconst result = await graphql({\n\t\t\t\tschema: dataSchema,\n\t\t\t\tsource: query,\n\t\t\t\tvariableValues: variables,\n\t\t\t\tcontextValue: ctx,\n\t\t\t})\n\t\t\tif (result.errors?.length) {\n\t\t\t\treturn { ok: false, errors: result.errors.map(formatErrorMessage) }\n\t\t\t}\n\t\t\treturn { ok: true, result }\n\t\t} catch (e) {\n\t\t\treturn { ok: false, errors: [formatErrorMessage(e)] }\n\t\t}\n\t}\n}\n\nconst formatErrorMessage = (e: any): string => {\n\tconst originalError = extractOriginalError(e)\n\tif (originalError instanceof GraphQLError) {\n\t\treturn originalError.message\n\t}\n\tconst errorDetails = typeof originalError === 'object'\n\t\t&& originalError !== null\n\t\t&& 'message' in originalError ? `: ${originalError.message}` : ''\n\n\tlogger.error(e)\n\n\treturn `Internal error${errorDetails}`\n}\n"],"names":[],"mappings":";;;;;;AAaO,MAAM,yBAAyD;AAAA,EACrE,YACkB,2BACA,6BAChB;AAFgB,SAAA,4BAAA;AACA,SAAA,8BAAA;AAAA,EAAA;AAAA,EAIlB,MAAa,QAAQ,EAAE,IAAI,QAAQ,YAAY,kBAAkB,OAAO,SAAS,SAAS,GAAgC,EAAE,OAAO,aAA6E;AAC/M,UAAM,cAAc,IAAI,4BAA4B,OAAO,OAAO,OAAO,IAAI;AAC7E,UAAM,eAAe,IAAI,aAAa,aAAa,IAAI;AACvD,UAAM,oBAAoB,KAAK,4BAA4B,OAAO,OAAO,OAAO,YAAY;AACtF,UAAA,aAAa,kBAAkB,MAAM;AAE3C,UAAM,aAAa,SAAS;AAEtB,UAAA,qBAAqB,KAAK,0BAA0B,OAAO;AAAA,MAChE,IAAI,GAAG,OAAO,UAAU,MAAM,MA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