@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
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { DatabasePluginInputError } from "@hot-updater/plugin-core";
|
|
2
|
-
//#region src/adapters/prismaQuery.ts
|
|
3
|
-
const stringFilter = (operator, value, mode) => {
|
|
4
|
-
return {
|
|
5
|
-
[operator === "starts_with" ? "startsWith" : operator === "ends_with" ? "endsWith" : "contains"]: value,
|
|
6
|
-
...mode ? { mode } : {}
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
|
-
const SQL_PATTERN_METACHARACTERS = /[%_\\]/u;
|
|
10
|
-
const MONGODB_PATTERN_METACHARACTERS = /[.*+?^${}()|[\]\\]/u;
|
|
11
|
-
const prismaMode = (mode, provider) => {
|
|
12
|
-
if (mode === "insensitive" || mode === "sensitive" && provider !== "postgresql") throw new DatabasePluginInputError("invalid-operation");
|
|
13
|
-
return mode === "sensitive" ? "default" : void 0;
|
|
14
|
-
};
|
|
15
|
-
const assertLiteralPattern = (value, provider) => {
|
|
16
|
-
if ((provider === "mongodb" ? MONGODB_PATTERN_METACHARACTERS : SQL_PATTERN_METACHARACTERS).test(value)) throw new DatabasePluginInputError("invalid-operation");
|
|
17
|
-
};
|
|
18
|
-
const predicate = (where, provider) => {
|
|
19
|
-
const mode = prismaMode("mode" in where ? where.mode : void 0, provider);
|
|
20
|
-
switch (where.operator) {
|
|
21
|
-
case void 0:
|
|
22
|
-
case "eq": return { [where.field]: mode ? {
|
|
23
|
-
equals: where.value,
|
|
24
|
-
mode
|
|
25
|
-
} : where.value };
|
|
26
|
-
case "ne": return { [where.field]: {
|
|
27
|
-
not: where.value,
|
|
28
|
-
...mode ? { mode } : {}
|
|
29
|
-
} };
|
|
30
|
-
case "gt":
|
|
31
|
-
case "gte":
|
|
32
|
-
case "lt":
|
|
33
|
-
case "lte": return { [where.field]: { [where.operator]: where.value } };
|
|
34
|
-
case "in": return { [where.field]: { in: where.value } };
|
|
35
|
-
case "not_in": return { [where.field]: { notIn: where.value } };
|
|
36
|
-
case "contains":
|
|
37
|
-
case "starts_with":
|
|
38
|
-
case "ends_with":
|
|
39
|
-
assertLiteralPattern(where.value, provider);
|
|
40
|
-
return { [where.field]: stringFilter(where.operator, where.value, mode) };
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
const createPrismaWhere = (where, provider) => {
|
|
44
|
-
const items = where ?? [];
|
|
45
|
-
const first = items[0];
|
|
46
|
-
if (first === void 0) return {};
|
|
47
|
-
let result = predicate(first, provider);
|
|
48
|
-
for (const item of items.slice(1)) result = { [item.connector === "OR" ? "OR" : "AND"]: [result, predicate(item, provider)] };
|
|
49
|
-
return result;
|
|
50
|
-
};
|
|
51
|
-
const createPrismaOrderBy = (orderBy) => {
|
|
52
|
-
if (orderBy === void 0) return void 0;
|
|
53
|
-
return (Array.isArray(orderBy) ? orderBy : [orderBy]).map((clause) => ({ [clause.field]: clause.direction }));
|
|
54
|
-
};
|
|
55
|
-
//#endregion
|
|
56
|
-
export { createPrismaOrderBy, createPrismaWhere };
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
-
let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
|
|
3
|
-
//#region src/adapters/prismaRows.ts
|
|
4
|
-
var PrismaAdapterError = class extends Error {
|
|
5
|
-
name = "PrismaAdapterError";
|
|
6
|
-
constructor(reason) {
|
|
7
|
-
super(`Invalid Prisma plugin state: ${reason}`);
|
|
8
|
-
this.reason = reason;
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
12
|
-
const hasDelegateMethods = (value) => isRecord(value) && typeof value["count"] === "function" && typeof value["create"] === "function" && typeof value["deleteMany"] === "function" && typeof value["findFirst"] === "function" && typeof value["findMany"] === "function" && typeof value["update"] === "function" && typeof value["upsert"] === "function";
|
|
13
|
-
const modelDelegates = {
|
|
14
|
-
bundles: "bundles",
|
|
15
|
-
bundle_patches: "bundle_patches",
|
|
16
|
-
bundle_events: "bundle_events",
|
|
17
|
-
channels: "channels",
|
|
18
|
-
api_keys: "api_keys",
|
|
19
|
-
releases: "releases",
|
|
20
|
-
release_catalogs: "release_catalogs"
|
|
21
|
-
};
|
|
22
|
-
const getPrismaDelegate = (client, model) => {
|
|
23
|
-
const delegate = Object.entries(client).find(([key]) => key === modelDelegates[model])?.[1];
|
|
24
|
-
if (delegate === void 0) throw new PrismaAdapterError(`missing model delegate "${model}"`);
|
|
25
|
-
if (!hasDelegateMethods(delegate)) throw new PrismaAdapterError(`invalid model delegate "${model}"`);
|
|
26
|
-
return delegate;
|
|
27
|
-
};
|
|
28
|
-
const readString = (row, field) => {
|
|
29
|
-
const value = row[field];
|
|
30
|
-
if (typeof value !== "string") throw new PrismaAdapterError(`expected string field "${field}"`);
|
|
31
|
-
return value;
|
|
32
|
-
};
|
|
33
|
-
const readNullableString = (row, field) => {
|
|
34
|
-
const value = row[field];
|
|
35
|
-
if (value === null) return null;
|
|
36
|
-
if (typeof value !== "string") throw new PrismaAdapterError(`expected nullable string field "${field}"`);
|
|
37
|
-
return value;
|
|
38
|
-
};
|
|
39
|
-
const readByteSize = (row, field) => {
|
|
40
|
-
const value = row[field];
|
|
41
|
-
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) throw new PrismaAdapterError(`expected byte-size field "${field}"`);
|
|
42
|
-
return value;
|
|
43
|
-
};
|
|
44
|
-
const parsePrismaBundleRow = (value) => {
|
|
45
|
-
if (!isRecord(value)) throw new PrismaAdapterError("invalid bundle row");
|
|
46
|
-
const platform = value["platform"];
|
|
47
|
-
if (platform !== "android" && platform !== "ios") throw new PrismaAdapterError("expected platform \"android\" or \"ios\"");
|
|
48
|
-
const metadata = value["metadata"];
|
|
49
|
-
if (!(0, _hot_updater_plugin_core.isDatabaseMetadataObject)(metadata)) throw new PrismaAdapterError("invalid metadata field");
|
|
50
|
-
return {
|
|
51
|
-
id: readString(value, "id"),
|
|
52
|
-
platform,
|
|
53
|
-
file_hash: readString(value, "file_hash"),
|
|
54
|
-
git_commit_hash: readNullableString(value, "git_commit_hash"),
|
|
55
|
-
storage_uri: readString(value, "storage_uri"),
|
|
56
|
-
archive_byte_size: readByteSize(value, "archive_byte_size"),
|
|
57
|
-
metadata,
|
|
58
|
-
manifest_storage_uri: readNullableString(value, "manifest_storage_uri"),
|
|
59
|
-
manifest_file_hash: readNullableString(value, "manifest_file_hash"),
|
|
60
|
-
asset_base_storage_uri: readNullableString(value, "asset_base_storage_uri")
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
const parsePrismaChannelRow = (value) => {
|
|
64
|
-
if (!isRecord(value)) throw new PrismaAdapterError("invalid channel row");
|
|
65
|
-
return {
|
|
66
|
-
id: readString(value, "id"),
|
|
67
|
-
name: readString(value, "name")
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
const parsePrismaPatchRow = (value) => {
|
|
71
|
-
if (!isRecord(value)) throw new PrismaAdapterError("invalid patch row");
|
|
72
|
-
const orderIndex = value["order_index"];
|
|
73
|
-
if (typeof orderIndex !== "number") throw new PrismaAdapterError("invalid patch order_index field");
|
|
74
|
-
return {
|
|
75
|
-
id: readString(value, "id"),
|
|
76
|
-
bundle_id: readString(value, "bundle_id"),
|
|
77
|
-
base_bundle_id: readString(value, "base_bundle_id"),
|
|
78
|
-
base_file_hash: readString(value, "base_file_hash"),
|
|
79
|
-
patch_file_hash: readString(value, "patch_file_hash"),
|
|
80
|
-
patch_storage_uri: readString(value, "patch_storage_uri"),
|
|
81
|
-
byte_size: readByteSize(value, "byte_size"),
|
|
82
|
-
order_index: orderIndex
|
|
83
|
-
};
|
|
84
|
-
};
|
|
85
|
-
const readNumber = (row, field) => {
|
|
86
|
-
const value = row[field];
|
|
87
|
-
if (typeof value !== "number" || !Number.isFinite(value)) throw new PrismaAdapterError(`expected number field "${field}"`);
|
|
88
|
-
return value;
|
|
89
|
-
};
|
|
90
|
-
const parsePrismaBundleEventRow = (value) => {
|
|
91
|
-
if (!isRecord(value)) throw new PrismaAdapterError("invalid event row");
|
|
92
|
-
const type = readString(value, "type");
|
|
93
|
-
const platform = readString(value, "platform");
|
|
94
|
-
const fromBundleId = readNullableString(value, "from_bundle_id");
|
|
95
|
-
const updateStrategy = readNullableString(value, "update_strategy");
|
|
96
|
-
if (platform !== "ios" && platform !== "android" || !((type === "UPDATE_APPLIED" || type === "RECOVERED" || type === "RELEASE_ADOPTED") && typeof fromBundleId === "string" && (updateStrategy === "fingerprint" || updateStrategy === "appVersion") || type === "UNCHANGED" && fromBundleId === null && updateStrategy === null)) throw new PrismaAdapterError("invalid event shape");
|
|
97
|
-
return {
|
|
98
|
-
id: readString(value, "id"),
|
|
99
|
-
type,
|
|
100
|
-
install_id: readString(value, "install_id"),
|
|
101
|
-
user_id: readNullableString(value, "user_id"),
|
|
102
|
-
username: readNullableString(value, "username"),
|
|
103
|
-
from_release_id: readNullableString(value, "from_release_id"),
|
|
104
|
-
from_bundle_id: fromBundleId,
|
|
105
|
-
to_release_id: readNullableString(value, "to_release_id"),
|
|
106
|
-
to_bundle_id: readString(value, "to_bundle_id"),
|
|
107
|
-
platform,
|
|
108
|
-
app_version: readString(value, "app_version"),
|
|
109
|
-
channel: readString(value, "channel"),
|
|
110
|
-
cohort: readString(value, "cohort"),
|
|
111
|
-
update_strategy: updateStrategy,
|
|
112
|
-
fingerprint_hash: readNullableString(value, "fingerprint_hash"),
|
|
113
|
-
sdk_version: readNullableString(value, "sdk_version"),
|
|
114
|
-
received_at_ms: readNumber(value, "received_at_ms")
|
|
115
|
-
};
|
|
116
|
-
};
|
|
117
|
-
const parsePrismaApiKeyRow = (value) => {
|
|
118
|
-
if (!isRecord(value)) throw new PrismaAdapterError("invalid API key row");
|
|
119
|
-
const role = readString(value, "role");
|
|
120
|
-
if (role !== "client") throw new PrismaAdapterError("invalid API key role");
|
|
121
|
-
const revokedAt = value["revoked_at_ms"];
|
|
122
|
-
return {
|
|
123
|
-
id: readString(value, "id"),
|
|
124
|
-
hash: readString(value, "hash"),
|
|
125
|
-
name: readString(value, "name"),
|
|
126
|
-
prefix: readString(value, "prefix"),
|
|
127
|
-
role,
|
|
128
|
-
created_at_ms: readNumber(value, "created_at_ms"),
|
|
129
|
-
revoked_at_ms: revokedAt === null ? null : readNumber(value, "revoked_at_ms")
|
|
130
|
-
};
|
|
131
|
-
};
|
|
132
|
-
const parsePrismaReleaseRow = (value) => {
|
|
133
|
-
if (!isRecord(value)) throw new PrismaAdapterError("invalid Release row");
|
|
134
|
-
const platform = readString(value, "platform");
|
|
135
|
-
const kind = readString(value, "kind");
|
|
136
|
-
const strategy = readString(value, "strategy");
|
|
137
|
-
const operation = readString(value, "operation");
|
|
138
|
-
const targetCohorts = value["target_cohorts"];
|
|
139
|
-
if (platform !== "ios" && platform !== "android" || kind !== "BUNDLE" && kind !== "EMBEDDED" || strategy !== "APP_VERSION" && strategy !== "FINGERPRINT" || operation !== "DEPLOY" && operation !== "PROMOTE" && operation !== "ROLLBACK" || !Array.isArray(targetCohorts) || !targetCohorts.every((cohort) => typeof cohort === "string")) throw new PrismaAdapterError("invalid Release fields");
|
|
140
|
-
const enabled = value["enabled"];
|
|
141
|
-
const shouldForceUpdate = value["should_force_update"];
|
|
142
|
-
if (typeof enabled !== "boolean" || typeof shouldForceUpdate !== "boolean") throw new PrismaAdapterError("invalid Release policy fields");
|
|
143
|
-
return {
|
|
144
|
-
bundle_id: readNullableString(value, "bundle_id"),
|
|
145
|
-
channel_id: readString(value, "channel_id"),
|
|
146
|
-
created_at_ms: readNumber(value, "created_at_ms"),
|
|
147
|
-
enabled,
|
|
148
|
-
fingerprint_hash: readNullableString(value, "fingerprint_hash"),
|
|
149
|
-
id: readString(value, "id"),
|
|
150
|
-
kind,
|
|
151
|
-
message: readNullableString(value, "message"),
|
|
152
|
-
operation,
|
|
153
|
-
platform,
|
|
154
|
-
revision: readNumber(value, "revision"),
|
|
155
|
-
rollout_cohort_count: readNumber(value, "rollout_cohort_count"),
|
|
156
|
-
scope_key: readString(value, "scope_key"),
|
|
157
|
-
should_force_update: shouldForceUpdate,
|
|
158
|
-
source_release_id: readNullableString(value, "source_release_id"),
|
|
159
|
-
strategy,
|
|
160
|
-
target_app_version: readNullableString(value, "target_app_version"),
|
|
161
|
-
target_cohorts: targetCohorts,
|
|
162
|
-
updated_at_ms: readNumber(value, "updated_at_ms")
|
|
163
|
-
};
|
|
164
|
-
};
|
|
165
|
-
const parsePrismaReleaseCatalogRow = (value) => {
|
|
166
|
-
if (!isRecord(value)) throw new PrismaAdapterError("invalid catalog row");
|
|
167
|
-
const platform = readString(value, "platform");
|
|
168
|
-
const strategy = readString(value, "strategy");
|
|
169
|
-
const isTombstone = value["is_tombstone"];
|
|
170
|
-
if (platform !== "ios" && platform !== "android" || strategy !== "APP_VERSION" && strategy !== "FINGERPRINT" || typeof isTombstone !== "boolean") throw new PrismaAdapterError("invalid catalog fields");
|
|
171
|
-
return {
|
|
172
|
-
catalog_id: readString(value, "catalog_id"),
|
|
173
|
-
byte_size: readNumber(value, "byte_size"),
|
|
174
|
-
catalog_hash: readString(value, "catalog_hash"),
|
|
175
|
-
channel_id: readString(value, "channel_id"),
|
|
176
|
-
channel_key: readString(value, "channel_key"),
|
|
177
|
-
fingerprint_hash: readNullableString(value, "fingerprint_hash"),
|
|
178
|
-
generation: readNumber(value, "generation"),
|
|
179
|
-
is_tombstone: isTombstone,
|
|
180
|
-
payload: readString(value, "payload"),
|
|
181
|
-
platform,
|
|
182
|
-
scope_key: readString(value, "scope_key"),
|
|
183
|
-
strategy,
|
|
184
|
-
updated_at_ms: readNumber(value, "updated_at_ms")
|
|
185
|
-
};
|
|
186
|
-
};
|
|
187
|
-
const parsePrismaRows = (rows, parse) => rows.map(parse);
|
|
188
|
-
//#endregion
|
|
189
|
-
exports.PrismaAdapterError = PrismaAdapterError;
|
|
190
|
-
exports.getPrismaDelegate = getPrismaDelegate;
|
|
191
|
-
exports.parsePrismaApiKeyRow = parsePrismaApiKeyRow;
|
|
192
|
-
exports.parsePrismaBundleEventRow = parsePrismaBundleEventRow;
|
|
193
|
-
exports.parsePrismaBundleRow = parsePrismaBundleRow;
|
|
194
|
-
exports.parsePrismaChannelRow = parsePrismaChannelRow;
|
|
195
|
-
exports.parsePrismaPatchRow = parsePrismaPatchRow;
|
|
196
|
-
exports.parsePrismaReleaseCatalogRow = parsePrismaReleaseCatalogRow;
|
|
197
|
-
exports.parsePrismaReleaseRow = parsePrismaReleaseRow;
|
|
198
|
-
exports.parsePrismaRows = parsePrismaRows;
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import { isDatabaseMetadataObject } from "@hot-updater/plugin-core";
|
|
2
|
-
//#region src/adapters/prismaRows.ts
|
|
3
|
-
var PrismaAdapterError = class extends Error {
|
|
4
|
-
name = "PrismaAdapterError";
|
|
5
|
-
constructor(reason) {
|
|
6
|
-
super(`Invalid Prisma plugin state: ${reason}`);
|
|
7
|
-
this.reason = reason;
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
11
|
-
const hasDelegateMethods = (value) => isRecord(value) && typeof value["count"] === "function" && typeof value["create"] === "function" && typeof value["deleteMany"] === "function" && typeof value["findFirst"] === "function" && typeof value["findMany"] === "function" && typeof value["update"] === "function" && typeof value["upsert"] === "function";
|
|
12
|
-
const modelDelegates = {
|
|
13
|
-
bundles: "bundles",
|
|
14
|
-
bundle_patches: "bundle_patches",
|
|
15
|
-
bundle_events: "bundle_events",
|
|
16
|
-
channels: "channels",
|
|
17
|
-
api_keys: "api_keys",
|
|
18
|
-
releases: "releases",
|
|
19
|
-
release_catalogs: "release_catalogs"
|
|
20
|
-
};
|
|
21
|
-
const getPrismaDelegate = (client, model) => {
|
|
22
|
-
const delegate = Object.entries(client).find(([key]) => key === modelDelegates[model])?.[1];
|
|
23
|
-
if (delegate === void 0) throw new PrismaAdapterError(`missing model delegate "${model}"`);
|
|
24
|
-
if (!hasDelegateMethods(delegate)) throw new PrismaAdapterError(`invalid model delegate "${model}"`);
|
|
25
|
-
return delegate;
|
|
26
|
-
};
|
|
27
|
-
const readString = (row, field) => {
|
|
28
|
-
const value = row[field];
|
|
29
|
-
if (typeof value !== "string") throw new PrismaAdapterError(`expected string field "${field}"`);
|
|
30
|
-
return value;
|
|
31
|
-
};
|
|
32
|
-
const readNullableString = (row, field) => {
|
|
33
|
-
const value = row[field];
|
|
34
|
-
if (value === null) return null;
|
|
35
|
-
if (typeof value !== "string") throw new PrismaAdapterError(`expected nullable string field "${field}"`);
|
|
36
|
-
return value;
|
|
37
|
-
};
|
|
38
|
-
const readByteSize = (row, field) => {
|
|
39
|
-
const value = row[field];
|
|
40
|
-
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) throw new PrismaAdapterError(`expected byte-size field "${field}"`);
|
|
41
|
-
return value;
|
|
42
|
-
};
|
|
43
|
-
const parsePrismaBundleRow = (value) => {
|
|
44
|
-
if (!isRecord(value)) throw new PrismaAdapterError("invalid bundle row");
|
|
45
|
-
const platform = value["platform"];
|
|
46
|
-
if (platform !== "android" && platform !== "ios") throw new PrismaAdapterError("expected platform \"android\" or \"ios\"");
|
|
47
|
-
const metadata = value["metadata"];
|
|
48
|
-
if (!isDatabaseMetadataObject(metadata)) throw new PrismaAdapterError("invalid metadata field");
|
|
49
|
-
return {
|
|
50
|
-
id: readString(value, "id"),
|
|
51
|
-
platform,
|
|
52
|
-
file_hash: readString(value, "file_hash"),
|
|
53
|
-
git_commit_hash: readNullableString(value, "git_commit_hash"),
|
|
54
|
-
storage_uri: readString(value, "storage_uri"),
|
|
55
|
-
archive_byte_size: readByteSize(value, "archive_byte_size"),
|
|
56
|
-
metadata,
|
|
57
|
-
manifest_storage_uri: readNullableString(value, "manifest_storage_uri"),
|
|
58
|
-
manifest_file_hash: readNullableString(value, "manifest_file_hash"),
|
|
59
|
-
asset_base_storage_uri: readNullableString(value, "asset_base_storage_uri")
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
const parsePrismaChannelRow = (value) => {
|
|
63
|
-
if (!isRecord(value)) throw new PrismaAdapterError("invalid channel row");
|
|
64
|
-
return {
|
|
65
|
-
id: readString(value, "id"),
|
|
66
|
-
name: readString(value, "name")
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
const parsePrismaPatchRow = (value) => {
|
|
70
|
-
if (!isRecord(value)) throw new PrismaAdapterError("invalid patch row");
|
|
71
|
-
const orderIndex = value["order_index"];
|
|
72
|
-
if (typeof orderIndex !== "number") throw new PrismaAdapterError("invalid patch order_index field");
|
|
73
|
-
return {
|
|
74
|
-
id: readString(value, "id"),
|
|
75
|
-
bundle_id: readString(value, "bundle_id"),
|
|
76
|
-
base_bundle_id: readString(value, "base_bundle_id"),
|
|
77
|
-
base_file_hash: readString(value, "base_file_hash"),
|
|
78
|
-
patch_file_hash: readString(value, "patch_file_hash"),
|
|
79
|
-
patch_storage_uri: readString(value, "patch_storage_uri"),
|
|
80
|
-
byte_size: readByteSize(value, "byte_size"),
|
|
81
|
-
order_index: orderIndex
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
const readNumber = (row, field) => {
|
|
85
|
-
const value = row[field];
|
|
86
|
-
if (typeof value !== "number" || !Number.isFinite(value)) throw new PrismaAdapterError(`expected number field "${field}"`);
|
|
87
|
-
return value;
|
|
88
|
-
};
|
|
89
|
-
const parsePrismaBundleEventRow = (value) => {
|
|
90
|
-
if (!isRecord(value)) throw new PrismaAdapterError("invalid event row");
|
|
91
|
-
const type = readString(value, "type");
|
|
92
|
-
const platform = readString(value, "platform");
|
|
93
|
-
const fromBundleId = readNullableString(value, "from_bundle_id");
|
|
94
|
-
const updateStrategy = readNullableString(value, "update_strategy");
|
|
95
|
-
if (platform !== "ios" && platform !== "android" || !((type === "UPDATE_APPLIED" || type === "RECOVERED" || type === "RELEASE_ADOPTED") && typeof fromBundleId === "string" && (updateStrategy === "fingerprint" || updateStrategy === "appVersion") || type === "UNCHANGED" && fromBundleId === null && updateStrategy === null)) throw new PrismaAdapterError("invalid event shape");
|
|
96
|
-
return {
|
|
97
|
-
id: readString(value, "id"),
|
|
98
|
-
type,
|
|
99
|
-
install_id: readString(value, "install_id"),
|
|
100
|
-
user_id: readNullableString(value, "user_id"),
|
|
101
|
-
username: readNullableString(value, "username"),
|
|
102
|
-
from_release_id: readNullableString(value, "from_release_id"),
|
|
103
|
-
from_bundle_id: fromBundleId,
|
|
104
|
-
to_release_id: readNullableString(value, "to_release_id"),
|
|
105
|
-
to_bundle_id: readString(value, "to_bundle_id"),
|
|
106
|
-
platform,
|
|
107
|
-
app_version: readString(value, "app_version"),
|
|
108
|
-
channel: readString(value, "channel"),
|
|
109
|
-
cohort: readString(value, "cohort"),
|
|
110
|
-
update_strategy: updateStrategy,
|
|
111
|
-
fingerprint_hash: readNullableString(value, "fingerprint_hash"),
|
|
112
|
-
sdk_version: readNullableString(value, "sdk_version"),
|
|
113
|
-
received_at_ms: readNumber(value, "received_at_ms")
|
|
114
|
-
};
|
|
115
|
-
};
|
|
116
|
-
const parsePrismaApiKeyRow = (value) => {
|
|
117
|
-
if (!isRecord(value)) throw new PrismaAdapterError("invalid API key row");
|
|
118
|
-
const role = readString(value, "role");
|
|
119
|
-
if (role !== "client") throw new PrismaAdapterError("invalid API key role");
|
|
120
|
-
const revokedAt = value["revoked_at_ms"];
|
|
121
|
-
return {
|
|
122
|
-
id: readString(value, "id"),
|
|
123
|
-
hash: readString(value, "hash"),
|
|
124
|
-
name: readString(value, "name"),
|
|
125
|
-
prefix: readString(value, "prefix"),
|
|
126
|
-
role,
|
|
127
|
-
created_at_ms: readNumber(value, "created_at_ms"),
|
|
128
|
-
revoked_at_ms: revokedAt === null ? null : readNumber(value, "revoked_at_ms")
|
|
129
|
-
};
|
|
130
|
-
};
|
|
131
|
-
const parsePrismaReleaseRow = (value) => {
|
|
132
|
-
if (!isRecord(value)) throw new PrismaAdapterError("invalid Release row");
|
|
133
|
-
const platform = readString(value, "platform");
|
|
134
|
-
const kind = readString(value, "kind");
|
|
135
|
-
const strategy = readString(value, "strategy");
|
|
136
|
-
const operation = readString(value, "operation");
|
|
137
|
-
const targetCohorts = value["target_cohorts"];
|
|
138
|
-
if (platform !== "ios" && platform !== "android" || kind !== "BUNDLE" && kind !== "EMBEDDED" || strategy !== "APP_VERSION" && strategy !== "FINGERPRINT" || operation !== "DEPLOY" && operation !== "PROMOTE" && operation !== "ROLLBACK" || !Array.isArray(targetCohorts) || !targetCohorts.every((cohort) => typeof cohort === "string")) throw new PrismaAdapterError("invalid Release fields");
|
|
139
|
-
const enabled = value["enabled"];
|
|
140
|
-
const shouldForceUpdate = value["should_force_update"];
|
|
141
|
-
if (typeof enabled !== "boolean" || typeof shouldForceUpdate !== "boolean") throw new PrismaAdapterError("invalid Release policy fields");
|
|
142
|
-
return {
|
|
143
|
-
bundle_id: readNullableString(value, "bundle_id"),
|
|
144
|
-
channel_id: readString(value, "channel_id"),
|
|
145
|
-
created_at_ms: readNumber(value, "created_at_ms"),
|
|
146
|
-
enabled,
|
|
147
|
-
fingerprint_hash: readNullableString(value, "fingerprint_hash"),
|
|
148
|
-
id: readString(value, "id"),
|
|
149
|
-
kind,
|
|
150
|
-
message: readNullableString(value, "message"),
|
|
151
|
-
operation,
|
|
152
|
-
platform,
|
|
153
|
-
revision: readNumber(value, "revision"),
|
|
154
|
-
rollout_cohort_count: readNumber(value, "rollout_cohort_count"),
|
|
155
|
-
scope_key: readString(value, "scope_key"),
|
|
156
|
-
should_force_update: shouldForceUpdate,
|
|
157
|
-
source_release_id: readNullableString(value, "source_release_id"),
|
|
158
|
-
strategy,
|
|
159
|
-
target_app_version: readNullableString(value, "target_app_version"),
|
|
160
|
-
target_cohorts: targetCohorts,
|
|
161
|
-
updated_at_ms: readNumber(value, "updated_at_ms")
|
|
162
|
-
};
|
|
163
|
-
};
|
|
164
|
-
const parsePrismaReleaseCatalogRow = (value) => {
|
|
165
|
-
if (!isRecord(value)) throw new PrismaAdapterError("invalid catalog row");
|
|
166
|
-
const platform = readString(value, "platform");
|
|
167
|
-
const strategy = readString(value, "strategy");
|
|
168
|
-
const isTombstone = value["is_tombstone"];
|
|
169
|
-
if (platform !== "ios" && platform !== "android" || strategy !== "APP_VERSION" && strategy !== "FINGERPRINT" || typeof isTombstone !== "boolean") throw new PrismaAdapterError("invalid catalog fields");
|
|
170
|
-
return {
|
|
171
|
-
catalog_id: readString(value, "catalog_id"),
|
|
172
|
-
byte_size: readNumber(value, "byte_size"),
|
|
173
|
-
catalog_hash: readString(value, "catalog_hash"),
|
|
174
|
-
channel_id: readString(value, "channel_id"),
|
|
175
|
-
channel_key: readString(value, "channel_key"),
|
|
176
|
-
fingerprint_hash: readNullableString(value, "fingerprint_hash"),
|
|
177
|
-
generation: readNumber(value, "generation"),
|
|
178
|
-
is_tombstone: isTombstone,
|
|
179
|
-
payload: readString(value, "payload"),
|
|
180
|
-
platform,
|
|
181
|
-
scope_key: readString(value, "scope_key"),
|
|
182
|
-
strategy,
|
|
183
|
-
updated_at_ms: readNumber(value, "updated_at_ms")
|
|
184
|
-
};
|
|
185
|
-
};
|
|
186
|
-
const parsePrismaRows = (rows, parse) => rows.map(parse);
|
|
187
|
-
//#endregion
|
|
188
|
-
export { PrismaAdapterError, getPrismaDelegate, parsePrismaApiKeyRow, parsePrismaBundleEventRow, parsePrismaBundleRow, parsePrismaChannelRow, parsePrismaPatchRow, parsePrismaReleaseCatalogRow, parsePrismaReleaseRow, parsePrismaRows };
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
-
const require_releaseCatalog = require("./releaseCatalog.cjs");
|
|
3
|
-
let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
|
|
4
|
-
let _hot_updater_core = require("@hot-updater/core");
|
|
5
|
-
//#region src/db/databasePluginCore.ts
|
|
6
|
-
function createDatabasePluginCore(database, resolveFileUrl, options) {
|
|
7
|
-
const client = (0, _hot_updater_plugin_core.createDatabaseClient)(database);
|
|
8
|
-
const beforeOperation = options?.beforeOperation;
|
|
9
|
-
const getReleaseCatalog = require_releaseCatalog.createReleaseCatalogReader(database);
|
|
10
|
-
const getArtifact = require_releaseCatalog.createArtifactResolver({
|
|
11
|
-
database,
|
|
12
|
-
readStorageText: options?.readStorageText,
|
|
13
|
-
resolveFileUrl
|
|
14
|
-
});
|
|
15
|
-
return {
|
|
16
|
-
api: {
|
|
17
|
-
async getBundleById(id) {
|
|
18
|
-
await beforeOperation?.();
|
|
19
|
-
return client.getBundleById(id);
|
|
20
|
-
},
|
|
21
|
-
async getReleaseCatalog(input) {
|
|
22
|
-
await beforeOperation?.();
|
|
23
|
-
return getReleaseCatalog(input);
|
|
24
|
-
},
|
|
25
|
-
async getArtifactInfo(targetBundleId, currentBundleId) {
|
|
26
|
-
await beforeOperation?.();
|
|
27
|
-
return getArtifact(targetBundleId, currentBundleId);
|
|
28
|
-
},
|
|
29
|
-
async getReleaseById(id) {
|
|
30
|
-
await beforeOperation?.();
|
|
31
|
-
return database.models.releases.findById(id);
|
|
32
|
-
},
|
|
33
|
-
async getReleasesByScope(input) {
|
|
34
|
-
await beforeOperation?.();
|
|
35
|
-
return database.models.releases.findManyByScope({
|
|
36
|
-
...input,
|
|
37
|
-
consistency: "strong"
|
|
38
|
-
});
|
|
39
|
-
},
|
|
40
|
-
async getReleases(input) {
|
|
41
|
-
await beforeOperation?.();
|
|
42
|
-
return database.models.releases.findMany(input);
|
|
43
|
-
},
|
|
44
|
-
async getReleaseCatalogByScopeKey(scopeKey) {
|
|
45
|
-
await beforeOperation?.();
|
|
46
|
-
return database.models.releaseCatalogs.findByScopeKey(scopeKey);
|
|
47
|
-
},
|
|
48
|
-
async getReleaseCatalogs(input) {
|
|
49
|
-
await beforeOperation?.();
|
|
50
|
-
return database.models.releaseCatalogs.findMany(input);
|
|
51
|
-
},
|
|
52
|
-
async updateReleasePolicy(input) {
|
|
53
|
-
await beforeOperation?.();
|
|
54
|
-
return (0, _hot_updater_plugin_core.updateReleasePolicy)({
|
|
55
|
-
database,
|
|
56
|
-
...input
|
|
57
|
-
});
|
|
58
|
-
},
|
|
59
|
-
async preflightReleasePolicy(input) {
|
|
60
|
-
await beforeOperation?.();
|
|
61
|
-
return (0, _hot_updater_plugin_core.preflightReleasePolicy)({
|
|
62
|
-
database,
|
|
63
|
-
...input
|
|
64
|
-
});
|
|
65
|
-
},
|
|
66
|
-
async deleteRelease(input) {
|
|
67
|
-
await beforeOperation?.();
|
|
68
|
-
return (0, _hot_updater_plugin_core.deleteRelease)({
|
|
69
|
-
database,
|
|
70
|
-
...input
|
|
71
|
-
});
|
|
72
|
-
},
|
|
73
|
-
async rebuildReleaseCatalog(scopeKey) {
|
|
74
|
-
await beforeOperation?.();
|
|
75
|
-
const catalog = await database.models.releaseCatalogs.findByScopeKey(scopeKey);
|
|
76
|
-
if (catalog === null) throw new Error(`Release catalog "${scopeKey}" was not found.`);
|
|
77
|
-
return (0, _hot_updater_plugin_core.rebuildReleaseCatalog)({
|
|
78
|
-
database,
|
|
79
|
-
scope: {
|
|
80
|
-
channelId: catalog.channel_id,
|
|
81
|
-
channelName: (0, _hot_updater_core.decodeChannelKey)(catalog.channel_key),
|
|
82
|
-
fingerprintHash: catalog.fingerprint_hash,
|
|
83
|
-
platform: catalog.platform,
|
|
84
|
-
scopeKey: catalog.scope_key,
|
|
85
|
-
strategy: catalog.strategy
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
},
|
|
89
|
-
async commitDatabase(input) {
|
|
90
|
-
await beforeOperation?.();
|
|
91
|
-
return database.commit(input);
|
|
92
|
-
},
|
|
93
|
-
async getChannels() {
|
|
94
|
-
await beforeOperation?.();
|
|
95
|
-
return client.getChannels();
|
|
96
|
-
},
|
|
97
|
-
async insertChannel(input) {
|
|
98
|
-
await beforeOperation?.();
|
|
99
|
-
return database.models.channels.insert(input);
|
|
100
|
-
},
|
|
101
|
-
async deleteChannel(input) {
|
|
102
|
-
await beforeOperation?.();
|
|
103
|
-
return database.models.channels.delete(input);
|
|
104
|
-
},
|
|
105
|
-
async getBundles(options) {
|
|
106
|
-
await beforeOperation?.();
|
|
107
|
-
return client.getBundles(options);
|
|
108
|
-
},
|
|
109
|
-
async insertBundle(bundle) {
|
|
110
|
-
await beforeOperation?.();
|
|
111
|
-
await client.insertBundle(bundle);
|
|
112
|
-
},
|
|
113
|
-
async insertBundles(bundles) {
|
|
114
|
-
await beforeOperation?.();
|
|
115
|
-
await client.mutate(async (transaction) => {
|
|
116
|
-
for (const bundle of bundles) await transaction.insertBundle(bundle);
|
|
117
|
-
});
|
|
118
|
-
},
|
|
119
|
-
async updateBundleById(bundleId, update) {
|
|
120
|
-
await beforeOperation?.();
|
|
121
|
-
await client.updateBundleById(bundleId, update);
|
|
122
|
-
},
|
|
123
|
-
async deleteBundleById(bundleId) {
|
|
124
|
-
await beforeOperation?.();
|
|
125
|
-
await client.deleteBundleById(bundleId);
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
adapterName: database.name,
|
|
129
|
-
createMigrator: () => {
|
|
130
|
-
throw new Error("createMigrator is only available for Kysely/MongoDB database plugins.");
|
|
131
|
-
},
|
|
132
|
-
generateSchema: () => {
|
|
133
|
-
throw new Error("generateSchema is only available for Drizzle/Prisma database plugins.");
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
//#endregion
|
|
138
|
-
exports.createDatabasePluginCore = createDatabasePluginCore;
|