@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
package/dist/handler.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { HandlerAPI, HotUpdaterHandler, HotUpdaterHandlers } from "./handlerTypes.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/handler.d.ts
|
|
4
3
|
declare function createHandlers(api: HandlerAPI): HotUpdaterHandlers;
|
|
5
4
|
//#endregion
|
|
6
|
-
export { createHandlers };
|
|
5
|
+
export { type HandlerAPI, type HotUpdaterHandler, type HotUpdaterHandlers, createHandlers };
|
package/dist/handler.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { createAnalyticsRouteHandlers, registerAnalyticsAdminRoutes, registerAnalyticsClientRoutes } from "./analytics/routes.mjs";
|
|
2
1
|
import { HandlerBadRequestError } from "./handlerErrors.mjs";
|
|
3
2
|
import { createBundleRouteHandlers } from "./handlerBundleRoutes.mjs";
|
|
4
3
|
import { createReleaseCatalogRouteHandlers } from "./handlerReleaseCatalogRoutes.mjs";
|
|
5
4
|
import { createReleaseManagementRouteHandlers } from "./handlerReleaseManagementRoutes.mjs";
|
|
6
5
|
import { createVersionRouteHandlers } from "./handlerVersionRoutes.mjs";
|
|
6
|
+
import { createInsightsRouteHandlers, registerInsightsAdminRoutes, registerInsightsClientRoutes } from "./insights/routes.mjs";
|
|
7
7
|
import { addRoute, createRouter, findRoute } from "./internalRouter.mjs";
|
|
8
8
|
//#region src/handler.ts
|
|
9
9
|
const withPrivateNoStore = (response) => {
|
|
@@ -63,13 +63,13 @@ const createDownloadStorageRouteHandler = (downloadStorageObject) => async (para
|
|
|
63
63
|
function createHandlers(api) {
|
|
64
64
|
return createHotUpdaterHandlers(api);
|
|
65
65
|
}
|
|
66
|
-
function createHotUpdaterHandlers(api,
|
|
66
|
+
function createHotUpdaterHandlers(api, insights, apiKeyAuth, downloadStorageObject) {
|
|
67
67
|
const routeHandlers = {
|
|
68
68
|
...createVersionRouteHandlers(),
|
|
69
69
|
...createReleaseCatalogRouteHandlers(apiKeyAuth?.headerName),
|
|
70
70
|
...createReleaseManagementRouteHandlers(),
|
|
71
71
|
...createBundleRouteHandlers(),
|
|
72
|
-
...
|
|
72
|
+
...insights === void 0 ? {} : createInsightsRouteHandlers(insights),
|
|
73
73
|
...downloadStorageObject === void 0 ? {} : { downloadStorageObject: createDownloadStorageRouteHandler(downloadStorageObject) }
|
|
74
74
|
};
|
|
75
75
|
const clientRouter = createRouter();
|
|
@@ -79,7 +79,7 @@ function createHotUpdaterHandlers(api, analytics, apiKeyAuth, downloadStorageObj
|
|
|
79
79
|
addClientRoute("GET", "/release-catalogs/app-version/:platform/:channelKey/:appVersion", "appVersionReleaseCatalog");
|
|
80
80
|
addClientRoute("GET", "/release-catalogs/fingerprint/:platform/:channelKey/:fingerprintHash", "fingerprintReleaseCatalog");
|
|
81
81
|
addClientRoute("GET", "/artifacts/:targetBundleId/from/:currentBundleId", "artifact");
|
|
82
|
-
if (
|
|
82
|
+
if (insights !== void 0) registerInsightsClientRoutes(addClientRoute);
|
|
83
83
|
const adminRouter = createRouter();
|
|
84
84
|
const addAdminRoute = (method, path, handler) => addRoute(adminRouter, method, path, handler);
|
|
85
85
|
addAdminRoute("GET", "/releases/:id", "getRelease");
|
|
@@ -99,7 +99,7 @@ function createHotUpdaterHandlers(api, analytics, apiKeyAuth, downloadStorageObj
|
|
|
99
99
|
addAdminRoute("POST", "/bundles", "createBundles");
|
|
100
100
|
addAdminRoute("PATCH", "/bundles/:id", "updateBundle");
|
|
101
101
|
addAdminRoute("DELETE", "/bundles/:id", "deleteBundle");
|
|
102
|
-
if (
|
|
102
|
+
if (insights !== void 0) registerInsightsAdminRoutes(addAdminRoute);
|
|
103
103
|
return Object.freeze({
|
|
104
104
|
client: createRequestHandler({
|
|
105
105
|
api,
|
package/dist/handlerTypes.d.cts
CHANGED
|
@@ -2,7 +2,6 @@ import { ReleaseCatalogRequest } from "./db/releaseCatalog.cjs";
|
|
|
2
2
|
import { PaginatedResult } from "./types/index.cjs";
|
|
3
3
|
import { ArtifactInfo, Bundle, ReleaseCatalog } from "@hot-updater/core";
|
|
4
4
|
import { ChannelDeleteInput, ChannelDeleteResult, ChannelInsertInput, ChannelInsertResult, ChannelRow, DatabaseBundleQueryOptions, DatabaseCommit, DatabaseCommitResult, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildResult, ReleaseCatalogRow, ReleasePolicyPatch, ReleaseRow } from "@hot-updater/plugin-core";
|
|
5
|
-
|
|
6
5
|
//#region src/handlerTypes.d.ts
|
|
7
6
|
interface HandlerAPI {
|
|
8
7
|
getReleaseCatalog?: (input: ReleaseCatalogRequest) => Promise<ReleaseCatalog | null>;
|
package/dist/handlerTypes.d.mts
CHANGED
|
@@ -2,7 +2,6 @@ import { ReleaseCatalogRequest } from "./db/releaseCatalog.mjs";
|
|
|
2
2
|
import { PaginatedResult } from "./types/index.mjs";
|
|
3
3
|
import { ChannelDeleteInput, ChannelDeleteResult, ChannelInsertInput, ChannelInsertResult, ChannelRow, DatabaseBundleQueryOptions, DatabaseCommit, DatabaseCommitResult, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildResult, ReleaseCatalogRow, ReleasePolicyPatch, ReleaseRow } from "@hot-updater/plugin-core";
|
|
4
4
|
import { ArtifactInfo, Bundle as Bundle$1, ReleaseCatalog } from "@hot-updater/core";
|
|
5
|
-
|
|
6
5
|
//#region src/handlerTypes.d.ts
|
|
7
6
|
interface HandlerAPI {
|
|
8
7
|
getReleaseCatalog?: (input: ReleaseCatalogRequest) => Promise<ReleaseCatalog | null>;
|
package/dist/index.cjs
CHANGED
|
@@ -2,15 +2,15 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_version = require("./version.cjs");
|
|
3
3
|
const require_handlerVersionRoutes = require("./handlerVersionRoutes.cjs");
|
|
4
4
|
const require_handler = require("./handler.cjs");
|
|
5
|
-
const require_provider = require("./
|
|
5
|
+
const require_provider = require("./insights/provider.cjs");
|
|
6
6
|
const require_apiKeys = require("./apiKeys.cjs");
|
|
7
7
|
const require_createHotUpdaterCore = require("./createHotUpdaterCore.cjs");
|
|
8
8
|
exports.API_KEY_HEADER_NAME = require_apiKeys.API_KEY_HEADER_NAME;
|
|
9
9
|
exports.HOT_UPDATER_INFRASTRUCTURE_GENERATION = require_handlerVersionRoutes.HOT_UPDATER_INFRASTRUCTURE_GENERATION;
|
|
10
10
|
exports.HOT_UPDATER_SERVER_VERSION = require_version.HOT_UPDATER_SERVER_VERSION;
|
|
11
|
-
exports.createAnalyticsProvider = require_provider.createAnalyticsProvider;
|
|
12
11
|
exports.createApiKey = require_apiKeys.createApiKey;
|
|
13
12
|
exports.createHandlers = require_handler.createHandlers;
|
|
14
13
|
exports.createHotUpdater = require_createHotUpdaterCore.createHotUpdater;
|
|
14
|
+
exports.createInsightsProvider = require_provider.createInsightsProvider;
|
|
15
15
|
exports.provisionApiKey = require_apiKeys.provisionApiKey;
|
|
16
16
|
exports.registerApiKey = require_apiKeys.registerApiKey;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ActiveInstallationInput, ActiveInstallationOverview, ActiveInstallationWindow, AnalyticsCohortPoint, AnalyticsSeriesPoint, BundleEventAnalyticsResult, BundleEventAnalyticsWindow, BundleEventOverview, BundleEventSummary, BundleEventSummaryByBundle, CreateBundleEventRequest, CreateBundleEventRequestBase, InstallationHistoryRow, InstallationSearchRow, OffsetPaginationResult } from "./analytics/domain.cjs";
|
|
2
|
-
import { AnalyticsProvider } from "./analytics/types.cjs";
|
|
3
1
|
import { API_KEY_HEADER_NAME, ApiKeyManagementAPI, ApiKeyMetadata, CreatedApiKey, createApiKey, provisionApiKey, registerApiKey } from "./apiKeys.cjs";
|
|
4
2
|
import { HandlerAPI, HotUpdaterHandler, HotUpdaterHandlers } from "./handlerTypes.cjs";
|
|
3
|
+
import { ActiveInstallationWindow, CreateBundleEventRequest, CreateBundleEventRequestBase, CursorPage, EventCursorPage, EventHistoryRow, InsightsBundleSelection, InsightsCountMeasurement, InsightsScope, InstallationHistoryRow, InstallationRow, ReportingOverview } from "./insights/domain.cjs";
|
|
4
|
+
import { InsightsEventPageInput, InsightsInstallationEventPageInput, InsightsProvider, InsightsUserInstallationPageInput } from "./insights/types.cjs";
|
|
5
5
|
import { createHandlers } from "./handler.cjs";
|
|
6
6
|
import { ClientAccessPolicy, CreateHotUpdaterOptions, HotUpdaterAPI, RuntimeHotUpdaterAPI, createHotUpdater } from "./createHotUpdaterCore.cjs";
|
|
7
7
|
import { Bundle, ChannelsResponse, DataResponse, Paginated, PaginatedResult, PaginationInfo, PaginationOptions } from "./types/index.cjs";
|
|
8
8
|
import { HOT_UPDATER_SERVER_VERSION } from "./version.cjs";
|
|
9
|
-
import {
|
|
9
|
+
import { createInsightsProvider } from "./insights/provider.cjs";
|
|
10
10
|
import { HOT_UPDATER_INFRASTRUCTURE_GENERATION } from "./handlerVersionRoutes.cjs";
|
|
11
|
-
export { API_KEY_HEADER_NAME,
|
|
11
|
+
export { API_KEY_HEADER_NAME, type ActiveInstallationWindow, type ApiKeyManagementAPI, type ApiKeyMetadata, type Bundle, ChannelsResponse, type ClientAccessPolicy, type CreateBundleEventRequest, type CreateBundleEventRequestBase, type CreateHotUpdaterOptions, type CreatedApiKey, type CursorPage, DataResponse, type EventCursorPage, type EventHistoryRow, HOT_UPDATER_INFRASTRUCTURE_GENERATION, HOT_UPDATER_SERVER_VERSION, type HandlerAPI, type HotUpdaterAPI, type HotUpdaterHandler, type HotUpdaterHandlers, type InsightsBundleSelection, type InsightsCountMeasurement, type InsightsEventPageInput, type InsightsInstallationEventPageInput, type InsightsProvider, type InsightsScope, type InsightsUserInstallationPageInput, type InstallationHistoryRow, type InstallationRow, Paginated, PaginatedResult, PaginationInfo, PaginationOptions, type ReportingOverview, type RuntimeHotUpdaterAPI, createApiKey, createHandlers, createHotUpdater, createInsightsProvider, provisionApiKey, registerApiKey };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ActiveInstallationInput, ActiveInstallationOverview, ActiveInstallationWindow, AnalyticsCohortPoint, AnalyticsSeriesPoint, BundleEventAnalyticsResult, BundleEventAnalyticsWindow, BundleEventOverview, BundleEventSummary, BundleEventSummaryByBundle, CreateBundleEventRequest, CreateBundleEventRequestBase, InstallationHistoryRow, InstallationSearchRow, OffsetPaginationResult } from "./analytics/domain.mjs";
|
|
2
|
-
import { AnalyticsProvider } from "./analytics/types.mjs";
|
|
3
1
|
import { API_KEY_HEADER_NAME, ApiKeyManagementAPI, ApiKeyMetadata, CreatedApiKey, createApiKey, provisionApiKey, registerApiKey } from "./apiKeys.mjs";
|
|
4
2
|
import { HandlerAPI, HotUpdaterHandler, HotUpdaterHandlers } from "./handlerTypes.mjs";
|
|
3
|
+
import { ActiveInstallationWindow, CreateBundleEventRequest, CreateBundleEventRequestBase, CursorPage, EventCursorPage, EventHistoryRow, InsightsBundleSelection, InsightsCountMeasurement, InsightsScope, InstallationHistoryRow, InstallationRow, ReportingOverview } from "./insights/domain.mjs";
|
|
4
|
+
import { InsightsEventPageInput, InsightsInstallationEventPageInput, InsightsProvider, InsightsUserInstallationPageInput } from "./insights/types.mjs";
|
|
5
5
|
import { createHandlers } from "./handler.mjs";
|
|
6
6
|
import { ClientAccessPolicy, CreateHotUpdaterOptions, HotUpdaterAPI, RuntimeHotUpdaterAPI, createHotUpdater } from "./createHotUpdaterCore.mjs";
|
|
7
7
|
import { Bundle, ChannelsResponse, DataResponse, Paginated, PaginatedResult, PaginationInfo, PaginationOptions } from "./types/index.mjs";
|
|
8
8
|
import { HOT_UPDATER_SERVER_VERSION } from "./version.mjs";
|
|
9
|
-
import {
|
|
9
|
+
import { createInsightsProvider } from "./insights/provider.mjs";
|
|
10
10
|
import { HOT_UPDATER_INFRASTRUCTURE_GENERATION } from "./handlerVersionRoutes.mjs";
|
|
11
|
-
export { API_KEY_HEADER_NAME,
|
|
11
|
+
export { API_KEY_HEADER_NAME, type ActiveInstallationWindow, type ApiKeyManagementAPI, type ApiKeyMetadata, type Bundle, ChannelsResponse, type ClientAccessPolicy, type CreateBundleEventRequest, type CreateBundleEventRequestBase, type CreateHotUpdaterOptions, type CreatedApiKey, type CursorPage, DataResponse, type EventCursorPage, type EventHistoryRow, HOT_UPDATER_INFRASTRUCTURE_GENERATION, HOT_UPDATER_SERVER_VERSION, type HandlerAPI, type HotUpdaterAPI, type HotUpdaterHandler, type HotUpdaterHandlers, type InsightsBundleSelection, type InsightsCountMeasurement, type InsightsEventPageInput, type InsightsInstallationEventPageInput, type InsightsProvider, type InsightsScope, type InsightsUserInstallationPageInput, type InstallationHistoryRow, type InstallationRow, Paginated, PaginatedResult, PaginationInfo, PaginationOptions, type ReportingOverview, type RuntimeHotUpdaterAPI, createApiKey, createHandlers, createHotUpdater, createInsightsProvider, provisionApiKey, registerApiKey };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HOT_UPDATER_SERVER_VERSION } from "./version.mjs";
|
|
2
2
|
import { HOT_UPDATER_INFRASTRUCTURE_GENERATION } from "./handlerVersionRoutes.mjs";
|
|
3
3
|
import { createHandlers } from "./handler.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { createInsightsProvider } from "./insights/provider.mjs";
|
|
5
5
|
import { API_KEY_HEADER_NAME, createApiKey, provisionApiKey, registerApiKey } from "./apiKeys.mjs";
|
|
6
6
|
import { createHotUpdater } from "./createHotUpdaterCore.mjs";
|
|
7
|
-
export { API_KEY_HEADER_NAME, HOT_UPDATER_INFRASTRUCTURE_GENERATION, HOT_UPDATER_SERVER_VERSION,
|
|
7
|
+
export { API_KEY_HEADER_NAME, HOT_UPDATER_INFRASTRUCTURE_GENERATION, HOT_UPDATER_SERVER_VERSION, createApiKey, createHandlers, createHotUpdater, createInsightsProvider, provisionApiKey, registerApiKey };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
//#region src/insights/domain.d.ts
|
|
2
|
+
type CreateBundleEventRequestBase = {
|
|
3
|
+
readonly installId: string;
|
|
4
|
+
readonly toBundleId: string;
|
|
5
|
+
readonly userId?: string;
|
|
6
|
+
readonly username?: string;
|
|
7
|
+
readonly platform: "ios" | "android";
|
|
8
|
+
readonly appVersion: string;
|
|
9
|
+
readonly channel: string;
|
|
10
|
+
readonly cohort: string;
|
|
11
|
+
readonly fingerprintHash: string | null;
|
|
12
|
+
readonly sdkVersion?: string | null;
|
|
13
|
+
readonly fromReleaseId: string | null;
|
|
14
|
+
readonly toReleaseId: string | null;
|
|
15
|
+
};
|
|
16
|
+
type CreateBundleEventRequest = (CreateBundleEventRequestBase & {
|
|
17
|
+
readonly type: "UPDATE_DOWNLOADED" | "UPDATE_APPLIED" | "RECOVERED";
|
|
18
|
+
readonly fromBundleId: string;
|
|
19
|
+
readonly updateStrategy: "fingerprint" | "appVersion";
|
|
20
|
+
}) | (CreateBundleEventRequestBase & {
|
|
21
|
+
readonly type: "UNCHANGED";
|
|
22
|
+
readonly fromBundleId: null;
|
|
23
|
+
readonly updateStrategy: null;
|
|
24
|
+
});
|
|
25
|
+
type ActiveInstallationWindow = "24h" | "7d" | "30d";
|
|
26
|
+
type EventHistoryRow = {
|
|
27
|
+
readonly id: string;
|
|
28
|
+
readonly installId: string;
|
|
29
|
+
readonly type: "UPDATE_DOWNLOADED" | "UPDATE_APPLIED" | "RECOVERED" | "UNCHANGED";
|
|
30
|
+
readonly fromBundleId: string | null;
|
|
31
|
+
readonly toBundleId: string;
|
|
32
|
+
readonly username: string | null;
|
|
33
|
+
readonly userId: string | null;
|
|
34
|
+
readonly platform: "ios" | "android";
|
|
35
|
+
readonly appVersion: string;
|
|
36
|
+
readonly channel: string;
|
|
37
|
+
readonly cohort: string;
|
|
38
|
+
readonly receivedAtMs: number;
|
|
39
|
+
};
|
|
40
|
+
type InstallationHistoryRow = EventHistoryRow & {
|
|
41
|
+
readonly type: "UPDATE_DOWNLOADED" | "UPDATE_APPLIED" | "RECOVERED";
|
|
42
|
+
readonly fromBundleId: string;
|
|
43
|
+
};
|
|
44
|
+
type InstallationRow = {
|
|
45
|
+
readonly installId: string;
|
|
46
|
+
readonly username: string | null;
|
|
47
|
+
readonly userId: string | null;
|
|
48
|
+
readonly lastKnownBundleId: string;
|
|
49
|
+
readonly pendingBundleId: string | null;
|
|
50
|
+
readonly pendingReleaseId: string | null;
|
|
51
|
+
readonly latestStatus: EventHistoryRow["type"];
|
|
52
|
+
readonly platform: "ios" | "android";
|
|
53
|
+
readonly appVersion: string;
|
|
54
|
+
readonly channel: string;
|
|
55
|
+
readonly cohort: string;
|
|
56
|
+
readonly receivedAtMs: number;
|
|
57
|
+
};
|
|
58
|
+
type CursorPage<T> = {
|
|
59
|
+
readonly data: readonly T[];
|
|
60
|
+
readonly nextCursor: string | null;
|
|
61
|
+
};
|
|
62
|
+
type EventCursorPage<T extends EventHistoryRow> = CursorPage<T> & {
|
|
63
|
+
readonly beforeReceivedAtMs: number;
|
|
64
|
+
};
|
|
65
|
+
type InsightsScope = {
|
|
66
|
+
readonly platform: "ios" | "android";
|
|
67
|
+
readonly channel: string;
|
|
68
|
+
};
|
|
69
|
+
type InsightsBundleSelection = InsightsScope & {
|
|
70
|
+
readonly bundleId: string;
|
|
71
|
+
readonly outcome: "downloaded" | "applied" | "recovered" | "unchanged";
|
|
72
|
+
};
|
|
73
|
+
type InsightsCountMeasurement = {
|
|
74
|
+
readonly count: number;
|
|
75
|
+
readonly measuredAtMs: number;
|
|
76
|
+
};
|
|
77
|
+
type ReportingOverview = InsightsScope & {
|
|
78
|
+
readonly window: ActiveInstallationWindow;
|
|
79
|
+
readonly sinceMs: number;
|
|
80
|
+
readonly beforeReceivedAtMs: number;
|
|
81
|
+
readonly reportingInstallations: InsightsCountMeasurement;
|
|
82
|
+
readonly bundle?: {
|
|
83
|
+
readonly bundleId: string;
|
|
84
|
+
readonly reportingInstallations: InsightsCountMeasurement;
|
|
85
|
+
readonly downloadedReports: InsightsCountMeasurement;
|
|
86
|
+
readonly appliedReports: InsightsCountMeasurement;
|
|
87
|
+
readonly recoveredReports: InsightsCountMeasurement;
|
|
88
|
+
readonly unchangedReports: InsightsCountMeasurement;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
//#endregion
|
|
92
|
+
export { ActiveInstallationWindow, CreateBundleEventRequest, CreateBundleEventRequestBase, CursorPage, EventCursorPage, EventHistoryRow, InsightsBundleSelection, InsightsCountMeasurement, InsightsScope, InstallationHistoryRow, InstallationRow, ReportingOverview };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
//#region src/insights/domain.d.ts
|
|
2
|
+
type CreateBundleEventRequestBase = {
|
|
3
|
+
readonly installId: string;
|
|
4
|
+
readonly toBundleId: string;
|
|
5
|
+
readonly userId?: string;
|
|
6
|
+
readonly username?: string;
|
|
7
|
+
readonly platform: "ios" | "android";
|
|
8
|
+
readonly appVersion: string;
|
|
9
|
+
readonly channel: string;
|
|
10
|
+
readonly cohort: string;
|
|
11
|
+
readonly fingerprintHash: string | null;
|
|
12
|
+
readonly sdkVersion?: string | null;
|
|
13
|
+
readonly fromReleaseId: string | null;
|
|
14
|
+
readonly toReleaseId: string | null;
|
|
15
|
+
};
|
|
16
|
+
type CreateBundleEventRequest = (CreateBundleEventRequestBase & {
|
|
17
|
+
readonly type: "UPDATE_DOWNLOADED" | "UPDATE_APPLIED" | "RECOVERED";
|
|
18
|
+
readonly fromBundleId: string;
|
|
19
|
+
readonly updateStrategy: "fingerprint" | "appVersion";
|
|
20
|
+
}) | (CreateBundleEventRequestBase & {
|
|
21
|
+
readonly type: "UNCHANGED";
|
|
22
|
+
readonly fromBundleId: null;
|
|
23
|
+
readonly updateStrategy: null;
|
|
24
|
+
});
|
|
25
|
+
type ActiveInstallationWindow = "24h" | "7d" | "30d";
|
|
26
|
+
type EventHistoryRow = {
|
|
27
|
+
readonly id: string;
|
|
28
|
+
readonly installId: string;
|
|
29
|
+
readonly type: "UPDATE_DOWNLOADED" | "UPDATE_APPLIED" | "RECOVERED" | "UNCHANGED";
|
|
30
|
+
readonly fromBundleId: string | null;
|
|
31
|
+
readonly toBundleId: string;
|
|
32
|
+
readonly username: string | null;
|
|
33
|
+
readonly userId: string | null;
|
|
34
|
+
readonly platform: "ios" | "android";
|
|
35
|
+
readonly appVersion: string;
|
|
36
|
+
readonly channel: string;
|
|
37
|
+
readonly cohort: string;
|
|
38
|
+
readonly receivedAtMs: number;
|
|
39
|
+
};
|
|
40
|
+
type InstallationHistoryRow = EventHistoryRow & {
|
|
41
|
+
readonly type: "UPDATE_DOWNLOADED" | "UPDATE_APPLIED" | "RECOVERED";
|
|
42
|
+
readonly fromBundleId: string;
|
|
43
|
+
};
|
|
44
|
+
type InstallationRow = {
|
|
45
|
+
readonly installId: string;
|
|
46
|
+
readonly username: string | null;
|
|
47
|
+
readonly userId: string | null;
|
|
48
|
+
readonly lastKnownBundleId: string;
|
|
49
|
+
readonly pendingBundleId: string | null;
|
|
50
|
+
readonly pendingReleaseId: string | null;
|
|
51
|
+
readonly latestStatus: EventHistoryRow["type"];
|
|
52
|
+
readonly platform: "ios" | "android";
|
|
53
|
+
readonly appVersion: string;
|
|
54
|
+
readonly channel: string;
|
|
55
|
+
readonly cohort: string;
|
|
56
|
+
readonly receivedAtMs: number;
|
|
57
|
+
};
|
|
58
|
+
type CursorPage<T> = {
|
|
59
|
+
readonly data: readonly T[];
|
|
60
|
+
readonly nextCursor: string | null;
|
|
61
|
+
};
|
|
62
|
+
type EventCursorPage<T extends EventHistoryRow> = CursorPage<T> & {
|
|
63
|
+
readonly beforeReceivedAtMs: number;
|
|
64
|
+
};
|
|
65
|
+
type InsightsScope = {
|
|
66
|
+
readonly platform: "ios" | "android";
|
|
67
|
+
readonly channel: string;
|
|
68
|
+
};
|
|
69
|
+
type InsightsBundleSelection = InsightsScope & {
|
|
70
|
+
readonly bundleId: string;
|
|
71
|
+
readonly outcome: "downloaded" | "applied" | "recovered" | "unchanged";
|
|
72
|
+
};
|
|
73
|
+
type InsightsCountMeasurement = {
|
|
74
|
+
readonly count: number;
|
|
75
|
+
readonly measuredAtMs: number;
|
|
76
|
+
};
|
|
77
|
+
type ReportingOverview = InsightsScope & {
|
|
78
|
+
readonly window: ActiveInstallationWindow;
|
|
79
|
+
readonly sinceMs: number;
|
|
80
|
+
readonly beforeReceivedAtMs: number;
|
|
81
|
+
readonly reportingInstallations: InsightsCountMeasurement;
|
|
82
|
+
readonly bundle?: {
|
|
83
|
+
readonly bundleId: string;
|
|
84
|
+
readonly reportingInstallations: InsightsCountMeasurement;
|
|
85
|
+
readonly downloadedReports: InsightsCountMeasurement;
|
|
86
|
+
readonly appliedReports: InsightsCountMeasurement;
|
|
87
|
+
readonly recoveredReports: InsightsCountMeasurement;
|
|
88
|
+
readonly unchangedReports: InsightsCountMeasurement;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
//#endregion
|
|
92
|
+
export { ActiveInstallationWindow, CreateBundleEventRequest, CreateBundleEventRequestBase, CursorPage, EventCursorPage, EventHistoryRow, InsightsBundleSelection, InsightsCountMeasurement, InsightsScope, InstallationHistoryRow, InstallationRow, ReportingOverview };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/insights/errors.ts
|
|
2
|
+
var InsightsBadRequestError = class extends Error {
|
|
3
|
+
name = "InsightsBadRequestError";
|
|
4
|
+
};
|
|
5
|
+
var InsightsPayloadTooLargeError = class extends Error {
|
|
6
|
+
maximumBytes;
|
|
7
|
+
name = "InsightsPayloadTooLargeError";
|
|
8
|
+
constructor(maximumBytes) {
|
|
9
|
+
super(`Event payload exceeds ${maximumBytes} bytes`);
|
|
10
|
+
this.maximumBytes = maximumBytes;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
exports.InsightsBadRequestError = InsightsBadRequestError;
|
|
15
|
+
exports.InsightsPayloadTooLargeError = InsightsPayloadTooLargeError;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/insights/errors.ts
|
|
2
|
+
var InsightsBadRequestError = class extends Error {
|
|
3
|
+
name = "InsightsBadRequestError";
|
|
4
|
+
};
|
|
5
|
+
var InsightsPayloadTooLargeError = class extends Error {
|
|
6
|
+
maximumBytes;
|
|
7
|
+
name = "InsightsPayloadTooLargeError";
|
|
8
|
+
constructor(maximumBytes) {
|
|
9
|
+
super(`Event payload exceeds ${maximumBytes} bytes`);
|
|
10
|
+
this.maximumBytes = maximumBytes;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { InsightsBadRequestError, InsightsPayloadTooLargeError };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
const require_errors = require("./errors.cjs");
|
|
2
|
-
|
|
2
|
+
let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
|
|
3
|
+
//#region src/insights/eventInput.ts
|
|
3
4
|
const MAX_EVENT_STRING_LENGTH = 1024;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
5
|
+
const MAX_IDENTITY_LENGTH = 255;
|
|
6
|
+
const EVENT_BODY_MAX_BYTES = 16384;
|
|
7
|
+
const eventKeys = /* @__PURE__ */ new Set([
|
|
6
8
|
"type",
|
|
7
9
|
"installId",
|
|
8
10
|
"toBundleId",
|
|
@@ -24,17 +26,22 @@ function isRecord(value) {
|
|
|
24
26
|
}
|
|
25
27
|
function requireStringField(payload, key) {
|
|
26
28
|
const value = payload[key];
|
|
27
|
-
if (typeof value !== "string" || value.length === 0 || value.length > MAX_EVENT_STRING_LENGTH) throw new require_errors.
|
|
29
|
+
if (typeof value !== "string" || value.length === 0 || value.length > MAX_EVENT_STRING_LENGTH || new TextDecoder("utf-8", { ignoreBOM: true }).decode(new TextEncoder().encode(value)) !== value) throw new require_errors.InsightsBadRequestError(`Invalid event field: ${key}`);
|
|
28
30
|
return value;
|
|
29
31
|
}
|
|
30
32
|
function requireNullableStringField(payload, key) {
|
|
31
33
|
if (payload[key] === null) return null;
|
|
32
34
|
return requireStringField(payload, key);
|
|
33
35
|
}
|
|
36
|
+
function requireIdentityField(payload, key) {
|
|
37
|
+
const value = requireStringField(payload, key);
|
|
38
|
+
if (value.length > MAX_IDENTITY_LENGTH) throw new require_errors.InsightsBadRequestError(`Invalid event field: ${key}`);
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
34
41
|
async function readBoundedText(request) {
|
|
35
42
|
const contentLength = request.headers.get("content-length");
|
|
36
43
|
const declaredByteLength = Number(contentLength);
|
|
37
|
-
if (contentLength !== null && Number.isSafeInteger(declaredByteLength) && declaredByteLength > 16384) throw new require_errors.
|
|
44
|
+
if (contentLength !== null && Number.isSafeInteger(declaredByteLength) && declaredByteLength > 16384) throw new require_errors.InsightsPayloadTooLargeError(EVENT_BODY_MAX_BYTES);
|
|
38
45
|
if (request.body === null) return "";
|
|
39
46
|
const reader = request.body.getReader();
|
|
40
47
|
const decoder = new TextDecoder();
|
|
@@ -46,7 +53,7 @@ async function readBoundedText(request) {
|
|
|
46
53
|
byteLength += result.value.byteLength;
|
|
47
54
|
if (byteLength > 16384) {
|
|
48
55
|
await reader.cancel();
|
|
49
|
-
throw new require_errors.
|
|
56
|
+
throw new require_errors.InsightsPayloadTooLargeError(EVENT_BODY_MAX_BYTES);
|
|
50
57
|
}
|
|
51
58
|
text += decoder.decode(result.value, { stream: true });
|
|
52
59
|
}
|
|
@@ -57,18 +64,18 @@ async function parseJson(request) {
|
|
|
57
64
|
try {
|
|
58
65
|
return JSON.parse(text);
|
|
59
66
|
} catch (error) {
|
|
60
|
-
if (error instanceof SyntaxError) throw new require_errors.
|
|
67
|
+
if (error instanceof SyntaxError) throw new require_errors.InsightsBadRequestError("Invalid event payload");
|
|
61
68
|
throw error;
|
|
62
69
|
}
|
|
63
70
|
}
|
|
64
71
|
function requireEvent(payload) {
|
|
65
|
-
if (!isRecord(payload) || Object.keys(payload).some((key) => !eventKeys.has(key))) throw new require_errors.
|
|
72
|
+
if (!isRecord(payload) || Object.keys(payload).some((key) => !eventKeys.has(key))) throw new require_errors.InsightsBadRequestError("Invalid event payload");
|
|
66
73
|
const platform = requireStringField(payload, "platform");
|
|
67
|
-
if (platform !== "ios" && platform !== "android") throw new require_errors.
|
|
74
|
+
if (platform !== "ios" && platform !== "android") throw new require_errors.InsightsBadRequestError("Invalid event field: platform");
|
|
68
75
|
const base = {
|
|
69
|
-
installId:
|
|
76
|
+
installId: requireIdentityField(payload, "installId"),
|
|
70
77
|
toBundleId: requireStringField(payload, "toBundleId"),
|
|
71
|
-
...payload.userId === void 0 ? {} : { userId:
|
|
78
|
+
...payload.userId === void 0 ? {} : { userId: requireIdentityField(payload, "userId") },
|
|
72
79
|
...payload.username === void 0 ? {} : { username: requireStringField(payload, "username") },
|
|
73
80
|
platform,
|
|
74
81
|
appVersion: requireStringField(payload, "appVersion"),
|
|
@@ -81,11 +88,11 @@ function requireEvent(payload) {
|
|
|
81
88
|
};
|
|
82
89
|
const type = requireStringField(payload, "type");
|
|
83
90
|
switch (type) {
|
|
91
|
+
case "UPDATE_DOWNLOADED":
|
|
84
92
|
case "UPDATE_APPLIED":
|
|
85
|
-
case "RECOVERED":
|
|
86
|
-
case "RELEASE_ADOPTED": {
|
|
93
|
+
case "RECOVERED": {
|
|
87
94
|
const updateStrategy = requireStringField(payload, "updateStrategy");
|
|
88
|
-
if (updateStrategy !== "fingerprint" && updateStrategy !== "appVersion") throw new require_errors.
|
|
95
|
+
if (updateStrategy !== "fingerprint" && updateStrategy !== "appVersion") throw new require_errors.InsightsBadRequestError("Invalid event field: updateStrategy");
|
|
89
96
|
return {
|
|
90
97
|
...base,
|
|
91
98
|
type,
|
|
@@ -94,18 +101,56 @@ function requireEvent(payload) {
|
|
|
94
101
|
};
|
|
95
102
|
}
|
|
96
103
|
case "UNCHANGED":
|
|
97
|
-
if (payload.fromBundleId !== null || payload.updateStrategy !== null) throw new require_errors.
|
|
104
|
+
if (payload.fromBundleId !== null || payload.updateStrategy !== null) throw new require_errors.InsightsBadRequestError("Invalid unchanged event shape");
|
|
98
105
|
return {
|
|
99
106
|
...base,
|
|
100
107
|
type,
|
|
101
108
|
fromBundleId: null,
|
|
102
109
|
updateStrategy: null
|
|
103
110
|
};
|
|
104
|
-
default: throw new require_errors.
|
|
111
|
+
default: throw new require_errors.InsightsBadRequestError("Invalid event field: type");
|
|
105
112
|
}
|
|
106
113
|
}
|
|
107
114
|
async function parseBundleEventRequest(request) {
|
|
108
115
|
return requireEvent(await parseJson(request));
|
|
109
116
|
}
|
|
117
|
+
function createBundleEventRow(input) {
|
|
118
|
+
input = requireEvent(input);
|
|
119
|
+
const base = {
|
|
120
|
+
app_version: input.appVersion,
|
|
121
|
+
channel: input.channel,
|
|
122
|
+
from_release_id: input.fromReleaseId,
|
|
123
|
+
id: (0, _hot_updater_plugin_core.createUUIDv7)(),
|
|
124
|
+
install_id: input.installId,
|
|
125
|
+
platform: input.platform,
|
|
126
|
+
received_at_ms: Date.now(),
|
|
127
|
+
to_bundle_id: input.toBundleId,
|
|
128
|
+
to_release_id: input.toReleaseId,
|
|
129
|
+
user_id: input.userId ?? null,
|
|
130
|
+
metadata: {
|
|
131
|
+
cohort: input.cohort,
|
|
132
|
+
fingerprint_hash: input.fingerprintHash,
|
|
133
|
+
sdk_version: input.sdkVersion ?? null,
|
|
134
|
+
username: input.username ?? null,
|
|
135
|
+
update_strategy: input.updateStrategy
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
switch (input.type) {
|
|
139
|
+
case "UPDATE_DOWNLOADED":
|
|
140
|
+
case "UPDATE_APPLIED":
|
|
141
|
+
case "RECOVERED": return {
|
|
142
|
+
...base,
|
|
143
|
+
from_bundle_id: input.fromBundleId,
|
|
144
|
+
type: input.type
|
|
145
|
+
};
|
|
146
|
+
case "UNCHANGED": return {
|
|
147
|
+
...base,
|
|
148
|
+
from_bundle_id: null,
|
|
149
|
+
type: input.type
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
}
|
|
110
153
|
//#endregion
|
|
154
|
+
exports.EVENT_BODY_MAX_BYTES = EVENT_BODY_MAX_BYTES;
|
|
155
|
+
exports.createBundleEventRow = createBundleEventRow;
|
|
111
156
|
exports.parseBundleEventRequest = parseBundleEventRequest;
|