@hot-updater/aws 1.2.0-rc.57 → 1.2.0-rc.58
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/init/index.cjs +1 -0
- package/dist/init/index.mjs +2 -1
- package/dist/lambda/index.cjs +258 -165
- package/package.json +8 -8
package/dist/init/index.cjs
CHANGED
|
@@ -8776,6 +8776,7 @@ const runInit = async ({ build, envFile, secretsEnv }) => {
|
|
|
8776
8776
|
let credential;
|
|
8777
8777
|
try {
|
|
8778
8778
|
await (0, _hot_updater_cli_tools.fillReleaseLabels)(server);
|
|
8779
|
+
await (0, _hot_updater_cli_tools.backfillInsightsReleaseRefs)(server);
|
|
8779
8780
|
credential = await (0, _hot_updater_cli_tools.provisionClientCredential)(server, {
|
|
8780
8781
|
env: providerEnv,
|
|
8781
8782
|
name: "AWS init"
|
package/dist/init/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
import { ConfigBuilder, InitError, MissingInitInputsError, assembleServer, assertInfrastructureGenerationAtUrl, assertInfrastructureGenerationPayload, assertInitProviderInputs, colors, confirmInitInputPersistence, copyDirToTmp, createHotUpdaterConfigScaffoldFromBuilder, createZip, ensureInstallPackages, fillReleaseLabels, getCwd, getHotUpdaterInitInputEnv, getInitProviderEnvVars, getInitProviderTextPromptValues, link, makeEnv, p, printAppSetup, provisionClientCredential, readHotUpdaterInitEnv, resolveInitProviderInput, transformEnv, writeHotUpdaterFiles } from "@hot-updater/cli-tools";
|
|
2
|
+
import { ConfigBuilder, InitError, MissingInitInputsError, assembleServer, assertInfrastructureGenerationAtUrl, assertInfrastructureGenerationPayload, assertInitProviderInputs, backfillInsightsReleaseRefs, colors, confirmInitInputPersistence, copyDirToTmp, createHotUpdaterConfigScaffoldFromBuilder, createZip, ensureInstallPackages, fillReleaseLabels, getCwd, getHotUpdaterInitInputEnv, getInitProviderEnvVars, getInitProviderTextPromptValues, link, makeEnv, p, printAppSetup, provisionClientCredential, readHotUpdaterInitEnv, resolveInitProviderInput, transformEnv, writeHotUpdaterFiles } from "@hot-updater/cli-tools";
|
|
3
3
|
import { apiKeys, insights, remoteConfig } from "@hot-updater/server/plugins";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import { ChildProcess, execFile, spawn, spawnSync } from "node:child_process";
|
|
@@ -8771,6 +8771,7 @@ const runInit = async ({ build, envFile, secretsEnv }) => {
|
|
|
8771
8771
|
let credential;
|
|
8772
8772
|
try {
|
|
8773
8773
|
await fillReleaseLabels(server);
|
|
8774
|
+
await backfillInsightsReleaseRefs(server);
|
|
8774
8775
|
credential = await provisionClientCredential(server, {
|
|
8775
8776
|
env: providerEnv,
|
|
8776
8777
|
name: "AWS init"
|
package/dist/lambda/index.cjs
CHANGED
|
@@ -554,14 +554,14 @@ function modularInverse(value, modulus) {
|
|
|
554
554
|
if (r > 1) throw new Error(`No modular inverse for ${value} mod ${modulus}`);
|
|
555
555
|
return positiveMod(t, modulus);
|
|
556
556
|
}
|
|
557
|
-
function getRolloutShuffleParameters(
|
|
558
|
-
let multiplier = positiveMod(hashString(`${
|
|
557
|
+
function getRolloutShuffleParameters(releaseId) {
|
|
558
|
+
let multiplier = positiveMod(hashString(`${releaseId}:multiplier`), 997);
|
|
559
559
|
if (multiplier === 0) multiplier = 1;
|
|
560
560
|
while (gcd(multiplier, NUMERIC_COHORT_SIZE) !== 1) {
|
|
561
561
|
multiplier = positiveMod(multiplier + 1, NUMERIC_COHORT_SIZE);
|
|
562
562
|
if (multiplier === 0) multiplier = 1;
|
|
563
563
|
}
|
|
564
|
-
const offset = positiveMod(hashString(`${
|
|
564
|
+
const offset = positiveMod(hashString(`${releaseId}:offset`), NUMERIC_COHORT_SIZE);
|
|
565
565
|
return {
|
|
566
566
|
multiplier,
|
|
567
567
|
offset,
|
|
@@ -594,16 +594,16 @@ function isValidCohort(cohort) {
|
|
|
594
594
|
const normalized = normalizeCohortValue(cohort);
|
|
595
595
|
return isNumericCohort(normalized) || isCustomCohort(normalized);
|
|
596
596
|
}
|
|
597
|
-
function getNumericCohortRolloutPosition(
|
|
597
|
+
function getNumericCohortRolloutPosition(releaseId, cohortValue) {
|
|
598
598
|
if (cohortValue < 1 || cohortValue > 1e3) throw new Error(`Invalid numeric cohort: ${cohortValue}`);
|
|
599
|
-
const { offset, inverseMultiplier } = getRolloutShuffleParameters(
|
|
599
|
+
const { offset, inverseMultiplier } = getRolloutShuffleParameters(releaseId);
|
|
600
600
|
return positiveMod(inverseMultiplier * (cohortValue - 1 - offset), NUMERIC_COHORT_SIZE);
|
|
601
601
|
}
|
|
602
|
-
function getRolledOutNumericCohorts(
|
|
602
|
+
function getRolledOutNumericCohorts(releaseId, rolloutCohortCount) {
|
|
603
603
|
const normalizedRolloutCount = normalizeRolloutCohortCount(rolloutCohortCount);
|
|
604
604
|
if (normalizedRolloutCount <= 0) return [];
|
|
605
605
|
if (normalizedRolloutCount >= 1e3) return Array.from({ length: NUMERIC_COHORT_SIZE }, (_, index) => index + 1);
|
|
606
|
-
const { multiplier, offset } = getRolloutShuffleParameters(
|
|
606
|
+
const { multiplier, offset } = getRolloutShuffleParameters(releaseId);
|
|
607
607
|
return Array.from({ length: normalizedRolloutCount }, (_, position) => positiveMod(multiplier * position + offset, NUMERIC_COHORT_SIZE)).map((zeroBasedCohort) => zeroBasedCohort + 1).sort((left, right) => left - right);
|
|
608
608
|
}
|
|
609
609
|
const RELEASE_CATALOG_FALLBACK_POLICY = "BUILTIN_IF_ACTIVE_INELIGIBLE";
|
|
@@ -5226,7 +5226,7 @@ const createKvAdapter = ({ store, tablePrefix = "" }) => {
|
|
|
5226
5226
|
};
|
|
5227
5227
|
//#endregion
|
|
5228
5228
|
//#region ../../packages/server/dist/version.mjs
|
|
5229
|
-
const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.
|
|
5229
|
+
const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.58";
|
|
5230
5230
|
//#endregion
|
|
5231
5231
|
//#region ../../packages/server/dist/handlerVersionRoutes.mjs
|
|
5232
5232
|
/**
|
|
@@ -6025,7 +6025,7 @@ const baseBundleIdsOf = (row, range, bundleId, limit) => {
|
|
|
6025
6025
|
};
|
|
6026
6026
|
//#endregion
|
|
6027
6027
|
//#region ../../packages/server/dist/core/reads.mjs
|
|
6028
|
-
const PAGE$
|
|
6028
|
+
const PAGE$5 = 500;
|
|
6029
6029
|
const pick$2 = (fields) => (row) => Object.fromEntries(fields.map((field) => [field, row[field]]));
|
|
6030
6030
|
const toBundleRow = pick$2([
|
|
6031
6031
|
"id",
|
|
@@ -6122,7 +6122,7 @@ const createCoreReads = (db, storage) => {
|
|
|
6122
6122
|
const page = await db.findMany("bundle_patches", {
|
|
6123
6123
|
index: "byBundle",
|
|
6124
6124
|
where: { bundle_id: row.id },
|
|
6125
|
-
limit: Math.min(count - patches.length, PAGE$
|
|
6125
|
+
limit: Math.min(count - patches.length, PAGE$5),
|
|
6126
6126
|
...cursor === void 0 ? {} : { cursor }
|
|
6127
6127
|
});
|
|
6128
6128
|
patches.push(...page.rows.map(toPatchRow));
|
|
@@ -6348,7 +6348,7 @@ const createCoreReads = (db, storage) => {
|
|
|
6348
6348
|
return (await drain$1((page) => db.findMany("channels", {
|
|
6349
6349
|
index: "all",
|
|
6350
6350
|
where: {},
|
|
6351
|
-
limit: PAGE$
|
|
6351
|
+
limit: PAGE$5,
|
|
6352
6352
|
...page
|
|
6353
6353
|
}))).map(toChannelRow);
|
|
6354
6354
|
},
|
|
@@ -6743,7 +6743,7 @@ const createLabelAllocator = (tx, used, caughtUp) => {
|
|
|
6743
6743
|
};
|
|
6744
6744
|
};
|
|
6745
6745
|
const FILL_BATCH = 25;
|
|
6746
|
-
const PAGE$
|
|
6746
|
+
const PAGE$4 = 500;
|
|
6747
6747
|
/**
|
|
6748
6748
|
* Labels a channel and platform's releases that have none, in ID order,
|
|
6749
6749
|
* which is the order they were created in, and marks its counter filled:
|
|
@@ -6796,7 +6796,7 @@ const fillLabels = async (db, { channelId, platform }, { dryRun = false } = {})
|
|
|
6796
6796
|
channel_id: channelId,
|
|
6797
6797
|
platform
|
|
6798
6798
|
},
|
|
6799
|
-
limit: PAGE$
|
|
6799
|
+
limit: PAGE$4,
|
|
6800
6800
|
...cursor === void 0 ? {} : { cursor }
|
|
6801
6801
|
});
|
|
6802
6802
|
const unlabeled = page.rows.filter((row) => typeof row.label !== "number").map((row) => row.id);
|
|
@@ -6984,7 +6984,7 @@ const pendingLabelPairs = async (db) => {
|
|
|
6984
6984
|
};
|
|
6985
6985
|
//#endregion
|
|
6986
6986
|
//#region ../../packages/server/dist/core/writes.mjs
|
|
6987
|
-
const PAGE$
|
|
6987
|
+
const PAGE$3 = 500;
|
|
6988
6988
|
/** Moves one bundle into or out of its platform's total and the overall total. */
|
|
6989
6989
|
const countBundle = (tx, platform, delta) => {
|
|
6990
6990
|
for (const key of [platform, "*"]) tx.aggregate("bundle_totals", { platform_key: key }, { bundles: delta });
|
|
@@ -7023,7 +7023,7 @@ const replaceBundlePatches = async (tx, bundle, rows, checkNew) => {
|
|
|
7023
7023
|
const page = await tx.findMany("bundle_patches", {
|
|
7024
7024
|
index: "byBundle",
|
|
7025
7025
|
where: { bundle_id: bundle.id },
|
|
7026
|
-
limit: Math.min(count - seen, PAGE$
|
|
7026
|
+
limit: Math.min(count - seen, PAGE$3),
|
|
7027
7027
|
...cursor === void 0 ? {} : { cursor }
|
|
7028
7028
|
});
|
|
7029
7029
|
for (const stored of page.rows) {
|
|
@@ -7587,7 +7587,7 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
7587
7587
|
});
|
|
7588
7588
|
//#endregion
|
|
7589
7589
|
//#region ../../packages/server/dist/core/releases.mjs
|
|
7590
|
-
const PAGE$
|
|
7590
|
+
const PAGE$2 = 500;
|
|
7591
7591
|
const fail$1 = (code, message) => {
|
|
7592
7592
|
throw new ReleaseCatalogMutationError(code, message);
|
|
7593
7593
|
};
|
|
@@ -7622,7 +7622,7 @@ const enabledIn = (scopeKey, cursor) => ({
|
|
|
7622
7622
|
scope_key: scopeKey,
|
|
7623
7623
|
enabled: true
|
|
7624
7624
|
},
|
|
7625
|
-
limit: PAGE$
|
|
7625
|
+
limit: PAGE$2,
|
|
7626
7626
|
...cursor === void 0 ? {} : { cursor }
|
|
7627
7627
|
});
|
|
7628
7628
|
/** A scope's enabled releases, all of them, under the catalog's guard. */
|
|
@@ -10037,21 +10037,29 @@ const isLaunch = (row) => {
|
|
|
10037
10037
|
const kinds = metadataOf(row).change?.kinds ?? [];
|
|
10038
10038
|
return kinds.includes("bundle") && !kinds.includes("first_seen") && row.to_release_id !== null;
|
|
10039
10039
|
};
|
|
10040
|
+
const sideRef = (key, releaseId, bundleId) => key === "release" ? releaseId ?? bundleId : bundleId;
|
|
10040
10041
|
/**
|
|
10041
10042
|
* The bundle a stored row's bundle filter matches: `from:<bundle>` for a
|
|
10042
10043
|
* recovery; `to:<bundle>` for a download, an apply, and an update failure;
|
|
10043
10044
|
* `on:<bundle>` for an UNCHANGED row that launched a bundle (`isLaunch`), a
|
|
10044
10045
|
* key no other row uses. None for a failed check, which targets no bundle, a
|
|
10045
|
-
* late row, or any other UNCHANGED row.
|
|
10046
|
+
* late row, or any other UNCHANGED row. Each names its bundle by `key`.
|
|
10046
10047
|
*/
|
|
10047
|
-
const bundleRefsOf = (row) => {
|
|
10048
|
+
const bundleRefsOf = (row, key = "release") => {
|
|
10048
10049
|
if (isFailedCheck(row) || isLateEvent(row)) return [];
|
|
10049
|
-
if (row.type === "RECOVERED") return [`from:${row.from_bundle_id}`];
|
|
10050
|
-
if (row.type === "UNCHANGED") return isLaunch(row) ? [`on:${row.to_bundle_id}`] : [];
|
|
10051
|
-
return [`to:${row.to_bundle_id}`];
|
|
10050
|
+
if (row.type === "RECOVERED") return [`from:${sideRef(key, row.from_release_id, row.from_bundle_id)}`];
|
|
10051
|
+
if (row.type === "UNCHANGED") return isLaunch(row) ? [`on:${sideRef(key, row.to_release_id, row.to_bundle_id)}`] : [];
|
|
10052
|
+
return [`to:${sideRef(key, row.to_release_id, row.to_bundle_id)}`];
|
|
10052
10053
|
};
|
|
10054
|
+
/**
|
|
10055
|
+
* The hourly outcome rows a stored row counts in, as `[type, bundle ref]`:
|
|
10056
|
+
* its bundle filter's (`bundleRefsOf`), and a download that a launch or
|
|
10057
|
+
* crash implied, in its bundle's download hour, so the download series
|
|
10058
|
+
* covers what the release's downloads count.
|
|
10059
|
+
*/
|
|
10060
|
+
const outcomeRefsOf = (row, key = "release") => [...bundleRefsOf(row, key).map((ref) => [row.type, ref]), ...metadataOf(row).implied_download === true ? [["UPDATE_DOWNLOADED", row.type === "RECOVERED" ? `to:${sideRef(key, row.from_release_id, row.from_bundle_id)}` : `to:${sideRef(key, row.to_release_id, row.to_bundle_id)}`]] : []];
|
|
10053
10061
|
/** The key a bundle filter reads, as `bundleRefsOf` writes it. */
|
|
10054
|
-
const bundleRefOfFilter = (filter) => filter.type === "RECOVERED" ? `from:${filter.
|
|
10062
|
+
const bundleRefOfFilter = (filter) => filter.type === "RECOVERED" ? `from:${filter.fromReleaseId}` : filter.type === "UNCHANGED" ? `on:${filter.toReleaseId}` : `to:${filter.toReleaseId}`;
|
|
10055
10063
|
/**
|
|
10056
10064
|
* Downloads, applies, recoveries, update failures, and the UNCHANGED
|
|
10057
10065
|
* reports that changed what their installation runs, whole. An UNCHANGED
|
|
@@ -10116,7 +10124,11 @@ const bundleEvents = (days) => defineTable({
|
|
|
10116
10124
|
type: "string",
|
|
10117
10125
|
compute: (row) => MOVEMENTS.has(row.type) ? row.install_id : null
|
|
10118
10126
|
},
|
|
10119
|
-
/**
|
|
10127
|
+
/**
|
|
10128
|
+
* The bundle a bundle filter matches (`bundleRefsOf`), by release.
|
|
10129
|
+
* Rows a 1.1 server wrote name the artifact until
|
|
10130
|
+
* `backfillReleaseRefs` rewrites them.
|
|
10131
|
+
*/
|
|
10120
10132
|
bundle_ref: {
|
|
10121
10133
|
type: "string",
|
|
10122
10134
|
multi: true,
|
|
@@ -10435,7 +10447,13 @@ const insightsBuiltinDistribution = (retention) => defineAggregate({
|
|
|
10435
10447
|
},
|
|
10436
10448
|
retention
|
|
10437
10449
|
});
|
|
10438
|
-
/**
|
|
10450
|
+
/**
|
|
10451
|
+
* Latest events by the artifact they came from or went to, bucketed like
|
|
10452
|
+
* the distribution, as 1.1 servers wrote them. Nothing writes or reads it
|
|
10453
|
+
* since a bundle's installations come from `insights_distribution`, which
|
|
10454
|
+
* names the release; it stays declared so retention still empties the rows
|
|
10455
|
+
* a 1.1 server wrote.
|
|
10456
|
+
*/
|
|
10439
10457
|
const insightsLatestByBundle = (retention) => defineAggregate({
|
|
10440
10458
|
platform: {
|
|
10441
10459
|
type: "string",
|
|
@@ -10483,7 +10501,9 @@ const insightsLatestByBundle = (retention) => defineAggregate({
|
|
|
10483
10501
|
* Stored events by outcome and the bundle a bundle filter matches, a row an
|
|
10484
10502
|
* hour, which a failed check has none of; and every stored event, a row a UTC
|
|
10485
10503
|
* day (`DAILY_EVENTS`). Bundle counts sum the hourly rows, and event lists
|
|
10486
|
-
* read either to skip days without events.
|
|
10504
|
+
* read either to skip days without events. `bundle_ref` names the release
|
|
10505
|
+
* (`outcomeRefsOf`); a 1.1 server's rows name the artifact until
|
|
10506
|
+
* `backfillReleaseRefs` moves their counts.
|
|
10487
10507
|
*/
|
|
10488
10508
|
const insightsOutcomes = (retention) => defineAggregate({
|
|
10489
10509
|
platform: {
|
|
@@ -10562,6 +10582,96 @@ const createInsightsSchema = ({ rawDays, dailyDays } = DEFAULT_INSIGHTS_RETENTIO
|
|
|
10562
10582
|
};
|
|
10563
10583
|
createInsightsSchema();
|
|
10564
10584
|
//#endregion
|
|
10585
|
+
//#region ../insights/dist/server/backfill.mjs
|
|
10586
|
+
/**
|
|
10587
|
+
* Stored events read a page, and rewritten up to `BATCH` a transaction. A
|
|
10588
|
+
* store that takes fewer physical writes a transaction, as DynamoDB's 100
|
|
10589
|
+
* items hold fewer than 25 rewrites with their index copies and counts,
|
|
10590
|
+
* refuses the batch before writing anything; it is then rewritten in halves.
|
|
10591
|
+
*/
|
|
10592
|
+
const PAGE$1 = 500;
|
|
10593
|
+
const BATCH = 25;
|
|
10594
|
+
const sameRefs = (stored, refs) => {
|
|
10595
|
+
const values = Array.isArray(stored) ? stored : [];
|
|
10596
|
+
return values.length === refs.length && values.every((value) => refs.includes(value));
|
|
10597
|
+
};
|
|
10598
|
+
/**
|
|
10599
|
+
* Whether a stored event still names its artifact, as a 1.1 server wrote
|
|
10600
|
+
* it: its stored refs are the artifact's and differ from the release's. Its
|
|
10601
|
+
* stored refs are how its outcome rows counted it, so they are what a
|
|
10602
|
+
* rewrite moves, and a rewritten event reads as done.
|
|
10603
|
+
*/
|
|
10604
|
+
const namesArtifact = (row) => {
|
|
10605
|
+
const byKey = (key) => bundleRefsOf(row, key);
|
|
10606
|
+
return sameRefs(row.bundle_ref, byKey("artifact")) && !sameRefs(row.bundle_ref, byKey("release"));
|
|
10607
|
+
};
|
|
10608
|
+
/**
|
|
10609
|
+
* Rewrites the stored events in the raw period whose refs name their
|
|
10610
|
+
* artifact, as 1.1 servers wrote them, to name their release, and moves
|
|
10611
|
+
* their hourly outcome counts with them, each event in the transaction that
|
|
10612
|
+
* rewrites it. Each event carries its own release IDs, so two releases of
|
|
10613
|
+
* one artifact in one scope come apart; an event without a release ID keeps
|
|
10614
|
+
* the bundle ID it reports, as new events do.
|
|
10615
|
+
*
|
|
10616
|
+
* It reads every stored event once and writes only those still to move, so
|
|
10617
|
+
* an interrupted run can run again. `hot-updater db migrate` and `hot-updater
|
|
10618
|
+
* init` run it once a database: when it completes they record the settings
|
|
10619
|
+
* row `insights.releaseRefs`, and later runs read no event. Installation
|
|
10620
|
+
* gauges need nothing: they name releases already.
|
|
10621
|
+
*/
|
|
10622
|
+
const backfillReleaseRefs = async (db, now, { rawDays }, { dryRun = false } = {}) => {
|
|
10623
|
+
const today = now() - now() % DAY_MS$1;
|
|
10624
|
+
let events = 0;
|
|
10625
|
+
const move = async (candidates) => {
|
|
10626
|
+
if (dryRun) {
|
|
10627
|
+
events += candidates.length;
|
|
10628
|
+
return;
|
|
10629
|
+
}
|
|
10630
|
+
const moved = await rewrite(candidates).catch(async (error) => {
|
|
10631
|
+
if (!(error instanceof DatabaseConstraintError) || error.reason !== "too_large" || candidates.length === 1) throw error;
|
|
10632
|
+
const half = Math.ceil(candidates.length / 2);
|
|
10633
|
+
await move(candidates.slice(0, half));
|
|
10634
|
+
await move(candidates.slice(half));
|
|
10635
|
+
return 0;
|
|
10636
|
+
});
|
|
10637
|
+
events += moved;
|
|
10638
|
+
};
|
|
10639
|
+
const rewrite = (candidates) => db.transaction(async (tx) => {
|
|
10640
|
+
const rows = await Promise.all(candidates.map(({ id }) => tx.findOne("bundle_events", { id })));
|
|
10641
|
+
let moved = 0;
|
|
10642
|
+
for (const row of rows) {
|
|
10643
|
+
if (row === null || !namesArtifact(row)) continue;
|
|
10644
|
+
tx.update("bundle_events", row, {});
|
|
10645
|
+
const outcome = (ref, delta) => tx.aggregate("insights_outcomes", {
|
|
10646
|
+
platform: row.platform,
|
|
10647
|
+
channel: row.channel,
|
|
10648
|
+
type: ref[0],
|
|
10649
|
+
bundle_ref: ref[1],
|
|
10650
|
+
bucket_start_ms: row.received_at_ms - row.received_at_ms % HOUR_MS$1
|
|
10651
|
+
}, { events: delta }, { shardBy: row.install_id });
|
|
10652
|
+
for (const ref of outcomeRefsOf(row, "artifact")) outcome(ref, -1);
|
|
10653
|
+
for (const ref of outcomeRefsOf(row, "release")) outcome(ref, 1);
|
|
10654
|
+
moved += 1;
|
|
10655
|
+
}
|
|
10656
|
+
return moved;
|
|
10657
|
+
});
|
|
10658
|
+
for (let day = today - rawDays * DAY_MS$1; day <= today; day += DAY_MS$1) {
|
|
10659
|
+
let cursor;
|
|
10660
|
+
do {
|
|
10661
|
+
const page = await db.findMany("bundle_events", {
|
|
10662
|
+
index: "byDay",
|
|
10663
|
+
where: { day },
|
|
10664
|
+
limit: PAGE$1,
|
|
10665
|
+
...cursor === void 0 ? {} : { cursor }
|
|
10666
|
+
});
|
|
10667
|
+
const stale = page.rows.filter(namesArtifact);
|
|
10668
|
+
for (let start = 0; start < stale.length; start += BATCH) await move(stale.slice(start, start + BATCH));
|
|
10669
|
+
cursor = page.next;
|
|
10670
|
+
} while (cursor !== void 0);
|
|
10671
|
+
}
|
|
10672
|
+
return { events };
|
|
10673
|
+
};
|
|
10674
|
+
//#endregion
|
|
10565
10675
|
//#region ../insights/dist/server/eventRow.mjs
|
|
10566
10676
|
const CHANGE_KINDS = /* @__PURE__ */ new Set([
|
|
10567
10677
|
"first_seen",
|
|
@@ -10658,7 +10768,7 @@ const isBundleFilter = (value, withKind = false) => {
|
|
|
10658
10768
|
"type",
|
|
10659
10769
|
...withKind ? ["kind"] : []
|
|
10660
10770
|
];
|
|
10661
|
-
return value.type === "RECOVERED" ? isText$1(value.
|
|
10771
|
+
return value.type === "RECOVERED" ? isText$1(value.fromReleaseId) && hasOnlyKeys(value, [...keys, "fromReleaseId"]) : (value.type === "UPDATE_DOWNLOADED" || value.type === "UPDATE_APPLIED" || value.type === "UPDATE_FAILED" || value.type === "UNCHANGED") && isText$1(value.toReleaseId) && hasOnlyKeys(value, [...keys, "toReleaseId"]);
|
|
10662
10772
|
};
|
|
10663
10773
|
const isEventFilter = (value) => {
|
|
10664
10774
|
if (!isRecord$3(value)) return false;
|
|
@@ -10759,20 +10869,24 @@ const createValidatedInsightsModel = (model) => ({
|
|
|
10759
10869
|
if (!isRecord$3(input) || !hasOnlyKeys(input, [
|
|
10760
10870
|
"platform",
|
|
10761
10871
|
"channel",
|
|
10762
|
-
"sinceMs"
|
|
10763
|
-
|
|
10764
|
-
]) || !hasScope(input) || !isTimestamp(input.sinceMs) || input.bundle !== void 0 && (!Array.isArray(input.bundle) || input.bundle.length < 1 || input.bundle.length > 2 || input.bundle.some((bundle) => !isRecord$3(bundle) || !hasOnlyKeys(bundle, [
|
|
10765
|
-
"field",
|
|
10766
|
-
"value",
|
|
10767
|
-
"types"
|
|
10768
|
-
]) || bundle.field !== "from_bundle_id" && bundle.field !== "to_bundle_id" || !isText$1(bundle.value) || !Array.isArray(bundle.types) || bundle.types.length === 0 || bundle.types.some((type) => ![
|
|
10769
|
-
"UNCHANGED",
|
|
10770
|
-
"UPDATE_DOWNLOADED",
|
|
10771
|
-
"UPDATE_APPLIED",
|
|
10772
|
-
"RECOVERED"
|
|
10773
|
-
].includes(type))))) invalidQuery();
|
|
10872
|
+
"sinceMs"
|
|
10873
|
+
]) || !hasScope(input) || !isTimestamp(input.sinceMs)) invalidQuery();
|
|
10774
10874
|
return validateCount(await model.countLatestEvents(input));
|
|
10775
10875
|
},
|
|
10876
|
+
async countReleaseInstallations(input) {
|
|
10877
|
+
if (!isRecord$3(input) || !hasOnlyKeys(input, [
|
|
10878
|
+
"platform",
|
|
10879
|
+
"channel",
|
|
10880
|
+
"sinceMs",
|
|
10881
|
+
"releaseId"
|
|
10882
|
+
]) || !hasScope(input) || !isTimestamp(input.sinceMs) || !isText$1(input.releaseId)) invalidQuery();
|
|
10883
|
+
const counts = await model.countReleaseInstallations(input);
|
|
10884
|
+
if (!isRecord$3(counts) || !hasOnlyKeys(counts, ["installations", "release"])) invalidResult();
|
|
10885
|
+
return {
|
|
10886
|
+
installations: validateCount(counts.installations),
|
|
10887
|
+
release: validateCount(counts.release)
|
|
10888
|
+
};
|
|
10889
|
+
},
|
|
10776
10890
|
async countEvents(input) {
|
|
10777
10891
|
if (!isRecord$3(input) || !hasOnlyKeys(input, [
|
|
10778
10892
|
"filter",
|
|
@@ -10829,6 +10943,7 @@ const createInsightsModel = (api) => createValidatedInsightsModel({
|
|
|
10829
10943
|
listEvents: api.listEvents,
|
|
10830
10944
|
findLatestEvents: api.findLatestEvents,
|
|
10831
10945
|
countLatestEvents: api.countLatestEvents,
|
|
10946
|
+
countReleaseInstallations: api.countReleaseInstallations,
|
|
10832
10947
|
countEvents: api.countEvents,
|
|
10833
10948
|
countEventSeries: api.countEventSeries,
|
|
10834
10949
|
getReleaseActivity: api.getReleaseActivity,
|
|
@@ -11231,27 +11346,27 @@ const readScope$1 = (input) => {
|
|
|
11231
11346
|
};
|
|
11232
11347
|
const bundleFilter = (input) => {
|
|
11233
11348
|
const scope = readScope$1(input);
|
|
11234
|
-
const
|
|
11349
|
+
const releaseId = requireString(input.releaseId, "bundle ID", MAX_EVENT_ID_LENGTH);
|
|
11235
11350
|
switch (input.outcome) {
|
|
11236
11351
|
case "downloaded": return {
|
|
11237
11352
|
...scope,
|
|
11238
11353
|
type: "UPDATE_DOWNLOADED",
|
|
11239
|
-
|
|
11354
|
+
toReleaseId: releaseId
|
|
11240
11355
|
};
|
|
11241
11356
|
case "applied": return {
|
|
11242
11357
|
...scope,
|
|
11243
11358
|
type: "UPDATE_APPLIED",
|
|
11244
|
-
|
|
11359
|
+
toReleaseId: releaseId
|
|
11245
11360
|
};
|
|
11246
11361
|
case "recovered": return {
|
|
11247
11362
|
...scope,
|
|
11248
11363
|
type: "RECOVERED",
|
|
11249
|
-
|
|
11364
|
+
fromReleaseId: releaseId
|
|
11250
11365
|
};
|
|
11251
11366
|
case "failed": return {
|
|
11252
11367
|
...scope,
|
|
11253
11368
|
type: "UPDATE_FAILED",
|
|
11254
|
-
|
|
11369
|
+
toReleaseId: releaseId
|
|
11255
11370
|
};
|
|
11256
11371
|
default: throw new InsightsBadRequestError("Invalid Insights outcome.");
|
|
11257
11372
|
}
|
|
@@ -11261,7 +11376,7 @@ const sameFilter = (left, right) => {
|
|
|
11261
11376
|
switch (right.kind) {
|
|
11262
11377
|
case "all": return true;
|
|
11263
11378
|
case "installationMovement": return left.installId === right.installId;
|
|
11264
|
-
case "bundle": return left.platform === right.platform && left.channel === right.channel && left.type === right.type && (right.type === "RECOVERED" ? left.
|
|
11379
|
+
case "bundle": return left.platform === right.platform && left.channel === right.channel && left.type === right.type && (right.type === "RECOVERED" ? left.fromReleaseId === right.fromReleaseId : left.toReleaseId === right.toReleaseId);
|
|
11265
11380
|
}
|
|
11266
11381
|
};
|
|
11267
11382
|
const readEventCursor = (value, filter) => {
|
|
@@ -11298,7 +11413,7 @@ const assertEventRows = (rows, input) => {
|
|
|
11298
11413
|
for (let index = 0; index < rows.length; index += 1) {
|
|
11299
11414
|
const row = rows[index];
|
|
11300
11415
|
const previous = rows[index - 1];
|
|
11301
|
-
if (!row || typeof row.id !== "string" || !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 || !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.
|
|
11416
|
+
if (!row || typeof row.id !== "string" || !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 || !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_release_id ?? row.from_bundle_id) !== input.filter.fromReleaseId : (row.to_release_id ?? row.to_bundle_id) !== input.filter.toReleaseId))) throw new Error("Insights database returned invalid event rows.");
|
|
11302
11417
|
}
|
|
11303
11418
|
};
|
|
11304
11419
|
/** An `UPDATE_FAILED` row's failure, as the event lists show it. */
|
|
@@ -11339,6 +11454,7 @@ const eventDetails = ({ type, metadata }) => ({
|
|
|
11339
11454
|
...metadata.implied_download === true ? { impliedDownload: true } : {}
|
|
11340
11455
|
});
|
|
11341
11456
|
const toEventHistoryRow = (row) => ({
|
|
11457
|
+
...row.from_release_id == null ? {} : { fromReleaseId: row.from_release_id },
|
|
11342
11458
|
...row.to_release_id == null ? {} : { toReleaseId: row.to_release_id },
|
|
11343
11459
|
...row.metadata.sdk_version == null ? {} : { sdkVersion: row.metadata.sdk_version },
|
|
11344
11460
|
...row.metadata.min_bundle_id === void 0 ? {} : { minBundleId: row.metadata.min_bundle_id },
|
|
@@ -11363,6 +11479,7 @@ const toInstallationRow = (row) => ({
|
|
|
11363
11479
|
cohort: row.metadata.cohort,
|
|
11364
11480
|
installId: row.install_id,
|
|
11365
11481
|
lastKnownBundleId: row.type === "UPDATE_DOWNLOADED" ? row.from_bundle_id : row.to_bundle_id,
|
|
11482
|
+
lastKnownReleaseId: row.type === "UPDATE_DOWNLOADED" ? row.from_release_id : row.to_release_id,
|
|
11366
11483
|
pendingBundleId: row.type === "UPDATE_DOWNLOADED" ? row.to_bundle_id : null,
|
|
11367
11484
|
pendingReleaseId: row.type === "UPDATE_DOWNLOADED" ? row.to_release_id : null,
|
|
11368
11485
|
latestStatus: row.type,
|
|
@@ -11491,46 +11608,33 @@ const createInsightsProvider = (model) => Object.freeze({
|
|
|
11491
11608
|
measuredAtMs: Date.now()
|
|
11492
11609
|
};
|
|
11493
11610
|
};
|
|
11494
|
-
const
|
|
11495
|
-
|
|
11496
|
-
...scope,
|
|
11497
|
-
sinceMs
|
|
11498
|
-
}));
|
|
11499
|
-
if (bundleId === void 0) return {
|
|
11611
|
+
const releaseId = input.releaseId === void 0 ? void 0 : requireString(input.releaseId, "bundle ID", MAX_EVENT_ID_LENGTH);
|
|
11612
|
+
if (releaseId === void 0) return {
|
|
11500
11613
|
...scope,
|
|
11501
11614
|
window,
|
|
11502
11615
|
sinceMs,
|
|
11503
11616
|
beforeReceivedAtMs,
|
|
11504
|
-
reportingInstallations: await
|
|
11617
|
+
reportingInstallations: await measure(model.countLatestEvents({
|
|
11618
|
+
...scope,
|
|
11619
|
+
sinceMs
|
|
11620
|
+
}))
|
|
11505
11621
|
};
|
|
11622
|
+
const installations = model.countReleaseInstallations({
|
|
11623
|
+
...scope,
|
|
11624
|
+
sinceMs,
|
|
11625
|
+
releaseId
|
|
11626
|
+
}).then(async (counts) => [await measure(Promise.resolve(counts.installations)), await measure(Promise.resolve(counts.release))]);
|
|
11506
11627
|
const countOutcome = (outcome) => measure(model.countEvents({
|
|
11507
11628
|
filter: bundleFilter({
|
|
11508
11629
|
...scope,
|
|
11509
|
-
|
|
11630
|
+
releaseId,
|
|
11510
11631
|
outcome
|
|
11511
11632
|
}),
|
|
11512
11633
|
sinceMs,
|
|
11513
11634
|
beforeReceivedAtMs
|
|
11514
11635
|
}));
|
|
11515
|
-
const [reportingInstallations, bundleInstallations, downloadedReports, appliedReports, recoveredReports, failedReports] = await Promise.all([
|
|
11516
|
-
|
|
11517
|
-
measure(model.countLatestEvents({
|
|
11518
|
-
...scope,
|
|
11519
|
-
sinceMs,
|
|
11520
|
-
bundle: [{
|
|
11521
|
-
field: "from_bundle_id",
|
|
11522
|
-
value: bundleId,
|
|
11523
|
-
types: ["UPDATE_DOWNLOADED"]
|
|
11524
|
-
}, {
|
|
11525
|
-
field: "to_bundle_id",
|
|
11526
|
-
value: bundleId,
|
|
11527
|
-
types: [
|
|
11528
|
-
"UNCHANGED",
|
|
11529
|
-
"UPDATE_APPLIED",
|
|
11530
|
-
"RECOVERED"
|
|
11531
|
-
]
|
|
11532
|
-
}]
|
|
11533
|
-
})),
|
|
11636
|
+
const [[reportingInstallations, bundleInstallations], downloadedReports, appliedReports, recoveredReports, failedReports] = await Promise.all([
|
|
11637
|
+
installations,
|
|
11534
11638
|
countOutcome("downloaded"),
|
|
11535
11639
|
countOutcome("applied"),
|
|
11536
11640
|
countOutcome("recovered"),
|
|
@@ -11543,7 +11647,7 @@ const createInsightsProvider = (model) => Object.freeze({
|
|
|
11543
11647
|
beforeReceivedAtMs,
|
|
11544
11648
|
reportingInstallations,
|
|
11545
11649
|
bundle: {
|
|
11546
|
-
|
|
11650
|
+
releaseId,
|
|
11547
11651
|
reportingInstallations: bundleInstallations,
|
|
11548
11652
|
downloadedReports,
|
|
11549
11653
|
appliedReports,
|
|
@@ -11678,17 +11782,10 @@ const gaugeSlot = (head) => ({
|
|
|
11678
11782
|
builtinBundleId: runningBuiltinBundleId(head)
|
|
11679
11783
|
});
|
|
11680
11784
|
/**
|
|
11681
|
-
* The `insights_latest_by_bundle` field of a head's (from, to) pair. A head
|
|
11682
|
-
* matches a `from` and a `to` predicate of one type at once only through its
|
|
11683
|
-
* pair, so this gauge is what a count subtracts to count it once.
|
|
11684
|
-
*/
|
|
11685
|
-
const PAIR_FIELD = "from_to";
|
|
11686
|
-
/** The pair gauge's `bundle_id`: a hash of the two bundle ids, which fit no single 36-character column. */
|
|
11687
|
-
const bundlePairKey = (from, to) => insightsKey(`${from.length}:${from}${to.length}:${to}`);
|
|
11688
|
-
/**
|
|
11689
11785
|
* Moves a head's gauges: the distribution row, and the built-in one when it
|
|
11690
|
-
* runs its build's built-in bundle
|
|
11691
|
-
*
|
|
11786
|
+
* runs its build's built-in bundle; -1 takes back the head an event
|
|
11787
|
+
* replaces. The distribution row names the release the head runs, so it is
|
|
11788
|
+
* also each release's installation gauge.
|
|
11692
11789
|
*/
|
|
11693
11790
|
const countHead = (tx, head, delta) => {
|
|
11694
11791
|
const { bucket, releaseId, builtinBundleId } = gaugeSlot(head);
|
|
@@ -11708,26 +11805,6 @@ const countHead = (tx, head, delta) => {
|
|
|
11708
11805
|
builtin_bundle_id: builtinBundleId,
|
|
11709
11806
|
bucket_start_ms: bucket
|
|
11710
11807
|
}, { latest_installations: delta }, { shardBy });
|
|
11711
|
-
for (const field of ["from_bundle_id", "to_bundle_id"]) {
|
|
11712
|
-
const bundleId = head[field];
|
|
11713
|
-
if (bundleId === null) continue;
|
|
11714
|
-
tx.aggregate("insights_latest_by_bundle", {
|
|
11715
|
-
platform: head.platform,
|
|
11716
|
-
channel: head.channel,
|
|
11717
|
-
bundle_field: field,
|
|
11718
|
-
bundle_id: bundleId,
|
|
11719
|
-
type: head.type,
|
|
11720
|
-
bucket_start_ms: bucket
|
|
11721
|
-
}, { installations: delta }, { shardBy });
|
|
11722
|
-
}
|
|
11723
|
-
if (head.from_bundle_id !== null) tx.aggregate("insights_latest_by_bundle", {
|
|
11724
|
-
platform: head.platform,
|
|
11725
|
-
channel: head.channel,
|
|
11726
|
-
bundle_field: PAIR_FIELD,
|
|
11727
|
-
bundle_id: bundlePairKey(head.from_bundle_id, head.to_bundle_id),
|
|
11728
|
-
type: head.type,
|
|
11729
|
-
bucket_start_ms: bucket
|
|
11730
|
-
}, { installations: delta }, { shardBy });
|
|
11731
11808
|
};
|
|
11732
11809
|
/**
|
|
11733
11810
|
* Where each period's rows go, each with its retention: hours for 90 days,
|
|
@@ -11788,26 +11865,19 @@ const countEvent = (tx, event) => {
|
|
|
11788
11865
|
}
|
|
11789
11866
|
};
|
|
11790
11867
|
/**
|
|
11791
|
-
* A stored event's outcome rows: its bundle filter's hour,
|
|
11792
|
-
*
|
|
11793
|
-
*
|
|
11794
|
-
* hour of that launch or crash, so the download series covers what the
|
|
11795
|
-
* release's downloads count; the launch or crash is its row.
|
|
11868
|
+
* A stored event's outcome rows: its bundle filter's hour, and the download
|
|
11869
|
+
* hour of a download its launch or crash implied, each by release
|
|
11870
|
+
* (`outcomeRefsOf`); and every stored event's UTC day.
|
|
11796
11871
|
*/
|
|
11797
11872
|
const countOutcome = (tx, event) => {
|
|
11798
11873
|
const shardBy = event.install_id;
|
|
11799
|
-
const
|
|
11874
|
+
for (const [type, bundleRef] of outcomeRefsOf(event)) tx.aggregate("insights_outcomes", {
|
|
11800
11875
|
platform: event.platform,
|
|
11801
11876
|
channel: event.channel,
|
|
11802
11877
|
type,
|
|
11803
11878
|
bundle_ref: bundleRef,
|
|
11804
11879
|
bucket_start_ms: hourOf(event.received_at_ms)
|
|
11805
11880
|
}, { events: 1 }, { shardBy });
|
|
11806
|
-
for (const bundleRef of bundleRefsOf(event)) hour(event.type, bundleRef);
|
|
11807
|
-
if (event.metadata.implied_download === true) hour("UPDATE_DOWNLOADED", bundleRefOfFilter({
|
|
11808
|
-
type: "UPDATE_DOWNLOADED",
|
|
11809
|
-
toBundleId: event.type === "RECOVERED" ? event.from_bundle_id : event.to_bundle_id
|
|
11810
|
-
}));
|
|
11811
11881
|
tx.aggregate("insights_outcomes", {
|
|
11812
11882
|
...DAILY_EVENTS,
|
|
11813
11883
|
bucket_start_ms: dayOf(event.received_at_ms)
|
|
@@ -12287,31 +12357,48 @@ const countEventSeries = async (db, input) => {
|
|
|
12287
12357
|
events: count
|
|
12288
12358
|
}));
|
|
12289
12359
|
};
|
|
12290
|
-
/**
|
|
12291
|
-
const
|
|
12292
|
-
if (
|
|
12293
|
-
return
|
|
12294
|
-
|
|
12295
|
-
|
|
12296
|
-
|
|
12297
|
-
|
|
12298
|
-
|
|
12299
|
-
|
|
12300
|
-
|
|
12301
|
-
|
|
12360
|
+
/** The distribution rows at or after `start`, a UTC day's start. */
|
|
12361
|
+
const distributionRows = (db, { platform, channel, sinceMs: start }) => {
|
|
12362
|
+
if (start % 864e5 !== 0) throw new DatabaseAdapterInputError("invalid-query");
|
|
12363
|
+
return drain((page) => db.findAggregates("insights_distribution", {
|
|
12364
|
+
index: "byScope",
|
|
12365
|
+
where: {
|
|
12366
|
+
channel,
|
|
12367
|
+
platform
|
|
12368
|
+
},
|
|
12369
|
+
range: { gte: start },
|
|
12370
|
+
limit: PAGE,
|
|
12371
|
+
...page
|
|
12372
|
+
}));
|
|
12302
12373
|
};
|
|
12374
|
+
const installations = (count) => Math.max(0, count);
|
|
12303
12375
|
/**
|
|
12304
12376
|
* Latest events at or after `sinceMs`, a UTC day's start: the gauges count
|
|
12305
12377
|
* each installation in the UTC day of its latest event, so they answer whole
|
|
12306
12378
|
* days only, and a later start is rejected rather than rounded.
|
|
12307
12379
|
*/
|
|
12308
|
-
const countLatestEvents = async (db, input) =>
|
|
12309
|
-
|
|
12310
|
-
|
|
12311
|
-
|
|
12380
|
+
const countLatestEvents = async (db, input) => installations((await distributionRows(db, input)).reduce((sum, row) => sum + row.latest_installations, 0));
|
|
12381
|
+
/**
|
|
12382
|
+
* `countLatestEvents`, and of those the installations it leaves running
|
|
12383
|
+
* `releaseId`, from the same distribution rows in one read: each names the
|
|
12384
|
+
* release its installations run. An ID no row names as a release may be a
|
|
12385
|
+
* built-in bundle's, which a report without a release names, as event
|
|
12386
|
+
* counts match it: its installations outside any release are in the
|
|
12387
|
+
* built-in rows, read only then. Release and bundle IDs never coincide.
|
|
12388
|
+
*/
|
|
12389
|
+
const countReleaseInstallations = async (db, input) => {
|
|
12390
|
+
const { platform, channel, sinceMs: start, releaseId } = input;
|
|
12312
12391
|
let total = 0;
|
|
12313
|
-
|
|
12314
|
-
|
|
12392
|
+
let release = 0;
|
|
12393
|
+
let named = false;
|
|
12394
|
+
for (const row of await distributionRows(db, input)) {
|
|
12395
|
+
total += row.latest_installations;
|
|
12396
|
+
if (row.release_id !== releaseId) continue;
|
|
12397
|
+
named = true;
|
|
12398
|
+
release += row.latest_installations;
|
|
12399
|
+
}
|
|
12400
|
+
if (!named) {
|
|
12401
|
+
const builtin = await drain((page) => db.findAggregates("insights_builtin_distribution", {
|
|
12315
12402
|
index: "byScope",
|
|
12316
12403
|
where: {
|
|
12317
12404
|
channel,
|
|
@@ -12321,33 +12408,12 @@ const countLatestEvents = async (db, input) => {
|
|
|
12321
12408
|
limit: PAGE,
|
|
12322
12409
|
...page
|
|
12323
12410
|
}));
|
|
12324
|
-
|
|
12325
|
-
} else {
|
|
12326
|
-
const gauge = async (bundleField, bundleId, type) => {
|
|
12327
|
-
return (await drain((page) => db.findAggregates("insights_latest_by_bundle", {
|
|
12328
|
-
index: "byBundle",
|
|
12329
|
-
where: {
|
|
12330
|
-
platform,
|
|
12331
|
-
channel,
|
|
12332
|
-
bundle_field: bundleField,
|
|
12333
|
-
bundle_id: bundleId,
|
|
12334
|
-
type
|
|
12335
|
-
},
|
|
12336
|
-
range: { gte: start },
|
|
12337
|
-
limit: PAGE,
|
|
12338
|
-
...page
|
|
12339
|
-
}))).reduce((sum, row) => sum + row.installations, 0);
|
|
12340
|
-
};
|
|
12341
|
-
for (const { field, value, type } of predicates) total += await gauge(field, value, type);
|
|
12342
|
-
for (const from of predicates) {
|
|
12343
|
-
if (from.field !== "from_bundle_id") continue;
|
|
12344
|
-
for (const to of predicates) {
|
|
12345
|
-
if (to.field !== "to_bundle_id" || to.type !== from.type) continue;
|
|
12346
|
-
total -= await gauge(PAIR_FIELD, bundlePairKey(from.value, to.value), from.type);
|
|
12347
|
-
}
|
|
12348
|
-
}
|
|
12411
|
+
for (const row of builtin) if (row.release_id === "" && row.builtin_bundle_id === releaseId) release += row.latest_installations;
|
|
12349
12412
|
}
|
|
12350
|
-
return
|
|
12413
|
+
return {
|
|
12414
|
+
installations: installations(total),
|
|
12415
|
+
release: installations(release)
|
|
12416
|
+
};
|
|
12351
12417
|
};
|
|
12352
12418
|
/** The oldest whole hour and UTC day that hourly and daily rows still hold. */
|
|
12353
12419
|
const retained = (now, { rawDays, dailyDays }) => ({
|
|
@@ -12817,6 +12883,26 @@ const getUpdateFailures = async (db, input, now, retention) => {
|
|
|
12817
12883
|
};
|
|
12818
12884
|
};
|
|
12819
12885
|
//#endregion
|
|
12886
|
+
//#region ../insights/dist/server/wire.mjs
|
|
12887
|
+
/**
|
|
12888
|
+
* The HTTP API calls a release ID `bundleId`, the word users have for it, in
|
|
12889
|
+
* its query parameters and its overview's JSON. The code calls it
|
|
12890
|
+
* `releaseId`; only this module maps between the two names.
|
|
12891
|
+
*/
|
|
12892
|
+
const RELEASE_ID_PARAM = "bundleId";
|
|
12893
|
+
/** An overview as the HTTP API and the CLI's `--json` send it. */
|
|
12894
|
+
const toWireOverview = ({ bundle, ...overview }) => {
|
|
12895
|
+
if (bundle === void 0) return overview;
|
|
12896
|
+
const { releaseId, ...counts } = bundle;
|
|
12897
|
+
return {
|
|
12898
|
+
...overview,
|
|
12899
|
+
bundle: {
|
|
12900
|
+
...counts,
|
|
12901
|
+
bundleId: releaseId
|
|
12902
|
+
}
|
|
12903
|
+
};
|
|
12904
|
+
};
|
|
12905
|
+
//#endregion
|
|
12820
12906
|
//#region ../insights/dist/server/queryInput.mjs
|
|
12821
12907
|
const MAX_PAGE_LIMIT = 100;
|
|
12822
12908
|
const MAX_IDENTITY_LENGTH = 255;
|
|
@@ -12861,7 +12947,7 @@ const readScope = (url) => {
|
|
|
12861
12947
|
const parseEventPageInput = (request) => {
|
|
12862
12948
|
const url = new URL(request.url);
|
|
12863
12949
|
const bundleFields = [
|
|
12864
|
-
|
|
12950
|
+
RELEASE_ID_PARAM,
|
|
12865
12951
|
"outcome",
|
|
12866
12952
|
"platform",
|
|
12867
12953
|
"channel"
|
|
@@ -12872,7 +12958,7 @@ const parseEventPageInput = (request) => {
|
|
|
12872
12958
|
if (outcome !== "downloaded" && outcome !== "applied" && outcome !== "recovered" && outcome !== "failed") throw new InsightsBadRequestError("Invalid 'outcome' query parameter.");
|
|
12873
12959
|
bundle = {
|
|
12874
12960
|
...readScope(url),
|
|
12875
|
-
|
|
12961
|
+
releaseId: readId(url, RELEASE_ID_PARAM, 1024),
|
|
12876
12962
|
outcome
|
|
12877
12963
|
};
|
|
12878
12964
|
}
|
|
@@ -12898,11 +12984,10 @@ const parseReportingOverviewInput = (request) => {
|
|
|
12898
12984
|
const url = new URL(request.url);
|
|
12899
12985
|
const window = readSingle(url, "window") ?? "30d";
|
|
12900
12986
|
if (window !== "24h" && window !== "7d" && window !== "30d") throw new InsightsBadRequestError("Invalid 'window' query parameter.");
|
|
12901
|
-
const bundleId = readSingle(url, "bundleId");
|
|
12902
12987
|
return {
|
|
12903
12988
|
...readScope(url),
|
|
12904
12989
|
window,
|
|
12905
|
-
...bundleId === void 0 ? {} : {
|
|
12990
|
+
...readSingle(url, "bundleId") === void 0 ? {} : { releaseId: readId(url, RELEASE_ID_PARAM, 1024) }
|
|
12906
12991
|
};
|
|
12907
12992
|
};
|
|
12908
12993
|
//#endregion
|
|
@@ -12983,7 +13068,7 @@ const createInsightsRouteHandlers = (provider) => ({
|
|
|
12983
13068
|
await provider.appendBundleEvent(await parseBundleEventRequest(request));
|
|
12984
13069
|
return new Response(null, { status: 204 });
|
|
12985
13070
|
}),
|
|
12986
|
-
getReportingOverview: (_params, request) => query(() => provider.getReportingOverview(parseReportingOverviewInput(request))),
|
|
13071
|
+
getReportingOverview: (_params, request) => query(async () => toWireOverview(await provider.getReportingOverview(parseReportingOverviewInput(request)))),
|
|
12987
13072
|
getInstallation: (params) => run$1(async () => {
|
|
12988
13073
|
const installation = await provider.getInstallation({ installId: requireParam(params, "installId") });
|
|
12989
13074
|
return installation === null ? json$1({ error: "Installation not found" }, 404) : json$1(installation, 200);
|
|
@@ -13005,12 +13090,20 @@ const createInsightsApi = (db, now, retention) => ({
|
|
|
13005
13090
|
listEvents: (input) => listEvents(db, input),
|
|
13006
13091
|
findLatestEvents: (input) => findLatestEvents(db, input),
|
|
13007
13092
|
countLatestEvents: (input) => countLatestEvents(db, input),
|
|
13093
|
+
countReleaseInstallations: (input) => countReleaseInstallations(db, input),
|
|
13008
13094
|
countEvents: (input) => countEvents(db, input),
|
|
13009
13095
|
countEventSeries: (input) => countEventSeries(db, input),
|
|
13010
13096
|
getReleaseActivity: (input) => getReleaseActivity(db, input, now),
|
|
13011
13097
|
getAppUsage: (input) => getAppUsage(db, input, now, retention),
|
|
13012
13098
|
/** A release's or a channel's update failures, and their breakdown over a time range. */
|
|
13013
|
-
getUpdateFailures: (input) => getUpdateFailures(db, input, now, retention)
|
|
13099
|
+
getUpdateFailures: (input) => getUpdateFailures(db, input, now, retention),
|
|
13100
|
+
/**
|
|
13101
|
+
* Moves the stored events a 1.1 server keyed by artifact, and their
|
|
13102
|
+
* outcome counts, to their release, reading every stored event of the
|
|
13103
|
+
* raw period: `hot-updater db migrate` and `hot-updater init` run it once
|
|
13104
|
+
* a database, and an interrupted run can run again.
|
|
13105
|
+
*/
|
|
13106
|
+
backfillReleaseRefs: (options) => backfillReleaseRefs(db, now, retention, options)
|
|
13014
13107
|
});
|
|
13015
13108
|
/** `GET /failures`'s query: a scope, an optional release, and a time range or none. */
|
|
13016
13109
|
const readFailuresQuery = (url) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/aws",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.2.0-rc.
|
|
4
|
+
"version": "1.2.0-rc.58",
|
|
5
5
|
"description": "React Native OTA solution for self-hosted",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"module": "dist/index.mjs",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"es-toolkit": "^1.32.0",
|
|
46
46
|
"execa": "9.5.2",
|
|
47
47
|
"mime": "^4.0.4",
|
|
48
|
-
"@hot-updater/protocol": "1.2.0-rc.
|
|
49
|
-
"@hot-updater/mock": "1.2.0-rc.
|
|
50
|
-
"@hot-updater/test-utils": "1.2.0-rc.
|
|
48
|
+
"@hot-updater/protocol": "1.2.0-rc.58",
|
|
49
|
+
"@hot-updater/mock": "1.2.0-rc.58",
|
|
50
|
+
"@hot-updater/test-utils": "1.2.0-rc.58"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@aws-sdk/client-cloudfront": "3.1066.0",
|
|
@@ -64,10 +64,10 @@
|
|
|
64
64
|
"@aws-sdk/lib-dynamodb": "3.1066.0",
|
|
65
65
|
"@aws-sdk/s3-request-presigner": "3.1066.0",
|
|
66
66
|
"hono": "4.12.34",
|
|
67
|
-
"@hot-updater/
|
|
68
|
-
"@hot-updater/
|
|
69
|
-
"@hot-updater/
|
|
70
|
-
"@hot-updater/storage-s3": "1.2.0-rc.
|
|
67
|
+
"@hot-updater/cli-tools": "1.2.0-rc.58",
|
|
68
|
+
"@hot-updater/plugin-core": "1.2.0-rc.58",
|
|
69
|
+
"@hot-updater/server": "1.2.0-rc.58",
|
|
70
|
+
"@hot-updater/storage-s3": "1.2.0-rc.58"
|
|
71
71
|
},
|
|
72
72
|
"scripts": {
|
|
73
73
|
"build": "tsdown",
|