@hot-updater/server 0.30.12 → 0.31.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +25 -0
  2. package/dist/_virtual/_rolldown/runtime.mjs +6 -0
  3. package/dist/adapters/drizzle.cjs +6 -9
  4. package/dist/adapters/drizzle.d.cts +8 -1
  5. package/dist/adapters/drizzle.d.mts +8 -1
  6. package/dist/adapters/drizzle.mjs +5 -2
  7. package/dist/adapters/kysely.cjs +7 -9
  8. package/dist/adapters/kysely.d.cts +14 -1
  9. package/dist/adapters/kysely.d.mts +14 -1
  10. package/dist/adapters/kysely.mjs +6 -2
  11. package/dist/adapters/mongodb.cjs +7 -9
  12. package/dist/adapters/mongodb.d.cts +9 -1
  13. package/dist/adapters/mongodb.d.mts +9 -1
  14. package/dist/adapters/mongodb.mjs +5 -2
  15. package/dist/adapters/prisma.cjs +6 -9
  16. package/dist/adapters/prisma.d.cts +8 -1
  17. package/dist/adapters/prisma.d.mts +8 -1
  18. package/dist/adapters/prisma.mjs +5 -2
  19. package/dist/db/createBundleDiff.cjs +166 -0
  20. package/dist/db/createBundleDiff.d.cts +20 -0
  21. package/dist/db/createBundleDiff.d.mts +20 -0
  22. package/dist/db/createBundleDiff.mjs +161 -0
  23. package/dist/db/index.cjs +15 -16
  24. package/dist/db/index.d.cts +5 -4
  25. package/dist/db/index.d.mts +5 -4
  26. package/dist/db/index.mjs +14 -16
  27. package/dist/db/ormCore.cjs +173 -65
  28. package/dist/db/ormCore.d.cts +100 -34
  29. package/dist/db/ormCore.d.mts +100 -34
  30. package/dist/db/ormCore.mjs +171 -64
  31. package/dist/db/pluginCore.cjs +37 -3
  32. package/dist/db/pluginCore.mjs +36 -3
  33. package/dist/db/schemaEnhancements.cjs +171 -0
  34. package/dist/db/schemaEnhancements.mjs +167 -0
  35. package/dist/db/types.cjs +6 -0
  36. package/dist/db/types.d.cts +19 -7
  37. package/dist/db/types.d.mts +22 -10
  38. package/dist/db/types.mjs +6 -1
  39. package/dist/db/updateArtifacts.cjs +127 -0
  40. package/dist/db/updateArtifacts.mjs +125 -0
  41. package/dist/handler.cjs +61 -5
  42. package/dist/handler.d.cts +2 -2
  43. package/dist/handler.d.mts +5 -5
  44. package/dist/handler.mjs +59 -5
  45. package/dist/index.cjs +2 -0
  46. package/dist/index.d.cts +3 -2
  47. package/dist/index.d.mts +3 -2
  48. package/dist/index.mjs +2 -1
  49. package/dist/node.d.cts +0 -1
  50. package/dist/node.d.mts +0 -1
  51. package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/_u64.cjs +112 -0
  52. package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/_u64.mjs +108 -0
  53. package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/cryptoNode.cjs +22 -0
  54. package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/cryptoNode.mjs +18 -0
  55. package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/sha3.cjs +219 -0
  56. package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/sha3.mjs +214 -0
  57. package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/utils.cjs +275 -0
  58. package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/utils.mjs +270 -0
  59. package/dist/node_modules/.pnpm/@paralleldrive_cuid2@2.3.1/node_modules/@paralleldrive/cuid2/index.cjs +17 -0
  60. package/dist/node_modules/.pnpm/@paralleldrive_cuid2@2.3.1/node_modules/@paralleldrive/cuid2/index.mjs +13 -0
  61. package/dist/node_modules/.pnpm/@paralleldrive_cuid2@2.3.1/node_modules/@paralleldrive/cuid2/src/index.cjs +69 -0
  62. package/dist/node_modules/.pnpm/@paralleldrive_cuid2@2.3.1/node_modules/@paralleldrive/cuid2/src/index.mjs +65 -0
  63. package/dist/node_modules/.pnpm/drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pglite@0.2.17_@_31f44b782f9321d71f3ce9d35aa1edf7/node_modules/drizzle-orm/column.cjs +52 -0
  64. package/dist/node_modules/.pnpm/drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pglite@0.2.17_@_31f44b782f9321d71f3ce9d35aa1edf7/node_modules/drizzle-orm/column.mjs +52 -0
  65. package/dist/node_modules/.pnpm/drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pglite@0.2.17_@_31f44b782f9321d71f3ce9d35aa1edf7/node_modules/drizzle-orm/entity.cjs +16 -0
  66. package/dist/node_modules/.pnpm/drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pglite@0.2.17_@_31f44b782f9321d71f3ce9d35aa1edf7/node_modules/drizzle-orm/entity.mjs +15 -0
  67. package/dist/node_modules/.pnpm/drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pglite@0.2.17_@_31f44b782f9321d71f3ce9d35aa1edf7/node_modules/drizzle-orm/pg-core/columns/enum.cjs +7 -0
  68. package/dist/node_modules/.pnpm/drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pglite@0.2.17_@_31f44b782f9321d71f3ce9d35aa1edf7/node_modules/drizzle-orm/pg-core/columns/enum.mjs +7 -0
  69. package/dist/node_modules/.pnpm/drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pglite@0.2.17_@_31f44b782f9321d71f3ce9d35aa1edf7/node_modules/drizzle-orm/sql/expressions/conditions.cjs +92 -0
  70. package/dist/node_modules/.pnpm/drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pglite@0.2.17_@_31f44b782f9321d71f3ce9d35aa1edf7/node_modules/drizzle-orm/sql/expressions/conditions.mjs +78 -0
  71. package/dist/node_modules/.pnpm/drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pglite@0.2.17_@_31f44b782f9321d71f3ce9d35aa1edf7/node_modules/drizzle-orm/sql/expressions/select.cjs +11 -0
  72. package/dist/node_modules/.pnpm/drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pglite@0.2.17_@_31f44b782f9321d71f3ce9d35aa1edf7/node_modules/drizzle-orm/sql/expressions/select.mjs +10 -0
  73. package/dist/node_modules/.pnpm/drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pglite@0.2.17_@_31f44b782f9321d71f3ce9d35aa1edf7/node_modules/drizzle-orm/sql/sql.cjs +383 -0
  74. package/dist/node_modules/.pnpm/drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pglite@0.2.17_@_31f44b782f9321d71f3ce9d35aa1edf7/node_modules/drizzle-orm/sql/sql.mjs +366 -0
  75. package/dist/node_modules/.pnpm/drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pglite@0.2.17_@_31f44b782f9321d71f3ce9d35aa1edf7/node_modules/drizzle-orm/subquery.cjs +17 -0
  76. package/dist/node_modules/.pnpm/drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pglite@0.2.17_@_31f44b782f9321d71f3ce9d35aa1edf7/node_modules/drizzle-orm/subquery.mjs +17 -0
  77. package/dist/node_modules/.pnpm/drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pglite@0.2.17_@_31f44b782f9321d71f3ce9d35aa1edf7/node_modules/drizzle-orm/table.cjs +60 -0
  78. package/dist/node_modules/.pnpm/drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pglite@0.2.17_@_31f44b782f9321d71f3ce9d35aa1edf7/node_modules/drizzle-orm/table.mjs +59 -0
  79. package/dist/node_modules/.pnpm/drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pglite@0.2.17_@_31f44b782f9321d71f3ce9d35aa1edf7/node_modules/drizzle-orm/table.utils.cjs +4 -0
  80. package/dist/node_modules/.pnpm/drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pglite@0.2.17_@_31f44b782f9321d71f3ce9d35aa1edf7/node_modules/drizzle-orm/table.utils.mjs +4 -0
  81. package/dist/node_modules/.pnpm/drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pglite@0.2.17_@_31f44b782f9321d71f3ce9d35aa1edf7/node_modules/drizzle-orm/tracing.cjs +6 -0
  82. package/dist/node_modules/.pnpm/drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pglite@0.2.17_@_31f44b782f9321d71f3ce9d35aa1edf7/node_modules/drizzle-orm/tracing.mjs +6 -0
  83. package/dist/node_modules/.pnpm/drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pglite@0.2.17_@_31f44b782f9321d71f3ce9d35aa1edf7/node_modules/drizzle-orm/view-common.cjs +4 -0
  84. package/dist/node_modules/.pnpm/drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pglite@0.2.17_@_31f44b782f9321d71f3ce9d35aa1edf7/node_modules/drizzle-orm/view-common.mjs +4 -0
  85. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/adapters/drizzle/index.cjs +383 -0
  86. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/adapters/drizzle/index.d.cts +12 -0
  87. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/adapters/drizzle/index.d.mts +12 -0
  88. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/adapters/drizzle/index.mjs +383 -0
  89. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/adapters/kysely/index.cjs +4 -0
  90. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/adapters/kysely/index.mjs +5 -0
  91. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/adapters/prisma/index.cjs +339 -0
  92. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/adapters/prisma/index.d.cts +70 -0
  93. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/adapters/prisma/index.d.mts +70 -0
  94. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/adapters/prisma/index.mjs +339 -0
  95. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/chunk-7PZK4ONR.cjs +57 -0
  96. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/chunk-7PZK4ONR.mjs +56 -0
  97. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/chunk-C6OTUURW.cjs +330 -0
  98. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/chunk-C6OTUURW.mjs +326 -0
  99. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/chunk-CHTIKPQU.cjs +166 -0
  100. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/chunk-CHTIKPQU.mjs +163 -0
  101. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/chunk-GUE4GMNC.cjs +14 -0
  102. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/chunk-GUE4GMNC.mjs +13 -0
  103. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/chunk-LHHP6UVP.cjs +24 -0
  104. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/chunk-LHHP6UVP.mjs +24 -0
  105. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/chunk-LVCPMTAT.cjs +1190 -0
  106. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/chunk-LVCPMTAT.mjs +1189 -0
  107. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/chunk-PK2W2SQ7.cjs +197 -0
  108. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/chunk-PK2W2SQ7.mjs +197 -0
  109. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/chunk-ZEQMAIFI.cjs +410 -0
  110. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/chunk-ZEQMAIFI.mjs +400 -0
  111. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/chunk-ZOCGSAWS.cjs +213 -0
  112. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/chunk-ZOCGSAWS.mjs +212 -0
  113. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/create-tg0451Y_.d.cts +285 -0
  114. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/create-tg0451Y_.d.mts +285 -0
  115. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/index-CMqePMTF.d.cts +45 -0
  116. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/index-CMqePMTF.d.mts +45 -0
  117. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/index.cjs +69 -0
  118. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/index.d.cts +49 -0
  119. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/index.d.mts +49 -0
  120. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/index.mjs +67 -0
  121. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/query/index.d.cts +156 -0
  122. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/query/index.d.mts +156 -0
  123. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/schema/index.cjs +1 -0
  124. package/dist/node_modules/.pnpm/fumadb@0.2.2_drizzle-orm@0.44.7_@cloudflare_workers-types@4.20260313.1_@electric-sql_pg_c72c8c754becd21f6d6662e8fbd28e7f/node_modules/fumadb/dist/schema/index.mjs +2 -0
  125. package/dist/{package.cjs → packages/server/package.cjs} +1 -1
  126. package/dist/{package.mjs → packages/server/package.mjs} +1 -1
  127. package/dist/runtime.cjs +13 -13
  128. package/dist/runtime.d.cts +4 -4
  129. package/dist/runtime.d.mts +4 -4
  130. package/dist/runtime.mjs +12 -13
  131. package/dist/schema/v0_21_0.cjs +16 -15
  132. package/dist/schema/v0_21_0.mjs +3 -2
  133. package/dist/schema/v0_29_0.cjs +18 -17
  134. package/dist/schema/v0_29_0.mjs +3 -2
  135. package/dist/schema/v0_31_0.cjs +48 -0
  136. package/dist/schema/v0_31_0.mjs +48 -0
  137. package/dist/storageAccess.cjs +44 -0
  138. package/dist/storageAccess.mjs +44 -0
  139. package/dist/version.cjs +1 -1
  140. package/dist/version.mjs +1 -1
  141. package/package.json +15 -7
  142. package/src/adapters/drizzle.ts +15 -1
  143. package/src/adapters/kysely.ts +24 -1
  144. package/src/adapters/mongodb.ts +19 -1
  145. package/src/adapters/prisma.ts +15 -1
  146. package/src/db/createBundleDiff.spec.ts +402 -0
  147. package/src/db/createBundleDiff.ts +375 -0
  148. package/src/db/index.spec.ts +528 -27
  149. package/src/db/index.ts +22 -36
  150. package/src/db/ormCore.ts +308 -75
  151. package/src/db/pluginCore.spec.ts +385 -0
  152. package/src/db/pluginCore.ts +45 -4
  153. package/src/db/schemaEnhancements.ts +460 -0
  154. package/src/db/types.ts +38 -7
  155. package/src/db/updateArtifacts.ts +388 -0
  156. package/src/handler-standalone.integration.spec.ts +1 -0
  157. package/src/handler.spec.ts +121 -0
  158. package/src/handler.ts +117 -5
  159. package/src/runtime.spec.ts +287 -55
  160. package/src/runtime.ts +21 -37
  161. package/src/schema/v0_21_0.ts +1 -1
  162. package/src/schema/v0_29_0.ts +1 -1
  163. package/src/schema/v0_31_0.ts +58 -0
  164. package/src/storageAccess.spec.ts +57 -0
  165. package/src/storageAccess.ts +90 -0
