@hot-updater/server 1.0.0-rc.1 → 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 (194) 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 +8 -3
  6. package/dist/adapters/drizzle.d.cts +0 -1
  7. package/dist/adapters/drizzle.d.mts +0 -1
  8. package/dist/adapters/drizzle.mjs +9 -3
  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 +24 -9
  49. package/dist/createHotUpdaterCore.d.cts +1 -1
  50. package/dist/createHotUpdaterCore.d.mts +1 -1
  51. package/dist/createHotUpdaterCore.mjs +23 -9
  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.d.cts +1 -2
  83. package/dist/handler.d.mts +1 -2
  84. package/dist/handlerReleaseCatalogRoutes.cjs +0 -1
  85. package/dist/handlerReleaseManagementRoutes.cjs +0 -1
  86. package/dist/handlerTypes.d.cts +0 -1
  87. package/dist/handlerTypes.d.mts +0 -1
  88. package/dist/handlerVersionRoutes.d.cts +1 -0
  89. package/dist/handlerVersionRoutes.d.mts +1 -0
  90. package/dist/index.cjs +1 -1
  91. package/dist/index.d.cts +4 -4
  92. package/dist/index.d.mts +4 -4
  93. package/dist/index.mjs +1 -1
  94. package/dist/insights/domain.d.cts +41 -70
  95. package/dist/insights/domain.d.mts +41 -70
  96. package/dist/insights/errors.cjs +1 -8
  97. package/dist/insights/errors.mjs +2 -8
  98. package/dist/insights/eventInput.cjs +52 -7
  99. package/dist/insights/eventInput.mjs +51 -8
  100. package/dist/insights/provider.cjs +332 -0
  101. package/dist/insights/provider.d.cts +6 -0
  102. package/dist/insights/provider.d.mts +6 -0
  103. package/dist/insights/provider.mjs +332 -0
  104. package/dist/insights/queryInput.cjs +78 -43
  105. package/dist/insights/queryInput.mjs +76 -40
  106. package/dist/insights/routes.cjs +20 -25
  107. package/dist/insights/routes.mjs +22 -27
  108. package/dist/insights/types.d.cts +27 -12
  109. package/dist/insights/types.d.mts +27 -12
  110. package/dist/node.d.cts +0 -1
  111. package/dist/node.d.mts +0 -1
  112. package/dist/package.cjs +1 -1
  113. package/dist/package.mjs +1 -1
  114. package/dist/schema/index.cjs +17 -3
  115. package/dist/schema/index.mjs +4 -4
  116. package/dist/schema/v1_0_0.cjs +64 -35
  117. package/dist/schema/v1_0_0.mjs +64 -36
  118. package/dist/storageAccess.cjs +0 -1
  119. package/dist/types/index.d.cts +0 -1
  120. package/dist/types/index.d.mts +0 -1
  121. package/package.json +7 -7
  122. package/src/adapters/databasePluginTestDatabase.ts +15 -5
  123. package/src/adapters/databasePluginUtils.ts +24 -0
  124. package/src/adapters/drizzle.spec.ts +203 -5
  125. package/src/adapters/drizzle.ts +15 -3
  126. package/src/adapters/drizzleCrud.ts +200 -9
  127. package/src/adapters/drizzleLazyDB.ts +33 -6
  128. package/src/adapters/kysely.spec.ts +62 -0
  129. package/src/adapters/kysely.ts +7 -1
  130. package/src/adapters/kyselyCrud.ts +115 -7
  131. package/src/adapters/kyselyInsights.spec.ts +168 -0
  132. package/src/adapters/mongodb.integration.spec.ts +483 -0
  133. package/src/adapters/mongodb.spec.ts +89 -0
  134. package/src/adapters/mongodb.ts +59 -1
  135. package/src/adapters/mongodbCollections.ts +16 -0
  136. package/src/adapters/mongodbQuery.ts +22 -3
  137. package/src/adapters/mongodbReads.ts +78 -2
  138. package/src/adapters/mongodbTestClient.ts +107 -6
  139. package/src/adapters/mongodbTestFilter.ts +5 -1
  140. package/src/adapters/mongodbWrites.ts +1 -0
  141. package/src/adapters/prisma.spec.ts +270 -0
  142. package/src/adapters/prisma.ts +75 -2
  143. package/src/adapters/prismaInsights.ts +190 -0
  144. package/src/adapters/prismaRows.ts +17 -10
  145. package/src/adapters/prismaTestClient.ts +89 -7
  146. package/src/apiKeys.integration.spec.ts +1 -1
  147. package/src/createHotUpdaterCore.ts +21 -7
  148. package/src/db/databasePluginUpdateCheck.bench.ts +10 -0
  149. package/src/db/fixedMigrator.spec.ts +63 -0
  150. package/src/db/fixedMigratorMongo.spec.ts +70 -9
  151. package/src/db/fixedMigratorMongo.ts +10 -10
  152. package/src/db/index.spec.ts +6 -1
  153. package/src/db/schema/insightsCollation.ts +21 -0
  154. package/src/db/schema/sql.ts +8 -5
  155. package/src/db/schemaGenerators.ts +42 -13
  156. package/src/db/types.spec.ts +8 -0
  157. package/src/db/types.ts +10 -4
  158. package/src/handler-standalone.integration.spec.ts +5 -7
  159. package/src/index.ts +2 -2
  160. package/src/insights/domain.ts +44 -77
  161. package/src/insights/errors.ts +0 -7
  162. package/src/insights/eventInput.ts +55 -5
  163. package/src/insights/insights.integration.spec.ts +348 -17
  164. package/src/insights/provider.spec.ts +396 -0
  165. package/src/insights/provider.ts +611 -0
  166. package/src/insights/queryInput.ts +113 -73
  167. package/src/insights/routes.ts +37 -56
  168. package/src/insights/types.ts +47 -36
  169. package/src/schema/dsl-all-versions.spec.ts +1 -1
  170. package/src/schema/v1_0_0.spec.ts +77 -3
  171. package/src/schema/v1_0_0.ts +83 -37
  172. package/dist/insights/bounded/activeOverview.cjs +0 -87
  173. package/dist/insights/bounded/activeOverview.mjs +0 -85
  174. package/dist/insights/bounded/installationSearch.cjs +0 -42
  175. package/dist/insights/bounded/installationSearch.mjs +0 -42
  176. package/dist/insights/bounded/persistence.cjs +0 -39
  177. package/dist/insights/bounded/persistence.mjs +0 -38
  178. package/dist/insights/bounded/provider.cjs +0 -170
  179. package/dist/insights/bounded/provider.d.cts +0 -7
  180. package/dist/insights/bounded/provider.d.mts +0 -7
  181. package/dist/insights/bounded/provider.mjs +0 -170
  182. package/dist/insights/bounded/scan.cjs +0 -144
  183. package/dist/insights/bounded/scan.mjs +0 -138
  184. package/dist/insights/persistence.d.cts +0 -6
  185. package/dist/insights/persistence.d.mts +0 -6
  186. package/src/insights/bounded/activeOverview.spec.ts +0 -189
  187. package/src/insights/bounded/activeOverview.ts +0 -148
  188. package/src/insights/bounded/installationSearch.spec.ts +0 -130
  189. package/src/insights/bounded/installationSearch.ts +0 -69
  190. package/src/insights/bounded/persistence.ts +0 -43
  191. package/src/insights/bounded/provider.spec.ts +0 -219
  192. package/src/insights/bounded/provider.ts +0 -229
  193. package/src/insights/bounded/scan.ts +0 -235
  194. package/src/insights/persistence.ts +0 -10
