@hot-updater/server 1.0.0-rc.0 → 1.0.0-rc.2

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 (210) 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 +0 -1
  4. package/dist/adapters/drizzle.cjs +11 -4
  5. package/dist/adapters/drizzle.d.cts +0 -1
  6. package/dist/adapters/drizzle.d.mts +0 -1
  7. package/dist/adapters/drizzle.mjs +12 -4
  8. package/dist/adapters/drizzleCrud.cjs +62 -1
  9. package/dist/adapters/drizzleCrud.mjs +61 -2
  10. package/dist/adapters/drizzleLazyDB.cjs +6 -1
  11. package/dist/adapters/drizzleLazyDB.mjs +6 -1
  12. package/dist/adapters/drizzleQuery.cjs +3 -2
  13. package/dist/adapters/drizzleQuery.mjs +3 -1
  14. package/dist/adapters/insightsTransaction.cjs +22 -0
  15. package/dist/adapters/insightsTransaction.mjs +22 -0
  16. package/dist/adapters/kysely.cjs +2 -1
  17. package/dist/adapters/kysely.d.cts +0 -1
  18. package/dist/adapters/kysely.d.mts +0 -1
  19. package/dist/adapters/kysely.mjs +3 -1
  20. package/dist/adapters/kyselyCrud.cjs +54 -3
  21. package/dist/adapters/kyselyCrud.mjs +54 -3
  22. package/dist/adapters/kyselyQuery.cjs +2 -2
  23. package/dist/adapters/kyselyQuery.mjs +2 -1
  24. package/dist/adapters/mongodb.cjs +27 -1
  25. package/dist/adapters/mongodb.d.cts +1 -1
  26. package/dist/adapters/mongodb.d.mts +1 -1
  27. package/dist/adapters/mongodb.mjs +28 -1
  28. package/dist/adapters/mongodbCollections.cjs +2 -0
  29. package/dist/adapters/mongodbCollections.mjs +2 -0
  30. package/dist/adapters/mongodbQuery.cjs +21 -4
  31. package/dist/adapters/mongodbQuery.mjs +21 -5
  32. package/dist/adapters/mongodbReads.cjs +91 -29
  33. package/dist/adapters/mongodbReads.mjs +92 -29
  34. package/dist/adapters/mongodbWrites.cjs +16 -2
  35. package/dist/adapters/mongodbWrites.mjs +18 -3
  36. package/dist/adapters/prisma.cjs +55 -7
  37. package/dist/adapters/prisma.d.cts +0 -1
  38. package/dist/adapters/prisma.d.mts +0 -1
  39. package/dist/adapters/prisma.mjs +56 -7
  40. package/dist/adapters/prismaQuery.cjs +0 -1
  41. package/dist/adapters/prismaRows.cjs +22 -1
  42. package/dist/adapters/prismaRows.mjs +22 -1
  43. package/dist/apiKeys.cjs +6 -2
  44. package/dist/apiKeys.d.cts +0 -1
  45. package/dist/apiKeys.d.mts +0 -1
  46. package/dist/apiKeys.mjs +3 -3
  47. package/dist/createHotUpdaterCore.cjs +27 -12
  48. package/dist/createHotUpdaterCore.d.cts +8 -8
  49. package/dist/createHotUpdaterCore.d.mts +8 -8
  50. package/dist/createHotUpdaterCore.mjs +26 -12
  51. package/dist/db/createBundleDiff.cjs +2 -2
  52. package/dist/db/createBundleDiff.d.cts +1 -5
  53. package/dist/db/createBundleDiff.d.mts +1 -5
  54. package/dist/db/databasePluginCore.cjs +0 -1
  55. package/dist/db/fixedMigrator.cjs +2 -2
  56. package/dist/db/fixedMigrator.mjs +2 -2
  57. package/dist/db/fixedMigratorMongo.cjs +6 -4
  58. package/dist/db/fixedMigratorMongo.mjs +6 -4
  59. package/dist/db/index.d.cts +0 -1
  60. package/dist/db/index.d.mts +0 -1
  61. package/dist/db/releaseCatalog.cjs +0 -1
  62. package/dist/db/releaseCatalog.d.cts +0 -1
  63. package/dist/db/releaseCatalog.d.mts +0 -1
  64. package/dist/db/schema/insightsCollation.cjs +14 -0
  65. package/dist/db/schema/insightsCollation.mjs +14 -0
  66. package/dist/db/schema/sql.cjs +11 -7
  67. package/dist/db/schema/sql.mjs +8 -8
  68. package/dist/db/schemaGenerators.cjs +28 -9
  69. package/dist/db/schemaGenerators.mjs +28 -9
  70. package/dist/db/schemaReadiness.cjs +2 -0
  71. package/dist/db/schemaReadiness.d.cts +1 -0
  72. package/dist/db/schemaReadiness.d.mts +1 -0
  73. package/dist/db/schemaReadiness.mjs +2 -0
  74. package/dist/db/sqlMigrationExecution.cjs +1 -1
  75. package/dist/db/sqlMigrationExecution.mjs +1 -0
  76. package/dist/db/types.cjs +3 -1
  77. package/dist/db/types.d.cts +3 -6
  78. package/dist/db/types.d.mts +3 -6
  79. package/dist/db/types.mjs +2 -2
  80. package/dist/db/updateArtifacts.cjs +0 -1
  81. package/dist/handler.cjs +5 -5
  82. package/dist/handler.d.cts +1 -2
  83. package/dist/handler.d.mts +1 -2
  84. package/dist/handler.mjs +5 -5
  85. package/dist/handlerReleaseCatalogRoutes.cjs +0 -1
  86. package/dist/handlerReleaseManagementRoutes.cjs +0 -1
  87. package/dist/handlerTypes.d.cts +0 -1
  88. package/dist/handlerTypes.d.mts +0 -1
  89. package/dist/handlerVersionRoutes.d.cts +1 -0
  90. package/dist/handlerVersionRoutes.d.mts +1 -0
  91. package/dist/index.cjs +2 -2
  92. package/dist/index.d.cts +4 -4
  93. package/dist/index.d.mts +4 -4
  94. package/dist/index.mjs +2 -2
  95. package/dist/insights/domain.d.cts +89 -0
  96. package/dist/insights/domain.d.mts +89 -0
  97. package/dist/insights/errors.cjs +15 -0
  98. package/dist/insights/errors.mjs +14 -0
  99. package/dist/{analytics → insights}/eventInput.cjs +58 -14
  100. package/dist/{analytics → insights}/eventInput.mjs +58 -16
  101. package/dist/insights/provider.cjs +314 -0
  102. package/dist/insights/provider.d.cts +6 -0
  103. package/dist/insights/provider.d.mts +6 -0
  104. package/dist/insights/provider.mjs +314 -0
  105. package/dist/insights/queryInput.cjs +93 -0
  106. package/dist/insights/queryInput.mjs +91 -0
  107. package/dist/insights/routes.cjs +58 -0
  108. package/dist/insights/routes.mjs +56 -0
  109. package/dist/insights/types.d.cts +32 -0
  110. package/dist/insights/types.d.mts +32 -0
  111. package/dist/node.d.cts +0 -1
  112. package/dist/node.d.mts +0 -1
  113. package/dist/package.cjs +1 -1
  114. package/dist/package.mjs +1 -1
  115. package/dist/schema/index.cjs +17 -3
  116. package/dist/schema/index.mjs +4 -4
  117. package/dist/schema/v1_0_0.cjs +72 -30
  118. package/dist/schema/v1_0_0.mjs +72 -31
  119. package/dist/storageAccess.cjs +0 -1
  120. package/dist/types/index.d.cts +0 -1
  121. package/dist/types/index.d.mts +0 -1
  122. package/package.json +7 -7
  123. package/src/adapters/databasePluginTestDatabase.ts +14 -0
  124. package/src/adapters/drizzle.spec.ts +99 -0
  125. package/src/adapters/drizzle.ts +22 -4
  126. package/src/adapters/drizzleCrud.ts +154 -2
  127. package/src/adapters/drizzleLazyDB.ts +17 -3
  128. package/src/adapters/insightsTransaction.ts +32 -0
  129. package/src/adapters/kysely.spec.ts +29 -0
  130. package/src/adapters/kysely.ts +10 -1
  131. package/src/adapters/kyselyCrud.ts +121 -0
  132. package/src/adapters/mongodb.integration.spec.ts +210 -0
  133. package/src/adapters/mongodb.spec.ts +69 -1
  134. package/src/adapters/mongodb.ts +66 -2
  135. package/src/adapters/mongodbCollections.ts +5 -0
  136. package/src/adapters/mongodbQuery.ts +32 -3
  137. package/src/adapters/mongodbReads.ts +69 -0
  138. package/src/adapters/mongodbTestClient.ts +41 -6
  139. package/src/adapters/mongodbTestFilter.ts +4 -1
  140. package/src/adapters/mongodbWrites.ts +27 -0
  141. package/src/adapters/prisma.spec.ts +97 -0
  142. package/src/adapters/prisma.ts +103 -3
  143. package/src/adapters/prismaRows.ts +37 -1
  144. package/src/adapters/prismaTestClient.ts +22 -5
  145. package/src/apiKeys.integration.spec.ts +3 -3
  146. package/src/createHotUpdaterCore.ts +30 -16
  147. package/src/db/databasePluginUpdateCheck.bench.ts +3 -0
  148. package/src/db/fixedMigrator.spec.ts +65 -0
  149. package/src/db/fixedMigratorMongo.spec.ts +56 -9
  150. package/src/db/fixedMigratorMongo.ts +10 -10
  151. package/src/db/index.spec.ts +8 -1
  152. package/src/db/schema/insightsCollation.ts +21 -0
  153. package/src/db/schema/sql.ts +8 -5
  154. package/src/db/schemaGenerators.ts +41 -13
  155. package/src/db/types.spec.ts +11 -3
  156. package/src/db/types.ts +13 -7
  157. package/src/handler-standalone.integration.spec.ts +6 -8
  158. package/src/handler.ts +12 -12
  159. package/src/index.ts +3 -3
  160. package/src/insights/domain.ts +103 -0
  161. package/src/insights/errors.ts +11 -0
  162. package/src/{analytics → insights}/eventInput.ts +71 -14
  163. package/src/insights/insights.integration.spec.ts +381 -0
  164. package/src/insights/provider.spec.ts +385 -0
  165. package/src/insights/provider.ts +591 -0
  166. package/src/insights/queryInput.ts +141 -0
  167. package/src/insights/routes.ts +104 -0
  168. package/src/insights/types.ts +55 -0
  169. package/src/schema/dsl-all-versions.spec.ts +3 -1
  170. package/src/schema/v1_0_0.spec.ts +77 -3
  171. package/src/schema/v1_0_0.ts +94 -30
  172. package/dist/analytics/bounded/activeOverview.cjs +0 -87
  173. package/dist/analytics/bounded/activeOverview.mjs +0 -85
  174. package/dist/analytics/bounded/installationSearch.cjs +0 -42
  175. package/dist/analytics/bounded/installationSearch.mjs +0 -42
  176. package/dist/analytics/bounded/persistence.cjs +0 -39
  177. package/dist/analytics/bounded/persistence.mjs +0 -38
  178. package/dist/analytics/bounded/provider.cjs +0 -170
  179. package/dist/analytics/bounded/provider.d.cts +0 -7
  180. package/dist/analytics/bounded/provider.d.mts +0 -7
  181. package/dist/analytics/bounded/provider.mjs +0 -170
  182. package/dist/analytics/bounded/scan.cjs +0 -144
  183. package/dist/analytics/bounded/scan.mjs +0 -138
  184. package/dist/analytics/domain.d.cts +0 -121
  185. package/dist/analytics/domain.d.mts +0 -121
  186. package/dist/analytics/errors.cjs +0 -22
  187. package/dist/analytics/errors.mjs +0 -20
  188. package/dist/analytics/persistence.d.cts +0 -6
  189. package/dist/analytics/persistence.d.mts +0 -6
  190. package/dist/analytics/queryInput.cjs +0 -58
  191. package/dist/analytics/queryInput.mjs +0 -55
  192. package/dist/analytics/routes.cjs +0 -63
  193. package/dist/analytics/routes.mjs +0 -61
  194. package/dist/analytics/types.d.cts +0 -17
  195. package/dist/analytics/types.d.mts +0 -17
  196. package/src/analytics/analytics.integration.spec.ts +0 -144
  197. package/src/analytics/bounded/activeOverview.spec.ts +0 -189
  198. package/src/analytics/bounded/activeOverview.ts +0 -148
  199. package/src/analytics/bounded/installationSearch.spec.ts +0 -130
  200. package/src/analytics/bounded/installationSearch.ts +0 -69
  201. package/src/analytics/bounded/persistence.ts +0 -43
  202. package/src/analytics/bounded/provider.spec.ts +0 -219
  203. package/src/analytics/bounded/provider.ts +0 -229
  204. package/src/analytics/bounded/scan.ts +0 -235
  205. package/src/analytics/domain.ts +0 -139
  206. package/src/analytics/errors.ts +0 -18
  207. package/src/analytics/persistence.ts +0 -10
  208. package/src/analytics/queryInput.ts +0 -102
  209. package/src/analytics/routes.ts +0 -123
  210. package/src/analytics/types.ts +0 -44
