@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.
Files changed (213) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +1 -1
  2. package/dist/adapters/databaseConstraintErrors.cjs +0 -1
  3. package/dist/adapters/databasePluginUtils.cjs +14 -1
  4. package/dist/adapters/databasePluginUtils.mjs +14 -2
  5. package/dist/adapters/drizzle.cjs +9 -4
  6. package/dist/adapters/drizzle.d.cts +0 -1
  7. package/dist/adapters/drizzle.d.mts +0 -1
  8. package/dist/adapters/drizzle.mjs +10 -4
  9. package/dist/adapters/drizzleCrud.cjs +93 -3
  10. package/dist/adapters/drizzleCrud.mjs +93 -5
  11. package/dist/adapters/drizzleLazyDB.cjs +2 -0
  12. package/dist/adapters/drizzleLazyDB.mjs +2 -0
  13. package/dist/adapters/drizzleQuery.cjs +3 -2
  14. package/dist/adapters/drizzleQuery.mjs +3 -1
  15. package/dist/adapters/kysely.cjs +1 -1
  16. package/dist/adapters/kysely.d.cts +0 -1
  17. package/dist/adapters/kysely.d.mts +0 -1
  18. package/dist/adapters/kysely.mjs +2 -1
  19. package/dist/adapters/kyselyCrud.cjs +44 -5
  20. package/dist/adapters/kyselyCrud.mjs +45 -6
  21. package/dist/adapters/kyselyQuery.cjs +2 -2
  22. package/dist/adapters/kyselyQuery.mjs +2 -1
  23. package/dist/adapters/mongodb.cjs +36 -1
  24. package/dist/adapters/mongodb.d.cts +1 -1
  25. package/dist/adapters/mongodb.d.mts +1 -1
  26. package/dist/adapters/mongodb.mjs +36 -0
  27. package/dist/adapters/mongodbCollections.cjs +2 -0
  28. package/dist/adapters/mongodbCollections.mjs +2 -0
  29. package/dist/adapters/mongodbQuery.cjs +17 -4
  30. package/dist/adapters/mongodbQuery.mjs +17 -4
  31. package/dist/adapters/mongodbReads.cjs +88 -30
  32. package/dist/adapters/mongodbReads.mjs +88 -29
  33. package/dist/adapters/mongodbWrites.cjs +1 -2
  34. package/dist/adapters/mongodbWrites.mjs +1 -1
  35. package/dist/adapters/prisma.cjs +44 -7
  36. package/dist/adapters/prisma.d.cts +0 -1
  37. package/dist/adapters/prisma.d.mts +0 -1
  38. package/dist/adapters/prisma.mjs +44 -6
  39. package/dist/adapters/prismaInsights.cjs +99 -0
  40. package/dist/adapters/prismaInsights.mjs +97 -0
  41. package/dist/adapters/prismaQuery.cjs +0 -1
  42. package/dist/adapters/prismaRows.cjs +7 -8
  43. package/dist/adapters/prismaRows.mjs +8 -8
  44. package/dist/apiKeys.cjs +6 -2
  45. package/dist/apiKeys.d.cts +0 -1
  46. package/dist/apiKeys.d.mts +0 -1
  47. package/dist/apiKeys.mjs +3 -3
  48. package/dist/createHotUpdaterCore.cjs +27 -12
  49. package/dist/createHotUpdaterCore.d.cts +8 -8
  50. package/dist/createHotUpdaterCore.d.mts +8 -8
  51. package/dist/createHotUpdaterCore.mjs +26 -12
  52. package/dist/db/createBundleDiff.cjs +2 -2
  53. package/dist/db/createBundleDiff.d.cts +1 -5
  54. package/dist/db/createBundleDiff.d.mts +1 -5
  55. package/dist/db/databasePluginCore.cjs +0 -1
  56. package/dist/db/fixedMigrator.cjs +2 -2
  57. package/dist/db/fixedMigrator.mjs +2 -2
  58. package/dist/db/fixedMigratorMongo.cjs +6 -4
  59. package/dist/db/fixedMigratorMongo.mjs +6 -4
  60. package/dist/db/index.d.cts +0 -1
  61. package/dist/db/index.d.mts +0 -1
  62. package/dist/db/releaseCatalog.cjs +0 -1
  63. package/dist/db/releaseCatalog.d.cts +0 -1
  64. package/dist/db/releaseCatalog.d.mts +0 -1
  65. package/dist/db/schema/insightsCollation.cjs +14 -0
  66. package/dist/db/schema/insightsCollation.mjs +14 -0
  67. package/dist/db/schema/sql.cjs +11 -7
  68. package/dist/db/schema/sql.mjs +8 -8
  69. package/dist/db/schemaGenerators.cjs +29 -9
  70. package/dist/db/schemaGenerators.mjs +29 -9
  71. package/dist/db/schemaReadiness.cjs +2 -0
  72. package/dist/db/schemaReadiness.d.cts +1 -0
  73. package/dist/db/schemaReadiness.d.mts +1 -0
  74. package/dist/db/schemaReadiness.mjs +2 -0
  75. package/dist/db/sqlMigrationExecution.cjs +1 -1
  76. package/dist/db/sqlMigrationExecution.mjs +1 -0
  77. package/dist/db/types.cjs +3 -1
  78. package/dist/db/types.d.cts +3 -6
  79. package/dist/db/types.d.mts +3 -6
  80. package/dist/db/types.mjs +2 -2
  81. package/dist/db/updateArtifacts.cjs +0 -1
  82. package/dist/handler.cjs +5 -5
  83. package/dist/handler.d.cts +1 -2
  84. package/dist/handler.d.mts +1 -2
  85. package/dist/handler.mjs +5 -5
  86. package/dist/handlerReleaseCatalogRoutes.cjs +0 -1
  87. package/dist/handlerReleaseManagementRoutes.cjs +0 -1
  88. package/dist/handlerTypes.d.cts +0 -1
  89. package/dist/handlerTypes.d.mts +0 -1
  90. package/dist/handlerVersionRoutes.d.cts +1 -0
  91. package/dist/handlerVersionRoutes.d.mts +1 -0
  92. package/dist/index.cjs +2 -2
  93. package/dist/index.d.cts +4 -4
  94. package/dist/index.d.mts +4 -4
  95. package/dist/index.mjs +2 -2
  96. package/dist/insights/domain.d.cts +92 -0
  97. package/dist/insights/domain.d.mts +92 -0
  98. package/dist/insights/errors.cjs +15 -0
  99. package/dist/insights/errors.mjs +14 -0
  100. package/dist/{analytics → insights}/eventInput.cjs +61 -16
  101. package/dist/{analytics → insights}/eventInput.mjs +61 -18
  102. package/dist/insights/provider.cjs +332 -0
  103. package/dist/insights/provider.d.cts +6 -0
  104. package/dist/insights/provider.d.mts +6 -0
  105. package/dist/insights/provider.mjs +332 -0
  106. package/dist/insights/queryInput.cjs +93 -0
  107. package/dist/insights/queryInput.mjs +91 -0
  108. package/dist/insights/routes.cjs +58 -0
  109. package/dist/insights/routes.mjs +56 -0
  110. package/dist/insights/types.d.cts +32 -0
  111. package/dist/insights/types.d.mts +32 -0
  112. package/dist/node.d.cts +0 -1
  113. package/dist/node.d.mts +0 -1
  114. package/dist/package.cjs +1 -1
  115. package/dist/package.mjs +1 -1
  116. package/dist/schema/index.cjs +17 -3
  117. package/dist/schema/index.mjs +4 -4
  118. package/dist/schema/v1_0_0.cjs +64 -35
  119. package/dist/schema/v1_0_0.mjs +64 -36
  120. package/dist/storageAccess.cjs +0 -1
  121. package/dist/types/index.d.cts +0 -1
  122. package/dist/types/index.d.mts +0 -1
  123. package/package.json +7 -7
  124. package/src/adapters/databasePluginTestDatabase.ts +15 -5
  125. package/src/adapters/databasePluginUtils.ts +24 -0
  126. package/src/adapters/drizzle.spec.ts +203 -5
  127. package/src/adapters/drizzle.ts +16 -4
  128. package/src/adapters/drizzleCrud.ts +200 -9
  129. package/src/adapters/drizzleLazyDB.ts +33 -6
  130. package/src/adapters/kysely.spec.ts +62 -0
  131. package/src/adapters/kysely.ts +7 -1
  132. package/src/adapters/kyselyCrud.ts +115 -7
  133. package/src/adapters/kyselyInsights.spec.ts +168 -0
  134. package/src/adapters/mongodb.integration.spec.ts +483 -0
  135. package/src/adapters/mongodb.spec.ts +89 -0
  136. package/src/adapters/mongodb.ts +59 -1
  137. package/src/adapters/mongodbCollections.ts +16 -0
  138. package/src/adapters/mongodbQuery.ts +22 -3
  139. package/src/adapters/mongodbReads.ts +78 -2
  140. package/src/adapters/mongodbTestClient.ts +107 -6
  141. package/src/adapters/mongodbTestFilter.ts +5 -1
  142. package/src/adapters/mongodbWrites.ts +1 -0
  143. package/src/adapters/prisma.spec.ts +270 -0
  144. package/src/adapters/prisma.ts +75 -2
  145. package/src/adapters/prismaInsights.ts +190 -0
  146. package/src/adapters/prismaRows.ts +17 -10
  147. package/src/adapters/prismaTestClient.ts +89 -7
  148. package/src/apiKeys.integration.spec.ts +3 -3
  149. package/src/createHotUpdaterCore.ts +30 -16
  150. package/src/db/databasePluginUpdateCheck.bench.ts +10 -0
  151. package/src/db/fixedMigrator.spec.ts +63 -0
  152. package/src/db/fixedMigratorMongo.spec.ts +70 -9
  153. package/src/db/fixedMigratorMongo.ts +10 -10
  154. package/src/db/index.spec.ts +6 -1
  155. package/src/db/schema/insightsCollation.ts +21 -0
  156. package/src/db/schema/sql.ts +8 -5
  157. package/src/db/schemaGenerators.ts +42 -13
  158. package/src/db/types.spec.ts +11 -3
  159. package/src/db/types.ts +13 -7
  160. package/src/handler-standalone.integration.spec.ts +6 -8
  161. package/src/handler.ts +12 -12
  162. package/src/index.ts +3 -3
  163. package/src/insights/domain.ts +106 -0
  164. package/src/insights/errors.ts +11 -0
  165. package/src/{analytics → insights}/eventInput.ts +66 -16
  166. package/src/insights/insights.integration.spec.ts +475 -0
  167. package/src/insights/provider.spec.ts +396 -0
  168. package/src/insights/provider.ts +611 -0
  169. package/src/insights/queryInput.ts +142 -0
  170. package/src/insights/routes.ts +104 -0
  171. package/src/insights/types.ts +55 -0
  172. package/src/schema/dsl-all-versions.spec.ts +1 -1
  173. package/src/schema/v1_0_0.spec.ts +77 -3
  174. package/src/schema/v1_0_0.ts +83 -37
  175. package/dist/analytics/bounded/activeOverview.cjs +0 -87
  176. package/dist/analytics/bounded/activeOverview.mjs +0 -85
  177. package/dist/analytics/bounded/installationSearch.cjs +0 -42
  178. package/dist/analytics/bounded/installationSearch.mjs +0 -42
  179. package/dist/analytics/bounded/persistence.cjs +0 -39
  180. package/dist/analytics/bounded/persistence.mjs +0 -38
  181. package/dist/analytics/bounded/provider.cjs +0 -170
  182. package/dist/analytics/bounded/provider.d.cts +0 -7
  183. package/dist/analytics/bounded/provider.d.mts +0 -7
  184. package/dist/analytics/bounded/provider.mjs +0 -170
  185. package/dist/analytics/bounded/scan.cjs +0 -144
  186. package/dist/analytics/bounded/scan.mjs +0 -138
  187. package/dist/analytics/domain.d.cts +0 -121
  188. package/dist/analytics/domain.d.mts +0 -121
  189. package/dist/analytics/errors.cjs +0 -22
  190. package/dist/analytics/errors.mjs +0 -20
  191. package/dist/analytics/persistence.d.cts +0 -6
  192. package/dist/analytics/persistence.d.mts +0 -6
  193. package/dist/analytics/queryInput.cjs +0 -58
  194. package/dist/analytics/queryInput.mjs +0 -55
  195. package/dist/analytics/routes.cjs +0 -63
  196. package/dist/analytics/routes.mjs +0 -61
  197. package/dist/analytics/types.d.cts +0 -17
  198. package/dist/analytics/types.d.mts +0 -17
  199. package/src/analytics/analytics.integration.spec.ts +0 -144
  200. package/src/analytics/bounded/activeOverview.spec.ts +0 -189
  201. package/src/analytics/bounded/activeOverview.ts +0 -148
  202. package/src/analytics/bounded/installationSearch.spec.ts +0 -130
  203. package/src/analytics/bounded/installationSearch.ts +0 -69
  204. package/src/analytics/bounded/persistence.ts +0 -43
  205. package/src/analytics/bounded/provider.spec.ts +0 -219
  206. package/src/analytics/bounded/provider.ts +0 -229
  207. package/src/analytics/bounded/scan.ts +0 -235
  208. package/src/analytics/domain.ts +0 -139
  209. package/src/analytics/errors.ts +0 -18
  210. package/src/analytics/persistence.ts +0 -10
  211. package/src/analytics/queryInput.ts +0 -102
  212. package/src/analytics/routes.ts +0 -123
  213. package/src/analytics/types.ts +0 -44
