@hot-updater/plugin-core 1.0.0-rc.15 → 1.0.0-rc.17

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 (151) hide show
  1. package/dist/coreApi.d.cts +131 -0
  2. package/dist/coreApi.d.mts +131 -0
  3. package/dist/database/adapter.cjs +46 -0
  4. package/dist/database/adapter.d.cts +183 -0
  5. package/dist/database/adapter.d.mts +183 -0
  6. package/dist/database/adapter.mjs +38 -0
  7. package/dist/{insightsDistinctSummary.mjs → database/distinct.cjs} +25 -11
  8. package/dist/database/distinct.d.cts +16 -0
  9. package/dist/database/distinct.d.mts +16 -0
  10. package/dist/{insightsDistinctSummary.cjs → database/distinct.mjs} +21 -15
  11. package/dist/database/memoryAdapter.cjs +115 -0
  12. package/dist/database/memoryAdapter.d.cts +16 -0
  13. package/dist/database/memoryAdapter.d.mts +16 -0
  14. package/dist/database/memoryAdapter.mjs +115 -0
  15. package/dist/database/values.cjs +110 -0
  16. package/dist/database/values.d.cts +30 -0
  17. package/dist/database/values.d.mts +30 -0
  18. package/dist/database/values.mjs +100 -0
  19. package/dist/database/verifyAdapter.cjs +136 -0
  20. package/dist/database/verifyAdapter.d.cts +29 -0
  21. package/dist/database/verifyAdapter.d.mts +29 -0
  22. package/dist/database/verifyAdapter.mjs +135 -0
  23. package/dist/databaseErrors.cjs +30 -0
  24. package/dist/databaseErrors.d.cts +21 -0
  25. package/dist/databaseErrors.d.mts +21 -0
  26. package/dist/databaseErrors.mjs +28 -0
  27. package/dist/databaseJsonValue.cjs +0 -2
  28. package/dist/databaseJsonValue.d.cts +3 -3
  29. package/dist/databaseJsonValue.d.mts +3 -3
  30. package/dist/databaseJsonValue.mjs +1 -2
  31. package/dist/databaseMetadata.cjs +2 -2
  32. package/dist/databaseMetadata.mjs +1 -1
  33. package/dist/index.cjs +9 -39
  34. package/dist/index.d.cts +13 -19
  35. package/dist/index.d.mts +13 -19
  36. package/dist/index.mjs +7 -14
  37. package/dist/internal.cjs +37 -20
  38. package/dist/internal.d.cts +11 -12
  39. package/dist/internal.d.mts +11 -12
  40. package/dist/internal.mjs +8 -6
  41. package/dist/releaseCatalogCompiler.cjs +1 -1
  42. package/dist/releaseCatalogCompiler.mjs +2 -2
  43. package/dist/releaseCatalogMutation.cjs +0 -292
  44. package/dist/releaseCatalogMutation.d.cts +4 -45
  45. package/dist/releaseCatalogMutation.d.mts +4 -45
  46. package/dist/releaseCatalogMutation.mjs +1 -288
  47. package/dist/releaseManagement.cjs +0 -221
  48. package/dist/releaseManagement.d.cts +4 -28
  49. package/dist/releaseManagement.d.mts +4 -28
  50. package/dist/releaseManagement.mjs +1 -216
  51. package/dist/types/databaseConfig.cjs +5 -0
  52. package/dist/types/databaseConfig.d.cts +61 -0
  53. package/dist/types/databaseConfig.d.mts +61 -0
  54. package/dist/types/databaseConfig.mjs +5 -0
  55. package/dist/types/databaseOperations.d.cts +5 -174
  56. package/dist/types/databaseOperations.d.mts +5 -174
  57. package/dist/types/databaseRows.d.cts +1 -53
  58. package/dist/types/databaseRows.d.mts +1 -53
  59. package/dist/types/index.cjs +2 -0
  60. package/dist/types/index.d.cts +8 -74
  61. package/dist/types/index.d.mts +8 -74
  62. package/dist/types/index.mjs +2 -1
  63. package/dist/types/internal.d.cts +4 -8
  64. package/dist/types/internal.d.mts +4 -8
  65. package/dist/types/models.d.cts +14 -0
  66. package/dist/types/models.d.mts +14 -0
  67. package/dist/types/public.d.cts +4 -3
  68. package/dist/types/public.d.mts +4 -3
  69. package/package.json +1 -1
  70. package/dist/calculatePagination.cjs +0 -25
  71. package/dist/calculatePagination.d.cts +0 -12
  72. package/dist/calculatePagination.d.mts +0 -12
  73. package/dist/calculatePagination.mjs +0 -25
  74. package/dist/createDatabasePlugin.cjs +0 -875
  75. package/dist/createDatabasePlugin.d.cts +0 -28
  76. package/dist/createDatabasePlugin.d.mts +0 -28
  77. package/dist/createDatabasePlugin.mjs +0 -871
  78. package/dist/databaseClient.cjs +0 -117
  79. package/dist/databaseClient.d.cts +0 -32
  80. package/dist/databaseClient.d.mts +0 -32
  81. package/dist/databaseClient.mjs +0 -114
  82. package/dist/databaseClientReads.cjs +0 -115
  83. package/dist/databaseClientReads.mjs +0 -113
  84. package/dist/databaseClientUpdates.cjs +0 -37
  85. package/dist/databaseClientUpdates.d.cts +0 -11
  86. package/dist/databaseClientUpdates.d.mts +0 -11
  87. package/dist/databaseClientUpdates.mjs +0 -35
  88. package/dist/databasePluginCrud.cjs +0 -87
  89. package/dist/databasePluginCrud.d.cts +0 -4
  90. package/dist/databasePluginCrud.d.mts +0 -4
  91. package/dist/databasePluginCrud.mjs +0 -86
  92. package/dist/databasePluginCrudValidation.d.cts +0 -6
  93. package/dist/databasePluginCrudValidation.d.mts +0 -6
  94. package/dist/databasePluginCrudValidationErrors.cjs +0 -11
  95. package/dist/databasePluginCrudValidationErrors.d.cts +0 -9
  96. package/dist/databasePluginCrudValidationErrors.d.mts +0 -9
  97. package/dist/databasePluginCrudValidationErrors.mjs +0 -11
  98. package/dist/databasePluginCrudValidationFields.cjs +0 -284
  99. package/dist/databasePluginCrudValidationFields.d.cts +0 -1
  100. package/dist/databasePluginCrudValidationFields.d.mts +0 -1
  101. package/dist/databasePluginCrudValidationFields.mjs +0 -272
  102. package/dist/databasePluginCrudValidationMutations.cjs +0 -88
  103. package/dist/databasePluginCrudValidationMutations.d.cts +0 -1
  104. package/dist/databasePluginCrudValidationMutations.d.mts +0 -1
  105. package/dist/databasePluginCrudValidationMutations.mjs +0 -82
  106. package/dist/databasePluginCrudValidationQueries.cjs +0 -103
  107. package/dist/databasePluginCrudValidationQueries.d.cts +0 -2
  108. package/dist/databasePluginCrudValidationQueries.d.mts +0 -2
  109. package/dist/databasePluginCrudValidationQueries.mjs +0 -97
  110. package/dist/databasePluginCrudValidationRows.cjs +0 -55
  111. package/dist/databasePluginCrudValidationRows.d.cts +0 -1
  112. package/dist/databasePluginCrudValidationRows.d.mts +0 -1
  113. package/dist/databasePluginCrudValidationRows.mjs +0 -53
  114. package/dist/databasePluginTransaction.cjs +0 -7
  115. package/dist/databasePluginTransaction.mjs +0 -7
  116. package/dist/insightsContract.cjs +0 -192
  117. package/dist/insightsContract.d.cts +0 -9
  118. package/dist/insightsContract.d.mts +0 -9
  119. package/dist/insightsContract.mjs +0 -189
  120. package/dist/insightsDistinctSummary.d.cts +0 -12
  121. package/dist/insightsDistinctSummary.d.mts +0 -12
  122. package/dist/insightsLatestQueries.cjs +0 -53
  123. package/dist/insightsLatestQueries.d.cts +0 -13
  124. package/dist/insightsLatestQueries.d.mts +0 -13
  125. package/dist/insightsLatestQueries.mjs +0 -52
  126. package/dist/insightsOverview.cjs +0 -139
  127. package/dist/insightsOverview.d.cts +0 -40
  128. package/dist/insightsOverview.d.mts +0 -40
  129. package/dist/insightsOverview.mjs +0 -135
  130. package/dist/paginateBundles.cjs +0 -53
  131. package/dist/paginateBundles.d.cts +0 -13
  132. package/dist/paginateBundles.d.mts +0 -13
  133. package/dist/paginateBundles.mjs +0 -53
  134. package/dist/queryBundles.cjs +0 -34
  135. package/dist/queryBundles.d.cts +0 -9
  136. package/dist/queryBundles.d.mts +0 -9
  137. package/dist/queryBundles.mjs +0 -32
  138. package/dist/requestBundleCache.cjs +0 -22
  139. package/dist/requestBundleCache.d.cts +0 -8
  140. package/dist/requestBundleCache.d.mts +0 -8
  141. package/dist/requestBundleCache.mjs +0 -22
  142. package/dist/types/database.d.cts +0 -5
  143. package/dist/types/database.d.mts +0 -5
  144. package/dist/types/databaseFields.cjs +0 -85
  145. package/dist/types/databaseFields.d.cts +0 -12
  146. package/dist/types/databaseFields.d.mts +0 -12
  147. package/dist/types/databaseFields.mjs +0 -85
  148. package/dist/types/databasePlugin.d.cts +0 -388
  149. package/dist/types/databasePlugin.d.mts +0 -388
  150. package/dist/types/databaseQuery.d.cts +0 -46
  151. package/dist/types/databaseQuery.d.mts +0 -46
