vidspotai-shared 1.0.112 → 1.0.114

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 (58) hide show
  1. package/lib/globals/types.d.ts +9 -1
  2. package/lib/globals/types.d.ts.map +1 -1
  3. package/lib/globals/types.js +9 -0
  4. package/lib/libs/index.d.ts +3 -0
  5. package/lib/libs/index.d.ts.map +1 -1
  6. package/lib/libs/index.js +3 -0
  7. package/lib/libs/mediaStore.d.ts +7 -0
  8. package/lib/libs/mediaStore.d.ts.map +1 -0
  9. package/lib/libs/mediaStore.js +24 -0
  10. package/lib/libs/r2KeyMap.d.ts +40 -0
  11. package/lib/libs/r2KeyMap.d.ts.map +1 -0
  12. package/lib/libs/r2KeyMap.js +110 -0
  13. package/lib/libs/storage/GcsBackend.d.ts +9 -0
  14. package/lib/libs/storage/GcsBackend.d.ts.map +1 -0
  15. package/lib/libs/storage/GcsBackend.js +42 -0
  16. package/lib/libs/storage/MediaStorage.d.ts +80 -0
  17. package/lib/libs/storage/MediaStorage.d.ts.map +1 -0
  18. package/lib/libs/storage/MediaStorage.js +105 -0
  19. package/lib/libs/storage/R2Backend.d.ts +23 -0
  20. package/lib/libs/storage/R2Backend.d.ts.map +1 -0
  21. package/lib/libs/storage/R2Backend.js +156 -0
  22. package/lib/libs/storage/StorageBackend.d.ts +41 -0
  23. package/lib/libs/storage/StorageBackend.d.ts.map +1 -0
  24. package/lib/libs/storage/StorageBackend.js +2 -0
  25. package/lib/libs/storage/index.d.ts +5 -0
  26. package/lib/libs/storage/index.d.ts.map +1 -0
  27. package/lib/libs/storage/index.js +20 -0
  28. package/lib/services/agent/tools/generateAvatarVideo.tool.d.ts.map +1 -1
  29. package/lib/services/agent/tools/generateAvatarVideo.tool.js +3 -5
  30. package/lib/services/aiGen/providers/alibaba/alibaba.d.ts.map +1 -1
  31. package/lib/services/aiGen/providers/alibaba/alibaba.js +5 -11
  32. package/lib/services/aiGen/providers/bytedance/bytedance.service.d.ts.map +1 -1
  33. package/lib/services/aiGen/providers/bytedance/bytedance.service.js +5 -0
  34. package/lib/services/aiGen/providers/elevenlabs/elevenlabs.service.d.ts.map +1 -1
  35. package/lib/services/aiGen/providers/elevenlabs/elevenlabs.service.js +3 -7
  36. package/lib/services/aiGen/providers/google/google.service.d.ts.map +1 -1
  37. package/lib/services/aiGen/providers/google/google.service.js +20 -10
  38. package/lib/services/aiGen/providers/google/googleMusic.d.ts.map +1 -1
  39. package/lib/services/aiGen/providers/google/googleMusic.js +3 -7
  40. package/lib/services/aiGen/providers/kling/kling.service.d.ts +16 -7
  41. package/lib/services/aiGen/providers/kling/kling.service.d.ts.map +1 -1
  42. package/lib/services/aiGen/providers/kling/kling.service.js +2 -2
  43. package/lib/services/aiGen/providers/kling/klingImage.service.d.ts.map +1 -1
  44. package/lib/services/aiGen/providers/kling/klingImage.service.js +3 -5
  45. package/lib/services/aiGen/providers/kling/klingStatus.d.ts +1 -1
  46. package/lib/services/aiGen/providers/kling/klingStatus.d.ts.map +1 -1
  47. package/lib/services/aiGen/providers/kling/klingStatus.js +8 -19
  48. package/lib/services/aiGen/providers/minimax/minimax.service.d.ts.map +1 -1
  49. package/lib/services/aiGen/providers/minimax/minimax.service.js +15 -17
  50. package/lib/services/aiGen/providers/openai/openai.service.d.ts.map +1 -1
  51. package/lib/services/aiGen/providers/openai/openai.service.js +5 -13
  52. package/lib/services/aiGen/providers/pixverse/pixverse.service.d.ts.map +1 -1
  53. package/lib/services/aiGen/providers/pixverse/pixverse.service.js +5 -0
  54. package/lib/services/aiGen/providers/runway/runway.service.d.ts.map +1 -1
  55. package/lib/services/aiGen/providers/runway/runway.service.js +5 -10
  56. package/lib/services/gcp/uploadAudioBuffer.d.ts.map +1 -1
  57. package/lib/services/gcp/uploadAudioBuffer.js +4 -0
  58. package/package.json +2 -1
