vidspotai-shared 1.0.113 → 1.0.115

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 (95) hide show
  1. package/lib/globals/types.d.ts +17 -1
  2. package/lib/globals/types.d.ts.map +1 -1
  3. package/lib/globals/types.js +18 -0
  4. package/lib/libs/index.d.ts +1 -0
  5. package/lib/libs/index.d.ts.map +1 -1
  6. package/lib/libs/index.js +1 -0
  7. package/lib/libs/mediaStore.d.ts +3 -31
  8. package/lib/libs/mediaStore.d.ts.map +1 -1
  9. package/lib/libs/mediaStore.js +16 -140
  10. package/lib/libs/storage/GcsBackend.d.ts +9 -0
  11. package/lib/libs/storage/GcsBackend.d.ts.map +1 -0
  12. package/lib/libs/storage/GcsBackend.js +42 -0
  13. package/lib/libs/storage/MediaStorage.d.ts +117 -0
  14. package/lib/libs/storage/MediaStorage.d.ts.map +1 -0
  15. package/lib/libs/storage/MediaStorage.js +117 -0
  16. package/lib/libs/storage/R2Backend.d.ts +42 -0
  17. package/lib/libs/storage/R2Backend.d.ts.map +1 -0
  18. package/lib/libs/storage/R2Backend.js +175 -0
  19. package/lib/libs/storage/StorageBackend.d.ts +41 -0
  20. package/lib/libs/storage/StorageBackend.d.ts.map +1 -0
  21. package/lib/libs/storage/StorageBackend.js +2 -0
  22. package/lib/libs/storage/cdnUrl.d.ts +27 -0
  23. package/lib/libs/storage/cdnUrl.d.ts.map +1 -0
  24. package/lib/libs/storage/cdnUrl.js +48 -0
  25. package/lib/libs/storage/index.d.ts +6 -0
  26. package/lib/libs/storage/index.d.ts.map +1 -0
  27. package/lib/libs/storage/index.js +21 -0
  28. package/lib/models/agent.model.d.ts +27 -0
  29. package/lib/models/agent.model.d.ts.map +1 -1
  30. package/lib/models/index.d.ts +1 -0
  31. package/lib/models/index.d.ts.map +1 -1
  32. package/lib/models/index.js +1 -0
  33. package/lib/models/outreach.model.d.ts +7 -1
  34. package/lib/models/outreach.model.d.ts.map +1 -1
  35. package/lib/models/outreachIntegration.model.d.ts +42 -0
  36. package/lib/models/outreachIntegration.model.d.ts.map +1 -0
  37. package/lib/models/outreachIntegration.model.js +8 -0
  38. package/lib/models/video.model.d.ts +7 -1
  39. package/lib/models/video.model.d.ts.map +1 -1
  40. package/lib/schemas/videoPlan.schema.d.ts +1 -0
  41. package/lib/schemas/videoPlan.schema.d.ts.map +1 -1
  42. package/lib/schemas/videoPlan.schema.js +10 -0
  43. package/lib/services/agent/tools/generateAvatarVideo.tool.d.ts.map +1 -1
  44. package/lib/services/agent/tools/generateAvatarVideo.tool.js +3 -5
  45. package/lib/services/agent/tools/planVideo.tool.d.ts +1 -0
  46. package/lib/services/agent/tools/planVideo.tool.d.ts.map +1 -1
  47. package/lib/services/aiGen/providers/alibaba/alibaba.d.ts.map +1 -1
  48. package/lib/services/aiGen/providers/alibaba/alibaba.js +5 -11
  49. package/lib/services/aiGen/providers/bytedance/bytedance.service.d.ts.map +1 -1
  50. package/lib/services/aiGen/providers/bytedance/bytedance.service.js +5 -0
  51. package/lib/services/aiGen/providers/elevenlabs/elevenlabs.service.d.ts.map +1 -1
  52. package/lib/services/aiGen/providers/elevenlabs/elevenlabs.service.js +3 -7
  53. package/lib/services/aiGen/providers/google/google.service.d.ts.map +1 -1
  54. package/lib/services/aiGen/providers/google/google.service.js +7 -4
  55. package/lib/services/aiGen/providers/google/googleMusic.d.ts.map +1 -1
  56. package/lib/services/aiGen/providers/google/googleMusic.js +3 -7
  57. package/lib/services/aiGen/providers/kling/kling.service.d.ts +16 -7
  58. package/lib/services/aiGen/providers/kling/kling.service.d.ts.map +1 -1
  59. package/lib/services/aiGen/providers/kling/kling.service.js +2 -2
  60. package/lib/services/aiGen/providers/kling/klingImage.service.d.ts.map +1 -1
  61. package/lib/services/aiGen/providers/kling/klingImage.service.js +3 -5
  62. package/lib/services/aiGen/providers/kling/klingStatus.d.ts +1 -1
  63. package/lib/services/aiGen/providers/kling/klingStatus.d.ts.map +1 -1
  64. package/lib/services/aiGen/providers/kling/klingStatus.js +8 -19
  65. package/lib/services/aiGen/providers/minimax/minimax.service.d.ts.map +1 -1
  66. package/lib/services/aiGen/providers/minimax/minimax.service.js +7 -17
  67. package/lib/services/aiGen/providers/openai/openai.service.d.ts.map +1 -1
  68. package/lib/services/aiGen/providers/openai/openai.service.js +5 -13
  69. package/lib/services/aiGen/providers/pixverse/pixverse.service.d.ts.map +1 -1
  70. package/lib/services/aiGen/providers/pixverse/pixverse.service.js +5 -0
  71. package/lib/services/aiGen/providers/runway/runway.service.d.ts.map +1 -1
  72. package/lib/services/aiGen/providers/runway/runway.service.js +5 -10
  73. package/lib/services/avatarGen/IAvatarVideoProvider.d.ts +25 -3
  74. package/lib/services/avatarGen/IAvatarVideoProvider.d.ts.map +1 -1
  75. package/lib/services/avatarGen/IAvatarVideoProvider.js +2 -1
  76. package/lib/services/avatarGen/providers/heygenAvatarProvider.d.ts +23 -2
  77. package/lib/services/avatarGen/providers/heygenAvatarProvider.d.ts.map +1 -1
  78. package/lib/services/avatarGen/providers/heygenAvatarProvider.js +71 -0
  79. package/lib/services/avatarGen/providers/tavusAvatarProvider.d.ts +3 -4
  80. package/lib/services/avatarGen/providers/tavusAvatarProvider.d.ts.map +1 -1
  81. package/lib/services/avatarGen/providers/tavusAvatarProvider.js +17 -0
  82. package/lib/services/editor/planToProject.d.ts.map +1 -1
  83. package/lib/services/editor/planToProject.js +29 -1
  84. package/lib/services/firestore.service.d.ts +3 -0
  85. package/lib/services/firestore.service.d.ts.map +1 -1
  86. package/lib/services/firestore.service.js +7 -0
  87. package/lib/services/gcp/uploadAudioBuffer.d.ts.map +1 -1
  88. package/lib/services/gcp/uploadAudioBuffer.js +4 -0
  89. package/lib/services/index.d.ts +1 -0
  90. package/lib/services/index.d.ts.map +1 -1
  91. package/lib/services/index.js +1 -0
  92. package/lib/services/outreachWebhooks.service.d.ts +24 -0
  93. package/lib/services/outreachWebhooks.service.d.ts.map +1 -0
  94. package/lib/services/outreachWebhooks.service.js +41 -0
  95. package/package.json +1 -1
