@hot-updater/vercel 1.2.0-rc.57 → 1.2.0-rc.59
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/function/index.mjs +212 -151
- package/dist/init/index.cjs +1 -0
- package/dist/init/index.mjs +2 -1
- package/package.json +7 -7
package/dist/function/index.mjs
CHANGED
|
@@ -541,14 +541,14 @@ function modularInverse(value, modulus) {
|
|
|
541
541
|
if (r > 1) throw new Error(`No modular inverse for ${value} mod ${modulus}`);
|
|
542
542
|
return positiveMod(t, modulus);
|
|
543
543
|
}
|
|
544
|
-
function getRolloutShuffleParameters(
|
|
545
|
-
let multiplier = positiveMod(hashString(`${
|
|
544
|
+
function getRolloutShuffleParameters(releaseId) {
|
|
545
|
+
let multiplier = positiveMod(hashString(`${releaseId}:multiplier`), 997);
|
|
546
546
|
if (multiplier === 0) multiplier = 1;
|
|
547
547
|
while (gcd(multiplier, NUMERIC_COHORT_SIZE) !== 1) {
|
|
548
548
|
multiplier = positiveMod(multiplier + 1, NUMERIC_COHORT_SIZE);
|
|
549
549
|
if (multiplier === 0) multiplier = 1;
|
|
550
550
|
}
|
|
551
|
-
const offset = positiveMod(hashString(`${
|
|
551
|
+
const offset = positiveMod(hashString(`${releaseId}:offset`), NUMERIC_COHORT_SIZE);
|
|
552
552
|
return {
|
|
553
553
|
multiplier,
|
|
554
554
|
offset,
|
|
@@ -581,16 +581,16 @@ function isValidCohort(cohort) {
|
|
|
581
581
|
const normalized = normalizeCohortValue(cohort);
|
|
582
582
|
return isNumericCohort(normalized) || isCustomCohort(normalized);
|
|
583
583
|
}
|
|
584
|
-
function getNumericCohortRolloutPosition(
|
|
584
|
+
function getNumericCohortRolloutPosition(releaseId, cohortValue) {
|
|
585
585
|
if (cohortValue < 1 || cohortValue > 1e3) throw new Error(`Invalid numeric cohort: ${cohortValue}`);
|
|
586
|
-
const { offset, inverseMultiplier } = getRolloutShuffleParameters(
|
|
586
|
+
const { offset, inverseMultiplier } = getRolloutShuffleParameters(releaseId);
|
|
587
587
|
return positiveMod(inverseMultiplier * (cohortValue - 1 - offset), NUMERIC_COHORT_SIZE);
|
|
588
588
|
}
|
|
589
|
-
function getRolledOutNumericCohorts(
|
|
589
|
+
function getRolledOutNumericCohorts(releaseId, rolloutCohortCount) {
|
|
590
590
|
const normalizedRolloutCount = normalizeRolloutCohortCount(rolloutCohortCount);
|
|
591
591
|
if (normalizedRolloutCount <= 0) return [];
|
|
592
592
|
if (normalizedRolloutCount >= 1e3) return Array.from({ length: NUMERIC_COHORT_SIZE }, (_, index) => index + 1);
|
|
593
|
-
const { multiplier, offset } = getRolloutShuffleParameters(
|
|
593
|
+
const { multiplier, offset } = getRolloutShuffleParameters(releaseId);
|
|
594
594
|
return Array.from({ length: normalizedRolloutCount }, (_, position) => positiveMod(multiplier * position + offset, NUMERIC_COHORT_SIZE)).map((zeroBasedCohort) => zeroBasedCohort + 1).sort((left, right) => left - right);
|
|
595
595
|
}
|
|
596
596
|
const RELEASE_CATALOG_FALLBACK_POLICY = "BUILTIN_IF_ACTIVE_INELIGIBLE";
|
|
@@ -3178,7 +3178,7 @@ const build = (changes, current) => {
|
|
|
3178
3178
|
return changes.map((change, at) => rewrites(change) ? rewrite$1(change, keys[at], current.get(rowId(change.model, keys[at])) ?? null) : increment(change, keys[at]));
|
|
3179
3179
|
};
|
|
3180
3180
|
const isOp = (op) => op !== void 0;
|
|
3181
|
-
const sleep = (attempt) => new Promise((resolve) => setTimeout(resolve, Math.min(250, 5 * 2 ** attempt) * Math.random()));
|
|
3181
|
+
const sleep$2 = (attempt) => new Promise((resolve) => setTimeout(resolve, Math.min(250, 5 * 2 ** attempt) * Math.random()));
|
|
3182
3182
|
const pack = (text) => {
|
|
3183
3183
|
const runs = (text.match(/(.)\1*/gsu) ?? []).flatMap((run) => [run[0], run.length]);
|
|
3184
3184
|
return JSON.stringify(runs).length < JSON.stringify(text).length ? runs : text;
|
|
@@ -3297,7 +3297,7 @@ const createAggregateBatches = ({ engine, adapter, schema, batching: { windowMs
|
|
|
3297
3297
|
const result = await adapter.write(ops);
|
|
3298
3298
|
if (result.ok) return true;
|
|
3299
3299
|
if (!("retry" in result)) return false;
|
|
3300
|
-
await sleep(failures);
|
|
3300
|
+
await sleep$2(failures);
|
|
3301
3301
|
}
|
|
3302
3302
|
return false;
|
|
3303
3303
|
};
|
|
@@ -4231,6 +4231,7 @@ const createTransactions = ({ adapter, schema, reads, retry = {} }) => {
|
|
|
4231
4231
|
let negative;
|
|
4232
4232
|
let failures = 0;
|
|
4233
4233
|
let lost;
|
|
4234
|
+
let busy = false;
|
|
4234
4235
|
for (let round = 0;; round += 1) {
|
|
4235
4236
|
const delay = round && Math.min(maxDelayMs, baseDelayMs * 2 ** (round - 1));
|
|
4236
4237
|
if (delay > 0) await new Promise((resolve) => setTimeout(resolve, delay / 2 + Math.random() * (delay / 2)));
|
|
@@ -4241,6 +4242,7 @@ const createTransactions = ({ adapter, schema, reads, retry = {} }) => {
|
|
|
4241
4242
|
if (run === void 0) {
|
|
4242
4243
|
onRetry?.("rerun", round + 1);
|
|
4243
4244
|
lost = void 0;
|
|
4245
|
+
busy = false;
|
|
4244
4246
|
if ((failures += 1) >= attempts) break;
|
|
4245
4247
|
continue;
|
|
4246
4248
|
}
|
|
@@ -4251,6 +4253,7 @@ const createTransactions = ({ adapter, schema, reads, retry = {} }) => {
|
|
|
4251
4253
|
if (!(error instanceof NegativeGaugeError)) throw error;
|
|
4252
4254
|
negative = error;
|
|
4253
4255
|
onRetry?.("rerun", round + 1);
|
|
4256
|
+
busy = false;
|
|
4254
4257
|
run = void 0;
|
|
4255
4258
|
lost = void 0;
|
|
4256
4259
|
if ((failures += 1) >= attempts) break;
|
|
@@ -4271,6 +4274,7 @@ const createTransactions = ({ adapter, schema, reads, retry = {} }) => {
|
|
|
4271
4274
|
}
|
|
4272
4275
|
if (outcome.ok) return run.result;
|
|
4273
4276
|
const failed = "failedOp" in outcome ? outcome.failedOp : void 0;
|
|
4277
|
+
busy = failed === void 0;
|
|
4274
4278
|
if (failed === void 0 || failed >= run.ops.length) {
|
|
4275
4279
|
onRetry?.("resend", round + 1);
|
|
4276
4280
|
failures += 1;
|
|
@@ -4284,7 +4288,7 @@ const createTransactions = ({ adapter, schema, reads, retry = {} }) => {
|
|
|
4284
4288
|
run = void 0;
|
|
4285
4289
|
if ((failures += 1) >= attempts) break;
|
|
4286
4290
|
}
|
|
4287
|
-
throw negative ?? new DatabaseConflictError(`The transaction conflicted ${attempts} times.`);
|
|
4291
|
+
throw negative ?? new DatabaseConflictError(busy ? `The database stayed busy through ${attempts} attempts of the transaction, as a store does at its throughput limit.` : `The transaction conflicted ${attempts} times.`);
|
|
4288
4292
|
} };
|
|
4289
4293
|
};
|
|
4290
4294
|
//#endregion
|
|
@@ -18083,7 +18087,7 @@ const postgres = (config) => {
|
|
|
18083
18087
|
};
|
|
18084
18088
|
//#endregion
|
|
18085
18089
|
//#region ../../packages/server/dist/version.mjs
|
|
18086
|
-
const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.
|
|
18090
|
+
const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.59";
|
|
18087
18091
|
//#endregion
|
|
18088
18092
|
//#region ../../packages/server/dist/handlerVersionRoutes.mjs
|
|
18089
18093
|
const createVersionRouteHandlers = (plugins = []) => {
|
|
@@ -18821,7 +18825,7 @@ const baseBundleIdsOf = (row, range, bundleId, limit) => {
|
|
|
18821
18825
|
};
|
|
18822
18826
|
//#endregion
|
|
18823
18827
|
//#region ../../packages/server/dist/core/reads.mjs
|
|
18824
|
-
const PAGE$
|
|
18828
|
+
const PAGE$5 = 500;
|
|
18825
18829
|
const pick$2 = (fields) => (row) => Object.fromEntries(fields.map((field) => [field, row[field]]));
|
|
18826
18830
|
const toBundleRow = pick$2([
|
|
18827
18831
|
"id",
|
|
@@ -18912,7 +18916,7 @@ const createCoreReads = (db, storage) => {
|
|
|
18912
18916
|
const page = await db.findMany("bundle_patches", {
|
|
18913
18917
|
index: "byBundle",
|
|
18914
18918
|
where: { bundle_id: row.id },
|
|
18915
|
-
limit: Math.min(count - patches.length, PAGE$
|
|
18919
|
+
limit: Math.min(count - patches.length, PAGE$5),
|
|
18916
18920
|
...cursor === void 0 ? {} : { cursor }
|
|
18917
18921
|
});
|
|
18918
18922
|
patches.push(...page.rows.map(toPatchRow));
|
|
@@ -19116,7 +19120,7 @@ const createCoreReads = (db, storage) => {
|
|
|
19116
19120
|
return (await drain$1((page) => db.findMany("channels", {
|
|
19117
19121
|
index: "all",
|
|
19118
19122
|
where: {},
|
|
19119
|
-
limit: PAGE$
|
|
19123
|
+
limit: PAGE$5,
|
|
19120
19124
|
...page
|
|
19121
19125
|
}))).map(toChannelRow);
|
|
19122
19126
|
},
|
|
@@ -19472,11 +19476,15 @@ const createLabelAllocator = (tx, used, caughtUp) => {
|
|
|
19472
19476
|
};
|
|
19473
19477
|
};
|
|
19474
19478
|
const FILL_BATCH = 25;
|
|
19475
|
-
const PAGE$
|
|
19479
|
+
const PAGE$4 = 500;
|
|
19480
|
+
const PAUSE_MS$1 = 1e3;
|
|
19481
|
+
const MAX_PAUSE_MS$1 = 32e3;
|
|
19482
|
+
const sleep$1 = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
19476
19483
|
const fillLabels = async (db, { channelId, platform }, { dryRun = false } = {}) => {
|
|
19477
19484
|
const id = labelSequenceId(channelId, platform);
|
|
19478
19485
|
let labeled = 0;
|
|
19479
19486
|
let batchSize = FILL_BATCH;
|
|
19487
|
+
let paused = 0;
|
|
19480
19488
|
const label = async (ids) => {
|
|
19481
19489
|
for (let at = 0; at < ids.length;) {
|
|
19482
19490
|
const batch = ids.slice(at, at + batchSize);
|
|
@@ -19501,12 +19509,16 @@ const fillLabels = async (db, { channelId, platform }, { dryRun = false } = {})
|
|
|
19501
19509
|
return count;
|
|
19502
19510
|
});
|
|
19503
19511
|
at += batch.length;
|
|
19512
|
+
paused = 0;
|
|
19504
19513
|
} catch (error) {
|
|
19505
19514
|
if (batchSize > 1 && error instanceof DatabaseConstraintError && error.reason === "too_large") {
|
|
19506
19515
|
batchSize = Math.max(1, Math.floor(batchSize / 2));
|
|
19507
19516
|
continue;
|
|
19508
19517
|
}
|
|
19509
|
-
throw error;
|
|
19518
|
+
if (!isDatabaseBusyError(error) || paused >= MAX_PAUSE_MS$1) throw error;
|
|
19519
|
+
batchSize = Math.max(1, Math.floor(batchSize / 2));
|
|
19520
|
+
paused = paused === 0 ? PAUSE_MS$1 : paused * 2;
|
|
19521
|
+
await sleep$1(paused);
|
|
19510
19522
|
}
|
|
19511
19523
|
}
|
|
19512
19524
|
};
|
|
@@ -19518,7 +19530,7 @@ const fillLabels = async (db, { channelId, platform }, { dryRun = false } = {})
|
|
|
19518
19530
|
channel_id: channelId,
|
|
19519
19531
|
platform
|
|
19520
19532
|
},
|
|
19521
|
-
limit: PAGE$
|
|
19533
|
+
limit: PAGE$4,
|
|
19522
19534
|
...cursor === void 0 ? {} : { cursor }
|
|
19523
19535
|
});
|
|
19524
19536
|
const unlabeled = page.rows.filter((row) => typeof row.label !== "number").map((row) => row.id);
|
|
@@ -19679,7 +19691,7 @@ const pendingLabelPairs = async (db) => {
|
|
|
19679
19691
|
};
|
|
19680
19692
|
//#endregion
|
|
19681
19693
|
//#region ../../packages/server/dist/core/writes.mjs
|
|
19682
|
-
const PAGE$
|
|
19694
|
+
const PAGE$3 = 500;
|
|
19683
19695
|
const countBundle = (tx, platform, delta) => {
|
|
19684
19696
|
for (const key of [platform, "*"]) tx.aggregate("bundle_totals", { platform_key: key }, { bundles: delta });
|
|
19685
19697
|
};
|
|
@@ -19706,7 +19718,7 @@ const replaceBundlePatches = async (tx, bundle, rows, checkNew) => {
|
|
|
19706
19718
|
const page = await tx.findMany("bundle_patches", {
|
|
19707
19719
|
index: "byBundle",
|
|
19708
19720
|
where: { bundle_id: bundle.id },
|
|
19709
|
-
limit: Math.min(count - seen, PAGE$
|
|
19721
|
+
limit: Math.min(count - seen, PAGE$3),
|
|
19710
19722
|
...cursor === void 0 ? {} : { cursor }
|
|
19711
19723
|
});
|
|
19712
19724
|
for (const stored of page.rows) {
|
|
@@ -20189,7 +20201,7 @@ const createNativeBuildApi = (db, { now = Date.now } = {}) => ({
|
|
|
20189
20201
|
});
|
|
20190
20202
|
//#endregion
|
|
20191
20203
|
//#region ../../packages/server/dist/core/releases.mjs
|
|
20192
|
-
const PAGE$
|
|
20204
|
+
const PAGE$2 = 500;
|
|
20193
20205
|
const fail$1 = (code, message) => {
|
|
20194
20206
|
throw new ReleaseCatalogMutationError(code, message);
|
|
20195
20207
|
};
|
|
@@ -20223,7 +20235,7 @@ const enabledIn = (scopeKey, cursor) => ({
|
|
|
20223
20235
|
scope_key: scopeKey,
|
|
20224
20236
|
enabled: true
|
|
20225
20237
|
},
|
|
20226
|
-
limit: PAGE$
|
|
20238
|
+
limit: PAGE$2,
|
|
20227
20239
|
...cursor === void 0 ? {} : { cursor }
|
|
20228
20240
|
});
|
|
20229
20241
|
const enabledReleases = (tx, scopeKey) => drainReleases((cursor) => tx.findMany("releases", enabledIn(scopeKey, cursor)));
|
|
@@ -22461,13 +22473,15 @@ const isLaunch = (row) => {
|
|
|
22461
22473
|
const kinds = metadataOf(row).change?.kinds ?? [];
|
|
22462
22474
|
return kinds.includes("bundle") && !kinds.includes("first_seen") && row.to_release_id !== null;
|
|
22463
22475
|
};
|
|
22464
|
-
const
|
|
22476
|
+
const sideRef = (key, releaseId, bundleId) => key === "release" ? releaseId ?? bundleId : bundleId;
|
|
22477
|
+
const bundleRefsOf = (row, key = "release") => {
|
|
22465
22478
|
if (isFailedCheck(row) || isLateEvent(row)) return [];
|
|
22466
|
-
if (row.type === "RECOVERED") return [`from:${row.from_bundle_id}`];
|
|
22467
|
-
if (row.type === "UNCHANGED") return isLaunch(row) ? [`on:${row.to_bundle_id}`] : [];
|
|
22468
|
-
return [`to:${row.to_bundle_id}`];
|
|
22479
|
+
if (row.type === "RECOVERED") return [`from:${sideRef(key, row.from_release_id, row.from_bundle_id)}`];
|
|
22480
|
+
if (row.type === "UNCHANGED") return isLaunch(row) ? [`on:${sideRef(key, row.to_release_id, row.to_bundle_id)}`] : [];
|
|
22481
|
+
return [`to:${sideRef(key, row.to_release_id, row.to_bundle_id)}`];
|
|
22469
22482
|
};
|
|
22470
|
-
const
|
|
22483
|
+
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)}`]] : []];
|
|
22484
|
+
const bundleRefOfFilter = (filter) => filter.type === "RECOVERED" ? `from:${filter.fromReleaseId}` : filter.type === "UNCHANGED" ? `on:${filter.toReleaseId}` : `to:${filter.toReleaseId}`;
|
|
22471
22485
|
const bundleEvents = (days) => defineTable({
|
|
22472
22486
|
id: {
|
|
22473
22487
|
type: "string",
|
|
@@ -22897,6 +22911,83 @@ const createInsightsSchema = ({ rawDays, dailyDays } = DEFAULT_INSIGHTS_RETENTIO
|
|
|
22897
22911
|
};
|
|
22898
22912
|
createInsightsSchema();
|
|
22899
22913
|
//#endregion
|
|
22914
|
+
//#region ../insights/dist/server/backfill.mjs
|
|
22915
|
+
const PAGE$1 = 500;
|
|
22916
|
+
const BATCH = 25;
|
|
22917
|
+
const PAUSE_MS = 1e3;
|
|
22918
|
+
const MAX_PAUSE_MS = 32e3;
|
|
22919
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
22920
|
+
const sameRefs = (stored, refs) => {
|
|
22921
|
+
const values = Array.isArray(stored) ? stored : [];
|
|
22922
|
+
return values.length === refs.length && values.every((value) => refs.includes(value));
|
|
22923
|
+
};
|
|
22924
|
+
const namesArtifact = (row) => {
|
|
22925
|
+
const byKey = (key) => bundleRefsOf(row, key);
|
|
22926
|
+
return sameRefs(row.bundle_ref, byKey("artifact")) && !sameRefs(row.bundle_ref, byKey("release"));
|
|
22927
|
+
};
|
|
22928
|
+
const backfillReleaseRefs = async (db, now, { rawDays }, { dryRun = false } = {}) => {
|
|
22929
|
+
const today = now() - now() % DAY_MS$1;
|
|
22930
|
+
let events = 0;
|
|
22931
|
+
let size = BATCH;
|
|
22932
|
+
let paused = 0;
|
|
22933
|
+
const move = async (stale) => {
|
|
22934
|
+
if (dryRun) {
|
|
22935
|
+
events += stale.length;
|
|
22936
|
+
return;
|
|
22937
|
+
}
|
|
22938
|
+
for (let start = 0; start < stale.length;) {
|
|
22939
|
+
const candidates = stale.slice(start, start + size);
|
|
22940
|
+
try {
|
|
22941
|
+
events += await rewrite(candidates);
|
|
22942
|
+
start += candidates.length;
|
|
22943
|
+
paused = 0;
|
|
22944
|
+
} catch (error) {
|
|
22945
|
+
if (error instanceof DatabaseConstraintError && error.reason === "too_large" && candidates.length > 1) {
|
|
22946
|
+
size = Math.ceil(candidates.length / 2);
|
|
22947
|
+
continue;
|
|
22948
|
+
}
|
|
22949
|
+
if (!isDatabaseBusyError(error) || paused >= MAX_PAUSE_MS) throw error;
|
|
22950
|
+
size = Math.ceil(candidates.length / 2);
|
|
22951
|
+
paused = paused === 0 ? PAUSE_MS : paused * 2;
|
|
22952
|
+
await sleep(paused);
|
|
22953
|
+
}
|
|
22954
|
+
}
|
|
22955
|
+
};
|
|
22956
|
+
const rewrite = (candidates) => db.transaction(async (tx) => {
|
|
22957
|
+
const rows = await Promise.all(candidates.map(({ id }) => tx.findOne("bundle_events", { id })));
|
|
22958
|
+
let moved = 0;
|
|
22959
|
+
for (const row of rows) {
|
|
22960
|
+
if (row === null || !namesArtifact(row)) continue;
|
|
22961
|
+
tx.update("bundle_events", row, {});
|
|
22962
|
+
const outcome = (ref, delta) => tx.aggregate("insights_outcomes", {
|
|
22963
|
+
platform: row.platform,
|
|
22964
|
+
channel: row.channel,
|
|
22965
|
+
type: ref[0],
|
|
22966
|
+
bundle_ref: ref[1],
|
|
22967
|
+
bucket_start_ms: row.received_at_ms - row.received_at_ms % HOUR_MS$1
|
|
22968
|
+
}, { events: delta }, { shardBy: row.install_id });
|
|
22969
|
+
for (const ref of outcomeRefsOf(row, "artifact")) outcome(ref, -1);
|
|
22970
|
+
for (const ref of outcomeRefsOf(row, "release")) outcome(ref, 1);
|
|
22971
|
+
moved += 1;
|
|
22972
|
+
}
|
|
22973
|
+
return moved;
|
|
22974
|
+
});
|
|
22975
|
+
for (let day = today - rawDays * DAY_MS$1; day <= today; day += DAY_MS$1) {
|
|
22976
|
+
let cursor;
|
|
22977
|
+
do {
|
|
22978
|
+
const page = await db.findMany("bundle_events", {
|
|
22979
|
+
index: "byDay",
|
|
22980
|
+
where: { day },
|
|
22981
|
+
limit: PAGE$1,
|
|
22982
|
+
...cursor === void 0 ? {} : { cursor }
|
|
22983
|
+
});
|
|
22984
|
+
await move(page.rows.filter(namesArtifact));
|
|
22985
|
+
cursor = page.next;
|
|
22986
|
+
} while (cursor !== void 0);
|
|
22987
|
+
}
|
|
22988
|
+
return { events };
|
|
22989
|
+
};
|
|
22990
|
+
//#endregion
|
|
22900
22991
|
//#region ../insights/dist/server/eventRow.mjs
|
|
22901
22992
|
const CHANGE_KINDS = /* @__PURE__ */ new Set([
|
|
22902
22993
|
"first_seen",
|
|
@@ -22974,7 +23065,7 @@ const isBundleFilter = (value, withKind = false) => {
|
|
|
22974
23065
|
"type",
|
|
22975
23066
|
...withKind ? ["kind"] : []
|
|
22976
23067
|
];
|
|
22977
|
-
return value.type === "RECOVERED" ? isText$1(value.
|
|
23068
|
+
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"]);
|
|
22978
23069
|
};
|
|
22979
23070
|
const isEventFilter = (value) => {
|
|
22980
23071
|
if (!isRecord$3(value)) return false;
|
|
@@ -23069,20 +23160,24 @@ const createValidatedInsightsModel = (model) => ({
|
|
|
23069
23160
|
if (!isRecord$3(input) || !hasOnlyKeys(input, [
|
|
23070
23161
|
"platform",
|
|
23071
23162
|
"channel",
|
|
23072
|
-
"sinceMs"
|
|
23073
|
-
|
|
23074
|
-
]) || !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, [
|
|
23075
|
-
"field",
|
|
23076
|
-
"value",
|
|
23077
|
-
"types"
|
|
23078
|
-
]) || 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) => ![
|
|
23079
|
-
"UNCHANGED",
|
|
23080
|
-
"UPDATE_DOWNLOADED",
|
|
23081
|
-
"UPDATE_APPLIED",
|
|
23082
|
-
"RECOVERED"
|
|
23083
|
-
].includes(type))))) invalidQuery();
|
|
23163
|
+
"sinceMs"
|
|
23164
|
+
]) || !hasScope(input) || !isTimestamp(input.sinceMs)) invalidQuery();
|
|
23084
23165
|
return validateCount(await model.countLatestEvents(input));
|
|
23085
23166
|
},
|
|
23167
|
+
async countReleaseInstallations(input) {
|
|
23168
|
+
if (!isRecord$3(input) || !hasOnlyKeys(input, [
|
|
23169
|
+
"platform",
|
|
23170
|
+
"channel",
|
|
23171
|
+
"sinceMs",
|
|
23172
|
+
"releaseId"
|
|
23173
|
+
]) || !hasScope(input) || !isTimestamp(input.sinceMs) || !isText$1(input.releaseId)) invalidQuery();
|
|
23174
|
+
const counts = await model.countReleaseInstallations(input);
|
|
23175
|
+
if (!isRecord$3(counts) || !hasOnlyKeys(counts, ["installations", "release"])) invalidResult();
|
|
23176
|
+
return {
|
|
23177
|
+
installations: validateCount(counts.installations),
|
|
23178
|
+
release: validateCount(counts.release)
|
|
23179
|
+
};
|
|
23180
|
+
},
|
|
23086
23181
|
async countEvents(input) {
|
|
23087
23182
|
if (!isRecord$3(input) || !hasOnlyKeys(input, [
|
|
23088
23183
|
"filter",
|
|
@@ -23135,6 +23230,7 @@ const createInsightsModel = (api) => createValidatedInsightsModel({
|
|
|
23135
23230
|
listEvents: api.listEvents,
|
|
23136
23231
|
findLatestEvents: api.findLatestEvents,
|
|
23137
23232
|
countLatestEvents: api.countLatestEvents,
|
|
23233
|
+
countReleaseInstallations: api.countReleaseInstallations,
|
|
23138
23234
|
countEvents: api.countEvents,
|
|
23139
23235
|
countEventSeries: api.countEventSeries,
|
|
23140
23236
|
getReleaseActivity: api.getReleaseActivity,
|
|
@@ -23503,27 +23599,27 @@ const readScope$1 = (input) => {
|
|
|
23503
23599
|
};
|
|
23504
23600
|
const bundleFilter = (input) => {
|
|
23505
23601
|
const scope = readScope$1(input);
|
|
23506
|
-
const
|
|
23602
|
+
const releaseId = requireString(input.releaseId, "bundle ID", MAX_EVENT_ID_LENGTH);
|
|
23507
23603
|
switch (input.outcome) {
|
|
23508
23604
|
case "downloaded": return {
|
|
23509
23605
|
...scope,
|
|
23510
23606
|
type: "UPDATE_DOWNLOADED",
|
|
23511
|
-
|
|
23607
|
+
toReleaseId: releaseId
|
|
23512
23608
|
};
|
|
23513
23609
|
case "applied": return {
|
|
23514
23610
|
...scope,
|
|
23515
23611
|
type: "UPDATE_APPLIED",
|
|
23516
|
-
|
|
23612
|
+
toReleaseId: releaseId
|
|
23517
23613
|
};
|
|
23518
23614
|
case "recovered": return {
|
|
23519
23615
|
...scope,
|
|
23520
23616
|
type: "RECOVERED",
|
|
23521
|
-
|
|
23617
|
+
fromReleaseId: releaseId
|
|
23522
23618
|
};
|
|
23523
23619
|
case "failed": return {
|
|
23524
23620
|
...scope,
|
|
23525
23621
|
type: "UPDATE_FAILED",
|
|
23526
|
-
|
|
23622
|
+
toReleaseId: releaseId
|
|
23527
23623
|
};
|
|
23528
23624
|
default: throw new InsightsBadRequestError("Invalid Insights outcome.");
|
|
23529
23625
|
}
|
|
@@ -23533,7 +23629,7 @@ const sameFilter = (left, right) => {
|
|
|
23533
23629
|
switch (right.kind) {
|
|
23534
23630
|
case "all": return true;
|
|
23535
23631
|
case "installationMovement": return left.installId === right.installId;
|
|
23536
|
-
case "bundle": return left.platform === right.platform && left.channel === right.channel && left.type === right.type && (right.type === "RECOVERED" ? left.
|
|
23632
|
+
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);
|
|
23537
23633
|
}
|
|
23538
23634
|
};
|
|
23539
23635
|
const readEventCursor = (value, filter) => {
|
|
@@ -23570,7 +23666,7 @@ const assertEventRows = (rows, input) => {
|
|
|
23570
23666
|
for (let index = 0; index < rows.length; index += 1) {
|
|
23571
23667
|
const row = rows[index];
|
|
23572
23668
|
const previous = rows[index - 1];
|
|
23573
|
-
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.
|
|
23669
|
+
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.");
|
|
23574
23670
|
}
|
|
23575
23671
|
};
|
|
23576
23672
|
const toFailure = (failure) => ({
|
|
@@ -23609,6 +23705,7 @@ const eventDetails = ({ type, metadata }) => ({
|
|
|
23609
23705
|
...metadata.implied_download === true ? { impliedDownload: true } : {}
|
|
23610
23706
|
});
|
|
23611
23707
|
const toEventHistoryRow = (row) => ({
|
|
23708
|
+
...row.from_release_id == null ? {} : { fromReleaseId: row.from_release_id },
|
|
23612
23709
|
...row.to_release_id == null ? {} : { toReleaseId: row.to_release_id },
|
|
23613
23710
|
...row.metadata.sdk_version == null ? {} : { sdkVersion: row.metadata.sdk_version },
|
|
23614
23711
|
...row.metadata.min_bundle_id === void 0 ? {} : { minBundleId: row.metadata.min_bundle_id },
|
|
@@ -23633,6 +23730,7 @@ const toInstallationRow = (row) => ({
|
|
|
23633
23730
|
cohort: row.metadata.cohort,
|
|
23634
23731
|
installId: row.install_id,
|
|
23635
23732
|
lastKnownBundleId: row.type === "UPDATE_DOWNLOADED" ? row.from_bundle_id : row.to_bundle_id,
|
|
23733
|
+
lastKnownReleaseId: row.type === "UPDATE_DOWNLOADED" ? row.from_release_id : row.to_release_id,
|
|
23636
23734
|
pendingBundleId: row.type === "UPDATE_DOWNLOADED" ? row.to_bundle_id : null,
|
|
23637
23735
|
pendingReleaseId: row.type === "UPDATE_DOWNLOADED" ? row.to_release_id : null,
|
|
23638
23736
|
latestStatus: row.type,
|
|
@@ -23755,46 +23853,33 @@ const createInsightsProvider = (model) => Object.freeze({
|
|
|
23755
23853
|
measuredAtMs: Date.now()
|
|
23756
23854
|
};
|
|
23757
23855
|
};
|
|
23758
|
-
const
|
|
23759
|
-
|
|
23760
|
-
...scope,
|
|
23761
|
-
sinceMs
|
|
23762
|
-
}));
|
|
23763
|
-
if (bundleId === void 0) return {
|
|
23856
|
+
const releaseId = input.releaseId === void 0 ? void 0 : requireString(input.releaseId, "bundle ID", MAX_EVENT_ID_LENGTH);
|
|
23857
|
+
if (releaseId === void 0) return {
|
|
23764
23858
|
...scope,
|
|
23765
23859
|
window,
|
|
23766
23860
|
sinceMs,
|
|
23767
23861
|
beforeReceivedAtMs,
|
|
23768
|
-
reportingInstallations: await
|
|
23862
|
+
reportingInstallations: await measure(model.countLatestEvents({
|
|
23863
|
+
...scope,
|
|
23864
|
+
sinceMs
|
|
23865
|
+
}))
|
|
23769
23866
|
};
|
|
23867
|
+
const installations = model.countReleaseInstallations({
|
|
23868
|
+
...scope,
|
|
23869
|
+
sinceMs,
|
|
23870
|
+
releaseId
|
|
23871
|
+
}).then(async (counts) => [await measure(Promise.resolve(counts.installations)), await measure(Promise.resolve(counts.release))]);
|
|
23770
23872
|
const countOutcome = (outcome) => measure(model.countEvents({
|
|
23771
23873
|
filter: bundleFilter({
|
|
23772
23874
|
...scope,
|
|
23773
|
-
|
|
23875
|
+
releaseId,
|
|
23774
23876
|
outcome
|
|
23775
23877
|
}),
|
|
23776
23878
|
sinceMs,
|
|
23777
23879
|
beforeReceivedAtMs
|
|
23778
23880
|
}));
|
|
23779
|
-
const [reportingInstallations, bundleInstallations, downloadedReports, appliedReports, recoveredReports, failedReports] = await Promise.all([
|
|
23780
|
-
|
|
23781
|
-
measure(model.countLatestEvents({
|
|
23782
|
-
...scope,
|
|
23783
|
-
sinceMs,
|
|
23784
|
-
bundle: [{
|
|
23785
|
-
field: "from_bundle_id",
|
|
23786
|
-
value: bundleId,
|
|
23787
|
-
types: ["UPDATE_DOWNLOADED"]
|
|
23788
|
-
}, {
|
|
23789
|
-
field: "to_bundle_id",
|
|
23790
|
-
value: bundleId,
|
|
23791
|
-
types: [
|
|
23792
|
-
"UNCHANGED",
|
|
23793
|
-
"UPDATE_APPLIED",
|
|
23794
|
-
"RECOVERED"
|
|
23795
|
-
]
|
|
23796
|
-
}]
|
|
23797
|
-
})),
|
|
23881
|
+
const [[reportingInstallations, bundleInstallations], downloadedReports, appliedReports, recoveredReports, failedReports] = await Promise.all([
|
|
23882
|
+
installations,
|
|
23798
23883
|
countOutcome("downloaded"),
|
|
23799
23884
|
countOutcome("applied"),
|
|
23800
23885
|
countOutcome("recovered"),
|
|
@@ -23807,7 +23892,7 @@ const createInsightsProvider = (model) => Object.freeze({
|
|
|
23807
23892
|
beforeReceivedAtMs,
|
|
23808
23893
|
reportingInstallations,
|
|
23809
23894
|
bundle: {
|
|
23810
|
-
|
|
23895
|
+
releaseId,
|
|
23811
23896
|
reportingInstallations: bundleInstallations,
|
|
23812
23897
|
downloadedReports,
|
|
23813
23898
|
appliedReports,
|
|
@@ -23932,8 +24017,6 @@ const gaugeSlot = (head) => ({
|
|
|
23932
24017
|
releaseId: head.type === "UPDATE_DOWNLOADED" ? head.from_release_id : head.to_release_id,
|
|
23933
24018
|
builtinBundleId: runningBuiltinBundleId(head)
|
|
23934
24019
|
});
|
|
23935
|
-
const PAIR_FIELD = "from_to";
|
|
23936
|
-
const bundlePairKey = (from, to) => insightsKey(`${from.length}:${from}${to.length}:${to}`);
|
|
23937
24020
|
const countHead = (tx, head, delta) => {
|
|
23938
24021
|
const { bucket, releaseId, builtinBundleId } = gaugeSlot(head);
|
|
23939
24022
|
const shardBy = head.install_id;
|
|
@@ -23952,26 +24035,6 @@ const countHead = (tx, head, delta) => {
|
|
|
23952
24035
|
builtin_bundle_id: builtinBundleId,
|
|
23953
24036
|
bucket_start_ms: bucket
|
|
23954
24037
|
}, { latest_installations: delta }, { shardBy });
|
|
23955
|
-
for (const field of ["from_bundle_id", "to_bundle_id"]) {
|
|
23956
|
-
const bundleId = head[field];
|
|
23957
|
-
if (bundleId === null) continue;
|
|
23958
|
-
tx.aggregate("insights_latest_by_bundle", {
|
|
23959
|
-
platform: head.platform,
|
|
23960
|
-
channel: head.channel,
|
|
23961
|
-
bundle_field: field,
|
|
23962
|
-
bundle_id: bundleId,
|
|
23963
|
-
type: head.type,
|
|
23964
|
-
bucket_start_ms: bucket
|
|
23965
|
-
}, { installations: delta }, { shardBy });
|
|
23966
|
-
}
|
|
23967
|
-
if (head.from_bundle_id !== null) tx.aggregate("insights_latest_by_bundle", {
|
|
23968
|
-
platform: head.platform,
|
|
23969
|
-
channel: head.channel,
|
|
23970
|
-
bundle_field: PAIR_FIELD,
|
|
23971
|
-
bundle_id: bundlePairKey(head.from_bundle_id, head.to_bundle_id),
|
|
23972
|
-
type: head.type,
|
|
23973
|
-
bucket_start_ms: bucket
|
|
23974
|
-
}, { installations: delta }, { shardBy });
|
|
23975
24038
|
};
|
|
23976
24039
|
const PERIOD_MODELS = {
|
|
23977
24040
|
hour: {
|
|
@@ -24021,18 +24084,13 @@ const countEvent = (tx, event) => {
|
|
|
24021
24084
|
};
|
|
24022
24085
|
const countOutcome = (tx, event) => {
|
|
24023
24086
|
const shardBy = event.install_id;
|
|
24024
|
-
const
|
|
24087
|
+
for (const [type, bundleRef] of outcomeRefsOf(event)) tx.aggregate("insights_outcomes", {
|
|
24025
24088
|
platform: event.platform,
|
|
24026
24089
|
channel: event.channel,
|
|
24027
24090
|
type,
|
|
24028
24091
|
bundle_ref: bundleRef,
|
|
24029
24092
|
bucket_start_ms: hourOf(event.received_at_ms)
|
|
24030
24093
|
}, { events: 1 }, { shardBy });
|
|
24031
|
-
for (const bundleRef of bundleRefsOf(event)) hour(event.type, bundleRef);
|
|
24032
|
-
if (event.metadata.implied_download === true) hour("UPDATE_DOWNLOADED", bundleRefOfFilter({
|
|
24033
|
-
type: "UPDATE_DOWNLOADED",
|
|
24034
|
-
toBundleId: event.type === "RECOVERED" ? event.from_bundle_id : event.to_bundle_id
|
|
24035
|
-
}));
|
|
24036
24094
|
tx.aggregate("insights_outcomes", {
|
|
24037
24095
|
...DAILY_EVENTS,
|
|
24038
24096
|
bucket_start_ms: dayOf(event.received_at_ms)
|
|
@@ -24418,25 +24476,34 @@ const countEventSeries = async (db, input) => {
|
|
|
24418
24476
|
events: count
|
|
24419
24477
|
}));
|
|
24420
24478
|
};
|
|
24421
|
-
const
|
|
24422
|
-
if (bundle === void 0) return void 0;
|
|
24423
|
-
return [...new Map(bundle.flatMap(({ field, value, types }) => types.map((type) => [JSON.stringify([
|
|
24424
|
-
field,
|
|
24425
|
-
value,
|
|
24426
|
-
type
|
|
24427
|
-
]), {
|
|
24428
|
-
field,
|
|
24429
|
-
value,
|
|
24430
|
-
type
|
|
24431
|
-
}]))).values()];
|
|
24432
|
-
};
|
|
24433
|
-
const countLatestEvents = async (db, input) => {
|
|
24434
|
-
const { platform, channel, sinceMs: start } = input;
|
|
24479
|
+
const distributionRows = (db, { platform, channel, sinceMs: start }) => {
|
|
24435
24480
|
if (start % 864e5 !== 0) throw new DatabaseAdapterInputError("invalid-query");
|
|
24436
|
-
|
|
24481
|
+
return drain((page) => db.findAggregates("insights_distribution", {
|
|
24482
|
+
index: "byScope",
|
|
24483
|
+
where: {
|
|
24484
|
+
channel,
|
|
24485
|
+
platform
|
|
24486
|
+
},
|
|
24487
|
+
range: { gte: start },
|
|
24488
|
+
limit: PAGE,
|
|
24489
|
+
...page
|
|
24490
|
+
}));
|
|
24491
|
+
};
|
|
24492
|
+
const installations = (count) => Math.max(0, count);
|
|
24493
|
+
const countLatestEvents = async (db, input) => installations((await distributionRows(db, input)).reduce((sum, row) => sum + row.latest_installations, 0));
|
|
24494
|
+
const countReleaseInstallations = async (db, input) => {
|
|
24495
|
+
const { platform, channel, sinceMs: start, releaseId } = input;
|
|
24437
24496
|
let total = 0;
|
|
24438
|
-
|
|
24439
|
-
|
|
24497
|
+
let release = 0;
|
|
24498
|
+
let named = false;
|
|
24499
|
+
for (const row of await distributionRows(db, input)) {
|
|
24500
|
+
total += row.latest_installations;
|
|
24501
|
+
if (row.release_id !== releaseId) continue;
|
|
24502
|
+
named = true;
|
|
24503
|
+
release += row.latest_installations;
|
|
24504
|
+
}
|
|
24505
|
+
if (!named) {
|
|
24506
|
+
const builtin = await drain((page) => db.findAggregates("insights_builtin_distribution", {
|
|
24440
24507
|
index: "byScope",
|
|
24441
24508
|
where: {
|
|
24442
24509
|
channel,
|
|
@@ -24446,33 +24513,12 @@ const countLatestEvents = async (db, input) => {
|
|
|
24446
24513
|
limit: PAGE,
|
|
24447
24514
|
...page
|
|
24448
24515
|
}));
|
|
24449
|
-
|
|
24450
|
-
} else {
|
|
24451
|
-
const gauge = async (bundleField, bundleId, type) => {
|
|
24452
|
-
return (await drain((page) => db.findAggregates("insights_latest_by_bundle", {
|
|
24453
|
-
index: "byBundle",
|
|
24454
|
-
where: {
|
|
24455
|
-
platform,
|
|
24456
|
-
channel,
|
|
24457
|
-
bundle_field: bundleField,
|
|
24458
|
-
bundle_id: bundleId,
|
|
24459
|
-
type
|
|
24460
|
-
},
|
|
24461
|
-
range: { gte: start },
|
|
24462
|
-
limit: PAGE,
|
|
24463
|
-
...page
|
|
24464
|
-
}))).reduce((sum, row) => sum + row.installations, 0);
|
|
24465
|
-
};
|
|
24466
|
-
for (const { field, value, type } of predicates) total += await gauge(field, value, type);
|
|
24467
|
-
for (const from of predicates) {
|
|
24468
|
-
if (from.field !== "from_bundle_id") continue;
|
|
24469
|
-
for (const to of predicates) {
|
|
24470
|
-
if (to.field !== "to_bundle_id" || to.type !== from.type) continue;
|
|
24471
|
-
total -= await gauge(PAIR_FIELD, bundlePairKey(from.value, to.value), from.type);
|
|
24472
|
-
}
|
|
24473
|
-
}
|
|
24516
|
+
for (const row of builtin) if (row.release_id === "" && row.builtin_bundle_id === releaseId) release += row.latest_installations;
|
|
24474
24517
|
}
|
|
24475
|
-
return
|
|
24518
|
+
return {
|
|
24519
|
+
installations: installations(total),
|
|
24520
|
+
release: installations(release)
|
|
24521
|
+
};
|
|
24476
24522
|
};
|
|
24477
24523
|
const retained = (now, { rawDays, dailyDays }) => ({
|
|
24478
24524
|
hour: hourCeil(now - rawDays * DAY_MS$1),
|
|
@@ -24889,6 +24935,20 @@ const getUpdateFailures = async (db, input, now, retention) => {
|
|
|
24889
24935
|
};
|
|
24890
24936
|
};
|
|
24891
24937
|
//#endregion
|
|
24938
|
+
//#region ../insights/dist/server/wire.mjs
|
|
24939
|
+
const RELEASE_ID_PARAM = "bundleId";
|
|
24940
|
+
const toWireOverview = ({ bundle, ...overview }) => {
|
|
24941
|
+
if (bundle === void 0) return overview;
|
|
24942
|
+
const { releaseId, ...counts } = bundle;
|
|
24943
|
+
return {
|
|
24944
|
+
...overview,
|
|
24945
|
+
bundle: {
|
|
24946
|
+
...counts,
|
|
24947
|
+
bundleId: releaseId
|
|
24948
|
+
}
|
|
24949
|
+
};
|
|
24950
|
+
};
|
|
24951
|
+
//#endregion
|
|
24892
24952
|
//#region ../insights/dist/server/queryInput.mjs
|
|
24893
24953
|
const MAX_PAGE_LIMIT = 100;
|
|
24894
24954
|
const MAX_IDENTITY_LENGTH = 255;
|
|
@@ -24933,7 +24993,7 @@ const readScope = (url) => {
|
|
|
24933
24993
|
const parseEventPageInput = (request) => {
|
|
24934
24994
|
const url = new URL(request.url);
|
|
24935
24995
|
const bundleFields = [
|
|
24936
|
-
|
|
24996
|
+
RELEASE_ID_PARAM,
|
|
24937
24997
|
"outcome",
|
|
24938
24998
|
"platform",
|
|
24939
24999
|
"channel"
|
|
@@ -24944,7 +25004,7 @@ const parseEventPageInput = (request) => {
|
|
|
24944
25004
|
if (outcome !== "downloaded" && outcome !== "applied" && outcome !== "recovered" && outcome !== "failed") throw new InsightsBadRequestError("Invalid 'outcome' query parameter.");
|
|
24945
25005
|
bundle = {
|
|
24946
25006
|
...readScope(url),
|
|
24947
|
-
|
|
25007
|
+
releaseId: readId(url, RELEASE_ID_PARAM, 1024),
|
|
24948
25008
|
outcome
|
|
24949
25009
|
};
|
|
24950
25010
|
}
|
|
@@ -24970,11 +25030,10 @@ const parseReportingOverviewInput = (request) => {
|
|
|
24970
25030
|
const url = new URL(request.url);
|
|
24971
25031
|
const window = readSingle(url, "window") ?? "30d";
|
|
24972
25032
|
if (window !== "24h" && window !== "7d" && window !== "30d") throw new InsightsBadRequestError("Invalid 'window' query parameter.");
|
|
24973
|
-
const bundleId = readSingle(url, "bundleId");
|
|
24974
25033
|
return {
|
|
24975
25034
|
...readScope(url),
|
|
24976
25035
|
window,
|
|
24977
|
-
...bundleId === void 0 ? {} : {
|
|
25036
|
+
...readSingle(url, "bundleId") === void 0 ? {} : { releaseId: readId(url, RELEASE_ID_PARAM, 1024) }
|
|
24978
25037
|
};
|
|
24979
25038
|
};
|
|
24980
25039
|
//#endregion
|
|
@@ -25053,7 +25112,7 @@ const createInsightsRouteHandlers = (provider) => ({
|
|
|
25053
25112
|
await provider.appendBundleEvent(await parseBundleEventRequest(request));
|
|
25054
25113
|
return new Response(null, { status: 204 });
|
|
25055
25114
|
}),
|
|
25056
|
-
getReportingOverview: (_params, request) => query(() => provider.getReportingOverview(parseReportingOverviewInput(request))),
|
|
25115
|
+
getReportingOverview: (_params, request) => query(async () => toWireOverview(await provider.getReportingOverview(parseReportingOverviewInput(request)))),
|
|
25057
25116
|
getInstallation: (params) => run$1(async () => {
|
|
25058
25117
|
const installation = await provider.getInstallation({ installId: requireParam(params, "installId") });
|
|
25059
25118
|
return installation === null ? json$1({ error: "Installation not found" }, 404) : json$1(installation, 200);
|
|
@@ -25073,11 +25132,13 @@ const createInsightsApi = (db, now, retention) => ({
|
|
|
25073
25132
|
listEvents: (input) => listEvents(db, input),
|
|
25074
25133
|
findLatestEvents: (input) => findLatestEvents(db, input),
|
|
25075
25134
|
countLatestEvents: (input) => countLatestEvents(db, input),
|
|
25135
|
+
countReleaseInstallations: (input) => countReleaseInstallations(db, input),
|
|
25076
25136
|
countEvents: (input) => countEvents(db, input),
|
|
25077
25137
|
countEventSeries: (input) => countEventSeries(db, input),
|
|
25078
25138
|
getReleaseActivity: (input) => getReleaseActivity(db, input, now),
|
|
25079
25139
|
getAppUsage: (input) => getAppUsage(db, input, now, retention),
|
|
25080
|
-
getUpdateFailures: (input) => getUpdateFailures(db, input, now, retention)
|
|
25140
|
+
getUpdateFailures: (input) => getUpdateFailures(db, input, now, retention),
|
|
25141
|
+
backfillReleaseRefs: (options) => backfillReleaseRefs(db, now, retention, options)
|
|
25081
25142
|
});
|
|
25082
25143
|
const readFailuresQuery = (url) => {
|
|
25083
25144
|
const query = url.searchParams;
|
package/dist/init/index.cjs
CHANGED
|
@@ -7136,6 +7136,7 @@ const runInit = async ({ build, envFile, secretsEnv }) => {
|
|
|
7136
7136
|
let credential;
|
|
7137
7137
|
try {
|
|
7138
7138
|
await (0, _hot_updater_cli_tools.fillReleaseLabels)(server);
|
|
7139
|
+
await (0, _hot_updater_cli_tools.backfillInsightsReleaseRefs)(server);
|
|
7139
7140
|
credential = await (0, _hot_updater_cli_tools.provisionClientCredential)(server, {
|
|
7140
7141
|
env: initInputEnv,
|
|
7141
7142
|
name: "Vercel init"
|
package/dist/init/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { createRequire } from "node:module";
|
|
|
2
2
|
import fs from "fs/promises";
|
|
3
3
|
import os from "os";
|
|
4
4
|
import path from "path";
|
|
5
|
-
import { ConfigBuilder, InitError, LegacyInfrastructureError, assembleServer, assertInfrastructureGenerationPayload, confirmInitInputPersistence, createHotUpdaterConfigScaffoldFromBuilder, createMigrator, fillReleaseLabels, getCwd, getHotUpdaterInitInputEnv, getInitProviderEnvVars, getInitProviderTextPromptValues, link, makeEnv, p, printAppSetup, provisionClientCredential, readHotUpdaterInitEnv, resolveInitProviderInputs, shouldAutoSelectOnlyInitResource, writeHotUpdaterFiles } from "@hot-updater/cli-tools";
|
|
5
|
+
import { ConfigBuilder, InitError, LegacyInfrastructureError, assembleServer, assertInfrastructureGenerationPayload, backfillInsightsReleaseRefs, confirmInitInputPersistence, createHotUpdaterConfigScaffoldFromBuilder, createMigrator, fillReleaseLabels, getCwd, getHotUpdaterInitInputEnv, getInitProviderEnvVars, getInitProviderTextPromptValues, link, makeEnv, p, printAppSetup, provisionClientCredential, readHotUpdaterInitEnv, resolveInitProviderInputs, shouldAutoSelectOnlyInitResource, writeHotUpdaterFiles } from "@hot-updater/cli-tools";
|
|
6
6
|
import { postgres } from "@hot-updater/postgres";
|
|
7
7
|
import { apiKeys, insights, remoteConfig } from "@hot-updater/server/plugins";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
@@ -7130,6 +7130,7 @@ const runInit = async ({ build, envFile, secretsEnv }) => {
|
|
|
7130
7130
|
let credential;
|
|
7131
7131
|
try {
|
|
7132
7132
|
await fillReleaseLabels(server);
|
|
7133
|
+
await backfillInsightsReleaseRefs(server);
|
|
7133
7134
|
credential = await provisionClientCredential(server, {
|
|
7134
7135
|
env: initInputEnv,
|
|
7135
7136
|
name: "Vercel init"
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/vercel",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.2.0-rc.
|
|
4
|
+
"version": "1.2.0-rc.59",
|
|
5
5
|
"description": "React Native OTA solution for self-hosted",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"module": "dist/index.mjs",
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
"@vercel/cli-auth": "0.3.10",
|
|
42
42
|
"@vercel/cli-config": "0.3.1",
|
|
43
43
|
"pg": "8.13.1",
|
|
44
|
-
"@hot-updater/
|
|
45
|
-
"@hot-updater/postgres": "1.2.0-rc.
|
|
46
|
-
"@hot-updater/
|
|
47
|
-
"@hot-updater/protocol": "1.2.0-rc.
|
|
48
|
-
"@hot-updater/
|
|
44
|
+
"@hot-updater/plugin-core": "1.2.0-rc.59",
|
|
45
|
+
"@hot-updater/postgres": "1.2.0-rc.59",
|
|
46
|
+
"@hot-updater/cli-tools": "1.2.0-rc.59",
|
|
47
|
+
"@hot-updater/protocol": "1.2.0-rc.59",
|
|
48
|
+
"@hot-updater/server": "1.2.0-rc.59"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/node": "^20",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"execa": "9.5.2",
|
|
55
55
|
"kysely": "0.28.17",
|
|
56
56
|
"vitest": "4.1.4",
|
|
57
|
-
"@hot-updater/test-utils": "1.2.0-rc.
|
|
57
|
+
"@hot-updater/test-utils": "1.2.0-rc.59"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"build": "tsdown",
|