@hot-updater/server 0.33.2 → 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
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import type { DrizzleConfig } from "./drizzle";
|
|
2
|
+
|
|
3
|
+
export type DrizzleTable = Record<string, unknown>;
|
|
4
|
+
|
|
5
|
+
export type DrizzleDB = {
|
|
6
|
+
readonly _: { readonly fullSchema: Record<string, DrizzleTable> };
|
|
7
|
+
readonly $count: (table: DrizzleTable, where?: unknown) => Promise<number>;
|
|
8
|
+
readonly delete: (table: DrizzleTable) => {
|
|
9
|
+
where: (condition: unknown) => Promise<unknown>;
|
|
10
|
+
};
|
|
11
|
+
readonly insert: (table: DrizzleTable) => {
|
|
12
|
+
values: (value: unknown) => {
|
|
13
|
+
onConflictDoUpdate?: (args: unknown) => Promise<unknown>;
|
|
14
|
+
onDuplicateKeyUpdate?: (args: unknown) => Promise<unknown>;
|
|
15
|
+
execute?: () => Promise<unknown>;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
readonly query: Record<
|
|
19
|
+
string,
|
|
20
|
+
{
|
|
21
|
+
findFirst: (
|
|
22
|
+
args?: unknown,
|
|
23
|
+
) => Promise<Record<string, unknown> | undefined>;
|
|
24
|
+
findMany: (args?: unknown) => Promise<Record<string, unknown>[]>;
|
|
25
|
+
}
|
|
26
|
+
>;
|
|
27
|
+
readonly select: (fields?: unknown) => {
|
|
28
|
+
from: (table: DrizzleTable) => {
|
|
29
|
+
where?: (condition: unknown) => unknown;
|
|
30
|
+
orderBy?: (order: unknown) => unknown;
|
|
31
|
+
limit?: (limit: number) => unknown;
|
|
32
|
+
offset?: (offset: number) => Promise<Record<string, unknown>[]>;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
readonly update: (table: DrizzleTable) => {
|
|
36
|
+
set: (values: unknown) => {
|
|
37
|
+
where: (condition: unknown) => Promise<unknown>;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
readonly transaction?: <T>(
|
|
41
|
+
operation: (tx: DrizzleDB) => Promise<T>,
|
|
42
|
+
) => Promise<T>;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const asDB = (db: unknown): DrizzleDB => {
|
|
46
|
+
const typed = db as DrizzleDB;
|
|
47
|
+
if (!typed._?.fullSchema) {
|
|
48
|
+
throw new Error(
|
|
49
|
+
"[hot-updater] Drizzle adapter requires query mode with schema.",
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
return typed;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const isDBFactory = (
|
|
56
|
+
db: DrizzleConfig["db"],
|
|
57
|
+
): db is () => unknown | Promise<unknown> => typeof db === "function";
|
|
58
|
+
|
|
59
|
+
export const createLazyDB = (config: DrizzleConfig): DrizzleDB => {
|
|
60
|
+
const dbSource = config.db;
|
|
61
|
+
if (!isDBFactory(dbSource)) return asDB(dbSource);
|
|
62
|
+
|
|
63
|
+
if (!config.schema) {
|
|
64
|
+
throw new Error(
|
|
65
|
+
"[hot-updater] Drizzle adapter requires schema when db is lazy.",
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
let resolvedDB: Promise<DrizzleDB> | undefined;
|
|
70
|
+
const getDB = async () => {
|
|
71
|
+
resolvedDB ??= Promise.resolve(dbSource()).then(asDB);
|
|
72
|
+
return resolvedDB;
|
|
73
|
+
};
|
|
74
|
+
const fullSchema = config.schema as Record<string, DrizzleTable>;
|
|
75
|
+
const runInserted = async (
|
|
76
|
+
table: DrizzleTable,
|
|
77
|
+
value: unknown,
|
|
78
|
+
operation: (
|
|
79
|
+
inserted: ReturnType<ReturnType<DrizzleDB["insert"]>["values"]>,
|
|
80
|
+
) => Promise<unknown> | unknown,
|
|
81
|
+
) => {
|
|
82
|
+
const db = await getDB();
|
|
83
|
+
return operation(db.insert(table).values(value));
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
_: { fullSchema },
|
|
88
|
+
$count: async (table, where) => (await getDB()).$count(table, where),
|
|
89
|
+
delete: (table) => ({
|
|
90
|
+
where: async (condition) =>
|
|
91
|
+
(await getDB()).delete(table).where(condition),
|
|
92
|
+
}),
|
|
93
|
+
insert: (table) => ({
|
|
94
|
+
values: (value) => ({
|
|
95
|
+
execute: async () =>
|
|
96
|
+
runInserted(table, value, async (inserted) => {
|
|
97
|
+
if (typeof inserted.execute === "function") {
|
|
98
|
+
return inserted.execute();
|
|
99
|
+
}
|
|
100
|
+
return inserted;
|
|
101
|
+
}),
|
|
102
|
+
onConflictDoUpdate: async (args) =>
|
|
103
|
+
runInserted(table, value, async (inserted) => {
|
|
104
|
+
if (typeof inserted.onConflictDoUpdate !== "function") {
|
|
105
|
+
throw new Error(
|
|
106
|
+
"[hot-updater] Drizzle insert does not support onConflictDoUpdate.",
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
return inserted.onConflictDoUpdate(args);
|
|
110
|
+
}),
|
|
111
|
+
onDuplicateKeyUpdate: async (args) =>
|
|
112
|
+
runInserted(table, value, async (inserted) => {
|
|
113
|
+
if (typeof inserted.onDuplicateKeyUpdate !== "function") {
|
|
114
|
+
throw new Error(
|
|
115
|
+
"[hot-updater] Drizzle insert does not support onDuplicateKeyUpdate.",
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
return inserted.onDuplicateKeyUpdate(args);
|
|
119
|
+
}),
|
|
120
|
+
}),
|
|
121
|
+
}),
|
|
122
|
+
query: new Proxy(
|
|
123
|
+
{},
|
|
124
|
+
{
|
|
125
|
+
get: (_target, tableName) => ({
|
|
126
|
+
findFirst: async (args?: unknown) =>
|
|
127
|
+
(await getDB()).query[String(tableName)]?.findFirst(args),
|
|
128
|
+
findMany: async (args?: unknown) =>
|
|
129
|
+
(await getDB()).query[String(tableName)]?.findMany(args) ?? [],
|
|
130
|
+
}),
|
|
131
|
+
},
|
|
132
|
+
) as DrizzleDB["query"],
|
|
133
|
+
select: (fields) => ({
|
|
134
|
+
from: (table) => ({
|
|
135
|
+
offset: async (offset) =>
|
|
136
|
+
(await getDB()).select(fields).from(table).offset?.(offset) ?? [],
|
|
137
|
+
}),
|
|
138
|
+
}),
|
|
139
|
+
update: (table) => ({
|
|
140
|
+
set: (values) => ({
|
|
141
|
+
where: async (condition) =>
|
|
142
|
+
(await getDB()).update(table).set(values).where(condition),
|
|
143
|
+
}),
|
|
144
|
+
}),
|
|
145
|
+
transaction: async (operation) => {
|
|
146
|
+
const db = await getDB();
|
|
147
|
+
if (typeof db.transaction !== "function") return operation(db);
|
|
148
|
+
return db.transaction(operation);
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { PGlite } from "@electric-sql/pglite";
|
|
2
|
+
import type { Bundle } from "@hot-updater/core";
|
|
3
|
+
import { Kysely } from "kysely";
|
|
4
|
+
import { PGliteDialect } from "kysely-pglite-dialect";
|
|
5
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
6
|
+
|
|
7
|
+
import { createHotUpdater } from "../db";
|
|
8
|
+
import {
|
|
9
|
+
HOT_UPDATER_SCHEMA_VERSION,
|
|
10
|
+
HOT_UPDATER_SETTINGS_TABLE,
|
|
11
|
+
} from "../schema/types";
|
|
12
|
+
import { kyselyAdapter } from "./kysely";
|
|
13
|
+
|
|
14
|
+
const sqliteJsonBundle: Bundle = {
|
|
15
|
+
id: "00000000-0000-0000-0000-000000000901",
|
|
16
|
+
platform: "ios",
|
|
17
|
+
shouldForceUpdate: false,
|
|
18
|
+
enabled: true,
|
|
19
|
+
fileHash: "sqlite-json-hash",
|
|
20
|
+
gitCommitHash: null,
|
|
21
|
+
message: "sqlite json bundle",
|
|
22
|
+
channel: "production",
|
|
23
|
+
storageUri: "s3://bucket/sqlite-json.zip",
|
|
24
|
+
targetAppVersion: "1.0.0",
|
|
25
|
+
fingerprintHash: null,
|
|
26
|
+
metadata: { app_version: "1.0.0" },
|
|
27
|
+
targetCohorts: ["17", "qa-group"],
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
describe("kyselyAdapter sqlite provider", () => {
|
|
31
|
+
const databases: PGlite[] = [];
|
|
32
|
+
const kyselyInstances: Kysely<object>[] = [];
|
|
33
|
+
|
|
34
|
+
afterEach(async () => {
|
|
35
|
+
for (const kysely of kyselyInstances.splice(0)) {
|
|
36
|
+
await kysely.destroy();
|
|
37
|
+
}
|
|
38
|
+
for (const db of databases.splice(0)) {
|
|
39
|
+
await db.close();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("stores bundle JSON columns as text and round-trips them", async () => {
|
|
44
|
+
const db = new PGlite();
|
|
45
|
+
databases.push(db);
|
|
46
|
+
const kysely = new Kysely({ dialect: new PGliteDialect(db) });
|
|
47
|
+
kyselyInstances.push(kysely);
|
|
48
|
+
await db.exec(`
|
|
49
|
+
create table bundles (
|
|
50
|
+
id text primary key,
|
|
51
|
+
platform text not null,
|
|
52
|
+
should_force_update boolean not null,
|
|
53
|
+
enabled boolean not null,
|
|
54
|
+
file_hash text not null,
|
|
55
|
+
git_commit_hash text,
|
|
56
|
+
message text,
|
|
57
|
+
channel text not null,
|
|
58
|
+
storage_uri text not null,
|
|
59
|
+
target_app_version text,
|
|
60
|
+
fingerprint_hash text,
|
|
61
|
+
metadata text not null,
|
|
62
|
+
manifest_storage_uri text,
|
|
63
|
+
manifest_file_hash text,
|
|
64
|
+
asset_base_storage_uri text,
|
|
65
|
+
rollout_cohort_count integer not null,
|
|
66
|
+
target_cohorts text
|
|
67
|
+
);
|
|
68
|
+
create table bundle_patches (
|
|
69
|
+
id text primary key,
|
|
70
|
+
bundle_id text not null,
|
|
71
|
+
base_bundle_id text not null,
|
|
72
|
+
base_file_hash text not null,
|
|
73
|
+
patch_file_hash text not null,
|
|
74
|
+
patch_storage_uri text not null,
|
|
75
|
+
order_index integer not null
|
|
76
|
+
);
|
|
77
|
+
create table ${HOT_UPDATER_SETTINGS_TABLE} (
|
|
78
|
+
key text primary key,
|
|
79
|
+
value text not null
|
|
80
|
+
);
|
|
81
|
+
insert into ${HOT_UPDATER_SETTINGS_TABLE} (key, value)
|
|
82
|
+
values ('version', '${HOT_UPDATER_SCHEMA_VERSION}');
|
|
83
|
+
`);
|
|
84
|
+
const hotUpdater = createHotUpdater({
|
|
85
|
+
database: kyselyAdapter({
|
|
86
|
+
db: kysely,
|
|
87
|
+
provider: "sqlite",
|
|
88
|
+
}),
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
await hotUpdater.insertBundle(sqliteJsonBundle);
|
|
92
|
+
const stored = await db.query<{
|
|
93
|
+
metadata: string;
|
|
94
|
+
target_cohorts: string;
|
|
95
|
+
}>("select metadata, target_cohorts from bundles where id = $1", [
|
|
96
|
+
sqliteJsonBundle.id,
|
|
97
|
+
]);
|
|
98
|
+
const restored = await hotUpdater.getBundleById(sqliteJsonBundle.id);
|
|
99
|
+
|
|
100
|
+
expect(stored.rows[0]).toEqual({
|
|
101
|
+
metadata: JSON.stringify({ app_version: "1.0.0" }),
|
|
102
|
+
target_cohorts: JSON.stringify(["17", "qa-group"]),
|
|
103
|
+
});
|
|
104
|
+
expect(restored?.metadata).toEqual({ app_version: "1.0.0" });
|
|
105
|
+
expect(restored?.targetCohorts).toEqual(["17", "qa-group"]);
|
|
106
|
+
});
|
|
107
|
+
});
|
package/src/adapters/kysely.ts
CHANGED
|
@@ -1,24 +1,359 @@
|
|
|
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 type { Kysely, Transaction } from "kysely";
|
|
2
14
|
|
|
3
|
-
import
|
|
15
|
+
import {
|
|
16
|
+
bundleToPatchRows,
|
|
17
|
+
bundleToRow,
|
|
18
|
+
type BundlePatchRow,
|
|
19
|
+
type BundleRow,
|
|
20
|
+
rowToBundle,
|
|
21
|
+
} from "../db/bundleRows";
|
|
22
|
+
import { createKyselyMigrator } from "../db/fixedMigrator";
|
|
23
|
+
import type {
|
|
24
|
+
DatabasePluginFactory,
|
|
25
|
+
ORMSQLProvider,
|
|
26
|
+
RelationMode,
|
|
27
|
+
} from "../db/types";
|
|
4
28
|
|
|
5
|
-
|
|
6
|
-
export type SQLProvider = import("fumadb").SQLProvider;
|
|
29
|
+
type KyselySQLProvider = Exclude<ORMSQLProvider, "mssql">;
|
|
7
30
|
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
31
|
+
export type { RelationMode, KyselySQLProvider as SQLProvider };
|
|
32
|
+
|
|
33
|
+
interface Database {
|
|
34
|
+
readonly bundles: BundleRow;
|
|
35
|
+
readonly bundle_patches: BundlePatchRow;
|
|
36
|
+
readonly private_hot_updater_settings: {
|
|
37
|
+
readonly key: string;
|
|
38
|
+
readonly value: string;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface KyselyAdapterConfig<TDatabase extends object = Database> {
|
|
43
|
+
readonly db: Kysely<TDatabase>;
|
|
44
|
+
readonly provider: KyselySQLProvider;
|
|
45
|
+
readonly relationMode?: RelationMode;
|
|
12
46
|
}
|
|
13
47
|
|
|
48
|
+
const assertKyselySQLProvider: (
|
|
49
|
+
provider: ORMSQLProvider,
|
|
50
|
+
) => asserts provider is KyselySQLProvider = (provider) => {
|
|
51
|
+
if (provider === "mssql") {
|
|
52
|
+
throw new Error("Kysely adapter does not support provider: mssql.");
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const applyWhere = <T extends object>(
|
|
57
|
+
query: T,
|
|
58
|
+
where: DatabaseBundleQueryWhere | undefined,
|
|
59
|
+
): T => {
|
|
60
|
+
let next = query as {
|
|
61
|
+
where: (column: string, op: string, value?: unknown) => unknown;
|
|
62
|
+
};
|
|
63
|
+
if (where?.channel !== undefined)
|
|
64
|
+
next = next.where("channel", "=", where.channel) as typeof next;
|
|
65
|
+
if (where?.platform !== undefined)
|
|
66
|
+
next = next.where("platform", "=", where.platform) as typeof next;
|
|
67
|
+
if (where?.enabled !== undefined)
|
|
68
|
+
next = next.where("enabled", "=", where.enabled) as typeof next;
|
|
69
|
+
if (where?.fingerprintHash !== undefined) {
|
|
70
|
+
next =
|
|
71
|
+
where.fingerprintHash === null
|
|
72
|
+
? (next.where("fingerprint_hash", "is", null) as typeof next)
|
|
73
|
+
: (next.where(
|
|
74
|
+
"fingerprint_hash",
|
|
75
|
+
"=",
|
|
76
|
+
where.fingerprintHash,
|
|
77
|
+
) as typeof next);
|
|
78
|
+
}
|
|
79
|
+
if (where?.targetAppVersion !== undefined) {
|
|
80
|
+
next =
|
|
81
|
+
where.targetAppVersion === null
|
|
82
|
+
? (next.where("target_app_version", "is", null) as typeof next)
|
|
83
|
+
: (next.where(
|
|
84
|
+
"target_app_version",
|
|
85
|
+
"=",
|
|
86
|
+
where.targetAppVersion,
|
|
87
|
+
) as typeof next);
|
|
88
|
+
}
|
|
89
|
+
if (where?.targetAppVersionIn) {
|
|
90
|
+
next = next.where(
|
|
91
|
+
"target_app_version",
|
|
92
|
+
"in",
|
|
93
|
+
where.targetAppVersionIn,
|
|
94
|
+
) as typeof next;
|
|
95
|
+
}
|
|
96
|
+
if (where?.targetAppVersionNotNull) {
|
|
97
|
+
next = next.where("target_app_version", "is not", null) as typeof next;
|
|
98
|
+
}
|
|
99
|
+
if (where?.id?.eq) next = next.where("id", "=", where.id.eq) as typeof next;
|
|
100
|
+
if (where?.id?.gt) next = next.where("id", ">", where.id.gt) as typeof next;
|
|
101
|
+
if (where?.id?.gte)
|
|
102
|
+
next = next.where("id", ">=", where.id.gte) as typeof next;
|
|
103
|
+
if (where?.id?.lt) next = next.where("id", "<", where.id.lt) as typeof next;
|
|
104
|
+
if (where?.id?.lte)
|
|
105
|
+
next = next.where("id", "<=", where.id.lte) as typeof next;
|
|
106
|
+
if (where?.id?.in) next = next.where("id", "in", where.id.in) as typeof next;
|
|
107
|
+
return next as T;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const hasEmptySetFilter = (
|
|
111
|
+
where: DatabaseBundleQueryWhere | undefined,
|
|
112
|
+
): boolean =>
|
|
113
|
+
where?.targetAppVersionIn?.length === 0 || where?.id?.in?.length === 0;
|
|
114
|
+
|
|
115
|
+
const toProviderBundleRow = (
|
|
116
|
+
row: BundleRow,
|
|
117
|
+
provider: KyselySQLProvider,
|
|
118
|
+
): BundleRow => {
|
|
119
|
+
if (provider !== "mysql" && provider !== "sqlite") return row;
|
|
120
|
+
return {
|
|
121
|
+
...row,
|
|
122
|
+
metadata: JSON.stringify(row.metadata ?? {}),
|
|
123
|
+
target_cohorts:
|
|
124
|
+
row.target_cohorts === null || row.target_cohorts === undefined
|
|
125
|
+
? null
|
|
126
|
+
: JSON.stringify(row.target_cohorts),
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const createKyselyPlugin = createDatabasePlugin<KyselyAdapterConfig<Database>>({
|
|
131
|
+
name: "kysely",
|
|
132
|
+
factory: ({ db, provider }) => {
|
|
133
|
+
const fetchPatchMap = async (bundleIds: readonly string[]) => {
|
|
134
|
+
const patchMap = new Map<string, BundlePatchRow[]>();
|
|
135
|
+
if (bundleIds.length === 0) return patchMap;
|
|
136
|
+
const rows = await db
|
|
137
|
+
.selectFrom("bundle_patches")
|
|
138
|
+
.selectAll()
|
|
139
|
+
.where("bundle_id", "in", [...bundleIds])
|
|
140
|
+
.orderBy("order_index", "asc")
|
|
141
|
+
.execute();
|
|
142
|
+
for (const row of rows) {
|
|
143
|
+
const current = patchMap.get(row.bundle_id) ?? [];
|
|
144
|
+
current.push(row);
|
|
145
|
+
patchMap.set(row.bundle_id, current);
|
|
146
|
+
}
|
|
147
|
+
return patchMap;
|
|
148
|
+
};
|
|
149
|
+
const mapRowsToBundles = async (
|
|
150
|
+
rows: readonly BundleRow[],
|
|
151
|
+
): Promise<Bundle[]> => {
|
|
152
|
+
const patchMap = await fetchPatchMap(rows.map((row) => row.id));
|
|
153
|
+
return rows.map((row) => rowToBundle(row, patchMap.get(row.id) ?? []));
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const upsertBundle = async (
|
|
157
|
+
executor: Kysely<Database> | Transaction<Database>,
|
|
158
|
+
bundle: Bundle,
|
|
159
|
+
) => {
|
|
160
|
+
const row = toProviderBundleRow(bundleToRow(bundle), provider);
|
|
161
|
+
const { id: _id, ...updateRow } = row;
|
|
162
|
+
if (provider === "mysql") {
|
|
163
|
+
await executor
|
|
164
|
+
.insertInto("bundles")
|
|
165
|
+
.values(row)
|
|
166
|
+
.onDuplicateKeyUpdate(updateRow)
|
|
167
|
+
.execute();
|
|
168
|
+
} else {
|
|
169
|
+
await executor
|
|
170
|
+
.insertInto("bundles")
|
|
171
|
+
.values(row)
|
|
172
|
+
.onConflict((oc) => oc.column("id").doUpdateSet(updateRow))
|
|
173
|
+
.execute();
|
|
174
|
+
}
|
|
175
|
+
await executor
|
|
176
|
+
.deleteFrom("bundle_patches")
|
|
177
|
+
.where("bundle_id", "=", bundle.id)
|
|
178
|
+
.execute();
|
|
179
|
+
const patches = bundleToPatchRows(bundle);
|
|
180
|
+
if (patches.length > 0) {
|
|
181
|
+
await executor.insertInto("bundle_patches").values(patches).execute();
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
return {
|
|
186
|
+
async getBundleById(bundleId) {
|
|
187
|
+
const row = await db
|
|
188
|
+
.selectFrom("bundles")
|
|
189
|
+
.selectAll()
|
|
190
|
+
.where("id", "=", bundleId)
|
|
191
|
+
.executeTakeFirst();
|
|
192
|
+
if (!row) return null;
|
|
193
|
+
const patchMap = await fetchPatchMap([bundleId]);
|
|
194
|
+
return rowToBundle(row, patchMap.get(bundleId) ?? []);
|
|
195
|
+
},
|
|
196
|
+
async getBundles(
|
|
197
|
+
options: DatabaseBundleQueryOptions & { offset?: number },
|
|
198
|
+
) {
|
|
199
|
+
const offset = options.offset ?? 0;
|
|
200
|
+
if (hasEmptySetFilter(options.where)) {
|
|
201
|
+
return {
|
|
202
|
+
data: [],
|
|
203
|
+
pagination: calculatePagination(0, {
|
|
204
|
+
limit: options.limit,
|
|
205
|
+
offset,
|
|
206
|
+
}),
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
const orderBy = options.orderBy ?? { field: "id", direction: "desc" };
|
|
210
|
+
const countRow = await applyWhere(
|
|
211
|
+
db.selectFrom("bundles"),
|
|
212
|
+
options.where,
|
|
213
|
+
)
|
|
214
|
+
.select(db.fn.count<number>("id").as("total"))
|
|
215
|
+
.executeTakeFirst();
|
|
216
|
+
const total = Number(countRow?.total ?? 0);
|
|
217
|
+
const rows = await applyWhere(
|
|
218
|
+
db.selectFrom("bundles").selectAll(),
|
|
219
|
+
options.where,
|
|
220
|
+
)
|
|
221
|
+
.orderBy("id", orderBy.direction)
|
|
222
|
+
.limit(options.limit)
|
|
223
|
+
.offset(offset)
|
|
224
|
+
.execute();
|
|
225
|
+
const patchMap = await fetchPatchMap(rows.map((row) => row.id));
|
|
226
|
+
return {
|
|
227
|
+
data: rows.map((row) => rowToBundle(row, patchMap.get(row.id) ?? [])),
|
|
228
|
+
pagination: calculatePagination(total, {
|
|
229
|
+
limit: options.limit,
|
|
230
|
+
offset,
|
|
231
|
+
}),
|
|
232
|
+
};
|
|
233
|
+
},
|
|
234
|
+
async getUpdateInfo(args, context) {
|
|
235
|
+
if (args._updateStrategy === "appVersion") {
|
|
236
|
+
const channel = args.channel ?? "production";
|
|
237
|
+
const minBundleId = args.minBundleId ?? NIL_UUID;
|
|
238
|
+
const rows = await db
|
|
239
|
+
.selectFrom("bundles")
|
|
240
|
+
.select("target_app_version")
|
|
241
|
+
.where("enabled", "=", true)
|
|
242
|
+
.where("platform", "=", args.platform)
|
|
243
|
+
.where("channel", "=", channel)
|
|
244
|
+
.where("id", ">=", minBundleId)
|
|
245
|
+
.where("target_app_version", "is not", null)
|
|
246
|
+
.execute();
|
|
247
|
+
|
|
248
|
+
const targetAppVersions = Array.from(
|
|
249
|
+
new Set(
|
|
250
|
+
rows
|
|
251
|
+
.map((row) => row.target_app_version)
|
|
252
|
+
.filter(
|
|
253
|
+
(value): value is string =>
|
|
254
|
+
typeof value === "string" && value.length > 0,
|
|
255
|
+
),
|
|
256
|
+
),
|
|
257
|
+
);
|
|
258
|
+
const compatibleAppVersions = filterCompatibleAppVersions(
|
|
259
|
+
targetAppVersions,
|
|
260
|
+
args.appVersion,
|
|
261
|
+
);
|
|
262
|
+
const bundles =
|
|
263
|
+
compatibleAppVersions.length > 0
|
|
264
|
+
? await db
|
|
265
|
+
.selectFrom("bundles")
|
|
266
|
+
.selectAll()
|
|
267
|
+
.where("enabled", "=", true)
|
|
268
|
+
.where("platform", "=", args.platform)
|
|
269
|
+
.where("channel", "=", channel)
|
|
270
|
+
.where("id", ">=", minBundleId)
|
|
271
|
+
.where("target_app_version", "in", compatibleAppVersions)
|
|
272
|
+
.orderBy("id", "desc")
|
|
273
|
+
.execute()
|
|
274
|
+
.then(mapRowsToBundles)
|
|
275
|
+
: [];
|
|
276
|
+
|
|
277
|
+
return resolveUpdateInfoFromBundles({
|
|
278
|
+
args: { ...args, channel, minBundleId },
|
|
279
|
+
bundles,
|
|
280
|
+
context,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const channel = args.channel ?? "production";
|
|
285
|
+
const minBundleId = args.minBundleId ?? NIL_UUID;
|
|
286
|
+
const rows = await db
|
|
287
|
+
.selectFrom("bundles")
|
|
288
|
+
.selectAll()
|
|
289
|
+
.where("enabled", "=", true)
|
|
290
|
+
.where("platform", "=", args.platform)
|
|
291
|
+
.where("channel", "=", channel)
|
|
292
|
+
.where("id", ">=", minBundleId)
|
|
293
|
+
.where("fingerprint_hash", "=", args.fingerprintHash)
|
|
294
|
+
.orderBy("id", "desc")
|
|
295
|
+
.execute();
|
|
296
|
+
|
|
297
|
+
return resolveUpdateInfoFromBundles({
|
|
298
|
+
args: { ...args, channel, minBundleId },
|
|
299
|
+
bundles: await mapRowsToBundles(rows),
|
|
300
|
+
context,
|
|
301
|
+
});
|
|
302
|
+
},
|
|
303
|
+
async getChannels() {
|
|
304
|
+
const rows = await db
|
|
305
|
+
.selectFrom("bundles")
|
|
306
|
+
.select("channel")
|
|
307
|
+
.orderBy("channel", "asc")
|
|
308
|
+
.execute();
|
|
309
|
+
return Array.from(new Set(rows.map((row) => row.channel)));
|
|
310
|
+
},
|
|
311
|
+
async commitBundle({ changedSets }) {
|
|
312
|
+
await db.transaction().execute(async (tx) => {
|
|
313
|
+
for (const change of changedSets) {
|
|
314
|
+
if (change.operation === "delete") {
|
|
315
|
+
await tx
|
|
316
|
+
.deleteFrom("bundle_patches")
|
|
317
|
+
.where("bundle_id", "=", change.data.id)
|
|
318
|
+
.execute();
|
|
319
|
+
await tx
|
|
320
|
+
.deleteFrom("bundle_patches")
|
|
321
|
+
.where("base_bundle_id", "=", change.data.id)
|
|
322
|
+
.execute();
|
|
323
|
+
await tx
|
|
324
|
+
.deleteFrom("bundles")
|
|
325
|
+
.where("id", "=", change.data.id)
|
|
326
|
+
.execute();
|
|
327
|
+
continue;
|
|
328
|
+
}
|
|
329
|
+
await upsertBundle(tx, change.data);
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
},
|
|
333
|
+
};
|
|
334
|
+
},
|
|
335
|
+
});
|
|
336
|
+
|
|
14
337
|
export const kyselyAdapter = <TDatabase extends object>(
|
|
15
|
-
config:
|
|
16
|
-
):
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
) as unknown as ORMDatabaseAdapter,
|
|
338
|
+
config: KyselyAdapterConfig<TDatabase>,
|
|
339
|
+
): DatabasePluginFactory => {
|
|
340
|
+
assertKyselySQLProvider(config.provider);
|
|
341
|
+
return Object.assign(
|
|
342
|
+
createKyselyPlugin(config as unknown as KyselyAdapterConfig<Database>),
|
|
21
343
|
{
|
|
344
|
+
adapterName: "kysely",
|
|
22
345
|
provider: config.provider,
|
|
346
|
+
createMigrator: () =>
|
|
347
|
+
createKyselyMigrator({
|
|
348
|
+
db: config.db as unknown as Kysely<{
|
|
349
|
+
private_hot_updater_settings: {
|
|
350
|
+
key: string;
|
|
351
|
+
value: string;
|
|
352
|
+
};
|
|
353
|
+
}>,
|
|
354
|
+
provider: config.provider,
|
|
355
|
+
relationMode: config.relationMode,
|
|
356
|
+
}),
|
|
23
357
|
},
|
|
24
358
|
);
|
|
359
|
+
};
|