@@ -151,7 +151,23 @@ 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
+ * VidSpot Reach — Phase 7 self-serve API integration. One job per outbound
157
+ * webhook delivery attempt (campaign.completed / video.ready /
158
+ * recipient.viewed). BullMQ's own attempts+backoff drive the retry — the
159
+ * dispatcher enqueues once per active subscriber per event, the worker owns
160
+ * the signed HTTP POST.
161
+ */
162
+ WEBHOOK_DELIVERY_JOBS = "webhook-delivery-job-queue",
163
+ /**
164
+ * R2 cutover — mirrors a resumable-upload object (already in GCS, up to
165
+ * 1 GiB) into R2 off the request path. `completeUploadSessionController`
166
+ * can't safely buffer these in a Function's memory itself, so it enqueues
167
+ * here and the worker streams GCS → R2 directly. Best-effort: GCS is
168
+ * already the durable copy either way.
169
+ */
170
+ MEDIA_MIRROR_JOBS = "media-mirror-job-queue"
155
171
  }
156
172
  export declare const REDIS_QUEUES: ERedisQueues[];
157
173
  /** 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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AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAExE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;iBAiB5B,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,eAAO,MAAM,yBAAyB;;;;iBAapC,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;iBAEhC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
@@ -153,6 +153,22 @@ 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
+ * VidSpot Reach — Phase 7 self-serve API integration. One job per outbound
158
+ * webhook delivery attempt (campaign.completed / video.ready /
159
+ * recipient.viewed). BullMQ's own attempts+backoff drive the retry — the
160
+ * dispatcher enqueues once per active subscriber per event, the worker owns
161
+ * the signed HTTP POST.
162
+ */
163
+ ERedisQueues["WEBHOOK_DELIVERY_JOBS"] = "webhook-delivery-job-queue";
164
+ /**
165
+ * R2 cutover — mirrors a resumable-upload object (already in GCS, up to
166
+ * 1 GiB) into R2 off the request path. `completeUploadSessionController`
167
+ * can't safely buffer these in a Function's memory itself, so it enqueues
168
+ * here and the worker streams GCS → R2 directly. Best-effort: GCS is
169
+ * already the durable copy either way.
170
+ */
171
+ ERedisQueues["MEDIA_MIRROR_JOBS"] = "media-mirror-job-queue";
156
172
  })(ERedisQueues || (exports.ERedisQueues = ERedisQueues = {}));
