@hot-updater/plugin-insights 1.0.0-rc.20 → 1.0.0-rc.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +7 -6
  2. package/dist/client/index.cjs +3 -4
  3. package/dist/client/index.d.cts +2 -3
  4. package/dist/client/index.d.mts +2 -3
  5. package/dist/client/index.mjs +2 -3
  6. package/dist/server/errors.cjs +4 -0
  7. package/dist/server/errors.d.cts +4 -0
  8. package/dist/server/errors.d.mts +4 -0
  9. package/dist/server/errors.mjs +4 -0
  10. package/dist/server/eventRow.cjs +2 -3
  11. package/dist/server/eventRow.mjs +1 -2
  12. package/dist/server/index.cjs +8 -7
  13. package/dist/server/index.d.cts +19 -18
  14. package/dist/server/index.d.mts +19 -18
  15. package/dist/server/index.mjs +5 -5
  16. package/dist/server/official.cjs +12 -0
  17. package/dist/server/official.mjs +12 -0
  18. package/dist/server/reads.cjs +7 -8
  19. package/dist/server/reads.d.cts +1 -1
  20. package/dist/server/reads.d.mts +1 -1
  21. package/dist/server/reads.mjs +1 -2
  22. package/dist/server/recordEvent.cjs +5 -5
  23. package/dist/server/recordEvent.d.cts +1 -1
  24. package/dist/server/recordEvent.d.mts +1 -1
  25. package/dist/server/recordEvent.mjs +1 -1
  26. package/dist/server/routes.cjs +2 -2
  27. package/dist/server/routes.mjs +1 -1
  28. package/dist/server/schema.cjs +10 -10
  29. package/dist/server/schema.d.cts +27 -38
  30. package/dist/server/schema.d.mts +27 -38
  31. package/dist/server/schema.mjs +1 -1
  32. package/package.json +7 -14
  33. package/dist/internal.cjs +0 -9
  34. package/dist/internal.d.cts +0 -5
  35. package/dist/internal.d.mts +0 -5
  36. package/dist/internal.mjs +0 -5
  37. package/dist/server/eventInput.d.cts +0 -6
  38. package/dist/server/eventInput.d.mts +0 -6
  39. package/dist/server/routes.d.cts +0 -36
  40. package/dist/server/routes.d.mts +0 -36
  41. package/dist/server/testing/eventRow.d.mts +0 -64
  42. package/dist/server/testing/expectInsightsIndex.mjs +0 -18
  43. package/dist/server/testing/fixtures.d.mts +0 -8
  44. package/dist/server/testing/fixtures.mjs +0 -25
  45. package/dist/server/testing/index.d.mts +0 -24
  46. package/dist/server/testing/index.mjs +0 -25
  47. package/dist/server/testing/insightsModelTests.mjs +0 -714
  48. package/dist/server/testing/modelTypes.d.mts +0 -176
  49. package/dist/server/testing/setupInsightsHttpTestSuite.d.mts +0 -11
  50. package/dist/server/testing/setupInsightsHttpTestSuite.mjs +0 -107
  51. package/dist/server/testing/setupInsightsModelTestSuite.d.mts +0 -11
  52. package/dist/server/testing/setupInsightsModelTestSuite.mjs +0 -31
  53. package/dist/server/testing/types.d.mts +0 -26
package/README.md CHANGED
@@ -12,13 +12,14 @@ You don't install it on its own. `@hot-updater/server` and
12
12
  import { insights } from "@hot-updater/server/plugins/insights";
13
13
 
14
14
  // The app
15
- import { insights } from "@hot-updater/react-native/plugins/insights";
15
+ import { HotUpdater, insights } from "@hot-updater/react-native";
16
16
  ```
17
17
 
18
- | Entry | Re-exported as |
19
- | ----------- | ----------------------------------------------- |
20
- | `./server` | `@hot-updater/server/plugins/insights` |
21
- | `./client` | `@hot-updater/react-native/plugins/insights` |
22
- | `./testing` | `@hot-updater/server/plugins/insights/testing` |
18
+ | Entry | Re-exported as |
19
+ | ---------- | ------------------------------------------------------------------ |
20
+ | `./server` | `@hot-updater/server/plugins/insights` |
21
+ | `./client` | `insights` and its types from the `@hot-updater/react-native` root |
22
+
23
+ Its test suites, such as `insightsTestSuite`, are in `@hot-updater/test-utils`.
23
24
 
24
25
  See [Insights](https://hot-updater.dev/docs/guides/insights).
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_eventId = require("./eventId.cjs");
3
3
  const require_sender = require("./sender.cjs");
4
4
  const require_state = require("./state.cjs");
5
- let _hot_updater_core = require("@hot-updater/core");
5
+ let _hot_updater_protocol = require("@hot-updater/protocol");
6
6
  //#region src/client/index.ts
7
7
  const normalizeUserId = (user) => {
8
8
  if (user === null) return null;
@@ -18,8 +18,7 @@ const normalizeUserId = (user) => {
18
18
  *
19
19
  * @example
20
20
  * ```ts
21
- * import { HotUpdater } from "@hot-updater/react-native";
22
- * import { insights } from "@hot-updater/react-native/plugins/insights";
21
+ * import { HotUpdater, insights } from "@hot-updater/react-native";
23
22
  *
24
23
  * const analytics = insights();
25
24
  * HotUpdater.init({ baseURL, plugins: [analytics] });
@@ -199,7 +198,7 @@ const insights = (options = {}) => {
199
198
  if (event.report !== null) state.recordReport(event.report);
200
199
  else state.forgetReport();
201
200
  };
