@hot-updater/server 1.0.0-rc.14 → 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 (514) hide show
  1. package/dist/adapters/drizzle.cjs +35 -74
  2. package/dist/adapters/drizzle.d.cts +13 -5
  3. package/dist/adapters/drizzle.d.mts +13 -5
  4. package/dist/adapters/drizzle.mjs +34 -75
  5. package/dist/adapters/drizzleExecutor.cjs +114 -0
  6. package/dist/adapters/drizzleExecutor.d.cts +9 -0
  7. package/dist/adapters/drizzleExecutor.d.mts +9 -0
  8. package/dist/adapters/drizzleExecutor.mjs +112 -0
  9. package/dist/adapters/kysely.cjs +25 -31
  10. package/dist/adapters/kysely.d.cts +10 -6
  11. package/dist/adapters/kysely.d.mts +10 -6
  12. package/dist/adapters/kysely.mjs +25 -32
  13. package/dist/adapters/kyselyExecutor.cjs +32 -0
  14. package/dist/adapters/kyselyExecutor.d.cts +12 -0
  15. package/dist/adapters/kyselyExecutor.d.mts +12 -0
  16. package/dist/adapters/kyselyExecutor.mjs +32 -0
  17. package/dist/adapters/mongodb.cjs +28 -62
  18. package/dist/adapters/mongodb.d.cts +10 -5
  19. package/dist/adapters/mongodb.d.mts +10 -5
  20. package/dist/adapters/mongodb.mjs +28 -63
  21. package/dist/adapters/mongodbAdapter.cjs +174 -0
  22. package/dist/adapters/mongodbAdapter.d.cts +9 -0
  23. package/dist/adapters/mongodbAdapter.d.mts +9 -0
  24. package/dist/adapters/mongodbAdapter.mjs +173 -0
  25. package/dist/adapters/prisma.cjs +38 -257
  26. package/dist/adapters/prisma.d.cts +12 -7
  27. package/dist/adapters/prisma.d.mts +12 -7
  28. package/dist/adapters/prisma.mjs +38 -257
  29. package/dist/adapters/prismaExecutor.cjs +64 -0
  30. package/dist/adapters/prismaExecutor.mjs +64 -0
  31. package/dist/adapters/sqlProviders.cjs +9 -0
  32. package/dist/adapters/sqlProviders.mjs +9 -0
  33. package/dist/apiKeys.cjs +2 -6
  34. package/dist/apiKeys.d.cts +1 -23
  35. package/dist/apiKeys.d.mts +1 -23
  36. package/dist/apiKeys.mjs +2 -6
  37. package/dist/assembly/assemblePlugins.cjs +147 -0
  38. package/dist/assembly/assemblePlugins.d.cts +12 -0
  39. package/dist/assembly/assemblePlugins.d.mts +12 -0
  40. package/dist/assembly/assemblePlugins.mjs +146 -0
  41. package/dist/assembly/databasePlugins.cjs +23 -0
  42. package/dist/assembly/databasePlugins.d.cts +43 -0
  43. package/dist/assembly/databasePlugins.d.mts +43 -0
  44. package/dist/assembly/databasePlugins.mjs +22 -0
  45. package/dist/core/api.cjs +91 -0
  46. package/dist/core/api.d.cts +65 -0
  47. package/dist/core/api.d.mts +65 -0
  48. package/dist/core/api.mjs +87 -0
  49. package/dist/core/baseCandidates.cjs +71 -0
  50. package/dist/core/baseCandidates.d.cts +17 -0
  51. package/dist/core/baseCandidates.d.mts +17 -0
  52. package/dist/core/baseCandidates.mjs +69 -0
  53. package/dist/core/operations.cjs +350 -0
  54. package/dist/core/operations.mjs +350 -0
  55. package/dist/core/reads.cjs +273 -0
  56. package/dist/core/reads.d.cts +48 -0
  57. package/dist/core/reads.d.mts +48 -0
  58. package/dist/core/reads.mjs +267 -0
  59. package/dist/core/releases.cjs +193 -0
  60. package/dist/core/releases.mjs +190 -0
  61. package/dist/core/schema.cjs +279 -0
  62. package/dist/core/schema.d.cts +307 -0
  63. package/dist/core/schema.d.mts +307 -0
  64. package/dist/core/schema.mjs +277 -0
  65. package/dist/core/writes.cjs +96 -0
  66. package/dist/core/writes.mjs +91 -0
  67. package/dist/createHotUpdaterCore.cjs +58 -75
  68. package/dist/createHotUpdaterCore.d.cts +52 -44
  69. package/dist/createHotUpdaterCore.d.mts +52 -44
  70. package/dist/createHotUpdaterCore.mjs +59 -75
  71. package/dist/database/cursor.cjs +44 -0
  72. package/dist/database/cursor.d.cts +7 -0
  73. package/dist/database/cursor.d.mts +7 -0
  74. package/dist/database/cursor.mjs +40 -0
  75. package/dist/database/database.cjs +44 -0
  76. package/dist/database/database.d.cts +123 -0
  77. package/dist/database/database.d.mts +123 -0
  78. package/dist/database/database.mjs +44 -0
  79. package/dist/database/definitions.d.cts +68 -0
  80. package/dist/database/definitions.d.mts +68 -0
  81. package/dist/database/engine.cjs +37 -0
  82. package/dist/database/engine.d.cts +40 -0
  83. package/dist/database/engine.d.mts +40 -0
  84. package/dist/database/engine.mjs +37 -0
  85. package/dist/database/engineAggregates.cjs +115 -0
  86. package/dist/database/engineAggregates.mjs +112 -0
  87. package/dist/database/engineReads.cjs +180 -0
  88. package/dist/database/engineReads.d.cts +35 -0
  89. package/dist/database/engineReads.d.mts +35 -0
  90. package/dist/database/engineReads.mjs +179 -0
  91. package/dist/database/engineTransaction.cjs +403 -0
  92. package/dist/database/engineTransaction.d.cts +26 -0
  93. package/dist/database/engineTransaction.d.mts +26 -0
  94. package/dist/database/engineTransaction.mjs +402 -0
  95. package/dist/database/errors.cjs +27 -0
  96. package/dist/database/errors.d.cts +21 -0
  97. package/dist/database/errors.d.mts +21 -0
  98. package/dist/database/errors.mjs +24 -0
  99. package/dist/database/fence.cjs +124 -0
  100. package/dist/database/fence.d.cts +42 -0
  101. package/dist/database/fence.d.mts +42 -0
  102. package/dist/database/fence.mjs +116 -0
  103. package/dist/database/index.cjs +127 -0
  104. package/dist/database/index.d.cts +17 -0
  105. package/dist/database/index.d.mts +17 -0
  106. package/dist/database/index.mjs +15 -0
  107. package/dist/database/kv/kvAdapter.cjs +273 -0
  108. package/dist/database/kv/kvAdapter.d.cts +101 -0
  109. package/dist/database/kv/kvAdapter.d.mts +101 -0
  110. package/dist/database/kv/kvAdapter.mjs +272 -0
  111. package/dist/database/resolveSchema.cjs +196 -0
  112. package/dist/database/resolveSchema.d.cts +42 -0
  113. package/dist/database/resolveSchema.d.mts +42 -0
  114. package/dist/database/resolveSchema.mjs +193 -0
  115. package/dist/database/schema.cjs +21 -0
  116. package/dist/database/schema.d.cts +61 -0
  117. package/dist/database/schema.d.mts +61 -0
  118. package/dist/database/schema.mjs +20 -0
  119. package/dist/database/sql/sqlAdapter.cjs +282 -0
  120. package/dist/database/sql/sqlAdapter.d.cts +46 -0
  121. package/dist/database/sql/sqlAdapter.d.mts +46 -0
  122. package/dist/database/sql/sqlAdapter.mjs +279 -0
  123. package/dist/database/sql/sqlSchema.cjs +115 -0
  124. package/dist/database/sql/sqlSchema.d.cts +8 -0
  125. package/dist/database/sql/sqlSchema.d.mts +8 -0
  126. package/dist/database/sql/sqlSchema.mjs +111 -0
  127. package/dist/db/builtInDatabase.cjs +104 -0
  128. package/dist/db/builtInDatabase.d.cts +38 -0
  129. package/dist/db/builtInDatabase.d.mts +38 -0
  130. package/dist/db/builtInDatabase.mjs +97 -0
  131. package/dist/db/createBundleDiff.cjs +4 -4
  132. package/dist/db/createBundleDiff.d.cts +3 -2
  133. package/dist/db/createBundleDiff.d.mts +3 -2
  134. package/dist/db/createBundleDiff.mjs +5 -5
  135. package/dist/db/engineDrizzleSchema.cjs +54 -0
  136. package/dist/db/engineDrizzleSchema.mjs +54 -0
  137. package/dist/db/engineMigrator.cjs +53 -0
  138. package/dist/db/engineMigrator.mjs +53 -0
  139. package/dist/db/enginePrismaSchema.cjs +85 -0
  140. package/dist/db/enginePrismaSchema.d.cts +5 -0
  141. package/dist/db/enginePrismaSchema.d.mts +5 -0
  142. package/dist/db/enginePrismaSchema.mjs +84 -0
  143. package/dist/db/engineSql.cjs +26 -0
  144. package/dist/db/engineSql.d.cts +17 -0
  145. package/dist/db/engineSql.d.mts +17 -0
  146. package/dist/db/engineSql.mjs +25 -0
  147. package/dist/db/engineSqlMigrator.cjs +66 -0
  148. package/dist/db/engineSqlMigrator.mjs +66 -0
  149. package/dist/db/fixedMigratorShared.cjs +0 -11
  150. package/dist/db/fixedMigratorShared.mjs +1 -8
  151. package/dist/db/index.cjs +23 -8
  152. package/dist/db/index.d.cts +10 -3
  153. package/dist/db/index.d.mts +10 -3
  154. package/dist/db/index.mjs +16 -8
  155. package/dist/db/releaseCatalog.cjs +20 -43
  156. package/dist/db/releaseCatalog.d.cts +2 -2
  157. package/dist/db/releaseCatalog.d.mts +2 -2
  158. package/dist/db/releaseCatalog.mjs +20 -44
  159. package/dist/db/schemaSettings.cjs +63 -0
  160. package/dist/db/schemaSettings.d.cts +12 -0
  161. package/dist/db/schemaSettings.d.mts +12 -0
  162. package/dist/db/schemaSettings.mjs +62 -0
  163. package/dist/db/settingsMigrator.cjs +92 -0
  164. package/dist/db/settingsMigrator.mjs +89 -0
  165. package/dist/db/types.cjs +1 -12
  166. package/dist/db/types.d.cts +26 -66
  167. package/dist/db/types.d.mts +26 -66
  168. package/dist/db/types.mjs +2 -11
  169. package/dist/db/updateArtifacts.cjs +38 -67
  170. package/dist/db/updateArtifacts.mjs +40 -69
  171. package/dist/handler.cjs +72 -43
  172. package/dist/handler.d.cts +3 -5
  173. package/dist/handler.d.mts +3 -5
  174. package/dist/handler.mjs +73 -43
  175. package/dist/handlerAdminRoutes.cjs +375 -0
  176. package/dist/handlerAdminRoutes.mjs +373 -0
  177. package/dist/handlerParameters.cjs +6 -11
  178. package/dist/handlerParameters.mjs +6 -10
  179. package/dist/handlerReleaseCatalogRoutes.cjs +11 -13
  180. package/dist/handlerReleaseCatalogRoutes.mjs +11 -13
  181. package/dist/handlerTypes.d.cts +2 -55
  182. package/dist/handlerTypes.d.mts +2 -55
  183. package/dist/handlerVersionRoutes.cjs +20 -4
  184. package/dist/handlerVersionRoutes.mjs +20 -4
  185. package/dist/index.cjs +4 -7
  186. package/dist/index.d.cts +8 -7
  187. package/dist/index.d.mts +8 -7
  188. package/dist/index.mjs +4 -4
  189. package/dist/insights/domain.d.cts +12 -0
  190. package/dist/insights/domain.d.mts +12 -0
  191. package/dist/insights/errors.cjs +34 -0
  192. package/dist/insights/errors.mjs +34 -1
  193. package/dist/insights/eventInput.cjs +14 -19
  194. package/dist/insights/eventInput.mjs +15 -20
  195. package/dist/insights/provider.cjs +47 -23
  196. package/dist/insights/provider.mjs +47 -24
  197. package/dist/insights/routes.cjs +79 -14
  198. package/dist/insights/routes.mjs +77 -14
  199. package/dist/node.d.cts +1 -1
  200. package/dist/node.d.mts +1 -1
  201. package/dist/package.cjs +1 -1
  202. package/dist/package.mjs +1 -1
  203. package/dist/plugins/api-keys/index.cjs +50 -0
  204. package/dist/plugins/api-keys/index.d.cts +85 -0
  205. package/dist/plugins/api-keys/index.d.mts +85 -0
  206. package/dist/plugins/api-keys/index.mjs +47 -0
  207. package/dist/plugins/api-keys/model.cjs +58 -0
  208. package/dist/plugins/api-keys/model.d.cts +8 -0
  209. package/dist/plugins/api-keys/model.d.mts +8 -0
  210. package/dist/plugins/api-keys/model.mjs +58 -0
  211. package/dist/plugins/api-keys/schema.cjs +38 -0
  212. package/dist/plugins/api-keys/schema.d.cts +44 -0
  213. package/dist/plugins/api-keys/schema.d.mts +44 -0
  214. package/dist/plugins/api-keys/schema.mjs +39 -0
  215. package/dist/plugins/builtIn.cjs +7 -0
  216. package/dist/plugins/builtIn.mjs +6 -0
  217. package/dist/plugins/definePlugin.cjs +5 -0
  218. package/dist/plugins/definePlugin.d.cts +73 -0
  219. package/dist/plugins/definePlugin.d.mts +73 -0
  220. package/dist/plugins/definePlugin.mjs +5 -0
  221. package/dist/plugins/index.cjs +17 -0
  222. package/dist/plugins/index.d.cts +9 -0
  223. package/dist/plugins/index.d.mts +9 -0
  224. package/dist/plugins/index.mjs +7 -0
  225. package/dist/plugins/insights/index.cjs +48 -0
  226. package/dist/plugins/insights/index.d.cts +295 -0
  227. package/dist/plugins/insights/index.d.mts +295 -0
  228. package/dist/plugins/insights/index.mjs +44 -0
  229. package/dist/plugins/insights/model.cjs +17 -0
  230. package/dist/plugins/insights/model.d.cts +10 -0
  231. package/dist/plugins/insights/model.d.mts +10 -0
  232. package/dist/plugins/insights/model.mjs +17 -0
  233. package/dist/plugins/insights/reads.cjs +471 -0
  234. package/dist/plugins/insights/reads.mjs +466 -0
  235. package/dist/plugins/insights/recordEvent.cjs +135 -0
  236. package/dist/plugins/insights/recordEvent.d.cts +13 -0
  237. package/dist/plugins/insights/recordEvent.d.mts +13 -0
  238. package/dist/plugins/insights/recordEvent.mjs +132 -0
  239. package/dist/plugins/insights/schema.cjs +347 -0
  240. package/dist/plugins/insights/schema.d.cts +258 -0
  241. package/dist/plugins/insights/schema.d.mts +258 -0
  242. package/dist/plugins/insights/schema.mjs +344 -0
  243. package/dist/types/index.d.cts +2 -28
  244. package/dist/types/index.d.mts +2 -28
  245. package/package.json +28 -5
  246. package/src/adapters/drizzle.conformance.integration.spec.ts +34 -0
  247. package/src/adapters/drizzle.readBudgets.integration.spec.ts +41 -0
  248. package/src/adapters/drizzle.spec.ts +270 -399
  249. package/src/adapters/drizzle.ts +48 -140
  250. package/src/adapters/drizzleExecutor.ts +166 -0
  251. package/src/adapters/kysely.conformance.integration.spec.ts +36 -0
  252. package/src/adapters/kysely.readBudgets.integration.spec.ts +42 -0
  253. package/src/adapters/kysely.spec.ts +204 -171
  254. package/src/adapters/kysely.ts +32 -93
  255. package/src/adapters/kyselyExecutor.ts +53 -0
  256. package/src/adapters/mongodb.integration.spec.ts +143 -446
  257. package/src/adapters/mongodb.readBudgets.integration.spec.ts +61 -0
  258. package/src/adapters/mongodb.ts +36 -123
  259. package/src/adapters/mongodbAdapter.ts +293 -0
  260. package/src/adapters/prisma.conformance.integration.spec.ts +36 -0
  261. package/src/adapters/prisma.integration.spec.ts +138 -0
  262. package/src/adapters/prisma.readBudgets.integration.spec.ts +40 -0
  263. package/src/adapters/prisma.spec.ts +216 -433
  264. package/src/adapters/prisma.ts +60 -524
  265. package/src/adapters/prismaExecutor.ts +107 -0
  266. package/src/adapters/prismaTestClients.ts +175 -0
  267. package/src/adapters/sqlProviders.ts +14 -0
  268. package/src/apiKeys.integration.spec.ts +19 -119
  269. package/src/apiKeys.spec.ts +39 -35
  270. package/src/apiKeys.ts +2 -8
  271. package/src/assembly/assemblePlugins.ts +269 -0
  272. package/src/assembly/assembly.spec.ts +325 -0
  273. package/src/assembly/assembly.types.spec.ts +155 -0
  274. package/src/assembly/builtInRoutes.spec.ts +213 -0
  275. package/src/assembly/databasePlugins.spec.ts +71 -0
  276. package/src/assembly/databasePlugins.ts +96 -0
  277. package/src/core/api.ts +139 -0
  278. package/src/core/baseCandidates.spec.ts +378 -0
  279. package/src/core/baseCandidates.ts +136 -0
  280. package/src/core/index.ts +44 -0
  281. package/src/core/operations.spec.ts +415 -0
  282. package/src/core/operations.ts +551 -0
  283. package/src/core/reads.spec.ts +300 -0
  284. package/src/core/reads.ts +417 -0
  285. package/src/core/releases.spec.ts +308 -0
  286. package/src/core/releases.ts +345 -0
  287. package/src/core/schema.ts +173 -0
  288. package/src/core/writes.ts +160 -0
  289. package/src/createHotUpdaterCore.ts +191 -181
  290. package/src/database/cursor.ts +65 -0
  291. package/src/database/database.ts +335 -0
  292. package/src/database/database.types.spec.ts +135 -0
  293. package/src/database/definitions.ts +72 -0
  294. package/src/database/engine.ts +62 -0
  295. package/src/database/engineAggregates.spec.ts +539 -0
  296. package/src/database/engineAggregates.ts +193 -0
  297. package/src/database/engineReads.spec.ts +219 -0
  298. package/src/database/engineReads.ts +302 -0
  299. package/src/database/engineTransaction.spec.ts +710 -0
  300. package/src/database/engineTransaction.ts +588 -0
  301. package/src/database/errors.ts +30 -0
  302. package/src/database/fence.spec.ts +223 -0
  303. package/src/database/fence.ts +171 -0
  304. package/src/database/index.ts +154 -0
  305. package/src/database/kv/kvAdapter.conformance.integration.spec.ts +17 -0
  306. package/src/database/kv/kvAdapter.readBudgets.integration.spec.ts +17 -0
  307. package/src/database/kv/kvAdapter.spec.ts +468 -0
  308. package/src/database/kv/kvAdapter.ts +450 -0
  309. package/src/database/kv/kvTestStore.ts +91 -0
  310. package/src/database/memory.readBudgets.integration.spec.ts +13 -0
  311. package/src/database/resolveSchema.spec.ts +230 -0
  312. package/src/database/resolveSchema.ts +372 -0
  313. package/src/database/schema.ts +169 -0
  314. package/src/database/schema.types.spec.ts +94 -0
  315. package/src/database/sql/docker-compose.yml +36 -0
  316. package/src/database/sql/sqlAdapter.integration.spec.ts +148 -0
  317. package/src/database/sql/sqlAdapter.readBudgets.integration.spec.ts +109 -0
  318. package/src/database/sql/sqlAdapter.spec.ts +255 -0
  319. package/src/database/sql/sqlAdapter.ts +532 -0
  320. package/src/database/sql/sqlSchema.ts +205 -0
  321. package/src/database/sql/sqlTestExecutors.ts +183 -0
  322. package/src/databaseTestSuite.spec.ts +39 -0
  323. package/src/db/builtInDatabase.ts +149 -0
  324. package/src/db/bundleRows.spec.ts +3 -3
  325. package/src/db/createBundleDiff.spec.ts +43 -29
  326. package/src/db/createBundleDiff.ts +13 -7
  327. package/src/db/engineDrizzleSchema.ts +72 -0
  328. package/src/db/engineMigrator.ts +105 -0
  329. package/src/db/enginePrismaSchema.ts +147 -0
  330. package/src/db/engineSql.spec.ts +129 -0
  331. package/src/db/engineSql.ts +48 -0
  332. package/src/db/engineSqlMigrator.ts +116 -0
  333. package/src/db/fixedMigratorShared.ts +1 -20
  334. package/src/db/index.spec.ts +116 -829
  335. package/src/db/index.ts +43 -14
  336. package/src/db/pluginTables.spec.ts +218 -0
  337. package/src/db/releaseCatalog.ts +48 -90
  338. package/src/db/schemaSettings.ts +104 -0
  339. package/src/db/settingsMigrator.spec.ts +65 -0
  340. package/src/db/settingsMigrator.ts +152 -0
  341. package/src/db/types.ts +25 -171
  342. package/src/db/updateArtifacts.spec.ts +170 -294
  343. package/src/db/updateArtifacts.ts +74 -142
  344. package/src/db/updateCheck.bench.ts +47 -0
  345. package/src/handler-standalone.integration.spec.ts +204 -410
  346. package/src/handler.spec.ts +134 -51
  347. package/src/handler.testFixtures.ts +14 -19
  348. package/src/handler.ts +163 -75
  349. package/src/handlerAdminRoutes.spec.ts +183 -0
  350. package/src/handlerAdminRoutes.ts +536 -0
  351. package/src/handlerAuth.integration.spec.ts +3 -3
  352. package/src/handlerManagement.spec.ts +136 -196
  353. package/src/handlerReleaseCatalogRoutes.ts +15 -17
  354. package/src/handlerTypes.ts +3 -80
  355. package/src/handlerVersionRoutes.ts +20 -7
  356. package/src/index.ts +5 -12
  357. package/src/insights/domain.ts +12 -0
  358. package/src/insights/errors.spec.ts +48 -0
  359. package/src/insights/errors.ts +51 -0
  360. package/src/insights/eventInput.ts +27 -24
  361. package/src/insights/insights.integration.spec.ts +228 -78
  362. package/src/insights/provider.spec.ts +203 -25
  363. package/src/insights/provider.ts +88 -32
  364. package/src/insights/routes.ts +95 -20
  365. package/src/lintRules.spec.ts +76 -0
  366. package/src/plugins/api-keys/apiKeysPlugin.spec.ts +172 -0
  367. package/src/plugins/api-keys/index.ts +66 -0
  368. package/src/plugins/api-keys/model.ts +69 -0
  369. package/src/plugins/api-keys/schema.ts +22 -0
  370. package/src/plugins/builtIn.ts +5 -0
  371. package/src/plugins/definePlugin.ts +100 -0
  372. package/src/plugins/index.ts +55 -0
  373. package/src/plugins/insights/index.ts +86 -0
  374. package/src/plugins/insights/insightsRollout.integration.spec.ts +187 -0
  375. package/src/plugins/insights/model.spec.ts +66 -0
  376. package/src/plugins/insights/model.ts +19 -0
  377. package/src/plugins/insights/reads.spec.ts +725 -0
  378. package/src/plugins/insights/reads.ts +707 -0
  379. package/src/plugins/insights/recordEvent.spec.ts +443 -0
  380. package/src/plugins/insights/recordEvent.ts +238 -0
  381. package/src/plugins/insights/schema.ts +229 -0
  382. package/src/plugins/pluginTestHarness.spec.ts +56 -0
  383. package/src/readBudgets.testFixtures.ts +15 -0
  384. package/src/releaseCatalogRoutes.integration.spec.ts +47 -92
  385. package/src/runtime.spec.ts +91 -77
  386. package/src/runtime.testFixtures.ts +28 -44
  387. package/src/runtimeBundles.integration.spec.ts +112 -0
  388. package/src/testUtilsMutation.integration.spec.ts +215 -0
  389. package/src/testUtilsPackage.integration.spec.ts +176 -0
  390. package/src/types/index.ts +0 -32
  391. package/dist/adapters/databaseConstraintErrors.cjs +0 -22
  392. package/dist/adapters/databaseConstraintErrors.mjs +0 -21
  393. package/dist/adapters/databasePluginUtils.cjs +0 -130
  394. package/dist/adapters/databasePluginUtils.mjs +0 -118
  395. package/dist/adapters/drizzleCrud.cjs +0 -340
  396. package/dist/adapters/drizzleCrud.mjs +0 -337
  397. package/dist/adapters/drizzleLazyDB.cjs +0 -103
  398. package/dist/adapters/drizzleLazyDB.mjs +0 -103
  399. package/dist/adapters/drizzleQuery.cjs +0 -69
  400. package/dist/adapters/drizzleQuery.mjs +0 -69
  401. package/dist/adapters/kyselyCrud.cjs +0 -293
  402. package/dist/adapters/kyselyCrud.mjs +0 -292
  403. package/dist/adapters/kyselyQuery.cjs +0 -56
  404. package/dist/adapters/kyselyQuery.mjs +0 -56
  405. package/dist/adapters/mongodbCollections.cjs +0 -38
  406. package/dist/adapters/mongodbCollections.mjs +0 -32
  407. package/dist/adapters/mongodbQuery.cjs +0 -90
  408. package/dist/adapters/mongodbQuery.mjs +0 -83
  409. package/dist/adapters/mongodbReads.cjs +0 -206
  410. package/dist/adapters/mongodbReads.mjs +0 -206
  411. package/dist/adapters/mongodbWrites.cjs +0 -133
  412. package/dist/adapters/mongodbWrites.mjs +0 -133
  413. package/dist/adapters/prismaInsights.cjs +0 -99
  414. package/dist/adapters/prismaInsights.mjs +0 -97
  415. package/dist/adapters/prismaQuery.cjs +0 -57
  416. package/dist/adapters/prismaQuery.mjs +0 -56
  417. package/dist/adapters/prismaRows.cjs +0 -197
  418. package/dist/adapters/prismaRows.mjs +0 -188
  419. package/dist/db/databasePluginCore.cjs +0 -137
  420. package/dist/db/databasePluginCore.mjs +0 -137
  421. package/dist/db/fixedMigrator.cjs +0 -79
  422. package/dist/db/fixedMigrator.mjs +0 -78
  423. package/dist/db/fixedMigratorMongo.cjs +0 -321
  424. package/dist/db/fixedMigratorMongo.mjs +0 -321
  425. package/dist/db/mongoMigrationExecution.cjs +0 -11
  426. package/dist/db/mongoMigrationExecution.mjs +0 -11
  427. package/dist/db/schema/insightsCollation.cjs +0 -14
  428. package/dist/db/schema/insightsCollation.mjs +0 -14
  429. package/dist/db/schema/mongodb.cjs +0 -25
  430. package/dist/db/schema/mongodb.mjs +0 -25
  431. package/dist/db/schema/registry.cjs +0 -21
  432. package/dist/db/schema/registry.mjs +0 -17
  433. package/dist/db/schema/sql.cjs +0 -105
  434. package/dist/db/schema/sql.mjs +0 -97
  435. package/dist/db/schema/sqlOperations.cjs +0 -27
  436. package/dist/db/schema/sqlOperations.mjs +0 -26
  437. package/dist/db/schemaGenerators.cjs +0 -276
  438. package/dist/db/schemaGenerators.mjs +0 -274
  439. package/dist/db/schemaReadiness.cjs +0 -26
  440. package/dist/db/schemaReadiness.d.cts +0 -9
  441. package/dist/db/schemaReadiness.d.mts +0 -9
  442. package/dist/db/schemaReadiness.mjs +0 -25
  443. package/dist/db/sqlMigrationExecution.cjs +0 -67
  444. package/dist/db/sqlMigrationExecution.mjs +0 -67
  445. package/dist/handlerBundleRoutes.cjs +0 -155
  446. package/dist/handlerBundleRoutes.mjs +0 -155
  447. package/dist/handlerReleaseManagementRoutes.cjs +0 -124
  448. package/dist/handlerReleaseManagementRoutes.mjs +0 -124
  449. package/dist/schema/dsl.cjs +0 -103
  450. package/dist/schema/dsl.mjs +0 -87
  451. package/dist/schema/index.cjs +0 -20
  452. package/dist/schema/index.mjs +0 -7
  453. package/dist/schema/settings.cjs +0 -9
  454. package/dist/schema/settings.mjs +0 -9
  455. package/dist/schema/types.cjs +0 -8
  456. package/dist/schema/types.mjs +0 -6
  457. package/dist/schema/v1_0_0.cjs +0 -393
  458. package/dist/schema/v1_0_0.mjs +0 -385
  459. package/src/adapters/databaseConstraintErrors.ts +0 -25
  460. package/src/adapters/databasePluginTestDatabase.ts +0 -116
  461. package/src/adapters/databasePluginUtils.spec.ts +0 -29
  462. package/src/adapters/databasePluginUtils.ts +0 -238
  463. package/src/adapters/drizzleCrud.ts +0 -610
  464. package/src/adapters/drizzleLazyDB.ts +0 -284
  465. package/src/adapters/drizzleQuery.ts +0 -164
  466. package/src/adapters/kyselyCrud.ts +0 -696
  467. package/src/adapters/kyselyInsights.spec.ts +0 -168
  468. package/src/adapters/kyselyQuery.ts +0 -128
  469. package/src/adapters/mongodb.spec.ts +0 -230
  470. package/src/adapters/mongodbCollections.ts +0 -78
  471. package/src/adapters/mongodbQuery.ts +0 -245
  472. package/src/adapters/mongodbReads.ts +0 -387
  473. package/src/adapters/mongodbRows.spec.ts +0 -64
  474. package/src/adapters/mongodbRows.ts +0 -118
  475. package/src/adapters/mongodbTestClient.ts +0 -443
  476. package/src/adapters/mongodbTestFilter.ts +0 -170
  477. package/src/adapters/mongodbWrites.ts +0 -261
  478. package/src/adapters/prismaInsights.ts +0 -190
  479. package/src/adapters/prismaQuery.ts +0 -129
  480. package/src/adapters/prismaRows.spec.ts +0 -98
  481. package/src/adapters/prismaRows.ts +0 -308
  482. package/src/adapters/prismaTestClient.ts +0 -478
  483. package/src/calculatePagination.ts +0 -34
  484. package/src/db/databasePluginCore.spec.ts +0 -62
  485. package/src/db/databasePluginCore.testFixtures.ts +0 -76
  486. package/src/db/databasePluginCore.ts +0 -185
  487. package/src/db/databasePluginUpdateCheck.bench.ts +0 -117
  488. package/src/db/fixedMigrator.spec.ts +0 -294
  489. package/src/db/fixedMigrator.ts +0 -147
  490. package/src/db/fixedMigratorMongo.spec.ts +0 -253
  491. package/src/db/fixedMigratorMongo.ts +0 -425
  492. package/src/db/hotUpdaterSchema.ts +0 -5
  493. package/src/db/mongoMigrationExecution.ts +0 -23
  494. package/src/db/schema/definitions.ts +0 -1
  495. package/src/db/schema/insightsCollation.ts +0 -21
  496. package/src/db/schema/mongodb.ts +0 -40
  497. package/src/db/schema/registry.ts +0 -55
  498. package/src/db/schema/sql.ts +0 -244
  499. package/src/db/schema/sqlOperations.ts +0 -63
  500. package/src/db/schema/types.ts +0 -1
  501. package/src/db/schemaGenerators.ts +0 -495
  502. package/src/db/schemaReadiness.ts +0 -34
  503. package/src/db/sqlMigrationExecution.spec.ts +0 -65
  504. package/src/db/sqlMigrationExecution.ts +0 -108
  505. package/src/db/types.spec.ts +0 -63
  506. package/src/handlerBundleRoutes.ts +0 -259
  507. package/src/handlerReleaseManagementRoutes.ts +0 -213
  508. package/src/schema/dsl-all-versions.spec.ts +0 -35
  509. package/src/schema/dsl.ts +0 -187
  510. package/src/schema/index.ts +0 -10
  511. package/src/schema/settings.ts +0 -15
  512. package/src/schema/types.ts +0 -79
  513. package/src/schema/v1_0_0.spec.ts +0 -220
  514. package/src/schema/v1_0_0.ts +0 -511