157
173
  exports.REDIS_QUEUES = [
158
174
  ERedisQueues.VIDEO_JOBS,
@@ -172,6 +188,8 @@ exports.REDIS_QUEUES = [
172
188
  ERedisQueues.DEMO_VIDEO_JOBS,
173
189
  ERedisQueues.OUTREACH_PERSONALIZE_JOBS,
174
190
  ERedisQueues.VIDEO_QA_JOBS,
191
+ ERedisQueues.WEBHOOK_DELIVERY_JOBS,
192
+ ERedisQueues.MEDIA_MIRROR_JOBS,
175
193
  ];
176
194
  /** X8 Social Suite — connected social platforms. Value = stable storage key. */
177
195
  var ESocialProvider;
@@ -1,4 +1,5 @@
1
1
  export * from "./firebase";
2
2
  export * from "./r2KeyMap";
3
+ export * from "./storage";
3
4
  export * from "./mediaStore";
4
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;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,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
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./firebase"), exports);
18
18
  __exportStar(require("./r2KeyMap"), exports);
19
+ __exportStar(require("./storage"), exports);
19
20
  __exportStar(require("./mediaStore"), exports);
@@ -1,35 +1,7 @@
1
1
  /**
2
- * Media store — GCS system-of-record + optional zero-egress R2 mirror.
3
- * ====================================================================
4
- *
5
- * `putMedia()` is the single write path new media should flow through. It:
6
- * 1. writes the bytes to GCS (unchanged system-of-record + pipeline source),
7
- * 2. mirror-writes them to Cloudflare R2 at the clean `toR2Key()` key IF
8
- * `R2_WRITE_ENABLED=true` (best-effort — a mirror failure never breaks the
9
- * pipeline; GCS already succeeded), and
10
- * 3. returns the same far-future GCS signed URL the call sites already use, so
11
- * stored URLs / Firestore records don't change at all.
12
- *
13
- * Delivery then flips to free egress automatically: the `cdn.vidspotai.com`
14
- * Worker is R2-first, so once an object is in R2 it's served from R2; until then
15
- * the Worker falls back to GCS. See notes/R2_MEDIA_MIGRATION_PLAN.md (Phase 2).
16
- *
17
- * The R2 SDK is imported lazily (dynamic import) so it stays out of the module
18
- * import graph — the shared package is already heavy at import time and this
19
- * must not add to Cloud Function cold start (see
20
- * memory/project_shared_lazy_load.md).
21
- */
22
- /** R2 mirror-writes are opt-in; off = today's GCS-only behavior, exactly. */
23
- export declare function isR2WriteEnabled(): boolean;
24
- /**
25
- * Write media to GCS (+ optional R2 mirror) and return a far-future signed read
26
- * URL. Drop-in for the ubiquitous
27
- * `file.save(buffer, { contentType })` + `getSignedUrl({ expires: "03-09-2491" })`
28
- * pair.
29
- *
30
- * @param objectPath canonical GCS object key, e.g. "final_videos/<id>.mp4"
31
- * @param body the bytes to store
32
- * @param contentType MIME type, e.g. "video/mp4"
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.
33
5
  */
34
6
  export declare function putMedia(objectPath: string, body: Buffer, contentType: string): Promise<string>;
35
7
  //# sourceMappingURL=mediaStore.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mediaStore.d.ts","sourceRoot":"","sources":["../../src/libs/mediaStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAaH,6EAA6E;AAC7E,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C;AAsED;;;;;;;;;GASG;AACH,wBAAsB,QAAQ,CAC5B,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,CAajB"}
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"}
@@ -1,148 +1,24 @@
1
1
  "use strict";
2
- /**
3
- * Media store — GCS system-of-record + optional zero-egress R2 mirror.
4
- * ====================================================================
5
- *
6
- * `putMedia()` is the single write path new media should flow through. It:
7
- * 1. writes the bytes to GCS (unchanged system-of-record + pipeline source),
8
- * 2. mirror-writes them to Cloudflare R2 at the clean `toR2Key()` key IF
9
- * `R2_WRITE_ENABLED=true` (best-effort — a mirror failure never breaks the
10
- * pipeline; GCS already succeeded), and
11
- * 3. returns the same far-future GCS signed URL the call sites already use, so
12
- * stored URLs / Firestore records don't change at all.
13
- *
14
- * Delivery then flips to free egress automatically: the `cdn.vidspotai.com`
15
- * Worker is R2-first, so once an object is in R2 it's served from R2; until then
16
- * the Worker falls back to GCS. See notes/R2_MEDIA_MIGRATION_PLAN.md (Phase 2).
17
- *
18
- * The R2 SDK is imported lazily (dynamic import) so it stays out of the module
19
- * import graph — the shared package is already heavy at import time and this
20
- * must not add to Cloud Function cold start (see
21
- * memory/project_shared_lazy_load.md).
22
- */
23
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
24
- if (k2 === undefined) k2 = k;
25
- var desc = Object.getOwnPropertyDescriptor(m, k);
26
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
27
- desc = { enumerable: true, get: function() { return m[k]; } };
28
- }
29
- Object.defineProperty(o, k2, desc);
30
- }) : (function(o, m, k, k2) {
31
- if (k2 === undefined) k2 = k;
32
- o[k2] = m[k];
33
- }));
34
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
35
- Object.defineProperty(o, "default", { enumerable: true, value: v });
36
- }) : function(o, v) {
37
- o["default"] = v;
38
- });
39
- var __importStar = (this && this.__importStar) || (function () {
40
- var ownKeys = function(o) {
41
- ownKeys = Object.getOwnPropertyNames || function (o) {
42
- var ar = [];
43
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
44
- return ar;
45
- };
46
- return ownKeys(o);
47
- };
48
- return function (mod) {
49
- if (mod && mod.__esModule) return mod;
50
- var result = {};
51
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
52
- __setModuleDefault(result, mod);
53
- return result;
54
- };
55
- })();
56
2
  Object.defineProperty(exports, "__esModule", { value: true });
