@contember/engine-http 2.1.0-beta.2 → 2.2.0-alpha.2

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 (556) hide show
  1. package/CLAUDE.md +2 -0
  2. package/dist/development/index.cjs +11 -0
  3. package/dist/development/index.cjs.map +1 -1
  4. package/dist/development/index.js +12 -1
  5. package/dist/development/index.js.map +1 -1
  6. package/dist/development/src/MasterContainer.cjs +48 -7
  7. package/dist/development/src/MasterContainer.cjs.map +1 -1
  8. package/dist/development/src/MasterContainer.js +48 -7
  9. package/dist/development/src/MasterContainer.js.map +1 -1
  10. package/dist/development/src/application/application.cjs +36 -7
  11. package/dist/development/src/application/application.cjs.map +1 -1
  12. package/dist/development/src/application/application.js +36 -7
  13. package/dist/development/src/application/application.js.map +1 -1
  14. package/dist/development/src/application/forceHttpOk.cjs +34 -0
  15. package/dist/development/src/application/forceHttpOk.cjs.map +1 -0
  16. package/dist/development/src/application/forceHttpOk.js +34 -0
  17. package/dist/development/src/application/forceHttpOk.js.map +1 -0
  18. package/dist/development/src/bootstrap/Initializer.cjs.map +1 -1
  19. package/dist/development/src/bootstrap/Initializer.js.map +1 -1
  20. package/dist/development/src/common/Authorizator.cjs +61 -4
  21. package/dist/development/src/common/Authorizator.cjs.map +1 -1
  22. package/dist/development/src/common/Authorizator.js +61 -4
  23. package/dist/development/src/common/Authorizator.js.map +1 -1
  24. package/dist/development/src/common/ModuleInfoMiddleware.cjs.map +1 -1
  25. package/dist/development/src/common/ModuleInfoMiddleware.js.map +1 -1
  26. package/dist/development/src/common/NotFoundMiddleware.cjs +15 -0
  27. package/dist/development/src/common/NotFoundMiddleware.cjs.map +1 -0
  28. package/dist/development/src/common/NotFoundMiddleware.js +15 -0
  29. package/dist/development/src/common/NotFoundMiddleware.js.map +1 -0
  30. package/dist/development/src/config/config.cjs.map +1 -1
  31. package/dist/development/src/config/config.js.map +1 -1
  32. package/dist/development/src/config/configSchema.cjs +64 -2
  33. package/dist/development/src/config/configSchema.cjs.map +1 -1
  34. package/dist/development/src/config/configSchema.js +64 -2
  35. package/dist/development/src/config/configSchema.js.map +1 -1
  36. package/dist/development/src/config/configTemplate.cjs +13 -2
  37. package/dist/development/src/config/configTemplate.cjs.map +1 -1
  38. package/dist/development/src/config/configTemplate.js +13 -2
  39. package/dist/development/src/config/configTemplate.js.map +1 -1
  40. package/dist/development/src/config/projectConfigResolver.cjs.map +1 -1
  41. package/dist/development/src/config/projectConfigResolver.js.map +1 -1
  42. package/dist/development/src/config/tenantConfigResolver.cjs.map +1 -1
  43. package/dist/development/src/config/tenantConfigResolver.js.map +1 -1
  44. package/dist/development/src/content/ContentApiControllerFactory.cjs +26 -4
  45. package/dist/development/src/content/ContentApiControllerFactory.cjs.map +1 -1
  46. package/dist/development/src/content/ContentApiControllerFactory.js +26 -4
  47. package/dist/development/src/content/ContentApiControllerFactory.js.map +1 -1
  48. package/dist/development/src/content/ContentQueryHandlerFactory.cjs.map +1 -1
  49. package/dist/development/src/content/ContentQueryHandlerFactory.js.map +1 -1
  50. package/dist/development/src/content/ContentSchemaResolver.cjs.map +1 -1
  51. package/dist/development/src/content/ContentSchemaResolver.js.map +1 -1
  52. package/dist/development/src/content/GraphQlSchemaFactory.cjs.map +1 -1
  53. package/dist/development/src/content/GraphQlSchemaFactory.js.map +1 -1
  54. package/dist/development/src/content/NotModifiedChecker.cjs.map +1 -1
  55. package/dist/development/src/content/NotModifiedChecker.js.map +1 -1
  56. package/dist/development/src/content/ProjectMembershipResolver.cjs +1 -0
  57. package/dist/development/src/content/ProjectMembershipResolver.cjs.map +1 -1
  58. package/dist/development/src/content/ProjectMembershipResolver.js +1 -0
  59. package/dist/development/src/content/ProjectMembershipResolver.js.map +1 -1
  60. package/dist/development/src/content/triggeredActionsListener.cjs.map +1 -1
  61. package/dist/development/src/content/triggeredActionsListener.js.map +1 -1
  62. package/dist/development/src/graphql/dbQueriesListener.cjs.map +1 -1
  63. package/dist/development/src/graphql/dbQueriesListener.js.map +1 -1
  64. package/dist/development/src/misc/HomepageMiddlewareFactory.cjs +1 -0
  65. package/dist/development/src/misc/HomepageMiddlewareFactory.cjs.map +1 -1
  66. package/dist/development/src/misc/HomepageMiddlewareFactory.js +1 -0
  67. package/dist/development/src/misc/HomepageMiddlewareFactory.js.map +1 -1
  68. package/dist/development/src/project/ProjectContainer.cjs +1 -0
  69. package/dist/development/src/project/ProjectContainer.cjs.map +1 -1
  70. package/dist/development/src/project/ProjectContainer.js +1 -0
  71. package/dist/development/src/project/ProjectContainer.js.map +1 -1
  72. package/dist/development/src/project/ProjectContainerResolver.cjs.map +1 -1
  73. package/dist/development/src/project/ProjectContainerResolver.js.map +1 -1
  74. package/dist/development/src/project/ProjectContainerStore.cjs.map +1 -1
  75. package/dist/development/src/project/ProjectContainerStore.js.map +1 -1
  76. package/dist/development/src/project/ProjectInitializer.cjs.map +1 -1
  77. package/dist/development/src/project/ProjectInitializer.js.map +1 -1
  78. package/dist/development/src/project/ProjectSchemaResolver.cjs.map +1 -1
  79. package/dist/development/src/project/ProjectSchemaResolver.js.map +1 -1
  80. package/dist/development/src/project-common/ProjectContextResolver.cjs +1 -0
  81. package/dist/development/src/project-common/ProjectContextResolver.cjs.map +1 -1
  82. package/dist/development/src/project-common/ProjectContextResolver.js +1 -0
  83. package/dist/development/src/project-common/ProjectContextResolver.js.map +1 -1
  84. package/dist/development/src/projectGroup/ProjectGroupContainer.cjs +17 -4
  85. package/dist/development/src/projectGroup/ProjectGroupContainer.cjs.map +1 -1
  86. package/dist/development/src/projectGroup/ProjectGroupContainer.js +17 -4
  87. package/dist/development/src/projectGroup/ProjectGroupContainer.js.map +1 -1
  88. package/dist/development/src/projectGroup/ProjectGroupContainerResolver.cjs.map +1 -1
  89. package/dist/development/src/projectGroup/ProjectGroupContainerResolver.js.map +1 -1
  90. package/dist/development/src/projectGroup/ProjectGroupResolver.cjs +1 -0
  91. package/dist/development/src/projectGroup/ProjectGroupResolver.cjs.map +1 -1
  92. package/dist/development/src/projectGroup/ProjectGroupResolver.js +1 -0
  93. package/dist/development/src/projectGroup/ProjectGroupResolver.js.map +1 -1
  94. package/dist/development/src/prometheus/CollectHttpMetricsMiddelware.cjs.map +1 -1
  95. package/dist/development/src/prometheus/CollectHttpMetricsMiddelware.js.map +1 -1
  96. package/dist/development/src/prometheus/ProjectGroupContainerMetricsHook.cjs.map +1 -1
  97. package/dist/development/src/prometheus/ProjectGroupContainerMetricsHook.js.map +1 -1
  98. package/dist/development/src/prometheus/PrometheusRegistryFactory.cjs.map +1 -1
  99. package/dist/development/src/prometheus/PrometheusRegistryFactory.js.map +1 -1
  100. package/dist/development/src/prometheus/ShowMetricsMiddleware.cjs.map +1 -1
  101. package/dist/development/src/prometheus/ShowMetricsMiddleware.js.map +1 -1
  102. package/dist/development/src/prometheus/dbMetrics.cjs.map +1 -1
  103. package/dist/development/src/prometheus/dbMetrics.js.map +1 -1
  104. package/dist/development/src/system/ContentQueryExecutor.cjs.map +1 -1
  105. package/dist/development/src/system/ContentQueryExecutor.js.map +1 -1
  106. package/dist/development/src/system/SystemApiMiddlewareFactory.cjs +1 -0
  107. package/dist/development/src/system/SystemApiMiddlewareFactory.cjs.map +1 -1
  108. package/dist/development/src/system/SystemApiMiddlewareFactory.js +1 -0
  109. package/dist/development/src/system/SystemApiMiddlewareFactory.js.map +1 -1
  110. package/dist/development/src/system/SystemGraphQLContextFactory.cjs.map +1 -1
  111. package/dist/development/src/system/SystemGraphQLContextFactory.js.map +1 -1
  112. package/dist/development/src/system/SystemGraphQLHandlerFactory.cjs.map +1 -1
  113. package/dist/development/src/system/SystemGraphQLHandlerFactory.js.map +1 -1
  114. package/dist/development/src/tenant/OidcBackchannelLogoutMiddlewareFactory.cjs +46 -0
  115. package/dist/development/src/tenant/OidcBackchannelLogoutMiddlewareFactory.cjs.map +1 -0
  116. package/dist/development/src/tenant/OidcBackchannelLogoutMiddlewareFactory.js +46 -0
  117. package/dist/development/src/tenant/OidcBackchannelLogoutMiddlewareFactory.js.map +1 -0
  118. package/dist/development/src/tenant/TenantApiMiddlewareFactory.cjs +8 -1
  119. package/dist/development/src/tenant/TenantApiMiddlewareFactory.cjs.map +1 -1
  120. package/dist/development/src/tenant/TenantApiMiddlewareFactory.js +8 -1
  121. package/dist/development/src/tenant/TenantApiMiddlewareFactory.js.map +1 -1
  122. package/dist/development/src/tenant/TenantGraphQLHandlerFactory.cjs.map +1 -1
  123. package/dist/development/src/tenant/TenantGraphQLHandlerFactory.js.map +1 -1
  124. package/dist/development/src/testing/TestTransactions.cjs +144 -0
  125. package/dist/development/src/testing/TestTransactions.cjs.map +1 -0
  126. package/dist/development/src/testing/TestTransactions.js +144 -0
  127. package/dist/development/src/testing/TestTransactions.js.map +1 -0
  128. package/dist/development/src/transfer/CommandStream.cjs.map +1 -1
  129. package/dist/development/src/transfer/CommandStream.js.map +1 -1
  130. package/dist/development/src/transfer/ContentSchemaTransferMappingFactory.cjs.map +1 -1
  131. package/dist/development/src/transfer/ContentSchemaTransferMappingFactory.js.map +1 -1
  132. package/dist/development/src/transfer/ExportApiControllerFactory.cjs +1 -0
  133. package/dist/development/src/transfer/ExportApiControllerFactory.cjs.map +1 -1
  134. package/dist/development/src/transfer/ExportApiControllerFactory.js +1 -0
  135. package/dist/development/src/transfer/ExportApiControllerFactory.js.map +1 -1
  136. package/dist/development/src/transfer/ExportExecutor.cjs +4 -1
  137. package/dist/development/src/transfer/ExportExecutor.cjs.map +1 -1
  138. package/dist/development/src/transfer/ExportExecutor.js +4 -1
  139. package/dist/development/src/transfer/ExportExecutor.js.map +1 -1
  140. package/dist/development/src/transfer/ImportApiMiddlewareFactory.cjs +1 -0
  141. package/dist/development/src/transfer/ImportApiMiddlewareFactory.cjs.map +1 -1
  142. package/dist/development/src/transfer/ImportApiMiddlewareFactory.js +1 -0
  143. package/dist/development/src/transfer/ImportApiMiddlewareFactory.js.map +1 -1
  144. package/dist/development/src/transfer/ImportExecutor.cjs +7 -3
  145. package/dist/development/src/transfer/ImportExecutor.cjs.map +1 -1
  146. package/dist/development/src/transfer/ImportExecutor.js +7 -3
  147. package/dist/development/src/transfer/ImportExecutor.js.map +1 -1
  148. package/dist/development/src/transfer/SystemSchemaTransferMappingFactory.cjs.map +1 -1
  149. package/dist/development/src/transfer/SystemSchemaTransferMappingFactory.js.map +1 -1
  150. package/dist/development/src/utils/CryptoWrapper.cjs +4 -0
  151. package/dist/development/src/utils/CryptoWrapper.cjs.map +1 -1
  152. package/dist/development/src/utils/CryptoWrapper.js +4 -0
  153. package/dist/development/src/utils/CryptoWrapper.js.map +1 -1
  154. package/dist/development/src/utils/remoteAddress.cjs +5 -4
  155. package/dist/development/src/utils/remoteAddress.cjs.map +1 -1
  156. package/dist/development/src/utils/remoteAddress.js +5 -4
  157. package/dist/development/src/utils/remoteAddress.js.map +1 -1
  158. package/dist/development/src/utils/sentry.cjs.map +1 -1
  159. package/dist/development/src/utils/sentry.js.map +1 -1
  160. package/dist/development/src/utils/serverStartup.cjs +2 -2
  161. package/dist/development/src/utils/serverStartup.cjs.map +1 -1
  162. package/dist/development/src/utils/serverStartup.js.map +1 -1
  163. package/dist/production/index.cjs +11 -0
  164. package/dist/production/index.cjs.map +1 -1
  165. package/dist/production/index.js +12 -1
  166. package/dist/production/index.js.map +1 -1
  167. package/dist/production/src/MasterContainer.cjs +48 -7
  168. package/dist/production/src/MasterContainer.cjs.map +1 -1
  169. package/dist/production/src/MasterContainer.js +48 -7
  170. package/dist/production/src/MasterContainer.js.map +1 -1
  171. package/dist/production/src/application/application.cjs +36 -7
  172. package/dist/production/src/application/application.cjs.map +1 -1
  173. package/dist/production/src/application/application.js +36 -7
  174. package/dist/production/src/application/application.js.map +1 -1
  175. package/dist/production/src/application/forceHttpOk.cjs +34 -0
  176. package/dist/production/src/application/forceHttpOk.cjs.map +1 -0
  177. package/dist/production/src/application/forceHttpOk.js +34 -0
  178. package/dist/production/src/application/forceHttpOk.js.map +1 -0
  179. package/dist/production/src/bootstrap/Initializer.cjs.map +1 -1
  180. package/dist/production/src/bootstrap/Initializer.js.map +1 -1
  181. package/dist/production/src/common/Authorizator.cjs +61 -4
  182. package/dist/production/src/common/Authorizator.cjs.map +1 -1
  183. package/dist/production/src/common/Authorizator.js +61 -4
  184. package/dist/production/src/common/Authorizator.js.map +1 -1
  185. package/dist/production/src/common/ModuleInfoMiddleware.cjs.map +1 -1
  186. package/dist/production/src/common/ModuleInfoMiddleware.js.map +1 -1
  187. package/dist/production/src/common/NotFoundMiddleware.cjs +15 -0
  188. package/dist/production/src/common/NotFoundMiddleware.cjs.map +1 -0
  189. package/dist/production/src/common/NotFoundMiddleware.js +15 -0
  190. package/dist/production/src/common/NotFoundMiddleware.js.map +1 -0
  191. package/dist/production/src/config/config.cjs.map +1 -1
  192. package/dist/production/src/config/config.js.map +1 -1
  193. package/dist/production/src/config/configSchema.cjs +64 -2
  194. package/dist/production/src/config/configSchema.cjs.map +1 -1
  195. package/dist/production/src/config/configSchema.js +64 -2
  196. package/dist/production/src/config/configSchema.js.map +1 -1
  197. package/dist/production/src/config/configTemplate.cjs +13 -2
  198. package/dist/production/src/config/configTemplate.cjs.map +1 -1
  199. package/dist/production/src/config/configTemplate.js +13 -2
  200. package/dist/production/src/config/configTemplate.js.map +1 -1
  201. package/dist/production/src/config/projectConfigResolver.cjs.map +1 -1
  202. package/dist/production/src/config/projectConfigResolver.js.map +1 -1
  203. package/dist/production/src/config/tenantConfigResolver.cjs.map +1 -1
  204. package/dist/production/src/config/tenantConfigResolver.js.map +1 -1
  205. package/dist/production/src/content/ContentApiControllerFactory.cjs +26 -4
  206. package/dist/production/src/content/ContentApiControllerFactory.cjs.map +1 -1
  207. package/dist/production/src/content/ContentApiControllerFactory.js +26 -4
  208. package/dist/production/src/content/ContentApiControllerFactory.js.map +1 -1
  209. package/dist/production/src/content/ContentQueryHandlerFactory.cjs.map +1 -1
  210. package/dist/production/src/content/ContentQueryHandlerFactory.js.map +1 -1
  211. package/dist/production/src/content/ContentSchemaResolver.cjs.map +1 -1
  212. package/dist/production/src/content/ContentSchemaResolver.js.map +1 -1
  213. package/dist/production/src/content/GraphQlSchemaFactory.cjs.map +1 -1
  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/ProjectMembershipResolver.cjs +1 -0
  218. package/dist/production/src/content/ProjectMembershipResolver.cjs.map +1 -1
  219. package/dist/production/src/content/ProjectMembershipResolver.js +1 -0
  220. package/dist/production/src/content/ProjectMembershipResolver.js.map +1 -1
  221. package/dist/production/src/content/triggeredActionsListener.cjs.map +1 -1
  222. package/dist/production/src/content/triggeredActionsListener.js.map +1 -1
  223. package/dist/production/src/graphql/dbQueriesListener.cjs.map +1 -1
  224. package/dist/production/src/graphql/dbQueriesListener.js.map +1 -1
  225. package/dist/production/src/misc/HomepageMiddlewareFactory.cjs +1 -0
  226. package/dist/production/src/misc/HomepageMiddlewareFactory.cjs.map +1 -1
  227. package/dist/production/src/misc/HomepageMiddlewareFactory.js +1 -0
  228. package/dist/production/src/misc/HomepageMiddlewareFactory.js.map +1 -1
  229. package/dist/production/src/project/ProjectContainer.cjs +1 -0
  230. package/dist/production/src/project/ProjectContainer.cjs.map +1 -1
  231. package/dist/production/src/project/ProjectContainer.js +1 -0
  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/ProjectInitializer.cjs.map +1 -1
  238. package/dist/production/src/project/ProjectInitializer.js.map +1 -1
  239. package/dist/production/src/project/ProjectSchemaResolver.cjs.map +1 -1
  240. package/dist/production/src/project/ProjectSchemaResolver.js.map +1 -1
  241. package/dist/production/src/project-common/ProjectContextResolver.cjs +1 -0
  242. package/dist/production/src/project-common/ProjectContextResolver.cjs.map +1 -1
  243. package/dist/production/src/project-common/ProjectContextResolver.js +1 -0
  244. package/dist/production/src/project-common/ProjectContextResolver.js.map +1 -1
  245. package/dist/production/src/projectGroup/ProjectGroupContainer.cjs +17 -4
  246. package/dist/production/src/projectGroup/ProjectGroupContainer.cjs.map +1 -1
  247. package/dist/production/src/projectGroup/ProjectGroupContainer.js +17 -4
  248. package/dist/production/src/projectGroup/ProjectGroupContainer.js.map +1 -1
  249. package/dist/production/src/projectGroup/ProjectGroupContainerResolver.cjs.map +1 -1
  250. package/dist/production/src/projectGroup/ProjectGroupContainerResolver.js.map +1 -1
  251. package/dist/production/src/projectGroup/ProjectGroupResolver.cjs +1 -0
  252. package/dist/production/src/projectGroup/ProjectGroupResolver.cjs.map +1 -1
  253. package/dist/production/src/projectGroup/ProjectGroupResolver.js +1 -0
  254. package/dist/production/src/projectGroup/ProjectGroupResolver.js.map +1 -1
  255. package/dist/production/src/prometheus/CollectHttpMetricsMiddelware.cjs.map +1 -1
  256. package/dist/production/src/prometheus/CollectHttpMetricsMiddelware.js.map +1 -1
  257. package/dist/production/src/prometheus/ProjectGroupContainerMetricsHook.cjs.map +1 -1
  258. package/dist/production/src/prometheus/ProjectGroupContainerMetricsHook.js.map +1 -1
  259. package/dist/production/src/prometheus/PrometheusRegistryFactory.cjs.map +1 -1
  260. package/dist/production/src/prometheus/PrometheusRegistryFactory.js.map +1 -1
  261. package/dist/production/src/prometheus/ShowMetricsMiddleware.cjs.map +1 -1
  262. package/dist/production/src/prometheus/ShowMetricsMiddleware.js.map +1 -1
  263. package/dist/production/src/prometheus/dbMetrics.cjs.map +1 -1
  264. package/dist/production/src/prometheus/dbMetrics.js.map +1 -1
  265. package/dist/production/src/system/ContentQueryExecutor.cjs.map +1 -1
  266. package/dist/production/src/system/ContentQueryExecutor.js.map +1 -1
  267. package/dist/production/src/system/SystemApiMiddlewareFactory.cjs +1 -0
  268. package/dist/production/src/system/SystemApiMiddlewareFactory.cjs.map +1 -1
  269. package/dist/production/src/system/SystemApiMiddlewareFactory.js +1 -0
  270. package/dist/production/src/system/SystemApiMiddlewareFactory.js.map +1 -1
  271. package/dist/production/src/system/SystemGraphQLContextFactory.cjs.map +1 -1
  272. package/dist/production/src/system/SystemGraphQLContextFactory.js.map +1 -1
  273. package/dist/production/src/system/SystemGraphQLHandlerFactory.cjs.map +1 -1
  274. package/dist/production/src/system/SystemGraphQLHandlerFactory.js.map +1 -1
  275. package/dist/production/src/tenant/OidcBackchannelLogoutMiddlewareFactory.cjs +46 -0
  276. package/dist/production/src/tenant/OidcBackchannelLogoutMiddlewareFactory.cjs.map +1 -0
  277. package/dist/production/src/tenant/OidcBackchannelLogoutMiddlewareFactory.js +46 -0
  278. package/dist/production/src/tenant/OidcBackchannelLogoutMiddlewareFactory.js.map +1 -0
  279. package/dist/production/src/tenant/TenantApiMiddlewareFactory.cjs +8 -1
  280. package/dist/production/src/tenant/TenantApiMiddlewareFactory.cjs.map +1 -1
  281. package/dist/production/src/tenant/TenantApiMiddlewareFactory.js +8 -1
  282. package/dist/production/src/tenant/TenantApiMiddlewareFactory.js.map +1 -1
  283. package/dist/production/src/tenant/TenantGraphQLHandlerFactory.cjs.map +1 -1
  284. package/dist/production/src/tenant/TenantGraphQLHandlerFactory.js.map +1 -1
  285. package/dist/production/src/testing/TestTransactions.cjs +144 -0
  286. package/dist/production/src/testing/TestTransactions.cjs.map +1 -0
  287. package/dist/production/src/testing/TestTransactions.js +144 -0
  288. package/dist/production/src/testing/TestTransactions.js.map +1 -0
  289. package/dist/production/src/transfer/CommandStream.cjs.map +1 -1
  290. package/dist/production/src/transfer/CommandStream.js.map +1 -1
  291. package/dist/production/src/transfer/ContentSchemaTransferMappingFactory.cjs.map +1 -1
  292. package/dist/production/src/transfer/ContentSchemaTransferMappingFactory.js.map +1 -1
  293. package/dist/production/src/transfer/ExportApiControllerFactory.cjs +1 -0
  294. package/dist/production/src/transfer/ExportApiControllerFactory.cjs.map +1 -1
  295. package/dist/production/src/transfer/ExportApiControllerFactory.js +1 -0
  296. package/dist/production/src/transfer/ExportApiControllerFactory.js.map +1 -1
  297. package/dist/production/src/transfer/ExportExecutor.cjs +4 -1
  298. package/dist/production/src/transfer/ExportExecutor.cjs.map +1 -1
  299. package/dist/production/src/transfer/ExportExecutor.js +4 -1
  300. package/dist/production/src/transfer/ExportExecutor.js.map +1 -1
  301. package/dist/production/src/transfer/ImportApiMiddlewareFactory.cjs +1 -0
  302. package/dist/production/src/transfer/ImportApiMiddlewareFactory.cjs.map +1 -1
  303. package/dist/production/src/transfer/ImportApiMiddlewareFactory.js +1 -0
  304. package/dist/production/src/transfer/ImportApiMiddlewareFactory.js.map +1 -1
  305. package/dist/production/src/transfer/ImportExecutor.cjs +7 -3
  306. package/dist/production/src/transfer/ImportExecutor.cjs.map +1 -1
  307. package/dist/production/src/transfer/ImportExecutor.js +7 -3
  308. package/dist/production/src/transfer/ImportExecutor.js.map +1 -1
  309. package/dist/production/src/transfer/SystemSchemaTransferMappingFactory.cjs.map +1 -1
  310. package/dist/production/src/transfer/SystemSchemaTransferMappingFactory.js.map +1 -1
  311. package/dist/production/src/utils/CryptoWrapper.cjs +4 -0
  312. package/dist/production/src/utils/CryptoWrapper.cjs.map +1 -1
  313. package/dist/production/src/utils/CryptoWrapper.js +4 -0
  314. package/dist/production/src/utils/CryptoWrapper.js.map +1 -1
  315. package/dist/production/src/utils/remoteAddress.cjs +5 -4
  316. package/dist/production/src/utils/remoteAddress.cjs.map +1 -1
  317. package/dist/production/src/utils/remoteAddress.js +5 -4
  318. package/dist/production/src/utils/remoteAddress.js.map +1 -1
  319. package/dist/production/src/utils/sentry.cjs.map +1 -1
  320. package/dist/production/src/utils/sentry.js.map +1 -1
  321. package/dist/production/src/utils/serverStartup.cjs +2 -2
  322. package/dist/production/src/utils/serverStartup.cjs.map +1 -1
  323. package/dist/production/src/utils/serverStartup.js.map +1 -1
  324. package/dist/tests/cases/unit/authenticatorGeoCountry.test.d.ts +2 -0
  325. package/dist/tests/cases/unit/authenticatorGeoCountry.test.d.ts.map +1 -0
  326. package/dist/tests/cases/unit/forceHttpOk.test.d.ts +2 -0
  327. package/dist/tests/cases/unit/forceHttpOk.test.d.ts.map +1 -0
  328. package/dist/tests/cases/unit/notFoundResponse.test.d.ts +2 -0
  329. package/dist/tests/cases/unit/notFoundResponse.test.d.ts.map +1 -0
  330. package/dist/tests/cases/unit/oidcBackchannelLogout.test.d.ts +2 -0
  331. package/dist/tests/cases/unit/oidcBackchannelLogout.test.d.ts.map +1 -0
  332. package/dist/tests/cases/unit/remoteAddress.test.d.ts +2 -0
  333. package/dist/tests/cases/unit/remoteAddress.test.d.ts.map +1 -0
  334. package/dist/tests/cases/unit/serverConfig.test.d.ts +2 -0
  335. package/dist/tests/cases/unit/serverConfig.test.d.ts.map +1 -0
  336. package/dist/tests/tsconfig.tsbuildinfo +1 -1
  337. package/dist/types/MasterContainer.d.ts +34 -22
  338. package/dist/types/MasterContainer.d.ts.map +1 -1
  339. package/dist/types/application/application.d.ts +14 -5
  340. package/dist/types/application/application.d.ts.map +1 -1
  341. package/dist/types/application/forceHttpOk.d.ts +41 -0
  342. package/dist/types/application/forceHttpOk.d.ts.map +1 -0
  343. package/dist/types/application/index.d.ts +3 -2
  344. package/dist/types/application/index.d.ts.map +1 -1
  345. package/dist/types/bootstrap/Initializer.d.ts +1 -1
  346. package/dist/types/bootstrap/Initializer.d.ts.map +1 -1
  347. package/dist/types/bootstrap/index.d.ts +1 -1
  348. package/dist/types/bootstrap/index.d.ts.map +1 -1
  349. package/dist/types/common/Authorizator.d.ts +14 -3
  350. package/dist/types/common/Authorizator.d.ts.map +1 -1
  351. package/dist/types/common/ModuleInfoMiddleware.d.ts +1 -1
  352. package/dist/types/common/ModuleInfoMiddleware.d.ts.map +1 -1
  353. package/dist/types/common/NotFoundMiddleware.d.ts +8 -0
  354. package/dist/types/common/NotFoundMiddleware.d.ts.map +1 -0
  355. package/dist/types/common/index.d.ts +4 -3
  356. package/dist/types/common/index.d.ts.map +1 -1
  357. package/dist/types/config/ConfigProcessor.d.ts +1 -1
  358. package/dist/types/config/ConfigProcessor.d.ts.map +1 -1
  359. package/dist/types/config/config.d.ts +4 -4
  360. package/dist/types/config/config.d.ts.map +1 -1
  361. package/dist/types/config/configSchema.d.ts +37 -0
  362. package/dist/types/config/configSchema.d.ts.map +1 -1
  363. package/dist/types/config/configTemplate.d.ts.map +1 -1
  364. package/dist/types/config/projectConfigResolver.d.ts +3 -3
  365. package/dist/types/config/projectConfigResolver.d.ts.map +1 -1
  366. package/dist/types/config/tenantConfigResolver.d.ts +1 -1
  367. package/dist/types/config/tenantConfigResolver.d.ts.map +1 -1
  368. package/dist/types/content/ContentApiControllerFactory.d.ts +8 -6
  369. package/dist/types/content/ContentApiControllerFactory.d.ts.map +1 -1
  370. package/dist/types/content/ContentQueryHandlerFactory.d.ts +2 -2
  371. package/dist/types/content/ContentQueryHandlerFactory.d.ts.map +1 -1
  372. package/dist/types/content/GraphQLSchemaContributor.d.ts +2 -2
  373. package/dist/types/content/GraphQLSchemaContributor.d.ts.map +1 -1
  374. package/dist/types/content/GraphQlSchemaFactory.d.ts +4 -4
  375. package/dist/types/content/GraphQlSchemaFactory.d.ts.map +1 -1
  376. package/dist/types/content/NotModifiedChecker.d.ts +1 -1
  377. package/dist/types/content/NotModifiedChecker.d.ts.map +1 -1
  378. package/dist/types/content/ProjectMembershipResolver.d.ts +1 -1
  379. package/dist/types/content/ProjectMembershipResolver.d.ts.map +1 -1
  380. package/dist/types/content/index.d.ts +9 -9
  381. package/dist/types/content/index.d.ts.map +1 -1
  382. package/dist/types/content/triggeredActionsListener.d.ts +2 -2
  383. package/dist/types/content/triggeredActionsListener.d.ts.map +1 -1
  384. package/dist/types/graphql/dbQueriesListener.d.ts +1 -1
  385. package/dist/types/graphql/dbQueriesListener.d.ts.map +1 -1
  386. package/dist/types/graphql/index.d.ts +3 -3
  387. package/dist/types/graphql/index.d.ts.map +1 -1
  388. package/dist/types/index.d.ts +29 -28
  389. package/dist/types/index.d.ts.map +1 -1
  390. package/dist/types/misc/HomepageMiddlewareFactory.d.ts +1 -1
  391. package/dist/types/misc/HomepageMiddlewareFactory.d.ts.map +1 -1
  392. package/dist/types/misc/index.d.ts +1 -1
  393. package/dist/types/misc/index.d.ts.map +1 -1
  394. package/dist/types/plugin/Plugin.d.ts +4 -4
  395. package/dist/types/plugin/Plugin.d.ts.map +1 -1
  396. package/dist/types/project/ProjectContainer.d.ts +5 -5
  397. package/dist/types/project/ProjectContainer.d.ts.map +1 -1
  398. package/dist/types/project/ProjectContainerResolver.d.ts +3 -3
  399. package/dist/types/project/ProjectContainerResolver.d.ts.map +1 -1
  400. package/dist/types/project/ProjectContainerStore.d.ts +1 -1
  401. package/dist/types/project/ProjectContainerStore.d.ts.map +1 -1
  402. package/dist/types/project/ProjectInitializer.d.ts +1 -1
  403. package/dist/types/project/ProjectInitializer.d.ts.map +1 -1
  404. package/dist/types/project/ProjectSchemaResolver.d.ts +1 -1
  405. package/dist/types/project/ProjectSchemaResolver.d.ts.map +1 -1
  406. package/dist/types/project/config.d.ts +6 -0
  407. package/dist/types/project/config.d.ts.map +1 -1
  408. package/dist/types/project/index.d.ts +4 -4
  409. package/dist/types/project/index.d.ts.map +1 -1
  410. package/dist/types/project-common/ProjectContextResolver.d.ts +3 -3
  411. package/dist/types/project-common/ProjectContextResolver.d.ts.map +1 -1
  412. package/dist/types/project-common/index.d.ts +2 -2
  413. package/dist/types/project-common/index.d.ts.map +1 -1
  414. package/dist/types/projectGroup/ProjectGroupContainer.d.ts +13 -9
  415. package/dist/types/projectGroup/ProjectGroupContainer.d.ts.map +1 -1
  416. package/dist/types/projectGroup/ProjectGroupContainerResolver.d.ts +2 -2
  417. package/dist/types/projectGroup/ProjectGroupContainerResolver.d.ts.map +1 -1
  418. package/dist/types/projectGroup/ProjectGroupResolver.d.ts +3 -3
  419. package/dist/types/projectGroup/ProjectGroupResolver.d.ts.map +1 -1
  420. package/dist/types/prometheus/CollectHttpMetricsMiddelware.d.ts +4 -4
  421. package/dist/types/prometheus/CollectHttpMetricsMiddelware.d.ts.map +1 -1
  422. package/dist/types/prometheus/ProjectGroupContainerMetricsHook.d.ts +1 -1
  423. package/dist/types/prometheus/ProjectGroupContainerMetricsHook.d.ts.map +1 -1
  424. package/dist/types/prometheus/PrometheusRegistryFactory.d.ts +1 -1
  425. package/dist/types/prometheus/PrometheusRegistryFactory.d.ts.map +1 -1
  426. package/dist/types/prometheus/ShowMetricsMiddleware.d.ts +1 -1
  427. package/dist/types/prometheus/ShowMetricsMiddleware.d.ts.map +1 -1
  428. package/dist/types/prometheus/index.d.ts +2 -2
  429. package/dist/types/prometheus/index.d.ts.map +1 -1
  430. package/dist/types/system/SystemApiMiddlewareFactory.d.ts +3 -3
  431. package/dist/types/system/SystemApiMiddlewareFactory.d.ts.map +1 -1
  432. package/dist/types/system/SystemGraphQLContextFactory.d.ts +3 -3
  433. package/dist/types/system/SystemGraphQLContextFactory.d.ts.map +1 -1
  434. package/dist/types/system/SystemGraphQLHandlerFactory.d.ts +1 -1
  435. package/dist/types/system/SystemGraphQLHandlerFactory.d.ts.map +1 -1
  436. package/dist/types/system/index.d.ts +3 -3
  437. package/dist/types/system/index.d.ts.map +1 -1
  438. package/dist/types/tenant/OidcBackchannelLogoutMiddlewareFactory.d.ts +18 -0
  439. package/dist/types/tenant/OidcBackchannelLogoutMiddlewareFactory.d.ts.map +1 -0
  440. package/dist/types/tenant/TenantApiMiddlewareFactory.d.ts +1 -1
  441. package/dist/types/tenant/TenantApiMiddlewareFactory.d.ts.map +1 -1
  442. package/dist/types/tenant/TenantGraphQLHandlerFactory.d.ts +1 -1
  443. package/dist/types/tenant/TenantGraphQLHandlerFactory.d.ts.map +1 -1
  444. package/dist/types/tenant/index.d.ts +3 -2
  445. package/dist/types/tenant/index.d.ts.map +1 -1
  446. package/dist/types/testing/TestTransactions.d.ts +22 -0
  447. package/dist/types/testing/TestTransactions.d.ts.map +1 -0
  448. package/dist/types/testing/index.d.ts +2 -0
  449. package/dist/types/testing/index.d.ts.map +1 -0
  450. package/dist/types/transfer/CommandStream.d.ts +1 -1
  451. package/dist/types/transfer/CommandStream.d.ts.map +1 -1
  452. package/dist/types/transfer/ContentSchemaTransferMappingFactory.d.ts +1 -1
  453. package/dist/types/transfer/ContentSchemaTransferMappingFactory.d.ts.map +1 -1
  454. package/dist/types/transfer/ExportApiControllerFactory.d.ts +3 -3
  455. package/dist/types/transfer/ExportApiControllerFactory.d.ts.map +1 -1
  456. package/dist/types/transfer/ExportExecutor.d.ts +4 -4
  457. package/dist/types/transfer/ExportExecutor.d.ts.map +1 -1
  458. package/dist/types/transfer/ImportApiMiddlewareFactory.d.ts +3 -3
  459. package/dist/types/transfer/ImportApiMiddlewareFactory.d.ts.map +1 -1
  460. package/dist/types/transfer/ImportExecutor.d.ts +6 -6
  461. package/dist/types/transfer/ImportExecutor.d.ts.map +1 -1
  462. package/dist/types/transfer/SystemSchemaTransferMappingFactory.d.ts +1 -1
  463. package/dist/types/transfer/SystemSchemaTransferMappingFactory.d.ts.map +1 -1
  464. package/dist/types/transfer/index.d.ts +6 -6
  465. package/dist/types/transfer/index.d.ts.map +1 -1
  466. package/dist/types/tsconfig.tsbuildinfo +1 -1
  467. package/dist/types/utils/CryptoWrapper.d.ts +2 -0
  468. package/dist/types/utils/CryptoWrapper.d.ts.map +1 -1
  469. package/dist/types/utils/remoteAddress.d.ts.map +1 -1
  470. package/dist/types/utils/serverStartup.d.ts +4 -4
  471. package/dist/types/utils/serverStartup.d.ts.map +1 -1
  472. package/dist/types/workers/index.d.ts +1 -1
  473. package/dist/types/workers/index.d.ts.map +1 -1
  474. package/package.json +15 -15
  475. package/src/MasterContainer.ts +75 -27
  476. package/src/application/application.ts +44 -13
  477. package/src/application/forceHttpOk.ts +70 -0
  478. package/src/application/index.ts +3 -2
  479. package/src/bootstrap/Initializer.ts +1 -1
  480. package/src/bootstrap/index.ts +1 -1
  481. package/src/common/Authorizator.ts +93 -5
  482. package/src/common/ModuleInfoMiddleware.ts +1 -1
  483. package/src/common/NotFoundMiddleware.ts +18 -0
  484. package/src/common/index.ts +4 -3
  485. package/src/config/ConfigProcessor.ts +1 -1
  486. package/src/config/config.ts +5 -5
  487. package/src/config/configSchema.ts +67 -1
  488. package/src/config/configTemplate.ts +11 -0
  489. package/src/config/projectConfigResolver.ts +4 -4
  490. package/src/config/tenantConfigResolver.ts +2 -2
  491. package/src/content/ContentApiControllerFactory.ts +43 -10
  492. package/src/content/ContentQueryHandlerFactory.ts +3 -3
  493. package/src/content/ContentSchemaResolver.ts +2 -2
  494. package/src/content/GraphQLSchemaContributor.ts +2 -2
  495. package/src/content/GraphQlSchemaFactory.ts +4 -4
  496. package/src/content/NotModifiedChecker.ts +1 -1
  497. package/src/content/ProjectMembershipResolver.ts +2 -2
  498. package/src/content/index.ts +9 -9
  499. package/src/content/triggeredActionsListener.ts +2 -2
  500. package/src/graphql/dbQueriesListener.ts +1 -1
  501. package/src/graphql/index.ts +3 -3
  502. package/src/index.ts +28 -27
  503. package/src/misc/HomepageMiddlewareFactory.ts +2 -2
  504. package/src/misc/index.ts +1 -1
  505. package/src/plugin/Plugin.ts +4 -4
  506. package/src/project/ProjectContainer.ts +6 -6
  507. package/src/project/ProjectContainerResolver.ts +4 -4
  508. package/src/project/ProjectContainerStore.ts +1 -1
  509. package/src/project/ProjectInitializer.ts +1 -1
  510. package/src/project/ProjectSchemaResolver.ts +1 -1
  511. package/src/project/config.ts +6 -0
  512. package/src/project/index.ts +4 -4
  513. package/src/project-common/ProjectContextResolver.ts +2 -2
  514. package/src/project-common/index.ts +2 -2
  515. package/src/projectGroup/ProjectGroupContainer.ts +34 -11
  516. package/src/projectGroup/ProjectGroupContainerResolver.ts +2 -2
  517. package/src/projectGroup/ProjectGroupResolver.ts +4 -4
  518. package/src/prometheus/CollectHttpMetricsMiddelware.ts +4 -4
  519. package/src/prometheus/ProjectGroupContainerMetricsHook.ts +2 -2
  520. package/src/prometheus/PrometheusRegistryFactory.ts +2 -2
  521. package/src/prometheus/ShowMetricsMiddleware.ts +1 -1
  522. package/src/prometheus/dbMetrics.ts +1 -1
  523. package/src/prometheus/index.ts +2 -2
  524. package/src/system/ContentQueryExecutor.ts +2 -2
  525. package/src/system/SystemApiMiddlewareFactory.ts +5 -5
  526. package/src/system/SystemGraphQLContextFactory.ts +3 -3
  527. package/src/system/SystemGraphQLHandlerFactory.ts +1 -1
  528. package/src/system/index.ts +3 -3
  529. package/src/tenant/OidcBackchannelLogoutMiddlewareFactory.ts +63 -0
  530. package/src/tenant/TenantApiMiddlewareFactory.ts +10 -4
  531. package/src/tenant/TenantGraphQLHandlerFactory.ts +1 -1
  532. package/src/tenant/index.ts +3 -2
  533. package/src/testing/TestTransactions.ts +237 -0
  534. package/src/testing/index.ts +1 -0
  535. package/src/transfer/CommandStream.ts +2 -2
  536. package/src/transfer/ContentSchemaTransferMappingFactory.ts +1 -1
  537. package/src/transfer/ExportApiControllerFactory.ts +6 -6
  538. package/src/transfer/ExportExecutor.ts +12 -6
  539. package/src/transfer/ImportApiMiddlewareFactory.ts +5 -5
  540. package/src/transfer/ImportExecutor.ts +12 -9
  541. package/src/transfer/SystemSchemaTransferMappingFactory.ts +2 -2
  542. package/src/transfer/index.ts +6 -6
  543. package/src/utils/CryptoWrapper.ts +5 -0
  544. package/src/utils/remoteAddress.ts +3 -1
  545. package/src/utils/sentry.ts +1 -1
  546. package/src/utils/serverStartup.ts +3 -3
  547. package/src/workers/index.ts +1 -1
  548. package/tests/cases/unit/authenticatorGeoCountry.test.ts +100 -0
  549. package/tests/cases/unit/configResolver.test.ts +33 -3
  550. package/tests/cases/unit/crypto.test.ts +1 -1
  551. package/tests/cases/unit/forceHttpOk.test.ts +92 -0
  552. package/tests/cases/unit/notFoundResponse.test.ts +39 -0
  553. package/tests/cases/unit/oidcBackchannelLogout.test.ts +113 -0
  554. package/tests/cases/unit/projectMembershipResolver.test.ts +2 -2
  555. package/tests/cases/unit/remoteAddress.test.ts +90 -0
  556. package/tests/cases/unit/serverConfig.test.ts +70 -0
