@hot-updater/server 1.0.0-rc.1 → 1.0.0-rc.16
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 +1 -1
- package/dist/adapters/drizzle.cjs +35 -69
- package/dist/adapters/drizzle.d.cts +13 -6
- package/dist/adapters/drizzle.d.mts +13 -6
- package/dist/adapters/drizzle.mjs +34 -69
- package/dist/adapters/drizzleExecutor.cjs +114 -0
- package/dist/adapters/drizzleExecutor.d.cts +9 -0
- package/dist/adapters/drizzleExecutor.d.mts +9 -0
- package/dist/adapters/drizzleExecutor.mjs +112 -0
- package/dist/adapters/kysely.cjs +25 -31
- package/dist/adapters/kysely.d.cts +10 -7
- package/dist/adapters/kysely.d.mts +10 -7
- package/dist/adapters/kysely.mjs +25 -31
- package/dist/adapters/kyselyExecutor.cjs +32 -0
- package/dist/adapters/kyselyExecutor.d.cts +12 -0
- package/dist/adapters/kyselyExecutor.d.mts +12 -0
- package/dist/adapters/kyselyExecutor.mjs +32 -0
- package/dist/adapters/mongodb.cjs +28 -27
- package/dist/adapters/mongodb.d.cts +10 -5
- package/dist/adapters/mongodb.d.mts +10 -5
- package/dist/adapters/mongodb.mjs +28 -27
- package/dist/adapters/mongodbAdapter.cjs +174 -0
- package/dist/adapters/mongodbAdapter.d.cts +9 -0
- package/dist/adapters/mongodbAdapter.d.mts +9 -0
- package/dist/adapters/mongodbAdapter.mjs +173 -0
- package/dist/adapters/prisma.cjs +38 -220
- package/dist/adapters/prisma.d.cts +12 -8
- package/dist/adapters/prisma.d.mts +12 -8
- package/dist/adapters/prisma.mjs +38 -219
- package/dist/adapters/prismaExecutor.cjs +64 -0
- package/dist/adapters/prismaExecutor.mjs +64 -0
- package/dist/adapters/sqlProviders.cjs +9 -0
- package/dist/adapters/sqlProviders.mjs +9 -0
- package/dist/apiKeys.cjs +8 -8
- package/dist/apiKeys.d.cts +1 -24
- package/dist/apiKeys.d.mts +1 -24
- package/dist/apiKeys.mjs +5 -9
- package/dist/assembly/assemblePlugins.cjs +147 -0
- package/dist/assembly/assemblePlugins.d.cts +12 -0
- package/dist/assembly/assemblePlugins.d.mts +12 -0
- package/dist/assembly/assemblePlugins.mjs +146 -0
- package/dist/assembly/databasePlugins.cjs +23 -0
- package/dist/assembly/databasePlugins.d.cts +43 -0
- package/dist/assembly/databasePlugins.d.mts +43 -0
- package/dist/assembly/databasePlugins.mjs +22 -0
- package/dist/core/api.cjs +91 -0
- package/dist/core/api.d.cts +65 -0
- package/dist/core/api.d.mts +65 -0
- package/dist/core/api.mjs +87 -0
- package/dist/core/baseCandidates.cjs +71 -0
- package/dist/core/baseCandidates.d.cts +17 -0
- package/dist/core/baseCandidates.d.mts +17 -0
- package/dist/core/baseCandidates.mjs +69 -0
- package/dist/core/operations.cjs +350 -0
- package/dist/core/operations.mjs +350 -0
- package/dist/core/reads.cjs +273 -0
- package/dist/core/reads.d.cts +48 -0
- package/dist/core/reads.d.mts +48 -0
- package/dist/core/reads.mjs +267 -0
- package/dist/core/releases.cjs +193 -0
- package/dist/core/releases.mjs +190 -0
- package/dist/core/schema.cjs +279 -0
- package/dist/core/schema.d.cts +307 -0
- package/dist/core/schema.d.mts +307 -0
- package/dist/core/schema.mjs +277 -0
- package/dist/core/writes.cjs +96 -0
- package/dist/core/writes.mjs +91 -0
- package/dist/createHotUpdaterCore.cjs +61 -63
- package/dist/createHotUpdaterCore.d.cts +53 -45
- package/dist/createHotUpdaterCore.d.mts +53 -45
- package/dist/createHotUpdaterCore.mjs +61 -63
- package/dist/database/cursor.cjs +44 -0
- package/dist/database/cursor.d.cts +7 -0
- package/dist/database/cursor.d.mts +7 -0
- package/dist/database/cursor.mjs +40 -0
- package/dist/database/database.cjs +44 -0
- package/dist/database/database.d.cts +123 -0
- package/dist/database/database.d.mts +123 -0
- package/dist/database/database.mjs +44 -0
- package/dist/database/definitions.d.cts +68 -0
- package/dist/database/definitions.d.mts +68 -0
- package/dist/database/engine.cjs +37 -0
- package/dist/database/engine.d.cts +40 -0
- package/dist/database/engine.d.mts +40 -0
- package/dist/database/engine.mjs +37 -0
- package/dist/database/engineAggregates.cjs +115 -0
- package/dist/database/engineAggregates.mjs +112 -0
- package/dist/database/engineReads.cjs +180 -0
- package/dist/database/engineReads.d.cts +35 -0
- package/dist/database/engineReads.d.mts +35 -0
- package/dist/database/engineReads.mjs +179 -0
- package/dist/database/engineTransaction.cjs +403 -0
- package/dist/database/engineTransaction.d.cts +26 -0
- package/dist/database/engineTransaction.d.mts +26 -0
- package/dist/database/engineTransaction.mjs +402 -0
- package/dist/database/errors.cjs +27 -0
- package/dist/database/errors.d.cts +21 -0
- package/dist/database/errors.d.mts +21 -0
- package/dist/database/errors.mjs +24 -0
- package/dist/database/fence.cjs +124 -0
- package/dist/database/fence.d.cts +42 -0
- package/dist/database/fence.d.mts +42 -0
- package/dist/database/fence.mjs +116 -0
- package/dist/database/index.cjs +127 -0
- package/dist/database/index.d.cts +17 -0
- package/dist/database/index.d.mts +17 -0
- package/dist/database/index.mjs +15 -0
- package/dist/database/kv/kvAdapter.cjs +273 -0
- package/dist/database/kv/kvAdapter.d.cts +101 -0
- package/dist/database/kv/kvAdapter.d.mts +101 -0
- package/dist/database/kv/kvAdapter.mjs +272 -0
- package/dist/database/resolveSchema.cjs +196 -0
- package/dist/database/resolveSchema.d.cts +42 -0
- package/dist/database/resolveSchema.d.mts +42 -0
- package/dist/database/resolveSchema.mjs +193 -0
- package/dist/database/schema.cjs +21 -0
- package/dist/database/schema.d.cts +61 -0
- package/dist/database/schema.d.mts +61 -0
- package/dist/database/schema.mjs +20 -0
- package/dist/database/sql/sqlAdapter.cjs +282 -0
- package/dist/database/sql/sqlAdapter.d.cts +46 -0
- package/dist/database/sql/sqlAdapter.d.mts +46 -0
- package/dist/database/sql/sqlAdapter.mjs +279 -0
- package/dist/database/sql/sqlSchema.cjs +115 -0
- package/dist/database/sql/sqlSchema.d.cts +8 -0
- package/dist/database/sql/sqlSchema.d.mts +8 -0
- package/dist/database/sql/sqlSchema.mjs +111 -0
- package/dist/db/builtInDatabase.cjs +104 -0
- package/dist/db/builtInDatabase.d.cts +38 -0
- package/dist/db/builtInDatabase.d.mts +38 -0
- package/dist/db/builtInDatabase.mjs +97 -0
- package/dist/db/createBundleDiff.cjs +6 -6
- package/dist/db/createBundleDiff.d.cts +4 -7
- package/dist/db/createBundleDiff.d.mts +4 -7
- package/dist/db/createBundleDiff.mjs +5 -5
- package/dist/db/engineDrizzleSchema.cjs +54 -0
- package/dist/db/engineDrizzleSchema.mjs +54 -0
- package/dist/db/engineMigrator.cjs +53 -0
- package/dist/db/engineMigrator.mjs +53 -0
- package/dist/db/enginePrismaSchema.cjs +85 -0
- package/dist/db/enginePrismaSchema.d.cts +5 -0
- package/dist/db/enginePrismaSchema.d.mts +5 -0
- package/dist/db/enginePrismaSchema.mjs +84 -0
- package/dist/db/engineSql.cjs +26 -0
- package/dist/db/engineSql.d.cts +17 -0
- package/dist/db/engineSql.d.mts +17 -0
- package/dist/db/engineSql.mjs +25 -0
- package/dist/db/engineSqlMigrator.cjs +66 -0
- package/dist/db/engineSqlMigrator.mjs +66 -0
- package/dist/db/fixedMigratorShared.cjs +0 -11
- package/dist/db/fixedMigratorShared.mjs +1 -8
- package/dist/db/index.cjs +23 -8
- package/dist/db/index.d.cts +10 -4
- package/dist/db/index.d.mts +10 -4
- package/dist/db/index.mjs +16 -8
- package/dist/db/releaseCatalog.cjs +20 -44
- package/dist/db/releaseCatalog.d.cts +2 -3
- package/dist/db/releaseCatalog.d.mts +2 -3
- package/dist/db/releaseCatalog.mjs +20 -44
- package/dist/db/schemaSettings.cjs +63 -0
- package/dist/db/schemaSettings.d.cts +12 -0
- package/dist/db/schemaSettings.d.mts +12 -0
- package/dist/db/schemaSettings.mjs +62 -0
- package/dist/db/settingsMigrator.cjs +92 -0
- package/dist/db/settingsMigrator.mjs +89 -0
- package/dist/db/types.cjs +3 -12
- package/dist/db/types.d.cts +26 -69
- package/dist/db/types.d.mts +26 -69
- package/dist/db/types.mjs +2 -11
- package/dist/db/updateArtifacts.cjs +38 -68
- package/dist/db/updateArtifacts.mjs +40 -69
- package/dist/handler.cjs +72 -43
- package/dist/handler.d.cts +3 -6
- package/dist/handler.d.mts +3 -6
- package/dist/handler.mjs +73 -43
- package/dist/handlerAdminRoutes.cjs +375 -0
- package/dist/handlerAdminRoutes.mjs +373 -0
- package/dist/handlerParameters.cjs +6 -11
- package/dist/handlerParameters.mjs +6 -10
- package/dist/handlerReleaseCatalogRoutes.cjs +11 -14
- package/dist/handlerReleaseCatalogRoutes.mjs +11 -13
- package/dist/handlerTypes.d.cts +2 -56
- package/dist/handlerTypes.d.mts +2 -56
- package/dist/handlerVersionRoutes.cjs +20 -4
- package/dist/handlerVersionRoutes.d.cts +1 -0
- package/dist/handlerVersionRoutes.d.mts +1 -0
- package/dist/handlerVersionRoutes.mjs +20 -4
- package/dist/index.cjs +4 -7
- package/dist/index.d.cts +10 -9
- package/dist/index.d.mts +10 -9
- package/dist/index.mjs +4 -4
- package/dist/insights/domain.d.cts +53 -70
- package/dist/insights/domain.d.mts +53 -70
- package/dist/insights/errors.cjs +35 -8
- package/dist/insights/errors.mjs +35 -8
- package/dist/insights/eventInput.cjs +64 -24
- package/dist/insights/eventInput.mjs +63 -25
- package/dist/insights/provider.cjs +356 -0
- package/dist/insights/provider.d.cts +6 -0
- package/dist/insights/provider.d.mts +6 -0
- package/dist/insights/provider.mjs +355 -0
- package/dist/insights/queryInput.cjs +78 -43
- package/dist/insights/queryInput.mjs +76 -40
- package/dist/insights/routes.cjs +94 -34
- package/dist/insights/routes.mjs +93 -35
- package/dist/insights/types.d.cts +27 -12
- package/dist/insights/types.d.mts +27 -12
- package/dist/node.d.cts +1 -2
- package/dist/node.d.mts +1 -2
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/plugins/api-keys/index.cjs +50 -0
- package/dist/plugins/api-keys/index.d.cts +85 -0
- package/dist/plugins/api-keys/index.d.mts +85 -0
- package/dist/plugins/api-keys/index.mjs +47 -0
- package/dist/plugins/api-keys/model.cjs +58 -0
- package/dist/plugins/api-keys/model.d.cts +8 -0
- package/dist/plugins/api-keys/model.d.mts +8 -0
- package/dist/plugins/api-keys/model.mjs +58 -0
- package/dist/plugins/api-keys/schema.cjs +38 -0
- package/dist/plugins/api-keys/schema.d.cts +44 -0
- package/dist/plugins/api-keys/schema.d.mts +44 -0
- package/dist/plugins/api-keys/schema.mjs +39 -0
- package/dist/plugins/builtIn.cjs +7 -0
- package/dist/plugins/builtIn.mjs +6 -0
- package/dist/plugins/definePlugin.cjs +5 -0
- package/dist/plugins/definePlugin.d.cts +73 -0
- package/dist/plugins/definePlugin.d.mts +73 -0
- package/dist/plugins/definePlugin.mjs +5 -0
- package/dist/plugins/index.cjs +17 -0
- package/dist/plugins/index.d.cts +9 -0
- package/dist/plugins/index.d.mts +9 -0
- package/dist/plugins/index.mjs +7 -0
- package/dist/plugins/insights/index.cjs +48 -0
- package/dist/plugins/insights/index.d.cts +295 -0
- package/dist/plugins/insights/index.d.mts +295 -0
- package/dist/plugins/insights/index.mjs +44 -0
- package/dist/plugins/insights/model.cjs +17 -0
- package/dist/plugins/insights/model.d.cts +10 -0
- package/dist/plugins/insights/model.d.mts +10 -0
- package/dist/plugins/insights/model.mjs +17 -0
- package/dist/plugins/insights/reads.cjs +471 -0
- package/dist/plugins/insights/reads.mjs +466 -0
- package/dist/plugins/insights/recordEvent.cjs +135 -0
- package/dist/plugins/insights/recordEvent.d.cts +13 -0
- package/dist/plugins/insights/recordEvent.d.mts +13 -0
- package/dist/plugins/insights/recordEvent.mjs +132 -0
- package/dist/plugins/insights/schema.cjs +347 -0
- package/dist/plugins/insights/schema.d.cts +258 -0
- package/dist/plugins/insights/schema.d.mts +258 -0
- package/dist/plugins/insights/schema.mjs +344 -0
- package/dist/storageAccess.cjs +0 -1
- package/dist/types/index.d.cts +2 -29
- package/dist/types/index.d.mts +2 -29
- package/package.json +30 -7
- package/src/adapters/drizzle.conformance.integration.spec.ts +34 -0
- package/src/adapters/drizzle.readBudgets.integration.spec.ts +41 -0
- package/src/adapters/drizzle.spec.ts +277 -208
- package/src/adapters/drizzle.ts +48 -128
- package/src/adapters/drizzleExecutor.ts +166 -0
- package/src/adapters/kysely.conformance.integration.spec.ts +36 -0
- package/src/adapters/kysely.readBudgets.integration.spec.ts +42 -0
- package/src/adapters/kysely.spec.ts +212 -117
- package/src/adapters/kysely.ts +32 -87
- package/src/adapters/kyselyExecutor.ts +53 -0
- package/src/adapters/mongodb.integration.spec.ts +180 -0
- package/src/adapters/mongodb.readBudgets.integration.spec.ts +61 -0
- package/src/adapters/mongodb.ts +36 -65
- package/src/adapters/mongodbAdapter.ts +293 -0
- package/src/adapters/prisma.conformance.integration.spec.ts +36 -0
- package/src/adapters/prisma.integration.spec.ts +138 -0
- package/src/adapters/prisma.readBudgets.integration.spec.ts +40 -0
- package/src/adapters/prisma.spec.ts +226 -173
- package/src/adapters/prisma.ts +60 -451
- package/src/adapters/prismaExecutor.ts +107 -0
- package/src/adapters/prismaTestClients.ts +175 -0
- package/src/adapters/sqlProviders.ts +14 -0
- package/src/apiKeys.integration.spec.ts +19 -119
- package/src/apiKeys.spec.ts +39 -35
- package/src/apiKeys.ts +2 -8
- package/src/assembly/assemblePlugins.ts +269 -0
- package/src/assembly/assembly.spec.ts +325 -0
- package/src/assembly/assembly.types.spec.ts +155 -0
- package/src/assembly/builtInRoutes.spec.ts +213 -0
- package/src/assembly/databasePlugins.spec.ts +71 -0
- package/src/assembly/databasePlugins.ts +96 -0
- package/src/core/api.ts +139 -0
- package/src/core/baseCandidates.spec.ts +378 -0
- package/src/core/baseCandidates.ts +136 -0
- package/src/core/index.ts +44 -0
- package/src/core/operations.spec.ts +415 -0
- package/src/core/operations.ts +551 -0
- package/src/core/reads.spec.ts +300 -0
- package/src/core/reads.ts +417 -0
- package/src/core/releases.spec.ts +308 -0
- package/src/core/releases.ts +345 -0
- package/src/core/schema.ts +173 -0
- package/src/core/writes.ts +160 -0
- package/src/createHotUpdaterCore.ts +191 -167
- package/src/database/cursor.ts +65 -0
- package/src/database/database.ts +335 -0
- package/src/database/database.types.spec.ts +135 -0
- package/src/database/definitions.ts +72 -0
- package/src/database/engine.ts +62 -0
- package/src/database/engineAggregates.spec.ts +539 -0
- package/src/database/engineAggregates.ts +193 -0
- package/src/database/engineReads.spec.ts +219 -0
- package/src/database/engineReads.ts +302 -0
- package/src/database/engineTransaction.spec.ts +710 -0
- package/src/database/engineTransaction.ts +588 -0
- package/src/database/errors.ts +30 -0
- package/src/database/fence.spec.ts +223 -0
- package/src/database/fence.ts +171 -0
- package/src/database/index.ts +154 -0
- package/src/database/kv/kvAdapter.conformance.integration.spec.ts +17 -0
- package/src/database/kv/kvAdapter.readBudgets.integration.spec.ts +17 -0
- package/src/database/kv/kvAdapter.spec.ts +468 -0
- package/src/database/kv/kvAdapter.ts +450 -0
- package/src/database/kv/kvTestStore.ts +91 -0
- package/src/database/memory.readBudgets.integration.spec.ts +13 -0
- package/src/database/resolveSchema.spec.ts +230 -0
- package/src/database/resolveSchema.ts +372 -0
- package/src/database/schema.ts +169 -0
- package/src/database/schema.types.spec.ts +94 -0
- package/src/database/sql/docker-compose.yml +36 -0
- package/src/database/sql/sqlAdapter.integration.spec.ts +148 -0
- package/src/database/sql/sqlAdapter.readBudgets.integration.spec.ts +109 -0
- package/src/database/sql/sqlAdapter.spec.ts +255 -0
- package/src/database/sql/sqlAdapter.ts +532 -0
- package/src/database/sql/sqlSchema.ts +205 -0
- package/src/database/sql/sqlTestExecutors.ts +183 -0
- package/src/databaseTestSuite.spec.ts +39 -0
- package/src/db/builtInDatabase.ts +149 -0
- package/src/db/bundleRows.spec.ts +3 -3
- package/src/db/createBundleDiff.spec.ts +43 -29
- package/src/db/createBundleDiff.ts +13 -7
- package/src/db/engineDrizzleSchema.ts +72 -0
- package/src/db/engineMigrator.ts +105 -0
- package/src/db/enginePrismaSchema.ts +147 -0
- package/src/db/engineSql.spec.ts +129 -0
- package/src/db/engineSql.ts +48 -0
- package/src/db/engineSqlMigrator.ts +116 -0
- package/src/db/fixedMigratorShared.ts +1 -20
- package/src/db/index.spec.ts +116 -824
- package/src/db/index.ts +43 -14
- package/src/db/pluginTables.spec.ts +218 -0
- package/src/db/releaseCatalog.ts +48 -90
- package/src/db/schemaSettings.ts +104 -0
- package/src/db/settingsMigrator.spec.ts +65 -0
- package/src/db/settingsMigrator.ts +152 -0
- package/src/db/types.ts +25 -165
- package/src/db/updateArtifacts.spec.ts +170 -294
- package/src/db/updateArtifacts.ts +74 -142
- package/src/db/updateCheck.bench.ts +47 -0
- package/src/handler-standalone.integration.spec.ts +204 -412
- package/src/handler.spec.ts +134 -51
- package/src/handler.testFixtures.ts +14 -19
- package/src/handler.ts +163 -75
- package/src/handlerAdminRoutes.spec.ts +183 -0
- package/src/handlerAdminRoutes.ts +536 -0
- package/src/handlerAuth.integration.spec.ts +3 -3
- package/src/handlerManagement.spec.ts +136 -196
- package/src/handlerReleaseCatalogRoutes.ts +15 -17
- package/src/handlerTypes.ts +3 -80
- package/src/handlerVersionRoutes.ts +20 -7
- package/src/index.ts +7 -14
- package/src/insights/domain.ts +56 -77
- package/src/insights/errors.spec.ts +48 -0
- package/src/insights/errors.ts +50 -6
- package/src/insights/eventInput.ts +80 -27
- package/src/insights/insights.integration.spec.ts +525 -44
- package/src/insights/provider.spec.ts +574 -0
- package/src/insights/provider.ts +667 -0
- package/src/insights/queryInput.ts +113 -73
- package/src/insights/routes.ts +125 -69
- package/src/insights/types.ts +47 -36
- package/src/lintRules.spec.ts +76 -0
- package/src/plugins/api-keys/apiKeysPlugin.spec.ts +172 -0
- package/src/plugins/api-keys/index.ts +66 -0
- package/src/plugins/api-keys/model.ts +69 -0
- package/src/plugins/api-keys/schema.ts +22 -0
- package/src/plugins/builtIn.ts +5 -0
- package/src/plugins/definePlugin.ts +100 -0
- package/src/plugins/index.ts +55 -0
- package/src/plugins/insights/index.ts +86 -0
- package/src/plugins/insights/insightsRollout.integration.spec.ts +187 -0
- package/src/plugins/insights/model.spec.ts +66 -0
- package/src/plugins/insights/model.ts +19 -0
- package/src/plugins/insights/reads.spec.ts +725 -0
- package/src/plugins/insights/reads.ts +707 -0
- package/src/plugins/insights/recordEvent.spec.ts +443 -0
- package/src/plugins/insights/recordEvent.ts +238 -0
- package/src/plugins/insights/schema.ts +229 -0
- package/src/plugins/pluginTestHarness.spec.ts +56 -0
- package/src/readBudgets.testFixtures.ts +15 -0
- package/src/releaseCatalogRoutes.integration.spec.ts +47 -92
- package/src/runtime.spec.ts +91 -77
- package/src/runtime.testFixtures.ts +28 -44
- package/src/runtimeBundles.integration.spec.ts +112 -0
- package/src/testUtilsMutation.integration.spec.ts +215 -0
- package/src/testUtilsPackage.integration.spec.ts +176 -0
- package/src/types/index.ts +0 -32
- package/dist/adapters/databaseConstraintErrors.cjs +0 -23
- package/dist/adapters/databaseConstraintErrors.mjs +0 -21
- package/dist/adapters/databasePluginUtils.cjs +0 -117
- package/dist/adapters/databasePluginUtils.mjs +0 -106
- package/dist/adapters/drizzleCrud.cjs +0 -250
- package/dist/adapters/drizzleCrud.mjs +0 -249
- package/dist/adapters/drizzleLazyDB.cjs +0 -101
- package/dist/adapters/drizzleLazyDB.mjs +0 -101
- package/dist/adapters/drizzleQuery.cjs +0 -68
- package/dist/adapters/drizzleQuery.mjs +0 -67
- package/dist/adapters/kyselyCrud.cjs +0 -254
- package/dist/adapters/kyselyCrud.mjs +0 -253
- package/dist/adapters/kyselyQuery.cjs +0 -56
- package/dist/adapters/kyselyQuery.mjs +0 -55
- package/dist/adapters/mongodbCollections.cjs +0 -36
- package/dist/adapters/mongodbCollections.mjs +0 -30
- package/dist/adapters/mongodbQuery.cjs +0 -77
- package/dist/adapters/mongodbQuery.mjs +0 -70
- package/dist/adapters/mongodbReads.cjs +0 -148
- package/dist/adapters/mongodbReads.mjs +0 -147
- package/dist/adapters/mongodbWrites.cjs +0 -134
- package/dist/adapters/mongodbWrites.mjs +0 -133
- package/dist/adapters/prismaQuery.cjs +0 -58
- package/dist/adapters/prismaQuery.mjs +0 -56
- package/dist/adapters/prismaRows.cjs +0 -198
- package/dist/adapters/prismaRows.mjs +0 -188
- package/dist/db/databasePluginCore.cjs +0 -138
- package/dist/db/databasePluginCore.mjs +0 -137
- package/dist/db/fixedMigrator.cjs +0 -79
- package/dist/db/fixedMigrator.mjs +0 -78
- package/dist/db/fixedMigratorMongo.cjs +0 -319
- package/dist/db/fixedMigratorMongo.mjs +0 -319
- package/dist/db/mongoMigrationExecution.cjs +0 -11
- package/dist/db/mongoMigrationExecution.mjs +0 -11
- package/dist/db/schema/mongodb.cjs +0 -25
- package/dist/db/schema/mongodb.mjs +0 -25
- package/dist/db/schema/registry.cjs +0 -21
- package/dist/db/schema/registry.mjs +0 -17
- package/dist/db/schema/sql.cjs +0 -101
- package/dist/db/schema/sql.mjs +0 -97
- package/dist/db/schema/sqlOperations.cjs +0 -27
- package/dist/db/schema/sqlOperations.mjs +0 -26
- package/dist/db/schemaGenerators.cjs +0 -256
- package/dist/db/schemaGenerators.mjs +0 -254
- package/dist/db/schemaReadiness.cjs +0 -24
- package/dist/db/schemaReadiness.d.cts +0 -8
- package/dist/db/schemaReadiness.d.mts +0 -8
- package/dist/db/schemaReadiness.mjs +0 -23
- package/dist/db/sqlMigrationExecution.cjs +0 -67
- package/dist/db/sqlMigrationExecution.mjs +0 -66
- package/dist/handlerBundleRoutes.cjs +0 -155
- package/dist/handlerBundleRoutes.mjs +0 -155
- package/dist/handlerReleaseManagementRoutes.cjs +0 -125
- package/dist/handlerReleaseManagementRoutes.mjs +0 -124
- package/dist/insights/bounded/activeOverview.cjs +0 -87
- package/dist/insights/bounded/activeOverview.mjs +0 -85
- package/dist/insights/bounded/installationSearch.cjs +0 -42
- package/dist/insights/bounded/installationSearch.mjs +0 -42
- package/dist/insights/bounded/persistence.cjs +0 -39
- package/dist/insights/bounded/persistence.mjs +0 -38
- package/dist/insights/bounded/provider.cjs +0 -170
- package/dist/insights/bounded/provider.d.cts +0 -7
- package/dist/insights/bounded/provider.d.mts +0 -7
- package/dist/insights/bounded/provider.mjs +0 -170
- package/dist/insights/bounded/scan.cjs +0 -144
- package/dist/insights/bounded/scan.mjs +0 -138
- package/dist/insights/persistence.d.cts +0 -6
- package/dist/insights/persistence.d.mts +0 -6
- package/dist/schema/dsl.cjs +0 -103
- package/dist/schema/dsl.mjs +0 -87
- package/dist/schema/index.cjs +0 -6
- package/dist/schema/index.mjs +0 -7
- package/dist/schema/settings.cjs +0 -9
- package/dist/schema/settings.mjs +0 -9
- package/dist/schema/types.cjs +0 -8
- package/dist/schema/types.mjs +0 -6
- package/dist/schema/v1_0_0.cjs +0 -364
- package/dist/schema/v1_0_0.mjs +0 -357
- package/src/adapters/databaseConstraintErrors.ts +0 -25
- package/src/adapters/databasePluginTestDatabase.ts +0 -106
- package/src/adapters/databasePluginUtils.spec.ts +0 -29
- package/src/adapters/databasePluginUtils.ts +0 -214
- package/src/adapters/drizzleCrud.ts +0 -419
- package/src/adapters/drizzleLazyDB.ts +0 -257
- package/src/adapters/drizzleQuery.ts +0 -164
- package/src/adapters/kyselyCrud.ts +0 -588
- package/src/adapters/kyselyQuery.ts +0 -128
- package/src/adapters/mongodb.spec.ts +0 -141
- package/src/adapters/mongodbCollections.ts +0 -62
- package/src/adapters/mongodbQuery.ts +0 -226
- package/src/adapters/mongodbReads.ts +0 -311
- package/src/adapters/mongodbRows.spec.ts +0 -64
- package/src/adapters/mongodbRows.ts +0 -118
- package/src/adapters/mongodbTestClient.ts +0 -342
- package/src/adapters/mongodbTestFilter.ts +0 -166
- package/src/adapters/mongodbWrites.ts +0 -260
- package/src/adapters/prismaQuery.ts +0 -129
- package/src/adapters/prismaRows.spec.ts +0 -98
- package/src/adapters/prismaRows.ts +0 -301
- package/src/adapters/prismaTestClient.ts +0 -396
- package/src/calculatePagination.ts +0 -34
- package/src/db/databasePluginCore.spec.ts +0 -62
- package/src/db/databasePluginCore.testFixtures.ts +0 -76
- package/src/db/databasePluginCore.ts +0 -185
- package/src/db/databasePluginUpdateCheck.bench.ts +0 -107
- package/src/db/fixedMigrator.spec.ts +0 -231
- package/src/db/fixedMigrator.ts +0 -147
- package/src/db/fixedMigratorMongo.spec.ts +0 -192
- package/src/db/fixedMigratorMongo.ts +0 -425
- package/src/db/hotUpdaterSchema.ts +0 -5
- package/src/db/mongoMigrationExecution.ts +0 -23
- package/src/db/schema/definitions.ts +0 -1
- package/src/db/schema/mongodb.ts +0 -40
- package/src/db/schema/registry.ts +0 -55
- package/src/db/schema/sql.ts +0 -241
- package/src/db/schema/sqlOperations.ts +0 -63
- package/src/db/schema/types.ts +0 -1
- package/src/db/schemaGenerators.ts +0 -466
- package/src/db/schemaReadiness.ts +0 -34
- package/src/db/sqlMigrationExecution.spec.ts +0 -65
- package/src/db/sqlMigrationExecution.ts +0 -108
- package/src/db/types.spec.ts +0 -55
- package/src/handlerBundleRoutes.ts +0 -259
- package/src/handlerReleaseManagementRoutes.ts +0 -213
- package/src/insights/bounded/activeOverview.spec.ts +0 -189
- package/src/insights/bounded/activeOverview.ts +0 -148
- package/src/insights/bounded/installationSearch.spec.ts +0 -130
- package/src/insights/bounded/installationSearch.ts +0 -69
- package/src/insights/bounded/persistence.ts +0 -43
- package/src/insights/bounded/provider.spec.ts +0 -219
- package/src/insights/bounded/provider.ts +0 -229
- package/src/insights/bounded/scan.ts +0 -235
- package/src/insights/persistence.ts +0 -10
- package/src/schema/dsl-all-versions.spec.ts +0 -35
- package/src/schema/dsl.ts +0 -187
- package/src/schema/index.ts +0 -10
- package/src/schema/settings.ts +0 -15
- package/src/schema/types.ts +0 -79
- package/src/schema/v1_0_0.spec.ts +0 -146
- package/src/schema/v1_0_0.ts +0 -465
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { HOT_UPDATER_SCHEMA_VERSION } from "../core/schema.mjs";
|
|
2
|
+
import { ENGINE_SCHEMA_KEY, HotUpdaterSchemaMigrationRequiredError, SETTINGS_TABLE, isMissingSchemaError } from "../database/fence.mjs";
|
|
3
|
+
import { assertSupportedMigrationMode, getEmptyMigrationResult } from "./fixedMigratorShared.mjs";
|
|
4
|
+
import { quoteSql } from "../database/sql/sqlSchema.mjs";
|
|
5
|
+
import { settingsStatements } from "./engineSql.mjs";
|
|
6
|
+
//#region src/db/settingsMigrator.ts
|
|
7
|
+
/**
|
|
8
|
+
* Every settings row by key and value alone, so a v0 layout reads too; null
|
|
9
|
+
* when the settings table is missing.
|
|
10
|
+
*/
|
|
11
|
+
const readStoredSettings = async (executor, tablePrefix = "") => {
|
|
12
|
+
const quote = (name) => quoteSql(executor.dialect, name);
|
|
13
|
+
try {
|
|
14
|
+
const { rows } = await executor.execute({
|
|
15
|
+
sql: `SELECT ${quote("key")}, ${quote("value")} FROM ${quote(tablePrefix + SETTINGS_TABLE.name)}`,
|
|
16
|
+
params: []
|
|
17
|
+
});
|
|
18
|
+
return new Map(rows.map((row) => [String(row.key), row.value]));
|
|
19
|
+
} catch (error) {
|
|
20
|
+
if (!isMissingSchemaError(error)) throw error;
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
/** `schema.core`, or a v0 database's `version`. */
|
|
25
|
+
const storedSchemaVersion = (stored) => {
|
|
26
|
+
const version = stored?.get("schema.core") ?? stored?.get("version");
|
|
27
|
+
return typeof version === "string" ? version : void 0;
|
|
28
|
+
};
|
|
29
|
+
/** A v0 or pre-engine database is recreated, never converted. */
|
|
30
|
+
const refusePreEngineDatabase = (adapterName, stored) => {
|
|
31
|
+
const version = storedSchemaVersion(stored);
|
|
32
|
+
if (version === void 0 || stored.has("schema.engine")) return;
|
|
33
|
+
throw new HotUpdaterSchemaMigrationRequiredError(adapterName, version, stored.has("schema.core") ? {
|
|
34
|
+
key: ENGINE_SCHEMA_KEY,
|
|
35
|
+
expected: "1",
|
|
36
|
+
found: null
|
|
37
|
+
} : void 0);
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* `hot-updater db migrate` for an ORM that applies the DDL itself (Drizzle,
|
|
41
|
+
* Prisma): it sets what the ORM cannot declare, writes the settings rows, and
|
|
42
|
+
* refuses a v0 or pre-engine database.
|
|
43
|
+
*/
|
|
44
|
+
const createSettingsMigrator = (options) => {
|
|
45
|
+
const read = () => readStoredSettings(options.executor);
|
|
46
|
+
const getVersion = async () => storedSchemaVersion(await read());
|
|
47
|
+
const makeResult = async (migrate = {}) => {
|
|
48
|
+
assertSupportedMigrationMode(migrate);
|
|
49
|
+
const stored = await read();
|
|
50
|
+
if (stored === null) throw new Error(`${options.adapterName}: the Hot Updater tables are missing. Run \`hot-updater db generate\`, apply the schema with ${options.applyTables}, then migrate again.`);
|
|
51
|
+
refusePreEngineDatabase(options.adapterName, stored);
|
|
52
|
+
if (migrate.updateSettings === false || Object.entries(options.settings).every(([key, value]) => stored.get(key) === value)) return getEmptyMigrationResult();
|
|
53
|
+
const fixups = options.fixups?.statements ?? [];
|
|
54
|
+
const statements = [...fixups, ...settingsStatements(options.executor.dialect, options.settings)];
|
|
55
|
+
return {
|
|
56
|
+
operations: [...fixups.length === 0 ? [] : [{
|
|
57
|
+
type: "custom",
|
|
58
|
+
description: options.fixups.description
|
|
59
|
+
}], {
|
|
60
|
+
type: "custom",
|
|
61
|
+
description: `Write the schema settings: ${Object.keys(options.settings).join(", ")}`
|
|
62
|
+
}],
|
|
63
|
+
getSQL: () => statements.map((statement) => `${statement};`).join("\n\n"),
|
|
64
|
+
execute: async () => {
|
|
65
|
+
for (const sql of statements) await options.executor.execute({
|
|
66
|
+
sql,
|
|
67
|
+
params: []
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
return {
|
|
73
|
+
getVersion,
|
|
74
|
+
getNameVariants: async () => void 0,
|
|
75
|
+
next: async () => await getVersion() === "1.0.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, migrate) => {
|
|
82
|
+
if (version !== "1.0.0") throw new Error(`Invalid version ${version}`);
|
|
83
|
+
return makeResult(migrate);
|
|
84
|
+
},
|
|
85
|
+
migrateToLatest: makeResult
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
//#endregion
|
|
89
|
+
export { createSettingsMigrator, readStoredSettings, refusePreEngineDatabase, storedSchemaVersion };
|
package/dist/db/types.cjs
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
//#region src/db/types.ts
|
|
2
2
|
const sqlProviders = [
|
|
3
3
|
"sqlite",
|
|
4
|
-
"cockroachdb",
|
|
5
4
|
"mysql",
|
|
6
|
-
"postgresql"
|
|
7
|
-
"mssql"
|
|
5
|
+
"postgresql"
|
|
8
6
|
];
|
|
9
7
|
const noSqlProviders = ["mongodb"];
|
|
10
8
|
[...sqlProviders, ...noSqlProviders];
|
|
11
|
-
function isDatabasePlugin(plugin) {
|
|
12
|
-
return typeof plugin === "object" && plugin !== null && "name" in plugin && typeof plugin.name === "string" && "models" in plugin && typeof plugin.models === "object" && plugin.models !== null && "bundles" in plugin.models && typeof plugin.models.bundles === "object" && plugin.models.bundles !== null && "findById" in plugin.models.bundles && typeof plugin.models.bundles.findById === "function" && "findMany" in plugin.models.bundles && typeof plugin.models.bundles.findMany === "function" && "count" in plugin.models.bundles && typeof plugin.models.bundles.count === "function" && "bundlePatches" in plugin.models && typeof plugin.models.bundlePatches === "object" && plugin.models.bundlePatches !== null && "findByBundleIds" in plugin.models.bundlePatches && typeof plugin.models.bundlePatches.findByBundleIds === "function" && "channels" in plugin.models && typeof plugin.models.channels === "object" && plugin.models.channels !== null && "insert" in plugin.models.channels && typeof plugin.models.channels.insert === "function" && "list" in plugin.models.channels && typeof plugin.models.channels.list === "function" && "delete" in plugin.models.channels && typeof plugin.models.channels.delete === "function" && "insights" in plugin.models && typeof plugin.models.insights === "object" && plugin.models.insights !== null && "append" in plugin.models.insights && typeof plugin.models.insights.append === "function" && "scan" in plugin.models.insights && typeof plugin.models.insights.scan === "function" && "apiKeys" in plugin.models && typeof plugin.models.apiKeys === "object" && plugin.models.apiKeys !== null && "create" in plugin.models.apiKeys && typeof plugin.models.apiKeys.create === "function" && "findByHash" in plugin.models.apiKeys && typeof plugin.models.apiKeys.findByHash === "function" && "list" in plugin.models.apiKeys && typeof plugin.models.apiKeys.list === "function" && "revoke" in plugin.models.apiKeys && typeof plugin.models.apiKeys.revoke === "function" && "commit" in plugin && typeof plugin.commit === "function" && (!("dispose" in plugin) || plugin.dispose === void 0 || typeof plugin.dispose === "function");
|
|
13
|
-
}
|
|
14
|
-
function getSQLProvider(provider) {
|
|
15
|
-
if (!provider) return;
|
|
16
|
-
return sqlProviders.includes(provider) ? provider : void 0;
|
|
17
|
-
}
|
|
18
9
|
//#endregion
|
|
19
|
-
exports.
|
|
20
|
-
exports.
|
|
10
|
+
exports.noSqlProviders = noSqlProviders;
|
|
11
|
+
exports.sqlProviders = sqlProviders;
|
package/dist/db/types.d.cts
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import { ArtifactInfo, Bundle } from "@hot-updater/core";
|
|
5
|
-
import * as _$_hot_updater_plugin_core0 from "@hot-updater/plugin-core";
|
|
6
|
-
import { ChannelDeleteInput, ChannelDeleteResult, ChannelInsertInput, ChannelInsertResult, ChannelRow, DatabaseCommit, DatabaseCommitResult, DatabasePlugin, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildResult, ReleaseCatalogRow, ReleasePolicyPatch, ReleaseRow } from "@hot-updater/plugin-core";
|
|
7
|
-
|
|
1
|
+
import { SchemaSettings } from "../database/fence.cjs";
|
|
2
|
+
import { ResolvedSchema } from "../database/resolveSchema.cjs";
|
|
3
|
+
import { EngineDatabase } from "@hot-updater/plugin-core";
|
|
8
4
|
//#region src/db/types.d.ts
|
|
9
|
-
declare const sqlProviders: readonly ["sqlite", "
|
|
10
|
-
declare const providers: readonly ["sqlite", "
|
|
5
|
+
declare const sqlProviders: readonly ["sqlite", "mysql", "postgresql"];
|
|
6
|
+
declare const providers: readonly ["sqlite", "mysql", "postgresql", "mongodb"];
|
|
11
7
|
type ORMProvider = (typeof providers)[number];
|
|
12
8
|
type ORMSQLProvider = (typeof sqlProviders)[number];
|
|
13
|
-
type RelationMode = "foreign-keys" | "fumadb";
|
|
14
9
|
interface MigrateOptions {
|
|
15
10
|
mode?: "from-schema" | "from-database";
|
|
16
11
|
updateSettings?: boolean;
|
|
@@ -55,67 +50,29 @@ interface Migrator {
|
|
|
55
50
|
migrateTo: (version: string, options?: MigrateOptions) => Promise<MigrationResult>;
|
|
56
51
|
migrateToLatest: (options?: MigrateOptions) => Promise<MigrationResult>;
|
|
57
52
|
}
|
|
58
|
-
|
|
53
|
+
/**
|
|
54
|
+
* The tables `db migrate` and `db generate` create and the settings rows they
|
|
55
|
+
* write: the built-in ones, and each third-party plugin's the server runs.
|
|
56
|
+
*/
|
|
57
|
+
interface ToolingTarget {
|
|
58
|
+
readonly schema: ResolvedSchema;
|
|
59
|
+
readonly settings: SchemaSettings;
|
|
60
|
+
}
|
|
61
|
+
type SchemaGenerator = (version: string | "latest", name?: string, target?: ToolingTarget) => {
|
|
59
62
|
code: string;
|
|
60
63
|
path: string;
|
|
61
64
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
getBundleById(id: string): Promise<Bundle | null>;
|
|
72
|
-
getReleaseCatalog(input: ReleaseCatalogRequest): Promise<_$_hot_updater_core0.ReleaseCatalog | null>;
|
|
73
|
-
getArtifactInfo(targetBundleId: string, currentBundleId: string): Promise<ArtifactInfo | null>;
|
|
74
|
-
getReleaseById(id: string): Promise<ReleaseRow | null>;
|
|
75
|
-
getReleasesByScope(input: {
|
|
76
|
-
readonly scopeKey: string;
|
|
77
|
-
readonly afterReleaseId?: string;
|
|
78
|
-
readonly limit: number;
|
|
79
|
-
}): Promise<readonly ReleaseRow[]>;
|
|
80
|
-
getReleases(input: {
|
|
81
|
-
readonly afterReleaseId?: string;
|
|
82
|
-
readonly beforeReleaseId?: string;
|
|
83
|
-
readonly bundleId?: string;
|
|
84
|
-
readonly channelId?: string;
|
|
85
|
-
readonly enabled?: boolean;
|
|
86
|
-
readonly platform?: "ios" | "android";
|
|
87
|
-
readonly targetAppVersion?: string;
|
|
88
|
-
readonly limit: number;
|
|
89
|
-
}): Promise<readonly ReleaseRow[]>;
|
|
90
|
-
getReleaseCatalogByScopeKey(scopeKey: string): Promise<ReleaseCatalogRow | null>;
|
|
91
|
-
getReleaseCatalogs(input: {
|
|
92
|
-
readonly afterScopeKey?: string;
|
|
93
|
-
readonly limit: number;
|
|
94
|
-
}): Promise<readonly ReleaseCatalogRow[]>;
|
|
95
|
-
updateReleasePolicy(input: {
|
|
96
|
-
readonly expectedRevision?: number;
|
|
97
|
-
readonly patch: ReleasePolicyPatch;
|
|
98
|
-
readonly releaseId: string;
|
|
99
|
-
}): Promise<ReleaseCatalogMutationResult>;
|
|
100
|
-
preflightReleasePolicy(input: {
|
|
101
|
-
readonly expectedRevision?: number;
|
|
102
|
-
readonly patch: ReleasePolicyPatch;
|
|
103
|
-
readonly releaseId: string;
|
|
104
|
-
}): Promise<ReleaseCatalogMutationPreflight>;
|
|
105
|
-
deleteRelease(input: {
|
|
106
|
-
readonly expectedRevision?: number;
|
|
107
|
-
readonly releaseId: string;
|
|
108
|
-
}): Promise<ReleaseCatalogMutationResult>;
|
|
109
|
-
rebuildReleaseCatalog(scopeKey: string): Promise<ReleaseCatalogRebuildResult>;
|
|
110
|
-
commitDatabase(input: DatabaseCommit): Promise<DatabaseCommitResult>;
|
|
111
|
-
getChannels(): Promise<readonly ChannelRow[]>;
|
|
112
|
-
insertChannel(input: ChannelInsertInput): Promise<ChannelInsertResult>;
|
|
113
|
-
deleteChannel(input: ChannelDeleteInput): Promise<ChannelDeleteResult>;
|
|
114
|
-
getBundles(options: _$_hot_updater_plugin_core0.DatabaseBundleQueryOptions): Promise<PaginatedResult>;
|
|
115
|
-
insertBundle(bundle: Bundle): Promise<void>;
|
|
116
|
-
insertBundles(bundles: readonly Bundle[]): Promise<void>;
|
|
117
|
-
updateBundleById(bundleId: string, newBundle: Partial<Bundle>): Promise<void>;
|
|
118
|
-
deleteBundleById(bundleId: string): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* What `hot-updater db generate` and `db migrate` run for a provider's
|
|
67
|
+
* database, beside the database itself. Without a target they cover the
|
|
68
|
+
* built-in tables.
|
|
69
|
+
*/
|
|
70
|
+
interface DatabaseTooling {
|
|
71
|
+
readonly provider?: ORMProvider;
|
|
72
|
+
readonly createMigrator?: (target?: ToolingTarget) => Migrator;
|
|
73
|
+
readonly generateSchema?: SchemaGenerator;
|
|
119
74
|
}
|
|
75
|
+
/** A provider's database on the storage engine, with its tooling. */
|
|
76
|
+
type ToolingDatabase = EngineDatabase & DatabaseTooling;
|
|
120
77
|
//#endregion
|
|
121
|
-
export {
|
|
78
|
+
export { DatabaseTooling, MigrateOptions, MigrationOperation, MigrationResult, Migrator, ORMProvider, ORMSQLProvider, SchemaGenerator, ToolingDatabase, ToolingTarget, providers, sqlProviders };
|
package/dist/db/types.d.mts
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import { ChannelDeleteInput, ChannelDeleteResult, ChannelInsertInput, ChannelInsertResult, ChannelRow, DatabaseCommit, DatabaseCommitResult, DatabasePlugin, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildResult, ReleaseCatalogRow, ReleasePolicyPatch, ReleaseRow } from "@hot-updater/plugin-core";
|
|
5
|
-
import * as _$_hot_updater_core0 from "@hot-updater/core";
|
|
6
|
-
import { ArtifactInfo, Bundle as Bundle$1 } from "@hot-updater/core";
|
|
7
|
-
|
|
1
|
+
import { SchemaSettings } from "../database/fence.mjs";
|
|
2
|
+
import { ResolvedSchema } from "../database/resolveSchema.mjs";
|
|
3
|
+
import { EngineDatabase } from "@hot-updater/plugin-core";
|
|
8
4
|
//#region src/db/types.d.ts
|
|
9
|
-
declare const sqlProviders: readonly ["sqlite", "
|
|
10
|
-
declare const providers: readonly ["sqlite", "
|
|
5
|
+
declare const sqlProviders: readonly ["sqlite", "mysql", "postgresql"];
|
|
6
|
+
declare const providers: readonly ["sqlite", "mysql", "postgresql", "mongodb"];
|
|
11
7
|
type ORMProvider = (typeof providers)[number];
|
|
12
8
|
type ORMSQLProvider = (typeof sqlProviders)[number];
|
|
13
|
-
type RelationMode = "foreign-keys" | "fumadb";
|
|
14
9
|
interface MigrateOptions {
|
|
15
10
|
mode?: "from-schema" | "from-database";
|
|
16
11
|
updateSettings?: boolean;
|
|
@@ -55,67 +50,29 @@ interface Migrator {
|
|
|
55
50
|
migrateTo: (version: string, options?: MigrateOptions) => Promise<MigrationResult>;
|
|
56
51
|
migrateToLatest: (options?: MigrateOptions) => Promise<MigrationResult>;
|
|
57
52
|
}
|
|
58
|
-
|
|
53
|
+
/**
|
|
54
|
+
* The tables `db migrate` and `db generate` create and the settings rows they
|
|
55
|
+
* write: the built-in ones, and each third-party plugin's the server runs.
|
|
56
|
+
*/
|
|
57
|
+
interface ToolingTarget {
|
|
58
|
+
readonly schema: ResolvedSchema;
|
|
59
|
+
readonly settings: SchemaSettings;
|
|
60
|
+
}
|
|
61
|
+
type SchemaGenerator = (version: string | "latest", name?: string, target?: ToolingTarget) => {
|
|
59
62
|
code: string;
|
|
60
63
|
path: string;
|
|
61
64
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
getBundleById(id: string): Promise<Bundle$1 | null>;
|
|
72
|
-
getReleaseCatalog(input: ReleaseCatalogRequest): Promise<_$_hot_updater_core0.ReleaseCatalog | null>;
|
|
73
|
-
getArtifactInfo(targetBundleId: string, currentBundleId: string): Promise<ArtifactInfo | null>;
|
|
74
|
-
getReleaseById(id: string): Promise<ReleaseRow | null>;
|
|
75
|
-
getReleasesByScope(input: {
|
|
76
|
-
readonly scopeKey: string;
|
|
77
|
-
readonly afterReleaseId?: string;
|
|
78
|
-
readonly limit: number;
|
|
79
|
-
}): Promise<readonly ReleaseRow[]>;
|
|
80
|
-
getReleases(input: {
|
|
81
|
-
readonly afterReleaseId?: string;
|
|
82
|
-
readonly beforeReleaseId?: string;
|
|
83
|
-
readonly bundleId?: string;
|
|
84
|
-
readonly channelId?: string;
|
|
85
|
-
readonly enabled?: boolean;
|
|
86
|
-
readonly platform?: "ios" | "android";
|
|
87
|
-
readonly targetAppVersion?: string;
|
|
88
|
-
readonly limit: number;
|
|
89
|
-
}): Promise<readonly ReleaseRow[]>;
|
|
90
|
-
getReleaseCatalogByScopeKey(scopeKey: string): Promise<ReleaseCatalogRow | null>;
|
|
91
|
-
getReleaseCatalogs(input: {
|
|
92
|
-
readonly afterScopeKey?: string;
|
|
93
|
-
readonly limit: number;
|
|
94
|
-
}): Promise<readonly ReleaseCatalogRow[]>;
|
|
95
|
-
updateReleasePolicy(input: {
|
|
96
|
-
readonly expectedRevision?: number;
|
|
97
|
-
readonly patch: ReleasePolicyPatch;
|
|
98
|
-
readonly releaseId: string;
|
|
99
|
-
}): Promise<ReleaseCatalogMutationResult>;
|
|
100
|
-
preflightReleasePolicy(input: {
|
|
101
|
-
readonly expectedRevision?: number;
|
|
102
|
-
readonly patch: ReleasePolicyPatch;
|
|
103
|
-
readonly releaseId: string;
|
|
104
|
-
}): Promise<ReleaseCatalogMutationPreflight>;
|
|
105
|
-
deleteRelease(input: {
|
|
106
|
-
readonly expectedRevision?: number;
|
|
107
|
-
readonly releaseId: string;
|
|
108
|
-
}): Promise<ReleaseCatalogMutationResult>;
|
|
109
|
-
rebuildReleaseCatalog(scopeKey: string): Promise<ReleaseCatalogRebuildResult>;
|
|
110
|
-
commitDatabase(input: DatabaseCommit): Promise<DatabaseCommitResult>;
|
|
111
|
-
getChannels(): Promise<readonly ChannelRow[]>;
|
|
112
|
-
insertChannel(input: ChannelInsertInput): Promise<ChannelInsertResult>;
|
|
113
|
-
deleteChannel(input: ChannelDeleteInput): Promise<ChannelDeleteResult>;
|
|
114
|
-
getBundles(options: _$_hot_updater_plugin_core0.DatabaseBundleQueryOptions): Promise<PaginatedResult>;
|
|
115
|
-
insertBundle(bundle: Bundle$1): Promise<void>;
|
|
116
|
-
insertBundles(bundles: readonly Bundle$1[]): Promise<void>;
|
|
117
|
-
updateBundleById(bundleId: string, newBundle: Partial<Bundle$1>): Promise<void>;
|
|
118
|
-
deleteBundleById(bundleId: string): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* What `hot-updater db generate` and `db migrate` run for a provider's
|
|
67
|
+
* database, beside the database itself. Without a target they cover the
|
|
68
|
+
* built-in tables.
|
|
69
|
+
*/
|
|
70
|
+
interface DatabaseTooling {
|
|
71
|
+
readonly provider?: ORMProvider;
|
|
72
|
+
readonly createMigrator?: (target?: ToolingTarget) => Migrator;
|
|
73
|
+
readonly generateSchema?: SchemaGenerator;
|
|
119
74
|
}
|
|
75
|
+
/** A provider's database on the storage engine, with its tooling. */
|
|
76
|
+
type ToolingDatabase = EngineDatabase & DatabaseTooling;
|
|
120
77
|
//#endregion
|
|
121
|
-
export {
|
|
78
|
+
export { DatabaseTooling, MigrateOptions, MigrationOperation, MigrationResult, Migrator, ORMProvider, ORMSQLProvider, SchemaGenerator, ToolingDatabase, ToolingTarget, providers, sqlProviders };
|
package/dist/db/types.mjs
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
//#region src/db/types.ts
|
|
2
2
|
const sqlProviders = [
|
|
3
3
|
"sqlite",
|
|
4
|
-
"cockroachdb",
|
|
5
4
|
"mysql",
|
|
6
|
-
"postgresql"
|
|
7
|
-
"mssql"
|
|
5
|
+
"postgresql"
|
|
8
6
|
];
|
|
9
7
|
const noSqlProviders = ["mongodb"];
|
|
10
8
|
[...sqlProviders, ...noSqlProviders];
|
|
11
|
-
function isDatabasePlugin(plugin) {
|
|
12
|
-
return typeof plugin === "object" && plugin !== null && "name" in plugin && typeof plugin.name === "string" && "models" in plugin && typeof plugin.models === "object" && plugin.models !== null && "bundles" in plugin.models && typeof plugin.models.bundles === "object" && plugin.models.bundles !== null && "findById" in plugin.models.bundles && typeof plugin.models.bundles.findById === "function" && "findMany" in plugin.models.bundles && typeof plugin.models.bundles.findMany === "function" && "count" in plugin.models.bundles && typeof plugin.models.bundles.count === "function" && "bundlePatches" in plugin.models && typeof plugin.models.bundlePatches === "object" && plugin.models.bundlePatches !== null && "findByBundleIds" in plugin.models.bundlePatches && typeof plugin.models.bundlePatches.findByBundleIds === "function" && "channels" in plugin.models && typeof plugin.models.channels === "object" && plugin.models.channels !== null && "insert" in plugin.models.channels && typeof plugin.models.channels.insert === "function" && "list" in plugin.models.channels && typeof plugin.models.channels.list === "function" && "delete" in plugin.models.channels && typeof plugin.models.channels.delete === "function" && "insights" in plugin.models && typeof plugin.models.insights === "object" && plugin.models.insights !== null && "append" in plugin.models.insights && typeof plugin.models.insights.append === "function" && "scan" in plugin.models.insights && typeof plugin.models.insights.scan === "function" && "apiKeys" in plugin.models && typeof plugin.models.apiKeys === "object" && plugin.models.apiKeys !== null && "create" in plugin.models.apiKeys && typeof plugin.models.apiKeys.create === "function" && "findByHash" in plugin.models.apiKeys && typeof plugin.models.apiKeys.findByHash === "function" && "list" in plugin.models.apiKeys && typeof plugin.models.apiKeys.list === "function" && "revoke" in plugin.models.apiKeys && typeof plugin.models.apiKeys.revoke === "function" && "commit" in plugin && typeof plugin.commit === "function" && (!("dispose" in plugin) || plugin.dispose === void 0 || typeof plugin.dispose === "function");
|
|
13
|
-
}
|
|
14
|
-
function getSQLProvider(provider) {
|
|
15
|
-
if (!provider) return;
|
|
16
|
-
return sqlProviders.includes(provider) ? provider : void 0;
|
|
17
|
-
}
|
|
18
9
|
//#endregion
|
|
19
|
-
export {
|
|
10
|
+
export { noSqlProviders, sqlProviders };
|
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
1
|
let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
|
|
3
2
|
let _hot_updater_core = require("@hot-updater/core");
|
|
4
3
|
//#region src/db/updateArtifacts.ts
|
|
5
4
|
const HBC_ASSET_PATH_RE = /\.bundle$/;
|
|
6
5
|
const asByteSize = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : null;
|
|
7
|
-
const sumByteSizes = (byteSizes) => {
|
|
8
|
-
let total = 0;
|
|
9
|
-
for (const byteSize of byteSizes) {
|
|
10
|
-
if (byteSize === null || total > Number.MAX_SAFE_INTEGER - byteSize) return null;
|
|
11
|
-
total += byteSize;
|
|
12
|
-
}
|
|
13
|
-
return total;
|
|
14
|
-
};
|
|
15
|
-
const shouldUseArchive = (targetBundle, downloadByteSize) => {
|
|
16
|
-
const archiveByteSize = asByteSize(targetBundle.archiveByteSize);
|
|
17
|
-
return archiveByteSize !== null && downloadByteSize !== null && downloadByteSize >= archiveByteSize;
|
|
18
|
-
};
|
|
19
6
|
const resolveUniqueHbcAssetPath = (manifest) => {
|
|
20
7
|
const candidates = Object.keys(manifest.assets).sort((left, right) => left.localeCompare(right)).filter((candidate) => HBC_ASSET_PATH_RE.test(candidate));
|
|
21
8
|
return candidates.length === 1 ? candidates[0] : null;
|
|
@@ -41,10 +28,7 @@ async function fetchBundleManifest(storageUri, readStorageText) {
|
|
|
41
28
|
return null;
|
|
42
29
|
}
|
|
43
30
|
if (!isBundleManifest(payload)) return null;
|
|
44
|
-
return
|
|
45
|
-
byteSize: asByteSize(new TextEncoder().encode(storageText).byteLength),
|
|
46
|
-
manifest: payload
|
|
47
|
-
};
|
|
31
|
+
return payload;
|
|
48
32
|
}
|
|
49
33
|
function resolveHbcPatchPlan({ currentBundle, targetBundle, targetManifest }) {
|
|
50
34
|
const matchingPatch = currentBundle ? (0, _hot_updater_core.getBundlePatch)(targetBundle, currentBundle.id) : null;
|
|
@@ -61,14 +45,13 @@ function resolveHbcPatchPlan({ currentBundle, targetBundle, targetManifest }) {
|
|
|
61
45
|
}
|
|
62
46
|
};
|
|
63
47
|
}
|
|
64
|
-
function createManifestArtifactPlan({ assetBaseStorageUri,
|
|
48
|
+
function createManifestArtifactPlan({ assetBaseStorageUri, currentBundle, targetBundle, targetManifest }) {
|
|
65
49
|
const patchCandidate = resolveHbcPatchPlan({
|
|
66
50
|
currentBundle,
|
|
67
51
|
targetBundle,
|
|
68
52
|
targetManifest
|
|
69
53
|
});
|
|
70
|
-
|
|
71
|
-
if ((currentManifest?.assets[assetPath])?.fileHash === asset.fileHash) return [];
|
|
54
|
+
return { assets: Object.entries(targetManifest.assets).map(([assetPath, asset]) => {
|
|
72
55
|
const downloadByteSize = asByteSize(asset.downloadByteSize);
|
|
73
56
|
const downloadPath = (0, _hot_updater_plugin_core.getManifestAssetDownloadPath)(assetPath);
|
|
74
57
|
const isTransformedDownload = downloadPath !== assetPath;
|
|
@@ -84,28 +67,16 @@ function createManifestArtifactPlan({ assetBaseStorageUri, currentManifest, curr
|
|
|
84
67
|
};
|
|
85
68
|
if (isTransformedDownload) file.compression = "br";
|
|
86
69
|
const patch = patchCandidate?.assetPath === assetPath ? patchCandidate.patch : null;
|
|
87
|
-
return
|
|
70
|
+
return {
|
|
88
71
|
assetPath,
|
|
89
72
|
file,
|
|
90
73
|
fileHash: asset.fileHash,
|
|
91
74
|
patch
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
const allPossibleByteSizesKnown = targetManifestByteSize !== null && changedAssets.every((asset) => asset.file.byteSize !== null && (asset.patch === null || asset.patch.byteSize !== null));
|
|
95
|
-
const primaryByteSizes = changedAssets.map((asset) => {
|
|
96
|
-
if (!asset.patch) return asset.file.byteSize;
|
|
97
|
-
if (asset.patch.byteSize === null || asset.file.byteSize === null) return null;
|
|
98
|
-
return Math.min(asset.patch.byteSize, asset.file.byteSize);
|
|
99
|
-
});
|
|
100
|
-
return {
|
|
101
|
-
allPossibleByteSizesKnown,
|
|
102
|
-
changedAssets,
|
|
103
|
-
manifestByteSize: targetManifestByteSize,
|
|
104
|
-
minimumDownloadByteSize: allPossibleByteSizesKnown ? sumByteSizes([targetManifestByteSize, ...primaryByteSizes]) : null
|
|
105
|
-
};
|
|
75
|
+
};
|
|
76
|
+
}) };
|
|
106
77
|
}
|
|
107
|
-
async function
|
|
108
|
-
const patchAsset = plan.
|
|
78
|
+
async function resolveAssets(plan, resolveFileUrl) {
|
|
79
|
+
const patchAsset = plan.assets.find((asset) => asset.patch !== null);
|
|
109
80
|
let resolvedPatch = null;
|
|
110
81
|
if (patchAsset?.patch) {
|
|
111
82
|
const patchUrl = await resolveFileUrl(patchAsset.patch.storageUri);
|
|
@@ -116,11 +87,12 @@ async function resolveChangedAssets(plan, resolveFileUrl) {
|
|
|
116
87
|
baseBundleId: patchAsset.patch.baseBundleId,
|
|
117
88
|
baseFileHash: patchAsset.patch.baseFileHash,
|
|
118
89
|
patchFileHash: patchAsset.patch.patchFileHash,
|
|
119
|
-
patchUrl
|
|
90
|
+
patchUrl,
|
|
91
|
+
...patchAsset.patch.byteSize === null ? {} : { byteSize: patchAsset.patch.byteSize }
|
|
120
92
|
}
|
|
121
93
|
};
|
|
122
94
|
}
|
|
123
|
-
const
|
|
95
|
+
const entries = await Promise.all(plan.assets.map(async (asset) => {
|
|
124
96
|
let patch = resolvedPatch?.assetPath === asset.assetPath ? resolvedPatch.patch : null;
|
|
125
97
|
let fileUrl = null;
|
|
126
98
|
try {
|
|
@@ -129,52 +101,50 @@ async function resolveChangedAssets(plan, resolveFileUrl) {
|
|
|
129
101
|
if (!patch) throw error;
|
|
130
102
|
}
|
|
131
103
|
if (fileUrl && patch && asset.file.byteSize !== null && asset.patch !== null && asset.patch.byteSize !== null && asset.patch.byteSize >= asset.file.byteSize) patch = null;
|
|
132
|
-
if (!fileUrl
|
|
133
|
-
const changedAsset = {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if (asset.file.compression) changedAsset.file.compression = asset.file.compression;
|
|
137
|
-
}
|
|
138
|
-
if (patch) changedAsset.patch = patch;
|
|
139
|
-
return {
|
|
140
|
-
asset: [asset.assetPath, changedAsset],
|
|
141
|
-
primaryByteSize: patch ? asset.patch?.byteSize ?? null : asset.file.byteSize
|
|
104
|
+
if (!fileUrl) return null;
|
|
105
|
+
const changedAsset = {
|
|
106
|
+
file: { url: fileUrl },
|
|
107
|
+
fileHash: asset.fileHash
|
|
142
108
|
};
|
|
109
|
+
if (asset.file.compression) changedAsset.file.compression = asset.file.compression;
|
|
110
|
+
if (patch) changedAsset.patch = patch;
|
|
111
|
+
return { asset: [asset.assetPath, changedAsset] };
|
|
143
112
|
}));
|
|
144
|
-
if (
|
|
145
|
-
const resolvedEntries =
|
|
146
|
-
return {
|
|
147
|
-
changedAssets: Object.fromEntries(resolvedEntries.map((entry) => entry.asset)),
|
|
148
|
-
primaryByteSizes: resolvedEntries.map((entry) => entry.primaryByteSize)
|
|
149
|
-
};
|
|
113
|
+
if (entries.some((entry) => entry === null)) return null;
|
|
114
|
+
const resolvedEntries = entries.filter((entry) => entry !== null);
|
|
115
|
+
return { assets: Object.fromEntries(resolvedEntries.map((entry) => entry.asset)) };
|
|
150
116
|
}
|
|
151
|
-
async function resolveManifestArtifacts({
|
|
117
|
+
async function resolveManifestArtifacts({ currentBundle, resolveFileUrl, readStorageText, targetBundle }) {
|
|
152
118
|
const manifestStorageUri = targetBundle ? (0, _hot_updater_core.getManifestStorageUri)(targetBundle) : null;
|
|
153
119
|
const manifestFileHash = targetBundle ? (0, _hot_updater_core.getManifestFileHash)(targetBundle) : null;
|
|
154
120
|
const assetBaseStorageUri = targetBundle ? (0, _hot_updater_core.getAssetBaseStorageUri)(targetBundle) : null;
|
|
155
121
|
if (!targetBundle || !manifestStorageUri || !manifestFileHash || !assetBaseStorageUri) return null;
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
if (!targetManifestResult) return null;
|
|
122
|
+
const targetManifest = await fetchBundleManifest(manifestStorageUri, readStorageText);
|
|
123
|
+
if (!targetManifest) return null;
|
|
159
124
|
const plan = createManifestArtifactPlan({
|
|
160
125
|
assetBaseStorageUri,
|
|
161
|
-
currentManifest: currentManifestResult?.manifest ?? null,
|
|
162
126
|
currentBundle,
|
|
163
127
|
targetBundle,
|
|
164
|
-
targetManifest
|
|
165
|
-
targetManifestByteSize: targetManifestResult.byteSize
|
|
128
|
+
targetManifest
|
|
166
129
|
});
|
|
167
|
-
if (archiveUrlUsable && plan.allPossibleByteSizesKnown && shouldUseArchive(targetBundle, plan.minimumDownloadByteSize)) return null;
|
|
168
130
|
const manifestUrl = await resolveFileUrl(manifestStorageUri);
|
|
169
131
|
if (!manifestUrl) return null;
|
|
170
|
-
const resolved = await
|
|
132
|
+
const resolved = await resolveAssets(plan, resolveFileUrl);
|
|
171
133
|
if (!resolved) return null;
|
|
172
|
-
|
|
173
|
-
|
|
134
|
+
let archiveUrl = null;
|
|
135
|
+
const archive = targetManifest.archive;
|
|
136
|
+
if (archive && (0, _hot_updater_plugin_core.isContentAddressedAssetFileHash)(archive.downloadFileHash) && (asByteSize(archive.downloadByteSize) ?? 0) > 0 && (asByteSize(archive.tarByteSize) ?? 0) > 0) try {
|
|
137
|
+
archiveUrl = await resolveFileUrl((0, _hot_updater_plugin_core.getBundleArchiveStorageUri)({
|
|
138
|
+
manifestStorageUri,
|
|
139
|
+
bundleId: targetBundle.id
|
|
140
|
+
}));
|
|
141
|
+
} catch {}
|
|
174
142
|
return {
|
|
175
|
-
|
|
143
|
+
artifactProtocolVersion: _hot_updater_core.ARTIFACT_PROTOCOL_VERSION,
|
|
144
|
+
assets: resolved.assets,
|
|
176
145
|
manifestFileHash,
|
|
177
|
-
manifestUrl
|
|
146
|
+
manifestUrl,
|
|
147
|
+
...archiveUrl ? { archiveUrl } : {}
|
|
178
148
|
};
|
|
179
149
|
}
|
|
180
150
|
//#endregion
|