@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.
- package/dist/_virtual/_rolldown/runtime.cjs +25 -0
- package/dist/_virtual/_rolldown/runtime.mjs +6 -0
- package/dist/adapters/drizzle.cjs +6 -9
- package/dist/adapters/drizzle.d.cts +8 -1
- package/dist/adapters/drizzle.d.mts +8 -1
- package/dist/adapters/drizzle.mjs +5 -2
- package/dist/adapters/kysely.cjs +7 -9
- package/dist/adapters/kysely.d.cts +14 -1
- package/dist/adapters/kysely.d.mts +14 -1
- package/dist/adapters/kysely.mjs +6 -2
- package/dist/adapters/mongodb.cjs +7 -9
- package/dist/adapters/mongodb.d.cts +9 -1
- package/dist/adapters/mongodb.d.mts +9 -1
- package/dist/adapters/mongodb.mjs +5 -2
- package/dist/adapters/prisma.cjs +6 -9
- package/dist/adapters/prisma.d.cts +8 -1
- package/dist/adapters/prisma.d.mts +8 -1
- package/dist/adapters/prisma.mjs +5 -2
- package/dist/db/createBundleDiff.cjs +166 -0
- package/dist/db/createBundleDiff.d.cts +20 -0
- package/dist/db/createBundleDiff.d.mts +20 -0
- package/dist/db/createBundleDiff.mjs +161 -0
- package/dist/db/index.cjs +15 -16
- package/dist/db/index.d.cts +5 -4
- package/dist/db/index.d.mts +5 -4
- package/dist/db/index.mjs +14 -16
- package/dist/db/ormCore.cjs +173 -65
- package/dist/db/ormCore.d.cts +100 -34
- package/dist/db/ormCore.d.mts +100 -34
- package/dist/db/ormCore.mjs +171 -64
- package/dist/db/pluginCore.cjs +37 -3
- package/dist/db/pluginCore.mjs +36 -3
- package/dist/db/schemaEnhancements.cjs +171 -0
- package/dist/db/schemaEnhancements.mjs +167 -0
- package/dist/db/types.cjs +6 -0
- package/dist/db/types.d.cts +19 -7
- package/dist/db/types.d.mts +22 -10
- package/dist/db/types.mjs +6 -1
- package/dist/db/updateArtifacts.cjs +127 -0
- package/dist/db/updateArtifacts.mjs +125 -0
- package/dist/handler.cjs +61 -5
- package/dist/handler.d.cts +2 -2
- package/dist/handler.d.mts +5 -5
- package/dist/handler.mjs +59 -5
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +3 -2
- package/dist/index.d.mts +3 -2
- package/dist/index.mjs +2 -1
- package/dist/node.d.cts +0 -1
- package/dist/node.d.mts +0 -1
- package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/_u64.cjs +112 -0
- package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/_u64.mjs +108 -0
- package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/cryptoNode.cjs +22 -0
- package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/cryptoNode.mjs +18 -0
- package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/sha3.cjs +219 -0
- package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/sha3.mjs +214 -0
- package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/utils.cjs +275 -0
- package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/utils.mjs +270 -0
- package/dist/node_modules/.pnpm/@paralleldrive_cuid2@2.3.1/node_modules/@paralleldrive/cuid2/index.cjs +17 -0
- package/dist/node_modules/.pnpm/@paralleldrive_cuid2@2.3.1/node_modules/@paralleldrive/cuid2/index.mjs +13 -0
- package/dist/node_modules/.pnpm/@paralleldrive_cuid2@2.3.1/node_modules/@paralleldrive/cuid2/src/index.cjs +69 -0
- package/dist/node_modules/.pnpm/@paralleldrive_cuid2@2.3.1/node_modules/@paralleldrive/cuid2/src/index.mjs +65 -0
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- package/dist/{package.cjs → packages/server/package.cjs} +1 -1
- package/dist/{package.mjs → packages/server/package.mjs} +1 -1
- package/dist/runtime.cjs +13 -13
- package/dist/runtime.d.cts +4 -4
- package/dist/runtime.d.mts +4 -4
- package/dist/runtime.mjs +12 -13
- package/dist/schema/v0_21_0.cjs +16 -15
- package/dist/schema/v0_21_0.mjs +3 -2
- package/dist/schema/v0_29_0.cjs +18 -17
- package/dist/schema/v0_29_0.mjs +3 -2
- package/dist/schema/v0_31_0.cjs +48 -0
- package/dist/schema/v0_31_0.mjs +48 -0
- package/dist/storageAccess.cjs +44 -0
- package/dist/storageAccess.mjs +44 -0
- package/dist/version.cjs +1 -1
- package/dist/version.mjs +1 -1
- package/package.json +15 -7
- package/src/adapters/drizzle.ts +15 -1
- package/src/adapters/kysely.ts +24 -1
- package/src/adapters/mongodb.ts +19 -1
- package/src/adapters/prisma.ts +15 -1
- package/src/db/createBundleDiff.spec.ts +402 -0
- package/src/db/createBundleDiff.ts +375 -0
- package/src/db/index.spec.ts +528 -27
- package/src/db/index.ts +22 -36
- package/src/db/ormCore.ts +308 -75
- package/src/db/pluginCore.spec.ts +385 -0
- package/src/db/pluginCore.ts +45 -4
- package/src/db/schemaEnhancements.ts +460 -0
- package/src/db/types.ts +38 -7
- package/src/db/updateArtifacts.ts +388 -0
- package/src/handler-standalone.integration.spec.ts +1 -0
- package/src/handler.spec.ts +121 -0
- package/src/handler.ts +117 -5
- package/src/runtime.spec.ts +287 -55
- package/src/runtime.ts +21 -37
- package/src/schema/v0_21_0.ts +1 -1
- package/src/schema/v0_29_0.ts +1 -1
- package/src/schema/v0_31_0.ts +58 -0
- package/src/storageAccess.spec.ts +57 -0
- package/src/storageAccess.ts +90 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
let _hot_updater_core = require("@hot-updater/core");
|
|
3
|
+
let semver = require("semver");
|
|
4
|
+
semver = require_runtime.__toESM(semver);
|
|
5
|
+
//#region src/db/schemaEnhancements.ts
|
|
6
|
+
const normalizeNullableString = (value) => {
|
|
7
|
+
if (value === null || value === void 0) return null;
|
|
8
|
+
const normalized = value.trim();
|
|
9
|
+
return normalized.length > 0 ? normalized : null;
|
|
10
|
+
};
|
|
11
|
+
const appendPrismaModelLines = (code, modelName, lines, options) => {
|
|
12
|
+
const pattern = new RegExp(`model ${modelName} \\{\\n([\\s\\S]*?)\\n\\}`, "m");
|
|
13
|
+
return code.replace(pattern, (full, body) => {
|
|
14
|
+
const bodyLines = body.split("\n");
|
|
15
|
+
const existingLines = new Set(bodyLines.map((line) => line.trim()).filter(Boolean));
|
|
16
|
+
const additions = lines.filter((line) => !existingLines.has(line)).map((line) => ` ${line}`);
|
|
17
|
+
if (additions.length === 0) return full;
|
|
18
|
+
if (options?.position === "beforeAttributes") {
|
|
19
|
+
const insertIndex = bodyLines.findIndex((line) => line.trim().startsWith("@@"));
|
|
20
|
+
if (insertIndex === -1) bodyLines.push(...additions);
|
|
21
|
+
else bodyLines.splice(insertIndex, 0, ...additions);
|
|
22
|
+
return `model ${modelName} {\n${bodyLines.join("\n")}\n}`;
|
|
23
|
+
}
|
|
24
|
+
return `model ${modelName} {\n${body}\n${additions.join("\n")}\n}`;
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
const getPrismaDatasourceProvider = (code) => {
|
|
28
|
+
return code.match(/datasource\s+\w+\s+\{[\s\S]*?provider\s*=\s*"([^"]+)"[\s\S]*?\}/m)?.[1] ?? null;
|
|
29
|
+
};
|
|
30
|
+
const ensureDrizzleIndexImport = (code) => code.replace(/import \{ ([^}]+) \} from "(drizzle-orm\/[^"]+-core)"/, (_full, imports, modulePath) => {
|
|
31
|
+
const values = imports.split(",").map((value) => value.trim()).filter(Boolean);
|
|
32
|
+
if (!values.includes("index")) values.push("index");
|
|
33
|
+
return `import { ${values.join(", ")} } from "${modulePath}"`;
|
|
34
|
+
});
|
|
35
|
+
const ensureDrizzleMetadataDefault = (code) => code.replace(/metadata: json\("metadata"\)\.notNull\(\)(?!\.default\(\{\}\))/, "metadata: json(\"metadata\").notNull().default({})").replace(/metadata: blob\("metadata", \{ mode: "json" \}\)\.notNull\(\)(?!\.default\(\{\}\))/, "metadata: blob(\"metadata\", { mode: \"json\" }).notNull().default({})");
|
|
36
|
+
const removeUnusedDrizzleRelationMany = (code) => code.replace(/export const bundle_patchesRelations = relations\(bundle_patches, \(\{ one, many \}\) => \(\{/, "export const bundle_patchesRelations = relations(bundle_patches, ({ one }) => ({");
|
|
37
|
+
const ensureTrailingComma = (line) => {
|
|
38
|
+
const trimmed = line.trim();
|
|
39
|
+
if (!trimmed || trimmed.endsWith(",") || trimmed.endsWith("[")) return line;
|
|
40
|
+
return `${line},`;
|
|
41
|
+
};
|
|
42
|
+
const updateDrizzleTableBlock = (code, tableName, callbackLines) => {
|
|
43
|
+
const blockStart = code.indexOf(`export const ${tableName} = `);
|
|
44
|
+
if (blockStart === -1) return code;
|
|
45
|
+
const nextBlockStart = code.indexOf("\n\nexport const ", blockStart + 1);
|
|
46
|
+
const blockEnd = nextBlockStart === -1 ? code.length : nextBlockStart;
|
|
47
|
+
const block = code.slice(blockStart, blockEnd);
|
|
48
|
+
if (block.includes(", (table) => [")) {
|
|
49
|
+
const callbackPattern = /, \(table\) => \[\n([\s\S]*?)\n\]\)\s*$/;
|
|
50
|
+
const match = block.match(callbackPattern);
|
|
51
|
+
if (!match) return code;
|
|
52
|
+
const callbackBody = match[1] ?? "";
|
|
53
|
+
const existingLines = callbackBody.split("\n").map((line) => line.trim()).filter(Boolean);
|
|
54
|
+
const additions = callbackLines.filter((line) => !existingLines.includes(line));
|
|
55
|
+
if (additions.length === 0) return code;
|
|
56
|
+
const callbackBodyLines = callbackBody.split("\n");
|
|
57
|
+
for (let index = callbackBodyLines.length - 1; index >= 0; index -= 1) if (callbackBodyLines[index]?.trim()) {
|
|
58
|
+
callbackBodyLines[index] = ensureTrailingComma(callbackBodyLines[index]);
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
const nextCallbackBody = [...callbackBodyLines, ...additions.map((line) => ` ${line}`)].join("\n");
|
|
62
|
+
const nextBlock = block.replace(callbackPattern, `, (table) => [\n${nextCallbackBody}\n])`);
|
|
63
|
+
return `${code.slice(0, blockStart)}${nextBlock}${code.slice(blockEnd)}`;
|
|
64
|
+
}
|
|
65
|
+
const callbackBody = callbackLines.map((line) => ` ${line}`).join("\n");
|
|
66
|
+
const nextBlock = block.replace(/\n\}\)\s*$/, `\n}, (table) => [\n${callbackBody}\n])`);
|
|
67
|
+
return `${code.slice(0, blockStart)}${nextBlock}${code.slice(blockEnd)}`;
|
|
68
|
+
};
|
|
69
|
+
const addCustomSqlOperation = (result, sql) => {
|
|
70
|
+
const normalizedSql = sql.trim();
|
|
71
|
+
if (!result.operations.some((operation) => {
|
|
72
|
+
return operation["type"] === "custom" && typeof operation["sql"] === "string" && operation["sql"].trim() === normalizedSql;
|
|
73
|
+
})) result.operations.push({
|
|
74
|
+
type: "custom",
|
|
75
|
+
sql: normalizedSql
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
const getMigrationCustomSql = (provider, targetVersion) => {
|
|
79
|
+
const statements = [];
|
|
80
|
+
const hasRolloutColumns = semver.default.gte(targetVersion, "0.29.0");
|
|
81
|
+
const hasPatchTable = semver.default.gte(targetVersion, "0.31.0");
|
|
82
|
+
if (provider === "postgresql") {
|
|
83
|
+
statements.push("create index bundles_target_app_version_idx on bundles(target_app_version)", "create index bundles_fingerprint_hash_idx on bundles(fingerprint_hash)", "create index bundles_channel_idx on bundles(channel)", "alter table bundles add constraint check_version_or_fingerprint check ((target_app_version is not null) or (fingerprint_hash is not null))");
|
|
84
|
+
if (hasRolloutColumns) statements.push("create index bundles_rollout_idx on bundles(rollout_cohort_count)", "alter table bundles add constraint bundles_rollout_cohort_count_check check (rollout_cohort_count >= 0 and rollout_cohort_count <= 1000)");
|
|
85
|
+
if (hasPatchTable) statements.push("create index bundle_patches_bundle_id_idx on bundle_patches(bundle_id)", "create index bundle_patches_base_bundle_id_idx on bundle_patches(base_bundle_id)");
|
|
86
|
+
return statements;
|
|
87
|
+
}
|
|
88
|
+
if (provider === "mysql") {
|
|
89
|
+
statements.push("create index bundles_target_app_version_idx on bundles(target_app_version(255))", "create index bundles_fingerprint_hash_idx on bundles(fingerprint_hash(255))", "create index bundles_channel_idx on bundles(channel(255))", "alter table bundles add constraint check_version_or_fingerprint check ((target_app_version is not null) or (fingerprint_hash is not null))");
|
|
90
|
+
if (hasRolloutColumns) statements.push("create index bundles_rollout_idx on bundles(rollout_cohort_count)", "alter table bundles add constraint bundles_rollout_cohort_count_check check (rollout_cohort_count >= 0 and rollout_cohort_count <= 1000)");
|
|
91
|
+
if (hasPatchTable) statements.push("create index bundle_patches_bundle_id_idx on bundle_patches(bundle_id)", "create index bundle_patches_base_bundle_id_idx on bundle_patches(base_bundle_id)");
|
|
92
|
+
return statements;
|
|
93
|
+
}
|
|
94
|
+
statements.push("create index bundles_target_app_version_idx on bundles(target_app_version)", "create index bundles_fingerprint_hash_idx on bundles(fingerprint_hash)", "create index bundles_channel_idx on bundles(channel)");
|
|
95
|
+
if (hasRolloutColumns) statements.push("create index bundles_rollout_idx on bundles(rollout_cohort_count)");
|
|
96
|
+
if (hasPatchTable) statements.push("create index bundle_patches_bundle_id_idx on bundle_patches(bundle_id)", "create index bundle_patches_base_bundle_id_idx on bundle_patches(base_bundle_id)");
|
|
97
|
+
return statements;
|
|
98
|
+
};
|
|
99
|
+
const enhanceUpwardMigrationResult = (result, provider, targetVersion) => {
|
|
100
|
+
for (const sql of getMigrationCustomSql(provider, targetVersion)) addCustomSqlOperation(result, sql);
|
|
101
|
+
return result;
|
|
102
|
+
};
|
|
103
|
+
const assertBundlePersistenceConstraints = (bundle) => {
|
|
104
|
+
const targetAppVersion = normalizeNullableString(bundle.targetAppVersion);
|
|
105
|
+
const fingerprintHash = normalizeNullableString(bundle.fingerprintHash);
|
|
106
|
+
if (!targetAppVersion && !fingerprintHash) throw new Error("Bundle must define either targetAppVersion or fingerprintHash.");
|
|
107
|
+
const rolloutCohortCount = bundle.rolloutCohortCount;
|
|
108
|
+
if (rolloutCohortCount !== null && rolloutCohortCount !== void 0) {
|
|
109
|
+
if (!Number.isInteger(rolloutCohortCount) || rolloutCohortCount < 0 || rolloutCohortCount > _hot_updater_core.DEFAULT_ROLLOUT_COHORT_COUNT) throw new Error(`rolloutCohortCount must be an integer between 0 and ${_hot_updater_core.DEFAULT_ROLLOUT_COHORT_COUNT}.`);
|
|
110
|
+
}
|
|
111
|
+
for (const cohort of bundle.targetCohorts ?? []) if (!(0, _hot_updater_core.isValidCohort)(cohort)) throw new Error(`Invalid target cohort "${cohort}". ${_hot_updater_core.INVALID_COHORT_ERROR_MESSAGE}`);
|
|
112
|
+
};
|
|
113
|
+
const enhanceGeneratedSchema = (adapterName, code, provider) => {
|
|
114
|
+
if (adapterName === "prisma") {
|
|
115
|
+
const datasourceProvider = provider ?? getPrismaDatasourceProvider(code);
|
|
116
|
+
let nextCode = code;
|
|
117
|
+
if (datasourceProvider !== "sqlite") nextCode = nextCode.replace(/^(\s*metadata\s+Json)(?!\s+@default\("?\{\}"?\))(.*)$/m, "$1 @default(\"{}\")$2");
|
|
118
|
+
nextCode = appendPrismaModelLines(nextCode, "bundles", ["patches bundle_patches[] @relation(\"bundle_patches_bundles_patches\")", "baseForPatches bundle_patches[] @relation(\"bundle_patches_bundles_baseForPatches\")"], { position: "beforeAttributes" });
|
|
119
|
+
nextCode = appendPrismaModelLines(nextCode, "bundles", [
|
|
120
|
+
"@@index([target_app_version], map: \"bundles_target_app_version_idx\")",
|
|
121
|
+
"@@index([fingerprint_hash], map: \"bundles_fingerprint_hash_idx\")",
|
|
122
|
+
"@@index([channel], map: \"bundles_channel_idx\")",
|
|
123
|
+
"@@index([rollout_cohort_count], map: \"bundles_rollout_idx\")"
|
|
124
|
+
]);
|
|
125
|
+
return appendPrismaModelLines(nextCode, "bundle_patches", ["@@index([bundle_id], map: \"bundle_patches_bundle_id_idx\")", "@@index([base_bundle_id], map: \"bundle_patches_base_bundle_id_idx\")"]);
|
|
126
|
+
}
|
|
127
|
+
if (adapterName === "drizzle") {
|
|
128
|
+
let nextCode = ensureDrizzleMetadataDefault(code);
|
|
129
|
+
nextCode = removeUnusedDrizzleRelationMany(nextCode);
|
|
130
|
+
nextCode = ensureDrizzleIndexImport(nextCode);
|
|
131
|
+
nextCode = updateDrizzleTableBlock(nextCode, "bundles", [
|
|
132
|
+
"index(\"bundles_target_app_version_idx\").on(table.target_app_version),",
|
|
133
|
+
"index(\"bundles_fingerprint_hash_idx\").on(table.fingerprint_hash),",
|
|
134
|
+
"index(\"bundles_channel_idx\").on(table.channel),",
|
|
135
|
+
"index(\"bundles_rollout_idx\").on(table.rollout_cohort_count),"
|
|
136
|
+
]);
|
|
137
|
+
nextCode = updateDrizzleTableBlock(nextCode, "bundle_patches", ["index(\"bundle_patches_bundle_id_idx\").on(table.bundle_id),", "index(\"bundle_patches_base_bundle_id_idx\").on(table.base_bundle_id),"]);
|
|
138
|
+
return nextCode;
|
|
139
|
+
}
|
|
140
|
+
return code;
|
|
141
|
+
};
|
|
142
|
+
const wrapKyselyMigrator = (migrator, provider, latestVersion) => {
|
|
143
|
+
if (!provider) return migrator;
|
|
144
|
+
return {
|
|
145
|
+
...migrator,
|
|
146
|
+
async up(...args) {
|
|
147
|
+
const next = await migrator.next();
|
|
148
|
+
const result = await migrator.up(...args);
|
|
149
|
+
if (next) enhanceUpwardMigrationResult(result, provider, next.version);
|
|
150
|
+
return result;
|
|
151
|
+
},
|
|
152
|
+
async migrateTo(...args) {
|
|
153
|
+
const version = args[0];
|
|
154
|
+
const options = args[1];
|
|
155
|
+
const currentVersion = await migrator.getVersion();
|
|
156
|
+
const result = await migrator.migrateTo(version, options);
|
|
157
|
+
if (!currentVersion || semver.default.gt(version, currentVersion)) enhanceUpwardMigrationResult(result, provider, version);
|
|
158
|
+
return result;
|
|
159
|
+
},
|
|
160
|
+
async migrateToLatest(...args) {
|
|
161
|
+
const currentVersion = await migrator.getVersion();
|
|
162
|
+
const result = await migrator.migrateToLatest(...args);
|
|
163
|
+
if (!currentVersion || semver.default.gt(latestVersion, currentVersion)) enhanceUpwardMigrationResult(result, provider, latestVersion);
|
|
164
|
+
return result;
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
//#endregion
|
|
169
|
+
exports.assertBundlePersistenceConstraints = assertBundlePersistenceConstraints;
|
|
170
|
+
exports.enhanceGeneratedSchema = enhanceGeneratedSchema;
|
|
171
|
+
exports.wrapKyselyMigrator = wrapKyselyMigrator;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { DEFAULT_ROLLOUT_COHORT_COUNT, INVALID_COHORT_ERROR_MESSAGE, isValidCohort } from "@hot-updater/core";
|
|
2
|
+
import semver from "semver";
|
|
3
|
+
//#region src/db/schemaEnhancements.ts
|
|
4
|
+
const normalizeNullableString = (value) => {
|
|
5
|
+
if (value === null || value === void 0) return null;
|
|
6
|
+
const normalized = value.trim();
|
|
7
|
+
return normalized.length > 0 ? normalized : null;
|
|
8
|
+
};
|
|
9
|
+
const appendPrismaModelLines = (code, modelName, lines, options) => {
|
|
10
|
+
const pattern = new RegExp(`model ${modelName} \\{\\n([\\s\\S]*?)\\n\\}`, "m");
|
|
11
|
+
return code.replace(pattern, (full, body) => {
|
|
12
|
+
const bodyLines = body.split("\n");
|
|
13
|
+
const existingLines = new Set(bodyLines.map((line) => line.trim()).filter(Boolean));
|
|
14
|
+
const additions = lines.filter((line) => !existingLines.has(line)).map((line) => ` ${line}`);
|
|
15
|
+
if (additions.length === 0) return full;
|
|
16
|
+
if (options?.position === "beforeAttributes") {
|
|
17
|
+
const insertIndex = bodyLines.findIndex((line) => line.trim().startsWith("@@"));
|
|
18
|
+
if (insertIndex === -1) bodyLines.push(...additions);
|
|
19
|
+
else bodyLines.splice(insertIndex, 0, ...additions);
|
|
20
|
+
return `model ${modelName} {\n${bodyLines.join("\n")}\n}`;
|
|
21
|
+
}
|
|
22
|
+
return `model ${modelName} {\n${body}\n${additions.join("\n")}\n}`;
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
const getPrismaDatasourceProvider = (code) => {
|
|
26
|
+
return code.match(/datasource\s+\w+\s+\{[\s\S]*?provider\s*=\s*"([^"]+)"[\s\S]*?\}/m)?.[1] ?? null;
|
|
27
|
+
};
|
|
28
|
+
const ensureDrizzleIndexImport = (code) => code.replace(/import \{ ([^}]+) \} from "(drizzle-orm\/[^"]+-core)"/, (_full, imports, modulePath) => {
|
|
29
|
+
const values = imports.split(",").map((value) => value.trim()).filter(Boolean);
|
|
30
|
+
if (!values.includes("index")) values.push("index");
|
|
31
|
+
return `import { ${values.join(", ")} } from "${modulePath}"`;
|
|
32
|
+
});
|
|
33
|
+
const ensureDrizzleMetadataDefault = (code) => code.replace(/metadata: json\("metadata"\)\.notNull\(\)(?!\.default\(\{\}\))/, "metadata: json(\"metadata\").notNull().default({})").replace(/metadata: blob\("metadata", \{ mode: "json" \}\)\.notNull\(\)(?!\.default\(\{\}\))/, "metadata: blob(\"metadata\", { mode: \"json\" }).notNull().default({})");
|
|
34
|
+
const removeUnusedDrizzleRelationMany = (code) => code.replace(/export const bundle_patchesRelations = relations\(bundle_patches, \(\{ one, many \}\) => \(\{/, "export const bundle_patchesRelations = relations(bundle_patches, ({ one }) => ({");
|
|
35
|
+
const ensureTrailingComma = (line) => {
|
|
36
|
+
const trimmed = line.trim();
|
|
37
|
+
if (!trimmed || trimmed.endsWith(",") || trimmed.endsWith("[")) return line;
|
|
38
|
+
return `${line},`;
|
|
39
|
+
};
|
|
40
|
+
const updateDrizzleTableBlock = (code, tableName, callbackLines) => {
|
|
41
|
+
const blockStart = code.indexOf(`export const ${tableName} = `);
|
|
42
|
+
if (blockStart === -1) return code;
|
|
43
|
+
const nextBlockStart = code.indexOf("\n\nexport const ", blockStart + 1);
|
|
44
|
+
const blockEnd = nextBlockStart === -1 ? code.length : nextBlockStart;
|
|
45
|
+
const block = code.slice(blockStart, blockEnd);
|
|
46
|
+
if (block.includes(", (table) => [")) {
|
|
47
|
+
const callbackPattern = /, \(table\) => \[\n([\s\S]*?)\n\]\)\s*$/;
|
|
48
|
+
const match = block.match(callbackPattern);
|
|
49
|
+
if (!match) return code;
|
|
50
|
+
const callbackBody = match[1] ?? "";
|
|
51
|
+
const existingLines = callbackBody.split("\n").map((line) => line.trim()).filter(Boolean);
|
|
52
|
+
const additions = callbackLines.filter((line) => !existingLines.includes(line));
|
|
53
|
+
if (additions.length === 0) return code;
|
|
54
|
+
const callbackBodyLines = callbackBody.split("\n");
|
|
55
|
+
for (let index = callbackBodyLines.length - 1; index >= 0; index -= 1) if (callbackBodyLines[index]?.trim()) {
|
|
56
|
+
callbackBodyLines[index] = ensureTrailingComma(callbackBodyLines[index]);
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
const nextCallbackBody = [...callbackBodyLines, ...additions.map((line) => ` ${line}`)].join("\n");
|
|
60
|
+
const nextBlock = block.replace(callbackPattern, `, (table) => [\n${nextCallbackBody}\n])`);
|
|
61
|
+
return `${code.slice(0, blockStart)}${nextBlock}${code.slice(blockEnd)}`;
|
|
62
|
+
}
|
|
63
|
+
const callbackBody = callbackLines.map((line) => ` ${line}`).join("\n");
|
|
64
|
+
const nextBlock = block.replace(/\n\}\)\s*$/, `\n}, (table) => [\n${callbackBody}\n])`);
|
|
65
|
+
return `${code.slice(0, blockStart)}${nextBlock}${code.slice(blockEnd)}`;
|
|
66
|
+
};
|
|
67
|
+
const addCustomSqlOperation = (result, sql) => {
|
|
68
|
+
const normalizedSql = sql.trim();
|
|
69
|
+
if (!result.operations.some((operation) => {
|
|
70
|
+
return operation["type"] === "custom" && typeof operation["sql"] === "string" && operation["sql"].trim() === normalizedSql;
|
|
71
|
+
})) result.operations.push({
|
|
72
|
+
type: "custom",
|
|
73
|
+
sql: normalizedSql
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
const getMigrationCustomSql = (provider, targetVersion) => {
|
|
77
|
+
const statements = [];
|
|
78
|
+
const hasRolloutColumns = semver.gte(targetVersion, "0.29.0");
|
|
79
|
+
const hasPatchTable = semver.gte(targetVersion, "0.31.0");
|
|
80
|
+
if (provider === "postgresql") {
|
|
81
|
+
statements.push("create index bundles_target_app_version_idx on bundles(target_app_version)", "create index bundles_fingerprint_hash_idx on bundles(fingerprint_hash)", "create index bundles_channel_idx on bundles(channel)", "alter table bundles add constraint check_version_or_fingerprint check ((target_app_version is not null) or (fingerprint_hash is not null))");
|
|
82
|
+
if (hasRolloutColumns) statements.push("create index bundles_rollout_idx on bundles(rollout_cohort_count)", "alter table bundles add constraint bundles_rollout_cohort_count_check check (rollout_cohort_count >= 0 and rollout_cohort_count <= 1000)");
|
|
83
|
+
if (hasPatchTable) statements.push("create index bundle_patches_bundle_id_idx on bundle_patches(bundle_id)", "create index bundle_patches_base_bundle_id_idx on bundle_patches(base_bundle_id)");
|
|
84
|
+
return statements;
|
|
85
|
+
}
|
|
86
|
+
if (provider === "mysql") {
|
|
87
|
+
statements.push("create index bundles_target_app_version_idx on bundles(target_app_version(255))", "create index bundles_fingerprint_hash_idx on bundles(fingerprint_hash(255))", "create index bundles_channel_idx on bundles(channel(255))", "alter table bundles add constraint check_version_or_fingerprint check ((target_app_version is not null) or (fingerprint_hash is not null))");
|
|
88
|
+
if (hasRolloutColumns) statements.push("create index bundles_rollout_idx on bundles(rollout_cohort_count)", "alter table bundles add constraint bundles_rollout_cohort_count_check check (rollout_cohort_count >= 0 and rollout_cohort_count <= 1000)");
|
|
89
|
+
if (hasPatchTable) statements.push("create index bundle_patches_bundle_id_idx on bundle_patches(bundle_id)", "create index bundle_patches_base_bundle_id_idx on bundle_patches(base_bundle_id)");
|
|
90
|
+
return statements;
|
|
91
|
+
}
|
|
92
|
+
statements.push("create index bundles_target_app_version_idx on bundles(target_app_version)", "create index bundles_fingerprint_hash_idx on bundles(fingerprint_hash)", "create index bundles_channel_idx on bundles(channel)");
|
|
93
|
+
if (hasRolloutColumns) statements.push("create index bundles_rollout_idx on bundles(rollout_cohort_count)");
|
|
94
|
+
if (hasPatchTable) statements.push("create index bundle_patches_bundle_id_idx on bundle_patches(bundle_id)", "create index bundle_patches_base_bundle_id_idx on bundle_patches(base_bundle_id)");
|
|
95
|
+
return statements;
|
|
96
|
+
};
|
|
97
|
+
const enhanceUpwardMigrationResult = (result, provider, targetVersion) => {
|
|
98
|
+
for (const sql of getMigrationCustomSql(provider, targetVersion)) addCustomSqlOperation(result, sql);
|
|
99
|
+
return result;
|
|
100
|
+
};
|
|
101
|
+
const assertBundlePersistenceConstraints = (bundle) => {
|
|
102
|
+
const targetAppVersion = normalizeNullableString(bundle.targetAppVersion);
|
|
103
|
+
const fingerprintHash = normalizeNullableString(bundle.fingerprintHash);
|
|
104
|
+
if (!targetAppVersion && !fingerprintHash) throw new Error("Bundle must define either targetAppVersion or fingerprintHash.");
|
|
105
|
+
const rolloutCohortCount = bundle.rolloutCohortCount;
|
|
106
|
+
if (rolloutCohortCount !== null && rolloutCohortCount !== void 0) {
|
|
107
|
+
if (!Number.isInteger(rolloutCohortCount) || rolloutCohortCount < 0 || rolloutCohortCount > DEFAULT_ROLLOUT_COHORT_COUNT) throw new Error(`rolloutCohortCount must be an integer between 0 and ${DEFAULT_ROLLOUT_COHORT_COUNT}.`);
|
|
108
|
+
}
|
|
109
|
+
for (const cohort of bundle.targetCohorts ?? []) if (!isValidCohort(cohort)) throw new Error(`Invalid target cohort "${cohort}". ${INVALID_COHORT_ERROR_MESSAGE}`);
|
|
110
|
+
};
|
|
111
|
+
const enhanceGeneratedSchema = (adapterName, code, provider) => {
|
|
112
|
+
if (adapterName === "prisma") {
|
|
113
|
+
const datasourceProvider = provider ?? getPrismaDatasourceProvider(code);
|
|
114
|
+
let nextCode = code;
|
|
115
|
+
if (datasourceProvider !== "sqlite") nextCode = nextCode.replace(/^(\s*metadata\s+Json)(?!\s+@default\("?\{\}"?\))(.*)$/m, "$1 @default(\"{}\")$2");
|
|
116
|
+
nextCode = appendPrismaModelLines(nextCode, "bundles", ["patches bundle_patches[] @relation(\"bundle_patches_bundles_patches\")", "baseForPatches bundle_patches[] @relation(\"bundle_patches_bundles_baseForPatches\")"], { position: "beforeAttributes" });
|
|
117
|
+
nextCode = appendPrismaModelLines(nextCode, "bundles", [
|
|
118
|
+
"@@index([target_app_version], map: \"bundles_target_app_version_idx\")",
|
|
119
|
+
"@@index([fingerprint_hash], map: \"bundles_fingerprint_hash_idx\")",
|
|
120
|
+
"@@index([channel], map: \"bundles_channel_idx\")",
|
|
121
|
+
"@@index([rollout_cohort_count], map: \"bundles_rollout_idx\")"
|
|
122
|
+
]);
|
|
123
|
+
return appendPrismaModelLines(nextCode, "bundle_patches", ["@@index([bundle_id], map: \"bundle_patches_bundle_id_idx\")", "@@index([base_bundle_id], map: \"bundle_patches_base_bundle_id_idx\")"]);
|
|
124
|
+
}
|
|
125
|
+
if (adapterName === "drizzle") {
|
|
126
|
+
let nextCode = ensureDrizzleMetadataDefault(code);
|
|
127
|
+
nextCode = removeUnusedDrizzleRelationMany(nextCode);
|
|
128
|
+
nextCode = ensureDrizzleIndexImport(nextCode);
|
|
129
|
+
nextCode = updateDrizzleTableBlock(nextCode, "bundles", [
|
|
130
|
+
"index(\"bundles_target_app_version_idx\").on(table.target_app_version),",
|
|
131
|
+
"index(\"bundles_fingerprint_hash_idx\").on(table.fingerprint_hash),",
|
|
132
|
+
"index(\"bundles_channel_idx\").on(table.channel),",
|
|
133
|
+
"index(\"bundles_rollout_idx\").on(table.rollout_cohort_count),"
|
|
134
|
+
]);
|
|
135
|
+
nextCode = updateDrizzleTableBlock(nextCode, "bundle_patches", ["index(\"bundle_patches_bundle_id_idx\").on(table.bundle_id),", "index(\"bundle_patches_base_bundle_id_idx\").on(table.base_bundle_id),"]);
|
|
136
|
+
return nextCode;
|
|
137
|
+
}
|
|
138
|
+
return code;
|
|
139
|
+
};
|
|
140
|
+
const wrapKyselyMigrator = (migrator, provider, latestVersion) => {
|
|
141
|
+
if (!provider) return migrator;
|
|
142
|
+
return {
|
|
143
|
+
...migrator,
|
|
144
|
+
async up(...args) {
|
|
145
|
+
const next = await migrator.next();
|
|
146
|
+
const result = await migrator.up(...args);
|
|
147
|
+
if (next) enhanceUpwardMigrationResult(result, provider, next.version);
|
|
148
|
+
return result;
|
|
149
|
+
},
|
|
150
|
+
async migrateTo(...args) {
|
|
151
|
+
const version = args[0];
|
|
152
|
+
const options = args[1];
|
|
153
|
+
const currentVersion = await migrator.getVersion();
|
|
154
|
+
const result = await migrator.migrateTo(version, options);
|
|
155
|
+
if (!currentVersion || semver.gt(version, currentVersion)) enhanceUpwardMigrationResult(result, provider, version);
|
|
156
|
+
return result;
|
|
157
|
+
},
|
|
158
|
+
async migrateToLatest(...args) {
|
|
159
|
+
const currentVersion = await migrator.getVersion();
|
|
160
|
+
const result = await migrator.migrateToLatest(...args);
|
|
161
|
+
if (!currentVersion || semver.gt(latestVersion, currentVersion)) enhanceUpwardMigrationResult(result, provider, latestVersion);
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
//#endregion
|
|
167
|
+
export { assertBundlePersistenceConstraints, enhanceGeneratedSchema, wrapKyselyMigrator };
|
package/dist/db/types.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const require_index = require("../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");
|
|
1
2
|
//#region src/db/types.ts
|
|
2
3
|
function isDatabasePluginFactory(adapter) {
|
|
3
4
|
return typeof adapter === "function";
|
|
@@ -5,6 +6,11 @@ function isDatabasePluginFactory(adapter) {
|
|
|
5
6
|
function isDatabasePlugin(adapter) {
|
|
6
7
|
return typeof adapter === "object" && adapter !== null && "getBundleById" in adapter && "getBundles" in adapter && "getChannels" in adapter;
|
|
7
8
|
}
|
|
9
|
+
function getSQLProvider(provider) {
|
|
10
|
+
if (!provider) return;
|
|
11
|
+
return require_index.sqlProviders.includes(provider) ? provider : void 0;
|
|
12
|
+
}
|
|
8
13
|
//#endregion
|
|
14
|
+
exports.getSQLProvider = getSQLProvider;
|
|
9
15
|
exports.isDatabasePlugin = isDatabasePlugin;
|
|
10
16
|
exports.isDatabasePluginFactory = isDatabasePluginFactory;
|
package/dist/db/types.d.cts
CHANGED
|
@@ -1,21 +1,33 @@
|
|
|
1
|
+
import { Provider } from "../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.cjs";
|
|
1
2
|
import { PaginatedResult } from "../types/index.cjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { FumaDBAdapter } from "fumadb/adapters";
|
|
3
|
+
import { AppUpdateAvailableInfo, Bundle, GetBundlesArgs, UpdateInfo } from "@hot-updater/core";
|
|
4
|
+
import { DatabaseBundleQueryOptions, DatabasePlugin, HotUpdaterContext, RuntimeStoragePlugin } from "@hot-updater/plugin-core";
|
|
5
5
|
|
|
6
6
|
//#region src/db/types.d.ts
|
|
7
7
|
type DatabasePluginFactory<TContext = unknown> = () => DatabasePlugin<TContext>;
|
|
8
|
-
type
|
|
8
|
+
type ORMProvider = Provider;
|
|
9
|
+
interface ORMDatabaseAdapter {
|
|
10
|
+
name: string;
|
|
11
|
+
provider?: ORMProvider;
|
|
12
|
+
createORM(this: any, schema: any): unknown;
|
|
13
|
+
getSchemaVersion(this: any): Promise<string | undefined>;
|
|
14
|
+
generateSchema?: (this: any, schema: any, schemaName: string) => {
|
|
15
|
+
code: string;
|
|
16
|
+
path: string;
|
|
17
|
+
};
|
|
18
|
+
createMigrationEngine?: (this: any) => unknown;
|
|
19
|
+
}
|
|
20
|
+
type DatabaseAdapter<TContext = unknown> = ORMDatabaseAdapter | DatabasePlugin<TContext> | DatabasePluginFactory<TContext>;
|
|
9
21
|
interface DatabaseAPI<TContext = unknown> {
|
|
10
22
|
getBundleById(id: string, context?: HotUpdaterContext<TContext>): Promise<Bundle | null>;
|
|
11
23
|
getUpdateInfo(args: GetBundlesArgs, context?: HotUpdaterContext<TContext>): Promise<UpdateInfo | null>;
|
|
12
|
-
getAppUpdateInfo(args: GetBundlesArgs, context?: HotUpdaterContext<TContext>): Promise<
|
|
24
|
+
getAppUpdateInfo(args: GetBundlesArgs, context?: HotUpdaterContext<TContext>): Promise<AppUpdateAvailableInfo | null>;
|
|
13
25
|
getChannels(context?: HotUpdaterContext<TContext>): Promise<string[]>;
|
|
14
26
|
getBundles(options: DatabaseBundleQueryOptions, context?: HotUpdaterContext<TContext>): Promise<PaginatedResult>;
|
|
15
27
|
insertBundle(bundle: Bundle, context?: HotUpdaterContext<TContext>): Promise<void>;
|
|
16
28
|
updateBundleById(bundleId: string, newBundle: Partial<Bundle>, context?: HotUpdaterContext<TContext>): Promise<void>;
|
|
17
29
|
deleteBundleById(bundleId: string, context?: HotUpdaterContext<TContext>): Promise<void>;
|
|
18
30
|
}
|
|
19
|
-
type StoragePluginFactory<TContext = unknown> = () =>
|
|
31
|
+
type StoragePluginFactory<TContext = unknown> = () => RuntimeStoragePlugin<TContext>;
|
|
20
32
|
//#endregion
|
|
21
|
-
export { DatabaseAPI, DatabaseAdapter, StoragePluginFactory };
|
|
33
|
+
export { DatabaseAPI, DatabaseAdapter, ORMDatabaseAdapter, StoragePluginFactory };
|
package/dist/db/types.d.mts
CHANGED
|
@@ -1,21 +1,33 @@
|
|
|
1
|
+
import { Provider } from "../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.mjs";
|
|
1
2
|
import { PaginatedResult } from "../types/index.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { FumaDBAdapter } from "fumadb/adapters";
|
|
3
|
+
import { DatabaseBundleQueryOptions, DatabasePlugin, HotUpdaterContext, RuntimeStoragePlugin } from "@hot-updater/plugin-core";
|
|
4
|
+
import { AppUpdateAvailableInfo, Bundle as Bundle$1, GetBundlesArgs, UpdateInfo } from "@hot-updater/core";
|
|
5
5
|
|
|
6
6
|
//#region src/db/types.d.ts
|
|
7
7
|
type DatabasePluginFactory<TContext = unknown> = () => DatabasePlugin<TContext>;
|
|
8
|
-
type
|
|
8
|
+
type ORMProvider = Provider;
|
|
9
|
+
interface ORMDatabaseAdapter {
|
|
10
|
+
name: string;
|
|
11
|
+
provider?: ORMProvider;
|
|
12
|
+
createORM(this: any, schema: any): unknown;
|
|
13
|
+
getSchemaVersion(this: any): Promise<string | undefined>;
|
|
14
|
+
generateSchema?: (this: any, schema: any, schemaName: string) => {
|
|
15
|
+
code: string;
|
|
16
|
+
path: string;
|
|
17
|
+
};
|
|
18
|
+
createMigrationEngine?: (this: any) => unknown;
|
|
19
|
+
}
|
|
20
|
+
type DatabaseAdapter<TContext = unknown> = ORMDatabaseAdapter | DatabasePlugin<TContext> | DatabasePluginFactory<TContext>;
|
|
9
21
|
interface DatabaseAPI<TContext = unknown> {
|
|
10
|
-
getBundleById(id: string, context?: HotUpdaterContext<TContext>): Promise<Bundle | null>;
|
|
22
|
+
getBundleById(id: string, context?: HotUpdaterContext<TContext>): Promise<Bundle$1 | null>;
|
|
11
23
|
getUpdateInfo(args: GetBundlesArgs, context?: HotUpdaterContext<TContext>): Promise<UpdateInfo | null>;
|
|
12
|
-
getAppUpdateInfo(args: GetBundlesArgs, context?: HotUpdaterContext<TContext>): Promise<
|
|
24
|
+
getAppUpdateInfo(args: GetBundlesArgs, context?: HotUpdaterContext<TContext>): Promise<AppUpdateAvailableInfo | null>;
|
|
13
25
|
getChannels(context?: HotUpdaterContext<TContext>): Promise<string[]>;
|
|
14
26
|
getBundles(options: DatabaseBundleQueryOptions, context?: HotUpdaterContext<TContext>): Promise<PaginatedResult>;
|
|
15
|
-
insertBundle(bundle: Bundle, context?: HotUpdaterContext<TContext>): Promise<void>;
|
|
16
|
-
updateBundleById(bundleId: string, newBundle: Partial<Bundle>, context?: HotUpdaterContext<TContext>): Promise<void>;
|
|
27
|
+
insertBundle(bundle: Bundle$1, context?: HotUpdaterContext<TContext>): Promise<void>;
|
|
28
|
+
updateBundleById(bundleId: string, newBundle: Partial<Bundle$1>, context?: HotUpdaterContext<TContext>): Promise<void>;
|
|
17
29
|
deleteBundleById(bundleId: string, context?: HotUpdaterContext<TContext>): Promise<void>;
|
|
18
30
|
}
|
|
19
|
-
type StoragePluginFactory<TContext = unknown> = () =>
|
|
31
|
+
type StoragePluginFactory<TContext = unknown> = () => RuntimeStoragePlugin<TContext>;
|
|
20
32
|
//#endregion
|
|
21
|
-
export { DatabaseAPI, DatabaseAdapter, StoragePluginFactory };
|
|
33
|
+
export { DatabaseAPI, DatabaseAdapter, ORMDatabaseAdapter, StoragePluginFactory };
|
package/dist/db/types.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { sqlProviders } from "../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";
|
|
1
2
|
//#region src/db/types.ts
|
|
2
3
|
function isDatabasePluginFactory(adapter) {
|
|
3
4
|
return typeof adapter === "function";
|
|
@@ -5,5 +6,9 @@ function isDatabasePluginFactory(adapter) {
|
|
|
5
6
|
function isDatabasePlugin(adapter) {
|
|
6
7
|
return typeof adapter === "object" && adapter !== null && "getBundleById" in adapter && "getBundles" in adapter && "getChannels" in adapter;
|
|
7
8
|
}
|
|
9
|
+
function getSQLProvider(provider) {
|
|
10
|
+
if (!provider) return;
|
|
11
|
+
return sqlProviders.includes(provider) ? provider : void 0;
|
|
12
|
+
}
|
|
8
13
|
//#endregion
|
|
9
|
-
export { isDatabasePlugin, isDatabasePluginFactory };
|
|
14
|
+
export { getSQLProvider, isDatabasePlugin, isDatabasePluginFactory };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
let _hot_updater_core = require("@hot-updater/core");
|
|
3
|
+
//#region src/db/updateArtifacts.ts
|
|
4
|
+
const HBC_ASSET_PATH_RE = /\.bundle$/;
|
|
5
|
+
const BR_COMPRESSED_ASSET_PATH_RE = /(^|\/)index\.[^/]+\.bundle$/;
|
|
6
|
+
const resolveUniqueHbcAssetPath = (manifest) => {
|
|
7
|
+
const candidates = Object.keys(manifest.assets).sort((left, right) => left.localeCompare(right)).filter((candidate) => HBC_ASSET_PATH_RE.test(candidate));
|
|
8
|
+
return candidates.length === 1 ? candidates[0] : null;
|
|
9
|
+
};
|
|
10
|
+
const isBundleManifest = (value) => {
|
|
11
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
12
|
+
const manifest = value;
|
|
13
|
+
if (typeof manifest.bundleId !== "string") return false;
|
|
14
|
+
if (!manifest.assets || typeof manifest.assets !== "object") return false;
|
|
15
|
+
return Object.values(manifest.assets).every((asset) => {
|
|
16
|
+
if (!asset || typeof asset !== "object" || Array.isArray(asset)) return false;
|
|
17
|
+
const manifestAsset = asset;
|
|
18
|
+
return typeof manifestAsset.fileHash === "string" && (manifestAsset.signature === void 0 || typeof manifestAsset.signature === "string");
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
const createChildStorageUri = (baseStorageUri, relativePath) => {
|
|
22
|
+
const baseUrl = new URL(baseStorageUri);
|
|
23
|
+
baseUrl.pathname = `${baseUrl.pathname.replace(/\/+$/, "")}/${relativePath.split("/").filter(Boolean).map((segment) => encodeURIComponent(segment)).join("/")}`;
|
|
24
|
+
return baseUrl.toString();
|
|
25
|
+
};
|
|
26
|
+
const parseBundleMetadata = (value) => {
|
|
27
|
+
if (!value) return;
|
|
28
|
+
let parsedValue = value;
|
|
29
|
+
if (typeof parsedValue === "string") try {
|
|
30
|
+
parsedValue = JSON.parse(parsedValue);
|
|
31
|
+
} catch {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (!parsedValue || typeof parsedValue !== "object" || Array.isArray(parsedValue)) return;
|
|
35
|
+
return (0, _hot_updater_core.stripBundleArtifactMetadata)(parsedValue);
|
|
36
|
+
};
|
|
37
|
+
async function fetchBundleManifest(storageUri, readStorageText, resolveFileUrl, context) {
|
|
38
|
+
const [storageText, fileUrl] = await Promise.all([readStorageText(storageUri, context), resolveFileUrl(storageUri, context)]);
|
|
39
|
+
if (storageText === null) return null;
|
|
40
|
+
let payload;
|
|
41
|
+
try {
|
|
42
|
+
payload = JSON.parse(storageText);
|
|
43
|
+
} catch {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
if (!isBundleManifest(payload)) return null;
|
|
47
|
+
if (!fileUrl) return null;
|
|
48
|
+
return {
|
|
49
|
+
fileUrl,
|
|
50
|
+
manifest: payload
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
async function resolveChangedAssets({ assetBaseStorageUri, currentManifest, currentBundle, resolveFileUrl, targetBundle, targetManifest, context }) {
|
|
54
|
+
const patchDescriptor = await resolveHbcPatchDescriptor({
|
|
55
|
+
currentBundle,
|
|
56
|
+
resolveFileUrl,
|
|
57
|
+
targetBundle,
|
|
58
|
+
targetManifest,
|
|
59
|
+
context
|
|
60
|
+
});
|
|
61
|
+
const changedEntries = await Promise.all(Object.entries(targetManifest.assets).map(async ([assetPath, asset]) => {
|
|
62
|
+
if ((currentManifest?.assets[assetPath])?.fileHash === asset.fileHash) return null;
|
|
63
|
+
const usesBrotliAsset = BR_COMPRESSED_ASSET_PATH_RE.test(assetPath);
|
|
64
|
+
const storageUri = createChildStorageUri(assetBaseStorageUri, usesBrotliAsset ? `${assetPath}.br` : assetPath);
|
|
65
|
+
const patch = patchDescriptor?.assetPath === assetPath ? patchDescriptor.patch : null;
|
|
66
|
+
let fileUrl = null;
|
|
67
|
+
try {
|
|
68
|
+
fileUrl = await resolveFileUrl(storageUri, context);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
if (!patch) throw error;
|
|
71
|
+
}
|
|
72
|
+
if (!fileUrl && !patch) return false;
|
|
73
|
+
const changedAsset = { fileHash: asset.fileHash };
|
|
74
|
+
if (fileUrl) {
|
|
75
|
+
changedAsset.file = { url: fileUrl };
|
|
76
|
+
if (usesBrotliAsset) changedAsset.file.compression = "br";
|
|
77
|
+
}
|
|
78
|
+
if (patch) changedAsset.patch = patch;
|
|
79
|
+
return [assetPath, changedAsset];
|
|
80
|
+
}));
|
|
81
|
+
if (changedEntries.some((entry) => entry === false)) return null;
|
|
82
|
+
return Object.fromEntries(changedEntries.filter((entry) => entry !== null));
|
|
83
|
+
}
|
|
84
|
+
async function resolveHbcPatchDescriptor({ currentBundle, resolveFileUrl, targetBundle, targetManifest, context }) {
|
|
85
|
+
const matchingPatch = targetBundle && currentBundle ? (0, _hot_updater_core.getBundlePatch)(targetBundle, currentBundle.id) : null;
|
|
86
|
+
const patchAssetPath = resolveUniqueHbcAssetPath(targetManifest);
|
|
87
|
+
if (!currentBundle || !matchingPatch || !patchAssetPath || !matchingPatch.patchStorageUri || !matchingPatch.patchFileHash || !matchingPatch.baseFileHash) return null;
|
|
88
|
+
const patchUrl = await resolveFileUrl(matchingPatch.patchStorageUri, context);
|
|
89
|
+
if (!patchUrl) return null;
|
|
90
|
+
return {
|
|
91
|
+
assetPath: patchAssetPath,
|
|
92
|
+
patch: {
|
|
93
|
+
algorithm: "bsdiff",
|
|
94
|
+
baseBundleId: matchingPatch.baseBundleId,
|
|
95
|
+
baseFileHash: matchingPatch.baseFileHash,
|
|
96
|
+
patchFileHash: matchingPatch.patchFileHash,
|
|
97
|
+
patchUrl
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
async function resolveManifestArtifacts({ currentBundle, resolveFileUrl, readStorageText, targetBundle, context }) {
|
|
102
|
+
const manifestStorageUri = targetBundle ? (0, _hot_updater_core.getManifestStorageUri)(targetBundle) : null;
|
|
103
|
+
const manifestFileHash = targetBundle ? (0, _hot_updater_core.getManifestFileHash)(targetBundle) : null;
|
|
104
|
+
const assetBaseStorageUri = targetBundle ? (0, _hot_updater_core.getAssetBaseStorageUri)(targetBundle) : null;
|
|
105
|
+
if (!manifestStorageUri || !manifestFileHash || !assetBaseStorageUri) return null;
|
|
106
|
+
const currentManifestStorageUri = currentBundle ? (0, _hot_updater_core.getManifestStorageUri)(currentBundle) : null;
|
|
107
|
+
const [targetManifestResult, currentManifestResult] = await Promise.all([fetchBundleManifest(manifestStorageUri, readStorageText, resolveFileUrl, context), currentManifestStorageUri ? fetchBundleManifest(currentManifestStorageUri, readStorageText, resolveFileUrl, context) : null]);
|
|
108
|
+
if (!targetManifestResult) return null;
|
|
109
|
+
const changedAssets = await resolveChangedAssets({
|
|
110
|
+
assetBaseStorageUri,
|
|
111
|
+
currentManifest: currentManifestResult?.manifest ?? null,
|
|
112
|
+
currentBundle,
|
|
113
|
+
resolveFileUrl,
|
|
114
|
+
targetBundle,
|
|
115
|
+
targetManifest: targetManifestResult.manifest,
|
|
116
|
+
context
|
|
117
|
+
});
|
|
118
|
+
if (!changedAssets) return null;
|
|
119
|
+
return {
|
|
120
|
+
changedAssets,
|
|
121
|
+
manifestFileHash,
|
|
122
|
+
manifestUrl: targetManifestResult.fileUrl
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
//#endregion
|
|
126
|
+
exports.parseBundleMetadata = parseBundleMetadata;
|
|
127
|
+
exports.resolveManifestArtifacts = resolveManifestArtifacts;
|