@hot-updater/server 1.0.0-rc.1 → 1.0.0-rc.16

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 (542) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +1 -1
  2. package/dist/adapters/drizzle.cjs +35 -69
  3. package/dist/adapters/drizzle.d.cts +13 -6
  4. package/dist/adapters/drizzle.d.mts +13 -6
  5. package/dist/adapters/drizzle.mjs +34 -69
  6. package/dist/adapters/drizzleExecutor.cjs +114 -0
  7. package/dist/adapters/drizzleExecutor.d.cts +9 -0
  8. package/dist/adapters/drizzleExecutor.d.mts +9 -0
  9. package/dist/adapters/drizzleExecutor.mjs +112 -0
  10. package/dist/adapters/kysely.cjs +25 -31
  11. package/dist/adapters/kysely.d.cts +10 -7
  12. package/dist/adapters/kysely.d.mts +10 -7
  13. package/dist/adapters/kysely.mjs +25 -31
  14. package/dist/adapters/kyselyExecutor.cjs +32 -0
  15. package/dist/adapters/kyselyExecutor.d.cts +12 -0
  16. package/dist/adapters/kyselyExecutor.d.mts +12 -0
  17. package/dist/adapters/kyselyExecutor.mjs +32 -0
  18. package/dist/adapters/mongodb.cjs +28 -27
  19. package/dist/adapters/mongodb.d.cts +10 -5
  20. package/dist/adapters/mongodb.d.mts +10 -5
  21. package/dist/adapters/mongodb.mjs +28 -27
  22. package/dist/adapters/mongodbAdapter.cjs +174 -0
  23. package/dist/adapters/mongodbAdapter.d.cts +9 -0
  24. package/dist/adapters/mongodbAdapter.d.mts +9 -0
  25. package/dist/adapters/mongodbAdapter.mjs +173 -0
  26. package/dist/adapters/prisma.cjs +38 -220
  27. package/dist/adapters/prisma.d.cts +12 -8
  28. package/dist/adapters/prisma.d.mts +12 -8
  29. package/dist/adapters/prisma.mjs +38 -219
  30. package/dist/adapters/prismaExecutor.cjs +64 -0
  31. package/dist/adapters/prismaExecutor.mjs +64 -0
  32. package/dist/adapters/sqlProviders.cjs +9 -0
  33. package/dist/adapters/sqlProviders.mjs +9 -0
  34. package/dist/apiKeys.cjs +8 -8
  35. package/dist/apiKeys.d.cts +1 -24
  36. package/dist/apiKeys.d.mts +1 -24
  37. package/dist/apiKeys.mjs +5 -9
  38. package/dist/assembly/assemblePlugins.cjs +147 -0
  39. package/dist/assembly/assemblePlugins.d.cts +12 -0
  40. package/dist/assembly/assemblePlugins.d.mts +12 -0
  41. package/dist/assembly/assemblePlugins.mjs +146 -0
  42. package/dist/assembly/databasePlugins.cjs +23 -0
  43. package/dist/assembly/databasePlugins.d.cts +43 -0
  44. package/dist/assembly/databasePlugins.d.mts +43 -0
  45. package/dist/assembly/databasePlugins.mjs +22 -0
  46. package/dist/core/api.cjs +91 -0
  47. package/dist/core/api.d.cts +65 -0
  48. package/dist/core/api.d.mts +65 -0
  49. package/dist/core/api.mjs +87 -0
  50. package/dist/core/baseCandidates.cjs +71 -0
  51. package/dist/core/baseCandidates.d.cts +17 -0
  52. package/dist/core/baseCandidates.d.mts +17 -0
  53. package/dist/core/baseCandidates.mjs +69 -0
  54. package/dist/core/operations.cjs +350 -0
  55. package/dist/core/operations.mjs +350 -0
  56. package/dist/core/reads.cjs +273 -0
  57. package/dist/core/reads.d.cts +48 -0
  58. package/dist/core/reads.d.mts +48 -0
  59. package/dist/core/reads.mjs +267 -0
  60. package/dist/core/releases.cjs +193 -0
  61. package/dist/core/releases.mjs +190 -0
  62. package/dist/core/schema.cjs +279 -0
  63. package/dist/core/schema.d.cts +307 -0
  64. package/dist/core/schema.d.mts +307 -0
  65. package/dist/core/schema.mjs +277 -0
  66. package/dist/core/writes.cjs +96 -0
  67. package/dist/core/writes.mjs +91 -0
  68. package/dist/createHotUpdaterCore.cjs +61 -63
  69. package/dist/createHotUpdaterCore.d.cts +53 -45
  70. package/dist/createHotUpdaterCore.d.mts +53 -45
  71. package/dist/createHotUpdaterCore.mjs +61 -63
  72. package/dist/database/cursor.cjs +44 -0
  73. package/dist/database/cursor.d.cts +7 -0
  74. package/dist/database/cursor.d.mts +7 -0
  75. package/dist/database/cursor.mjs +40 -0
  76. package/dist/database/database.cjs +44 -0
  77. package/dist/database/database.d.cts +123 -0
  78. package/dist/database/database.d.mts +123 -0
  79. package/dist/database/database.mjs +44 -0
  80. package/dist/database/definitions.d.cts +68 -0
  81. package/dist/database/definitions.d.mts +68 -0
  82. package/dist/database/engine.cjs +37 -0
  83. package/dist/database/engine.d.cts +40 -0
  84. package/dist/database/engine.d.mts +40 -0
  85. package/dist/database/engine.mjs +37 -0
  86. package/dist/database/engineAggregates.cjs +115 -0
  87. package/dist/database/engineAggregates.mjs +112 -0
  88. package/dist/database/engineReads.cjs +180 -0
  89. package/dist/database/engineReads.d.cts +35 -0
  90. package/dist/database/engineReads.d.mts +35 -0
  91. package/dist/database/engineReads.mjs +179 -0
  92. package/dist/database/engineTransaction.cjs +403 -0
  93. package/dist/database/engineTransaction.d.cts +26 -0
  94. package/dist/database/engineTransaction.d.mts +26 -0
  95. package/dist/database/engineTransaction.mjs +402 -0
  96. package/dist/database/errors.cjs +27 -0
  97. package/dist/database/errors.d.cts +21 -0
  98. package/dist/database/errors.d.mts +21 -0
  99. package/dist/database/errors.mjs +24 -0
  100. package/dist/database/fence.cjs +124 -0
  101. package/dist/database/fence.d.cts +42 -0
  102. package/dist/database/fence.d.mts +42 -0
  103. package/dist/database/fence.mjs +116 -0
  104. package/dist/database/index.cjs +127 -0
  105. package/dist/database/index.d.cts +17 -0
  106. package/dist/database/index.d.mts +17 -0
  107. package/dist/database/index.mjs +15 -0
  108. package/dist/database/kv/kvAdapter.cjs +273 -0
  109. package/dist/database/kv/kvAdapter.d.cts +101 -0
  110. package/dist/database/kv/kvAdapter.d.mts +101 -0
  111. package/dist/database/kv/kvAdapter.mjs +272 -0
  112. package/dist/database/resolveSchema.cjs +196 -0
  113. package/dist/database/resolveSchema.d.cts +42 -0
  114. package/dist/database/resolveSchema.d.mts +42 -0
  115. package/dist/database/resolveSchema.mjs +193 -0
  116. package/dist/database/schema.cjs +21 -0
  117. package/dist/database/schema.d.cts +61 -0
  118. package/dist/database/schema.d.mts +61 -0
  119. package/dist/database/schema.mjs +20 -0
  120. package/dist/database/sql/sqlAdapter.cjs +282 -0
  121. package/dist/database/sql/sqlAdapter.d.cts +46 -0
  122. package/dist/database/sql/sqlAdapter.d.mts +46 -0
  123. package/dist/database/sql/sqlAdapter.mjs +279 -0
  124. package/dist/database/sql/sqlSchema.cjs +115 -0
  125. package/dist/database/sql/sqlSchema.d.cts +8 -0
  126. package/dist/database/sql/sqlSchema.d.mts +8 -0
  127. package/dist/database/sql/sqlSchema.mjs +111 -0
  128. package/dist/db/builtInDatabase.cjs +104 -0
  129. package/dist/db/builtInDatabase.d.cts +38 -0
  130. package/dist/db/builtInDatabase.d.mts +38 -0
  131. package/dist/db/builtInDatabase.mjs +97 -0
  132. package/dist/db/createBundleDiff.cjs +6 -6
  133. package/dist/db/createBundleDiff.d.cts +4 -7
  134. package/dist/db/createBundleDiff.d.mts +4 -7
  135. package/dist/db/createBundleDiff.mjs +5 -5
  136. package/dist/db/engineDrizzleSchema.cjs +54 -0
  137. package/dist/db/engineDrizzleSchema.mjs +54 -0
  138. package/dist/db/engineMigrator.cjs +53 -0
  139. package/dist/db/engineMigrator.mjs +53 -0
  140. package/dist/db/enginePrismaSchema.cjs +85 -0
  141. package/dist/db/enginePrismaSchema.d.cts +5 -0
  142. package/dist/db/enginePrismaSchema.d.mts +5 -0
  143. package/dist/db/enginePrismaSchema.mjs +84 -0
  144. package/dist/db/engineSql.cjs +26 -0
  145. package/dist/db/engineSql.d.cts +17 -0
  146. package/dist/db/engineSql.d.mts +17 -0
  147. package/dist/db/engineSql.mjs +25 -0
  148. package/dist/db/engineSqlMigrator.cjs +66 -0
  149. package/dist/db/engineSqlMigrator.mjs +66 -0
  150. package/dist/db/fixedMigratorShared.cjs +0 -11
  151. package/dist/db/fixedMigratorShared.mjs +1 -8
  152. package/dist/db/index.cjs +23 -8
  153. package/dist/db/index.d.cts +10 -4
  154. package/dist/db/index.d.mts +10 -4
  155. package/dist/db/index.mjs +16 -8
  156. package/dist/db/releaseCatalog.cjs +20 -44
  157. package/dist/db/releaseCatalog.d.cts +2 -3
  158. package/dist/db/releaseCatalog.d.mts +2 -3
  159. package/dist/db/releaseCatalog.mjs +20 -44
  160. package/dist/db/schemaSettings.cjs +63 -0
  161. package/dist/db/schemaSettings.d.cts +12 -0
  162. package/dist/db/schemaSettings.d.mts +12 -0
  163. package/dist/db/schemaSettings.mjs +62 -0
  164. package/dist/db/settingsMigrator.cjs +92 -0
  165. package/dist/db/settingsMigrator.mjs +89 -0
  166. package/dist/db/types.cjs +3 -12
  167. package/dist/db/types.d.cts +26 -69
  168. package/dist/db/types.d.mts +26 -69
  169. package/dist/db/types.mjs +2 -11
  170. package/dist/db/updateArtifacts.cjs +38 -68
  171. package/dist/db/updateArtifacts.mjs +40 -69
  172. package/dist/handler.cjs +72 -43
  173. package/dist/handler.d.cts +3 -6
  174. package/dist/handler.d.mts +3 -6
  175. package/dist/handler.mjs +73 -43
  176. package/dist/handlerAdminRoutes.cjs +375 -0
  177. package/dist/handlerAdminRoutes.mjs +373 -0
  178. package/dist/handlerParameters.cjs +6 -11
  179. package/dist/handlerParameters.mjs +6 -10
  180. package/dist/handlerReleaseCatalogRoutes.cjs +11 -14
  181. package/dist/handlerReleaseCatalogRoutes.mjs +11 -13
  182. package/dist/handlerTypes.d.cts +2 -56
  183. package/dist/handlerTypes.d.mts +2 -56
  184. package/dist/handlerVersionRoutes.cjs +20 -4
  185. package/dist/handlerVersionRoutes.d.cts +1 -0
  186. package/dist/handlerVersionRoutes.d.mts +1 -0
  187. package/dist/handlerVersionRoutes.mjs +20 -4
  188. package/dist/index.cjs +4 -7
  189. package/dist/index.d.cts +10 -9
  190. package/dist/index.d.mts +10 -9
  191. package/dist/index.mjs +4 -4
  192. package/dist/insights/domain.d.cts +53 -70
  193. package/dist/insights/domain.d.mts +53 -70
  194. package/dist/insights/errors.cjs +35 -8
  195. package/dist/insights/errors.mjs +35 -8
  196. package/dist/insights/eventInput.cjs +64 -24
  197. package/dist/insights/eventInput.mjs +63 -25
  198. package/dist/insights/provider.cjs +356 -0
  199. package/dist/insights/provider.d.cts +6 -0
  200. package/dist/insights/provider.d.mts +6 -0
  201. package/dist/insights/provider.mjs +355 -0
  202. package/dist/insights/queryInput.cjs +78 -43
  203. package/dist/insights/queryInput.mjs +76 -40
  204. package/dist/insights/routes.cjs +94 -34
  205. package/dist/insights/routes.mjs +93 -35
  206. package/dist/insights/types.d.cts +27 -12
  207. package/dist/insights/types.d.mts +27 -12
  208. package/dist/node.d.cts +1 -2
  209. package/dist/node.d.mts +1 -2
  210. package/dist/package.cjs +1 -1
  211. package/dist/package.mjs +1 -1
  212. package/dist/plugins/api-keys/index.cjs +50 -0
  213. package/dist/plugins/api-keys/index.d.cts +85 -0
  214. package/dist/plugins/api-keys/index.d.mts +85 -0
  215. package/dist/plugins/api-keys/index.mjs +47 -0
  216. package/dist/plugins/api-keys/model.cjs +58 -0
  217. package/dist/plugins/api-keys/model.d.cts +8 -0
  218. package/dist/plugins/api-keys/model.d.mts +8 -0
  219. package/dist/plugins/api-keys/model.mjs +58 -0
  220. package/dist/plugins/api-keys/schema.cjs +38 -0
  221. package/dist/plugins/api-keys/schema.d.cts +44 -0
  222. package/dist/plugins/api-keys/schema.d.mts +44 -0
  223. package/dist/plugins/api-keys/schema.mjs +39 -0
  224. package/dist/plugins/builtIn.cjs +7 -0
  225. package/dist/plugins/builtIn.mjs +6 -0
  226. package/dist/plugins/definePlugin.cjs +5 -0
  227. package/dist/plugins/definePlugin.d.cts +73 -0
  228. package/dist/plugins/definePlugin.d.mts +73 -0
  229. package/dist/plugins/definePlugin.mjs +5 -0
  230. package/dist/plugins/index.cjs +17 -0
  231. package/dist/plugins/index.d.cts +9 -0
  232. package/dist/plugins/index.d.mts +9 -0
  233. package/dist/plugins/index.mjs +7 -0
  234. package/dist/plugins/insights/index.cjs +48 -0
  235. package/dist/plugins/insights/index.d.cts +295 -0
  236. package/dist/plugins/insights/index.d.mts +295 -0
  237. package/dist/plugins/insights/index.mjs +44 -0
  238. package/dist/plugins/insights/model.cjs +17 -0
  239. package/dist/plugins/insights/model.d.cts +10 -0
  240. package/dist/plugins/insights/model.d.mts +10 -0
  241. package/dist/plugins/insights/model.mjs +17 -0
  242. package/dist/plugins/insights/reads.cjs +471 -0
  243. package/dist/plugins/insights/reads.mjs +466 -0
  244. package/dist/plugins/insights/recordEvent.cjs +135 -0
  245. package/dist/plugins/insights/recordEvent.d.cts +13 -0
  246. package/dist/plugins/insights/recordEvent.d.mts +13 -0
  247. package/dist/plugins/insights/recordEvent.mjs +132 -0
  248. package/dist/plugins/insights/schema.cjs +347 -0
  249. package/dist/plugins/insights/schema.d.cts +258 -0
  250. package/dist/plugins/insights/schema.d.mts +258 -0
  251. package/dist/plugins/insights/schema.mjs +344 -0
  252. package/dist/storageAccess.cjs +0 -1
  253. package/dist/types/index.d.cts +2 -29
  254. package/dist/types/index.d.mts +2 -29
  255. package/package.json +30 -7
  256. package/src/adapters/drizzle.conformance.integration.spec.ts +34 -0
  257. package/src/adapters/drizzle.readBudgets.integration.spec.ts +41 -0
  258. package/src/adapters/drizzle.spec.ts +277 -208
  259. package/src/adapters/drizzle.ts +48 -128
  260. package/src/adapters/drizzleExecutor.ts +166 -0
  261. package/src/adapters/kysely.conformance.integration.spec.ts +36 -0
  262. package/src/adapters/kysely.readBudgets.integration.spec.ts +42 -0
  263. package/src/adapters/kysely.spec.ts +212 -117
  264. package/src/adapters/kysely.ts +32 -87
  265. package/src/adapters/kyselyExecutor.ts +53 -0
  266. package/src/adapters/mongodb.integration.spec.ts +180 -0
  267. package/src/adapters/mongodb.readBudgets.integration.spec.ts +61 -0
  268. package/src/adapters/mongodb.ts +36 -65
  269. package/src/adapters/mongodbAdapter.ts +293 -0
  270. package/src/adapters/prisma.conformance.integration.spec.ts +36 -0
  271. package/src/adapters/prisma.integration.spec.ts +138 -0
  272. package/src/adapters/prisma.readBudgets.integration.spec.ts +40 -0
  273. package/src/adapters/prisma.spec.ts +226 -173
  274. package/src/adapters/prisma.ts +60 -451
  275. package/src/adapters/prismaExecutor.ts +107 -0
  276. package/src/adapters/prismaTestClients.ts +175 -0
  277. package/src/adapters/sqlProviders.ts +14 -0
  278. package/src/apiKeys.integration.spec.ts +19 -119
  279. package/src/apiKeys.spec.ts +39 -35
  280. package/src/apiKeys.ts +2 -8
  281. package/src/assembly/assemblePlugins.ts +269 -0
  282. package/src/assembly/assembly.spec.ts +325 -0
  283. package/src/assembly/assembly.types.spec.ts +155 -0
  284. package/src/assembly/builtInRoutes.spec.ts +213 -0
  285. package/src/assembly/databasePlugins.spec.ts +71 -0
  286. package/src/assembly/databasePlugins.ts +96 -0
  287. package/src/core/api.ts +139 -0
  288. package/src/core/baseCandidates.spec.ts +378 -0
  289. package/src/core/baseCandidates.ts +136 -0
  290. package/src/core/index.ts +44 -0
  291. package/src/core/operations.spec.ts +415 -0
  292. package/src/core/operations.ts +551 -0
  293. package/src/core/reads.spec.ts +300 -0
  294. package/src/core/reads.ts +417 -0
  295. package/src/core/releases.spec.ts +308 -0
  296. package/src/core/releases.ts +345 -0
  297. package/src/core/schema.ts +173 -0
  298. package/src/core/writes.ts +160 -0
  299. package/src/createHotUpdaterCore.ts +191 -167
  300. package/src/database/cursor.ts +65 -0
  301. package/src/database/database.ts +335 -0
  302. package/src/database/database.types.spec.ts +135 -0
  303. package/src/database/definitions.ts +72 -0
  304. package/src/database/engine.ts +62 -0
  305. package/src/database/engineAggregates.spec.ts +539 -0
  306. package/src/database/engineAggregates.ts +193 -0
  307. package/src/database/engineReads.spec.ts +219 -0
  308. package/src/database/engineReads.ts +302 -0
  309. package/src/database/engineTransaction.spec.ts +710 -0
  310. package/src/database/engineTransaction.ts +588 -0
  311. package/src/database/errors.ts +30 -0
  312. package/src/database/fence.spec.ts +223 -0
  313. package/src/database/fence.ts +171 -0
  314. package/src/database/index.ts +154 -0
  315. package/src/database/kv/kvAdapter.conformance.integration.spec.ts +17 -0
  316. package/src/database/kv/kvAdapter.readBudgets.integration.spec.ts +17 -0
  317. package/src/database/kv/kvAdapter.spec.ts +468 -0
  318. package/src/database/kv/kvAdapter.ts +450 -0
  319. package/src/database/kv/kvTestStore.ts +91 -0
  320. package/src/database/memory.readBudgets.integration.spec.ts +13 -0
  321. package/src/database/resolveSchema.spec.ts +230 -0
  322. package/src/database/resolveSchema.ts +372 -0
  323. package/src/database/schema.ts +169 -0
  324. package/src/database/schema.types.spec.ts +94 -0
  325. package/src/database/sql/docker-compose.yml +36 -0
  326. package/src/database/sql/sqlAdapter.integration.spec.ts +148 -0
  327. package/src/database/sql/sqlAdapter.readBudgets.integration.spec.ts +109 -0
  328. package/src/database/sql/sqlAdapter.spec.ts +255 -0
  329. package/src/database/sql/sqlAdapter.ts +532 -0
  330. package/src/database/sql/sqlSchema.ts +205 -0
  331. package/src/database/sql/sqlTestExecutors.ts +183 -0
  332. package/src/databaseTestSuite.spec.ts +39 -0
  333. package/src/db/builtInDatabase.ts +149 -0
  334. package/src/db/bundleRows.spec.ts +3 -3
  335. package/src/db/createBundleDiff.spec.ts +43 -29
  336. package/src/db/createBundleDiff.ts +13 -7
  337. package/src/db/engineDrizzleSchema.ts +72 -0
  338. package/src/db/engineMigrator.ts +105 -0
  339. package/src/db/enginePrismaSchema.ts +147 -0
  340. package/src/db/engineSql.spec.ts +129 -0
  341. package/src/db/engineSql.ts +48 -0
  342. package/src/db/engineSqlMigrator.ts +116 -0
  343. package/src/db/fixedMigratorShared.ts +1 -20
  344. package/src/db/index.spec.ts +116 -824
  345. package/src/db/index.ts +43 -14
  346. package/src/db/pluginTables.spec.ts +218 -0
  347. package/src/db/releaseCatalog.ts +48 -90
  348. package/src/db/schemaSettings.ts +104 -0
  349. package/src/db/settingsMigrator.spec.ts +65 -0
  350. package/src/db/settingsMigrator.ts +152 -0
  351. package/src/db/types.ts +25 -165
  352. package/src/db/updateArtifacts.spec.ts +170 -294
  353. package/src/db/updateArtifacts.ts +74 -142
  354. package/src/db/updateCheck.bench.ts +47 -0
  355. package/src/handler-standalone.integration.spec.ts +204 -412
  356. package/src/handler.spec.ts +134 -51
  357. package/src/handler.testFixtures.ts +14 -19
  358. package/src/handler.ts +163 -75
  359. package/src/handlerAdminRoutes.spec.ts +183 -0
  360. package/src/handlerAdminRoutes.ts +536 -0
  361. package/src/handlerAuth.integration.spec.ts +3 -3
  362. package/src/handlerManagement.spec.ts +136 -196
  363. package/src/handlerReleaseCatalogRoutes.ts +15 -17
  364. package/src/handlerTypes.ts +3 -80
  365. package/src/handlerVersionRoutes.ts +20 -7
  366. package/src/index.ts +7 -14
  367. package/src/insights/domain.ts +56 -77
  368. package/src/insights/errors.spec.ts +48 -0
  369. package/src/insights/errors.ts +50 -6
  370. package/src/insights/eventInput.ts +80 -27
  371. package/src/insights/insights.integration.spec.ts +525 -44
  372. package/src/insights/provider.spec.ts +574 -0
  373. package/src/insights/provider.ts +667 -0
  374. package/src/insights/queryInput.ts +113 -73
  375. package/src/insights/routes.ts +125 -69
  376. package/src/insights/types.ts +47 -36
  377. package/src/lintRules.spec.ts +76 -0
  378. package/src/plugins/api-keys/apiKeysPlugin.spec.ts +172 -0
  379. package/src/plugins/api-keys/index.ts +66 -0
  380. package/src/plugins/api-keys/model.ts +69 -0
  381. package/src/plugins/api-keys/schema.ts +22 -0
  382. package/src/plugins/builtIn.ts +5 -0
  383. package/src/plugins/definePlugin.ts +100 -0
  384. package/src/plugins/index.ts +55 -0
  385. package/src/plugins/insights/index.ts +86 -0
  386. package/src/plugins/insights/insightsRollout.integration.spec.ts +187 -0
  387. package/src/plugins/insights/model.spec.ts +66 -0
  388. package/src/plugins/insights/model.ts +19 -0
  389. package/src/plugins/insights/reads.spec.ts +725 -0
  390. package/src/plugins/insights/reads.ts +707 -0
  391. package/src/plugins/insights/recordEvent.spec.ts +443 -0
  392. package/src/plugins/insights/recordEvent.ts +238 -0
  393. package/src/plugins/insights/schema.ts +229 -0
  394. package/src/plugins/pluginTestHarness.spec.ts +56 -0
  395. package/src/readBudgets.testFixtures.ts +15 -0
  396. package/src/releaseCatalogRoutes.integration.spec.ts +47 -92
  397. package/src/runtime.spec.ts +91 -77
  398. package/src/runtime.testFixtures.ts +28 -44
  399. package/src/runtimeBundles.integration.spec.ts +112 -0
  400. package/src/testUtilsMutation.integration.spec.ts +215 -0
  401. package/src/testUtilsPackage.integration.spec.ts +176 -0
  402. package/src/types/index.ts +0 -32
  403. package/dist/adapters/databaseConstraintErrors.cjs +0 -23
  404. package/dist/adapters/databaseConstraintErrors.mjs +0 -21
  405. package/dist/adapters/databasePluginUtils.cjs +0 -117
  406. package/dist/adapters/databasePluginUtils.mjs +0 -106
  407. package/dist/adapters/drizzleCrud.cjs +0 -250
  408. package/dist/adapters/drizzleCrud.mjs +0 -249
  409. package/dist/adapters/drizzleLazyDB.cjs +0 -101
  410. package/dist/adapters/drizzleLazyDB.mjs +0 -101
  411. package/dist/adapters/drizzleQuery.cjs +0 -68
  412. package/dist/adapters/drizzleQuery.mjs +0 -67
  413. package/dist/adapters/kyselyCrud.cjs +0 -254
  414. package/dist/adapters/kyselyCrud.mjs +0 -253
  415. package/dist/adapters/kyselyQuery.cjs +0 -56
  416. package/dist/adapters/kyselyQuery.mjs +0 -55
  417. package/dist/adapters/mongodbCollections.cjs +0 -36
  418. package/dist/adapters/mongodbCollections.mjs +0 -30
  419. package/dist/adapters/mongodbQuery.cjs +0 -77
  420. package/dist/adapters/mongodbQuery.mjs +0 -70
  421. package/dist/adapters/mongodbReads.cjs +0 -148
  422. package/dist/adapters/mongodbReads.mjs +0 -147
  423. package/dist/adapters/mongodbWrites.cjs +0 -134
  424. package/dist/adapters/mongodbWrites.mjs +0 -133
  425. package/dist/adapters/prismaQuery.cjs +0 -58
  426. package/dist/adapters/prismaQuery.mjs +0 -56
  427. package/dist/adapters/prismaRows.cjs +0 -198
  428. package/dist/adapters/prismaRows.mjs +0 -188
  429. package/dist/db/databasePluginCore.cjs +0 -138
  430. package/dist/db/databasePluginCore.mjs +0 -137
  431. package/dist/db/fixedMigrator.cjs +0 -79
  432. package/dist/db/fixedMigrator.mjs +0 -78
  433. package/dist/db/fixedMigratorMongo.cjs +0 -319
  434. package/dist/db/fixedMigratorMongo.mjs +0 -319
  435. package/dist/db/mongoMigrationExecution.cjs +0 -11
  436. package/dist/db/mongoMigrationExecution.mjs +0 -11
  437. package/dist/db/schema/mongodb.cjs +0 -25
  438. package/dist/db/schema/mongodb.mjs +0 -25
  439. package/dist/db/schema/registry.cjs +0 -21
  440. package/dist/db/schema/registry.mjs +0 -17
  441. package/dist/db/schema/sql.cjs +0 -101
  442. package/dist/db/schema/sql.mjs +0 -97
  443. package/dist/db/schema/sqlOperations.cjs +0 -27
  444. package/dist/db/schema/sqlOperations.mjs +0 -26
  445. package/dist/db/schemaGenerators.cjs +0 -256
  446. package/dist/db/schemaGenerators.mjs +0 -254
  447. package/dist/db/schemaReadiness.cjs +0 -24
  448. package/dist/db/schemaReadiness.d.cts +0 -8
  449. package/dist/db/schemaReadiness.d.mts +0 -8
  450. package/dist/db/schemaReadiness.mjs +0 -23
  451. package/dist/db/sqlMigrationExecution.cjs +0 -67
  452. package/dist/db/sqlMigrationExecution.mjs +0 -66
  453. package/dist/handlerBundleRoutes.cjs +0 -155
  454. package/dist/handlerBundleRoutes.mjs +0 -155
  455. package/dist/handlerReleaseManagementRoutes.cjs +0 -125
  456. package/dist/handlerReleaseManagementRoutes.mjs +0 -124
  457. package/dist/insights/bounded/activeOverview.cjs +0 -87
  458. package/dist/insights/bounded/activeOverview.mjs +0 -85
  459. package/dist/insights/bounded/installationSearch.cjs +0 -42
  460. package/dist/insights/bounded/installationSearch.mjs +0 -42
  461. package/dist/insights/bounded/persistence.cjs +0 -39
  462. package/dist/insights/bounded/persistence.mjs +0 -38
  463. package/dist/insights/bounded/provider.cjs +0 -170
  464. package/dist/insights/bounded/provider.d.cts +0 -7
  465. package/dist/insights/bounded/provider.d.mts +0 -7
  466. package/dist/insights/bounded/provider.mjs +0 -170
  467. package/dist/insights/bounded/scan.cjs +0 -144
  468. package/dist/insights/bounded/scan.mjs +0 -138
  469. package/dist/insights/persistence.d.cts +0 -6
  470. package/dist/insights/persistence.d.mts +0 -6
  471. package/dist/schema/dsl.cjs +0 -103
  472. package/dist/schema/dsl.mjs +0 -87
  473. package/dist/schema/index.cjs +0 -6
  474. package/dist/schema/index.mjs +0 -7
  475. package/dist/schema/settings.cjs +0 -9
  476. package/dist/schema/settings.mjs +0 -9
  477. package/dist/schema/types.cjs +0 -8
  478. package/dist/schema/types.mjs +0 -6
  479. package/dist/schema/v1_0_0.cjs +0 -364
  480. package/dist/schema/v1_0_0.mjs +0 -357
  481. package/src/adapters/databaseConstraintErrors.ts +0 -25
  482. package/src/adapters/databasePluginTestDatabase.ts +0 -106
  483. package/src/adapters/databasePluginUtils.spec.ts +0 -29
  484. package/src/adapters/databasePluginUtils.ts +0 -214
  485. package/src/adapters/drizzleCrud.ts +0 -419
  486. package/src/adapters/drizzleLazyDB.ts +0 -257
  487. package/src/adapters/drizzleQuery.ts +0 -164
  488. package/src/adapters/kyselyCrud.ts +0 -588
  489. package/src/adapters/kyselyQuery.ts +0 -128
  490. package/src/adapters/mongodb.spec.ts +0 -141
  491. package/src/adapters/mongodbCollections.ts +0 -62
  492. package/src/adapters/mongodbQuery.ts +0 -226
  493. package/src/adapters/mongodbReads.ts +0 -311
  494. package/src/adapters/mongodbRows.spec.ts +0 -64
  495. package/src/adapters/mongodbRows.ts +0 -118
  496. package/src/adapters/mongodbTestClient.ts +0 -342
  497. package/src/adapters/mongodbTestFilter.ts +0 -166
  498. package/src/adapters/mongodbWrites.ts +0 -260
  499. package/src/adapters/prismaQuery.ts +0 -129
  500. package/src/adapters/prismaRows.spec.ts +0 -98
  501. package/src/adapters/prismaRows.ts +0 -301
  502. package/src/adapters/prismaTestClient.ts +0 -396
  503. package/src/calculatePagination.ts +0 -34
  504. package/src/db/databasePluginCore.spec.ts +0 -62
  505. package/src/db/databasePluginCore.testFixtures.ts +0 -76
  506. package/src/db/databasePluginCore.ts +0 -185
  507. package/src/db/databasePluginUpdateCheck.bench.ts +0 -107
  508. package/src/db/fixedMigrator.spec.ts +0 -231
  509. package/src/db/fixedMigrator.ts +0 -147
  510. package/src/db/fixedMigratorMongo.spec.ts +0 -192
  511. package/src/db/fixedMigratorMongo.ts +0 -425
  512. package/src/db/hotUpdaterSchema.ts +0 -5
  513. package/src/db/mongoMigrationExecution.ts +0 -23
  514. package/src/db/schema/definitions.ts +0 -1
  515. package/src/db/schema/mongodb.ts +0 -40
  516. package/src/db/schema/registry.ts +0 -55
  517. package/src/db/schema/sql.ts +0 -241
  518. package/src/db/schema/sqlOperations.ts +0 -63
  519. package/src/db/schema/types.ts +0 -1
  520. package/src/db/schemaGenerators.ts +0 -466
  521. package/src/db/schemaReadiness.ts +0 -34
  522. package/src/db/sqlMigrationExecution.spec.ts +0 -65
  523. package/src/db/sqlMigrationExecution.ts +0 -108
  524. package/src/db/types.spec.ts +0 -55
  525. package/src/handlerBundleRoutes.ts +0 -259
  526. package/src/handlerReleaseManagementRoutes.ts +0 -213
  527. package/src/insights/bounded/activeOverview.spec.ts +0 -189
  528. package/src/insights/bounded/activeOverview.ts +0 -148
  529. package/src/insights/bounded/installationSearch.spec.ts +0 -130
  530. package/src/insights/bounded/installationSearch.ts +0 -69
  531. package/src/insights/bounded/persistence.ts +0 -43
  532. package/src/insights/bounded/provider.spec.ts +0 -219
  533. package/src/insights/bounded/provider.ts +0 -229
  534. package/src/insights/bounded/scan.ts +0 -235
  535. package/src/insights/persistence.ts +0 -10
  536. package/src/schema/dsl-all-versions.spec.ts +0 -35
  537. package/src/schema/dsl.ts +0 -187
  538. package/src/schema/index.ts +0 -10
  539. package/src/schema/settings.ts +0 -15
  540. package/src/schema/types.ts +0 -79
  541. package/src/schema/v1_0_0.spec.ts +0 -146
  542. package/src/schema/v1_0_0.ts +0 -465