@@ -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_installations";
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_installations";
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.bundleInstallationsV100].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 { bundleEventsV100, bundleInstallationsV100 } 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, bundleInstallationsV100].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,6 +1,8 @@
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));
@@ -55,17 +57,34 @@ const prismaRelationFields = (table, schema) => {
55
57
  return lines;
56
58
  };
57
59
  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");
60
+ const generatePrismaSchema = (provider, schema = require_registry.hotUpdaterSchema) => {
61
+ const sqlProvider = require_types$1.getSQLProvider(provider);
62
+ const collationSql = sqlProvider ? require_insightsCollation.getInsightsCollationSql(sqlProvider) : [];
63
+ return (collationSql.length === 0 ? "" : [
64
+ "// Apply these statements in the initial Prisma SQL migration to preserve exact Insights identities and cursors:",
65
+ ...collationSql.map((statement) => `// ${statement};`),
66
+ ""
67
+ ].join("\n")) + schema.tables.map((table) => {
68
+ const lines = [
69
+ ...table.columns.map((column) => prismaField(column, provider)),
70
+ ...prismaRelationFields(table, schema),
71
+ ...prismaIndexes(table, provider)
72
+ ];
73
+ return `model ${table.ormName} {\n${lines.map((line) => ` ${line}`).join("\n")}\n}`;
74
+ }).join("\n\n");
75
+ };
66
76
  const drizzleImportSource = (provider) => provider === "sqlite" ? "drizzle-orm/sqlite-core" : provider === "mysql" ? "drizzle-orm/mysql-core" : "drizzle-orm/pg-core";