@@ -1,62 +1,9 @@
1
- import { ReleaseCatalogRequest } from "./db/releaseCatalog.mjs";
2
- import { PaginatedResult } from "./types/index.mjs";
3
- import { ChannelDeleteInput, ChannelDeleteResult, ChannelInsertInput, ChannelInsertResult, ChannelRow, DatabaseBundleQueryOptions, DatabaseCommit, DatabaseCommitResult, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildResult, ReleaseCatalogRow, ReleasePolicyPatch, ReleaseRow } from "@hot-updater/plugin-core";
4
- import { ArtifactInfo, Bundle as Bundle$1, ReleaseCatalog } from "@hot-updater/core";
1
+ import "./core/api.mjs";
5
2
  //#region src/handlerTypes.d.ts
6
- interface HandlerAPI {
7
- getReleaseCatalog?: (input: ReleaseCatalogRequest) => Promise<ReleaseCatalog | null>;
8
- getArtifactInfo?: (targetBundleId: string, currentBundleId: string) => Promise<ArtifactInfo | null>;
9
- getReleaseById?: (id: string) => Promise<ReleaseRow | null>;
10
- getReleasesByScope?: (input: {
11
- readonly scopeKey: string;
12
- readonly afterReleaseId?: string;
13
- readonly limit: number;
14
- }) => Promise<readonly ReleaseRow[]>;
15
- getReleases?: (input: {
16
- readonly afterReleaseId?: string;
17
- readonly beforeReleaseId?: string;
18
- readonly bundleId?: string;
19
- readonly channelId?: string;
20
- readonly enabled?: boolean;
21
- readonly platform?: "ios" | "android";
22
- readonly targetAppVersion?: string;
23
- readonly limit: number;
24
- }) => Promise<readonly ReleaseRow[]>;
25
- getReleaseCatalogByScopeKey?: (scopeKey: string) => Promise<ReleaseCatalogRow | null>;
26
- getReleaseCatalogs?: (input: {
27
- readonly afterScopeKey?: string;
28
- readonly limit: number;
29
- }) => Promise<readonly ReleaseCatalogRow[]>;
30
- updateReleasePolicy?: (input: {
31
- readonly expectedRevision?: number;
32
- readonly patch: ReleasePolicyPatch;
33
- readonly releaseId: string;
34
- }) => Promise<ReleaseCatalogMutationResult>;
35
- preflightReleasePolicy?: (input: {
36
- readonly expectedRevision?: number;
37
- readonly patch: ReleasePolicyPatch;
38
- readonly releaseId: string;
39
- }) => Promise<ReleaseCatalogMutationPreflight>;
40
- deleteRelease?: (input: {
41
- readonly expectedRevision?: number;
42
- readonly releaseId: string;
43
- }) => Promise<ReleaseCatalogMutationResult>;
44
- rebuildReleaseCatalog?: (scopeKey: string) => Promise<ReleaseCatalogRebuildResult>;
45
- commitDatabase?: (input: DatabaseCommit) => Promise<DatabaseCommitResult>;
46
- getBundleById: (id: string) => Promise<Bundle$1 | null>;
47
- getBundles: (options: DatabaseBundleQueryOptions) => Promise<PaginatedResult>;
48
- insertBundle: (bundle: Bundle$1) => Promise<void>;
49
- insertBundles?: (bundles: readonly Bundle$1[]) => Promise<void>;
50
- updateBundleById: (bundleId: string, bundle: Partial<Bundle$1>) => Promise<void>;
51
- deleteBundleById: (bundleId: string) => Promise<void>;
52
- getChannels: () => Promise<readonly ChannelRow[]>;
53
- insertChannel: (input: ChannelInsertInput) => Promise<ChannelInsertResult>;
54
- deleteChannel: (input: ChannelDeleteInput) => Promise<ChannelDeleteResult>;
55
- }
56
3
  type HotUpdaterHandler = (request: Request) => Promise<Response>;
