vidspotai-shared 1.0.117 → 1.0.119

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 (72) hide show
  1. package/lib/globals/aiModels/enums.d.ts +22 -1
  2. package/lib/globals/aiModels/enums.d.ts.map +1 -1
  3. package/lib/globals/aiModels/enums.js +22 -1
  4. package/lib/globals/aiModels/index.d.ts.map +1 -1
  5. package/lib/globals/aiModels/index.js +2 -0
  6. package/lib/globals/aiModels/providers/topaz.d.ts +21 -0
  7. package/lib/globals/aiModels/providers/topaz.d.ts.map +1 -0
  8. package/lib/globals/aiModels/providers/topaz.js +57 -0
  9. package/lib/globals/aiModels/types.d.ts +7 -1
  10. package/lib/globals/aiModels/types.d.ts.map +1 -1
  11. package/lib/globals/types.d.ts +26 -1
  12. package/lib/globals/types.d.ts.map +1 -1
  13. package/lib/globals/types.js +31 -1
  14. package/lib/libs/storage/MediaStorage.d.ts +4 -3
  15. package/lib/libs/storage/MediaStorage.d.ts.map +1 -1
  16. package/lib/models/index.d.ts +2 -0
  17. package/lib/models/index.d.ts.map +1 -1
  18. package/lib/models/index.js +2 -0
  19. package/lib/models/posterProject.model.d.ts +30 -0
  20. package/lib/models/posterProject.model.d.ts.map +1 -0
  21. package/lib/models/posterProject.model.js +2 -0
  22. package/lib/models/upscale.model.d.ts +57 -0
  23. package/lib/models/upscale.model.d.ts.map +1 -0
  24. package/lib/models/upscale.model.js +2 -0
  25. package/lib/schemas/project.schema.d.ts +226 -0
  26. package/lib/schemas/project.schema.d.ts.map +1 -1
  27. package/lib/schemas/project.schema.js +45 -1
  28. package/lib/schemas/videoPlan.schema.d.ts +3 -3
  29. package/lib/services/agent/tools/composeScene.tool.d.ts +204 -0
  30. package/lib/services/agent/tools/composeScene.tool.d.ts.map +1 -1
  31. package/lib/services/agent/tools/estimateCost.tool.d.ts +68 -0
  32. package/lib/services/agent/tools/estimateCost.tool.d.ts.map +1 -1
  33. package/lib/services/agent/tools/planVideo.tool.d.ts +1 -1
  34. package/lib/services/agent/tools/render.tool.d.ts +68 -0
  35. package/lib/services/agent/tools/render.tool.d.ts.map +1 -1
  36. package/lib/services/aiGen/aiGenFactory.service.d.ts +19 -1
  37. package/lib/services/aiGen/aiGenFactory.service.d.ts.map +1 -1
  38. package/lib/services/aiGen/aiGenFactory.service.js +38 -1
  39. package/lib/services/aiGen/providers/baseAiGenProvider.service.d.ts +13 -1
  40. package/lib/services/aiGen/providers/baseAiGenProvider.service.d.ts.map +1 -1
  41. package/lib/services/aiGen/providers/baseAiGenProvider.service.js +20 -0
  42. package/lib/services/aiGen/providers/fal/falUpscale.service.d.ts +38 -0
  43. package/lib/services/aiGen/providers/fal/falUpscale.service.d.ts.map +1 -0
  44. package/lib/services/aiGen/providers/fal/falUpscale.service.js +226 -0
  45. package/lib/services/aiGen/providers/fal/index.d.ts +1 -0
  46. package/lib/services/aiGen/providers/fal/index.d.ts.map +1 -1
  47. package/lib/services/aiGen/providers/fal/index.js +1 -0
  48. package/lib/services/aiGen/providers/openai/openai.service.d.ts.map +1 -1
  49. package/lib/services/aiGen/providers/openai/openai.service.js +88 -56
  50. package/lib/services/aiGen/providers/topaz/topaz.service.d.ts +51 -0
  51. package/lib/services/aiGen/providers/topaz/topaz.service.d.ts.map +1 -0
  52. package/lib/services/aiGen/providers/topaz/topaz.service.js +321 -0
  53. package/lib/services/aiGen/providers/types.d.ts +73 -2
  54. package/lib/services/aiGen/providers/types.d.ts.map +1 -1
  55. package/lib/services/editor/designToProject.d.ts +10 -1
  56. package/lib/services/editor/designToProject.d.ts.map +1 -1
  57. package/lib/services/editor/designToProject.js +78 -8
  58. package/lib/services/editor/projectToDesign.d.ts.map +1 -1
  59. package/lib/services/editor/projectToDesign.js +38 -2
  60. package/lib/services/firestore.service.d.ts +4 -0
  61. package/lib/services/firestore.service.d.ts.map +1 -1
  62. package/lib/services/firestore.service.js +6 -0
  63. package/lib/services/index.d.ts +1 -0
  64. package/lib/services/index.d.ts.map +1 -1
  65. package/lib/services/index.js +1 -0
  66. package/lib/services/moderation/index.d.ts +3 -0
  67. package/lib/services/moderation/index.d.ts.map +1 -0
  68. package/lib/services/moderation/index.js +5 -0
  69. package/lib/services/moderation/textModeration.service.d.ts +6 -0
  70. package/lib/services/moderation/textModeration.service.d.ts.map +1 -0
  71. package/lib/services/moderation/textModeration.service.js +44 -0
  72. package/package.json +1 -1
@@ -241,6 +241,12 @@ declare const InputSchema: z.ZodObject<{
241
241
  }>>;
242
242
  backgroundColor: z.ZodOptional<z.ZodString>;
243
243
  shadow: z.ZodOptional<z.ZodString>;