67
77
  const drizzleTableFn = (provider) => provider === "sqlite" ? "sqliteTable" : provider === "mysql" ? "mysqlTable" : "pgTable";
68
78
  const drizzleColumnFn = (column, provider) => {
79
+ const collation = column.providerCollations?.[provider];
80
+ if (collation !== void 0) {
81
+ const charset = provider === "mysql" ? ` character set ${collation === "ascii_bin" ? "ascii" : "utf8mb4"}` : "";
82
+ const dataType = `${require_sql.getSqlType(column.type, provider)}${charset} collate ${collation}`;
83
+ return {
84
+ code: `customType<{ data: string }>({ dataType: () => ${literal(dataType)} })(${literal(column.ormName)})`,
85
+ imports: ["customType"]
86
+ };
87
+ }
69
88
  if (provider === "sqlite") {
70
89
  if (column.type === "bool") return {
71
90
  code: `integer(${literal(column.ormName)}, { mode: "boolean" })`,
@@ -227,7 +246,7 @@ ${lines.join(",\n")}
227
246
  }))`;
228
247
  };
229
248
  const generateDrizzleSchema = (provider, schema = require_registry.hotUpdaterSchema) => {
230
- const imports = new Set([drizzleTableFn(provider)]);
249
+ const imports = /* @__PURE__ */ new Set([drizzleTableFn(provider)]);
231
250
  const body = [];
232
251
  for (const table of schema.tables) {
233
252
  body.push(drizzleTable(table, provider, imports));
@@ -1,6 +1,8 @@
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));
@@ -55,17 +57,34 @@ const prismaRelationFields = (table, schema) => {
55
57
  return lines;
56
58
  };
57
59
  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");
60
+ const generatePrismaSchema = (provider, schema = hotUpdaterSchema) => {
61
+ const sqlProvider = getSQLProvider(provider);
62
+ const collationSql = sqlProvider ? getInsightsCollationSql(sqlProvider) : [];
63
+ return (collationSql.length === 0 ? "" : [
64
+ "// Apply these statements in the initial Prisma SQL migration to preserve exact Insights identities and cursors:",
65
+ ...collationSql.map((statement) => `// ${statement};`),
66
+ ""
67
+ ].join("\n")) + schema.tables.map((table) => {
68
+ const lines = [
69
+ ...table.columns.map((column) => prismaField(column, provider)),
70
+ ...prismaRelationFields(table, schema),
71
+ ...prismaIndexes(table, provider)
72
+ ];
73
+ return `model ${table.ormName} {\n${lines.map((line) => ` ${line}`).join("\n")}\n}`;
74
+ }).join("\n\n");
75
+ };
66
76
  const drizzleImportSource = (provider) => provider === "sqlite" ? "drizzle-orm/sqlite-core" : provider === "mysql" ? "drizzle-orm/mysql-core" : "drizzle-orm/pg-core";
