@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/adapters/kysely.cjs
CHANGED
|
@@ -1,7 +1,158 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
3
|
-
require("../
|
|
2
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_bundleRows = require("../db/bundleRows.cjs");
|
|
4
|
+
const require_fixedMigrator = require("../db/fixedMigrator.cjs");
|
|
5
|
+
let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
|
|
6
|
+
let _hot_updater_core = require("@hot-updater/core");
|
|
4
7
|
//#region src/adapters/kysely.ts
|
|
5
|
-
const
|
|
8
|
+
const assertKyselySQLProvider = (provider) => {
|
|
9
|
+
if (provider === "mssql") throw new Error("Kysely adapter does not support provider: mssql.");
|
|
10
|
+
};
|
|
11
|
+
const applyWhere = (query, where) => {
|
|
12
|
+
let next = query;
|
|
13
|
+
if (where?.channel !== void 0) next = next.where("channel", "=", where.channel);
|
|
14
|
+
if (where?.platform !== void 0) next = next.where("platform", "=", where.platform);
|
|
15
|
+
if (where?.enabled !== void 0) next = next.where("enabled", "=", where.enabled);
|
|
16
|
+
if (where?.fingerprintHash !== void 0) next = where.fingerprintHash === null ? next.where("fingerprint_hash", "is", null) : next.where("fingerprint_hash", "=", where.fingerprintHash);
|
|
17
|
+
if (where?.targetAppVersion !== void 0) next = where.targetAppVersion === null ? next.where("target_app_version", "is", null) : next.where("target_app_version", "=", where.targetAppVersion);
|
|
18
|
+
if (where?.targetAppVersionIn) next = next.where("target_app_version", "in", where.targetAppVersionIn);
|
|
19
|
+
if (where?.targetAppVersionNotNull) next = next.where("target_app_version", "is not", null);
|
|
20
|
+
if (where?.id?.eq) next = next.where("id", "=", where.id.eq);
|
|
21
|
+
if (where?.id?.gt) next = next.where("id", ">", where.id.gt);
|
|
22
|
+
if (where?.id?.gte) next = next.where("id", ">=", where.id.gte);
|
|
23
|
+
if (where?.id?.lt) next = next.where("id", "<", where.id.lt);
|
|
24
|
+
if (where?.id?.lte) next = next.where("id", "<=", where.id.lte);
|
|
25
|
+
if (where?.id?.in) next = next.where("id", "in", where.id.in);
|
|
26
|
+
return next;
|
|
27
|
+
};
|
|
28
|
+
const hasEmptySetFilter = (where) => where?.targetAppVersionIn?.length === 0 || where?.id?.in?.length === 0;
|
|
29
|
+
const toProviderBundleRow = (row, provider) => {
|
|
30
|
+
if (provider !== "mysql" && provider !== "sqlite") return row;
|
|
31
|
+
return {
|
|
32
|
+
...row,
|
|
33
|
+
metadata: JSON.stringify(row.metadata ?? {}),
|
|
34
|
+
target_cohorts: row.target_cohorts === null || row.target_cohorts === void 0 ? null : JSON.stringify(row.target_cohorts)
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
const createKyselyPlugin = (0, _hot_updater_plugin_core.createDatabasePlugin)({
|
|
38
|
+
name: "kysely",
|
|
39
|
+
factory: ({ db, provider }) => {
|
|
40
|
+
const fetchPatchMap = async (bundleIds) => {
|
|
41
|
+
const patchMap = /* @__PURE__ */ new Map();
|
|
42
|
+
if (bundleIds.length === 0) return patchMap;
|
|
43
|
+
const rows = await db.selectFrom("bundle_patches").selectAll().where("bundle_id", "in", [...bundleIds]).orderBy("order_index", "asc").execute();
|
|
44
|
+
for (const row of rows) {
|
|
45
|
+
const current = patchMap.get(row.bundle_id) ?? [];
|
|
46
|
+
current.push(row);
|
|
47
|
+
patchMap.set(row.bundle_id, current);
|
|
48
|
+
}
|
|
49
|
+
return patchMap;
|
|
50
|
+
};
|
|
51
|
+
const mapRowsToBundles = async (rows) => {
|
|
52
|
+
const patchMap = await fetchPatchMap(rows.map((row) => row.id));
|
|
53
|
+
return rows.map((row) => require_bundleRows.rowToBundle(row, patchMap.get(row.id) ?? []));
|
|
54
|
+
};
|
|
55
|
+
const upsertBundle = async (executor, bundle) => {
|
|
56
|
+
const row = toProviderBundleRow(require_bundleRows.bundleToRow(bundle), provider);
|
|
57
|
+
const { id: _id, ...updateRow } = row;
|
|
58
|
+
if (provider === "mysql") await executor.insertInto("bundles").values(row).onDuplicateKeyUpdate(updateRow).execute();
|
|
59
|
+
else await executor.insertInto("bundles").values(row).onConflict((oc) => oc.column("id").doUpdateSet(updateRow)).execute();
|
|
60
|
+
await executor.deleteFrom("bundle_patches").where("bundle_id", "=", bundle.id).execute();
|
|
61
|
+
const patches = require_bundleRows.bundleToPatchRows(bundle);
|
|
62
|
+
if (patches.length > 0) await executor.insertInto("bundle_patches").values(patches).execute();
|
|
63
|
+
};
|
|
64
|
+
return {
|
|
65
|
+
async getBundleById(bundleId) {
|
|
66
|
+
const row = await db.selectFrom("bundles").selectAll().where("id", "=", bundleId).executeTakeFirst();
|
|
67
|
+
if (!row) return null;
|
|
68
|
+
return require_bundleRows.rowToBundle(row, (await fetchPatchMap([bundleId])).get(bundleId) ?? []);
|
|
69
|
+
},
|
|
70
|
+
async getBundles(options) {
|
|
71
|
+
const offset = options.offset ?? 0;
|
|
72
|
+
if (hasEmptySetFilter(options.where)) return {
|
|
73
|
+
data: [],
|
|
74
|
+
pagination: (0, _hot_updater_plugin_core.calculatePagination)(0, {
|
|
75
|
+
limit: options.limit,
|
|
76
|
+
offset
|
|
77
|
+
})
|
|
78
|
+
};
|
|
79
|
+
const orderBy = options.orderBy ?? {
|
|
80
|
+
field: "id",
|
|
81
|
+
direction: "desc"
|
|
82
|
+
};
|
|
83
|
+
const countRow = await applyWhere(db.selectFrom("bundles"), options.where).select(db.fn.count("id").as("total")).executeTakeFirst();
|
|
84
|
+
const total = Number(countRow?.total ?? 0);
|
|
85
|
+
const rows = await applyWhere(db.selectFrom("bundles").selectAll(), options.where).orderBy("id", orderBy.direction).limit(options.limit).offset(offset).execute();
|
|
86
|
+
const patchMap = await fetchPatchMap(rows.map((row) => row.id));
|
|
87
|
+
return {
|
|
88
|
+
data: rows.map((row) => require_bundleRows.rowToBundle(row, patchMap.get(row.id) ?? [])),
|
|
89
|
+
pagination: (0, _hot_updater_plugin_core.calculatePagination)(total, {
|
|
90
|
+
limit: options.limit,
|
|
91
|
+
offset
|
|
92
|
+
})
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
async getUpdateInfo(args, context) {
|
|
96
|
+
if (args._updateStrategy === "appVersion") {
|
|
97
|
+
const channel = args.channel ?? "production";
|
|
98
|
+
const minBundleId = args.minBundleId ?? _hot_updater_core.NIL_UUID;
|
|
99
|
+
const rows = await db.selectFrom("bundles").select("target_app_version").where("enabled", "=", true).where("platform", "=", args.platform).where("channel", "=", channel).where("id", ">=", minBundleId).where("target_app_version", "is not", null).execute();
|
|
100
|
+
const compatibleAppVersions = (0, _hot_updater_plugin_core.filterCompatibleAppVersions)(Array.from(new Set(rows.map((row) => row.target_app_version).filter((value) => typeof value === "string" && value.length > 0))), args.appVersion);
|
|
101
|
+
const bundles = compatibleAppVersions.length > 0 ? await db.selectFrom("bundles").selectAll().where("enabled", "=", true).where("platform", "=", args.platform).where("channel", "=", channel).where("id", ">=", minBundleId).where("target_app_version", "in", compatibleAppVersions).orderBy("id", "desc").execute().then(mapRowsToBundles) : [];
|
|
102
|
+
return (0, _hot_updater_plugin_core.resolveUpdateInfoFromBundles)({
|
|
103
|
+
args: {
|
|
104
|
+
...args,
|
|
105
|
+
channel,
|
|
106
|
+
minBundleId
|
|
107
|
+
},
|
|
108
|
+
bundles,
|
|
109
|
+
context
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
const channel = args.channel ?? "production";
|
|
113
|
+
const minBundleId = args.minBundleId ?? _hot_updater_core.NIL_UUID;
|
|
114
|
+
const rows = await db.selectFrom("bundles").selectAll().where("enabled", "=", true).where("platform", "=", args.platform).where("channel", "=", channel).where("id", ">=", minBundleId).where("fingerprint_hash", "=", args.fingerprintHash).orderBy("id", "desc").execute();
|
|
115
|
+
return (0, _hot_updater_plugin_core.resolveUpdateInfoFromBundles)({
|
|
116
|
+
args: {
|
|
117
|
+
...args,
|
|
118
|
+
channel,
|
|
119
|
+
minBundleId
|
|
120
|
+
},
|
|
121
|
+
bundles: await mapRowsToBundles(rows),
|
|
122
|
+
context
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
async getChannels() {
|
|
126
|
+
const rows = await db.selectFrom("bundles").select("channel").orderBy("channel", "asc").execute();
|
|
127
|
+
return Array.from(new Set(rows.map((row) => row.channel)));
|
|
128
|
+
},
|
|
129
|
+
async commitBundle({ changedSets }) {
|
|
130
|
+
await db.transaction().execute(async (tx) => {
|
|
131
|
+
for (const change of changedSets) {
|
|
132
|
+
if (change.operation === "delete") {
|
|
133
|
+
await tx.deleteFrom("bundle_patches").where("bundle_id", "=", change.data.id).execute();
|
|
134
|
+
await tx.deleteFrom("bundle_patches").where("base_bundle_id", "=", change.data.id).execute();
|
|
135
|
+
await tx.deleteFrom("bundles").where("id", "=", change.data.id).execute();
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
await upsertBundle(tx, change.data);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
const kyselyAdapter = (config) => {
|
|
146
|
+
assertKyselySQLProvider(config.provider);
|
|
147
|
+
return Object.assign(createKyselyPlugin(config), {
|
|
148
|
+
adapterName: "kysely",
|
|
149
|
+
provider: config.provider,
|
|
150
|
+
createMigrator: () => require_fixedMigrator.createKyselyMigrator({
|
|
151
|
+
db: config.db,
|
|
152
|
+
provider: config.provider,
|
|
153
|
+
relationMode: config.relationMode
|
|
154
|
+
})
|
|
155
|
+
});
|
|
156
|
+
};
|
|
6
157
|
//#endregion
|
|
7
158
|
exports.kyselyAdapter = kyselyAdapter;
|
|
@@ -1,14 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { DatabasePluginFactory, ORMSQLProvider, RelationMode } from "../db/types.cjs";
|
|
2
|
+
import { BundlePatchRow, BundleRow } from "../db/bundleRows.cjs";
|
|
3
|
+
import { Kysely } from "kysely";
|
|
3
4
|
|
|
4
5
|
//#region src/adapters/kysely.d.ts
|
|
5
|
-
type
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
type KyselySQLProvider = Exclude<ORMSQLProvider, "mssql">;
|
|
7
|
+
interface Database {
|
|
8
|
+
readonly bundles: BundleRow;
|
|
9
|
+
readonly bundle_patches: BundlePatchRow;
|
|
10
|
+
readonly private_hot_updater_settings: {
|
|
11
|
+
readonly key: string;
|
|
12
|
+
readonly value: string;
|
|
13
|
+
};
|
|
11
14
|
}
|
|
12
|
-
|
|
15
|
+
interface KyselyAdapterConfig<TDatabase extends object = Database> {
|
|
16
|
+
readonly db: Kysely<TDatabase>;
|
|
17
|
+
readonly provider: KyselySQLProvider;
|
|
18
|
+
readonly relationMode?: RelationMode;
|
|
19
|
+
}
|
|
20
|
+
declare const kyselyAdapter: <TDatabase extends object>(config: KyselyAdapterConfig<TDatabase>) => DatabasePluginFactory;
|
|
13
21
|
//#endregion
|
|
14
|
-
export {
|
|
22
|
+
export { KyselyAdapterConfig, type RelationMode, type KyselySQLProvider as SQLProvider, kyselyAdapter };
|
|
@@ -1,14 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { DatabasePluginFactory, ORMSQLProvider, RelationMode } from "../db/types.mjs";
|
|
2
|
+
import { BundlePatchRow, BundleRow } from "../db/bundleRows.mjs";
|
|
3
|
+
import { Kysely } from "kysely";
|
|
3
4
|
|
|
4
5
|
//#region src/adapters/kysely.d.ts
|
|
5
|
-
type
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
type KyselySQLProvider = Exclude<ORMSQLProvider, "mssql">;
|
|
7
|
+
interface Database {
|
|
8
|
+
readonly bundles: BundleRow;
|
|
9
|
+
readonly bundle_patches: BundlePatchRow;
|
|
10
|
+
readonly private_hot_updater_settings: {
|
|
11
|
+
readonly key: string;
|
|
12
|
+
readonly value: string;
|
|
13
|
+
};
|
|
11
14
|
}
|
|
12
|
-
|
|
15
|
+
interface KyselyAdapterConfig<TDatabase extends object = Database> {
|
|
16
|
+
readonly db: Kysely<TDatabase>;
|
|
17
|
+
readonly provider: KyselySQLProvider;
|
|
18
|
+
readonly relationMode?: RelationMode;
|
|
19
|
+
}
|
|
20
|
+
declare const kyselyAdapter: <TDatabase extends object>(config: KyselyAdapterConfig<TDatabase>) => DatabasePluginFactory;
|
|
13
21
|
//#endregion
|
|
14
|
-
export {
|
|
22
|
+
export { KyselyAdapterConfig, type RelationMode, type KyselySQLProvider as SQLProvider, kyselyAdapter };
|
package/dist/adapters/kysely.mjs
CHANGED
|
@@ -1,6 +1,156 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../
|
|
1
|
+
import { bundleToPatchRows, bundleToRow, rowToBundle } from "../db/bundleRows.mjs";
|
|
2
|
+
import { createKyselyMigrator } from "../db/fixedMigrator.mjs";
|
|
3
|
+
import { calculatePagination, createDatabasePlugin, filterCompatibleAppVersions, resolveUpdateInfoFromBundles } from "@hot-updater/plugin-core";
|
|
4
|
+
import { NIL_UUID } from "@hot-updater/core";
|
|
3
5
|
//#region src/adapters/kysely.ts
|
|
4
|
-
const
|
|
6
|
+
const assertKyselySQLProvider = (provider) => {
|
|
7
|
+
if (provider === "mssql") throw new Error("Kysely adapter does not support provider: mssql.");
|
|
8
|
+
};
|
|
9
|
+
const applyWhere = (query, where) => {
|
|
10
|
+
let next = query;
|
|
11
|
+
if (where?.channel !== void 0) next = next.where("channel", "=", where.channel);
|
|
12
|
+
if (where?.platform !== void 0) next = next.where("platform", "=", where.platform);
|
|
13
|
+
if (where?.enabled !== void 0) next = next.where("enabled", "=", where.enabled);
|
|
14
|
+
if (where?.fingerprintHash !== void 0) next = where.fingerprintHash === null ? next.where("fingerprint_hash", "is", null) : next.where("fingerprint_hash", "=", where.fingerprintHash);
|
|
15
|
+
if (where?.targetAppVersion !== void 0) next = where.targetAppVersion === null ? next.where("target_app_version", "is", null) : next.where("target_app_version", "=", where.targetAppVersion);
|
|
16
|
+
if (where?.targetAppVersionIn) next = next.where("target_app_version", "in", where.targetAppVersionIn);
|
|
17
|
+
if (where?.targetAppVersionNotNull) next = next.where("target_app_version", "is not", null);
|
|
18
|
+
if (where?.id?.eq) next = next.where("id", "=", where.id.eq);
|
|
19
|
+
if (where?.id?.gt) next = next.where("id", ">", where.id.gt);
|
|
20
|
+
if (where?.id?.gte) next = next.where("id", ">=", where.id.gte);
|
|
21
|
+
if (where?.id?.lt) next = next.where("id", "<", where.id.lt);
|
|
22
|
+
if (where?.id?.lte) next = next.where("id", "<=", where.id.lte);
|
|
23
|
+
if (where?.id?.in) next = next.where("id", "in", where.id.in);
|
|
24
|
+
return next;
|
|
25
|
+
};
|
|
26
|
+
const hasEmptySetFilter = (where) => where?.targetAppVersionIn?.length === 0 || where?.id?.in?.length === 0;
|
|
27
|
+
const toProviderBundleRow = (row, provider) => {
|
|
28
|
+
if (provider !== "mysql" && provider !== "sqlite") return row;
|
|
29
|
+
return {
|
|
30
|
+
...row,
|
|
31
|
+
metadata: JSON.stringify(row.metadata ?? {}),
|
|
32
|
+
target_cohorts: row.target_cohorts === null || row.target_cohorts === void 0 ? null : JSON.stringify(row.target_cohorts)
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
const createKyselyPlugin = createDatabasePlugin({
|
|
36
|
+
name: "kysely",
|
|
37
|
+
factory: ({ db, provider }) => {
|
|
38
|
+
const fetchPatchMap = async (bundleIds) => {
|
|
39
|
+
const patchMap = /* @__PURE__ */ new Map();
|
|
40
|
+
if (bundleIds.length === 0) return patchMap;
|
|
41
|
+
const rows = await db.selectFrom("bundle_patches").selectAll().where("bundle_id", "in", [...bundleIds]).orderBy("order_index", "asc").execute();
|
|
42
|
+
for (const row of rows) {
|
|
43
|
+
const current = patchMap.get(row.bundle_id) ?? [];
|
|
44
|
+
current.push(row);
|
|
45
|
+
patchMap.set(row.bundle_id, current);
|
|
46
|
+
}
|
|
47
|
+
return patchMap;
|
|
48
|
+
};
|
|
49
|
+
const mapRowsToBundles = async (rows) => {
|
|
50
|
+
const patchMap = await fetchPatchMap(rows.map((row) => row.id));
|
|
51
|
+
return rows.map((row) => rowToBundle(row, patchMap.get(row.id) ?? []));
|
|
52
|
+
};
|
|
53
|
+
const upsertBundle = async (executor, bundle) => {
|
|
54
|
+
const row = toProviderBundleRow(bundleToRow(bundle), provider);
|
|
55
|
+
const { id: _id, ...updateRow } = row;
|
|
56
|
+
if (provider === "mysql") await executor.insertInto("bundles").values(row).onDuplicateKeyUpdate(updateRow).execute();
|
|
57
|
+
else await executor.insertInto("bundles").values(row).onConflict((oc) => oc.column("id").doUpdateSet(updateRow)).execute();
|
|
58
|
+
await executor.deleteFrom("bundle_patches").where("bundle_id", "=", bundle.id).execute();
|
|
59
|
+
const patches = bundleToPatchRows(bundle);
|
|
60
|
+
if (patches.length > 0) await executor.insertInto("bundle_patches").values(patches).execute();
|
|
61
|
+
};
|
|
62
|
+
return {
|
|
63
|
+
async getBundleById(bundleId) {
|
|
64
|
+
const row = await db.selectFrom("bundles").selectAll().where("id", "=", bundleId).executeTakeFirst();
|
|
65
|
+
if (!row) return null;
|
|
66
|
+
return rowToBundle(row, (await fetchPatchMap([bundleId])).get(bundleId) ?? []);
|
|
67
|
+
},
|
|
68
|
+
async getBundles(options) {
|
|
69
|
+
const offset = options.offset ?? 0;
|
|
70
|
+
if (hasEmptySetFilter(options.where)) return {
|
|
71
|
+
data: [],
|
|
72
|
+
pagination: calculatePagination(0, {
|
|
73
|
+
limit: options.limit,
|
|
74
|
+
offset
|
|
75
|
+
})
|
|
76
|
+
};
|
|
77
|
+
const orderBy = options.orderBy ?? {
|
|
78
|
+
field: "id",
|
|
79
|
+
direction: "desc"
|
|
80
|
+
};
|
|
81
|
+
const countRow = await applyWhere(db.selectFrom("bundles"), options.where).select(db.fn.count("id").as("total")).executeTakeFirst();
|
|
82
|
+
const total = Number(countRow?.total ?? 0);
|
|
83
|
+
const rows = await applyWhere(db.selectFrom("bundles").selectAll(), options.where).orderBy("id", orderBy.direction).limit(options.limit).offset(offset).execute();
|
|
84
|
+
const patchMap = await fetchPatchMap(rows.map((row) => row.id));
|
|
85
|
+
return {
|
|
86
|
+
data: rows.map((row) => rowToBundle(row, patchMap.get(row.id) ?? [])),
|
|
87
|
+
pagination: calculatePagination(total, {
|
|
88
|
+
limit: options.limit,
|
|
89
|
+
offset
|
|
90
|
+
})
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
async getUpdateInfo(args, context) {
|
|
94
|
+
if (args._updateStrategy === "appVersion") {
|
|
95
|
+
const channel = args.channel ?? "production";
|
|
96
|
+
const minBundleId = args.minBundleId ?? NIL_UUID;
|
|
97
|
+
const rows = await db.selectFrom("bundles").select("target_app_version").where("enabled", "=", true).where("platform", "=", args.platform).where("channel", "=", channel).where("id", ">=", minBundleId).where("target_app_version", "is not", null).execute();
|
|
98
|
+
const compatibleAppVersions = filterCompatibleAppVersions(Array.from(new Set(rows.map((row) => row.target_app_version).filter((value) => typeof value === "string" && value.length > 0))), args.appVersion);
|
|
99
|
+
const bundles = compatibleAppVersions.length > 0 ? await db.selectFrom("bundles").selectAll().where("enabled", "=", true).where("platform", "=", args.platform).where("channel", "=", channel).where("id", ">=", minBundleId).where("target_app_version", "in", compatibleAppVersions).orderBy("id", "desc").execute().then(mapRowsToBundles) : [];
|
|
100
|
+
return resolveUpdateInfoFromBundles({
|
|
101
|
+
args: {
|
|
102
|
+
...args,
|
|
103
|
+
channel,
|
|
104
|
+
minBundleId
|
|
105
|
+
},
|
|
106
|
+
bundles,
|
|
107
|
+
context
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
const channel = args.channel ?? "production";
|
|
111
|
+
const minBundleId = args.minBundleId ?? NIL_UUID;
|
|
112
|
+
const rows = await db.selectFrom("bundles").selectAll().where("enabled", "=", true).where("platform", "=", args.platform).where("channel", "=", channel).where("id", ">=", minBundleId).where("fingerprint_hash", "=", args.fingerprintHash).orderBy("id", "desc").execute();
|
|
113
|
+
return resolveUpdateInfoFromBundles({
|
|
114
|
+
args: {
|
|
115
|
+
...args,
|
|
116
|
+
channel,
|
|
117
|
+
minBundleId
|
|
118
|
+
},
|
|
119
|
+
bundles: await mapRowsToBundles(rows),
|
|
120
|
+
context
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
async getChannels() {
|
|
124
|
+
const rows = await db.selectFrom("bundles").select("channel").orderBy("channel", "asc").execute();
|
|
125
|
+
return Array.from(new Set(rows.map((row) => row.channel)));
|
|
126
|
+
},
|
|
127
|
+
async commitBundle({ changedSets }) {
|
|
128
|
+
await db.transaction().execute(async (tx) => {
|
|
129
|
+
for (const change of changedSets) {
|
|
130
|
+
if (change.operation === "delete") {
|
|
131
|
+
await tx.deleteFrom("bundle_patches").where("bundle_id", "=", change.data.id).execute();
|
|
132
|
+
await tx.deleteFrom("bundle_patches").where("base_bundle_id", "=", change.data.id).execute();
|
|
133
|
+
await tx.deleteFrom("bundles").where("id", "=", change.data.id).execute();
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
await upsertBundle(tx, change.data);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
const kyselyAdapter = (config) => {
|
|
144
|
+
assertKyselySQLProvider(config.provider);
|
|
145
|
+
return Object.assign(createKyselyPlugin(config), {
|
|
146
|
+
adapterName: "kysely",
|
|
147
|
+
provider: config.provider,
|
|
148
|
+
createMigrator: () => createKyselyMigrator({
|
|
149
|
+
db: config.db,
|
|
150
|
+
provider: config.provider,
|
|
151
|
+
relationMode: config.relationMode
|
|
152
|
+
})
|
|
153
|
+
});
|
|
154
|
+
};
|
|
5
155
|
//#endregion
|
|
6
156
|
export { kyselyAdapter };
|
|
@@ -1,7 +1,188 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("../_virtual/_rolldown/runtime.cjs");
|
|
3
|
-
|
|
3
|
+
const require_bundleRows = require("../db/bundleRows.cjs");
|
|
4
|
+
const require_fixedMigrator = require("../db/fixedMigrator.cjs");
|
|
5
|
+
let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
|
|
6
|
+
let _hot_updater_core = require("@hot-updater/core");
|
|
4
7
|
//#region src/adapters/mongodb.ts
|
|
5
|
-
const
|
|
8
|
+
const mongoWhere = (where) => {
|
|
9
|
+
const baseFilter = {
|
|
10
|
+
...where?.channel !== void 0 ? { channel: where.channel } : {},
|
|
11
|
+
...where?.platform !== void 0 ? { platform: where.platform } : {},
|
|
12
|
+
...where?.enabled !== void 0 ? { enabled: where.enabled } : {},
|
|
13
|
+
...where?.fingerprintHash !== void 0 ? where.fingerprintHash === null ? { fingerprint_hash: { $in: [null, ""] } } : { fingerprint_hash: where.fingerprintHash } : {},
|
|
14
|
+
...where?.id ? { id: {
|
|
15
|
+
...where.id.eq !== void 0 ? { $eq: where.id.eq } : {},
|
|
16
|
+
...where.id.gt !== void 0 ? { $gt: where.id.gt } : {},
|
|
17
|
+
...where.id.gte !== void 0 ? { $gte: where.id.gte } : {},
|
|
18
|
+
...where.id.lt !== void 0 ? { $lt: where.id.lt } : {},
|
|
19
|
+
...where.id.lte !== void 0 ? { $lte: where.id.lte } : {},
|
|
20
|
+
...where.id.in !== void 0 ? { $in: where.id.in } : {}
|
|
21
|
+
} } : {}
|
|
22
|
+
};
|
|
23
|
+
const targetAppVersionFilters = [];
|
|
24
|
+
if (where?.targetAppVersion !== void 0) targetAppVersionFilters.push(where.targetAppVersion === null ? { target_app_version: { $in: [null, ""] } } : { target_app_version: where.targetAppVersion });
|
|
25
|
+
if (where?.targetAppVersionIn) targetAppVersionFilters.push({ target_app_version: { $in: where.targetAppVersionIn } });
|
|
26
|
+
if (where?.targetAppVersionNotNull) targetAppVersionFilters.push({ target_app_version: {
|
|
27
|
+
$exists: true,
|
|
28
|
+
$nin: [null, ""]
|
|
29
|
+
} });
|
|
30
|
+
const filters = [...Object.keys(baseFilter).length > 0 ? [baseFilter] : [], ...targetAppVersionFilters];
|
|
31
|
+
if (filters.length === 0) return {};
|
|
32
|
+
if (filters.length === 1) return filters[0] ?? {};
|
|
33
|
+
return { $and: filters };
|
|
34
|
+
};
|
|
35
|
+
const createMongoPlugin = (0, _hot_updater_plugin_core.createDatabasePlugin)({
|
|
36
|
+
name: "mongodb",
|
|
37
|
+
factory: ({ client }) => {
|
|
38
|
+
const db = client.db();
|
|
39
|
+
const bundles = db.collection("bundles");
|
|
40
|
+
const patches = db.collection("bundle_patches");
|
|
41
|
+
const fetchPatchMap = async (bundleIds) => {
|
|
42
|
+
const patchMap = /* @__PURE__ */ new Map();
|
|
43
|
+
if (bundleIds.length === 0) return patchMap;
|
|
44
|
+
const rows = await patches.find({ bundle_id: { $in: [...bundleIds] } }).sort({ order_index: 1 }).toArray();
|
|
45
|
+
for (const row of rows) {
|
|
46
|
+
const current = patchMap.get(row.bundle_id) ?? [];
|
|
47
|
+
current.push(row);
|
|
48
|
+
patchMap.set(row.bundle_id, current);
|
|
49
|
+
}
|
|
50
|
+
return patchMap;
|
|
51
|
+
};
|
|
52
|
+
const mapRowsToBundles = async (rows) => {
|
|
53
|
+
const patchMap = await fetchPatchMap(rows.map((row) => row.id));
|
|
54
|
+
return rows.map((row) => require_bundleRows.rowToBundle(row, patchMap.get(row.id) ?? []));
|
|
55
|
+
};
|
|
56
|
+
const isTransactionUnsupported = (error) => error instanceof Error && /Transaction numbers are only allowed|replica set member or mongos|Transaction API error/i.test(error.message);
|
|
57
|
+
const runInTransaction = async (operation) => {
|
|
58
|
+
if (typeof client.startSession !== "function") return operation(void 0);
|
|
59
|
+
const session = client.startSession();
|
|
60
|
+
try {
|
|
61
|
+
if (typeof session.withTransaction !== "function") return await operation(session);
|
|
62
|
+
let result;
|
|
63
|
+
await session.withTransaction(async () => {
|
|
64
|
+
result = await operation(session);
|
|
65
|
+
});
|
|
66
|
+
return result;
|
|
67
|
+
} catch (error) {
|
|
68
|
+
if (isTransactionUnsupported(error)) return operation(void 0);
|
|
69
|
+
throw error;
|
|
70
|
+
} finally {
|
|
71
|
+
await session.endSession();
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const replaceBundle = async (bundle, session) => {
|
|
75
|
+
const row = require_bundleRows.bundleToRow(bundle);
|
|
76
|
+
await bundles.updateOne({ id: bundle.id }, { $set: row }, {
|
|
77
|
+
session,
|
|
78
|
+
upsert: true
|
|
79
|
+
});
|
|
80
|
+
await patches.deleteMany({ bundle_id: bundle.id }, { session });
|
|
81
|
+
const patchRows = require_bundleRows.bundleToPatchRows(bundle);
|
|
82
|
+
if (patchRows.length > 0) await patches.insertMany(patchRows, { session });
|
|
83
|
+
};
|
|
84
|
+
const deleteByBundleId = async (collection, field, bundleId, session) => {
|
|
85
|
+
await collection.deleteMany({ [field]: bundleId }, { session });
|
|
86
|
+
};
|
|
87
|
+
return {
|
|
88
|
+
async getBundleById(bundleId) {
|
|
89
|
+
const row = await bundles.findOne({ id: bundleId });
|
|
90
|
+
if (!row) return null;
|
|
91
|
+
return require_bundleRows.rowToBundle(row, (await fetchPatchMap([bundleId])).get(bundleId) ?? []);
|
|
92
|
+
},
|
|
93
|
+
async getBundles(options) {
|
|
94
|
+
const offset = options.offset ?? 0;
|
|
95
|
+
const orderBy = options.orderBy ?? {
|
|
96
|
+
field: "id",
|
|
97
|
+
direction: "desc"
|
|
98
|
+
};
|
|
99
|
+
const where = mongoWhere(options.where);
|
|
100
|
+
const [total, rows] = await Promise.all([bundles.countDocuments(where), bundles.find(where).sort({ id: orderBy.direction === "asc" ? 1 : -1 }).skip(offset).limit(options.limit).toArray()]);
|
|
101
|
+
const patchMap = await fetchPatchMap(rows.map((row) => row.id));
|
|
102
|
+
return {
|
|
103
|
+
data: rows.map((row) => require_bundleRows.rowToBundle(row, patchMap.get(row.id) ?? [])),
|
|
104
|
+
pagination: (0, _hot_updater_plugin_core.calculatePagination)(total, {
|
|
105
|
+
limit: options.limit,
|
|
106
|
+
offset
|
|
107
|
+
})
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
async getUpdateInfo(args, context) {
|
|
111
|
+
if (args._updateStrategy === "appVersion") {
|
|
112
|
+
const channel = args.channel ?? "production";
|
|
113
|
+
const minBundleId = args.minBundleId ?? _hot_updater_core.NIL_UUID;
|
|
114
|
+
const rows = await bundles.find({
|
|
115
|
+
enabled: true,
|
|
116
|
+
platform: args.platform,
|
|
117
|
+
channel,
|
|
118
|
+
id: { $gte: minBundleId },
|
|
119
|
+
target_app_version: {
|
|
120
|
+
$exists: true,
|
|
121
|
+
$nin: [null, ""]
|
|
122
|
+
}
|
|
123
|
+
}).project({ target_app_version: 1 }).toArray();
|
|
124
|
+
const compatibleAppVersions = (0, _hot_updater_plugin_core.filterCompatibleAppVersions)(Array.from(new Set(rows.map((row) => row.target_app_version).filter((value) => typeof value === "string" && value.length > 0))), args.appVersion);
|
|
125
|
+
const updateRows = compatibleAppVersions.length > 0 ? await bundles.find({
|
|
126
|
+
enabled: true,
|
|
127
|
+
platform: args.platform,
|
|
128
|
+
channel,
|
|
129
|
+
id: { $gte: minBundleId },
|
|
130
|
+
target_app_version: { $in: compatibleAppVersions }
|
|
131
|
+
}).sort({ id: -1 }).toArray() : [];
|
|
132
|
+
return (0, _hot_updater_plugin_core.resolveUpdateInfoFromBundles)({
|
|
133
|
+
args: {
|
|
134
|
+
...args,
|
|
135
|
+
channel,
|
|
136
|
+
minBundleId
|
|
137
|
+
},
|
|
138
|
+
bundles: await mapRowsToBundles(updateRows),
|
|
139
|
+
context
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
const channel = args.channel ?? "production";
|
|
143
|
+
const minBundleId = args.minBundleId ?? _hot_updater_core.NIL_UUID;
|
|
144
|
+
const rows = await bundles.find({
|
|
145
|
+
enabled: true,
|
|
146
|
+
platform: args.platform,
|
|
147
|
+
channel,
|
|
148
|
+
id: { $gte: minBundleId },
|
|
149
|
+
fingerprint_hash: args.fingerprintHash
|
|
150
|
+
}).sort({ id: -1 }).toArray();
|
|
151
|
+
return (0, _hot_updater_plugin_core.resolveUpdateInfoFromBundles)({
|
|
152
|
+
args: {
|
|
153
|
+
...args,
|
|
154
|
+
channel,
|
|
155
|
+
minBundleId
|
|
156
|
+
},
|
|
157
|
+
bundles: await mapRowsToBundles(rows),
|
|
158
|
+
context
|
|
159
|
+
});
|
|
160
|
+
},
|
|
161
|
+
async getChannels() {
|
|
162
|
+
return (await bundles.distinct("channel")).filter((channel) => typeof channel === "string").sort((left, right) => left.localeCompare(right));
|
|
163
|
+
},
|
|
164
|
+
async commitBundle({ changedSets }) {
|
|
165
|
+
await runInTransaction(async (session) => {
|
|
166
|
+
for (const change of changedSets) {
|
|
167
|
+
if (change.operation === "delete") {
|
|
168
|
+
await deleteByBundleId(patches, "bundle_id", change.data.id, session);
|
|
169
|
+
await deleteByBundleId(patches, "base_bundle_id", change.data.id, session);
|
|
170
|
+
await bundles.deleteMany({ id: change.data.id }, { session });
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
await replaceBundle(change.data, session);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
const mongoAdapter = (config) => {
|
|
181
|
+
return Object.assign(createMongoPlugin(config), {
|
|
182
|
+
adapterName: "mongodb",
|
|
183
|
+
provider: "mongodb",
|
|
184
|
+
createMigrator: () => require_fixedMigrator.createMongoMigrator(config.client)
|
|
185
|
+
});
|
|
186
|
+
};
|
|
6
187
|
//#endregion
|
|
7
188
|
exports.mongoAdapter = mongoAdapter;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DatabasePluginFactory } from "../db/types.cjs";
|
|
2
|
+
import { MongoClient } from "mongodb";
|
|
2
3
|
|
|
3
4
|
//#region src/adapters/mongodb.d.ts
|
|
4
|
-
interface MongoDBConfig
|
|
5
|
-
client:
|
|
5
|
+
interface MongoDBConfig {
|
|
6
|
+
readonly client: MongoClient;
|
|
6
7
|
}
|
|
7
|
-
declare const mongoAdapter:
|
|
8
|
+
declare const mongoAdapter: (config: MongoDBConfig) => DatabasePluginFactory;
|
|
8
9
|
//#endregion
|
|
9
10
|
export { MongoDBConfig, mongoAdapter };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DatabasePluginFactory } from "../db/types.mjs";
|
|
2
|
+
import { MongoClient } from "mongodb";
|
|
2
3
|
|
|
3
4
|
//#region src/adapters/mongodb.d.ts
|
|
4
|
-
interface MongoDBConfig
|
|
5
|
-
client:
|
|
5
|
+
interface MongoDBConfig {
|
|
6
|
+
readonly client: MongoClient;
|
|
6
7
|
}
|
|
7
|
-
declare const mongoAdapter:
|
|
8
|
+
declare const mongoAdapter: (config: MongoDBConfig) => DatabasePluginFactory;
|
|
8
9
|
//#endregion
|
|
9
10
|
export { MongoDBConfig, mongoAdapter };
|