244
+ gradient: z.ZodOptional<z.ZodObject<{
245
+ from: z.ZodString;
246
+ to: z.ZodString;
247
+ angle: z.ZodOptional<z.ZodNumber>;
248
+ }, z.core.$strip>>;
249
+ curve: z.ZodOptional<z.ZodNumber>;
244
250
  preset: z.ZodOptional<z.ZodEnum<{
245
251
  none: "none";
246
252
  "fade-soft": "fade-soft";
@@ -351,6 +357,68 @@ declare const InputSchema: z.ZodObject<{
351
357
  }, z.core.$strip>>;
352
358
  locked: z.ZodDefault<z.ZodBoolean>;
353
359
  metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
360
+ }, z.core.$strip>, z.ZodObject<{
361
+ type: z.ZodLiteral<"shape">;
362
+ width: z.ZodNumber;
363
+ height: z.ZodNumber;
364
+ shapeKind: z.ZodOptional<z.ZodEnum<{
365
+ rectangle: "rectangle";
366
+ ellipse: "ellipse";
367
+ line: "line";
368
+ triangle: "triangle";
369
+ arrow: "arrow";
370
+ }>>;
371
+ fill: z.ZodDefault<z.ZodString>;
372
+ gradient: z.ZodOptional<z.ZodObject<{
373
+ from: z.ZodString;
374
+ to: z.ZodString;
375
+ angle: z.ZodOptional<z.ZodNumber>;
376
+ }, z.core.$strip>>;
377
+ borderWidth: z.ZodOptional<z.ZodNumber>;
378
+ borderColor: z.ZodOptional<z.ZodString>;
379
+ borderRadius: z.ZodOptional<z.ZodNumber>;
380
+ maskSrc: z.ZodOptional<z.ZodString>;
381
+ id: z.ZodString;
382
+ trackId: z.ZodString;
383
+ display: z.ZodObject<{
384
+ from: z.ZodNumber;
385
+ to: z.ZodNumber;
386
+ }, z.core.$strip>;
387
+ name: z.ZodOptional<z.ZodString>;
388
+ provenance: z.ZodOptional<z.ZodObject<{
389
+ tier: z.ZodEnum<{
390
+ T0: "T0";
391
+ T1: "T1";
392
+ T2: "T2";
393
+ T3: "T3";
394
+ }>;
395
+ source: z.ZodString;
396
+ modelKey: z.ZodOptional<z.ZodString>;
397
+ prompt: z.ZodOptional<z.ZodString>;
398
+ assetHash: z.ZodOptional<z.ZodString>;
399
+ creditsSpent: z.ZodOptional<z.ZodNumber>;
400
+ generationId: z.ZodOptional<z.ZodString>;
401
+ attribution: z.ZodOptional<z.ZodObject<{
402
+ name: z.ZodString;
403
+ url: z.ZodOptional<z.ZodString>;
404
+ }, z.core.$strip>>;
405
+ }, z.core.$strip>>;
406
+ effects: z.ZodDefault<z.ZodArray<z.ZodObject<{
407
+ id: z.ZodString;
408
+ kind: z.ZodString;
409
+ enabled: z.ZodDefault<z.ZodBoolean>;
410
+ params: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
411
+ }, z.core.$strip>>>;
412
+ transform: z.ZodDefault<z.ZodObject<{
413
+ x: z.ZodDefault<z.ZodNumber>;
414
+ y: z.ZodDefault<z.ZodNumber>;
415
+ scaleX: z.ZodDefault<z.ZodNumber>;
416
+ scaleY: z.ZodDefault<z.ZodNumber>;
417
+ rotation: z.ZodDefault<z.ZodNumber>;
418
+ opacity: z.ZodDefault<z.ZodNumber>;
419
+ }, z.core.$strip>>;
420
+ locked: z.ZodDefault<z.ZodBoolean>;
421
+ metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
354
422
  }, z.core.$strip>], "type">>;
