@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
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_updateArtifacts = require("./updateArtifacts.cjs");
|
|
3
|
+
let _hot_updater_core = require("@hot-updater/core");
|
|
4
|
+
//#region src/db/bundleRows.ts
|
|
5
|
+
const parseTargetCohorts = (value) => {
|
|
6
|
+
if (!value) return null;
|
|
7
|
+
if (Array.isArray(value)) return value.filter((item) => typeof item === "string");
|
|
8
|
+
if (typeof value !== "string") return null;
|
|
9
|
+
try {
|
|
10
|
+
const parsed = JSON.parse(value);
|
|
11
|
+
return Array.isArray(parsed) ? parsed.filter((item) => typeof item === "string") : null;
|
|
12
|
+
} catch {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const buildBundlePatchId = (bundleId, baseBundleId) => `${bundleId}:${baseBundleId}`;
|
|
17
|
+
const bundleToRow = (bundle) => ({
|
|
18
|
+
id: bundle.id,
|
|
19
|
+
platform: bundle.platform,
|
|
20
|
+
should_force_update: bundle.shouldForceUpdate,
|
|
21
|
+
enabled: bundle.enabled,
|
|
22
|
+
file_hash: bundle.fileHash,
|
|
23
|
+
git_commit_hash: bundle.gitCommitHash,
|
|
24
|
+
message: bundle.message,
|
|
25
|
+
channel: bundle.channel,
|
|
26
|
+
storage_uri: bundle.storageUri,
|
|
27
|
+
target_app_version: bundle.targetAppVersion,
|
|
28
|
+
fingerprint_hash: bundle.fingerprintHash,
|
|
29
|
+
metadata: (0, _hot_updater_core.stripBundleArtifactMetadata)(bundle.metadata) ?? {},
|
|
30
|
+
manifest_storage_uri: (0, _hot_updater_core.getManifestStorageUri)(bundle),
|
|
31
|
+
manifest_file_hash: (0, _hot_updater_core.getManifestFileHash)(bundle),
|
|
32
|
+
asset_base_storage_uri: (0, _hot_updater_core.getAssetBaseStorageUri)(bundle),
|
|
33
|
+
rollout_cohort_count: bundle.rolloutCohortCount ?? _hot_updater_core.DEFAULT_ROLLOUT_COHORT_COUNT,
|
|
34
|
+
target_cohorts: bundle.targetCohorts ?? null
|
|
35
|
+
});
|
|
36
|
+
const bundleToPatchRows = (bundle) => (0, _hot_updater_core.getBundlePatches)(bundle).map((patch, index) => ({
|
|
37
|
+
id: buildBundlePatchId(bundle.id, patch.baseBundleId),
|
|
38
|
+
bundle_id: bundle.id,
|
|
39
|
+
base_bundle_id: patch.baseBundleId,
|
|
40
|
+
base_file_hash: patch.baseFileHash,
|
|
41
|
+
patch_file_hash: patch.patchFileHash,
|
|
42
|
+
patch_storage_uri: patch.patchStorageUri,
|
|
43
|
+
order_index: index
|
|
44
|
+
}));
|
|
45
|
+
const mapPatchRowToPatch = (record) => ({
|
|
46
|
+
baseBundleId: record.base_bundle_id,
|
|
47
|
+
baseFileHash: record.base_file_hash,
|
|
48
|
+
patchFileHash: record.patch_file_hash,
|
|
49
|
+
patchStorageUri: record.patch_storage_uri
|
|
50
|
+
});
|
|
51
|
+
const rowToBundle = (record, patchRecords = []) => {
|
|
52
|
+
const patches = patchRecords.slice().sort((left, right) => (left.order_index ?? 0) - (right.order_index ?? 0) || left.base_bundle_id.localeCompare(right.base_bundle_id)).map(mapPatchRowToPatch);
|
|
53
|
+
const primaryPatch = patches[0] ?? null;
|
|
54
|
+
return {
|
|
55
|
+
id: record.id,
|
|
56
|
+
platform: record.platform,
|
|
57
|
+
shouldForceUpdate: Boolean(record.should_force_update),
|
|
58
|
+
enabled: Boolean(record.enabled),
|
|
59
|
+
fileHash: record.file_hash,
|
|
60
|
+
gitCommitHash: record.git_commit_hash ?? null,
|
|
61
|
+
message: record.message ?? null,
|
|
62
|
+
channel: record.channel,
|
|
63
|
+
storageUri: record.storage_uri,
|
|
64
|
+
targetAppVersion: record.target_app_version ?? null,
|
|
65
|
+
fingerprintHash: record.fingerprint_hash ?? null,
|
|
66
|
+
metadata: require_updateArtifacts.parseBundleMetadata(record.metadata),
|
|
67
|
+
manifestStorageUri: record.manifest_storage_uri ?? null,
|
|
68
|
+
manifestFileHash: record.manifest_file_hash ?? null,
|
|
69
|
+
assetBaseStorageUri: record.asset_base_storage_uri ?? null,
|
|
70
|
+
patches,
|
|
71
|
+
patchBaseBundleId: primaryPatch?.baseBundleId ?? null,
|
|
72
|
+
patchBaseFileHash: primaryPatch?.baseFileHash ?? null,
|
|
73
|
+
patchFileHash: primaryPatch?.patchFileHash ?? null,
|
|
74
|
+
patchStorageUri: primaryPatch?.patchStorageUri ?? null,
|
|
75
|
+
rolloutCohortCount: record.rollout_cohort_count ?? _hot_updater_core.DEFAULT_ROLLOUT_COHORT_COUNT,
|
|
76
|
+
targetCohorts: parseTargetCohorts(record.target_cohorts)
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
//#endregion
|
|
80
|
+
exports.bundleToPatchRows = bundleToPatchRows;
|
|
81
|
+
exports.bundleToRow = bundleToRow;
|
|
82
|
+
exports.rowToBundle = rowToBundle;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Bundle } from "@hot-updater/core";
|
|
2
|
+
|
|
3
|
+
//#region src/db/bundleRows.d.ts
|
|
4
|
+
type BundleRow = {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly platform: string;
|
|
7
|
+
readonly should_force_update: unknown;
|
|
8
|
+
readonly enabled: unknown;
|
|
9
|
+
readonly file_hash: string;
|
|
10
|
+
readonly git_commit_hash: string | null;
|
|
11
|
+
readonly message: string | null;
|
|
12
|
+
readonly channel: string;
|
|
13
|
+
readonly storage_uri: string;
|
|
14
|
+
readonly target_app_version: string | null;
|
|
15
|
+
readonly fingerprint_hash: string | null;
|
|
16
|
+
readonly metadata?: unknown;
|
|
17
|
+
readonly manifest_storage_uri?: string | null;
|
|
18
|
+
readonly manifest_file_hash?: string | null;
|
|
19
|
+
readonly asset_base_storage_uri?: string | null;
|
|
20
|
+
readonly rollout_cohort_count?: number | null;
|
|
21
|
+
readonly target_cohorts?: unknown;
|
|
22
|
+
};
|
|
23
|
+
type BundlePatchRow = {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly bundle_id: string;
|
|
26
|
+
readonly base_bundle_id: string;
|
|
27
|
+
readonly base_file_hash: string;
|
|
28
|
+
readonly patch_file_hash: string;
|
|
29
|
+
readonly patch_storage_uri: string;
|
|
30
|
+
readonly order_index?: number | null;
|
|
31
|
+
};
|
|
32
|
+
//#endregion
|
|
33
|
+
export { BundlePatchRow, BundleRow };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Bundle } from "@hot-updater/core";
|
|
2
|
+
|
|
3
|
+
//#region src/db/bundleRows.d.ts
|
|
4
|
+
type BundleRow = {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly platform: string;
|
|
7
|
+
readonly should_force_update: unknown;
|
|
8
|
+
readonly enabled: unknown;
|
|
9
|
+
readonly file_hash: string;
|
|
10
|
+
readonly git_commit_hash: string | null;
|
|
11
|
+
readonly message: string | null;
|
|
12
|
+
readonly channel: string;
|
|
13
|
+
readonly storage_uri: string;
|
|
14
|
+
readonly target_app_version: string | null;
|
|
15
|
+
readonly fingerprint_hash: string | null;
|
|
16
|
+
readonly metadata?: unknown;
|
|
17
|
+
readonly manifest_storage_uri?: string | null;
|
|
18
|
+
readonly manifest_file_hash?: string | null;
|
|
19
|
+
readonly asset_base_storage_uri?: string | null;
|
|
20
|
+
readonly rollout_cohort_count?: number | null;
|
|
21
|
+
readonly target_cohorts?: unknown;
|
|
22
|
+
};
|
|
23
|
+
type BundlePatchRow = {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly bundle_id: string;
|
|
26
|
+
readonly base_bundle_id: string;
|
|
27
|
+
readonly base_file_hash: string;
|
|
28
|
+
readonly patch_file_hash: string;
|
|
29
|
+
readonly patch_storage_uri: string;
|
|
30
|
+
readonly order_index?: number | null;
|
|
31
|
+
};
|
|
32
|
+
//#endregion
|
|
33
|
+
export { BundlePatchRow, BundleRow };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { parseBundleMetadata } from "./updateArtifacts.mjs";
|
|
2
|
+
import { DEFAULT_ROLLOUT_COHORT_COUNT, getAssetBaseStorageUri, getBundlePatches, getManifestFileHash, getManifestStorageUri, stripBundleArtifactMetadata } from "@hot-updater/core";
|
|
3
|
+
//#region src/db/bundleRows.ts
|
|
4
|
+
const parseTargetCohorts = (value) => {
|
|
5
|
+
if (!value) return null;
|
|
6
|
+
if (Array.isArray(value)) return value.filter((item) => typeof item === "string");
|
|
7
|
+
if (typeof value !== "string") return null;
|
|
8
|
+
try {
|
|
9
|
+
const parsed = JSON.parse(value);
|
|
10
|
+
return Array.isArray(parsed) ? parsed.filter((item) => typeof item === "string") : null;
|
|
11
|
+
} catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const buildBundlePatchId = (bundleId, baseBundleId) => `${bundleId}:${baseBundleId}`;
|
|
16
|
+
const bundleToRow = (bundle) => ({
|
|
17
|
+
id: bundle.id,
|
|
18
|
+
platform: bundle.platform,
|
|
19
|
+
should_force_update: bundle.shouldForceUpdate,
|
|
20
|
+
enabled: bundle.enabled,
|
|
21
|
+
file_hash: bundle.fileHash,
|
|
22
|
+
git_commit_hash: bundle.gitCommitHash,
|
|
23
|
+
message: bundle.message,
|
|
24
|
+
channel: bundle.channel,
|
|
25
|
+
storage_uri: bundle.storageUri,
|
|
26
|
+
target_app_version: bundle.targetAppVersion,
|
|
27
|
+
fingerprint_hash: bundle.fingerprintHash,
|
|
28
|
+
metadata: stripBundleArtifactMetadata(bundle.metadata) ?? {},
|
|
29
|
+
manifest_storage_uri: getManifestStorageUri(bundle),
|
|
30
|
+
manifest_file_hash: getManifestFileHash(bundle),
|
|
31
|
+
asset_base_storage_uri: getAssetBaseStorageUri(bundle),
|
|
32
|
+
rollout_cohort_count: bundle.rolloutCohortCount ?? DEFAULT_ROLLOUT_COHORT_COUNT,
|
|
33
|
+
target_cohorts: bundle.targetCohorts ?? null
|
|
34
|
+
});
|
|
35
|
+
const bundleToPatchRows = (bundle) => getBundlePatches(bundle).map((patch, index) => ({
|
|
36
|
+
id: buildBundlePatchId(bundle.id, patch.baseBundleId),
|
|
37
|
+
bundle_id: bundle.id,
|
|
38
|
+
base_bundle_id: patch.baseBundleId,
|
|
39
|
+
base_file_hash: patch.baseFileHash,
|
|
40
|
+
patch_file_hash: patch.patchFileHash,
|
|
41
|
+
patch_storage_uri: patch.patchStorageUri,
|
|
42
|
+
order_index: index
|
|
43
|
+
}));
|
|
44
|
+
const mapPatchRowToPatch = (record) => ({
|
|
45
|
+
baseBundleId: record.base_bundle_id,
|
|
46
|
+
baseFileHash: record.base_file_hash,
|
|
47
|
+
patchFileHash: record.patch_file_hash,
|
|
48
|
+
patchStorageUri: record.patch_storage_uri
|
|
49
|
+
});
|
|
50
|
+
const rowToBundle = (record, patchRecords = []) => {
|
|
51
|
+
const patches = patchRecords.slice().sort((left, right) => (left.order_index ?? 0) - (right.order_index ?? 0) || left.base_bundle_id.localeCompare(right.base_bundle_id)).map(mapPatchRowToPatch);
|
|
52
|
+
const primaryPatch = patches[0] ?? null;
|
|
53
|
+
return {
|
|
54
|
+
id: record.id,
|
|
55
|
+
platform: record.platform,
|
|
56
|
+
shouldForceUpdate: Boolean(record.should_force_update),
|
|
57
|
+
enabled: Boolean(record.enabled),
|
|
58
|
+
fileHash: record.file_hash,
|
|
59
|
+
gitCommitHash: record.git_commit_hash ?? null,
|
|
60
|
+
message: record.message ?? null,
|
|
61
|
+
channel: record.channel,
|
|
62
|
+
storageUri: record.storage_uri,
|
|
63
|
+
targetAppVersion: record.target_app_version ?? null,
|
|
64
|
+
fingerprintHash: record.fingerprint_hash ?? null,
|
|
65
|
+
metadata: parseBundleMetadata(record.metadata),
|
|
66
|
+
manifestStorageUri: record.manifest_storage_uri ?? null,
|
|
67
|
+
manifestFileHash: record.manifest_file_hash ?? null,
|
|
68
|
+
assetBaseStorageUri: record.asset_base_storage_uri ?? null,
|
|
69
|
+
patches,
|
|
70
|
+
patchBaseBundleId: primaryPatch?.baseBundleId ?? null,
|
|
71
|
+
patchBaseFileHash: primaryPatch?.baseFileHash ?? null,
|
|
72
|
+
patchFileHash: primaryPatch?.patchFileHash ?? null,
|
|
73
|
+
patchStorageUri: primaryPatch?.patchStorageUri ?? null,
|
|
74
|
+
rolloutCohortCount: record.rollout_cohort_count ?? DEFAULT_ROLLOUT_COHORT_COUNT,
|
|
75
|
+
targetCohorts: parseTargetCohorts(record.target_cohorts)
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
//#endregion
|
|
79
|
+
export { bundleToPatchRows, bundleToRow, rowToBundle };
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
const require_types = require("../schema/types.cjs");
|
|
2
|
+
const require_registry = require("./schema/registry.cjs");
|
|
3
|
+
const require_sql = require("./schema/sql.cjs");
|
|
4
|
+
const require_mongodb = require("./schema/mongodb.cjs");
|
|
5
|
+
const require_sqlMigrations = require("./schema/sqlMigrations.cjs");
|
|
6
|
+
const require_sqlOperations = require("./schema/sqlOperations.cjs");
|
|
7
|
+
//#region src/db/fixedMigrator.ts
|
|
8
|
+
const getEmptyResult = () => ({
|
|
9
|
+
operations: [],
|
|
10
|
+
execute: async () => {},
|
|
11
|
+
getSQL: () => ""
|
|
12
|
+
});
|
|
13
|
+
const assertSupportedMigrationMode = (options) => {
|
|
14
|
+
if (options.mode === "from-database") throw new Error("Hot Updater migrations support only mode: 'from-schema'.");
|
|
15
|
+
};
|
|
16
|
+
const isMissingSettingsTableError = (error) => {
|
|
17
|
+
if (!(error instanceof Error)) return false;
|
|
18
|
+
const message = error.message.toLowerCase();
|
|
19
|
+
return message.includes("private_hot_updater_settings") && (message.includes("does not exist") || message.includes("no such table") || message.includes("doesn't exist") || message.includes("not found"));
|
|
20
|
+
};
|
|
21
|
+
const isMongoNamespaceExistsError = (error) => {
|
|
22
|
+
if (!(error instanceof Error)) return false;
|
|
23
|
+
const mongoError = error;
|
|
24
|
+
return mongoError.code === 48 || mongoError.codeName === "NamespaceExists";
|
|
25
|
+
};
|
|
26
|
+
const ignoreExistingCollection = (error) => {
|
|
27
|
+
if (isMongoNamespaceExistsError(error)) return;
|
|
28
|
+
throw error;
|
|
29
|
+
};
|
|
30
|
+
const toCustomOperations = (statements, settingsOperation) => [...statements.map((statement) => ({
|
|
31
|
+
type: "custom",
|
|
32
|
+
sql: statement
|
|
33
|
+
})), ...settingsOperation ? [settingsOperation] : []];
|
|
34
|
+
const assertSupportedSchemaVersion = (currentVersion) => {
|
|
35
|
+
if (currentVersion !== void 0 && currentVersion !== "0.21.0" && currentVersion !== "0.29.0") throw new Error(`Unsupported Hot Updater schema version: ${currentVersion}`);
|
|
36
|
+
};
|
|
37
|
+
const createKyselyMigrator = ({ db, provider, relationMode = "foreign-keys" }) => {
|
|
38
|
+
const getVersion = async () => {
|
|
39
|
+
try {
|
|
40
|
+
const row = await db.selectFrom(require_types.HOT_UPDATER_SETTINGS_TABLE).select("value").where("key", "=", "version").executeTakeFirst();
|
|
41
|
+
return typeof row?.value === "string" ? row.value : void 0;
|
|
42
|
+
} catch (error) {
|
|
43
|
+
if (!isMissingSettingsTableError(error)) throw error;
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const makeResult = async (options = {}) => {
|
|
48
|
+
assertSupportedMigrationMode(options);
|
|
49
|
+
const currentVersion = await getVersion();
|
|
50
|
+
if (currentVersion === "0.31.0") return getEmptyResult();
|
|
51
|
+
assertSupportedSchemaVersion(currentVersion);
|
|
52
|
+
const settingsStatement = require_sqlOperations.getSettingsInsertSql(provider);
|
|
53
|
+
const settingsOperation = options.updateSettings === false ? void 0 : {
|
|
54
|
+
type: "custom",
|
|
55
|
+
sql: settingsStatement
|
|
56
|
+
};
|
|
57
|
+
const executableSettingsStatements = options.updateSettings === false ? [] : [settingsStatement];
|
|
58
|
+
const statements = currentVersion === void 0 ? [...require_sql.createTableSql(provider, relationMode), settingsStatement] : [
|
|
59
|
+
...currentVersion === "0.21.0" ? require_sqlMigrations.createV029AlterSql(provider) : [],
|
|
60
|
+
...currentVersion === "0.21.0" || currentVersion === "0.29.0" ? require_sqlMigrations.createV031AlterSql(provider, relationMode) : [],
|
|
61
|
+
...executableSettingsStatements
|
|
62
|
+
];
|
|
63
|
+
return {
|
|
64
|
+
operations: currentVersion === void 0 ? require_sqlOperations.createSqlCreateOperations(provider, relationMode, settingsOperation) : toCustomOperations([...currentVersion === "0.21.0" ? require_sqlMigrations.createV029AlterSql(provider) : [], ...currentVersion === "0.21.0" || currentVersion === "0.29.0" ? require_sqlMigrations.createV031AlterSql(provider, relationMode) : []], settingsOperation),
|
|
65
|
+
getSQL: () => statements.map((statement) => `${statement};`).join("\n\n"),
|
|
66
|
+
execute: async () => {
|
|
67
|
+
const { sql } = await import("kysely");
|
|
68
|
+
for (const statement of statements) await sql.raw(statement).execute(db);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
return {
|
|
73
|
+
getVersion,
|
|
74
|
+
getNameVariants: async () => void 0,
|
|
75
|
+
next: async () => await getVersion() === "0.31.0" ? void 0 : { version: require_types.HOT_UPDATER_SCHEMA_VERSION },
|
|
76
|
+
previous: async () => void 0,
|
|
77
|
+
up: makeResult,
|
|
78
|
+
down: async () => {
|
|
79
|
+
throw new Error("No previous schema to migrate to.");
|
|
80
|
+
},
|
|
81
|
+
migrateTo: async (version, options) => {
|
|
82
|
+
if (version !== "0.31.0") throw new Error(`Invalid version ${version}`);
|
|
83
|
+
return makeResult(options);
|
|
84
|
+
},
|
|
85
|
+
migrateToLatest: makeResult
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
const createMongoMigrator = (client) => {
|
|
89
|
+
const settings = client.db().collection(require_types.HOT_UPDATER_SETTINGS_TABLE);
|
|
90
|
+
const getVersion = async () => {
|
|
91
|
+
const row = await settings.findOne({ key: "version" });
|
|
92
|
+
return typeof row?.value === "string" ? row.value : void 0;
|
|
93
|
+
};
|
|
94
|
+
const makeResult = async (options = {}) => {
|
|
95
|
+
assertSupportedMigrationMode(options);
|
|
96
|
+
if (await getVersion() === "0.31.0") return getEmptyResult();
|
|
97
|
+
return {
|
|
98
|
+
operations: require_mongodb.createMongoMigrationOperations(options.updateSettings === false ? void 0 : {
|
|
99
|
+
type: "custom",
|
|
100
|
+
key: "version",
|
|
101
|
+
value: require_types.HOT_UPDATER_SCHEMA_VERSION
|
|
102
|
+
}),
|
|
103
|
+
execute: async () => {
|
|
104
|
+
const db = client.db();
|
|
105
|
+
for (const table of require_registry.hotUpdaterSchema.tables) {
|
|
106
|
+
if (table.internal) continue;
|
|
107
|
+
await db.createCollection(table.ormName).catch(ignoreExistingCollection);
|
|
108
|
+
}
|
|
109
|
+
await db.collection("bundles").createIndex({ id: 1 }, { name: "bundles_id_idx" });
|
|
110
|
+
for (const table of require_registry.hotUpdaterSchema.tables) {
|
|
111
|
+
if (table.internal) continue;
|
|
112
|
+
for (const index of (table.indexes ?? []).filter((item) => require_registry.schemaIndexAppliesToProvider(item, "mongodb"))) await db.collection(table.ormName).createIndex(Object.fromEntries(index.columns.map((column) => [column, 1])), { name: index.name });
|
|
113
|
+
}
|
|
114
|
+
if (options.updateSettings !== false) await settings.updateOne({ key: "version" }, { $set: { value: require_types.HOT_UPDATER_SCHEMA_VERSION } }, { upsert: true });
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
return {
|
|
119
|
+
getVersion,
|
|
120
|
+
getNameVariants: async () => void 0,
|
|
121
|
+
next: async () => await getVersion() === "0.31.0" ? void 0 : { version: require_types.HOT_UPDATER_SCHEMA_VERSION },
|
|
122
|
+
previous: async () => void 0,
|
|
123
|
+
up: makeResult,
|
|
124
|
+
down: async () => {
|
|
125
|
+
throw new Error("No previous schema to migrate to.");
|
|
126
|
+
},
|
|
127
|
+
migrateTo: async (version, options) => {
|
|
128
|
+
if (version !== "0.31.0") throw new Error(`Invalid version ${version}`);
|
|
129
|
+
return makeResult(options);
|
|
130
|
+
},
|
|
131
|
+
migrateToLatest: makeResult
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
//#endregion
|
|
135
|
+
exports.createKyselyMigrator = createKyselyMigrator;
|
|
136
|
+
exports.createMongoMigrator = createMongoMigrator;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { HOT_UPDATER_SCHEMA_VERSION, HOT_UPDATER_SETTINGS_TABLE } from "../schema/types.mjs";
|
|
2
|
+
import { hotUpdaterSchema, schemaIndexAppliesToProvider } from "./schema/registry.mjs";
|
|
3
|
+
import { createTableSql } from "./schema/sql.mjs";
|
|
4
|
+
import { createMongoMigrationOperations } from "./schema/mongodb.mjs";
|
|
5
|
+
import { createV029AlterSql, createV031AlterSql } from "./schema/sqlMigrations.mjs";
|
|
6
|
+
import { createSqlCreateOperations, getSettingsInsertSql } from "./schema/sqlOperations.mjs";
|
|
7
|
+
//#region src/db/fixedMigrator.ts
|
|
8
|
+
const getEmptyResult = () => ({
|
|
9
|
+
operations: [],
|
|
10
|
+
execute: async () => {},
|
|
11
|
+
getSQL: () => ""
|
|
12
|
+
});
|
|
13
|
+
const assertSupportedMigrationMode = (options) => {
|
|
14
|
+
if (options.mode === "from-database") throw new Error("Hot Updater migrations support only mode: 'from-schema'.");
|
|
15
|
+
};
|
|
16
|
+
const isMissingSettingsTableError = (error) => {
|
|
17
|
+
if (!(error instanceof Error)) return false;
|
|
18
|
+
const message = error.message.toLowerCase();
|
|
19
|
+
return message.includes("private_hot_updater_settings") && (message.includes("does not exist") || message.includes("no such table") || message.includes("doesn't exist") || message.includes("not found"));
|
|
20
|
+
};
|
|
21
|
+
const isMongoNamespaceExistsError = (error) => {
|
|
22
|
+
if (!(error instanceof Error)) return false;
|
|
23
|
+
const mongoError = error;
|
|
24
|
+
return mongoError.code === 48 || mongoError.codeName === "NamespaceExists";
|
|
25
|
+
};
|
|
26
|
+
const ignoreExistingCollection = (error) => {
|
|
27
|
+
if (isMongoNamespaceExistsError(error)) return;
|
|
28
|
+
throw error;
|
|
29
|
+
};
|
|
30
|
+
const toCustomOperations = (statements, settingsOperation) => [...statements.map((statement) => ({
|
|
31
|
+
type: "custom",
|
|
32
|
+
sql: statement
|
|
33
|
+
})), ...settingsOperation ? [settingsOperation] : []];
|
|
34
|
+
const assertSupportedSchemaVersion = (currentVersion) => {
|
|
35
|
+
if (currentVersion !== void 0 && currentVersion !== "0.21.0" && currentVersion !== "0.29.0") throw new Error(`Unsupported Hot Updater schema version: ${currentVersion}`);
|
|
36
|
+
};
|
|
37
|
+
const createKyselyMigrator = ({ db, provider, relationMode = "foreign-keys" }) => {
|
|
38
|
+
const getVersion = async () => {
|
|
39
|
+
try {
|
|
40
|
+
const row = await db.selectFrom(HOT_UPDATER_SETTINGS_TABLE).select("value").where("key", "=", "version").executeTakeFirst();
|
|
41
|
+
return typeof row?.value === "string" ? row.value : void 0;
|
|
42
|
+
} catch (error) {
|
|
43
|
+
if (!isMissingSettingsTableError(error)) throw error;
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const makeResult = async (options = {}) => {
|
|
48
|
+
assertSupportedMigrationMode(options);
|
|
49
|
+
const currentVersion = await getVersion();
|
|
50
|
+
if (currentVersion === "0.31.0") return getEmptyResult();
|
|
51
|
+
assertSupportedSchemaVersion(currentVersion);
|
|
52
|
+
const settingsStatement = getSettingsInsertSql(provider);
|
|
53
|
+
const settingsOperation = options.updateSettings === false ? void 0 : {
|
|
54
|
+
type: "custom",
|
|
55
|
+
sql: settingsStatement
|
|
56
|
+
};
|
|
57
|
+
const executableSettingsStatements = options.updateSettings === false ? [] : [settingsStatement];
|
|
58
|
+
const statements = currentVersion === void 0 ? [...createTableSql(provider, relationMode), settingsStatement] : [
|
|
59
|
+
...currentVersion === "0.21.0" ? createV029AlterSql(provider) : [],
|
|
60
|
+
...currentVersion === "0.21.0" || currentVersion === "0.29.0" ? createV031AlterSql(provider, relationMode) : [],
|
|
61
|
+
...executableSettingsStatements
|
|
62
|
+
];
|
|
63
|
+
return {
|
|
64
|
+
operations: currentVersion === void 0 ? createSqlCreateOperations(provider, relationMode, settingsOperation) : toCustomOperations([...currentVersion === "0.21.0" ? createV029AlterSql(provider) : [], ...currentVersion === "0.21.0" || currentVersion === "0.29.0" ? createV031AlterSql(provider, relationMode) : []], settingsOperation),
|
|
65
|
+
getSQL: () => statements.map((statement) => `${statement};`).join("\n\n"),
|
|
66
|
+
execute: async () => {
|
|
67
|
+
const { sql } = await import("kysely");
|
|
68
|
+
for (const statement of statements) await sql.raw(statement).execute(db);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
return {
|
|
73
|
+
getVersion,
|
|
74
|
+
getNameVariants: async () => void 0,
|
|
75
|
+
next: async () => await getVersion() === "0.31.0" ? void 0 : { version: HOT_UPDATER_SCHEMA_VERSION },
|
|
76
|
+
previous: async () => void 0,
|
|
77
|
+
up: makeResult,
|
|
78
|
+
down: async () => {
|
|
79
|
+
throw new Error("No previous schema to migrate to.");
|
|
80
|
+
},
|
|
81
|
+
migrateTo: async (version, options) => {
|
|
82
|
+
if (version !== "0.31.0") throw new Error(`Invalid version ${version}`);
|
|
83
|
+
return makeResult(options);
|
|
84
|
+
},
|
|
85
|
+
migrateToLatest: makeResult
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
const createMongoMigrator = (client) => {
|
|
89
|
+
const settings = client.db().collection(HOT_UPDATER_SETTINGS_TABLE);
|
|
90
|
+
const getVersion = async () => {
|
|
91
|
+
const row = await settings.findOne({ key: "version" });
|
|
92
|
+
return typeof row?.value === "string" ? row.value : void 0;
|
|
93
|
+
};
|
|
94
|
+
const makeResult = async (options = {}) => {
|
|
95
|
+
assertSupportedMigrationMode(options);
|
|
96
|
+
if (await getVersion() === "0.31.0") return getEmptyResult();
|
|
97
|
+
return {
|
|
98
|
+
operations: createMongoMigrationOperations(options.updateSettings === false ? void 0 : {
|
|
99
|
+
type: "custom",
|
|
100
|
+
key: "version",
|
|
101
|
+
value: HOT_UPDATER_SCHEMA_VERSION
|
|
102
|
+
}),
|
|
103
|
+
execute: async () => {
|
|
104
|
+
const db = client.db();
|
|
105
|
+
for (const table of hotUpdaterSchema.tables) {
|
|
106
|
+
if (table.internal) continue;
|
|
107
|
+
await db.createCollection(table.ormName).catch(ignoreExistingCollection);
|
|
108
|
+
}
|
|
109
|
+
await db.collection("bundles").createIndex({ id: 1 }, { name: "bundles_id_idx" });
|
|
110
|
+
for (const table of hotUpdaterSchema.tables) {
|
|
111
|
+
if (table.internal) continue;
|
|
112
|
+
for (const index of (table.indexes ?? []).filter((item) => schemaIndexAppliesToProvider(item, "mongodb"))) await db.collection(table.ormName).createIndex(Object.fromEntries(index.columns.map((column) => [column, 1])), { name: index.name });
|
|
113
|
+
}
|
|
114
|
+
if (options.updateSettings !== false) await settings.updateOne({ key: "version" }, { $set: { value: HOT_UPDATER_SCHEMA_VERSION } }, { upsert: true });
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
return {
|
|
119
|
+
getVersion,
|
|
120
|
+
getNameVariants: async () => void 0,
|
|
121
|
+
next: async () => await getVersion() === "0.31.0" ? void 0 : { version: HOT_UPDATER_SCHEMA_VERSION },
|
|
122
|
+
previous: async () => void 0,
|
|
123
|
+
up: makeResult,
|
|
124
|
+
down: async () => {
|
|
125
|
+
throw new Error("No previous schema to migrate to.");
|
|
126
|
+
},
|
|
127
|
+
migrateTo: async (version, options) => {
|
|
128
|
+
if (version !== "0.31.0") throw new Error(`Invalid version ${version}`);
|
|
129
|
+
return makeResult(options);
|
|
130
|
+
},
|
|
131
|
+
migrateToLatest: makeResult
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
//#endregion
|
|
135
|
+
export { createKyselyMigrator, createMongoMigrator };
|
package/dist/db/index.cjs
CHANGED
|
@@ -4,9 +4,10 @@ require("../version.cjs");
|
|
|
4
4
|
const require_handler = require("../handler.cjs");
|
|
5
5
|
const require_route = require("../route.cjs");
|
|
6
6
|
const require_storageAccess = require("../storageAccess.cjs");
|
|
7
|
-
const require_types = require("./types.cjs");
|
|
8
|
-
const require_ormCore = require("./ormCore.cjs");
|
|
9
7
|
const require_pluginCore = require("./pluginCore.cjs");
|
|
8
|
+
const require_types = require("./types.cjs");
|
|
9
|
+
const require_schemaGenerators = require("./schemaGenerators.cjs");
|
|
10
|
+
const require_schemaReadiness = require("./schemaReadiness.cjs");
|
|
10
11
|
let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
|
|
11
12
|
//#region src/db/index.ts
|
|
12
13
|
function createHotUpdater(options) {
|
|
@@ -17,22 +18,23 @@ function createHotUpdater(options) {
|
|
|
17
18
|
return storagePlugin;
|
|
18
19
|
}));
|
|
19
20
|
const database = options.database;
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
const capabilities = database;
|
|
22
|
+
const plugin = require_types.isDatabasePluginFactory(database) ? database() : database;
|
|
23
|
+
const assertSchemaReady = require_schemaReadiness.createSchemaReadinessChecker(capabilities.adapterName ?? plugin.name, capabilities.createMigrator);
|
|
24
|
+
const core = require_pluginCore.createPluginDatabaseCore(() => plugin, resolveFileUrl, require_types.isDatabasePluginFactory(database) ? {
|
|
25
|
+
createMutationPlugin: () => database(),
|
|
26
|
+
beforeOperation: assertSchemaReady,
|
|
27
|
+
readStorageText
|
|
28
|
+
} : {
|
|
29
|
+
beforeOperation: assertSchemaReady,
|
|
30
|
+
readStorageText
|
|
30
31
|
});
|
|
32
|
+
const generateSchema = capabilities.generateSchema ?? core.generateSchema;
|
|
31
33
|
const api = {
|
|
32
34
|
basePath,
|
|
33
|
-
adapterName: core.adapterName,
|
|
34
|
-
createMigrator: core.createMigrator,
|
|
35
|
-
generateSchema:
|
|
35
|
+
adapterName: capabilities.adapterName ?? core.adapterName,
|
|
36
|
+
createMigrator: capabilities.createMigrator ?? core.createMigrator,
|
|
37
|
+
generateSchema: (...args) => require_schemaGenerators.generateSchemaFromHotUpdaterSchema(api.adapterName, capabilities.provider, args[0], generateSchema(...args)),
|
|
36
38
|
handler: require_handler.createHandler(core.api, {
|
|
37
39
|
basePath,
|
|
38
40
|
routes: options.routes
|
package/dist/db/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CreateBundleDiffDependencies, CreateBundleDiffInput, CreateBundleDiffOptions, createBundleDiff } from "./createBundleDiff.cjs";
|
|
2
2
|
import { HandlerRoutes } from "../handler.cjs";
|
|
3
|
-
import {
|
|
3
|
+
import { HotUpdaterSchemaMigrationRequiredError } from "./schemaReadiness.cjs";
|
|
4
4
|
import { HOT_UPDATER_SERVER_VERSION } from "../version.cjs";
|
|
5
|
-
import { DatabaseAPI, DatabaseAdapter, StoragePluginFactory } from "./types.cjs";
|
|
5
|
+
import { DatabaseAPI, DatabaseAdapter, Migrator, SchemaGenerator, StoragePluginFactory } from "./types.cjs";
|
|
6
6
|
import { HotUpdaterContext, RuntimeStoragePlugin } from "@hot-updater/plugin-core";
|
|
7
7
|
|
|
8
8
|
//#region src/db/index.d.ts
|
|
@@ -11,7 +11,7 @@ type HotUpdaterAPI<TContext = unknown> = DatabaseAPI<TContext> & {
|
|
|
11
11
|
handler: (request: Request, context?: HotUpdaterContext<TContext>) => Promise<Response>;
|
|
12
12
|
adapterName: string;
|
|
13
13
|
createMigrator: () => Migrator;
|
|
14
|
-
generateSchema:
|
|
14
|
+
generateSchema: SchemaGenerator;
|
|
15
15
|
};
|
|
16
16
|
interface CreateHotUpdaterOptions<TContext = unknown> {
|
|
17
17
|
database: DatabaseAdapter<TContext>;
|
package/dist/db/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CreateBundleDiffDependencies, CreateBundleDiffInput, CreateBundleDiffOptions, createBundleDiff } from "./createBundleDiff.mjs";
|
|
2
2
|
import { HandlerRoutes } from "../handler.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { HotUpdaterSchemaMigrationRequiredError } from "./schemaReadiness.mjs";
|
|
4
4
|
import { HOT_UPDATER_SERVER_VERSION } from "../version.mjs";
|
|
5
|
-
import { DatabaseAPI, DatabaseAdapter, StoragePluginFactory } from "./types.mjs";
|
|
5
|
+
import { DatabaseAPI, DatabaseAdapter, Migrator, SchemaGenerator, StoragePluginFactory } from "./types.mjs";
|
|
6
6
|
import { HotUpdaterContext, RuntimeStoragePlugin } from "@hot-updater/plugin-core";
|
|
7
7
|
|
|
8
8
|
//#region src/db/index.d.ts
|
|
@@ -11,7 +11,7 @@ type HotUpdaterAPI<TContext = unknown> = DatabaseAPI<TContext> & {
|
|
|
11
11
|
handler: (request: Request, context?: HotUpdaterContext<TContext>) => Promise<Response>;
|
|
12
12
|
adapterName: string;
|
|
13
13
|
createMigrator: () => Migrator;
|
|
14
|
-
generateSchema:
|
|
14
|
+
generateSchema: SchemaGenerator;
|
|
15
15
|
};
|
|
16
16
|
interface CreateHotUpdaterOptions<TContext = unknown> {
|
|
17
17
|
database: DatabaseAdapter<TContext>;
|
package/dist/db/index.mjs
CHANGED
|
@@ -3,9 +3,10 @@ import "../version.mjs";
|
|
|
3
3
|
import { createHandler } from "../handler.mjs";
|
|
4
4
|
import { normalizeBasePath } from "../route.mjs";
|
|
5
5
|
import { createStorageAccess } from "../storageAccess.mjs";
|
|
6
|
-
import { isDatabasePlugin, isDatabasePluginFactory } from "./types.mjs";
|
|
7
|
-
import { createOrmDatabaseCore } from "./ormCore.mjs";
|
|
8
6
|
import { createPluginDatabaseCore } from "./pluginCore.mjs";
|
|
7
|
+
import { isDatabasePluginFactory } from "./types.mjs";
|
|
8
|
+
import { generateSchemaFromHotUpdaterSchema } from "./schemaGenerators.mjs";
|
|
9
|
+
import { createSchemaReadinessChecker } from "./schemaReadiness.mjs";
|
|
9
10
|
import { assertRuntimeStoragePlugin } from "@hot-updater/plugin-core";
|
|
10
11
|
//#region src/db/index.ts
|
|
11
12
|
function createHotUpdater(options) {
|
|
@@ -16,22 +17,23 @@ function createHotUpdater(options) {
|
|
|
16
17
|
return storagePlugin;
|
|
17
18
|
}));
|
|
18
19
|
const database = options.database;
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
const capabilities = database;
|
|
21
|
+
const plugin = isDatabasePluginFactory(database) ? database() : database;
|
|
22
|
+
const assertSchemaReady = createSchemaReadinessChecker(capabilities.adapterName ?? plugin.name, capabilities.createMigrator);
|
|
23
|
+
const core = createPluginDatabaseCore(() => plugin, resolveFileUrl, isDatabasePluginFactory(database) ? {
|
|
24
|
+
createMutationPlugin: () => database(),
|
|
25
|
+
beforeOperation: assertSchemaReady,
|
|
26
|
+
readStorageText
|
|
27
|
+
} : {
|
|
28
|
+
beforeOperation: assertSchemaReady,
|
|
29
|
+
readStorageText
|
|
29
30
|
});
|
|
31
|
+
const generateSchema = capabilities.generateSchema ?? core.generateSchema;
|
|
30
32
|
const api = {
|
|
31
33
|
basePath,
|
|
32
|
-
adapterName: core.adapterName,
|
|
33
|
-
createMigrator: core.createMigrator,
|
|
34
|
-
generateSchema:
|
|
34
|
+
adapterName: capabilities.adapterName ?? core.adapterName,
|
|
35
|
+
createMigrator: capabilities.createMigrator ?? core.createMigrator,
|
|
36
|
+
generateSchema: (...args) => generateSchemaFromHotUpdaterSchema(api.adapterName, capabilities.provider, args[0], generateSchema(...args)),
|
|
35
37
|
handler: createHandler(core.api, {
|
|
36
38
|
basePath,
|
|
37
39
|
routes: options.routes
|