57
4
  interface HotUpdaterHandlers {
58
5
  readonly client: HotUpdaterHandler;
59
6
  readonly admin: HotUpdaterHandler;
60
7
  }
61
8
  //#endregion
62
- export { HandlerAPI, HotUpdaterHandler, HotUpdaterHandlers };
9
+ export { HotUpdaterHandler, HotUpdaterHandlers };
@@ -1,10 +1,26 @@
1
1
  const require_version = require("./version.cjs");
2
2
  //#region src/handlerVersionRoutes.ts
3
3
  const HOT_UPDATER_INFRASTRUCTURE_GENERATION = 1;
4
- const createVersionRouteHandlers = () => ({ version: async () => Response.json({
5
- infrastructureGeneration: 1,
6
- version: require_version.HOT_UPDATER_SERVER_VERSION
7
- }) });
4
+ /**
5
+ * `/version` on both mounts. The admin mount also lists the ids of the
6
+ * plugins the server runs, sorted, so a console shows only the features they
7
+ * serve; apps never learn which plugins a server runs.
8
+ */
9
+ const createVersionRouteHandlers = (plugins = []) => {
10
+ const version = {
11
+ adminProtocol: 2,
12
+ infrastructureGeneration: 1,
13
+ version: require_version.HOT_UPDATER_SERVER_VERSION
14
+ };
15
+ const adminVersion = {
16
+ ...version,
17
+ plugins: [...plugins].sort()
18
+ };
19
+ return {
20
+ version: async () => Response.json(version),
21
+ adminVersion: async () => Response.json(adminVersion)
22
+ };
23
+ };
8
24
  //#endregion
