@hot-updater/server 1.0.0-rc.18 → 1.0.0-rc.21
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/LICENSE +12 -14
- package/dist/adapters/drizzle.cjs +6 -8
- package/dist/adapters/drizzle.d.cts +2 -2
- package/dist/adapters/drizzle.d.mts +2 -2
- package/dist/adapters/drizzle.mjs +1 -3
- package/dist/adapters/drizzleExecutor.d.cts +1 -1
- package/dist/adapters/drizzleExecutor.d.mts +1 -1
- package/dist/adapters/kysely.cjs +4 -6
- package/dist/adapters/kysely.d.cts +3 -3
- package/dist/adapters/kysely.d.mts +3 -3
- package/dist/adapters/kysely.mjs +1 -3
- package/dist/adapters/kyselyExecutor.d.cts +1 -2
- package/dist/adapters/kyselyExecutor.d.mts +1 -2
- package/dist/adapters/mongodb.cjs +10 -21
- package/dist/adapters/mongodb.d.cts +1 -1
- package/dist/adapters/mongodb.d.mts +1 -1
- package/dist/adapters/mongodb.mjs +9 -20
- package/dist/adapters/mongodbAdapter.cjs +11 -11
- package/dist/adapters/mongodbAdapter.d.cts +1 -1
- package/dist/adapters/mongodbAdapter.d.mts +1 -1
- package/dist/adapters/mongodbAdapter.mjs +1 -1
- package/dist/adapters/prisma.cjs +7 -9
- package/dist/adapters/prisma.d.cts +1 -1
- package/dist/adapters/prisma.d.mts +1 -1
- package/dist/adapters/prisma.mjs +1 -3
- package/dist/adapters/prismaExecutor.cjs +2 -3
- package/dist/adapters/prismaExecutor.mjs +1 -2
- package/dist/adapters/sqlProviders.cjs +7 -2
- package/dist/adapters/sqlProviders.mjs +6 -1
- package/dist/assembly/assemblePlugins.cjs +26 -48
- package/dist/assembly/assemblePlugins.d.cts +2 -5
- package/dist/assembly/assemblePlugins.d.mts +2 -5
- package/dist/assembly/assemblePlugins.mjs +19 -45
- package/dist/assembly/clientPlugins.cjs +6 -4
- package/dist/assembly/clientPlugins.mjs +2 -0
- package/dist/assembly/configError.d.cts +1 -6
- package/dist/assembly/configError.d.mts +1 -6
- package/dist/assembly/configError.mjs +1 -6
- package/dist/core/api.cjs +0 -40
- package/dist/core/api.d.cts +5 -16
- package/dist/core/api.d.mts +5 -16
- package/dist/core/api.mjs +1 -37
- package/dist/core/baseCandidates.cjs +0 -43
- package/dist/core/baseCandidates.mjs +2 -43
- package/dist/core/operations.cjs +13 -12
- package/dist/core/operations.mjs +6 -5
- package/dist/core/reads.cjs +4 -4
- package/dist/core/reads.d.cts +2 -41
- package/dist/core/reads.d.mts +2 -41
- package/dist/core/reads.mjs +3 -3
- package/dist/core/releases.cjs +6 -6
- package/dist/core/releases.mjs +1 -1
- package/dist/core/writes.cjs +2 -2
- package/dist/core/writes.mjs +1 -1
- package/dist/createHotUpdaterCore.cjs +39 -39
- package/dist/createHotUpdaterCore.d.cts +61 -8
- package/dist/createHotUpdaterCore.d.mts +61 -8
- package/dist/createHotUpdaterCore.mjs +35 -32
- package/dist/db/engineDrizzleSchema.cjs +3 -4
- package/dist/db/engineDrizzleSchema.mjs +1 -2
- package/dist/db/enginePrismaSchema.cjs +4 -5
- package/dist/db/enginePrismaSchema.d.cts +1 -1
- package/dist/db/enginePrismaSchema.d.mts +1 -1
- package/dist/db/enginePrismaSchema.mjs +1 -2
- package/dist/db/releaseCatalog.cjs +6 -6
- package/dist/db/releaseCatalog.mjs +1 -1
- package/dist/db/updateArtifacts.cjs +6 -6
- package/dist/db/updateArtifacts.mjs +1 -1
- package/dist/handler.cjs +3 -4
- package/dist/handler.mjs +1 -1
- package/dist/handlerAdminRoutes.cjs +1 -2
- package/dist/handlerAdminRoutes.mjs +1 -2
- package/dist/handlerVersionRoutes.cjs +2 -2
- package/dist/handlerVersionRoutes.mjs +2 -2
- package/dist/index.cjs +9 -2
- package/dist/index.d.cts +4 -3
- package/dist/index.d.mts +4 -3
- package/dist/index.mjs +2 -1
- package/dist/node.cjs +3 -6
- package/dist/node.d.cts +3 -3
- package/dist/node.d.mts +3 -3
- package/dist/node.mjs +4 -4
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/plugins/api-keys/index.cjs +8 -52
- package/dist/plugins/api-keys/index.d.cts +1 -84
- package/dist/plugins/api-keys/index.d.mts +1 -84
- package/dist/plugins/api-keys/index.mjs +2 -49
- package/dist/plugins/definePlugin.d.cts +2 -200
- package/dist/plugins/definePlugin.d.mts +2 -200
- package/dist/plugins/insights/index.cjs +7 -126
- package/dist/plugins/insights/index.d.cts +1 -398
- package/dist/plugins/insights/index.d.mts +1 -398
- package/dist/plugins/insights/index.mjs +2 -121
- package/dist/plugins/official.cjs +30 -0
- package/dist/plugins/official.mjs +29 -0
- package/dist/storageAccess.cjs +13 -10
- package/dist/storageAccess.mjs +13 -10
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.mts +1 -1
- package/package.json +15 -37
- package/dist/_virtual/_rolldown/runtime.cjs +0 -23
- package/dist/assembly/clientPlugins.d.cts +0 -16
- package/dist/assembly/clientPlugins.d.mts +0 -16
- package/dist/assembly/configError.cjs +0 -7
- package/dist/assembly/databasePlugins.cjs +0 -27
- package/dist/assembly/databasePlugins.d.cts +0 -43
- package/dist/assembly/databasePlugins.d.mts +0 -43
- package/dist/assembly/databasePlugins.mjs +0 -26
- package/dist/assembly/pluginCli.cjs +0 -125
- package/dist/assembly/pluginCli.d.cts +0 -59
- package/dist/assembly/pluginCli.d.mts +0 -59
- package/dist/assembly/pluginCli.mjs +0 -121
- package/dist/core/baseCandidates.d.cts +0 -17
- package/dist/core/baseCandidates.d.mts +0 -17
- package/dist/core/schema.cjs +0 -279
- package/dist/core/schema.d.cts +0 -307
- package/dist/core/schema.d.mts +0 -307
- package/dist/core/schema.mjs +0 -277
- package/dist/database/aggregateBatching.cjs +0 -626
- package/dist/database/aggregateBatching.d.cts +0 -10
- package/dist/database/aggregateBatching.d.mts +0 -10
- package/dist/database/aggregateBatching.mjs +0 -625
- package/dist/database/busy.cjs +0 -36
- package/dist/database/busy.d.cts +0 -12
- package/dist/database/busy.d.mts +0 -12
- package/dist/database/busy.mjs +0 -36
- package/dist/database/cursor.cjs +0 -44
- package/dist/database/cursor.d.cts +0 -7
- package/dist/database/cursor.d.mts +0 -7
- package/dist/database/cursor.mjs +0 -40
- package/dist/database/database.cjs +0 -63
- package/dist/database/database.d.cts +0 -136
- package/dist/database/database.d.mts +0 -136
- package/dist/database/database.mjs +0 -63
- package/dist/database/definitions.d.cts +0 -78
- package/dist/database/definitions.d.mts +0 -78
- package/dist/database/engine.cjs +0 -37
- package/dist/database/engine.d.cts +0 -41
- package/dist/database/engine.d.mts +0 -41
- package/dist/database/engine.mjs +0 -37
- package/dist/database/engineAggregates.cjs +0 -118
- package/dist/database/engineAggregates.mjs +0 -115
- package/dist/database/engineReads.cjs +0 -182
- package/dist/database/engineReads.d.cts +0 -35
- package/dist/database/engineReads.d.mts +0 -35
- package/dist/database/engineReads.mjs +0 -181
- package/dist/database/engineTransaction.cjs +0 -399
- package/dist/database/engineTransaction.d.cts +0 -26
- package/dist/database/engineTransaction.d.mts +0 -26
- package/dist/database/engineTransaction.mjs +0 -398
- package/dist/database/errors.cjs +0 -27
- package/dist/database/errors.d.cts +0 -21
- package/dist/database/errors.d.mts +0 -21
- package/dist/database/errors.mjs +0 -24
- package/dist/database/fence.cjs +0 -125
- package/dist/database/fence.d.cts +0 -42
- package/dist/database/fence.d.mts +0 -42
- package/dist/database/fence.mjs +0 -117
- package/dist/database/index.cjs +0 -136
- package/dist/database/index.d.cts +0 -18
- package/dist/database/index.d.mts +0 -18
- package/dist/database/index.mjs +0 -16
- package/dist/database/kv/kvAdapter.cjs +0 -285
- package/dist/database/kv/kvAdapter.d.cts +0 -109
- package/dist/database/kv/kvAdapter.d.mts +0 -109
- package/dist/database/kv/kvAdapter.mjs +0 -284
- package/dist/database/resolveSchema.cjs +0 -199
- package/dist/database/resolveSchema.d.cts +0 -42
- package/dist/database/resolveSchema.d.mts +0 -42
- package/dist/database/resolveSchema.mjs +0 -196
- package/dist/database/retention.cjs +0 -92
- package/dist/database/retention.mjs +0 -90
- package/dist/database/schema.cjs +0 -24
- package/dist/database/schema.d.cts +0 -90
- package/dist/database/schema.d.mts +0 -90
- package/dist/database/schema.mjs +0 -23
- package/dist/database/sql/sqlAdapter.cjs +0 -290
- package/dist/database/sql/sqlAdapter.d.cts +0 -46
- package/dist/database/sql/sqlAdapter.d.mts +0 -46
- package/dist/database/sql/sqlAdapter.mjs +0 -287
- package/dist/database/sql/sqlSchema.cjs +0 -171
- package/dist/database/sql/sqlSchema.d.cts +0 -8
- package/dist/database/sql/sqlSchema.d.mts +0 -8
- package/dist/database/sql/sqlSchema.mjs +0 -165
- package/dist/db/coreDatabase.cjs +0 -85
- package/dist/db/coreDatabase.d.cts +0 -57
- package/dist/db/coreDatabase.d.mts +0 -57
- package/dist/db/coreDatabase.mjs +0 -78
- package/dist/db/createBundleDiff.cjs +0 -144
- package/dist/db/createBundleDiff.d.cts +0 -17
- package/dist/db/createBundleDiff.d.mts +0 -17
- package/dist/db/createBundleDiff.mjs +0 -141
- package/dist/db/engineMigrator.cjs +0 -53
- package/dist/db/engineMigrator.mjs +0 -53
- package/dist/db/engineSql.cjs +0 -26
- package/dist/db/engineSql.d.cts +0 -17
- package/dist/db/engineSql.d.mts +0 -17
- package/dist/db/engineSql.mjs +0 -25
- package/dist/db/engineSqlMigrator.cjs +0 -66
- package/dist/db/engineSqlMigrator.mjs +0 -66
- package/dist/db/fixedMigratorShared.cjs +0 -12
- package/dist/db/fixedMigratorShared.mjs +0 -11
- package/dist/db/index.cjs +0 -50
- package/dist/db/index.d.cts +0 -23
- package/dist/db/index.d.mts +0 -23
- package/dist/db/index.mjs +0 -33
- package/dist/db/releaseCatalog.d.cts +0 -16
- package/dist/db/releaseCatalog.d.mts +0 -16
- package/dist/db/schemaSettings.cjs +0 -63
- package/dist/db/schemaSettings.d.cts +0 -12
- package/dist/db/schemaSettings.d.mts +0 -12
- package/dist/db/schemaSettings.mjs +0 -62
- package/dist/db/settingsMigrator.cjs +0 -92
- package/dist/db/settingsMigrator.mjs +0 -89
- package/dist/db/types.cjs +0 -11
- package/dist/db/types.d.cts +0 -78
- package/dist/db/types.d.mts +0 -78
- package/dist/db/types.mjs +0 -10
- package/dist/diff.cjs +0 -3
- package/dist/diff.d.cts +0 -2
- package/dist/diff.d.mts +0 -2
- package/dist/diff.mjs +0 -2
- package/dist/plugins/api-keys/apiKeys.cjs +0 -139
- package/dist/plugins/api-keys/apiKeys.d.cts +0 -27
- package/dist/plugins/api-keys/apiKeys.d.mts +0 -27
- package/dist/plugins/api-keys/apiKeys.mjs +0 -129
- package/dist/plugins/api-keys/cli.cjs +0 -115
- package/dist/plugins/api-keys/cli.mjs +0 -114
- package/dist/plugins/api-keys/model.cjs +0 -58
- package/dist/plugins/api-keys/model.d.cts +0 -26
- package/dist/plugins/api-keys/model.d.mts +0 -26
- package/dist/plugins/api-keys/model.mjs +0 -58
- package/dist/plugins/api-keys/schema.cjs +0 -38
- package/dist/plugins/api-keys/schema.d.cts +0 -44
- package/dist/plugins/api-keys/schema.d.mts +0 -44
- package/dist/plugins/api-keys/schema.mjs +0 -39
- package/dist/plugins/definePlugin.cjs +0 -5
- package/dist/plugins/definePlugin.mjs +0 -5
- package/dist/plugins/index.cjs +0 -38
- package/dist/plugins/index.d.cts +0 -12
- package/dist/plugins/index.d.mts +0 -12
- package/dist/plugins/index.mjs +0 -9
- package/dist/plugins/insights/contract.cjs +0 -193
- package/dist/plugins/insights/contract.mjs +0 -189
- package/dist/plugins/insights/domain.d.cts +0 -149
- package/dist/plugins/insights/domain.d.mts +0 -149
- package/dist/plugins/insights/errors.cjs +0 -15
- package/dist/plugins/insights/errors.mjs +0 -14
- package/dist/plugins/insights/eventInput.cjs +0 -284
- package/dist/plugins/insights/eventInput.mjs +0 -282
- package/dist/plugins/insights/eventRow.cjs +0 -49
- package/dist/plugins/insights/eventRow.d.cts +0 -64
- package/dist/plugins/insights/eventRow.d.mts +0 -64
- package/dist/plugins/insights/eventRow.mjs +0 -47
- package/dist/plugins/insights/model.cjs +0 -17
- package/dist/plugins/insights/model.d.cts +0 -10
- package/dist/plugins/insights/model.d.mts +0 -10
- package/dist/plugins/insights/model.mjs +0 -17
- package/dist/plugins/insights/modelTypes.d.cts +0 -176
- package/dist/plugins/insights/modelTypes.d.mts +0 -176
- package/dist/plugins/insights/overview.cjs +0 -109
- package/dist/plugins/insights/overview.d.cts +0 -15
- package/dist/plugins/insights/overview.d.mts +0 -15
- package/dist/plugins/insights/overview.mjs +0 -107
- package/dist/plugins/insights/provider.cjs +0 -375
- package/dist/plugins/insights/provider.d.cts +0 -6
- package/dist/plugins/insights/provider.d.mts +0 -6
- package/dist/plugins/insights/provider.mjs +0 -374
- package/dist/plugins/insights/queryInput.cjs +0 -93
- package/dist/plugins/insights/queryInput.mjs +0 -91
- package/dist/plugins/insights/reads.cjs +0 -681
- package/dist/plugins/insights/reads.d.cts +0 -61
- package/dist/plugins/insights/reads.d.mts +0 -61
- package/dist/plugins/insights/reads.mjs +0 -674
- package/dist/plugins/insights/recordEvent.cjs +0 -319
- package/dist/plugins/insights/recordEvent.d.cts +0 -18
- package/dist/plugins/insights/recordEvent.d.mts +0 -18
- package/dist/plugins/insights/recordEvent.mjs +0 -316
- package/dist/plugins/insights/routes.cjs +0 -96
- package/dist/plugins/insights/routes.mjs +0 -95
- package/dist/plugins/insights/schema.cjs +0 -489
- package/dist/plugins/insights/schema.d.cts +0 -698
- package/dist/plugins/insights/schema.d.mts +0 -698
- package/dist/plugins/insights/schema.mjs +0 -483
- package/dist/plugins/insights/testing/eventRow.d.mts +0 -64
- package/dist/plugins/insights/testing/expectInsightsIndex.mjs +0 -18
- package/dist/plugins/insights/testing/fixtures.d.mts +0 -8
- package/dist/plugins/insights/testing/fixtures.mjs +0 -25
- package/dist/plugins/insights/testing/index.d.mts +0 -24
- package/dist/plugins/insights/testing/index.mjs +0 -25
- package/dist/plugins/insights/testing/insightsModelTests.mjs +0 -714
- package/dist/plugins/insights/testing/modelTypes.d.mts +0 -176
- package/dist/plugins/insights/testing/setupInsightsHttpTestSuite.d.mts +0 -11
- package/dist/plugins/insights/testing/setupInsightsHttpTestSuite.mjs +0 -107
- package/dist/plugins/insights/testing/setupInsightsModelTestSuite.d.mts +0 -11
- package/dist/plugins/insights/testing/setupInsightsModelTestSuite.mjs +0 -31
- package/dist/plugins/insights/testing/types.d.mts +0 -26
- package/dist/plugins/insights/types.d.cts +0 -33
- package/dist/plugins/insights/types.d.mts +0 -33
- package/src/adapters/drizzle.conformance.integration.spec.ts +0 -34
- package/src/adapters/drizzle.readBudgets.integration.spec.ts +0 -43
- package/src/adapters/drizzle.spec.ts +0 -314
- package/src/adapters/drizzle.ts +0 -64
- package/src/adapters/drizzleExecutor.ts +0 -166
- package/src/adapters/kysely.conformance.integration.spec.ts +0 -36
- package/src/adapters/kysely.readBudgets.integration.spec.ts +0 -44
- package/src/adapters/kysely.spec.ts +0 -244
- package/src/adapters/kysely.ts +0 -46
- package/src/adapters/kyselyExecutor.ts +0 -53
- package/src/adapters/mongodb.integration.spec.ts +0 -271
- package/src/adapters/mongodb.readBudgets.integration.spec.ts +0 -61
- package/src/adapters/mongodb.ts +0 -45
- package/src/adapters/mongodbAdapter.ts +0 -307
- package/src/adapters/prisma.conformance.integration.spec.ts +0 -36
- package/src/adapters/prisma.integration.spec.ts +0 -146
- package/src/adapters/prisma.readBudgets.integration.spec.ts +0 -43
- package/src/adapters/prisma.spec.ts +0 -257
- package/src/adapters/prisma.ts +0 -74
- package/src/adapters/prismaExecutor.ts +0 -107
- package/src/adapters/prismaTestClients.ts +0 -182
- package/src/adapters/sqlProviders.ts +0 -14
- package/src/assembly/assemblePlugins.ts +0 -302
- package/src/assembly/assembly.spec.ts +0 -377
- package/src/assembly/assembly.types.spec.ts +0 -203
- package/src/assembly/clientPlugins.ts +0 -113
- package/src/assembly/configError.ts +0 -4
- package/src/assembly/databasePlugins.spec.ts +0 -71
- package/src/assembly/databasePlugins.ts +0 -102
- package/src/assembly/pluginCli.spec.ts +0 -254
- package/src/assembly/pluginCli.ts +0 -248
- package/src/assembly/pluginRoutes.spec.ts +0 -186
- package/src/core/api.ts +0 -139
- package/src/core/baseCandidates.spec.ts +0 -378
- package/src/core/baseCandidates.ts +0 -136
- package/src/core/index.ts +0 -44
- package/src/core/operations.spec.ts +0 -415
- package/src/core/operations.ts +0 -551
- package/src/core/reads.spec.ts +0 -300
- package/src/core/reads.ts +0 -417
- package/src/core/releases.spec.ts +0 -308
- package/src/core/releases.ts +0 -345
- package/src/core/schema.ts +0 -173
- package/src/core/writes.ts +0 -160
- package/src/createHotUpdaterCore.ts +0 -260
- package/src/database/aggregateBatching.spec.ts +0 -577
- package/src/database/aggregateBatching.ts +0 -803
- package/src/database/busy.spec.ts +0 -45
- package/src/database/busy.ts +0 -50
- package/src/database/cursor.ts +0 -65
- package/src/database/database.ts +0 -366
- package/src/database/database.types.spec.ts +0 -135
- package/src/database/definitions.ts +0 -76
- package/src/database/engine.ts +0 -62
- package/src/database/engineAggregates.spec.ts +0 -536
- package/src/database/engineAggregates.ts +0 -189
- package/src/database/engineReads.spec.ts +0 -219
- package/src/database/engineReads.ts +0 -304
- package/src/database/engineTransaction.spec.ts +0 -710
- package/src/database/engineTransaction.ts +0 -582
- package/src/database/errors.ts +0 -30
- package/src/database/fence.spec.ts +0 -223
- package/src/database/fence.ts +0 -175
- package/src/database/index.ts +0 -160
- package/src/database/kv/kvAdapter.batching.integration.spec.ts +0 -15
- package/src/database/kv/kvAdapter.conformance.integration.spec.ts +0 -19
- package/src/database/kv/kvAdapter.readBudgets.integration.spec.ts +0 -17
- package/src/database/kv/kvAdapter.spec.ts +0 -595
- package/src/database/kv/kvAdapter.ts +0 -479
- package/src/database/kv/kvTestStore.ts +0 -118
- package/src/database/memory.readBudgets.integration.spec.ts +0 -13
- package/src/database/resolveSchema.spec.ts +0 -230
- package/src/database/resolveSchema.ts +0 -375
- package/src/database/retention.spec.ts +0 -314
- package/src/database/retention.ts +0 -129
- package/src/database/schema.ts +0 -213
- package/src/database/schema.types.spec.ts +0 -94
- package/src/database/sql/docker-compose.yml +0 -36
- package/src/database/sql/sqlAdapter.integration.spec.ts +0 -145
- package/src/database/sql/sqlAdapter.readBudgets.integration.spec.ts +0 -123
- package/src/database/sql/sqlAdapter.spec.ts +0 -343
- package/src/database/sql/sqlAdapter.ts +0 -552
- package/src/database/sql/sqlSchema.ts +0 -286
- package/src/database/sql/sqlTestExecutors.ts +0 -183
- package/src/databaseTestSuite.spec.ts +0 -44
- package/src/db/bundleRows.spec.ts +0 -164
- package/src/db/bundleRows.ts +0 -10
- package/src/db/coreDatabase.ts +0 -153
- package/src/db/createBundleDiff.spec.ts +0 -464
- package/src/db/createBundleDiff.ts +0 -370
- package/src/db/engineDrizzleSchema.ts +0 -72
- package/src/db/engineMigrator.ts +0 -105
- package/src/db/enginePrismaSchema.ts +0 -147
- package/src/db/engineSql.spec.ts +0 -130
- package/src/db/engineSql.ts +0 -48
- package/src/db/engineSqlMigrator.ts +0 -116
- package/src/db/fixedMigratorShared.ts +0 -17
- package/src/db/index.spec.ts +0 -554
- package/src/db/index.ts +0 -93
- package/src/db/node-sqlite.d.ts +0 -25
- package/src/db/pluginTables.spec.ts +0 -248
- package/src/db/releaseCatalog.ts +0 -106
- package/src/db/schemaSettings.ts +0 -104
- package/src/db/settingsMigrator.spec.ts +0 -65
- package/src/db/settingsMigrator.ts +0 -152
- package/src/db/types.ts +0 -82
- package/src/db/updateArtifacts.spec.ts +0 -235
- package/src/db/updateArtifacts.ts +0 -473
- package/src/db/updateCheck.bench.ts +0 -47
- package/src/diff.ts +0 -6
- package/src/handler-standalone.integration.spec.ts +0 -321
- package/src/handler.spec.ts +0 -273
- package/src/handler.testFixtures.ts +0 -25
- package/src/handler.ts +0 -302
- package/src/handlerAdminRoutes.spec.ts +0 -183
- package/src/handlerAdminRoutes.ts +0 -536
- package/src/handlerAuth.integration.spec.ts +0 -33
- package/src/handlerErrors.ts +0 -7
- package/src/handlerManagement.spec.ts +0 -202
- package/src/handlerParameters.ts +0 -105
- package/src/handlerReleaseCatalogRoutes.ts +0 -176
- package/src/handlerTypes.ts +0 -19
- package/src/handlerVersionRoutes.ts +0 -25
- package/src/index.ts +0 -13
- package/src/internalRouter.ts +0 -104
- package/src/lintRules.spec.ts +0 -76
- package/src/node.spec.ts +0 -119
- package/src/node.ts +0 -111
- package/src/plugins/api-keys/apiKeys.integration.spec.ts +0 -92
- package/src/plugins/api-keys/apiKeys.spec.ts +0 -166
- package/src/plugins/api-keys/apiKeys.ts +0 -214
- package/src/plugins/api-keys/apiKeysPlugin.spec.ts +0 -168
- package/src/plugins/api-keys/cli.spec.ts +0 -187
- package/src/plugins/api-keys/cli.ts +0 -140
- package/src/plugins/api-keys/index.ts +0 -73
- package/src/plugins/api-keys/model.ts +0 -88
- package/src/plugins/api-keys/schema.ts +0 -22
- package/src/plugins/definePlugin.ts +0 -242
- package/src/plugins/index.ts +0 -73
- package/src/plugins/insights/contract.spec.ts +0 -285
- package/src/plugins/insights/contract.ts +0 -372
- package/src/plugins/insights/domain.ts +0 -176
- package/src/plugins/insights/errors.ts +0 -11
- package/src/plugins/insights/eventInput.ts +0 -381
- package/src/plugins/insights/eventRow.ts +0 -209
- package/src/plugins/insights/index.ts +0 -222
- package/src/plugins/insights/insights.integration.spec.ts +0 -921
- package/src/plugins/insights/insightsRollout.integration.spec.ts +0 -186
- package/src/plugins/insights/model.spec.ts +0 -64
- package/src/plugins/insights/model.ts +0 -18
- package/src/plugins/insights/modelTypes.ts +0 -197
- package/src/plugins/insights/overview.spec.ts +0 -64
- package/src/plugins/insights/overview.ts +0 -214
- package/src/plugins/insights/provider.spec.ts +0 -585
- package/src/plugins/insights/provider.ts +0 -704
- package/src/plugins/insights/queryInput.ts +0 -142
- package/src/plugins/insights/reads.spec.ts +0 -1013
- package/src/plugins/insights/reads.ts +0 -1037
- package/src/plugins/insights/recordEvent.spec.ts +0 -897
- package/src/plugins/insights/recordEvent.ts +0 -476
- package/src/plugins/insights/retention.spec.ts +0 -115
- package/src/plugins/insights/routes.ts +0 -149
- package/src/plugins/insights/schema.ts +0 -409
- package/src/plugins/insights/testing/expectInsightsIndex.spec.ts +0 -42
- package/src/plugins/insights/testing/expectInsightsIndex.ts +0 -20
- package/src/plugins/insights/testing/fixtures.ts +0 -30
- package/src/plugins/insights/testing/index.ts +0 -45
- package/src/plugins/insights/testing/insightsModelTests.ts +0 -860
- package/src/plugins/insights/testing/setupInsightsHttpTestSuite.ts +0 -152
- package/src/plugins/insights/testing/setupInsightsModelTestSuite.ts +0 -36
- package/src/plugins/insights/testing/types.ts +0 -30
- package/src/plugins/insights/types.ts +0 -55
- package/src/plugins/pluginTestHarness.spec.ts +0 -56
- package/src/readBudgets.testFixtures.ts +0 -15
- package/src/releaseCatalogRoutes.integration.spec.ts +0 -200
- package/src/retention.spec.ts +0 -73
- package/src/runtime.spec.ts +0 -207
- package/src/runtime.testFixtures.ts +0 -60
- package/src/runtimeBundles.integration.spec.ts +0 -112
- package/src/storageAccess.spec.ts +0 -152
- package/src/storageAccess.ts +0 -141
- package/src/testUtilsMutation.integration.spec.ts +0 -216
- package/src/testUtilsPackage.integration.spec.ts +0 -180
- package/src/types/index.ts +0 -2
- package/src/version.ts +0 -3
|
@@ -1,921 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createMemoryAdapter,
|
|
3
|
-
type DatabaseAdapter,
|
|
4
|
-
} from "@hot-updater/plugin-core/internal";
|
|
5
|
-
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
6
|
-
|
|
7
|
-
import { toolingTargetOf } from "../../db/coreDatabase";
|
|
8
|
-
import { createHotUpdater } from "../../index";
|
|
9
|
-
import {
|
|
10
|
-
createFencedDatabase,
|
|
11
|
-
createRuntimeDatabase,
|
|
12
|
-
} from "../../runtime.testFixtures";
|
|
13
|
-
import { EVENT_BODY_MAX_BYTES } from "./eventInput";
|
|
14
|
-
import { insights } from "./index";
|
|
15
|
-
|
|
16
|
-
/** A server with the Insights plugin on an empty in-memory database. */
|
|
17
|
-
const start = () =>
|
|
18
|
-
createHotUpdater({
|
|
19
|
-
database: createRuntimeDatabase(),
|
|
20
|
-
plugins: [insights()],
|
|
21
|
-
clientAccess: "public",
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const event = {
|
|
25
|
-
appVersion: "1.0.0",
|
|
26
|
-
channel: "production",
|
|
27
|
-
cohort: "default",
|
|
28
|
-
fingerprintHash: null,
|
|
29
|
-
fromBundleId: null,
|
|
30
|
-
fromReleaseId: null,
|
|
31
|
-
installId: "install-1",
|
|
32
|
-
platform: "ios",
|
|
33
|
-
toBundleId: "bundle-1",
|
|
34
|
-
toReleaseId: null,
|
|
35
|
-
type: "UNCHANGED",
|
|
36
|
-
updateStrategy: null,
|
|
37
|
-
userId: "user-1",
|
|
38
|
-
sdkVersion: "2.0.0",
|
|
39
|
-
} as const;
|
|
40
|
-
|
|
41
|
-
const eventRequest = (body: unknown = event) =>
|
|
42
|
-
new Request("https://example.com/events", {
|
|
43
|
-
method: "POST",
|
|
44
|
-
headers: { "content-type": "application/json" },
|
|
45
|
-
body: JSON.stringify(body),
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
afterEach(() => {
|
|
49
|
-
vi.useRealTimers();
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
describe("createHotUpdater Insights", () => {
|
|
53
|
-
it("ingests a downloaded bundle and exposes the running and pending state until apply", async () => {
|
|
54
|
-
const hotUpdater = start();
|
|
55
|
-
const downloaded = {
|
|
56
|
-
...event,
|
|
57
|
-
type: "UPDATE_DOWNLOADED",
|
|
58
|
-
fromBundleId: "bundle-1",
|
|
59
|
-
toBundleId: "bundle-2",
|
|
60
|
-
toReleaseId: "release-2",
|
|
61
|
-
updateStrategy: "appVersion",
|
|
62
|
-
};
|
|
63
|
-
expect(
|
|
64
|
-
(await hotUpdater.handlers.client(eventRequest(downloaded))).status,
|
|
65
|
-
).toBe(204);
|
|
66
|
-
const downloads = await hotUpdater.handlers.admin(
|
|
67
|
-
new Request(
|
|
68
|
-
`https://example.com/events?platform=ios&channel=production&bundleId=bundle-2&outcome=downloaded&beforeReceivedAtMs=${Date.now() + 1}`,
|
|
69
|
-
),
|
|
70
|
-
);
|
|
71
|
-
expect(downloads.status).toBe(200);
|
|
72
|
-
await expect(downloads.json()).resolves.toMatchObject({
|
|
73
|
-
data: [{ type: "UPDATE_DOWNLOADED", toBundleId: "bundle-2" }],
|
|
74
|
-
});
|
|
75
|
-
const lookup = () =>
|
|
76
|
-
hotUpdater.handlers.admin(
|
|
77
|
-
new Request("https://example.com/installations/install-1"),
|
|
78
|
-
);
|
|
79
|
-
await expect((await lookup()).json()).resolves.toMatchObject({
|
|
80
|
-
latestStatus: "UPDATE_DOWNLOADED",
|
|
81
|
-
lastKnownBundleId: "bundle-1",
|
|
82
|
-
pendingBundleId: "bundle-2",
|
|
83
|
-
pendingReleaseId: "release-2",
|
|
84
|
-
});
|
|
85
|
-
expect(
|
|
86
|
-
(
|
|
87
|
-
await hotUpdater.handlers.client(
|
|
88
|
-
eventRequest({ ...downloaded, type: "UPDATE_APPLIED" }),
|
|
89
|
-
)
|
|
90
|
-
).status,
|
|
91
|
-
).toBe(204);
|
|
92
|
-
await expect((await lookup()).json()).resolves.toMatchObject({
|
|
93
|
-
latestStatus: "UPDATE_APPLIED",
|
|
94
|
-
lastKnownBundleId: "bundle-2",
|
|
95
|
-
pendingBundleId: null,
|
|
96
|
-
pendingReleaseId: null,
|
|
97
|
-
});
|
|
98
|
-
expect(
|
|
99
|
-
(
|
|
100
|
-
await hotUpdater.handlers.client(
|
|
101
|
-
eventRequest({ ...downloaded, fromBundleId: null }),
|
|
102
|
-
)
|
|
103
|
-
).status,
|
|
104
|
-
).toBe(400);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it("keeps an UNCHANGED report as the installation's latest event, not a listed event, and serves the lean Insights views", async () => {
|
|
108
|
-
vi.useFakeTimers();
|
|
109
|
-
vi.setSystemTime(new Date("2026-08-12T00:00:00.000Z"));
|
|
110
|
-
const receivedAtMs = Date.now();
|
|
111
|
-
const hotUpdater = start();
|
|
112
|
-
const append = vi.spyOn(hotUpdater.api.insights, "recordEvent");
|
|
113
|
-
|
|
114
|
-
const ingestion = await hotUpdater.handlers.client(eventRequest());
|
|
115
|
-
vi.advanceTimersByTime(1);
|
|
116
|
-
const events = await hotUpdater.handlers.admin(
|
|
117
|
-
new Request("https://example.com/events"),
|
|
118
|
-
);
|
|
119
|
-
const installation = await hotUpdater.handlers.admin(
|
|
120
|
-
new Request("https://example.com/installations/install-1"),
|
|
121
|
-
);
|
|
122
|
-
const matches = await hotUpdater.handlers.admin(
|
|
123
|
-
new Request("https://example.com/installations?userId=user-1"),
|
|
124
|
-
);
|
|
125
|
-
const active = await hotUpdater.handlers.admin(
|
|
126
|
-
new Request(
|
|
127
|
-
"https://example.com/overview?platform=ios&channel=production&window=24h",
|
|
128
|
-
),
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
expect(ingestion.status).toBe(204);
|
|
132
|
-
expect(append).toHaveBeenCalledWith(
|
|
133
|
-
expect.objectContaining({
|
|
134
|
-
install_id: "install-1",
|
|
135
|
-
metadata: expect.objectContaining({ sdk_version: "2.0.0" }),
|
|
136
|
-
to_bundle_id: "bundle-1",
|
|
137
|
-
type: "UNCHANGED",
|
|
138
|
-
}),
|
|
139
|
-
);
|
|
140
|
-
// A launch without an update is no event of its own.
|
|
141
|
-
expect(events.status).toBe(200);
|
|
142
|
-
await expect(events.json()).resolves.toEqual({
|
|
143
|
-
beforeReceivedAtMs: expect.any(Number),
|
|
144
|
-
data: [],
|
|
145
|
-
nextCursor: null,
|
|
146
|
-
});
|
|
147
|
-
expect(installation.status).toBe(200);
|
|
148
|
-
await expect(installation.json()).resolves.toMatchObject({
|
|
149
|
-
installId: "install-1",
|
|
150
|
-
latestStatus: "UNCHANGED",
|
|
151
|
-
receivedAtMs,
|
|
152
|
-
userId: "user-1",
|
|
153
|
-
});
|
|
154
|
-
expect(matches.status).toBe(200);
|
|
155
|
-
await expect(matches.json()).resolves.toMatchObject({
|
|
156
|
-
data: [{ installId: "install-1", userId: "user-1" }],
|
|
157
|
-
nextCursor: null,
|
|
158
|
-
});
|
|
159
|
-
expect(active.status).toBe(200);
|
|
160
|
-
// Ending with the current hour, from the UTC day the window reaches into.
|
|
161
|
-
await expect(active.json()).resolves.toEqual({
|
|
162
|
-
platform: "ios",
|
|
163
|
-
channel: "production",
|
|
164
|
-
sinceMs: Date.parse("2026-08-11T00:00:00.000Z"),
|
|
165
|
-
beforeReceivedAtMs: Date.parse("2026-08-12T01:00:00.000Z"),
|
|
166
|
-
reportingInstallations: { count: 1, measuredAtMs: Date.now() },
|
|
167
|
-
window: "24h",
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
it("serves scoped bundle counts and the same half-open recovery drill-down", async () => {
|
|
172
|
-
vi.useFakeTimers();
|
|
173
|
-
const hotUpdater = start();
|
|
174
|
-
const report = async (
|
|
175
|
-
receivedAtMs: number,
|
|
176
|
-
overrides: Record<string, unknown>,
|
|
177
|
-
) => {
|
|
178
|
-
vi.setSystemTime(receivedAtMs);
|
|
179
|
-
const response = await hotUpdater.handlers.client(
|
|
180
|
-
eventRequest({ ...event, ...overrides }),
|
|
181
|
-
);
|
|
182
|
-
expect(response.status).toBe(204);
|
|
183
|
-
};
|
|
184
|
-
await report(100, {
|
|
185
|
-
type: "UPDATE_APPLIED",
|
|
186
|
-
fromBundleId: "A",
|
|
187
|
-
toBundleId: "B",
|
|
188
|
-
updateStrategy: "appVersion",
|
|
189
|
-
});
|
|
190
|
-
await report(200, {
|
|
191
|
-
type: "RECOVERED",
|
|
192
|
-
fromBundleId: "B",
|
|
193
|
-
toBundleId: "A",
|
|
194
|
-
updateStrategy: "appVersion",
|
|
195
|
-
});
|
|
196
|
-
await report(300, {
|
|
197
|
-
installId: "install-2",
|
|
198
|
-
type: "UNCHANGED",
|
|
199
|
-
fromBundleId: null,
|
|
200
|
-
toBundleId: "B",
|
|
201
|
-
updateStrategy: null,
|
|
202
|
-
});
|
|
203
|
-
await report(400, {
|
|
204
|
-
installId: "install-3",
|
|
205
|
-
platform: "android",
|
|
206
|
-
toBundleId: "B",
|
|
207
|
-
});
|
|
208
|
-
vi.setSystemTime(500);
|
|
209
|
-
const overview = await hotUpdater.handlers.admin(
|
|
210
|
-
new Request(
|
|
211
|
-
"https://example.com/overview?platform=ios&channel=production&window=24h&bundleId=B",
|
|
212
|
-
),
|
|
213
|
-
);
|
|
214
|
-
expect(overview.status).toBe(200);
|
|
215
|
-
// install-2's UNCHANGED report counts it among the bundle's latest
|
|
216
|
-
// events, and in no event count.
|
|
217
|
-
await expect(overview.json()).resolves.toEqual({
|
|
218
|
-
platform: "ios",
|
|
219
|
-
channel: "production",
|
|
220
|
-
window: "24h",
|
|
221
|
-
sinceMs: 0,
|
|
222
|
-
beforeReceivedAtMs: 60 * 60 * 1_000,
|
|
223
|
-
reportingInstallations: { count: 2, measuredAtMs: 500 },
|
|
224
|
-
bundle: {
|
|
225
|
-
bundleId: "B",
|
|
226
|
-
reportingInstallations: { count: 1, measuredAtMs: 500 },
|
|
227
|
-
downloadedReports: { count: 0, measuredAtMs: 500 },
|
|
228
|
-
appliedReports: { count: 1, measuredAtMs: 500 },
|
|
229
|
-
recoveredReports: { count: 1, measuredAtMs: 500 },
|
|
230
|
-
failedReports: { count: 0, measuredAtMs: 500 },
|
|
231
|
-
},
|
|
232
|
-
});
|
|
233
|
-
const drilldown = await hotUpdater.handlers.admin(
|
|
234
|
-
new Request(
|
|
235
|
-
"https://example.com/events?platform=ios&channel=production&bundleId=B&outcome=recovered&sinceMs=200&beforeReceivedAtMs=300",
|
|
236
|
-
),
|
|
237
|
-
);
|
|
238
|
-
await expect(drilldown.json()).resolves.toMatchObject({
|
|
239
|
-
data: [
|
|
240
|
-
{
|
|
241
|
-
type: "RECOVERED",
|
|
242
|
-
fromBundleId: "B",
|
|
243
|
-
toBundleId: "A",
|
|
244
|
-
receivedAtMs: 200,
|
|
245
|
-
},
|
|
246
|
-
],
|
|
247
|
-
nextCursor: null,
|
|
248
|
-
});
|
|
249
|
-
const outside = await hotUpdater.handlers.admin(
|
|
250
|
-
new Request(
|
|
251
|
-
"https://example.com/events?platform=ios&channel=production&bundleId=B&outcome=recovered&sinceMs=0&beforeReceivedAtMs=200",
|
|
252
|
-
),
|
|
253
|
-
);
|
|
254
|
-
await expect(outside.json()).resolves.toMatchObject({
|
|
255
|
-
data: [],
|
|
256
|
-
nextCursor: null,
|
|
257
|
-
});
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
it.each([
|
|
261
|
-
"/overview?window=24h",
|
|
262
|
-
"/overview?platform=ios&channel=production&platform=android",
|
|
263
|
-
"/events?bundleId=B",
|
|
264
|
-
"/events?platform=ios&channel=production&bundleId=B&outcome=UNCHANGED",
|
|
265
|
-
// UNCHANGED reports are kept as no events, so no list holds them.
|
|
266
|
-
"/events?platform=ios&channel=production&bundleId=B&outcome=unchanged",
|
|
267
|
-
"/events?sinceMs=20&beforeReceivedAtMs=10",
|
|
268
|
-
// 90 days and 1 ms, longer than a bundle list covers.
|
|
269
|
-
"/events?platform=ios&channel=production&bundleId=B&outcome=applied&sinceMs=0&beforeReceivedAtMs=7776000001",
|
|
270
|
-
"/installations/install-1/events?platform=ios&channel=production&bundleId=B&outcome=applied",
|
|
271
|
-
])("rejects ambiguous or invalid Insights query %s", async (path) => {
|
|
272
|
-
const hotUpdater = start();
|
|
273
|
-
expect(
|
|
274
|
-
(
|
|
275
|
-
await hotUpdater.handlers.admin(
|
|
276
|
-
new Request(`https://example.com${path}`),
|
|
277
|
-
)
|
|
278
|
-
).status,
|
|
279
|
-
).toBe(400);
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
it("lists at most 90 days of events, and says so for a longer range", async () => {
|
|
283
|
-
const hotUpdater = start();
|
|
284
|
-
const range = "sinceMs=0&beforeReceivedAtMs=7776000001";
|
|
285
|
-
const events = await hotUpdater.handlers.admin(
|
|
286
|
-
new Request(`https://example.com/events?${range}`),
|
|
287
|
-
);
|
|
288
|
-
expect(events.status).toBe(400);
|
|
289
|
-
await expect(events.json()).resolves.toEqual({
|
|
290
|
-
error:
|
|
291
|
-
"Insights event lists cover at most 90 days: send a sinceMs no more than 90 days before beforeReceivedAtMs.",
|
|
292
|
-
});
|
|
293
|
-
// An installation's history is one index range, however long.
|
|
294
|
-
const history = await hotUpdater.handlers.admin(
|
|
295
|
-
new Request(
|
|
296
|
-
`https://example.com/installations/install-1/events?${range}`,
|
|
297
|
-
),
|
|
298
|
-
);
|
|
299
|
-
expect(history.status).toBe(200);
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
it("checks the schema settings before Insights reads and writes", async () => {
|
|
303
|
-
const error = vi.spyOn(console, "error").mockImplementation(() => {});
|
|
304
|
-
const unmigrated = createHotUpdater({
|
|
305
|
-
database: await createFencedDatabase("kysely"),
|
|
306
|
-
plugins: [insights()],
|
|
307
|
-
clientAccess: "public",
|
|
308
|
-
});
|
|
309
|
-
const migrated = createHotUpdater({
|
|
310
|
-
database: await createFencedDatabase(
|
|
311
|
-
"kysely",
|
|
312
|
-
toolingTargetOf([insights()]).settings,
|
|
313
|
-
),
|
|
314
|
-
plugins: [insights()],
|
|
315
|
-
clientAccess: "public",
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
expect((await unmigrated.handlers.client(eventRequest())).status).toBe(503);
|
|
319
|
-
expect((await migrated.handlers.client(eventRequest())).status).toBe(204);
|
|
320
|
-
error.mockRestore();
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
it("keeps ingestion and queries on separate handler surfaces", async () => {
|
|
324
|
-
const hotUpdater = start();
|
|
325
|
-
|
|
326
|
-
expect((await hotUpdater.handlers.client(eventRequest())).status).toBe(204);
|
|
327
|
-
const clientQuery = await hotUpdater.handlers.client(
|
|
328
|
-
new Request("https://example.com/events"),
|
|
329
|
-
);
|
|
330
|
-
const adminIngestion = await hotUpdater.handlers.admin(eventRequest());
|
|
331
|
-
const adminQuery = await hotUpdater.handlers.admin(
|
|
332
|
-
new Request("https://example.com/events"),
|
|
333
|
-
);
|
|
334
|
-
|
|
335
|
-
expect(clientQuery.status).toBe(404);
|
|
336
|
-
expect(adminIngestion.status).toBe(404);
|
|
337
|
-
expect(adminQuery.status).toBe(200);
|
|
338
|
-
expect(adminQuery.headers.get("cache-control")).toBe("private, no-store");
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
it("records same-file selection as no change and rejects a fourth event type", async () => {
|
|
342
|
-
const hotUpdater = start();
|
|
343
|
-
const recordEvent = vi.spyOn(hotUpdater.api.insights, "recordEvent");
|
|
344
|
-
const selection = {
|
|
345
|
-
...event,
|
|
346
|
-
fromReleaseId: "previous-release",
|
|
347
|
-
toReleaseId: "selected-release",
|
|
348
|
-
};
|
|
349
|
-
expect(
|
|
350
|
-
(await hotUpdater.handlers.client(eventRequest(selection))).status,
|
|
351
|
-
).toBe(204);
|
|
352
|
-
expect(recordEvent).toHaveBeenCalledWith(
|
|
353
|
-
expect.objectContaining({
|
|
354
|
-
type: "UNCHANGED",
|
|
355
|
-
from_bundle_id: null,
|
|
356
|
-
metadata: expect.objectContaining({ update_strategy: null }),
|
|
357
|
-
from_release_id: "previous-release",
|
|
358
|
-
to_release_id: "selected-release",
|
|
359
|
-
to_bundle_id: event.toBundleId,
|
|
360
|
-
}),
|
|
361
|
-
);
|
|
362
|
-
const response = await hotUpdater.handlers.client(
|
|
363
|
-
eventRequest({
|
|
364
|
-
...selection,
|
|
365
|
-
type: "RELEASE_ADOPTED",
|
|
366
|
-
fromBundleId: event.toBundleId,
|
|
367
|
-
updateStrategy: "appVersion",
|
|
368
|
-
}),
|
|
369
|
-
);
|
|
370
|
-
expect(response.status).toBe(400);
|
|
371
|
-
expect(recordEvent).toHaveBeenCalledTimes(1);
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
it("returns a stable client error for malformed event payloads", async () => {
|
|
375
|
-
const hotUpdater = start();
|
|
376
|
-
|
|
377
|
-
const response = await hotUpdater.handlers.client(
|
|
378
|
-
eventRequest({ ...event, platform: "web" }),
|
|
379
|
-
);
|
|
380
|
-
|
|
381
|
-
expect(response.status).toBe(400);
|
|
382
|
-
await expect(response.json()).resolves.toEqual({
|
|
383
|
-
error: "Invalid event field: platform",
|
|
384
|
-
});
|
|
385
|
-
});
|
|
386
|
-
|
|
387
|
-
it.each(["installId", "userId"] as const)(
|
|
388
|
-
"rejects a 256-character event %s",
|
|
389
|
-
async (field) => {
|
|
390
|
-
const hotUpdater = start();
|
|
391
|
-
|
|
392
|
-
const response = await hotUpdater.handlers.client(
|
|
393
|
-
eventRequest({ ...event, [field]: "x".repeat(256) }),
|
|
394
|
-
);
|
|
395
|
-
|
|
396
|
-
expect(response.status).toBe(400);
|
|
397
|
-
await expect(response.json()).resolves.toEqual({
|
|
398
|
-
error: `Invalid event field: ${field}`,
|
|
399
|
-
});
|
|
400
|
-
},
|
|
401
|
-
);
|
|
402
|
-
|
|
403
|
-
it("preserves a leading Unicode BOM in exact installation and current-user IDs", async () => {
|
|
404
|
-
const hotUpdater = start();
|
|
405
|
-
const installId = "\uFEFFinstall";
|
|
406
|
-
const userId = "\uFEFFuser";
|
|
407
|
-
expect(
|
|
408
|
-
(
|
|
409
|
-
await hotUpdater.handlers.client(
|
|
410
|
-
eventRequest({ ...event, installId, userId }),
|
|
411
|
-
)
|
|
412
|
-
).status,
|
|
413
|
-
).toBe(204);
|
|
414
|
-
const installation = await hotUpdater.handlers.admin(
|
|
415
|
-
new Request(
|
|
416
|
-
`https://example.com/installations/${encodeURIComponent(installId)}`,
|
|
417
|
-
),
|
|
418
|
-
);
|
|
419
|
-
expect(installation.status).toBe(200);
|
|
420
|
-
await expect(installation.json()).resolves.toMatchObject({
|
|
421
|
-
installId,
|
|
422
|
-
userId,
|
|
423
|
-
});
|
|
424
|
-
const matches = await hotUpdater.handlers.admin(
|
|
425
|
-
new Request(
|
|
426
|
-
`https://example.com/installations?userId=${encodeURIComponent(userId)}`,
|
|
427
|
-
),
|
|
428
|
-
);
|
|
429
|
-
expect(matches.status).toBe(200);
|
|
430
|
-
await expect(matches.json()).resolves.toMatchObject({
|
|
431
|
-
data: [{ installId, userId }],
|
|
432
|
-
});
|
|
433
|
-
});
|
|
434
|
-
|
|
435
|
-
it.each(["\uD800", "\uDC00"])(
|
|
436
|
-
"rejects an unmatched surrogate identity %j",
|
|
437
|
-
async (installId) => {
|
|
438
|
-
const hotUpdater = start();
|
|
439
|
-
expect(
|
|
440
|
-
(
|
|
441
|
-
await hotUpdater.handlers.client(
|
|
442
|
-
eventRequest({ ...event, installId }),
|
|
443
|
-
)
|
|
444
|
-
).status,
|
|
445
|
-
).toBe(400);
|
|
446
|
-
},
|
|
447
|
-
);
|
|
448
|
-
|
|
449
|
-
it("rejects 256-character installation query identities", async () => {
|
|
450
|
-
const hotUpdater = start();
|
|
451
|
-
const tooLong = "x".repeat(256);
|
|
452
|
-
|
|
453
|
-
const user = await hotUpdater.handlers.admin(
|
|
454
|
-
new Request(`https://example.com/installations?userId=${tooLong}`),
|
|
455
|
-
);
|
|
456
|
-
const installation = await hotUpdater.handlers.admin(
|
|
457
|
-
new Request(`https://example.com/installations/${tooLong}`),
|
|
458
|
-
);
|
|
459
|
-
|
|
460
|
-
expect(user.status).toBe(400);
|
|
461
|
-
expect(installation.status).toBe(400);
|
|
462
|
-
});
|
|
463
|
-
|
|
464
|
-
it.each(["fromReleaseId", "toReleaseId"] as const)(
|
|
465
|
-
"rejects an omitted %s instead of treating it as null",
|
|
466
|
-
async (field) => {
|
|
467
|
-
const hotUpdater = start();
|
|
468
|
-
const payload: Record<string, unknown> = { ...event };
|
|
469
|
-
delete payload[field];
|
|
470
|
-
|
|
471
|
-
const response = await hotUpdater.handlers.client(eventRequest(payload));
|
|
472
|
-
|
|
473
|
-
expect(response.status).toBe(400);
|
|
474
|
-
await expect(response.json()).resolves.toEqual({
|
|
475
|
-
error: `Invalid event field: ${field}`,
|
|
476
|
-
});
|
|
477
|
-
},
|
|
478
|
-
);
|
|
479
|
-
|
|
480
|
-
it("records a report with fields it does not know and still checks the ones it does", async () => {
|
|
481
|
-
const hotUpdater = start();
|
|
482
|
-
const recordEvent = vi.spyOn(hotUpdater.api.insights, "recordEvent");
|
|
483
|
-
// `username` left the contract; an older client's is ignored like any other.
|
|
484
|
-
const newer = {
|
|
485
|
-
...event,
|
|
486
|
-
networkType: "wifi",
|
|
487
|
-
screen: { width: 390 },
|
|
488
|
-
username: "Jane",
|
|
489
|
-
};
|
|
490
|
-
|
|
491
|
-
expect((await hotUpdater.handlers.client(eventRequest(newer))).status).toBe(
|
|
492
|
-
204,
|
|
493
|
-
);
|
|
494
|
-
expect(recordEvent.mock.calls[0]![0].metadata).not.toHaveProperty(
|
|
495
|
-
"username",
|
|
496
|
-
);
|
|
497
|
-
const installation = await hotUpdater.handlers.admin(
|
|
498
|
-
new Request("https://example.com/installations/install-1"),
|
|
499
|
-
);
|
|
500
|
-
const found = await installation.json();
|
|
501
|
-
expect(found).toMatchObject({
|
|
502
|
-
installId: "install-1",
|
|
503
|
-
latestStatus: "UNCHANGED",
|
|
504
|
-
});
|
|
505
|
-
expect(found).not.toHaveProperty("username");
|
|
506
|
-
const invalid = await hotUpdater.handlers.client(
|
|
507
|
-
eventRequest({ ...newer, channel: 7 }),
|
|
508
|
-
);
|
|
509
|
-
expect(invalid.status).toBe(400);
|
|
510
|
-
await expect(invalid.json()).resolves.toEqual({
|
|
511
|
-
error: "Invalid event field: channel",
|
|
512
|
-
});
|
|
513
|
-
const tooLarge = await hotUpdater.handlers.client(
|
|
514
|
-
eventRequest({ ...newer, padding: "x".repeat(EVENT_BODY_MAX_BYTES) }),
|
|
515
|
-
);
|
|
516
|
-
expect(tooLarge.status).toBe(413);
|
|
517
|
-
});
|
|
518
|
-
|
|
519
|
-
it("records every update failure, reading unknown or malformed parts as unknown, and lists it with what failed", async () => {
|
|
520
|
-
vi.useFakeTimers();
|
|
521
|
-
vi.setSystemTime(Date.UTC(2026, 8, 20, 10));
|
|
522
|
-
const hotUpdater = start();
|
|
523
|
-
const failed = {
|
|
524
|
-
...event,
|
|
525
|
-
type: "UPDATE_FAILED",
|
|
526
|
-
fromBundleId: "bundle-1",
|
|
527
|
-
toBundleId: "bundle-2",
|
|
528
|
-
toReleaseId: "release-2",
|
|
529
|
-
updateStrategy: "appVersion",
|
|
530
|
-
};
|
|
531
|
-
const report = async (metadata: unknown) => {
|
|
532
|
-
const response = await hotUpdater.handlers.client(
|
|
533
|
-
eventRequest({ ...failed, metadata }),
|
|
534
|
-
);
|
|
535
|
-
expect(response.status).toBe(204);
|
|
536
|
-
vi.advanceTimersByTime(1);
|
|
537
|
-
};
|
|
538
|
-
await report({
|
|
539
|
-
failure: {
|
|
540
|
-
stage: "download",
|
|
541
|
-
reason: "http",
|
|
542
|
-
resource: "artifact",
|
|
543
|
-
httpStatus: 403,
|
|
544
|
-
originCode: "AccessDenied",
|
|
545
|
-
},
|
|
546
|
-
});
|
|
547
|
-
// A newer client's stage, reason, resource, and transport.
|
|
548
|
-
await report({
|
|
549
|
-
failure: {
|
|
550
|
-
stage: "verify",
|
|
551
|
-
reason: "quantum",
|
|
552
|
-
resource: "shard",
|
|
553
|
-
transport: "carrier-pigeon",
|
|
554
|
-
},
|
|
555
|
-
});
|
|
556
|
-
// No failure, one that is not an object, and malformed optional fields.
|
|
557
|
-
await report(undefined);
|
|
558
|
-
await report({ failure: "broken" });
|
|
559
|
-
await report({
|
|
560
|
-
failure: {
|
|
561
|
-
stage: "install",
|
|
562
|
-
reason: "storage",
|
|
563
|
-
httpStatus: "403",
|
|
564
|
-
originCode: "not a code",
|
|
565
|
-
previousProcessExit: "x".repeat(65),
|
|
566
|
-
},
|
|
567
|
-
});
|
|
568
|
-
|
|
569
|
-
const events = await hotUpdater.handlers.admin(
|
|
570
|
-
new Request(
|
|
571
|
-
`https://example.com/events?platform=ios&channel=production&bundleId=bundle-2&outcome=failed&beforeReceivedAtMs=${Date.now()}`,
|
|
572
|
-
),
|
|
573
|
-
);
|
|
574
|
-
expect(events.status).toBe(200);
|
|
575
|
-
const { data } = (await events.json()) as {
|
|
576
|
-
data: { type: string; failure: unknown }[];
|
|
577
|
-
};
|
|
578
|
-
expect(data.map(({ type }) => type)).toEqual(
|
|
579
|
-
Array(5).fill("UPDATE_FAILED"),
|
|
580
|
-
);
|
|
581
|
-
expect(data.map(({ failure }) => failure)).toEqual([
|
|
582
|
-
{ stage: "install", reason: "storage" },
|
|
583
|
-
{ stage: "unknown", reason: "unknown" },
|
|
584
|
-
{ stage: "unknown", reason: "unknown" },
|
|
585
|
-
{
|
|
586
|
-
stage: "unknown",
|
|
587
|
-
reason: "unknown",
|
|
588
|
-
resource: "unknown",
|
|
589
|
-
transport: "unknown",
|
|
590
|
-
},
|
|
591
|
-
{
|
|
592
|
-
stage: "download",
|
|
593
|
-
reason: "http",
|
|
594
|
-
resource: "artifact",
|
|
595
|
-
httpStatus: 403,
|
|
596
|
-
originCode: "AccessDenied",
|
|
597
|
-
},
|
|
598
|
-
]);
|
|
599
|
-
// A failure moves no installation: none has reported a launch.
|
|
600
|
-
expect(
|
|
601
|
-
(
|
|
602
|
-
await hotUpdater.handlers.admin(
|
|
603
|
-
new Request("https://example.com/installations/install-1"),
|
|
604
|
-
)
|
|
605
|
-
).status,
|
|
606
|
-
).toBe(404);
|
|
607
|
-
// Only a structurally invalid report is refused.
|
|
608
|
-
for (const invalid of [
|
|
609
|
-
{ ...failed, fromBundleId: null },
|
|
610
|
-
{ ...failed, updateStrategy: null },
|
|
611
|
-
{ ...failed, eventId: "not-a-uuid" },
|
|
612
|
-
]) {
|
|
613
|
-
expect(
|
|
614
|
-
(await hotUpdater.handlers.client(eventRequest(invalid))).status,
|
|
615
|
-
).toBe(400);
|
|
616
|
-
}
|
|
617
|
-
});
|
|
618
|
-
|
|
619
|
-
it("keeps how a bundle arrived and why a crashed process exited", async () => {
|
|
620
|
-
const hotUpdater = start();
|
|
621
|
-
const movement = {
|
|
622
|
-
...event,
|
|
623
|
-
fromBundleId: "bundle-1",
|
|
624
|
-
toBundleId: "bundle-2",
|
|
625
|
-
toReleaseId: "release-2",
|
|
626
|
-
updateStrategy: "appVersion",
|
|
627
|
-
};
|
|
628
|
-
for (const body of [
|
|
629
|
-
{
|
|
630
|
-
...movement,
|
|
631
|
-
type: "UPDATE_DOWNLOADED",
|
|
632
|
-
metadata: { delivery: "archive", patchFallback: true },
|
|
633
|
-
},
|
|
634
|
-
{
|
|
635
|
-
...movement,
|
|
636
|
-
type: "RECOVERED",
|
|
637
|
-
installId: "install-2",
|
|
638
|
-
metadata: { previousProcessExit: "CRASH_NATIVE" },
|
|
639
|
-
},
|
|
640
|
-
{
|
|
641
|
-
...movement,
|
|
642
|
-
type: "UPDATE_DOWNLOADED",
|
|
643
|
-
installId: "install-3",
|
|
644
|
-
metadata: { delivery: "teleport", patchFallback: "yes" },
|
|
645
|
-
},
|
|
646
|
-
]) {
|
|
647
|
-
expect(
|
|
648
|
-
(await hotUpdater.handlers.client(eventRequest(body))).status,
|
|
649
|
-
).toBe(204);
|
|
650
|
-
}
|
|
651
|
-
const events = await hotUpdater.handlers.admin(
|
|
652
|
-
new Request(
|
|
653
|
-
`https://example.com/events?beforeReceivedAtMs=${Date.now() + 1}`,
|
|
654
|
-
),
|
|
655
|
-
);
|
|
656
|
-
const { data } = (await events.json()) as {
|
|
657
|
-
data: Record<string, unknown>[];
|
|
658
|
-
};
|
|
659
|
-
const byInstall = Object.fromEntries(
|
|
660
|
-
data.map((row) => [row.installId, row]),
|
|
661
|
-
);
|
|
662
|
-
expect(byInstall["install-1"]).toMatchObject({
|
|
663
|
-
delivery: "archive",
|
|
664
|
-
patchFallback: true,
|
|
665
|
-
});
|
|
666
|
-
expect(byInstall["install-2"]).toMatchObject({
|
|
667
|
-
previousProcessExit: "CRASH_NATIVE",
|
|
668
|
-
});
|
|
669
|
-
expect(byInstall["install-3"]).toMatchObject({ delivery: "unknown" });
|
|
670
|
-
expect(byInstall["install-3"]).not.toHaveProperty("patchFallback");
|
|
671
|
-
});
|
|
672
|
-
|
|
673
|
-
it("serves a release's and a channel's update failures to admins", async () => {
|
|
674
|
-
vi.useFakeTimers();
|
|
675
|
-
const at = Date.UTC(2026, 8, 20, 10, 30);
|
|
676
|
-
vi.setSystemTime(at);
|
|
677
|
-
const hotUpdater = start();
|
|
678
|
-
const failed = (installId: string, failure: Record<string, unknown>) =>
|
|
679
|
-
hotUpdater.handlers.client(
|
|
680
|
-
eventRequest({
|
|
681
|
-
...event,
|
|
682
|
-
installId,
|
|
683
|
-
type: "UPDATE_FAILED",
|
|
684
|
-
fromBundleId: "bundle-1",
|
|
685
|
-
toBundleId: failure.stage === "check" ? "bundle-1" : "bundle-2",
|
|
686
|
-
toReleaseId: failure.stage === "check" ? null : "release-2",
|
|
687
|
-
updateStrategy: "appVersion",
|
|
688
|
-
metadata: { failure },
|
|
689
|
-
}),
|
|
690
|
-
);
|
|
691
|
-
await failed("install-1", {
|
|
692
|
-
stage: "download",
|
|
693
|
-
reason: "http",
|
|
694
|
-
httpStatus: 403,
|
|
695
|
-
});
|
|
696
|
-
await failed("install-2", { stage: "check", reason: "http" });
|
|
697
|
-
const hour = at - (at % 3_600_000);
|
|
698
|
-
const range = `start=${hour}&end=${hour + 3_600_000}`;
|
|
699
|
-
const read = (query: string) =>
|
|
700
|
-
hotUpdater.handlers.admin(
|
|
701
|
-
new Request(`https://example.com/failures?${query}`),
|
|
702
|
-
);
|
|
703
|
-
|
|
704
|
-
const release = await read(
|
|
705
|
-
`platform=ios&channel=production&releaseId=release-2&${range}`,
|
|
706
|
-
);
|
|
707
|
-
expect(release.status).toBe(200);
|
|
708
|
-
await expect(release.json()).resolves.toMatchObject({
|
|
709
|
-
failedUpdates: 1,
|
|
710
|
-
failedInstallations: 1,
|
|
711
|
-
downloads: 0,
|
|
712
|
-
breakdown: [
|
|
713
|
-
{
|
|
714
|
-
stage: "download",
|
|
715
|
-
reason: "http",
|
|
716
|
-
events: 1,
|
|
717
|
-
details: [
|
|
718
|
-
{
|
|
719
|
-
resource: null,
|
|
720
|
-
httpStatus: 403,
|
|
721
|
-
originCode: null,
|
|
722
|
-
transport: null,
|
|
723
|
-
events: 1,
|
|
724
|
-
},
|
|
725
|
-
],
|
|
726
|
-
},
|
|
727
|
-
],
|
|
728
|
-
recoveries: { failedLaunches: 0, byExitReason: [] },
|
|
729
|
-
});
|
|
730
|
-
await expect(
|
|
731
|
-
(
|
|
732
|
-
await read("platform=ios&channel=production&releaseId=release-2")
|
|
733
|
-
).json(),
|
|
734
|
-
).resolves.toMatchObject({ failedUpdates: 1, failedInstallations: 1 });
|
|
735
|
-
const channel = await read(`platform=ios&channel=production&${range}`);
|
|
736
|
-
await expect(channel.json()).resolves.toMatchObject({
|
|
737
|
-
failedUpdates: 1,
|
|
738
|
-
checks: { failures: 1, failedInstallations: 1 },
|
|
739
|
-
breakdown: [
|
|
740
|
-
{ stage: "check", reason: "http", events: 1 },
|
|
741
|
-
{ stage: "download", reason: "http", events: 1 },
|
|
742
|
-
],
|
|
743
|
-
});
|
|
744
|
-
for (const invalid of [
|
|
745
|
-
"channel=production&releaseId=release-2",
|
|
746
|
-
"platform=ios&channel=production",
|
|
747
|
-
`platform=ios&channel=production&start=${hour}`,
|
|
748
|
-
"platform=ios&channel=production&start=a&end=b",
|
|
749
|
-
// Over 30 days, the console's longest period.
|
|
750
|
-
`platform=ios&channel=production&start=${hour - 30 * 86_400_000}&end=${hour + 1}`,
|
|
751
|
-
]) {
|
|
752
|
-
expect((await read(invalid)).status).toBe(400);
|
|
753
|
-
}
|
|
754
|
-
});
|
|
755
|
-
|
|
756
|
-
it("counts a retried report once under its client event ID, whichever installation repeats it", async () => {
|
|
757
|
-
const hotUpdater = start();
|
|
758
|
-
const eventId = "01987a6e-4c00-7abc-8def-0123456789ab";
|
|
759
|
-
const applied = {
|
|
760
|
-
...event,
|
|
761
|
-
type: "UPDATE_APPLIED",
|
|
762
|
-
fromBundleId: "bundle-0",
|
|
763
|
-
updateStrategy: "appVersion",
|
|
764
|
-
} as const;
|
|
765
|
-
const report = { ...applied, eventId };
|
|
766
|
-
const counts = async () => {
|
|
767
|
-
const overview = await hotUpdater.handlers.admin(
|
|
768
|
-
new Request(
|
|
769
|
-
"https://example.com/overview?platform=ios&channel=production&window=24h&bundleId=bundle-1",
|
|
770
|
-
),
|
|
771
|
-
);
|
|
772
|
-
return (
|
|
773
|
-
(await overview.json()) as {
|
|
774
|
-
readonly bundle: { readonly appliedReports: { count: number } };
|
|
775
|
-
}
|
|
776
|
-
).bundle.appliedReports.count;
|
|
777
|
-
};
|
|
778
|
-
|
|
779
|
-
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
780
|
-
expect(
|
|
781
|
-
(await hotUpdater.handlers.client(eventRequest(report))).status,
|
|
782
|
-
).toBe(204);
|
|
783
|
-
}
|
|
784
|
-
await expect(counts()).resolves.toBe(1);
|
|
785
|
-
const events = await hotUpdater.handlers.admin(
|
|
786
|
-
new Request(
|
|
787
|
-
`https://example.com/events?beforeReceivedAtMs=${Date.now() + 1}`,
|
|
788
|
-
),
|
|
789
|
-
);
|
|
790
|
-
await expect(events.json()).resolves.toMatchObject({
|
|
791
|
-
data: [{ id: eventId, installId: "install-1" }],
|
|
792
|
-
});
|
|
793
|
-
|
|
794
|
-
// A report under a stored ID changes nothing, as analytics ingestion
|
|
795
|
-
// drops duplicates.
|
|
796
|
-
expect(
|
|
797
|
-
(
|
|
798
|
-
await hotUpdater.handlers.client(
|
|
799
|
-
eventRequest({ ...report, installId: "install-2" }),
|
|
800
|
-
)
|
|
801
|
-
).status,
|
|
802
|
-
).toBe(204);
|
|
803
|
-
expect(
|
|
804
|
-
(
|
|
805
|
-
await hotUpdater.handlers.admin(
|
|
806
|
-
new Request("https://example.com/installations/install-2"),
|
|
807
|
-
)
|
|
808
|
-
).status,
|
|
809
|
-
).toBe(404);
|
|
810
|
-
|
|
811
|
-
// Without an ID the server creates one, so each report counts.
|
|
812
|
-
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
813
|
-
expect(
|
|
814
|
-
(await hotUpdater.handlers.client(eventRequest(applied))).status,
|
|
815
|
-
).toBe(204);
|
|
816
|
-
}
|
|
817
|
-
await expect(counts()).resolves.toBe(3);
|
|
818
|
-
});
|
|
819
|
-
|
|
820
|
-
it("counts an installation's UNCHANGED reports once a UTC day, retried or repeated", async () => {
|
|
821
|
-
vi.useFakeTimers();
|
|
822
|
-
vi.setSystemTime(new Date("2026-08-12T10:00:00.000Z"));
|
|
823
|
-
const hotUpdater = start();
|
|
824
|
-
const append = vi.spyOn(hotUpdater.api.insights, "recordEvent");
|
|
825
|
-
const launches = async () => {
|
|
826
|
-
const {
|
|
827
|
-
data: [activity],
|
|
828
|
-
} = await hotUpdater.api.insights.getReleaseActivity({
|
|
829
|
-
scope: { platform: "ios", channel: "production" },
|
|
830
|
-
timeRange: {
|
|
831
|
-
start: Date.parse("2026-08-12T00:00:00.000Z"),
|
|
832
|
-
end: Date.parse("2026-08-14T00:00:00.000Z"),
|
|
833
|
-
},
|
|
834
|
-
});
|
|
835
|
-
return activity!.metrics.launches;
|
|
836
|
-
};
|
|
837
|
-
const report = {
|
|
838
|
-
...event,
|
|
839
|
-
eventId: "01987a6e-4c00-7abc-8def-0123456789ab",
|
|
840
|
-
};
|
|
841
|
-
|
|
842
|
-
// A retry, then relaunches later that day, with and without an ID.
|
|
843
|
-
for (const body of [report, report, event, event]) {
|
|
844
|
-
expect(
|
|
845
|
-
(await hotUpdater.handlers.client(eventRequest(body))).status,
|
|
846
|
-
).toBe(204);
|
|
847
|
-
vi.advanceTimersByTime(60 * 60 * 1_000);
|
|
848
|
-
}
|
|
849
|
-
expect(append).toHaveBeenCalledTimes(4);
|
|
850
|
-
await expect(launches()).resolves.toBe(1);
|
|
851
|
-
|
|
852
|
-
// The next UTC day counts the installation again.
|
|
853
|
-
vi.setSystemTime(new Date("2026-08-13T09:00:00.000Z"));
|
|
854
|
-
expect((await hotUpdater.handlers.client(eventRequest())).status).toBe(204);
|
|
855
|
-
await expect(launches()).resolves.toBe(2);
|
|
856
|
-
});
|
|
857
|
-
|
|
858
|
-
it.each([
|
|
859
|
-
"event-1",
|
|
860
|
-
"01987A6E-4C00-7ABC-8DEF-0123456789AB",
|
|
861
|
-
"01987a6e-4c00-4abc-8def-0123456789ab",
|
|
862
|
-
null,
|
|
863
|
-
])("rejects the event ID %j", async (eventId) => {
|
|
864
|
-
const hotUpdater = start();
|
|
865
|
-
|
|
866
|
-
const response = await hotUpdater.handlers.client(
|
|
867
|
-
eventRequest({ ...event, eventId }),
|
|
868
|
-
);
|
|
869
|
-
|
|
870
|
-
expect(response.status).toBe(400);
|
|
871
|
-
await expect(response.json()).resolves.toEqual({
|
|
872
|
-
error: "Invalid event field: eventId",
|
|
873
|
-
});
|
|
874
|
-
});
|
|
875
|
-
|
|
876
|
-
it("answers 503 with Retry-After while the database is busy, and 500 when it fails", async () => {
|
|
877
|
-
const error = vi.spyOn(console, "error").mockImplementation(() => {});
|
|
878
|
-
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
879
|
-
const on = (overrides: Partial<DatabaseAdapter>) =>
|
|
880
|
-
createHotUpdater({
|
|
881
|
-
database: {
|
|
882
|
-
name: "testDatabase",
|
|
883
|
-
adapter: { ...createMemoryAdapter(), ...overrides },
|
|
884
|
-
},
|
|
885
|
-
plugins: [insights()],
|
|
886
|
-
clientAccess: "public",
|
|
887
|
-
}).handlers.client(eventRequest());
|
|
888
|
-
const throttled = Object.assign(
|
|
889
|
-
new Error("The level of configured provisioned throughput was exceeded."),
|
|
890
|
-
{ name: "ProvisionedThroughputExceededException" },
|
|
891
|
-
);
|
|
892
|
-
|
|
893
|
-
// Every write is refused as transient until the engine runs out of retries.
|
|
894
|
-
const busy = await on({ write: async () => ({ ok: false, retry: true }) });
|
|
895
|
-
expect(busy.status).toBe(503);
|
|
896
|
-
expect(busy.headers.get("retry-after")).toBe("5");
|
|
897
|
-
await expect(busy.json()).resolves.toEqual({
|
|
898
|
-
error: "Service unavailable",
|
|
899
|
-
});
|
|
900
|
-
// A throttled read throws the backend's own error.
|
|
901
|
-
const throttledRead = await on({
|
|
902
|
-
get: async () => {
|
|
903
|
-
throw throttled;
|
|
904
|
-
},
|
|
905
|
-
});
|
|
906
|
-
expect(throttledRead.status).toBe(503);
|
|
907
|
-
expect(throttledRead.headers.get("retry-after")).toBe("5");
|
|
908
|
-
const failed = await on({
|
|
909
|
-
get: async () => {
|
|
910
|
-
throw new Error("connection refused");
|
|
911
|
-
},
|
|
912
|
-
});
|
|
913
|
-
expect(failed.status).toBe(500);
|
|
914
|
-
expect(failed.headers.get("retry-after")).toBeNull();
|
|
915
|
-
// Each 503 warns, and only the failure logs as an error.
|
|
916
|
-
expect(warn).toHaveBeenCalledTimes(2);
|
|
917
|
-
expect(error).toHaveBeenCalledTimes(1);
|
|
918
|
-
error.mockRestore();
|
|
919
|
-
warn.mockRestore();
|
|
920
|
-
});
|
|
921
|
-
});
|