@@ -151,7 +151,15 @@ export declare enum ERedisQueues {
151
151
  * same engine the demo pipeline uses), applies any permitted allow-listed
152
152
  * repairs, and writes the report back. See notes/SAAS_DEMO_GENERATOR_PLAN.md §12.
153
153
  */
154
- VIDEO_QA_JOBS = "video-qa-job-queue"
154
+ VIDEO_QA_JOBS = "video-qa-job-queue",
155
+ /**
156
+ * R2 cutover — mirrors a resumable-upload object (already in GCS, up to
157
+ * 1 GiB) into R2 off the request path. `completeUploadSessionController`
158
+ * can't safely buffer these in a Function's memory itself, so it enqueues
159
+ * here and the worker streams GCS → R2 directly. Best-effort: GCS is
160
+ * already the durable copy either way.
161
+ */
162
+ MEDIA_MIRROR_JOBS = "media-mirror-job-queue"
155
163
  }
156
164
  export declare const REDIS_QUEUES: ERedisQueues[];
157
165
  /** X8 Social Suite — connected social platforms. Value = stable storage key. */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/globals/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE;QACT,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,cAAc,CAAC;QACrB,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IACJ,MAAM,EAAE,GAAG,EAAE,CAAC;CACf;AAED,oBAAY,eAAe;IACzB,MAAM,WAAW,CAAE,wCAAwC;IAC3D,WAAW,eAAe,CAAE,2DAA2D;IAGvF,SAAS,cAAc,CAAE,8CAA8C;IACvE,MAAM,WAAW,CAAE,+BAA+B;IAClD,mBAAmB,uBAAuB,CAAE,oEAAoE;IAChH,SAAS,cAAc;CACxB;AAED,oBAAY,iBAAiB;IAC3B,WAAW,eAAe,CAAE,qFAAqF;IACjH,SAAS,cAAc,CAAE,2FAA2F;IACpH,OAAO,YAAY,CAAE,kKAAkK;IACvL,MAAM,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AC"}
@@ -153,6 +153,14 @@ var ERedisQueues;
153
153
  * repairs, and writes the report back. See notes/SAAS_DEMO_GENERATOR_PLAN.md §12.
154
154
  */
155
155
  ERedisQueues["VIDEO_QA_JOBS"] = "video-qa-job-queue";
156
+ /**
157
+ * R2 cutover — mirrors a resumable-upload object (already in GCS, up to
158
+ * 1 GiB) into R2 off the request path. `completeUploadSessionController`
159
+ * can't safely buffer these in a Function's memory itself, so it enqueues
160
+ * here and the worker streams GCS → R2 directly. Best-effort: GCS is
161
+ * already the durable copy either way.
162
+ */
163
+ ERedisQueues["MEDIA_MIRROR_JOBS"] = "media-mirror-job-queue";
156
164
  })(ERedisQueues || (exports.ERedisQueues = ERedisQueues = {}));
