@hot-updater/supabase 0.20.14 → 0.21.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 +28 -1350
- package/dist/index.js +29 -1351
- package/package.json +8 -6
- package/supabase/edge-functions/index.ts +1 -0
- package/supabase/migrations/20251014000000_hot-updater_0.21.0.sql +184 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/supabase",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.21.0",
|
|
5
5
|
"description": "React Native OTA solution for self-hosted",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"types": "./dist/iac/index.d.ts",
|
|
20
20
|
"import": "./dist/iac/index.js",
|
|
21
21
|
"require": "./dist/iac/index.cjs"
|
|
22
|
-
}
|
|
22
|
+
},
|
|
23
|
+
"./package.json": "./package.json"
|
|
23
24
|
},
|
|
24
25
|
"license": "MIT",
|
|
25
26
|
"repository": "https://github.com/gronxb/hot-updater",
|
|
@@ -39,18 +40,19 @@
|
|
|
39
40
|
"package.json"
|
|
40
41
|
],
|
|
41
42
|
"dependencies": {
|
|
42
|
-
"@supabase/supabase-js": "^2.
|
|
43
|
-
"@hot-updater/core": "0.
|
|
44
|
-
"@hot-updater/plugin-core": "0.
|
|
43
|
+
"@supabase/supabase-js": "^2.76.1",
|
|
44
|
+
"@hot-updater/core": "0.21.0",
|
|
45
|
+
"@hot-updater/plugin-core": "0.21.0"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"@clack/prompts": "0.10.0",
|
|
48
49
|
"dayjs": "^1.11.13",
|
|
49
50
|
"es-toolkit": "^1.32.0",
|
|
50
51
|
"execa": "9.5.2",
|
|
52
|
+
"@types/node": "^20",
|
|
51
53
|
"mime": "^4.0.4",
|
|
52
54
|
"picocolors": "1.1.1",
|
|
53
|
-
"@hot-updater/postgres": "0.
|
|
55
|
+
"@hot-updater/postgres": "0.21.0"
|
|
54
56
|
},
|
|
55
57
|
"scripts": {
|
|
56
58
|
"build": "tsdown",
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
DROP FUNCTION IF EXISTS get_update_info_by_fingerprint_hash;
|
|
2
|
+
DROP FUNCTION IF EXISTS get_update_info_by_app_version;
|
|
3
|
+
|
|
4
|
+
-- HotUpdater.get_update_info
|
|
5
|
+
CREATE OR REPLACE FUNCTION get_update_info_by_fingerprint_hash (
|
|
6
|
+
app_platform platforms,
|
|
7
|
+
bundle_id uuid,
|
|
8
|
+
min_bundle_id uuid,
|
|
9
|
+
target_channel text,
|
|
10
|
+
target_fingerprint_hash text
|
|
11
|
+
)
|
|
12
|
+
RETURNS TABLE (
|
|
13
|
+
id uuid,
|
|
14
|
+
should_force_update boolean,
|
|
15
|
+
message text,
|
|
16
|
+
status text,
|
|
17
|
+
storage_uri text,
|
|
18
|
+
file_hash text
|
|
19
|
+
)
|
|
20
|
+
LANGUAGE plpgsql
|
|
21
|
+
AS
|
|
22
|
+
$$
|
|
23
|
+
DECLARE
|
|
24
|
+
NIL_UUID CONSTANT uuid := '00000000-0000-0000-0000-000000000000';
|
|
25
|
+
BEGIN
|
|
26
|
+
RETURN QUERY
|
|
27
|
+
WITH update_candidate AS (
|
|
28
|
+
SELECT
|
|
29
|
+
b.id,
|
|
30
|
+
b.should_force_update,
|
|
31
|
+
b.message,
|
|
32
|
+
'UPDATE' AS status,
|
|
33
|
+
b.storage_uri,
|
|
34
|
+
b.file_hash
|
|
35
|
+
FROM bundles b
|
|
36
|
+
WHERE b.enabled = TRUE
|
|
37
|
+
AND b.platform = app_platform
|
|
38
|
+
AND b.id >= bundle_id
|
|
39
|
+
AND b.id > min_bundle_id
|
|
40
|
+
AND b.channel = target_channel
|
|
41
|
+
AND b.fingerprint_hash = target_fingerprint_hash
|
|
42
|
+
ORDER BY b.id DESC
|
|
43
|
+
LIMIT 1
|
|
44
|
+
),
|
|
45
|
+
rollback_candidate AS (
|
|
46
|
+
SELECT
|
|
47
|
+
b.id,
|
|
48
|
+
TRUE AS should_force_update,
|
|
49
|
+
b.message,
|
|
50
|
+
'ROLLBACK' AS status,
|
|
51
|
+
b.storage_uri,
|
|
52
|
+
b.file_hash
|
|
53
|
+
FROM bundles b
|
|
54
|
+
WHERE b.enabled = TRUE
|
|
55
|
+
AND b.platform = app_platform
|
|
56
|
+
AND b.id < bundle_id
|
|
57
|
+
AND b.id > min_bundle_id
|
|
58
|
+
AND b.channel = target_channel
|
|
59
|
+
AND b.fingerprint_hash = target_fingerprint_hash
|
|
60
|
+
ORDER BY b.id DESC
|
|
61
|
+
LIMIT 1
|
|
62
|
+
),
|
|
63
|
+
final_result AS (
|
|
64
|
+
SELECT * FROM update_candidate
|
|
65
|
+
UNION ALL
|
|
66
|
+
SELECT * FROM rollback_candidate
|
|
67
|
+
WHERE NOT EXISTS (SELECT 1 FROM update_candidate)
|
|
68
|
+
)
|
|
69
|
+
SELECT *
|
|
70
|
+
FROM final_result
|
|
71
|
+
WHERE final_result.id != bundle_id
|
|
72
|
+
|
|
73
|
+
UNION ALL
|
|
74
|
+
|
|
75
|
+
SELECT
|
|
76
|
+
NIL_UUID AS id,
|
|
77
|
+
TRUE AS should_force_update,
|
|
78
|
+
NULL AS message,
|
|
79
|
+
'ROLLBACK' AS status,
|
|
80
|
+
NULL AS storage_uri,
|
|
81
|
+
NULL AS file_hash
|
|
82
|
+
WHERE (SELECT COUNT(*) FROM final_result) = 0
|
|
83
|
+
AND bundle_id != NIL_UUID
|
|
84
|
+
AND bundle_id > min_bundle_id
|
|
85
|
+
AND NOT EXISTS (
|
|
86
|
+
SELECT 1
|
|
87
|
+
FROM bundles b
|
|
88
|
+
WHERE b.id = bundle_id
|
|
89
|
+
AND b.enabled = TRUE
|
|
90
|
+
AND b.platform = app_platform
|
|
91
|
+
);
|
|
92
|
+
END;
|
|
93
|
+
$$;
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
-- HotUpdater.get_update_info
|
|
97
|
+
CREATE OR REPLACE FUNCTION get_update_info_by_app_version (
|
|
98
|
+
app_platform platforms,
|
|
99
|
+
app_version text,
|
|
100
|
+
bundle_id uuid,
|
|
101
|
+
min_bundle_id uuid,
|
|
102
|
+
target_channel text,
|
|
103
|
+
target_app_version_list text[]
|
|
104
|
+
)
|
|
105
|
+
RETURNS TABLE (
|
|
106
|
+
id uuid,
|
|
107
|
+
should_force_update boolean,
|
|
108
|
+
message text,
|
|
109
|
+
status text,
|
|
110
|
+
storage_uri text,
|
|
111
|
+
file_hash text
|
|
112
|
+
)
|
|
113
|
+
LANGUAGE plpgsql
|
|
114
|
+
AS
|
|
115
|
+
$$
|
|
116
|
+
DECLARE
|
|
117
|
+
NIL_UUID CONSTANT uuid := '00000000-0000-0000-0000-000000000000';
|
|
118
|
+
BEGIN
|
|
119
|
+
RETURN QUERY
|
|
120
|
+
WITH update_candidate AS (
|
|
121
|
+
SELECT
|
|
122
|
+
b.id,
|
|
123
|
+
b.should_force_update,
|
|
124
|
+
b.message,
|
|
125
|
+
'UPDATE' AS status,
|
|
126
|
+
b.storage_uri,
|
|
127
|
+
b.file_hash
|
|
128
|
+
FROM bundles b
|
|
129
|
+
WHERE b.enabled = TRUE
|
|
130
|
+
AND b.platform = app_platform
|
|
131
|
+
AND b.id >= bundle_id
|
|
132
|
+
AND b.id > min_bundle_id
|
|
133
|
+
AND b.target_app_version IN (SELECT unnest(target_app_version_list))
|
|
134
|
+
AND b.channel = target_channel
|
|
135
|
+
ORDER BY b.id DESC
|
|
136
|
+
LIMIT 1
|
|
137
|
+
),
|
|
138
|
+
rollback_candidate AS (
|
|
139
|
+
SELECT
|
|
140
|
+
b.id,
|
|
141
|
+
TRUE AS should_force_update,
|
|
142
|
+
b.message,
|
|
143
|
+
'ROLLBACK' AS status,
|
|
144
|
+
b.storage_uri,
|
|
145
|
+
b.file_hash
|
|
146
|
+
FROM bundles b
|
|
147
|
+
WHERE b.enabled = TRUE
|
|
148
|
+
AND b.platform = app_platform
|
|
149
|
+
AND b.id < bundle_id
|
|
150
|
+
AND b.id > min_bundle_id
|
|
151
|
+
ORDER BY b.id DESC
|
|
152
|
+
LIMIT 1
|
|
153
|
+
),
|
|
154
|
+
final_result AS (
|
|
155
|
+
SELECT * FROM update_candidate
|
|
156
|
+
UNION ALL
|
|
157
|
+
SELECT * FROM rollback_candidate
|
|
158
|
+
WHERE NOT EXISTS (SELECT 1 FROM update_candidate)
|
|
159
|
+
)
|
|
160
|
+
SELECT *
|
|
161
|
+
FROM final_result
|
|
162
|
+
WHERE final_result.id != bundle_id
|
|
163
|
+
|
|
164
|
+
UNION ALL
|
|
165
|
+
|
|
166
|
+
SELECT
|
|
167
|
+
NIL_UUID AS id,
|
|
168
|
+
TRUE AS should_force_update,
|
|
169
|
+
NULL AS message,
|
|
170
|
+
'ROLLBACK' AS status,
|
|
171
|
+
NULL AS storage_uri,
|
|
172
|
+
NULL AS file_hash
|
|
173
|
+
WHERE (SELECT COUNT(*) FROM final_result) = 0
|
|
174
|
+
AND bundle_id != NIL_UUID
|
|
175
|
+
AND bundle_id > min_bundle_id
|
|
176
|
+
AND NOT EXISTS (
|
|
177
|
+
SELECT 1
|
|
178
|
+
FROM bundles b
|
|
179
|
+
WHERE b.id = bundle_id
|
|
180
|
+
AND b.enabled = TRUE
|
|
181
|
+
AND b.platform = app_platform
|
|
182
|
+
);
|
|
183
|
+
END;
|
|
184
|
+
$$;
|