@hot-updater/firebase 0.18.4 → 0.18.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 +12 -6
- package/dist/index.js +12 -6
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1377,11 +1377,11 @@ const firebaseStorage = (config, hooks) => (_) => {
|
|
|
1377
1377
|
return {
|
|
1378
1378
|
name: "firebaseStorage",
|
|
1379
1379
|
async deleteBundle(bundleId) {
|
|
1380
|
-
const
|
|
1380
|
+
const Key = `${bundleId}/bundle.zip`;
|
|
1381
1381
|
try {
|
|
1382
|
-
const [files] = await bucket.getFiles({ prefix });
|
|
1382
|
+
const [files] = await bucket.getFiles({ prefix: Key });
|
|
1383
1383
|
await Promise.all(files.map((file) => file.delete()));
|
|
1384
|
-
return
|
|
1384
|
+
return { storageUri: `gs://${config.storageBucket}/${Key}` };
|
|
1385
1385
|
} catch (e) {
|
|
1386
1386
|
console.error("Error listing or deleting files:", e);
|
|
1387
1387
|
throw new Error("Bundle Not Found");
|
|
@@ -1482,14 +1482,13 @@ const firebaseDatabase = (config, hooks) => {
|
|
|
1482
1482
|
async commitBundle(context, { changedSets }) {
|
|
1483
1483
|
if (changedSets.length === 0) return;
|
|
1484
1484
|
let isTargetAppVersionChanged = false;
|
|
1485
|
+
const deletedBundleIds = /* @__PURE__ */ new Set();
|
|
1485
1486
|
await context.db.runTransaction(async (transaction) => {
|
|
1486
1487
|
const bundlesSnapshot = await transaction.get(context.bundlesCollection);
|
|
1487
1488
|
const targetVersionsSnapshot = await transaction.get(context.db.collection("target_app_versions"));
|
|
1488
1489
|
const channelsSnapshot = await transaction.get(context.db.collection("channels"));
|
|
1489
1490
|
const bundlesMap = {};
|
|
1490
1491
|
for (const doc of bundlesSnapshot.docs) bundlesMap[doc.id] = doc.data();
|
|
1491
|
-
const channelsMap = {};
|
|
1492
|
-
for (const doc of channelsSnapshot.docs) channelsMap[doc.id] = true;
|
|
1493
1492
|
for (const { operation, data } of changedSets) {
|
|
1494
1493
|
if (data.targetAppVersion) isTargetAppVersionChanged = true;
|
|
1495
1494
|
if (operation === "insert" || operation === "update") {
|
|
@@ -1509,6 +1508,11 @@ const firebaseDatabase = (config, hooks) => {
|
|
|
1509
1508
|
};
|
|
1510
1509
|
const channelRef = context.db.collection("channels").doc(data.channel);
|
|
1511
1510
|
transaction.set(channelRef, { name: data.channel }, { merge: true });
|
|
1511
|
+
} else if (operation === "delete") {
|
|
1512
|
+
if (!bundlesMap[data.id]) throw new Error(`Bundle with id ${data.id} not found`);
|
|
1513
|
+
delete bundlesMap[data.id];
|
|
1514
|
+
deletedBundleIds.add(data.id);
|
|
1515
|
+
isTargetAppVersionChanged = true;
|
|
1512
1516
|
}
|
|
1513
1517
|
}
|
|
1514
1518
|
const requiredTargetVersionKeys = /* @__PURE__ */ new Set();
|
|
@@ -1546,13 +1550,15 @@ const firebaseDatabase = (config, hooks) => {
|
|
|
1546
1550
|
target_app_version: data.targetAppVersion
|
|
1547
1551
|
}, { merge: true });
|
|
1548
1552
|
}
|
|
1549
|
-
}
|
|
1553
|
+
} else if (operation === "delete") transaction.delete(bundleRef);
|
|
1550
1554
|
}
|
|
1551
1555
|
if (isTargetAppVersionChanged) {
|
|
1552
1556
|
for (const targetDoc of targetVersionsSnapshot.docs) if (!requiredTargetVersionKeys.has(targetDoc.id)) transaction.delete(targetDoc.ref);
|
|
1553
1557
|
}
|
|
1554
1558
|
for (const channelDoc of channelsSnapshot.docs) if (!requiredChannels.has(channelDoc.id)) transaction.delete(channelDoc.ref);
|
|
1555
1559
|
});
|
|
1560
|
+
for (const bundleId of deletedBundleIds) bundles = bundles.filter((b) => b.id !== bundleId);
|
|
1561
|
+
hooks?.onDatabaseUpdated?.();
|
|
1556
1562
|
}
|
|
1557
1563
|
}, hooks);
|
|
1558
1564
|
};
|
package/dist/index.js
CHANGED
|
@@ -1355,11 +1355,11 @@ const firebaseStorage = (config, hooks) => (_) => {
|
|
|
1355
1355
|
return {
|
|
1356
1356
|
name: "firebaseStorage",
|
|
1357
1357
|
async deleteBundle(bundleId) {
|
|
1358
|
-
const
|
|
1358
|
+
const Key = `${bundleId}/bundle.zip`;
|
|
1359
1359
|
try {
|
|
1360
|
-
const [files] = await bucket.getFiles({ prefix });
|
|
1360
|
+
const [files] = await bucket.getFiles({ prefix: Key });
|
|
1361
1361
|
await Promise.all(files.map((file) => file.delete()));
|
|
1362
|
-
return
|
|
1362
|
+
return { storageUri: `gs://${config.storageBucket}/${Key}` };
|
|
1363
1363
|
} catch (e) {
|
|
1364
1364
|
console.error("Error listing or deleting files:", e);
|
|
1365
1365
|
throw new Error("Bundle Not Found");
|
|
@@ -1460,14 +1460,13 @@ const firebaseDatabase = (config, hooks) => {
|
|
|
1460
1460
|
async commitBundle(context, { changedSets }) {
|
|
1461
1461
|
if (changedSets.length === 0) return;
|
|
1462
1462
|
let isTargetAppVersionChanged = false;
|
|
1463
|
+
const deletedBundleIds = /* @__PURE__ */ new Set();
|
|
1463
1464
|
await context.db.runTransaction(async (transaction) => {
|
|
1464
1465
|
const bundlesSnapshot = await transaction.get(context.bundlesCollection);
|
|
1465
1466
|
const targetVersionsSnapshot = await transaction.get(context.db.collection("target_app_versions"));
|
|
1466
1467
|
const channelsSnapshot = await transaction.get(context.db.collection("channels"));
|
|
1467
1468
|
const bundlesMap = {};
|
|
1468
1469
|
for (const doc of bundlesSnapshot.docs) bundlesMap[doc.id] = doc.data();
|
|
1469
|
-
const channelsMap = {};
|
|
1470
|
-
for (const doc of channelsSnapshot.docs) channelsMap[doc.id] = true;
|
|
1471
1470
|
for (const { operation, data } of changedSets) {
|
|
1472
1471
|
if (data.targetAppVersion) isTargetAppVersionChanged = true;
|
|
1473
1472
|
if (operation === "insert" || operation === "update") {
|
|
@@ -1487,6 +1486,11 @@ const firebaseDatabase = (config, hooks) => {
|
|
|
1487
1486
|
};
|
|
1488
1487
|
const channelRef = context.db.collection("channels").doc(data.channel);
|
|
1489
1488
|
transaction.set(channelRef, { name: data.channel }, { merge: true });
|
|
1489
|
+
} else if (operation === "delete") {
|
|
1490
|
+
if (!bundlesMap[data.id]) throw new Error(`Bundle with id ${data.id} not found`);
|
|
1491
|
+
delete bundlesMap[data.id];
|
|
1492
|
+
deletedBundleIds.add(data.id);
|
|
1493
|
+
isTargetAppVersionChanged = true;
|
|
1490
1494
|
}
|
|
1491
1495
|
}
|
|
1492
1496
|
const requiredTargetVersionKeys = /* @__PURE__ */ new Set();
|
|
@@ -1524,13 +1528,15 @@ const firebaseDatabase = (config, hooks) => {
|
|
|
1524
1528
|
target_app_version: data.targetAppVersion
|
|
1525
1529
|
}, { merge: true });
|
|
1526
1530
|
}
|
|
1527
|
-
}
|
|
1531
|
+
} else if (operation === "delete") transaction.delete(bundleRef);
|
|
1528
1532
|
}
|
|
1529
1533
|
if (isTargetAppVersionChanged) {
|
|
1530
1534
|
for (const targetDoc of targetVersionsSnapshot.docs) if (!requiredTargetVersionKeys.has(targetDoc.id)) transaction.delete(targetDoc.ref);
|
|
1531
1535
|
}
|
|
1532
1536
|
for (const channelDoc of channelsSnapshot.docs) if (!requiredChannels.has(channelDoc.id)) transaction.delete(channelDoc.ref);
|
|
1533
1537
|
});
|
|
1538
|
+
for (const bundleId of deletedBundleIds) bundles = bundles.filter((b) => b.id !== bundleId);
|
|
1539
|
+
hooks?.onDatabaseUpdated?.();
|
|
1534
1540
|
}
|
|
1535
1541
|
}, hooks);
|
|
1536
1542
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/firebase",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.18.
|
|
4
|
+
"version": "0.18.5",
|
|
5
5
|
"description": "React Native OTA solution for self-hosted",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"firebase": "^11.3.1",
|
|
37
|
-
"@hot-updater/core": "0.18.
|
|
38
|
-
"@hot-updater/plugin-core": "0.18.
|
|
37
|
+
"@hot-updater/core": "0.18.5",
|
|
38
|
+
"@hot-updater/plugin-core": "0.18.5"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"hono": "^4.6.3",
|
|
54
54
|
"mime": "^4.0.4",
|
|
55
55
|
"picocolors": "^1.0.0",
|
|
56
|
-
"@hot-updater/js": "0.18.
|
|
56
|
+
"@hot-updater/js": "0.18.5"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"firebase-admin": "*"
|