@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,460 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_ROLLOUT_COHORT_COUNT,
|
|
3
|
+
INVALID_COHORT_ERROR_MESSAGE,
|
|
4
|
+
isValidCohort,
|
|
5
|
+
type Bundle,
|
|
6
|
+
} from "@hot-updater/core";
|
|
7
|
+
import semver from "semver";
|
|
8
|
+
|
|
9
|
+
import type { ORMProvider, ORMSQLProvider } from "./types";
|
|
10
|
+
|
|
11
|
+
type AdapterName = "drizzle" | "prisma" | string;
|
|
12
|
+
|
|
13
|
+
type MigrationResultLike = {
|
|
14
|
+
execute: () => Promise<void>;
|
|
15
|
+
getSQL?: () => string;
|
|
16
|
+
operations: Array<Record<string, unknown>>;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type SchemaVersionLike = {
|
|
20
|
+
version: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
type MigratorLike = {
|
|
24
|
+
down: (options?: undefined) => Promise<MigrationResultLike>;
|
|
25
|
+
getNameVariants: () => Promise<unknown>;
|
|
26
|
+
getVersion: () => Promise<string | undefined>;
|
|
27
|
+
migrateTo: (
|
|
28
|
+
version: string,
|
|
29
|
+
options?: undefined,
|
|
30
|
+
) => Promise<MigrationResultLike>;
|
|
31
|
+
migrateToLatest: (options?: undefined) => Promise<MigrationResultLike>;
|
|
32
|
+
next: () => Promise<SchemaVersionLike | undefined>;
|
|
33
|
+
previous: () => Promise<SchemaVersionLike | undefined>;
|
|
34
|
+
up: (options?: undefined) => Promise<MigrationResultLike>;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const normalizeNullableString = (value: string | null | undefined) => {
|
|
38
|
+
if (value === null || value === undefined) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const normalized = value.trim();
|
|
43
|
+
return normalized.length > 0 ? normalized : null;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const appendPrismaModelLines = (
|
|
47
|
+
code: string,
|
|
48
|
+
modelName: string,
|
|
49
|
+
lines: string[],
|
|
50
|
+
options?: {
|
|
51
|
+
position?: "beforeAttributes" | "end";
|
|
52
|
+
},
|
|
53
|
+
) => {
|
|
54
|
+
const pattern = new RegExp(
|
|
55
|
+
`model ${modelName} \\{\\n([\\s\\S]*?)\\n\\}`,
|
|
56
|
+
"m",
|
|
57
|
+
);
|
|
58
|
+
return code.replace(pattern, (full, body: string) => {
|
|
59
|
+
const bodyLines = body.split("\n");
|
|
60
|
+
const existingLines = new Set(
|
|
61
|
+
bodyLines.map((line) => line.trim()).filter(Boolean),
|
|
62
|
+
);
|
|
63
|
+
const additions = lines
|
|
64
|
+
.filter((line) => !existingLines.has(line))
|
|
65
|
+
.map((line) => ` ${line}`);
|
|
66
|
+
|
|
67
|
+
if (additions.length === 0) {
|
|
68
|
+
return full;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (options?.position === "beforeAttributes") {
|
|
72
|
+
const insertIndex = bodyLines.findIndex((line) =>
|
|
73
|
+
line.trim().startsWith("@@"),
|
|
74
|
+
);
|
|
75
|
+
if (insertIndex === -1) {
|
|
76
|
+
bodyLines.push(...additions);
|
|
77
|
+
} else {
|
|
78
|
+
bodyLines.splice(insertIndex, 0, ...additions);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return `model ${modelName} {\n${bodyLines.join("\n")}\n}`;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return `model ${modelName} {\n${body}\n${additions.join("\n")}\n}`;
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const getPrismaDatasourceProvider = (code: string): ORMProvider | null => {
|
|
89
|
+
const match = code.match(
|
|
90
|
+
/datasource\s+\w+\s+\{[\s\S]*?provider\s*=\s*"([^"]+)"[\s\S]*?\}/m,
|
|
91
|
+
);
|
|
92
|
+
return (match?.[1] as ORMProvider | undefined) ?? null;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const ensureDrizzleIndexImport = (code: string) =>
|
|
96
|
+
code.replace(
|
|
97
|
+
/import \{ ([^}]+) \} from "(drizzle-orm\/[^"]+-core)"/,
|
|
98
|
+
(_full, imports: string, modulePath: string) => {
|
|
99
|
+
const values = imports
|
|
100
|
+
.split(",")
|
|
101
|
+
.map((value) => value.trim())
|
|
102
|
+
.filter(Boolean);
|
|
103
|
+
|
|
104
|
+
if (!values.includes("index")) {
|
|
105
|
+
values.push("index");
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return `import { ${values.join(", ")} } from "${modulePath}"`;
|
|
109
|
+
},
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const ensureDrizzleMetadataDefault = (code: string) =>
|
|
113
|
+
code
|
|
114
|
+
.replace(
|
|
115
|
+
/metadata: json\("metadata"\)\.notNull\(\)(?!\.default\(\{\}\))/,
|
|
116
|
+
'metadata: json("metadata").notNull().default({})',
|
|
117
|
+
)
|
|
118
|
+
.replace(
|
|
119
|
+
/metadata: blob\("metadata", \{ mode: "json" \}\)\.notNull\(\)(?!\.default\(\{\}\))/,
|
|
120
|
+
'metadata: blob("metadata", { mode: "json" }).notNull().default({})',
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
const removeUnusedDrizzleRelationMany = (code: string) =>
|
|
124
|
+
code.replace(
|
|
125
|
+
/export const bundle_patchesRelations = relations\(bundle_patches, \(\{ one, many \}\) => \(\{/,
|
|
126
|
+
"export const bundle_patchesRelations = relations(bundle_patches, ({ one }) => ({",
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
const ensureTrailingComma = (line: string) => {
|
|
130
|
+
const trimmed = line.trim();
|
|
131
|
+
if (!trimmed || trimmed.endsWith(",") || trimmed.endsWith("[")) {
|
|
132
|
+
return line;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return `${line},`;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const updateDrizzleTableBlock = (
|
|
139
|
+
code: string,
|
|
140
|
+
tableName: string,
|
|
141
|
+
callbackLines: string[],
|
|
142
|
+
) => {
|
|
143
|
+
const blockStart = code.indexOf(`export const ${tableName} = `);
|
|
144
|
+
if (blockStart === -1) {
|
|
145
|
+
return code;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const nextBlockStart = code.indexOf("\n\nexport const ", blockStart + 1);
|
|
149
|
+
const blockEnd = nextBlockStart === -1 ? code.length : nextBlockStart;
|
|
150
|
+
const block = code.slice(blockStart, blockEnd);
|
|
151
|
+
|
|
152
|
+
if (block.includes(", (table) => [")) {
|
|
153
|
+
const callbackPattern = /, \(table\) => \[\n([\s\S]*?)\n\]\)\s*$/;
|
|
154
|
+
const match = block.match(callbackPattern);
|
|
155
|
+
|
|
156
|
+
if (!match) {
|
|
157
|
+
return code;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const callbackBody = match[1] ?? "";
|
|
161
|
+
const existingLines = callbackBody
|
|
162
|
+
.split("\n")
|
|
163
|
+
.map((line) => line.trim())
|
|
164
|
+
.filter(Boolean);
|
|
165
|
+
const additions = callbackLines.filter(
|
|
166
|
+
(line) => !existingLines.includes(line),
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
if (additions.length === 0) {
|
|
170
|
+
return code;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const callbackBodyLines = callbackBody.split("\n");
|
|
174
|
+
for (let index = callbackBodyLines.length - 1; index >= 0; index -= 1) {
|
|
175
|
+
if (callbackBodyLines[index]?.trim()) {
|
|
176
|
+
callbackBodyLines[index] = ensureTrailingComma(
|
|
177
|
+
callbackBodyLines[index]!,
|
|
178
|
+
);
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const nextCallbackBody = [
|
|
184
|
+
...callbackBodyLines,
|
|
185
|
+
...additions.map((line) => ` ${line}`),
|
|
186
|
+
].join("\n");
|
|
187
|
+
const nextBlock = block.replace(
|
|
188
|
+
callbackPattern,
|
|
189
|
+
`, (table) => [\n${nextCallbackBody}\n])`,
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
return `${code.slice(0, blockStart)}${nextBlock}${code.slice(blockEnd)}`;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const callbackBody = callbackLines.map((line) => ` ${line}`).join("\n");
|
|
196
|
+
const nextBlock = block.replace(
|
|
197
|
+
/\n\}\)\s*$/,
|
|
198
|
+
`\n}, (table) => [\n${callbackBody}\n])`,
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
return `${code.slice(0, blockStart)}${nextBlock}${code.slice(blockEnd)}`;
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
const addCustomSqlOperation = (
|
|
205
|
+
result: MigrationResultLike,
|
|
206
|
+
sql: string,
|
|
207
|
+
): void => {
|
|
208
|
+
const normalizedSql = sql.trim();
|
|
209
|
+
const alreadyAdded = result.operations.some((operation) => {
|
|
210
|
+
return (
|
|
211
|
+
operation["type"] === "custom" &&
|
|
212
|
+
typeof operation["sql"] === "string" &&
|
|
213
|
+
operation["sql"].trim() === normalizedSql
|
|
214
|
+
);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
if (!alreadyAdded) {
|
|
218
|
+
result.operations.push({
|
|
219
|
+
type: "custom",
|
|
220
|
+
sql: normalizedSql,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
const getMigrationCustomSql = (
|
|
226
|
+
provider: ORMSQLProvider,
|
|
227
|
+
targetVersion: string,
|
|
228
|
+
): string[] => {
|
|
229
|
+
const statements: string[] = [];
|
|
230
|
+
const hasRolloutColumns = semver.gte(targetVersion, "0.29.0");
|
|
231
|
+
const hasPatchTable = semver.gte(targetVersion, "0.31.0");
|
|
232
|
+
|
|
233
|
+
if (provider === "postgresql") {
|
|
234
|
+
statements.push(
|
|
235
|
+
"create index bundles_target_app_version_idx on bundles(target_app_version)",
|
|
236
|
+
"create index bundles_fingerprint_hash_idx on bundles(fingerprint_hash)",
|
|
237
|
+
"create index bundles_channel_idx on bundles(channel)",
|
|
238
|
+
"alter table bundles add constraint check_version_or_fingerprint check ((target_app_version is not null) or (fingerprint_hash is not null))",
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
if (hasRolloutColumns) {
|
|
242
|
+
statements.push(
|
|
243
|
+
"create index bundles_rollout_idx on bundles(rollout_cohort_count)",
|
|
244
|
+
"alter table bundles add constraint bundles_rollout_cohort_count_check check (rollout_cohort_count >= 0 and rollout_cohort_count <= 1000)",
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (hasPatchTable) {
|
|
249
|
+
statements.push(
|
|
250
|
+
"create index bundle_patches_bundle_id_idx on bundle_patches(bundle_id)",
|
|
251
|
+
"create index bundle_patches_base_bundle_id_idx on bundle_patches(base_bundle_id)",
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return statements;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (provider === "mysql") {
|
|
259
|
+
statements.push(
|
|
260
|
+
"create index bundles_target_app_version_idx on bundles(target_app_version(255))",
|
|
261
|
+
"create index bundles_fingerprint_hash_idx on bundles(fingerprint_hash(255))",
|
|
262
|
+
"create index bundles_channel_idx on bundles(channel(255))",
|
|
263
|
+
"alter table bundles add constraint check_version_or_fingerprint check ((target_app_version is not null) or (fingerprint_hash is not null))",
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
if (hasRolloutColumns) {
|
|
267
|
+
statements.push(
|
|
268
|
+
"create index bundles_rollout_idx on bundles(rollout_cohort_count)",
|
|
269
|
+
"alter table bundles add constraint bundles_rollout_cohort_count_check check (rollout_cohort_count >= 0 and rollout_cohort_count <= 1000)",
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if (hasPatchTable) {
|
|
274
|
+
statements.push(
|
|
275
|
+
"create index bundle_patches_bundle_id_idx on bundle_patches(bundle_id)",
|
|
276
|
+
"create index bundle_patches_base_bundle_id_idx on bundle_patches(base_bundle_id)",
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return statements;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
statements.push(
|
|
284
|
+
"create index bundles_target_app_version_idx on bundles(target_app_version)",
|
|
285
|
+
"create index bundles_fingerprint_hash_idx on bundles(fingerprint_hash)",
|
|
286
|
+
"create index bundles_channel_idx on bundles(channel)",
|
|
287
|
+
);
|
|
288
|
+
|
|
289
|
+
if (hasRolloutColumns) {
|
|
290
|
+
statements.push(
|
|
291
|
+
"create index bundles_rollout_idx on bundles(rollout_cohort_count)",
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if (hasPatchTable) {
|
|
296
|
+
statements.push(
|
|
297
|
+
"create index bundle_patches_bundle_id_idx on bundle_patches(bundle_id)",
|
|
298
|
+
"create index bundle_patches_base_bundle_id_idx on bundle_patches(base_bundle_id)",
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
return statements;
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
const enhanceUpwardMigrationResult = (
|
|
306
|
+
result: MigrationResultLike,
|
|
307
|
+
provider: ORMSQLProvider,
|
|
308
|
+
targetVersion: string,
|
|
309
|
+
) => {
|
|
310
|
+
for (const sql of getMigrationCustomSql(provider, targetVersion)) {
|
|
311
|
+
addCustomSqlOperation(result, sql);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
return result;
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
export const assertBundlePersistenceConstraints = (
|
|
318
|
+
bundle: Pick<
|
|
319
|
+
Bundle,
|
|
320
|
+
| "fingerprintHash"
|
|
321
|
+
| "rolloutCohortCount"
|
|
322
|
+
| "targetAppVersion"
|
|
323
|
+
| "targetCohorts"
|
|
324
|
+
>,
|
|
325
|
+
) => {
|
|
326
|
+
const targetAppVersion = normalizeNullableString(bundle.targetAppVersion);
|
|
327
|
+
const fingerprintHash = normalizeNullableString(bundle.fingerprintHash);
|
|
328
|
+
|
|
329
|
+
if (!targetAppVersion && !fingerprintHash) {
|
|
330
|
+
throw new Error(
|
|
331
|
+
"Bundle must define either targetAppVersion or fingerprintHash.",
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
const rolloutCohortCount = bundle.rolloutCohortCount;
|
|
336
|
+
if (rolloutCohortCount !== null && rolloutCohortCount !== undefined) {
|
|
337
|
+
if (
|
|
338
|
+
!Number.isInteger(rolloutCohortCount) ||
|
|
339
|
+
rolloutCohortCount < 0 ||
|
|
340
|
+
rolloutCohortCount > DEFAULT_ROLLOUT_COHORT_COUNT
|
|
341
|
+
) {
|
|
342
|
+
throw new Error(
|
|
343
|
+
`rolloutCohortCount must be an integer between 0 and ${DEFAULT_ROLLOUT_COHORT_COUNT}.`,
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
for (const cohort of bundle.targetCohorts ?? []) {
|
|
349
|
+
if (!isValidCohort(cohort)) {
|
|
350
|
+
throw new Error(
|
|
351
|
+
`Invalid target cohort "${cohort}". ${INVALID_COHORT_ERROR_MESSAGE}`,
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
export const enhanceGeneratedSchema = (
|
|
358
|
+
adapterName: AdapterName,
|
|
359
|
+
code: string,
|
|
360
|
+
provider?: ORMProvider,
|
|
361
|
+
) => {
|
|
362
|
+
if (adapterName === "prisma") {
|
|
363
|
+
const datasourceProvider = provider ?? getPrismaDatasourceProvider(code);
|
|
364
|
+
let nextCode = code;
|
|
365
|
+
|
|
366
|
+
if (datasourceProvider !== "sqlite") {
|
|
367
|
+
nextCode = nextCode.replace(
|
|
368
|
+
/^(\s*metadata\s+Json)(?!\s+@default\("?\{\}"?\))(.*)$/m,
|
|
369
|
+
'$1 @default("{}")$2',
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
nextCode = appendPrismaModelLines(
|
|
374
|
+
nextCode,
|
|
375
|
+
"bundles",
|
|
376
|
+
[
|
|
377
|
+
'patches bundle_patches[] @relation("bundle_patches_bundles_patches")',
|
|
378
|
+
'baseForPatches bundle_patches[] @relation("bundle_patches_bundles_baseForPatches")',
|
|
379
|
+
],
|
|
380
|
+
{
|
|
381
|
+
position: "beforeAttributes",
|
|
382
|
+
},
|
|
383
|
+
);
|
|
384
|
+
nextCode = appendPrismaModelLines(nextCode, "bundles", [
|
|
385
|
+
'@@index([target_app_version], map: "bundles_target_app_version_idx")',
|
|
386
|
+
'@@index([fingerprint_hash], map: "bundles_fingerprint_hash_idx")',
|
|
387
|
+
'@@index([channel], map: "bundles_channel_idx")',
|
|
388
|
+
'@@index([rollout_cohort_count], map: "bundles_rollout_idx")',
|
|
389
|
+
]);
|
|
390
|
+
return appendPrismaModelLines(nextCode, "bundle_patches", [
|
|
391
|
+
'@@index([bundle_id], map: "bundle_patches_bundle_id_idx")',
|
|
392
|
+
'@@index([base_bundle_id], map: "bundle_patches_base_bundle_id_idx")',
|
|
393
|
+
]);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
if (adapterName === "drizzle") {
|
|
397
|
+
let nextCode = ensureDrizzleMetadataDefault(code);
|
|
398
|
+
nextCode = removeUnusedDrizzleRelationMany(nextCode);
|
|
399
|
+
nextCode = ensureDrizzleIndexImport(nextCode);
|
|
400
|
+
nextCode = updateDrizzleTableBlock(nextCode, "bundles", [
|
|
401
|
+
'index("bundles_target_app_version_idx").on(table.target_app_version),',
|
|
402
|
+
'index("bundles_fingerprint_hash_idx").on(table.fingerprint_hash),',
|
|
403
|
+
'index("bundles_channel_idx").on(table.channel),',
|
|
404
|
+
'index("bundles_rollout_idx").on(table.rollout_cohort_count),',
|
|
405
|
+
]);
|
|
406
|
+
nextCode = updateDrizzleTableBlock(nextCode, "bundle_patches", [
|
|
407
|
+
'index("bundle_patches_bundle_id_idx").on(table.bundle_id),',
|
|
408
|
+
'index("bundle_patches_base_bundle_id_idx").on(table.base_bundle_id),',
|
|
409
|
+
]);
|
|
410
|
+
return nextCode;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
return code;
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
export const wrapKyselyMigrator = <TMigrator extends MigratorLike>(
|
|
417
|
+
migrator: TMigrator,
|
|
418
|
+
provider: ORMSQLProvider | undefined,
|
|
419
|
+
latestVersion: string,
|
|
420
|
+
): TMigrator => {
|
|
421
|
+
if (!provider) {
|
|
422
|
+
return migrator;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
return {
|
|
426
|
+
...migrator,
|
|
427
|
+
async up(...args: Parameters<TMigrator["up"]>) {
|
|
428
|
+
const next = await migrator.next();
|
|
429
|
+
const result = await migrator.up(...args);
|
|
430
|
+
|
|
431
|
+
if (next) {
|
|
432
|
+
enhanceUpwardMigrationResult(result, provider, next.version);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
return result;
|
|
436
|
+
},
|
|
437
|
+
async migrateTo(...args: Parameters<TMigrator["migrateTo"]>) {
|
|
438
|
+
const version = args[0];
|
|
439
|
+
const options = args[1];
|
|
440
|
+
const currentVersion = await migrator.getVersion();
|
|
441
|
+
const result = await migrator.migrateTo(version, options);
|
|
442
|
+
|
|
443
|
+
if (!currentVersion || semver.gt(version, currentVersion)) {
|
|
444
|
+
enhanceUpwardMigrationResult(result, provider, version);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
return result;
|
|
448
|
+
},
|
|
449
|
+
async migrateToLatest(...args: Parameters<TMigrator["migrateToLatest"]>) {
|
|
450
|
+
const currentVersion = await migrator.getVersion();
|
|
451
|
+
const result = await migrator.migrateToLatest(...args);
|
|
452
|
+
|
|
453
|
+
if (!currentVersion || semver.gt(latestVersion, currentVersion)) {
|
|
454
|
+
enhanceUpwardMigrationResult(result, provider, latestVersion);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
return result;
|
|
458
|
+
},
|
|
459
|
+
} as TMigrator;
|
|
460
|
+
};
|
package/src/db/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
2
|
+
AppUpdateAvailableInfo,
|
|
3
3
|
Bundle,
|
|
4
4
|
GetBundlesArgs,
|
|
5
5
|
UpdateInfo,
|
|
@@ -8,17 +8,36 @@ import type {
|
|
|
8
8
|
DatabaseBundleQueryOptions,
|
|
9
9
|
DatabasePlugin,
|
|
10
10
|
HotUpdaterContext,
|
|
11
|
-
|
|
11
|
+
RuntimeStoragePlugin,
|
|
12
12
|
} from "@hot-updater/plugin-core";
|
|
13
|
-
import type
|
|
13
|
+
import { sqlProviders, type Provider, type SQLProvider } from "fumadb";
|
|
14
14
|
|
|
15
15
|
import type { PaginatedResult } from "../types";
|
|
16
16
|
|
|
17
17
|
export type DatabasePluginFactory<TContext = unknown> =
|
|
18
18
|
() => DatabasePlugin<TContext>;
|
|
19
19
|
|
|
20
|
+
export type ORMProvider = Provider;
|
|
21
|
+
export type ORMSQLProvider = SQLProvider;
|
|
22
|
+
|
|
23
|
+
export interface ORMDatabaseAdapter {
|
|
24
|
+
name: string;
|
|
25
|
+
provider?: ORMProvider;
|
|
26
|
+
createORM(this: any, schema: any): unknown;
|
|
27
|
+
getSchemaVersion(this: any): Promise<string | undefined>;
|
|
28
|
+
generateSchema?: (
|
|
29
|
+
this: any,
|
|
30
|
+
schema: any,
|
|
31
|
+
schemaName: string,
|
|
32
|
+
) => {
|
|
33
|
+
code: string;
|
|
34
|
+
path: string;
|
|
35
|
+
};
|
|
36
|
+
createMigrationEngine?: (this: any) => unknown;
|
|
37
|
+
}
|
|
38
|
+
|
|
20
39
|
export type DatabaseAdapter<TContext = unknown> =
|
|
21
|
-
|
|
|
40
|
+
| ORMDatabaseAdapter
|
|
22
41
|
| DatabasePlugin<TContext>
|
|
23
42
|
| DatabasePluginFactory<TContext>;
|
|
24
43
|
|
|
@@ -42,10 +61,22 @@ export function isDatabasePlugin<TContext = unknown>(
|
|
|
42
61
|
|
|
43
62
|
export function isFumaAdapter<TContext = unknown>(
|
|
44
63
|
adapter: DatabaseAdapter<TContext>,
|
|
45
|
-
): adapter is
|
|
64
|
+
): adapter is ORMDatabaseAdapter {
|
|
46
65
|
return !isDatabasePluginFactory(adapter) && !isDatabasePlugin(adapter);
|
|
47
66
|
}
|
|
48
67
|
|
|
68
|
+
export function getSQLProvider(
|
|
69
|
+
provider: ORMProvider | undefined,
|
|
70
|
+
): ORMSQLProvider | undefined {
|
|
71
|
+
if (!provider) {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return sqlProviders.includes(provider as ORMSQLProvider)
|
|
76
|
+
? (provider as ORMSQLProvider)
|
|
77
|
+
: undefined;
|
|
78
|
+
}
|
|
79
|
+
|
|
49
80
|
export interface DatabaseAPI<TContext = unknown> {
|
|
50
81
|
getBundleById(
|
|
51
82
|
id: string,
|
|
@@ -58,7 +89,7 @@ export interface DatabaseAPI<TContext = unknown> {
|
|
|
58
89
|
getAppUpdateInfo(
|
|
59
90
|
args: GetBundlesArgs,
|
|
60
91
|
context?: HotUpdaterContext<TContext>,
|
|
61
|
-
): Promise<
|
|
92
|
+
): Promise<AppUpdateAvailableInfo | null>;
|
|
62
93
|
getChannels(context?: HotUpdaterContext<TContext>): Promise<string[]>;
|
|
63
94
|
getBundles(
|
|
64
95
|
options: DatabaseBundleQueryOptions,
|
|
@@ -80,4 +111,4 @@ export interface DatabaseAPI<TContext = unknown> {
|
|
|
80
111
|
}
|
|
81
112
|
|
|
82
113
|
export type StoragePluginFactory<TContext = unknown> =
|
|
83
|
-
() =>
|
|
114
|
+
() => RuntimeStoragePlugin<TContext>;
|