@hot-updater/postgres 0.5.3 → 0.5.5

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
@@ -53,7 +53,7 @@ const postgres = (config, hooks)=>(_)=>{
53
53
  id: bundle.id,
54
54
  enabled: bundle.enabled,
55
55
  file_url: bundle.fileUrl,
56
- force_update: bundle.forceUpdate,
56
+ should_force_update: bundle.shouldForceUpdate,
57
57
  file_hash: bundle.fileHash,
58
58
  git_commit_hash: bundle.gitCommitHash,
59
59
  message: bundle.message,
@@ -62,7 +62,7 @@ const postgres = (config, hooks)=>(_)=>{
62
62
  }).onConflict((oc)=>oc.column("id").doUpdateSet({
63
63
  enabled: bundle.enabled,
64
64
  file_url: bundle.fileUrl,
65
- force_update: bundle.forceUpdate,
65
+ should_force_update: bundle.shouldForceUpdate,
66
66
  file_hash: bundle.fileHash,
67
67
  git_commit_hash: bundle.gitCommitHash,
68
68
  message: bundle.message,
@@ -91,7 +91,7 @@ const postgres = (config, hooks)=>(_)=>{
91
91
  return {
92
92
  enabled: data.enabled,
93
93
  fileUrl: data.file_url,
94
- forceUpdate: data.force_update,
94
+ shouldForceUpdate: data.should_force_update,
95
95
  fileHash: data.file_hash,
96
96
  gitCommitHash: data.git_commit_hash,
97
97
  id: data.id,
@@ -106,7 +106,7 @@ const postgres = (config, hooks)=>(_)=>{
106
106
  return data.map((bundle)=>({
107
107
  enabled: bundle.enabled,
108
108
  fileUrl: bundle.file_url,
109
- forceUpdate: bundle.force_update,
109
+ shouldForceUpdate: bundle.should_force_update,
110
110
  fileHash: bundle.file_hash,
111
111
  gitCommitHash: bundle.git_commit_hash,
112
112
  id: bundle.id,
package/dist/index.js CHANGED
@@ -23,7 +23,7 @@ const postgres = (config, hooks)=>(_)=>{
23
23
  id: bundle.id,
24
24
  enabled: bundle.enabled,
25
25
  file_url: bundle.fileUrl,
26
- force_update: bundle.forceUpdate,
26
+ should_force_update: bundle.shouldForceUpdate,
27
27
  file_hash: bundle.fileHash,
28
28
  git_commit_hash: bundle.gitCommitHash,
29
29
  message: bundle.message,
@@ -32,7 +32,7 @@ const postgres = (config, hooks)=>(_)=>{
32
32
  }).onConflict((oc)=>oc.column("id").doUpdateSet({
33
33
  enabled: bundle.enabled,
34
34
  file_url: bundle.fileUrl,
35
- force_update: bundle.forceUpdate,
35
+ should_force_update: bundle.shouldForceUpdate,
36
36
  file_hash: bundle.fileHash,
37
37
  git_commit_hash: bundle.gitCommitHash,
38
38
  message: bundle.message,
@@ -61,7 +61,7 @@ const postgres = (config, hooks)=>(_)=>{
61
61
  return {
62
62
  enabled: data.enabled,
63
63
  fileUrl: data.file_url,
64
- forceUpdate: data.force_update,
64
+ shouldForceUpdate: data.should_force_update,
65
65
  fileHash: data.file_hash,
66
66
  gitCommitHash: data.git_commit_hash,
67
67
  id: data.id,
@@ -76,7 +76,7 @@ const postgres = (config, hooks)=>(_)=>{
76
76
  return data.map((bundle)=>({
77
77
  enabled: bundle.enabled,
78
78
  fileUrl: bundle.file_url,
79
- forceUpdate: bundle.force_update,
79
+ shouldForceUpdate: bundle.should_force_update,
80
80
  fileHash: bundle.file_hash,
81
81
  gitCommitHash: bundle.git_commit_hash,
82
82
  id: bundle.id,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hot-updater/postgres",
3
3
  "type": "module",
4
- "version": "0.5.3",
4
+ "version": "0.5.5",
5
5
  "description": "React Native OTA solution for self-hosted",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.js",
@@ -29,8 +29,8 @@
29
29
  "package.json"
30
30
  ],
31
31
  "dependencies": {
32
- "@hot-updater/core": "0.5.3",
33
- "@hot-updater/plugin-core": "0.5.3",
32
+ "@hot-updater/core": "0.5.5",
33
+ "@hot-updater/plugin-core": "0.5.5",
34
34
  "kysely": "^0.27.5",
35
35
  "pg": "^8.13.1"
36
36
  },
package/sql/bundles.sql CHANGED
@@ -6,7 +6,7 @@ CREATE TABLE bundles (
6
6
  id uuid PRIMARY KEY,
7
7
  platform platforms NOT NULL,
8
8
  target_app_version text NOT NULL,
9
- force_update boolean NOT NULL,
9
+ should_force_update boolean NOT NULL,
10
10
  enabled boolean NOT NULL,
11
11
  file_url text NOT NULL,
12
12
  file_hash text NOT NULL,
@@ -7,7 +7,7 @@ CREATE OR REPLACE FUNCTION get_update_info (
7
7
  )
8
8
  RETURNS TABLE (
9
9
  id uuid,
10
- force_update boolean,
10
+ should_force_update boolean,
11
11
  file_url text,
12
12
  file_hash text,
13
13
  status text
@@ -22,8 +22,8 @@ BEGIN
22
22
  WITH rollback_candidate AS (
23
23
  SELECT
24
24
  b.id,
25
- -- If status is 'ROLLBACK', force_update is always TRUE
26
- TRUE AS force_update,
25
+ -- If status is 'ROLLBACK', should_force_update is always TRUE
26
+ TRUE AS should_force_update,
27
27
  b.file_url,
28
28
  b.file_hash,
29
29
  'ROLLBACK' AS status
@@ -37,7 +37,7 @@ BEGIN
37
37
  update_candidate AS (
38
38
  SELECT
39
39
  b.id,
40
- b.force_update,
40
+ b.should_force_update,
41
41
  b.file_url,
42
42
  b.file_hash,
43
43
  'UPDATE' AS status
@@ -66,11 +66,11 @@ BEGIN
66
66
  /*
67
67
  When there are no final results and bundle_id != NIL_UUID,
68
68
  add one fallback row.
69
- This fallback row is also ROLLBACK so forceUpdate = TRUE.
69
+ This fallback row is also ROLLBACK so shouldForceUpdate = TRUE.
70
70
  */
71
71
  SELECT
72
72
  NIL_UUID AS id,
73
- TRUE AS force_update, -- Always TRUE
73
+ TRUE AS should_force_update, -- Always TRUE
74
74
  NULL AS file_url,
75
75
  NULL AS file_hash,
76
76
  'ROLLBACK' AS status
@@ -9,14 +9,14 @@ const createInsertBundleQuery = (bundle: Bundle) => {
9
9
  return `
10
10
  INSERT INTO bundles (
11
11
  id, file_url, file_hash, platform, target_app_version,
12
- force_update, enabled, git_commit_hash, message
12
+ should_force_update, enabled, git_commit_hash, message
13
13
  ) VALUES (
14
14
  '${bundle.id}',
15
15
  '${bundle.fileUrl}',
16
16
  '${bundle.fileHash}',
17
17
  '${bundle.platform}',
18
18
  '${bundle.targetAppVersion}',
19
- ${bundle.forceUpdate},
19
+ ${bundle.shouldForceUpdate},
20
20
  ${bundle.enabled},
21
21
  ${bundle.gitCommitHash ? `'${bundle.gitCommitHash}'` : "null"},
22
22
  ${bundle.message ? `'${bundle.message}'` : "null"}
@@ -34,7 +34,7 @@ const createGetUpdateInfo =
34
34
 
35
35
  const result = await db.query<{
36
36
  id: string;
37
- force_update: boolean;
37
+ should_force_update: boolean;
38
38
  file_url: string;
39
39
  file_hash: string;
40
40
  status: string;
@@ -89,11 +89,38 @@ BEGIN
89
89
  satisfies := (version >= lower_bound AND version < upper_bound);
90
90
  END;
91
91
 
92
+ -- [Added] 1) Single major version pattern '^(\d+)$'
93
+ ELSIF range_expression ~ '^\d+$' THEN
94
+ /*
95
+ e.g.) "1" is interpreted as (>=1.0.0 <2.0.0) in semver range
96
+ "2" would be interpreted as (>=2.0.0 <3.0.0)
97
+ */
98
+ DECLARE
99
+ major_range INT := range_expression::INT;
100
+ lower_bound TEXT := major_range || '.0.0';
101
+ upper_bound TEXT := (major_range + 1) || '.0.0';
102
+ BEGIN
103
+ satisfies := (version >= lower_bound AND version < upper_bound);
104
+ END;
105
+
106
+ -- [Added] 2) major.x pattern '^(\d+)\.x$'
107
+ ELSIF range_expression ~ '^\d+\.x$' THEN
108
+ /*
109
+ e.g.) "2.x" => as long as major=2 matches, any minor and patch is OK
110
+ effectively works like (>=2.0.0 <3.0.0)
111
+ */
112
+ DECLARE
113
+ major_range INT := split_part(range_expression, '.', 1)::INT;
114
+ lower_bound TEXT := major_range || '.0.0';
115
+ upper_bound TEXT := (major_range + 1) || '.0.0';
116
+ BEGIN
117
+ satisfies := (version >= lower_bound AND version < upper_bound);
118
+ END;
119
+
92
120
  ELSE
93
121
  RAISE EXCEPTION 'Unsupported range expression: %', range_expression;
94
122
  END IF;
95
123
 
96
124
  RETURN satisfies;
97
125
  END;
98
- $$ LANGUAGE plpgsql;
99
-
126
+ $$ LANGUAGE plpgsql;