@hot-updater/cloudflare 1.0.0-rc.0 → 1.0.0-rc.1

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hot-updater/cloudflare",
3
3
  "type": "module",
4
- "version": "1.0.0-rc.0",
4
+ "version": "1.0.0-rc.1",
5
5
  "description": "React Native OTA solution for self-hosted",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.mjs",
@@ -60,10 +60,10 @@
60
60
  "cloudflare": "4.2.0",
61
61
  "hono": "4.12.34",
62
62
  "uuidv7": "^1.0.2",
63
+ "@hot-updater/cli-tools": "1.0.0-rc.0",
63
64
  "@hot-updater/core": "1.0.0-rc.0",
64
- "@hot-updater/plugin-core": "1.0.0-rc.0",
65
65
  "@hot-updater/server": "1.0.0-rc.0",
66
- "@hot-updater/cli-tools": "1.0.0-rc.0"
66
+ "@hot-updater/plugin-core": "1.0.0-rc.0"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@cloudflare/vitest-pool-workers": "0.13.0",
@@ -1 +1 @@
1
- This folder contains the built output assets for the worker "hot-updater" generated at 2026-08-31T01:29:11.045Z.
1
+ This folder contains the built output assets for the worker "hot-updater" generated at 2026-08-31T06:17:57.099Z.
@@ -13,10 +13,14 @@ CREATE TABLE bundles (
13
13
  file_hash TEXT NOT NULL,
14
14
  git_commit_hash TEXT,
15
15
  storage_uri TEXT NOT NULL,
16
+ archive_byte_size REAL NOT NULL,
16
17
  metadata TEXT NOT NULL DEFAULT '{}',
17
18
  manifest_storage_uri TEXT,
18
19
  manifest_file_hash TEXT,
19
- asset_base_storage_uri TEXT
20
+ asset_base_storage_uri TEXT,
21
+ CONSTRAINT bundles_archive_byte_size_check CHECK (
22
+ archive_byte_size BETWEEN 0 AND 9007199254740991
23
+ )
20
24
  );
21
25
 
