@hot-updater/plugin-insights 1.2.0-rc.6 → 1.2.0-rc.60

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.
Files changed (39) hide show
  1. package/dist/server/adminReads.cjs +5 -4
  2. package/dist/server/adminReads.mjs +5 -4
  3. package/dist/server/backfill.cjs +117 -0
  4. package/dist/server/backfill.d.cts +9 -0
  5. package/dist/server/backfill.d.mts +9 -0
  6. package/dist/server/backfill.mjs +117 -0
  7. package/dist/server/contract.cjs +18 -14
  8. package/dist/server/contract.mjs +18 -14
  9. package/dist/server/domain.d.cts +20 -2
  10. package/dist/server/domain.d.mts +20 -2
  11. package/dist/server/index.cjs +12 -1
  12. package/dist/server/index.d.cts +24 -2
  13. package/dist/server/index.d.mts +24 -2
  14. package/dist/server/index.mjs +13 -3
  15. package/dist/server/model.cjs +1 -0
  16. package/dist/server/model.mjs +1 -0
  17. package/dist/server/modelTypes.d.cts +32 -13
  18. package/dist/server/modelTypes.d.mts +32 -13
  19. package/dist/server/provider.cjs +24 -35
  20. package/dist/server/provider.mjs +24 -35
  21. package/dist/server/queryInput.cjs +4 -4
  22. package/dist/server/queryInput.mjs +4 -4
  23. package/dist/server/reads.cjs +118 -61
  24. package/dist/server/reads.d.cts +7 -0
  25. package/dist/server/reads.d.mts +7 -0
  26. package/dist/server/reads.mjs +119 -63
  27. package/dist/server/recordEvent.cjs +8 -44
  28. package/dist/server/recordEvent.mjs +10 -44
  29. package/dist/server/routes.cjs +2 -1
  30. package/dist/server/routes.mjs +2 -1
  31. package/dist/server/schema.cjs +30 -9
  32. package/dist/server/schema.mjs +30 -10
  33. package/dist/server/types.d.cts +2 -1
  34. package/dist/server/types.d.mts +2 -1
  35. package/dist/server/wire.cjs +34 -0
  36. package/dist/server/wire.d.cts +13 -0
  37. package/dist/server/wire.d.mts +13 -0
  38. package/dist/server/wire.mjs +32 -0
  39. package/package.json +4 -10
@@ -1,7 +1,7 @@
1
+ import { DAILY_EVENTS, DAY_MS, HOUR_MS, isLaunch, outcomeRefsOf } from "./schema.mjs";
1
2
  import { runningBuiltinBundleId } from "./eventRow.mjs";
2
- import { DAILY_EVENTS, DAY_MS, HOUR_MS, bundleRefOfFilter, bundleRefsOf, isLaunch } from "./schema.mjs";
3
3
  import { assertBundleEventRow } from "./contract.mjs";
4
- import { insightsKey, insightsOverviewDeltas, insightsOverviewId } from "./overview.mjs";
4
+ import { insightsOverviewDeltas, insightsOverviewId } from "./overview.mjs";
5
5
  import { addDistinct, compareUtf8, extractTimestampFromUUIDv7, isUUIDv7 } from "@hot-updater/plugin-core";
6
6
  //#region src/server/recordEvent.ts
7
7
  const hourOf = (ms) => ms - ms % HOUR_MS;
@@ -26,17 +26,10 @@ const gaugeSlot = (head) => ({
26
26
  builtinBundleId: runningBuiltinBundleId(head)
27
27
  });
28
28
  /**
29
- * The `insights_latest_by_bundle` field of a head's (from, to) pair. A head
30
- * matches a `from` and a `to` predicate of one type at once only through its
31
- * pair, so this gauge is what a count subtracts to count it once.
32
- */
33
- const PAIR_FIELD = "from_to";
34
- /** The pair gauge's `bundle_id`: a hash of the two bundle ids, which fit no single 36-character column. */
35
- const bundlePairKey = (from, to) => insightsKey(`${from.length}:${from}${to.length}:${to}`);
36
- /**
37
29
  * Moves a head's gauges: the distribution row, and the built-in one when it
38
- * runs its build's built-in bundle, one row per bundle it references, and
39
- * its pair; -1 takes back the head an event replaces.
30
+ * runs its build's built-in bundle; -1 takes back the head an event
31
+ * replaces. The distribution row names the release the head runs, so it is
32
+ * also each release's installation gauge.
40
33
  */
