@hot-updater/server 0.33.2 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rolldown/runtime.cjs +0 -2
- package/dist/adapters/drizzle.cjs +195 -2
- package/dist/adapters/drizzle.d.cts +7 -4
- package/dist/adapters/drizzle.d.mts +7 -4
- package/dist/adapters/drizzle.mjs +194 -2
- package/dist/adapters/drizzleLazyDB.cjs +53 -0
- package/dist/adapters/drizzleLazyDB.mjs +53 -0
- package/dist/adapters/kysely.cjs +154 -3
- package/dist/adapters/kysely.d.cts +18 -10
- package/dist/adapters/kysely.d.mts +18 -10
- package/dist/adapters/kysely.mjs +153 -3
- package/dist/adapters/mongodb.cjs +183 -2
- package/dist/adapters/mongodb.d.cts +5 -4
- package/dist/adapters/mongodb.d.mts +5 -4
- package/dist/adapters/mongodb.mjs +183 -2
- package/dist/adapters/prisma.cjs +200 -2
- package/dist/adapters/prisma.d.cts +9 -4
- package/dist/adapters/prisma.d.mts +9 -4
- package/dist/adapters/prisma.mjs +199 -2
- package/dist/db/bundleRows.cjs +82 -0
- package/dist/db/bundleRows.d.cts +33 -0
- package/dist/db/bundleRows.d.mts +33 -0
- package/dist/db/bundleRows.mjs +79 -0
- package/dist/db/fixedMigrator.cjs +136 -0
- package/dist/db/fixedMigrator.mjs +135 -0
- package/dist/db/index.cjs +17 -15
- package/dist/db/index.d.cts +3 -3
- package/dist/db/index.d.mts +3 -3
- package/dist/db/index.mjs +17 -15
- package/dist/db/pluginCore.cjs +13 -5
- package/dist/db/pluginCore.mjs +13 -5
- package/dist/db/schema/mongodb.cjs +17 -0
- package/dist/db/schema/mongodb.mjs +17 -0
- package/dist/db/schema/registry.cjs +23 -0
- package/dist/db/schema/registry.mjs +18 -0
- package/dist/db/schema/sql.cjs +84 -0
- package/dist/db/schema/sql.mjs +78 -0
- package/dist/db/schema/sqlMigrations.cjs +74 -0
- package/dist/db/schema/sqlMigrations.mjs +73 -0
- package/dist/db/schema/sqlOperations.cjs +27 -0
- package/dist/db/schema/sqlOperations.mjs +26 -0
- package/dist/db/schemaEnhancements.cjs +1 -152
- package/dist/db/schemaEnhancements.mjs +1 -149
- package/dist/db/schemaGenerators.cjs +222 -0
- package/dist/db/schemaGenerators.mjs +220 -0
- package/dist/db/schemaReadiness.cjs +23 -0
- package/dist/db/schemaReadiness.d.cts +8 -0
- package/dist/db/schemaReadiness.d.mts +8 -0
- package/dist/db/schemaReadiness.mjs +22 -0
- package/dist/db/types.cjs +10 -2
- package/dist/db/types.d.cts +58 -14
- package/dist/db/types.d.mts +58 -14
- package/dist/db/types.mjs +9 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +3 -2
- package/dist/index.d.mts +3 -2
- package/dist/index.mjs +2 -2
- package/dist/{packages/server/package.cjs → package.cjs} +1 -1
- package/dist/{packages/server/package.mjs → package.mjs} +1 -1
- package/dist/runtime.cjs +9 -2
- package/dist/runtime.mjs +9 -2
- package/dist/schema/dsl.cjs +86 -0
- package/dist/schema/dsl.mjs +73 -0
- package/dist/schema/index.cjs +13 -0
- package/dist/schema/index.mjs +13 -0
- package/dist/schema/settings.cjs +9 -0
- package/dist/schema/settings.mjs +9 -0
- package/dist/schema/types.cjs +6 -0
- package/dist/schema/types.mjs +5 -0
- package/dist/schema/v0_21_0.cjs +33 -18
- package/dist/schema/v0_21_0.mjs +32 -18
- package/dist/schema/v0_29_0.cjs +40 -20
- package/dist/schema/v0_29_0.mjs +39 -20
- package/dist/schema/v0_31_0.cjs +77 -43
- package/dist/schema/v0_31_0.mjs +75 -43
- package/dist/version.cjs +1 -1
- package/dist/version.mjs +1 -1
- package/package.json +30 -16
- package/src/adapters/drizzle.spec.ts +75 -0
- package/src/adapters/drizzle.ts +328 -12
- package/src/adapters/drizzleLazyDB.ts +151 -0
- package/src/adapters/kysely.spec.ts +107 -0
- package/src/adapters/kysely.ts +349 -14
- package/src/adapters/mongodb.ts +298 -15
- package/src/adapters/prisma.ts +337 -12
- package/src/db/bundleRows.ts +140 -0
- package/src/db/fixedMigrator.spec.ts +89 -0
- package/src/db/fixedMigrator.ts +288 -0
- package/src/db/hotUpdaterSchema.ts +6 -0
- package/src/db/index.spec.ts +976 -13
- package/src/db/index.ts +37 -36
- package/src/db/pluginCore.spec.ts +17 -11
- package/src/db/pluginCore.ts +15 -6
- package/src/db/schema/definitions.ts +1 -0
- package/src/db/schema/mongodb.ts +26 -0
- package/src/db/schema/registry.ts +55 -0
- package/src/db/schema/sql.ts +200 -0
- package/src/db/schema/sqlMigrations.ts +219 -0
- package/src/db/schema/sqlOperations.ts +62 -0
- package/src/db/schema/types.ts +1 -0
- package/src/db/schemaEnhancements.ts +0 -405
- package/src/db/schemaGenerators.ts +382 -0
- package/src/db/schemaReadiness.ts +33 -0
- package/src/db/types.ts +69 -25
- package/src/runtime.spec.ts +70 -0
- package/src/runtime.ts +14 -2
- package/src/schema/dsl-all-versions.spec.ts +26 -0
- package/src/schema/dsl.ts +148 -0
- package/src/schema/index.ts +16 -0
- package/src/schema/settings.ts +15 -0
- package/src/schema/types.ts +73 -0
- package/src/schema/v0_21_0.ts +48 -18
- package/src/schema/v0_29_0.ts +58 -22
- package/src/schema/v0_31_0.spec.ts +73 -0
- package/src/schema/v0_31_0.ts +116 -54
- package/dist/_virtual/_rolldown/runtime.mjs +0 -6
- package/dist/calculatePagination.cjs +0 -25
- package/dist/calculatePagination.mjs +0 -25
- package/dist/db/ormCore.cjs +0 -577
- package/dist/db/ormCore.d.cts +0 -110
- package/dist/db/ormCore.d.mts +0 -110
- package/dist/db/ormCore.mjs +0 -575
- package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/_u64.cjs +0 -112
- package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/_u64.mjs +0 -108
- package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/cryptoNode.cjs +0 -22
- package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/cryptoNode.mjs +0 -18
- package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/sha3.cjs +0 -219
- package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/sha3.mjs +0 -214
- package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/utils.cjs +0 -275
- package/dist/node_modules/.pnpm/@noble_hashes@1.8.0/node_modules/@noble/hashes/utils.mjs +0 -270
- package/dist/node_modules/.pnpm/@paralleldrive_cuid2@2.3.1/node_modules/@paralleldrive/cuid2/index.cjs +0 -17
- package/dist/node_modules/.pnpm/@paralleldrive_cuid2@2.3.1/node_modules/@paralleldrive/cuid2/index.mjs +0 -13
- package/dist/node_modules/.pnpm/@paralleldrive_cuid2@2.3.1/node_modules/@paralleldrive/cuid2/src/index.cjs +0 -69
- package/dist/node_modules/.pnpm/@paralleldrive_cuid2@2.3.1/node_modules/@paralleldrive/cuid2/src/index.mjs +0 -65
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/column.cjs +0 -52
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/column.mjs +0 -52
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/entity.cjs +0 -16
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/entity.mjs +0 -15
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/pg-core/columns/enum.cjs +0 -7
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/pg-core/columns/enum.mjs +0 -7
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/sql/expressions/conditions.cjs +0 -92
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/sql/expressions/conditions.mjs +0 -78
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/sql/expressions/select.cjs +0 -11
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/sql/expressions/select.mjs +0 -10
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/sql/sql.cjs +0 -383
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/sql/sql.mjs +0 -366
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/subquery.cjs +0 -17
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/subquery.mjs +0 -17
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/table.cjs +0 -60
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/table.mjs +0 -59
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/table.utils.cjs +0 -4
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/table.utils.mjs +0 -4
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/tracing.cjs +0 -6
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/tracing.mjs +0 -6
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/view-common.cjs +0 -4
- package/dist/node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare_workers-types@4.20260611.1_@electric-sql_pglite@0.4.1_@l_601a3995dfc55b0b7fac93cbe1e76579/node_modules/drizzle-orm/view-common.mjs +0 -4
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/adapters/drizzle/index.cjs +0 -383
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/adapters/drizzle/index.d.cts +0 -12
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/adapters/drizzle/index.d.mts +0 -12
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/adapters/drizzle/index.mjs +0 -383
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/adapters/kysely/index.cjs +0 -4
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/adapters/kysely/index.mjs +0 -5
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/adapters/prisma/index.cjs +0 -339
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/adapters/prisma/index.d.cts +0 -70
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/adapters/prisma/index.d.mts +0 -70
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/adapters/prisma/index.mjs +0 -339
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-7PZK4ONR.cjs +0 -57
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-7PZK4ONR.mjs +0 -56
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-C6OTUURW.cjs +0 -330
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-C6OTUURW.mjs +0 -326
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-CHTIKPQU.cjs +0 -166
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-CHTIKPQU.mjs +0 -163
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-GUE4GMNC.cjs +0 -14
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-GUE4GMNC.mjs +0 -13
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-LHHP6UVP.cjs +0 -24
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-LHHP6UVP.mjs +0 -24
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-LVCPMTAT.cjs +0 -1190
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-LVCPMTAT.mjs +0 -1189
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-PK2W2SQ7.cjs +0 -197
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-PK2W2SQ7.mjs +0 -197
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-ZEQMAIFI.cjs +0 -410
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-ZEQMAIFI.mjs +0 -400
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-ZOCGSAWS.cjs +0 -213
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/chunk-ZOCGSAWS.mjs +0 -212
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/create-tg0451Y_.d.cts +0 -285
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/create-tg0451Y_.d.mts +0 -285
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/index-CMqePMTF.d.cts +0 -45
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/index-CMqePMTF.d.mts +0 -45
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/index.cjs +0 -69
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/index.d.cts +0 -49
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/index.d.mts +0 -49
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/index.mjs +0 -67
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/query/index.d.cts +0 -156
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/query/index.d.mts +0 -156
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/schema/index.cjs +0 -1
- package/dist/node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk_credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/schema/index.mjs +0 -2
- package/src/db/ormCore.ts +0 -1059
- package/src/db/ormUpdateCheck.bench.ts +0 -262
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import "../schema/types.mjs";
|
|
2
|
+
import { getHotUpdaterSchemaVersion, hotUpdaterSchema, schemaIndexAppliesToProvider } from "./schema/registry.mjs";
|
|
3
|
+
import { getSQLProvider } from "./types.mjs";
|
|
4
|
+
//#region src/db/schemaGenerators.ts
|
|
5
|
+
const literal = (value) => JSON.stringify(value);
|
|
6
|
+
const toPascalCase = (value) => value.split("_").filter(Boolean).map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`).join("");
|
|
7
|
+
const prismaDb = (type, provider) => {
|
|
8
|
+
if (provider === "postgresql") {
|
|
9
|
+
if (type === "uuid") return " @db.Uuid";
|
|
10
|
+
if (type.startsWith("varchar")) return " @db.VarChar(255)";
|
|
11
|
+
}
|
|
12
|
+
if (provider === "mysql") {
|
|
13
|
+
if (type === "uuid") return " @db.Char(36)";
|
|
14
|
+
if (type.startsWith("varchar")) return " @db.VarChar(255)";
|
|
15
|
+
}
|
|
16
|
+
return "";
|
|
17
|
+
};
|
|
18
|
+
const prismaType = (column, provider) => {
|
|
19
|
+
return `${(() => {
|
|
20
|
+
if (column.type === "bool") return "Boolean";
|
|
21
|
+
if (column.type === "integer") return "Int";
|
|
22
|
+
if (column.type === "json") return "Json";
|
|
23
|
+
return "String";
|
|
24
|
+
})()}${column.nullable ? "?" : ""}${prismaDb(column.type, provider)}`;
|
|
25
|
+
};
|
|
26
|
+
const prismaDefault = (column, provider) => {
|
|
27
|
+
if (!column.default) return "";
|
|
28
|
+
if (provider === "sqlite" && column.type === "json") return "";
|
|
29
|
+
if (column.default.type === "json") return ` @default(${literal(JSON.stringify(column.default.value))})`;
|
|
30
|
+
return ` @default(${JSON.stringify(column.default.value)})`;
|
|
31
|
+
};
|
|
32
|
+
const prismaField = (column, provider) => [
|
|
33
|
+
column.ormName,
|
|
34
|
+
prismaType(column, provider),
|
|
35
|
+
column.primaryKey ? "@id" : void 0,
|
|
36
|
+
prismaDefault(column, provider).trim() || void 0
|
|
37
|
+
].filter(Boolean).join(" ");
|
|
38
|
+
const relationTargetFields = (table, schema) => schema.tables.flatMap((sourceTable) => (sourceTable.relations ?? []).filter((relation) => relation.referencedTable === table.ormName));
|
|
39
|
+
const prismaRelationFields = (table, schema) => {
|
|
40
|
+
const lines = relationTargetFields(table, schema).map((relation) => `${relation.fieldName} ${relation.referencedTable === table.ormName ? "bundle_patches" : relation.referencedTable}[] @relation(${literal(relation.relationName)})`);
|
|
41
|
+
for (const relation of table.relations ?? []) {
|
|
42
|
+
const targetType = toPascalCase(relation.referencedTable);
|
|
43
|
+
lines.push(`${relation.targetFieldName} ${targetType === "Bundles" ? "bundles" : relation.referencedTable} @relation(${literal(relation.relationName)}, fields: [${relation.columns.join(", ")}], references: [${relation.referencedColumns.join(", ")}], onUpdate: Restrict, onDelete: Cascade)`);
|
|
44
|
+
}
|
|
45
|
+
return lines;
|
|
46
|
+
};
|
|
47
|
+
const prismaIndexes = (table, provider) => (table.indexes ?? []).filter((index) => schemaIndexAppliesToProvider(index, provider)).map((index) => `@@index([${index.columns.join(", ")}], map: ${literal(index.name)})`);
|
|
48
|
+
const generatePrismaSchema = (provider, schema = hotUpdaterSchema) => schema.tables.map((table) => {
|
|
49
|
+
const lines = [
|
|
50
|
+
...table.columns.map((column) => prismaField(column, provider)),
|
|
51
|
+
...prismaRelationFields(table, schema),
|
|
52
|
+
...prismaIndexes(table, provider)
|
|
53
|
+
];
|
|
54
|
+
return `model ${table.ormName} {\n${lines.map((line) => ` ${line}`).join("\n")}\n}`;
|
|
55
|
+
}).join("\n\n");
|
|
56
|
+
const drizzleImportSource = (provider) => provider === "sqlite" ? "drizzle-orm/sqlite-core" : provider === "mysql" ? "drizzle-orm/mysql-core" : "drizzle-orm/pg-core";
|
|
57
|
+
const drizzleTableFn = (provider) => provider === "sqlite" ? "sqliteTable" : provider === "mysql" ? "mysqlTable" : "pgTable";
|
|
58
|
+
const drizzleColumnFn = (column, provider) => {
|
|
59
|
+
if (provider === "sqlite") {
|
|
60
|
+
if (column.type === "bool") return {
|
|
61
|
+
code: `integer(${literal(column.ormName)}, { mode: "boolean" })`,
|
|
62
|
+
imports: ["integer"]
|
|
63
|
+
};
|
|
64
|
+
if (column.type === "integer") return {
|
|
65
|
+
code: `integer(${literal(column.ormName)})`,
|
|
66
|
+
imports: ["integer"]
|
|
67
|
+
};
|
|
68
|
+
if (column.type === "json") return {
|
|
69
|
+
code: `blob(${literal(column.ormName)}, { mode: "json" })`,
|
|
70
|
+
imports: ["blob"]
|
|
71
|
+
};
|
|
72
|
+
if (column.type.startsWith("varchar")) return {
|
|
73
|
+
code: `text(${literal(column.ormName)}, { length: 255 })`,
|
|
74
|
+
imports: ["text"]
|
|
75
|
+
};
|
|
76
|
+
return {
|
|
77
|
+
code: `text(${literal(column.ormName)})`,
|
|
78
|
+
imports: ["text"]
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
if (provider === "mysql") {
|
|
82
|
+
if (column.type === "uuid") return {
|
|
83
|
+
code: `char(${literal(column.ormName)}, { length: 36 })`,
|
|
84
|
+
imports: ["char"]
|
|
85
|
+
};
|
|
86
|
+
if (column.type === "bool") return {
|
|
87
|
+
code: `boolean(${literal(column.ormName)})`,
|
|
88
|
+
imports: ["boolean"]
|
|
89
|
+
};
|
|
90
|
+
if (column.type === "integer") return {
|
|
91
|
+
code: `int(${literal(column.ormName)})`,
|
|
92
|
+
imports: ["int"]
|
|
93
|
+
};
|
|
94
|
+
if (column.type === "json") return {
|
|
95
|
+
code: `json(${literal(column.ormName)})`,
|
|
96
|
+
imports: ["json"]
|
|
97
|
+
};
|
|
98
|
+
if (column.type.startsWith("varchar")) return {
|
|
99
|
+
code: `varchar(${literal(column.ormName)}, { length: 255 })`,
|
|
100
|
+
imports: ["varchar"]
|
|
101
|
+
};
|
|
102
|
+
return {
|
|
103
|
+
code: `text(${literal(column.ormName)})`,
|
|
104
|
+
imports: ["text"]
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
if (column.type === "uuid") return {
|
|
108
|
+
code: `uuid(${literal(column.ormName)})`,
|
|
109
|
+
imports: ["uuid"]
|
|
110
|
+
};
|
|
111
|
+
if (column.type === "bool") return {
|
|
112
|
+
code: `boolean(${literal(column.ormName)})`,
|
|
113
|
+
imports: ["boolean"]
|
|
114
|
+
};
|
|
115
|
+
if (column.type === "integer") return {
|
|
116
|
+
code: `integer(${literal(column.ormName)})`,
|
|
117
|
+
imports: ["integer"]
|
|
118
|
+
};
|
|
119
|
+
if (column.type === "json") return {
|
|
120
|
+
code: `json(${literal(column.ormName)})`,
|
|
121
|
+
imports: ["json"]
|
|
122
|
+
};
|
|
123
|
+
if (column.type.startsWith("varchar")) return {
|
|
124
|
+
code: `varchar(${literal(column.ormName)}, { length: 255 })`,
|
|
125
|
+
imports: ["varchar"]
|
|
126
|
+
};
|
|
127
|
+
return {
|
|
128
|
+
code: `text(${literal(column.ormName)})`,
|
|
129
|
+
imports: ["text"]
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
const drizzleDefault = (value) => {
|
|
133
|
+
if (!value) return "";
|
|
134
|
+
if (value.type === "json") return ".default({})";
|
|
135
|
+
return `.default(${JSON.stringify(value.value)})`;
|
|
136
|
+
};
|
|
137
|
+
const drizzleColumn = (table, column) => {
|
|
138
|
+
if (table.ormName !== "private_hot_updater_settings") return column;
|
|
139
|
+
if (column.ormName === "key") return {
|
|
140
|
+
...column,
|
|
141
|
+
ormName: "id",
|
|
142
|
+
type: "varchar(255)"
|
|
143
|
+
};
|
|
144
|
+
if (column.ormName === "value") return {
|
|
145
|
+
...column,
|
|
146
|
+
ormName: "version",
|
|
147
|
+
type: "varchar(255)"
|
|
148
|
+
};
|
|
149
|
+
return column;
|
|
150
|
+
};
|
|
151
|
+
const drizzleTable = (table, provider, imports) => {
|
|
152
|
+
const columns = table.columns.map((sourceColumn) => {
|
|
153
|
+
const column = drizzleColumn(table, sourceColumn);
|
|
154
|
+
const type = drizzleColumnFn(column, provider);
|
|
155
|
+
for (const item of type.imports) imports.add(item);
|
|
156
|
+
const chain = [
|
|
157
|
+
type.code,
|
|
158
|
+
column.primaryKey ? "primaryKey()" : void 0,
|
|
159
|
+
column.nullable ? void 0 : "notNull()",
|
|
160
|
+
drizzleDefault(column.default).slice(1) || void 0
|
|
161
|
+
].filter(Boolean);
|
|
162
|
+
return ` ${column.ormName}: ${chain.join(".")}`;
|
|
163
|
+
});
|
|
164
|
+
const callbacks = [];
|
|
165
|
+
for (const foreignKey of table.foreignKeys ?? []) {
|
|
166
|
+
imports.add("foreignKey");
|
|
167
|
+
callbacks.push(`foreignKey({
|
|
168
|
+
columns: [table.${foreignKey.columns.join(", table.")}],
|
|
169
|
+
foreignColumns: [${foreignKey.referencedTable}.${foreignKey.referencedColumns.join(`, ${foreignKey.referencedTable}.`)}],
|
|
170
|
+
name: ${literal(foreignKey.name)}
|
|
171
|
+
}).onUpdate(${literal(foreignKey.onUpdate)}).onDelete(${literal(foreignKey.onDelete)})`);
|
|
172
|
+
}
|
|
173
|
+
for (const index of (table.indexes ?? []).filter((item) => schemaIndexAppliesToProvider(item, provider))) {
|
|
174
|
+
imports.add("index");
|
|
175
|
+
callbacks.push(`index(${literal(index.name)}).on(${index.columns.map((column) => `table.${column}`).join(", ")})`);
|
|
176
|
+
}
|
|
177
|
+
const args = [
|
|
178
|
+
literal(table.ormName),
|
|
179
|
+
`{\n${columns.join(",\n")}\n}`,
|
|
180
|
+
callbacks.length > 0 ? `(table) => [\n${callbacks.map((line) => ` ${line}`).join(",\n")}\n]` : void 0
|
|
181
|
+
].filter(Boolean);
|
|
182
|
+
return `export const ${table.ormName} = ${drizzleTableFn(provider)}(${args.join(", ")})`;
|
|
183
|
+
};
|
|
184
|
+
const drizzleRelations = (table) => {
|
|
185
|
+
if (!table.relations || table.relations.length === 0) return void 0;
|
|
186
|
+
const lines = table.relations.map((relation) => ` ${relation.targetFieldName}: one(${relation.referencedTable}, {
|
|
187
|
+
relationName: ${literal(relation.relationName)},
|
|
188
|
+
fields: [${relation.columns.map((column) => `${table.ormName}.${column}`).join(", ")}],
|
|
189
|
+
references: [${relation.referencedColumns.map((column) => `${relation.referencedTable}.${column}`).join(", ")}]
|
|
190
|
+
})`);
|
|
191
|
+
return `export const ${table.ormName}Relations = relations(${table.ormName}, ({ one }) => ({
|
|
192
|
+
${lines.join(",\n")}
|
|
193
|
+
}))`;
|
|
194
|
+
};
|
|
195
|
+
const generateDrizzleSchema = (provider, schema = hotUpdaterSchema) => {
|
|
196
|
+
const imports = new Set([drizzleTableFn(provider)]);
|
|
197
|
+
const body = [];
|
|
198
|
+
for (const table of schema.tables) {
|
|
199
|
+
body.push(drizzleTable(table, provider, imports));
|
|
200
|
+
const relations = drizzleRelations(table);
|
|
201
|
+
if (relations) body.push(relations);
|
|
202
|
+
}
|
|
203
|
+
if (body.some((block) => block.includes("relations("))) body.unshift("import { relations } from \"drizzle-orm\"");
|
|
204
|
+
return [`import { ${Array.from(imports).sort().join(", ")} } from "${drizzleImportSource(provider)}"`, ...body].join("\n\n");
|
|
205
|
+
};
|
|
206
|
+
const generateSchemaFromHotUpdaterSchema = (adapterName, provider, version, fallback) => {
|
|
207
|
+
const schema = version === "latest" ? hotUpdaterSchema : getHotUpdaterSchemaVersion(version);
|
|
208
|
+
if (adapterName === "prisma" && provider) return {
|
|
209
|
+
...fallback,
|
|
210
|
+
code: generatePrismaSchema(provider, schema)
|
|
211
|
+
};
|
|
212
|
+
const sqlProvider = getSQLProvider(provider);
|
|
213
|
+
if (adapterName === "drizzle" && sqlProvider) return {
|
|
214
|
+
...fallback,
|
|
215
|
+
code: generateDrizzleSchema(sqlProvider, schema)
|
|
216
|
+
};
|
|
217
|
+
return fallback;
|
|
218
|
+
};
|
|
219
|
+
//#endregion
|
|
220
|
+
export { generateDrizzleSchema, generatePrismaSchema, generateSchemaFromHotUpdaterSchema };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const require_types = require("../schema/types.cjs");
|
|
2
|
+
//#region src/db/schemaReadiness.ts
|
|
3
|
+
var HotUpdaterSchemaMigrationRequiredError = class extends Error {
|
|
4
|
+
constructor(adapterName, currentVersion) {
|
|
5
|
+
super(currentVersion === void 0 ? `Hot Updater database schema is not initialized for ${adapterName}. Run \`hot-updater db migrate\` before using this adapter.` : `Hot Updater database schema version ${currentVersion} is not supported by ${adapterName}. Run \`hot-updater db migrate\` to upgrade to ${require_types.HOT_UPDATER_SCHEMA_VERSION}.`);
|
|
6
|
+
this.adapterName = adapterName;
|
|
7
|
+
this.currentVersion = currentVersion;
|
|
8
|
+
this.name = "HotUpdaterSchemaMigrationRequiredError";
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
const createSchemaReadinessChecker = (adapterName, createMigrator) => {
|
|
12
|
+
if (!createMigrator) return async () => {};
|
|
13
|
+
let ready = false;
|
|
14
|
+
return async () => {
|
|
15
|
+
if (ready) return;
|
|
16
|
+
const version = await createMigrator().getVersion();
|
|
17
|
+
if (version !== "0.31.0") throw new HotUpdaterSchemaMigrationRequiredError(adapterName, version);
|
|
18
|
+
ready = true;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.HotUpdaterSchemaMigrationRequiredError = HotUpdaterSchemaMigrationRequiredError;
|
|
23
|
+
exports.createSchemaReadinessChecker = createSchemaReadinessChecker;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/db/schemaReadiness.d.ts
|
|
2
|
+
declare class HotUpdaterSchemaMigrationRequiredError extends Error {
|
|
3
|
+
readonly adapterName: string;
|
|
4
|
+
readonly currentVersion: string | undefined;
|
|
5
|
+
constructor(adapterName: string, currentVersion: string | undefined);
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { HotUpdaterSchemaMigrationRequiredError };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/db/schemaReadiness.d.ts
|
|
2
|
+
declare class HotUpdaterSchemaMigrationRequiredError extends Error {
|
|
3
|
+
readonly adapterName: string;
|
|
4
|
+
readonly currentVersion: string | undefined;
|
|
5
|
+
constructor(adapterName: string, currentVersion: string | undefined);
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { HotUpdaterSchemaMigrationRequiredError };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { HOT_UPDATER_SCHEMA_VERSION } from "../schema/types.mjs";
|
|
2
|
+
//#region src/db/schemaReadiness.ts
|
|
3
|
+
var HotUpdaterSchemaMigrationRequiredError = class extends Error {
|
|
4
|
+
constructor(adapterName, currentVersion) {
|
|
5
|
+
super(currentVersion === void 0 ? `Hot Updater database schema is not initialized for ${adapterName}. Run \`hot-updater db migrate\` before using this adapter.` : `Hot Updater database schema version ${currentVersion} is not supported by ${adapterName}. Run \`hot-updater db migrate\` to upgrade to ${HOT_UPDATER_SCHEMA_VERSION}.`);
|
|
6
|
+
this.adapterName = adapterName;
|
|
7
|
+
this.currentVersion = currentVersion;
|
|
8
|
+
this.name = "HotUpdaterSchemaMigrationRequiredError";
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
const createSchemaReadinessChecker = (adapterName, createMigrator) => {
|
|
12
|
+
if (!createMigrator) return async () => {};
|
|
13
|
+
let ready = false;
|
|
14
|
+
return async () => {
|
|
15
|
+
if (ready) return;
|
|
16
|
+
const version = await createMigrator().getVersion();
|
|
17
|
+
if (version !== "0.31.0") throw new HotUpdaterSchemaMigrationRequiredError(adapterName, version);
|
|
18
|
+
ready = true;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
//#endregion
|
|
22
|
+
export { HotUpdaterSchemaMigrationRequiredError, createSchemaReadinessChecker };
|
package/dist/db/types.cjs
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
const require_index = require("../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");
|
|
2
1
|
//#region src/db/types.ts
|
|
2
|
+
const sqlProviders = [
|
|
3
|
+
"sqlite",
|
|
4
|
+
"cockroachdb",
|
|
5
|
+
"mysql",
|
|
6
|
+
"postgresql",
|
|
7
|
+
"mssql"
|
|
8
|
+
];
|
|
9
|
+
const noSqlProviders = ["mongodb"];
|
|
10
|
+
[...sqlProviders, ...noSqlProviders];
|
|
3
11
|
function isDatabasePluginFactory(adapter) {
|
|
4
12
|
return typeof adapter === "function";
|
|
5
13
|
}
|
|
@@ -8,7 +16,7 @@ function isDatabasePlugin(adapter) {
|
|
|
8
16
|
}
|
|
9
17
|
function getSQLProvider(provider) {
|
|
10
18
|
if (!provider) return;
|
|
11
|
-
return
|
|
19
|
+
return sqlProviders.includes(provider) ? provider : void 0;
|
|
12
20
|
}
|
|
13
21
|
//#endregion
|
|
14
22
|
exports.getSQLProvider = getSQLProvider;
|
package/dist/db/types.d.cts
CHANGED
|
@@ -1,23 +1,67 @@
|
|
|
1
|
-
import { Provider } 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/index-CMqePMTF.cjs";
|
|
2
1
|
import { PaginatedResult } from "../types/index.cjs";
|
|
3
2
|
import { AppUpdateAvailableInfo, Bundle, GetBundlesArgs, UpdateInfo } from "@hot-updater/core";
|
|
4
3
|
import { DatabaseBundleQueryOptions, DatabasePlugin, HotUpdaterContext, RuntimeStoragePlugin } from "@hot-updater/plugin-core";
|
|
5
4
|
|
|
6
5
|
//#region src/db/types.d.ts
|
|
7
|
-
type DatabasePluginFactory<TContext = unknown> = () => DatabasePlugin<TContext>;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
type DatabasePluginFactory<TContext = unknown> = (() => DatabasePlugin<TContext>) & Partial<DatabaseAdapterCapabilities>;
|
|
7
|
+
declare const sqlProviders: readonly ["sqlite", "cockroachdb", "mysql", "postgresql", "mssql"];
|
|
8
|
+
declare const providers: readonly ["sqlite", "cockroachdb", "mysql", "postgresql", "mssql", "mongodb"];
|
|
9
|
+
type ORMProvider = (typeof providers)[number];
|
|
10
|
+
type ORMSQLProvider = (typeof sqlProviders)[number];
|
|
11
|
+
type RelationMode = "foreign-keys" | "fumadb";
|
|
12
|
+
interface MigrateOptions {
|
|
13
|
+
mode?: "from-schema" | "from-database";
|
|
14
|
+
updateSettings?: boolean;
|
|
15
|
+
unsafe?: boolean;
|
|
16
|
+
}
|
|
17
|
+
type MigrationOperation = {
|
|
18
|
+
type: "create-table";
|
|
19
|
+
value: {
|
|
20
|
+
ormName: string;
|
|
21
|
+
columns: Record<string, {
|
|
22
|
+
ormName: string;
|
|
23
|
+
type: string;
|
|
24
|
+
}>;
|
|
17
25
|
};
|
|
18
|
-
|
|
26
|
+
} | {
|
|
27
|
+
type: "custom";
|
|
28
|
+
sql: string;
|
|
29
|
+
} | {
|
|
30
|
+
type: "custom";
|
|
31
|
+
key: string;
|
|
32
|
+
value: unknown;
|
|
33
|
+
};
|
|
34
|
+
interface MigrationResult {
|
|
35
|
+
operations: MigrationOperation[];
|
|
36
|
+
execute: () => Promise<void>;
|
|
37
|
+
getSQL?: () => string;
|
|
38
|
+
}
|
|
39
|
+
interface Migrator {
|
|
40
|
+
getVersion: () => Promise<string | undefined>;
|
|
41
|
+
getNameVariants: () => Promise<unknown>;
|
|
42
|
+
next: () => Promise<{
|
|
43
|
+
version: string;
|
|
44
|
+
} | undefined>;
|
|
45
|
+
previous: () => Promise<{
|
|
46
|
+
version: string;
|
|
47
|
+
} | undefined>;
|
|
48
|
+
up: (options?: MigrateOptions) => Promise<MigrationResult>;
|
|
49
|
+
down: (options?: MigrateOptions) => Promise<MigrationResult>;
|
|
50
|
+
migrateTo: (version: string, options?: MigrateOptions) => Promise<MigrationResult>;
|
|
51
|
+
migrateToLatest: (options?: MigrateOptions) => Promise<MigrationResult>;
|
|
52
|
+
}
|
|
53
|
+
type SchemaGenerator = (version: string | "latest", name?: string) => {
|
|
54
|
+
code: string;
|
|
55
|
+
path: string;
|
|
56
|
+
};
|
|
57
|
+
interface DatabaseAdapterCapabilities {
|
|
58
|
+
adapterName?: string;
|
|
59
|
+
provider?: ORMProvider;
|
|
60
|
+
createMigrator?: () => Migrator;
|
|
61
|
+
generateSchema?: SchemaGenerator;
|
|
19
62
|
}
|
|
20
|
-
type
|
|
63
|
+
type DatabaseAdapterWithCapabilities<TContext = unknown> = DatabasePlugin<TContext> & DatabaseAdapterCapabilities;
|
|
64
|
+
type DatabaseAdapter<TContext = unknown> = DatabaseAdapterWithCapabilities<TContext> | DatabasePlugin<TContext> | DatabasePluginFactory<TContext>;
|
|
21
65
|
interface DatabaseAPI<TContext = unknown> {
|
|
22
66
|
getBundleById(id: string, context?: HotUpdaterContext<TContext>): Promise<Bundle | null>;
|
|
23
67
|
getUpdateInfo(args: GetBundlesArgs, context?: HotUpdaterContext<TContext>): Promise<UpdateInfo | null>;
|
|
@@ -30,4 +74,4 @@ interface DatabaseAPI<TContext = unknown> {
|
|
|
30
74
|
}
|
|
31
75
|
type StoragePluginFactory<TContext = unknown> = () => RuntimeStoragePlugin<TContext>;
|
|
32
76
|
//#endregion
|
|
33
|
-
export { DatabaseAPI, DatabaseAdapter,
|
|
77
|
+
export { DatabaseAPI, DatabaseAdapter, DatabasePluginFactory, Migrator, ORMProvider, ORMSQLProvider, RelationMode, SchemaGenerator, StoragePluginFactory };
|
package/dist/db/types.d.mts
CHANGED
|
@@ -1,23 +1,67 @@
|
|
|
1
|
-
import { Provider } 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/index-CMqePMTF.mjs";
|
|
2
1
|
import { PaginatedResult } from "../types/index.mjs";
|
|
3
2
|
import { DatabaseBundleQueryOptions, DatabasePlugin, HotUpdaterContext, RuntimeStoragePlugin } from "@hot-updater/plugin-core";
|
|
4
3
|
import { AppUpdateAvailableInfo, Bundle as Bundle$1, GetBundlesArgs, UpdateInfo } from "@hot-updater/core";
|
|
5
4
|
|
|
6
5
|
//#region src/db/types.d.ts
|
|
7
|
-
type DatabasePluginFactory<TContext = unknown> = () => DatabasePlugin<TContext>;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
type DatabasePluginFactory<TContext = unknown> = (() => DatabasePlugin<TContext>) & Partial<DatabaseAdapterCapabilities>;
|
|
7
|
+
declare const sqlProviders: readonly ["sqlite", "cockroachdb", "mysql", "postgresql", "mssql"];
|
|
8
|
+
declare const providers: readonly ["sqlite", "cockroachdb", "mysql", "postgresql", "mssql", "mongodb"];
|
|
9
|
+
type ORMProvider = (typeof providers)[number];
|
|
10
|
+
type ORMSQLProvider = (typeof sqlProviders)[number];
|
|
11
|
+
type RelationMode = "foreign-keys" | "fumadb";
|
|
12
|
+
interface MigrateOptions {
|
|
13
|
+
mode?: "from-schema" | "from-database";
|
|
14
|
+
updateSettings?: boolean;
|
|
15
|
+
unsafe?: boolean;
|
|
16
|
+
}
|
|
17
|
+
type MigrationOperation = {
|
|
18
|
+
type: "create-table";
|
|
19
|
+
value: {
|
|
20
|
+
ormName: string;
|
|
21
|
+
columns: Record<string, {
|
|
22
|
+
ormName: string;
|
|
23
|
+
type: string;
|
|
24
|
+
}>;
|
|
17
25
|
};
|
|
18
|
-
|
|
26
|
+
} | {
|
|
27
|
+
type: "custom";
|
|
28
|
+
sql: string;
|
|
29
|
+
} | {
|
|
30
|
+
type: "custom";
|
|
31
|
+
key: string;
|
|
32
|
+
value: unknown;
|
|
33
|
+
};
|
|
34
|
+
interface MigrationResult {
|
|
35
|
+
operations: MigrationOperation[];
|
|
36
|
+
execute: () => Promise<void>;
|
|
37
|
+
getSQL?: () => string;
|
|
38
|
+
}
|
|
39
|
+
interface Migrator {
|
|
40
|
+
getVersion: () => Promise<string | undefined>;
|
|
41
|
+
getNameVariants: () => Promise<unknown>;
|
|
42
|
+
next: () => Promise<{
|
|
43
|
+
version: string;
|
|
44
|
+
} | undefined>;
|
|
45
|
+
previous: () => Promise<{
|
|
46
|
+
version: string;
|
|
47
|
+
} | undefined>;
|
|
48
|
+
up: (options?: MigrateOptions) => Promise<MigrationResult>;
|
|
49
|
+
down: (options?: MigrateOptions) => Promise<MigrationResult>;
|
|
50
|
+
migrateTo: (version: string, options?: MigrateOptions) => Promise<MigrationResult>;
|
|
51
|
+
migrateToLatest: (options?: MigrateOptions) => Promise<MigrationResult>;
|
|
52
|
+
}
|
|
53
|
+
type SchemaGenerator = (version: string | "latest", name?: string) => {
|
|
54
|
+
code: string;
|
|
55
|
+
path: string;
|
|
56
|
+
};
|
|
57
|
+
interface DatabaseAdapterCapabilities {
|
|
58
|
+
adapterName?: string;
|
|
59
|
+
provider?: ORMProvider;
|
|
60
|
+
createMigrator?: () => Migrator;
|
|
61
|
+
generateSchema?: SchemaGenerator;
|
|
19
62
|
}
|
|
20
|
-
type
|
|
63
|
+
type DatabaseAdapterWithCapabilities<TContext = unknown> = DatabasePlugin<TContext> & DatabaseAdapterCapabilities;
|
|
64
|
+
type DatabaseAdapter<TContext = unknown> = DatabaseAdapterWithCapabilities<TContext> | DatabasePlugin<TContext> | DatabasePluginFactory<TContext>;
|
|
21
65
|
interface DatabaseAPI<TContext = unknown> {
|
|
22
66
|
getBundleById(id: string, context?: HotUpdaterContext<TContext>): Promise<Bundle$1 | null>;
|
|
23
67
|
getUpdateInfo(args: GetBundlesArgs, context?: HotUpdaterContext<TContext>): Promise<UpdateInfo | null>;
|
|
@@ -30,4 +74,4 @@ interface DatabaseAPI<TContext = unknown> {
|
|
|
30
74
|
}
|
|
31
75
|
type StoragePluginFactory<TContext = unknown> = () => RuntimeStoragePlugin<TContext>;
|
|
32
76
|
//#endregion
|
|
33
|
-
export { DatabaseAPI, DatabaseAdapter,
|
|
77
|
+
export { DatabaseAPI, DatabaseAdapter, DatabasePluginFactory, Migrator, ORMProvider, ORMSQLProvider, RelationMode, SchemaGenerator, StoragePluginFactory };
|
package/dist/db/types.mjs
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import { sqlProviders } 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/index.mjs";
|
|
2
1
|
//#region src/db/types.ts
|
|
2
|
+
const sqlProviders = [
|
|
3
|
+
"sqlite",
|
|
4
|
+
"cockroachdb",
|
|
5
|
+
"mysql",
|
|
6
|
+
"postgresql",
|
|
7
|
+
"mssql"
|
|
8
|
+
];
|
|
9
|
+
const noSqlProviders = ["mongodb"];
|
|
10
|
+
[...sqlProviders, ...noSqlProviders];
|
|
3
11
|
function isDatabasePluginFactory(adapter) {
|
|
4
12
|
return typeof adapter === "function";
|
|
5
13
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -2,10 +2,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_createBundleDiff = require("./db/createBundleDiff.cjs");
|
|
3
3
|
const require_version = require("./version.cjs");
|
|
4
4
|
const require_handler = require("./handler.cjs");
|
|
5
|
-
const
|
|
5
|
+
const require_schemaReadiness = require("./db/schemaReadiness.cjs");
|
|
6
6
|
const require_index = require("./db/index.cjs");
|
|
7
7
|
exports.HOT_UPDATER_SERVER_VERSION = require_version.HOT_UPDATER_SERVER_VERSION;
|
|
8
|
-
exports.
|
|
8
|
+
exports.HotUpdaterSchemaMigrationRequiredError = require_schemaReadiness.HotUpdaterSchemaMigrationRequiredError;
|
|
9
9
|
exports.createBundleDiff = require_createBundleDiff.createBundleDiff;
|
|
10
10
|
exports.createHandler = require_handler.createHandler;
|
|
11
11
|
exports.createHotUpdater = require_index.createHotUpdater;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { CreateBundleDiffDependencies, CreateBundleDiffInput, CreateBundleDiffOptions, createBundleDiff } from "./db/createBundleDiff.cjs";
|
|
2
2
|
import { HandlerAPI, HandlerOptions, HandlerRoutes, createHandler } from "./handler.cjs";
|
|
3
|
-
import {
|
|
3
|
+
import { HotUpdaterSchemaMigrationRequiredError } from "./db/schemaReadiness.cjs";
|
|
4
4
|
import { HOT_UPDATER_SERVER_VERSION } from "./version.cjs";
|
|
5
5
|
import { CreateHotUpdaterOptions, HotUpdaterAPI, createHotUpdater } from "./db/index.cjs";
|
|
6
6
|
import { Bundle, ChannelsResponse, DataResponse, Paginated, PaginatedResult, PaginationInfo, PaginationOptions } from "./types/index.cjs";
|
|
7
|
-
|
|
7
|
+
import { Migrator, SchemaGenerator } from "./db/types.cjs";
|
|
8
|
+
export { Bundle, ChannelsResponse, CreateBundleDiffDependencies, CreateBundleDiffInput, CreateBundleDiffOptions, CreateHotUpdaterOptions, DataResponse, HOT_UPDATER_SERVER_VERSION, HandlerAPI, HandlerOptions, HandlerRoutes, HotUpdaterAPI, HotUpdaterSchemaMigrationRequiredError, Migrator, Paginated, PaginatedResult, PaginationInfo, PaginationOptions, SchemaGenerator, createBundleDiff, createHandler, createHotUpdater };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { CreateBundleDiffDependencies, CreateBundleDiffInput, CreateBundleDiffOptions, createBundleDiff } from "./db/createBundleDiff.mjs";
|
|
2
2
|
import { HandlerAPI, HandlerOptions, HandlerRoutes, createHandler } from "./handler.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { HotUpdaterSchemaMigrationRequiredError } from "./db/schemaReadiness.mjs";
|
|
4
4
|
import { HOT_UPDATER_SERVER_VERSION } from "./version.mjs";
|
|
5
5
|
import { CreateHotUpdaterOptions, HotUpdaterAPI, createHotUpdater } from "./db/index.mjs";
|
|
6
6
|
import { Bundle, ChannelsResponse, DataResponse, Paginated, PaginatedResult, PaginationInfo, PaginationOptions } from "./types/index.mjs";
|
|
7
|
-
|
|
7
|
+
import { Migrator, SchemaGenerator } from "./db/types.mjs";
|
|
8
|
+
export { Bundle, ChannelsResponse, CreateBundleDiffDependencies, CreateBundleDiffInput, CreateBundleDiffOptions, CreateHotUpdaterOptions, DataResponse, HOT_UPDATER_SERVER_VERSION, HandlerAPI, HandlerOptions, HandlerRoutes, HotUpdaterAPI, HotUpdaterSchemaMigrationRequiredError, Migrator, Paginated, PaginatedResult, PaginationInfo, PaginationOptions, SchemaGenerator, createBundleDiff, createHandler, createHotUpdater };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createBundleDiff } from "./db/createBundleDiff.mjs";
|
|
2
2
|
import { HOT_UPDATER_SERVER_VERSION } from "./version.mjs";
|
|
3
3
|
import { createHandler } from "./handler.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { HotUpdaterSchemaMigrationRequiredError } from "./db/schemaReadiness.mjs";
|
|
5
5
|
import { createHotUpdater } from "./db/index.mjs";
|
|
6
|
-
export { HOT_UPDATER_SERVER_VERSION,
|
|
6
|
+
export { HOT_UPDATER_SERVER_VERSION, HotUpdaterSchemaMigrationRequiredError, createBundleDiff, createHandler, createHotUpdater };
|
package/dist/runtime.cjs
CHANGED
|
@@ -4,8 +4,9 @@ const require_version = 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("./db/types.cjs");
|
|
8
7
|
const require_pluginCore = require("./db/pluginCore.cjs");
|
|
8
|
+
const require_types = require("./db/types.cjs");
|
|
9
|
+
const require_schemaReadiness = require("./db/schemaReadiness.cjs");
|
|
9
10
|
let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
|
|
10
11
|
//#region src/runtime.ts
|
|
11
12
|
function createHotUpdater(options) {
|
|
@@ -17,11 +18,17 @@ function createHotUpdater(options) {
|
|
|
17
18
|
return storagePlugin;
|
|
18
19
|
}));
|
|
19
20
|
if (!require_types.isDatabasePluginFactory(database) && !require_types.isDatabasePlugin(database)) throw new Error("@hot-updater/server/runtime only supports database plugins.");
|
|
21
|
+
const capabilities = database;
|
|
20
22
|
const plugin = require_types.isDatabasePluginFactory(database) ? database() : database;
|
|
23
|
+
const assertSchemaReady = require_schemaReadiness.createSchemaReadinessChecker(capabilities.adapterName ?? plugin.name, capabilities.createMigrator);
|
|
21
24
|
const core = require_pluginCore.createPluginDatabaseCore(() => plugin, resolveFileUrl, require_types.isDatabasePluginFactory(database) ? {
|
|
22
25
|
createMutationPlugin: () => database(),
|
|
26
|
+
beforeOperation: assertSchemaReady,
|
|
23
27
|
readStorageText
|
|
24
|
-
} : {
|
|
28
|
+
} : {
|
|
29
|
+
beforeOperation: assertSchemaReady,
|
|
30
|
+
readStorageText
|
|
31
|
+
});
|
|
25
32
|
const internalHandler = require_handler.createHandler(core.api, {
|
|
26
33
|
basePath,
|
|
27
34
|
routes: options.routes
|
package/dist/runtime.mjs
CHANGED
|
@@ -2,8 +2,9 @@ import { HOT_UPDATER_SERVER_VERSION } from "./version.mjs";
|
|
|
2
2
|
import { createHandler } from "./handler.mjs";
|
|
3
3
|
import { normalizeBasePath } from "./route.mjs";
|
|
4
4
|
import { createStorageAccess } from "./storageAccess.mjs";
|
|
5
|
-
import { isDatabasePlugin, isDatabasePluginFactory } from "./db/types.mjs";
|
|
6
5
|
import { createPluginDatabaseCore } from "./db/pluginCore.mjs";
|
|
6
|
+
import { isDatabasePlugin, isDatabasePluginFactory } from "./db/types.mjs";
|
|
7
|
+
import { createSchemaReadinessChecker } from "./db/schemaReadiness.mjs";
|
|
7
8
|
import { assertRuntimeStoragePlugin } from "@hot-updater/plugin-core";
|
|
8
9
|
//#region src/runtime.ts
|
|
9
10
|
function createHotUpdater(options) {
|
|
@@ -15,11 +16,17 @@ function createHotUpdater(options) {
|
|
|
15
16
|
return storagePlugin;
|
|
16
17
|
}));
|
|
17
18
|
if (!isDatabasePluginFactory(database) && !isDatabasePlugin(database)) throw new Error("@hot-updater/server/runtime only supports database plugins.");
|
|
19
|
+
const capabilities = database;
|
|
18
20
|
const plugin = isDatabasePluginFactory(database) ? database() : database;
|
|
21
|
+
const assertSchemaReady = createSchemaReadinessChecker(capabilities.adapterName ?? plugin.name, capabilities.createMigrator);
|
|
19
22
|
const core = createPluginDatabaseCore(() => plugin, resolveFileUrl, isDatabasePluginFactory(database) ? {
|
|
20
23
|
createMutationPlugin: () => database(),
|
|
24
|
+
beforeOperation: assertSchemaReady,
|
|
21
25
|
readStorageText
|
|
22
|
-
} : {
|
|
26
|
+
} : {
|
|
27
|
+
beforeOperation: assertSchemaReady,
|
|
28
|
+
readStorageText
|
|
29
|
+
});
|
|
23
30
|
const internalHandler = createHandler(core.api, {
|
|
24
31
|
basePath,
|
|
25
32
|
routes: options.routes
|