57
- exports.isR2WriteEnabled = isR2WriteEnabled;
58
3
  exports.putMedia = putMedia;
59
- const firebase_1 = require("./firebase");
60
- const r2KeyMap_1 = require("./r2KeyMap");
61
- const logger_1 = require("../utils/logger");
62
- // Far-future expiry — matches the permanent bearer-token URLs used everywhere
63
- // in the codebase (getSignedUrl expires "03-09-2491").
64
- const PERMANENT_EXPIRY = "03-09-2491";
65
- const R2_BUCKET = process.env.R2_BUCKET || "vidspot-media";
66
- /** R2 mirror-writes are opt-in; off = today's GCS-only behavior, exactly. */
67
- function isR2WriteEnabled() {
68
- return process.env.R2_WRITE_ENABLED === "true";
69
- }
70
- function r2Config() {
71
- const accessKeyId = process.env.CLOUDFLARE_R2_ACCESS_KEY_ID || process.env.R2_ACCESS_KEY_ID;
72
- const secretAccessKey = process.env.CLOUDFLARE_R2_SECRET_ACCESS_KEY ||
73
- process.env.R2_SECRET_ACCESS_KEY;
74
- const endpoint = process.env.CLOUDFLARE_R2_S3_ENDPOINT || process.env.R2_S3_ENDPOINT;
75
- return { accessKeyId, secretAccessKey, endpoint };
76
- }
77
- // Lazily-built singleton S3 client (only when the first mirror actually runs).
78
- let s3Client = null;
79
- let s3Init = null;
80
- async function getS3() {
81
- if (s3Client)
82
- return s3Client;
83
- if (s3Init)
84
- return s3Init;
85
- s3Init = (async () => {
86
- const { accessKeyId, secretAccessKey, endpoint } = r2Config();
87
- if (!accessKeyId || !secretAccessKey || !endpoint) {
88
- logger_1.logger.warn("mediaStore: R2_WRITE_ENABLED but R2 creds/endpoint missing — skipping mirror");
89
- return null;
90
- }
91
- const { S3Client: Client } = await Promise.resolve().then(() => __importStar(require("@aws-sdk/client-s3")));
92
- s3Client = new Client({
93
- region: "auto",
94
- endpoint,
95
- credentials: { accessKeyId, secretAccessKey },
96
- });
97
- return s3Client;
98
- })();
99
- return s3Init;
100
- }
101
4
  /**
102
- * Best-effort mirror of an object into R2. Never throws — a mirror failure is
103
- * logged and swallowed so the (already-succeeded) GCS write remains the truth.
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`.
104
15
  */