41
34
  const countHead = (tx, head, delta) => {
42
35
  const { bucket, releaseId, builtinBundleId } = gaugeSlot(head);
@@ -56,26 +49,6 @@ const countHead = (tx, head, delta) => {
56
49
  builtin_bundle_id: builtinBundleId,
57
50
  bucket_start_ms: bucket
58
51
  }, { latest_installations: delta }, { shardBy });
59
- for (const field of ["from_bundle_id", "to_bundle_id"]) {
60
- const bundleId = head[field];
61
- if (bundleId === null) continue;
62
- tx.aggregate("insights_latest_by_bundle", {
63
- platform: head.platform,
64
- channel: head.channel,
65
- bundle_field: field,
66
- bundle_id: bundleId,
67
- type: head.type,
68
- bucket_start_ms: bucket
69
- }, { installations: delta }, { shardBy });
70
- }
71
- if (head.from_bundle_id !== null) tx.aggregate("insights_latest_by_bundle", {
72
- platform: head.platform,
73
- channel: head.channel,
74
- bundle_field: PAIR_FIELD,
75
- bundle_id: bundlePairKey(head.from_bundle_id, head.to_bundle_id),
76
- type: head.type,
77
- bucket_start_ms: bucket
78
- }, { installations: delta }, { shardBy });
79
52
  };
80
53
  /**
81
54
  * Where each period's rows go, each with its retention: hours for 90 days,
@@ -136,26 +109,19 @@ const countEvent = (tx, event) => {
136
109
  }
137
110
  };
138
111
  /**
139
- * A stored event's outcome rows: its bundle filter's hour, when it has one
140
- * (`bundleRefsOf`), and every stored event's UTC day. A download that a
141
- * launch or crash implied counts in its bundle's download hour too, in the
142
- * hour of that launch or crash, so the download series covers what the
143
- * release's downloads count; the launch or crash is its row.
112
+ * A stored event's outcome rows: its bundle filter's hour, and the download
113
+ * hour of a download its launch or crash implied, each by release
114
+ * (`outcomeRefsOf`); and every stored event's UTC day.
144
115
  */
