@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
package/dist/insights/errors.mjs
CHANGED
|
@@ -1,20 +1,47 @@
|
|
|
1
|
+
import { DatabaseConflictError } from "../database/errors.mjs";
|
|
1
2
|
//#region src/insights/errors.ts
|
|
2
|
-
var InsightsScanLimitExceededError = class extends Error {
|
|
3
|
-
constructor(limit) {
|
|
4
|
-
super(`Insights event scan exceeded ${limit} rows.`);
|
|
5
|
-
this.limit = limit;
|
|
6
|
-
this.name = "InsightsScanLimitExceededError";
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
3
|
var InsightsBadRequestError = class extends Error {
|
|
10
4
|
name = "InsightsBadRequestError";
|
|
11
5
|
};
|
|
12
6
|
var InsightsPayloadTooLargeError = class extends Error {
|
|
7
|
+
maximumBytes;
|
|
13
8
|
name = "InsightsPayloadTooLargeError";
|
|
14
9
|
constructor(maximumBytes) {
|
|
15
10
|
super(`Event payload exceeds ${maximumBytes} bytes`);
|
|
16
11
|
this.maximumBytes = maximumBytes;
|
|
17
12
|
}
|
|
18
13
|
};
|
|
14
|
+
/** Error names the AWS SDKs give a throttled request, as their retry strategy classifies them. */
|
|
15
|
+
const THROTTLING_NAMES = /* @__PURE__ */ new Set([
|
|
16
|
+
"ProvisionedThroughputExceededException",
|
|
17
|
+
"RequestLimitExceeded",
|
|
18
|
+
"RequestThrottled",
|
|
19
|
+
"RequestThrottledException",
|
|
20
|
+
"SlowDown",
|
|
21
|
+
"ThrottledException",
|
|
22
|
+
"Throttling",
|
|
23
|
+
"ThrottlingException",
|
|
24
|
+
"TooManyRequestsException"
|
|
25
|
+
]);
|
|
26
|
+
/** gRPC's RESOURCE_EXHAUSTED, the status Firestore throttles a request with. */
|
|
27
|
+
const RESOURCE_EXHAUSTED = 8;
|
|
28
|
+
/**
|
|
29
|
+
* Whether the database is busy rather than broken, so the same request can
|
|
30
|
+
* succeed later: a transaction ran out of retries, or the backend throttled
|
|
31
|
+
* a request. Writes already retry transient failures, throttled ones
|
|
32
|
+
* included, until the budget runs out. A throttled read throws the backend's
|
|
33
|
+
* own error, so it is recognized by what the backends call it: a name the
|
|
34
|
+
* AWS SDKs retry as throttling, HTTP 429, or gRPC's RESOURCE_EXHAUSTED.
|
|
35
|
+
*/
|
|
36
|
+
const isDatabaseBusyError = (error) => {
|
|
37
|
+
if (error instanceof DatabaseConflictError) return true;
|
|
38
|
+
if (typeof error !== "object" || error === null) return false;
|
|
39
|
+
const { name, code, message, status, statusCode, $metadata } = error;
|
|
40
|
+
return typeof name === "string" && THROTTLING_NAMES.has(name) || [
|
|
41
|
+
status,
|
|
42
|
+
statusCode,
|
|
43
|
+
$metadata?.httpStatusCode
|
|
44
|
+
].includes(429) || code === RESOURCE_EXHAUSTED && typeof message === "string" && message.includes("RESOURCE_EXHAUSTED");
|
|
45
|
+
};
|
|
19
46
|
//#endregion
|
|
20
|
-
export { InsightsBadRequestError, InsightsPayloadTooLargeError,
|
|
47
|
+
export { InsightsBadRequestError, InsightsPayloadTooLargeError, isDatabaseBusyError };
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
const require_errors = require("./errors.cjs");
|
|
2
|
+
let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
|
|
2
3
|
//#region src/insights/eventInput.ts
|
|
3
4
|
const MAX_EVENT_STRING_LENGTH = 1024;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
"type",
|
|
7
|
-
"installId",
|
|
8
|
-
"toBundleId",
|
|
9
|
-
"userId",
|
|
10
|
-
"username",
|
|
11
|
-
"platform",
|
|
12
|
-
"appVersion",
|
|
13
|
-
"channel",
|
|
14
|
-
"cohort",
|
|
15
|
-
"fingerprintHash",
|
|
16
|
-
"fromBundleId",
|
|
17
|
-
"fromReleaseId",
|
|
18
|
-
"toReleaseId",
|
|
19
|
-
"updateStrategy",
|
|
20
|
-
"sdkVersion"
|
|
21
|
-
]);
|
|
5
|
+
const MAX_IDENTITY_LENGTH = 255;
|
|
6
|
+
const EVENT_BODY_MAX_BYTES = 16384;
|
|
22
7
|
function isRecord(value) {
|
|
23
8
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24
9
|
}
|
|
25
10
|
function requireStringField(payload, key) {
|
|
26
11
|
const value = payload[key];
|
|
27
|
-
if (typeof value !== "string" || value.length === 0 || value.length > MAX_EVENT_STRING_LENGTH) throw new require_errors.InsightsBadRequestError(`Invalid event field: ${key}`);
|
|
12
|
+
if (typeof value !== "string" || value.length === 0 || value.length > MAX_EVENT_STRING_LENGTH || new TextDecoder("utf-8", { ignoreBOM: true }).decode(new TextEncoder().encode(value)) !== value) throw new require_errors.InsightsBadRequestError(`Invalid event field: ${key}`);
|
|
28
13
|
return value;
|
|
29
14
|
}
|
|
30
15
|
function requireNullableStringField(payload, key) {
|
|
31
16
|
if (payload[key] === null) return null;
|
|
32
17
|
return requireStringField(payload, key);
|
|
33
18
|
}
|
|
19
|
+
function requireIdentityField(payload, key) {
|
|
20
|
+
const value = requireStringField(payload, key);
|
|
21
|
+
if (value.length > MAX_IDENTITY_LENGTH) throw new require_errors.InsightsBadRequestError(`Invalid event field: ${key}`);
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The report's idempotency key, when the client sends one: it creates the
|
|
26
|
+
* UUIDv7 once and repeats it on every retry of that report.
|
|
27
|
+
*/
|
|
28
|
+
function readEventId(payload) {
|
|
29
|
+
const value = payload.eventId;
|
|
30
|
+
if (value === void 0) return void 0;
|
|
31
|
+
if (!(0, _hot_updater_plugin_core.isUUIDv7)(value)) throw new require_errors.InsightsBadRequestError("Invalid event field: eventId");
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
34
|
async function readBoundedText(request) {
|
|
35
35
|
const contentLength = request.headers.get("content-length");
|
|
36
36
|
const declaredByteLength = Number(contentLength);
|
|
@@ -62,13 +62,15 @@ async function parseJson(request) {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
function requireEvent(payload) {
|
|
65
|
-
if (!isRecord(payload)
|
|
65
|
+
if (!isRecord(payload)) throw new require_errors.InsightsBadRequestError("Invalid event payload");
|
|
66
66
|
const platform = requireStringField(payload, "platform");
|
|
67
67
|
if (platform !== "ios" && platform !== "android") throw new require_errors.InsightsBadRequestError("Invalid event field: platform");
|
|
68
|
+
const eventId = readEventId(payload);
|
|
68
69
|
const base = {
|
|
69
|
-
|
|
70
|
+
...eventId === void 0 ? {} : { eventId },
|
|
71
|
+
installId: requireIdentityField(payload, "installId"),
|
|
70
72
|
toBundleId: requireStringField(payload, "toBundleId"),
|
|
71
|
-
...payload.userId === void 0 ? {} : { userId:
|
|
73
|
+
...payload.userId === void 0 ? {} : { userId: requireIdentityField(payload, "userId") },
|
|
72
74
|
...payload.username === void 0 ? {} : { username: requireStringField(payload, "username") },
|
|
73
75
|
platform,
|
|
74
76
|
appVersion: requireStringField(payload, "appVersion"),
|
|
@@ -81,9 +83,9 @@ function requireEvent(payload) {
|
|
|
81
83
|
};
|
|
82
84
|
const type = requireStringField(payload, "type");
|
|
83
85
|
switch (type) {
|
|
86
|
+
case "UPDATE_DOWNLOADED":
|
|
84
87
|
case "UPDATE_APPLIED":
|
|
85
|
-
case "RECOVERED":
|
|
86
|
-
case "RELEASE_ADOPTED": {
|
|
88
|
+
case "RECOVERED": {
|
|
87
89
|
const updateStrategy = requireStringField(payload, "updateStrategy");
|
|
88
90
|
if (updateStrategy !== "fingerprint" && updateStrategy !== "appVersion") throw new require_errors.InsightsBadRequestError("Invalid event field: updateStrategy");
|
|
89
91
|
return {
|
|
@@ -107,5 +109,43 @@ function requireEvent(payload) {
|
|
|
107
109
|
async function parseBundleEventRequest(request) {
|
|
108
110
|
return requireEvent(await parseJson(request));
|
|
109
111
|
}
|
|
112
|
+
function createBundleEventRow(input) {
|
|
113
|
+
input = requireEvent(input);
|
|
114
|
+
const base = {
|
|
115
|
+
app_version: input.appVersion,
|
|
116
|
+
channel: input.channel,
|
|
117
|
+
from_release_id: input.fromReleaseId,
|
|
118
|
+
id: input.eventId ?? (0, _hot_updater_plugin_core.createUUIDv7)(),
|
|
119
|
+
install_id: input.installId,
|
|
120
|
+
platform: input.platform,
|
|
121
|
+
received_at_ms: Date.now(),
|
|
122
|
+
to_bundle_id: input.toBundleId,
|
|
123
|
+
to_release_id: input.toReleaseId,
|
|
124
|
+
user_id: input.userId ?? null,
|
|
125
|
+
metadata: {
|
|
126
|
+
cohort: input.cohort,
|
|
127
|
+
fingerprint_hash: input.fingerprintHash,
|
|
128
|
+
sdk_version: input.sdkVersion ?? null,
|
|
129
|
+
username: input.username ?? null,
|
|
130
|
+
update_strategy: input.updateStrategy
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
switch (input.type) {
|
|
134
|
+
case "UPDATE_DOWNLOADED":
|
|
135
|
+
case "UPDATE_APPLIED":
|
|
136
|
+
case "RECOVERED": return {
|
|
137
|
+
...base,
|
|
138
|
+
from_bundle_id: input.fromBundleId,
|
|
139
|
+
type: input.type
|
|
140
|
+
};
|
|
141
|
+
case "UNCHANGED": return {
|
|
142
|
+
...base,
|
|
143
|
+
from_bundle_id: null,
|
|
144
|
+
type: input.type
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
}
|
|
110
148
|
//#endregion
|
|
149
|
+
exports.EVENT_BODY_MAX_BYTES = EVENT_BODY_MAX_BYTES;
|
|
150
|
+
exports.createBundleEventRow = createBundleEventRow;
|
|
111
151
|
exports.parseBundleEventRequest = parseBundleEventRequest;
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
import { InsightsBadRequestError, InsightsPayloadTooLargeError } from "./errors.mjs";
|
|
2
|
+
import { createUUIDv7, isUUIDv7 } from "@hot-updater/plugin-core";
|
|
2
3
|
//#region src/insights/eventInput.ts
|
|
3
4
|
const MAX_EVENT_STRING_LENGTH = 1024;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
"type",
|
|
7
|
-
"installId",
|
|
8
|
-
"toBundleId",
|
|
9
|
-
"userId",
|
|
10
|
-
"username",
|
|
11
|
-
"platform",
|
|
12
|
-
"appVersion",
|
|
13
|
-
"channel",
|
|
14
|
-
"cohort",
|
|
15
|
-
"fingerprintHash",
|
|
16
|
-
"fromBundleId",
|
|
17
|
-
"fromReleaseId",
|
|
18
|
-
"toReleaseId",
|
|
19
|
-
"updateStrategy",
|
|
20
|
-
"sdkVersion"
|
|
21
|
-
]);
|
|
5
|
+
const MAX_IDENTITY_LENGTH = 255;
|
|
6
|
+
const EVENT_BODY_MAX_BYTES = 16384;
|
|
22
7
|
function isRecord(value) {
|
|
23
8
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24
9
|
}
|
|
25
10
|
function requireStringField(payload, key) {
|
|
26
11
|
const value = payload[key];
|
|
27
|
-
if (typeof value !== "string" || value.length === 0 || value.length > MAX_EVENT_STRING_LENGTH) throw new InsightsBadRequestError(`Invalid event field: ${key}`);
|
|
12
|
+
if (typeof value !== "string" || value.length === 0 || value.length > MAX_EVENT_STRING_LENGTH || new TextDecoder("utf-8", { ignoreBOM: true }).decode(new TextEncoder().encode(value)) !== value) throw new InsightsBadRequestError(`Invalid event field: ${key}`);
|
|
28
13
|
return value;
|
|
29
14
|
}
|
|
30
15
|
function requireNullableStringField(payload, key) {
|
|
31
16
|
if (payload[key] === null) return null;
|
|
32
17
|
return requireStringField(payload, key);
|
|
33
18
|
}
|
|
19
|
+
function requireIdentityField(payload, key) {
|
|
20
|
+
const value = requireStringField(payload, key);
|
|
21
|
+
if (value.length > MAX_IDENTITY_LENGTH) throw new InsightsBadRequestError(`Invalid event field: ${key}`);
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The report's idempotency key, when the client sends one: it creates the
|
|
26
|
+
* UUIDv7 once and repeats it on every retry of that report.
|
|
27
|
+
*/
|
|
28
|
+
function readEventId(payload) {
|
|
29
|
+
const value = payload.eventId;
|
|
30
|
+
if (value === void 0) return void 0;
|
|
31
|
+
if (!isUUIDv7(value)) throw new InsightsBadRequestError("Invalid event field: eventId");
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
34
|
async function readBoundedText(request) {
|
|
35
35
|
const contentLength = request.headers.get("content-length");
|
|
36
36
|
const declaredByteLength = Number(contentLength);
|
|
@@ -62,13 +62,15 @@ async function parseJson(request) {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
function requireEvent(payload) {
|
|
65
|
-
if (!isRecord(payload)
|
|
65
|
+
if (!isRecord(payload)) throw new InsightsBadRequestError("Invalid event payload");
|
|
66
66
|
const platform = requireStringField(payload, "platform");
|
|
67
67
|
if (platform !== "ios" && platform !== "android") throw new InsightsBadRequestError("Invalid event field: platform");
|
|
68
|
+
const eventId = readEventId(payload);
|
|
68
69
|
const base = {
|
|
69
|
-
|
|
70
|
+
...eventId === void 0 ? {} : { eventId },
|
|
71
|
+
installId: requireIdentityField(payload, "installId"),
|
|
70
72
|
toBundleId: requireStringField(payload, "toBundleId"),
|
|
71
|
-
...payload.userId === void 0 ? {} : { userId:
|
|
73
|
+
...payload.userId === void 0 ? {} : { userId: requireIdentityField(payload, "userId") },
|
|
72
74
|
...payload.username === void 0 ? {} : { username: requireStringField(payload, "username") },
|
|
73
75
|
platform,
|
|
74
76
|
appVersion: requireStringField(payload, "appVersion"),
|
|
@@ -81,9 +83,9 @@ function requireEvent(payload) {
|
|
|
81
83
|
};
|
|
82
84
|
const type = requireStringField(payload, "type");
|
|
83
85
|
switch (type) {
|
|
86
|
+
case "UPDATE_DOWNLOADED":
|
|
84
87
|
case "UPDATE_APPLIED":
|
|
85
|
-
case "RECOVERED":
|
|
86
|
-
case "RELEASE_ADOPTED": {
|
|
88
|
+
case "RECOVERED": {
|
|
87
89
|
const updateStrategy = requireStringField(payload, "updateStrategy");
|
|
88
90
|
if (updateStrategy !== "fingerprint" && updateStrategy !== "appVersion") throw new InsightsBadRequestError("Invalid event field: updateStrategy");
|
|
89
91
|
return {
|
|
@@ -107,5 +109,41 @@ function requireEvent(payload) {
|
|
|
107
109
|
async function parseBundleEventRequest(request) {
|
|
108
110
|
return requireEvent(await parseJson(request));
|
|
109
111
|
}
|
|
112
|
+
function createBundleEventRow(input) {
|
|
113
|
+
input = requireEvent(input);
|
|
114
|
+
const base = {
|
|
115
|
+
app_version: input.appVersion,
|
|
116
|
+
channel: input.channel,
|
|
117
|
+
from_release_id: input.fromReleaseId,
|
|
118
|
+
id: input.eventId ?? createUUIDv7(),
|
|
119
|
+
install_id: input.installId,
|
|
120
|
+
platform: input.platform,
|
|
121
|
+
received_at_ms: Date.now(),
|
|
122
|
+
to_bundle_id: input.toBundleId,
|
|
123
|
+
to_release_id: input.toReleaseId,
|
|
124
|
+
user_id: input.userId ?? null,
|
|
125
|
+
metadata: {
|
|
126
|
+
cohort: input.cohort,
|
|
127
|
+
fingerprint_hash: input.fingerprintHash,
|
|
128
|
+
sdk_version: input.sdkVersion ?? null,
|
|
129
|
+
username: input.username ?? null,
|
|
130
|
+
update_strategy: input.updateStrategy
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
switch (input.type) {
|
|
134
|
+
case "UPDATE_DOWNLOADED":
|
|
135
|
+
case "UPDATE_APPLIED":
|
|
136
|
+
case "RECOVERED": return {
|
|
137
|
+
...base,
|
|
138
|
+
from_bundle_id: input.fromBundleId,
|
|
139
|
+
type: input.type
|
|
140
|
+
};
|
|
141
|
+
case "UNCHANGED": return {
|
|
142
|
+
...base,
|
|
143
|
+
from_bundle_id: null,
|
|
144
|
+
type: input.type
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
}
|
|
110
148
|
//#endregion
|
|
111
|
-
export { parseBundleEventRequest };
|
|
149
|
+
export { EVENT_BODY_MAX_BYTES, createBundleEventRow, parseBundleEventRequest };
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
const require_errors = require("./errors.cjs");
|
|
2
|
+
const require_eventInput = require("./eventInput.cjs");
|
|
3
|
+
let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
|
|
4
|
+
//#region src/insights/provider.ts
|
|
5
|
+
const DEFAULT_PAGE_LIMIT = 50;
|
|
6
|
+
const MAX_PAGE_LIMIT = 100;
|
|
7
|
+
const MAX_EVENT_ID_LENGTH = 1024;
|
|
8
|
+
const MAX_IDENTITY_LENGTH = 255;
|
|
9
|
+
const MAX_CURSOR_LENGTH = 8192;
|
|
10
|
+
const HOUR_MS = 36e5;
|
|
11
|
+
const WINDOW_MS = {
|
|
12
|
+
"24h": 864e5,
|
|
13
|
+
"7d": 6048e5,
|
|
14
|
+
"30d": 2592e6
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The longest receipt range, `[sinceMs, beforeReceivedAtMs)`, of a global or
|
|
18
|
+
* bundle event list, and the range one covers without `sinceMs`: raw events
|
|
19
|
+
* are listed inside a time range, as analytics products list them. It is a
|
|
20
|
+
* duration, so a range that ends mid-day touches 91 UTC days. Installation
|
|
21
|
+
* history is one index range and reads back to `sinceMs`.
|
|
22
|
+
*/
|
|
23
|
+
const EVENT_LIST_RANGE_MS = 2160 * HOUR_MS;
|
|
24
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25
|
+
const requireString = (value, label, maximumLength) => {
|
|
26
|
+
if (typeof value !== "string" || value.length === 0 || value.length > maximumLength || new TextDecoder("utf-8", { ignoreBOM: true }).decode(new TextEncoder().encode(value)) !== value) throw new require_errors.InsightsBadRequestError(`Invalid ${label}.`);
|
|
27
|
+
return value;
|
|
28
|
+
};
|
|
29
|
+
const requireTimestamp = (value, label) => {
|
|
30
|
+
if (!Number.isSafeInteger(value) || Number(value) < 0) throw new require_errors.InsightsBadRequestError(`Invalid ${label}.`);
|
|
31
|
+
return Number(value);
|
|
32
|
+
};
|
|
33
|
+
const readLimit = (value) => {
|
|
34
|
+
const limit = value ?? DEFAULT_PAGE_LIMIT;
|
|
35
|
+
if (!Number.isSafeInteger(limit) || limit < 1 || limit > MAX_PAGE_LIMIT) throw new require_errors.InsightsBadRequestError("Invalid page limit.");
|
|
36
|
+
return limit;
|
|
37
|
+
};
|
|
38
|
+
const encodeBase64Url = (value) => {
|
|
39
|
+
const bytes = new TextEncoder().encode(value);
|
|
40
|
+
let binary = "";
|
|
41
|
+
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
42
|
+
return btoa(binary).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/u, "");
|
|
43
|
+
};
|
|
44
|
+
const decodeBase64Url = (value) => {
|
|
45
|
+
if (value.length === 0 || value.length > MAX_CURSOR_LENGTH) throw new require_errors.InsightsBadRequestError("Invalid Insights cursor.");
|
|
46
|
+
try {
|
|
47
|
+
const base64 = value.replaceAll("-", "+").replaceAll("_", "/");
|
|
48
|
+
const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
|
|
49
|
+
const binary = atob(padded);
|
|
50
|
+
const bytes = Uint8Array.from(binary, (character) => character.charCodeAt(0));
|
|
51
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
52
|
+
} catch {
|
|
53
|
+
throw new require_errors.InsightsBadRequestError("Invalid Insights cursor.");
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const encodeCursor = (value) => encodeBase64Url(JSON.stringify(value));
|
|
57
|
+
const decodeCursor = (value) => {
|
|
58
|
+
try {
|
|
59
|
+
return JSON.parse(decodeBase64Url(value));
|
|
60
|
+
} catch (error) {
|
|
61
|
+
if (error instanceof require_errors.InsightsBadRequestError) throw error;
|
|
62
|
+
throw new require_errors.InsightsBadRequestError("Invalid Insights cursor.");
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const readScope = (input) => {
|
|
66
|
+
if (input.platform !== "ios" && input.platform !== "android") throw new require_errors.InsightsBadRequestError("Invalid Insights platform.");
|
|
67
|
+
return {
|
|
68
|
+
platform: input.platform,
|
|
69
|
+
channel: requireString(input.channel, "channel", MAX_EVENT_ID_LENGTH)
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
const bundleFilter = (input) => {
|
|
73
|
+
const scope = readScope(input);
|
|
74
|
+
const bundleId = requireString(input.bundleId, "bundle ID", MAX_EVENT_ID_LENGTH);
|
|
75
|
+
switch (input.outcome) {
|
|
76
|
+
case "downloaded": return {
|
|
77
|
+
...scope,
|
|
78
|
+
type: "UPDATE_DOWNLOADED",
|
|
79
|
+
toBundleId: bundleId
|
|
80
|
+
};
|
|
81
|
+
case "applied": return {
|
|
82
|
+
...scope,
|
|
83
|
+
type: "UPDATE_APPLIED",
|
|
84
|
+
toBundleId: bundleId
|
|
85
|
+
};
|
|
86
|
+
case "recovered": return {
|
|
87
|
+
...scope,
|
|
88
|
+
type: "RECOVERED",
|
|
89
|
+
fromBundleId: bundleId
|
|
90
|
+
};
|
|
91
|
+
case "unchanged": return {
|
|
92
|
+
...scope,
|
|
93
|
+
type: "UNCHANGED",
|
|
94
|
+
toBundleId: bundleId
|
|
95
|
+
};
|
|
96
|
+
default: throw new require_errors.InsightsBadRequestError("Invalid Insights outcome.");
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const sameFilter = (left, right) => {
|
|
100
|
+
if (!isRecord(left) || left.kind !== right.kind) return false;
|
|
101
|
+
switch (right.kind) {
|
|
102
|
+
case "all": return true;
|
|
103
|
+
case "installationMovement": return left.installId === right.installId;
|
|
104
|
+
case "bundle": return left.platform === right.platform && left.channel === right.channel && left.type === right.type && (right.type === "RECOVERED" ? left.fromBundleId === right.fromBundleId : left.toBundleId === right.toBundleId);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
const readEventCursor = (value, filter) => {
|
|
108
|
+
const cursor = decodeCursor(value);
|
|
109
|
+
if (!isRecord(cursor) || cursor.version !== 2 || cursor.kind !== "events" || !isRecord(cursor.filter) || !isRecord(cursor.after)) throw new require_errors.InsightsBadRequestError("Invalid Insights cursor.");
|
|
110
|
+
if (!sameFilter(cursor.filter, filter)) throw new require_errors.InsightsBadRequestError("Insights cursor does not match the requested events.");
|
|
111
|
+
if (typeof cursor.after.id !== "string" || !(0, _hot_updater_plugin_core.isUUIDv7)(cursor.after.id)) throw new require_errors.InsightsBadRequestError("Invalid Insights event cursor ID.");
|
|
112
|
+
return {
|
|
113
|
+
after: {
|
|
114
|
+
id: cursor.after.id,
|
|
115
|
+
receivedAtMs: requireTimestamp(cursor.after.receivedAtMs, "event cursor")
|
|
116
|
+
},
|
|
117
|
+
beforeReceivedAtMs: requireTimestamp(cursor.beforeReceivedAtMs, "event cutoff"),
|
|
118
|
+
kind: "events",
|
|
119
|
+
sinceMs: requireTimestamp(cursor.sinceMs, "event start"),
|
|
120
|
+
filter,
|
|
121
|
+
version: 2
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
const readUserInstallationCursor = (value, userId) => {
|
|
125
|
+
const cursor = decodeCursor(value);
|
|
126
|
+
if (!isRecord(cursor) || cursor.version !== 1 || cursor.kind !== "user-installations" || cursor.userId !== userId) throw new require_errors.InsightsBadRequestError("Insights cursor does not match the requested user ID.");
|
|
127
|
+
return {
|
|
128
|
+
afterInstallId: requireString(cursor.afterInstallId, "installation cursor", MAX_IDENTITY_LENGTH),
|
|
129
|
+
kind: "user-installations",
|
|
130
|
+
userId,
|
|
131
|
+
version: 1
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
const compareEventNewest = (left, right) => right.received_at_ms - left.received_at_ms || (0, _hot_updater_plugin_core.compareInsightsText)(right.id, left.id);
|
|
135
|
+
const isAfterEventCursor = (row, after) => row.received_at_ms < after.receivedAtMs || row.received_at_ms === after.receivedAtMs && (0, _hot_updater_plugin_core.compareInsightsText)(row.id, after.id) < 0;
|
|
136
|
+
const assertEventRows = (rows, input) => {
|
|
137
|
+
if (rows.length > input.limit) throw new Error("Insights database returned too many event rows.");
|
|
138
|
+
for (let index = 0; index < rows.length; index += 1) {
|
|
139
|
+
const row = rows[index];
|
|
140
|
+
const previous = rows[index - 1];
|
|
141
|
+
if (!row || typeof row.id !== "string" || !(0, _hot_updater_plugin_core.isUUIDv7)(row.id) || !Number.isSafeInteger(row.received_at_ms) || row.received_at_ms >= input.beforeReceivedAtMs || row.received_at_ms < input.sinceMs || previous !== void 0 && compareEventNewest(previous, row) >= 0 || input.after !== void 0 && !isAfterEventCursor(row, input.after) || input.filter.kind === "installationMovement" && (row.install_id !== input.filter.installId || !(0, _hot_updater_plugin_core.isInsightsMovementEvent)(row)) || input.filter.kind === "bundle" && (row.platform !== input.filter.platform || row.channel !== input.filter.channel || row.type !== input.filter.type || (input.filter.type === "RECOVERED" ? row.from_bundle_id !== input.filter.fromBundleId : row.to_bundle_id !== input.filter.toBundleId))) throw new Error("Insights database returned invalid event rows.");
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
const toEventHistoryRow = (row) => ({
|
|
145
|
+
appVersion: row.app_version,
|
|
146
|
+
channel: row.channel,
|
|
147
|
+
cohort: row.metadata.cohort,
|
|
148
|
+
fromBundleId: row.from_bundle_id,
|
|
149
|
+
id: row.id,
|
|
150
|
+
installId: row.install_id,
|
|
151
|
+
platform: row.platform,
|
|
152
|
+
receivedAtMs: row.received_at_ms,
|
|
153
|
+
toBundleId: row.to_bundle_id,
|
|
154
|
+
type: row.type,
|
|
155
|
+
userId: row.user_id,
|
|
156
|
+
username: row.metadata.username
|
|
157
|
+
});
|
|
158
|
+
const toInstallationRow = (row) => ({
|
|
159
|
+
appVersion: row.app_version,
|
|
160
|
+
channel: row.channel,
|
|
161
|
+
cohort: row.metadata.cohort,
|
|
162
|
+
installId: row.install_id,
|
|
163
|
+
lastKnownBundleId: row.type === "UPDATE_DOWNLOADED" ? row.from_bundle_id : row.to_bundle_id,
|
|
164
|
+
pendingBundleId: row.type === "UPDATE_DOWNLOADED" ? row.to_bundle_id : null,
|
|
165
|
+
pendingReleaseId: row.type === "UPDATE_DOWNLOADED" ? row.to_release_id : null,
|
|
166
|
+
latestStatus: row.type,
|
|
167
|
+
platform: row.platform,
|
|
168
|
+
receivedAtMs: row.received_at_ms,
|
|
169
|
+
userId: row.user_id,
|
|
170
|
+
username: row.metadata.username
|
|
171
|
+
});
|
|
172
|
+
/**
|
|
173
|
+
* Where a list without `sinceMs` starts: 90 days before its cutoff for the
|
|
174
|
+
* global and bundle lists, at the first event for installation history.
|
|
175
|
+
*/
|
|
176
|
+
const defaultEventStart = (filter, beforeReceivedAtMs) => filter.kind === "installationMovement" ? 0 : Math.max(0, beforeReceivedAtMs - EVENT_LIST_RANGE_MS);
|
|
177
|
+
/** Whether a cursor's row lies inside the list's range. */
|
|
178
|
+
const isInsideBounds = ({ after }, bounds) => after.receivedAtMs >= bounds.sinceMs && after.receivedAtMs < bounds.beforeReceivedAtMs;
|
|
179
|
+
/** A page's range: its cursor's, which the request may repeat but not change. */
|
|
180
|
+
const readEventBounds = (input, cursor, filter) => {
|
|
181
|
+
const beforeReceivedAtMs = cursor?.beforeReceivedAtMs ?? (input.beforeReceivedAtMs === void 0 ? Date.now() : requireTimestamp(input.beforeReceivedAtMs, "event cutoff"));
|
|
182
|
+
if (cursor !== void 0 && input.beforeReceivedAtMs !== void 0 && input.beforeReceivedAtMs !== beforeReceivedAtMs) throw new require_errors.InsightsBadRequestError("Insights cursor does not match the requested event cutoff.");
|
|
183
|
+
const sinceMs = cursor?.sinceMs ?? (input.sinceMs === void 0 ? defaultEventStart(filter, beforeReceivedAtMs) : requireTimestamp(input.sinceMs, "event start"));
|
|
184
|
+
const bounds = {
|
|
185
|
+
beforeReceivedAtMs,
|
|
186
|
+
sinceMs
|
|
187
|
+
};
|
|
188
|
+
if (sinceMs > beforeReceivedAtMs || input.sinceMs !== void 0 && input.sinceMs !== sinceMs || cursor !== void 0 && !isInsideBounds(cursor, bounds)) throw new require_errors.InsightsBadRequestError("Insights cursor or range does not match the requested event start.");
|
|
189
|
+
if (filter.kind !== "installationMovement" && beforeReceivedAtMs - sinceMs > 7776e6) throw new require_errors.InsightsBadRequestError("Insights event lists cover at most 90 days: send a sinceMs no more than 90 days before beforeReceivedAtMs.");
|
|
190
|
+
return bounds;
|
|
191
|
+
};
|
|
192
|
+
const pageEventRows = async (model, input, filter, map) => {
|
|
193
|
+
const limit = readLimit(input.limit);
|
|
194
|
+
const cursor = input.cursor === void 0 ? void 0 : readEventCursor(input.cursor, filter);
|
|
195
|
+
const bounds = readEventBounds(input, cursor, filter);
|
|
196
|
+
const query = {
|
|
197
|
+
filter,
|
|
198
|
+
...bounds,
|
|
199
|
+
...cursor === void 0 ? {} : { after: cursor.after },
|
|
200
|
+
limit
|
|
201
|
+
};
|
|
202
|
+
const rows = await model.listEvents(query);
|
|
203
|
+
assertEventRows(rows, query);
|
|
204
|
+
const last = rows.at(-1);
|
|
205
|
+
return {
|
|
206
|
+
beforeReceivedAtMs: bounds.beforeReceivedAtMs,
|
|
207
|
+
data: rows.map(map),
|
|
208
|
+
nextCursor: rows.length === limit && last ? encodeCursor({
|
|
209
|
+
after: {
|
|
210
|
+
id: last.id,
|
|
211
|
+
receivedAtMs: last.received_at_ms
|
|
212
|
+
},
|
|
213
|
+
...bounds,
|
|
214
|
+
kind: "events",
|
|
215
|
+
filter,
|
|
216
|
+
version: 2
|
|
217
|
+
}) : null
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
const assertInstallationRows = (rows, input) => {
|
|
221
|
+
if (rows.length > input.limit) throw new Error("Insights database returned too many installation rows.");
|
|
222
|
+
for (let index = 0; index < rows.length; index += 1) {
|
|
223
|
+
const row = rows[index];
|
|
224
|
+
const previous = rows[index - 1];
|
|
225
|
+
if (!row || row.user_id !== input.userId || input.afterInstallId !== void 0 && (0, _hot_updater_plugin_core.compareInsightsText)(row.install_id, input.afterInstallId) <= 0 || previous !== void 0 && (0, _hot_updater_plugin_core.compareInsightsText)(previous.install_id, row.install_id) >= 0) throw new Error("Insights database returned invalid installation rows.");
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
const createInsightsProvider = (model) => Object.freeze({
|
|
229
|
+
async appendBundleEvent(input) {
|
|
230
|
+
const event = require_eventInput.createBundleEventRow(input);
|
|
231
|
+
await model.recordEvent({ event });
|
|
232
|
+
},
|
|
233
|
+
listEvents(input) {
|
|
234
|
+
const filter = input.bundle === void 0 ? { kind: "all" } : {
|
|
235
|
+
kind: "bundle",
|
|
236
|
+
...bundleFilter(input.bundle)
|
|
237
|
+
};
|
|
238
|
+
return pageEventRows(model, input, filter, toEventHistoryRow);
|
|
239
|
+
},
|
|
240
|
+
async listInstallationEvents(input) {
|
|
241
|
+
if ("bundle" in input && input.bundle !== void 0) throw new require_errors.InsightsBadRequestError("Installation movement queries cannot include a bundle filter.");
|
|
242
|
+
const installId = requireString(input.installId, "install ID", MAX_IDENTITY_LENGTH);
|
|
243
|
+
return pageEventRows(model, input, {
|
|
244
|
+
kind: "installationMovement",
|
|
245
|
+
installId
|
|
246
|
+
}, (row) => toEventHistoryRow(row));
|
|
247
|
+
},
|
|
248
|
+
async getInstallation({ installId }) {
|
|
249
|
+
const normalizedInstallId = requireString(installId, "install ID", MAX_IDENTITY_LENGTH);
|
|
250
|
+
const rows = await model.findLatestEvents({ installId: normalizedInstallId });
|
|
251
|
+
const row = rows[0] ?? null;
|
|
252
|
+
if (rows.length > 1 || row !== null && row.install_id !== normalizedInstallId) throw new Error("Insights database returned an invalid installation.");
|
|
253
|
+
return row === null ? null : toInstallationRow(row);
|
|
254
|
+
},
|
|
255
|
+
async pageInstallationsByCurrentUserId(input) {
|
|
256
|
+
const userId = requireString(input.userId, "user ID", MAX_IDENTITY_LENGTH);
|
|
257
|
+
const limit = readLimit(input.limit);
|
|
258
|
+
const cursor = input.cursor === void 0 ? void 0 : readUserInstallationCursor(input.cursor, userId);
|
|
259
|
+
const databaseInput = {
|
|
260
|
+
userId,
|
|
261
|
+
...cursor === void 0 ? {} : { afterInstallId: cursor.afterInstallId },
|
|
262
|
+
limit
|
|
263
|
+
};
|
|
264
|
+
const rows = await model.findLatestEvents(databaseInput);
|
|
265
|
+
assertInstallationRows(rows, databaseInput);
|
|
266
|
+
const last = rows.at(-1);
|
|
267
|
+
return {
|
|
268
|
+
data: rows.map(toInstallationRow),
|
|
269
|
+
nextCursor: rows.length === limit && last ? encodeCursor({
|
|
270
|
+
afterInstallId: last.install_id,
|
|
271
|
+
kind: "user-installations",
|
|
272
|
+
userId,
|
|
273
|
+
version: 1
|
|
274
|
+
}) : null
|
|
275
|
+
};
|
|
276
|
+
},
|
|
277
|
+
async getReportingOverview(input) {
|
|
278
|
+
const scope = readScope(input);
|
|
279
|
+
const { window } = input;
|
|
280
|
+
if (!Object.hasOwn(WINDOW_MS, window)) throw new require_errors.InsightsBadRequestError("Invalid reporting installation window.");
|
|
281
|
+
const now = Date.now();
|
|
282
|
+
const beforeReceivedAtMs = now - now % HOUR_MS + (now % HOUR_MS === 0 ? 0 : HOUR_MS);
|
|
283
|
+
const sinceMs = Math.max(0, beforeReceivedAtMs - WINDOW_MS[window]);
|
|
284
|
+
const measure = async (count) => {
|
|
285
|
+
const value = await count;
|
|
286
|
+
if (!Number.isSafeInteger(value) || value < 0) throw new Error("Insights database returned an invalid count.");
|
|
287
|
+
return {
|
|
288
|
+
count: value,
|
|
289
|
+
measuredAtMs: Date.now()
|
|
290
|
+
};
|
|
291
|
+
};
|
|
292
|
+
const bundleId = input.bundleId === void 0 ? void 0 : requireString(input.bundleId, "bundle ID", MAX_EVENT_ID_LENGTH);
|
|
293
|
+
const reporting = measure(model.countLatestEvents({
|
|
294
|
+
...scope,
|
|
295
|
+
sinceMs
|
|
296
|
+
}));
|
|
297
|
+
if (bundleId === void 0) return {
|
|
298
|
+
...scope,
|
|
299
|
+
window,
|
|
300
|
+
sinceMs,
|
|
301
|
+
beforeReceivedAtMs,
|
|
302
|
+
reportingInstallations: await reporting
|
|
303
|
+
};
|
|
304
|
+
const countOutcome = (outcome) => measure(model.countEvents({
|
|
305
|
+
filter: bundleFilter({
|
|
306
|
+
...scope,
|
|
307
|
+
bundleId,
|
|
308
|
+
outcome
|
|
309
|
+
}),
|
|
310
|
+
sinceMs,
|
|
311
|
+
beforeReceivedAtMs
|
|
312
|
+
}));
|
|
313
|
+
const [reportingInstallations, bundleInstallations, downloadedReports, appliedReports, recoveredReports, unchangedReports] = await Promise.all([
|
|
314
|
+
reporting,
|
|
315
|
+
measure(model.countLatestEvents({
|
|
316
|
+
...scope,
|
|
317
|
+
sinceMs,
|
|
318
|
+
bundle: [{
|
|
319
|
+
field: "from_bundle_id",
|
|
320
|
+
value: bundleId,
|
|
321
|
+
types: ["UPDATE_DOWNLOADED"]
|
|
322
|
+
}, {
|
|
323
|
+
field: "to_bundle_id",
|
|
324
|
+
value: bundleId,
|
|
325
|
+
types: [
|
|
326
|
+
"UNCHANGED",
|
|
327
|
+
"UPDATE_APPLIED",
|
|
328
|
+
"RECOVERED"
|
|
329
|
+
]
|
|
330
|
+
}]
|
|
331
|
+
})),
|
|
332
|
+
countOutcome("downloaded"),
|
|
333
|
+
countOutcome("applied"),
|
|
334
|
+
countOutcome("recovered"),
|
|
335
|
+
countOutcome("unchanged")
|
|
336
|
+
]);
|
|
337
|
+
return {
|
|
338
|
+
...scope,
|
|
339
|
+
window,
|
|
340
|
+
sinceMs,
|
|
341
|
+
beforeReceivedAtMs,
|
|
342
|
+
reportingInstallations,
|
|
343
|
+
bundle: {
|
|
344
|
+
bundleId,
|
|
345
|
+
reportingInstallations: bundleInstallations,
|
|
346
|
+
downloadedReports,
|
|
347
|
+
appliedReports,
|
|
348
|
+
recoveredReports,
|
|
349
|
+
unchangedReports
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
//#endregion
|
|
355
|
+
exports.EVENT_LIST_RANGE_MS = EVENT_LIST_RANGE_MS;
|
|
356
|
+
exports.createInsightsProvider = createInsightsProvider;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { InsightsProvider } from "./types.cjs";
|
|
2
|
+
import { InsightsModel } from "@hot-updater/plugin-core";
|
|
3
|
+
//#region src/insights/provider.d.ts
|
|
4
|
+
declare const createInsightsProvider: (model: InsightsModel) => InsightsProvider;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { createInsightsProvider };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { InsightsProvider } from "./types.mjs";
|
|
2
|
+
import { InsightsModel } from "@hot-updater/plugin-core";
|
|
3
|
+
//#region src/insights/provider.d.ts
|
|
4
|
+
declare const createInsightsProvider: (model: InsightsModel) => InsightsProvider;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { createInsightsProvider };
|