105
- async function mirrorToR2(objectPath, body, contentType) {
106
- try {
107
- const client = await getS3();
108
- if (!client)
109
- return;
110
- const { PutObjectCommand } = await Promise.resolve().then(() => __importStar(require("@aws-sdk/client-s3")));
111
- const r2Key = (0, r2KeyMap_1.toR2Key)(objectPath);
112
- await client.send(new PutObjectCommand({
113
- Bucket: R2_BUCKET,
114
- Key: r2Key,
115
- Body: body,
116
- ContentType: contentType,
117
- }));
118
- logger_1.logger.info("mediaStore: mirrored to R2", { objectPath, r2Key });
119
- }
120
- catch (err) {
121
- logger_1.logger.error("mediaStore: R2 mirror failed (GCS write still stands)", {
122
- objectPath,
123
- err: err instanceof Error ? err.stack ?? err.message : String(err),
124
- });
125
- }
126
- }
16
+ const storage_1 = require("./storage");
127
17
  /**
128
- * Write media to GCS (+ optional R2 mirror) and return a far-future signed read
129
- * URL. Drop-in for the ubiquitous
130
- * `file.save(buffer, { contentType })` + `getSignedUrl({ expires: "03-09-2491" })`
131
- * pair.
132
- *
133
- * @param objectPath canonical GCS object key, e.g. "final_videos/<id>.mp4"
134
- * @param body the bytes to store
135
- * @param contentType MIME type, e.g. "video/mp4"
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.
136
21
  */
