@_nazmiforreal/flutter-ota 0.1.0 → 0.1.2
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/bin/flutter-patcher.js +48 -39
- package/dart-src/packages/cli-tools/.gitkeep +0 -0
- package/dart-src/packages/cli-tools/bin/flutter_patcher.dart +9 -0
- package/dart-src/packages/cli-tools/lib/flutter_patcher_cli.dart +73 -0
- package/dart-src/packages/cli-tools/lib/src/backend.dart +162 -0
- package/dart-src/packages/cli-tools/lib/src/cli_base.dart +56 -0
- package/dart-src/packages/cli-tools/lib/src/commands/build.dart +99 -0
- package/dart-src/packages/cli-tools/lib/src/commands/bundle.dart +151 -0
- package/dart-src/packages/cli-tools/lib/src/commands/channel.dart +140 -0
- package/dart-src/packages/cli-tools/lib/src/commands/config_command.dart +113 -0
- package/dart-src/packages/cli-tools/lib/src/commands/console.dart +55 -0
- package/dart-src/packages/cli-tools/lib/src/commands/deploy.dart +95 -0
- package/dart-src/packages/cli-tools/lib/src/commands/doctor.dart +48 -0
- package/dart-src/packages/cli-tools/lib/src/commands/fingerprint.dart +29 -0
- package/dart-src/packages/cli-tools/lib/src/commands/init.dart +82 -0
- package/dart-src/packages/cli-tools/lib/src/commands/keys.dart +55 -0
- package/dart-src/packages/cli-tools/lib/src/commands/migrate.dart +132 -0
- package/dart-src/packages/cli-tools/lib/src/commands/rollback.dart +41 -0
- package/dart-src/packages/cli-tools/lib/src/config.dart +715 -0
- package/dart-src/packages/cli-tools/lib/src/operations.dart +206 -0
- package/dart-src/packages/cli-tools/lib/src/pack.dart +417 -0
- package/dart-src/packages/cli-tools/lib/src/sign.dart +60 -0
- package/dart-src/packages/cli-tools/lib/src/util.dart +86 -0
- package/dart-src/packages/cli-tools/migrations/cloudflare/0001_hot-updater_init.sql +16 -0
- package/dart-src/packages/cli-tools/migrations/cloudflare/0002_hot-updater_0.13.0.sql +8 -0
- package/dart-src/packages/cli-tools/migrations/cloudflare/0003_hot-updater_0.18.0.sql +38 -0
- package/dart-src/packages/cli-tools/migrations/cloudflare/0004_hot-updater_0.29.0.sql +11 -0
- package/dart-src/packages/cli-tools/migrations/cloudflare/0005_hot-updater_0.31.0.sql +24 -0
- package/dart-src/packages/cli-tools/migrations/cloudflare/bundles.sql +42 -0
- package/dart-src/packages/cli-tools/migrations/supabase/20250103114225_init.sql +228 -0
- package/dart-src/packages/cli-tools/migrations/supabase/20250314000000_hot-updater_0.13.0.sql +134 -0
- package/dart-src/packages/cli-tools/migrations/supabase/20250516000000_hot-updater_0.18.0.sql +194 -0
- package/dart-src/packages/cli-tools/migrations/supabase/20251014000000_hot-updater_0.21.0.sql +184 -0
- package/dart-src/packages/cli-tools/migrations/supabase/20260401000000_hot-updater_0.29.0.sql +503 -0
- package/dart-src/packages/cli-tools/migrations/supabase/20260414000000_hot-updater_0.30.0.sql +50 -0
- package/dart-src/packages/cli-tools/migrations/supabase/20260422000000_hot-updater_0.31.0.sql +20 -0
- package/dart-src/packages/cli-tools/migrations/supabase/20260520014100_hot-updater_rls.sql +48 -0
- package/dart-src/packages/cli-tools/pubspec.yaml +37 -0
- package/dart-src/packages/core/lib/flutter_patcher_core.dart +29 -0
- package/dart-src/packages/core/lib/src/app_update_info.dart +111 -0
- package/dart-src/packages/core/lib/src/bundle.dart +191 -0
- package/dart-src/packages/core/lib/src/bundle_artifacts.dart +39 -0
- package/dart-src/packages/core/lib/src/bundle_patch_artifact.dart +47 -0
- package/dart-src/packages/core/lib/src/changed_asset.dart +77 -0
- package/dart-src/packages/core/lib/src/get_bundles_args.dart +78 -0
- package/dart-src/packages/core/lib/src/metadata.dart +31 -0
- package/dart-src/packages/core/lib/src/patch_info.dart +284 -0
- package/dart-src/packages/core/lib/src/platform.dart +15 -0
- package/dart-src/packages/core/lib/src/rollout.dart +209 -0
- package/dart-src/packages/core/lib/src/semver.dart +70 -0
- package/dart-src/packages/core/lib/src/semver_range.dart +358 -0
- package/dart-src/packages/core/lib/src/semver_version.dart +94 -0
- package/dart-src/packages/core/lib/src/status.dart +24 -0
- package/dart-src/packages/core/lib/src/strategy.dart +10 -0
- package/dart-src/packages/core/lib/src/update_bundle_params.dart +30 -0
- package/dart-src/packages/core/lib/src/uuid.dart +45 -0
- package/dart-src/packages/core/pubspec.yaml +9 -0
- package/dart-src/packages/core/tool/dbg.dart +6 -0
- package/dart-src/plugins/aws/.gitkeep +0 -0
- package/dart-src/plugins/aws/lib/flutter_patcher_aws.dart +12 -0
- package/dart-src/plugins/aws/lib/src/aws_cloudfront_client.dart +207 -0
- package/dart-src/plugins/aws/lib/src/aws_cloudfront_signer.dart +130 -0
- package/dart-src/plugins/aws/lib/src/aws_config.dart +59 -0
- package/dart-src/plugins/aws/lib/src/aws_database.dart +198 -0
- package/dart-src/plugins/aws/lib/src/aws_lambda_edge_storage.dart +72 -0
- package/dart-src/plugins/aws/lib/src/aws_s3_client.dart +312 -0
- package/dart-src/plugins/aws/lib/src/aws_ssm_client.dart +125 -0
- package/dart-src/plugins/aws/lib/src/aws_storage.dart +20 -0
- package/dart-src/plugins/aws/lib/src/aws_storage_profile.dart +123 -0
- package/dart-src/plugins/aws/lib/src/with_cloudfront_signed_url.dart +136 -0
- package/dart-src/plugins/aws/pubspec.yaml +22 -0
- package/dart-src/plugins/cloudflare/.gitkeep +0 -0
- package/dart-src/plugins/cloudflare/lib/flutter_patcher_cloudflare.dart +18 -0
- package/dart-src/plugins/cloudflare/lib/src/cloudflare_worker_database.dart +29 -0
- package/dart-src/plugins/cloudflare/lib/src/d1_build_where.dart +93 -0
- package/dart-src/plugins/cloudflare/lib/src/d1_bundle_mapper.dart +131 -0
- package/dart-src/plugins/cloudflare/lib/src/d1_client.dart +66 -0
- package/dart-src/plugins/cloudflare/lib/src/d1_config.dart +30 -0
- package/dart-src/plugins/cloudflare/lib/src/d1_database.dart +16 -0
- package/dart-src/plugins/cloudflare/lib/src/d1_database_plugin.dart +314 -0
- package/dart-src/plugins/cloudflare/lib/src/r2_config.dart +50 -0
- package/dart-src/plugins/cloudflare/lib/src/r2_s3_client.dart +287 -0
- package/dart-src/plugins/cloudflare/lib/src/r2_storage.dart +23 -0
- package/dart-src/plugins/cloudflare/lib/src/r2_storage_profile.dart +110 -0
- package/dart-src/plugins/cloudflare/migrations/0001_hot-updater_init.sql +16 -0
- package/dart-src/plugins/cloudflare/migrations/0002_hot-updater_0.13.0.sql +8 -0
- package/dart-src/plugins/cloudflare/migrations/0003_hot-updater_0.18.0.sql +38 -0
- package/dart-src/plugins/cloudflare/migrations/0004_hot-updater_0.29.0.sql +11 -0
- package/dart-src/plugins/cloudflare/migrations/0005_hot-updater_0.31.0.sql +24 -0
- package/dart-src/plugins/cloudflare/pubspec.yaml +20 -0
- package/dart-src/plugins/cloudflare/sql/bundles.sql +42 -0
- package/dart-src/plugins/plugin-core/lib/flutter_patcher_plugin_core.dart +42 -0
- package/dart-src/plugins/plugin-core/lib/src/asset_storage_layout.dart +94 -0
- package/dart-src/plugins/plugin-core/lib/src/bundle_storage_layout.dart +44 -0
- package/dart-src/plugins/plugin-core/lib/src/bundle_unit_of_work.dart +259 -0
- package/dart-src/plugins/plugin-core/lib/src/bundle_unit_of_work_store.dart +20 -0
- package/dart-src/plugins/plugin-core/lib/src/calculate_pagination.dart +29 -0
- package/dart-src/plugins/plugin-core/lib/src/compression_format.dart +63 -0
- package/dart-src/plugins/plugin-core/lib/src/content_addressed_assets.dart +22 -0
- package/dart-src/plugins/plugin-core/lib/src/create_blob_database_plugin.dart +853 -0
- package/dart-src/plugins/plugin-core/lib/src/create_database_plugin.dart +525 -0
- package/dart-src/plugins/plugin-core/lib/src/create_storage_key_builder.dart +15 -0
- package/dart-src/plugins/plugin-core/lib/src/create_storage_plugin.dart +130 -0
- package/dart-src/plugins/plugin-core/lib/src/filter_compatible_app_versions.dart +18 -0
- package/dart-src/plugins/plugin-core/lib/src/generate_min_bundle_id.dart +19 -0
- package/dart-src/plugins/plugin-core/lib/src/get_update_info.dart +241 -0
- package/dart-src/plugins/plugin-core/lib/src/is_object.dart +5 -0
- package/dart-src/plugins/plugin-core/lib/src/legacy_asset_storage_layout.dart +9 -0
- package/dart-src/plugins/plugin-core/lib/src/paginate_bundles.dart +112 -0
- package/dart-src/plugins/plugin-core/lib/src/parse_storage_uri.dart +44 -0
- package/dart-src/plugins/plugin-core/lib/src/query_bundles.dart +70 -0
- package/dart-src/plugins/plugin-core/lib/src/request_update_bundle_state.dart +62 -0
- package/dart-src/plugins/plugin-core/lib/src/resolve_update_info_from_bundles.dart +43 -0
- package/dart-src/plugins/plugin-core/lib/src/storage_profile.dart +27 -0
- package/dart-src/plugins/plugin-core/lib/src/types.dart +454 -0
- package/dart-src/plugins/plugin-core/lib/src/uuidv7.dart +41 -0
- package/dart-src/plugins/plugin-core/pubspec.yaml +15 -0
- package/dart-src/plugins/postgres/.gitkeep +0 -0
- package/dart-src/plugins/postgres/lib/flutter_patcher_postgres.dart +17 -0
- package/dart-src/plugins/postgres/lib/src/postgres_bundle_mapper.dart +130 -0
- package/dart-src/plugins/postgres/lib/src/postgres_client.dart +90 -0
- package/dart-src/plugins/postgres/lib/src/postgres_config.dart +35 -0
- package/dart-src/plugins/postgres/lib/src/postgres_database.dart +302 -0
- package/dart-src/plugins/postgres/lib/src/postgres_get_update_info.dart +120 -0
- package/dart-src/plugins/postgres/lib/src/postgres_storage.dart +205 -0
- package/dart-src/plugins/postgres/lib/src/postgres_types.dart +132 -0
- package/dart-src/plugins/postgres/pubspec.yaml +18 -0
- package/dart-src/plugins/postgres/sql/bundles.sql +45 -0
- package/dart-src/plugins/postgres/sql/get_target_app_version_list.sql +21 -0
- package/dart-src/plugins/postgres/sql/get_update_info.spec.ts +171 -0
- package/dart-src/plugins/postgres/sql/get_update_info_by_app_version.sql +126 -0
- package/dart-src/plugins/postgres/sql/get_update_info_by_fingerprint_hash.sql +125 -0
- package/dart-src/plugins/postgres/sql/hash_user_id.sql +30 -0
- package/dart-src/plugins/postgres/sql/is_device_eligible.sql +237 -0
- package/dart-src/plugins/postgres/sql/prepareSql.ts +11 -0
- package/dart-src/plugins/standalone/.gitkeep +0 -0
- package/dart-src/plugins/standalone/lib/flutter_patcher_standalone.dart +12 -0
- package/dart-src/plugins/standalone/lib/src/standalone_config.dart +107 -0
- package/dart-src/plugins/standalone/lib/src/standalone_database.dart +233 -0
- package/dart-src/plugins/standalone/lib/src/standalone_storage.dart +175 -0
- package/dart-src/plugins/standalone/pubspec.yaml +18 -0
- package/dart-src/plugins/supabase/lib/edge.dart +10 -0
- package/dart-src/plugins/supabase/lib/flutter_patcher_supabase.dart +21 -0
- package/dart-src/plugins/supabase/lib/src/supabase_bundle_mapper.dart +129 -0
- package/dart-src/plugins/supabase/lib/src/supabase_client_adapter.dart +154 -0
- package/dart-src/plugins/supabase/lib/src/supabase_client_http.dart +516 -0
- package/dart-src/plugins/supabase/lib/src/supabase_config.dart +34 -0
- package/dart-src/plugins/supabase/lib/src/supabase_database.dart +422 -0
- package/dart-src/plugins/supabase/lib/src/supabase_edge_function_database.dart +32 -0
- package/dart-src/plugins/supabase/lib/src/supabase_edge_function_storage.dart +99 -0
- package/dart-src/plugins/supabase/lib/src/supabase_signed_url_batcher.dart +145 -0
- package/dart-src/plugins/supabase/lib/src/supabase_storage.dart +298 -0
- package/dart-src/plugins/supabase/lib/src/types.dart +130 -0
- package/dart-src/plugins/supabase/pubspec.yaml +19 -0
- package/dart-src/plugins/supabase/supabase/edge-functions/index.ts +44 -0
- package/dart-src/plugins/supabase/supabase/edge-functions/runtime.docker.integration.spec.ts +968 -0
- package/dart-src/plugins/supabase/supabase/migrations/20250103114225_init.sql +228 -0
- package/dart-src/plugins/supabase/supabase/migrations/20250314000000_hot-updater_0.13.0.sql +134 -0
- package/dart-src/plugins/supabase/supabase/migrations/20250516000000_hot-updater_0.18.0.sql +194 -0
- package/dart-src/plugins/supabase/supabase/migrations/20251014000000_hot-updater_0.21.0.sql +184 -0
- package/dart-src/plugins/supabase/supabase/migrations/20260401000000_hot-updater_0.29.0.sql +503 -0
- package/dart-src/plugins/supabase/supabase/migrations/20260414000000_hot-updater_0.30.0.sql +50 -0
- package/dart-src/plugins/supabase/supabase/migrations/20260422000000_hot-updater_0.31.0.sql +20 -0
- package/dart-src/plugins/supabase/supabase/migrations/20260520014100_hot-updater_rls.sql +48 -0
- package/package.json +2 -1
- package/scripts/postinstall.js +53 -25
- /package/bin/{flutter-patcher-linux → flutter-patcher-linux-x64} +0 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
|
|
2
|
+
ALTER TABLE bundles ADD COLUMN IF NOT EXISTS fingerprint_hash text;
|
|
3
|
+
ALTER TABLE bundles ADD COLUMN IF NOT EXISTS metadata JSONB DEFAULT '{}'::jsonb;
|
|
4
|
+
|
|
5
|
+
ALTER TABLE bundles ADD COLUMN IF NOT EXISTS storage_uri TEXT;
|
|
6
|
+
|
|
7
|
+
UPDATE bundles
|
|
8
|
+
SET storage_uri = 'supabase-storage://%%BUCKET_NAME%%/' || id || '/bundle.zip'
|
|
9
|
+
WHERE storage_uri IS NULL;
|
|
10
|
+
|
|
11
|
+
ALTER TABLE bundles ALTER COLUMN storage_uri SET NOT NULL;
|
|
12
|
+
ALTER TABLE bundles ALTER COLUMN target_app_version DROP NOT NULL;
|
|
13
|
+
|
|
14
|
+
ALTER TABLE bundles ADD CONSTRAINT check_version_or_fingerprint CHECK (
|
|
15
|
+
(target_app_version IS NOT NULL) OR (fingerprint_hash IS NOT NULL)
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
CREATE INDEX bundles_fingerprint_hash_idx ON bundles(fingerprint_hash);
|
|
19
|
+
|
|
20
|
+
DROP FUNCTION IF EXISTS get_update_info;
|
|
21
|
+
|
|
22
|
+
-- HotUpdater.get_update_info
|
|
23
|
+
CREATE OR REPLACE FUNCTION get_update_info_by_fingerprint_hash (
|
|
24
|
+
app_platform platforms,
|
|
25
|
+
bundle_id uuid,
|
|
26
|
+
min_bundle_id uuid,
|
|
27
|
+
target_channel text,
|
|
28
|
+
target_fingerprint_hash text
|
|
29
|
+
)
|
|
30
|
+
RETURNS TABLE (
|
|
31
|
+
id uuid,
|
|
32
|
+
should_force_update boolean,
|
|
33
|
+
message text,
|
|
34
|
+
status text,
|
|
35
|
+
storage_uri text
|
|
36
|
+
)
|
|
37
|
+
LANGUAGE plpgsql
|
|
38
|
+
AS
|
|
39
|
+
$$
|
|
40
|
+
DECLARE
|
|
41
|
+
NIL_UUID CONSTANT uuid := '00000000-0000-0000-0000-000000000000';
|
|
42
|
+
BEGIN
|
|
43
|
+
RETURN QUERY
|
|
44
|
+
WITH update_candidate AS (
|
|
45
|
+
SELECT
|
|
46
|
+
b.id,
|
|
47
|
+
b.should_force_update,
|
|
48
|
+
b.message,
|
|
49
|
+
'UPDATE' AS status,
|
|
50
|
+
b.storage_uri
|
|
51
|
+
FROM bundles b
|
|
52
|
+
WHERE b.enabled = TRUE
|
|
53
|
+
AND b.platform = app_platform
|
|
54
|
+
AND b.id >= bundle_id
|
|
55
|
+
AND b.id > min_bundle_id
|
|
56
|
+
AND b.channel = target_channel
|
|
57
|
+
AND b.fingerprint_hash = target_fingerprint_hash
|
|
58
|
+
ORDER BY b.id DESC
|
|
59
|
+
LIMIT 1
|
|
60
|
+
),
|
|
61
|
+
rollback_candidate AS (
|
|
62
|
+
SELECT
|
|
63
|
+
b.id,
|
|
64
|
+
TRUE AS should_force_update,
|
|
65
|
+
b.message,
|
|
66
|
+
'ROLLBACK' AS status,
|
|
67
|
+
b.storage_uri
|
|
68
|
+
FROM bundles b
|
|
69
|
+
WHERE b.enabled = TRUE
|
|
70
|
+
AND b.platform = app_platform
|
|
71
|
+
AND b.id < bundle_id
|
|
72
|
+
AND b.id > min_bundle_id
|
|
73
|
+
AND b.channel = target_channel
|
|
74
|
+
AND b.fingerprint_hash = target_fingerprint_hash
|
|
75
|
+
ORDER BY b.id DESC
|
|
76
|
+
LIMIT 1
|
|
77
|
+
),
|
|
78
|
+
final_result AS (
|
|
79
|
+
SELECT * FROM update_candidate
|
|
80
|
+
UNION ALL
|
|
81
|
+
SELECT * FROM rollback_candidate
|
|
82
|
+
WHERE NOT EXISTS (SELECT 1 FROM update_candidate)
|
|
83
|
+
)
|
|
84
|
+
SELECT *
|
|
85
|
+
FROM final_result
|
|
86
|
+
WHERE final_result.id != bundle_id
|
|
87
|
+
|
|
88
|
+
UNION ALL
|
|
89
|
+
|
|
90
|
+
SELECT
|
|
91
|
+
NIL_UUID AS id,
|
|
92
|
+
TRUE AS should_force_update,
|
|
93
|
+
NULL AS message,
|
|
94
|
+
'ROLLBACK' AS status,
|
|
95
|
+
NULL AS storage_uri
|
|
96
|
+
WHERE (SELECT COUNT(*) FROM final_result) = 0
|
|
97
|
+
AND bundle_id != NIL_UUID
|
|
98
|
+
AND bundle_id > min_bundle_id
|
|
99
|
+
AND NOT EXISTS (
|
|
100
|
+
SELECT 1
|
|
101
|
+
FROM bundles b
|
|
102
|
+
WHERE b.id = bundle_id
|
|
103
|
+
AND b.enabled = TRUE
|
|
104
|
+
AND b.platform = app_platform
|
|
105
|
+
);
|
|
106
|
+
END;
|
|
107
|
+
$$;
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
-- HotUpdater.get_update_info
|
|
111
|
+
CREATE OR REPLACE FUNCTION get_update_info_by_app_version (
|
|
112
|
+
app_platform platforms,
|
|
113
|
+
app_version text,
|
|
114
|
+
bundle_id uuid,
|
|
115
|
+
min_bundle_id uuid,
|
|
116
|
+
target_channel text,
|
|
117
|
+
target_app_version_list text[]
|
|
118
|
+
)
|
|
119
|
+
RETURNS TABLE (
|
|
120
|
+
id uuid,
|
|
121
|
+
should_force_update boolean,
|
|
122
|
+
message text,
|
|
123
|
+
status text,
|
|
124
|
+
storage_uri text
|
|
125
|
+
)
|
|
126
|
+
LANGUAGE plpgsql
|
|
127
|
+
AS
|
|
128
|
+
$$
|
|
129
|
+
DECLARE
|
|
130
|
+
NIL_UUID CONSTANT uuid := '00000000-0000-0000-0000-000000000000';
|
|
131
|
+
BEGIN
|
|
132
|
+
RETURN QUERY
|
|
133
|
+
WITH update_candidate AS (
|
|
134
|
+
SELECT
|
|
135
|
+
b.id,
|
|
136
|
+
b.should_force_update,
|
|
137
|
+
b.message,
|
|
138
|
+
'UPDATE' AS status,
|
|
139
|
+
b.storage_uri
|
|
140
|
+
FROM bundles b
|
|
141
|
+
WHERE b.enabled = TRUE
|
|
142
|
+
AND b.platform = app_platform
|
|
143
|
+
AND b.id >= bundle_id
|
|
144
|
+
AND b.id > min_bundle_id
|
|
145
|
+
AND b.target_app_version IN (SELECT unnest(target_app_version_list))
|
|
146
|
+
AND b.channel = target_channel
|
|
147
|
+
ORDER BY b.id DESC
|
|
148
|
+
LIMIT 1
|
|
149
|
+
),
|
|
150
|
+
rollback_candidate AS (
|
|
151
|
+
SELECT
|
|
152
|
+
b.id,
|
|
153
|
+
TRUE AS should_force_update,
|
|
154
|
+
b.message,
|
|
155
|
+
'ROLLBACK' AS status,
|
|
156
|
+
b.storage_uri
|
|
157
|
+
FROM bundles b
|
|
158
|
+
WHERE b.enabled = TRUE
|
|
159
|
+
AND b.platform = app_platform
|
|
160
|
+
AND b.id < bundle_id
|
|
161
|
+
AND b.id > min_bundle_id
|
|
162
|
+
ORDER BY b.id DESC
|
|
163
|
+
LIMIT 1
|
|
164
|
+
),
|
|
165
|
+
final_result AS (
|
|
166
|
+
SELECT * FROM update_candidate
|
|
167
|
+
UNION ALL
|
|
168
|
+
SELECT * FROM rollback_candidate
|
|
169
|
+
WHERE NOT EXISTS (SELECT 1 FROM update_candidate)
|
|
170
|
+
)
|
|
171
|
+
SELECT *
|
|
172
|
+
FROM final_result
|
|
173
|
+
WHERE final_result.id != bundle_id
|
|
174
|
+
|
|
175
|
+
UNION ALL
|
|
176
|
+
|
|
177
|
+
SELECT
|
|
178
|
+
NIL_UUID AS id,
|
|
179
|
+
TRUE AS should_force_update,
|
|
180
|
+
NULL AS message,
|
|
181
|
+
'ROLLBACK' AS status,
|
|
182
|
+
NULL AS storage_uri
|
|
183
|
+
WHERE (SELECT COUNT(*) FROM final_result) = 0
|
|
184
|
+
AND bundle_id != NIL_UUID
|
|
185
|
+
AND bundle_id > min_bundle_id
|
|
186
|
+
AND NOT EXISTS (
|
|
187
|
+
SELECT 1
|
|
188
|
+
FROM bundles b
|
|
189
|
+
WHERE b.id = bundle_id
|
|
190
|
+
AND b.enabled = TRUE
|
|
191
|
+
AND b.platform = app_platform
|
|
192
|
+
);
|
|
193
|
+
END;
|
|
194
|
+
$$;
|
|
@@ -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
|
+
$$;
|