@hot-updater/aws 0.33.1 → 0.34.0

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.
@@ -5929,12 +5929,13 @@ const INIT_BUNDLE_ROLLBACK_UPDATE_INFO = {
5929
5929
  fileHash: null
5930
5930
  };
5931
5931
  function createPluginDatabaseCore(getPlugin, resolveFileUrl, options) {
5932
+ const coreOptions = options;
5932
5933
  const runWithMutationPlugin = async (operation) => {
5933
- const plugin = options?.createMutationPlugin?.() ?? getPlugin();
5934
+ const plugin = coreOptions?.createMutationPlugin?.() ?? getPlugin();
5934
5935
  try {
5935
5936
  return await operation(plugin);
5936
5937
  } finally {
5937
- if (options?.createMutationPlugin) await options.cleanupMutationPlugin?.(plugin);
5938
+ if (coreOptions?.createMutationPlugin) await coreOptions.cleanupMutationPlugin?.(plugin);
5938
5939
  }
5939
5940
  };
5940
5941
  const getSortedBundlePage = async (options, context) => {
@@ -5993,9 +5994,11 @@ function createPluginDatabaseCore(getPlugin, resolveFileUrl, options) {
5993
5994
  return {
5994
5995
  api: {
5995
5996
  async getBundleById(id, context) {
5997
+ await coreOptions?.beforeOperation?.();
5996
5998
  return getPlugin().getBundleById(id, context);
5997
5999
  },
5998
6000
  async getUpdateInfo(args, context) {
6001
+ await coreOptions?.beforeOperation?.();
5999
6002
  const directGetUpdateInfo = getPlugin().getUpdateInfo;
6000
6003
  if (directGetUpdateInfo) return context === void 0 ? await directGetUpdateInfo(args) : await directGetUpdateInfo(args, context);
6001
6004
  const channel = args.channel ?? "production";
@@ -6029,7 +6032,7 @@ function createPluginDatabaseCore(getPlugin, resolveFileUrl, options) {
6029
6032
  const info = await this.getUpdateInfo(args, context);
6030
6033
  if (!info) return null;
6031
6034
  const { storageUri, ...rest } = info;
6032
- const readStorageText = options?.readStorageText;
6035
+ const readStorageText = coreOptions?.readStorageText;
6033
6036
  if (info.id === "00000000-0000-0000-0000-000000000000" || !readStorageText) {
6034
6037
  const fileUrl = await resolveFileUrl(storageUri ?? null, context);
6035
6038
  return {
@@ -6067,12 +6070,15 @@ function createPluginDatabaseCore(getPlugin, resolveFileUrl, options) {
6067
6070
  };
6068
6071
  },
6069
6072
  async getChannels(context) {
6073
+ await coreOptions?.beforeOperation?.();
6070
6074
  return getPlugin().getChannels(context);
6071
6075
  },
6072
6076
  async getBundles(options, context) {
6077
+ await coreOptions?.beforeOperation?.();
6073
6078
  return getPlugin().getBundles(options, context);
6074
6079
  },
6075
6080
  async insertBundle(bundle, context) {
6081
+ await coreOptions?.beforeOperation?.();
6076
6082
  assertBundlePersistenceConstraints(bundle);
6077
6083
  await runWithMutationPlugin(async (plugin) => {
6078
6084
  await plugin.appendBundle(bundle, context);
@@ -6080,6 +6086,7 @@ function createPluginDatabaseCore(getPlugin, resolveFileUrl, options) {
6080
6086
  });
6081
6087
  },
6082
6088
  async updateBundleById(bundleId, newBundle, context) {
6089
+ await coreOptions?.beforeOperation?.();
6083
6090
  await runWithMutationPlugin(async (plugin) => {
6084
6091
  const current = await plugin.getBundleById(bundleId, context);
6085
6092
  if (!current) throw new Error("targetBundleId not found");
@@ -6092,6 +6099,7 @@ function createPluginDatabaseCore(getPlugin, resolveFileUrl, options) {
6092
6099
  });
6093
6100
  },
6094
6101
  async deleteBundleById(bundleId, context) {
6102
+ await coreOptions?.beforeOperation?.();
6095
6103
  await runWithMutationPlugin(async (plugin) => {
6096
6104
  const bundle = await plugin.getBundleById(bundleId, context);
6097
6105
  if (!bundle) return;
@@ -6102,26 +6110,47 @@ function createPluginDatabaseCore(getPlugin, resolveFileUrl, options) {
6102
6110
  },
6103
6111
  adapterName: getPlugin().name,
6104
6112
  createMigrator: () => {
6105
- throw new Error("createMigrator is only available for Kysely/Prisma/Drizzle database adapters.");
6113
+ throw new Error("createMigrator is only available for Kysely/MongoDB database adapters.");
6106
6114
  },
6107
6115
  generateSchema: () => {
6108
- throw new Error("generateSchema is only available for Kysely/Prisma/Drizzle database adapters.");
6116
+ throw new Error("generateSchema is only available for Drizzle/Prisma database adapters.");
6109
6117
  }
6110
6118
  };
6111
6119
  }
6112
6120
  //#endregion
6113
- //#region ../../node_modules/.pnpm/fumadb@0.2.2_mongodb@6.20.0_@aws-sdk+credential-providers@3.1066.0_socks@2.8.9__prisma@_ee79457f0e32f18f0beb5c2db02e4f73/node_modules/fumadb/dist/index.js
6114
- var sqlProviders = [
6121
+ //#region ../../packages/server/src/schema/types.ts
6122
+ const HOT_UPDATER_SCHEMA_VERSION = "0.31.0";
6123
+ //#endregion
6124
+ //#region ../../packages/server/src/db/schemaReadiness.ts
6125
+ var HotUpdaterSchemaMigrationRequiredError = class extends Error {
6126
+ constructor(adapterName, currentVersion) {
6127
+ super(currentVersion === void 0 ? `Hot Updater database schema is not initialized for ${adapterName}. Run \`hot-updater db migrate\` before using this adapter.` : `Hot Updater database schema version ${currentVersion} is not supported by ${adapterName}. Run \`hot-updater db migrate\` to upgrade to ${HOT_UPDATER_SCHEMA_VERSION}.`);
6128
+ this.adapterName = adapterName;
6129
+ this.currentVersion = currentVersion;
6130
+ this.name = "HotUpdaterSchemaMigrationRequiredError";
6131
+ }
6132
+ };
6133
+ const createSchemaReadinessChecker = (adapterName, createMigrator) => {
6134
+ if (!createMigrator) return async () => {};
6135
+ let ready = false;
6136
+ return async () => {
6137
+ if (ready) return;
6138
+ const version = await createMigrator().getVersion();
6139
+ if (version !== "0.31.0") throw new HotUpdaterSchemaMigrationRequiredError(adapterName, version);
6140
+ ready = true;
6141
+ };
6142
+ };
6143
+ //#endregion
6144
+ //#region ../../packages/server/src/db/types.ts
6145
+ const sqlProviders = [
6115
6146
  "sqlite",
6116
6147
  "cockroachdb",
6117
6148
  "mysql",
6118
6149
  "postgresql",
6119
6150
  "mssql"
6120
6151
  ];
6121
- var noSqlProviders = ["mongodb"];
6152
+ const noSqlProviders = ["mongodb"];
6122
6153
  [...sqlProviders, ...noSqlProviders];
6123
- //#endregion
6124
- //#region ../../packages/server/src/db/types.ts
6125
6154
  function isDatabasePluginFactory(adapter) {
6126
6155
  return typeof adapter === "function";
6127
6156
  }
@@ -6181,7 +6210,7 @@ function findRoute(router, method, path) {
6181
6210
  }
6182
6211
  //#endregion
6183
6212
  //#region ../../packages/server/src/version.ts
6184
- const HOT_UPDATER_SERVER_VERSION = "0.33.1";
6213
+ const HOT_UPDATER_SERVER_VERSION = "0.34.0";
6185
6214
  //#endregion
6186
6215
  //#region ../../packages/server/src/handler.ts
6187
6216
  var HandlerBadRequestError = class extends Error {
@@ -6531,11 +6560,17 @@ function createHotUpdater(options) {
6531
6560
  return storagePlugin;
6532
6561
  }));
6533
6562
  if (!isDatabasePluginFactory(database) && !isDatabasePlugin(database)) throw new Error("@hot-updater/server/runtime only supports database plugins.");
6563
+ const capabilities = database;
6534
6564
  const plugin = isDatabasePluginFactory(database) ? database() : database;
6565
+ const assertSchemaReady = createSchemaReadinessChecker(capabilities.adapterName ?? plugin.name, capabilities.createMigrator);
6535
6566
  const core = createPluginDatabaseCore(() => plugin, resolveFileUrl, isDatabasePluginFactory(database) ? {
6536
6567
  createMutationPlugin: () => database(),
6568
+ beforeOperation: assertSchemaReady,
6537
6569
  readStorageText
6538
- } : { readStorageText });
6570
+ } : {
6571
+ beforeOperation: assertSchemaReady,
6572
+ readStorageText
6573
+ });
6539
6574
  const internalHandler = createHandler(core.api, {
6540
6575
  basePath,
6541
6576
  routes: options.routes
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hot-updater/aws",
3
3
  "type": "module",
4
- "version": "0.33.1",
4
+ "version": "0.34.0",
5
5
  "description": "React Native OTA solution for self-hosted",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.mjs",
@@ -45,10 +45,10 @@
45
45
  "es-toolkit": "^1.32.0",
46
46
  "execa": "9.5.2",
47
47
  "mime": "^4.0.4",
48
- "@hot-updater/core": "0.33.1",
49
- "@hot-updater/js": "0.33.1",
50
- "@hot-updater/mock": "0.33.1",
51
- "@hot-updater/test-utils": "0.33.1"
48
+ "@hot-updater/core": "0.34.0",
49
+ "@hot-updater/js": "0.34.0",
50
+ "@hot-updater/mock": "0.34.0",
51
+ "@hot-updater/test-utils": "0.34.0"
52
52
  },
53
53
  "dependencies": {
54
54
  "@aws-sdk/client-cloudfront": "3.1066.0",
@@ -63,9 +63,9 @@
63
63
  "@aws-sdk/lib-storage": "3.1066.0",
64
64
  "hono": "4.12.9",
65
65
  "aws-lambda": "1.0.7",
66
- "@hot-updater/cli-tools": "0.33.1",
67
- "@hot-updater/plugin-core": "0.33.1",
68
- "@hot-updater/server": "0.33.1"
66
+ "@hot-updater/cli-tools": "0.34.0",
67
+ "@hot-updater/plugin-core": "0.34.0",
68
+ "@hot-updater/server": "0.34.0"
69
69
  },
70
70
  "scripts": {
71
71
  "build": "tsdown",