@hot-updater/server 1.0.0-rc.0 → 1.0.0-rc.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rolldown/runtime.cjs +1 -1
- package/dist/adapters/databaseConstraintErrors.cjs +0 -1
- package/dist/adapters/databasePluginUtils.cjs +14 -1
- package/dist/adapters/databasePluginUtils.mjs +14 -2
- package/dist/adapters/drizzle.cjs +9 -4
- package/dist/adapters/drizzle.d.cts +0 -1
- package/dist/adapters/drizzle.d.mts +0 -1
- package/dist/adapters/drizzle.mjs +10 -4
- package/dist/adapters/drizzleCrud.cjs +93 -3
- package/dist/adapters/drizzleCrud.mjs +93 -5
- package/dist/adapters/drizzleLazyDB.cjs +2 -0
- package/dist/adapters/drizzleLazyDB.mjs +2 -0
- package/dist/adapters/drizzleQuery.cjs +3 -2
- package/dist/adapters/drizzleQuery.mjs +3 -1
- package/dist/adapters/kysely.cjs +1 -1
- package/dist/adapters/kysely.d.cts +0 -1
- package/dist/adapters/kysely.d.mts +0 -1
- package/dist/adapters/kysely.mjs +2 -1
- package/dist/adapters/kyselyCrud.cjs +44 -5
- package/dist/adapters/kyselyCrud.mjs +45 -6
- package/dist/adapters/kyselyQuery.cjs +2 -2
- package/dist/adapters/kyselyQuery.mjs +2 -1
- package/dist/adapters/mongodb.cjs +36 -1
- package/dist/adapters/mongodb.d.cts +1 -1
- package/dist/adapters/mongodb.d.mts +1 -1
- package/dist/adapters/mongodb.mjs +36 -0
- package/dist/adapters/mongodbCollections.cjs +2 -0
- package/dist/adapters/mongodbCollections.mjs +2 -0
- package/dist/adapters/mongodbQuery.cjs +17 -4
- package/dist/adapters/mongodbQuery.mjs +17 -4
- package/dist/adapters/mongodbReads.cjs +88 -30
- package/dist/adapters/mongodbReads.mjs +88 -29
- package/dist/adapters/mongodbWrites.cjs +1 -2
- package/dist/adapters/mongodbWrites.mjs +1 -1
- package/dist/adapters/prisma.cjs +44 -7
- package/dist/adapters/prisma.d.cts +0 -1
- package/dist/adapters/prisma.d.mts +0 -1
- package/dist/adapters/prisma.mjs +44 -6
- package/dist/adapters/prismaInsights.cjs +99 -0
- package/dist/adapters/prismaInsights.mjs +97 -0
- package/dist/adapters/prismaQuery.cjs +0 -1
- package/dist/adapters/prismaRows.cjs +7 -8
- package/dist/adapters/prismaRows.mjs +8 -8
- package/dist/apiKeys.cjs +6 -2
- package/dist/apiKeys.d.cts +0 -1
- package/dist/apiKeys.d.mts +0 -1
- package/dist/apiKeys.mjs +3 -3
- package/dist/createHotUpdaterCore.cjs +27 -12
- package/dist/createHotUpdaterCore.d.cts +8 -8
- package/dist/createHotUpdaterCore.d.mts +8 -8
- package/dist/createHotUpdaterCore.mjs +26 -12
- package/dist/db/createBundleDiff.cjs +2 -2
- package/dist/db/createBundleDiff.d.cts +1 -5
- package/dist/db/createBundleDiff.d.mts +1 -5
- package/dist/db/databasePluginCore.cjs +0 -1
- package/dist/db/fixedMigrator.cjs +2 -2
- package/dist/db/fixedMigrator.mjs +2 -2
- package/dist/db/fixedMigratorMongo.cjs +6 -4
- package/dist/db/fixedMigratorMongo.mjs +6 -4
- package/dist/db/index.d.cts +0 -1
- package/dist/db/index.d.mts +0 -1
- package/dist/db/releaseCatalog.cjs +0 -1
- package/dist/db/releaseCatalog.d.cts +0 -1
- package/dist/db/releaseCatalog.d.mts +0 -1
- package/dist/db/schema/insightsCollation.cjs +14 -0
- package/dist/db/schema/insightsCollation.mjs +14 -0
- package/dist/db/schema/sql.cjs +11 -7
- package/dist/db/schema/sql.mjs +8 -8
- package/dist/db/schemaGenerators.cjs +29 -9
- package/dist/db/schemaGenerators.mjs +29 -9
- package/dist/db/schemaReadiness.cjs +2 -0
- package/dist/db/schemaReadiness.d.cts +1 -0
- package/dist/db/schemaReadiness.d.mts +1 -0
- package/dist/db/schemaReadiness.mjs +2 -0
- package/dist/db/sqlMigrationExecution.cjs +1 -1
- package/dist/db/sqlMigrationExecution.mjs +1 -0
- package/dist/db/types.cjs +3 -1
- package/dist/db/types.d.cts +3 -6
- package/dist/db/types.d.mts +3 -6
- package/dist/db/types.mjs +2 -2
- package/dist/db/updateArtifacts.cjs +0 -1
- package/dist/handler.cjs +5 -5
- package/dist/handler.d.cts +1 -2
- package/dist/handler.d.mts +1 -2
- package/dist/handler.mjs +5 -5
- package/dist/handlerReleaseCatalogRoutes.cjs +0 -1
- package/dist/handlerReleaseManagementRoutes.cjs +0 -1
- package/dist/handlerTypes.d.cts +0 -1
- package/dist/handlerTypes.d.mts +0 -1
- package/dist/handlerVersionRoutes.d.cts +1 -0
- package/dist/handlerVersionRoutes.d.mts +1 -0
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +4 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +2 -2
- package/dist/insights/domain.d.cts +92 -0
- package/dist/insights/domain.d.mts +92 -0
- package/dist/insights/errors.cjs +15 -0
- package/dist/insights/errors.mjs +14 -0
- package/dist/{analytics → insights}/eventInput.cjs +61 -16
- package/dist/{analytics → insights}/eventInput.mjs +61 -18
- package/dist/insights/provider.cjs +332 -0
- package/dist/insights/provider.d.cts +6 -0
- package/dist/insights/provider.d.mts +6 -0
- package/dist/insights/provider.mjs +332 -0
- package/dist/insights/queryInput.cjs +93 -0
- package/dist/insights/queryInput.mjs +91 -0
- package/dist/insights/routes.cjs +58 -0
- package/dist/insights/routes.mjs +56 -0
- package/dist/insights/types.d.cts +32 -0
- package/dist/insights/types.d.mts +32 -0
- package/dist/node.d.cts +0 -1
- package/dist/node.d.mts +0 -1
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/schema/index.cjs +17 -3
- package/dist/schema/index.mjs +4 -4
- package/dist/schema/v1_0_0.cjs +64 -35
- package/dist/schema/v1_0_0.mjs +64 -36
- package/dist/storageAccess.cjs +0 -1
- package/dist/types/index.d.cts +0 -1
- package/dist/types/index.d.mts +0 -1
- package/package.json +7 -7
- package/src/adapters/databasePluginTestDatabase.ts +15 -5
- package/src/adapters/databasePluginUtils.ts +24 -0
- package/src/adapters/drizzle.spec.ts +203 -5
- package/src/adapters/drizzle.ts +16 -4
- package/src/adapters/drizzleCrud.ts +200 -9
- package/src/adapters/drizzleLazyDB.ts +33 -6
- package/src/adapters/kysely.spec.ts +62 -0
- package/src/adapters/kysely.ts +7 -1
- package/src/adapters/kyselyCrud.ts +115 -7
- package/src/adapters/kyselyInsights.spec.ts +168 -0
- package/src/adapters/mongodb.integration.spec.ts +483 -0
- package/src/adapters/mongodb.spec.ts +89 -0
- package/src/adapters/mongodb.ts +59 -1
- package/src/adapters/mongodbCollections.ts +16 -0
- package/src/adapters/mongodbQuery.ts +22 -3
- package/src/adapters/mongodbReads.ts +78 -2
- package/src/adapters/mongodbTestClient.ts +107 -6
- package/src/adapters/mongodbTestFilter.ts +5 -1
- package/src/adapters/mongodbWrites.ts +1 -0
- package/src/adapters/prisma.spec.ts +270 -0
- package/src/adapters/prisma.ts +75 -2
- package/src/adapters/prismaInsights.ts +190 -0
- package/src/adapters/prismaRows.ts +17 -10
- package/src/adapters/prismaTestClient.ts +89 -7
- package/src/apiKeys.integration.spec.ts +3 -3
- package/src/createHotUpdaterCore.ts +30 -16
- package/src/db/databasePluginUpdateCheck.bench.ts +10 -0
- package/src/db/fixedMigrator.spec.ts +63 -0
- package/src/db/fixedMigratorMongo.spec.ts +70 -9
- package/src/db/fixedMigratorMongo.ts +10 -10
- package/src/db/index.spec.ts +6 -1
- package/src/db/schema/insightsCollation.ts +21 -0
- package/src/db/schema/sql.ts +8 -5
- package/src/db/schemaGenerators.ts +42 -13
- package/src/db/types.spec.ts +11 -3
- package/src/db/types.ts +13 -7
- package/src/handler-standalone.integration.spec.ts +6 -8
- package/src/handler.ts +12 -12
- package/src/index.ts +3 -3
- package/src/insights/domain.ts +106 -0
- package/src/insights/errors.ts +11 -0
- package/src/{analytics → insights}/eventInput.ts +66 -16
- package/src/insights/insights.integration.spec.ts +475 -0
- package/src/insights/provider.spec.ts +396 -0
- package/src/insights/provider.ts +611 -0
- package/src/insights/queryInput.ts +142 -0
- package/src/insights/routes.ts +104 -0
- package/src/insights/types.ts +55 -0
- package/src/schema/dsl-all-versions.spec.ts +1 -1
- package/src/schema/v1_0_0.spec.ts +77 -3
- package/src/schema/v1_0_0.ts +83 -37
- package/dist/analytics/bounded/activeOverview.cjs +0 -87
- package/dist/analytics/bounded/activeOverview.mjs +0 -85
- package/dist/analytics/bounded/installationSearch.cjs +0 -42
- package/dist/analytics/bounded/installationSearch.mjs +0 -42
- package/dist/analytics/bounded/persistence.cjs +0 -39
- package/dist/analytics/bounded/persistence.mjs +0 -38
- package/dist/analytics/bounded/provider.cjs +0 -170
- package/dist/analytics/bounded/provider.d.cts +0 -7
- package/dist/analytics/bounded/provider.d.mts +0 -7
- package/dist/analytics/bounded/provider.mjs +0 -170
- package/dist/analytics/bounded/scan.cjs +0 -144
- package/dist/analytics/bounded/scan.mjs +0 -138
- package/dist/analytics/domain.d.cts +0 -121
- package/dist/analytics/domain.d.mts +0 -121
- package/dist/analytics/errors.cjs +0 -22
- package/dist/analytics/errors.mjs +0 -20
- package/dist/analytics/persistence.d.cts +0 -6
- package/dist/analytics/persistence.d.mts +0 -6
- package/dist/analytics/queryInput.cjs +0 -58
- package/dist/analytics/queryInput.mjs +0 -55
- package/dist/analytics/routes.cjs +0 -63
- package/dist/analytics/routes.mjs +0 -61
- package/dist/analytics/types.d.cts +0 -17
- package/dist/analytics/types.d.mts +0 -17
- package/src/analytics/analytics.integration.spec.ts +0 -144
- package/src/analytics/bounded/activeOverview.spec.ts +0 -189
- package/src/analytics/bounded/activeOverview.ts +0 -148
- package/src/analytics/bounded/installationSearch.spec.ts +0 -130
- package/src/analytics/bounded/installationSearch.ts +0 -69
- package/src/analytics/bounded/persistence.ts +0 -43
- package/src/analytics/bounded/provider.spec.ts +0 -219
- package/src/analytics/bounded/provider.ts +0 -229
- package/src/analytics/bounded/scan.ts +0 -235
- package/src/analytics/domain.ts +0 -139
- package/src/analytics/errors.ts +0 -18
- package/src/analytics/persistence.ts +0 -10
- package/src/analytics/queryInput.ts +0 -102
- package/src/analytics/routes.ts +0 -123
- package/src/analytics/types.ts +0 -44
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ActiveInstallationWindow,
|
|
3
|
+
InsightsBundleSelection,
|
|
4
|
+
InsightsScope,
|
|
5
|
+
} from "./domain";
|
|
6
|
+
import { InsightsBadRequestError } from "./errors";
|
|
7
|
+
import type {
|
|
8
|
+
InsightsEventPageInput,
|
|
9
|
+
InsightsUserInstallationPageInput,
|
|
10
|
+
} from "./types";
|
|
11
|
+
|
|
12
|
+
const MAX_PAGE_LIMIT = 100;
|
|
13
|
+
const MAX_IDENTITY_LENGTH = 255;
|
|
14
|
+
const MAX_CURSOR_LENGTH = 8 * 1_024;
|
|
15
|
+
|
|
16
|
+
const readSingle = (url: URL, key: string): string | undefined => {
|
|
17
|
+
const values = url.searchParams.getAll(key);
|
|
18
|
+
if (values.length > 1) {
|
|
19
|
+
throw new InsightsBadRequestError(`Duplicate '${key}' query parameter.`);
|
|
20
|
+
}
|
|
21
|
+
return values[0];
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const readPageLimit = (url: URL): number | undefined => {
|
|
25
|
+
const value = readSingle(url, "limit");
|
|
26
|
+
if (value === undefined) return undefined;
|
|
27
|
+
const limit = Number(value);
|
|
28
|
+
if (!Number.isSafeInteger(limit) || limit < 1 || limit > MAX_PAGE_LIMIT) {
|
|
29
|
+
throw new InsightsBadRequestError("Invalid 'limit' query parameter.");
|
|
30
|
+
}
|
|
31
|
+
return limit;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const readCursor = (url: URL): string | undefined => {
|
|
35
|
+
const cursor = readSingle(url, "cursor");
|
|
36
|
+
if (
|
|
37
|
+
cursor !== undefined &&
|
|
38
|
+
(cursor.length === 0 || cursor.length > MAX_CURSOR_LENGTH)
|
|
39
|
+
) {
|
|
40
|
+
throw new InsightsBadRequestError("Invalid 'cursor' query parameter.");
|
|
41
|
+
}
|
|
42
|
+
return cursor;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const readId = (
|
|
46
|
+
url: URL,
|
|
47
|
+
key: string,
|
|
48
|
+
maximumLength = MAX_IDENTITY_LENGTH,
|
|
49
|
+
): string => {
|
|
50
|
+
const value = readSingle(url, key);
|
|
51
|
+
if (
|
|
52
|
+
value === undefined ||
|
|
53
|
+
value.length === 0 ||
|
|
54
|
+
value.length > maximumLength
|
|
55
|
+
) {
|
|
56
|
+
throw new InsightsBadRequestError(`Invalid '${key}' query parameter.`);
|
|
57
|
+
}
|
|
58
|
+
return value;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const readTimestamp = (url: URL, key: string): number | undefined => {
|
|
62
|
+
const raw = readSingle(url, key);
|
|
63
|
+
if (raw === undefined) return undefined;
|
|
64
|
+
const value = Number(raw);
|
|
65
|
+
if (!raw.length || !Number.isSafeInteger(value) || value < 0) {
|
|
66
|
+
throw new InsightsBadRequestError(`Invalid '${key}' query parameter.`);
|
|
67
|
+
}
|
|
68
|
+
return value;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const readScope = (url: URL): InsightsScope => {
|
|
72
|
+
const platform = readSingle(url, "platform");
|
|
73
|
+
if (platform !== "ios" && platform !== "android") {
|
|
74
|
+
throw new InsightsBadRequestError("Invalid 'platform' query parameter.");
|
|
75
|
+
}
|
|
76
|
+
return { platform, channel: readId(url, "channel", 1_024) };
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const parseEventPageInput = (
|
|
80
|
+
request: Request,
|
|
81
|
+
): InsightsEventPageInput => {
|
|
82
|
+
const url = new URL(request.url);
|
|
83
|
+
const bundleFields = ["bundleId", "outcome", "platform", "channel"];
|
|
84
|
+
let bundle: InsightsBundleSelection | undefined;
|
|
85
|
+
if (bundleFields.some((key) => url.searchParams.has(key))) {
|
|
86
|
+
const outcome = readSingle(url, "outcome");
|
|
87
|
+
if (
|
|
88
|
+
outcome !== "downloaded" &&
|
|
89
|
+
outcome !== "applied" &&
|
|
90
|
+
outcome !== "recovered" &&
|
|
91
|
+
outcome !== "unchanged"
|
|
92
|
+
) {
|
|
93
|
+
throw new InsightsBadRequestError("Invalid 'outcome' query parameter.");
|
|
94
|
+
}
|
|
95
|
+
bundle = {
|
|
96
|
+
...readScope(url),
|
|
97
|
+
bundleId: readId(url, "bundleId", 1_024),
|
|
98
|
+
outcome,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
beforeReceivedAtMs: readTimestamp(url, "beforeReceivedAtMs"),
|
|
103
|
+
sinceMs: readTimestamp(url, "sinceMs"),
|
|
104
|
+
cursor: readCursor(url),
|
|
105
|
+
limit: readPageLimit(url),
|
|
106
|
+
...(bundle === undefined ? {} : { bundle }),
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export const parseUserInstallationPageInput = (
|
|
111
|
+
request: Request,
|
|
112
|
+
): InsightsUserInstallationPageInput => {
|
|
113
|
+
const url = new URL(request.url);
|
|
114
|
+
const cursor = readCursor(url);
|
|
115
|
+
const limit = readPageLimit(url);
|
|
116
|
+
return {
|
|
117
|
+
userId: readId(url, "userId"),
|
|
118
|
+
...(cursor === undefined ? {} : { cursor }),
|
|
119
|
+
...(limit === undefined ? {} : { limit }),
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export const parseReportingOverviewInput = (
|
|
124
|
+
request: Request,
|
|
125
|
+
): InsightsScope & {
|
|
126
|
+
readonly window: ActiveInstallationWindow;
|
|
127
|
+
readonly bundleId?: string;
|
|
128
|
+
} => {
|
|
129
|
+
const url = new URL(request.url);
|
|
130
|
+
const window = readSingle(url, "window") ?? "30d";
|
|
131
|
+
if (window !== "24h" && window !== "7d" && window !== "30d") {
|
|
132
|
+
throw new InsightsBadRequestError("Invalid 'window' query parameter.");
|
|
133
|
+
}
|
|
134
|
+
const bundleId = readSingle(url, "bundleId");
|
|
135
|
+
return {
|
|
136
|
+
...readScope(url),
|
|
137
|
+
window,
|
|
138
|
+
...(bundleId === undefined
|
|
139
|
+
? {}
|
|
140
|
+
: { bundleId: readId(url, "bundleId", 1_024) }),
|
|
141
|
+
};
|
|
142
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { RouteHandler } from "../handlerTypes";
|
|
2
|
+
import {
|
|
3
|
+
InsightsBadRequestError,
|
|
4
|
+
InsightsPayloadTooLargeError,
|
|
5
|
+
} from "./errors";
|
|
6
|
+
import { parseBundleEventRequest } from "./eventInput";
|
|
7
|
+
import {
|
|
8
|
+
parseReportingOverviewInput,
|
|
9
|
+
parseEventPageInput,
|
|
10
|
+
parseUserInstallationPageInput,
|
|
11
|
+
} from "./queryInput";
|
|
12
|
+
import type { InsightsProvider } from "./types";
|
|
13
|
+
|
|
14
|
+
const json = (body: unknown, status: number): Response =>
|
|
15
|
+
Response.json(body, {
|
|
16
|
+
headers: { "cache-control": "private, no-store" },
|
|
17
|
+
status,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const requireParam = (
|
|
21
|
+
params: Readonly<Record<string, string>>,
|
|
22
|
+
key: string,
|
|
23
|
+
): string => {
|
|
24
|
+
const value = params[key];
|
|
25
|
+
if (value === undefined || value.length === 0) {
|
|
26
|
+
throw new InsightsBadRequestError(`Missing route parameter: ${key}`);
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
return decodeURIComponent(value);
|
|
30
|
+
} catch {
|
|
31
|
+
throw new InsightsBadRequestError(`Invalid route parameter: ${key}`);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const run = async (operation: () => Promise<Response>): Promise<Response> => {
|
|
36
|
+
try {
|
|
37
|
+
return await operation();
|
|
38
|
+
} catch (error) {
|
|
39
|
+
if (error instanceof InsightsBadRequestError) {
|
|
40
|
+
return json({ error: error.message }, 400);
|
|
41
|
+
}
|
|
42
|
+
if (error instanceof InsightsPayloadTooLargeError) {
|
|
43
|
+
return json({ error: error.message }, 413);
|
|
44
|
+
}
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const query = (operation: () => Promise<unknown>): Promise<Response> =>
|
|
50
|
+
run(async () => json(await operation(), 200));
|
|
51
|
+
|
|
52
|
+
export const createInsightsRouteHandlers = (
|
|
53
|
+
provider: InsightsProvider,
|
|
54
|
+
): Record<string, RouteHandler> => ({
|
|
55
|
+
appendBundleEvent: async (_params, request) =>
|
|
56
|
+
run(async () => {
|
|
57
|
+
await provider.appendBundleEvent(await parseBundleEventRequest(request));
|
|
58
|
+
return new Response(null, { status: 204 });
|
|
59
|
+
}),
|
|
60
|
+
getReportingOverview: (_params, request) =>
|
|
61
|
+
query(() =>
|
|
62
|
+
provider.getReportingOverview(parseReportingOverviewInput(request)),
|
|
63
|
+
),
|
|
64
|
+
getInstallation: (params) =>
|
|
65
|
+
run(async () => {
|
|
66
|
+
const installation = await provider.getInstallation({
|
|
67
|
+
installId: requireParam(params, "installId"),
|
|
68
|
+
});
|
|
69
|
+
return installation === null
|
|
70
|
+
? json({ error: "Installation not found" }, 404)
|
|
71
|
+
: json(installation, 200);
|
|
72
|
+
}),
|
|
73
|
+
listEvents: (_params, request) =>
|
|
74
|
+
query(() => provider.listEvents(parseEventPageInput(request))),
|
|
75
|
+
listInstallationEvents: (params, request) =>
|
|
76
|
+
query(() =>
|
|
77
|
+
provider.listInstallationEvents({
|
|
78
|
+
...parseEventPageInput(request),
|
|
79
|
+
installId: requireParam(params, "installId"),
|
|
80
|
+
}),
|
|
81
|
+
),
|
|
82
|
+
pageInstallationsByCurrentUserId: (_params, request) =>
|
|
83
|
+
query(() =>
|
|
84
|
+
provider.pageInstallationsByCurrentUserId(
|
|
85
|
+
parseUserInstallationPageInput(request),
|
|
86
|
+
),
|
|
87
|
+
),
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
export const registerInsightsClientRoutes = (
|
|
91
|
+
add: (method: string, path: string, handler: string) => void,
|
|
92
|
+
): void => {
|
|
93
|
+
add("POST", "/events", "appendBundleEvent");
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export const registerInsightsAdminRoutes = (
|
|
97
|
+
add: (method: string, path: string, handler: string) => void,
|
|
98
|
+
): void => {
|
|
99
|
+
add("GET", "/events", "listEvents");
|
|
100
|
+
add("GET", "/overview", "getReportingOverview");
|
|
101
|
+
add("GET", "/installations", "pageInstallationsByCurrentUserId");
|
|
102
|
+
add("GET", "/installations/:installId/events", "listInstallationEvents");
|
|
103
|
+
add("GET", "/installations/:installId", "getInstallation");
|
|
104
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ReportingOverview,
|
|
3
|
+
InsightsBundleSelection,
|
|
4
|
+
InsightsScope,
|
|
5
|
+
ActiveInstallationWindow,
|
|
6
|
+
CreateBundleEventRequest,
|
|
7
|
+
CursorPage,
|
|
8
|
+
EventCursorPage,
|
|
9
|
+
EventHistoryRow,
|
|
10
|
+
InstallationHistoryRow,
|
|
11
|
+
InstallationRow,
|
|
12
|
+
} from "./domain";
|
|
13
|
+
|
|
14
|
+
export type InsightsEventPageInput = {
|
|
15
|
+
readonly beforeReceivedAtMs?: number;
|
|
16
|
+
readonly sinceMs?: number;
|
|
17
|
+
readonly bundle?: InsightsBundleSelection;
|
|
18
|
+
readonly cursor?: string;
|
|
19
|
+
readonly limit?: number;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type InsightsInstallationEventPageInput = Omit<
|
|
23
|
+
InsightsEventPageInput,
|
|
24
|
+
"bundle"
|
|
25
|
+
> & {
|
|
26
|
+
readonly installId: string;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type InsightsUserInstallationPageInput = {
|
|
30
|
+
readonly userId: string;
|
|
31
|
+
readonly cursor?: string;
|
|
32
|
+
readonly limit?: number;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type InsightsProvider = {
|
|
36
|
+
appendBundleEvent(input: CreateBundleEventRequest): Promise<void>;
|
|
37
|
+
listEvents(
|
|
38
|
+
input: InsightsEventPageInput,
|
|
39
|
+
): Promise<EventCursorPage<EventHistoryRow>>;
|
|
40
|
+
listInstallationEvents(
|
|
41
|
+
input: InsightsInstallationEventPageInput,
|
|
42
|
+
): Promise<EventCursorPage<InstallationHistoryRow>>;
|
|
43
|
+
getInstallation(input: {
|
|
44
|
+
readonly installId: string;
|
|
45
|
+
}): Promise<InstallationRow | null>;
|
|
46
|
+
pageInstallationsByCurrentUserId(
|
|
47
|
+
input: InsightsUserInstallationPageInput,
|
|
48
|
+
): Promise<CursorPage<InstallationRow>>;
|
|
49
|
+
getReportingOverview(
|
|
50
|
+
input: InsightsScope & {
|
|
51
|
+
readonly window: ActiveInstallationWindow;
|
|
52
|
+
readonly bundleId?: string;
|
|
53
|
+
},
|
|
54
|
+
): Promise<ReportingOverview>;
|
|
55
|
+
};
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
generatePrismaSchema,
|
|
7
7
|
} from "../db/schemaGenerators";
|
|
8
8
|
import {
|
|
9
|
+
bundleEventHeadsV100,
|
|
9
10
|
bundleEventsV100,
|
|
10
11
|
bundlePatchesV100,
|
|
11
12
|
bundlesV100,
|
|
@@ -57,7 +58,7 @@ describe("v1.0.0 Release Catalog schema", () => {
|
|
|
57
58
|
const patchSize = bundlePatchesV100.columns.find(
|
|
58
59
|
({ ormName }) => ormName === "byte_size",
|
|
59
60
|
);
|
|
60
|
-
const sql = createTableSql("postgresql").join("\n");
|
|
61
|
+
const sql = createTableSql("postgresql", "foreign-keys", v1_0_0).join("\n");
|
|
61
62
|
const prisma = generatePrismaSchema("postgresql", v1_0_0);
|
|
62
63
|
const drizzle = generateDrizzleSchema("postgresql", v1_0_0);
|
|
63
64
|
|
|
@@ -96,6 +97,79 @@ describe("v1.0.0 Release Catalog schema", () => {
|
|
|
96
97
|
).toBeUndefined();
|
|
97
98
|
});
|
|
98
99
|
|
|
100
|
+
it("stores canonical payloads once and indexes only latest-event access fields", () => {
|
|
101
|
+
const sql = createTableSql("postgresql", "foreign-keys", v1_0_0).join("\n");
|
|
102
|
+
expect(sql).toContain("metadata json not null");
|
|
103
|
+
expect(sql).toContain(
|
|
104
|
+
"bundle_events_latest_idx on bundle_events(install_id, received_at_ms, id)",
|
|
105
|
+
);
|
|
106
|
+
expect(sql).toContain(
|
|
107
|
+
"bundle_event_heads_user_idx on bundle_event_heads(user_id, install_id)",
|
|
108
|
+
);
|
|
109
|
+
expect(sql).toContain(
|
|
110
|
+
"bundle_event_heads_scope_idx on bundle_event_heads(platform, channel, received_at_ms)",
|
|
111
|
+
);
|
|
112
|
+
expect(sql).not.toContain("bundle_events_user_idx");
|
|
113
|
+
expect(bundleEventHeadsV100.columns.map(({ ormName }) => ormName)).toEqual([
|
|
114
|
+
"install_id",
|
|
115
|
+
"id",
|
|
116
|
+
"received_at_ms",
|
|
117
|
+
"user_id",
|
|
118
|
+
"platform",
|
|
119
|
+
"channel",
|
|
120
|
+
"type",
|
|
121
|
+
"from_bundle_id",
|
|
122
|
+
"to_bundle_id",
|
|
123
|
+
]);
|
|
124
|
+
for (const generated of [
|
|
125
|
+
sql,
|
|
126
|
+
generatePrismaSchema("postgresql", v1_0_0),
|
|
127
|
+
generateDrizzleSchema("postgresql", v1_0_0),
|
|
128
|
+
])
|
|
129
|
+
expect(generated).not.toContain("bundle_installations");
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it("keeps identity indexes valid on MySQL and MSSQL", () => {
|
|
133
|
+
const mysql = createTableSql("mysql", "foreign-keys", v1_0_0).join("\n");
|
|
134
|
+
const mssql = createTableSql("mssql", "foreign-keys", v1_0_0).join("\n");
|
|
135
|
+
|
|
136
|
+
expect(mysql).toContain(
|
|
137
|
+
"install_id varchar(255) character set utf8mb4 collate utf8mb4_0900_bin not null",
|
|
138
|
+
);
|
|
139
|
+
expect(mysql).toContain("user_id varchar(255)");
|
|
140
|
+
expect(mssql).toContain("install_id nvarchar(255) not null");
|
|
141
|
+
expect(mssql).toContain("user_id nvarchar(255)");
|
|
142
|
+
|
|
143
|
+
for (const sql of [mysql, mssql]) {
|
|
144
|
+
expect(sql).toContain(
|
|
145
|
+
"create index bundle_events_install_idx on bundle_events(install_id, type, received_at_ms, id)",
|
|
146
|
+
);
|
|
147
|
+
expect(sql).toContain(
|
|
148
|
+
"create index bundle_event_heads_user_idx on bundle_event_heads(user_id, install_id)",
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
expect(mssql).not.toContain("install_id nvarchar(max)");
|
|
152
|
+
expect(mssql).not.toContain("user_id nvarchar(max)");
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it("keeps generated Cockroach event and head UUIDs compatible with native queries", () => {
|
|
156
|
+
const prisma = generatePrismaSchema("cockroachdb", v1_0_0);
|
|
157
|
+
const sql = createTableSql("cockroachdb", "foreign-keys", v1_0_0).join(
|
|
158
|
+
"\n",
|
|
159
|
+
);
|
|
160
|
+
for (const table of [bundleEventsV100, bundleEventHeadsV100]) {
|
|
161
|
+
const model = prisma.split(`model ${table.ormName} {`)[1]!.split("}")[0]!;
|
|
162
|
+
for (const column of table.columns.filter(
|
|
163
|
+
({ type }) => type === "uuid",
|
|
164
|
+
)) {
|
|
165
|
+
expect(model).toContain(
|
|
166
|
+
`${column.ormName} String${column.nullable ? "?" : ""} @db.Uuid`,
|
|
167
|
+
);
|
|
168
|
+
expect(sql).toContain(`${column.ormName} uuid`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
99
173
|
it("generates nullable source and artifact relations with the intended deletion rules", () => {
|
|
100
174
|
const prisma = generatePrismaSchema("postgresql", v1_0_0);
|
|
101
175
|
const drizzle = generateDrizzleSchema("postgresql", v1_0_0);
|
|
@@ -111,7 +185,7 @@ describe("v1.0.0 Release Catalog schema", () => {
|
|
|
111
185
|
});
|
|
112
186
|
|
|
113
187
|
it("creates both projection tables and their constraints from empty", () => {
|
|
114
|
-
const sql = createTableSql("postgresql").join("\n");
|
|
188
|
+
const sql = createTableSql("postgresql", "foreign-keys", v1_0_0).join("\n");
|
|
115
189
|
|
|
116
190
|
expect(sql).toContain("create table releases");
|
|
117
191
|
expect(sql).toContain("create table release_catalogs");
|
|
@@ -124,7 +198,7 @@ describe("v1.0.0 Release Catalog schema", () => {
|
|
|
124
198
|
});
|
|
125
199
|
|
|
126
200
|
it("uses byte-bounded MySQL catalog keys", () => {
|
|
127
|
-
const sql = createTableSql("mysql").join("\n");
|
|
201
|
+
const sql = createTableSql("mysql", "foreign-keys", v1_0_0).join("\n");
|
|
128
202
|
|
|
129
203
|
expect(sql).toContain(
|
|
130
204
|
"scope_key varchar(2048) character set ascii collate ascii_bin",
|
package/src/schema/v1_0_0.ts
CHANGED
|
@@ -366,67 +366,72 @@ export const releaseCatalogsV100 = table(
|
|
|
366
366
|
},
|
|
367
367
|
);
|
|
368
368
|
|
|
369
|
+
const insightsTextCollations = {
|
|
370
|
+
postgresql: '"C"',
|
|
371
|
+
mysql: "utf8mb4_0900_bin",
|
|
372
|
+
} as const;
|
|
373
|
+
const insightsProviders = [
|
|
374
|
+
"postgresql",
|
|
375
|
+
"mysql",
|
|
376
|
+
"sqlite",
|
|
377
|
+
"cockroachdb",
|
|
378
|
+
"mongodb",
|
|
379
|
+
] as const;
|
|
380
|
+
|
|
369
381
|
export const bundleEventsV100 = table(
|
|
370
382
|
"bundle_events",
|
|
371
383
|
{
|
|
372
384
|
id: idColumn("id", "uuid"),
|
|
373
|
-
type:
|
|
374
|
-
install_id:
|
|
375
|
-
|
|
376
|
-
|
|
385
|
+
type: column("type", varchar(32)),
|
|
386
|
+
install_id: column("install_id", varchar(255)).collate(
|
|
387
|
+
insightsTextCollations,
|
|
388
|
+
),
|
|
389
|
+
user_id: column("user_id", varchar(255))
|
|
390
|
+
.collate(insightsTextCollations)
|
|
391
|
+
.nullable(),
|
|
377
392
|
from_release_id: uuid("from_release_id").nullable(),
|
|
378
393
|
from_bundle_id: uuid("from_bundle_id").nullable(),
|
|
379
394
|
to_release_id: uuid("to_release_id").nullable(),
|
|
380
395
|
to_bundle_id: uuid("to_bundle_id"),
|
|
381
|
-
platform: stringColumn("platform"),
|
|
396
|
+
platform: stringColumn("platform").collate(insightsTextCollations),
|
|
382
397
|
app_version: stringColumn("app_version"),
|
|
383
|
-
channel: stringColumn("channel"),
|
|
384
|
-
|
|
385
|
-
update_strategy: stringColumn("update_strategy").nullable(),
|
|
386
|
-
fingerprint_hash: stringColumn("fingerprint_hash").nullable(),
|
|
387
|
-
sdk_version: stringColumn("sdk_version").nullable(),
|
|
398
|
+
channel: stringColumn("channel").collate(insightsTextCollations),
|
|
399
|
+
metadata: json("metadata"),
|
|
388
400
|
received_at_ms: float("received_at_ms"),
|
|
389
401
|
},
|
|
390
402
|
{
|
|
391
403
|
indexes: [
|
|
392
404
|
index("bundle_events_received_at_idx", ["received_at_ms", "id"]),
|
|
405
|
+
index("bundle_events_latest_idx", ["install_id", "received_at_ms", "id"]),
|
|
393
406
|
index("bundle_events_install_idx", [
|
|
394
407
|
"install_id",
|
|
395
|
-
"received_at_ms",
|
|
396
|
-
"id",
|
|
397
|
-
]),
|
|
398
|
-
index("bundle_events_user_id_idx", ["user_id", "received_at_ms", "id"]),
|
|
399
|
-
index("bundle_events_username_idx", ["username", "received_at_ms", "id"]),
|
|
400
|
-
index("bundle_events_to_bundle_idx", [
|
|
401
408
|
"type",
|
|
402
|
-
"to_bundle_id",
|
|
403
|
-
"received_at_ms",
|
|
404
|
-
"id",
|
|
405
|
-
]),
|
|
406
|
-
index("bundle_events_from_bundle_idx", [
|
|
407
|
-
"type",
|
|
408
|
-
"from_bundle_id",
|
|
409
|
-
"received_at_ms",
|
|
410
|
-
"id",
|
|
411
|
-
]),
|
|
412
|
-
index("bundle_events_to_release_idx", [
|
|
413
|
-
"type",
|
|
414
|
-
"to_release_id",
|
|
415
|
-
"received_at_ms",
|
|
416
|
-
"id",
|
|
417
|
-
]),
|
|
418
|
-
index("bundle_events_from_release_idx", [
|
|
419
|
-
"type",
|
|
420
|
-
"from_release_id",
|
|
421
409
|
"received_at_ms",
|
|
422
410
|
"id",
|
|
423
411
|
]),
|
|
412
|
+
index(
|
|
413
|
+
"bundle_events_from_bundle_idx",
|
|
414
|
+
[
|
|
415
|
+
"type",
|
|
416
|
+
"platform",
|
|
417
|
+
"channel",
|
|
418
|
+
"from_bundle_id",
|
|
419
|
+
"received_at_ms",
|
|
420
|
+
"id",
|
|
421
|
+
],
|
|
422
|
+
insightsProviders,
|
|
423
|
+
),
|
|
424
|
+
index(
|
|
425
|
+
"bundle_events_to_bundle_idx",
|
|
426
|
+
["type", "platform", "channel", "to_bundle_id", "received_at_ms", "id"],
|
|
427
|
+
insightsProviders,
|
|
428
|
+
),
|
|
424
429
|
],
|
|
425
430
|
checks: [
|
|
426
431
|
check({
|
|
427
432
|
name: "bundle_events_type_check",
|
|
428
433
|
expression:
|
|
429
|
-
"type in ('
|
|
434
|
+
"type in ('UPDATE_DOWNLOADED', 'UPDATE_APPLIED', 'RECOVERED', 'UNCHANGED')",
|
|
430
435
|
sqliteInline: true,
|
|
431
436
|
}),
|
|
432
437
|
check({
|
|
@@ -437,7 +442,7 @@ export const bundleEventsV100 = table(
|
|
|
437
442
|
check({
|
|
438
443
|
name: "bundle_events_shape_check",
|
|
439
444
|
expression:
|
|
440
|
-
"((type in ('
|
|
445
|
+
"((type in ('UPDATE_DOWNLOADED', 'UPDATE_APPLIED', 'RECOVERED')) and from_bundle_id is not null) or (type = 'UNCHANGED' and from_bundle_id is null)",
|
|
441
446
|
sqliteInline: true,
|
|
442
447
|
}),
|
|
443
448
|
check({
|
|
@@ -449,6 +454,46 @@ export const bundleEventsV100 = table(
|
|
|
449
454
|
},
|
|
450
455
|
);
|
|
451
456
|
|
|
457
|
+
// Private access index: full event payloads remain in bundle_events.
|
|
458
|
+
export const bundleEventHeadsV100 = table(
|
|
459
|
+
"bundle_event_heads",
|
|
460
|
+
{
|
|
461
|
+
install_id: idColumn("install_id", varchar(255)).collate(
|
|
462
|
+
insightsTextCollations,
|
|
463
|
+
),
|
|
464
|
+
id: uuid("id"),
|
|
465
|
+
received_at_ms: float("received_at_ms"),
|
|
466
|
+
user_id: column("user_id", varchar(255))
|
|
467
|
+
.collate(insightsTextCollations)
|
|
468
|
+
.nullable(),
|
|
469
|
+
platform: stringColumn("platform").collate(insightsTextCollations),
|
|
470
|
+
channel: stringColumn("channel").collate(insightsTextCollations),
|
|
471
|
+
type: column("type", varchar(32)),
|
|
472
|
+
from_bundle_id: uuid("from_bundle_id").nullable(),
|
|
473
|
+
to_bundle_id: uuid("to_bundle_id"),
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
indexes: [
|
|
477
|
+
index("bundle_event_heads_user_idx", ["user_id", "install_id"]),
|
|
478
|
+
index(
|
|
479
|
+
"bundle_event_heads_scope_idx",
|
|
480
|
+
["platform", "channel", "received_at_ms"],
|
|
481
|
+
insightsProviders,
|
|
482
|
+
),
|
|
483
|
+
index(
|
|
484
|
+
"bundle_event_heads_from_idx",
|
|
485
|
+
["type", "platform", "channel", "from_bundle_id", "received_at_ms"],
|
|
486
|
+
insightsProviders,
|
|
487
|
+
),
|
|
488
|
+
index(
|
|
489
|
+
"bundle_event_heads_to_idx",
|
|
490
|
+
["type", "platform", "channel", "to_bundle_id", "received_at_ms"],
|
|
491
|
+
insightsProviders,
|
|
492
|
+
),
|
|
493
|
+
],
|
|
494
|
+
},
|
|
495
|
+
);
|
|
496
|
+
|
|
452
497
|
export const v1_0_0 = schema({
|
|
453
498
|
version: "1.0.0",
|
|
454
499
|
settingsTable: HOT_UPDATER_SETTINGS_TABLE,
|
|
@@ -459,6 +504,7 @@ export const v1_0_0 = schema({
|
|
|
459
504
|
releasesV100,
|
|
460
505
|
releaseCatalogsV100,
|
|
461
506
|
bundleEventsV100,
|
|
507
|
+
bundleEventHeadsV100,
|
|
462
508
|
apiKeysV100,
|
|
463
509
|
createSettingsTable("1.0.0"),
|
|
464
510
|
],
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
//#region src/analytics/bounded/activeOverview.ts
|
|
2
|
-
const HOUR_MS = 3600 * 1e3;
|
|
3
|
-
const DAY_MS = 24 * HOUR_MS;
|
|
4
|
-
const ACTIVE_BUNDLE_EVENT_TYPES = [
|
|
5
|
-
"UPDATE_APPLIED",
|
|
6
|
-
"RECOVERED",
|
|
7
|
-
"RELEASE_ADOPTED",
|
|
8
|
-
"UNCHANGED"
|
|
9
|
-
];
|
|
10
|
-
const activeWindowDefinitions = {
|
|
11
|
-
"24h": {
|
|
12
|
-
bucketCount: 24,
|
|
13
|
-
bucketSizeMs: HOUR_MS
|
|
14
|
-
},
|
|
15
|
-
"7d": {
|
|
16
|
-
bucketCount: 7,
|
|
17
|
-
bucketSizeMs: DAY_MS
|
|
18
|
-
},
|
|
19
|
-
"30d": {
|
|
20
|
-
bucketCount: 30,
|
|
21
|
-
bucketSizeMs: DAY_MS
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
function getActiveWindowDefinition(window) {
|
|
25
|
-
return activeWindowDefinitions[window];
|
|
26
|
-
}
|
|
27
|
-
function compareCodePoints(left, right) {
|
|
28
|
-
if (left < right) return -1;
|
|
29
|
-
if (left > right) return 1;
|
|
30
|
-
return 0;
|
|
31
|
-
}
|
|
32
|
-
function isNewer(candidate, current) {
|
|
33
|
-
return candidate.received_at_ms > current.received_at_ms || candidate.received_at_ms === current.received_at_ms && compareCodePoints(candidate.id, current.id) > 0;
|
|
34
|
-
}
|
|
35
|
-
function collectActiveInstallationOverview(request) {
|
|
36
|
-
const definition = getActiveWindowDefinition(request.window);
|
|
37
|
-
const windowStartMs = request.asOfMs - definition.bucketCount * definition.bucketSizeMs;
|
|
38
|
-
const rows = request.rows.filter((row) => row.received_at_ms >= windowStartMs && row.received_at_ms < request.asOfMs);
|
|
39
|
-
const latestByInstall = /* @__PURE__ */ new Map();
|
|
40
|
-
for (const row of rows) {
|
|
41
|
-
const current = latestByInstall.get(row.install_id);
|
|
42
|
-
if (current === void 0 || isNewer(row, current)) latestByInstall.set(row.install_id, row);
|
|
43
|
-
}
|
|
44
|
-
const selectedRows = [...latestByInstall.values()].filter((row) => request.userId === void 0 || row.user_id === request.userId);
|
|
45
|
-
const selectedInstallIds = new Set(selectedRows.map((row) => row.install_id));
|
|
46
|
-
const bundleCounts = /* @__PURE__ */ new Map();
|
|
47
|
-
for (const row of selectedRows) bundleCounts.set(row.to_bundle_id, (bundleCounts.get(row.to_bundle_id) ?? 0) + 1);
|
|
48
|
-
const latestByBucket = Array.from({ length: definition.bucketCount }, () => /* @__PURE__ */ new Map());
|
|
49
|
-
for (const row of rows) {
|
|
50
|
-
if (!selectedInstallIds.has(row.install_id)) continue;
|
|
51
|
-
const bucket = latestByBucket[Math.floor((row.received_at_ms - windowStartMs) / definition.bucketSizeMs)];
|
|
52
|
-
if (bucket === void 0) continue;
|
|
53
|
-
const current = bucket.get(row.install_id);
|
|
54
|
-
if (current === void 0 || isNewer(row, current)) bucket.set(row.install_id, row);
|
|
55
|
-
}
|
|
56
|
-
const bundleCountsByBucket = latestByBucket.map((bucket) => {
|
|
57
|
-
const counts = /* @__PURE__ */ new Map();
|
|
58
|
-
for (const row of bucket.values()) counts.set(row.to_bundle_id, (counts.get(row.to_bundle_id) ?? 0) + 1);
|
|
59
|
-
return counts;
|
|
60
|
-
});
|
|
61
|
-
const bundleObservationTotals = /* @__PURE__ */ new Map();
|
|
62
|
-
for (const counts of bundleCountsByBucket) for (const [bundleId, count] of counts) bundleObservationTotals.set(bundleId, (bundleObservationTotals.get(bundleId) ?? 0) + count);
|
|
63
|
-
return {
|
|
64
|
-
asOfMs: request.asOfMs,
|
|
65
|
-
window: request.window,
|
|
66
|
-
activeInstallations: selectedInstallIds.size,
|
|
67
|
-
series: latestByBucket.map((bucket, index) => ({
|
|
68
|
-
bucketStartMs: windowStartMs + index * definition.bucketSizeMs,
|
|
69
|
-
value: bucket.size
|
|
70
|
-
})),
|
|
71
|
-
bundleSeries: [...bundleObservationTotals].sort(([leftId, leftTotal], [rightId, rightTotal]) => rightTotal - leftTotal || compareCodePoints(leftId, rightId)).map(([bundleId]) => ({
|
|
72
|
-
bundleId,
|
|
73
|
-
series: bundleCountsByBucket.map((counts, index) => ({
|
|
74
|
-
bucketStartMs: windowStartMs + index * definition.bucketSizeMs,
|
|
75
|
-
value: counts.get(bundleId) ?? 0
|
|
76
|
-
}))
|
|
77
|
-
})),
|
|
78
|
-
bundles: [...bundleCounts].map(([bundleId, installations]) => ({
|
|
79
|
-
bundleId,
|
|
80
|
-
installations
|
|
81
|
-
})).sort((left, right) => right.installations - left.installations || compareCodePoints(left.bundleId, right.bundleId))
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
//#endregion
|
|
85
|
-
exports.ACTIVE_BUNDLE_EVENT_TYPES = ACTIVE_BUNDLE_EVENT_TYPES;
|
|
86
|
-
exports.collectActiveInstallationOverview = collectActiveInstallationOverview;
|
|
87
|
-
exports.getActiveWindowDefinition = getActiveWindowDefinition;
|