@@ -1,12 +0,0 @@
1
- //#region src/insightsDistinctSummary.d.ts
2
- declare const getInsightsDistinctRegister: (identity: string) => {
3
- index: number;
4
- rank: number;
5
- character: string;
6
- };
7
- declare const addInsightsDistinct: (summary: string | null | undefined, identity: string) => string;
8
- declare const mergeInsightsDistinct: (summaries: readonly (string | null | undefined)[]) => string;
9
- declare const countInsightsDistinct: (summary: string | null | undefined) => number;
10
- declare const emptyInsightsDistinct: () => string;
11
- //#endregion
12
- export { addInsightsDistinct, countInsightsDistinct, emptyInsightsDistinct, getInsightsDistinctRegister, mergeInsightsDistinct };
@@ -1,12 +0,0 @@
1
- //#region src/insightsDistinctSummary.d.ts
2
- declare const getInsightsDistinctRegister: (identity: string) => {
3
- index: number;
4
- rank: number;
5
- character: string;
6
- };
7
- declare const addInsightsDistinct: (summary: string | null | undefined, identity: string) => string;
8
- declare const mergeInsightsDistinct: (summaries: readonly (string | null | undefined)[]) => string;
9
- declare const countInsightsDistinct: (summary: string | null | undefined) => number;
10
- declare const emptyInsightsDistinct: () => string;
11
- //#endregion
12
- export { addInsightsDistinct, countInsightsDistinct, emptyInsightsDistinct, getInsightsDistinctRegister, mergeInsightsDistinct };
@@ -1,53 +0,0 @@
1
- //#region src/insightsLatestQueries.ts
2
- /** Internal query translation for the bundled CRUD adapters. */
3
- const latestInsightsWhere = (input) => {
4
- if ("installId" in input) return [{
5
- field: "install_id",
6
- value: input.installId
7
- }];
8
- if ("userId" in input) return [{
9
- field: "user_id",
10
- value: input.userId
11
- }, ...input.afterInstallId === void 0 ? [] : [{
12
- field: "install_id",
13
- operator: "gt",
14
- value: input.afterInstallId
15
- }]];
16
- return [
17
- {
18
- field: "platform",
19
- value: input.platform
20
- },
21
- {
22
- field: "channel",
23
- value: input.channel
24
- },
25
- {
26
- field: "received_at_ms",
27
- operator: "gte",
28
- value: input.sinceMs
29
- },
30
- ...input.bundle === void 0 ? [] : [input.bundle.field === "from_bundle_id" ? {
31
- field: "from_bundle_id",
32
- value: input.bundle.value
33
- } : {
34
- field: "to_bundle_id",
35
- value: input.bundle.value
36
- }, {
37
- field: "type",
38
- operator: "in",
39
- value: input.bundle.types
40
- }]
41
- ];
42
- };
43
- /** OR groups for one latest-event count; an installation is counted once. */
44
- const latestInsightsCountGroups = (input) => input.bundle === void 0 ? [latestInsightsWhere({
45
- ...input,
46
- bundle: void 0
47
- })] : input.bundle.map((bundle) => latestInsightsWhere({
48
- ...input,
49
- bundle
50
- }));
51
- //#endregion
52
- exports.latestInsightsCountGroups = latestInsightsCountGroups;
53
- exports.latestInsightsWhere = latestInsightsWhere;
@@ -1,13 +0,0 @@
1
- import { InsightsCountLatestEventsInput, InsightsFindLatestEventsInput } from "./types/databasePlugin.cjs";
2
- import { DatabaseWhere } from "./types/databaseQuery.cjs";
3
- import "./types/index.cjs";
4
- import "./types/internal.cjs";
5
- //#region src/insightsLatestQueries.d.ts
6
- /** Internal query translation for the bundled CRUD adapters. */
7
- declare const latestInsightsWhere: (input: InsightsFindLatestEventsInput | (Omit<InsightsCountLatestEventsInput, "bundle"> & {
8
- bundle?: NonNullable<InsightsCountLatestEventsInput["bundle"]>[number];
9
- })) => readonly DatabaseWhere<"bundle_events">[];
10
- /** OR groups for one latest-event count; an installation is counted once. */
11
- declare const latestInsightsCountGroups: (input: InsightsCountLatestEventsInput) => readonly (readonly DatabaseWhere<"bundle_events">[])[];
12
- //#endregion
13
- export { latestInsightsCountGroups, latestInsightsWhere };
@@ -1,13 +0,0 @@
1
- import { InsightsCountLatestEventsInput, InsightsFindLatestEventsInput } from "./types/databasePlugin.mjs";
2
- import { DatabaseWhere } from "./types/databaseQuery.mjs";
3
- import "./types/index.mjs";
4
- import "./types/internal.mjs";
5
- //#region src/insightsLatestQueries.d.ts
6
- /** Internal query translation for the bundled CRUD adapters. */
7
- declare const latestInsightsWhere: (input: InsightsFindLatestEventsInput | (Omit<InsightsCountLatestEventsInput, "bundle"> & {
8
- bundle?: NonNullable<InsightsCountLatestEventsInput["bundle"]>[number];
9
- })) => readonly DatabaseWhere<"bundle_events">[];
10
- /** OR groups for one latest-event count; an installation is counted once. */
11
- declare const latestInsightsCountGroups: (input: InsightsCountLatestEventsInput) => readonly (readonly DatabaseWhere<"bundle_events">[])[];
12
- //#endregion
13
- export { latestInsightsCountGroups, latestInsightsWhere };
@@ -1,52 +0,0 @@
1
- //#region src/insightsLatestQueries.ts
2
- /** Internal query translation for the bundled CRUD adapters. */
3
- const latestInsightsWhere = (input) => {
4
- if ("installId" in input) return [{
5
- field: "install_id",
6
- value: input.installId
7
- }];
8
- if ("userId" in input) return [{
9
- field: "user_id",
10
- value: input.userId
11
- }, ...input.afterInstallId === void 0 ? [] : [{
12
- field: "install_id",
13
- operator: "gt",
14
- value: input.afterInstallId
15
- }]];
16
- return [
17
- {
18
- field: "platform",
19
- value: input.platform
20
- },
21
- {
22
- field: "channel",
23
- value: input.channel
24
- },
25
- {
26
- field: "received_at_ms",
27
- operator: "gte",
28
- value: input.sinceMs
29
- },
30
- ...input.bundle === void 0 ? [] : [input.bundle.field === "from_bundle_id" ? {
31
- field: "from_bundle_id",
32
- value: input.bundle.value
33
- } : {
34
- field: "to_bundle_id",
35
- value: input.bundle.value
36
- }, {
37
- field: "type",
38
- operator: "in",
39
- value: input.bundle.types
40
- }]
41
- ];
42
- };
43
- /** OR groups for one latest-event count; an installation is counted once. */
44
- const latestInsightsCountGroups = (input) => input.bundle === void 0 ? [latestInsightsWhere({
45
- ...input,
46
- bundle: void 0
47
- })] : input.bundle.map((bundle) => latestInsightsWhere({
48
- ...input,
49
- bundle
50
- }));
51
- //#endregion
52
- export { latestInsightsCountGroups, latestInsightsWhere };
@@ -1,139 +0,0 @@
1
- //#region src/insightsOverview.ts
2
- const encodeIdentity = (identity) => [
3
- identity.scopeKind,
4
- identity.releaseKind,
5
- identity.releaseId,
6
- identity.channel,
7
- identity.platform,
8
- identity.appVersionKind,
9
- identity.appVersion,
10
- identity.periodKind,
11
- String(identity.bucketStartMs)
12
- ].map((value) => `${new TextEncoder().encode(value).length}:${value}`).join("");
13
- const fnv = (value, seed) => {
14
- let result = seed;
15
- for (const byte of new TextEncoder().encode(value)) {
16
- result ^= BigInt(byte);
17
- result = BigInt.asUintN(64, result * 1099511628211n);
18
- }
19
- return result.toString(16).padStart(16, "0");
20
- };
21
- const insightsOverviewId = (identity) => {
22
- const value = encodeIdentity(identity);
23
- return `${fnv(value, 14695981039346656037n)}${fnv(value, 9521211207457086692n)}`;
24
- };
25
- const insightsOverviewValues = (identity) => ({
26
- id: insightsOverviewId(identity),
27
- scope_kind: identity.scopeKind,
28
- release_kind: identity.releaseKind,
29
- release_id: identity.releaseId,
30
- channel: identity.channel,
31
- platform: identity.platform,
32
- app_version_kind: identity.appVersionKind,
33
- app_version: identity.appVersion,
34
- period_kind: identity.periodKind,
35
- bucket_start_ms: identity.bucketStartMs
36
- });
37
- const hour = (value) => Math.floor(value / 36e5) * 36e5;
38
- const currentInsightsReleaseId = (event) => event.type === "UPDATE_DOWNLOADED" ? event.from_release_id : event.to_release_id;
39
- const insightsDistributionIdentity = (event) => {
40
- const releaseId = currentInsightsReleaseId(event);
41
- return {
42
- scopeKind: "distribution",
43
- releaseKind: releaseId === null ? "embedded" : "specific",
44
- releaseId: releaseId ?? "",
45
- channel: event.channel,
46
- platform: event.platform,
47
- appVersionKind: "specific",
48
- appVersion: event.app_version,
49
- periodKind: "latest",
50
- bucketStartMs: hour(event.received_at_ms)
51
- };
52
- };
53
- const insightsOverviewDeltas = (event) => {
54
- const bucketStartMs = hour(event.received_at_ms);
55
- const counters = /* @__PURE__ */ new Map();
56
- const append = (identity, values) => {
57
- const key = encodeIdentity(identity);
58
- const previous = counters.get(key);
59
- counters.set(key, {
60
- identity,
61
- downloads: (previous?.downloads ?? 0) + values.downloads,
62
- launches: (previous?.launches ?? 0) + values.launches,
63
- failedLaunches: (previous?.failedLaunches ?? 0) + values.failedLaunches,
64
- launchIdentity: previous?.launchIdentity ?? values.launchIdentity,
65
- activityIdentity: previous?.activityIdentity ?? values.activityIdentity
66
- });
67
- };
68
- const metric = (releaseId, values) => {
69
- const launchIdentity = values.launches > 0 ? event.install_id : void 0;
70
- if (releaseId !== null) for (const [periodKind, start] of [["lifetime", 0], ["hour", bucketStartMs]]) append({
71
- scopeKind: "release",
72
- releaseKind: "specific",
73
- releaseId,
74
- channel: event.channel,
75
- platform: event.platform,
76
- appVersionKind: "all",
77
- appVersion: "",
78
- periodKind,
79
- bucketStartMs: start
80
- }, {
81
- ...values,
82
- ...periodKind === "hour" ? { launchIdentity } : {}
83
- });
84
- append({
85
- scopeKind: "channel",
86
- releaseKind: "all",
87
- releaseId: "",
88
- channel: event.channel,
89
- platform: event.platform,
90
- appVersionKind: "all",
91
- appVersion: "",
92
- periodKind: "hour",
93
- bucketStartMs
94
- }, {
95
- ...values,
96
- launchIdentity
97
- });
98
- };
99
- if (event.type === "UPDATE_DOWNLOADED") metric(event.to_release_id, {
100
- downloads: 1,
101
- launches: 0,
102
- failedLaunches: 0
103
- });
104
- else {
105
- metric(event.to_release_id, {
106
- downloads: 0,
107
- launches: 1,
108
- failedLaunches: 0
109
- });
110
- if (event.type === "RECOVERED") metric(event.from_release_id, {
111
- downloads: 0,
112
- launches: 0,
113
- failedLaunches: 1
114
- });
115
- }
116
- for (const platform of [event.platform, "all"]) for (const appVersionKind of ["specific", "all"]) append({
117
- scopeKind: "usage",
118
- releaseKind: "all",
119
- releaseId: "",
120
- channel: event.channel,
121
- platform,
122
- appVersionKind,
123
- appVersion: appVersionKind === "specific" ? event.app_version : "",
124
- periodKind: "hour",
125
- bucketStartMs
126
- }, {
127
- downloads: 0,
128
- launches: 0,
129
- failedLaunches: 0,
130
- activityIdentity: event.install_id
131
- });
132
- return [...counters.values()];
133
- };
134
- //#endregion
135
- exports.currentInsightsReleaseId = currentInsightsReleaseId;
136
- exports.insightsDistributionIdentity = insightsDistributionIdentity;
137
- exports.insightsOverviewDeltas = insightsOverviewDeltas;
138
- exports.insightsOverviewId = insightsOverviewId;
139
- exports.insightsOverviewValues = insightsOverviewValues;
@@ -1,40 +0,0 @@
1
- import { BundleEventRow } from "./types/databaseRows.cjs";
2
- import "./types/internal.cjs";
3
- //#region src/insightsOverview.d.ts
4
- type InsightsOverviewIdentity = {
5
- readonly scopeKind: "release" | "channel" | "usage" | "distribution";
6
- readonly releaseKind: "all" | "specific" | "embedded";
7
- readonly releaseId: string;
8
- readonly channel: string;
9
- readonly platform: "all" | "ios" | "android";
10
- readonly appVersionKind: "all" | "specific";
11
- readonly appVersion: string;
12
- readonly periodKind: "lifetime" | "hour" | "latest";
13
- readonly bucketStartMs: number;
14
- };
15
- type InsightsOverviewDelta = {
16
- readonly identity: InsightsOverviewIdentity;
17
- readonly downloads: number;
18
- readonly launches: number;
19
- readonly failedLaunches: number;
20
- readonly launchIdentity?: string;
21
- readonly activityIdentity?: string;
22
- };
23
- declare const insightsOverviewId: (identity: InsightsOverviewIdentity) => string;
24
- declare const insightsOverviewValues: (identity: InsightsOverviewIdentity) => {
25
- id: string;
26
- scope_kind: "release" | "channel" | "usage" | "distribution";
27
- release_kind: "all" | "specific" | "embedded";
28
- release_id: string;
29
- channel: string;
30
- platform: "all" | "ios" | "android";
31
- app_version_kind: "all" | "specific";
32
- app_version: string;
33
- period_kind: "lifetime" | "hour" | "latest";
34
- bucket_start_ms: number;
35
- };
36
- declare const currentInsightsReleaseId: (event: BundleEventRow) => string | null;
37
- declare const insightsDistributionIdentity: (event: BundleEventRow) => InsightsOverviewIdentity;
38
- declare const insightsOverviewDeltas: (event: BundleEventRow) => readonly InsightsOverviewDelta[];
39
- //#endregion
40
- export { InsightsOverviewDelta, InsightsOverviewIdentity, currentInsightsReleaseId, insightsDistributionIdentity, insightsOverviewDeltas, insightsOverviewId, insightsOverviewValues };
@@ -1,40 +0,0 @@
1
- import { BundleEventRow } from "./types/databaseRows.mjs";
2
- import "./types/internal.mjs";
3
- //#region src/insightsOverview.d.ts
4
- type InsightsOverviewIdentity = {
5
- readonly scopeKind: "release" | "channel" | "usage" | "distribution";
6
- readonly releaseKind: "all" | "specific" | "embedded";
7
- readonly releaseId: string;
8
- readonly channel: string;
9
- readonly platform: "all" | "ios" | "android";
10
- readonly appVersionKind: "all" | "specific";
11
- readonly appVersion: string;
12
- readonly periodKind: "lifetime" | "hour" | "latest";
13
- readonly bucketStartMs: number;
14
- };
15
- type InsightsOverviewDelta = {
16
- readonly identity: InsightsOverviewIdentity;
17
- readonly downloads: number;
18
- readonly launches: number;
19
- readonly failedLaunches: number;
20
- readonly launchIdentity?: string;
21
- readonly activityIdentity?: string;
22
- };
23
- declare const insightsOverviewId: (identity: InsightsOverviewIdentity) => string;
24
- declare const insightsOverviewValues: (identity: InsightsOverviewIdentity) => {
25
- id: string;
26
- scope_kind: "release" | "channel" | "usage" | "distribution";
27
- release_kind: "all" | "specific" | "embedded";
28
- release_id: string;
29
- channel: string;
30
- platform: "all" | "ios" | "android";
31
- app_version_kind: "all" | "specific";
32
- app_version: string;
33
- period_kind: "lifetime" | "hour" | "latest";
34
- bucket_start_ms: number;
35
- };
36
- declare const currentInsightsReleaseId: (event: BundleEventRow) => string | null;
37
- declare const insightsDistributionIdentity: (event: BundleEventRow) => InsightsOverviewIdentity;
38
- declare const insightsOverviewDeltas: (event: BundleEventRow) => readonly InsightsOverviewDelta[];
39
- //#endregion
40
- export { InsightsOverviewDelta, InsightsOverviewIdentity, currentInsightsReleaseId, insightsDistributionIdentity, insightsOverviewDeltas, insightsOverviewId, insightsOverviewValues };
@@ -1,135 +0,0 @@
1
- //#region src/insightsOverview.ts
2
- const encodeIdentity = (identity) => [
3
- identity.scopeKind,
4
- identity.releaseKind,
5
- identity.releaseId,
6
- identity.channel,
7
- identity.platform,
8
- identity.appVersionKind,
9
- identity.appVersion,
10
- identity.periodKind,
11
- String(identity.bucketStartMs)
12
- ].map((value) => `${new TextEncoder().encode(value).length}:${value}`).join("");
13
- const fnv = (value, seed) => {
14
- let result = seed;
15
- for (const byte of new TextEncoder().encode(value)) {
16
- result ^= BigInt(byte);
17
- result = BigInt.asUintN(64, result * 1099511628211n);
18
- }
19
- return result.toString(16).padStart(16, "0");
20
- };
21
- const insightsOverviewId = (identity) => {
22
- const value = encodeIdentity(identity);
23
- return `${fnv(value, 14695981039346656037n)}${fnv(value, 9521211207457086692n)}`;
24
- };
25
- const insightsOverviewValues = (identity) => ({
26
- id: insightsOverviewId(identity),
27
- scope_kind: identity.scopeKind,
28
- release_kind: identity.releaseKind,
29
- release_id: identity.releaseId,
30
- channel: identity.channel,
31
- platform: identity.platform,
32
- app_version_kind: identity.appVersionKind,
33
- app_version: identity.appVersion,
34
- period_kind: identity.periodKind,
35
- bucket_start_ms: identity.bucketStartMs
36
- });
37
- const hour = (value) => Math.floor(value / 36e5) * 36e5;
38
- const currentInsightsReleaseId = (event) => event.type === "UPDATE_DOWNLOADED" ? event.from_release_id : event.to_release_id;
39
- const insightsDistributionIdentity = (event) => {
40
- const releaseId = currentInsightsReleaseId(event);
41
- return {
42
- scopeKind: "distribution",
43
- releaseKind: releaseId === null ? "embedded" : "specific",
44
- releaseId: releaseId ?? "",
45
- channel: event.channel,
46
- platform: event.platform,
47
- appVersionKind: "specific",
48
- appVersion: event.app_version,
49
- periodKind: "latest",
50
- bucketStartMs: hour(event.received_at_ms)
51
- };
52
- };
53
- const insightsOverviewDeltas = (event) => {
54
- const bucketStartMs = hour(event.received_at_ms);
55
- const counters = /* @__PURE__ */ new Map();
56
- const append = (identity, values) => {
57
- const key = encodeIdentity(identity);
58
- const previous = counters.get(key);
59
- counters.set(key, {
60
- identity,
61
- downloads: (previous?.downloads ?? 0) + values.downloads,
62
- launches: (previous?.launches ?? 0) + values.launches,
63
- failedLaunches: (previous?.failedLaunches ?? 0) + values.failedLaunches,
64
- launchIdentity: previous?.launchIdentity ?? values.launchIdentity,
65
- activityIdentity: previous?.activityIdentity ?? values.activityIdentity
66
- });
67
- };
68
- const metric = (releaseId, values) => {
69
- const launchIdentity = values.launches > 0 ? event.install_id : void 0;
70
- if (releaseId !== null) for (const [periodKind, start] of [["lifetime", 0], ["hour", bucketStartMs]]) append({
71
- scopeKind: "release",
72
- releaseKind: "specific",
73
- releaseId,
74
- channel: event.channel,
75
- platform: event.platform,
76
- appVersionKind: "all",
77
- appVersion: "",
78
- periodKind,
79
- bucketStartMs: start
80
- }, {
81
- ...values,
82
- ...periodKind === "hour" ? { launchIdentity } : {}
83
- });
84
- append({
85
- scopeKind: "channel",
86
- releaseKind: "all",
87
- releaseId: "",
88
- channel: event.channel,
89
- platform: event.platform,
90
- appVersionKind: "all",
91
- appVersion: "",
92
- periodKind: "hour",
93
- bucketStartMs
94
- }, {
95
- ...values,
96
- launchIdentity
97
- });
98
- };
99
- if (event.type === "UPDATE_DOWNLOADED") metric(event.to_release_id, {
100
- downloads: 1,
101
- launches: 0,
102
- failedLaunches: 0
103
- });
104
- else {
105
- metric(event.to_release_id, {
106
- downloads: 0,
107
- launches: 1,
108
- failedLaunches: 0
109
- });
110
- if (event.type === "RECOVERED") metric(event.from_release_id, {
111
- downloads: 0,
112
- launches: 0,
113
- failedLaunches: 1
114
- });
115
- }
116
- for (const platform of [event.platform, "all"]) for (const appVersionKind of ["specific", "all"]) append({
117
- scopeKind: "usage",
118
- releaseKind: "all",
119
- releaseId: "",
120
- channel: event.channel,
121
- platform,
122
- appVersionKind,
123
- appVersion: appVersionKind === "specific" ? event.app_version : "",
124
- periodKind: "hour",
125
- bucketStartMs
126
- }, {
127
- downloads: 0,
128
- launches: 0,
129
- failedLaunches: 0,
130
- activityIdentity: event.install_id
131
- });
132
- return [...counters.values()];
133
- };
134
- //#endregion
135
- export { currentInsightsReleaseId, insightsDistributionIdentity, insightsOverviewDeltas, insightsOverviewId, insightsOverviewValues };
@@ -1,53 +0,0 @@
1
- const require_calculatePagination = require("./calculatePagination.cjs");
2
- const require_queryBundles = require("./queryBundles.cjs");
3
- //#region src/paginateBundles.ts
4
- function paginateBundles({ bundles, limit, offset, cursor, orderBy }) {
5
- const sortedBundles = require_queryBundles.sortBundles(bundles, orderBy);
6
- const direction = orderBy?.direction ?? "desc";
7
- const total = sortedBundles.length;
8
- if (offset !== void 0) {
9
- const normalizedOffset = Math.max(0, offset);
10
- const data = limit > 0 ? sortedBundles.slice(normalizedOffset, normalizedOffset + limit) : sortedBundles.slice(normalizedOffset);
11
- const pagination = require_calculatePagination.calculatePagination(total, {
12
- limit,
13
- offset: normalizedOffset
14
- });
15
- const nextCursor = data.length > 0 && normalizedOffset + data.length < total ? data.at(-1)?.id : void 0;
16
- const previousCursor = data.length > 0 && normalizedOffset > 0 ? data[0]?.id : void 0;
17
- return {
18
- data,
19
- pagination: {
20
- ...pagination,
21
- ...nextCursor ? { nextCursor } : {},
22
- ...previousCursor ? { previousCursor } : {}
23
- }
24
- };
25
- }
26
- let data;
27
- if (cursor?.after) {
28
- const candidates = sortedBundles.filter((bundle) => direction === "desc" ? bundle.id.localeCompare(cursor.after) < 0 : bundle.id.localeCompare(cursor.after) > 0);
29
- data = limit > 0 ? candidates.slice(0, limit) : candidates;
30
- } else if (cursor?.before) {
31
- const candidates = sortedBundles.filter((bundle) => direction === "desc" ? bundle.id.localeCompare(cursor.before) > 0 : bundle.id.localeCompare(cursor.before) < 0);
32
- data = limit > 0 ? candidates.slice(Math.max(0, candidates.length - limit)) : candidates;
33
- } else data = limit > 0 ? sortedBundles.slice(0, limit) : sortedBundles;
34
- const startIndex = data.length > 0 ? sortedBundles.findIndex((bundle) => bundle.id === data[0].id) : cursor?.after ? total : 0;
35
- const pagination = require_calculatePagination.calculatePagination(total, {
36
- limit,
37
- offset: startIndex
38
- });
39
- const nextCursor = data.length > 0 && startIndex + data.length < total ? data.at(-1)?.id : void 0;
40
- const previousCursor = data.length > 0 && startIndex > 0 ? data[0]?.id : void 0;
41
- return {
42
- data,
43
- pagination: {
44
- ...pagination,
45
- ...nextCursor ? { nextCursor } : {},
46
- ...previousCursor ? { previousCursor } : {},
47
- ...data.length === 0 && cursor?.after ? { previousCursor: cursor.after } : {},
48
- ...data.length === 0 && cursor?.before ? { nextCursor: cursor.before } : {}
49
- }
50
- };
51
- }
52
- //#endregion
53
- exports.paginateBundles = paginateBundles;
@@ -1,13 +0,0 @@
1
- import { DatabaseBundleCursor, DatabaseBundleQueryOrder, Paginated } from "./types/index.cjs";
2
- //#region src/paginateBundles.d.ts
3
- declare function paginateBundles<TBundle extends {
4
- readonly id: string;
5
- }>({ bundles, limit, offset, cursor, orderBy }: {
6
- bundles: readonly TBundle[];
7
- limit: number;
8
- offset?: number;
9
- cursor?: DatabaseBundleCursor;
10
- orderBy?: DatabaseBundleQueryOrder;
11
- }): Paginated<TBundle[]>;
12
- //#endregion
13
- export { paginateBundles };
@@ -1,13 +0,0 @@
1
- import { DatabaseBundleCursor, DatabaseBundleQueryOrder, Paginated } from "./types/index.mjs";
2
- //#region src/paginateBundles.d.ts
3
- declare function paginateBundles<TBundle extends {
4
- readonly id: string;
5
- }>({ bundles, limit, offset, cursor, orderBy }: {
6
- bundles: readonly TBundle[];
7
- limit: number;
8
- offset?: number;
9
- cursor?: DatabaseBundleCursor;
10
- orderBy?: DatabaseBundleQueryOrder;
11
- }): Paginated<TBundle[]>;
12
- //#endregion
13
- export { paginateBundles };
@@ -1,53 +0,0 @@
1
- import { calculatePagination } from "./calculatePagination.mjs";
2
- import { sortBundles } from "./queryBundles.mjs";
3
- //#region src/paginateBundles.ts
4
- function paginateBundles({ bundles, limit, offset, cursor, orderBy }) {
5
- const sortedBundles = sortBundles(bundles, orderBy);
6
- const direction = orderBy?.direction ?? "desc";
7
- const total = sortedBundles.length;
8
- if (offset !== void 0) {
9
- const normalizedOffset = Math.max(0, offset);
10
- const data = limit > 0 ? sortedBundles.slice(normalizedOffset, normalizedOffset + limit) : sortedBundles.slice(normalizedOffset);
11
- const pagination = calculatePagination(total, {
12
- limit,
13
- offset: normalizedOffset
14
- });
15
- const nextCursor = data.length > 0 && normalizedOffset + data.length < total ? data.at(-1)?.id : void 0;
16
- const previousCursor = data.length > 0 && normalizedOffset > 0 ? data[0]?.id : void 0;
17
- return {
18
- data,
19
- pagination: {
20
- ...pagination,
21
- ...nextCursor ? { nextCursor } : {},
22
- ...previousCursor ? { previousCursor } : {}
23
- }
24
- };
25
- }
26
- let data;
27
- if (cursor?.after) {
28
- const candidates = sortedBundles.filter((bundle) => direction === "desc" ? bundle.id.localeCompare(cursor.after) < 0 : bundle.id.localeCompare(cursor.after) > 0);
29
- data = limit > 0 ? candidates.slice(0, limit) : candidates;
30
- } else if (cursor?.before) {
31
- const candidates = sortedBundles.filter((bundle) => direction === "desc" ? bundle.id.localeCompare(cursor.before) > 0 : bundle.id.localeCompare(cursor.before) < 0);
32
- data = limit > 0 ? candidates.slice(Math.max(0, candidates.length - limit)) : candidates;
33
- } else data = limit > 0 ? sortedBundles.slice(0, limit) : sortedBundles;
34
- const startIndex = data.length > 0 ? sortedBundles.findIndex((bundle) => bundle.id === data[0].id) : cursor?.after ? total : 0;
35
- const pagination = calculatePagination(total, {
36
- limit,
37
- offset: startIndex
38
- });
39
- const nextCursor = data.length > 0 && startIndex + data.length < total ? data.at(-1)?.id : void 0;
40
- const previousCursor = data.length > 0 && startIndex > 0 ? data[0]?.id : void 0;
41
- return {
42
- data,
43
- pagination: {
44
- ...pagination,
45
- ...nextCursor ? { nextCursor } : {},
46
- ...previousCursor ? { previousCursor } : {},
47
- ...data.length === 0 && cursor?.after ? { previousCursor: cursor.after } : {},
48
- ...data.length === 0 && cursor?.before ? { nextCursor: cursor.before } : {}
49
- }
50
- };
51
- }
52
- //#endregion
53
- export { paginateBundles };