22
26
  CREATE TABLE bundle_patches (
@@ -26,7 +30,11 @@ CREATE TABLE bundle_patches (
26
30
  base_file_hash TEXT NOT NULL,
27
31
  patch_file_hash TEXT NOT NULL,
28
32
  patch_storage_uri TEXT NOT NULL,
33
+ byte_size REAL NOT NULL,
29
34
  order_index INTEGER NOT NULL DEFAULT 0,
35
+ CONSTRAINT bundle_patches_byte_size_check CHECK (
36
+ byte_size BETWEEN 0 AND 9007199254740991
37
+ ),
30
38
  CONSTRAINT bundle_patches_bundle_id_fk FOREIGN KEY (bundle_id)
31
39
  REFERENCES bundles(id) ON UPDATE RESTRICT ON DELETE CASCADE,
32
40
  CONSTRAINT bundle_patches_base_bundle_id_fk FOREIGN KEY (base_bundle_id)
@@ -10,44 +10,34 @@ declare module "vitest" {
10
10
  }
11
11
  }
12
12
 
13
- it("ships ordered D1 1.0.0 migrations", () => {
13
+ it("ships a single D1 1.0.0 CREATE migration", () => {
14
14
  expect(inject("d1Migrations").map(({ name }) => name)).toEqual([
15
15
  "0001_hot-updater_1.0.0.sql",
16
- "0002_hot-updater_artifact_byte_sizes.sql",
17
16
  ]);
18
17
  });
19
18
 
20
- it("upgrades existing rows and accepts current artifact sizes", async () => {
21
- const [createMigration, byteSizeMigration] = inject("d1Migrations");
19
+ it("creates the current schema with required artifact sizes", async () => {
20
+ const [createMigration] = inject("d1Migrations");
22
21
  await env.DB.prepare(createMigration!.sql).run();
23
22
  await env.DB.prepare(`
24
23
  INSERT INTO bundles (
25
- id, platform, file_hash, storage_uri, metadata
24
+ id, platform, file_hash, storage_uri, archive_byte_size, metadata
26
25
  ) VALUES (
27
26
  '00000000-0000-0000-0000-000000000001', 'ios', 'hash',
28
- 'storage://bundle', '{}'
27
+ 'storage://bundle', 3000000001, '{}'
29
28
  )
30
29
  `).run();
31
30
  await env.DB.prepare(`
32
31
  INSERT INTO bundle_patches (
33
32
  id, bundle_id, base_bundle_id, base_file_hash, patch_file_hash,
34
- patch_storage_uri
33
+ patch_storage_uri, byte_size
35
34
  ) VALUES (
36
35
  'patch-1', '00000000-0000-0000-0000-000000000001',
37
36
  '00000000-0000-0000-0000-000000000001', 'base-hash', 'patch-hash',
38
- 'storage://patch'
37
+ 'storage://patch', 3000000002
39
38
  )
40
39
  `).run();
41
40
 
42
- await env.DB.prepare(byteSizeMigration!.sql).run();
43
-
44
- const legacySizes = await env.DB.prepare(`
45
- SELECT bundle.archive_byte_size, patch.byte_size
46
- FROM bundles AS bundle
47
- JOIN bundle_patches AS patch ON patch.bundle_id = bundle.id
48
- `).first();
49
- expect(legacySizes).toEqual({ archive_byte_size: 0, byte_size: 0 });
50
-
51
41
  const tables = await env.DB.prepare(`
52
42
  SELECT name FROM sqlite_master
53
43
  WHERE type = 'table'
@@ -75,12 +65,6 @@ it("upgrades existing rows and accepts current artifact sizes", async () => {
75
65
  await env.DB.prepare(
76
66
  "INSERT INTO channels (id, name) VALUES ('channel-1', 'production')",
77
67
  ).run();
78
- await env.DB.prepare(
79
- "UPDATE bundles SET archive_byte_size = 3000000001",
80
- ).run();
81
- await env.DB.prepare(
82
- "UPDATE bundle_patches SET byte_size = 3000000002",
83
- ).run();
84
68
  await env.DB.prepare(`
85
69
  INSERT INTO releases (
86
70
  id, revision, scope_key, channel_id, platform, kind, bundle_id,
@@ -111,4 +95,36 @@ it("upgrades existing rows and accepts current artifact sizes", async () => {
111
95
  archive_byte_size: 3_000_000_001,
112
96
  byte_size: 3_000_000_002,
113
97
  });
98
+
99
+ for (const size of [-1, Number.MAX_SAFE_INTEGER + 1, null]) {
100
+ await expect(
101
+ env.DB.prepare("UPDATE bundles SET archive_byte_size = ?")
102
+ .bind(size)
103
+ .run(),
104
+ ).rejects.toThrow(/constraint failed/);
105
+ await expect(
106
+ env.DB.prepare("UPDATE bundle_patches SET byte_size = ?")
107
+ .bind(size)
108
+ .run(),
109
+ ).rejects.toThrow(/constraint failed/);
110
+ }
111
+
112
+ await expect(
113
+ env.DB.prepare(`
114
+ INSERT INTO bundles (id, platform, file_hash, storage_uri)
115
+ VALUES ('missing-size', 'ios', 'hash', 'storage://bundle')
116
+ `).run(),
117
+ ).rejects.toThrow(/NOT NULL constraint failed/);
118
+ await expect(
119
+ env.DB.prepare(`
120
+ INSERT INTO bundle_patches (
121
+ id, bundle_id, base_bundle_id, base_file_hash, patch_file_hash,
122
+ patch_storage_uri
123
+ ) VALUES (
124
+ 'missing-size', '00000000-0000-0000-0000-000000000001',
125
+ '00000000-0000-0000-0000-000000000001', 'base-hash', 'patch-hash',
126
+ 'storage://patch'
127
+ )
128
+ `).run(),
129
+ ).rejects.toThrow(/NOT NULL constraint failed/);
114
130
  });
@@ -1,11 +0,0 @@
1
- ALTER TABLE bundles
2
- ADD COLUMN archive_byte_size REAL NOT NULL DEFAULT 0
3
- CONSTRAINT bundles_archive_byte_size_check CHECK (
4
- archive_byte_size BETWEEN 0 AND 9007199254740991
5
- );
6
-
7
- ALTER TABLE bundle_patches
8
- ADD COLUMN byte_size REAL NOT NULL DEFAULT 0
9
- CONSTRAINT bundle_patches_byte_size_check CHECK (
10
- byte_size BETWEEN 0 AND 9007199254740991
11
- );