9
25
  exports.HOT_UPDATER_INFRASTRUCTURE_GENERATION = HOT_UPDATER_INFRASTRUCTURE_GENERATION;
10
26
  exports.createVersionRouteHandlers = createVersionRouteHandlers;
@@ -1,9 +1,25 @@
1
1
  import { HOT_UPDATER_SERVER_VERSION } from "./version.mjs";
2
2
  //#region src/handlerVersionRoutes.ts
3
3
  const HOT_UPDATER_INFRASTRUCTURE_GENERATION = 1;
4
- const createVersionRouteHandlers = () => ({ version: async () => Response.json({
5
- infrastructureGeneration: 1,
6
- version: HOT_UPDATER_SERVER_VERSION
7
- }) });
4
+ /**
5
+ * `/version` on both mounts. The admin mount also lists the ids of the
6
+ * plugins the server runs, sorted, so a console shows only the features they
7
+ * serve; apps never learn which plugins a server runs.
8
+ */
9
+ const createVersionRouteHandlers = (plugins = []) => {
10
+ const version = {
11
+ adminProtocol: 2,
12
+ infrastructureGeneration: 1,
13
+ version: HOT_UPDATER_SERVER_VERSION
14
+ };
15
+ const adminVersion = {
16
+ ...version,
17
+ plugins: [...plugins].sort()
18
+ };
19
+ return {
20
+ version: async () => Response.json(version),
21
+ adminVersion: async () => Response.json(adminVersion)
22
+ };
23
+ };
8
24
  //#endregion
