@hot-updater/cloudflare 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.
package/dist/index.cjs CHANGED
@@ -499,27 +499,49 @@ const d1Database = (0, _hot_updater_plugin_core.createDatabasePlugin)({
499
499
  }))).map((row) => row.target_app_version);
500
500
  }
501
501
  return {
502
- getUpdateInfo: (0, _hot_updater_plugin_core.createDatabasePluginGetUpdateInfo)({
503
- listTargetAppVersions: getTargetAppVersionsForUpdateInfo,
504
- getBundlesByTargetAppVersions({ platform, channel, minBundleId }, targetAppVersions) {
505
- return queryBundlesForUpdateInfo({
506
- enabled: true,
507
- platform,
502
+ async getUpdateInfo(args, context) {
503
+ const channel = args.channel ?? "production";
504
+ const minBundleId = args.minBundleId ?? _hot_updater_core.NIL_UUID;
505
+ if (args._updateStrategy === "appVersion") {
506
+ const compatibleAppVersions = (0, _hot_updater_plugin_core.filterCompatibleAppVersions)(await getTargetAppVersionsForUpdateInfo({
507
+ platform: args.platform,
508
508
  channel,
509
- id: { gte: minBundleId },
510
- targetAppVersionIn: targetAppVersions
511
- });
512
- },
513
- getBundlesByFingerprint({ platform, channel, minBundleId, fingerprintHash }) {
514
- return queryBundlesForUpdateInfo({
509
+ minBundleId
510
+ }), args.appVersion);
511
+ const bundles = compatibleAppVersions.length > 0 ? await queryBundlesForUpdateInfo({
515
512
  enabled: true,
516
- platform,
513
+ platform: args.platform,
517
514
  channel,
518
515
  id: { gte: minBundleId },
519
- fingerprintHash
516
+ targetAppVersionIn: compatibleAppVersions
517
+ }) : [];
518
+ return (0, _hot_updater_plugin_core.resolveUpdateInfoFromBundles)({
519
+ args: {
520
+ ...args,
521
+ channel,
522
+ minBundleId
523
+ },
524
+ bundles,
525
+ context
520
526
  });
521
527
  }
522
- }),
528
+ const bundles = await queryBundlesForUpdateInfo({
529
+ enabled: true,
530
+ platform: args.platform,
531
+ channel,
532
+ id: { gte: minBundleId },
533
+ fingerprintHash: args.fingerprintHash
534
+ });
535
+ return (0, _hot_updater_plugin_core.resolveUpdateInfoFromBundles)({
536
+ args: {
537
+ ...args,
538
+ channel,
539
+ minBundleId
540
+ },
541
+ bundles,
542
+ context
543
+ });
544
+ },
523
545
  async getBundleById(bundleId) {
524
546
  const sql = (0, import_lib.default)(`
525
547
  SELECT * FROM bundles WHERE id = ? LIMIT 1`);
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createRequire } from "node:module";
2
- import { DEFAULT_ROLLOUT_COHORT_COUNT, getAssetBaseStorageUri, getBundlePatches, getManifestFileHash, getManifestStorageUri, stripBundleArtifactMetadata } from "@hot-updater/core";
3
- import { calculatePagination, createDatabasePlugin, createDatabasePluginGetUpdateInfo, createStorageKeyBuilder, createUniversalStoragePlugin, getContentType, parseStorageUri } from "@hot-updater/plugin-core";
2
+ import { DEFAULT_ROLLOUT_COHORT_COUNT, NIL_UUID, getAssetBaseStorageUri, getBundlePatches, getManifestFileHash, getManifestStorageUri, stripBundleArtifactMetadata } from "@hot-updater/core";
3
+ import { calculatePagination, createDatabasePlugin, createStorageKeyBuilder, createUniversalStoragePlugin, filterCompatibleAppVersions, getContentType, parseStorageUri, resolveUpdateInfoFromBundles } from "@hot-updater/plugin-core";
4
4
  import Cloudflare from "cloudflare";
5
5
  import fs from "node:fs/promises";
6
6
  import path from "node:path";
@@ -494,27 +494,49 @@ const d1Database = createDatabasePlugin({
494
494
  }))).map((row) => row.target_app_version);
495
495
  }
496
496
  return {
497
- getUpdateInfo: createDatabasePluginGetUpdateInfo({
498
- listTargetAppVersions: getTargetAppVersionsForUpdateInfo,
499
- getBundlesByTargetAppVersions({ platform, channel, minBundleId }, targetAppVersions) {
500
- return queryBundlesForUpdateInfo({
501
- enabled: true,
502
- platform,
497
+ async getUpdateInfo(args, context) {
498
+ const channel = args.channel ?? "production";
499
+ const minBundleId = args.minBundleId ?? NIL_UUID;
500
+ if (args._updateStrategy === "appVersion") {
501
+ const compatibleAppVersions = filterCompatibleAppVersions(await getTargetAppVersionsForUpdateInfo({
502
+ platform: args.platform,
503
503
  channel,
504
- id: { gte: minBundleId },
505
- targetAppVersionIn: targetAppVersions
506
- });
507
- },
508
- getBundlesByFingerprint({ platform, channel, minBundleId, fingerprintHash }) {
509
- return queryBundlesForUpdateInfo({
504
+ minBundleId
505
+ }), args.appVersion);
506
+ const bundles = compatibleAppVersions.length > 0 ? await queryBundlesForUpdateInfo({
510
507
  enabled: true,
511
- platform,
508
+ platform: args.platform,
512
509
  channel,
513
510
  id: { gte: minBundleId },
514
- fingerprintHash
511
+ targetAppVersionIn: compatibleAppVersions
512
+ }) : [];
513
+ return resolveUpdateInfoFromBundles({
514
+ args: {
515
+ ...args,
516
+ channel,
517
+ minBundleId
518
+ },
519
+ bundles,
520
+ context
515
521
  });
516
522
  }
517
- }),
523
+ const bundles = await queryBundlesForUpdateInfo({
524
+ enabled: true,
525
+ platform: args.platform,
526
+ channel,
527
+ id: { gte: minBundleId },
528
+ fingerprintHash: args.fingerprintHash
529
+ });
530
+ return resolveUpdateInfoFromBundles({
531
+ args: {
532
+ ...args,
533
+ channel,
534
+ minBundleId
535
+ },
536
+ bundles,
537
+ context
538
+ });
539
+ },
518
540
  async getBundleById(bundleId) {
519
541
  const sql = (0, import_lib.default)(`
520
542
  SELECT * FROM bundles WHERE id = ? LIMIT 1`);
@@ -185,27 +185,49 @@ const d1WorkerDatabase = () => (0, _hot_updater_plugin_core.createDatabasePlugin
185
185
  ], context)).map((row) => row.target_app_version);
186
186
  };
187
187
  return {
188
- getUpdateInfo: (0, _hot_updater_plugin_core.createDatabasePluginGetUpdateInfo)({
189
- listTargetAppVersions: getTargetAppVersionsForUpdateInfo,
190
- getBundlesByTargetAppVersions({ platform, channel, minBundleId }, targetAppVersions, context) {
191
- return queryBundlesForUpdateInfo({
192
- enabled: true,
193
- platform,
188
+ async getUpdateInfo(args, context) {
189
+ const channel = args.channel ?? "production";
190
+ const minBundleId = args.minBundleId ?? _hot_updater_core.NIL_UUID;
191
+ if (args._updateStrategy === "appVersion") {
192
+ const compatibleAppVersions = (0, _hot_updater_plugin_core.filterCompatibleAppVersions)(await getTargetAppVersionsForUpdateInfo({
193
+ platform: args.platform,
194
194
  channel,
195
- id: { gte: minBundleId },
196
- targetAppVersionIn: targetAppVersions
197
- }, context);
198
- },
199
- getBundlesByFingerprint({ platform, channel, minBundleId, fingerprintHash }, context) {
200
- return queryBundlesForUpdateInfo({
195
+ minBundleId
196
+ }, context), args.appVersion);
197
+ const bundles = compatibleAppVersions.length > 0 ? await queryBundlesForUpdateInfo({
201
198
  enabled: true,
202
- platform,
199
+ platform: args.platform,
203
200
  channel,
204
201
  id: { gte: minBundleId },
205
- fingerprintHash
206
- }, context);
202
+ targetAppVersionIn: compatibleAppVersions
203
+ }, context) : [];
204
+ return (0, _hot_updater_plugin_core.resolveUpdateInfoFromBundles)({
205
+ args: {
206
+ ...args,
207
+ channel,
208
+ minBundleId
209
+ },
210
+ bundles,
211
+ context
212
+ });
207
213
  }
208
- }),
214
+ const bundles = await queryBundlesForUpdateInfo({
215
+ enabled: true,
216
+ platform: args.platform,
217
+ channel,
218
+ id: { gte: minBundleId },
219
+ fingerprintHash: args.fingerprintHash
220
+ }, context);
221
+ return (0, _hot_updater_plugin_core.resolveUpdateInfoFromBundles)({
222
+ args: {
223
+ ...args,
224
+ channel,
225
+ minBundleId
226
+ },
227
+ bundles,
228
+ context
229
+ });
230
+ },
209
231
  async getBundleById(bundleId, context) {
210
232
  const [row, patchMap] = await Promise.all([queryFirst("SELECT * FROM bundles WHERE id = ? LIMIT 1", [bundleId], context), getPatchMap([bundleId], context)]);
211
233
  return row ? transformRowToBundle(row, patchMap.get(bundleId)) : null;
@@ -1,6 +1,6 @@
1
1
  import { signToken, verifyJwtSignedUrl } from "@hot-updater/js";
2
- import { DEFAULT_ROLLOUT_COHORT_COUNT, getAssetBaseStorageUri, getBundlePatches, getManifestFileHash, getManifestStorageUri, stripBundleArtifactMetadata } from "@hot-updater/core";
3
- import { calculatePagination, createDatabasePlugin, createDatabasePluginGetUpdateInfo, createRuntimeStoragePlugin } from "@hot-updater/plugin-core";
2
+ import { DEFAULT_ROLLOUT_COHORT_COUNT, NIL_UUID, getAssetBaseStorageUri, getBundlePatches, getManifestFileHash, getManifestStorageUri, stripBundleArtifactMetadata } from "@hot-updater/core";
3
+ import { calculatePagination, createDatabasePlugin, createRuntimeStoragePlugin, filterCompatibleAppVersions, resolveUpdateInfoFromBundles } from "@hot-updater/plugin-core";
4
4
  //#region src/cloudflareWorkerDatabase.ts
5
5
  const buildJsonEachInClause = (columnName, values, params) => {
6
6
  if (values.length === 0) return "1 = 0";
@@ -184,27 +184,49 @@ const d1WorkerDatabase = () => createDatabasePlugin({
184
184
  ], context)).map((row) => row.target_app_version);
185
185
  };
186
186
  return {
187
- getUpdateInfo: createDatabasePluginGetUpdateInfo({
188
- listTargetAppVersions: getTargetAppVersionsForUpdateInfo,
189
- getBundlesByTargetAppVersions({ platform, channel, minBundleId }, targetAppVersions, context) {
190
- return queryBundlesForUpdateInfo({
191
- enabled: true,
192
- platform,
187
+ async getUpdateInfo(args, context) {
188
+ const channel = args.channel ?? "production";
189
+ const minBundleId = args.minBundleId ?? NIL_UUID;
190
+ if (args._updateStrategy === "appVersion") {
191
+ const compatibleAppVersions = filterCompatibleAppVersions(await getTargetAppVersionsForUpdateInfo({
192
+ platform: args.platform,
193
193
  channel,
194
- id: { gte: minBundleId },
195
- targetAppVersionIn: targetAppVersions
196
- }, context);
197
- },
198
- getBundlesByFingerprint({ platform, channel, minBundleId, fingerprintHash }, context) {
199
- return queryBundlesForUpdateInfo({
194
+ minBundleId
195
+ }, context), args.appVersion);
196
+ const bundles = compatibleAppVersions.length > 0 ? await queryBundlesForUpdateInfo({
200
197
  enabled: true,
201
- platform,
198
+ platform: args.platform,
202
199
  channel,
203
200
  id: { gte: minBundleId },
204
- fingerprintHash
205
- }, context);
201
+ targetAppVersionIn: compatibleAppVersions
202
+ }, context) : [];
203
+ return resolveUpdateInfoFromBundles({
204
+ args: {
205
+ ...args,
206
+ channel,
207
+ minBundleId
208
+ },
209
+ bundles,
210
+ context
211
+ });
206
212
  }
207
- }),
213
+ const bundles = await queryBundlesForUpdateInfo({
214
+ enabled: true,
215
+ platform: args.platform,
216
+ channel,
217
+ id: { gte: minBundleId },
218
+ fingerprintHash: args.fingerprintHash
219
+ }, context);
220
+ return resolveUpdateInfoFromBundles({
221
+ args: {
222
+ ...args,
223
+ channel,
224
+ minBundleId
225
+ },
226
+ bundles,
227
+ context
228
+ });
229
+ },
208
230
  async getBundleById(bundleId, context) {
209
231
  const [row, patchMap] = await Promise.all([queryFirst("SELECT * FROM bundles WHERE id = ? LIMIT 1", [bundleId], context), getPatchMap([bundleId], context)]);
210
232
  return row ? transformRowToBundle(row, patchMap.get(bundleId)) : null;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hot-updater/cloudflare",
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",
@@ -56,11 +56,11 @@
56
56
  "cloudflare": "4.2.0",
57
57
  "hono": "4.12.9",
58
58
  "uuidv7": "^1.0.2",
59
- "@hot-updater/cli-tools": "0.33.1",
60
- "@hot-updater/core": "0.33.1",
61
- "@hot-updater/js": "0.33.1",
62
- "@hot-updater/plugin-core": "0.33.1",
63
- "@hot-updater/server": "0.33.1"
59
+ "@hot-updater/core": "0.34.0",
60
+ "@hot-updater/js": "0.34.0",
61
+ "@hot-updater/plugin-core": "0.34.0",
62
+ "@hot-updater/server": "0.34.0",
63
+ "@hot-updater/cli-tools": "0.34.0"
64
64
  },
65
65
  "devDependencies": {
66
66
  "@cloudflare/vitest-pool-workers": "0.13.0",
@@ -77,7 +77,7 @@
77
77
  "vitest": "4.1.4",
78
78
  "wrangler": "^4.5.0",
79
79
  "xdg-app-paths": "^8.3.0",
80
- "@hot-updater/test-utils": "0.33.1"
80
+ "@hot-updater/test-utils": "0.34.0"
81
81
  },
82
82
  "scripts": {
83
83
  "build": "tsdown && pnpm build:worker",
@@ -4,6 +4,7 @@ import {
4
4
  getBundlePatches,
5
5
  getManifestFileHash,
6
6
  getManifestStorageUri,
7
+ NIL_UUID,
7
8
  stripBundleArtifactMetadata,
8
9
  } from "@hot-updater/core";
9
10
  import type {
@@ -16,7 +17,8 @@ import type {
16
17
  import {
17
18
  calculatePagination,
18
19
  createDatabasePlugin,
19
- createDatabasePluginGetUpdateInfo,
20
+ filterCompatibleAppVersions,
21
+ resolveUpdateInfoFromBundles,
20
22
  } from "@hot-updater/plugin-core";
21
23
 
22
24
  type D1Result<T> = {
@@ -414,44 +416,65 @@ export const d1WorkerDatabase = <
414
416
  };
415
417
 
416
418
  return {
417
- getUpdateInfo: createDatabasePluginGetUpdateInfo({
418
- listTargetAppVersions: getTargetAppVersionsForUpdateInfo,
419
- getBundlesByTargetAppVersions(
420
- { platform, channel, minBundleId },
421
- targetAppVersions,
422
- context,
423
- ) {
424
- return queryBundlesForUpdateInfo(
419
+ async getUpdateInfo(args, context) {
420
+ const channel = args.channel ?? "production";
421
+ const minBundleId = args.minBundleId ?? NIL_UUID;
422
+
423
+ if (args._updateStrategy === "appVersion") {
424
+ const targetAppVersions = await getTargetAppVersionsForUpdateInfo(
425
425
  {
426
- enabled: true,
427
- platform,
426
+ platform: args.platform,
428
427
  channel,
429
- id: {
430
- gte: minBundleId,
431
- },
432
- targetAppVersionIn: targetAppVersions,
428
+ minBundleId,
433
429
  },
434
430
  context,
435
431
  );
436
- },
437
- getBundlesByFingerprint(
438
- { platform, channel, minBundleId, fingerprintHash },
439
- context,
440
- ) {
441
- return queryBundlesForUpdateInfo(
442
- {
443
- enabled: true,
444
- platform,
445
- channel,
446
- id: {
447
- gte: minBundleId,
448
- },
449
- fingerprintHash,
450
- },
451
- context,
432
+ const compatibleAppVersions = filterCompatibleAppVersions(
433
+ targetAppVersions,
434
+ args.appVersion,
452
435
  );
453
- },
454
- }),
436
+ const bundles =
437
+ compatibleAppVersions.length > 0
438
+ ? await queryBundlesForUpdateInfo(
439
+ {
440
+ enabled: true,
441
+ platform: args.platform,
442
+ channel,
443
+ id: {
444
+ gte: minBundleId,
445
+ },
446
+ targetAppVersionIn: compatibleAppVersions,
447
+ },
448
+ context,
449
+ )
450
+ : [];
451
+
452
+ return resolveUpdateInfoFromBundles({
453
+ args: { ...args, channel, minBundleId },
454
+ bundles,
455
+ context,
456
+ });
457
+ }
458
+
459
+ const bundles = await queryBundlesForUpdateInfo(
460
+ {
461
+ enabled: true,
462
+ platform: args.platform,
463
+ channel,
464
+ id: {
465
+ gte: minBundleId,
466
+ },
467
+ fingerprintHash: args.fingerprintHash,
468
+ },
469
+ context,
470
+ );
471
+
472
+ return resolveUpdateInfoFromBundles({
473
+ args: { ...args, channel, minBundleId },
474
+ bundles,
475
+ context,
476
+ });
477
+ },
455
478
 
456
479
  async getBundleById(bundleId, context) {
457
480
  const [row, patchMap] = await Promise.all([
package/src/d1Database.ts CHANGED
@@ -4,6 +4,7 @@ import {
4
4
  getBundlePatches,
5
5
  getManifestFileHash,
6
6
  getManifestStorageUri,
7
+ NIL_UUID,
7
8
  stripBundleArtifactMetadata,
8
9
  } from "@hot-updater/core";
9
10
  import type {
@@ -15,7 +16,8 @@ import type {
15
16
  import {
16
17
  calculatePagination,
17
18
  createDatabasePlugin,
18
- createDatabasePluginGetUpdateInfo,
19
+ filterCompatibleAppVersions,
20
+ resolveUpdateInfoFromBundles,
19
21
  } from "@hot-updater/plugin-core";
20
22
  import Cloudflare from "cloudflare";
21
23
  import minify from "pg-minify";
@@ -405,39 +407,56 @@ export const d1Database = createDatabasePlugin<D1DatabaseConfig>({
405
407
  }
406
408
 
407
409
  return {
408
- getUpdateInfo: createDatabasePluginGetUpdateInfo({
409
- listTargetAppVersions: getTargetAppVersionsForUpdateInfo,
410
- getBundlesByTargetAppVersions(
411
- { platform, channel, minBundleId },
412
- targetAppVersions,
413
- ) {
414
- return queryBundlesForUpdateInfo({
415
- enabled: true,
416
- platform,
410
+ async getUpdateInfo(args, context) {
411
+ const channel = args.channel ?? "production";
412
+ const minBundleId = args.minBundleId ?? NIL_UUID;
413
+
414
+ if (args._updateStrategy === "appVersion") {
415
+ const targetAppVersions = await getTargetAppVersionsForUpdateInfo({
416
+ platform: args.platform,
417
417
  channel,
418
- id: {
419
- gte: minBundleId,
420
- },
421
- targetAppVersionIn: targetAppVersions,
418
+ minBundleId,
422
419
  });
423
- },
424
- getBundlesByFingerprint({
425
- platform,
426
- channel,
427
- minBundleId,
428
- fingerprintHash,
429
- }) {
430
- return queryBundlesForUpdateInfo({
431
- enabled: true,
432
- platform,
433
- channel,
434
- id: {
435
- gte: minBundleId,
436
- },
437
- fingerprintHash,
420
+ const compatibleAppVersions = filterCompatibleAppVersions(
421
+ targetAppVersions,
422
+ args.appVersion,
423
+ );
424
+ const bundles =
425
+ compatibleAppVersions.length > 0
426
+ ? await queryBundlesForUpdateInfo({
427
+ enabled: true,
428
+ platform: args.platform,
429
+ channel,
430
+ id: {
431
+ gte: minBundleId,
432
+ },
433
+ targetAppVersionIn: compatibleAppVersions,
434
+ })
435
+ : [];
436
+
437
+ return resolveUpdateInfoFromBundles({
438
+ args: { ...args, channel, minBundleId },
439
+ bundles,
440
+ context,
438
441
  });
439
- },
440
- }),
442
+ }
443
+
444
+ const bundles = await queryBundlesForUpdateInfo({
445
+ enabled: true,
446
+ platform: args.platform,
447
+ channel,
448
+ id: {
449
+ gte: minBundleId,
450
+ },
451
+ fingerprintHash: args.fingerprintHash,
452
+ });
453
+
454
+ return resolveUpdateInfoFromBundles({
455
+ args: { ...args, channel, minBundleId },
456
+ bundles,
457
+ context,
458
+ });
459
+ },
441
460
 
442
461
  async getBundleById(bundleId) {
443
462
  const sql = minify(/* sql */ `
@@ -1 +1 @@
1
- This folder contains the built output assets for the worker "hot-updater" generated at 2026-06-12T18:34:53.149Z.
1
+ This folder contains the built output assets for the worker "hot-updater" generated at 2026-06-19T14:23:49.100Z.