202
- return (0, _hot_updater_core.defineClientPlugin)({
201
+ return (0, _hot_updater_protocol.defineClientPlugin)({
203
202
  id: "insights",
204
203
  setup(pluginContext) {
205
204
  context = pluginContext;
@@ -1,4 +1,4 @@
1
- import { HotUpdaterClientPlugin } from "@hot-updater/core";
1
+ import { HotUpdaterClientPlugin } from "@hot-updater/protocol";
2
2
  //#region src/client/index.d.ts
3
3
  interface InsightsOptions {
4
4
  /**
@@ -29,8 +29,7 @@ interface InsightsPlugin extends HotUpdaterClientPlugin {
29
29
  *
30
30
  * @example
31
31
  * ```ts
32
- * import { HotUpdater } from "@hot-updater/react-native";
33
- * import { insights } from "@hot-updater/react-native/plugins/insights";
32
+ * import { HotUpdater, insights } from "@hot-updater/react-native";
34
33
  *
35
34
  * const analytics = insights();
36
35
  * HotUpdater.init({ baseURL, plugins: [analytics] });
@@ -1,4 +1,4 @@
1
- import { HotUpdaterClientPlugin } from "@hot-updater/core";
1
+ import { HotUpdaterClientPlugin } from "@hot-updater/protocol";
2
2
  //#region src/client/index.d.ts
3
3
  interface InsightsOptions {
4
4
  /**
@@ -29,8 +29,7 @@ interface InsightsPlugin extends HotUpdaterClientPlugin {
29
29
  *
30
30
  * @example
31
31
  * ```ts
32
- * import { HotUpdater } from "@hot-updater/react-native";
33
- * import { insights } from "@hot-updater/react-native/plugins/insights";
32
+ * import { HotUpdater, insights } from "@hot-updater/react-native";
34
33
  *
35
34
  * const analytics = insights();
36
35
  * HotUpdater.init({ baseURL, plugins: [analytics] });
@@ -1,7 +1,7 @@
1
1
  import { createKeyedUUIDv7, createUUIDv7 } from "./eventId.mjs";
2
2
  import { createInsightsEventSender } from "./sender.mjs";
3
3
  import { createInsightsState, utcDay, utcDayStart } from "./state.mjs";
4
- import { defineClientPlugin } from "@hot-updater/core";
4
+ import { defineClientPlugin } from "@hot-updater/protocol";
5
5
  //#region src/client/index.ts
6
6
  const normalizeUserId = (user) => {
7
7
  if (user === null) return null;
@@ -17,8 +17,7 @@ const normalizeUserId = (user) => {
17
17
  *
18
18
  * @example
19
19
  * ```ts
20
- * import { HotUpdater } from "@hot-updater/react-native";
21
- * import { insights } from "@hot-updater/react-native/plugins/insights";
20
+ * import { HotUpdater, insights } from "@hot-updater/react-native";
22
21
  *
23
22
  * const analytics = insights();
24
23
  * HotUpdater.init({ baseURL, plugins: [analytics] });
@@ -1,4 +1,8 @@
1
1
  //#region src/server/errors.ts
2
+ /**
3
+ * What Insights' API throws for an input it refuses, such as an unknown
4
+ * event field or a malformed cursor; its routes answer 400 for it.
5
+ */
2
6
  var InsightsBadRequestError = class extends Error {
3
7
  name = "InsightsBadRequestError";
4
8
  };
@@ -1,4 +1,8 @@
1
1
  //#region src/server/errors.d.ts
2
+ /**
3
+ * What Insights' API throws for an input it refuses, such as an unknown
4
+ * event field or a malformed cursor; its routes answer 400 for it.
5
+ */
2
6
  declare class InsightsBadRequestError extends Error {
3
7
  readonly name = "InsightsBadRequestError";
4
8
  }
@@ -1,4 +1,8 @@
1
1
  //#region src/server/errors.d.ts
2
+ /**
3
+ * What Insights' API throws for an input it refuses, such as an unknown
4
+ * event field or a malformed cursor; its routes answer 400 for it.
5
+ */
2
6
  declare class InsightsBadRequestError extends Error {
3
7
  readonly name = "InsightsBadRequestError";
4
8
  }
@@ -1,4 +1,8 @@
1
1
  //#region src/server/errors.ts
2
+ /**
3
+ * What Insights' API throws for an input it refuses, such as an unknown
4
+ * event field or a malformed cursor; its routes answer 400 for it.
5
+ */
2
6
  var InsightsBadRequestError = class extends Error {
3
7
  name = "InsightsBadRequestError";
4
8
  };
@@ -1,11 +1,10 @@
1
1
  let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
2
- let _hot_updater_plugin_core_internal = require("@hot-updater/plugin-core/internal");
3
2
  //#region src/server/eventRow.ts
4
3
  const isOptional = (value, key, valid) => !Object.hasOwn(value, key) || valid(value[key]);
5
4
  const isString = (value) => typeof value === "string";
6
5
  /** An `UPDATE_FAILED` report's stored failure: a stage and a reason, and what else the client knew. */
7
- const isDatabaseBundleEventFailure = (value) => (0, _hot_updater_plugin_core_internal.isDatabaseJsonObject)(value) && isString(value.stage) && isString(value.reason) && isOptional(value, "resource", isString) && isOptional(value, "http_status", (status) => Number.isSafeInteger(status)) && isOptional(value, "transport", isString) && isOptional(value, "origin_code", isString) && isOptional(value, "previous_process_exit", isString);
8
- const isDatabaseBundleEventMetadata = (value) => (0, _hot_updater_plugin_core_internal.isDatabaseJsonObject)(value) && typeof value.cohort === "string" && (value.update_strategy === null || value.update_strategy === "fingerprint" || value.update_strategy === "appVersion") && (value.fingerprint_hash === null || typeof value.fingerprint_hash === "string") && (value.sdk_version === null || typeof value.sdk_version === "string") && isOptional(value, "failure", isDatabaseBundleEventFailure) && isOptional(value, "delivery", isString) && isOptional(value, "patch_fallback", (flag) => typeof flag === "boolean") && isOptional(value, "previous_process_exit", isString);
6
+ const isDatabaseBundleEventFailure = (value) => (0, _hot_updater_plugin_core.isDatabaseJsonObject)(value) && isString(value.stage) && isString(value.reason) && isOptional(value, "resource", isString) && isOptional(value, "http_status", (status) => Number.isSafeInteger(status)) && isOptional(value, "transport", isString) && isOptional(value, "origin_code", isString) && isOptional(value, "previous_process_exit", isString);
7
+ const isDatabaseBundleEventMetadata = (value) => (0, _hot_updater_plugin_core.isDatabaseJsonObject)(value) && typeof value.cohort === "string" && (value.update_strategy === null || value.update_strategy === "fingerprint" || value.update_strategy === "appVersion") && (value.fingerprint_hash === null || typeof value.fingerprint_hash === "string") && (value.sdk_version === null || typeof value.sdk_version === "string") && isOptional(value, "failure", isDatabaseBundleEventFailure) && isOptional(value, "delivery", isString) && isOptional(value, "patch_fallback", (flag) => typeof flag === "boolean") && isOptional(value, "previous_process_exit", isString);
9
8
  const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
10
9
  const isIdentity = (value) => typeof value === "string" && value.length > 0 && value.length <= 255;
11
10
  const isTextOrNull = (value) => value === null || typeof value === "string";
@@ -1,5 +1,4 @@
1
- import { DatabaseAdapterInputError } from "@hot-updater/plugin-core";
2
- import { isDatabaseJsonObject } from "@hot-updater/plugin-core/internal";
1
+ import { DatabaseAdapterInputError, isDatabaseJsonObject } from "@hot-updater/plugin-core";
3
2
  //#region src/server/eventRow.ts
4
3
  const isOptional = (value, key, valid) => !Object.hasOwn(value, key) || valid(value[key]);
5
4
  const isString = (value) => typeof value === "string";
@@ -1,13 +1,13 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_model = require("./model.cjs");
3
+ const require_official = require("./official.cjs");
4
+ const require_errors = require("./errors.cjs");
3
5
  const require_provider = require("./provider.cjs");
4
6
  const require_schema = require("./schema.cjs");
5
7
  const require_recordEvent = require("./recordEvent.cjs");
6
8
  const require_reads = require("./reads.cjs");
7
9
  const require_routes = require("./routes.cjs");
8
10
  let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
9
- let _hot_updater_plugin_core_internal = require("@hot-updater/plugin-core/internal");
10
- let _hot_updater_plugin_core_server_plugin = require("@hot-updater/plugin-core/server-plugin");
11
11
  //#region src/server/index.ts
12
12
  const createInsightsApi = (db, now, retention) => ({
13
13
  /** How long this plugin keeps its rows. */
@@ -58,7 +58,7 @@ const failuresEndpoint = (api) => ({
58
58
  return Response.json(await api.getUpdateFailures(readFailuresQuery(new URL(request.url))), { headers: { "cache-control": "private, no-store" } });
59
59
  } catch (error) {
60
60
  if (error instanceof _hot_updater_plugin_core.DatabaseAdapterInputError) return Response.json({ error: "Send platform and channel, and releaseId or start and end in epoch milliseconds, at most 30 days apart." }, { status: 400 });
61
- if (!(0, _hot_updater_plugin_core_server_plugin.isDatabaseBusyError)(error)) throw error;
61
+ if (!(0, _hot_updater_plugin_core.isDatabaseBusyError)(error)) throw error;
62
62
  return Response.json({ error: "Service unavailable" }, {
63
63
  status: 503,
64
64
  headers: { "retry-after": "5" }
@@ -70,7 +70,7 @@ const retentionOf = ({ retention }) => {
70
70
  const rawDays = retention?.rawDays ?? 90;
71
71
  const dailyDays = retention?.dailyDays ?? 400;
72
72
  const whole = (days) => Number.isSafeInteger(days) && days >= 1;
73
- if (!whole(rawDays) || !whole(dailyDays) || dailyDays < rawDays) throw new _hot_updater_plugin_core_server_plugin.HotUpdaterConfigError(`insights({ retention }) takes whole days of at least 1, with dailyDays at least rawDays; got rawDays ${rawDays} and dailyDays ${dailyDays}.`);
73
+ if (!whole(rawDays) || !whole(dailyDays) || dailyDays < rawDays) throw new _hot_updater_plugin_core.HotUpdaterConfigError(`insights({ retention }) takes whole days of at least 1, with dailyDays at least rawDays; got rawDays ${rawDays} and dailyDays ${dailyDays}.`);
74
74
  return {
75
75
  rawDays,
76
76
  dailyDays
@@ -84,7 +84,7 @@ const retentionOf = ({ retention }) => {
84
84
  */
85
85
  const insights = (options = {}) => {
86
86
  const retention = retentionOf(options);
87
- const plugin = (0, _hot_updater_plugin_core_server_plugin.definePlugin)({
87
+ const plugin = (0, _hot_updater_plugin_core.definePlugin)({
88
88
  id: "insights",
89
89
  namespace: false,
90
90
  schemaVersion: "1.2.0",
@@ -112,14 +112,15 @@ const insights = (options = {}) => {
112
112
  };
113
113
  },
114
114
  cli: { clientPlugin: {
115
- module: "@hot-updater/react-native/plugins/insights",
115
+ module: "@hot-updater/react-native",
116
116
  name: "insights"
117
117
  } }
118
118
  });
119
- return (0, _hot_updater_plugin_core_internal.markOfficial)(plugin);
119
+ return require_official.markOfficial(plugin);
120
120
  };
121
121
  //#endregion
122
122
  exports.DEFAULT_INSIGHTS_RETENTION = require_schema.DEFAULT_INSIGHTS_RETENTION;
123
+ exports.InsightsBadRequestError = require_errors.InsightsBadRequestError;
123
124
  exports.createInsightsModel = require_model.createInsightsModel;
124
125
  exports.createInsightsProvider = require_provider.createInsightsProvider;
125
126
  exports.createInsightsSchema = require_schema.createInsightsSchema;
@@ -1,13 +1,14 @@
1
1
  import { BundleEventFailure, BundleEventFailureReason, BundleEventFailureStage, BundleEventRow, BundleEventRowBase, DatabaseBundleEventMetadata } from "./eventRow.cjs";
2
2
  import { InsightsBundleEventFilter, InsightsCountEventsInput, InsightsCountLatestEventsInput, InsightsCoverage, InsightsEventCursor, InsightsEventFilter, InsightsFindLatestEventsInput, InsightsGetAppUsageInput, InsightsGetAppUsageResult, InsightsGetReleaseActivityInput, InsightsGetReleaseActivityResult, InsightsListEventsInput, InsightsModel, InsightsRecordEventInput, InsightsScope, InsightsTimeRange, ReleaseActivityMetrics, ReleaseReference } from "./modelTypes.cjs";
3
- import { ActiveInstallationWindow, BundleEventFailureInput, CreateBundleEventRequest, CreateBundleEventRequestBase, CursorPage, EventCursorPage, EventHistoryRow, InsightsBundleSelection, InsightsCountMeasurement, InstallationHistoryRow, InstallationRow, ReportingOverview } from "./domain.cjs";
4
- import { InsightsEventPageInput, InsightsInstallationEventPageInput, InsightsProvider, InsightsUserInstallationPageInput } from "./types.cjs";
5
3
  import { DEFAULT_INSIGHTS_RETENTION, InsightsRetention, InsightsSchema, createInsightsSchema, insightsSchema } from "./schema.cjs";
6
4
  import { InsightsFailureBreakdown, InsightsUpdateFailures, InsightsUpdateFailuresInput } from "./reads.cjs";
5
+ import { ActiveInstallationWindow, BundleEventFailureInput, CreateBundleEventRequest, CreateBundleEventRequestBase, CursorPage, EventCursorPage, EventHistoryRow, InsightsBundleSelection, InsightsCountMeasurement, InstallationHistoryRow, InstallationRow, ReportingOverview } from "./domain.cjs";
6
+ import { InsightsBadRequestError } from "./errors.cjs";
7
7
  import { createInsightsModel } from "./model.cjs";
8
+ import { InsightsEventPageInput, InsightsInstallationEventPageInput, InsightsProvider, InsightsUserInstallationPageInput } from "./types.cjs";
8
9
  import { createInsightsProvider } from "./provider.cjs";
9
10
  import { InsightsIdentityParts, insightsIdentity } from "./recordEvent.cjs";
10
- import { HotUpdaterDatabase, PluginEndpoint } from "@hot-updater/plugin-core/server-plugin";
11
+ import { HotUpdaterDatabase, PluginEndpoint } from "@hot-updater/plugin-core";
11
12
  //#region src/server/index.d.ts
12
13
  declare const createInsightsApi: (db: HotUpdaterDatabase<InsightsSchema>, now: () => number, retention: InsightsRetention) => {
13
14
  /** How long this plugin keeps its rows. */
@@ -39,8 +40,8 @@ interface InsightsOptions {
39
40
  * reads come from, each kept for its retention. It serves `POST /events` to
40
41
  * clients, and the Insights reads, update failures, and retention to admins.
41
42
  */
42
- declare const insights: (options?: InsightsOptions) => import("@hot-updater/plugin-core/server-plugin").HotUpdaterPlugin<"insights", {
43
- readonly bundle_events: import("@hot-updater/plugin-core/server-plugin").TableDefinition<{
43
+ declare const insights: (options?: InsightsOptions) => import("@hot-updater/plugin-core").HotUpdaterPlugin<"insights", {
44
+ readonly bundle_events: import("@hot-updater/plugin-core").TableDefinition<{
44
45
  readonly id: {
45
46
  readonly type: "string";
46
47
  readonly maxLength: 36;
@@ -115,7 +116,7 @@ declare const insights: (options?: InsightsOptions) => import("@hot-updater/plug
115
116
  readonly sort: readonly ["received_at_ms"];
116
117
  };
117
118
  }, readonly ["id"]>;
118
- readonly bundle_event_heads: import("@hot-updater/plugin-core/server-plugin").TableDefinition<{
119
+ readonly bundle_event_heads: import("@hot-updater/plugin-core").TableDefinition<{
119
120
  readonly install_id: {
120
121
  readonly type: "string";
121
122
  readonly maxLength: 255;
@@ -168,13 +169,13 @@ declare const insights: (options?: InsightsOptions) => import("@hot-updater/plug
168
169
  readonly received_at_ms: {
169
170
  readonly type: "integer";
170
171
  };
171
- }, Readonly<Record<string, import("@hot-updater/plugin-core/server-plugin").FieldType>>, {
172
+ }, Readonly<Record<string, import("@hot-updater/plugin-core").FieldType>>, {
172
173
  readonly byUser: {
173
174
  readonly eq: readonly ["user_id"];
174
175
  readonly sort: readonly ["install_id"];
175
176
  };
176
177
  }, readonly ["install_id"]>;
177
- readonly insights_overview: import("@hot-updater/plugin-core/server-plugin").AggregateDefinition<{
178
+ readonly insights_overview: import("@hot-updater/plugin-core").AggregateDefinition<{
178
179
  readonly identity: {
179
180
  readonly type: "string";
180
181
  readonly maxLength: 32;
@@ -188,7 +189,7 @@ declare const insights: (options?: InsightsOptions) => import("@hot-updater/plug
188
189
  readonly sort: readonly ["bucket_start_ms"];
189
190
  };
190
191
  }, never, readonly ["identity", "bucket_start_ms"]>;
191
- readonly insights_sketches: import("@hot-updater/plugin-core/server-plugin").AggregateDefinition<{
192
+ readonly insights_sketches: import("@hot-updater/plugin-core").AggregateDefinition<{
192
193
  readonly identity: {
193
194
  readonly type: "string";
194
195
  readonly maxLength: 32;
@@ -202,7 +203,7 @@ declare const insights: (options?: InsightsOptions) => import("@hot-updater/plug
202
203
  readonly sort: readonly ["bucket_start_ms"];
203
204
  };
204
205
  }, "launch_users" | "activity_users" | "failed_users", readonly ["identity", "bucket_start_ms"]>;
205
- readonly insights_overview_daily: import("@hot-updater/plugin-core/server-plugin").AggregateDefinition<{
206
+ readonly insights_overview_daily: import("@hot-updater/plugin-core").AggregateDefinition<{
206
207
  readonly identity: {
207
208
  readonly type: "string";
208
209
  readonly maxLength: 32;
@@ -216,7 +217,7 @@ declare const insights: (options?: InsightsOptions) => import("@hot-updater/plug
216
217
  readonly sort: readonly ["bucket_start_ms"];
217
218
  };
218
219
  }, never, readonly ["identity", "bucket_start_ms"]>;
219
- readonly insights_sketches_daily: import("@hot-updater/plugin-core/server-plugin").AggregateDefinition<{
220
+ readonly insights_sketches_daily: import("@hot-updater/plugin-core").AggregateDefinition<{
220
221
  readonly identity: {
221
222
  readonly type: "string";
222
223
  readonly maxLength: 32;
@@ -230,7 +231,7 @@ declare const insights: (options?: InsightsOptions) => import("@hot-updater/plug
230
231
  readonly sort: readonly ["bucket_start_ms"];
231
232
  };
232
233
  }, "launch_users" | "activity_users" | "failed_users", readonly ["identity", "bucket_start_ms"]>;
233
- readonly insights_overview_lifetime: import("@hot-updater/plugin-core/server-plugin").AggregateDefinition<{
234
+ readonly insights_overview_lifetime: import("@hot-updater/plugin-core").AggregateDefinition<{
234
235
  readonly identity: {
235
236
  readonly type: "string";
236
237
  readonly maxLength: 32;
@@ -244,7 +245,7 @@ declare const insights: (options?: InsightsOptions) => import("@hot-updater/plug
244
245
  readonly sort: readonly ["bucket_start_ms"];
245
246
  };
246
247
  }, never, readonly ["identity", "bucket_start_ms"]>;
247
- readonly insights_sketches_lifetime: import("@hot-updater/plugin-core/server-plugin").AggregateDefinition<{
248
+ readonly insights_sketches_lifetime: import("@hot-updater/plugin-core").AggregateDefinition<{
248
249
  readonly identity: {
249
250
  readonly type: "string";
250
251
  readonly maxLength: 32;
@@ -258,7 +259,7 @@ declare const insights: (options?: InsightsOptions) => import("@hot-updater/plug
258
259
  readonly sort: readonly ["bucket_start_ms"];
259
260
  };
260
261
  }, "failed_users", readonly ["identity", "bucket_start_ms"]>;
261
- readonly insights_distribution: import("@hot-updater/plugin-core/server-plugin").AggregateDefinition<{
262
+ readonly insights_distribution: import("@hot-updater/plugin-core").AggregateDefinition<{
262
263
  readonly channel: {
263
264
  readonly type: "string";
264
265
  };
@@ -286,7 +287,7 @@ declare const insights: (options?: InsightsOptions) => import("@hot-updater/plug
286
287
  readonly sort: readonly ["bucket_start_ms"];
287
288
  };
288
289
  }, never, readonly ["channel", "platform", "app_version", "release_id", "bucket_start_ms"]>;
289
- readonly insights_latest_by_bundle: import("@hot-updater/plugin-core/server-plugin").AggregateDefinition<{
290
+ readonly insights_latest_by_bundle: import("@hot-updater/plugin-core").AggregateDefinition<{
290
291
  readonly platform: {
291
292
  readonly type: "string";
292
293
  readonly maxLength: 16;
@@ -315,7 +316,7 @@ declare const insights: (options?: InsightsOptions) => import("@hot-updater/plug
315
316
  readonly sort: readonly ["bucket_start_ms"];
316
317
  };
317
318
  }, never, readonly ["platform", "channel", "bundle_field", "bundle_id", "type", "bucket_start_ms"]>;
318
- readonly insights_outcomes: import("@hot-updater/plugin-core/server-plugin").AggregateDefinition<{
319
+ readonly insights_outcomes: import("@hot-updater/plugin-core").AggregateDefinition<{
319
320
  readonly platform: {
320
321
  readonly type: "string";
321
322
  readonly maxLength: 16;
@@ -340,7 +341,7 @@ declare const insights: (options?: InsightsOptions) => import("@hot-updater/plug
340
341
  readonly sort: readonly ["bucket_start_ms"];
341
342
  };
342
343
  }, never, readonly ["platform", "channel", "type", "bundle_ref", "bucket_start_ms"]>;
343
- readonly insights_failures: import("@hot-updater/plugin-core/server-plugin").AggregateDefinition<{
344
+ readonly insights_failures: import("@hot-updater/plugin-core").AggregateDefinition<{
344
345
  readonly platform: {
345
346
  readonly type: "string";
346
347
  readonly maxLength: 16;
@@ -391,4 +392,4 @@ declare const insights: (options?: InsightsOptions) => import("@hot-updater/plug
391
392
  endpoints: PluginEndpoint[];
392
393
  }, {}>;
393
394
  //#endregion
394
- export { type ActiveInstallationWindow, type BundleEventFailure, type BundleEventFailureInput, type BundleEventFailureReason, type BundleEventFailureStage, type BundleEventRow, type BundleEventRowBase, type CreateBundleEventRequest, type CreateBundleEventRequestBase, type CursorPage, DEFAULT_INSIGHTS_RETENTION, type DatabaseBundleEventMetadata, type EventCursorPage, type EventHistoryRow, InsightsApi, type InsightsBundleEventFilter, type InsightsBundleSelection, type InsightsCountEventsInput, type InsightsCountLatestEventsInput, type InsightsCountMeasurement, type InsightsCoverage, type InsightsEventCursor, type InsightsEventFilter, type InsightsEventPageInput, type InsightsFailureBreakdown, type InsightsFindLatestEventsInput, type InsightsGetAppUsageInput, type InsightsGetAppUsageResult, type InsightsGetReleaseActivityInput, type InsightsGetReleaseActivityResult, type InsightsIdentityParts, type InsightsInstallationEventPageInput, type InsightsListEventsInput, type InsightsModel, InsightsOptions, type InsightsProvider, type InsightsRecordEventInput, type InsightsRetention, type InsightsSchema, type InsightsScope, type InsightsTimeRange, type InsightsUpdateFailures, type InsightsUpdateFailuresInput, type InsightsUserInstallationPageInput, type InstallationHistoryRow, type InstallationRow, type ReleaseActivityMetrics, type ReleaseReference, type ReportingOverview, createInsightsModel, createInsightsProvider, createInsightsSchema, insights, insightsIdentity, insightsSchema };
395
+ export { type ActiveInstallationWindow, type BundleEventFailure, type BundleEventFailureInput, type BundleEventFailureReason, type BundleEventFailureStage, type BundleEventRow, type BundleEventRowBase, type CreateBundleEventRequest, type CreateBundleEventRequestBase, type CursorPage, DEFAULT_INSIGHTS_RETENTION, type DatabaseBundleEventMetadata, type EventCursorPage, type EventHistoryRow, InsightsApi, InsightsBadRequestError, type InsightsBundleEventFilter, type InsightsBundleSelection, type InsightsCountEventsInput, type InsightsCountLatestEventsInput, type InsightsCountMeasurement, type InsightsCoverage, type InsightsEventCursor, type InsightsEventFilter, type InsightsEventPageInput, type InsightsFailureBreakdown, type InsightsFindLatestEventsInput, type InsightsGetAppUsageInput, type InsightsGetAppUsageResult, type InsightsGetReleaseActivityInput, type InsightsGetReleaseActivityResult, type InsightsIdentityParts, type InsightsInstallationEventPageInput, type InsightsListEventsInput, type InsightsModel, InsightsOptions, type InsightsProvider, type InsightsRecordEventInput, type InsightsRetention, type InsightsSchema, type InsightsScope, type InsightsTimeRange, type InsightsUpdateFailures, type InsightsUpdateFailuresInput, type InsightsUserInstallationPageInput, type InstallationHistoryRow, type InstallationRow, type ReleaseActivityMetrics, type ReleaseReference, type ReportingOverview, createInsightsModel, createInsightsProvider, createInsightsSchema, insights, insightsIdentity, insightsSchema };
@@ -1,13 +1,14 @@
1
1
  import { BundleEventFailure, BundleEventFailureReason, BundleEventFailureStage, BundleEventRow, BundleEventRowBase, DatabaseBundleEventMetadata } from "./eventRow.mjs";
2
2
  import { InsightsBundleEventFilter, InsightsCountEventsInput, InsightsCountLatestEventsInput, InsightsCoverage, InsightsEventCursor, InsightsEventFilter, InsightsFindLatestEventsInput, InsightsGetAppUsageInput, InsightsGetAppUsageResult, InsightsGetReleaseActivityInput, InsightsGetReleaseActivityResult, InsightsListEventsInput, InsightsModel, InsightsRecordEventInput, InsightsScope, InsightsTimeRange, ReleaseActivityMetrics, ReleaseReference } from "./modelTypes.mjs";
3
- import { ActiveInstallationWindow, BundleEventFailureInput, CreateBundleEventRequest, CreateBundleEventRequestBase, CursorPage, EventCursorPage, EventHistoryRow, InsightsBundleSelection, InsightsCountMeasurement, InstallationHistoryRow, InstallationRow, ReportingOverview } from "./domain.mjs";
4
- import { InsightsEventPageInput, InsightsInstallationEventPageInput, InsightsProvider, InsightsUserInstallationPageInput } from "./types.mjs";
5
3
  import { DEFAULT_INSIGHTS_RETENTION, InsightsRetention, InsightsSchema, createInsightsSchema, insightsSchema } from "./schema.mjs";
6
4
  import { InsightsFailureBreakdown, InsightsUpdateFailures, InsightsUpdateFailuresInput } from "./reads.mjs";
5
+ import { ActiveInstallationWindow, BundleEventFailureInput, CreateBundleEventRequest, CreateBundleEventRequestBase, CursorPage, EventCursorPage, EventHistoryRow, InsightsBundleSelection, InsightsCountMeasurement, InstallationHistoryRow, InstallationRow, ReportingOverview } from "./domain.mjs";
6
+ import { InsightsBadRequestError } from "./errors.mjs";
7
7
  import { createInsightsModel } from "./model.mjs";
8
+ import { InsightsEventPageInput, InsightsInstallationEventPageInput, InsightsProvider, InsightsUserInstallationPageInput } from "./types.mjs";
8
9
  import { createInsightsProvider } from "./provider.mjs";
9
10
  import { InsightsIdentityParts, insightsIdentity } from "./recordEvent.mjs";
10
- import { HotUpdaterDatabase, PluginEndpoint } from "@hot-updater/plugin-core/server-plugin";
11
+ import { HotUpdaterDatabase, PluginEndpoint } from "@hot-updater/plugin-core";
11
12
  //#region src/server/index.d.ts
12
13
  declare const createInsightsApi: (db: HotUpdaterDatabase<InsightsSchema>, now: () => number, retention: InsightsRetention) => {
13
14
  /** How long this plugin keeps its rows. */
@@ -39,8 +40,8 @@ interface InsightsOptions {
39
40
  * reads come from, each kept for its retention. It serves `POST /events` to
40
41
  * clients, and the Insights reads, update failures, and retention to admins.
41
42
  */
42
- declare const insights: (options?: InsightsOptions) => import("@hot-updater/plugin-core/server-plugin").HotUpdaterPlugin<"insights", {
43
- readonly bundle_events: import("@hot-updater/plugin-core/server-plugin").TableDefinition<{
43
+ declare const insights: (options?: InsightsOptions) => import("@hot-updater/plugin-core").HotUpdaterPlugin<"insights", {
44
+ readonly bundle_events: import("@hot-updater/plugin-core").TableDefinition<{
44
45
  readonly id: {
45
46
  readonly type: "string";
46
47
  readonly maxLength: 36;
@@ -115,7 +116,7 @@ declare const insights: (options?: InsightsOptions) => import("@hot-updater/plug
115
116
  readonly sort: readonly ["received_at_ms"];
116
117
  };
117
118
  }, readonly ["id"]>;
118
- readonly bundle_event_heads: import("@hot-updater/plugin-core/server-plugin").TableDefinition<{
119
+ readonly bundle_event_heads: import("@hot-updater/plugin-core").TableDefinition<{
119
120
  readonly install_id: {
120
121
  readonly type: "string";
121
122
  readonly maxLength: 255;
@@ -168,13 +169,13 @@ declare const insights: (options?: InsightsOptions) => import("@hot-updater/plug
168
169
  readonly received_at_ms: {
169
170
  readonly type: "integer";
170
171
  };
171
- }, Readonly<Record<string, import("@hot-updater/plugin-core/server-plugin").FieldType>>, {
172
+ }, Readonly<Record<string, import("@hot-updater/plugin-core").FieldType>>, {
172
173
  readonly byUser: {
173
174
  readonly eq: readonly ["user_id"];
174
175
  readonly sort: readonly ["install_id"];
175
176
  };
176
177
  }, readonly ["install_id"]>;
177
- readonly insights_overview: import("@hot-updater/plugin-core/server-plugin").AggregateDefinition<{
178
+ readonly insights_overview: import("@hot-updater/plugin-core").AggregateDefinition<{
178
179
  readonly identity: {
179
180
  readonly type: "string";
180
181
  readonly maxLength: 32;
@@ -188,7 +189,7 @@ declare const insights: (options?: InsightsOptions) => import("@hot-updater/plug
188
189
  readonly sort: readonly ["bucket_start_ms"];
189
190
  };
190
191
  }, never, readonly ["identity", "bucket_start_ms"]>;
191
- readonly insights_sketches: import("@hot-updater/plugin-core/server-plugin").AggregateDefinition<{
192
+ readonly insights_sketches: import("@hot-updater/plugin-core").AggregateDefinition<{
192
193
  readonly identity: {
193
194
  readonly type: "string";
194
195
  readonly maxLength: 32;
@@ -202,7 +203,7 @@ declare const insights: (options?: InsightsOptions) => import("@hot-updater/plug
202
203
  readonly sort: readonly ["bucket_start_ms"];
203
204
  };
204
205
  }, "launch_users" | "activity_users" | "failed_users", readonly ["identity", "bucket_start_ms"]>;
205
- readonly insights_overview_daily: import("@hot-updater/plugin-core/server-plugin").AggregateDefinition<{
206
+ readonly insights_overview_daily: import("@hot-updater/plugin-core").AggregateDefinition<{
206
207
  readonly identity: {
207
208
  readonly type: "string";
208
209
  readonly maxLength: 32;
@@ -216,7 +217,7 @@ declare const insights: (options?: InsightsOptions) => import("@hot-updater/plug
216
217
  readonly sort: readonly ["bucket_start_ms"];
217
218
  };
218
219
  }, never, readonly ["identity", "bucket_start_ms"]>;
219
- readonly insights_sketches_daily: import("@hot-updater/plugin-core/server-plugin").AggregateDefinition<{
220
+ readonly insights_sketches_daily: import("@hot-updater/plugin-core").AggregateDefinition<{
220
221
  readonly identity: {
221
222
  readonly type: "string";
222
223
  readonly maxLength: 32;
@@ -230,7 +231,7 @@ declare const insights: (options?: InsightsOptions) => import("@hot-updater/plug
230
231
  readonly sort: readonly ["bucket_start_ms"];
231
232
  };
232
233
  }, "launch_users" | "activity_users" | "failed_users", readonly ["identity", "bucket_start_ms"]>;
233
- readonly insights_overview_lifetime: import("@hot-updater/plugin-core/server-plugin").AggregateDefinition<{
234
+ readonly insights_overview_lifetime: import("@hot-updater/plugin-core").AggregateDefinition<{
234
235
  readonly identity: {
235
236
  readonly type: "string";
236
237
  readonly maxLength: 32;
@@ -244,7 +245,7 @@ declare const insights: (options?: InsightsOptions) => import("@hot-updater/plug
244
245
  readonly sort: readonly ["bucket_start_ms"];
245
246
  };
246
247
  }, never, readonly ["identity", "bucket_start_ms"]>;
247
- readonly insights_sketches_lifetime: import("@hot-updater/plugin-core/server-plugin").AggregateDefinition<{
248
+ readonly insights_sketches_lifetime: import("@hot-updater/plugin-core").AggregateDefinition<{
248
249
  readonly identity: {
249
250
  readonly type: "string";
250
251
  readonly maxLength: 32;
@@ -258,7 +259,7 @@ declare const insights: (options?: InsightsOptions) => import("@hot-updater/plug
258
259
  readonly sort: readonly ["bucket_start_ms"];
259
260
  };
260
261
  }, "failed_users", readonly ["identity", "bucket_start_ms"]>;
261
- readonly insights_distribution: import("@hot-updater/plugin-core/server-plugin").AggregateDefinition<{
262
+ readonly insights_distribution: import("@hot-updater/plugin-core").AggregateDefinition<{
262
263
  readonly channel: {
263
264
  readonly type: "string";
264
265
  };
@@ -286,7 +287,7 @@ declare const insights: (options?: InsightsOptions) => import("@hot-updater/plug
286
287
  readonly sort: readonly ["bucket_start_ms"];
287
288
  };
288
289
  }, never, readonly ["channel", "platform", "app_version", "release_id", "bucket_start_ms"]>;
289
- readonly insights_latest_by_bundle: import("@hot-updater/plugin-core/server-plugin").AggregateDefinition<{
290
+ readonly insights_latest_by_bundle: import("@hot-updater/plugin-core").AggregateDefinition<{
290
291
  readonly platform: {
291
292
  readonly type: "string";
292
293
  readonly maxLength: 16;
@@ -315,7 +316,7 @@ declare const insights: (options?: InsightsOptions) => import("@hot-updater/plug
315
316
  readonly sort: readonly ["bucket_start_ms"];
316
317
  };
317
318
  }, never, readonly ["platform", "channel", "bundle_field", "bundle_id", "type", "bucket_start_ms"]>;
318
- readonly insights_outcomes: import("@hot-updater/plugin-core/server-plugin").AggregateDefinition<{
319
+ readonly insights_outcomes: import("@hot-updater/plugin-core").AggregateDefinition<{
319
320
  readonly platform: {
320
321
  readonly type: "string";
321
322
  readonly maxLength: 16;
@@ -340,7 +341,7 @@ declare const insights: (options?: InsightsOptions) => import("@hot-updater/plug
340
341
  readonly sort: readonly ["bucket_start_ms"];
341
342
  };
342
343
  }, never, readonly ["platform", "channel", "type", "bundle_ref", "bucket_start_ms"]>;
343
- readonly insights_failures: import("@hot-updater/plugin-core/server-plugin").AggregateDefinition<{
344
+ readonly insights_failures: import("@hot-updater/plugin-core").AggregateDefinition<{
344
345
  readonly platform: {
345
346
  readonly type: "string";
346
347
  readonly maxLength: 16;
@@ -391,4 +392,4 @@ declare const insights: (options?: InsightsOptions) => import("@hot-updater/plug
391
392
  endpoints: PluginEndpoint[];
392
393
  }, {}>;
393
394
  //#endregion
394
- export { type ActiveInstallationWindow, type BundleEventFailure, type BundleEventFailureInput, type BundleEventFailureReason, type BundleEventFailureStage, type BundleEventRow, type BundleEventRowBase, type CreateBundleEventRequest, type CreateBundleEventRequestBase, type CursorPage, DEFAULT_INSIGHTS_RETENTION, type DatabaseBundleEventMetadata, type EventCursorPage, type EventHistoryRow, InsightsApi, type InsightsBundleEventFilter, type InsightsBundleSelection, type InsightsCountEventsInput, type InsightsCountLatestEventsInput, type InsightsCountMeasurement, type InsightsCoverage, type InsightsEventCursor, type InsightsEventFilter, type InsightsEventPageInput, type InsightsFailureBreakdown, type InsightsFindLatestEventsInput, type InsightsGetAppUsageInput, type InsightsGetAppUsageResult, type InsightsGetReleaseActivityInput, type InsightsGetReleaseActivityResult, type InsightsIdentityParts, type InsightsInstallationEventPageInput, type InsightsListEventsInput, type InsightsModel, InsightsOptions, type InsightsProvider, type InsightsRecordEventInput, type InsightsRetention, type InsightsSchema, type InsightsScope, type InsightsTimeRange, type InsightsUpdateFailures, type InsightsUpdateFailuresInput, type InsightsUserInstallationPageInput, type InstallationHistoryRow, type InstallationRow, type ReleaseActivityMetrics, type ReleaseReference, type ReportingOverview, createInsightsModel, createInsightsProvider, createInsightsSchema, insights, insightsIdentity, insightsSchema };
395
+ export { type ActiveInstallationWindow, type BundleEventFailure, type BundleEventFailureInput, type BundleEventFailureReason, type BundleEventFailureStage, type BundleEventRow, type BundleEventRowBase, type CreateBundleEventRequest, type CreateBundleEventRequestBase, type CursorPage, DEFAULT_INSIGHTS_RETENTION, type DatabaseBundleEventMetadata, type EventCursorPage, type EventHistoryRow, InsightsApi, InsightsBadRequestError, type InsightsBundleEventFilter, type InsightsBundleSelection, type InsightsCountEventsInput, type InsightsCountLatestEventsInput, type InsightsCountMeasurement, type InsightsCoverage, type InsightsEventCursor, type InsightsEventFilter, type InsightsEventPageInput, type InsightsFailureBreakdown, type InsightsFindLatestEventsInput, type InsightsGetAppUsageInput, type InsightsGetAppUsageResult, type InsightsGetReleaseActivityInput, type InsightsGetReleaseActivityResult, type InsightsIdentityParts, type InsightsInstallationEventPageInput, type InsightsListEventsInput, type InsightsModel, InsightsOptions, type InsightsProvider, type InsightsRecordEventInput, type InsightsRetention, type InsightsSchema, type InsightsScope, type InsightsTimeRange, type InsightsUpdateFailures, type InsightsUpdateFailuresInput, type InsightsUserInstallationPageInput, type InstallationHistoryRow, type InstallationRow, type ReleaseActivityMetrics, type ReleaseReference, type ReportingOverview, createInsightsModel, createInsightsProvider, createInsightsSchema, insights, insightsIdentity, insightsSchema };
@@ -1,12 +1,12 @@
1
1
  import { createInsightsModel } from "./model.mjs";
2
+ import { markOfficial } from "./official.mjs";
3
+ import { InsightsBadRequestError } from "./errors.mjs";
2
4
  import { createInsightsProvider } from "./provider.mjs";
3
5
  import { DEFAULT_INSIGHTS_RETENTION, createInsightsSchema, insightsSchema } from "./schema.mjs";
4
6
  import { insightsIdentity, recordEvent } from "./recordEvent.mjs";
5
7
  import { countEvents, countLatestEvents, findLatestEvents, getAppUsage, getReleaseActivity, getUpdateFailures, listEvents } from "./reads.mjs";
6
8
  import { INSIGHTS_ROUTES, createInsightsRouteHandlers } from "./routes.mjs";
7
- import { DatabaseAdapterInputError } from "@hot-updater/plugin-core";
8
- import { markOfficial } from "@hot-updater/plugin-core/internal";
9
- import { HotUpdaterConfigError, definePlugin, isDatabaseBusyError } from "@hot-updater/plugin-core/server-plugin";
9
+ import { DatabaseAdapterInputError, HotUpdaterConfigError, definePlugin, isDatabaseBusyError } from "@hot-updater/plugin-core";
10
10
  //#region src/server/index.ts
11
11
  const createInsightsApi = (db, now, retention) => ({
12
12
  /** How long this plugin keeps its rows. */
@@ -111,11 +111,11 @@ const insights = (options = {}) => {
111
111
  };
112
112
  },
113
113
  cli: { clientPlugin: {
114
- module: "@hot-updater/react-native/plugins/insights",
114
+ module: "@hot-updater/react-native",
115
115
  name: "insights"
116
116
  } }
117
117
  });
118
118
  return markOfficial(plugin);
119
119
  };
120
120
  //#endregion
121
- export { DEFAULT_INSIGHTS_RETENTION, createInsightsModel, createInsightsProvider, createInsightsSchema, insights, insightsIdentity, insightsSchema };
121
+ export { DEFAULT_INSIGHTS_RETENTION, InsightsBadRequestError, createInsightsModel, createInsightsProvider, createInsightsSchema, insights, insightsIdentity, insightsSchema };
@@ -0,0 +1,12 @@
1
+ //#region src/server/official.ts
2
+ /**
3
+ * The brand of Hot Updater's own plugins, a registered symbol that
4
+ * `@hot-updater/server` reads to reserve the id "insights" for this plugin.
5
+ * Each official plugin package keeps this copy, so none imports another's
6
+ * internals for it.
7
+ */
8
+ const OFFICIAL = Symbol.for("@hot-updater/server/official-plugin");
9
+ /** Marks a plugin one of Hot Updater's own factories made. */
10
+ const markOfficial = (plugin) => Object.defineProperty(plugin, OFFICIAL, { value: true });
11
+ //#endregion
12
+ exports.markOfficial = markOfficial;
@@ -0,0 +1,12 @@
1
+ //#region src/server/official.ts
2
+ /**
3
+ * The brand of Hot Updater's own plugins, a registered symbol that
4
+ * `@hot-updater/server` reads to reserve the id "insights" for this plugin.
5
+ * Each official plugin package keeps this copy, so none imports another's
6
+ * internals for it.
7
+ */
8
+ const OFFICIAL = Symbol.for("@hot-updater/server/official-plugin");
9
+ /** Marks a plugin one of Hot Updater's own factories made. */
10
+ const markOfficial = (plugin) => Object.defineProperty(plugin, OFFICIAL, { value: true });
11
+ //#endregion
12
+ export { markOfficial };