355
423
  transitions: z.ZodDefault<z.ZodArray<z.ZodObject<{
356
424
  id: z.ZodString;
@@ -1 +1 @@
1
- {"version":3,"file":"estimateCost.tool.d.ts","sourceRoot":"","sources":["../../../../src/services/agent/tools/estimateCost.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAgB,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE/D,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAEf,CAAC;AAEH,QAAA,MAAM,YAAY;;;;;;;;;;;;;;iBAmBhB,CAAC;AAEH,eAAO,MAAM,gBAAgB,EAAE,cAAc,CAC3C,OAAO,WAAW,EAClB,OAAO,YAAY,CAgEpB,CAAC"}
1
+ {"version":3,"file":"estimateCost.tool.d.ts","sourceRoot":"","sources":["../../../../src/services/agent/tools/estimateCost.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAgB,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE/D,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAEf,CAAC;AAEH,QAAA,MAAM,YAAY;;;;;;;;;;;;;;iBAmBhB,CAAC;AAEH,eAAO,MAAM,gBAAgB,EAAE,cAAc,CAC3C,OAAO,WAAW,EAClB,OAAO,YAAY,CAgEpB,CAAC"}
@@ -308,12 +308,12 @@ declare const OutputSchema: z.ZodObject<{
308
308
  y: z.ZodNumber;
309
309
  }, z.core.$strip>>;
310
310
  backgroundFill: z.ZodOptional<z.ZodEnum<{
311
+ gradient: "gradient";
311
312
  black: "black";
312
313
  white: "white";
313
314
  "brand-primary": "brand-primary";
314
315
  "brand-secondary": "brand-secondary";
315
316
  "blur-extend": "blur-extend";
316
- gradient: "gradient";
317
317
  }>>;
318
318
  }, z.core.$strip>>;
319
319
  broll: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -256,6 +256,12 @@ declare const InputSchema: z.ZodObject<{
256
256
  }>>;
257
257
  backgroundColor: z.ZodOptional<z.ZodString>;
258
258
  shadow: z.ZodOptional<z.ZodString>;
259
+ gradient: z.ZodOptional<z.ZodObject<{
260
+ from: z.ZodString;
261
+ to: z.ZodString;
262
+ angle: z.ZodOptional<z.ZodNumber>;
263
+ }, z.core.$strip>>;
264
+ curve: z.ZodOptional<z.ZodNumber>;
259
265
  preset: z.ZodOptional<z.ZodEnum<{
260
266
  none: "none";
261
267
  "fade-soft": "fade-soft";
@@ -366,6 +372,68 @@ declare const InputSchema: z.ZodObject<{
366
372
  }, z.core.$strip>>;
367
373
  locked: z.ZodDefault<z.ZodBoolean>;
368
374
  metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
375
+ }, z.core.$strip>, z.ZodObject<{
376
+ type: z.ZodLiteral<"shape">;
377
+ width: z.ZodNumber;
378
+ height: z.ZodNumber;
379
+ shapeKind: z.ZodOptional<z.ZodEnum<{
380
+ rectangle: "rectangle";
381
+ ellipse: "ellipse";
382
+ line: "line";
383
+ triangle: "triangle";
384
+ arrow: "arrow";
385
+ }>>;
386
+ fill: z.ZodDefault<z.ZodString>;
387
+ gradient: z.ZodOptional<z.ZodObject<{
388
+ from: z.ZodString;
389
+ to: z.ZodString;
390
+ angle: z.ZodOptional<z.ZodNumber>;
391
+ }, z.core.$strip>>;
392
+ borderWidth: z.ZodOptional<z.ZodNumber>;
393
+ borderColor: z.ZodOptional<z.ZodString>;
394
+ borderRadius: z.ZodOptional<z.ZodNumber>;
395
+ maskSrc: z.ZodOptional<z.ZodString>;
396
+ id: z.ZodString;
397
+ trackId: z.ZodString;
398
+ display: z.ZodObject<{
399
+ from: z.ZodNumber;
400
+ to: z.ZodNumber;
401
+ }, z.core.$strip>;
402
+ name: z.ZodOptional<z.ZodString>;
403
+ provenance: z.ZodOptional<z.ZodObject<{
404
+ tier: z.ZodEnum<{
405
+ T0: "T0";
406
+ T1: "T1";
407
+ T2: "T2";
408
+ T3: "T3";
409
+ }>;
410
+ source: z.ZodString;
411
+ modelKey: z.ZodOptional<z.ZodString>;
412
+ prompt: z.ZodOptional<z.ZodString>;
413
+ assetHash: z.ZodOptional<z.ZodString>;
414
+ creditsSpent: z.ZodOptional<z.ZodNumber>;
415
+ generationId: z.ZodOptional<z.ZodString>;
416
+ attribution: z.ZodOptional<z.ZodObject<{
417
+ name: z.ZodString;
418
+ url: z.ZodOptional<z.ZodString>;
419
+ }, z.core.$strip>>;
420
+ }, z.core.$strip>>;
421
+ effects: z.ZodDefault<z.ZodArray<z.ZodObject<{
422
+ id: z.ZodString;
423
+ kind: z.ZodString;
424
+ enabled: z.ZodDefault<z.ZodBoolean>;
425
+ params: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
426
+ }, z.core.$strip>>>;
427
+ transform: z.ZodDefault<z.ZodObject<{
428
+ x: z.ZodDefault<z.ZodNumber>;
429
+ y: z.ZodDefault<z.ZodNumber>;
430
+ scaleX: z.ZodDefault<z.ZodNumber>;
431
+ scaleY: z.ZodDefault<z.ZodNumber>;
432
+ rotation: z.ZodDefault<z.ZodNumber>;
433
+ opacity: z.ZodDefault<z.ZodNumber>;
434
+ }, z.core.$strip>>;
435
+ locked: z.ZodDefault<z.ZodBoolean>;
436
+ metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
369
437
  }, z.core.$strip>], "type">>;
370
438
  transitions: z.ZodDefault<z.ZodArray<z.ZodObject<{
371
439
  id: z.ZodString;
@@ -1 +1 @@
1
- {"version":3,"file":"render.tool.d.ts","sourceRoot":"","sources":["../../../../src/services/agent/tools/render.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAgB,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE/D;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;IACvC,OAAO,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,CAAC;CAC3C,KAAK,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAGvC,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,eAAe,GAAG,IAAI,CAE5D;AAED,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAQf,CAAC;AAEH,QAAA,MAAM,YAAY;;;iBAGhB,CAAC;AAEH,eAAO,MAAM,UAAU,EAAE,cAAc,CACrC,OAAO,WAAW,EAClB,OAAO,YAAY,CA2BpB,CAAC"}
1
+ {"version":3,"file":"render.tool.d.ts","sourceRoot":"","sources":["../../../../src/services/agent/tools/render.tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAgB,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE/D;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;IACvC,OAAO,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,CAAC;CAC3C,KAAK,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAGvC,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,eAAe,GAAG,IAAI,CAE5D;AAED,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAQf,CAAC;AAEH,QAAA,MAAM,YAAY;;;iBAGhB,CAAC;AAEH,eAAO,MAAM,UAAU,EAAE,cAAc,CACrC,OAAO,WAAW,EAClB,OAAO,YAAY,CA2BpB,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { BaseAiGenProviderService } from "./providers/baseAiGenProvider.service";
2
- import { EImageGenModelKey, EMusicGenModels, ESfxGenModels, ETextGenModels, EVideoGenModels, TAiGenModel } from "../../globals/aiModels";
2
+ import { EImageGenModelKey, EMusicGenModels, ESfxGenModels, ETextGenModels, EUpscaleImageModelKey, EUpscaleVideoModelKey, EVideoGenModels, TAiGenModel } from "../../globals/aiModels";
3
3
  type AiGenServiceConstructor = new () => BaseAiGenProviderService;
4
4
  export declare const videoServicesMap: Partial<Record<EVideoGenModels, AiGenServiceConstructor>>;
5
5
  /**
@@ -26,6 +26,24 @@ export declare const musicServicesMap: Record<EMusicGenModels, AiGenServiceConst
26
26
  */
27
27
  export declare const sfxServicesMap: Record<ESfxGenModels, AiGenServiceConstructor>;
28
28
  export declare const textServicesMap: Record<ETextGenModels, AiGenServiceConstructor>;
29
+ /**
30
+ * Upscale factories — deliberately separate from `imageServicesMap` /
31
+ * `videoServicesMap` (and NOT folded into `getAiGenProviderService`): upscale
32
+ * callers (upscale controller/processors) always know their modality up
33
+ * front, so a giant shared if-chain would just add an unused branch to every
34
+ * other caller.
35
+ *
36
+ * Currently routed to FalUpscaleService (fal.ai `fal-ai/esrgan` /
37
+ * `fal-ai/video-upscaler`), NOT TopazService — this is a cost/pricing
38
+ * evaluation swap, not a model-key change: the enum keys, request schemas,
39
+ * and credit-estimate formulas are all still the "topaz-*" ones (see
40
+ * FalUpscaleService.getCreditUsed doc). TopazService itself is untouched and
41
+ * fully working; revert either line below to switch back.
42
+ */
43
+ export declare const upscaleImageServicesMap: Record<EUpscaleImageModelKey, AiGenServiceConstructor>;
44
+ export declare const upscaleVideoServicesMap: Record<EUpscaleVideoModelKey, AiGenServiceConstructor>;
45
+ export declare function getUpscaleImageProviderService(modelKey: EUpscaleImageModelKey): BaseAiGenProviderService;
46
+ export declare function getUpscaleVideoProviderService(modelKey: EUpscaleVideoModelKey): BaseAiGenProviderService;
29
47
  export declare function getAiGenProviderService(modelKey: TAiGenModel): BaseAiGenProviderService;
30
48
  export {};
31
49
  //# sourceMappingURL=aiGenFactory.service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"aiGenFactory.service.d.ts","sourceRoot":"","sources":["../../../src/services/aiGen/aiGenFactory.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,EACL,iBAAiB,EAEjB,eAAe,EACf,aAAa,EACb,cAAc,EACd,eAAe,EACf,WAAW,EACZ,MAAM,wBAAwB,CAAC;AAchC,KAAK,uBAAuB,GAAG,UAAU,wBAAwB,CAAC;AASlE,eAAO,MAAM,gBAAgB,EAAE,OAAO,CACpC,MAAM,CAAC,eAAe,EAAE,uBAAuB,CAAC,CAkEjD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,iBAAiB,EACjB,uBAAuB,CA2CxB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,eAAe,EACf,uBAAuB,CAMxB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,aAAa,EACb,uBAAuB,CAGxB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,cAAc,EAAE,uBAAuB,CAsBzE,CAAC;AAEJ,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,WAAW,GACpB,wBAAwB,CAmB1B"}
1
+ {"version":3,"file":"aiGenFactory.service.d.ts","sourceRoot":"","sources":["../../../src/services/aiGen/aiGenFactory.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,EACL,iBAAiB,EAEjB,eAAe,EACf,aAAa,EACb,cAAc,EACd,qBAAqB,EAErB,qBAAqB,EAErB,eAAe,EACf,WAAW,EACZ,MAAM,wBAAwB,CAAC;AAehC,KAAK,uBAAuB,GAAG,UAAU,wBAAwB,CAAC;AASlE,eAAO,MAAM,gBAAgB,EAAE,OAAO,CACpC,MAAM,CAAC,eAAe,EAAE,uBAAuB,CAAC,CAkEjD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,iBAAiB,EACjB,uBAAuB,CA2CxB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,eAAe,EACf,uBAAuB,CAMxB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,aAAa,EACb,uBAAuB,CAGxB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,cAAc,EAAE,uBAAuB,CAsBzE,CAAC;AAEJ;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAC1C,qBAAqB,EACrB,uBAAuB,CAGxB,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAC1C,qBAAqB,EACrB,uBAAuB,CAGxB,CAAC;AAEF,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,qBAAqB,GAC9B,wBAAwB,CAM1B;AAED,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,qBAAqB,GAC9B,wBAAwB,CAM1B;AAED,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,WAAW,GACpB,wBAAwB,CAmB1B"}
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.textServicesMap = exports.sfxServicesMap = exports.musicServicesMap = exports.imageServicesMap = exports.videoServicesMap = void 0;
3
+ exports.upscaleVideoServicesMap = exports.upscaleImageServicesMap = exports.textServicesMap = exports.sfxServicesMap = exports.musicServicesMap = exports.imageServicesMap = exports.videoServicesMap = void 0;
4
+ exports.getUpscaleImageProviderService = getUpscaleImageProviderService;
5
+ exports.getUpscaleVideoProviderService = getUpscaleVideoProviderService;
4
6
  exports.getAiGenProviderService = getAiGenProviderService;
5
7
  const aiModels_1 = require("../../globals/aiModels");
6
8
  const google_service_1 = require("./providers/google/google.service");
@@ -14,6 +16,7 @@ const pixverse_service_1 = require("./providers/pixverse/pixverse.service");
14
16
  const bytedance_service_1 = require("./providers/bytedance/bytedance.service");
15
17
  const elevenlabs_service_1 = require("./providers/elevenlabs/elevenlabs.service");
16
18
  const anthropic_service_1 = require("./providers/anthropic/anthropic.service");
19
+ const falUpscale_service_1 = require("./providers/fal/falUpscale.service");
17
20
  // Partial, intentionally: hosted avatar engines (heygen-avatar, tavus-avatar)
18
21
  // are NOT generic video models — they're handled by the dedicated avatar seam
19
22
  // (getAvatarVideoProvider / IAvatarVideoProvider). getAiGenProviderService gates
@@ -166,6 +169,40 @@ exports.textServicesMap = {
166
169
  // "openai-gpt-4o": OpenaiService,
167
170
  // "openai-gpt-3.5-turbo": OpenaiService,
168
171
  };
172
+ /**
173
+ * Upscale factories — deliberately separate from `imageServicesMap` /
174
+ * `videoServicesMap` (and NOT folded into `getAiGenProviderService`): upscale
175
+ * callers (upscale controller/processors) always know their modality up
176
+ * front, so a giant shared if-chain would just add an unused branch to every
177
+ * other caller.
178
+ *
179
+ * Currently routed to FalUpscaleService (fal.ai `fal-ai/esrgan` /
180
+ * `fal-ai/video-upscaler`), NOT TopazService — this is a cost/pricing
181
+ * evaluation swap, not a model-key change: the enum keys, request schemas,
182
+ * and credit-estimate formulas are all still the "topaz-*" ones (see
183
+ * FalUpscaleService.getCreditUsed doc). TopazService itself is untouched and
184
+ * fully working; revert either line below to switch back.
185
+ */
186
+ exports.upscaleImageServicesMap = {
187
+ [aiModels_1.EUpscaleImageModels.TOPAZ_IMAGE_STANDARD_V2]: falUpscale_service_1.FalUpscaleService, // was: TopazService
188
+ };
189
+ exports.upscaleVideoServicesMap = {
190
+ [aiModels_1.EUpscaleVideoModels.TOPAZ_VIDEO_PROTEUS]: falUpscale_service_1.FalUpscaleService, // was: TopazService
191
+ };
192
+ function getUpscaleImageProviderService(modelKey) {
193
+ const Service = exports.upscaleImageServicesMap[modelKey];
194
+ if (!Service) {
195
+ throw new Error(`Unsupported upscale image model: ${modelKey}`);
196
+ }
197
+ return new Service();
198
+ }
199
+ function getUpscaleVideoProviderService(modelKey) {
200
+ const Service = exports.upscaleVideoServicesMap[modelKey];
201
+ if (!Service) {
202
+ throw new Error(`Unsupported upscale video model: ${modelKey}`);
203
+ }
204
+ return new Service();
205
+ }
169
206
  function getAiGenProviderService(modelKey) {
170
207
  const VideoService = exports.videoServicesMap[modelKey];
171
208
  if (VideoService) {
@@ -1,4 +1,4 @@
1
- import { CreditUsageParams, ImageGenerationParams, ImageGenerationResult, MusicGenerationParams, MusicGenerationResult, SfxGenerationParams, SfxGenerationResult, StockSearchParams, StockSearchResult, TextGenerationParams, TextGenerationResult, VideoGenerationParams, VideoGenerationResult, VideoStatusParams, VideoStatusResult } from "./types";
1
+ import { CreditUsageParams, ImageGenerationParams, ImageGenerationResult, MusicGenerationParams, MusicGenerationResult, SfxGenerationParams, SfxGenerationResult, StockSearchParams, StockSearchResult, TextGenerationParams, TextGenerationResult, UpscaleImageParams, UpscaleImageStatusResult, UpscaleStatusParams, UpscaleSubmitResult, UpscaleVideoParams, UpscaleVideoStatusResult, VideoGenerationParams, VideoGenerationResult, VideoStatusParams, VideoStatusResult } from "./types";
2
2
  /**
3
3
  * Base class for every AI-generation provider (video, image, text).
4
4
  *
@@ -21,6 +21,18 @@ export declare abstract class BaseAiGenProviderService {
21
21
  generateSoundEffects(params: SfxGenerationParams): Promise<SfxGenerationResult>;
22
22
  /** Stock asset search (T0 tier providers like Pexels/Pixabay). */
23
23
  searchStock(params: StockSearchParams): Promise<StockSearchResult>;
24
+ /** Submit an async image-upscale job. Returns the provider's request id — poll via checkUpscaleImageStatus. */
25
+ upscaleImage(params: UpscaleImageParams): Promise<UpscaleSubmitResult>;
26
+ /** Poll an image-upscale job. On completion, `outputUrl` must already be persisted into our own storage. */
27
+ checkUpscaleImageStatus(params: UpscaleStatusParams): Promise<UpscaleImageStatusResult>;
28
+ /**
29
+ * Submit an async video-upscale job. Drives the full submit -> accept ->
30
+ * upload -> complete-upload sequence and returns the provider's request id
31
+ * once processing has started — poll via checkUpscaleVideoStatus.
32
+ */
33
+ upscaleVideo(params: UpscaleVideoParams): Promise<UpscaleSubmitResult>;
34
+ /** Poll a video-upscale job. On completion, `outputUrl` must already be persisted into our own storage. */
35
+ checkUpscaleVideoStatus(params: UpscaleStatusParams): Promise<UpscaleVideoStatusResult>;
24
36
  getCreditUsed(params: CreditUsageParams): number;
25
37
  }
26
38
  //# sourceMappingURL=baseAiGenProvider.service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"baseAiGenProvider.service.d.ts","sourceRoot":"","sources":["../../../../src/services/aiGen/providers/baseAiGenProvider.service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;GASG;AACH,8BAAsB,wBAAwB;IACtC,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IAI3B,gBAAgB,CACpB,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,iBAAiB,CAAC;IAIvB,YAAY,CAChB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,oBAAoB,CAAC;IAIhC,oEAAoE;IAC9D,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IAIjC,8FAA8F;IACxF,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IAIjC,0DAA0D;IACpD,oBAAoB,CACxB,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,mBAAmB,CAAC;IAI/B,kEAAkE;IAC5D,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAIxE,aAAa,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM;CAGjD"}
1
+ {"version":3,"file":"baseAiGenProvider.service.d.ts","sourceRoot":"","sources":["../../../../src/services/aiGen/providers/baseAiGenProvider.service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;GASG;AACH,8BAAsB,wBAAwB;IACtC,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IAI3B,gBAAgB,CACpB,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,iBAAiB,CAAC;IAIvB,YAAY,CAChB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,oBAAoB,CAAC;IAIhC,oEAAoE;IAC9D,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IAIjC,8FAA8F;IACxF,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IAIjC,0DAA0D;IACpD,oBAAoB,CACxB,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,mBAAmB,CAAC;IAI/B,kEAAkE;IAC5D,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAIxE,+GAA+G;IACzG,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAI5E,4GAA4G;IACtG,uBAAuB,CAC3B,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,wBAAwB,CAAC;IAMpC;;;;OAIG;IACG,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAI5E,2GAA2G;IACrG,uBAAuB,CAC3B,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,wBAAwB,CAAC;IAMpC,aAAa,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM;CAGjD"}
@@ -37,6 +37,26 @@ class BaseAiGenProviderService {
37
37
  async searchStock(params) {
38
38
  throw new Error("searchStock not implemented for this provider");
39
39
  }
40
+ /** Submit an async image-upscale job. Returns the provider's request id — poll via checkUpscaleImageStatus. */
41
+ async upscaleImage(params) {
42
+ throw new Error("upscaleImage not implemented for this provider");
43
+ }
44
+ /** Poll an image-upscale job. On completion, `outputUrl` must already be persisted into our own storage. */
45
+ async checkUpscaleImageStatus(params) {
46
+ throw new Error("checkUpscaleImageStatus not implemented for this provider");
47
+ }
48
+ /**
49
+ * Submit an async video-upscale job. Drives the full submit -> accept ->
50
+ * upload -> complete-upload sequence and returns the provider's request id
51
+ * once processing has started — poll via checkUpscaleVideoStatus.
52
+ */
53
+ async upscaleVideo(params) {
54
+ throw new Error("upscaleVideo not implemented for this provider");
55
+ }
56
+ /** Poll a video-upscale job. On completion, `outputUrl` must already be persisted into our own storage. */
57
+ async checkUpscaleVideoStatus(params) {
58
+ throw new Error("checkUpscaleVideoStatus not implemented for this provider");
59
+ }
40
60
  getCreditUsed(params) {
41
61
  throw new Error("getCreditUsed not implemented for this provider");
42
62
  }
@@ -0,0 +1,38 @@
1
+ import { BaseAiGenProviderService } from "../baseAiGenProvider.service";
2
+ import { CreditUsageParams, UpscaleImageParams, UpscaleImageStatusResult, UpscaleStatusParams, UpscaleSubmitResult, UpscaleVideoParams, UpscaleVideoStatusResult } from "../types";
3
+ /**
4
+ * fal.ai upscale provider (image + video) — wired in behind the SAME
5
+ * EUpscaleImageModels/EUpscaleVideoModels model keys Topaz used
6
+ * ("topaz-image-standard-v2" / "topaz-video-proteus"), via
7
+ * upscaleImageServicesMap/upscaleVideoServicesMap in aiGenFactory.service.ts.
8
+ * TopazService is left fully intact (not deleted, not called) — this is
9
+ * purely a factory-map swap so the frontend, request schemas, model configs,
10
+ * and credit estimates are all untouched. Re-point the map back to
11
+ * TopazService to revert.
12
+ *
13
+ * Both fal endpoints (`fal-ai/esrgan`, `fal-ai/video-upscaler`) take a public
14
+ * URL directly and run over fal's async queue API — no multipart upload or
15
+ * multi-step accept/upload/complete dance like Topaz's video flow, since fal
16
+ * fetches the source URL itself (our own already-stored asset, same as
17
+ * Topaz's inputImageUrl/inputVideoUrl contract).
18
+ */
19
+ export declare class FalUpscaleService extends BaseAiGenProviderService {
20
+ private readonly apiKey;
21
+ constructor();
22
+ private headers;
23
+ upscaleImage(params: UpscaleImageParams): Promise<UpscaleSubmitResult>;
24
+ checkUpscaleImageStatus({ providerRequestId, outputFilename, outputFilePath, }: UpscaleStatusParams): Promise<UpscaleImageStatusResult>;
25
+ upscaleVideo(params: UpscaleVideoParams): Promise<UpscaleSubmitResult>;
26
+ checkUpscaleVideoStatus({ providerRequestId, outputFilename, outputFilePath, }: UpscaleStatusParams): Promise<UpscaleVideoStatusResult>;
27
+ /**
28
+ * Deliberately IDENTICAL formula to TopazService.getCreditUsed(): cost
29
+ * config is looked up from aiModelConfigs by modelKey, and the model keys
30
+ * ("topaz-image-standard-v2" / "topaz-video-proteus") are unchanged — so
31
+ * credit estimates and billed amounts stay exactly what they were under
32
+ * Topaz, regardless of which provider actually services the request. Do
33
+ * NOT diverge this from Topaz's formula without also revisiting
34
+ * topaz.ts's cost config.
35
+ */
36
+ getCreditUsed({ modelKey, outputMegapixels, duration, creditFloor }: CreditUsageParams): number;
37
+ }
38
+ //# sourceMappingURL=falUpscale.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"falUpscale.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/fal/falUpscale.service.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,wBAAwB,EACxB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,wBAAwB,EACzB,MAAM,UAAU,CAAC;AA8BlB;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,iBAAkB,SAAQ,wBAAwB;IAC7D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;;IAUhC,OAAO,CAAC,OAAO;IAUT,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAkCtE,uBAAuB,CAAC,EAC5B,iBAAiB,EACjB,cAAc,EACd,cAAiC,GAClC,EAAE,mBAAmB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAmDpD,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAiCtE,uBAAuB,CAAC,EAC5B,iBAAiB,EACjB,cAAc,EACd,cAAiC,GAClC,EAAE,mBAAmB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IA+C1D;;;;;;;;OAQG;IACH,aAAa,CAAC,EAAE,QAAQ,EAAE,gBAAgB,EAAE,QAAY,EAAE,WAAW,EAAE,EAAE,iBAAiB,GAAG,MAAM;CAiBpG"}
@@ -0,0 +1,226 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FalUpscaleService = void 0;
4
+ const aiModels_1 = require("../../../../globals/aiModels");
5
+ const creditUnit_1 = require("../../../../globals/creditUnit");
6
+ const storage_1 = require("../../../../libs/storage");
7
+ const errors_1 = require("../../../../utils/errors");
8
+ const helpers_1 = require("../../../../utils/helpers");
9
+ const logger_1 = require("../../../../utils/logger");
10
+ const transientRetry_1 = require("../../transientRetry");
11
+ const baseAiGenProvider_service_1 = require("../baseAiGenProvider.service");
12
+ const QUEUE_BASE_URL = "https://queue.fal.run";
13
+ // fal app ids — fixed one-per-modality, unlike Topaz's per-modelKey `modelId`
14
+ // lookup: today exactly one EUpscaleImageModels / EUpscaleVideoModels key
15
+ // routes here (see aiGenFactory.service.ts upscale*ServicesMap), so there's
16
+ // no per-request model selection to thread through.
17
+ const IMAGE_APP_ID = "fal-ai/esrgan";
18
+ const VIDEO_APP_ID = "fal-ai/video-upscaler";
19
+ /**
20
+ * Classify a fal.ai HTTP failure (non-2xx). Same shape as every other
21
+ * provider's classifier (see topaz.service.ts's classifyTopazHttpError) —
22
+ * 401/403 is a deploy/config bug (fail fast, no Slack noise per job), 5xx/429
23
+ * is transient and retried by withTransientRetry, everything else is a real
24
+ * bug worth alerting on. Error body shape per fal docs: {detail, error_type}.
25
+ */
26
+ function classifyFalHttpError(status, body, op) {
27
+ if (status === 401 || status === 403) {
28
+ return new errors_1.UserFacingError(`fal.ai rejected the API key (HTTP ${status}). Ask an operator to verify FAL_KEY.`, errors_1.USER_FACING_ERROR_CODES.PROVIDER_AUTH_ERROR);
29
+ }
30
+ if (status >= 500 || status === 429) {
31
+ return new transientRetry_1.TransientHttpError(status, `fal ${op} transient HTTP ${status}: ${body.slice(0, 200)}`);
32
+ }
33
+ return new Error(`fal ${op} failed (${status}): ${body}`);
34
+ }
35
+ /**
36
+ * fal.ai upscale provider (image + video) — wired in behind the SAME
37
+ * EUpscaleImageModels/EUpscaleVideoModels model keys Topaz used
38
+ * ("topaz-image-standard-v2" / "topaz-video-proteus"), via
39
+ * upscaleImageServicesMap/upscaleVideoServicesMap in aiGenFactory.service.ts.
40
+ * TopazService is left fully intact (not deleted, not called) — this is
41
+ * purely a factory-map swap so the frontend, request schemas, model configs,
42
+ * and credit estimates are all untouched. Re-point the map back to
43
+ * TopazService to revert.
44
+ *
45
+ * Both fal endpoints (`fal-ai/esrgan`, `fal-ai/video-upscaler`) take a public
46
+ * URL directly and run over fal's async queue API — no multipart upload or
47
+ * multi-step accept/upload/complete dance like Topaz's video flow, since fal
48
+ * fetches the source URL itself (our own already-stored asset, same as
49
+ * Topaz's inputImageUrl/inputVideoUrl contract).
50
+ */
51
+ class FalUpscaleService extends baseAiGenProvider_service_1.BaseAiGenProviderService {
52
+ constructor() {
53
+ super();
54
+ if (!process.env.FAL_KEY) {
55
+ throw new Error("Missing FAL_KEY in environment variables");
56
+ }
57
+ this.apiKey = process.env.FAL_KEY;
58
+ }
59
+ headers(json) {
60
+ const h = { Authorization: `Key ${this.apiKey}` };
61
+ if (json)
62
+ h["Content-Type"] = "application/json";
63
+ return h;
64
+ }
65
+ // ============================================================
66
+ // IMAGE UPSCALE
67
+ // ============================================================
68
+ async upscaleImage(params) {
69
+ return (0, transientRetry_1.withTransientRetry)("fal:upscaleImage", async () => {
70
+ const resp = await fetch(`${QUEUE_BASE_URL}/${IMAGE_APP_ID}`, {
71
+ method: "POST",
72
+ headers: this.headers(true),
73
+ body: JSON.stringify({
74
+ image_url: params.inputImageUrl,
75
+ scale: params.scale,
76
+ output_format: params.outputFormat ?? "jpeg",
77
+ }),
78
+ });
79
+ if (!resp.ok) {
80
+ throw classifyFalHttpError(resp.status, await resp.text(), "upscaleImage");
81
+ }
82
+ const data = (await resp.json());
83
+ if (!data.request_id) {
84
+ throw new Error("fal image upscale did not return a request_id");
85
+ }
86
+ return { providerRequestId: data.request_id };
87
+ }, {
88
+ onRetry: ({ attempt, maxAttempts, backoffMs, err }) => logger_1.logger.warn("fal upscaleImage transient error — retrying", {
89
+ attempt,
90
+ maxAttempts,
91
+ backoffMs,
92
+ message: err.message,
93
+ }),
94
+ });
95
+ }
96
+ async checkUpscaleImageStatus({ providerRequestId, outputFilename, outputFilePath = "upscale_images", }) {
97
+ const statusResp = await fetch(`${QUEUE_BASE_URL}/${IMAGE_APP_ID}/requests/${providerRequestId}/status`, {
98
+ headers: this.headers(false),
99
+ });
100
+ if (!statusResp.ok) {
101
+ throw classifyFalHttpError(statusResp.status, await statusResp.text(), "checkUpscaleImageStatus");
102
+ }
103
+ const statusData = (await statusResp.json());
104
+ const normalized = (statusData.status ?? "").toUpperCase();
105
+ // fal's status payload carries an `error` field on the terminal COMPLETED
106
+ // state when the job actually failed — there is no separate FAILED status.
107
+ if (normalized === "COMPLETED" && statusData.error) {
108
+ return { status: "failed", errorMessage: statusData.error };
109
+ }
110
+ if (normalized !== "COMPLETED") {
111
+ return { status: "processing" };
112
+ }
113
+ const resultResp = await fetch(`${QUEUE_BASE_URL}/${IMAGE_APP_ID}/requests/${providerRequestId}`, {
114
+ headers: this.headers(false),
115
+ });
116
+ if (!resultResp.ok) {
117
+ throw classifyFalHttpError(resultResp.status, await resultResp.text(), "checkUpscaleImageStatus:result");
118
+ }
119
+ const result = (await resultResp.json());
120
+ if (!result.image?.url) {
121
+ return { status: "failed", errorMessage: result.detail ?? result.error ?? "fal image upscale failed" };
122
+ }
123
+ const assetResp = await fetch(result.image.url);
124
+ if (!assetResp.ok) {
125
+ throw new Error(`Failed to download fal upscaled image: ${assetResp.status}`);
126
+ }
127
+ const contentType = result.image.content_type || assetResp.headers.get("content-type") || "image/jpeg";
128
+ const ext = (contentType.split("/")[1] || "jpeg").toLowerCase();
129
+ const buffer = Buffer.from(await assetResp.arrayBuffer());
130
+ // mediaStorage: GCS write + best-effort R2 mirror (zero-egress delivery).
131
+ const signedUrl = await storage_1.mediaStorage.put(`${outputFilePath}/${outputFilename}.${ext}`, buffer, contentType);
132
+ return { status: "completed", outputUrl: signedUrl, width: result.image.width, height: result.image.height };
133
+ }
134
+ // ============================================================
135
+ // VIDEO UPSCALE
136
+ // ============================================================
137
+ async upscaleVideo(params) {
138
+ return (0, transientRetry_1.withTransientRetry)("fal:upscaleVideo", async () => {
139
+ const resp = await fetch(`${QUEUE_BASE_URL}/${VIDEO_APP_ID}`, {
140
+ method: "POST",
141
+ headers: this.headers(true),
142
+ body: JSON.stringify({
143
+ video_url: params.inputVideoUrl,
144
+ scale: params.scale,
145
+ }),
146
+ });
147
+ if (!resp.ok) {
148
+ throw classifyFalHttpError(resp.status, await resp.text(), "upscaleVideo");
149
+ }
150
+ const data = (await resp.json());
151
+ if (!data.request_id) {
152
+ throw new Error("fal video upscale did not return a request_id");
153
+ }
154
+ return { providerRequestId: data.request_id };
155
+ }, {
156
+ onRetry: ({ attempt, maxAttempts, backoffMs, err }) => logger_1.logger.warn("fal upscaleVideo transient error — retrying", {
157
+ attempt,
158
+ maxAttempts,
159
+ backoffMs,
160
+ message: err.message,
161
+ }),
162
+ });
163
+ }
164
+ async checkUpscaleVideoStatus({ providerRequestId, outputFilename, outputFilePath = "upscale_videos", }) {
165
+ const statusResp = await fetch(`${QUEUE_BASE_URL}/${VIDEO_APP_ID}/requests/${providerRequestId}/status`, {
166
+ headers: this.headers(false),
167
+ });
168
+ if (!statusResp.ok) {
169
+ throw classifyFalHttpError(statusResp.status, await statusResp.text(), "checkUpscaleVideoStatus");
170
+ }
171
+ const statusData = (await statusResp.json());
172
+ const normalized = (statusData.status ?? "").toUpperCase();
173
+ if (normalized === "COMPLETED" && statusData.error) {
174
+ return { status: "failed", errorMessage: statusData.error };
175
+ }
176
+ if (normalized !== "COMPLETED") {
177
+ return { status: "processing" };
178
+ }
179
+ const resultResp = await fetch(`${QUEUE_BASE_URL}/${VIDEO_APP_ID}/requests/${providerRequestId}`, {
180
+ headers: this.headers(false),
181
+ });
182
+ if (!resultResp.ok) {
183
+ throw classifyFalHttpError(resultResp.status, await resultResp.text(), "checkUpscaleVideoStatus:result");
184
+ }
185
+ const result = (await resultResp.json());
186
+ if (!result.video?.url) {
187
+ return { status: "failed", errorMessage: result.detail ?? result.error ?? "fal video upscale failed" };
188
+ }
189
+ const assetResp = await fetch(result.video.url);
190
+ if (!assetResp.ok) {
191
+ throw new Error(`Failed to download fal upscaled video: ${assetResp.status}`);
192
+ }
193
+ const buffer = Buffer.from(await assetResp.arrayBuffer());
194
+ // mediaStorage: GCS write + best-effort R2 mirror (zero-egress delivery).
195
+ const signedUrl = await storage_1.mediaStorage.put(`${outputFilePath}/${outputFilename}.mp4`, buffer, "video/mp4");
196
+ return { status: "completed", outputUrl: signedUrl };
197
+ }
198
+ // ============================================================
199
+ // CREDITS
200
+ // ============================================================
201
+ /**
202
+ * Deliberately IDENTICAL formula to TopazService.getCreditUsed(): cost
203
+ * config is looked up from aiModelConfigs by modelKey, and the model keys
204
+ * ("topaz-image-standard-v2" / "topaz-video-proteus") are unchanged — so
205
+ * credit estimates and billed amounts stay exactly what they were under
206
+ * Topaz, regardless of which provider actually services the request. Do
207
+ * NOT diverge this from Topaz's formula without also revisiting
208
+ * topaz.ts's cost config.
209
+ */
210
+ getCreditUsed({ modelKey, outputMegapixels, duration = 5, creditFloor }) {
211
+ const modelConfig = aiModels_1.aiModelConfigs[modelKey];
212
+ const cost = modelConfig?.cost;
213
+ if (cost?.perMegapixel !== undefined) {
214
+ const megapixels = outputMegapixels ?? 24;
215
+ return (0, helpers_1.getCreditsFromCost)(cost.perMegapixel * megapixels, true, creditFloor ?? creditUnit_1.MIN_CREDITS_PER_IMAGE_OP);
216
+ }
217
+ if (cost?.perSecond !== undefined) {
218
+ return (0, helpers_1.getCreditsFromCost)(cost.perSecond * duration, true, creditFloor);
219
+ }
220
+ logger_1.logger.warn(`fal upscale getCreditUsed: no cost config for modelKey="${modelKey}" — returning fallback`, {
221
+ modelKey,
222
+ });
223
+ return (0, helpers_1.getCreditsFromCost)(1.0, true, creditFloor);
224
+ }
225
+ }
226
+ exports.FalUpscaleService = FalUpscaleService;
@@ -1,2 +1,3 @@
1
1
  export * from "./falImage.service";
2
+ export * from "./falUpscale.service";
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/fal/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/fal/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC"}
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./falImage.service"), exports);
18
+ __exportStar(require("./falUpscale.service"), exports);