@@ -0,0 +1,375 @@
1
+ import crypto, { randomUUID } from "node:crypto";
2
+ import fs from "node:fs/promises";
3
+ import os from "node:os";
4
+ import path from "node:path";
5
+ import { promisify } from "node:util";
6
+ import { brotliDecompress } from "node:zlib";
7
+
8
+ import { hdiff } from "@hot-updater/bsdiff";
9
+ import {
10
+ getAssetBaseStorageUri,
11
+ getBundlePatch,
12
+ getBundlePatches,
13
+ getManifestStorageUri,
14
+ } from "@hot-updater/core";
15
+ import type {
16
+ Bundle,
17
+ DatabasePlugin,
18
+ NodeStoragePlugin,
19
+ } from "@hot-updater/plugin-core";
20
+
21
+ type BundleManifest = {
22
+ bundleId: string;
23
+ assets: Record<string, { fileHash: string; signature?: string }>;
24
+ };
25
+
26
+ export interface CreateBundleDiffInput {
27
+ baseBundleId: string;
28
+ bundleId: string;
29
+ }
30
+
31
+ export interface CreateBundleDiffDependencies {
32
+ databasePlugin: DatabasePlugin;
33
+ storagePlugin: NodeStoragePlugin | null;
34
+ }
35
+
36
+ export interface CreateBundleDiffOptions {
37
+ makePrimary?: boolean;
38
+ }
39
+
40
+ const HBC_ASSET_PATH_RE = /\.bundle$/;
41
+ const BR_COMPRESSED_ASSET_PATH_RE = /(^|\/)index\.[^/]+\.bundle$/;
42
+ const HOT_UPDATER_DOWNLOAD_DIR_PREFIX = "downloads-";
43
+ const decompressBrotli = promisify(brotliDecompress);
44
+
45
+ const isBundleManifest = (value: unknown): value is BundleManifest => {
46
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
47
+ return false;
48
+ }
49
+
50
+ const manifest = value as {
51
+ bundleId?: unknown;
52
+ assets?: unknown;
53
+ };
54
+
55
+ if (typeof manifest.bundleId !== "string") {
56
+ return false;
57
+ }
58
+
59
+ if (!manifest.assets || typeof manifest.assets !== "object") {
60
+ return false;
61
+ }
62
+
63
+ return Object.values(manifest.assets as Record<string, unknown>).every(
64
+ (asset) => {
65
+ if (!asset || typeof asset !== "object" || Array.isArray(asset)) {
66
+ return false;
67
+ }
68
+
69
+ const manifestAsset = asset as {
70
+ fileHash?: unknown;
71
+ signature?: unknown;
72
+ };
73
+
74
+ return (
75
+ typeof manifestAsset.fileHash === "string" &&
76
+ (manifestAsset.signature === undefined ||
77
+ typeof manifestAsset.signature === "string")
78
+ );
79
+ },
80
+ );
81
+ };
82
+
83
+ const createChildStorageUri = (
84
+ baseStorageUri: string,
85
+ relativePath: string,
86
+ ) => {
87
+ const baseUrl = new URL(baseStorageUri);
88
+ const normalizedBasePath = baseUrl.pathname.replace(/\/+$/, "");
89
+ const relativeSegments = relativePath
90
+ .split("/")
91
+ .filter(Boolean)
92
+ .map((segment) => encodeURIComponent(segment));
93
+
94
+ baseUrl.pathname = `${normalizedBasePath}/${relativeSegments.join("/")}`;
95
+ return baseUrl.toString();
96
+ };
97
+
98
+ const getRelativeStorageDir = (relativePath: string) => {
99
+ const normalized = relativePath.replace(/\\/g, "/");
100
+ const dirname = path.posix.dirname(normalized);
101
+ return dirname === "." ? "" : dirname;
102
+ };
103
+
104
+ async function downloadFromUrl(url: string) {
105
+ const response = await fetch(url);
106
+ if (!response.ok) {
107
+ throw new Error(`Failed to download storage object: ${response.status}`);
108
+ }
109
+
110
+ return new Uint8Array(await response.arrayBuffer());
111
+ }
112
+
113
+ async function downloadStorageBytes(
114
+ storageUri: string,
115
+ storagePlugin: NodeStoragePlugin | null,
116
+ ) {
117
+ const protocol = new URL(storageUri).protocol.replace(":", "");
118
+
119
+ if (protocol === "http" || protocol === "https") {
120
+ return downloadFromUrl(storageUri);
121
+ }
122
+
123
+ if (!storagePlugin) {
124
+ throw new Error("Storage plugin is not configured");
125
+ }
126
+
127
+ if (storagePlugin.supportedProtocol !== protocol) {
128
+ throw new Error(`No storage plugin for protocol: ${protocol}`);
129
+ }
130
+
131
+ const downloadRoot = path.join(process.cwd(), ".hot-updater");
132
+ await fs.mkdir(downloadRoot, { recursive: true });
133
+ const workDir = await fs.mkdtemp(
134
+ path.join(downloadRoot, HOT_UPDATER_DOWNLOAD_DIR_PREFIX),
135
+ );
136
+ const filename = path.basename(new URL(storageUri).pathname) || randomUUID();
137
+ const filePath = path.join(workDir, filename);
138
+
139
+ try {
140
+ await storagePlugin.profiles.node.downloadFile(storageUri, filePath);
141
+ return new Uint8Array(await fs.readFile(filePath));
142
+ } finally {
143
+ await fs.rm(workDir, { force: true, recursive: true });
144
+ }
145
+ }
146
+
147
+ async function fetchManifest(
148
+ bundle: Bundle,
149
+ storagePlugin: NodeStoragePlugin | null,
150
+ ): Promise<BundleManifest> {
151
+ const manifestStorageUri = getManifestStorageUri(bundle);
152
+ if (!manifestStorageUri) {
153
+ throw new Error(`Bundle ${bundle.id} does not have manifest metadata`);
154
+ }
155
+
156
+ const manifestBytes = await downloadStorageBytes(
157
+ manifestStorageUri,
158
+ storagePlugin,
159
+ );
160
+
161
+ const payload = JSON.parse(
162
+ new TextDecoder().decode(manifestBytes),
163
+ ) as unknown;
164
+ if (!isBundleManifest(payload)) {
165
+ throw new Error(`Invalid manifest payload for bundle ${bundle.id}`);
166
+ }
167
+
168
+ return payload;
169
+ }
170
+
171
+ function resolveHbcAssetPath(manifest: BundleManifest) {
172
+ const candidates = Object.keys(manifest.assets)
173
+ .sort((left, right) => left.localeCompare(right))
174
+ .filter((candidate) => HBC_ASSET_PATH_RE.test(candidate));
175
+
176
+ if (candidates.length === 0) {
177
+ throw new Error("No Hermes bundle asset found in manifest");
178
+ }
179
+ if (candidates.length > 1) {
180
+ throw new Error(
181
+ `Expected exactly one Hermes bundle asset in manifest, found ${candidates.length}: ${candidates.join(", ")}`,
182
+ );
183
+ }
184
+
185
+ return candidates[0];
186
+ }
187
+
188
+ async function fetchAssetBytes(
189
+ bundle: Bundle,
190
+ assetPath: string,
191
+ storagePlugin: NodeStoragePlugin | null,
192
+ ) {
193
+ const assetBaseStorageUri = getAssetBaseStorageUri(bundle);
194
+ if (!assetBaseStorageUri) {
195
+ throw new Error(`Bundle ${bundle.id} does not have asset storage metadata`);
196
+ }
197
+
198
+ if (BR_COMPRESSED_ASSET_PATH_RE.test(assetPath)) {
199
+ const compressedAssetStorageUri = createChildStorageUri(
200
+ assetBaseStorageUri,
201
+ `${assetPath}.br`,
202
+ );
203
+
204
+ let compressedBytes: Uint8Array | null = null;
205
+ try {
206
+ compressedBytes = await downloadStorageBytes(
207
+ compressedAssetStorageUri,
208
+ storagePlugin,
209
+ );
210
+ } catch {
211
+ // Older deployments stored manifest assets uncompressed.
212
+ }
213
+
214
+ if (compressedBytes) {
215
+ return new Uint8Array(await decompressBrotli(compressedBytes));
216
+ }
217
+ }
218
+
219
+ const assetStorageUri = createChildStorageUri(assetBaseStorageUri, assetPath);
220
+ return downloadStorageBytes(assetStorageUri, storagePlugin);
221
+ }
222
+
223
+ async function getFileHash(filePath: string) {
224
+ const file = await fs.readFile(filePath);
225
+ return crypto.createHash("sha256").update(file).digest("hex");
226
+ }
227
+
228
+ function buildNextPatchState({
229
+ currentBundle,
230
+ nextPatch,
231
+ makePrimary,
232
+ }: {
233
+ currentBundle: Bundle;
234
+ nextPatch: NonNullable<ReturnType<typeof getBundlePatch>>;
235
+ makePrimary: boolean;
236
+ }) {
237
+ const existingPatches = getBundlePatches(currentBundle).filter(
238
+ (patch) => patch.baseBundleId !== nextPatch.baseBundleId,
239
+ );
240
+ const orderedPatches = makePrimary
241
+ ? [nextPatch, ...existingPatches]
242
+ : [...existingPatches, nextPatch];
243
+ const primaryPatch = orderedPatches[0] ?? nextPatch;
244
+
245
+ return {
246
+ patches: orderedPatches,
247
+ primaryPatch,
248
+ };
249
+ }
250
+
251
+ export async function createBundleDiff(
252
+ { baseBundleId, bundleId }: CreateBundleDiffInput,
253
+ deps: CreateBundleDiffDependencies,
254
+ options: CreateBundleDiffOptions = {},
255
+ ) {
256
+ if (!deps.storagePlugin) {
257
+ throw new Error("Storage plugin is not configured");
258
+ }
259
+
260
+ if (baseBundleId === bundleId) {
261
+ throw new Error("Base bundle must be different from the target bundle");
262
+ }
263
+
264
+ const baseBundle = await deps.databasePlugin.getBundleById(baseBundleId);
265
+ const targetBundle = await deps.databasePlugin.getBundleById(bundleId);
266
+
267
+ if (!baseBundle || !targetBundle) {
268
+ throw new Error("Bundle not found");
269
+ }
270
+
271
+ if (baseBundle.platform !== targetBundle.platform) {
272
+ throw new Error("Base bundle platform must match the target bundle");
273
+ }
274
+
275
+ if (baseBundle.id.localeCompare(targetBundle.id) >= 0) {
276
+ throw new Error("Base bundle must be older than the target bundle");
277
+ }
278
+
279
+ const [baseManifest, targetManifest] = await Promise.all([
280
+ fetchManifest(baseBundle, deps.storagePlugin),
281
+ fetchManifest(targetBundle, deps.storagePlugin),
282
+ ]);
283
+
284
+ const baseAssetPath = resolveHbcAssetPath(baseManifest);
285
+ const targetAssetPath = resolveHbcAssetPath(targetManifest);
286
+
287
+ if (baseAssetPath !== targetAssetPath) {
288
+ throw new Error("Base and target Hermes asset paths do not match");
289
+ }
290
+
291
+ const baseAssetHash = baseManifest.assets[baseAssetPath]?.fileHash;
292
+ const targetAssetHash = targetManifest.assets[targetAssetPath]?.fileHash;
293
+
294
+ if (!baseAssetHash || !targetAssetHash) {
295
+ throw new Error("Hermes asset hash is missing from manifest");
296
+ }
297
+
298
+ if (baseAssetHash === targetAssetHash) {
299
+ throw new Error("Hermes bundle is unchanged; no diff patch is required");
300
+ }
301
+
302
+ const [baseBytes, targetBytes] = await Promise.all([
303
+ fetchAssetBytes(baseBundle, baseAssetPath, deps.storagePlugin),
304
+ fetchAssetBytes(targetBundle, targetAssetPath, deps.storagePlugin),
305
+ ]);
306
+
307
+ const patchBytes = await hdiff(baseBytes, targetBytes);
308
+ const workDir = await fs.mkdtemp(
309
+ path.join(os.tmpdir(), "hot-updater-console-bsdiff-"),
310
+ );
311
+ const patchFilename = `${path.posix.basename(targetAssetPath)}.bsdiff`;
312
+ const patchPath = path.join(workDir, patchFilename);
313
+ const previousPatch = getBundlePatch(targetBundle, baseBundle.id);
314
+
315
+ try {
316
+ await fs.writeFile(patchPath, patchBytes);
317
+
318
+ const uploadKey = [
319
+ targetBundle.id,
320
+ "patches",
321
+ baseBundle.id,
322
+ getRelativeStorageDir(targetAssetPath),
323
+ ]
324
+ .filter(Boolean)
325
+ .join("/");
326
+ const patchUpload = await deps.storagePlugin.profiles.node.upload(
327
+ uploadKey,
328
+ patchPath,
329
+ );
330
+ const patchFileHash = await getFileHash(patchPath);
331
+
332
+ const nextPatch = {
333
+ baseBundleId: baseBundle.id,
334
+ baseFileHash: baseAssetHash,
335
+ patchFileHash,
336
+ patchStorageUri: patchUpload.storageUri,
337
+ };
338
+ const nextState = buildNextPatchState({
339
+ currentBundle: targetBundle,
340
+ nextPatch,
341
+ makePrimary: options.makePrimary ?? true,
342
+ });
343
+
344
+ await deps.databasePlugin.updateBundle(targetBundle.id, {
345
+ patches: nextState.patches,
346
+ patchBaseBundleId: nextState.primaryPatch.baseBundleId,
347
+ patchBaseFileHash: nextState.primaryPatch.baseFileHash,
348
+ patchFileHash: nextState.primaryPatch.patchFileHash,
349
+ patchStorageUri: nextState.primaryPatch.patchStorageUri,
350
+ });
351
+ await deps.databasePlugin.commitBundle();
352
+
353
+ if (
354
+ previousPatch?.patchStorageUri &&
355
+ previousPatch.patchStorageUri !== patchUpload.storageUri
356
+ ) {
357
+ await deps.storagePlugin.profiles.node
358
+ .delete(previousPatch.patchStorageUri)
359
+ .catch(() => {
360
+ return;
361
+ });
362
+ }
363
+
364
+ const updatedBundle = await deps.databasePlugin.getBundleById(
365
+ targetBundle.id,
366
+ );
367
+ if (!updatedBundle) {
368
+ throw new Error("Updated bundle not found");
369
+ }
370
+
371
+ return updatedBundle;
372
+ } finally {
373
+ await fs.rm(workDir, { force: true, recursive: true });
374
+ }
375
+ }