@hot-updater/postgres 0.18.4 → 0.19.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 +31 -25
- package/dist/index.js +31 -25
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -103,33 +103,39 @@ const postgres = (config, hooks) => {
|
|
|
103
103
|
},
|
|
104
104
|
async commitBundle(context, { changedSets }) {
|
|
105
105
|
if (changedSets.length === 0) return;
|
|
106
|
-
const bundles = changedSets.map((op) => op.data);
|
|
107
106
|
await context.db.transaction().execute(async (tx) => {
|
|
108
|
-
for (const
|
|
109
|
-
id
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
107
|
+
for (const op of changedSets) if (op.operation === "delete") {
|
|
108
|
+
const result = await tx.deleteFrom("bundles").where("id", "=", op.data.id).executeTakeFirst();
|
|
109
|
+
if (result.numDeletedRows === 0n) throw new Error(`Bundle with id ${op.data.id} not found`);
|
|
110
|
+
} else if (op.operation === "insert" || op.operation === "update") {
|
|
111
|
+
const bundle = op.data;
|
|
112
|
+
await tx.insertInto("bundles").values({
|
|
113
|
+
id: bundle.id,
|
|
114
|
+
enabled: bundle.enabled,
|
|
115
|
+
should_force_update: bundle.shouldForceUpdate,
|
|
116
|
+
file_hash: bundle.fileHash,
|
|
117
|
+
git_commit_hash: bundle.gitCommitHash,
|
|
118
|
+
message: bundle.message,
|
|
119
|
+
platform: bundle.platform,
|
|
120
|
+
target_app_version: bundle.targetAppVersion,
|
|
121
|
+
channel: bundle.channel,
|
|
122
|
+
storage_uri: bundle.storageUri,
|
|
123
|
+
fingerprint_hash: bundle.fingerprintHash
|
|
124
|
+
}).onConflict((oc) => oc.column("id").doUpdateSet({
|
|
125
|
+
enabled: bundle.enabled,
|
|
126
|
+
should_force_update: bundle.shouldForceUpdate,
|
|
127
|
+
file_hash: bundle.fileHash,
|
|
128
|
+
git_commit_hash: bundle.gitCommitHash,
|
|
129
|
+
message: bundle.message,
|
|
130
|
+
platform: bundle.platform,
|
|
131
|
+
target_app_version: bundle.targetAppVersion,
|
|
132
|
+
channel: bundle.channel,
|
|
133
|
+
storage_uri: bundle.storageUri,
|
|
134
|
+
fingerprint_hash: bundle.fingerprintHash
|
|
135
|
+
})).execute();
|
|
136
|
+
}
|
|
132
137
|
});
|
|
138
|
+
hooks?.onDatabaseUpdated?.();
|
|
133
139
|
}
|
|
134
140
|
}, hooks);
|
|
135
141
|
};
|
package/dist/index.js
CHANGED
|
@@ -105,33 +105,39 @@ const postgres = (config, hooks) => {
|
|
|
105
105
|
},
|
|
106
106
|
async commitBundle(context, { changedSets }) {
|
|
107
107
|
if (changedSets.length === 0) return;
|
|
108
|
-
const bundles = changedSets.map((op) => op.data);
|
|
109
108
|
await context.db.transaction().execute(async (tx) => {
|
|
110
|
-
for (const
|
|
111
|
-
id
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
109
|
+
for (const op of changedSets) if (op.operation === "delete") {
|
|
110
|
+
const result = await tx.deleteFrom("bundles").where("id", "=", op.data.id).executeTakeFirst();
|
|
111
|
+
if (result.numDeletedRows === 0n) throw new Error(`Bundle with id ${op.data.id} not found`);
|
|
112
|
+
} else if (op.operation === "insert" || op.operation === "update") {
|
|
113
|
+
const bundle = op.data;
|
|
114
|
+
await tx.insertInto("bundles").values({
|
|
115
|
+
id: bundle.id,
|
|
116
|
+
enabled: bundle.enabled,
|
|
117
|
+
should_force_update: bundle.shouldForceUpdate,
|
|
118
|
+
file_hash: bundle.fileHash,
|
|
119
|
+
git_commit_hash: bundle.gitCommitHash,
|
|
120
|
+
message: bundle.message,
|
|
121
|
+
platform: bundle.platform,
|
|
122
|
+
target_app_version: bundle.targetAppVersion,
|
|
123
|
+
channel: bundle.channel,
|
|
124
|
+
storage_uri: bundle.storageUri,
|
|
125
|
+
fingerprint_hash: bundle.fingerprintHash
|
|
126
|
+
}).onConflict((oc) => oc.column("id").doUpdateSet({
|
|
127
|
+
enabled: bundle.enabled,
|
|
128
|
+
should_force_update: bundle.shouldForceUpdate,
|
|
129
|
+
file_hash: bundle.fileHash,
|
|
130
|
+
git_commit_hash: bundle.gitCommitHash,
|
|
131
|
+
message: bundle.message,
|
|
132
|
+
platform: bundle.platform,
|
|
133
|
+
target_app_version: bundle.targetAppVersion,
|
|
134
|
+
channel: bundle.channel,
|
|
135
|
+
storage_uri: bundle.storageUri,
|
|
136
|
+
fingerprint_hash: bundle.fingerprintHash
|
|
137
|
+
})).execute();
|
|
138
|
+
}
|
|
134
139
|
});
|
|
140
|
+
hooks?.onDatabaseUpdated?.();
|
|
135
141
|
}
|
|
136
142
|
}, hooks);
|
|
137
143
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/postgres",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.19.0",
|
|
5
5
|
"description": "React Native OTA solution for self-hosted",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -31,15 +31,15 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"kysely": "^0.27.5",
|
|
33
33
|
"pg": "^8.13.1",
|
|
34
|
-
"@hot-updater/core": "0.
|
|
35
|
-
"@hot-updater/
|
|
34
|
+
"@hot-updater/plugin-core": "0.19.0",
|
|
35
|
+
"@hot-updater/core": "0.19.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@electric-sql/pglite": "^0.2.15",
|
|
39
39
|
"@types/pg": "^8.11.10",
|
|
40
40
|
"camelcase-keys": "^9.1.3",
|
|
41
41
|
"pg-minify": "^1.6.5",
|
|
42
|
-
"@hot-updater/js": "0.
|
|
42
|
+
"@hot-updater/js": "0.19.0"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "tsdown",
|