9
25
  export { HOT_UPDATER_INFRASTRUCTURE_GENERATION, createVersionRouteHandlers };
package/dist/index.cjs CHANGED
@@ -1,16 +1,13 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_version = require("./version.cjs");
3
- const require_handlerVersionRoutes = require("./handlerVersionRoutes.cjs");
4
- const require_handler = require("./handler.cjs");
5
2
  const require_provider = require("./insights/provider.cjs");
6
3
  const require_apiKeys = require("./apiKeys.cjs");
4
+ const require_assemblePlugins = require("./assembly/assemblePlugins.cjs");
5
+ const require_version = require("./version.cjs");
6
+ const require_handlerVersionRoutes = require("./handlerVersionRoutes.cjs");
7
7
  const require_createHotUpdaterCore = require("./createHotUpdaterCore.cjs");
8
8
  exports.API_KEY_HEADER_NAME = require_apiKeys.API_KEY_HEADER_NAME;
9
9
  exports.HOT_UPDATER_INFRASTRUCTURE_GENERATION = require_handlerVersionRoutes.HOT_UPDATER_INFRASTRUCTURE_GENERATION;
10
10
  exports.HOT_UPDATER_SERVER_VERSION = require_version.HOT_UPDATER_SERVER_VERSION;
11
- exports.createApiKey = require_apiKeys.createApiKey;
12
- exports.createHandlers = require_handler.createHandlers;
11
+ exports.HotUpdaterConfigError = require_assemblePlugins.HotUpdaterConfigError;
13
12
  exports.createHotUpdater = require_createHotUpdaterCore.createHotUpdater;
14
13
  exports.createInsightsProvider = require_provider.createInsightsProvider;
15
- exports.provisionApiKey = require_apiKeys.provisionApiKey;
16
- exports.registerApiKey = require_apiKeys.registerApiKey;
package/dist/index.d.cts CHANGED
@@ -1,11 +1,12 @@
1
- import { API_KEY_HEADER_NAME, ApiKeyManagementAPI, ApiKeyMetadata, CreatedApiKey, createApiKey, provisionApiKey, registerApiKey } from "./apiKeys.cjs";
2
- import { HandlerAPI, HotUpdaterHandler, HotUpdaterHandlers } from "./handlerTypes.cjs";
1
+ import { HOT_UPDATER_SERVER_VERSION } from "./version.cjs";
2
+ import { HotUpdaterConfigError } from "./assembly/assemblePlugins.cjs";
3
+ import { HotUpdaterHandler, HotUpdaterHandlers } from "./handlerTypes.cjs";
4
+ import "./handler.cjs";
3
5
  import { ActiveInstallationWindow, CreateBundleEventRequest, CreateBundleEventRequestBase, CursorPage, EventCursorPage, EventHistoryRow, InsightsBundleSelection, InsightsCountMeasurement, InsightsScope, InstallationHistoryRow, InstallationRow, ReportingOverview } from "./insights/domain.cjs";
4
6
  import { InsightsEventPageInput, InsightsInstallationEventPageInput, InsightsProvider, InsightsUserInstallationPageInput } from "./insights/types.cjs";
5
- import { createHandlers } from "./handler.cjs";
6
- import { ClientAccessPolicy, CreateHotUpdaterOptions, HotUpdaterAPI, RuntimeHotUpdaterAPI, createHotUpdater } from "./createHotUpdaterCore.cjs";
7
- import { Bundle, ChannelsResponse, DataResponse, Paginated, PaginatedResult, PaginationInfo, PaginationOptions } from "./types/index.cjs";
8
- import { HOT_UPDATER_SERVER_VERSION } from "./version.cjs";
9
7
  import { createInsightsProvider } from "./insights/provider.cjs";
8
+ import { API_KEY_HEADER_NAME, ApiKeyManagementAPI, ApiKeyMetadata, CreatedApiKey } from "./apiKeys.cjs";
9
+ import { ClientAccessPolicy, ClientAccessRule, CreateHotUpdaterOptions, HotUpdaterAPI, RemovedClientAccess, RuntimeHotUpdaterAPI, createHotUpdater } from "./createHotUpdaterCore.cjs";
10
+ import { Bundle } from "./types/index.cjs";
10
11
  import { HOT_UPDATER_INFRASTRUCTURE_GENERATION } from "./handlerVersionRoutes.cjs";
11
- export { API_KEY_HEADER_NAME, type ActiveInstallationWindow, type ApiKeyManagementAPI, type ApiKeyMetadata, type Bundle, ChannelsResponse, type ClientAccessPolicy, type CreateBundleEventRequest, type CreateBundleEventRequestBase, type CreateHotUpdaterOptions, type CreatedApiKey, type CursorPage, DataResponse, type EventCursorPage, type EventHistoryRow, HOT_UPDATER_INFRASTRUCTURE_GENERATION, HOT_UPDATER_SERVER_VERSION, type HandlerAPI, type HotUpdaterAPI, type HotUpdaterHandler, type HotUpdaterHandlers, type InsightsBundleSelection, type InsightsCountMeasurement, type InsightsEventPageInput, type InsightsInstallationEventPageInput, type InsightsProvider, type InsightsScope, type InsightsUserInstallationPageInput, type InstallationHistoryRow, type InstallationRow, Paginated, PaginatedResult, PaginationInfo, PaginationOptions, type ReportingOverview, type RuntimeHotUpdaterAPI, createApiKey, createHandlers, createHotUpdater, createInsightsProvider, provisionApiKey, registerApiKey };
12
+ export { API_KEY_HEADER_NAME, type ActiveInstallationWindow, type ApiKeyManagementAPI, type ApiKeyMetadata, type Bundle, type ClientAccessPolicy, type ClientAccessRule, type CreateBundleEventRequest, type CreateBundleEventRequestBase, type CreateHotUpdaterOptions, type CreatedApiKey, type CursorPage, type EventCursorPage, type EventHistoryRow, HOT_UPDATER_INFRASTRUCTURE_GENERATION, HOT_UPDATER_SERVER_VERSION, type HotUpdaterAPI, HotUpdaterConfigError, type HotUpdaterHandler, type HotUpdaterHandlers, type InsightsBundleSelection, type InsightsCountMeasurement, type InsightsEventPageInput, type InsightsInstallationEventPageInput, type InsightsProvider, type InsightsScope, type InsightsUserInstallationPageInput, type InstallationHistoryRow, type InstallationRow, type RemovedClientAccess, type ReportingOverview, type RuntimeHotUpdaterAPI, createHotUpdater, createInsightsProvider };
package/dist/index.d.mts CHANGED
@@ -1,11 +1,12 @@
1
- import { API_KEY_HEADER_NAME, ApiKeyManagementAPI, ApiKeyMetadata, CreatedApiKey, createApiKey, provisionApiKey, registerApiKey } from "./apiKeys.mjs";
2
- import { HandlerAPI, HotUpdaterHandler, HotUpdaterHandlers } from "./handlerTypes.mjs";
1
+ import { HOT_UPDATER_SERVER_VERSION } from "./version.mjs";
2
+ import { HotUpdaterConfigError } from "./assembly/assemblePlugins.mjs";
3
+ import { HotUpdaterHandler, HotUpdaterHandlers } from "./handlerTypes.mjs";
4
+ import "./handler.mjs";
3
5
  import { ActiveInstallationWindow, CreateBundleEventRequest, CreateBundleEventRequestBase, CursorPage, EventCursorPage, EventHistoryRow, InsightsBundleSelection, InsightsCountMeasurement, InsightsScope, InstallationHistoryRow, InstallationRow, ReportingOverview } from "./insights/domain.mjs";