@@ -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" && "insights" in plugin.models && typeof plugin.models.insights === "object" && plugin.models.insights !== null && "append" in plugin.models.insights && typeof plugin.models.insights.append === "function" && "scan" in plugin.models.insights && typeof plugin.models.insights.scan === "function" && "apiKeys" in plugin.models && typeof plugin.models.apiKeys === "object" && plugin.models.apiKeys !== null && "create" in plugin.models.apiKeys && typeof plugin.models.apiKeys.create === "function" && "findByHash" in plugin.models.apiKeys && typeof plugin.models.apiKeys.findByHash === "function" && "list" in plugin.models.apiKeys && typeof plugin.models.apiKeys.list === "function" && "revoke" in plugin.models.apiKeys && typeof plugin.models.apiKeys.revoke === "function" && "commit" in plugin && typeof plugin.commit === "function" && (!("dispose" in plugin) || plugin.dispose === void 0 || typeof plugin.dispose === "function");
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" && "insights" in plugin.models && typeof plugin.models.insights === "object" && plugin.models.insights !== null && "append" in plugin.models.insights && typeof plugin.models.insights.append === "function" && "scan" in plugin.models.insights && typeof plugin.models.insights.scan === "function" && "apiKeys" in plugin.models && typeof plugin.models.apiKeys === "object" && plugin.models.apiKeys !== null && "create" in plugin.models.apiKeys && typeof plugin.models.apiKeys.create === "function" && "findByHash" in plugin.models.apiKeys && typeof plugin.models.apiKeys.findByHash === "function" && "list" in plugin.models.apiKeys && typeof plugin.models.apiKeys.list === "function" && "revoke" in plugin.models.apiKeys && typeof plugin.models.apiKeys.revoke === "function" && "commit" in plugin && typeof plugin.commit === "function" && (!("dispose" in plugin) || plugin.dispose === void 0 || typeof plugin.dispose === "function");
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
@@ -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 };
@@ -1,4 +1,3 @@
1
- require("./_virtual/_rolldown/runtime.cjs");
2
1
  const require_handlerParameters = require("./handlerParameters.cjs");