@@ -1,5 +1,4 @@
1
1
  import { Bundle, BundleRepository, StoragePluginWith } from "@hot-updater/plugin-core";
2
-
3
2
  //#region src/db/createBundleDiff.d.ts
4
3
  interface CreateBundleDiffInput {
5
4
  baseBundleId: string;
@@ -12,9 +11,6 @@ interface CreateBundleDiffDependencies {
12
11
  interface CreateBundleDiffOptions {
13
12
  makePrimary?: boolean;
14
13
  }
15
- declare function createBundleDiff({
16
- baseBundleId,
17
- bundleId
18
- }: CreateBundleDiffInput, deps: CreateBundleDiffDependencies, options?: CreateBundleDiffOptions): Promise<Bundle>;
14
+ declare function createBundleDiff({ baseBundleId, bundleId }: CreateBundleDiffInput, deps: CreateBundleDiffDependencies, options?: CreateBundleDiffOptions): Promise<Bundle>;
19
15
  //#endregion
20
16
  export { CreateBundleDiffDependencies, CreateBundleDiffInput, CreateBundleDiffOptions, createBundleDiff };
@@ -1,4 +1,3 @@
1
- require("../_virtual/_rolldown/runtime.cjs");
2
1
  const require_releaseCatalog = require("./releaseCatalog.cjs");
3
2
  let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
4
3
  let _hot_updater_core = require("@hot-updater/core");
@@ -1,10 +1,9 @@
1
- require("../_virtual/_rolldown/runtime.cjs");
2
1
  const require_types = require("../schema/types.cjs");
3
2
  const require_fixedMigratorShared = require("./fixedMigratorShared.cjs");
4
3
  const require_sql = require("./schema/sql.cjs");
5
4
  const require_sqlOperations = require("./schema/sqlOperations.cjs");
6
5
  const require_sqlMigrationExecution = require("./sqlMigrationExecution.cjs");
7
- require("./fixedMigratorMongo.cjs");
6
+ const require_fixedMigratorMongo = require("./fixedMigratorMongo.cjs");
8
7
  let kysely = require("kysely");
9
8
  //#region src/db/fixedMigrator.ts
10
9
  const isMissingSettingsTableError = (error) => {
@@ -77,3 +76,4 @@ const createKyselyMigrator = ({ db, provider, relationMode = "foreign-keys" }) =
77
76
  };
78
77
  //#endregion
79
78
  exports.createKyselyMigrator = createKyselyMigrator;
79
+ exports.createMongoMigrator = require_fixedMigratorMongo.createMongoMigrator;
@@ -3,7 +3,7 @@ import { assertCurrentOrEmptySchemaVersion, assertSupportedMigrationMode, getEmp
3
3
  import { createTableSql } from "./schema/sql.mjs";
4
4
  import { createSqlCreateOperations, getSettingsInsertSql } from "./schema/sqlOperations.mjs";
5
5
  import { executeMigrationStatements } from "./sqlMigrationExecution.mjs";
6
- import "./fixedMigratorMongo.mjs";
6
+ import { createMongoMigrator } from "./fixedMigratorMongo.mjs";
7
7
  import { sql } from "kysely";
8
8
  //#region src/db/fixedMigrator.ts
9
9
  const isMissingSettingsTableError = (error) => {
@@ -75,4 +75,4 @@ const createKyselyMigrator = ({ db, provider, relationMode = "foreign-keys" }) =
75
75
  };
76
76
  };
77
77
  //#endregion
78
- export { createKyselyMigrator };
78
+ export { createKyselyMigrator, createMongoMigrator };
@@ -259,19 +259,21 @@ const createMongoMigrator = (client) => {
259
259
  await ensureSettingsKeyIndex();
260
260
  for (const table of require_registry.hotUpdaterSchema.tables) {
261
261
  if (table.internal) continue;
262
+ const isInsights = table.ormName === "bundle_events" || table.ormName === "bundle_event_heads";
262
263
  const collection = db.collection(table.ormName);
264
+ const collation = isInsights ? { locale: "simple" } : void 0;
263
265
  const primaryKey = table.columns.find((column) => column.primaryKey);
264
266
  if (!primaryKey) throw new Error(`MongoDB table ${table.ormName} does not define a primary key.`);
265
267
  const idIndexName = `${table.ormName}_${primaryKey.ormName}_idx`;
266
- const existingIdIndex = (await collection.listIndexes().toArray()).find(({ name }) => name === idIndexName);
267
- if (existingIdIndex && existingIdIndex.unique !== true) await collection.dropIndex(idIndexName);
268
268
  await collection.createIndex({ [primaryKey.ormName]: 1 }, {
269
269
  name: idIndexName,
270
- unique: true
270
+ unique: true,
271
+ ...collation ? { collation } : {}
271
272
  });
272
273
  for (const index of (table.indexes ?? []).filter((item) => require_registry.schemaIndexAppliesToProvider(item, "mongodb"))) await collection.createIndex(Object.fromEntries(index.columns.map((column) => [column, 1])), {
273
274
  name: index.name,
274
- ...index.unique ? { unique: true } : {}
275
+ ...index.unique ? { unique: true } : {},
276
+ ...collation ? { collation } : {}
275
277
  });
276
278
  }
277
279
  },
@@ -259,19 +259,21 @@ const createMongoMigrator = (client) => {
259
259
  await ensureSettingsKeyIndex();
260
260
  for (const table of hotUpdaterSchema.tables) {
261
261
  if (table.internal) continue;
262
+ const isInsights = table.ormName === "bundle_events" || table.ormName === "bundle_event_heads";
262
263
  const collection = db.collection(table.ormName);
264
+ const collation = isInsights ? { locale: "simple" } : void 0;
263
265
  const primaryKey = table.columns.find((column) => column.primaryKey);
264
266
  if (!primaryKey) throw new Error(`MongoDB table ${table.ormName} does not define a primary key.`);
265
267
  const idIndexName = `${table.ormName}_${primaryKey.ormName}_idx`;
266
- const existingIdIndex = (await collection.listIndexes().toArray()).find(({ name }) => name === idIndexName);
267
- if (existingIdIndex && existingIdIndex.unique !== true) await collection.dropIndex(idIndexName);
268
268
  await collection.createIndex({ [primaryKey.ormName]: 1 }, {
269
269
  name: idIndexName,
270
- unique: true
270
+ unique: true,
271
+ ...collation ? { collation } : {}
271
272
  });
272
273
  for (const index of (table.indexes ?? []).filter((item) => schemaIndexAppliesToProvider(item, "mongodb"))) await collection.createIndex(Object.fromEntries(index.columns.map((column) => [column, 1])), {
273
274
  name: index.name,
274
- ...index.unique ? { unique: true } : {}
275
+ ...index.unique ? { unique: true } : {},
276
+ ...collation ? { collation } : {}
275
277
  });
276
278
  }
277
279
  },
@@ -2,7 +2,6 @@ import { Migrator, SchemaGenerator } from "./types.cjs";
2
2
  import { CreateBundleDiffDependencies, CreateBundleDiffInput, CreateBundleDiffOptions, createBundleDiff } from "./createBundleDiff.cjs";
3
3
  import { HotUpdaterSchemaMigrationRequiredError } from "./schemaReadiness.cjs";
4
4
  import { HOT_UPDATER_SERVER_VERSION } from "../version.cjs";
5
-
6
5
  //#region src/db/index.d.ts
7
6
  type HotUpdaterDBTarget = {
8
7
  readonly adapterName: string;
@@ -2,7 +2,6 @@ import { Migrator, SchemaGenerator } from "./types.mjs";
2
2
  import { CreateBundleDiffDependencies, CreateBundleDiffInput, CreateBundleDiffOptions, createBundleDiff } from "./createBundleDiff.mjs";
3
3
  import { HotUpdaterSchemaMigrationRequiredError } from "./schemaReadiness.mjs";
4
4
  import { HOT_UPDATER_SERVER_VERSION } from "../version.mjs";
5
-
6
5
  //#region src/db/index.d.ts
7
6
  type HotUpdaterDBTarget = {
8
7
  readonly adapterName: string;
@@ -1,4 +1,3 @@
1
- require("../_virtual/_rolldown/runtime.cjs");
2
1
  const require_updateArtifacts = require("./updateArtifacts.cjs");
3
2
  let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
4
3
  let _hot_updater_core = require("@hot-updater/core");
@@ -1,6 +1,5 @@
1
1
  import { ArtifactInfo, ReleaseCatalog } from "@hot-updater/core";
2
2
  import { DatabasePlugin } from "@hot-updater/plugin-core";
3
-
4
3
  //#region src/db/releaseCatalog.d.ts
5
4
  type ReleaseCatalogRequest = {
6
5
  readonly strategy: "APP_VERSION";
@@ -1,6 +1,5 @@
1
1
  import { DatabasePlugin } from "@hot-updater/plugin-core";
2
2
  import { ArtifactInfo, ReleaseCatalog } from "@hot-updater/core";
3
-
4
3
  //#region src/db/releaseCatalog.d.ts
5
4
  type ReleaseCatalogRequest = {
6
5
  readonly strategy: "APP_VERSION";
@@ -0,0 +1,14 @@
1
+ const require_v1_0_0 = require("../../schema/v1_0_0.cjs");
2
+ const require_sql = require("./sql.cjs");
3
+ //#region src/db/schema/insightsCollation.ts
4
+ const getInsightsCollationSql = (provider) => [require_v1_0_0.bundleEventsV100, require_v1_0_0.bundleEventHeadsV100].flatMap((table) => table.columns.flatMap((column) => {
5
+ const collation = column.providerCollations?.[provider];
6
+ if (collation === void 0) return [];
7
+ if (provider === "mysql") return [`alter table ${table.ormName} modify column ${require_sql.sqlColumnDefinition(table, {
8
+ ...column,
9
+ primaryKey: void 0
10
+ }, provider)}`];
11
+ return [`alter table ${table.ormName} alter column ${column.ormName} type ${require_sql.getSqlType(column.type, provider)} collate ${collation}`];
12
+ }));
13
+ //#endregion
14
+ exports.getInsightsCollationSql = getInsightsCollationSql;
@@ -0,0 +1,14 @@
1
+ import { bundleEventHeadsV100, bundleEventsV100 } from "../../schema/v1_0_0.mjs";
2
+ import { getSqlType, sqlColumnDefinition } from "./sql.mjs";
3
+ //#region src/db/schema/insightsCollation.ts
4
+ const getInsightsCollationSql = (provider) => [bundleEventsV100, bundleEventHeadsV100].flatMap((table) => table.columns.flatMap((column) => {
5
+ const collation = column.providerCollations?.[provider];
6
+ if (collation === void 0) return [];
7
+ if (provider === "mysql") return [`alter table ${table.ormName} modify column ${sqlColumnDefinition(table, {
8
+ ...column,
9
+ primaryKey: void 0
10
+ }, provider)}`];
11
+ return [`alter table ${table.ormName} alter column ${column.ormName} type ${getSqlType(column.type, provider)} collate ${collation}`];
12
+ }));
13
+ //#endregion
14
+ export { getInsightsCollationSql };
@@ -83,19 +83,23 @@ const createTableStatement = (table, provider, relationMode = "foreign-keys") =>
83
83
  ];
84
84
  return `create table ${table.ormName} (\n${lines.join(",\n")}\n)`;
85
85
  };
86
- const createForeignKeySqlStatements = (provider, relationMode = "foreign-keys") => {
86
+ const createForeignKeySqlStatements = (provider, relationMode = "foreign-keys", schema = require_registry.hotUpdaterSchema) => {
87
87
  if (relationMode !== "foreign-keys" || provider === "sqlite") return [];
88
- return require_registry.hotUpdaterSchema.tables.flatMap((table) => (table.foreignKeys ?? []).map((foreignKey) => createForeignKeySql(table, foreignKey, provider)));
88
+ return schema.tables.flatMap((table) => (table.foreignKeys ?? []).map((foreignKey) => createForeignKeySql(table, foreignKey, provider)));
89
89
  };
90
- const createTableSql = (provider, relationMode = "foreign-keys") => [
91
- ...require_registry.hotUpdaterSchema.tables.map((table) => createTableStatement(table, provider, relationMode)),
92
- ...require_registry.hotUpdaterSchema.tables.flatMap((table) => (table.indexes ?? []).filter((index) => require_registry.schemaIndexAppliesToProvider(index, provider)).map((index) => createIndexSql(table, index, provider))),
93
- ...provider === "sqlite" ? [] : require_registry.hotUpdaterSchema.tables.flatMap((table) => (table.checks ?? []).map((check) => createCheckSql(table, check, provider))),
94
- ...createForeignKeySqlStatements(provider, relationMode)
90
+ const createTableSql = (provider, relationMode = "foreign-keys", schema = require_registry.hotUpdaterSchema) => [
91
+ ...schema.tables.map((table) => createTableStatement(table, provider, relationMode)),
92
+ ...schema.tables.flatMap((table) => (table.indexes ?? []).filter((index) => require_registry.schemaIndexAppliesToProvider(index, provider)).map((index) => createIndexSql(table, index, provider))),
93
+ ...provider === "sqlite" ? [] : schema.tables.flatMap((table) => (table.checks ?? []).map((check) => createCheckSql(table, check, provider))),
94
+ ...createForeignKeySqlStatements(provider, relationMode, schema)
95
95
  ];
96
96
  //#endregion
97
97
  exports.createCheckSql = createCheckSql;
98
98
  exports.createForeignKeySql = createForeignKeySql;
99
+ exports.createForeignKeySqlStatements = createForeignKeySqlStatements;
99
100
  exports.createIndexSql = createIndexSql;
100
101
  exports.createTableSql = createTableSql;
102
+ exports.createTableStatement = createTableStatement;
103
+ exports.getSqlType = getSqlType;
101
104
  exports.hotUpdaterCreateTableOperations = hotUpdaterCreateTableOperations;
105
+ exports.sqlColumnDefinition = sqlColumnDefinition;
@@ -83,15 +83,15 @@ const createTableStatement = (table, provider, relationMode = "foreign-keys") =>
83
83
  ];
84
84
  return `create table ${table.ormName} (\n${lines.join(",\n")}\n)`;
85
85
  };
86
- const createForeignKeySqlStatements = (provider, relationMode = "foreign-keys") => {
86
+ const createForeignKeySqlStatements = (provider, relationMode = "foreign-keys", schema = hotUpdaterSchema) => {
87
87
  if (relationMode !== "foreign-keys" || provider === "sqlite") return [];
88
- return hotUpdaterSchema.tables.flatMap((table) => (table.foreignKeys ?? []).map((foreignKey) => createForeignKeySql(table, foreignKey, provider)));
88
+ return schema.tables.flatMap((table) => (table.foreignKeys ?? []).map((foreignKey) => createForeignKeySql(table, foreignKey, provider)));
89
89
  };
90
- const createTableSql = (provider, relationMode = "foreign-keys") => [
91
- ...hotUpdaterSchema.tables.map((table) => createTableStatement(table, provider, relationMode)),
92
- ...hotUpdaterSchema.tables.flatMap((table) => (table.indexes ?? []).filter((index) => schemaIndexAppliesToProvider(index, provider)).map((index) => createIndexSql(table, index, provider))),
93
- ...provider === "sqlite" ? [] : hotUpdaterSchema.tables.flatMap((table) => (table.checks ?? []).map((check) => createCheckSql(table, check, provider))),
94
- ...createForeignKeySqlStatements(provider, relationMode)
90
+ const createTableSql = (provider, relationMode = "foreign-keys", schema = hotUpdaterSchema) => [
91
+ ...schema.tables.map((table) => createTableStatement(table, provider, relationMode)),
92
+ ...schema.tables.flatMap((table) => (table.indexes ?? []).filter((index) => schemaIndexAppliesToProvider(index, provider)).map((index) => createIndexSql(table, index, provider))),
93
+ ...provider === "sqlite" ? [] : schema.tables.flatMap((table) => (table.checks ?? []).map((check) => createCheckSql(table, check, provider))),
94
+ ...createForeignKeySqlStatements(provider, relationMode, schema)
95
95
  ];
96
96
  //#endregion
97
- export { createCheckSql, createForeignKeySql, createIndexSql, createTableSql, hotUpdaterCreateTableOperations };
97
+ export { createCheckSql, createForeignKeySql, createForeignKeySqlStatements, createIndexSql, createTableSql, createTableStatement, getSqlType, hotUpdaterCreateTableOperations, sqlColumnDefinition };
@@ -1,11 +1,14 @@
1
1
  require("../schema/types.cjs");
2
2
  const require_types$1 = require("./types.cjs");
3
3
  const require_registry = require("./schema/registry.cjs");
4
+ const require_sql = require("./schema/sql.cjs");
5
+ const require_insightsCollation = require("./schema/insightsCollation.cjs");
4
6
  //#region src/db/schemaGenerators.ts
5
7
  const literal = (value) => JSON.stringify(value);
6
8
  const varcharLength = (type) => Number(type.slice(8, -1));
7
9
  const toPascalCase = (value) => value.split("_").filter(Boolean).map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`).join("");
8
10
  const prismaDb = (type, provider) => {
11
+ if (provider === "cockroachdb" && type === "uuid") return " @db.Uuid";
9
12
  if (provider === "postgresql") {
10
13
  if (type === "uuid") return " @db.Uuid";
11
14
  if (type.startsWith("varchar")) return ` @db.VarChar(${varcharLength(type)})`;
@@ -55,17 +58,34 @@ const prismaRelationFields = (table, schema) => {
55
58
  return lines;
56
59
  };
57
60
  const prismaIndexes = (table, provider) => (table.indexes ?? []).filter((index) => require_registry.schemaIndexAppliesToProvider(index, provider)).map((index) => `@@${index.unique ? "unique" : "index"}([${index.columns.join(", ")}], map: ${literal(index.name)})`);
58
- const generatePrismaSchema = (provider, schema = require_registry.hotUpdaterSchema) => schema.tables.map((table) => {
59
- const lines = [
60
- ...table.columns.map((column) => prismaField(column, provider)),
61
- ...prismaRelationFields(table, schema),
62
- ...prismaIndexes(table, provider)
63
- ];
64
- return `model ${table.ormName} {\n${lines.map((line) => ` ${line}`).join("\n")}\n}`;
65
- }).join("\n\n");
61
+ const generatePrismaSchema = (provider, schema = require_registry.hotUpdaterSchema) => {
62
+ const sqlProvider = require_types$1.getSQLProvider(provider);
63
+ const collationSql = sqlProvider ? require_insightsCollation.getInsightsCollationSql(sqlProvider) : [];
64
+ return (collationSql.length === 0 ? "" : [
65
+ "// Apply these statements in the initial Prisma SQL migration to preserve exact Insights identities and cursors:",
66
+ ...collationSql.map((statement) => `// ${statement};`),
67
+ ""
68
+ ].join("\n")) + schema.tables.map((table) => {
69
+ const lines = [
70
+ ...table.columns.map((column) => prismaField(column, provider)),
71
+ ...prismaRelationFields(table, schema),
72
+ ...prismaIndexes(table, provider)
73
+ ];
74
+ return `model ${table.ormName} {\n${lines.map((line) => ` ${line}`).join("\n")}\n}`;
75
+ }).join("\n\n");
76
+ };
66
77
  const drizzleImportSource = (provider) => provider === "sqlite" ? "drizzle-orm/sqlite-core" : provider === "mysql" ? "drizzle-orm/mysql-core" : "drizzle-orm/pg-core";
67
78
  const drizzleTableFn = (provider) => provider === "sqlite" ? "sqliteTable" : provider === "mysql" ? "mysqlTable" : "pgTable";
68
79
  const drizzleColumnFn = (column, provider) => {
80
+ const collation = column.providerCollations?.[provider];
81
+ if (collation !== void 0) {
82
+ const charset = provider === "mysql" ? ` character set ${collation === "ascii_bin" ? "ascii" : "utf8mb4"}` : "";
83
+ const dataType = `${require_sql.getSqlType(column.type, provider)}${charset} collate ${collation}`;
84
+ return {
85
+ code: `customType<{ data: string }>({ dataType: () => ${literal(dataType)} })(${literal(column.ormName)})`,
86
+ imports: ["customType"]
87
+ };
88
+ }
69
89
  if (provider === "sqlite") {
70
90
  if (column.type === "bool") return {
71
91
  code: `integer(${literal(column.ormName)}, { mode: "boolean" })`,
@@ -227,7 +247,7 @@ ${lines.join(",\n")}
227
247
  }))`;
228
248
  };
229
249
  const generateDrizzleSchema = (provider, schema = require_registry.hotUpdaterSchema) => {
230
- const imports = new Set([drizzleTableFn(provider)]);
250
+ const imports = /* @__PURE__ */ new Set([drizzleTableFn(provider)]);
231
251
  const body = [];
232
252
  for (const table of schema.tables) {
233
253
  body.push(drizzleTable(table, provider, imports));
@@ -1,11 +1,14 @@
1
1
  import "../schema/types.mjs";
2
2
  import { getSQLProvider } from "./types.mjs";
3
3
  import { getHotUpdaterSchemaVersion, hotUpdaterSchema, schemaIndexAppliesToProvider } from "./schema/registry.mjs";
4
+ import { getSqlType } from "./schema/sql.mjs";
5
+ import { getInsightsCollationSql } from "./schema/insightsCollation.mjs";
4
6
  //#region src/db/schemaGenerators.ts
5
7
  const literal = (value) => JSON.stringify(value);
6
8
  const varcharLength = (type) => Number(type.slice(8, -1));
7
9
  const toPascalCase = (value) => value.split("_").filter(Boolean).map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`).join("");
8
10
  const prismaDb = (type, provider) => {
11
+ if (provider === "cockroachdb" && type === "uuid") return " @db.Uuid";
9
12
  if (provider === "postgresql") {
10
13
  if (type === "uuid") return " @db.Uuid";
11
14
  if (type.startsWith("varchar")) return ` @db.VarChar(${varcharLength(type)})`;
@@ -55,17 +58,34 @@ const prismaRelationFields = (table, schema) => {
55
58
  return lines;
56
59
  };
57
60
  const prismaIndexes = (table, provider) => (table.indexes ?? []).filter((index) => schemaIndexAppliesToProvider(index, provider)).map((index) => `@@${index.unique ? "unique" : "index"}([${index.columns.join(", ")}], map: ${literal(index.name)})`);
58
- const generatePrismaSchema = (provider, schema = hotUpdaterSchema) => schema.tables.map((table) => {
59
- const lines = [
60
- ...table.columns.map((column) => prismaField(column, provider)),
61
- ...prismaRelationFields(table, schema),
62
- ...prismaIndexes(table, provider)
63
- ];
64
- return `model ${table.ormName} {\n${lines.map((line) => ` ${line}`).join("\n")}\n}`;
65
- }).join("\n\n");
61
+ const generatePrismaSchema = (provider, schema = hotUpdaterSchema) => {
62
+ const sqlProvider = getSQLProvider(provider);
63
+ const collationSql = sqlProvider ? getInsightsCollationSql(sqlProvider) : [];
64
+ return (collationSql.length === 0 ? "" : [
65
+ "// Apply these statements in the initial Prisma SQL migration to preserve exact Insights identities and cursors:",
66
+ ...collationSql.map((statement) => `// ${statement};`),
67
+ ""
68
+ ].join("\n")) + schema.tables.map((table) => {
69
+ const lines = [
70
+ ...table.columns.map((column) => prismaField(column, provider)),
71
+ ...prismaRelationFields(table, schema),
72
+ ...prismaIndexes(table, provider)
73
+ ];
74
+ return `model ${table.ormName} {\n${lines.map((line) => ` ${line}`).join("\n")}\n}`;
75
+ }).join("\n\n");
76
+ };
66
77
  const drizzleImportSource = (provider) => provider === "sqlite" ? "drizzle-orm/sqlite-core" : provider === "mysql" ? "drizzle-orm/mysql-core" : "drizzle-orm/pg-core";
67
78
  const drizzleTableFn = (provider) => provider === "sqlite" ? "sqliteTable" : provider === "mysql" ? "mysqlTable" : "pgTable";
68
79
  const drizzleColumnFn = (column, provider) => {
80
+ const collation = column.providerCollations?.[provider];
81
+ if (collation !== void 0) {
82
+ const charset = provider === "mysql" ? ` character set ${collation === "ascii_bin" ? "ascii" : "utf8mb4"}` : "";
83
+ const dataType = `${getSqlType(column.type, provider)}${charset} collate ${collation}`;
84
+ return {
85
+ code: `customType<{ data: string }>({ dataType: () => ${literal(dataType)} })(${literal(column.ormName)})`,
86
+ imports: ["customType"]
87
+ };
88
+ }
69
89
  if (provider === "sqlite") {
70
90
  if (column.type === "bool") return {
71
91
  code: `integer(${literal(column.ormName)}, { mode: "boolean" })`,
@@ -227,7 +247,7 @@ ${lines.join(",\n")}
227
247
  }))`;
228
248
  };
229
249
  const generateDrizzleSchema = (provider, schema = hotUpdaterSchema) => {
230
- const imports = new Set([drizzleTableFn(provider)]);
250
+ const imports = /* @__PURE__ */ new Set([drizzleTableFn(provider)]);
231
251
  const body = [];
232
252
  for (const table of schema.tables) {
233
253
  body.push(drizzleTable(table, provider, imports));
@@ -2,6 +2,8 @@ require("../schema/types.cjs");
2
2
  const require_fixedMigratorShared = require("./fixedMigratorShared.cjs");
3
3
  //#region src/db/schemaReadiness.ts
4
4
  var HotUpdaterSchemaMigrationRequiredError = class extends Error {
5
+ adapterName;
6
+ currentVersion;
5
7
  constructor(adapterName, currentVersion) {
6
8
  super(currentVersion === void 0 ? `Hot Updater database schema is not initialized for ${adapterName}. Run \`hot-updater db migrate\` before using this adapter.` : require_fixedMigratorShared.unsupportedSchemaUpgradeMessage(currentVersion));
7
9
  this.adapterName = adapterName;
@@ -1,3 +1,4 @@
1
+ import "./types.cjs";
1
2
  //#region src/db/schemaReadiness.d.ts
2
3
  declare class HotUpdaterSchemaMigrationRequiredError extends Error {
3
4
  readonly adapterName: string;
@@ -1,3 +1,4 @@
1
+ import "./types.mjs";
1
2
  //#region src/db/schemaReadiness.d.ts
2
3
  declare class HotUpdaterSchemaMigrationRequiredError extends Error {
3
4
  readonly adapterName: string;
@@ -2,6 +2,8 @@ import "../schema/types.mjs";
2
2
  import { unsupportedSchemaUpgradeMessage } from "./fixedMigratorShared.mjs";
3
3
  //#region src/db/schemaReadiness.ts
4
4
  var HotUpdaterSchemaMigrationRequiredError = class extends Error {
5
+ adapterName;
6
+ currentVersion;
5
7
  constructor(adapterName, currentVersion) {
6
8
  super(currentVersion === void 0 ? `Hot Updater database schema is not initialized for ${adapterName}. Run \`hot-updater db migrate\` before using this adapter.` : unsupportedSchemaUpgradeMessage(currentVersion));
7
9
  this.adapterName = adapterName;
@@ -1,7 +1,7 @@
1
- require("../_virtual/_rolldown/runtime.cjs");
2
1
  let kysely = require("kysely");
3
2
  //#region src/db/sqlMigrationExecution.ts
4
3
  var SqliteMigrationForeignKeyError = class extends Error {
4
+ violations;
5
5
  name = "SqliteMigrationForeignKeyError";
6
6
  constructor(violations) {
7
7
  super(`SQLite migration produced ${violations} foreign key violation(s).`);
@@ -1,6 +1,7 @@
1
1
  import { sql } from "kysely";
2
2
  //#region src/db/sqlMigrationExecution.ts
3
3
  var SqliteMigrationForeignKeyError = class extends Error {
4
+ violations;
4
5
  name = "SqliteMigrationForeignKeyError";
5
6
  constructor(violations) {
6
7
  super(`SQLite migration produced ${violations} foreign key violation(s).`);
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" && "analytics" in plugin.models && typeof plugin.models.analytics === "object" && plugin.models.analytics !== null && "append" in plugin.models.analytics && typeof plugin.models.analytics.append === "function" && "scan" in plugin.models.analytics && typeof plugin.models.analytics.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");
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 && "recordEvent" in plugin.models.insights && typeof plugin.models.insights.recordEvent === "function" && "listEvents" in plugin.models.insights && typeof plugin.models.insights.listEvents === "function" && "findLatestEvents" in plugin.models.insights && typeof plugin.models.insights.findLatestEvents === "function" && "countEvents" in plugin.models.insights && typeof plugin.models.insights.countEvents === "function" && "countLatestEvents" in plugin.models.insights && typeof plugin.models.insights.countLatestEvents === "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;
@@ -18,3 +18,5 @@ function getSQLProvider(provider) {
18
18
  //#endregion
19
19
  exports.getSQLProvider = getSQLProvider;
20
20
  exports.isDatabasePlugin = isDatabasePlugin;
21
+ exports.noSqlProviders = noSqlProviders;
22
+ exports.sqlProviders = sqlProviders;
@@ -1,10 +1,7 @@
1
1
  import { ReleaseCatalogRequest } from "./releaseCatalog.cjs";
2
2
  import { PaginatedResult } from "../types/index.cjs";
3
- import * as _$_hot_updater_core0 from "@hot-updater/core";
4
3
  import { ArtifactInfo, Bundle } from "@hot-updater/core";
5
- import * as _$_hot_updater_plugin_core0 from "@hot-updater/plugin-core";
6
4
  import { ChannelDeleteInput, ChannelDeleteResult, ChannelInsertInput, ChannelInsertResult, ChannelRow, DatabaseCommit, DatabaseCommitResult, DatabasePlugin, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildResult, ReleaseCatalogRow, ReleasePolicyPatch, ReleaseRow } from "@hot-updater/plugin-core";
7
-
8
5
  //#region src/db/types.d.ts
9
6
  declare const sqlProviders: readonly ["sqlite", "cockroachdb", "mysql", "postgresql", "mssql"];
10
7
  declare const providers: readonly ["sqlite", "cockroachdb", "mysql", "postgresql", "mssql", "mongodb"];
@@ -69,7 +66,7 @@ type DatabaseAdapterWithCapabilities = DatabasePlugin & DatabaseAdapterCapabilit
69
66
  type DatabasePlugin$1 = DatabaseAdapterWithCapabilities;
70
67
  interface DatabaseAPI {
71
68
  getBundleById(id: string): Promise<Bundle | null>;
72
- getReleaseCatalog(input: ReleaseCatalogRequest): Promise<_$_hot_updater_core0.ReleaseCatalog | null>;
69
+ getReleaseCatalog(input: ReleaseCatalogRequest): Promise<import("@hot-updater/core").ReleaseCatalog | null>;
73
70
  getArtifactInfo(targetBundleId: string, currentBundleId: string): Promise<ArtifactInfo | null>;
74
71
  getReleaseById(id: string): Promise<ReleaseRow | null>;
75
72
  getReleasesByScope(input: {
@@ -111,11 +108,11 @@ interface DatabaseAPI {
111
108
  getChannels(): Promise<readonly ChannelRow[]>;
112
109
  insertChannel(input: ChannelInsertInput): Promise<ChannelInsertResult>;
113
110
  deleteChannel(input: ChannelDeleteInput): Promise<ChannelDeleteResult>;
114
- getBundles(options: _$_hot_updater_plugin_core0.DatabaseBundleQueryOptions): Promise<PaginatedResult>;
111
+ getBundles(options: import("@hot-updater/plugin-core").DatabaseBundleQueryOptions): Promise<PaginatedResult>;
115
112
  insertBundle(bundle: Bundle): Promise<void>;
116
113
  insertBundles(bundles: readonly Bundle[]): Promise<void>;
117
114
  updateBundleById(bundleId: string, newBundle: Partial<Bundle>): Promise<void>;
118
115
  deleteBundleById(bundleId: string): Promise<void>;
119
116
  }
120
117
  //#endregion
121
- export { DatabaseAPI, DatabaseAdapterWithCapabilities, DatabasePlugin$1 as DatabasePlugin, Migrator, ORMProvider, ORMSQLProvider, RelationMode, SchemaGenerator };
118
+ export { DatabaseAPI, DatabaseAdapterCapabilities, DatabaseAdapterWithCapabilities, DatabasePlugin$1 as DatabasePlugin, MigrateOptions, MigrationOperation, MigrationResult, Migrator, ORMProvider, ORMSQLProvider, RelationMode, SchemaGenerator, providers, sqlProviders };
@@ -1,10 +1,7 @@
1
1
  import { ReleaseCatalogRequest } from "./releaseCatalog.mjs";
2
2
  import { PaginatedResult } from "../types/index.mjs";
3
- import * as _$_hot_updater_plugin_core0 from "@hot-updater/plugin-core";
4
3
  import { ChannelDeleteInput, ChannelDeleteResult, ChannelInsertInput, ChannelInsertResult, ChannelRow, DatabaseCommit, DatabaseCommitResult, DatabasePlugin, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildResult, ReleaseCatalogRow, ReleasePolicyPatch, ReleaseRow } from "@hot-updater/plugin-core";
5
- import * as _$_hot_updater_core0 from "@hot-updater/core";
6
4
  import { ArtifactInfo, Bundle as Bundle$1 } from "@hot-updater/core";
7
-
8
5
  //#region src/db/types.d.ts
9
6
  declare const sqlProviders: readonly ["sqlite", "cockroachdb", "mysql", "postgresql", "mssql"];
10
7
  declare const providers: readonly ["sqlite", "cockroachdb", "mysql", "postgresql", "mssql", "mongodb"];
@@ -69,7 +66,7 @@ type DatabaseAdapterWithCapabilities = DatabasePlugin & DatabaseAdapterCapabilit
69
66
  type DatabasePlugin$1 = DatabaseAdapterWithCapabilities;
70
67
  interface DatabaseAPI {
71
68
  getBundleById(id: string): Promise<Bundle$1 | null>;
72
- getReleaseCatalog(input: ReleaseCatalogRequest): Promise<_$_hot_updater_core0.ReleaseCatalog | null>;
69
+ getReleaseCatalog(input: ReleaseCatalogRequest): Promise<import("@hot-updater/core").ReleaseCatalog | null>;
73
70
  getArtifactInfo(targetBundleId: string, currentBundleId: string): Promise<ArtifactInfo | null>;
74
71
  getReleaseById(id: string): Promise<ReleaseRow | null>;
75
72
  getReleasesByScope(input: {
@@ -111,11 +108,11 @@ interface DatabaseAPI {
111
108
  getChannels(): Promise<readonly ChannelRow[]>;
112
109
  insertChannel(input: ChannelInsertInput): Promise<ChannelInsertResult>;
113
110
  deleteChannel(input: ChannelDeleteInput): Promise<ChannelDeleteResult>;
114
- getBundles(options: _$_hot_updater_plugin_core0.DatabaseBundleQueryOptions): Promise<PaginatedResult>;
111
+ getBundles(options: import("@hot-updater/plugin-core").DatabaseBundleQueryOptions): Promise<PaginatedResult>;
115
112
  insertBundle(bundle: Bundle$1): Promise<void>;
116
113
  insertBundles(bundles: readonly Bundle$1[]): Promise<void>;
117
114
  updateBundleById(bundleId: string, newBundle: Partial<Bundle$1>): Promise<void>;
118
115
  deleteBundleById(bundleId: string): Promise<void>;
119
116
  }
120
117
  //#endregion
121
- export { DatabaseAPI, DatabaseAdapterWithCapabilities, DatabasePlugin$1 as DatabasePlugin, Migrator, ORMProvider, ORMSQLProvider, RelationMode, SchemaGenerator };
118
+ export { DatabaseAPI, DatabaseAdapterCapabilities, DatabaseAdapterWithCapabilities, DatabasePlugin$1 as DatabasePlugin, MigrateOptions, MigrationOperation, MigrationResult, Migrator, ORMProvider, ORMSQLProvider, RelationMode, SchemaGenerator, providers, sqlProviders };
package/dist/db/types.mjs CHANGED
@@ -9,11 +9,11 @@ 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" && "analytics" in plugin.models && typeof plugin.models.analytics === "object" && plugin.models.analytics !== null && "append" in plugin.models.analytics && typeof plugin.models.analytics.append === "function" && "scan" in plugin.models.analytics && typeof plugin.models.analytics.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");
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 && "recordEvent" in plugin.models.insights && typeof plugin.models.insights.recordEvent === "function" && "listEvents" in plugin.models.insights && typeof plugin.models.insights.listEvents === "function" && "findLatestEvents" in plugin.models.insights && typeof plugin.models.insights.findLatestEvents === "function" && "countEvents" in plugin.models.insights && typeof plugin.models.insights.countEvents === "function" && "countLatestEvents" in plugin.models.insights && typeof plugin.models.insights.countLatestEvents === "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;
16
16
  return sqlProviders.includes(provider) ? provider : void 0;
17
17
  }
18
18
  //#endregion
19
- export { getSQLProvider, isDatabasePlugin };
19
+ export { getSQLProvider, isDatabasePlugin, noSqlProviders, sqlProviders };
@@ -1,4 +1,3 @@
1
- require("../_virtual/_rolldown/runtime.cjs");
2
1
  let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
3
2
  let _hot_updater_core = require("@hot-updater/core");
4
3
  //#region src/db/updateArtifacts.ts
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, analytics, apiKeyAuth, downloadStorageObject) {
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
- ...analytics === void 0 ? {} : require_routes.createAnalyticsRouteHandlers(analytics),
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 (analytics !== void 0) require_routes.registerAnalyticsClientRoutes(addClientRoute);
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 (analytics !== void 0) require_routes.registerAnalyticsAdminRoutes(addAdminRoute);
102
+ if (insights !== void 0) require_routes.registerInsightsAdminRoutes(addAdminRoute);
103
103
  return Object.freeze({
104
104
  client: createRequestHandler({
105
105
  api,
@@ -1,6 +1,5 @@
1
1
  import { HandlerAPI, HotUpdaterHandler, HotUpdaterHandlers } from "./handlerTypes.cjs";
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 };