4
6
  import { InsightsEventPageInput, InsightsInstallationEventPageInput, InsightsProvider, InsightsUserInstallationPageInput } from "./insights/types.mjs";
5
- import { createHandlers } from "./handler.mjs";
6
- import { ClientAccessPolicy, CreateHotUpdaterOptions, HotUpdaterAPI, RuntimeHotUpdaterAPI, createHotUpdater } from "./createHotUpdaterCore.mjs";
7
- import { Bundle, ChannelsResponse, DataResponse, Paginated, PaginatedResult, PaginationInfo, PaginationOptions } from "./types/index.mjs";
8
- import { HOT_UPDATER_SERVER_VERSION } from "./version.mjs";
9
7
  import { createInsightsProvider } from "./insights/provider.mjs";
8
+ import { API_KEY_HEADER_NAME, ApiKeyManagementAPI, ApiKeyMetadata, CreatedApiKey } from "./apiKeys.mjs";
9
+ import { ClientAccessPolicy, ClientAccessRule, CreateHotUpdaterOptions, HotUpdaterAPI, RemovedClientAccess, RuntimeHotUpdaterAPI, createHotUpdater } from "./createHotUpdaterCore.mjs";
10
+ import { Bundle } from "./types/index.mjs";
10
11
  import { HOT_UPDATER_INFRASTRUCTURE_GENERATION } from "./handlerVersionRoutes.mjs";
11
- export { API_KEY_HEADER_NAME, type ActiveInstallationWindow, type ApiKeyManagementAPI, type ApiKeyMetadata, type Bundle, ChannelsResponse, type ClientAccessPolicy, type CreateBundleEventRequest, type CreateBundleEventRequestBase, type CreateHotUpdaterOptions, type CreatedApiKey, type CursorPage, DataResponse, type EventCursorPage, type EventHistoryRow, HOT_UPDATER_INFRASTRUCTURE_GENERATION, HOT_UPDATER_SERVER_VERSION, type HandlerAPI, type HotUpdaterAPI, type HotUpdaterHandler, type HotUpdaterHandlers, type InsightsBundleSelection, type InsightsCountMeasurement, type InsightsEventPageInput, type InsightsInstallationEventPageInput, type InsightsProvider, type InsightsScope, type InsightsUserInstallationPageInput, type InstallationHistoryRow, type InstallationRow, Paginated, PaginatedResult, PaginationInfo, PaginationOptions, type ReportingOverview, type RuntimeHotUpdaterAPI, createApiKey, createHandlers, createHotUpdater, createInsightsProvider, provisionApiKey, registerApiKey };
12
+ export { API_KEY_HEADER_NAME, type ActiveInstallationWindow, type ApiKeyManagementAPI, type ApiKeyMetadata, type Bundle, type ClientAccessPolicy, type ClientAccessRule, type CreateBundleEventRequest, type CreateBundleEventRequestBase, type CreateHotUpdaterOptions, type CreatedApiKey, type CursorPage, type EventCursorPage, type EventHistoryRow, HOT_UPDATER_INFRASTRUCTURE_GENERATION, HOT_UPDATER_SERVER_VERSION, type HotUpdaterAPI, HotUpdaterConfigError, type HotUpdaterHandler, type HotUpdaterHandlers, type InsightsBundleSelection, type InsightsCountMeasurement, type InsightsEventPageInput, type InsightsInstallationEventPageInput, type InsightsProvider, type InsightsScope, type InsightsUserInstallationPageInput, type InstallationHistoryRow, type InstallationRow, type RemovedClientAccess, type ReportingOverview, type RuntimeHotUpdaterAPI, createHotUpdater, createInsightsProvider };
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
+ import { createInsightsProvider } from "./insights/provider.mjs";
2
+ import { API_KEY_HEADER_NAME } from "./apiKeys.mjs";
3
+ import { HotUpdaterConfigError } from "./assembly/assemblePlugins.mjs";
1
4
  import { HOT_UPDATER_SERVER_VERSION } from "./version.mjs";
2
5
  import { HOT_UPDATER_INFRASTRUCTURE_GENERATION } from "./handlerVersionRoutes.mjs";
3
- import { createHandlers } from "./handler.mjs";
4
- import { createInsightsProvider } from "./insights/provider.mjs";
5
- import { API_KEY_HEADER_NAME, createApiKey, provisionApiKey, registerApiKey } from "./apiKeys.mjs";
6
6
  import { createHotUpdater } from "./createHotUpdaterCore.mjs";
7
- export { API_KEY_HEADER_NAME, HOT_UPDATER_INFRASTRUCTURE_GENERATION, HOT_UPDATER_SERVER_VERSION, createApiKey, createHandlers, createHotUpdater, createInsightsProvider, provisionApiKey, registerApiKey };
7
+ export { API_KEY_HEADER_NAME, HOT_UPDATER_INFRASTRUCTURE_GENERATION, HOT_UPDATER_SERVER_VERSION, HotUpdaterConfigError, createHotUpdater, createInsightsProvider };
@@ -1,5 +1,17 @@
1
1
  //#region src/insights/domain.d.ts
