@hot-updater/server 0.33.1 → 0.34.0
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 +0 -2
- package/dist/adapters/drizzle.cjs +195 -2
- package/dist/adapters/drizzle.d.cts +7 -4
- package/dist/adapters/drizzle.d.mts +7 -4
- package/dist/adapters/drizzle.mjs +194 -2
- package/dist/adapters/drizzleLazyDB.cjs +53 -0
- package/dist/adapters/drizzleLazyDB.mjs +53 -0
- package/dist/adapters/kysely.cjs +154 -3
- package/dist/adapters/kysely.d.cts +18 -10
- package/dist/adapters/kysely.d.mts +18 -10
- package/dist/adapters/kysely.mjs +153 -3
- package/dist/adapters/mongodb.cjs +183 -2
- package/dist/adapters/mongodb.d.cts +5 -4
- package/dist/adapters/mongodb.d.mts +5 -4
- package/dist/adapters/mongodb.mjs +183 -2
- package/dist/adapters/prisma.cjs +200 -2
- package/dist/adapters/prisma.d.cts +9 -4
- package/dist/adapters/prisma.d.mts +9 -4
- package/dist/adapters/prisma.mjs +199 -2
- package/dist/db/bundleRows.cjs +82 -0
- package/dist/db/bundleRows.d.cts +33 -0
- package/dist/db/bundleRows.d.mts +33 -0
- package/dist/db/bundleRows.mjs +79 -0
- package/dist/db/fixedMigrator.cjs +136 -0
- package/dist/db/fixedMigrator.mjs +135 -0
- package/dist/db/index.cjs +17 -15
- package/dist/db/index.d.cts +3 -3
- package/dist/db/index.d.mts +3 -3
- package/dist/db/index.mjs +17 -15
- package/dist/db/pluginCore.cjs +13 -5
- package/dist/db/pluginCore.mjs +13 -5
- package/dist/db/schema/mongodb.cjs +17 -0
- package/dist/db/schema/mongodb.mjs +17 -0
- package/dist/db/schema/registry.cjs +23 -0
- package/dist/db/schema/registry.mjs +18 -0
- package/dist/db/schema/sql.cjs +84 -0
- package/dist/db/schema/sql.mjs +78 -0
- package/dist/db/schema/sqlMigrations.cjs +74 -0
- package/dist/db/schema/sqlMigrations.mjs +73 -0
- package/dist/db/schema/sqlOperations.cjs +27 -0
- package/dist/db/schema/sqlOperations.mjs +26 -0
- package/dist/db/schemaEnhancements.cjs +1 -152
- package/dist/db/schemaEnhancements.mjs +1 -149
- package/dist/db/schemaGenerators.cjs +222 -0
- package/dist/db/schemaGenerators.mjs +220 -0
- package/dist/db/schemaReadiness.cjs +23 -0
- package/dist/db/schemaReadiness.d.cts +8 -0
- package/dist/db/schemaReadiness.d.mts +8 -0
- package/dist/db/schemaReadiness.mjs +22 -0
- package/dist/db/types.cjs +10 -2
- package/dist/db/types.d.cts +58 -14
- package/dist/db/types.d.mts +58 -14
- package/dist/db/types.mjs +9 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +3 -2
- package/dist/index.d.mts +3 -2
- package/dist/index.mjs +2 -2
- package/dist/{packages/server/package.cjs → package.cjs} +1 -1
- package/dist/{packages/server/package.mjs → package.mjs} +1 -1
- package/dist/runtime.cjs +9 -2
- package/dist/runtime.mjs +9 -2
- package/dist/schema/dsl.cjs +86 -0
- package/dist/schema/dsl.mjs +73 -0
- package/dist/schema/index.cjs +13 -0
- package/dist/schema/index.mjs +13 -0
- package/dist/schema/settings.cjs +9 -0
- package/dist/schema/settings.mjs +9 -0
- package/dist/schema/types.cjs +6 -0
- package/dist/schema/types.mjs +5 -0
- package/dist/schema/v0_21_0.cjs +33 -18
- package/dist/schema/v0_21_0.mjs +32 -18
- package/dist/schema/v0_29_0.cjs +40 -20
- package/dist/schema/v0_29_0.mjs +39 -20
- package/dist/schema/v0_31_0.cjs +77 -43
- package/dist/schema/v0_31_0.mjs +75 -43
- package/dist/version.cjs +1 -1
- package/dist/version.mjs +1 -1
- package/package.json +30 -16
- package/src/adapters/drizzle.spec.ts +75 -0
- package/src/adapters/drizzle.ts +328 -12
- package/src/adapters/drizzleLazyDB.ts +151 -0
- package/src/adapters/kysely.spec.ts +107 -0
- package/src/adapters/kysely.ts +349 -14
- package/src/adapters/mongodb.ts +298 -15
- package/src/adapters/prisma.ts +337 -12
- package/src/db/bundleRows.ts +140 -0
- package/src/db/fixedMigrator.spec.ts +89 -0
- package/src/db/fixedMigrator.ts +288 -0
- package/src/db/hotUpdaterSchema.ts +6 -0
- package/src/db/index.spec.ts +976 -13
- package/src/db/index.ts +37 -36
- package/src/db/pluginCore.spec.ts +17 -11
- package/src/db/pluginCore.ts +15 -6
- package/src/db/schema/definitions.ts +1 -0
- package/src/db/schema/mongodb.ts +26 -0
- package/src/db/schema/registry.ts +55 -0
- package/src/db/schema/sql.ts +200 -0
- package/src/db/schema/sqlMigrations.ts +219 -0
- package/src/db/schema/sqlOperations.ts +62 -0
- package/src/db/schema/types.ts +1 -0
- package/src/db/schemaEnhancements.ts +0 -405
- package/src/db/schemaGenerators.ts +382 -0
- package/src/db/schemaReadiness.ts +33 -0
- package/src/db/types.ts +69 -25
- package/src/runtime.spec.ts +70 -0
- package/src/runtime.ts +14 -2
- package/src/schema/dsl-all-versions.spec.ts +26 -0
- package/src/schema/dsl.ts +148 -0
- package/src/schema/index.ts +16 -0
- package/src/schema/settings.ts +15 -0
- package/src/schema/types.ts +73 -0
- package/src/schema/v0_21_0.ts +48 -18
- package/src/schema/v0_29_0.ts +58 -22
- package/src/schema/v0_31_0.spec.ts +73 -0
- package/src/schema/v0_31_0.ts +116 -54
- package/dist/_virtual/_rolldown/runtime.mjs +0 -6
- package/dist/calculatePagination.cjs +0 -25
- package/dist/calculatePagination.mjs +0 -25
- package/dist/db/ormCore.cjs +0 -577
- package/dist/db/ormCore.d.cts +0 -110
- package/dist/db/ormCore.d.mts +0 -110
- package/dist/db/ormCore.mjs +0 -575
- package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/_u64.cjs +0 -112
- package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/_u64.mjs +0 -108
- package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/cryptoNode.cjs +0 -22
- package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/cryptoNode.mjs +0 -18
- package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/sha3.cjs +0 -219
- package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/sha3.mjs +0 -214
- package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/utils.cjs +0 -275
- package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/utils.mjs +0 -270
- package/dist/node_modules/.pnpm/@paralleldrive_cuid2@2.3.1/node_modules/@paralleldrive/cuid2/index.cjs +0 -17
- package/dist/node_modules/.pnpm/@paralleldrive_cuid2@2.3.1/node_modules/@paralleldrive/cuid2/index.mjs +0 -13
- package/dist/node_modules/.pnpm/@paralleldrive_cuid2@2.3.1/node_modules/@paralleldrive/cuid2/src/index.cjs +0 -69
- package/dist/node_modules/.pnpm/@paralleldrive_cuid2@2.3.1/node_modules/@paralleldrive/cuid2/src/index.mjs +0 -65
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/column.cjs +0 -52
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/column.mjs +0 -52
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/entity.cjs +0 -16
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/entity.mjs +0 -15
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/pg-core/columns/enum.cjs +0 -7
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/pg-core/columns/enum.mjs +0 -7
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/sql/expressions/conditions.cjs +0 -92
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/sql/expressions/conditions.mjs +0 -78
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/sql/expressions/select.cjs +0 -11
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/sql/expressions/select.mjs +0 -10
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/sql/sql.cjs +0 -383
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/sql/sql.mjs +0 -366
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/subquery.cjs +0 -17
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/subquery.mjs +0 -17
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/table.cjs +0 -60
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/table.mjs +0 -59
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/table.utils.cjs +0 -4
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/table.utils.mjs +0 -4
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/tracing.cjs +0 -6
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/tracing.mjs +0 -6
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/view-common.cjs +0 -4
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/view-common.mjs +0 -4
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/adapters/drizzle/index.cjs +0 -383
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/adapters/drizzle/index.d.cts +0 -12
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/adapters/drizzle/index.d.mts +0 -12
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/adapters/drizzle/index.mjs +0 -383
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/adapters/kysely/index.cjs +0 -4
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/adapters/kysely/index.mjs +0 -5
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/adapters/prisma/index.cjs +0 -339
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/adapters/prisma/index.d.cts +0 -70
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/adapters/prisma/index.d.mts +0 -70
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/adapters/prisma/index.mjs +0 -339
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-7PZK4ONR.cjs +0 -57
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-7PZK4ONR.mjs +0 -56
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-C6OTUURW.cjs +0 -330
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-C6OTUURW.mjs +0 -326
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-CHTIKPQU.cjs +0 -166
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-CHTIKPQU.mjs +0 -163
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-GUE4GMNC.cjs +0 -14
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-GUE4GMNC.mjs +0 -13
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-LHHP6UVP.cjs +0 -24
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-LHHP6UVP.mjs +0 -24
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-LVCPMTAT.cjs +0 -1190
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-LVCPMTAT.mjs +0 -1189
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-PK2W2SQ7.cjs +0 -197
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-PK2W2SQ7.mjs +0 -197
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-ZEQMAIFI.cjs +0 -410
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-ZEQMAIFI.mjs +0 -400
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-ZOCGSAWS.cjs +0 -213
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-ZOCGSAWS.mjs +0 -212
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/create-tg0451Y_.d.cts +0 -285
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/create-tg0451Y_.d.mts +0 -285
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/index-CMqePMTF.d.cts +0 -45
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/index-CMqePMTF.d.mts +0 -45
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/index.cjs +0 -69
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/index.d.cts +0 -49
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/index.d.mts +0 -49
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/index.mjs +0 -67
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/query/index.d.cts +0 -156
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/query/index.d.mts +0 -156
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/schema/index.cjs +0 -1
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/schema/index.mjs +0 -2
- package/src/db/ormCore.ts +0 -1059
- package/src/db/ormUpdateCheck.bench.ts +0 -262
package/dist/schema/v0_31_0.mjs
CHANGED
|
@@ -1,48 +1,80 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "
|
|
1
|
+
import { HOT_UPDATER_SETTINGS_TABLE } from "./types.mjs";
|
|
2
|
+
import { bool, check, column, foreignKey, idColumn, index, integer, json, relation, schema, stringColumn, table, uuid, varchar } from "./dsl.mjs";
|
|
3
|
+
import { createSettingsTable } from "./settings.mjs";
|
|
3
4
|
//#region src/schema/v0_31_0.ts
|
|
5
|
+
const bundlesV031 = table("bundles", {
|
|
6
|
+
id: idColumn("id", "uuid"),
|
|
7
|
+
platform: stringColumn("platform"),
|
|
8
|
+
should_force_update: bool("should_force_update"),
|
|
9
|
+
enabled: bool("enabled"),
|
|
10
|
+
file_hash: stringColumn("file_hash"),
|
|
11
|
+
git_commit_hash: stringColumn("git_commit_hash").nullable(),
|
|
12
|
+
message: stringColumn("message").nullable(),
|
|
13
|
+
channel: stringColumn("channel").defaultTo("production"),
|
|
14
|
+
storage_uri: stringColumn("storage_uri"),
|
|
15
|
+
target_app_version: stringColumn("target_app_version").nullable(),
|
|
16
|
+
fingerprint_hash: stringColumn("fingerprint_hash").nullable(),
|
|
17
|
+
metadata: json("metadata").defaultTo({}),
|
|
18
|
+
rollout_cohort_count: integer("rollout_cohort_count").defaultTo(1e3),
|
|
19
|
+
target_cohorts: json("target_cohorts").nullable(),
|
|
20
|
+
manifest_storage_uri: stringColumn("manifest_storage_uri").nullable(),
|
|
21
|
+
manifest_file_hash: stringColumn("manifest_file_hash").nullable(),
|
|
22
|
+
asset_base_storage_uri: stringColumn("asset_base_storage_uri").nullable()
|
|
23
|
+
}, {
|
|
24
|
+
indexes: [
|
|
25
|
+
index("bundles_target_app_version_idx", ["target_app_version"]),
|
|
26
|
+
index("bundles_fingerprint_hash_idx", ["fingerprint_hash"]),
|
|
27
|
+
index("bundles_channel_idx", ["channel"]),
|
|
28
|
+
index("bundles_platform_idx", ["platform"], ["mongodb"]),
|
|
29
|
+
index("bundles_rollout_idx", ["rollout_cohort_count"])
|
|
30
|
+
],
|
|
31
|
+
checks: [check({
|
|
32
|
+
name: "check_version_or_fingerprint",
|
|
33
|
+
expression: "(target_app_version is not null) or (fingerprint_hash is not null)",
|
|
34
|
+
sqliteInline: true
|
|
35
|
+
}), check({
|
|
36
|
+
name: "bundles_rollout_cohort_count_check",
|
|
37
|
+
expression: "rollout_cohort_count >= 0 and rollout_cohort_count <= 1000",
|
|
38
|
+
sqliteInline: true
|
|
39
|
+
})]
|
|
40
|
+
});
|
|
41
|
+
const bundlePatchesV031 = table("bundle_patches", {
|
|
42
|
+
id: idColumn("id", varchar(255)),
|
|
43
|
+
bundle_id: uuid("bundle_id"),
|
|
44
|
+
base_bundle_id: uuid("base_bundle_id"),
|
|
45
|
+
base_file_hash: column("base_file_hash", "string"),
|
|
46
|
+
patch_file_hash: column("patch_file_hash", "string"),
|
|
47
|
+
patch_storage_uri: column("patch_storage_uri", "string"),
|
|
48
|
+
order_index: integer("order_index").defaultTo(0)
|
|
49
|
+
}, {
|
|
50
|
+
indexes: [index("bundle_patches_bundle_id_idx", ["bundle_id"]), index("bundle_patches_base_bundle_id_idx", ["base_bundle_id"])],
|
|
51
|
+
foreignKeys: [foreignKey("bundle_patches_bundle_id_fk", ["bundle_id"], "bundles", ["id"]), foreignKey("bundle_patches_base_bundle_id_fk", ["base_bundle_id"], "bundles", ["id"])],
|
|
52
|
+
relations: [relation({
|
|
53
|
+
name: "bundle",
|
|
54
|
+
fieldName: "patches",
|
|
55
|
+
targetFieldName: "bundle",
|
|
56
|
+
relationName: "bundle_patches_bundles_patches",
|
|
57
|
+
columns: ["bundle_id"],
|
|
58
|
+
referencedTable: "bundles",
|
|
59
|
+
referencedColumns: ["id"]
|
|
60
|
+
}), relation({
|
|
61
|
+
name: "baseBundle",
|
|
62
|
+
fieldName: "baseForPatches",
|
|
63
|
+
targetFieldName: "baseBundle",
|
|
64
|
+
relationName: "bundle_patches_bundles_baseForPatches",
|
|
65
|
+
columns: ["base_bundle_id"],
|
|
66
|
+
referencedTable: "bundles",
|
|
67
|
+
referencedColumns: ["id"]
|
|
68
|
+
})]
|
|
69
|
+
});
|
|
4
70
|
const v0_31_0 = schema({
|
|
5
71
|
version: "0.31.0",
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
file_hash: column("file_hash", "string"),
|
|
13
|
-
git_commit_hash: column("git_commit_hash", "string").nullable(),
|
|
14
|
-
message: column("message", "string").nullable(),
|
|
15
|
-
channel: column("channel", "string").defaultTo("production"),
|
|
16
|
-
storage_uri: column("storage_uri", "string"),
|
|
17
|
-
target_app_version: column("target_app_version", "string").nullable(),
|
|
18
|
-
fingerprint_hash: column("fingerprint_hash", "string").nullable(),
|
|
19
|
-
metadata: column("metadata", "json"),
|
|
20
|
-
manifest_storage_uri: column("manifest_storage_uri", "string").nullable(),
|
|
21
|
-
manifest_file_hash: column("manifest_file_hash", "string").nullable(),
|
|
22
|
-
asset_base_storage_uri: column("asset_base_storage_uri", "string").nullable(),
|
|
23
|
-
rollout_cohort_count: column("rollout_cohort_count", "integer").defaultTo(1e3),
|
|
24
|
-
target_cohorts: column("target_cohorts", "json").nullable()
|
|
25
|
-
}),
|
|
26
|
-
bundle_patches: table("bundle_patches", {
|
|
27
|
-
id: idColumn("id", "varchar(255)"),
|
|
28
|
-
bundle_id: column("bundle_id", "uuid"),
|
|
29
|
-
base_bundle_id: column("base_bundle_id", "uuid"),
|
|
30
|
-
base_file_hash: column("base_file_hash", "string"),
|
|
31
|
-
patch_file_hash: column("patch_file_hash", "string"),
|
|
32
|
-
patch_storage_uri: column("patch_storage_uri", "string"),
|
|
33
|
-
order_index: column("order_index", "integer").defaultTo(0)
|
|
34
|
-
})
|
|
35
|
-
},
|
|
36
|
-
relations: { bundle_patches: (builder) => ({
|
|
37
|
-
bundle: builder.one("bundles", ["bundle_id", "id"]).imply("patches").foreignKey({
|
|
38
|
-
name: "bundle_patches_bundle_id_fk",
|
|
39
|
-
onDelete: "CASCADE"
|
|
40
|
-
}),
|
|
41
|
-
baseBundle: builder.one("bundles", ["base_bundle_id", "id"]).imply("baseForPatches").foreignKey({
|
|
42
|
-
name: "bundle_patches_base_bundle_id_fk",
|
|
43
|
-
onDelete: "CASCADE"
|
|
44
|
-
})
|
|
45
|
-
}) }
|
|
72
|
+
settingsTable: HOT_UPDATER_SETTINGS_TABLE,
|
|
73
|
+
tables: [
|
|
74
|
+
bundlesV031,
|
|
75
|
+
bundlePatchesV031,
|
|
76
|
+
createSettingsTable("0.31.0")
|
|
77
|
+
]
|
|
46
78
|
});
|
|
47
79
|
//#endregion
|
|
48
|
-
export { v0_31_0 };
|
|
80
|
+
export { bundlePatchesV031, bundlesV031, v0_31_0 };
|
package/dist/version.cjs
CHANGED
package/dist/version.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React Native OTA solution for self-hosted",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -53,32 +53,46 @@
|
|
|
53
53
|
"access": "public"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"fumadb": "0.2.2",
|
|
57
|
-
"kysely": "0.28.17",
|
|
58
|
-
"mongodb": "6.20.0",
|
|
59
56
|
"rou3": "0.7.9",
|
|
60
57
|
"semver": "^7.7.2",
|
|
61
|
-
"@hot-updater/
|
|
62
|
-
"@hot-updater/
|
|
63
|
-
"@hot-updater/
|
|
64
|
-
"@hot-updater/
|
|
58
|
+
"@hot-updater/bsdiff": "0.34.0",
|
|
59
|
+
"@hot-updater/core": "0.34.0",
|
|
60
|
+
"@hot-updater/js": "0.34.0",
|
|
61
|
+
"@hot-updater/plugin-core": "0.34.0"
|
|
62
|
+
},
|
|
63
|
+
"peerDependencies": {
|
|
64
|
+
"@prisma/client": "*",
|
|
65
|
+
"drizzle-orm": "*",
|
|
66
|
+
"kysely": "*",
|
|
67
|
+
"mongodb": "*"
|
|
68
|
+
},
|
|
69
|
+
"peerDependenciesMeta": {
|
|
70
|
+
"@prisma/client": {
|
|
71
|
+
"optional": true
|
|
72
|
+
},
|
|
73
|
+
"drizzle-orm": {
|
|
74
|
+
"optional": true
|
|
75
|
+
},
|
|
76
|
+
"kysely": {
|
|
77
|
+
"optional": true
|
|
78
|
+
},
|
|
79
|
+
"mongodb": {
|
|
80
|
+
"optional": true
|
|
81
|
+
}
|
|
65
82
|
},
|
|
66
83
|
"devDependencies": {
|
|
67
84
|
"@electric-sql/pglite": "0.4.1",
|
|
68
85
|
"@types/node": "^20",
|
|
69
86
|
"@types/semver": "^7.5.8",
|
|
87
|
+
"drizzle-orm": "0.45.2",
|
|
70
88
|
"execa": "9.5.2",
|
|
89
|
+
"kysely": "0.28.17",
|
|
71
90
|
"kysely-pglite-dialect": "1.2.0",
|
|
91
|
+
"mongodb": "6.20.0",
|
|
72
92
|
"msw": "^2.7.0",
|
|
73
93
|
"uuidv7": "^1.0.2",
|
|
74
|
-
"@hot-updater/standalone": "0.
|
|
75
|
-
"@hot-updater/test-utils": "0.
|
|
76
|
-
},
|
|
77
|
-
"inlinedDependencies": {
|
|
78
|
-
"@noble/hashes": "1.8.0",
|
|
79
|
-
"@paralleldrive/cuid2": "2.3.1",
|
|
80
|
-
"drizzle-orm": "0.45.2",
|
|
81
|
-
"fumadb": "0.2.2"
|
|
94
|
+
"@hot-updater/standalone": "0.34.0",
|
|
95
|
+
"@hot-updater/test-utils": "0.34.0"
|
|
82
96
|
},
|
|
83
97
|
"scripts": {
|
|
84
98
|
"build": "tsdown",
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { createHotUpdater } from "../db";
|
|
4
|
+
import { drizzleAdapter } from "./drizzle";
|
|
5
|
+
|
|
6
|
+
describe("drizzleAdapter", () => {
|
|
7
|
+
it("generates schema without resolving a lazy runtime database", () => {
|
|
8
|
+
const getDB = vi.fn(() => {
|
|
9
|
+
throw new Error("runtime database should not be opened");
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const hotUpdater = createHotUpdater({
|
|
13
|
+
database: drizzleAdapter({
|
|
14
|
+
db: getDB,
|
|
15
|
+
provider: "postgresql",
|
|
16
|
+
}),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const schema = hotUpdater.generateSchema("latest");
|
|
20
|
+
|
|
21
|
+
expect(schema.path).toBe("hot-updater-schema.ts");
|
|
22
|
+
expect(schema.code).toContain("pgTable");
|
|
23
|
+
expect(getDB).not.toHaveBeenCalled();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("resolves a lazy runtime database only when a database operation runs", async () => {
|
|
27
|
+
const bundles = { channel: "channel" };
|
|
28
|
+
const bundlePatches = { bundle_id: "bundle_id" };
|
|
29
|
+
const db = {
|
|
30
|
+
_: { fullSchema: { bundle_patches: bundlePatches, bundles } },
|
|
31
|
+
$count: vi.fn(),
|
|
32
|
+
delete: vi.fn(),
|
|
33
|
+
insert: vi.fn(),
|
|
34
|
+
query: {
|
|
35
|
+
bundle_patches: {
|
|
36
|
+
findMany: vi.fn(),
|
|
37
|
+
},
|
|
38
|
+
bundles: {
|
|
39
|
+
findFirst: vi.fn(),
|
|
40
|
+
findMany: vi.fn(async () => [{ channel: "production" }]),
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
select: vi.fn(),
|
|
44
|
+
update: vi.fn(),
|
|
45
|
+
};
|
|
46
|
+
const getDB = vi.fn(async () => db);
|
|
47
|
+
|
|
48
|
+
const plugin = drizzleAdapter({
|
|
49
|
+
db: getDB,
|
|
50
|
+
provider: "postgresql",
|
|
51
|
+
schema: { bundle_patches: bundlePatches, bundles },
|
|
52
|
+
})();
|
|
53
|
+
|
|
54
|
+
expect(getDB).not.toHaveBeenCalled();
|
|
55
|
+
|
|
56
|
+
await expect(plugin.getChannels()).resolves.toEqual(["production"]);
|
|
57
|
+
expect(getDB).toHaveBeenCalledOnce();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("requires schema for lazy runtime database configs", async () => {
|
|
61
|
+
const getDB = vi.fn(() => {
|
|
62
|
+
throw new Error("runtime database should not be opened");
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const plugin = drizzleAdapter({
|
|
66
|
+
db: getDB,
|
|
67
|
+
provider: "postgresql",
|
|
68
|
+
})();
|
|
69
|
+
|
|
70
|
+
await expect(plugin.getChannels()).rejects.toThrow(
|
|
71
|
+
"[hot-updater] Drizzle adapter requires schema when db is lazy.",
|
|
72
|
+
);
|
|
73
|
+
expect(getDB).not.toHaveBeenCalled();
|
|
74
|
+
});
|
|
75
|
+
});
|
package/src/adapters/drizzle.ts
CHANGED
|
@@ -1,15 +1,331 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NIL_UUID } from "@hot-updater/core";
|
|
2
|
+
import type {
|
|
3
|
+
Bundle,
|
|
4
|
+
DatabaseBundleQueryOptions,
|
|
5
|
+
DatabaseBundleQueryWhere,
|
|
6
|
+
} from "@hot-updater/plugin-core";
|
|
7
|
+
import {
|
|
8
|
+
calculatePagination,
|
|
9
|
+
createDatabasePlugin,
|
|
10
|
+
filterCompatibleAppVersions,
|
|
11
|
+
resolveUpdateInfoFromBundles,
|
|
12
|
+
} from "@hot-updater/plugin-core";
|
|
13
|
+
import {
|
|
14
|
+
and,
|
|
15
|
+
asc,
|
|
16
|
+
desc,
|
|
17
|
+
eq,
|
|
18
|
+
gt,
|
|
19
|
+
gte,
|
|
20
|
+
inArray,
|
|
21
|
+
isNotNull,
|
|
22
|
+
isNull,
|
|
23
|
+
lt,
|
|
24
|
+
lte,
|
|
25
|
+
} from "drizzle-orm";
|
|
26
|
+
import type { SQLWrapper } from "drizzle-orm";
|
|
2
27
|
|
|
3
|
-
import
|
|
28
|
+
import {
|
|
29
|
+
bundleToPatchRows,
|
|
30
|
+
bundleToRow,
|
|
31
|
+
type BundlePatchRow,
|
|
32
|
+
type BundleRow,
|
|
33
|
+
rowToBundle,
|
|
34
|
+
} from "../db/bundleRows";
|
|
35
|
+
import {
|
|
36
|
+
getHotUpdaterSchemaVersion,
|
|
37
|
+
hotUpdaterSchema,
|
|
38
|
+
} from "../db/schema/registry";
|
|
39
|
+
import { generateDrizzleSchema } from "../db/schemaGenerators";
|
|
40
|
+
import type {
|
|
41
|
+
DatabasePluginFactory,
|
|
42
|
+
ORMProvider,
|
|
43
|
+
ORMSQLProvider,
|
|
44
|
+
SchemaGenerator,
|
|
45
|
+
} from "../db/types";
|
|
46
|
+
import {
|
|
47
|
+
createLazyDB,
|
|
48
|
+
type DrizzleDB,
|
|
49
|
+
type DrizzleTable,
|
|
50
|
+
} from "./drizzleLazyDB";
|
|
4
51
|
|
|
5
|
-
export
|
|
52
|
+
export interface DrizzleConfig {
|
|
53
|
+
readonly db: unknown | (() => unknown | Promise<unknown>);
|
|
54
|
+
readonly provider: Exclude<ORMProvider, "cockroachdb" | "mongodb" | "mssql">;
|
|
55
|
+
readonly schema?: Record<string, unknown>;
|
|
56
|
+
}
|
|
6
57
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
58
|
+
const getTable = (db: DrizzleDB, name: string) => {
|
|
59
|
+
const table = db._.fullSchema[name];
|
|
60
|
+
if (!table) throw new Error(`Drizzle schema is missing table "${name}".`);
|
|
61
|
+
return table;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const column = (table: DrizzleTable, name: string): SQLWrapper =>
|
|
65
|
+
table[name] as SQLWrapper;
|
|
66
|
+
|
|
67
|
+
const buildWhere = (
|
|
68
|
+
table: DrizzleTable,
|
|
69
|
+
where: DatabaseBundleQueryWhere | undefined,
|
|
70
|
+
) => {
|
|
71
|
+
const conditions = [];
|
|
72
|
+
if (where?.channel !== undefined)
|
|
73
|
+
conditions.push(eq(column(table, "channel"), where.channel));
|
|
74
|
+
if (where?.platform !== undefined)
|
|
75
|
+
conditions.push(eq(column(table, "platform"), where.platform));
|
|
76
|
+
if (where?.enabled !== undefined)
|
|
77
|
+
conditions.push(eq(column(table, "enabled"), where.enabled));
|
|
78
|
+
if (where?.fingerprintHash !== undefined) {
|
|
79
|
+
conditions.push(
|
|
80
|
+
where.fingerprintHash === null
|
|
81
|
+
? isNull(column(table, "fingerprint_hash"))
|
|
82
|
+
: eq(column(table, "fingerprint_hash"), where.fingerprintHash),
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
if (where?.targetAppVersion !== undefined) {
|
|
86
|
+
conditions.push(
|
|
87
|
+
where.targetAppVersion === null
|
|
88
|
+
? isNull(column(table, "target_app_version"))
|
|
89
|
+
: eq(column(table, "target_app_version"), where.targetAppVersion),
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
if (where?.targetAppVersionIn) {
|
|
93
|
+
conditions.push(
|
|
94
|
+
inArray(column(table, "target_app_version"), where.targetAppVersionIn),
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
if (where?.targetAppVersionNotNull) {
|
|
98
|
+
conditions.push(isNotNull(column(table, "target_app_version")));
|
|
99
|
+
}
|
|
100
|
+
if (where?.id?.eq) conditions.push(eq(column(table, "id"), where.id.eq));
|
|
101
|
+
if (where?.id?.gt) conditions.push(gt(column(table, "id"), where.id.gt));
|
|
102
|
+
if (where?.id?.gte) conditions.push(gte(column(table, "id"), where.id.gte));
|
|
103
|
+
if (where?.id?.lt) conditions.push(lt(column(table, "id"), where.id.lt));
|
|
104
|
+
if (where?.id?.lte) conditions.push(lte(column(table, "id"), where.id.lte));
|
|
105
|
+
if (where?.id?.in) conditions.push(inArray(column(table, "id"), where.id.in));
|
|
106
|
+
return conditions.length > 0 ? and(...conditions) : undefined;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const createDrizzlePlugin = createDatabasePlugin<DrizzleConfig>({
|
|
110
|
+
name: "drizzle",
|
|
111
|
+
factory: (config) => {
|
|
112
|
+
const db = createLazyDB(config);
|
|
113
|
+
const bundles = getTable(db, "bundles");
|
|
114
|
+
const patches = getTable(db, "bundle_patches");
|
|
115
|
+
const runInTransaction = async <T>(
|
|
116
|
+
operation: (activeDB: DrizzleDB) => Promise<T>,
|
|
117
|
+
) => {
|
|
118
|
+
if (typeof db.transaction !== "function") return operation(db);
|
|
119
|
+
return db.transaction(operation);
|
|
120
|
+
};
|
|
121
|
+
const fetchPatchMap = async (bundleIds: readonly string[]) => {
|
|
122
|
+
const patchMap = new Map<string, BundlePatchRow[]>();
|
|
123
|
+
if (bundleIds.length === 0) return patchMap;
|
|
124
|
+
const rows = await db.query["bundle_patches"]?.findMany({
|
|
125
|
+
where: inArray(column(patches, "bundle_id"), [...bundleIds]),
|
|
126
|
+
orderBy: [asc(column(patches, "order_index"))],
|
|
127
|
+
});
|
|
128
|
+
for (const row of rows ?? []) {
|
|
129
|
+
const patch = row as BundlePatchRow;
|
|
130
|
+
const current = patchMap.get(patch.bundle_id) ?? [];
|
|
131
|
+
current.push(patch);
|
|
132
|
+
patchMap.set(patch.bundle_id, current);
|
|
133
|
+
}
|
|
134
|
+
return patchMap;
|
|
135
|
+
};
|
|
136
|
+
const mapRowsToBundles = async (
|
|
137
|
+
rows: readonly Record<string, unknown>[],
|
|
138
|
+
): Promise<Bundle[]> => {
|
|
139
|
+
const patchMap = await fetchPatchMap(
|
|
140
|
+
rows.map((row) => String(row["id"])),
|
|
141
|
+
);
|
|
142
|
+
return rows.map((row) =>
|
|
143
|
+
rowToBundle(row as BundleRow, patchMap.get(String(row["id"])) ?? []),
|
|
144
|
+
);
|
|
145
|
+
};
|
|
146
|
+
const upsertBundle = async (activeDB: DrizzleDB, bundle: Bundle) => {
|
|
147
|
+
const row = bundleToRow(bundle);
|
|
148
|
+
const current = await activeDB.query["bundles"]?.findFirst({
|
|
149
|
+
where: eq(column(bundles, "id"), bundle.id),
|
|
150
|
+
});
|
|
151
|
+
if (current) {
|
|
152
|
+
await activeDB
|
|
153
|
+
.update(bundles)
|
|
154
|
+
.set(row)
|
|
155
|
+
.where(eq(column(bundles, "id"), bundle.id));
|
|
156
|
+
} else {
|
|
157
|
+
const inserted = activeDB.insert(bundles).values(row);
|
|
158
|
+
if (inserted.execute) await inserted.execute();
|
|
159
|
+
else await inserted;
|
|
160
|
+
}
|
|
161
|
+
await activeDB
|
|
162
|
+
.delete(patches)
|
|
163
|
+
.where(eq(column(patches, "bundle_id"), bundle.id));
|
|
164
|
+
const patchRows = bundleToPatchRows(bundle);
|
|
165
|
+
if (patchRows.length > 0) {
|
|
166
|
+
const inserted = activeDB.insert(patches).values(patchRows);
|
|
167
|
+
if (inserted.execute) await inserted.execute();
|
|
168
|
+
else await inserted;
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
return {
|
|
172
|
+
async getBundleById(bundleId) {
|
|
173
|
+
const row = await db.query["bundles"]?.findFirst({
|
|
174
|
+
where: eq(column(bundles, "id"), bundleId),
|
|
175
|
+
});
|
|
176
|
+
if (!row) return null;
|
|
177
|
+
const patchMap = await fetchPatchMap([bundleId]);
|
|
178
|
+
return rowToBundle(row as BundleRow, patchMap.get(bundleId) ?? []);
|
|
179
|
+
},
|
|
180
|
+
async getBundles(
|
|
181
|
+
options: DatabaseBundleQueryOptions & { offset?: number },
|
|
182
|
+
) {
|
|
183
|
+
const offset = options.offset ?? 0;
|
|
184
|
+
const orderBy = options.orderBy ?? { field: "id", direction: "desc" };
|
|
185
|
+
const where = buildWhere(bundles, options.where);
|
|
186
|
+
const total = await db.$count(bundles, where);
|
|
187
|
+
const rows = await db.query["bundles"]?.findMany({
|
|
188
|
+
where,
|
|
189
|
+
orderBy: [
|
|
190
|
+
orderBy.direction === "asc"
|
|
191
|
+
? asc(column(bundles, "id"))
|
|
192
|
+
: desc(column(bundles, "id")),
|
|
193
|
+
],
|
|
194
|
+
limit: options.limit,
|
|
195
|
+
offset,
|
|
196
|
+
});
|
|
197
|
+
const dataRows = rows ?? [];
|
|
198
|
+
const patchMap = await fetchPatchMap(
|
|
199
|
+
dataRows.map((row) => String(row["id"])),
|
|
200
|
+
);
|
|
201
|
+
return {
|
|
202
|
+
data: dataRows.map((row) =>
|
|
203
|
+
rowToBundle(
|
|
204
|
+
row as BundleRow,
|
|
205
|
+
patchMap.get(String(row["id"])) ?? [],
|
|
206
|
+
),
|
|
207
|
+
),
|
|
208
|
+
pagination: calculatePagination(total, {
|
|
209
|
+
limit: options.limit,
|
|
210
|
+
offset,
|
|
211
|
+
}),
|
|
212
|
+
};
|
|
213
|
+
},
|
|
214
|
+
async getUpdateInfo(args, context) {
|
|
215
|
+
if (args._updateStrategy === "appVersion") {
|
|
216
|
+
const channel = args.channel ?? "production";
|
|
217
|
+
const minBundleId = args.minBundleId ?? NIL_UUID;
|
|
218
|
+
const rows = await db.query["bundles"]?.findMany({
|
|
219
|
+
columns: { target_app_version: true },
|
|
220
|
+
where: buildWhere(bundles, {
|
|
221
|
+
enabled: true,
|
|
222
|
+
platform: args.platform,
|
|
223
|
+
channel,
|
|
224
|
+
id: { gte: minBundleId },
|
|
225
|
+
targetAppVersionNotNull: true,
|
|
226
|
+
}),
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
const targetAppVersions = Array.from(
|
|
230
|
+
new Set(
|
|
231
|
+
(rows ?? [])
|
|
232
|
+
.map((row) => row["target_app_version"])
|
|
233
|
+
.filter(
|
|
234
|
+
(value): value is string =>
|
|
235
|
+
typeof value === "string" && value.length > 0,
|
|
236
|
+
),
|
|
237
|
+
),
|
|
238
|
+
);
|
|
239
|
+
const compatibleAppVersions = filterCompatibleAppVersions(
|
|
240
|
+
targetAppVersions,
|
|
241
|
+
args.appVersion,
|
|
242
|
+
);
|
|
243
|
+
const updateRows =
|
|
244
|
+
compatibleAppVersions.length > 0
|
|
245
|
+
? await db.query["bundles"]?.findMany({
|
|
246
|
+
where: buildWhere(bundles, {
|
|
247
|
+
enabled: true,
|
|
248
|
+
platform: args.platform,
|
|
249
|
+
channel,
|
|
250
|
+
id: { gte: minBundleId },
|
|
251
|
+
targetAppVersionIn: compatibleAppVersions,
|
|
252
|
+
}),
|
|
253
|
+
orderBy: [desc(column(bundles, "id"))],
|
|
254
|
+
})
|
|
255
|
+
: [];
|
|
256
|
+
|
|
257
|
+
return resolveUpdateInfoFromBundles({
|
|
258
|
+
args: { ...args, channel, minBundleId },
|
|
259
|
+
bundles: await mapRowsToBundles(updateRows ?? []),
|
|
260
|
+
context,
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const channel = args.channel ?? "production";
|
|
265
|
+
const minBundleId = args.minBundleId ?? NIL_UUID;
|
|
266
|
+
const rows = await db.query["bundles"]?.findMany({
|
|
267
|
+
where: buildWhere(bundles, {
|
|
268
|
+
enabled: true,
|
|
269
|
+
platform: args.platform,
|
|
270
|
+
channel,
|
|
271
|
+
id: { gte: minBundleId },
|
|
272
|
+
fingerprintHash: args.fingerprintHash,
|
|
273
|
+
}),
|
|
274
|
+
orderBy: [desc(column(bundles, "id"))],
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
return resolveUpdateInfoFromBundles({
|
|
278
|
+
args: { ...args, channel, minBundleId },
|
|
279
|
+
bundles: await mapRowsToBundles(rows ?? []),
|
|
280
|
+
context,
|
|
281
|
+
});
|
|
282
|
+
},
|
|
283
|
+
async getChannels() {
|
|
284
|
+
const rows = await db.query["bundles"]?.findMany({
|
|
285
|
+
columns: { channel: true },
|
|
286
|
+
orderBy: [asc(column(bundles, "channel"))],
|
|
287
|
+
});
|
|
288
|
+
return Array.from(
|
|
289
|
+
new Set((rows ?? []).map((row) => String(row["channel"]))),
|
|
290
|
+
);
|
|
291
|
+
},
|
|
292
|
+
async commitBundle({ changedSets }) {
|
|
293
|
+
await runInTransaction(async (activeDB) => {
|
|
294
|
+
for (const change of changedSets) {
|
|
295
|
+
if (change.operation === "delete") {
|
|
296
|
+
await activeDB
|
|
297
|
+
.delete(patches)
|
|
298
|
+
.where(eq(column(patches, "bundle_id"), change.data.id));
|
|
299
|
+
await activeDB
|
|
300
|
+
.delete(patches)
|
|
301
|
+
.where(eq(column(patches, "base_bundle_id"), change.data.id));
|
|
302
|
+
await activeDB
|
|
303
|
+
.delete(bundles)
|
|
304
|
+
.where(eq(column(bundles, "id"), change.data.id));
|
|
305
|
+
continue;
|
|
306
|
+
}
|
|
307
|
+
await upsertBundle(activeDB, change.data);
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
},
|
|
311
|
+
};
|
|
312
|
+
},
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
export const drizzleAdapter = (
|
|
316
|
+
config: DrizzleConfig,
|
|
317
|
+
): DatabasePluginFactory => {
|
|
318
|
+
return Object.assign(createDrizzlePlugin(config), {
|
|
319
|
+
adapterName: "drizzle",
|
|
320
|
+
provider: config.provider,
|
|
321
|
+
generateSchema: (version: Parameters<SchemaGenerator>[0]) => ({
|
|
322
|
+
code: generateDrizzleSchema(
|
|
323
|
+
config.provider as ORMSQLProvider,
|
|
324
|
+
version === "latest"
|
|
325
|
+
? hotUpdaterSchema
|
|
326
|
+
: getHotUpdaterSchemaVersion(version),
|
|
327
|
+
),
|
|
328
|
+
path: "hot-updater-schema.ts",
|
|
329
|
+
}),
|
|
330
|
+
});
|
|
331
|
+
};
|