vidspotai-shared 1.0.128 → 1.0.129
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.
|
@@ -37,6 +37,11 @@
|
|
|
37
37
|
* real bytes to GCS today — converting them is a separate, larger effort
|
|
38
38
|
* (see the notes doc §9).
|
|
39
39
|
*
|
|
40
|
+
* ✅ Since 2026-10-10 every URL this returns is ALREADY the working CDN form
|
|
41
|
+
* (see `signedReadUrl`), so new URLs are safe to fetch, embed, or hand to a
|
|
42
|
+
* third party as-is. The warning below still applies to URLs STORED between
|
|
43
|
+
* 2026-09-22 and 2026-10-10 (raw GCS-signed shape, dead at that address):
|
|
44
|
+
*
|
|
40
45
|
* ⚠️ RE-DOWNLOADING a URL this returned, anywhere else in the backend (a
|
|
41
46
|
* provider re-fetching a bible reference image, a pipeline step re-fetching a
|
|
42
47
|
* scene clip to post-process it, ASR re-fetching an audio URL, handing a URL
|
|
@@ -107,7 +112,19 @@ export declare class MediaStorage {
|
|
|
107
112
|
* backend doesn't implement streaming writes, or on failure.
|
|
108
113
|
*/
|
|
109
114
|
mirrorFromReadable(objectPath: string, stream: Readable, contentType: string, size: number): Promise<void>;
|
|
110
|
-
/**
|
|
115
|
+
/**
|
|
116
|
+
* Delivery URL for an object already stored — ALWAYS the CDN form
|
|
117
|
+
* (`https://cdn.vidspotai.com/gcs-priv/<bucket>/<object>?<signature>`).
|
|
118
|
+
*
|
|
119
|
+
* 2026-10-10: this used to return the raw GCS-signed URL. Since the
|
|
120
|
+
* R2-primary flip that URL is dead at its literal address (the bytes live
|
|
121
|
+
* only in R2), so it only worked for consumers that remembered to rewrite
|
|
122
|
+
* it through `toCdnUrl()`/`cdn()` — and the ones that didn't (providers,
|
|
123
|
+
* the renderer, MCP results, webhooks, a dozen UI surfaces) broke in prod.
|
|
124
|
+
* Minting the working URL HERE means no consumer can get it wrong. The
|
|
125
|
+
* consumer-side rewrites stay as idempotent no-ops for the URLs already
|
|
126
|
+
* stored between 2026-09-22 and this change.
|
|
127
|
+
*/
|
|
111
128
|
signedReadUrl(objectPath: string): Promise<string>;
|
|
112
129
|
/**
|
|
113
130
|
* Delete the object's bytes from R2. Does NOT touch GCS — since 2026-09-22
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MediaStorage.d.ts","sourceRoot":"","sources":["../../../src/libs/storage/MediaStorage.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"MediaStorage.d.ts","sourceRoot":"","sources":["../../../src/libs/storage/MediaStorage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAGvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAIxD;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C;AAED,qBAAa,YAAY;IACvB,iEAAiE;IACjE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAkB;IACxC,0EAA0E;IAC1E,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkB;gBAEhC,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,eAAe;IAK9D;;;;;;OAMG;IACG,GAAG,CACP,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC;IAKlB;;;;;OAKG;IACG,WAAW,CACf,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAMzC;;;;;;;OAOG;IACG,WAAW,CACf,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC;IAQhB;;;;;OAKG;IACG,cAAc,CAClB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC;IAQhB;;;;;;OAMG;IACG,kBAAkB,CACtB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,QAAQ,EAChB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC;IAShB;;;;;;;;;;;;OAYG;IACG,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIxD;;;;;;;;OAQG;IACG,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/C;;;;;OAKG;YACW,gBAAgB;CAa/B;AAED,8EAA8E;AAC9E,eAAO,MAAM,YAAY,cAAsD,CAAC"}
|
|
@@ -5,6 +5,7 @@ exports.isR2WriteEnabled = isR2WriteEnabled;
|
|
|
5
5
|
const GcsBackend_1 = require("./GcsBackend");
|
|
6
6
|
const R2Backend_1 = require("./R2Backend");
|
|
7
7
|
const logger_1 = require("../../utils/logger");
|
|
8
|
+
const cdnUrl_1 = require("./cdnUrl");
|
|
8
9
|
/**
|
|
9
10
|
* Legacy pipeline mirror-writes (see NOT COVERED above) stay opt-in behind
|
|
10
11
|
* this flag; unrelated to the `put`/`putFromFile`/`delete` R2-primary path,
|
|
@@ -27,7 +28,7 @@ class MediaStorage {
|
|
|
27
28
|
*/
|
|
28
29
|
async put(objectPath, body, contentType) {
|
|
29
30
|
await this.bytes.write(objectPath, body, contentType);
|
|
30
|
-
return this.
|
|
31
|
+
return this.signedReadUrl(objectPath);
|
|
31
32
|
}
|
|
32
33
|
/**
|
|
33
34
|
* Stream a local file to the primary (no whole-file buffering) and return the
|
|
@@ -37,7 +38,7 @@ class MediaStorage {
|
|
|
37
38
|
*/
|
|
38
39
|
async putFromFile(objectPath, localPath, contentType) {
|
|
39
40
|
const size = await this.bytes.writeFromFile(objectPath, localPath, contentType);
|
|
40
|
-
const url = await this.
|
|
41
|
+
const url = await this.signedReadUrl(objectPath);
|
|
41
42
|
return { url, size };
|
|
42
43
|
}
|
|
43
44
|
/**
|
|
@@ -78,9 +79,21 @@ class MediaStorage {
|
|
|
78
79
|
return;
|
|
79
80
|
await this.bestEffortMirror(() => this.bytes.writeFromReadable(objectPath, stream, contentType, size), objectPath);
|
|
80
81
|
}
|
|
81
|
-
/**
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
/**
|
|
83
|
+
* Delivery URL for an object already stored — ALWAYS the CDN form
|
|
84
|
+
* (`https://cdn.vidspotai.com/gcs-priv/<bucket>/<object>?<signature>`).
|
|
85
|
+
*
|
|
86
|
+
* 2026-10-10: this used to return the raw GCS-signed URL. Since the
|
|
87
|
+
* R2-primary flip that URL is dead at its literal address (the bytes live
|
|
88
|
+
* only in R2), so it only worked for consumers that remembered to rewrite
|
|
89
|
+
* it through `toCdnUrl()`/`cdn()` — and the ones that didn't (providers,
|
|
90
|
+
* the renderer, MCP results, webhooks, a dozen UI surfaces) broke in prod.
|
|
91
|
+
* Minting the working URL HERE means no consumer can get it wrong. The
|
|
92
|
+
* consumer-side rewrites stay as idempotent no-ops for the URLs already
|
|
93
|
+
* stored between 2026-09-22 and this change.
|
|
94
|
+
*/
|
|
95
|
+
async signedReadUrl(objectPath) {
|
|
96
|
+
return (0, cdnUrl_1.toCdnUrl)(await this.urlMinter.signedReadUrl(objectPath), { visibility: "private" });
|
|
84
97
|
}
|
|
85
98
|
/**
|
|
86
99
|
* Delete the object's bytes from R2. Does NOT touch GCS — since 2026-09-22
|