2
+ /**
3
+ * The body of `POST /events`. Fields the server does not know are ignored, so
4
+ * a newer client's report still records on an older server.
5
+ */
2
6
  type CreateBundleEventRequestBase = {
7
+ /**
8
+ * The report's idempotency key: a canonical lowercase UUIDv7 that the
9
+ * client creates once per report and repeats on every retry. The server
10
+ * stores the report under it, so a retried report counts once, and a
11
+ * report under an ID already stored changes nothing. Without it, the
12
+ * server creates the ID, and a retry counts as another report.
13
+ */
14
+ readonly eventId?: string;
3
15
  readonly installId: string;
4
16
  readonly toBundleId: string;
5
17
  readonly userId?: string;
@@ -1,5 +1,17 @@
1
1
  //#region src/insights/domain.d.ts
2
+ /**
3
+ * The body of `POST /events`. Fields the server does not know are ignored, so
4
+ * a newer client's report still records on an older server.
5
+ */
2
6
  type CreateBundleEventRequestBase = {
7
+ /**
8
+ * The report's idempotency key: a canonical lowercase UUIDv7 that the
9
+ * client creates once per report and repeats on every retry. The server
10
+ * stores the report under it, so a retried report counts once, and a
11
+ * report under an ID already stored changes nothing. Without it, the
12
+ * server creates the ID, and a retry counts as another report.
13
+ */
14
+ readonly eventId?: string;
3
15
  readonly installId: string;
4
16
  readonly toBundleId: string;
5
17
  readonly userId?: string;
@@ -1,3 +1,4 @@
1
+ const require_errors = require("../database/errors.cjs");
1
2
  //#region src/insights/errors.ts
2
3
  var InsightsBadRequestError = class extends Error {
3
4
  name = "InsightsBadRequestError";
@@ -10,6 +11,39 @@ var InsightsPayloadTooLargeError = class extends Error {
10
11
  this.maximumBytes = maximumBytes;
11
12
  }
12
13
  };
14
+ /** Error names the AWS SDKs give a throttled request, as their retry strategy classifies them. */
15
+ const THROTTLING_NAMES = /* @__PURE__ */ new Set([
16
+ "ProvisionedThroughputExceededException",
17
+ "RequestLimitExceeded",
18
+ "RequestThrottled",
19
+ "RequestThrottledException",
20
+ "SlowDown",
21
+ "ThrottledException",
22
+ "Throttling",
23
+ "ThrottlingException",
24
+ "TooManyRequestsException"
25
+ ]);
26
+ /** gRPC's RESOURCE_EXHAUSTED, the status Firestore throttles a request with. */
27
+ const RESOURCE_EXHAUSTED = 8;
28
+ /**
29
+ * Whether the database is busy rather than broken, so the same request can
30
+ * succeed later: a transaction ran out of retries, or the backend throttled
31
+ * a request. Writes already retry transient failures, throttled ones
32
+ * included, until the budget runs out. A throttled read throws the backend's
33
+ * own error, so it is recognized by what the backends call it: a name the
34
+ * AWS SDKs retry as throttling, HTTP 429, or gRPC's RESOURCE_EXHAUSTED.
35
+ */
36
+ const isDatabaseBusyError = (error) => {
37
+ if (error instanceof require_errors.DatabaseConflictError) return true;
38
+ if (typeof error !== "object" || error === null) return false;
39
+ const { name, code, message, status, statusCode, $metadata } = error;
40
+ return typeof name === "string" && THROTTLING_NAMES.has(name) || [
41
+ status,
42
+ statusCode,
43
+ $metadata?.httpStatusCode
44
+ ].includes(429) || code === RESOURCE_EXHAUSTED && typeof message === "string" && message.includes("RESOURCE_EXHAUSTED");
45
+ };
13
46
  //#endregion
14
47
  exports.InsightsBadRequestError = InsightsBadRequestError;
15
48
  exports.InsightsPayloadTooLargeError = InsightsPayloadTooLargeError;
49
+ exports.isDatabaseBusyError = isDatabaseBusyError;
@@ -1,3 +1,4 @@
1
+ import { DatabaseConflictError } from "../database/errors.mjs";
1
2
  //#region src/insights/errors.ts
2
3
  var InsightsBadRequestError = class extends Error {
3
4
  name = "InsightsBadRequestError";
@@ -10,5 +11,37 @@ var InsightsPayloadTooLargeError = class extends Error {
10
11
  this.maximumBytes = maximumBytes;
11
12
  }
12
13
  };
14
+ /** Error names the AWS SDKs give a throttled request, as their retry strategy classifies them. */
15
+ const THROTTLING_NAMES = /* @__PURE__ */ new Set([
16
+ "ProvisionedThroughputExceededException",
17
+ "RequestLimitExceeded",
18
+ "RequestThrottled",
19
+ "RequestThrottledException",
20
+ "SlowDown",
21
+ "ThrottledException",
22
+ "Throttling",
23
+ "ThrottlingException",
24
+ "TooManyRequestsException"
25
+ ]);
26
+ /** gRPC's RESOURCE_EXHAUSTED, the status Firestore throttles a request with. */
27
+ const RESOURCE_EXHAUSTED = 8;
28
+ /**
29
+ * Whether the database is busy rather than broken, so the same request can
30
+ * succeed later: a transaction ran out of retries, or the backend throttled
31
+ * a request. Writes already retry transient failures, throttled ones
32
+ * included, until the budget runs out. A throttled read throws the backend's
33
+ * own error, so it is recognized by what the backends call it: a name the
34
+ * AWS SDKs retry as throttling, HTTP 429, or gRPC's RESOURCE_EXHAUSTED.
35
+ */
36
+ const isDatabaseBusyError = (error) => {
37
+ if (error instanceof DatabaseConflictError) return true;
38
+ if (typeof error !== "object" || error === null) return false;
39
+ const { name, code, message, status, statusCode, $metadata } = error;
40
+ return typeof name === "string" && THROTTLING_NAMES.has(name) || [
41
+ status,
42
+ statusCode,
43
+ $metadata?.httpStatusCode
44
+ ].includes(429) || code === RESOURCE_EXHAUSTED && typeof message === "string" && message.includes("RESOURCE_EXHAUSTED");
45
+ };
13
46
  //#endregion
14
- export { InsightsBadRequestError, InsightsPayloadTooLargeError };
47
+ export { InsightsBadRequestError, InsightsPayloadTooLargeError, isDatabaseBusyError };
@@ -4,23 +4,6 @@ let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
4
4
  const MAX_EVENT_STRING_LENGTH = 1024;
5
5
  const MAX_IDENTITY_LENGTH = 255;
6
6
  const EVENT_BODY_MAX_BYTES = 16384;
7
- const eventKeys = /* @__PURE__ */ new Set([
8
- "type",
9
- "installId",
10
- "toBundleId",
11
- "userId",
12
- "username",
13
- "platform",
14
- "appVersion",
15
- "channel",
16
- "cohort",
17
- "fingerprintHash",
18
- "fromBundleId",
19
- "fromReleaseId",
20
- "toReleaseId",
21
- "updateStrategy",
22
- "sdkVersion"
23
- ]);
24
7
  function isRecord(value) {
25
8
  return typeof value === "object" && value !== null && !Array.isArray(value);
26
9
  }
@@ -38,6 +21,16 @@ function requireIdentityField(payload, key) {
38
21
  if (value.length > MAX_IDENTITY_LENGTH) throw new require_errors.InsightsBadRequestError(`Invalid event field: ${key}`);
39
22
  return value;
40
23
  }
24
+ /**
25
+ * The report's idempotency key, when the client sends one: it creates the
26
+ * UUIDv7 once and repeats it on every retry of that report.
27
+ */
28
+ function readEventId(payload) {
29
+ const value = payload.eventId;
30
+ if (value === void 0) return void 0;
31
+ if (!(0, _hot_updater_plugin_core.isUUIDv7)(value)) throw new require_errors.InsightsBadRequestError("Invalid event field: eventId");
32
+ return value;
33
+ }
41
34
  async function readBoundedText(request) {
42
35
  const contentLength = request.headers.get("content-length");
43
36
  const declaredByteLength = Number(contentLength);
@@ -69,10 +62,12 @@ async function parseJson(request) {
69
62
  }
70
63
  }
71
64
  function requireEvent(payload) {
72
- if (!isRecord(payload) || Object.keys(payload).some((key) => !eventKeys.has(key))) throw new require_errors.InsightsBadRequestError("Invalid event payload");
65
+ if (!isRecord(payload)) throw new require_errors.InsightsBadRequestError("Invalid event payload");
73
66
  const platform = requireStringField(payload, "platform");
74
67
  if (platform !== "ios" && platform !== "android") throw new require_errors.InsightsBadRequestError("Invalid event field: platform");
68
+ const eventId = readEventId(payload);
75
69
  const base = {
70
+ ...eventId === void 0 ? {} : { eventId },
76
71
  installId: requireIdentityField(payload, "installId"),
77
72
  toBundleId: requireStringField(payload, "toBundleId"),
78
73
  ...payload.userId === void 0 ? {} : { userId: requireIdentityField(payload, "userId") },
@@ -120,7 +115,7 @@ function createBundleEventRow(input) {
120
115
  app_version: input.appVersion,
121
116
  channel: input.channel,
122
117
  from_release_id: input.fromReleaseId,
123
- id: (0, _hot_updater_plugin_core.createUUIDv7)(),
118
+ id: input.eventId ?? (0, _hot_updater_plugin_core.createUUIDv7)(),
124
119
  install_id: input.installId,
125
120
  platform: input.platform,
126
121
  received_at_ms: Date.now(),
@@ -1,26 +1,9 @@
1
1
  import { InsightsBadRequestError, InsightsPayloadTooLargeError } from "./errors.mjs";
2
- import { createUUIDv7 } from "@hot-updater/plugin-core";
2
+ import { createUUIDv7, isUUIDv7 } from "@hot-updater/plugin-core";
3
3
  //#region src/insights/eventInput.ts
4
4
  const MAX_EVENT_STRING_LENGTH = 1024;
5
5
  const MAX_IDENTITY_LENGTH = 255;
6
6
  const EVENT_BODY_MAX_BYTES = 16384;
7
- const eventKeys = /* @__PURE__ */ new Set([
8
- "type",
9
- "installId",
10
- "toBundleId",
11
- "userId",
12
- "username",
13
- "platform",
14
- "appVersion",
15
- "channel",
16
- "cohort",
17
- "fingerprintHash",
18
- "fromBundleId",
19
- "fromReleaseId",
20
- "toReleaseId",
21
- "updateStrategy",
22
- "sdkVersion"
23
- ]);
24
7
  function isRecord(value) {
25
8
  return typeof value === "object" && value !== null && !Array.isArray(value);
26
9
  }
@@ -38,6 +21,16 @@ function requireIdentityField(payload, key) {
38
21
  if (value.length > MAX_IDENTITY_LENGTH) throw new InsightsBadRequestError(`Invalid event field: ${key}`);
39
22
  return value;
40
23
  }
24
+ /**
25
+ * The report's idempotency key, when the client sends one: it creates the
26
+ * UUIDv7 once and repeats it on every retry of that report.
27
+ */
28
+ function readEventId(payload) {
29
+ const value = payload.eventId;
30
+ if (value === void 0) return void 0;
31
+ if (!isUUIDv7(value)) throw new InsightsBadRequestError("Invalid event field: eventId");
32
+ return value;
33
+ }
41
34
  async function readBoundedText(request) {
42
35
  const contentLength = request.headers.get("content-length");
43
36
  const declaredByteLength = Number(contentLength);
@@ -69,10 +62,12 @@ async function parseJson(request) {
69
62
  }
70
63
  }
71
64
  function requireEvent(payload) {
72
- if (!isRecord(payload) || Object.keys(payload).some((key) => !eventKeys.has(key))) throw new InsightsBadRequestError("Invalid event payload");
65
+ if (!isRecord(payload)) throw new InsightsBadRequestError("Invalid event payload");
73
66
  const platform = requireStringField(payload, "platform");
74
67
  if (platform !== "ios" && platform !== "android") throw new InsightsBadRequestError("Invalid event field: platform");
68
+ const eventId = readEventId(payload);
75
69
  const base = {
70
+ ...eventId === void 0 ? {} : { eventId },
76
71
  installId: requireIdentityField(payload, "installId"),
77
72
  toBundleId: requireStringField(payload, "toBundleId"),
78
73
  ...payload.userId === void 0 ? {} : { userId: requireIdentityField(payload, "userId") },
@@ -120,7 +115,7 @@ function createBundleEventRow(input) {
120
115
  app_version: input.appVersion,
121
116
  channel: input.channel,
122
117
  from_release_id: input.fromReleaseId,
123
- id: createUUIDv7(),
118
+ id: input.eventId ?? createUUIDv7(),
124
119
  install_id: input.installId,
125
120
  platform: input.platform,
126
121
  received_at_ms: Date.now(),
@@ -7,11 +7,20 @@ const MAX_PAGE_LIMIT = 100;
7
7
  const MAX_EVENT_ID_LENGTH = 1024;
8
8
  const MAX_IDENTITY_LENGTH = 255;
9
9
  const MAX_CURSOR_LENGTH = 8192;
10
+ const HOUR_MS = 36e5;
10
11
  const WINDOW_MS = {
11
12
  "24h": 864e5,
12
13
  "7d": 6048e5,
13
14
  "30d": 2592e6
14
15
  };
16
+ /**
17
+ * The longest receipt range, `[sinceMs, beforeReceivedAtMs)`, of a global or
18
+ * bundle event list, and the range one covers without `sinceMs`: raw events
19
+ * are listed inside a time range, as analytics products list them. It is a
20
+ * duration, so a range that ends mid-day touches 91 UTC days. Installation
21
+ * history is one index range and reads back to `sinceMs`.
22
+ */
23
+ const EVENT_LIST_RANGE_MS = 2160 * HOUR_MS;
15
24
  const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
16
25
  const requireString = (value, label, maximumLength) => {
17
26
  if (typeof value !== "string" || value.length === 0 || value.length > maximumLength || new TextDecoder("utf-8", { ignoreBOM: true }).decode(new TextEncoder().encode(value)) !== value) throw new require_errors.InsightsBadRequestError(`Invalid ${label}.`);
@@ -160,36 +169,50 @@ const toInstallationRow = (row) => ({
160
169
  userId: row.user_id,
161
170
  username: row.metadata.username
162
171
  });
172
+ /**
173
+ * Where a list without `sinceMs` starts: 90 days before its cutoff for the
174
+ * global and bundle lists, at the first event for installation history.
175
+ */
176
+ const defaultEventStart = (filter, beforeReceivedAtMs) => filter.kind === "installationMovement" ? 0 : Math.max(0, beforeReceivedAtMs - EVENT_LIST_RANGE_MS);
177
+ /** Whether a cursor's row lies inside the list's range. */
178
+ const isInsideBounds = ({ after }, bounds) => after.receivedAtMs >= bounds.sinceMs && after.receivedAtMs < bounds.beforeReceivedAtMs;
179
+ /** A page's range: its cursor's, which the request may repeat but not change. */
180
+ const readEventBounds = (input, cursor, filter) => {
181
+ const beforeReceivedAtMs = cursor?.beforeReceivedAtMs ?? (input.beforeReceivedAtMs === void 0 ? Date.now() : requireTimestamp(input.beforeReceivedAtMs, "event cutoff"));
182
+ if (cursor !== void 0 && input.beforeReceivedAtMs !== void 0 && input.beforeReceivedAtMs !== beforeReceivedAtMs) throw new require_errors.InsightsBadRequestError("Insights cursor does not match the requested event cutoff.");
183
+ const sinceMs = cursor?.sinceMs ?? (input.sinceMs === void 0 ? defaultEventStart(filter, beforeReceivedAtMs) : requireTimestamp(input.sinceMs, "event start"));
184
+ const bounds = {
185
+ beforeReceivedAtMs,
186
+ sinceMs
187
+ };
188
+ if (sinceMs > beforeReceivedAtMs || input.sinceMs !== void 0 && input.sinceMs !== sinceMs || cursor !== void 0 && !isInsideBounds(cursor, bounds)) throw new require_errors.InsightsBadRequestError("Insights cursor or range does not match the requested event start.");
189
+ if (filter.kind !== "installationMovement" && beforeReceivedAtMs - sinceMs > 7776e6) throw new require_errors.InsightsBadRequestError("Insights event lists cover at most 90 days: send a sinceMs no more than 90 days before beforeReceivedAtMs.");
190
+ return bounds;
191
+ };
163
192
  const pageEventRows = async (model, input, filter, map) => {
164
193
  const limit = readLimit(input.limit);
165
194
  const cursor = input.cursor === void 0 ? void 0 : readEventCursor(input.cursor, filter);
166
- const beforeReceivedAtMs = cursor?.beforeReceivedAtMs ?? (input.beforeReceivedAtMs === void 0 ? Date.now() : requireTimestamp(input.beforeReceivedAtMs, "event cutoff"));
167
- if (cursor !== void 0 && input.beforeReceivedAtMs !== void 0 && input.beforeReceivedAtMs !== beforeReceivedAtMs) throw new require_errors.InsightsBadRequestError("Insights cursor does not match the requested event cutoff.");
168
- const sinceMs = cursor?.sinceMs ?? (input.sinceMs === void 0 ? 0 : requireTimestamp(input.sinceMs, "event start"));
169
- if (sinceMs > beforeReceivedAtMs || input.sinceMs !== void 0 && input.sinceMs !== sinceMs || cursor !== void 0 && (cursor.after.receivedAtMs < sinceMs || cursor.after.receivedAtMs >= beforeReceivedAtMs)) throw new require_errors.InsightsBadRequestError("Insights cursor or range does not match the requested event start.");
170
- const databaseInput = {
195
+ const bounds = readEventBounds(input, cursor, filter);
196
+ const query = {
171
197
  filter,
172
- sinceMs,
173
- beforeReceivedAtMs,
198
+ ...bounds,
174
199
  ...cursor === void 0 ? {} : { after: cursor.after },
175
- limit: limit + 1
200
+ limit
176
201
  };
177
- const rows = await model.listEvents(databaseInput);
178
- assertEventRows(rows, databaseInput);
179
- const pageRows = rows.slice(0, limit);
180
- const last = pageRows.at(-1);
202
+ const rows = await model.listEvents(query);
203
+ assertEventRows(rows, query);
204
+ const last = rows.at(-1);
181
205
  return {
182
- beforeReceivedAtMs,
183
- data: pageRows.map(map),
184
- nextCursor: rows.length > limit && last ? encodeCursor({
206
+ beforeReceivedAtMs: bounds.beforeReceivedAtMs,
207
+ data: rows.map(map),
208
+ nextCursor: rows.length === limit && last ? encodeCursor({
185
209
  after: {
186
210
  id: last.id,
187
211
  receivedAtMs: last.received_at_ms
188
212
  },
189
- beforeReceivedAtMs,
213
+ ...bounds,
190
214
  kind: "events",
191
215
  filter,
192
- sinceMs,
193
216
  version: 2
194
217
  }) : null
195
218
  };
@@ -236,15 +259,14 @@ const createInsightsProvider = (model) => Object.freeze({
236
259
  const databaseInput = {
237
260
  userId,
238
261
  ...cursor === void 0 ? {} : { afterInstallId: cursor.afterInstallId },
239
- limit: limit + 1
262
+ limit
240
263
  };
241
264
  const rows = await model.findLatestEvents(databaseInput);
242
265
  assertInstallationRows(rows, databaseInput);
243
- const pageRows = rows.slice(0, limit);
244
- const last = pageRows.at(-1);
266
+ const last = rows.at(-1);
245
267
  return {
246
- data: pageRows.map(toInstallationRow),
247
- nextCursor: rows.length > limit && last ? encodeCursor({
268
+ data: rows.map(toInstallationRow),
269
+ nextCursor: rows.length === limit && last ? encodeCursor({
248
270
  afterInstallId: last.install_id,
249
271
  kind: "user-installations",
250
272
  userId,
@@ -256,7 +278,8 @@ const createInsightsProvider = (model) => Object.freeze({
256
278
  const scope = readScope(input);
257
279
  const { window } = input;
258
280
  if (!Object.hasOwn(WINDOW_MS, window)) throw new require_errors.InsightsBadRequestError("Invalid reporting installation window.");
259
- const beforeReceivedAtMs = Date.now();
281
+ const now = Date.now();
282
+ const beforeReceivedAtMs = now - now % HOUR_MS + (now % HOUR_MS === 0 ? 0 : HOUR_MS);
260
283
  const sinceMs = Math.max(0, beforeReceivedAtMs - WINDOW_MS[window]);
261
284
  const measure = async (count) => {
262
285
  const value = await count;
@@ -329,4 +352,5 @@ const createInsightsProvider = (model) => Object.freeze({
329
352
  }
330
353
  });
331
354
  //#endregion
355
+ exports.EVENT_LIST_RANGE_MS = EVENT_LIST_RANGE_MS;
332
356
  exports.createInsightsProvider = createInsightsProvider;