@@ -15,8 +15,15 @@ import { ProjectMembershipFetcher } from "../content/ProjectMembershipFetcher.js
15
15
  import { ProjectMembershipResolver } from "../content/ProjectMembershipResolver.js";
16
16
  import { ProjectContainerResolver } from "../project/ProjectContainerResolver.js";
17
17
  import { CryptoWrapper } from "../utils/CryptoWrapper.js";
18
+ const normalizeTokenList = (value) => {
19
+ if (value === void 0) {
20
+ return void 0;
21
+ }
22
+ const items = (Array.isArray(value) ? value : value.split(/[\s,]+/)).map((it) => it.trim()).filter((it) => it.length > 0);
23
+ return items.length > 0 ? items : void 0;
24
+ };
18
25
  class ProjectGroupContainerFactory {
19
- constructor(debug, providers, systemContainerFactory, tenantContainerFactory, projectContainerFactoryFactory, projectConfigResolver, tenantGraphQLHandlerFactory, systemGraphQLHandlerFactory, logger) {
26
+ constructor(debug, providers, systemContainerFactory, tenantContainerFactory, projectContainerFactoryFactory, projectConfigResolver, tenantGraphQLHandlerFactory, systemGraphQLHandlerFactory, logger, geoCountryHeader) {
20
27
  this.debug = debug;
21
28
  this.providers = providers;
22
29
  this.systemContainerFactory = systemContainerFactory;
@@ -26,6 +33,7 @@ class ProjectGroupContainerFactory {
26
33
  this.tenantGraphQLHandlerFactory = tenantGraphQLHandlerFactory;
27
34
  this.systemGraphQLHandlerFactory = systemGraphQLHandlerFactory;
28
35
  this.logger = logger;
36
+ this.geoCountryHeader = geoCountryHeader;
29
37
  }
30
38
  create({ config, slug }) {
31
39
  return new Builder({}).addService("slug", () => slug).addService("logger", ({ slug: slug2 }) => this.logger.child({ projectGroup: slug2 })).addService("providers", () => this.providers).addService("tenantDbCredentials", () => config.db).addService(
@@ -51,12 +59,17 @@ class ProjectGroupContainerFactory {
51
59
  readConnection: tenantReadConnection,
52
60
  dbCredentials: tenantDbCredentials,
53
61
  mailOptions: config.mailer,
54
- tenantCredentials: config.credentials,
62
+ tenantCredentials: {
63
+ ...config.credentials,
64
+ rootTokens: normalizeTokenList(config.credentials.rootTokens),
65
+ rootTokenHashes: normalizeTokenList(config.credentials.rootTokenHashes)
66
+ },
55
67
  projectInitializer,
56
68
  projectSchemaResolver,
57
69
  cryptoProviders: {
58
70
  decrypt: cryptoWrapper.decrypt.bind(cryptoWrapper),
59
- encrypt: cryptoWrapper.encrypt.bind(cryptoWrapper)
71
+ encrypt: cryptoWrapper.encrypt.bind(cryptoWrapper),
72
+ encryptionEnabled: cryptoWrapper.enabled
60
73
  }
61
74
  });
62
75
  }).addService("tenantDatabase", ({ tenantContainer }) => tenantContainer.databaseContext).addService("tenantReadDatabase", ({ tenantContainer }) => tenantContainer.readDatabaseContext).addService("identityFetcher", ({ tenantContainer: { identityFetcher } }) => identityFetcher).addService("systemContainer", ({ identityFetcher }) => this.systemContainerFactory.create({ identityFetcher })).addService("schemaProvider", ({ systemContainer }) => systemContainer.schemaProvider).addService("projectContainerFactory", ({ schemaProvider, logger }) => this.projectContainerFactoryFactory.create(schemaProvider, logger)).addService("tenantProjectManager", ({ tenantContainer }) => tenantContainer.projectManager).addService("tenantProjectMemberManager", ({ tenantContainer }) => tenantContainer.projectMemberManager).addService("projectContainerResolver", ({ projectContainerFactory, tenantProjectManager, tenantReadDatabase }) => new ProjectContainerResolver(
@@ -71,7 +84,7 @@ class ProjectGroupContainerFactory {
71
84
  it.setInitializer(new ProjectInitializer(projectContainerResolver));
72
85
  }).addService("tenantGraphQLHandler", ({ tenantContainer }) => this.tenantGraphQLHandlerFactory.create(tenantContainer.resolvers)).addService("systemGraphQLHandler", ({ systemContainer }) => this.systemGraphQLHandlerFactory.create(systemContainer.systemResolversFactory)).addService(
73
86
  "authenticator",
74
- ({ tenantDatabase, tenantReadDatabase, tenantContainer }) => new Authenticator(tenantDatabase, tenantReadDatabase, tenantContainer.apiKeyManager)
87
+ ({ tenantDatabase, tenantReadDatabase, tenantContainer }) => new Authenticator(tenantDatabase, tenantReadDatabase, tenantContainer.apiKeyManager, this.geoCountryHeader)
75
88
  ).addService(
76
89
  "projectMembershipResolver",
77
90
  ({ tenantProjectMemberManager, tenantReadDatabase }) => new ProjectMembershipResolver(this.debug, new ProjectMembershipFetcher(tenantProjectMemberManager, tenantReadDatabase))
@@ -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 {\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\ninterface ProjectGroupContainerFactoryArgs {\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', () => slug)\n\t\t\t.addService('logger', ({ slug }) => this.logger.child({ projectGroup: slug }))\n\t\t\t.addService('providers', () => this.providers)\n\t\t\t.addService('tenantDbCredentials', () => config.db)\n\t\t\t.addService(\n\t\t\t\t'tenantConnection',\n\t\t\t\t({ tenantDbCredentials, logger }): Connection.ConnectionType => Connection.create(tenantDbCredentials, err => logger.error(err)),\n\t\t\t)\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', () => new ProjectSchemaResolverProxy())\n\t\t\t.addService('projectInitializer', () => new 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 }) => tenantContainer.databaseContext)\n\t\t\t.addService('tenantReadDatabase', ({ tenantContainer }) => tenantContainer.readDatabaseContext)\n\t\t\t.addService('identityFetcher', ({ tenantContainer: { identityFetcher } }) => identityFetcher)\n\t\t\t.addService('systemContainer', ({ identityFetcher }) => this.systemContainerFactory.create({ identityFetcher }))\n\t\t\t.addService('schemaProvider', ({ systemContainer }) => systemContainer.schemaProvider)\n\t\t\t.addService('projectContainerFactory', ({ schemaProvider, logger }) => this.projectContainerFactoryFactory.create(schemaProvider, logger))\n\t\t\t.addService('tenantProjectManager', ({ tenantContainer }) => tenantContainer.projectManager)\n\t\t\t.addService('tenantProjectMemberManager', ({ tenantContainer }) => tenantContainer.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\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 }) => this.tenantGraphQLHandlerFactory.create(tenantContainer.resolvers))\n\t\t\t.addService('systemGraphQLHandler', ({ systemContainer }) => this.systemGraphQLHandlerFactory.create(systemContainer.systemResolversFactory))\n\t\t\t.addService(\n\t\t\t\t'authenticator',\n\t\t\t\t({ tenantDatabase, tenantReadDatabase, tenantContainer }) => new Authenticator(tenantDatabase, tenantReadDatabase, tenantContainer.apiKeyManager),\n\t\t\t)\n\t\t\t.addService(\n\t\t\t\t'projectMembershipResolver',\n\t\t\t\t({ tenantProjectMemberManager, tenantReadDatabase }) =>\n\t\t\t\t\tnew ProjectMembershipResolver(this.debug, new ProjectMembershipFetcher(tenantProjectMemberManager, tenantReadDatabase)),\n\t\t\t)\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":";;;;;;;;;;;;;;;;;AAmDO,MAAM,6BAA6B;AAAA,EACzC,YACkB,OACA,WACA,wBACA,wBACA,gCACA,uBACA,6BACA,6BACA,QAChB;AATgB,SAAA,QAAA;AACA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AwB,CAAC,EAAE,sBAAsB,KAAK,4BAA4B,OAAO,gBAAgB,SAAS,CAAC,EAC9H,WAAW,wBAAwB,CAAC,EAAE,sBAAsB,KAAK,4BAA4B,OAAO,gBAAgB,sBAAsB,CAAC,EAC3I;AAAA,MACA;AAAA,MACA,CAAC,EAAE,gBAAgB,oBAAoB,gBAAA,MAAsB,IAAI,cAAc,gBAAgB,oBAAoB,gBAAgB,aAAa;AAAA,IAAA,EAEhJ;AAAA,MACA;AAAA,MACA,CAAC,EAAE,4BAA4B,mBAAA,MAC9B,IAAI,0BAA0B,KAAK,OAAO,IAAI,yBAAyB,4BAA4B,kBAAkB,CAAC;AAAA,IAAA,EAEvH,QACA;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.js'\nimport {\n\tProjectContainerFactoryFactory,\n\tProjectContainerResolver,\n\tProjectInitializer,\n\tProjectInitializerProxy,\n\tProjectSchemaResolver,\n\tProjectSchemaResolverProxy,\n} from '../project/index.js'\nimport { SystemContainer, SystemContainerFactory } from '@contember/engine-system-api'\nimport { ProjectConfigResolver } from '../config/projectConfigResolver.js'\nimport { createSecretKey } from 'node:crypto'\nimport { Logger } from '@contember/logger'\nimport { TenantGraphQLHandler, TenantGraphQLHandlerFactory } from '../tenant/index.js'\nimport { SystemGraphQLHandler, SystemGraphQLHandlerFactory } from '../system/index.js'\nimport { Authenticator } from '../common/index.js'\nimport { ProjectMembershipFetcher, ProjectMembershipResolver } from '../content/index.js'\nimport { Providers } from '../providers.js'\nimport { CryptoWrapper } from '../utils/CryptoWrapper.js'\n\n/**\n * Normalizes a token list that may be provided either as an array (JSON config)\n * or as a comma/whitespace-separated string (env-based config) into an array of\n * non-empty tokens.\n */\nconst normalizeTokenList = (value: string | readonly string[] | undefined): readonly string[] | undefined => {\n\tif (value === undefined) {\n\t\treturn undefined\n\t}\n\tconst items = (Array.isArray(value) ? value : (value as string).split(/[\\s,]+/))\n\t\t.map(it => it.trim())\n\t\t.filter(it => it.length > 0)\n\treturn items.length > 0 ? items : undefined\n}\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\ninterface ProjectGroupContainerFactoryArgs {\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\t/** A03: configured trusted geo-country header name, or undefined when off. */\n\t\tprivate readonly geoCountryHeader?: string,\n\t) {}\n\n\tpublic create({ config, slug }: ProjectGroupContainerFactoryArgs): ProjectGroupContainer {\n\t\treturn new Builder({})\n\t\t\t.addService('slug', () => slug)\n\t\t\t.addService('logger', ({ slug }) => this.logger.child({ projectGroup: slug }))\n\t\t\t.addService('providers', () => this.providers)\n\t\t\t.addService('tenantDbCredentials', () => config.db)\n\t\t\t.addService(\n\t\t\t\t'tenantConnection',\n\t\t\t\t({ tenantDbCredentials, logger }): Connection.ConnectionType => Connection.create(tenantDbCredentials, err => logger.error(err)),\n\t\t\t)\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', () => new ProjectSchemaResolverProxy())\n\t\t\t.addService('projectInitializer', () => new 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: {\n\t\t\t\t\t\t...config.credentials,\n\t\t\t\t\t\trootTokens: normalizeTokenList(config.credentials.rootTokens),\n\t\t\t\t\t\trootTokenHashes: normalizeTokenList(config.credentials.rootTokenHashes),\n\t\t\t\t\t},\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\tencryptionEnabled: cryptoWrapper.enabled,\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t})\n\t\t\t.addService('tenantDatabase', ({ tenantContainer }) => tenantContainer.databaseContext)\n\t\t\t.addService('tenantReadDatabase', ({ tenantContainer }) => tenantContainer.readDatabaseContext)\n\t\t\t.addService('identityFetcher', ({ tenantContainer: { identityFetcher } }) => identityFetcher)\n\t\t\t.addService('systemContainer', ({ identityFetcher }) => this.systemContainerFactory.create({ identityFetcher }))\n\t\t\t.addService('schemaProvider', ({ systemContainer }) => systemContainer.schemaProvider)\n\t\t\t.addService('projectContainerFactory', ({ schemaProvider, logger }) => this.projectContainerFactoryFactory.create(schemaProvider, logger))\n\t\t\t.addService('tenantProjectManager', ({ tenantContainer }) => tenantContainer.projectManager)\n\t\t\t.addService('tenantProjectMemberManager', ({ tenantContainer }) => tenantContainer.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\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 }) => this.tenantGraphQLHandlerFactory.create(tenantContainer.resolvers))\n\t\t\t.addService('systemGraphQLHandler', ({ systemContainer }) => this.systemGraphQLHandlerFactory.create(systemContainer.systemResolversFactory))\n\t\t\t.addService(\n\t\t\t\t'authenticator',\n\t\t\t\t({ tenantDatabase, tenantReadDatabase, tenantContainer }) =>\n\t\t\t\t\tnew Authenticator(tenantDatabase, tenantReadDatabase, tenantContainer.apiKeyManager, this.geoCountryHeader),\n\t\t\t)\n\t\t\t.addService(\n\t\t\t\t'projectMembershipResolver',\n\t\t\t\t({ tenantProjectMemberManager, tenantReadDatabase }) =>\n\t\t\t\t\tnew ProjectMembershipResolver(this.debug, new ProjectMembershipFetcher(tenantProjectMemberManager, tenantReadDatabase)),\n\t\t\t)\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":";;;;;;;;;;;;;;;;;AAiCA,MAAM,qBAAqB,CAAC,UAAiF;AAC5G,MAAI,UAAU,QAAW;AACxB,WAAO;AAAA,EACR;AACA,QAAM,SAAS,MAAM,QAAQ,KAAK,IAAI,QAAS,MAAiB,MAAM,QAAQ,GAC5E,IAAI,CAAA,OAAM,GAAG,MAAM,EACnB,OAAO,CAAA,OAAM,GAAG,SAAS,CAAC;AAC5B,SAAO,MAAM,SAAS,IAAI,QAAQ;AACnC;AAyBO,MAAM,6BAA6B;AAAA,EACzC,YACkB,OACA,WACA,wBACA,wBACA,gCAC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AAyB,CAAC,IAAI,EAAE,+BAA+B;AAC5E,SAAG,YAAY,IAAI,sBAAsB,wBAAwB,CAAC;AAAA,IACnE,CAAC,EACA,aAAa,sBAAsB,CAAC,IAAI,EAAE,+BAA+B;AACzE,SAAG,eAAe,IAAI,mBAAmB,wBAAwB,CAAC;AAAA,IACnE,CAAC,EACA,WAAW,wBAAwB,CAAC,EAAE,sBAAsB,KAAK,4BAA4B,OAAO,gBAAgB,SAAS,CAAC,EAC9H,WAAW,wBAAwB,CAAC,EAAE,sBAAsB,KAAK,4BAA4B,OAAO,gBAAgB,sBAAsB,CAAC,EAC3I;AAAA,MACA;AAAA,MACA,CAAC,EAAE,gBAAgB,oBAAoB,gBAAA,MACtC,IAAI,cAAc,gBAAgB,oBAAoB,gBAAgB,eAAe,KAAK,gBAAgB;AAAA,IAAA,EAE3G;AAAA,MACA;AAAA,MACA,CAAC,EAAE,4BAA4B,mBAAA,MAC9B,IAAI,0BAA0B,KAAK,OAAO,IAAI,yBAAyB,4BAA4B,kBAAkB,CAAC;AAAA,IAAA,EAEvH,QACA;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 +1 @@
1
- {"version":3,"file":"ProjectGroupContainerResolver.cjs","sources":["../../../../../packages/engine-http/src/projectGroup/ProjectGroupContainerResolver.ts"],"sourcesContent":["import { EventEmitter, EventManager, PromiseMap } 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\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":";;;;;;;AAcO,MAAM,8BAA2F;AAAA,EAMvG,YACkB,gBACA,kBAChB;AAFgB,SAAA,iBAAA;AACA,SAAA,mBAAA;AAPlB,kBAAA,MAAQ,cAAa,IAAIA,aAAAA,WAAA,CAAkD;AAC3E,kBAAA,MAAQ,gBAAe,IAAIC,aAAAA,aAAA,CAAkD;AAE7E,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,CAAA,OAAM,GAAA,CAAI;AAC3C,WAAK,WAAW,OAAO,IAAI;AAAA,IAC5B;AACA,YAAQ,MAAM,KAAK,WAAW,MAAM,MAAM,OAAMC,UAAQ;AACvD,YAAM,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,MAAAA,CAAM,EAAE,IAAI,CAAA,OAAM,OAAO,MAAM,KAAK;AAEnG,gBAAU,yBAAyB,GAAG,UAAU,CAAC,EAAE,WAAW,uBAAuB;AACpF,iBAAS,KAAK,MAAM,UAAU,yBAAyB,iBAAiB,iBAAiB,QAAQ,IAAI,CAAC;AAAA,MACvG,CAAC;AAED,YAAM,UAAU,gBAAgB,iBAAiB,IAAI,UAAU,OAAO,OAAO;AAC7E,aAAO,EAAE,WAAW,aAAa,QAAQ,SAAA;AAAA,IAC1C,CAAC,GAAG;AAAA,EACL;AACD;;"}
1
+ {"version":3,"file":"ProjectGroupContainerResolver.cjs","sources":["../../../../../packages/engine-http/src/projectGroup/ProjectGroupContainerResolver.ts"],"sourcesContent":["import { EventEmitter, EventManager, PromiseMap } from '@contember/engine-common'\nimport { isDeepStrictEqual } from 'node:util'\nimport { ProjectGroupContainer, ProjectGroupContainerFactory } from './ProjectGroupContainer.js'\nimport { TenantConfigResolver } from '../config/tenantConfigResolver.js'\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\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":";;;;;;;AAcO,MAAM,8BAA2F;AAAA,EAMvG,YACkB,gBACA,kBAChB;AAFgB,SAAA,iBAA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ent":["import { EventEmitter, EventManager, PromiseMap } 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\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,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 {"version":3,"file":"ProjectGroupContainerResolver.js","sources":["../../../../../packages/engine-http/src/projectGroup/ProjectGroupContainerResolver.ts"],"sourcesContent":["import { EventEmitter, EventManager, PromiseMap } from '@contember/engine-common'\nimport { isDeepStrictEqual } from 'node:util'\nimport { ProjectGroupContainer, ProjectGroupContainerFactory } from './ProjectGroupContainer.js'\nimport { TenantConfigResolver } from '../config/tenantConfigResolver.js'\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\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":";;;;;AAcO,MAAM,8BAA2F;AAAA,EAMvG,YACkB,gBACA,kBAChB;AAFgB,SAAA,iBAAA;AACA,SAAA,mBAAA;AAPlB,kBAAA,MAAQ,cAAa,IAAI,WAAA,CAAkD;AAC3E,kBAAA,MAAQ,gBAAe,IAAI,aAAA,CAAkD;AAE7E,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,UAAI,kBAAkB,QAAQ,gBAAgB,WAAW,GAAG;AAC3D,eAAO,gBAAgB;AAAA,MACxB;AACA,sBAAgB,SAAS,QAAQ,CAAA,OAAM,GAAA,CAAI;AAC3C,WAAK,WAAW,OAAO,IAAI;AAAA,IAC5B;AACA,YAAQ,MAAM,KAAK,WAAW,MAAM,MAAM,OAAMA,UAAQ;AACvD,YAAM,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,MAAAA,CAAM,EAAE,IAAI,CAAA,OAAM,OAAO,MAAM,KAAK;AAEnG,gBAAU,yBAAyB,GAAG,UAAU,CAAC,EAAE,WAAW,uBAAuB;AACpF,iBAAS,KAAK,MAAM,UAAU,yBAAyB,iBAAiB,iBAAiB,QAAQ,IAAI,CAAC;AAAA,MACvG,CAAC;AAED,YAAM,UAAU,gBAAgB,iBAAiB,IAAI,UAAU,OAAO,OAAO;AAC7E,aAAO,EAAE,WAAW,aAAa,QAAQ,SAAA;AAAA,IAC1C,CAAC,GAAG;AAAA,EACL;AACD;"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const CryptoWrapper = require("../utils/CryptoWrapper.cjs");
4
4
  const HttpResponse = require("../common/HttpResponse.cjs");
5
+ require("ipaddr.js");
5
6
  var __defProp = Object.defineProperty;
6
7
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
8
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -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 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 = this.projectGroupDomainMapping\n\t\t\t? new RegExp(\n\t\t\t\tthis.projectGroupDomainMapping.includes('{group}')\n\t\t\t\t\t? regexpQuote(this.projectGroupDomainMapping).replace(regexpQuote('{group}'), '([^.]+)')\n\t\t\t\t\t: this.projectGroupDomainMapping,\n\t\t\t)\n\t\t\t: undefined\n\t}\n\n\tasync resolveContainer({ request }: { request: IncomingMessage }): Promise<ProjectGroupContainer> {\n\t\tlet group: string | 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":";;;;;;;AAMO,MAAM,qBAAqB;AAAA,EAIjC,YACS,2BACR,0BACQ,0BACA,+BACP;AAJO,SAAA,4BAAA;AAEA,SAAA,2BAAA;AACA,SAAA,gCAAA;AAPT,kBAAA,MAAQ,YAAA;AACR,kBAAA,MAAQ,0BAAA;AAQP,SAAK,2BAA2B,0BAA0B,YAAA;AAC1D,SAAK,aAAa,KAAK,4BACpB,IAAI;AAAA,MACL,KAAK,0BAA0B,SAAS,SAAS,IAC9C,YAAY,KAAK,yBAAyB,EAAE,QAAQ,YAAY,SAAS,GAAG,SAAS,IACrF,KAAK;AAAA,IAAA,IAEP;AAAA,EACJ;AAAA,EAEA,MAAM,iBAAiB,EAAE,WAAyE;AACjG,QAAI;AACJ,QAAI,SAAS,CAAA;AACb,QAAI,KAAK,YAAY;AACpB,YAAM,OAAO,QAAQ,QAAQ;AAC7B,YAAM,QAAQ,MAAM,MAAM,KAAK,UAAU;AACzC,UAAI,CAAC,OAAO;AACX,cAAM,IAAIA,aAAAA,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,IAAIA,aAAAA,kBAAkB,KAAK,GAAG,KAAK,wBAAwB,oBAAoB;AAAA,QACtF;AACA,cAAM,cAAc,OAAO,KAAK,cAAc,QAAQ;AACtD,cAAM,iBAAiB,KAAK,4BACxB,MAAM,KAAK,yBAAyB,QAAQ,aAAaC,cAAAA,cAAc,aAAa,GAAG,QACxF;AACH,YAAI;AACH,mBAAS,KAAK,MAAM,eAAe,SAAA,CAAU;AAAA,QAC9C,SAAS,GAAQ;AAChB,gBAAM,IAAID,aAAAA,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.cjs","sources":["../../../../../packages/engine-http/src/projectGroup/ProjectGroupResolver.ts"],"sourcesContent":["import { CryptoWrapper } from '../utils/CryptoWrapper.js'\nimport { ProjectGroupContainer } from './ProjectGroupContainer.js'\nimport { IncomingMessage } from 'node:http'\nimport { ProjectGroupContainerResolver } from './ProjectGroupContainerResolver.js'\nimport { HttpErrorResponse } from '../common/index.js'\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 = this.projectGroupDomainMapping\n\t\t\t? new RegExp(\n\t\t\t\tthis.projectGroupDomainMapping.includes('{group}')\n\t\t\t\t\t? regexpQuote(this.projectGroupDomainMapping).replace(regexpQuote('{group}'), '([^.]+)')\n\t\t\t\t\t: this.projectGroupDomainMapping,\n\t\t\t)\n\t\t\t: undefined\n\t}\n\n\tasync resolveContainer({ request }: { request: IncomingMessage }): Promise<ProjectGroupContainer> {\n\t\tlet group: string | 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":";;;;;;;;AAMO,MAAM,qBAAqB;AAAA,EAIjC,YACS,2BACR,0BACQ,0BACA,+BACP;AAJO,SAAA,4BAAA;AAEA,SAAA,2BAAA;AACA,SAAA,gCAAA;AAPT,kBAAA,MAAQ,YAAA;AACR,kBAAA,MAAQ,0BAAA;AAQP,SAAK,2BAA2B,0BAA0B,YAAA;AAC1D,SAAK,aAAa,KAAK,4BACpB,IAAI;AAAA,MACL,KAAK,0BAA0B,SAAS,SAAS,IAC9C,YAAY,KAAK,yBAAyB,EAAE,QAAQ,YAAY,SAAS,GAAG,SAAS,IACrF,KAAK;AAAA,IAAA,IAEP;AAAA,EACJ;AAAA,EAEA,MAAM,iBAAiB,EAAE,WAAyE;AACjG,QAAI;AACJ,QAAI,SAAS,CAAA;AACb,QAAI,KAAK,YAAY;AACpB,YAAM,OAAO,QAAQ,QAAQ;AAC7B,YAAM,QAAQ,MAAM,MAAM,KAAK,UAAU;AACzC,UAAI,CAAC,OAAO;AACX,cAAM,IAAIA,aAAAA,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,IAAIA,aAAAA,kBAAkB,KAAK,GAAG,KAAK,wBAAwB,oBAAoB;AAAA,QACtF;AACA,cAAM,cAAc,OAAO,KAAK,cAAc,QAAQ;AACtD,cAAM,iBAAiB,KAAK,4BACxB,MAAM,KAAK,yBAAyB,QAAQ,aAAaC,cAAAA,cAAc,aAAa,GAAG,QACxF;AACH,YAAI;AACH,mBAAS,KAAK,MAAM,eAAe,SAAA,CAAU;AAAA,QAC9C,SAAS,GAAQ;AAChB,gBAAM,IAAID,aAAAA,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,5 +1,6 @@
1
1
  import { CryptoWrapper } from "../utils/CryptoWrapper.js";
2
2
  import { HttpErrorResponse } from "../common/HttpResponse.js";
3
+ import "ipaddr.js";
3
4
  var __defProp = Object.defineProperty;
4
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5
6
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -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 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 = this.projectGroupDomainMapping\n\t\t\t? new RegExp(\n\t\t\t\tthis.projectGroupDomainMapping.includes('{group}')\n\t\t\t\t\t? regexpQuote(this.projectGroupDomainMapping).replace(regexpQuote('{group}'), '([^.]+)')\n\t\t\t\t\t: this.projectGroupDomainMapping,\n\t\t\t)\n\t\t\t: undefined\n\t}\n\n\tasync resolveContainer({ request }: { request: IncomingMessage }): Promise<ProjectGroupContainer> {\n\t\tlet group: string | 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,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sources":["../../../../../packages/engine-http/src/projectGroup/ProjectGroupResolver.ts"],"sourcesContent":["import { CryptoWrapper } from '../utils/CryptoWrapper.js'\nimport { ProjectGroupContainer } from './ProjectGroupContainer.js'\nimport { IncomingMessage } from 'node:http'\nimport { ProjectGroupContainerResolver } from './ProjectGroupContainerResolver.js'\nimport { HttpErrorResponse } from '../common/index.js'\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 = this.projectGroupDomainMapping\n\t\t\t? new RegExp(\n\t\t\t\tthis.projectGroupDomainMapping.includes('{group}')\n\t\t\t\t\t? regexpQuote(this.projectGroupDomainMapping).replace(regexpQuote('{group}'), '([^.]+)')\n\t\t\t\t\t: this.projectGroupDomainMapping,\n\t\t\t)\n\t\t\t: undefined\n\t}\n\n\tasync resolveContainer({ request }: { request: IncomingMessage }): Promise<ProjectGroupContainer> {\n\t\tlet group: string | 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,gCAAA;AAPT,kBAAA,MAAQ,YAAA;AACR,kBAAA,MAAQ,0BAAA;AAQP,SAAK,2BAA2B,0BAA0B,YAAA;AAC1D,SAAK,aAAa,KAAK,4BACpB,IAAI;AAAA,MACL,KAAK,0BAA0B,SAAS,SAAS,IAC9C,YAAY,KAAK,yBAAyB,EAAE,QAAQ,YAAY,SAAS,GAAG,SAAS,IACrF,KAAK;AAAA,IAAA,IAEP;AAAA,EACJ;AAAA,EAEA,MAAM,iBAAiB,EAAE,WAAyE;AACjG,QAAI;AACJ,QAAI,SAAS,CAAA;AACb,QAAI,KAAK,YAAY;AACpB,YAAM,OAAO,QAAQ,QAAQ;AAC7B,YAAM,QAAQ,MAAM,MAAM,KAAK,UAAU;AACzC,UAAI,CAAC,OAAO;AACX,cAAM,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;AACtD,cAAM,iBAAiB,KAAK,4BACxB,MAAM,KAAK,yBAAyB,QAAQ,aAAa,cAAc,aAAa,GAAG,QACxF;AACH,YAAI;AACH,mBAAS,KAAK,MAAM,eAAe,SAAA,CAAU;AAAA,QAC9C,SAAS,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 +1 @@
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:\n\t\t\t'[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:\n\t\t\t'[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":";;;AAMO,MAAM,sCAAsC,CAClD,aACsG;AACtG,QAAM,iBAAiB,IAAI,KAAK,UAAU;AAAA,IACzC,MAAM;AAAA,IACN,MACC;AAAA,IACD,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;AAED,QAAM,mBAAmB,IAAI,KAAK,UAAU;AAAA,IAC3C,MAAM;AAAA,IACN,MACC;AAAA,IACD,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;AAED,SAAO,OAAO,KAAK,SAAS;AAC3B,UAAM,QAAQ,KAAK,IAAA;AACnB,QAAI;AACH,YAAM,KAAA;AAAA,IACP,UAAA;AACC,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;AAExD,UAAI,IAAI,WAAW,WAAW;AAC7B,uBAAe,QAAQ,SAAS,KAAK,IAAA,IAAQ,SAAS,GAAI;AAC1D,yBAAiB,QAAQ,QAAQ,KAAK,IAAA,IAAQ,KAAK;AAAA,MACpD;AAAA,IACD;AAAA,EACD;AACD;;"}
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/index.js'\nimport { KoaMiddleware } from '../application/index.js'\nimport { ModuleInfoMiddlewareState } from '../common/index.js'\nimport { GraphQLKoaState } from '../graphql/index.js'\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:\n\t\t\t'[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:\n\t\t\t'[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":";;;AAMO,MAAM,sCAAsC,CAClD,aACsG;AACtG,QAAM,iBAAiB,IAAI,KAAK,UAAU;AAAA,IACzC,MAAM;AAAA,IACN,MACC;AAAA,IACD,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;AAED,QAAM,mBAAmB,IAAI,KAAK,UAAU;AAAA,IAC3C,MAAM;AAAA,IACN,MACC;AAAA,IACD,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;AAED,SAAO,OAAO,KAAK,SAAS;AAC3B,UAAM,QAAQ,KAAK,IAAA;AACnB,QAAI;AACH,YAAM,KAAA;AAAA,IACP,UAAA;AACC,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;AAExD,UAAI,IAAI,WAAW,WAAW;AAC7B,uBAAe,QAAQ,SAAS,KAAK,IAAA,IAAQ,SAAS,GAAI;AAC1D,yBAAiB,QAAQ,QAAQ,KAAK,IAAA,IAAQ,KAAK;AAAA,MACpD;AAAA,IACD;AAAA,EACD;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:\n\t\t\t'[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:\n\t\t\t'[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":";AAMO,MAAM,sCAAsC,CAClD,aACsG;AACtG,QAAM,iBAAiB,IAAI,KAAK,UAAU;AAAA,IACzC,MAAM;AAAA,IACN,MACC;AAAA,IACD,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;AAED,QAAM,mBAAmB,IAAI,KAAK,UAAU;AAAA,IAC3C,MAAM;AAAA,IACN,MACC;AAAA,IACD,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;AAED,SAAO,OAAO,KAAK,SAAS;AAC3B,UAAM,QAAQ,KAAK,IAAA;AACnB,QAAI;AACH,YAAM,KAAA;AAAA,IACP,UAAA;AACC,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;AAExD,UAAI,IAAI,WAAW,WAAW;AAC7B,uBAAe,QAAQ,SAAS,KAAK,IAAA,IAAQ,SAAS,GAAI;AAC1D,yBAAiB,QAAQ,QAAQ,KAAK,IAAA,IAAQ,KAAK;AAAA,MACpD;AAAA,IACD;AAAA,EACD;AACD;"}
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/index.js'\nimport { KoaMiddleware } from '../application/index.js'\nimport { ModuleInfoMiddlewareState } from '../common/index.js'\nimport { GraphQLKoaState } from '../graphql/index.js'\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:\n\t\t\t'[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:\n\t\t\t'[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":";AAMO,MAAM,sCAAsC,CAClD,aACsG;AACtG,QAAM,iBAAiB,IAAI,KAAK,UAAU;AAAA,IACzC,MAAM;AAAA,IACN,MACC;AAAA,IACD,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;AAED,QAAM,mBAAmB,IAAI,KAAK,UAAU;AAAA,IAC3C,MAAM;AAAA,IACN,MACC;AAAA,IACD,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;AAED,SAAO,OAAO,KAAK,SAAS;AAC3B,UAAM,QAAQ,KAAK,IAAA;AACnB,QAAI;AACH,YAAM,KAAA;AAAA,IACP,UAAA;AACC,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;AAExD,UAAI,IAAI,WAAW,WAAW;AAC7B,uBAAe,QAAQ,SAAS,KAAK,IAAA,IAAQ,SAAS,GAAI;AAC1D,yBAAiB,QAAQ,QAAQ,KAAK,IAAA,IAAQ,KAAK;AAAA,MACpD;AAAA,IACD;AAAA,EACD;AACD;"}
@@ -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\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;AACvC,UAAM,YAAYA,UAAAA,yBAAyB,YAAY;AACvD,SAAK,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mB;AAAA,YACnB,mBAAmB;AAAA,UAAA;AAAA,QACpB,CACA,CAAC;AAAA,MACH;AAEA,aAAO,MAAM,WAAW,QAAQ,CAAA,OAAM,IAAI;AAAA,IAC3C,CAAC;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.js'\nimport { createDbMetricsRegistrar } from './dbMetrics.js'\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\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;AACvC,UAAM,YAAYA,UAAAA,yBAAyB,YAAY;AACvD,SAAK,kBAAkB,GAAG,UAAU,CAAC,EAAE,WAAW,gBAAgB,WAAW;AAC5E,qBAAe,yBAAyB,GAAG,UAAU,CAAC,EAAE,WAAW,uBAAuB;AACzF,cAAMC,qBAAoB,iBAAiB;AAC3C,cAAMC,kBAAiB,iBAAi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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\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;AACvC,UAAM,YAAY,yBAAyB,YAAY;AACvD,SAAK,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,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,QACH;AACA,eAAO,MAAME,YAAW,QAAQ,CAAA,OAAM,IAAI;AAAA,MAC3C,CAAC;AAED,YAAM,oBAAoB,eAAe,gBAAgB;AACzD,YAAM,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,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,MACH;AAEA,aAAO,MAAM,WAAW,QAAQ,CAAA,OAAM,IAAI;AAAA,IAC3C,CAAC;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.js'\nimport { createDbMetricsRegistrar } from './dbMetrics.js'\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\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;AACvC,UAAM,YAAY,yBAAyB,YAAY;AACvD,SAAK,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,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,QACH;AACA,eAAO,MAAME,YAAW,QAAQ,CAAA,OAAM,IAAI;AAAA,MAC3C,CAAC;AAED,YAAM,oBAAoB,eAAe,gBAAgB;AACzD,YAAM,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,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,MACH;AAEA,aAAO,MAAM,WAAW,QAAQ,CAAA,OAAM,IAAI;AAAA,IAC3C,CAAC;AAAA,EACF;AACD;"}
@@ -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;AACzB,QAAI,KAAK,gBAAgB,iBAAiB;AACzC,YAAMA,YAAW,IAAI,KAAK,mBAAA;AAC1B,WAAK,sBAAsB,EAAE,UAAAA,UAAAA,CAAU;AACvC,aAAOA;AAAAA,IACR;AACA,UAAM,WAAW,KAAK;AACtB,aAAS,eAAeC,0BAAAA,gCAAgC,KAAK,mBAAmB,CAAC;AACjF,QAAI,EAAE,SAAS,SAAS;AACvB,WAAK,sBAAsB,EAAE,UAAU;AAAA,IACxC;AAEA,WAAO;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.js'\nimport { ProcessType } from '../MasterContainer.js'\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;AACzB,QAAI,KAAK,gBAAgB,iBAAiB;AACzC,YAAMA,YAAW,IAAI,KAAK,mBAAA;AAC1B,WAAK,sBAAsB,EAAE,UAAAA,UAAAA,CAAU;AACvC,aAAOA;AAAAA,IACR;AACA,UAAM,WAAW,KAAK;AACtB,aAAS,eAAeC,0BAAAA,gCAAgC,KAAK,mBAAmB,CAAC;AACjF,QAAI,EAAE,SAAS,SAAS;AACvB,WAAK,sBAAsB,EAAE,UAAU;AAAA,IACxC;AAEA,WAAO;AAAA,EACR;AACD;;"}
@@ -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;AACzB,QAAI,KAAK,gBAAgB,iBAAiB;AACzC,YAAMA,YAAW,IAAI,KAAK,mBAAA;AAC1B,WAAK,sBAAsB,EAAE,UAAAA,UAAAA,CAAU;AACvC,aAAOA;AAAAA,IACR;AACA,UAAM,WAAW,KAAK;AACtB,aAAS,eAAe,gCAAgC,KAAK,mBAAmB,CAAC;AACjF,QAAI,EAAE,SAAS,SAAS;AACvB,WAAK,sBAAsB,EAAE,UAAU;AAAA,IACxC;AAEA,WAAO;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.js'\nimport { ProcessType } from '../MasterContainer.js'\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;AACzB,QAAI,KAAK,gBAAgB,iBAAiB;AACzC,YAAMA,YAAW,IAAI,KAAK,mBAAA;AAC1B,WAAK,sBAAsB,EAAE,UAAAA,UAAAA,CAAU;AACvC,aAAOA;AAAAA,IACR;AACA,UAAM,WAAW,KAAK;AACtB,aAAS,eAAe,gCAAgC,KAAK,mBAAmB,CAAC;AACjF,QAAI,EAAE,SAAS,SAAS;AACvB,WAAK,sBAAsB,EAAE,UAAU;AAAA,IACxC;AAEA,WAAO;AAAA,EACR;AACD;"}
@@ -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":";;;AAGO,MAAM,8BAA8B,CAAC,aAAgD;AAC3F,SAAO,OAAO,KAAK,SAAS;AAC3B,QAAI,IAAI,SAAS,YAAY;AAC5B,aAAO,KAAA;AAAA,IACR;AACA,QAAI,oBAAoB,KAAK,oBAAoB;AAChD,UAAI,OAAO,MAAM,SAAS,eAAA;AAAA,IAC3B,OAAO;AACN,UAAI,OAAO,SAAS,QAAA;AAAA,IACrB;AAAA,EACD;AACD;;"}
1
+ {"version":3,"file":"ShowMetricsMiddleware.cjs","sources":["../../../../../packages/engine-http/src/prometheus/ShowMetricsMiddleware.ts"],"sourcesContent":["import prom from 'prom-client'\nimport { KoaMiddleware } from '../application/index.js'\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":";;;AAGO,MAAM,8BAA8B,CAAC,aAAgD;AAC3F,SAAO,OAAO,KAAK,SAAS;AAC3B,QAAI,IAAI,SAAS,YAAY;AAC5B,aAAO,KAAA;AAAA,IACR;AACA,QAAI,oBAAoB,KAAK,oBAAoB;AAChD,UAAI,OAAO,MAAM,SAAS,eAAA;AAAA,IAC3B,OAAO;AACN,UAAI,OAAO,SAAS,QAAA;AAAA,IACrB;AAAA,EACD;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":";AAGO,MAAM,8BAA8B,CAAC,aAAgD;AAC3F,SAAO,OAAO,KAAK,SAAS;AAC3B,QAAI,IAAI,SAAS,YAAY;AAC5B,aAAO,KAAA;AAAA,IACR;AACA,QAAI,oBAAoB,KAAK,oBAAoB;AAChD,UAAI,OAAO,MAAM,SAAS,eAAA;AAAA,IAC3B,OAAO;AACN,UAAI,OAAO,SAAS,QAAA;AAAA,IACrB;AAAA,EACD;AACD;"}
1
+ {"version":3,"file":"ShowMetricsMiddleware.js","sources":["../../../../../packages/engine-http/src/prometheus/ShowMetricsMiddleware.ts"],"sourcesContent":["import prom from 'prom-client'\nimport { KoaMiddleware } from '../application/index.js'\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":";AAGO,MAAM,8BAA8B,CAAC,aAAgD;AAC3F,SAAO,OAAO,KAAK,SAAS;AAC3B,QAAI,IAAI,SAAS,YAAY;AAC5B,aAAO,KAAA;AAAA,IACR;AACA,QAAI,oBAAoB,KAAK,oBAAoB;AAChD,UAAI,OAAO,MAAM,SAAS,eAAA;AAAA,IAC3B,OAAO;AACN,UAAI,OAAO,SAAS,QAAA;AAAA,IACrB;AAAA,EACD;AACD;"}
@@ -1 +1 @@
1
- {"version":3,"file":"dbMetrics.cjs","sources":["../../../../../packages/engine-http/src/prometheus/dbMetrics.ts"],"sourcesContent":["/// <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\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\tconst descriptionSuffix =\n\t\t'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:\n\t\t\t`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":";;;;;AAKA,MAAM,aAAa,CAAC,qBAA8B,oBAA6B,2BAAoC,mBAAmB;AAU/H,MAAM,2BAA2B,CAAC,aAAsD;AAC9F,QAAM,uBAAuB,6BAA6B,QAAQ;AAClE,QAAM,8BAAc,IAAA;AACpB,QAAM,YAAY,MAAM;AACvB,yBAAqB,OAAO;AAAA,EAC7B;AACA,WAAS,kBAAkB,SAAS;AACpC,QAAM,sBAAsB,0BAA0B,QAAQ;AAC9D,SAAO,CAAA,UAAS;AACf,YAAQ,IAAI,KAAK;AACjB,UAAM,wBAAwB,oBAAoB,MAAM,YAAY,MAAM,MAAM;AAChF,WAAO,MAAM;AACZ,cAAQ,OAAO,KAAK;AACpB,4BAAA;AAAA,IACD;AAAA,EACD;AACD;AAEA,MAAM,+BAA+B,CAAC,aAA4B;AACjE,QAAM,oBACL;AACD,QAAM,aAAa,IAAI,KAAK,MAAM;AAAA,IACjC,WAAW,CAAC,QAAQ;AAAA,IACpB,MAAM;AAAA,IACN,MAAM,yDAAyD,iBAAiB;AAAA,IAChF;AAAA,EA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AA,MAAA,CACxC;AAAA,IACF;AACA,eAAW,aAAa,GAAGC,SAAAA,aAAa,MAAM,UAAU,gBAAgB;AACxE,eAAW,aAAa,GAAGA,SAAAA,aAAa,MAAM,YAAY,kBAAkB;AAC5E,WAAO,MAAM;AACZ,iBAAW,aAAa,eAAeA,SAAAA,aAAa,MAAM,UAAU,gBAAgB;AACpF,iBAAW,aAAa,eAAeA,SAAAA,aAAa,MAAM,YAAY,kBAAkB;AAAA,IACzF;AAAA,EACD;AACD;;"}
1
+ {"version":3,"file":"dbMetrics.cjs","sources":["../../../../../packages/engine-http/src/prometheus/dbMetrics.ts"],"sourcesContent":["/// <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.js'\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\tconst descriptionSuffix =\n\t\t'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:\n\t\t\t`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":";;;;;AAKA,MAAM,aAAa,CAAC,qBAA8B,oBAA6B,2BAAoC,mBAAmB;AAU/H,MAAM,2BAA2B,CAAC,aAAsD;AAC9F,QAAM,uBAAuB,6BAA6B,QAAQ;AAClE,QAAM,8BAAc,IAAA;AACpB,QAAM,YAAY,MAAM;AACvB,yBAAqB,OAAO;AAAA,EAC7B;AACA,WAAS,kBAAkB,SAAS;AACpC,QAAM,sBAAsB,0BAA0B,QAAQ;AAC9D,SAAO,CAAA,UAAS;AACf,YAAQ,IAAI,KAAK;AACjB,UAAM,wBAAwB,oBAAoB,MAAM,YAAY,MAAM,MAAM;AAChF,WAAO,MAAM;AACZ,cAAQ,OAAO,KAAK;AACpB,4BAAA;AAAA,IACD;AAAA,EACD;AACD;AAEA,MAAM,+BAA+B,CAAC,aAA4B;AACjE,QAAM,oBACL;AACD,QAAM,aAAa,IAAI,KAAK,MAAM;AAAA,IACjC,WAAW,CAAC,QAAQ;AAAA,IACpB,MAAM;AAAA,IACN,MAAM,yDAAyD,iBAAiB;AAAA,IAChF;AAAA,EAAA,CACA;AACD,QAAM,YAAY,IAA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A,eAAW,aAAa,GAAGC,SAAAA,aAAa,MAAM,UAAU,gBAAgB;AACxE,eAAW,aAAa,GAAGA,SAAAA,aAAa,MAAM,YAAY,kBAAkB;AAC5E,WAAO,MAAM;AACZ,iBAAW,aAAa,eAAeA,SAAAA,aAAa,MAAM,UAAU,gBAAgB;AACpF,iBAAW,aAAa,eAAeA,SAAAA,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":["/// <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\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\tconst descriptionSuffix =\n\t\t'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:\n\t\t\t`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":";;;AAKA,MAAM,aAAa,CAAC,qBAA8B,oBAA6B,2BAAoC,mBAAmB;AAU/H,MAAM,2BAA2B,CAAC,aAAsD;AAC9F,QAAM,uBAAuB,6BAA6B,QAAQ;AAClE,QAAM,8BAAc,IAAA;AACpB,QAAM,YAAY,MAAM;AACvB,yBAAqB,OAAO;AAAA,EAC7B;AACA,WAAS,kBAAkB,SAAS;AACpC,QAAM,sBAAsB,0BAA0B,QAAQ;AAC9D,SAAO,CAAA,UAAS;AACf,YAAQ,IAAI,KAAK;AACjB,UAAM,wBAAwB,oBAAoB,MAAM,YAAY,MAAM,MAAM;AAChF,WAAO,MAAM;AACZ,cAAQ,OAAO,KAAK;AACpB,4BAAA;AAAA,IACD;AAAA,EACD;AACD;AAEA,MAAM,+BAA+B,CAAC,aAA4B;AACjE,QAAM,oBACL;AACD,QAAM,aAAa,IAAI,KAAK,MAAM;AAAA,IACjC,WAAW,CAAC,QAAQ;AAAA,IACpB,MAAM;AAAA,IACN,MAAM,yDAAyD,iBAAiB;AAAA,IAChF;AAAA,EAAA,CACA;AACD,QAAM,YAAY,IAAI,KAAK,MAAM;AAAA,IAChC,WAAW,CAAC,QAAQ;AA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,aAAa,GAAG,aAAa,MAAM,YAAY,kBAAkB;AAC5E,WAAO,MAAM;AACZ,iBAAW,aAAa,eAAe,aAAa,MAAM,UAAU,gBAAgB;AACpF,iBAAW,aAAa,eAAe,aAAa,MAAM,YAAY,kBAAkB;AAAA,IACzF;AAAA,EACD;AACD;"}
1
+ {"version":3,"file":"dbMetrics.js","sources":["../../../../../packages/engine-http/src/prometheus/dbMetrics.ts"],"sourcesContent":["/// <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.js'\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\tconst descriptionSuffix =\n\t\t'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:\n\t\t\t`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":";;;AAKA,MAAM,aAAa,CAAC,qBAA8B,oBAA6B,2BAAoC,mBAAmB;AAU/H,MAAM,2BAA2B,CAAC,aAAsD;AAC9F,QAAM,uBAAuB,6BAA6B,QAAQ;AAClE,QAAM,8BAAc,IAAA;AACpB,QAAM,YAAY,MAAM;AACvB,yBAAqB,OAAO;AAAA,EAC7B;AACA,WAAS,kBAAkB,SAAS;AACpC,QAAM,sBAAsB,0BAA0B,QAAQ;AAC9D,SAAO,CAAA,UAAS;AACf,YAAQ,IAAI,KAAK;AACjB,UAAM,wBAAwB,oBAAoB,MAAM,YAAY,MAAM,MAAM;AAChF,WAAO,MAAM;AACZ,cAAQ,OAAO,KAAK;AACpB,4BAAA;AAAA,IACD;AAAA,EACD;AACD;AAEA,MAAM,+BAA+B,CAAC,aAA4B;AACjE,QAAM,oBACL;AACD,QAAM,aAAa,IAAI,KAAK,MAAM;AAAA,IACjC,WAAW,CAAC,QAAQ;AAAA,IACpB,MAAM;AAAA,IACN,MAAM,yDAAyD,iBAAiB;AAAA,IAChF;AAAA,EAAA,CACA;AACD,QAAM,YAAY,IAAI,KAAK,MAAM;AAAA,IAChC,WAAW,CAAC,QAAQ;AAAA,IACpB,MAAM;AAAA,IACN,MAAM,uFAAuF,iBAAiB;AAAA,IAC9G;AAAA,EAAA,CACA;AACD,QAAM,eAAe,IAAI,K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BAAgB;AACpF,iBAAW,aAAa,eAAe,aAAa,MAAM,YAAY,kBAAkB;AAAA,IACzF;AAAA,EACD;AACD;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ContentQueryExecutor.cjs","sources":["../../../../../packages/engine-http/src/system/ContentQueryExecutor.ts"],"sourcesContent":["import { Authorizator, ExecutionContainerFactory, GraphQlSchemaBuilderFactory } from '@contember/engine-content-api'\nimport {\n\tContentQueryExecutor,\n\tContentQueryExecutorContext,\n\tContentQueryExecutorQuery,\n\tContentQueryExecutorResult,\n} from '@contember/engine-system-api'\nimport { logger } from '@contember/logger'\nimport { AllowAllPermissionFactory } from '@contember/schema-utils'\nimport { graphql, GraphQLError } from 'graphql'\nimport { ContentGraphqlContext } from '../content/ContentGraphqlContext'\nimport { extractOriginalError } from '../graphql'\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(\n\t\t{ db, schema, schemaMeta, databaseMetadata, stage, project, identity }: ContentQueryExecutorContext,\n\t\t{ query, variables }: ContentQueryExecutorQuery,\n\t): Promise<ContentQueryExecutorResult> {\n\t\tconst permissions = new AllowAllPermissionFactory().create(schema.model, true)\n\t\tconst authorizator = new Authorizator(permissions, true, false)\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\tuserInfo: {\n\t\t\t\tipAddress: null,\n\t\t\t\tuserAgent: null,\n\t\t\t},\n\t\t})\n\n\t\tconst ctx: ContentGraphqlContext = {\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\t&& originalError !== null\n\t\t\t&& 'message' in originalError\n\t\t? `: ${originalError.message}`\n\t\t: ''\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,QACZ,EAAE,IAAI,QAAQ,YAAY,kBAAkB,OAAO,SAAS,SAAA,GAC5D,EAAE,OAAO,aAC6B;AACtC,UAAM,cAAc,IAAIA,sCAAA,EAA4B,OAAO,OAAO,OAAO,IAAI;AAC7E,UAAM,eAAe,IAAIC,iBAAAA,aAAa,aAAa,MAAM,KAAK;AAC9D,UAAM,oBAAo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OAAO,KAC1B;AAEHC,SAAAA,OAAO,MAAM,CAAC;AAEd,SAAO,iBAAiB,YAAY;AACrC;;"}
1
+ {"version":3,"file":"ContentQueryExecutor.cjs","sources":["../../../../../packages/engine-http/src/system/ContentQueryExecutor.ts"],"sourcesContent":["import { Authorizator, ExecutionContainerFactory, GraphQlSchemaBuilderFactory } from '@contember/engine-content-api'\nimport {\n\tContentQueryExecutor,\n\tContentQueryExecutorContext,\n\tContentQueryExecutorQuery,\n\tContentQueryExecutorResult,\n} from '@contember/engine-system-api'\nimport { logger } from '@contember/logger'\nimport { AllowAllPermissionFactory } from '@contember/schema-utils'\nimport { graphql, GraphQLError } from 'graphql'\nimport { ContentGraphqlContext } from '../content/ContentGraphqlContext.js'\nimport { extractOriginalError } from '../graphql/index.js'\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(\n\t\t{ db, schema, schemaMeta, databaseMetadata, stage, project, identity }: ContentQueryExecutorContext,\n\t\t{ query, variables }: ContentQueryExecutorQuery,\n\t): Promise<ContentQueryExecutorResult> {\n\t\tconst permissions = new AllowAllPermissionFactory().create(schema.model, true)\n\t\tconst authorizator = new Authorizator(permissions, true, false)\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\tuserInfo: {\n\t\t\t\tipAddress: null,\n\t\t\t\tuserAgent: null,\n\t\t\t},\n\t\t})\n\n\t\tconst ctx: ContentGraphqlContext = {\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\t&& originalError !== null\n\t\t\t&& 'message' in originalError\n\t\t? `: ${originalError.message}`\n\t\t: ''\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,QACZ,EAAE,IAAI,QAAQ,YAAY,kBAAkB,OAAO,SAAS,SAAA,GAC5D,EAAE,OAAO,aAC6B;AACtC,UAAM,cAAc,IAAIA,sCAAA,EAA4B,OAAO,OAAO,OAAO,IAAI;AAC7E,UAAM,eAAe,IAAIC,iBAAAA,aAAa,aAAa,MAAM,KAAK;AAC9D,UAAM,oBAAoB,KAAK,4BAA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AAEHC,SAAAA,OAAO,MAAM,CAAC;AAEd,SAAO,iBAAiB,YAAY;AACrC;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ContentQueryExecutor.js","sources":["../../../../../packages/engine-http/src/system/ContentQueryExecutor.ts"],"sourcesContent":["import { Authorizator, ExecutionContainerFactory, GraphQlSchemaBuilderFactory } from '@contember/engine-content-api'\nimport {\n\tContentQueryExecutor,\n\tContentQueryExecutorContext,\n\tContentQueryExecutorQuery,\n\tContentQueryExecutorResult,\n} from '@contember/engine-system-api'\nimport { logger } from '@contember/logger'\nimport { AllowAllPermissionFactory } from '@contember/schema-utils'\nimport { graphql, GraphQLError } from 'graphql'\nimport { ContentGraphqlContext } from '../content/ContentGraphqlContext'\nimport { extractOriginalError } from '../graphql'\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(\n\t\t{ db, schema, schemaMeta, databaseMetadata, stage, project, identity }: ContentQueryExecutorContext,\n\t\t{ query, variables }: ContentQueryExecutorQuery,\n\t): Promise<ContentQueryExecutorResult> {\n\t\tconst permissions = new AllowAllPermissionFactory().create(schema.model, true)\n\t\tconst authorizator = new Authorizator(permissions, true, false)\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\tuserInfo: {\n\t\t\t\tipAddress: null,\n\t\t\t\tuserAgent: null,\n\t\t\t},\n\t\t})\n\n\t\tconst ctx: ContentGraphqlContext = {\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\t&& originalError !== null\n\t\t\t&& 'message' in originalError\n\t\t? `: ${originalError.message}`\n\t\t: ''\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,QACZ,EAAE,IAAI,QAAQ,YAAY,kBAAkB,OAAO,SAAS,SAAA,GAC5D,EAAE,OAAO,aAC6B;AACtC,UAAM,cAAc,IAAI,0BAAA,EAA4B,OAAO,OAAO,OAAO,IAAI;AAC7E,UAAM,eAAe,IAAI,aAAa,aAAa,MAAM,KAAK;AAC9D,UAAM,oBAAoB,KAAK,4BAA4B,OAAO,OAAO,OAAO,YAAY;AAC5F,UAAM,aAAa,kBAAkB,MAAA;AAErC,UAAM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","sources":["../../../../../packages/engine-http/src/system/ContentQueryExecutor.ts"],"sourcesContent":["import { Authorizator, ExecutionContainerFactory, GraphQlSchemaBuilderFactory } from '@contember/engine-content-api'\nimport {\n\tContentQueryExecutor,\n\tContentQueryExecutorContext,\n\tContentQueryExecutorQuery,\n\tContentQueryExecutorResult,\n} from '@contember/engine-system-api'\nimport { logger } from '@contember/logger'\nimport { AllowAllPermissionFactory } from '@contember/schema-utils'\nimport { graphql, GraphQLError } from 'graphql'\nimport { ContentGraphqlContext } from '../content/ContentGraphqlContext.js'\nimport { extractOriginalError } from '../graphql/index.js'\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(\n\t\t{ db, schema, schemaMeta, databaseMetadata, stage, project, identity }: ContentQueryExecutorContext,\n\t\t{ query, variables }: ContentQueryExecutorQuery,\n\t): Promise<ContentQueryExecutorResult> {\n\t\tconst permissions = new AllowAllPermissionFactory().create(schema.model, true)\n\t\tconst authorizator = new Authorizator(permissions, true, false)\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\tuserInfo: {\n\t\t\t\tipAddress: null,\n\t\t\t\tuserAgent: null,\n\t\t\t},\n\t\t})\n\n\t\tconst ctx: ContentGraphqlContext = {\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\t&& originalError !== null\n\t\t\t&& 'message' in originalError\n\t\t? `: ${originalError.message}`\n\t\t: ''\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,QACZ,EAAE,IAAI,QAAQ,YAAY,kBAAkB,OAAO,SAAS,SAAA,GAC5D,EAAE,OAAO,aAC6B;AACtC,UAAM,cAAc,IAAI,0BAAA,EAA4B,OAAO,OAAO,OAAO,IAAI;AAC7E,UAAM,eAAe,IAAI,aAAa,aAAa,MAAM,KAAK;AAC9D,UAAM,oBAAoB,KAAK,4BAA4B,OAAO,OAAO,OAAO,YAAY;AAC5F,UAAM,aAAa,kBAAkB,MAAA;AAErC,UAAM,aAAa,SAAS;AAE5B,UAAM,qBAAqB,KAAK,0BAA0B,OAAO;AAAA,MAChE,IAAI,GAAG,OAAO,UAAU,MAAM,MAAM;AAAA,MACpC,mBAAmB,CAAA;AAAA,MACnB;AAAA,MACA;AAAA,MACA;AAAA,MACA,wBAAwB;AAAA,MACxB;AAAA,MACA,cAAc,QAAQ;AAAA,MACtB;AAAA,MACA;AAAA,MACA,UAAU;AAAA,QACT,WAAW;AAAA,QACX,WAAW;AAAA,MAAA;AAAA,IACZ,CACA;AAED,UAAM,MAA6B;AAAA,MAClC;AAAA,MACA,IAAI,GAAG,OAAO,UAAU,MAAM,MAAM;AAAA,MACpC,mBAAmB,CAAA;AAAA,MACnB;AAAA,MACA,cAAc;AAAA,MACd;AAAA,MACA,OAAO,CAAC,OAAO,OAAO,GAAA;AAAA,IAAG;AAG1B,QAAI;AACH,YAAM,SAAS,MAAM,QAAQ;AAAA,QAC5B,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,gBAAgB;AAAA,QAChB,cAAc;AAAA,MAAA,CACd;AACD,UAAI,OAAO,QAAQ,QAAQ;AAC1B,eAAO,EAAE,IAAI,OAAO,QAAQ,OAAO,OAAO,IAAI,kBAAkB,EAAA;AAAA,MACjE;AACA,aAAO,EAAE,IAAI,MAAM,OAAA;AAAA,IACpB,SAAS,GAAG;AACX,aAAO,EAAE,IAAI,OAAO,QAAQ,CAAC,mBAAmB,CAAC,CAAC,EAAA;AAAA,IACnD;AAAA,EACD;AACD;AAEA,MAAM,qBAAqB,CAAC,MAAmB;AAC9C,QAAM,gBAAgB,qBAAqB,CAAC;AAC5C,MAAI,yBAAyB,cAAc;AAC1C,WAAO,cAAc;AAAA,EACtB;AACA,QAAM,eAAe,OAAO,kBAAkB,YACzC,kBAAkB,QAClB,aAAa,gBACf,KAAK,cAAc,OAAO,KAC1B;AAEH,SAAO,MAAM,CAAC;AAEd,SAAO,iBAAiB,YAAY;AACrC;"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const HttpResponse = require("../common/HttpResponse.cjs");
4
+ require("ipaddr.js");
4
5
  class SystemApiMiddlewareFactory {
5
6
  constructor(debug, systemGraphqlContextFactory, projectContextResolver) {
6
7
  this.debug = debug;
@@ -1 +1 @@
1
- {"version":3,"file":"SystemApiMiddlewareFactory.cjs","sources":["../../../../../packages/engine-http/src/system/SystemApiMiddlewareFactory.ts"],"sourcesContent":["import { HttpController } from '../application'\nimport { ProjectContextResolver } from '../project-common'\nimport { HttpErrorResponse } from '../common'\nimport { SystemGraphQLContextFactory } from './SystemGraphQLContextFactory'\nimport { GraphQLKoaState } from '../graphql'\n\nexport class SystemApiMiddlewareFactory {\n\tconstructor(\n\t\tprivate readonly debug: boolean,\n\t\tprivate readonly systemGraphqlContextFactory: SystemGraphQLContextFactory,\n\t\tprivate readonly projectContextResolver: ProjectContextResolver,\n\t) {\n\t}\n\n\tcreate(): HttpController {\n\t\treturn async context => {\n\t\t\tconst { timer, projectGroup, authResult, koa } = context\n\t\t\tif (!authResult) {\n\t\t\t\treturn new HttpErrorResponse(401, 'Authentication required')\n\t\t\t}\n\t\t\tconst { projectContainer, project } = await this.projectContextResolver.resolve(context)\n\n\t\t\tconst logger = context.logger.child({\n\t\t\t\tproject: project.slug,\n\t\t\t})\n\n\t\t\tconst tenantContainer = projectGroup.tenantContainer\n\t\t\tconst memberships = await timer('MembershipFetch', () =>\n\t\t\t\ttenantContainer.projectMemberManager.getEffectiveProjectMemberships(\n\t\t\t\t\ttenantContainer.databaseContext,\n\t\t\t\t\t{ slug: project.slug },\n\t\t\t\t\t{\n\t\t\t\t\t\tid: authResult.identityId,\n\t\t\t\t\t\troles: authResult.roles,\n\t\t\t\t\t},\n\t\t\t\t))\n\t\t\tlogger.debug('Memberships fetched', { memberships })\n\n\t\t\tif (memberships.length === 0) {\n\t\t\t\tthrow this.debug\n\t\t\t\t\t? new HttpErrorResponse(403, `You are not allowed to access project ${project.slug}`)\n\t\t\t\t\t: new HttpErrorResponse(404, `Project ${project.slug} NOT found`)\n\t\t\t}\n\n\t\t\tawait logger.scope(async logger => {\n\t\t\t\tlogger.debug('System query processing started')\n\t\t\t\tconst graphqlContext = await this.systemGraphqlContextFactory.create({\n\t\t\t\t\tauthResult,\n\t\t\t\t\tmemberships,\n\t\t\t\t\tprojectContainer,\n\t\t\t\t\tsystemContainer: projectGroup.systemContainer,\n\t\t\t\t\tonClearCache: () => {\n\t\t\t\t\t\tprojectContainer.contentSchemaResolver.clearCache()\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t\tconst handler = projectGroup.systemGraphQLHandler\n\n\t\t\t\tawait timer('GraphQL', () =>\n\t\t\t\t\thandler({\n\t\t\t\t\t\trequest: koa.request,\n\t\t\t\t\t\tresponse: koa.response,\n\t\t\t\t\t\tcreateContext: ({ operation }) => {\n\t\t\t\t\t\t\t;(koa.state as GraphQLKoaState).graphql = {\n\t\t\t\t\t\t\t\toperationName: operation,\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn graphqlContext\n\t\t\t\t\t\t},\n\t\t\t\t\t}))\n\t\t\t\tlogger.debug('System query finished')\n\t\t\t})\n\t\t}\n\t}\n}\n"],"names":["HttpErrorResponse","logger"],"mappings":";;;AAMO,MAAM,2BAA2B;AAAA,EACvC,YACkB,OACA,6BACA,wBAChB;AAHgB,SAAA,QAAA;AACA,SAAA,8BAAA;AACA,SAAA,yBAAA;AAAA,EAElB;AAAA,EAEA,SAAyB;AACxB,WAAO,OAAM,YAAW;AACvB,YAAM,EAAE,OAAO,cAAc,YAAY,QAAQ;AACjD,UAAI,CAAC,YAAY;AAChB,eAAO,IAAIA,aAAAA,kBAAkB,KAAK,yBAAyB;AAAA,MAC5D;AACA,YAAM,EAAE,kBAAkB,QAAA,IAAY,MAAM,KAAK,uBAAuB,QAAQ,OAAO;AAEvF,YAAM,SAAS,QAAQ,OAAO,MAAM;AAAA,QACnC,SAAS,QAAQ;AAAA,MAAA,CACjB;AAED,YAAM,kBAAkB,aAAa;AACrC,YAAM,cAAc,MAAM,MAAM,mBAAmB,MAClD,gBAAgB,qBAAqB;AAAA,QACpC,gBAAgB;AAAA,QAChB,EAAE,MAAM,QAAQ,KAAA;AAAA,QAChB;AAAA,UACC,IAAI,WAAW;AAAA,UACf,OAAO,WAAW;AAAA,QAAA;AAAA,MACnB,CACA;AACF,aAAO,MAAM,uBAAuB,EAAE,YAAA,CAAa;AAEnD,UAAI,YAAY,WAAW,GAAG;AAC7B,cAAM,KAAK,QACR,IAAIA,aAAAA,kBAAkB,KAAK,yCAAyC,QAAQ,IAAI,EAAE,IAClF,IAAIA,aAAAA,kBAAkB,KAAK,WAAW,QAAQ,IAAI,YAAY;AAAA,MAClE;AAEA,YAAM,OAAO,MAAM,OAAMC,YAAU;AAClCA,gBAAO,MAAM,iCAAiC;AAC9C,cAAM,iBAAiB,MAAM,KAAK,4BAA4B,OAAO;AAAA,UACpE;AAAA,UACA;AAAA,UACA;AAAA,UACA,iBAAiB,aAAa;AAAA,UAC9B,cAAc,MAAM;AACnB,6BAAiB,sBAAsB,WAAA;AAAA,UACxC;AAAA,QAAA,CACA;AACD,cAAM,UAAU,aAAa;AAE7B,cAAM,MAAM,WAAW,MACtB,QAAQ;AAAA,UACP,SAAS,IAAI;AAAA,UACb,UAAU,IAAI;AAAA,UACd,eAAe,CAAC,EAAE,gBAAgB;AAC/B,gBAAI,MAA0B,UAAU;AAAA,cACzC,eAAe;AAAA,YAAA;AAGhB,mBAAO;AAAA,UACR;AAAA,QAAA,CACA,CAAC;AACHA,gBAAO,MAAM,uBAAuB;AAAA,MACrC,CAAC;AAAA,IACF;AAAA,EACD;AACD;;"}
1
+ {"version":3,"file":"SystemApiMiddlewareFactory.cjs","sources":["../../../../../packages/engine-http/src/system/SystemApiMiddlewareFactory.ts"],"sourcesContent":["import { HttpController } from '../application/index.js'\nimport { ProjectContextResolver } from '../project-common/index.js'\nimport { HttpErrorResponse } from '../common/index.js'\nimport { SystemGraphQLContextFactory } from './SystemGraphQLContextFactory.js'\nimport { GraphQLKoaState } from '../graphql/index.js'\n\nexport class SystemApiMiddlewareFactory {\n\tconstructor(\n\t\tprivate readonly debug: boolean,\n\t\tprivate readonly systemGraphqlContextFactory: SystemGraphQLContextFactory,\n\t\tprivate readonly projectContextResolver: ProjectContextResolver,\n\t) {\n\t}\n\n\tcreate(): HttpController {\n\t\treturn async context => {\n\t\t\tconst { timer, projectGroup, authResult, koa } = context\n\t\t\tif (!authResult) {\n\t\t\t\treturn new HttpErrorResponse(401, 'Authentication required')\n\t\t\t}\n\t\t\tconst { projectContainer, project } = await this.projectContextResolver.resolve(context)\n\n\t\t\tconst logger = context.logger.child({\n\t\t\t\tproject: project.slug,\n\t\t\t})\n\n\t\t\tconst tenantContainer = projectGroup.tenantContainer\n\t\t\tconst memberships = await timer('MembershipFetch', () =>\n\t\t\t\ttenantContainer.projectMemberManager.getEffectiveProjectMemberships(\n\t\t\t\t\ttenantContainer.databaseContext,\n\t\t\t\t\t{ slug: project.slug },\n\t\t\t\t\t{\n\t\t\t\t\t\tid: authResult.identityId,\n\t\t\t\t\t\troles: authResult.roles,\n\t\t\t\t\t},\n\t\t\t\t))\n\t\t\tlogger.debug('Memberships fetched', { memberships })\n\n\t\t\tif (memberships.length === 0) {\n\t\t\t\tthrow this.debug\n\t\t\t\t\t? new HttpErrorResponse(403, `You are not allowed to access project ${project.slug}`)\n\t\t\t\t\t: new HttpErrorResponse(404, `Project ${project.slug} NOT found`)\n\t\t\t}\n\n\t\t\tawait logger.scope(async logger => {\n\t\t\t\tlogger.debug('System query processing started')\n\t\t\t\tconst graphqlContext = await this.systemGraphqlContextFactory.create({\n\t\t\t\t\tauthResult,\n\t\t\t\t\tmemberships,\n\t\t\t\t\tprojectContainer,\n\t\t\t\t\tsystemContainer: projectGroup.systemContainer,\n\t\t\t\t\tonClearCache: () => {\n\t\t\t\t\t\tprojectContainer.contentSchemaResolver.clearCache()\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t\tconst handler = projectGroup.systemGraphQLHandler\n\n\t\t\t\tawait timer('GraphQL', () =>\n\t\t\t\t\thandler({\n\t\t\t\t\t\trequest: koa.request,\n\t\t\t\t\t\tresponse: koa.response,\n\t\t\t\t\t\tcreateContext: ({ operation }) => {\n\t\t\t\t\t\t\t;(koa.state as GraphQLKoaState).graphql = {\n\t\t\t\t\t\t\t\toperationName: operation,\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn graphqlContext\n\t\t\t\t\t\t},\n\t\t\t\t\t}))\n\t\t\t\tlogger.debug('System query finished')\n\t\t\t})\n\t\t}\n\t}\n}\n"],"names":["HttpErrorResponse","logger"],"mappings":";;;;AAMO,MAAM,2BAA2B;AAAA,EACvC,YACkB,OACA,6BACA,wBAChB;AAHgB,SAAA,QAAA;AACA,SAAA,8BAAA;AACA,SAAA,yBAAA;AAAA,EAElB;AAAA,EAEA,SAAyB;AACxB,WAAO,OAAM,YAAW;AACvB,YAAM,EAAE,OAAO,cAAc,YAAY,QAAQ;AACjD,UAAI,CAAC,YAAY;AAChB,eAAO,IAAIA,aAAAA,kBAAkB,KAAK,yBAAyB;AAAA,MAC5D;AACA,YAAM,EAAE,kBAAkB,QAAA,IAAY,MAAM,KAAK,uBAAuB,QAAQ,OAAO;AAEvF,YAAM,SAAS,QAAQ,OAAO,MAAM;AAAA,QACnC,SAAS,QAAQ;AAAA,MAAA,CACjB;AAED,YAAM,kBAAkB,aAAa;AACrC,YAAM,cAAc,MAAM,MAAM,mBAAmB,MAClD,gBAAgB,qBAAqB;AAAA,QACpC,gBAAgB;AAAA,QAChB,EAAE,MAAM,QAAQ,KAAA;AAAA,QAChB;AAAA,UACC,IAAI,WAAW;AAAA,UACf,OAAO,WAAW;AAAA,QAAA;AAAA,MACnB,CACA;AACF,aAAO,MAAM,uBAAuB,EAAE,YAAA,CAAa;AAEnD,UAAI,YAAY,WAAW,GAAG;AAC7B,cAAM,KAAK,QACR,IAAIA,aAAAA,kBAAkB,KAAK,yCAAyC,QAAQ,IAAI,EAAE,IAClF,IAAIA,aAAAA,kBAAkB,KAAK,WAAW,QAAQ,IAAI,YAAY;AAAA,MAClE;AAEA,YAAM,OAAO,MAAM,OAAMC,YAAU;AAClCA,gBAAO,MAAM,iCAAiC;AAC9C,cAAM,iBAAiB,MAAM,KAAK,4BAA4B,OAAO;AAAA,UACpE;AAAA,UACA;AAAA,UACA;AAAA,UACA,iBAAiB,aAAa;AAAA,UAC9B,cAAc,MAAM;AACnB,6BAAiB,sBAAsB,WAAA;AAAA,UACxC;AAAA,QAAA,CACA;AACD,cAAM,UAAU,aAAa;AAE7B,cAAM,MAAM,WAAW,MACtB,QAAQ;AAAA,UACP,SAAS,IAAI;AAAA,UACb,UAAU,IAAI;AAAA,UACd,eAAe,CAAC,EAAE,gBAAgB;AAC/B,gBAAI,MAA0B,UAAU;AAAA,cACzC,eAAe;AAAA,YAAA;AAGhB,mBAAO;AAAA,UACR;AAAA,QAAA,CACA,CAAC;AACHA,gBAAO,MAAM,uBAAuB;AAAA,MACrC,CAAC;AAAA,IACF;AAAA,EACD;AACD;;"}
@@ -1,4 +1,5 @@
1
1
  import { HttpErrorResponse } from "../common/HttpResponse.js";
2
+ import "ipaddr.js";
2
3
  class SystemApiMiddlewareFactory {
3
4
  constructor(debug, systemGraphqlContextFactory, projectContextResolver) {
4
5
  this.debug = debug;
@@ -1 +1 @@
1
- {"version":3,"file":"SystemApiMiddlewareFactory.js","sources":["../../../../../packages/engine-http/src/system/SystemApiMiddlewareFactory.ts"],"sourcesContent":["import { HttpController } from '../application'\nimport { ProjectContextResolver } from '../project-common'\nimport { HttpErrorResponse } from '../common'\nimport { SystemGraphQLContextFactory } from './SystemGraphQLContextFactory'\nimport { GraphQLKoaState } from '../graphql'\n\nexport class SystemApiMiddlewareFactory {\n\tconstructor(\n\t\tprivate readonly debug: boolean,\n\t\tprivate readonly systemGraphqlContextFactory: SystemGraphQLContextFactory,\n\t\tprivate readonly projectContextResolver: ProjectContextResolver,\n\t) {\n\t}\n\n\tcreate(): HttpController {\n\t\treturn async context => {\n\t\t\tconst { timer, projectGroup, authResult, koa } = context\n\t\t\tif (!authResult) {\n\t\t\t\treturn new HttpErrorResponse(401, 'Authentication required')\n\t\t\t}\n\t\t\tconst { projectContainer, project } = await this.projectContextResolver.resolve(context)\n\n\t\t\tconst logger = context.logger.child({\n\t\t\t\tproject: project.slug,\n\t\t\t})\n\n\t\t\tconst tenantContainer = projectGroup.tenantContainer\n\t\t\tconst memberships = await timer('MembershipFetch', () =>\n\t\t\t\ttenantContainer.projectMemberManager.getEffectiveProjectMemberships(\n\t\t\t\t\ttenantContainer.databaseContext,\n\t\t\t\t\t{ slug: project.slug },\n\t\t\t\t\t{\n\t\t\t\t\t\tid: authResult.identityId,\n\t\t\t\t\t\troles: authResult.roles,\n\t\t\t\t\t},\n\t\t\t\t))\n\t\t\tlogger.debug('Memberships fetched', { memberships })\n\n\t\t\tif (memberships.length === 0) {\n\t\t\t\tthrow this.debug\n\t\t\t\t\t? new HttpErrorResponse(403, `You are not allowed to access project ${project.slug}`)\n\t\t\t\t\t: new HttpErrorResponse(404, `Project ${project.slug} NOT found`)\n\t\t\t}\n\n\t\t\tawait logger.scope(async logger => {\n\t\t\t\tlogger.debug('System query processing started')\n\t\t\t\tconst graphqlContext = await this.systemGraphqlContextFactory.create({\n\t\t\t\t\tauthResult,\n\t\t\t\t\tmemberships,\n\t\t\t\t\tprojectContainer,\n\t\t\t\t\tsystemContainer: projectGroup.systemContainer,\n\t\t\t\t\tonClearCache: () => {\n\t\t\t\t\t\tprojectContainer.contentSchemaResolver.clearCache()\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t\tconst handler = projectGroup.systemGraphQLHandler\n\n\t\t\t\tawait timer('GraphQL', () =>\n\t\t\t\t\thandler({\n\t\t\t\t\t\trequest: koa.request,\n\t\t\t\t\t\tresponse: koa.response,\n\t\t\t\t\t\tcreateContext: ({ operation }) => {\n\t\t\t\t\t\t\t;(koa.state as GraphQLKoaState).graphql = {\n\t\t\t\t\t\t\t\toperationName: operation,\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\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AA;AAAA,UACxC;AAAA,QAAA,CACA;AACD,cAAM,UAAU,aAAa;AAE7B,cAAM,MAAM,WAAW,MACtB,QAAQ;AAAA,UACP,SAAS,IAAI;AAAA,UACb,UAAU,IAAI;AAAA,UACd,eAAe,CAAC,EAAE,gBAAgB;AAC/B,gBAAI,MAA0B,UAAU;AAAA,cACzC,eAAe;AAAA,YAAA;AAGhB,mBAAO;AAAA,UACR;AAAA,QAAA,CACA,CAAC;AACHA,gBAAO,MAAM,uBAAuB;AAAA,MACrC,CAAC;AAAA,IACF;AAAA,EACD;AACD;"}
1
+ {"version":3,"file":"SystemApiMiddlewareFactory.js","sources":["../../../../../packages/engine-http/src/system/SystemApiMiddlewareFactory.ts"],"sourcesContent":["import { HttpController } from '../application/index.js'\nimport { ProjectContextResolver } from '../project-common/index.js'\nimport { HttpErrorResponse } from '../common/index.js'\nimport { SystemGraphQLContextFactory } from './SystemGraphQLContextFactory.js'\nimport { GraphQLKoaState } from '../graphql/index.js'\n\nexport class SystemApiMiddlewareFactory {\n\tconstructor(\n\t\tprivate readonly debug: boolean,\n\t\tprivate readonly systemGraphqlContextFactory: SystemGraphQLContextFactory,\n\t\tprivate readonly projectContextResolver: ProjectContextResolver,\n\t) {\n\t}\n\n\tcreate(): HttpController {\n\t\treturn async context => {\n\t\t\tconst { timer, projectGroup, authResult, koa } = context\n\t\t\tif (!authResult) {\n\t\t\t\treturn new HttpErrorResponse(401, 'Authentication required')\n\t\t\t}\n\t\t\tconst { projectContainer, project } = await this.projectContextResolver.resolve(context)\n\n\t\t\tconst logger = context.logger.child({\n\t\t\t\tproject: project.slug,\n\t\t\t})\n\n\t\t\tconst tenantContainer = projectGroup.tenantContainer\n\t\t\tconst memberships = await timer('MembershipFetch', () =>\n\t\t\t\ttenantContainer.projectMemberManager.getEffectiveProjectMemberships(\n\t\t\t\t\ttenantContainer.databaseContext,\n\t\t\t\t\t{ slug: project.slug },\n\t\t\t\t\t{\n\t\t\t\t\t\tid: authResult.identityId,\n\t\t\t\t\t\troles: authResult.roles,\n\t\t\t\t\t},\n\t\t\t\t))\n\t\t\tlogger.debug('Memberships fetched', { memberships })\n\n\t\t\tif (memberships.length === 0) {\n\t\t\t\tthrow this.debug\n\t\t\t\t\t? new HttpErrorResponse(403, `You are not allowed to access project ${project.slug}`)\n\t\t\t\t\t: new HttpErrorResponse(404, `Project ${project.slug} NOT found`)\n\t\t\t}\n\n\t\t\tawait logger.scope(async logger => {\n\t\t\t\tlogger.debug('System query processing started')\n\t\t\t\tconst graphqlContext = await this.systemGraphqlContextFactory.create({\n\t\t\t\t\tauthResult,\n\t\t\t\t\tmemberships,\n\t\t\t\t\tprojectContainer,\n\t\t\t\t\tsystemContainer: projectGroup.systemContainer,\n\t\t\t\t\tonClearCache: () => {\n\t\t\t\t\t\tprojectContainer.contentSchemaResolver.clearCache()\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t\tconst handler = projectGroup.systemGraphQLHandler\n\n\t\t\t\tawait timer('GraphQL', () =>\n\t\t\t\t\thandler({\n\t\t\t\t\t\trequest: koa.request,\n\t\t\t\t\t\tresponse: koa.response,\n\t\t\t\t\t\tcreateContext: ({ operation }) => {\n\t\t\t\t\t\t\t;(koa.state as GraphQLKoaState).graphql = {\n\t\t\t\t\t\t\t\toperationName: operation,\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn graphqlContext\n\t\t\t\t\t\t},\n\t\t\t\t\t}))\n\t\t\t\tlogger.debug('System query finished')\n\t\t\t})\n\t\t}\n\t}\n}\n"],"names":["logger"],"mappings":";;AAMO,MAAM,2BAA2B;AAAA,EACvC,YACkB,OACA,6BACA,wBAChB;AAHgB,SAAA,QAAA;AACA,SAAA,8BAAA;AACA,SAAA,yBAAA;AAAA,EAElB;AAAA,EAEA,SAAyB;AACxB,WAAO,OAAM,YAAW;AACvB,YAAM,EAAE,OAAO,cAAc,YAAY,QAAQ;AACjD,UAAI,CAAC,YAAY;AAChB,eAAO,IAAI,kBAAkB,KAAK,y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raphQLContextFactory.cjs","sources":["../../../../../packages/engine-http/src/system/SystemGraphQLContextFactory.ts"],"sourcesContent":["import { Identity, SystemContainer } from '@contember/engine-system-api'\nimport { SystemGraphQLContext } from './SystemGraphQLHandlerFactory'\nimport { AuthResult } from '../common'\nimport { Acl } from '@contember/schema'\nimport { ProjectContainer } from '../project'\n\nexport class SystemGraphQLContextFactory {\n\tpublic async create({ authResult, memberships, projectContainer, systemContainer, onClearCache }: {\n\t\tauthResult: AuthResult\n\t\tmemberships: readonly Acl.Membership[]\n\t\tprojectContainer: ProjectContainer\n\t\tsystemContainer: SystemContainer\n\t\tonClearCache: () => void\n\t}): Promise<SystemGraphQLContext> {\n\t\tconst identity = new Identity(\n\t\t\tauthResult.identityId,\n\t\t\tmemberships.map(it => it.role),\n\t\t)\n\n\t\tconst db = projectContainer.systemDatabaseContext\n\t\tconst systemContext = await systemContainer.resolverContextFactory.create({\n\t\t\tdb,\n\t\t\tidentity,\n\t\t\tproject: { ...projectContainer.project, systemSchema: db.client.schema },\n\t\t\tgetSchema: async options => {\n\t\t\t\treturn (await projectContainer.contentSchemaResolver.getSchema({ db, ...options })).schema\n\t\t\t},\n\t\t})\n\t\treturn {\n\t\t\t...systemContext,\n\t\t\tonClearCache,\n\t\t}\n\t}\n}\n"],"names":["Identity"],"mappings":";;;AAMO,MAAM,4BAA4B;AAAA,EACxC,MAAa,OAAO,EAAE,YAAY,aAAa,kBAAkB,iBAAiB,gBAMhD;AACjC,UAAM,WAAW,IAAIA,gBAAAA;AAAAA,MACpB,WAAW;AAAA,MACX,YAAY,IAAI,CAAA,OAAM,GAAG,IAAI;AAAA,IAAA;AAG9B,UAAM,KAAK,iBAAiB;AAC5B,UAAM,gBAAgB,MAAM,gBAAgB,uBAAuB,OAAO;AAAA,MACzE;AAAA,MACA;AAAA,MACA,SAAS,EAAE,GAAG,iBAAiB,SAAS,cAAc,GAAG,OAAO,OAAA;AAAA,MAChE,WAAW,OAAM,YAAW;AAC3B,gBAAQ,MAAM,iBAAiB,sBAAsB,UAAU,EAAE,IAAI,GAAG,QAAA,CAAS,GAAG;AAAA,MACrF;AAAA,IAAA,CACA;AACD,WAAO;AAAA,MACN,GAAG;AAAA,MACH;AAAA,IAAA;AAAA,EAEF;AACD;;"}
1
+ {"version":3,"file":"SystemGraphQLContextFactory.cjs","sources":["../../../../../packages/engine-http/src/system/SystemGraphQLContextFactory.ts"],"sourcesContent":["import { Identity, SystemContainer } from '@contember/engine-system-api'\nimport { SystemGraphQLContext } from './SystemGraphQLHandlerFactory.js'\nimport { AuthResult } from '../common/index.js'\nimport { Acl } from '@contember/schema'\nimport { ProjectContainer } from '../project/index.js'\n\nexport class SystemGraphQLContextFactory {\n\tpublic async create({ authResult, memberships, projectContainer, systemContainer, onClearCache }: {\n\t\tauthResult: AuthResult\n\t\tmemberships: readonly Acl.Membership[]\n\t\tprojectContainer: ProjectContainer\n\t\tsystemContainer: SystemContainer\n\t\tonClearCache: () => void\n\t}): Promise<SystemGraphQLContext> {\n\t\tconst identity = new Identity(\n\t\t\tauthResult.identityId,\n\t\t\tmemberships.map(it => it.role),\n\t\t)\n\n\t\tconst db = projectContainer.systemDatabaseContext\n\t\tconst systemContext = await systemContainer.resolverContextFactory.create({\n\t\t\tdb,\n\t\t\tidentity,\n\t\t\tproject: { ...projectContainer.project, systemSchema: db.client.schema },\n\t\t\tgetSchema: async options => {\n\t\t\t\treturn (await projectContainer.contentSchemaResolver.getSchema({ db, ...options })).schema\n\t\t\t},\n\t\t})\n\t\treturn {\n\t\t\t...systemContext,\n\t\t\tonClearCache,\n\t\t}\n\t}\n}\n"],"names":["Identity"],"mappings":";;;AAMO,MAAM,4BAA4B;AAAA,EACxC,MAAa,OAAO,EAAE,YAAY,aAAa,kBAAkB,iBAAiB,gBAMhD;AACjC,UAAM,WAAW,IAAIA,gBAAAA;AAAAA,MACpB,WAAW;AAAA,MACX,YAAY,IAAI,CAAA,OAAM,GAAG,IAAI;AAAA,IAAA;AAG9B,UAAM,KAAK,iBAAiB;AAC5B,UAAM,gBAAgB,MAAM,gBAAgB,uBAAuB,OAAO;AAAA,MACzE;AAAA,MACA;AAAA,MACA,SAAS,EAAE,GAAG,iBAAiB,SAAS,cAAc,GAAG,OAAO,OAAA;AAAA,MAChE,WAAW,OAAM,YAAW;AAC3B,gBAAQ,MAAM,iBAAiB,sBAAsB,UAAU,EAAE,IAAI,GAAG,QAAA,CAAS,GAAG;AAAA,MACrF;AAAA,IAAA,CACA;AACD,WAAO;AAAA,MACN,GAAG;AAAA,MACH;AAAA,IAAA;AAAA,EAEF;AACD;;"}