137
- async function putMedia(objectPath, body, contentType) {
138
- const file = (0, firebase_1.getBucket)().file(objectPath);
139
- await file.save(body, { contentType });
140
- if (isR2WriteEnabled()) {
141
- await mirrorToR2(objectPath, body, contentType);
142
- }
143
- const [signedUrl] = await file.getSignedUrl({
144
- action: "read",
145
- expires: PERMANENT_EXPIRY,
146
- });
147
- return signedUrl;
22
+ function putMedia(objectPath, body, contentType) {
23
+ return storage_1.mediaStorage.put(objectPath, body, contentType);
148
24
  }
@@ -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,117 @@
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
+ * Stage 2 composition (flipped 2026-09-22 — full reasoning in
12
+ * notes/R2_MEDIA_MIGRATION_PLAN.md §9 "Stage 2 decision log — R2-primary flip"):
13
+ * • BYTES = R2 — the only place object bytes are written, read, or
14
+ * deleted for anything going through `put`/`putFromFile`/`delete` below.
15
+ * • URL MINTER = GCS — used ONLY to mint the V4-signed URL *shape* that
16
+ * the `cdn.vidspotai.com` Worker already recognizes, including its
17
+ * private-access gate (which just checks the signature param is
18
+ * present — see worker.js `privateRequestAllowed()`, it never
19
+ * cryptographically verifies it). V4 signing is a local crypto
20
+ * operation against the service-account key: no network call, and the
21
+ * object does NOT need to exist in the GCS bucket for a valid-shaped
22
+ * URL to be minted. So this eliminates real GCS *storage* (and its
23
+ * cost) while keeping one small, cost-free GCS *credential*
24
+ * dependency purely for the URL shape — a deliberate, documented
25
+ * trade-off, not an oversight. Building a fully GCS-independent
26
+ * signed-URL scheme (HMAC tokens + Worker verification) was considered
27
+ * and explicitly deferred — see the notes doc.
28
+ *
29
+ * NOT covered by this flip — a few bespoke pipeline paths write bytes
30
+ * directly to GCS via their own streaming/integrity logic instead of
31
+ * routing through `put`/`putFromFile` (direct multipart uploads in
32
+ * handleUploadFile.ts, resumable-upload completion in
33
+ * mediaUploadSession.controller.ts, the google.service.ts moov-atom guard,
34
+ * mediaMirrorQueueProcessor), then call `mirrorBytes`/`mirrorFromFile`/
35
+ * `mirrorFromReadable` below for a best-effort R2 copy. Those still write
36
+ * real bytes to GCS today — converting them is a separate, larger effort
37
+ * (see the notes doc §9).
38
+ */
39
+ import type { Readable } from "stream";
40
+ import type { IStorageBackend } from "./StorageBackend";
41
+ /**
42
+ * Legacy pipeline mirror-writes (see NOT COVERED above) stay opt-in behind
43
+ * this flag; unrelated to the `put`/`putFromFile`/`delete` R2-primary path,
44
+ * which is unconditional since 2026-09-22.
45
+ */
46
+ export declare function isR2WriteEnabled(): boolean;
47
+ export declare class MediaStorage {
48
+ /** Actual byte store — reads/writes/deletes real object data. */
49
+ private readonly bytes;
50
+ /** URL-shape minter only — never written to, never read from directly. */
51
+ private readonly urlMinter;
52
+ constructor(bytes: IStorageBackend, urlMinter: IStorageBackend);
53
+ /**
54
+ * Write in-memory bytes and return a durable delivery URL. Drop-in for the
55
+ * ubiquitous `file.save(buf, { contentType })` + `getSignedUrl({ expires })`
56
+ * pair.
57
+ *
58
+ * @param objectPath canonical object key, e.g. "final_videos/<id>.mp4"
59
+ */
60
+ put(objectPath: string, body: Buffer, contentType: string): Promise<string>;
61
+ /**
62
+ * Stream a local file to the primary (no whole-file buffering) and return the
63
+ * delivery URL plus the stored object size for integrity checks. For large
64
+ * clips whose GCS upload is size-verified by the caller (e.g. the google
65
+ * scene-download moov-atom guard).
66
+ */
67
+ putFromFile(objectPath: string, localPath: string, contentType: string): Promise<{
68
+ url: string;
69
+ size: number;
70
+ }>;
71
+ /**
72
+ * Best-effort R2 copy of an object ALREADY written to GCS by one of the
73
+ * bespoke pipeline paths listed in the class doc (a specialized
74
+ * streaming/integrity write that doesn't route through `put`). Distinct
75
+ * from `put`'s unconditional R2 write above: these callers still write
76
+ * their real/primary copy to GCS themselves, so this R2 copy is genuinely
77
+ * best-effort and stays flag-gated. No-op when disabled; never throws.
78
+ */
79
+ mirrorBytes(objectPath: string, body: Buffer, contentType: string): Promise<void>;
80
+ /**
81
+ * Best-effort R2 copy of a LOCAL FILE already written to GCS through a
82
+ * bespoke streaming/integrity path (e.g. the google scene-download
83
+ * moov-atom guard). Reads the file only when mirroring is enabled; never
84
+ * throws.
85
+ */
86
+ mirrorFromFile(objectPath: string, localPath: string, contentType: string): Promise<void>;
87
+ /**
88
+ * Best-effort R2 copy of an object ALREADY written to GCS, streamed
89
+ * straight through from an open Readable (e.g. a GCS read stream) without
90
+ * buffering it whole — for objects too large to safely hold in process
91
+ * memory (resumable uploads, up to 1 GiB). No-op when disabled, when the
92
+ * backend doesn't implement streaming writes, or on failure.
93
+ */
94
+ mirrorFromReadable(objectPath: string, stream: Readable, contentType: string, size: number): Promise<void>;
95
+ /** Delivery URL for an object already stored. */
96
+ signedReadUrl(objectPath: string): Promise<string>;
97
+ /**
98
+ * Delete the object's bytes from R2. Does NOT touch GCS — since 2026-09-22
99
+ * new writes never land there, so there's nothing of record to delete. Any
100
+ * pre-flip object that still has a GCS copy becomes orphaned bytes there;
101
+ * acceptable, since GCS bulk cleanup is its own explicitly user-gated step
102
+ * (see notes/R2_MEDIA_MIGRATION_PLAN.md) — this doesn't make that step
103
+ * harder, just means it'll find a few objects Firestore no longer
104
+ * references.
105
+ */
106
+ delete(objectPath: string): Promise<void>;
107
+ /**
108
+ * Run a legacy bespoke-pipeline mirror op, swallowing failures — the
109
+ * caller's own direct GCS write already stands regardless. Used only by
110
+ * mirrorBytes/mirrorFromFile/mirrorFromReadable above, never by
111
+ * put/putFromFile/delete (those need R2 to actually succeed).
112
+ */
113
+ private bestEffortMirror;
114
+ }
115
+ /** App-wide singleton: R2 is the byte store, GCS mints the URL shape only. */
116
+ export declare const mediaStorage: MediaStorage;
117
+ //# 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAGvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGxD;;;;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,iDAAiD;IACjD,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIlD;;;;;;;;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"}
@@ -0,0 +1,117 @@
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
+ /**
9
+ * Legacy pipeline mirror-writes (see NOT COVERED above) stay opt-in behind
10
+ * this flag; unrelated to the `put`/`putFromFile`/`delete` R2-primary path,
11
+ * which is unconditional since 2026-09-22.
12
+ */
13
+ function isR2WriteEnabled() {
14
+ return process.env.R2_WRITE_ENABLED === "true";
15
+ }
16
+ class MediaStorage {
17
+ constructor(bytes, urlMinter) {
18
+ this.bytes = bytes;
19
+ this.urlMinter = urlMinter;
20
+ }
21
+ /**
22
+ * Write in-memory bytes and return a durable delivery URL. Drop-in for the
23
+ * ubiquitous `file.save(buf, { contentType })` + `getSignedUrl({ expires })`
24
+ * pair.
25
+ *
26
+ * @param objectPath canonical object key, e.g. "final_videos/<id>.mp4"
27
+ */
28
+ async put(objectPath, body, contentType) {
29
+ await this.bytes.write(objectPath, body, contentType);
30
+ return this.urlMinter.signedReadUrl(objectPath);
31
+ }
32
+ /**
33
+ * Stream a local file to the primary (no whole-file buffering) and return the
34
+ * delivery URL plus the stored object size for integrity checks. For large
35
+ * clips whose GCS upload is size-verified by the caller (e.g. the google
36
+ * scene-download moov-atom guard).
37
+ */
38
+ async putFromFile(objectPath, localPath, contentType) {
39
+ const size = await this.bytes.writeFromFile(objectPath, localPath, contentType);
40
+ const url = await this.urlMinter.signedReadUrl(objectPath);
41
+ return { url, size };
42
+ }
43
+ /**
44
+ * Best-effort R2 copy of an object ALREADY written to GCS by one of the
45
+ * bespoke pipeline paths listed in the class doc (a specialized
46
+ * streaming/integrity write that doesn't route through `put`). Distinct
47
+ * from `put`'s unconditional R2 write above: these callers still write
48
+ * their real/primary copy to GCS themselves, so this R2 copy is genuinely
49
+ * best-effort and stays flag-gated. No-op when disabled; never throws.
50
+ */
51
+ async mirrorBytes(objectPath, body, contentType) {
52
+ if (!isR2WriteEnabled())
53
+ return;
54
+ await this.bestEffortMirror(() => this.bytes.write(objectPath, body, contentType), objectPath);
55
+ }
56
+ /**
57
+ * Best-effort R2 copy of a LOCAL FILE already written to GCS through a
58
+ * bespoke streaming/integrity path (e.g. the google scene-download
59
+ * moov-atom guard). Reads the file only when mirroring is enabled; never
60
+ * throws.
61
+ */
62
+ async mirrorFromFile(objectPath, localPath, contentType) {
63
+ if (!isR2WriteEnabled())
64
+ return;
65
+ await this.bestEffortMirror(() => this.bytes.writeFromFile(objectPath, localPath, contentType), objectPath);
66
+ }
67
+ /**
68
+ * Best-effort R2 copy of an object ALREADY written to GCS, streamed
69
+ * straight through from an open Readable (e.g. a GCS read stream) without
70
+ * buffering it whole — for objects too large to safely hold in process
71
+ * memory (resumable uploads, up to 1 GiB). No-op when disabled, when the
72
+ * backend doesn't implement streaming writes, or on failure.
73
+ */
74
+ async mirrorFromReadable(objectPath, stream, contentType, size) {
75
+ if (!isR2WriteEnabled())
76
+ return;
77
+ if (!this.bytes.writeFromReadable)
78
+ return;
79
+ await this.bestEffortMirror(() => this.bytes.writeFromReadable(objectPath, stream, contentType, size), objectPath);
80
+ }
81
+ /** Delivery URL for an object already stored. */
82
+ signedReadUrl(objectPath) {
83
+ return this.urlMinter.signedReadUrl(objectPath);
84
+ }
85
+ /**
86
+ * Delete the object's bytes from R2. Does NOT touch GCS — since 2026-09-22
87
+ * new writes never land there, so there's nothing of record to delete. Any
88
+ * pre-flip object that still has a GCS copy becomes orphaned bytes there;
89
+ * acceptable, since GCS bulk cleanup is its own explicitly user-gated step
90
+ * (see notes/R2_MEDIA_MIGRATION_PLAN.md) — this doesn't make that step
91
+ * harder, just means it'll find a few objects Firestore no longer
92
+ * references.
93
+ */
94
+ async delete(objectPath) {
95
+ await this.bytes.delete(objectPath);
96
+ }
97
+ /**
98
+ * Run a legacy bespoke-pipeline mirror op, swallowing failures — the
99
+ * caller's own direct GCS write already stands regardless. Used only by
100
+ * mirrorBytes/mirrorFromFile/mirrorFromReadable above, never by
101
+ * put/putFromFile/delete (those need R2 to actually succeed).
102
+ */
103
+ async bestEffortMirror(op, objectPath) {
104
+ try {
105
+ await op();
106
+ }
107
+ catch (err) {
108
+ logger_1.logger.error("MediaStorage: R2 mirror failed (GCS write stands)", {
109
+ objectPath,
110
+ err: err instanceof Error ? err.stack ?? err.message : String(err),
111
+ });
112
+ }
113
+ }
114
+ }
115
+ exports.MediaStorage = MediaStorage;
116
+ /** App-wide singleton: R2 is the byte store, GCS mints the URL shape only. */
117
+ exports.mediaStorage = new MediaStorage(new R2Backend_1.R2Backend(), new GcsBackend_1.GcsBackend());