@hot-updater/server 1.0.0-rc.0 → 1.0.0-rc.1
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/adapters/drizzle.cjs +3 -3
- package/dist/adapters/drizzle.mjs +3 -3
- package/dist/createHotUpdaterCore.cjs +6 -6
- package/dist/createHotUpdaterCore.d.cts +7 -7
- package/dist/createHotUpdaterCore.d.mts +7 -7
- package/dist/createHotUpdaterCore.mjs +6 -6
- package/dist/db/types.cjs +1 -1
- package/dist/db/types.mjs +1 -1
- package/dist/handler.cjs +5 -5
- package/dist/handler.mjs +5 -5
- 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/{analytics → insights}/bounded/activeOverview.cjs +1 -1
- package/dist/{analytics → insights}/bounded/activeOverview.mjs +1 -1
- package/dist/{analytics → insights}/bounded/installationSearch.cjs +1 -1
- package/dist/{analytics → insights}/bounded/installationSearch.mjs +1 -1
- package/dist/{analytics → insights}/bounded/persistence.cjs +1 -1
- package/dist/{analytics → insights}/bounded/persistence.mjs +1 -1
- package/dist/{analytics → insights}/bounded/provider.cjs +9 -9
- package/dist/insights/bounded/provider.d.cts +7 -0
- package/dist/insights/bounded/provider.d.mts +7 -0
- package/dist/{analytics → insights}/bounded/provider.mjs +10 -10
- package/dist/{analytics → insights}/bounded/scan.cjs +15 -15
- package/dist/{analytics → insights}/bounded/scan.mjs +16 -16
- package/dist/{analytics → insights}/domain.d.cts +12 -12
- package/dist/{analytics → insights}/domain.d.mts +12 -12
- package/dist/insights/errors.cjs +22 -0
- package/dist/insights/errors.mjs +20 -0
- package/dist/{analytics → insights}/eventInput.cjs +10 -10
- package/dist/{analytics → insights}/eventInput.mjs +11 -11
- package/dist/insights/persistence.d.cts +6 -0
- package/dist/insights/persistence.d.mts +6 -0
- package/dist/{analytics → insights}/queryInput.cjs +9 -9
- package/dist/{analytics → insights}/queryInput.mjs +10 -10
- package/dist/{analytics → insights}/routes.cjs +16 -16
- package/dist/{analytics → insights}/routes.mjs +16 -16
- package/dist/{analytics → insights}/types.d.cts +6 -6
- package/dist/{analytics → insights}/types.d.mts +6 -6
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/package.json +4 -4
- package/src/adapters/drizzle.ts +3 -3
- package/src/apiKeys.integration.spec.ts +2 -2
- package/src/createHotUpdaterCore.ts +13 -13
- package/src/db/types.spec.ts +3 -3
- package/src/db/types.ts +7 -7
- package/src/handler-standalone.integration.spec.ts +1 -1
- package/src/handler.ts +12 -12
- package/src/index.ts +3 -3
- package/src/{analytics → insights}/bounded/provider.spec.ts +21 -21
- package/src/{analytics → insights}/bounded/provider.ts +18 -18
- package/src/{analytics → insights}/bounded/scan.ts +26 -26
- package/src/{analytics → insights}/domain.ts +10 -10
- package/src/insights/errors.ts +18 -0
- package/src/{analytics → insights}/eventInput.ts +11 -11
- package/src/{analytics/analytics.integration.spec.ts → insights/insights.integration.spec.ts} +6 -6
- package/src/insights/persistence.ts +10 -0
- package/src/{analytics → insights}/queryInput.ts +11 -11
- package/src/{analytics → insights}/routes.ts +18 -18
- package/src/{analytics → insights}/types.ts +7 -7
- package/dist/analytics/bounded/provider.d.cts +0 -7
- package/dist/analytics/bounded/provider.d.mts +0 -7
- 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/src/analytics/errors.ts +0 -18
- package/src/analytics/persistence.ts +0 -10
- /package/src/{analytics → insights}/bounded/activeOverview.spec.ts +0 -0
- /package/src/{analytics → insights}/bounded/activeOverview.ts +0 -0
- /package/src/{analytics → insights}/bounded/installationSearch.spec.ts +0 -0
- /package/src/{analytics → insights}/bounded/installationSearch.ts +0 -0
- /package/src/{analytics → insights}/bounded/persistence.ts +0 -0
|
@@ -50,9 +50,9 @@ const drizzleAdapter = (config) => {
|
|
|
50
50
|
list: (input) => getAdapter().models.channels.list(input),
|
|
51
51
|
delete: (input) => getAdapter().models.channels.delete(input)
|
|
52
52
|
},
|
|
53
|
-
|
|
54
|
-
append: (row) => getAdapter().models.
|
|
55
|
-
scan: (input) => getAdapter().models.
|
|
53
|
+
insights: {
|
|
54
|
+
append: (row) => getAdapter().models.insights.append(row),
|
|
55
|
+
scan: (input) => getAdapter().models.insights.scan(input)
|
|
56
56
|
},
|
|
57
57
|
apiKeys: {
|
|
58
58
|
create: (row) => getAdapter().models.apiKeys.create(row),
|
|
@@ -48,9 +48,9 @@ const drizzleAdapter = (config) => {
|
|
|
48
48
|
list: (input) => getAdapter().models.channels.list(input),
|
|
49
49
|
delete: (input) => getAdapter().models.channels.delete(input)
|
|
50
50
|
},
|
|
51
|
-
|
|
52
|
-
append: (row) => getAdapter().models.
|
|
53
|
-
scan: (input) => getAdapter().models.
|
|
51
|
+
insights: {
|
|
52
|
+
append: (row) => getAdapter().models.insights.append(row),
|
|
53
|
+
scan: (input) => getAdapter().models.insights.scan(input)
|
|
54
54
|
},
|
|
55
55
|
apiKeys: {
|
|
56
56
|
create: (row) => getAdapter().models.apiKeys.create(row),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require("./_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
const require_handler = require("./handler.cjs");
|
|
3
|
-
const require_provider = require("./
|
|
3
|
+
const require_provider = require("./insights/bounded/provider.cjs");
|
|
4
4
|
const require_apiKeys = require("./apiKeys.cjs");
|
|
5
5
|
const require_databasePluginCore = require("./db/databasePluginCore.cjs");
|
|
6
6
|
const require_schemaReadiness = require("./db/schemaReadiness.cjs");
|
|
@@ -38,21 +38,21 @@ function createHotUpdaterCore(options) {
|
|
|
38
38
|
readStorageText
|
|
39
39
|
});
|
|
40
40
|
const clientAccess = normalizeClientAccess(options.clientAccess);
|
|
41
|
-
const
|
|
41
|
+
const insights = require_provider.createInsightsProvider({
|
|
42
42
|
async append(row) {
|
|
43
43
|
await assertSchemaReady();
|
|
44
|
-
return plugin.models.
|
|
44
|
+
return plugin.models.insights.append(row);
|
|
45
45
|
},
|
|
46
46
|
async scan(input) {
|
|
47
47
|
await assertSchemaReady();
|
|
48
|
-
return plugin.models.
|
|
48
|
+
return plugin.models.insights.scan(input);
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
51
|
const apiKeys = require_apiKeys.createApiKeyManagement({
|
|
52
52
|
apiKeys: plugin.models.apiKeys,
|
|
53
53
|
beforeOperation: assertSchemaReady
|
|
54
54
|
});
|
|
55
|
-
const handlers = require_handler.createHotUpdaterHandlers(core.api,
|
|
55
|
+
const handlers = require_handler.createHotUpdaterHandlers(core.api, insights, clientAccess.type === "api-key" ? {
|
|
56
56
|
authenticate: (request) => require_apiKeys.authenticateApiKey({
|
|
57
57
|
apiKeys: plugin.models.apiKeys,
|
|
58
58
|
beforeLookup: assertSchemaReady,
|
|
@@ -63,7 +63,7 @@ function createHotUpdaterCore(options) {
|
|
|
63
63
|
} : void 0, downloadStorageObject);
|
|
64
64
|
const api = Object.assign({
|
|
65
65
|
adapterName: adapterCapabilities.adapterName ?? core.adapterName,
|
|
66
|
-
|
|
66
|
+
insights,
|
|
67
67
|
apiKeys,
|
|
68
68
|
handlers
|
|
69
69
|
}, core.api);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AnalyticsProvider } from "./analytics/types.cjs";
|
|
2
1
|
import { ApiKeyManagementAPI } from "./apiKeys.cjs";
|
|
3
2
|
import { HotUpdaterHandlers } from "./handlerTypes.cjs";
|
|
3
|
+
import { InsightsProvider } from "./insights/types.cjs";
|
|
4
4
|
import { DatabaseAPI, DatabasePlugin as DatabasePlugin$1 } from "./db/types.cjs";
|
|
5
5
|
import { StoragePlugin } from "@hot-updater/plugin-core";
|
|
6
6
|
|
|
@@ -9,11 +9,11 @@ type RuntimeHotUpdaterAPI = DatabaseAPI & {
|
|
|
9
9
|
readonly handlers: HotUpdaterHandlers;
|
|
10
10
|
readonly adapterName: string;
|
|
11
11
|
/**
|
|
12
|
-
* Built-in
|
|
13
|
-
* always mounted; React Native clients
|
|
14
|
-
*
|
|
12
|
+
* Built-in Insights provider. Client ingestion and admin query routes are
|
|
13
|
+
* always mounted; React Native clients report lifecycle events by default
|
|
14
|
+
* and can opt out with `HotUpdater.init({ insights: false })`.
|
|
15
15
|
*/
|
|
16
|
-
readonly
|
|
16
|
+
readonly insights: InsightsProvider;
|
|
17
17
|
/**
|
|
18
18
|
* In-process API key lifecycle operations for trusted server tooling.
|
|
19
19
|
* Creation returns the plaintext once; list and revoke expose only metadata.
|
|
@@ -24,14 +24,14 @@ type RuntimeHotUpdaterAPI = DatabaseAPI & {
|
|
|
24
24
|
type HotUpdaterAPI = RuntimeHotUpdaterAPI;
|
|
25
25
|
type ClientAccessPolicy = {
|
|
26
26
|
/**
|
|
27
|
-
* Leaves Release Catalog, artifact, and
|
|
27
|
+
* Leaves Release Catalog, artifact, and Insights ingestion routes
|
|
28
28
|
* publicly accessible without a client credential.
|
|
29
29
|
*/
|
|
30
30
|
readonly type: "public";
|
|
31
31
|
} | {
|
|
32
32
|
/**
|
|
33
33
|
* Requires a key registered in `database.models.apiKeys` for
|
|
34
|
-
* Release Catalog, artifact, and
|
|
34
|
+
* Release Catalog, artifact, and Insights ingestion requests.
|
|
35
35
|
*/
|
|
36
36
|
readonly type: "api-key";
|
|
37
37
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AnalyticsProvider } from "./analytics/types.mjs";
|
|
2
1
|
import { ApiKeyManagementAPI } from "./apiKeys.mjs";
|
|
3
2
|
import { HotUpdaterHandlers } from "./handlerTypes.mjs";
|
|
3
|
+
import { InsightsProvider } from "./insights/types.mjs";
|
|
4
4
|
import { DatabaseAPI, DatabasePlugin as DatabasePlugin$1 } from "./db/types.mjs";
|
|
5
5
|
import { StoragePlugin } from "@hot-updater/plugin-core";
|
|
6
6
|
|
|
@@ -9,11 +9,11 @@ type RuntimeHotUpdaterAPI = DatabaseAPI & {
|
|
|
9
9
|
readonly handlers: HotUpdaterHandlers;
|
|
10
10
|
readonly adapterName: string;
|
|
11
11
|
/**
|
|
12
|
-
* Built-in
|
|
13
|
-
* always mounted; React Native clients
|
|
14
|
-
*
|
|
12
|
+
* Built-in Insights provider. Client ingestion and admin query routes are
|
|
13
|
+
* always mounted; React Native clients report lifecycle events by default
|
|
14
|
+
* and can opt out with `HotUpdater.init({ insights: false })`.
|
|
15
15
|
*/
|
|
16
|
-
readonly
|
|
16
|
+
readonly insights: InsightsProvider;
|
|
17
17
|
/**
|
|
18
18
|
* In-process API key lifecycle operations for trusted server tooling.
|
|
19
19
|
* Creation returns the plaintext once; list and revoke expose only metadata.
|
|
@@ -24,14 +24,14 @@ type RuntimeHotUpdaterAPI = DatabaseAPI & {
|
|
|
24
24
|
type HotUpdaterAPI = RuntimeHotUpdaterAPI;
|
|
25
25
|
type ClientAccessPolicy = {
|
|
26
26
|
/**
|
|
27
|
-
* Leaves Release Catalog, artifact, and
|
|
27
|
+
* Leaves Release Catalog, artifact, and Insights ingestion routes
|
|
28
28
|
* publicly accessible without a client credential.
|
|
29
29
|
*/
|
|
30
30
|
readonly type: "public";
|
|
31
31
|
} | {
|
|
32
32
|
/**
|
|
33
33
|
* Requires a key registered in `database.models.apiKeys` for
|
|
34
|
-
* Release Catalog, artifact, and
|
|
34
|
+
* Release Catalog, artifact, and Insights ingestion requests.
|
|
35
35
|
*/
|
|
36
36
|
readonly type: "api-key";
|
|
37
37
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHotUpdaterHandlers } from "./handler.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { createInsightsProvider } from "./insights/bounded/provider.mjs";
|
|
3
3
|
import { authenticateApiKey, createApiKeyManagement, normalizeApiKeyHeaderName } from "./apiKeys.mjs";
|
|
4
4
|
import { createDatabasePluginCore } from "./db/databasePluginCore.mjs";
|
|
5
5
|
import { createSchemaReadinessChecker } from "./db/schemaReadiness.mjs";
|
|
@@ -37,21 +37,21 @@ function createHotUpdaterCore(options) {
|
|
|
37
37
|
readStorageText
|
|
38
38
|
});
|
|
39
39
|
const clientAccess = normalizeClientAccess(options.clientAccess);
|
|
40
|
-
const
|
|
40
|
+
const insights = createInsightsProvider({
|
|
41
41
|
async append(row) {
|
|
42
42
|
await assertSchemaReady();
|
|
43
|
-
return plugin.models.
|
|
43
|
+
return plugin.models.insights.append(row);
|
|
44
44
|
},
|
|
45
45
|
async scan(input) {
|
|
46
46
|
await assertSchemaReady();
|
|
47
|
-
return plugin.models.
|
|
47
|
+
return plugin.models.insights.scan(input);
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
50
|
const apiKeys = createApiKeyManagement({
|
|
51
51
|
apiKeys: plugin.models.apiKeys,
|
|
52
52
|
beforeOperation: assertSchemaReady
|
|
53
53
|
});
|
|
54
|
-
const handlers = createHotUpdaterHandlers(core.api,
|
|
54
|
+
const handlers = createHotUpdaterHandlers(core.api, insights, clientAccess.type === "api-key" ? {
|
|
55
55
|
authenticate: (request) => authenticateApiKey({
|
|
56
56
|
apiKeys: plugin.models.apiKeys,
|
|
57
57
|
beforeLookup: assertSchemaReady,
|
|
@@ -62,7 +62,7 @@ function createHotUpdaterCore(options) {
|
|
|
62
62
|
} : void 0, downloadStorageObject);
|
|
63
63
|
const api = Object.assign({
|
|
64
64
|
adapterName: adapterCapabilities.adapterName ?? core.adapterName,
|
|
65
|
-
|
|
65
|
+
insights,
|
|
66
66
|
apiKeys,
|
|
67
67
|
handlers
|
|
68
68
|
}, core.api);
|
package/dist/db/types.cjs
CHANGED
|
@@ -9,7 +9,7 @@ const sqlProviders = [
|
|
|
9
9
|
const noSqlProviders = ["mongodb"];
|
|
10
10
|
[...sqlProviders, ...noSqlProviders];
|
|
11
11
|
function isDatabasePlugin(plugin) {
|
|
12
|
-
return typeof plugin === "object" && plugin !== null && "name" in plugin && typeof plugin.name === "string" && "models" in plugin && typeof plugin.models === "object" && plugin.models !== null && "bundles" in plugin.models && typeof plugin.models.bundles === "object" && plugin.models.bundles !== null && "findById" in plugin.models.bundles && typeof plugin.models.bundles.findById === "function" && "findMany" in plugin.models.bundles && typeof plugin.models.bundles.findMany === "function" && "count" in plugin.models.bundles && typeof plugin.models.bundles.count === "function" && "bundlePatches" in plugin.models && typeof plugin.models.bundlePatches === "object" && plugin.models.bundlePatches !== null && "findByBundleIds" in plugin.models.bundlePatches && typeof plugin.models.bundlePatches.findByBundleIds === "function" && "channels" in plugin.models && typeof plugin.models.channels === "object" && plugin.models.channels !== null && "insert" in plugin.models.channels && typeof plugin.models.channels.insert === "function" && "list" in plugin.models.channels && typeof plugin.models.channels.list === "function" && "delete" in plugin.models.channels && typeof plugin.models.channels.delete === "function" && "
|
|
12
|
+
return typeof plugin === "object" && plugin !== null && "name" in plugin && typeof plugin.name === "string" && "models" in plugin && typeof plugin.models === "object" && plugin.models !== null && "bundles" in plugin.models && typeof plugin.models.bundles === "object" && plugin.models.bundles !== null && "findById" in plugin.models.bundles && typeof plugin.models.bundles.findById === "function" && "findMany" in plugin.models.bundles && typeof plugin.models.bundles.findMany === "function" && "count" in plugin.models.bundles && typeof plugin.models.bundles.count === "function" && "bundlePatches" in plugin.models && typeof plugin.models.bundlePatches === "object" && plugin.models.bundlePatches !== null && "findByBundleIds" in plugin.models.bundlePatches && typeof plugin.models.bundlePatches.findByBundleIds === "function" && "channels" in plugin.models && typeof plugin.models.channels === "object" && plugin.models.channels !== null && "insert" in plugin.models.channels && typeof plugin.models.channels.insert === "function" && "list" in plugin.models.channels && typeof plugin.models.channels.list === "function" && "delete" in plugin.models.channels && typeof plugin.models.channels.delete === "function" && "insights" in plugin.models && typeof plugin.models.insights === "object" && plugin.models.insights !== null && "append" in plugin.models.insights && typeof plugin.models.insights.append === "function" && "scan" in plugin.models.insights && typeof plugin.models.insights.scan === "function" && "apiKeys" in plugin.models && typeof plugin.models.apiKeys === "object" && plugin.models.apiKeys !== null && "create" in plugin.models.apiKeys && typeof plugin.models.apiKeys.create === "function" && "findByHash" in plugin.models.apiKeys && typeof plugin.models.apiKeys.findByHash === "function" && "list" in plugin.models.apiKeys && typeof plugin.models.apiKeys.list === "function" && "revoke" in plugin.models.apiKeys && typeof plugin.models.apiKeys.revoke === "function" && "commit" in plugin && typeof plugin.commit === "function" && (!("dispose" in plugin) || plugin.dispose === void 0 || typeof plugin.dispose === "function");
|
|
13
13
|
}
|
|
14
14
|
function getSQLProvider(provider) {
|
|
15
15
|
if (!provider) return;
|
package/dist/db/types.mjs
CHANGED
|
@@ -9,7 +9,7 @@ const sqlProviders = [
|
|
|
9
9
|
const noSqlProviders = ["mongodb"];
|
|
10
10
|
[...sqlProviders, ...noSqlProviders];
|
|
11
11
|
function isDatabasePlugin(plugin) {
|
|
12
|
-
return typeof plugin === "object" && plugin !== null && "name" in plugin && typeof plugin.name === "string" && "models" in plugin && typeof plugin.models === "object" && plugin.models !== null && "bundles" in plugin.models && typeof plugin.models.bundles === "object" && plugin.models.bundles !== null && "findById" in plugin.models.bundles && typeof plugin.models.bundles.findById === "function" && "findMany" in plugin.models.bundles && typeof plugin.models.bundles.findMany === "function" && "count" in plugin.models.bundles && typeof plugin.models.bundles.count === "function" && "bundlePatches" in plugin.models && typeof plugin.models.bundlePatches === "object" && plugin.models.bundlePatches !== null && "findByBundleIds" in plugin.models.bundlePatches && typeof plugin.models.bundlePatches.findByBundleIds === "function" && "channels" in plugin.models && typeof plugin.models.channels === "object" && plugin.models.channels !== null && "insert" in plugin.models.channels && typeof plugin.models.channels.insert === "function" && "list" in plugin.models.channels && typeof plugin.models.channels.list === "function" && "delete" in plugin.models.channels && typeof plugin.models.channels.delete === "function" && "
|
|
12
|
+
return typeof plugin === "object" && plugin !== null && "name" in plugin && typeof plugin.name === "string" && "models" in plugin && typeof plugin.models === "object" && plugin.models !== null && "bundles" in plugin.models && typeof plugin.models.bundles === "object" && plugin.models.bundles !== null && "findById" in plugin.models.bundles && typeof plugin.models.bundles.findById === "function" && "findMany" in plugin.models.bundles && typeof plugin.models.bundles.findMany === "function" && "count" in plugin.models.bundles && typeof plugin.models.bundles.count === "function" && "bundlePatches" in plugin.models && typeof plugin.models.bundlePatches === "object" && plugin.models.bundlePatches !== null && "findByBundleIds" in plugin.models.bundlePatches && typeof plugin.models.bundlePatches.findByBundleIds === "function" && "channels" in plugin.models && typeof plugin.models.channels === "object" && plugin.models.channels !== null && "insert" in plugin.models.channels && typeof plugin.models.channels.insert === "function" && "list" in plugin.models.channels && typeof plugin.models.channels.list === "function" && "delete" in plugin.models.channels && typeof plugin.models.channels.delete === "function" && "insights" in plugin.models && typeof plugin.models.insights === "object" && plugin.models.insights !== null && "append" in plugin.models.insights && typeof plugin.models.insights.append === "function" && "scan" in plugin.models.insights && typeof plugin.models.insights.scan === "function" && "apiKeys" in plugin.models && typeof plugin.models.apiKeys === "object" && plugin.models.apiKeys !== null && "create" in plugin.models.apiKeys && typeof plugin.models.apiKeys.create === "function" && "findByHash" in plugin.models.apiKeys && typeof plugin.models.apiKeys.findByHash === "function" && "list" in plugin.models.apiKeys && typeof plugin.models.apiKeys.list === "function" && "revoke" in plugin.models.apiKeys && typeof plugin.models.apiKeys.revoke === "function" && "commit" in plugin && typeof plugin.commit === "function" && (!("dispose" in plugin) || plugin.dispose === void 0 || typeof plugin.dispose === "function");
|
|
13
13
|
}
|
|
14
14
|
function getSQLProvider(provider) {
|
|
15
15
|
if (!provider) return;
|
package/dist/handler.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const require_routes = require("./analytics/routes.cjs");
|
|
2
1
|
const require_handlerErrors = require("./handlerErrors.cjs");
|
|
3
2
|
const require_handlerBundleRoutes = require("./handlerBundleRoutes.cjs");
|
|
4
3
|
const require_handlerReleaseCatalogRoutes = require("./handlerReleaseCatalogRoutes.cjs");
|
|
5
4
|
const require_handlerReleaseManagementRoutes = require("./handlerReleaseManagementRoutes.cjs");
|
|
6
5
|
const require_handlerVersionRoutes = require("./handlerVersionRoutes.cjs");
|
|
6
|
+
const require_routes = require("./insights/routes.cjs");
|
|
7
7
|
const require_internalRouter = require("./internalRouter.cjs");
|
|
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
|
...require_handlerVersionRoutes.createVersionRouteHandlers(),
|
|
69
69
|
...require_handlerReleaseCatalogRoutes.createReleaseCatalogRouteHandlers(apiKeyAuth?.headerName),
|
|
70
70
|
...require_handlerReleaseManagementRoutes.createReleaseManagementRouteHandlers(),
|
|
71
71
|
...require_handlerBundleRoutes.createBundleRouteHandlers(),
|
|
72
|
-
...
|
|
72
|
+
...insights === void 0 ? {} : require_routes.createInsightsRouteHandlers(insights),
|
|
73
73
|
...downloadStorageObject === void 0 ? {} : { downloadStorageObject: createDownloadStorageRouteHandler(downloadStorageObject) }
|
|
74
74
|
};
|
|
75
75
|
const clientRouter = require_internalRouter.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) require_routes.registerInsightsClientRoutes(addClientRoute);
|
|
83
83
|
const adminRouter = require_internalRouter.createRouter();
|
|
84
84
|
const addAdminRoute = (method, path, handler) => require_internalRouter.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) require_routes.registerInsightsAdminRoutes(addAdminRoute);
|
|
103
103
|
return Object.freeze({
|
|
104
104
|
client: createRequestHandler({
|
|
105
105
|
api,
|
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/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/bounded/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 { ActiveInstallationInput, ActiveInstallationOverview, ActiveInstallationWindow, BundleEventInsightsResult, BundleEventInsightsWindow, BundleEventOverview, BundleEventSummary, BundleEventSummaryByBundle, CreateBundleEventRequest, CreateBundleEventRequestBase, InsightsCohortPoint, InsightsSeriesPoint, InstallationHistoryRow, InstallationSearchRow, OffsetPaginationResult } from "./insights/domain.cjs";
|
|
4
|
+
import { InsightsProvider } 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/bounded/provider.cjs";
|
|
10
10
|
import { HOT_UPDATER_INFRASTRUCTURE_GENERATION } from "./handlerVersionRoutes.cjs";
|
|
11
|
-
export { API_KEY_HEADER_NAME, ActiveInstallationInput, ActiveInstallationOverview, ActiveInstallationWindow,
|
|
11
|
+
export { API_KEY_HEADER_NAME, ActiveInstallationInput, ActiveInstallationOverview, ActiveInstallationWindow, type ApiKeyManagementAPI, type ApiKeyMetadata, Bundle, BundleEventInsightsResult, BundleEventInsightsWindow, BundleEventOverview, BundleEventSummary, BundleEventSummaryByBundle, ChannelsResponse, type ClientAccessPolicy, CreateBundleEventRequest, CreateBundleEventRequestBase, type CreateHotUpdaterOptions, type CreatedApiKey, DataResponse, HOT_UPDATER_INFRASTRUCTURE_GENERATION, HOT_UPDATER_SERVER_VERSION, type HandlerAPI, type HotUpdaterAPI, type HotUpdaterHandler, type HotUpdaterHandlers, InsightsCohortPoint, type InsightsProvider, InsightsSeriesPoint, InstallationHistoryRow, InstallationSearchRow, OffsetPaginationResult, Paginated, PaginatedResult, PaginationInfo, PaginationOptions, 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 { ActiveInstallationInput, ActiveInstallationOverview, ActiveInstallationWindow, BundleEventInsightsResult, BundleEventInsightsWindow, BundleEventOverview, BundleEventSummary, BundleEventSummaryByBundle, CreateBundleEventRequest, CreateBundleEventRequestBase, InsightsCohortPoint, InsightsSeriesPoint, InstallationHistoryRow, InstallationSearchRow, OffsetPaginationResult } from "./insights/domain.mjs";
|
|
4
|
+
import { InsightsProvider } 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/bounded/provider.mjs";
|
|
10
10
|
import { HOT_UPDATER_INFRASTRUCTURE_GENERATION } from "./handlerVersionRoutes.mjs";
|
|
11
|
-
export { API_KEY_HEADER_NAME, ActiveInstallationInput, ActiveInstallationOverview, ActiveInstallationWindow,
|
|
11
|
+
export { API_KEY_HEADER_NAME, ActiveInstallationInput, ActiveInstallationOverview, ActiveInstallationWindow, type ApiKeyManagementAPI, type ApiKeyMetadata, Bundle, BundleEventInsightsResult, BundleEventInsightsWindow, BundleEventOverview, BundleEventSummary, BundleEventSummaryByBundle, ChannelsResponse, type ClientAccessPolicy, CreateBundleEventRequest, CreateBundleEventRequestBase, type CreateHotUpdaterOptions, type CreatedApiKey, DataResponse, HOT_UPDATER_INFRASTRUCTURE_GENERATION, HOT_UPDATER_SERVER_VERSION, type HandlerAPI, type HotUpdaterAPI, type HotUpdaterHandler, type HotUpdaterHandlers, InsightsCohortPoint, type InsightsProvider, InsightsSeriesPoint, InstallationHistoryRow, InstallationSearchRow, OffsetPaginationResult, Paginated, PaginatedResult, PaginationInfo, PaginationOptions, 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/bounded/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 };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/insights/bounded/persistence.ts
|
|
4
4
|
function createBundleEventRow(input) {
|
|
5
5
|
const base = {
|
|
6
6
|
id: (0, _hot_updater_plugin_core.createUUIDv7)(),
|
|
@@ -2,7 +2,7 @@ const require_activeOverview = require("./activeOverview.cjs");
|
|
|
2
2
|
const require_scan = require("./scan.cjs");
|
|
3
3
|
const require_installationSearch = require("./installationSearch.cjs");
|
|
4
4
|
const require_persistence = require("./persistence.cjs");
|
|
5
|
-
//#region src/
|
|
5
|
+
//#region src/insights/bounded/provider.ts
|
|
6
6
|
const isTransitionEventRow = (row) => row.type === "UPDATE_APPLIED" || row.type === "RECOVERED";
|
|
7
7
|
const toHistoryRow = (row) => ({
|
|
8
8
|
id: row.id,
|
|
@@ -20,7 +20,7 @@ const toHistoryRow = (row) => ({
|
|
|
20
20
|
const isInstalledForBundle = (row, bundleId) => row.type === "UPDATE_APPLIED" && row.to_bundle_id === bundleId;
|
|
21
21
|
const isRecoveredFromBundle = (row, bundleId) => row.type === "RECOVERED" && row.from_bundle_id === bundleId;
|
|
22
22
|
const countDistinctInstallations = (rows) => new Set(rows.map(({ install_id }) => install_id)).size;
|
|
23
|
-
const
|
|
23
|
+
const getInsightsResult = async (persistence, bundleId, window, limit, offset) => {
|
|
24
24
|
const scope = {
|
|
25
25
|
persistence,
|
|
26
26
|
cutoffMs: Date.now()
|
|
@@ -62,7 +62,7 @@ const getAnalyticsResult = async (persistence, bundleId, window, limit, offset)
|
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
};
|
|
65
|
-
const
|
|
65
|
+
const getInsightsSummaries = async (persistence, bundleIds, window) => {
|
|
66
66
|
const normalizedBundleIds = [...new Set(bundleIds)];
|
|
67
67
|
if (normalizedBundleIds.length === 0) return [];
|
|
68
68
|
const requestedBundleIds = new Set(normalizedBundleIds);
|
|
@@ -86,9 +86,9 @@ const getAnalyticsSummaries = async (persistence, bundleIds, window) => {
|
|
|
86
86
|
recovered: recoveredByBundleId.get(bundleId)?.size ?? 0
|
|
87
87
|
}));
|
|
88
88
|
};
|
|
89
|
-
const
|
|
89
|
+
const createInsightsProvider = (persistence) => Object.freeze({
|
|
90
90
|
mode: "bounded",
|
|
91
|
-
maxMatchingRows: require_scan.
|
|
91
|
+
maxMatchingRows: require_scan.INSIGHTS_SCAN_MAX_ROWS,
|
|
92
92
|
async appendBundleEvent(input) {
|
|
93
93
|
await persistence.append(require_persistence.createBundleEventRow(input));
|
|
94
94
|
},
|
|
@@ -103,10 +103,10 @@ const createAnalyticsProvider = (persistence) => Object.freeze({
|
|
|
103
103
|
};
|
|
104
104
|
},
|
|
105
105
|
getBundleEventSummaries(bundleIds, window) {
|
|
106
|
-
return
|
|
106
|
+
return getInsightsSummaries(persistence, bundleIds, window);
|
|
107
107
|
},
|
|
108
|
-
|
|
109
|
-
return
|
|
108
|
+
getBundleEventInsights(bundleId, window, limit, offset) {
|
|
109
|
+
return getInsightsResult(persistence, bundleId, window, limit, offset);
|
|
110
110
|
},
|
|
111
111
|
async getBundleEventOverview() {
|
|
112
112
|
const rows = await require_scan.materializeEventRows({
|
|
@@ -167,4 +167,4 @@ const createAnalyticsProvider = (persistence) => Object.freeze({
|
|
|
167
167
|
}
|
|
168
168
|
});
|
|
169
169
|
//#endregion
|
|
170
|
-
exports.
|
|
170
|
+
exports.createInsightsProvider = createInsightsProvider;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { InsightsProvider } from "../types.cjs";
|
|
2
|
+
import { InsightsPersistence } from "../persistence.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/insights/bounded/provider.d.ts
|
|
5
|
+
declare const createInsightsProvider: (persistence: InsightsPersistence) => InsightsProvider;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { createInsightsProvider };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { InsightsProvider } from "../types.mjs";
|
|
2
|
+
import { InsightsPersistence } from "../persistence.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/insights/bounded/provider.d.ts
|
|
5
|
+
declare const createInsightsProvider: (persistence: InsightsPersistence) => InsightsProvider;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { createInsightsProvider };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { collectActiveInstallationOverview } from "./activeOverview.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { INSIGHTS_SCAN_MAX_ROWS, collectEventActivity, compareCodePoints, compareEventNewest, materializeActiveRows, materializeEventRows, materializeRowsForWindow } from "./scan.mjs";
|
|
3
3
|
import { searchEventInstallations } from "./installationSearch.mjs";
|
|
4
4
|
import { createBundleEventRow } from "./persistence.mjs";
|
|
5
|
-
//#region src/
|
|
5
|
+
//#region src/insights/bounded/provider.ts
|
|
6
6
|
const isTransitionEventRow = (row) => row.type === "UPDATE_APPLIED" || row.type === "RECOVERED";
|
|
7
7
|
const toHistoryRow = (row) => ({
|
|
8
8
|
id: row.id,
|
|
@@ -20,7 +20,7 @@ const toHistoryRow = (row) => ({
|
|
|
20
20
|
const isInstalledForBundle = (row, bundleId) => row.type === "UPDATE_APPLIED" && row.to_bundle_id === bundleId;
|
|
21
21
|
const isRecoveredFromBundle = (row, bundleId) => row.type === "RECOVERED" && row.from_bundle_id === bundleId;
|
|
22
22
|
const countDistinctInstallations = (rows) => new Set(rows.map(({ install_id }) => install_id)).size;
|
|
23
|
-
const
|
|
23
|
+
const getInsightsResult = async (persistence, bundleId, window, limit, offset) => {
|
|
24
24
|
const scope = {
|
|
25
25
|
persistence,
|
|
26
26
|
cutoffMs: Date.now()
|
|
@@ -62,7 +62,7 @@ const getAnalyticsResult = async (persistence, bundleId, window, limit, offset)
|
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
};
|
|
65
|
-
const
|
|
65
|
+
const getInsightsSummaries = async (persistence, bundleIds, window) => {
|
|
66
66
|
const normalizedBundleIds = [...new Set(bundleIds)];
|
|
67
67
|
if (normalizedBundleIds.length === 0) return [];
|
|
68
68
|
const requestedBundleIds = new Set(normalizedBundleIds);
|
|
@@ -86,9 +86,9 @@ const getAnalyticsSummaries = async (persistence, bundleIds, window) => {
|
|
|
86
86
|
recovered: recoveredByBundleId.get(bundleId)?.size ?? 0
|
|
87
87
|
}));
|
|
88
88
|
};
|
|
89
|
-
const
|
|
89
|
+
const createInsightsProvider = (persistence) => Object.freeze({
|
|
90
90
|
mode: "bounded",
|
|
91
|
-
maxMatchingRows:
|
|
91
|
+
maxMatchingRows: INSIGHTS_SCAN_MAX_ROWS,
|
|
92
92
|
async appendBundleEvent(input) {
|
|
93
93
|
await persistence.append(createBundleEventRow(input));
|
|
94
94
|
},
|
|
@@ -103,10 +103,10 @@ const createAnalyticsProvider = (persistence) => Object.freeze({
|
|
|
103
103
|
};
|
|
104
104
|
},
|
|
105
105
|
getBundleEventSummaries(bundleIds, window) {
|
|
106
|
-
return
|
|
106
|
+
return getInsightsSummaries(persistence, bundleIds, window);
|
|
107
107
|
},
|
|
108
|
-
|
|
109
|
-
return
|
|
108
|
+
getBundleEventInsights(bundleId, window, limit, offset) {
|
|
109
|
+
return getInsightsResult(persistence, bundleId, window, limit, offset);
|
|
110
110
|
},
|
|
111
111
|
async getBundleEventOverview() {
|
|
112
112
|
const rows = await materializeEventRows({
|
|
@@ -167,4 +167,4 @@ const createAnalyticsProvider = (persistence) => Object.freeze({
|
|
|
167
167
|
}
|
|
168
168
|
});
|
|
169
169
|
//#endregion
|
|
170
|
-
export {
|
|
170
|
+
export { createInsightsProvider };
|