@hot-updater/cloudflare 1.2.0-rc.0 → 1.2.0-rc.10
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 +13 -87
- package/dist/index.d.cts +12 -6
- package/dist/index.d.mts +12 -6
- package/dist/index.mjs +14 -88
- package/dist/init/index.cjs +75 -19
- package/dist/init/index.d.cts +2 -1
- package/dist/init/index.d.mts +2 -1
- package/dist/init/index.mjs +75 -19
- package/dist/worker/index.cjs +39 -0
- package/dist/worker/index.d.cts +3 -2
- package/dist/worker/index.d.mts +3 -2
- package/dist/worker/index.mjs +39 -0
- package/package.json +10 -9
- package/src/d1Rest.ts +21 -5
- package/src/r2S3Storage.ts +18 -141
- package/src/r2Storage.ts +2 -3
- package/src/r2WorkerStorage.ts +56 -3
- package/worker/dist/README.md +1 -1
- package/worker/dist/index.js +43 -1
- package/worker/dist/index.js.map +3 -3
package/worker/dist/index.js
CHANGED
|
@@ -4632,7 +4632,7 @@ var createSqlAdapter = /* @__PURE__ */ __name(({ executor, tablePrefix = "", max
|
|
|
4632
4632
|
}, "createSqlAdapter");
|
|
4633
4633
|
|
|
4634
4634
|
// ../../packages/server/dist/package.mjs
|
|
4635
|
-
var version = "1.2.0-rc.
|
|
4635
|
+
var version = "1.2.0-rc.10";
|
|
4636
4636
|
|
|
4637
4637
|
// ../../packages/server/dist/version.mjs
|
|
4638
4638
|
var HOT_UPDATER_SERVER_VERSION = version;
|
|
@@ -13683,8 +13683,10 @@ var presignR2GetUrl = /* @__PURE__ */ __name(async ({
|
|
|
13683
13683
|
|
|
13684
13684
|
// src/r2WorkerStorage.ts
|
|
13685
13685
|
var PRESIGNED_URL_EXPIRES_IN_SECONDS = 3600;
|
|
13686
|
+
var DELETE_BATCH_SIZE = 1e3;
|
|
13686
13687
|
function r2WorkerStorage(config) {
|
|
13687
13688
|
const getStorageKey = createStorageKeyBuilder(config.basePath);
|
|
13689
|
+
const basePrefix = getStorageKey() ? `${getStorageKey()}/` : "";
|
|
13688
13690
|
const parseAndValidate = /* @__PURE__ */ __name((storageUri) => {
|
|
13689
13691
|
const parsed = parseStorageUri(storageUri, "r2");
|
|
13690
13692
|
if (parsed.bucket !== config.bucketName) {
|
|
@@ -13761,6 +13763,46 @@ function r2WorkerStorage(config) {
|
|
|
13761
13763
|
const { key } = parseAndValidate(storageUri);
|
|
13762
13764
|
await config.bucket.delete(key);
|
|
13763
13765
|
return { deleted: true };
|
|
13766
|
+
},
|
|
13767
|
+
async listObjects(prefix) {
|
|
13768
|
+
const folder = getStorageKey(prefix ?? "");
|
|
13769
|
+
const objects = [];
|
|
13770
|
+
let cursor;
|
|
13771
|
+
do {
|
|
13772
|
+
const listed2 = await config.bucket.list({
|
|
13773
|
+
prefix: folder ? `${folder}/` : "",
|
|
13774
|
+
...cursor === void 0 ? {} : { cursor }
|
|
13775
|
+
});
|
|
13776
|
+
for (const object of listed2.objects) {
|
|
13777
|
+
if (!object.key.startsWith(basePrefix)) continue;
|
|
13778
|
+
let storageUri;
|
|
13779
|
+
try {
|
|
13780
|
+
storageUri = createStorageUri({
|
|
13781
|
+
protocol: "r2",
|
|
13782
|
+
bucket: config.bucketName,
|
|
13783
|
+
key: object.key
|
|
13784
|
+
});
|
|
13785
|
+
} catch {
|
|
13786
|
+
continue;
|
|
13787
|
+
}
|
|
13788
|
+
objects.push({
|
|
13789
|
+
key: object.key.slice(basePrefix.length),
|
|
13790
|
+
lastModifiedAt: object.uploaded,
|
|
13791
|
+
size: object.size,
|
|
13792
|
+
storageUri
|
|
13793
|
+
});
|
|
13794
|
+
}
|
|
13795
|
+
cursor = listed2.truncated ? listed2.cursor : void 0;
|
|
13796
|
+
} while (cursor !== void 0);
|
|
13797
|
+
return objects;
|
|
13798
|
+
},
|
|
13799
|
+
async deleteObjects(relativeKeys) {
|
|
13800
|
+
const keys = relativeKeys.map((key) => getStorageKey(key));
|
|
13801
|
+
for (let offset = 0; offset < keys.length; offset += DELETE_BATCH_SIZE) {
|
|
13802
|
+
await config.bucket.delete(
|
|
13803
|
+
keys.slice(offset, offset + DELETE_BATCH_SIZE)
|
|
13804
|
+
);
|
|
13805
|
+
}
|
|
13764
13806
|
}
|
|
13765
13807
|
});
|
|
13766
13808
|
}
|