157
165
  exports.REDIS_QUEUES = [
158
166
  ERedisQueues.VIDEO_JOBS,
@@ -172,6 +180,7 @@ exports.REDIS_QUEUES = [
172
180
  ERedisQueues.DEMO_VIDEO_JOBS,
173
181
  ERedisQueues.OUTREACH_PERSONALIZE_JOBS,
174
182
  ERedisQueues.VIDEO_QA_JOBS,
183
+ ERedisQueues.MEDIA_MIRROR_JOBS,
175
184
  ];
176
185
  /** X8 Social Suite — connected social platforms. Value = stable storage key. */
177
186
  var ESocialProvider;
@@ -1,2 +1,5 @@
1
1
  export * from "./firebase";
2
+ export * from "./r2KeyMap";
3
+ export * from "./storage";
4
+ export * from "./mediaStore";
2
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/libs/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/libs/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC"}
package/lib/libs/index.js CHANGED
@@ -15,3 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./firebase"), exports);
18
+ __exportStar(require("./r2KeyMap"), exports);
19
+ __exportStar(require("./storage"), exports);
20
+ __exportStar(require("./mediaStore"), exports);
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @deprecated Use `mediaStorage.put(objectPath, body, contentType)`.
3
+ * Writes media (GCS primary + best-effort R2 mirror when enabled) and returns a
4
+ * far-future signed read URL.
5
+ */
6
+ export declare function putMedia(objectPath: string, body: Buffer, contentType: string): Promise<string>;
7
+ //# sourceMappingURL=mediaStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mediaStore.d.ts","sourceRoot":"","sources":["../../src/libs/mediaStore.ts"],"names":[],"mappings":"AAcA;;;;GAIG;AACH,wBAAgB,QAAQ,CACtB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,CAEjB"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.putMedia = putMedia;
4
+ /**
5
+ * mediaStore — DEPRECATED compatibility shim.
6
+ * ===========================================
7
+ *
8
+ * The media write path now lives in the `MediaStorage` class
9
+ * (`./storage/MediaStorage.ts`, singleton `mediaStorage`). Everything should
10
+ * call `mediaStorage.put(...)` / `.putFromFile(...)` / `.mirrorBytes(...)`
11
+ * directly so storage is swappable in ONE place.
12
+ *
13
+ * `putMedia()` is kept only as a thin delegate so pre-existing call sites keep
14
+ * working during migration. Prefer `mediaStorage.put`.
15
+ */
16
+ const storage_1 = require("./storage");
17
+ /**
18
+ * @deprecated Use `mediaStorage.put(objectPath, body, contentType)`.
19
+ * Writes media (GCS primary + best-effort R2 mirror when enabled) and returns a
20
+ * far-future signed read URL.
21
+ */
22
+ function putMedia(objectPath, body, contentType) {
23
+ return storage_1.mediaStorage.put(objectPath, body, contentType);
24
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Canonical GCS → R2 key mapping — BACKEND TS PORT.
3
+ * =================================================
4
+ *
5
+ * This is the TypeScript twin of the CDN Worker's single source of truth
6
+ * (`vidspot-frontend/infra/cloudflare-media-cdn/r2-key-map.mjs`). The two files
7
+ * MUST stay vector-for-vector identical: the Worker maps an incoming request to
8
+ * an R2 key with `toR2Key()`, and the backend write-through / bulk migration
9
+ * writes each object to R2 at `toR2Key()` — if they disagree, a migrated object
10
+ * would be stored at one key and looked up at another.
11
+ *
12
+ * A parity check lives in `scripts/verify-r2-keymap-parity.mjs` (run it after
13
+ * editing either file). See `notes/R2_STRUCTURE_AND_MAPPING.md` for the taxonomy.
14
+ *
15
+ * Pure, dependency-free. No I/O.
16
+ */
17
+ /**
18
+ * Reserved R2 top-level namespaces (documentation + bootstrap use). Keep in sync
19
+ * with the `.mjs` twin.
20
+ *
21
+ * NOTE: no `videos/web/` — the old single "web rendition" is superseded by the
22
+ * per-video multi-quality layout, where the 720p tier lives at
23
+ * `videos/final/{jobId}/sd.mp4` (see notes/R2_MULTI_QUALITY_VARIANTS_PLAN.md).
24
+ * Per-namespace self-documenting blurbs (R2_NAMESPACE_DOCS) live only in the
25
+ * `.mjs` twin, since only the frontend bootstrap script writes them to R2.
26
+ */
27
+ export declare const R2_NAMESPACES: string[];
28
+ /**
29
+ * Map a canonical GCS object key to its clean R2 key.
30
+ *
31
+ * TOTAL by construction: an unmapped prefix falls through to the identity, so
32
+ * nothing is ever dropped or misrouted — a forgotten prefix simply keeps its
33
+ * original key in R2 (and the Worker still finds it, since it calls this same
34
+ * function).
35
+ *
36
+ * @param key e.g. "final_videos/abc.mp4"
37
+ * @returns e.g. "videos/final/abc.mp4"
38
+ */
39
+ export declare function toR2Key(key: string): string;
40
+ //# sourceMappingURL=r2KeyMap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"r2KeyMap.d.ts","sourceRoot":"","sources":["../../src/libs/r2KeyMap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAoDH;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,EAejC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAS3C"}
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ /**
3
+ * Canonical GCS → R2 key mapping — BACKEND TS PORT.
4
+ * =================================================
5
+ *
6
+ * This is the TypeScript twin of the CDN Worker's single source of truth
7
+ * (`vidspot-frontend/infra/cloudflare-media-cdn/r2-key-map.mjs`). The two files
8
+ * MUST stay vector-for-vector identical: the Worker maps an incoming request to
9
+ * an R2 key with `toR2Key()`, and the backend write-through / bulk migration
10
+ * writes each object to R2 at `toR2Key()` — if they disagree, a migrated object
11
+ * would be stored at one key and looked up at another.
12
+ *
13
+ * A parity check lives in `scripts/verify-r2-keymap-parity.mjs` (run it after
14
+ * editing either file). See `notes/R2_STRUCTURE_AND_MAPPING.md` for the taxonomy.
15
+ *
16
+ * Pure, dependency-free. No I/O.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.R2_NAMESPACES = void 0;
20
+ exports.toR2Key = toR2Key;
21
+ /**
22
+ * Ordered prefix-rewrite rules. First match wins, so more-specific prefixes
23
+ * (e.g. `avatar-audio-preview/` before `avatar-audio/`) come first. Each rule
24
+ * swaps a legacy top-level prefix for its clean role-based home; the remainder
25
+ * of the key is preserved verbatim unless a `reshape` is given.
26
+ */
27
+ const RULES = [
28
+ // --- generated video, by role -----------------------------------------
29
+ { from: "final_videos/", to: "videos/final/" },
30
+ { from: "watermarked_videos/", to: "videos/watermarked/" },
31
+ {
32
+ // videos/<jobId>_scene<n>.mp4 -> videos/scenes/<jobId>/scene<n>.mp4
33
+ from: "videos/",
34
+ to: "videos/scenes/",
35
+ reshape(rest) {
36
+ const m = /^(.+)_scene(\d+)(\.[A-Za-z0-9]+)$/.exec(rest);
37
+ return m ? `${m[1]}/scene${m[2]}${m[3]}` : rest;
38
+ },
39
+ },
40
+ // NOTE: `social_variants/` (reframeVideo output) is intentionally NOT mapped
41
+ // yet — it falls through to identity, which is CONSISTENT in both this file
42
+ // and the deployed Worker `.mjs`. To give it a clean home (`videos/social/`)
43
+ // later, add the rule to BOTH maps + redeploy the Worker in one change so the
44
+ // migrate-side and lookup-side never disagree.
45
+ // --- already clean role names: keep as-is (identity) -------------------
46
+ { from: "posters/", to: "posters/" },
47
+ { from: "images/", to: "images/" },
48
+ // --- user source uploads ----------------------------------------------
49
+ { from: "media-uploads/", to: "uploads/" },
50
+ // --- avatars (longer prefix FIRST) ------------------------------------
51
+ { from: "avatar-audio-preview/", to: "avatars/audio-preview/" },
52
+ { from: "avatar-videos/", to: "avatars/video/" },
53
+ { from: "avatar-audio/", to: "avatars/audio/" },
54
+ // --- agent workspace --------------------------------------------------
55
+ { from: "agent-projects/", to: "agent/projects/" },
56
+ { from: "agent_renders/", to: "agent/renders/" },
57
+ // --- public showcase gallery ------------------------------------------
58
+ { from: "sample_videos/", to: "gallery/" },
59
+ // --- internal demo pipeline -------------------------------------------
60
+ { from: "demo_inputs/", to: "demo/inputs/" },
61
+ { from: "demo_renders/", to: "demo/renders/" },
62
+ ];
63
+ /**
64
+ * Reserved R2 top-level namespaces (documentation + bootstrap use). Keep in sync
65
+ * with the `.mjs` twin.
66
+ *
67
+ * NOTE: no `videos/web/` — the old single "web rendition" is superseded by the
68
+ * per-video multi-quality layout, where the 720p tier lives at
69
+ * `videos/final/{jobId}/sd.mp4` (see notes/R2_MULTI_QUALITY_VARIANTS_PLAN.md).
70
+ * Per-namespace self-documenting blurbs (R2_NAMESPACE_DOCS) live only in the
71
+ * `.mjs` twin, since only the frontend bootstrap script writes them to R2.
72
+ */
73
+ exports.R2_NAMESPACES = [
74
+ "videos/final/",
75
+ "videos/watermarked/",
76
+ "videos/scenes/",
77
+ "posters/",
78
+ "images/",
79
+ "uploads/",
80
+ "avatars/video/",
81
+ "avatars/audio/",
82
+ "avatars/audio-preview/",
83
+ "agent/projects/",
84
+ "agent/renders/",
85
+ "gallery/",
86
+ "demo/inputs/",
87
+ "demo/renders/",
88
+ ];
89
+ /**
90
+ * Map a canonical GCS object key to its clean R2 key.
91
+ *
92
+ * TOTAL by construction: an unmapped prefix falls through to the identity, so
93
+ * nothing is ever dropped or misrouted — a forgotten prefix simply keeps its
94
+ * original key in R2 (and the Worker still finds it, since it calls this same
95
+ * function).
96
+ *
97
+ * @param key e.g. "final_videos/abc.mp4"
98
+ * @returns e.g. "videos/final/abc.mp4"
99
+ */
100
+ function toR2Key(key) {
101
+ if (!key)
102
+ return key;
103
+ for (const rule of RULES) {
104
+ if (key.startsWith(rule.from)) {
105
+ const rest = key.slice(rule.from.length);
106
+ return rule.to + (rule.reshape ? rule.reshape(rest) : rest);
107
+ }
108
+ }
109
+ return key; // safety net — identity for anything unmapped
110
+ }
@@ -0,0 +1,9 @@
1
+ import type { IStorageBackend } from "./StorageBackend";
2
+ export declare class GcsBackend implements IStorageBackend {
3
+ readonly name = "gcs";
4
+ write(key: string, body: Buffer, contentType: string): Promise<void>;
5
+ writeFromFile(key: string, localPath: string, contentType: string): Promise<number>;
6
+ signedReadUrl(key: string): Promise<string>;
7
+ delete(key: string): Promise<void>;
8
+ }
9
+ //# sourceMappingURL=GcsBackend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GcsBackend.d.ts","sourceRoot":"","sources":["../../../src/libs/storage/GcsBackend.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAMxD,qBAAa,UAAW,YAAW,eAAe;IAChD,QAAQ,CAAC,IAAI,SAAS;IAEhB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpE,aAAa,CACjB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC;IAOZ,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAO3C,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGzC"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GcsBackend = void 0;
4
+ /**
5
+ * Google Cloud Storage backend — today's system-of-record.
6
+ * ========================================================
7
+ *
8
+ * Wraps the Firebase Admin bucket. The canonical object path IS the GCS key
9
+ * (identity mapping). Read URLs are the far-future signed URLs used everywhere
10
+ * in the codebase (`getSignedUrl({ expires: "03-09-2491" })`) — permanent
11
+ * bearer tokens, so stored Firestore URLs never need refreshing.
12
+ */
13
+ const fs_1 = require("fs");
14
+ const promises_1 = require("stream/promises");
15
+ const firebase_1 = require("../firebase");
16
+ // Far-future expiry — matches the permanent bearer-token URLs used everywhere
17
+ // (getSignedUrl expires "03-09-2491").
18
+ const PERMANENT_EXPIRY = "03-09-2491";
19
+ class GcsBackend {
20
+ constructor() {
21
+ this.name = "gcs";
22
+ }
23
+ async write(key, body, contentType) {
24
+ await (0, firebase_1.getBucket)().file(key).save(body, { contentType });
25
+ }
26
+ async writeFromFile(key, localPath, contentType) {
27
+ const file = (0, firebase_1.getBucket)().file(key);
28
+ await (0, promises_1.pipeline)((0, fs_1.createReadStream)(localPath), file.createWriteStream({ contentType }));
29
+ const [meta] = await file.getMetadata();
30
+ return Number(meta.size);
31
+ }
32
+ async signedReadUrl(key) {
33
+ const [url] = await (0, firebase_1.getBucket)()
34
+ .file(key)
35
+ .getSignedUrl({ action: "read", expires: PERMANENT_EXPIRY });
36
+ return url;
37
+ }
38
+ async delete(key) {
39
+ await (0, firebase_1.getBucket)().file(key).delete({ ignoreNotFound: true });
40
+ }
41
+ }
42
+ exports.GcsBackend = GcsBackend;
@@ -0,0 +1,80 @@
1
+ /**
2
+ * MediaStorage — the single media write/read path for the whole backend.
3
+ * ======================================================================
4
+ *
5
+ * Every media write (final videos, scene clips, posters, images, music/SFX/TTS,
6
+ * uploads, agent edits) goes through the `mediaStorage` singleton instead of
7
+ * touching a bucket directly. That gives us ONE place to change how/where media
8
+ * is stored — swapping backends, or flipping which one is primary, never touches
9
+ * the ~30 call sites.
10
+ *
11
+ * Today's composition:
12
+ * • PRIMARY = GCS (system-of-record + pipeline source; returns the delivery URL)
13
+ * • MIRROR = R2, best-effort, only when `R2_WRITE_ENABLED=true`
14
+ *
15
+ * Delivery flips to free egress automatically: the `cdn.vidspotai.com` Worker is
16
+ * R2-first, so once an object is mirrored it serves from R2; until then the
17
+ * Worker falls back to GCS. See notes/R2_MEDIA_MIGRATION_PLAN.md (Phase 2).
18
+ *
19
+ * FUTURE SWAP (Stage 2 — decommission GCS): make R2 the primary and return its
20
+ * CDN read URL. That is an edit to THIS FILE ONLY — every caller keeps calling
21
+ * `mediaStorage.put(...)` unchanged.
22
+ */
23
+ import type { Readable } from "stream";
24
+ import type { IStorageBackend } from "./StorageBackend";
25
+ /** R2 mirror-writes are opt-in; off = today's GCS-only behavior, exactly. */
26
+ export declare function isR2WriteEnabled(): boolean;
27
+ export declare class MediaStorage {
28
+ /** Store-of-record + delivery-URL source. */
29
+ private readonly primary;
30
+ /** Zero-egress mirror; written best-effort when enabled. */
31
+ private readonly mirror;
32
+ constructor(primary: IStorageBackend, mirror: IStorageBackend);
33
+ /**
34
+ * Write in-memory bytes and return a durable delivery URL. Drop-in for the
35
+ * ubiquitous `file.save(buf, { contentType })` + `getSignedUrl({ expires })`
36
+ * pair.
37
+ *
38
+ * @param objectPath canonical object key, e.g. "final_videos/<id>.mp4"
39
+ */
40
+ put(objectPath: string, body: Buffer, contentType: string): Promise<string>;
41
+ /**
42
+ * Stream a local file to the primary (no whole-file buffering) and return the
43
+ * delivery URL plus the stored object size for integrity checks. For large
44
+ * clips whose GCS upload is size-verified by the caller (e.g. the google
45
+ * scene-download moov-atom guard).
46
+ */
47
+ putFromFile(objectPath: string, localPath: string, contentType: string): Promise<{
48
+ url: string;
49
+ size: number;
50
+ }>;
51
+ /**
52
+ * Best-effort R2 mirror of an object ALREADY written to the primary through a
53
+ * bespoke path (a specialized streaming/integrity write we don't want to route
54
+ * through `put`). No-op when disabled; never throws.
55
+ */
56
+ mirrorBytes(objectPath: string, body: Buffer, contentType: string): Promise<void>;
57
+ /**
58
+ * Best-effort R2 mirror of a LOCAL FILE already written to the primary through
59
+ * a bespoke streaming/integrity path (e.g. the google scene-download moov-atom
60
+ * guard). Reads the file only when mirroring is enabled; never throws.
61
+ */
62
+ mirrorFromFile(objectPath: string, localPath: string, contentType: string): Promise<void>;
63
+ /**
64
+ * Best-effort R2 mirror of an object ALREADY written to the primary,
65
+ * streamed straight through from an open Readable (e.g. a GCS read stream)
66
+ * without buffering it whole — for objects too large to safely hold in
67
+ * process memory (resumable uploads, up to 1 GiB). No-op when disabled, when
68
+ * the mirror backend doesn't implement streaming writes, or on failure.
69
+ */
70
+ mirrorFromReadable(objectPath: string, stream: Readable, contentType: string, size: number): Promise<void>;
71
+ /** Delivery URL for an object already stored. */
72
+ signedReadUrl(objectPath: string): Promise<string>;
73
+ /** Delete from both stores (mirror delete best-effort). */
74
+ delete(objectPath: string): Promise<void>;
75
+ /** Run a mirror op, swallowing failures — the primary write already stands. */
76
+ private bestEffortMirror;
77
+ }
78
+ /** App-wide singleton: GCS primary today, R2 mirror when enabled. */
79
+ export declare const mediaStorage: MediaStorage;
80
+ //# sourceMappingURL=MediaStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MediaStorage.d.ts","sourceRoot":"","sources":["../../../src/libs/storage/MediaStorage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAGvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBA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AY,cAAsD,CAAC"}
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mediaStorage = exports.MediaStorage = void 0;
4
+ exports.isR2WriteEnabled = isR2WriteEnabled;
5
+ const GcsBackend_1 = require("./GcsBackend");
6
+ const R2Backend_1 = require("./R2Backend");
7
+ const logger_1 = require("../../utils/logger");
8
+ /** R2 mirror-writes are opt-in; off = today's GCS-only behavior, exactly. */
9
+ function isR2WriteEnabled() {
10
+ return process.env.R2_WRITE_ENABLED === "true";
11
+ }
12
+ class MediaStorage {
13
+ constructor(primary, mirror) {
14
+ this.primary = primary;
15
+ this.mirror = mirror;
16
+ }
17
+ /**
18
+ * Write in-memory bytes and return a durable delivery URL. Drop-in for the
19
+ * ubiquitous `file.save(buf, { contentType })` + `getSignedUrl({ expires })`
20
+ * pair.
21
+ *
22
+ * @param objectPath canonical object key, e.g. "final_videos/<id>.mp4"
23
+ */
24
+ async put(objectPath, body, contentType) {
25
+ await this.primary.write(objectPath, body, contentType);
26
+ if (isR2WriteEnabled()) {
27
+ await this.bestEffortMirror(() => this.mirror.write(objectPath, body, contentType), objectPath);
28
+ }
29
+ return this.primary.signedReadUrl(objectPath);
30
+ }
31
+ /**
32
+ * Stream a local file to the primary (no whole-file buffering) and return the
33
+ * delivery URL plus the stored object size for integrity checks. For large
34
+ * clips whose GCS upload is size-verified by the caller (e.g. the google
35
+ * scene-download moov-atom guard).
36
+ */
37
+ async putFromFile(objectPath, localPath, contentType) {
38
+ const size = await this.primary.writeFromFile(objectPath, localPath, contentType);
39
+ if (isR2WriteEnabled()) {
40
+ await this.bestEffortMirror(() => this.mirror.writeFromFile(objectPath, localPath, contentType), objectPath);
41
+ }
42
+ const url = await this.primary.signedReadUrl(objectPath);
43
+ return { url, size };
44
+ }
45
+ /**
46
+ * Best-effort R2 mirror of an object ALREADY written to the primary through a
47
+ * bespoke path (a specialized streaming/integrity write we don't want to route
48
+ * through `put`). No-op when disabled; never throws.
49
+ */
50
+ async mirrorBytes(objectPath, body, contentType) {
51
+ if (!isR2WriteEnabled())
52
+ return;
53
+ await this.bestEffortMirror(() => this.mirror.write(objectPath, body, contentType), objectPath);
54
+ }
55
+ /**
56
+ * Best-effort R2 mirror of a LOCAL FILE already written to the primary through
57
+ * a bespoke streaming/integrity path (e.g. the google scene-download moov-atom
58
+ * guard). Reads the file only when mirroring is enabled; never throws.
59
+ */
60
+ async mirrorFromFile(objectPath, localPath, contentType) {
61
+ if (!isR2WriteEnabled())
62
+ return;
63
+ await this.bestEffortMirror(() => this.mirror.writeFromFile(objectPath, localPath, contentType), objectPath);
64
+ }
65
+ /**
66
+ * Best-effort R2 mirror of an object ALREADY written to the primary,
67
+ * streamed straight through from an open Readable (e.g. a GCS read stream)
68
+ * without buffering it whole — for objects too large to safely hold in
69
+ * process memory (resumable uploads, up to 1 GiB). No-op when disabled, when
70
+ * the mirror backend doesn't implement streaming writes, or on failure.
71
+ */
72
+ async mirrorFromReadable(objectPath, stream, contentType, size) {
73
+ if (!isR2WriteEnabled())
74
+ return;
75
+ if (!this.mirror.writeFromReadable)
76
+ return;
77
+ await this.bestEffortMirror(() => this.mirror.writeFromReadable(objectPath, stream, contentType, size), objectPath);
78
+ }
79
+ /** Delivery URL for an object already stored. */
80
+ signedReadUrl(objectPath) {
81
+ return this.primary.signedReadUrl(objectPath);
82
+ }
83
+ /** Delete from both stores (mirror delete best-effort). */
84
+ async delete(objectPath) {
85
+ await this.primary.delete(objectPath);
86
+ if (isR2WriteEnabled()) {
87
+ await this.bestEffortMirror(() => this.mirror.delete(objectPath), objectPath);
88
+ }
89
+ }
90
+ /** Run a mirror op, swallowing failures — the primary write already stands. */
91
+ async bestEffortMirror(op, objectPath) {
92
+ try {
93
+ await op();
94
+ }
95
+ catch (err) {
96
+ logger_1.logger.error("MediaStorage: R2 mirror failed (primary write stands)", {
97
+ objectPath,
98
+ err: err instanceof Error ? err.stack ?? err.message : String(err),
99
+ });
100
+ }
101
+ }
102
+ }
103
+ exports.MediaStorage = MediaStorage;
104
+ /** App-wide singleton: GCS primary today, R2 mirror when enabled. */
105
+ exports.mediaStorage = new MediaStorage(new GcsBackend_1.GcsBackend(), new R2Backend_1.R2Backend());
@@ -0,0 +1,23 @@
1
+ import type { Readable } from "stream";
2
+ import type { IStorageBackend } from "./StorageBackend";
3
+ export declare class R2Backend implements IStorageBackend {
4
+ readonly name = "r2";
5
+ private client;
6
+ private init;
7
+ /** True once creds+endpoint are present; a missing config is logged once. */
8
+ private getClient;
9
+ write(key: string, body: Buffer, contentType: string): Promise<void>;
10
+ writeFromFile(key: string, localPath: string, contentType: string): Promise<number>;
11
+ /**
12
+ * Mirror an object already stored elsewhere (GCS) straight through, without
13
+ * buffering it in process memory — for objects a caller never downloads to
14
+ * a local file (e.g. a resumable-upload completion, which only has a GCS
15
+ * read stream). A single PutObject with an explicit ContentLength handles
16
+ * up to 5GiB without multipart, comfortably covering our upload ceiling.
17
+ */
18
+ writeFromReadable(key: string, stream: Readable, contentType: string, size: number): Promise<void>;
19
+ /** Delivery URL once R2 is primary: the CDN host + clean key. */
20
+ signedReadUrl(key: string): Promise<string>;
21
+ delete(key: string): Promise<void>;
22
+ }
23
+ //# sourceMappingURL=R2Backend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"R2Backend.d.ts","sourceRoot":"","sources":["../../../src/libs/storage/R2Backend.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAIvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAyBxD,qBAAa,SAAU,YAAW,eAAe;IAC/C,QAAQ,CAAC,IAAI,QAAQ;IAGrB,OAAO,CAAC,MAAM,CAAyB;IACvC,OAAO,CAAC,IAAI,CAAyC;IAErD,6EAA6E;YAC/D,SAAS;IAoBjB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBpE,aAAa,CACjB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC;IAQlB;;;;;;OAMG;IACG,iBAAiB,CACrB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,QAAQ,EAChB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC;IAiBhB,iEAAiE;IAC3D,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI3C,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAQzC"}