145
116
  const countOutcome = (tx, event) => {
146
117
  const shardBy = event.install_id;
147
- const hour = (type, bundleRef) => tx.aggregate("insights_outcomes", {
118
+ for (const [type, bundleRef] of outcomeRefsOf(event)) tx.aggregate("insights_outcomes", {
148
119
  platform: event.platform,
149
120
  channel: event.channel,
150
121
  type,
151
122
  bundle_ref: bundleRef,
152
123
  bucket_start_ms: hourOf(event.received_at_ms)
153
124
  }, { events: 1 }, { shardBy });
154
- for (const bundleRef of bundleRefsOf(event)) hour(event.type, bundleRef);
155
- if (event.metadata.implied_download === true) hour("UPDATE_DOWNLOADED", bundleRefOfFilter({
156
- type: "UPDATE_DOWNLOADED",
157
- toBundleId: event.type === "RECOVERED" ? event.from_bundle_id : event.to_bundle_id
158
- }));
159
125
  tx.aggregate("insights_outcomes", {
160
126
  ...DAILY_EVENTS,
161
127
  bucket_start_ms: dayOf(event.received_at_ms)
@@ -438,4 +404,4 @@ const recordEvent = (db, event) => {
438
404
  });
439
405
  };
440
406
  //#endregion
441
- export { PAIR_FIELD, bundlePairKey, insightsIdentity, recordEvent };
407
+ export { insightsIdentity, recordEvent };
@@ -1,5 +1,6 @@
1
1
  const require_errors = require("./errors.cjs");
2
2
  const require_eventInput = require("./eventInput.cjs");
3
+ const require_wire = require("./wire.cjs");
3
4
  const require_queryInput = require("./queryInput.cjs");
4
5
  let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
5
6
  //#region src/server/routes.ts
@@ -79,7 +80,7 @@ const createInsightsRouteHandlers = (provider) => ({
79
80
  await provider.appendBundleEvent(await require_eventInput.parseBundleEventRequest(request));
80
81
  return new Response(null, { status: 204 });
81
82
  }),
82
- getReportingOverview: (_params, request) => query(() => provider.getReportingOverview(require_queryInput.parseReportingOverviewInput(request))),
83
+ getReportingOverview: (_params, request) => query(async () => require_wire.toWireOverview(await provider.getReportingOverview(require_queryInput.parseReportingOverviewInput(request)))),
83
84
  getInstallation: (params) => run(async () => {
84
85
  const installation = await provider.getInstallation({ installId: requireParam(params, "installId") });
85
86
  return installation === null ? json({ error: "Installation not found" }, 404) : json(installation, 200);
@@ -1,5 +1,6 @@
1
1
  import { InsightsBadRequestError, InsightsPayloadTooLargeError } from "./errors.mjs";
2
2
  import { parseBundleEventRequest } from "./eventInput.mjs";
3
+ import { toWireOverview } from "./wire.mjs";
3
4
  import { parseEventPageInput, parseReportingOverviewInput, parseUserInstallationPageInput } from "./queryInput.mjs";
4
5
  import { isDatabaseBusyError } from "@hot-updater/plugin-core";
5
6
  //#region src/server/routes.ts
@@ -79,7 +80,7 @@ const createInsightsRouteHandlers = (provider) => ({
79
80
  await provider.appendBundleEvent(await parseBundleEventRequest(request));
80
81
  return new Response(null, { status: 204 });
81
82
  }),
82
- getReportingOverview: (_params, request) => query(() => provider.getReportingOverview(parseReportingOverviewInput(request))),
83
+ getReportingOverview: (_params, request) => query(async () => toWireOverview(await provider.getReportingOverview(parseReportingOverviewInput(request)))),
83
84
  getInstallation: (params) => run(async () => {
84
85
  const installation = await provider.getInstallation({ installId: requireParam(params, "installId") });
85
86
  return installation === null ? json({ error: "Installation not found" }, 404) : json(installation, 200);
@@ -37,21 +37,29 @@ const isLaunch = (row) => {
37
37
  const kinds = metadataOf(row).change?.kinds ?? [];
38
38
  return kinds.includes("bundle") && !kinds.includes("first_seen") && row.to_release_id !== null;
39
39
  };
40
+ const sideRef = (key, releaseId, bundleId) => key === "release" ? releaseId ?? bundleId : bundleId;
40
41
  /**
41
42
  * The bundle a stored row's bundle filter matches: `from:<bundle>` for a
42
43
  * recovery; `to:<bundle>` for a download, an apply, and an update failure;
43
44
  * `on:<bundle>` for an UNCHANGED row that launched a bundle (`isLaunch`), a
44
45
  * key no other row uses. None for a failed check, which targets no bundle, a
45
- * late row, or any other UNCHANGED row.
46
+ * late row, or any other UNCHANGED row. Each names its bundle by `key`.
46
47
  */
47
- const bundleRefsOf = (row) => {
48
+ const bundleRefsOf = (row, key = "release") => {
48
49
  if (isFailedCheck(row) || isLateEvent(row)) return [];
49
- if (row.type === "RECOVERED") return [`from:${row.from_bundle_id}`];
50
- if (row.type === "UNCHANGED") return isLaunch(row) ? [`on:${row.to_bundle_id}`] : [];
51
- return [`to:${row.to_bundle_id}`];
50
+ if (row.type === "RECOVERED") return [`from:${sideRef(key, row.from_release_id, row.from_bundle_id)}`];
51
+ if (row.type === "UNCHANGED") return isLaunch(row) ? [`on:${sideRef(key, row.to_release_id, row.to_bundle_id)}`] : [];
52
+ return [`to:${sideRef(key, row.to_release_id, row.to_bundle_id)}`];
52
53
  };
54
+ /**
55
+ * The hourly outcome rows a stored row counts in, as `[type, bundle ref]`:
56
+ * its bundle filter's (`bundleRefsOf`), and a download that a launch or
57
+ * crash implied, in its bundle's download hour, so the download series
58
+ * covers what the release's downloads count.
59
+ */
60
+ 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)}`]] : []];
53
61
  /** The key a bundle filter reads, as `bundleRefsOf` writes it. */
54
- const bundleRefOfFilter = (filter) => filter.type === "RECOVERED" ? `from:${filter.fromBundleId}` : filter.type === "UNCHANGED" ? `on:${filter.toBundleId}` : `to:${filter.toBundleId}`;
62
+ const bundleRefOfFilter = (filter) => filter.type === "RECOVERED" ? `from:${filter.fromReleaseId}` : filter.type === "UNCHANGED" ? `on:${filter.toReleaseId}` : `to:${filter.toReleaseId}`;
55
63
  /**
56
64
  * Downloads, applies, recoveries, update failures, and the UNCHANGED
57
65
  * reports that changed what their installation runs, whole. An UNCHANGED
@@ -116,7 +124,11 @@ const bundleEvents = (days) => (0, _hot_updater_plugin_core.defineTable)({
116
124
  type: "string",
117
125
  compute: (row) => MOVEMENTS.has(row.type) ? row.install_id : null
118
126
  },
119
- /** The bundle a bundle filter matches (`bundleRefsOf`). */
127
+ /**
128
+ * The bundle a bundle filter matches (`bundleRefsOf`), by release.
129
+ * Rows a 1.1 server wrote name the artifact until
130
+ * `backfillReleaseRefs` rewrites them.
131
+ */
120
132
  bundle_ref: {
121
133
  type: "string",
122
134
  multi: true,
@@ -435,7 +447,13 @@ const insightsBuiltinDistribution = (retention) => (0, _hot_updater_plugin_core.
435
447
  },
436
448
  retention
437
449
  });
438
- /** Latest events by the bundle they came from or went to, bucketed like the distribution. */
450
+ /**
451
+ * Latest events by the artifact they came from or went to, bucketed like
452
+ * the distribution, as 1.1 servers wrote them. Nothing writes or reads it
453
+ * since a bundle's installations come from `insights_distribution`, which
454
+ * names the release; it stays declared so retention still empties the rows
455
+ * a 1.1 server wrote.
456
+ */
439
457
  const insightsLatestByBundle = (retention) => (0, _hot_updater_plugin_core.defineAggregate)({
440
458
  platform: {
441
459
  type: "string",
@@ -483,7 +501,9 @@ const insightsLatestByBundle = (retention) => (0, _hot_updater_plugin_core.defin
483
501
  * Stored events by outcome and the bundle a bundle filter matches, a row an
484
502
  * hour, which a failed check has none of; and every stored event, a row a UTC
485
503
  * day (`DAILY_EVENTS`). Bundle counts sum the hourly rows, and event lists
486
- * read either to skip days without events.
504
+ * read either to skip days without events. `bundle_ref` names the release
505
+ * (`outcomeRefsOf`); a 1.1 server's rows name the artifact until
506
+ * `backfillReleaseRefs` moves their counts.
487
507
  */
488
508
  const insightsOutcomes = (retention) => (0, _hot_updater_plugin_core.defineAggregate)({
489
509
  platform: {
@@ -573,3 +593,4 @@ exports.insightsSchema = insightsSchema;
573
593
  exports.isFailedCheck = isFailedCheck;
574
594
  exports.isLateEvent = isLateEvent;
575
595
  exports.isLaunch = isLaunch;
596
+ exports.outcomeRefsOf = outcomeRefsOf;
@@ -37,21 +37,29 @@ const isLaunch = (row) => {
37
37
  const kinds = metadataOf(row).change?.kinds ?? [];
38
38
  return kinds.includes("bundle") && !kinds.includes("first_seen") && row.to_release_id !== null;
39
39
  };
40
+ const sideRef = (key, releaseId, bundleId) => key === "release" ? releaseId ?? bundleId : bundleId;
40
41
  /**
41
42
  * The bundle a stored row's bundle filter matches: `from:<bundle>` for a
42
43
  * recovery; `to:<bundle>` for a download, an apply, and an update failure;
43
44
  * `on:<bundle>` for an UNCHANGED row that launched a bundle (`isLaunch`), a
44
45
  * key no other row uses. None for a failed check, which targets no bundle, a
45
- * late row, or any other UNCHANGED row.
46
+ * late row, or any other UNCHANGED row. Each names its bundle by `key`.
46
47
  */
47
- const bundleRefsOf = (row) => {
48
+ const bundleRefsOf = (row, key = "release") => {
48
49
  if (isFailedCheck(row) || isLateEvent(row)) return [];
49
- if (row.type === "RECOVERED") return [`from:${row.from_bundle_id}`];
50
- if (row.type === "UNCHANGED") return isLaunch(row) ? [`on:${row.to_bundle_id}`] : [];
51
- return [`to:${row.to_bundle_id}`];
50
+ if (row.type === "RECOVERED") return [`from:${sideRef(key, row.from_release_id, row.from_bundle_id)}`];
51
+ if (row.type === "UNCHANGED") return isLaunch(row) ? [`on:${sideRef(key, row.to_release_id, row.to_bundle_id)}`] : [];
52
+ return [`to:${sideRef(key, row.to_release_id, row.to_bundle_id)}`];
52
53
  };
54
+ /**
55
+ * The hourly outcome rows a stored row counts in, as `[type, bundle ref]`:
56
+ * its bundle filter's (`bundleRefsOf`), and a download that a launch or
57
+ * crash implied, in its bundle's download hour, so the download series
58
+ * covers what the release's downloads count.
59
+ */
60
+ 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)}`]] : []];
53
61
  /** The key a bundle filter reads, as `bundleRefsOf` writes it. */
54
- const bundleRefOfFilter = (filter) => filter.type === "RECOVERED" ? `from:${filter.fromBundleId}` : filter.type === "UNCHANGED" ? `on:${filter.toBundleId}` : `to:${filter.toBundleId}`;
62
+ const bundleRefOfFilter = (filter) => filter.type === "RECOVERED" ? `from:${filter.fromReleaseId}` : filter.type === "UNCHANGED" ? `on:${filter.toReleaseId}` : `to:${filter.toReleaseId}`;
55
63
  /**
56
64
  * Downloads, applies, recoveries, update failures, and the UNCHANGED
57
65
  * reports that changed what their installation runs, whole. An UNCHANGED
@@ -116,7 +124,11 @@ const bundleEvents = (days) => defineTable({
116
124
  type: "string",
117
125
  compute: (row) => MOVEMENTS.has(row.type) ? row.install_id : null
118
126
  },
119
- /** The bundle a bundle filter matches (`bundleRefsOf`). */
127
+ /**
128
+ * The bundle a bundle filter matches (`bundleRefsOf`), by release.
129
+ * Rows a 1.1 server wrote name the artifact until
130
+ * `backfillReleaseRefs` rewrites them.
131
+ */
120
132
  bundle_ref: {
121
133
  type: "string",
122
134
  multi: true,
@@ -435,7 +447,13 @@ const insightsBuiltinDistribution = (retention) => defineAggregate({
435
447
  },
436
448
  retention
437
449
  });
438
- /** Latest events by the bundle they came from or went to, bucketed like the distribution. */
450
+ /**
451
+ * Latest events by the artifact they came from or went to, bucketed like
452
+ * the distribution, as 1.1 servers wrote them. Nothing writes or reads it
453
+ * since a bundle's installations come from `insights_distribution`, which
454
+ * names the release; it stays declared so retention still empties the rows
455
+ * a 1.1 server wrote.
456
+ */
439
457
  const insightsLatestByBundle = (retention) => defineAggregate({
440
458
  platform: {
441
459
  type: "string",
@@ -483,7 +501,9 @@ const insightsLatestByBundle = (retention) => defineAggregate({
483
501
  * Stored events by outcome and the bundle a bundle filter matches, a row an
484
502
  * hour, which a failed check has none of; and every stored event, a row a UTC
485
503
  * day (`DAILY_EVENTS`). Bundle counts sum the hourly rows, and event lists
486
- * read either to skip days without events.
504
+ * read either to skip days without events. `bundle_ref` names the release
505
+ * (`outcomeRefsOf`); a 1.1 server's rows name the artifact until
506
+ * `backfillReleaseRefs` moves their counts.
487
507
  */
488
508
  const insightsOutcomes = (retention) => defineAggregate({
489
509
  platform: {
@@ -562,4 +582,4 @@ const createInsightsSchema = ({ rawDays, dailyDays } = DEFAULT_INSIGHTS_RETENTIO
562
582
  };
563
583
  const insightsSchema = createInsightsSchema();
564
584
  //#endregion
565
- export { DAILY_EVENTS, DAY_MS, DEFAULT_INSIGHTS_RETENTION, HOUR_MS, bundleRefOfFilter, bundleRefsOf, createInsightsSchema, insightsSchema, isFailedCheck, isLateEvent, isLaunch };
585
+ export { DAILY_EVENTS, DAY_MS, DEFAULT_INSIGHTS_RETENTION, HOUR_MS, bundleRefOfFilter, bundleRefsOf, createInsightsSchema, insightsSchema, isFailedCheck, isLateEvent, isLaunch, outcomeRefsOf };
@@ -26,7 +26,8 @@ type InsightsProvider = {
26
26
  pageInstallationsByCurrentUserId(input: InsightsUserInstallationPageInput): Promise<CursorPage<InstallationRow>>;
27
27
  getReportingOverview(input: InsightsScope & {
28
28
  readonly window: ActiveInstallationWindow;
29
- readonly bundleId?: string;
29
+ /** The bundle users see, by its release ID. */
30
+ readonly releaseId?: string;
30
31
  }): Promise<ReportingOverview>;
31
32
  };
32
33
  //#endregion
@@ -26,7 +26,8 @@ type InsightsProvider = {
26
26
  pageInstallationsByCurrentUserId(input: InsightsUserInstallationPageInput): Promise<CursorPage<InstallationRow>>;
27
27
  getReportingOverview(input: InsightsScope & {
28
28
  readonly window: ActiveInstallationWindow;
29
- readonly bundleId?: string;
29
+ /** The bundle users see, by its release ID. */
30
+ readonly releaseId?: string;
30
31
  }): Promise<ReportingOverview>;
31
32
  };
32
33
  //#endregion
@@ -0,0 +1,34 @@
1
+ //#region src/server/wire.ts
2
+ /**
3
+ * The HTTP API calls a release ID `bundleId`, the word users have for it, in
4
+ * its query parameters and its overview's JSON. The code calls it
5
+ * `releaseId`; only this module maps between the two names.
6
+ */
7
+ const RELEASE_ID_PARAM = "bundleId";
8
+ /** An overview as the HTTP API and the CLI's `--json` send it. */
9
+ const toWireOverview = ({ bundle, ...overview }) => {
10
+ if (bundle === void 0) return overview;
11
+ const { releaseId, ...counts } = bundle;
12
+ return {
13
+ ...overview,
14
+ bundle: {
15
+ ...counts,
16
+ bundleId: releaseId
17
+ }
18
+ };
19
+ };
20
+ const fromWireOverview = ({ bundle, ...overview }) => {
21
+ if (bundle === void 0) return overview;
22
+ const { bundleId: releaseId, ...counts } = bundle;
23
+ return {
24
+ ...overview,
25
+ bundle: {
26
+ ...counts,
27
+ releaseId
28
+ }
29
+ };
30
+ };
31
+ //#endregion
32
+ exports.RELEASE_ID_PARAM = RELEASE_ID_PARAM;
33
+ exports.fromWireOverview = fromWireOverview;
34
+ exports.toWireOverview = toWireOverview;
@@ -0,0 +1,13 @@
1
+ import { ReportingOverview } from "./domain.cjs";
2
+ //#region src/server/wire.d.ts
3
+ type OverviewBundle = NonNullable<ReportingOverview["bundle"]>;
4
+ /** A reporting overview as the HTTP API sends it. */
5
+ type WireReportingOverview = Omit<ReportingOverview, "bundle"> & {
6
+ readonly bundle?: Omit<OverviewBundle, "releaseId"> & {
7
+ readonly bundleId: string;
8
+ };
9
+ };
10
+ /** An overview as the HTTP API and the CLI's `--json` send it. */
11
+ declare const toWireOverview: ({ bundle, ...overview }: ReportingOverview) => WireReportingOverview;
12
+ //#endregion
13
+ export { WireReportingOverview, toWireOverview };
@@ -0,0 +1,13 @@
1
+ import { ReportingOverview } from "./domain.mjs";
2
+ //#region src/server/wire.d.ts
3
+ type OverviewBundle = NonNullable<ReportingOverview["bundle"]>;
4
+ /** A reporting overview as the HTTP API sends it. */
5
+ type WireReportingOverview = Omit<ReportingOverview, "bundle"> & {
6
+ readonly bundle?: Omit<OverviewBundle, "releaseId"> & {
7
+ readonly bundleId: string;
8
+ };
9
+ };
10
+ /** An overview as the HTTP API and the CLI's `--json` send it. */
11
+ declare const toWireOverview: ({ bundle, ...overview }: ReportingOverview) => WireReportingOverview;
12
+ //#endregion
13
+ export { WireReportingOverview, toWireOverview };
@@ -0,0 +1,32 @@
1
+ //#region src/server/wire.ts
2
+ /**
3
+ * The HTTP API calls a release ID `bundleId`, the word users have for it, in
4
+ * its query parameters and its overview's JSON. The code calls it
5
+ * `releaseId`; only this module maps between the two names.
6
+ */
7
+ const RELEASE_ID_PARAM = "bundleId";
8
+ /** An overview as the HTTP API and the CLI's `--json` send it. */
9
+ const toWireOverview = ({ bundle, ...overview }) => {
10
+ if (bundle === void 0) return overview;
11
+ const { releaseId, ...counts } = bundle;
12
+ return {
13
+ ...overview,
14
+ bundle: {
15
+ ...counts,
16
+ bundleId: releaseId
17
+ }
18
+ };
19
+ };
20
+ const fromWireOverview = ({ bundle, ...overview }) => {
21
+ if (bundle === void 0) return overview;
22
+ const { bundleId: releaseId, ...counts } = bundle;
23
+ return {
24
+ ...overview,
25
+ bundle: {
26
+ ...counts,
27
+ releaseId
28
+ }
29
+ };
30
+ };
31
+ //#endregion
32
+ export { RELEASE_ID_PARAM, fromWireOverview, toWireOverview };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hot-updater/plugin-insights",
3
3
  "type": "module",
4
- "version": "1.2.0-rc.6",
4
+ "version": "1.2.0-rc.60",
5
5
  "description": "Hot Updater's Insights plugin: launch, download, and update failure events, for the server and the React Native app",
6
6
  "exports": {
7
7
  "./client": {
@@ -33,10 +33,10 @@
33
33
  "package.json"
34
34
  ],
35
35
  "dependencies": {
36
- "@hot-updater/protocol": "1.2.0-rc.6"
36
+ "@hot-updater/protocol": "1.2.0-rc.60"
37
37
  },
38
38
  "peerDependencies": {
39
- "@hot-updater/plugin-core": "^1.2.0-rc.6"
39
+ "@hot-updater/plugin-core": "^1.2.0-rc.60"
40
40
  },
41
41
  "peerDependenciesMeta": {
42
42
  "@hot-updater/plugin-core": {
@@ -46,13 +46,7 @@
46
46
  "devDependencies": {
47
47
  "@types/node": "^20",
48
48
  "vitest": "4.1.4",
49
- "@hot-updater/plugin-core": "1.2.0-rc.6",
50
- "@hot-updater/test-utils": "1.2.0-rc.6"
51
- },
52
- "nx": {
53
- "implicitDependencies": [
54
- "!@hot-updater/test-utils"
55
- ]
49
+ "@hot-updater/plugin-core": "1.2.0-rc.60"
56
50
  },
57
51
  "scripts": {
58
52
  "build": "tsdown",