@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
|
@@ -1,5 +1,186 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { bundleToPatchRows, bundleToRow, rowToBundle } from "../db/bundleRows.mjs";
|
|
2
|
+
import { createMongoMigrator } from "../db/fixedMigrator.mjs";
|
|
3
|
+
import { calculatePagination, createDatabasePlugin, filterCompatibleAppVersions, resolveUpdateInfoFromBundles } from "@hot-updater/plugin-core";
|
|
4
|
+
import { NIL_UUID } from "@hot-updater/core";
|
|
2
5
|
//#region src/adapters/mongodb.ts
|
|
3
|
-
const
|
|
6
|
+
const mongoWhere = (where) => {
|
|
7
|
+
const baseFilter = {
|
|
8
|
+
...where?.channel !== void 0 ? { channel: where.channel } : {},
|
|
9
|
+
...where?.platform !== void 0 ? { platform: where.platform } : {},
|
|
10
|
+
...where?.enabled !== void 0 ? { enabled: where.enabled } : {},
|
|
11
|
+
...where?.fingerprintHash !== void 0 ? where.fingerprintHash === null ? { fingerprint_hash: { $in: [null, ""] } } : { fingerprint_hash: where.fingerprintHash } : {},
|
|
12
|
+
...where?.id ? { id: {
|
|
13
|
+
...where.id.eq !== void 0 ? { $eq: where.id.eq } : {},
|
|
14
|
+
...where.id.gt !== void 0 ? { $gt: where.id.gt } : {},
|
|
15
|
+
...where.id.gte !== void 0 ? { $gte: where.id.gte } : {},
|
|
16
|
+
...where.id.lt !== void 0 ? { $lt: where.id.lt } : {},
|
|
17
|
+
...where.id.lte !== void 0 ? { $lte: where.id.lte } : {},
|
|
18
|
+
...where.id.in !== void 0 ? { $in: where.id.in } : {}
|
|
19
|
+
} } : {}
|
|
20
|
+
};
|
|
21
|
+
const targetAppVersionFilters = [];
|
|
22
|
+
if (where?.targetAppVersion !== void 0) targetAppVersionFilters.push(where.targetAppVersion === null ? { target_app_version: { $in: [null, ""] } } : { target_app_version: where.targetAppVersion });
|
|
23
|
+
if (where?.targetAppVersionIn) targetAppVersionFilters.push({ target_app_version: { $in: where.targetAppVersionIn } });
|
|
24
|
+
if (where?.targetAppVersionNotNull) targetAppVersionFilters.push({ target_app_version: {
|
|
25
|
+
$exists: true,
|
|
26
|
+
$nin: [null, ""]
|
|
27
|
+
} });
|
|
28
|
+
const filters = [...Object.keys(baseFilter).length > 0 ? [baseFilter] : [], ...targetAppVersionFilters];
|
|
29
|
+
if (filters.length === 0) return {};
|
|
30
|
+
if (filters.length === 1) return filters[0] ?? {};
|
|
31
|
+
return { $and: filters };
|
|
32
|
+
};
|
|
33
|
+
const createMongoPlugin = createDatabasePlugin({
|
|
34
|
+
name: "mongodb",
|
|
35
|
+
factory: ({ client }) => {
|
|
36
|
+
const db = client.db();
|
|
37
|
+
const bundles = db.collection("bundles");
|
|
38
|
+
const patches = db.collection("bundle_patches");
|
|
39
|
+
const fetchPatchMap = async (bundleIds) => {
|
|
40
|
+
const patchMap = /* @__PURE__ */ new Map();
|
|
41
|
+
if (bundleIds.length === 0) return patchMap;
|
|
42
|
+
const rows = await patches.find({ bundle_id: { $in: [...bundleIds] } }).sort({ order_index: 1 }).toArray();
|
|
43
|
+
for (const row of rows) {
|
|
44
|
+
const current = patchMap.get(row.bundle_id) ?? [];
|
|
45
|
+
current.push(row);
|
|
46
|
+
patchMap.set(row.bundle_id, current);
|
|
47
|
+
}
|
|
48
|
+
return patchMap;
|
|
49
|
+
};
|
|
50
|
+
const mapRowsToBundles = async (rows) => {
|
|
51
|
+
const patchMap = await fetchPatchMap(rows.map((row) => row.id));
|
|
52
|
+
return rows.map((row) => rowToBundle(row, patchMap.get(row.id) ?? []));
|
|
53
|
+
};
|
|
54
|
+
const isTransactionUnsupported = (error) => error instanceof Error && /Transaction numbers are only allowed|replica set member or mongos|Transaction API error/i.test(error.message);
|
|
55
|
+
const runInTransaction = async (operation) => {
|
|
56
|
+
if (typeof client.startSession !== "function") return operation(void 0);
|
|
57
|
+
const session = client.startSession();
|
|
58
|
+
try {
|
|
59
|
+
if (typeof session.withTransaction !== "function") return await operation(session);
|
|
60
|
+
let result;
|
|
61
|
+
await session.withTransaction(async () => {
|
|
62
|
+
result = await operation(session);
|
|
63
|
+
});
|
|
64
|
+
return result;
|
|
65
|
+
} catch (error) {
|
|
66
|
+
if (isTransactionUnsupported(error)) return operation(void 0);
|
|
67
|
+
throw error;
|
|
68
|
+
} finally {
|
|
69
|
+
await session.endSession();
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const replaceBundle = async (bundle, session) => {
|
|
73
|
+
const row = bundleToRow(bundle);
|
|
74
|
+
await bundles.updateOne({ id: bundle.id }, { $set: row }, {
|
|
75
|
+
session,
|
|
76
|
+
upsert: true
|
|
77
|
+
});
|
|
78
|
+
await patches.deleteMany({ bundle_id: bundle.id }, { session });
|
|
79
|
+
const patchRows = bundleToPatchRows(bundle);
|
|
80
|
+
if (patchRows.length > 0) await patches.insertMany(patchRows, { session });
|
|
81
|
+
};
|
|
82
|
+
const deleteByBundleId = async (collection, field, bundleId, session) => {
|
|
83
|
+
await collection.deleteMany({ [field]: bundleId }, { session });
|
|
84
|
+
};
|
|
85
|
+
return {
|
|
86
|
+
async getBundleById(bundleId) {
|
|
87
|
+
const row = await bundles.findOne({ id: bundleId });
|
|
88
|
+
if (!row) return null;
|
|
89
|
+
return rowToBundle(row, (await fetchPatchMap([bundleId])).get(bundleId) ?? []);
|
|
90
|
+
},
|
|
91
|
+
async getBundles(options) {
|
|
92
|
+
const offset = options.offset ?? 0;
|
|
93
|
+
const orderBy = options.orderBy ?? {
|
|
94
|
+
field: "id",
|
|
95
|
+
direction: "desc"
|
|
96
|
+
};
|
|
97
|
+
const where = mongoWhere(options.where);
|
|
98
|
+
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()]);
|
|
99
|
+
const patchMap = await fetchPatchMap(rows.map((row) => row.id));
|
|
100
|
+
return {
|
|
101
|
+
data: rows.map((row) => rowToBundle(row, patchMap.get(row.id) ?? [])),
|
|
102
|
+
pagination: calculatePagination(total, {
|
|
103
|
+
limit: options.limit,
|
|
104
|
+
offset
|
|
105
|
+
})
|
|
106
|
+
};
|
|
107
|
+
},
|
|
108
|
+
async getUpdateInfo(args, context) {
|
|
109
|
+
if (args._updateStrategy === "appVersion") {
|
|
110
|
+
const channel = args.channel ?? "production";
|
|
111
|
+
const minBundleId = args.minBundleId ?? NIL_UUID;
|
|
112
|
+
const rows = await bundles.find({
|
|
113
|
+
enabled: true,
|
|
114
|
+
platform: args.platform,
|
|
115
|
+
channel,
|
|
116
|
+
id: { $gte: minBundleId },
|
|
117
|
+
target_app_version: {
|
|
118
|
+
$exists: true,
|
|
119
|
+
$nin: [null, ""]
|
|
120
|
+
}
|
|
121
|
+
}).project({ target_app_version: 1 }).toArray();
|
|
122
|
+
const compatibleAppVersions = filterCompatibleAppVersions(Array.from(new Set(rows.map((row) => row.target_app_version).filter((value) => typeof value === "string" && value.length > 0))), args.appVersion);
|
|
123
|
+
const updateRows = compatibleAppVersions.length > 0 ? await bundles.find({
|
|
124
|
+
enabled: true,
|
|
125
|
+
platform: args.platform,
|
|
126
|
+
channel,
|
|
127
|
+
id: { $gte: minBundleId },
|
|
128
|
+
target_app_version: { $in: compatibleAppVersions }
|
|
129
|
+
}).sort({ id: -1 }).toArray() : [];
|
|
130
|
+
return resolveUpdateInfoFromBundles({
|
|
131
|
+
args: {
|
|
132
|
+
...args,
|
|
133
|
+
channel,
|
|
134
|
+
minBundleId
|
|
135
|
+
},
|
|
136
|
+
bundles: await mapRowsToBundles(updateRows),
|
|
137
|
+
context
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
const channel = args.channel ?? "production";
|
|
141
|
+
const minBundleId = args.minBundleId ?? NIL_UUID;
|
|
142
|
+
const rows = await bundles.find({
|
|
143
|
+
enabled: true,
|
|
144
|
+
platform: args.platform,
|
|
145
|
+
channel,
|
|
146
|
+
id: { $gte: minBundleId },
|
|
147
|
+
fingerprint_hash: args.fingerprintHash
|
|
148
|
+
}).sort({ id: -1 }).toArray();
|
|
149
|
+
return resolveUpdateInfoFromBundles({
|
|
150
|
+
args: {
|
|
151
|
+
...args,
|
|
152
|
+
channel,
|
|
153
|
+
minBundleId
|
|
154
|
+
},
|
|
155
|
+
bundles: await mapRowsToBundles(rows),
|
|
156
|
+
context
|
|
157
|
+
});
|
|
158
|
+
},
|
|
159
|
+
async getChannels() {
|
|
160
|
+
return (await bundles.distinct("channel")).filter((channel) => typeof channel === "string").sort((left, right) => left.localeCompare(right));
|
|
161
|
+
},
|
|
162
|
+
async commitBundle({ changedSets }) {
|
|
163
|
+
await runInTransaction(async (session) => {
|
|
164
|
+
for (const change of changedSets) {
|
|
165
|
+
if (change.operation === "delete") {
|
|
166
|
+
await deleteByBundleId(patches, "bundle_id", change.data.id, session);
|
|
167
|
+
await deleteByBundleId(patches, "base_bundle_id", change.data.id, session);
|
|
168
|
+
await bundles.deleteMany({ id: change.data.id }, { session });
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
await replaceBundle(change.data, session);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
const mongoAdapter = (config) => {
|
|
179
|
+
return Object.assign(createMongoPlugin(config), {
|
|
180
|
+
adapterName: "mongodb",
|
|
181
|
+
provider: "mongodb",
|
|
182
|
+
createMigrator: () => createMongoMigrator(config.client)
|
|
183
|
+
});
|
|
184
|
+
};
|
|
4
185
|
//#endregion
|
|
5
186
|
export { mongoAdapter };
|
package/dist/adapters/prisma.cjs
CHANGED
|
@@ -1,6 +1,204 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
2
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_registry = require("../db/schema/registry.cjs");
|
|
4
|
+
const require_schemaGenerators = require("../db/schemaGenerators.cjs");
|
|
5
|
+
const require_bundleRows = require("../db/bundleRows.cjs");
|
|
6
|
+
let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
|
|
7
|
+
let _hot_updater_core = require("@hot-updater/core");
|
|
3
8
|
//#region src/adapters/prisma.ts
|
|
4
|
-
const
|
|
9
|
+
const assertSupportedRelationMode = (relationMode) => {
|
|
10
|
+
if (relationMode && relationMode !== "prisma" && relationMode !== "foreign-keys") throw new Error(`Unsupported Prisma relation mode: ${relationMode}`);
|
|
11
|
+
};
|
|
12
|
+
const getDelegate = (prisma, model) => {
|
|
13
|
+
const delegate = prisma[model];
|
|
14
|
+
if (!delegate || typeof delegate !== "object") throw new Error(`Prisma client is missing model delegate "${model}".`);
|
|
15
|
+
return delegate;
|
|
16
|
+
};
|
|
17
|
+
const prismaWhere = (where) => {
|
|
18
|
+
const targetAppVersionFilters = [];
|
|
19
|
+
if (where?.targetAppVersion !== void 0) targetAppVersionFilters.push({ target_app_version: where.targetAppVersion });
|
|
20
|
+
if (where?.targetAppVersionIn) targetAppVersionFilters.push({ target_app_version: { in: where.targetAppVersionIn } });
|
|
21
|
+
if (where?.targetAppVersionNotNull) targetAppVersionFilters.push({ target_app_version: { not: null } });
|
|
22
|
+
return {
|
|
23
|
+
...where?.channel !== void 0 ? { channel: where.channel } : {},
|
|
24
|
+
...where?.platform !== void 0 ? { platform: where.platform } : {},
|
|
25
|
+
...where?.enabled !== void 0 ? { enabled: where.enabled } : {},
|
|
26
|
+
...where?.fingerprintHash !== void 0 ? { fingerprint_hash: where.fingerprintHash } : {},
|
|
27
|
+
...where?.id ? { id: {
|
|
28
|
+
...where.id.eq !== void 0 ? { equals: where.id.eq } : {},
|
|
29
|
+
...where.id.gt !== void 0 ? { gt: where.id.gt } : {},
|
|
30
|
+
...where.id.gte !== void 0 ? { gte: where.id.gte } : {},
|
|
31
|
+
...where.id.lt !== void 0 ? { lt: where.id.lt } : {},
|
|
32
|
+
...where.id.lte !== void 0 ? { lte: where.id.lte } : {},
|
|
33
|
+
...where.id.in !== void 0 ? { in: where.id.in } : {}
|
|
34
|
+
} } : {},
|
|
35
|
+
...targetAppVersionFilters.length > 0 ? { AND: targetAppVersionFilters } : {}
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
const createPrismaPlugin = (0, _hot_updater_plugin_core.createDatabasePlugin)({
|
|
39
|
+
name: "prisma",
|
|
40
|
+
factory: (config) => {
|
|
41
|
+
const prisma = config.prisma;
|
|
42
|
+
const runInTransaction = async (operation) => {
|
|
43
|
+
if (typeof prisma.$transaction !== "function") return operation(prisma);
|
|
44
|
+
return prisma.$transaction(operation);
|
|
45
|
+
};
|
|
46
|
+
const fetchPatchMap = async (bundleIds) => {
|
|
47
|
+
const patches = getDelegate(prisma, "bundle_patches");
|
|
48
|
+
const patchMap = /* @__PURE__ */ new Map();
|
|
49
|
+
if (bundleIds.length === 0) return patchMap;
|
|
50
|
+
const rows = await patches.findMany({
|
|
51
|
+
where: { bundle_id: { in: [...bundleIds] } },
|
|
52
|
+
orderBy: { order_index: "asc" }
|
|
53
|
+
});
|
|
54
|
+
for (const row of rows) {
|
|
55
|
+
const patch = row;
|
|
56
|
+
const current = patchMap.get(patch.bundle_id) ?? [];
|
|
57
|
+
current.push(patch);
|
|
58
|
+
patchMap.set(patch.bundle_id, current);
|
|
59
|
+
}
|
|
60
|
+
return patchMap;
|
|
61
|
+
};
|
|
62
|
+
const mapRowsToBundles = async (rows) => {
|
|
63
|
+
const patchMap = await fetchPatchMap(rows.map((row) => String(row["id"])));
|
|
64
|
+
return rows.map((row) => require_bundleRows.rowToBundle(row, patchMap.get(String(row["id"])) ?? []));
|
|
65
|
+
};
|
|
66
|
+
const upsertBundle = async (client, bundle) => {
|
|
67
|
+
const bundles = getDelegate(client, "bundles");
|
|
68
|
+
const patches = getDelegate(client, "bundle_patches");
|
|
69
|
+
const row = require_bundleRows.bundleToRow(bundle);
|
|
70
|
+
const { id, ...update } = row;
|
|
71
|
+
await bundles.upsert({
|
|
72
|
+
where: { id },
|
|
73
|
+
create: row,
|
|
74
|
+
update
|
|
75
|
+
});
|
|
76
|
+
await patches.deleteMany({ where: { bundle_id: id } });
|
|
77
|
+
const patchRows = require_bundleRows.bundleToPatchRows(bundle);
|
|
78
|
+
if (patchRows.length > 0) await patches.createMany({ data: patchRows });
|
|
79
|
+
};
|
|
80
|
+
return {
|
|
81
|
+
async getBundleById(bundleId) {
|
|
82
|
+
const row = await getDelegate(prisma, "bundles").findFirst({ where: { id: bundleId } });
|
|
83
|
+
if (!row) return null;
|
|
84
|
+
return require_bundleRows.rowToBundle(row, (await fetchPatchMap([bundleId])).get(bundleId) ?? []);
|
|
85
|
+
},
|
|
86
|
+
async getBundles(options) {
|
|
87
|
+
const bundles = getDelegate(prisma, "bundles");
|
|
88
|
+
const offset = options.offset ?? 0;
|
|
89
|
+
const orderBy = options.orderBy ?? {
|
|
90
|
+
field: "id",
|
|
91
|
+
direction: "desc"
|
|
92
|
+
};
|
|
93
|
+
const where = prismaWhere(options.where);
|
|
94
|
+
const [total, rows] = await Promise.all([bundles.count({ where }), bundles.findMany({
|
|
95
|
+
where,
|
|
96
|
+
orderBy: { id: orderBy.direction },
|
|
97
|
+
skip: offset,
|
|
98
|
+
take: options.limit
|
|
99
|
+
})]);
|
|
100
|
+
const patchMap = await fetchPatchMap(rows.map((row) => String(row["id"])));
|
|
101
|
+
return {
|
|
102
|
+
data: rows.map((row) => require_bundleRows.rowToBundle(row, patchMap.get(String(row["id"])) ?? [])),
|
|
103
|
+
pagination: (0, _hot_updater_plugin_core.calculatePagination)(total, {
|
|
104
|
+
limit: options.limit,
|
|
105
|
+
offset
|
|
106
|
+
})
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
async getUpdateInfo(args, context) {
|
|
110
|
+
const bundles = getDelegate(prisma, "bundles");
|
|
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.findMany({
|
|
115
|
+
select: { target_app_version: true },
|
|
116
|
+
where: {
|
|
117
|
+
enabled: true,
|
|
118
|
+
platform: args.platform,
|
|
119
|
+
channel,
|
|
120
|
+
id: { gte: minBundleId },
|
|
121
|
+
target_app_version: { not: null }
|
|
122
|
+
}
|
|
123
|
+
});
|
|
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 updateBundles = compatibleAppVersions.length > 0 ? await bundles.findMany({
|
|
126
|
+
where: {
|
|
127
|
+
enabled: true,
|
|
128
|
+
platform: args.platform,
|
|
129
|
+
channel,
|
|
130
|
+
id: { gte: minBundleId },
|
|
131
|
+
target_app_version: { in: compatibleAppVersions }
|
|
132
|
+
},
|
|
133
|
+
orderBy: { id: "desc" }
|
|
134
|
+
}).then(mapRowsToBundles) : [];
|
|
135
|
+
return (0, _hot_updater_plugin_core.resolveUpdateInfoFromBundles)({
|
|
136
|
+
args: {
|
|
137
|
+
...args,
|
|
138
|
+
channel,
|
|
139
|
+
minBundleId
|
|
140
|
+
},
|
|
141
|
+
bundles: updateBundles,
|
|
142
|
+
context
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
const channel = args.channel ?? "production";
|
|
146
|
+
const minBundleId = args.minBundleId ?? _hot_updater_core.NIL_UUID;
|
|
147
|
+
const rows = await bundles.findMany({
|
|
148
|
+
where: {
|
|
149
|
+
enabled: true,
|
|
150
|
+
platform: args.platform,
|
|
151
|
+
channel,
|
|
152
|
+
id: { gte: minBundleId },
|
|
153
|
+
fingerprint_hash: args.fingerprintHash
|
|
154
|
+
},
|
|
155
|
+
orderBy: { id: "desc" }
|
|
156
|
+
});
|
|
157
|
+
return (0, _hot_updater_plugin_core.resolveUpdateInfoFromBundles)({
|
|
158
|
+
args: {
|
|
159
|
+
...args,
|
|
160
|
+
channel,
|
|
161
|
+
minBundleId
|
|
162
|
+
},
|
|
163
|
+
bundles: await mapRowsToBundles(rows),
|
|
164
|
+
context
|
|
165
|
+
});
|
|
166
|
+
},
|
|
167
|
+
async getChannels() {
|
|
168
|
+
const rows = await getDelegate(prisma, "bundles").findMany({
|
|
169
|
+
select: { channel: true },
|
|
170
|
+
orderBy: { channel: "asc" }
|
|
171
|
+
});
|
|
172
|
+
return Array.from(new Set(rows.map((row) => String(row["channel"]))));
|
|
173
|
+
},
|
|
174
|
+
async commitBundle({ changedSets }) {
|
|
175
|
+
await runInTransaction(async (client) => {
|
|
176
|
+
const bundles = getDelegate(client, "bundles");
|
|
177
|
+
const patches = getDelegate(client, "bundle_patches");
|
|
178
|
+
for (const change of changedSets) {
|
|
179
|
+
if (change.operation === "delete") {
|
|
180
|
+
await patches.deleteMany({ where: { bundle_id: change.data.id } });
|
|
181
|
+
await patches.deleteMany({ where: { base_bundle_id: change.data.id } });
|
|
182
|
+
await bundles.deleteMany({ where: { id: change.data.id } });
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
await upsertBundle(client, change.data);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
const prismaAdapter = (config) => {
|
|
193
|
+
assertSupportedRelationMode(config.relationMode);
|
|
194
|
+
return Object.assign(createPrismaPlugin(config), {
|
|
195
|
+
adapterName: "prisma",
|
|
196
|
+
provider: config.provider,
|
|
197
|
+
generateSchema: (version) => ({
|
|
198
|
+
code: require_schemaGenerators.generatePrismaSchema(config.provider, version === "latest" ? require_registry.hotUpdaterSchema : require_registry.getHotUpdaterSchemaVersion(version)),
|
|
199
|
+
path: "./prisma/schema/hot_updater.prisma"
|
|
200
|
+
})
|
|
201
|
+
});
|
|
202
|
+
};
|
|
5
203
|
//#endregion
|
|
6
204
|
exports.prismaAdapter = prismaAdapter;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { prismaAdapter as prismaAdapter$1 } from "../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";
|
|
1
|
+
import { DatabasePluginFactory, ORMProvider } from "../db/types.cjs";
|
|
3
2
|
|
|
4
3
|
//#region src/adapters/prisma.d.ts
|
|
5
|
-
type
|
|
6
|
-
|
|
4
|
+
type PrismaRelationMode = "prisma" | "foreign-keys";
|
|
5
|
+
interface PrismaConfig {
|
|
6
|
+
readonly prisma: object;
|
|
7
|
+
readonly provider: ORMProvider;
|
|
8
|
+
readonly relationMode?: PrismaRelationMode;
|
|
9
|
+
readonly db?: unknown;
|
|
10
|
+
}
|
|
11
|
+
declare const prismaAdapter: (config: PrismaConfig) => DatabasePluginFactory;
|
|
7
12
|
//#endregion
|
|
8
13
|
export { PrismaConfig, prismaAdapter };
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { prismaAdapter as prismaAdapter$1 } from "../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";
|
|
1
|
+
import { DatabasePluginFactory, ORMProvider } from "../db/types.mjs";
|
|
3
2
|
|
|
4
3
|
//#region src/adapters/prisma.d.ts
|
|
5
|
-
type
|
|
6
|
-
|
|
4
|
+
type PrismaRelationMode = "prisma" | "foreign-keys";
|
|
5
|
+
interface PrismaConfig {
|
|
6
|
+
readonly prisma: object;
|
|
7
|
+
readonly provider: ORMProvider;
|
|
8
|
+
readonly relationMode?: PrismaRelationMode;
|
|
9
|
+
readonly db?: unknown;
|
|
10
|
+
}
|
|
11
|
+
declare const prismaAdapter: (config: PrismaConfig) => DatabasePluginFactory;
|
|
7
12
|
//#endregion
|
|
8
13
|
export { PrismaConfig, prismaAdapter };
|
package/dist/adapters/prisma.mjs
CHANGED
|
@@ -1,5 +1,202 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getHotUpdaterSchemaVersion, hotUpdaterSchema } from "../db/schema/registry.mjs";
|
|
2
|
+
import { generatePrismaSchema } from "../db/schemaGenerators.mjs";
|
|
3
|
+
import { bundleToPatchRows, bundleToRow, rowToBundle } from "../db/bundleRows.mjs";
|
|
4
|
+
import { calculatePagination, createDatabasePlugin, filterCompatibleAppVersions, resolveUpdateInfoFromBundles } from "@hot-updater/plugin-core";
|
|
5
|
+
import { NIL_UUID } from "@hot-updater/core";
|
|
2
6
|
//#region src/adapters/prisma.ts
|
|
3
|
-
const
|
|
7
|
+
const assertSupportedRelationMode = (relationMode) => {
|
|
8
|
+
if (relationMode && relationMode !== "prisma" && relationMode !== "foreign-keys") throw new Error(`Unsupported Prisma relation mode: ${relationMode}`);
|
|
9
|
+
};
|
|
10
|
+
const getDelegate = (prisma, model) => {
|
|
11
|
+
const delegate = prisma[model];
|
|
12
|
+
if (!delegate || typeof delegate !== "object") throw new Error(`Prisma client is missing model delegate "${model}".`);
|
|
13
|
+
return delegate;
|
|
14
|
+
};
|
|
15
|
+
const prismaWhere = (where) => {
|
|
16
|
+
const targetAppVersionFilters = [];
|
|
17
|
+
if (where?.targetAppVersion !== void 0) targetAppVersionFilters.push({ target_app_version: where.targetAppVersion });
|
|
18
|
+
if (where?.targetAppVersionIn) targetAppVersionFilters.push({ target_app_version: { in: where.targetAppVersionIn } });
|
|
19
|
+
if (where?.targetAppVersionNotNull) targetAppVersionFilters.push({ target_app_version: { not: null } });
|
|
20
|
+
return {
|
|
21
|
+
...where?.channel !== void 0 ? { channel: where.channel } : {},
|
|
22
|
+
...where?.platform !== void 0 ? { platform: where.platform } : {},
|
|
23
|
+
...where?.enabled !== void 0 ? { enabled: where.enabled } : {},
|
|
24
|
+
...where?.fingerprintHash !== void 0 ? { fingerprint_hash: where.fingerprintHash } : {},
|
|
25
|
+
...where?.id ? { id: {
|
|
26
|
+
...where.id.eq !== void 0 ? { equals: where.id.eq } : {},
|
|
27
|
+
...where.id.gt !== void 0 ? { gt: where.id.gt } : {},
|
|
28
|
+
...where.id.gte !== void 0 ? { gte: where.id.gte } : {},
|
|
29
|
+
...where.id.lt !== void 0 ? { lt: where.id.lt } : {},
|
|
30
|
+
...where.id.lte !== void 0 ? { lte: where.id.lte } : {},
|
|
31
|
+
...where.id.in !== void 0 ? { in: where.id.in } : {}
|
|
32
|
+
} } : {},
|
|
33
|
+
...targetAppVersionFilters.length > 0 ? { AND: targetAppVersionFilters } : {}
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
const createPrismaPlugin = createDatabasePlugin({
|
|
37
|
+
name: "prisma",
|
|
38
|
+
factory: (config) => {
|
|
39
|
+
const prisma = config.prisma;
|
|
40
|
+
const runInTransaction = async (operation) => {
|
|
41
|
+
if (typeof prisma.$transaction !== "function") return operation(prisma);
|
|
42
|
+
return prisma.$transaction(operation);
|
|
43
|
+
};
|
|
44
|
+
const fetchPatchMap = async (bundleIds) => {
|
|
45
|
+
const patches = getDelegate(prisma, "bundle_patches");
|
|
46
|
+
const patchMap = /* @__PURE__ */ new Map();
|
|
47
|
+
if (bundleIds.length === 0) return patchMap;
|
|
48
|
+
const rows = await patches.findMany({
|
|
49
|
+
where: { bundle_id: { in: [...bundleIds] } },
|
|
50
|
+
orderBy: { order_index: "asc" }
|
|
51
|
+
});
|
|
52
|
+
for (const row of rows) {
|
|
53
|
+
const patch = row;
|
|
54
|
+
const current = patchMap.get(patch.bundle_id) ?? [];
|
|
55
|
+
current.push(patch);
|
|
56
|
+
patchMap.set(patch.bundle_id, current);
|
|
57
|
+
}
|
|
58
|
+
return patchMap;
|
|
59
|
+
};
|
|
60
|
+
const mapRowsToBundles = async (rows) => {
|
|
61
|
+
const patchMap = await fetchPatchMap(rows.map((row) => String(row["id"])));
|
|
62
|
+
return rows.map((row) => rowToBundle(row, patchMap.get(String(row["id"])) ?? []));
|
|
63
|
+
};
|
|
64
|
+
const upsertBundle = async (client, bundle) => {
|
|
65
|
+
const bundles = getDelegate(client, "bundles");
|
|
66
|
+
const patches = getDelegate(client, "bundle_patches");
|
|
67
|
+
const row = bundleToRow(bundle);
|
|
68
|
+
const { id, ...update } = row;
|
|
69
|
+
await bundles.upsert({
|
|
70
|
+
where: { id },
|
|
71
|
+
create: row,
|
|
72
|
+
update
|
|
73
|
+
});
|
|
74
|
+
await patches.deleteMany({ where: { bundle_id: id } });
|
|
75
|
+
const patchRows = bundleToPatchRows(bundle);
|
|
76
|
+
if (patchRows.length > 0) await patches.createMany({ data: patchRows });
|
|
77
|
+
};
|
|
78
|
+
return {
|
|
79
|
+
async getBundleById(bundleId) {
|
|
80
|
+
const row = await getDelegate(prisma, "bundles").findFirst({ where: { id: bundleId } });
|
|
81
|
+
if (!row) return null;
|
|
82
|
+
return rowToBundle(row, (await fetchPatchMap([bundleId])).get(bundleId) ?? []);
|
|
83
|
+
},
|
|
84
|
+
async getBundles(options) {
|
|
85
|
+
const bundles = getDelegate(prisma, "bundles");
|
|
86
|
+
const offset = options.offset ?? 0;
|
|
87
|
+
const orderBy = options.orderBy ?? {
|
|
88
|
+
field: "id",
|
|
89
|
+
direction: "desc"
|
|
90
|
+
};
|
|
91
|
+
const where = prismaWhere(options.where);
|
|
92
|
+
const [total, rows] = await Promise.all([bundles.count({ where }), bundles.findMany({
|
|
93
|
+
where,
|
|
94
|
+
orderBy: { id: orderBy.direction },
|
|
95
|
+
skip: offset,
|
|
96
|
+
take: options.limit
|
|
97
|
+
})]);
|
|
98
|
+
const patchMap = await fetchPatchMap(rows.map((row) => String(row["id"])));
|
|
99
|
+
return {
|
|
100
|
+
data: rows.map((row) => rowToBundle(row, patchMap.get(String(row["id"])) ?? [])),
|
|
101
|
+
pagination: calculatePagination(total, {
|
|
102
|
+
limit: options.limit,
|
|
103
|
+
offset
|
|
104
|
+
})
|
|
105
|
+
};
|
|
106
|
+
},
|
|
107
|
+
async getUpdateInfo(args, context) {
|
|
108
|
+
const bundles = getDelegate(prisma, "bundles");
|
|
109
|
+
if (args._updateStrategy === "appVersion") {
|
|
110
|
+
const channel = args.channel ?? "production";
|
|
111
|
+
const minBundleId = args.minBundleId ?? NIL_UUID;
|
|
112
|
+
const rows = await bundles.findMany({
|
|
113
|
+
select: { target_app_version: true },
|
|
114
|
+
where: {
|
|
115
|
+
enabled: true,
|
|
116
|
+
platform: args.platform,
|
|
117
|
+
channel,
|
|
118
|
+
id: { gte: minBundleId },
|
|
119
|
+
target_app_version: { not: null }
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
const compatibleAppVersions = filterCompatibleAppVersions(Array.from(new Set(rows.map((row) => row["target_app_version"]).filter((value) => typeof value === "string" && value.length > 0))), args.appVersion);
|
|
123
|
+
const updateBundles = compatibleAppVersions.length > 0 ? await bundles.findMany({
|
|
124
|
+
where: {
|
|
125
|
+
enabled: true,
|
|
126
|
+
platform: args.platform,
|
|
127
|
+
channel,
|
|
128
|
+
id: { gte: minBundleId },
|
|
129
|
+
target_app_version: { in: compatibleAppVersions }
|
|
130
|
+
},
|
|
131
|
+
orderBy: { id: "desc" }
|
|
132
|
+
}).then(mapRowsToBundles) : [];
|
|
133
|
+
return resolveUpdateInfoFromBundles({
|
|
134
|
+
args: {
|
|
135
|
+
...args,
|
|
136
|
+
channel,
|
|
137
|
+
minBundleId
|
|
138
|
+
},
|
|
139
|
+
bundles: updateBundles,
|
|
140
|
+
context
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
const channel = args.channel ?? "production";
|
|
144
|
+
const minBundleId = args.minBundleId ?? NIL_UUID;
|
|
145
|
+
const rows = await bundles.findMany({
|
|
146
|
+
where: {
|
|
147
|
+
enabled: true,
|
|
148
|
+
platform: args.platform,
|
|
149
|
+
channel,
|
|
150
|
+
id: { gte: minBundleId },
|
|
151
|
+
fingerprint_hash: args.fingerprintHash
|
|
152
|
+
},
|
|
153
|
+
orderBy: { id: "desc" }
|
|
154
|
+
});
|
|
155
|
+
return resolveUpdateInfoFromBundles({
|
|
156
|
+
args: {
|
|
157
|
+
...args,
|
|
158
|
+
channel,
|
|
159
|
+
minBundleId
|
|
160
|
+
},
|
|
161
|
+
bundles: await mapRowsToBundles(rows),
|
|
162
|
+
context
|
|
163
|
+
});
|
|
164
|
+
},
|
|
165
|
+
async getChannels() {
|
|
166
|
+
const rows = await getDelegate(prisma, "bundles").findMany({
|
|
167
|
+
select: { channel: true },
|
|
168
|
+
orderBy: { channel: "asc" }
|
|
169
|
+
});
|
|
170
|
+
return Array.from(new Set(rows.map((row) => String(row["channel"]))));
|
|
171
|
+
},
|
|
172
|
+
async commitBundle({ changedSets }) {
|
|
173
|
+
await runInTransaction(async (client) => {
|
|
174
|
+
const bundles = getDelegate(client, "bundles");
|
|
175
|
+
const patches = getDelegate(client, "bundle_patches");
|
|
176
|
+
for (const change of changedSets) {
|
|
177
|
+
if (change.operation === "delete") {
|
|
178
|
+
await patches.deleteMany({ where: { bundle_id: change.data.id } });
|
|
179
|
+
await patches.deleteMany({ where: { base_bundle_id: change.data.id } });
|
|
180
|
+
await bundles.deleteMany({ where: { id: change.data.id } });
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
await upsertBundle(client, change.data);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
const prismaAdapter = (config) => {
|
|
191
|
+
assertSupportedRelationMode(config.relationMode);
|
|
192
|
+
return Object.assign(createPrismaPlugin(config), {
|
|
193
|
+
adapterName: "prisma",
|
|
194
|
+
provider: config.provider,
|
|
195
|
+
generateSchema: (version) => ({
|
|
196
|
+
code: generatePrismaSchema(config.provider, version === "latest" ? hotUpdaterSchema : getHotUpdaterSchemaVersion(version)),
|
|
197
|
+
path: "./prisma/schema/hot_updater.prisma"
|
|
198
|
+
})
|
|
199
|
+
});
|
|
200
|
+
};
|
|
4
201
|
//#endregion
|
|
5
202
|
export { prismaAdapter };
|