67
77
  const drizzleTableFn = (provider) => provider === "sqlite" ? "sqliteTable" : provider === "mysql" ? "mysqlTable" : "pgTable";
68
78
  const drizzleColumnFn = (column, provider) => {
79
+ const collation = column.providerCollations?.[provider];
80
+ if (collation !== void 0) {
81
+ const charset = provider === "mysql" ? ` character set ${collation === "ascii_bin" ? "ascii" : "utf8mb4"}` : "";
82
+ const dataType = `${getSqlType(column.type, provider)}${charset} collate ${collation}`;
83
+ return {
84
+ code: `customType<{ data: string }>({ dataType: () => ${literal(dataType)} })(${literal(column.ormName)})`,
85
+ imports: ["customType"]
86
+ };
87
+ }
69
88
  if (provider === "sqlite") {
70
89
  if (column.type === "bool") return {
71
90
  code: `integer(${literal(column.ormName)}, { mode: "boolean" })`,
@@ -227,7 +246,7 @@ ${lines.join(",\n")}
227
246
  }))`;
228
247
  };
229
248
  const generateDrizzleSchema = (provider, schema = hotUpdaterSchema) => {
230
- const imports = new Set([drizzleTableFn(provider)]);
249
+ const imports = /* @__PURE__ */ new Set([drizzleTableFn(provider)]);
231
250
  const body = [];
232
251
  for (const table of schema.tables) {
233
252
  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 && "record" in plugin.models.insights && typeof plugin.models.insights.record === "function" && "listEvents" in plugin.models.insights && typeof plugin.models.insights.listEvents === "function" && "findInstallations" in plugin.models.insights && typeof plugin.models.insights.findInstallations === "function" && "countEvents" in plugin.models.insights && typeof plugin.models.insights.countEvents === "function" && "countInstallations" in plugin.models.insights && typeof plugin.models.insights.countInstallations === "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 && "record" in plugin.models.insights && typeof plugin.models.insights.record === "function" && "listEvents" in plugin.models.insights && typeof plugin.models.insights.listEvents === "function" && "findInstallations" in plugin.models.insights && typeof plugin.models.insights.findInstallations === "function" && "countEvents" in plugin.models.insights && typeof plugin.models.insights.countEvents === "function" && "countInstallations" in plugin.models.insights && typeof plugin.models.insights.countInstallations === "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 };
@@ -1,6 +1,5 @@
1
1
  import { HandlerAPI, HotUpdaterHandler, HotUpdaterHandlers } from "./handlerTypes.mjs";
2
-
3
2
  //#region src/handler.d.ts
4
3
  declare function createHandlers(api: HandlerAPI): HotUpdaterHandlers;
5
4
  //#endregion
6
- export { createHandlers };
5
+ export { type HandlerAPI, type HotUpdaterHandler, type HotUpdaterHandlers, createHandlers };
package/dist/handler.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import { createAnalyticsRouteHandlers, registerAnalyticsAdminRoutes, registerAnalyticsClientRoutes } from "./analytics/routes.mjs";
2
1
  import { HandlerBadRequestError } from "./handlerErrors.mjs";
3
2
  import { createBundleRouteHandlers } from "./handlerBundleRoutes.mjs";
4
3
  import { createReleaseCatalogRouteHandlers } from "./handlerReleaseCatalogRoutes.mjs";
5
4
  import { createReleaseManagementRouteHandlers } from "./handlerReleaseManagementRoutes.mjs";
6
5
  import { createVersionRouteHandlers } from "./handlerVersionRoutes.mjs";
6
+ import { createInsightsRouteHandlers, registerInsightsAdminRoutes, registerInsightsClientRoutes } from "./insights/routes.mjs";
7
7
  import { addRoute, createRouter, findRoute } from "./internalRouter.mjs";
8
8
  //#region src/handler.ts
9
9
  const withPrivateNoStore = (response) => {
@@ -63,13 +63,13 @@ const createDownloadStorageRouteHandler = (downloadStorageObject) => async (para
63
63
  function createHandlers(api) {
64
64
  return createHotUpdaterHandlers(api);
65
65
  }
66
- function createHotUpdaterHandlers(api, analytics, apiKeyAuth, downloadStorageObject) {
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
- ...analytics === void 0 ? {} : createAnalyticsRouteHandlers(analytics),
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 (analytics !== void 0) registerAnalyticsClientRoutes(addClientRoute);
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 (analytics !== void 0) registerAnalyticsAdminRoutes(addAdminRoute);
102
+ if (insights !== void 0) registerInsightsAdminRoutes(addAdminRoute);
103
103
  return Object.freeze({
104
104
  client: createRequestHandler({
105
105
  api,