@@ -2,14 +2,23 @@ const require_errors = require("./errors.cjs");
2
2
  const require_eventInput = require("./eventInput.cjs");
3
3
  const require_queryInput = require("./queryInput.cjs");
4
4
  //#region src/insights/routes.ts
5
- const json = (body, status) => Response.json(body, {
6
- headers: { "cache-control": "private, no-store" },
5
+ /** Seconds a client waits before it resends a request the busy database refused. */
6
+ const RETRY_AFTER_SECONDS = 5;
7
+ const json = (body, status, headers = {}) => Response.json(body, {
8
+ headers: {
9
+ "cache-control": "private, no-store",
10
+ ...headers
11
+ },
7
12
  status
8
13
  });
9
14
  const requireParam = (params, key) => {
10
15
  const value = params[key];
11
16
  if (value === void 0 || value.length === 0) throw new require_errors.InsightsBadRequestError(`Missing route parameter: ${key}`);
12
- return value;
17
+ try {
18
+ return decodeURIComponent(value);
19
+ } catch {
20
+ throw new require_errors.InsightsBadRequestError(`Invalid route parameter: ${key}`);
21
+ }
13
22
  };
14
23
  const run = async (operation) => {
15
24
  try {
@@ -17,47 +26,98 @@ const run = async (operation) => {
17
26
  } catch (error) {
18
27
  if (error instanceof require_errors.InsightsBadRequestError) return json({ error: error.message }, 400);
19
28
  if (error instanceof require_errors.InsightsPayloadTooLargeError) return json({ error: error.message }, 413);
20
- if (error instanceof require_errors.InsightsScanLimitExceededError) return json({ error: {
21
- code: "INSIGHTS_SCAN_LIMIT_EXCEEDED",
22
- limit: error.limit
23
- } }, 503);
29
+ if (require_errors.isDatabaseBusyError(error)) {
30
+ console.warn("[hot-updater] Insights answered 503: the database is busy.", error);
31
+ return json({ error: "Service unavailable" }, 503, { "retry-after": String(RETRY_AFTER_SECONDS) });
32
+ }
24
33
  throw error;
25
34
  }
26
35
  };
27
36
  const query = (operation) => run(async () => json(await operation(), 200));
37
+ /** Every Insights route: where it mounts, and the handler it runs. */
38
+ const INSIGHTS_ROUTES = [
39
+ {
40
+ access: "client",
41
+ method: "POST",
42
+ path: "/events",
43
+ handler: "appendBundleEvent"
44
+ },
45
+ {
46
+ access: "admin",
47
+ method: "GET",
48
+ path: "/events",
49
+ handler: "listEvents"
50
+ },
51
+ {
52
+ access: "admin",
53
+ method: "GET",
54
+ path: "/overview",
55
+ handler: "getReportingOverview"
56
+ },
57
+ {
58
+ access: "admin",
59
+ method: "GET",
60
+ path: "/installations",
61
+ handler: "pageInstallationsByCurrentUserId"
62
+ },
63
+ {
64
+ access: "admin",
65
+ method: "GET",
66
+ path: "/installations/:installId/events",
67
+ handler: "listInstallationEvents"
68
+ },
69
+ {
70
+ access: "admin",
71
+ method: "GET",
72
+ path: "/installations/:installId",
73
+ handler: "getInstallation"
74
+ }
75
+ ];
76
+ /** Without the insights plugin, its routes answer 204 and say Insights is off. */
77
+ const insightsDisabled = async () => new Response(null, {
78
+ headers: {
79
+ "cache-control": "private, no-store",
80
+ "x-hot-updater-insights": "disabled"
81
+ },
82
+ status: 204
83
+ });
84
+ /** What a server without the insights plugin logs on the first event it drops. */
85
+ const INSIGHTS_OFF_WARNING = "[hot-updater] Insights is off, so POST /events answered 204 and stored nothing. Add insights() from @hot-updater/server/plugins/insights to plugins to record app events, or set insights: false in the app's HotUpdater.init to stop sending them. This warning prints once per server.";
86
+ /**
87
+ * The client's `POST /events` without the insights plugin. It answers as
88
+ * {@link insightsDisabled} does, so apps need no change, and warns on the
89
+ * first event it drops, so a server that left out `insights()` says so.
90
+ */
91
+ const createDroppedEventHandler = () => {
92
+ let warned = false;
93
+ return (params, request) => {
94
+ if (!warned) {
95
+ warned = true;
96
+ console.warn(INSIGHTS_OFF_WARNING);
97
+ }
98
+ return insightsDisabled(params, request);
99
+ };
100
+ };
28
101
  const createInsightsRouteHandlers = (provider) => ({
29
102
  appendBundleEvent: async (_params, request) => run(async () => {
30
103
  await provider.appendBundleEvent(await require_eventInput.parseBundleEventRequest(request));
31
104
  return new Response(null, { status: 204 });
32
105
  }),
33
- getBundleEventSummary: (params) => query(() => provider.getBundleEventSummary(requireParam(params, "id"))),
34
- getBundleEventInsights: (params, request) => query(() => {
35
- const input = require_queryInput.parseInsightsQuery(request);
36
- return provider.getBundleEventInsights(requireParam(params, "id"), input.window, input.limit, input.offset);
37
- }),
38
- getBundleEventOverview: () => query(() => provider.getBundleEventOverview()),
39
- getActiveInstallationOverview: (_params, request) => query(() => provider.getActiveInstallationOverview(require_queryInput.parseActiveInstallationInput(request))),
40
- searchInstallations: (_params, request) => query(() => {
41
- const input = require_queryInput.parseSearchInput(request);
42
- return provider.searchInstallations(input.query, input.limit, input.offset);
106
+ getReportingOverview: (_params, request) => query(() => provider.getReportingOverview(require_queryInput.parseReportingOverviewInput(request))),
107
+ getInstallation: (params) => run(async () => {
108
+ const installation = await provider.getInstallation({ installId: requireParam(params, "installId") });
109
+ return installation === null ? json({ error: "Installation not found" }, 404) : json(installation, 200);
43
110
  }),
44
- getInstallationHistory: (params, request) => query(() => {
45
- const input = require_queryInput.parsePagination(request);
46
- return provider.getInstallationHistory(requireParam(params, "installId"), input.limit, input.offset);
47
- })
111
+ listEvents: (_params, request) => query(() => provider.listEvents(require_queryInput.parseEventPageInput(request))),
112
+ listInstallationEvents: (params, request) => query(() => provider.listInstallationEvents({
113
+ ...require_queryInput.parseEventPageInput(request),
114
+ installId: requireParam(params, "installId")
115
+ })),
116
+ pageInstallationsByCurrentUserId: (_params, request) => query(() => provider.pageInstallationsByCurrentUserId(require_queryInput.parseUserInstallationPageInput(request)))
48
117
  });
49
- const registerInsightsClientRoutes = (add) => {
50
- add("POST", "/events", "appendBundleEvent");
51
- };
52
- const registerInsightsAdminRoutes = (add) => {
53
- add("GET", "/bundles/:id/events/summary", "getBundleEventSummary");
54
- add("GET", "/bundles/:id/events/insights", "getBundleEventInsights");
55
- add("GET", "/installations/overview", "getBundleEventOverview");
56
- add("GET", "/installations/active", "getActiveInstallationOverview");
57
- add("GET", "/installations", "searchInstallations");
58
- add("GET", "/installations/:installId/events", "getInstallationHistory");
59
- };
60
118
  //#endregion
119
+ exports.INSIGHTS_OFF_WARNING = INSIGHTS_OFF_WARNING;
120
+ exports.INSIGHTS_ROUTES = INSIGHTS_ROUTES;
121
+ exports.createDroppedEventHandler = createDroppedEventHandler;
61
122
  exports.createInsightsRouteHandlers = createInsightsRouteHandlers;
62
- exports.registerInsightsAdminRoutes = registerInsightsAdminRoutes;
63
- exports.registerInsightsClientRoutes = registerInsightsClientRoutes;
123
+ exports.insightsDisabled = insightsDisabled;
@@ -1,15 +1,24 @@
1
- import { InsightsBadRequestError, InsightsPayloadTooLargeError, InsightsScanLimitExceededError } from "./errors.mjs";
1
+ import { InsightsBadRequestError, InsightsPayloadTooLargeError, isDatabaseBusyError } from "./errors.mjs";
2
2
  import { parseBundleEventRequest } from "./eventInput.mjs";
3
- import { parseActiveInstallationInput, parseInsightsQuery, parsePagination, parseSearchInput } from "./queryInput.mjs";
3
+ import { parseEventPageInput, parseReportingOverviewInput, parseUserInstallationPageInput } from "./queryInput.mjs";
4
4
  //#region src/insights/routes.ts
5
- const json = (body, status) => Response.json(body, {
6
- headers: { "cache-control": "private, no-store" },
5
+ /** Seconds a client waits before it resends a request the busy database refused. */
6
+ const RETRY_AFTER_SECONDS = 5;
7
+ const json = (body, status, headers = {}) => Response.json(body, {
8
+ headers: {
9
+ "cache-control": "private, no-store",
10
+ ...headers
11
+ },
7
12
  status
8
13
  });
9
14
  const requireParam = (params, key) => {
10
15
  const value = params[key];
11
16
  if (value === void 0 || value.length === 0) throw new InsightsBadRequestError(`Missing route parameter: ${key}`);
12
- return value;
17
+ try {
18
+ return decodeURIComponent(value);
19
+ } catch {
20
+ throw new InsightsBadRequestError(`Invalid route parameter: ${key}`);
21
+ }
13
22
  };
14
23
  const run = async (operation) => {
15
24
  try {
@@ -17,45 +26,94 @@ const run = async (operation) => {
17
26
  } catch (error) {
18
27
  if (error instanceof InsightsBadRequestError) return json({ error: error.message }, 400);
19
28
  if (error instanceof InsightsPayloadTooLargeError) return json({ error: error.message }, 413);
20
- if (error instanceof InsightsScanLimitExceededError) return json({ error: {
21
- code: "INSIGHTS_SCAN_LIMIT_EXCEEDED",
22
- limit: error.limit
23
- } }, 503);
29
+ if (isDatabaseBusyError(error)) {
30
+ console.warn("[hot-updater] Insights answered 503: the database is busy.", error);
31
+ return json({ error: "Service unavailable" }, 503, { "retry-after": String(RETRY_AFTER_SECONDS) });
32
+ }
24
33
  throw error;
25
34
  }
26
35
  };
27
36
  const query = (operation) => run(async () => json(await operation(), 200));
37
+ /** Every Insights route: where it mounts, and the handler it runs. */
38
+ const INSIGHTS_ROUTES = [
39
+ {
40
+ access: "client",
41
+ method: "POST",
42
+ path: "/events",
43
+ handler: "appendBundleEvent"
44
+ },
45
+ {
46
+ access: "admin",
47
+ method: "GET",
48
+ path: "/events",
49
+ handler: "listEvents"
50
+ },
51
+ {
52
+ access: "admin",
53
+ method: "GET",
54
+ path: "/overview",
55
+ handler: "getReportingOverview"
56
+ },
57
+ {
58
+ access: "admin",
59
+ method: "GET",
60
+ path: "/installations",
61
+ handler: "pageInstallationsByCurrentUserId"
62
+ },
63
+ {
64
+ access: "admin",
65
+ method: "GET",
66
+ path: "/installations/:installId/events",
67
+ handler: "listInstallationEvents"
68
+ },
69
+ {
70
+ access: "admin",
71
+ method: "GET",
72
+ path: "/installations/:installId",
73
+ handler: "getInstallation"
74
+ }
75
+ ];
76
+ /** Without the insights plugin, its routes answer 204 and say Insights is off. */
77
+ const insightsDisabled = async () => new Response(null, {
78
+ headers: {
79
+ "cache-control": "private, no-store",
80
+ "x-hot-updater-insights": "disabled"
81
+ },
82
+ status: 204
83
+ });
84
+ /** What a server without the insights plugin logs on the first event it drops. */
85
+ const INSIGHTS_OFF_WARNING = "[hot-updater] Insights is off, so POST /events answered 204 and stored nothing. Add insights() from @hot-updater/server/plugins/insights to plugins to record app events, or set insights: false in the app's HotUpdater.init to stop sending them. This warning prints once per server.";
86
+ /**
87
+ * The client's `POST /events` without the insights plugin. It answers as
88
+ * {@link insightsDisabled} does, so apps need no change, and warns on the
89
+ * first event it drops, so a server that left out `insights()` says so.
90
+ */
91
+ const createDroppedEventHandler = () => {
92
+ let warned = false;
93
+ return (params, request) => {
94
+ if (!warned) {
95
+ warned = true;
96
+ console.warn(INSIGHTS_OFF_WARNING);
97
+ }
98
+ return insightsDisabled(params, request);
99
+ };
100
+ };
28
101
  const createInsightsRouteHandlers = (provider) => ({
29
102
  appendBundleEvent: async (_params, request) => run(async () => {
30
103
  await provider.appendBundleEvent(await parseBundleEventRequest(request));
31
104
  return new Response(null, { status: 204 });
32
105
  }),
33
- getBundleEventSummary: (params) => query(() => provider.getBundleEventSummary(requireParam(params, "id"))),
34
- getBundleEventInsights: (params, request) => query(() => {
35
- const input = parseInsightsQuery(request);
36
- return provider.getBundleEventInsights(requireParam(params, "id"), input.window, input.limit, input.offset);
37
- }),
38
- getBundleEventOverview: () => query(() => provider.getBundleEventOverview()),
39
- getActiveInstallationOverview: (_params, request) => query(() => provider.getActiveInstallationOverview(parseActiveInstallationInput(request))),
40
- searchInstallations: (_params, request) => query(() => {
41
- const input = parseSearchInput(request);
42
- return provider.searchInstallations(input.query, input.limit, input.offset);
106
+ getReportingOverview: (_params, request) => query(() => provider.getReportingOverview(parseReportingOverviewInput(request))),
107
+ getInstallation: (params) => run(async () => {
108
+ const installation = await provider.getInstallation({ installId: requireParam(params, "installId") });
109
+ return installation === null ? json({ error: "Installation not found" }, 404) : json(installation, 200);
43
110
  }),
44
- getInstallationHistory: (params, request) => query(() => {
45
- const input = parsePagination(request);
46
- return provider.getInstallationHistory(requireParam(params, "installId"), input.limit, input.offset);
47
- })
111
+ listEvents: (_params, request) => query(() => provider.listEvents(parseEventPageInput(request))),
112
+ listInstallationEvents: (params, request) => query(() => provider.listInstallationEvents({
113
+ ...parseEventPageInput(request),
114
+ installId: requireParam(params, "installId")
115
+ })),
116
+ pageInstallationsByCurrentUserId: (_params, request) => query(() => provider.pageInstallationsByCurrentUserId(parseUserInstallationPageInput(request)))
48
117
  });
49
- const registerInsightsClientRoutes = (add) => {
50
- add("POST", "/events", "appendBundleEvent");
51
- };
52
- const registerInsightsAdminRoutes = (add) => {
53
- add("GET", "/bundles/:id/events/summary", "getBundleEventSummary");
54
- add("GET", "/bundles/:id/events/insights", "getBundleEventInsights");
55
- add("GET", "/installations/overview", "getBundleEventOverview");
56
- add("GET", "/installations/active", "getActiveInstallationOverview");
57
- add("GET", "/installations", "searchInstallations");
58
- add("GET", "/installations/:installId/events", "getInstallationHistory");
59
- };
60
118
  //#endregion
61
- export { createInsightsRouteHandlers, registerInsightsAdminRoutes, registerInsightsClientRoutes };
119
+ export { INSIGHTS_OFF_WARNING, INSIGHTS_ROUTES, createDroppedEventHandler, createInsightsRouteHandlers, insightsDisabled };
@@ -1,17 +1,32 @@
1
- import { ActiveInstallationInput, ActiveInstallationOverview, BundleEventInsightsResult, BundleEventInsightsWindow, BundleEventOverview, BundleEventSummary, BundleEventSummaryByBundle, CreateBundleEventRequest, InstallationHistoryRow, InstallationSearchRow, OffsetPaginationResult } from "./domain.cjs";
2
-
1
+ import { ActiveInstallationWindow, CreateBundleEventRequest, CursorPage, EventCursorPage, EventHistoryRow, InsightsBundleSelection, InsightsScope, InstallationHistoryRow, InstallationRow, ReportingOverview } from "./domain.cjs";
3
2
  //#region src/insights/types.d.ts
3
+ type InsightsEventPageInput = {
4
+ readonly beforeReceivedAtMs?: number;
5
+ readonly sinceMs?: number;
6
+ readonly bundle?: InsightsBundleSelection;
7
+ readonly cursor?: string;
8
+ readonly limit?: number;
9
+ };
10
+ type InsightsInstallationEventPageInput = Omit<InsightsEventPageInput, "bundle"> & {
11
+ readonly installId: string;
12
+ };
13
+ type InsightsUserInstallationPageInput = {
14
+ readonly userId: string;
15
+ readonly cursor?: string;
16
+ readonly limit?: number;
17
+ };
4
18
  type InsightsProvider = {
5
- readonly mode: "bounded";
6
- readonly maxMatchingRows: number;
7
19
  appendBundleEvent(input: CreateBundleEventRequest): Promise<void>;
8
- getBundleEventSummary(bundleId: string): Promise<BundleEventSummary>;
9
- getBundleEventSummaries(bundleIds: readonly string[], window: BundleEventInsightsWindow): Promise<readonly BundleEventSummaryByBundle[]>;
10
- getBundleEventInsights(bundleId: string, window: BundleEventInsightsWindow, limit: number, offset: number): Promise<BundleEventInsightsResult>;
11
- getBundleEventOverview(): Promise<BundleEventOverview>;
12
- getActiveInstallationOverview(input: ActiveInstallationInput): Promise<ActiveInstallationOverview>;
13
- searchInstallations(query: string, limit: number, offset: number): Promise<OffsetPaginationResult<InstallationSearchRow>>;
14
- getInstallationHistory(installId: string, limit: number, offset: number): Promise<OffsetPaginationResult<InstallationHistoryRow>>;
20
+ listEvents(input: InsightsEventPageInput): Promise<EventCursorPage<EventHistoryRow>>;
21
+ listInstallationEvents(input: InsightsInstallationEventPageInput): Promise<EventCursorPage<InstallationHistoryRow>>;
22
+ getInstallation(input: {
23
+ readonly installId: string;
24
+ }): Promise<InstallationRow | null>;
25
+ pageInstallationsByCurrentUserId(input: InsightsUserInstallationPageInput): Promise<CursorPage<InstallationRow>>;
26
+ getReportingOverview(input: InsightsScope & {
27
+ readonly window: ActiveInstallationWindow;
28
+ readonly bundleId?: string;
29
+ }): Promise<ReportingOverview>;
15
30
  };
16
31
  //#endregion
17
- export { InsightsProvider };
32
+ export { InsightsEventPageInput, InsightsInstallationEventPageInput, InsightsProvider, InsightsUserInstallationPageInput };
@@ -1,17 +1,32 @@
1
- import { ActiveInstallationInput, ActiveInstallationOverview, BundleEventInsightsResult, BundleEventInsightsWindow, BundleEventOverview, BundleEventSummary, BundleEventSummaryByBundle, CreateBundleEventRequest, InstallationHistoryRow, InstallationSearchRow, OffsetPaginationResult } from "./domain.mjs";
2
-
1
+ import { ActiveInstallationWindow, CreateBundleEventRequest, CursorPage, EventCursorPage, EventHistoryRow, InsightsBundleSelection, InsightsScope, InstallationHistoryRow, InstallationRow, ReportingOverview } from "./domain.mjs";
3
2
  //#region src/insights/types.d.ts
3
+ type InsightsEventPageInput = {
4
+ readonly beforeReceivedAtMs?: number;
5
+ readonly sinceMs?: number;
6
+ readonly bundle?: InsightsBundleSelection;
7
+ readonly cursor?: string;
8
+ readonly limit?: number;
9
+ };
10
+ type InsightsInstallationEventPageInput = Omit<InsightsEventPageInput, "bundle"> & {
11
+ readonly installId: string;
12
+ };
13
+ type InsightsUserInstallationPageInput = {
14
+ readonly userId: string;
15
+ readonly cursor?: string;
16
+ readonly limit?: number;
17
+ };
4
18
  type InsightsProvider = {
5
- readonly mode: "bounded";
6
- readonly maxMatchingRows: number;
7
19
  appendBundleEvent(input: CreateBundleEventRequest): Promise<void>;
8
- getBundleEventSummary(bundleId: string): Promise<BundleEventSummary>;
9
- getBundleEventSummaries(bundleIds: readonly string[], window: BundleEventInsightsWindow): Promise<readonly BundleEventSummaryByBundle[]>;
10
- getBundleEventInsights(bundleId: string, window: BundleEventInsightsWindow, limit: number, offset: number): Promise<BundleEventInsightsResult>;
11
- getBundleEventOverview(): Promise<BundleEventOverview>;
12
- getActiveInstallationOverview(input: ActiveInstallationInput): Promise<ActiveInstallationOverview>;
13
- searchInstallations(query: string, limit: number, offset: number): Promise<OffsetPaginationResult<InstallationSearchRow>>;
14
- getInstallationHistory(installId: string, limit: number, offset: number): Promise<OffsetPaginationResult<InstallationHistoryRow>>;
20
+ listEvents(input: InsightsEventPageInput): Promise<EventCursorPage<EventHistoryRow>>;
21
+ listInstallationEvents(input: InsightsInstallationEventPageInput): Promise<EventCursorPage<InstallationHistoryRow>>;
22
+ getInstallation(input: {
23
+ readonly installId: string;
24
+ }): Promise<InstallationRow | null>;
25
+ pageInstallationsByCurrentUserId(input: InsightsUserInstallationPageInput): Promise<CursorPage<InstallationRow>>;
26
+ getReportingOverview(input: InsightsScope & {
27
+ readonly window: ActiveInstallationWindow;
28
+ readonly bundleId?: string;
29
+ }): Promise<ReportingOverview>;
15
30
  };
16
31
  //#endregion
17
- export { InsightsProvider };
32
+ export { InsightsEventPageInput, InsightsInstallationEventPageInput, InsightsProvider, InsightsUserInstallationPageInput };
package/dist/node.d.cts CHANGED
@@ -1,7 +1,6 @@
1
- import { HotUpdaterHandler } from "./handlerTypes.cjs";
2
1
  import { HOT_UPDATER_SERVER_VERSION } from "./version.cjs";
2
+ import { HotUpdaterHandler } from "./handlerTypes.cjs";
3
3
  import { HOT_UPDATER_INFRASTRUCTURE_GENERATION } from "./handlerVersionRoutes.cjs";
4
-
5
4
  //#region src/node.d.ts
6
5
  /**
7
6
  * Converts a Hot Updater handler to a Node.js-compatible middleware
package/dist/node.d.mts CHANGED
@@ -1,7 +1,6 @@
1
- import { HotUpdaterHandler } from "./handlerTypes.mjs";
2
1
  import { HOT_UPDATER_SERVER_VERSION } from "./version.mjs";
2
+ import { HotUpdaterHandler } from "./handlerTypes.mjs";
3
3
  import { HOT_UPDATER_INFRASTRUCTURE_GENERATION } from "./handlerVersionRoutes.mjs";
4
-
5
4
  //#region src/node.d.ts
6
5
  /**
7
6
  * Converts a Hot Updater handler to a Node.js-compatible middleware
package/dist/package.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "1.0.0-rc.1";
2
+ var version = "1.0.0-rc.16";
3
3
  //#endregion
4
4
  Object.defineProperty(exports, "version", {
5
5
  enumerable: true,
package/dist/package.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "1.0.0-rc.1";
2
+ var version = "1.0.0-rc.16";
3
3
  //#endregion
4
4
  export { version };
@@ -0,0 +1,50 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_apiKeys = require("../../apiKeys.cjs");
3
+ const require_builtIn = require("../builtIn.cjs");
4
+ const require_definePlugin = require("../definePlugin.cjs");
5
+ const require_model = require("./model.cjs");
6
+ const require_schema = require("./schema.cjs");
7
+ //#region src/plugins/api-keys/index.ts
8
+ /**
9
+ * Built-in API keys: protects client routes with keys whose SHA-256 digests
10
+ * are stored, and manages them in-process.
11
+ */
12
+ const apiKeys = (options = {}) => {
13
+ const headerName = require_apiKeys.normalizeApiKeyHeaderName(options.headerName ?? "x-api-key");
14
+ return require_builtIn.markBuiltIn(require_definePlugin.definePlugin({
15
+ id: "apiKeys",
16
+ provides: { clientAuth: true },
17
+ schemaVersion: "1.0.0",
18
+ schema: require_schema.apiKeysSchema,
19
+ init: ({ db }) => {
20
+ const model = require_model.createApiKeyModel(db);
21
+ return {
22
+ api: {
23
+ ...require_apiKeys.createApiKeyManagement({ apiKeys: model }),
24
+ /** Registers a known plaintext key idempotently, for managed init. */
25
+ register: (input) => require_apiKeys.registerApiKey({
26
+ ...input,
27
+ apiKeys: model
28
+ }),
29
+ /** Reuses a saved key or creates one, for managed init. */
30
+ provision: (input) => require_apiKeys.provisionApiKey({
31
+ ...input,
32
+ apiKeys: model
33
+ })
34
+ },
35
+ clientAuth: {
36
+ varyHeaders: [headerName],
37
+ authenticate: (headers) => require_apiKeys.authenticateApiKey({
38
+ apiKeys: model,
39
+ headerName,
40
+ request: { headers }
41
+ })
42
+ }
43
+ };
44
+ }
45
+ }));
46
+ };
47
+ //#endregion
48
+ exports.apiKeys = apiKeys;
49
+ exports.apiKeysSchema = require_schema.apiKeysSchema;
50
+ exports.createApiKeyModel = require_model.createApiKeyModel;
@@ -0,0 +1,85 @@
1
+ import { TableDefinition } from "../../database/schema.cjs";
2
+ import { HotUpdaterPlugin } from "../definePlugin.cjs";
3
+ import { ApiKeyMetadata, CreatedApiKey } from "../../apiKeys.cjs";
4
+ import "../../index.cjs";
5
+ import "../index.cjs";
6
+ import { ApiKeysSchema, apiKeysSchema } from "./schema.cjs";
7
+ import { createApiKeyModel } from "./model.cjs";
8
+ //#region src/plugins/api-keys/index.d.ts
9
+ interface ApiKeysOptions {
10
+ /** The request header that carries the key; defaults to `x-api-key`. */
11
+ readonly headerName?: string;
12
+ }
13
+ /**
14
+ * Built-in API keys: protects client routes with keys whose SHA-256 digests
15
+ * are stored, and manages them in-process.
16
+ */
17
+ declare const apiKeys: (options?: ApiKeysOptions) => HotUpdaterPlugin<"apiKeys", {
18
+ readonly api_keys: TableDefinition<{
19
+ readonly id: {
20
+ readonly type: "string";
21
+ readonly maxLength: 255;
22
+ };
23
+ readonly hash: {
24
+ readonly type: "string";
25
+ readonly maxLength: 64;
26
+ readonly unique: true;
27
+ };
28
+ readonly name: {
29
+ readonly type: "string";
30
+ readonly maxLength: 64;
31
+ };
32
+ readonly prefix: {
33
+ readonly type: "string";
34
+ readonly maxLength: 16;
35
+ };
36
+ readonly role: {
37
+ readonly type: "string";
38
+ readonly maxLength: 16;
39
+ };
40
+ readonly created_at_ms: {
41
+ readonly type: "integer";
42
+ };
43
+ readonly revoked_at_ms: {
44
+ readonly type: "integer";
45
+ readonly required: false;
46
+ };
47
+ }, {}, {
48
+ readonly byCreated: {
49
+ readonly eq: readonly [];
50
+ readonly sort: readonly ["created_at_ms"];
51
+ };
52
+ }, readonly ["id"]>;
53
+ }, {
54
+ api: {
55
+ /** Registers a known plaintext key idempotently, for managed init. */
56
+ register: (input: {
57
+ readonly apiKey: string;
58
+ readonly name: string;
59
+ readonly createdAtMs?: number;
60
+ }) => Promise<CreatedApiKey>;
61
+ /** Reuses a saved key or creates one, for managed init. */
62
+ provision: (input: {
63
+ readonly existingApiKey?: string;
64
+ readonly name: string;
65
+ }) => Promise<CreatedApiKey>;
66
+ create(input: {
67
+ readonly name: string;
68
+ }): Promise<{
69
+ readonly apiKey: string;
70
+ readonly record: ApiKeyMetadata;
71
+ }>;
72
+ list(): Promise<readonly ApiKeyMetadata[]>;
73
+ revoke(input: {
74
+ readonly id: string;
75
+ }): Promise<ApiKeyMetadata | null>;
76
+ };
77
+ clientAuth: {
78
+ varyHeaders: string[];
79
+ authenticate: (headers: Headers) => Promise<boolean>;
80
+ };
81
+ }, {
82
+ readonly clientAuth: true;
83
+ }>;
84
+ //#endregion
85
+ export { ApiKeysOptions, type ApiKeysSchema, apiKeys, apiKeysSchema, createApiKeyModel };
@@ -0,0 +1,85 @@
1
+ import { TableDefinition } from "../../database/schema.mjs";
2
+ import { HotUpdaterPlugin } from "../definePlugin.mjs";
3
+ import { ApiKeyMetadata, CreatedApiKey } from "../../apiKeys.mjs";
4
+ import "../../index.mjs";
5
+ import "../index.mjs";
6
+ import { ApiKeysSchema, apiKeysSchema } from "./schema.mjs";
7
+ import { createApiKeyModel } from "./model.mjs";
8
+ //#region src/plugins/api-keys/index.d.ts
9
+ interface ApiKeysOptions {
10
+ /** The request header that carries the key; defaults to `x-api-key`. */
11
+ readonly headerName?: string;
12
+ }
13
+ /**
14
+ * Built-in API keys: protects client routes with keys whose SHA-256 digests
15
+ * are stored, and manages them in-process.
16
+ */
17
+ declare const apiKeys: (options?: ApiKeysOptions) => HotUpdaterPlugin<"apiKeys", {
18
+ readonly api_keys: TableDefinition<{
19
+ readonly id: {
20
+ readonly type: "string";
21
+ readonly maxLength: 255;
22
+ };
23
+ readonly hash: {
24
+ readonly type: "string";
25
+ readonly maxLength: 64;
26
+ readonly unique: true;
27
+ };
28
+ readonly name: {
29
+ readonly type: "string";
30
+ readonly maxLength: 64;
31
+ };
32
+ readonly prefix: {
33
+ readonly type: "string";
34
+ readonly maxLength: 16;
35
+ };
36
+ readonly role: {
37
+ readonly type: "string";
38
+ readonly maxLength: 16;
39
+ };
40
+ readonly created_at_ms: {
41
+ readonly type: "integer";
42
+ };
43
+ readonly revoked_at_ms: {
44
+ readonly type: "integer";
45
+ readonly required: false;
46
+ };
47
+ }, {}, {
48
+ readonly byCreated: {
49
+ readonly eq: readonly [];
50
+ readonly sort: readonly ["created_at_ms"];
51
+ };
52
+ }, readonly ["id"]>;
53
+ }, {
54
+ api: {
55
+ /** Registers a known plaintext key idempotently, for managed init. */
56
+ register: (input: {
57
+ readonly apiKey: string;
58
+ readonly name: string;
59
+ readonly createdAtMs?: number;
60
+ }) => Promise<CreatedApiKey>;
61
+ /** Reuses a saved key or creates one, for managed init. */
62
+ provision: (input: {
63
+ readonly existingApiKey?: string;
64
+ readonly name: string;
65
+ }) => Promise<CreatedApiKey>;
66
+ create(input: {
67
+ readonly name: string;
68
+ }): Promise<{
69
+ readonly apiKey: string;
70
+ readonly record: ApiKeyMetadata;
71
+ }>;
72
+ list(): Promise<readonly ApiKeyMetadata[]>;
73
+ revoke(input: {
74
+ readonly id: string;
75
+ }): Promise<ApiKeyMetadata | null>;
76
+ };
77
+ clientAuth: {
78
+ varyHeaders: string[];
79
+ authenticate: (headers: Headers) => Promise<boolean>;
80
+ };
81
+ }, {
82
+ readonly clientAuth: true;
83
+ }>;
84
+ //#endregion
85
+ export { ApiKeysOptions, type ApiKeysSchema, apiKeys, apiKeysSchema, createApiKeyModel };