@devultur/self-host 1.6.0 → 1.6.1

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.
Files changed (2) hide show
  1. package/dist/index.js +9 -21
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -747,12 +747,6 @@ import { contentDispositionAttachment as contentDispositionAttachment2, relative
747
747
  import { Hono as Hono2 } from "hono";
748
748
 
749
749
  // src/download-link.ts
750
- var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
751
- function recordContext(record) {
752
- if (record.context) return record.context;
753
- const legacy = record.callerContext;
754
- return isRecord(legacy) ? legacy : void 0;
755
- }
756
750
  var DownloadLinkPath = {
757
751
  CREATE: "/create",
758
752
  REDEEM: "/redeem",
@@ -1280,8 +1274,11 @@ function attachmentDisposition(record, storedDisposition) {
1280
1274
  var callLink = (stub, path) => stub.fetch(`https://download-link${path}`, { method: "POST" });
1281
1275
  var relayLinkFailure = (response) => new Response(response.body, { status: response.status, headers: response.headers });
1282
1276
  function linkInfoOf(record) {
1283
- const context = recordContext(record);
1284
- return { storagePrefix: record.storagePrefix, key: record.key, ...context ? { context } : {} };
1277
+ return {
1278
+ storagePrefix: record.storagePrefix,
1279
+ key: record.key,
1280
+ ...record.context ? { context: record.context } : {}
1281
+ };
1285
1282
  }
1286
1283
  async function gateRedemption(context, stub) {
1287
1284
  if (getPluginHooks(context).beforeLinkRedeem.length === 0) return null;
@@ -1303,7 +1300,7 @@ download.get("/:linkId", async (context) => {
1303
1300
  if (!redeemed.ok) return relayLinkFailure(redeemed);
1304
1301
  const record = await redeemed.json();
1305
1302
  const object = await context.env.MEDIA_BUCKET.get(record.storageKey);
1306
- if (!object) return context.json({ error: "Not found" }, 404);
1303
+ if (!object) return context.json({ error: "This link's file was deleted", code: "file_gone" }, 410);
1307
1304
  if (isObjectExpired(object.customMetadata)) return expiredResponse();
1308
1305
  addRouteResult(context, { redeemedLink: linkInfoOf(record) });
1309
1306
  const headers = new Headers({
@@ -2755,9 +2752,9 @@ function perTitleMetrics(encode) {
2755
2752
  ...encodeParams ? { encodeParams } : {}
2756
2753
  };
2757
2754
  }
2758
- var isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
2755
+ var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
2759
2756
  function parseEncodeMetrics(event) {
2760
- if (!isRecord2(event) || event.event !== "transcode.complete" || !isRecord2(event.encode)) return null;
2757
+ if (!isRecord(event) || event.event !== "transcode.complete" || !isRecord(event.encode)) return null;
2761
2758
  const { encode } = event;
2762
2759
  if (!isNonNegativeNumber(encode.seconds) || !isNonNegativeNumber(event.duration)) return null;
2763
2760
  return {
@@ -5536,20 +5533,11 @@ function uploadPendingIdOf(uploadUrl) {
5536
5533
  if (id === null) return void 0;
5537
5534
  return PENDING_ID_PATTERN.test(id) ? id : null;
5538
5535
  }
5539
- var isRecord3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
5540
- function withLegacyFieldNames(pending) {
5541
- const { callerContext, objectMetadata, ...current } = pending;
5542
- return {
5543
- ...current,
5544
- ...current.context === void 0 && isRecord3(callerContext) ? { context: callerContext } : {},
5545
- ...current.uploadMetadata === void 0 && isRecord3(objectMetadata) ? { uploadMetadata: objectMetadata } : {}
5546
- };
5547
- }
5548
5536
  function parsePending(raw) {
5549
5537
  if (!raw) return null;
5550
5538
  try {
5551
5539
  const pending = JSON.parse(raw);
5552
- return pending?.storageKey ? withLegacyFieldNames(pending) : null;
5540
+ return pending?.storageKey ? pending : null;
5553
5541
  } catch {
5554
5542
  return null;
5555
5543
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devultur/self-host",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "Self-hosted media Worker for Cloudflare: R2 uploads, edge-cached delivery, image transforms, HLS transcode and captions",
5
5
  "keywords": [
6
6
  "cloudflare-workers",
@@ -47,7 +47,7 @@
47
47
  "@jsquash/resize": "2.1.1",
48
48
  "@jsquash/webp": "1.5.0",
49
49
  "hono": "^4.7.0",
50
- "@devultur/core": "1.6.0"
50
+ "@devultur/core": "1.6.1"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@cf-wasm/photon": "0.4.0",