3
2
  let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
4
3
  //#region src/handlerReleaseCatalogRoutes.ts
@@ -1,4 +1,3 @@
1
- require("./_virtual/_rolldown/runtime.cjs");
2
1
  const require_handlerErrors = require("./handlerErrors.cjs");
3
2
  const require_handlerParameters = require("./handlerParameters.cjs");
4
3
  let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
@@ -2,7 +2,6 @@ import { ReleaseCatalogRequest } from "./db/releaseCatalog.cjs";
2
2
  import { PaginatedResult } from "./types/index.cjs";
3
3
  import { ArtifactInfo, Bundle, ReleaseCatalog } from "@hot-updater/core";
4
4
  import { ChannelDeleteInput, ChannelDeleteResult, ChannelInsertInput, ChannelInsertResult, ChannelRow, DatabaseBundleQueryOptions, DatabaseCommit, DatabaseCommitResult, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildResult, ReleaseCatalogRow, ReleasePolicyPatch, ReleaseRow } from "@hot-updater/plugin-core";
5
-
6
5
  //#region src/handlerTypes.d.ts
7
6
  interface HandlerAPI {
8
7
  getReleaseCatalog?: (input: ReleaseCatalogRequest) => Promise<ReleaseCatalog | null>;
@@ -2,7 +2,6 @@ import { ReleaseCatalogRequest } from "./db/releaseCatalog.mjs";
2
2
  import { PaginatedResult } from "./types/index.mjs";
3
3
  import { ChannelDeleteInput, ChannelDeleteResult, ChannelInsertInput, ChannelInsertResult, ChannelRow, DatabaseBundleQueryOptions, DatabaseCommit, DatabaseCommitResult, ReleaseCatalogMutationPreflight, ReleaseCatalogMutationResult, ReleaseCatalogRebuildResult, ReleaseCatalogRow, ReleasePolicyPatch, ReleaseRow } from "@hot-updater/plugin-core";
4
4
  import { ArtifactInfo, Bundle as Bundle$1, ReleaseCatalog } from "@hot-updater/core";
5
-
6
5
  //#region src/handlerTypes.d.ts
7
6
  interface HandlerAPI {
8
7
  getReleaseCatalog?: (input: ReleaseCatalogRequest) => Promise<ReleaseCatalog | null>;
@@ -1,3 +1,4 @@
1
+ import "./handlerTypes.cjs";
1
2
  //#region src/handlerVersionRoutes.d.ts
2
3
  declare const HOT_UPDATER_INFRASTRUCTURE_GENERATION = 1;
3
4
  //#endregion
@@ -1,3 +1,4 @@
1
+ import "./handlerTypes.mjs";
1
2
  //#region src/handlerVersionRoutes.d.ts
2
3
  declare const HOT_UPDATER_INFRASTRUCTURE_GENERATION = 1;
3
4
  //#endregion
package/dist/index.cjs CHANGED
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_version = require("./version.cjs");
3
3
  const require_handlerVersionRoutes = require("./handlerVersionRoutes.cjs");
4
4
  const require_handler = require("./handler.cjs");
5
- const require_provider = require("./insights/bounded/provider.cjs");
5
+ const require_provider = require("./insights/provider.cjs");
6
6
  const require_apiKeys = require("./apiKeys.cjs");
7
7
  const require_createHotUpdaterCore = require("./createHotUpdaterCore.cjs");
8
8
  exports.API_KEY_HEADER_NAME = require_apiKeys.API_KEY_HEADER_NAME;
package/dist/index.d.cts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { API_KEY_HEADER_NAME, ApiKeyManagementAPI, ApiKeyMetadata, CreatedApiKey, createApiKey, provisionApiKey, registerApiKey } from "./apiKeys.cjs";
2
2
  import { HandlerAPI, HotUpdaterHandler, HotUpdaterHandlers } from "./handlerTypes.cjs";
3
- import { ActiveInstallationInput, ActiveInstallationOverview, ActiveInstallationWindow, BundleEventInsightsResult, BundleEventInsightsWindow, BundleEventOverview, BundleEventSummary, BundleEventSummaryByBundle, CreateBundleEventRequest, CreateBundleEventRequestBase, InsightsCohortPoint, InsightsSeriesPoint, InstallationHistoryRow, InstallationSearchRow, OffsetPaginationResult } from "./insights/domain.cjs";
4
- import { InsightsProvider } from "./insights/types.cjs";
3
+ import { ActiveInstallationWindow, CreateBundleEventRequest, CreateBundleEventRequestBase, CursorPage, EventCursorPage, EventHistoryRow, InsightsBundleSelection, InsightsCountMeasurement, InsightsScope, InstallationHistoryRow, InstallationRow, ReportingOverview } from "./insights/domain.cjs";
4
+ import { InsightsEventPageInput, InsightsInstallationEventPageInput, InsightsProvider, InsightsUserInstallationPageInput } from "./insights/types.cjs";
5
5
  import { createHandlers } from "./handler.cjs";
6
6
  import { ClientAccessPolicy, CreateHotUpdaterOptions, HotUpdaterAPI, RuntimeHotUpdaterAPI, createHotUpdater } from "./createHotUpdaterCore.cjs";
7
7
  import { Bundle, ChannelsResponse, DataResponse, Paginated, PaginatedResult, PaginationInfo, PaginationOptions } from "./types/index.cjs";
8
8
  import { HOT_UPDATER_SERVER_VERSION } from "./version.cjs";
9
- import { createInsightsProvider } from "./insights/bounded/provider.cjs";
9
+ import { createInsightsProvider } from "./insights/provider.cjs";
10
10
  import { HOT_UPDATER_INFRASTRUCTURE_GENERATION } from "./handlerVersionRoutes.cjs";
11
- export { API_KEY_HEADER_NAME, ActiveInstallationInput, ActiveInstallationOverview, ActiveInstallationWindow, type ApiKeyManagementAPI, type ApiKeyMetadata, Bundle, BundleEventInsightsResult, BundleEventInsightsWindow, BundleEventOverview, BundleEventSummary, BundleEventSummaryByBundle, ChannelsResponse, type ClientAccessPolicy, CreateBundleEventRequest, CreateBundleEventRequestBase, type CreateHotUpdaterOptions, type CreatedApiKey, DataResponse, HOT_UPDATER_INFRASTRUCTURE_GENERATION, HOT_UPDATER_SERVER_VERSION, type HandlerAPI, type HotUpdaterAPI, type HotUpdaterHandler, type HotUpdaterHandlers, InsightsCohortPoint, type InsightsProvider, InsightsSeriesPoint, InstallationHistoryRow, InstallationSearchRow, OffsetPaginationResult, Paginated, PaginatedResult, PaginationInfo, PaginationOptions, type RuntimeHotUpdaterAPI, createApiKey, createHandlers, createHotUpdater, createInsightsProvider, provisionApiKey, registerApiKey };
11
+ export { API_KEY_HEADER_NAME, type ActiveInstallationWindow, type ApiKeyManagementAPI, type ApiKeyMetadata, type Bundle, ChannelsResponse, type ClientAccessPolicy, type CreateBundleEventRequest, type CreateBundleEventRequestBase, type CreateHotUpdaterOptions, type CreatedApiKey, type CursorPage, DataResponse, type EventCursorPage, type EventHistoryRow, HOT_UPDATER_INFRASTRUCTURE_GENERATION, HOT_UPDATER_SERVER_VERSION, type HandlerAPI, type HotUpdaterAPI, type HotUpdaterHandler, type HotUpdaterHandlers, type InsightsBundleSelection, type InsightsCountMeasurement, type InsightsEventPageInput, type InsightsInstallationEventPageInput, type InsightsProvider, type InsightsScope, type InsightsUserInstallationPageInput, type InstallationHistoryRow, type InstallationRow, Paginated, PaginatedResult, PaginationInfo, PaginationOptions, type ReportingOverview, type RuntimeHotUpdaterAPI, createApiKey, createHandlers, createHotUpdater, createInsightsProvider, provisionApiKey, registerApiKey };
package/dist/index.d.mts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { API_KEY_HEADER_NAME, ApiKeyManagementAPI, ApiKeyMetadata, CreatedApiKey, createApiKey, provisionApiKey, registerApiKey } from "./apiKeys.mjs";
2
2
  import { HandlerAPI, HotUpdaterHandler, HotUpdaterHandlers } from "./handlerTypes.mjs";
3
- import { ActiveInstallationInput, ActiveInstallationOverview, ActiveInstallationWindow, BundleEventInsightsResult, BundleEventInsightsWindow, BundleEventOverview, BundleEventSummary, BundleEventSummaryByBundle, CreateBundleEventRequest, CreateBundleEventRequestBase, InsightsCohortPoint, InsightsSeriesPoint, InstallationHistoryRow, InstallationSearchRow, OffsetPaginationResult } from "./insights/domain.mjs";
4
- import { InsightsProvider } from "./insights/types.mjs";
3
+ import { ActiveInstallationWindow, CreateBundleEventRequest, CreateBundleEventRequestBase, CursorPage, EventCursorPage, EventHistoryRow, InsightsBundleSelection, InsightsCountMeasurement, InsightsScope, InstallationHistoryRow, InstallationRow, ReportingOverview } from "./insights/domain.mjs";
4
+ import { InsightsEventPageInput, InsightsInstallationEventPageInput, InsightsProvider, InsightsUserInstallationPageInput } from "./insights/types.mjs";
5
5
  import { createHandlers } from "./handler.mjs";
6
6
  import { ClientAccessPolicy, CreateHotUpdaterOptions, HotUpdaterAPI, RuntimeHotUpdaterAPI, createHotUpdater } from "./createHotUpdaterCore.mjs";
7
7
  import { Bundle, ChannelsResponse, DataResponse, Paginated, PaginatedResult, PaginationInfo, PaginationOptions } from "./types/index.mjs";
8
8
  import { HOT_UPDATER_SERVER_VERSION } from "./version.mjs";
9
- import { createInsightsProvider } from "./insights/bounded/provider.mjs";
9
+ import { createInsightsProvider } from "./insights/provider.mjs";
10
10
  import { HOT_UPDATER_INFRASTRUCTURE_GENERATION } from "./handlerVersionRoutes.mjs";
11
- export { API_KEY_HEADER_NAME, ActiveInstallationInput, ActiveInstallationOverview, ActiveInstallationWindow, type ApiKeyManagementAPI, type ApiKeyMetadata, Bundle, BundleEventInsightsResult, BundleEventInsightsWindow, BundleEventOverview, BundleEventSummary, BundleEventSummaryByBundle, ChannelsResponse, type ClientAccessPolicy, CreateBundleEventRequest, CreateBundleEventRequestBase, type CreateHotUpdaterOptions, type CreatedApiKey, DataResponse, HOT_UPDATER_INFRASTRUCTURE_GENERATION, HOT_UPDATER_SERVER_VERSION, type HandlerAPI, type HotUpdaterAPI, type HotUpdaterHandler, type HotUpdaterHandlers, InsightsCohortPoint, type InsightsProvider, InsightsSeriesPoint, InstallationHistoryRow, InstallationSearchRow, OffsetPaginationResult, Paginated, PaginatedResult, PaginationInfo, PaginationOptions, type RuntimeHotUpdaterAPI, createApiKey, createHandlers, createHotUpdater, createInsightsProvider, provisionApiKey, registerApiKey };
11
+ export { API_KEY_HEADER_NAME, type ActiveInstallationWindow, type ApiKeyManagementAPI, type ApiKeyMetadata, type Bundle, ChannelsResponse, type ClientAccessPolicy, type CreateBundleEventRequest, type CreateBundleEventRequestBase, type CreateHotUpdaterOptions, type CreatedApiKey, type CursorPage, DataResponse, type EventCursorPage, type EventHistoryRow, HOT_UPDATER_INFRASTRUCTURE_GENERATION, HOT_UPDATER_SERVER_VERSION, type HandlerAPI, type HotUpdaterAPI, type HotUpdaterHandler, type HotUpdaterHandlers, type InsightsBundleSelection, type InsightsCountMeasurement, type InsightsEventPageInput, type InsightsInstallationEventPageInput, type InsightsProvider, type InsightsScope, type InsightsUserInstallationPageInput, type InstallationHistoryRow, type InstallationRow, Paginated, PaginatedResult, PaginationInfo, PaginationOptions, type ReportingOverview, type RuntimeHotUpdaterAPI, createApiKey, createHandlers, createHotUpdater, createInsightsProvider, provisionApiKey, registerApiKey };
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { HOT_UPDATER_SERVER_VERSION } from "./version.mjs";
2
2
  import { HOT_UPDATER_INFRASTRUCTURE_GENERATION } from "./handlerVersionRoutes.mjs";
3
3
  import { createHandlers } from "./handler.mjs";
4
- import { createInsightsProvider } from "./insights/bounded/provider.mjs";
4
+ import { createInsightsProvider } from "./insights/provider.mjs";
5
5
  import { API_KEY_HEADER_NAME, createApiKey, provisionApiKey, registerApiKey } from "./apiKeys.mjs";
6
6
  import { createHotUpdater } from "./createHotUpdaterCore.mjs";
7
7
  export { API_KEY_HEADER_NAME, HOT_UPDATER_INFRASTRUCTURE_GENERATION, HOT_UPDATER_SERVER_VERSION, createApiKey, createHandlers, createHotUpdater, createInsightsProvider, provisionApiKey, registerApiKey };