vidspotai-shared 1.0.0
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.
- package/lib/globals/aiModels.d.ts +60 -0
- package/lib/globals/aiModels.d.ts.map +1 -0
- package/lib/globals/aiModels.js +463 -0
- package/lib/globals/config.d.ts +4 -0
- package/lib/globals/config.d.ts.map +1 -0
- package/lib/globals/config.js +20 -0
- package/lib/globals/index.d.ts +6 -0
- package/lib/globals/index.d.ts.map +1 -0
- package/lib/globals/index.js +21 -0
- package/lib/globals/plans.d.ts +3 -0
- package/lib/globals/plans.d.ts.map +1 -0
- package/lib/globals/plans.js +60 -0
- package/lib/globals/schemas.d.ts +3 -0
- package/lib/globals/schemas.d.ts.map +1 -0
- package/lib/globals/schemas.js +18 -0
- package/lib/globals/types.d.ts +90 -0
- package/lib/globals/types.d.ts.map +1 -0
- package/lib/globals/types.js +93 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +21 -0
- package/lib/libs/firebase.d.ts +7 -0
- package/lib/libs/firebase.d.ts.map +1 -0
- package/lib/libs/firebase.js +60 -0
- package/lib/libs/index.d.ts +2 -0
- package/lib/libs/index.d.ts.map +1 -0
- package/lib/libs/index.js +17 -0
- package/lib/models/index.d.ts +4 -0
- package/lib/models/index.d.ts.map +1 -0
- package/lib/models/index.js +19 -0
- package/lib/models/script.model.d.ts +39 -0
- package/lib/models/script.model.d.ts.map +1 -0
- package/lib/models/script.model.js +26 -0
- package/lib/models/user.model.d.ts +46 -0
- package/lib/models/user.model.d.ts.map +1 -0
- package/lib/models/user.model.js +2 -0
- package/lib/models/video.model.d.ts +43 -0
- package/lib/models/video.model.d.ts.map +1 -0
- package/lib/models/video.model.js +2 -0
- package/lib/services/aiGen/aiGenFactory.service.d.ts +8 -0
- package/lib/services/aiGen/aiGenFactory.service.d.ts.map +1 -0
- package/lib/services/aiGen/aiGenFactory.service.js +56 -0
- package/lib/services/aiGen/atypes.d.ts +5 -0
- package/lib/services/aiGen/atypes.d.ts.map +1 -0
- package/lib/services/aiGen/atypes.js +8 -0
- package/lib/services/aiGen/helpers.d.ts +3 -0
- package/lib/services/aiGen/helpers.d.ts.map +1 -0
- package/lib/services/aiGen/helpers.js +76 -0
- package/lib/services/aiGen/index.d.ts +5 -0
- package/lib/services/aiGen/index.d.ts.map +1 -0
- package/lib/services/aiGen/index.js +20 -0
- package/lib/services/aiGen/providers/alibaba/alibaba.d.ts +12 -0
- package/lib/services/aiGen/providers/alibaba/alibaba.d.ts.map +1 -0
- package/lib/services/aiGen/providers/alibaba/alibaba.js +146 -0
- package/lib/services/aiGen/providers/alibaba/helpers.d.ts +3 -0
- package/lib/services/aiGen/providers/alibaba/helpers.d.ts.map +1 -0
- package/lib/services/aiGen/providers/alibaba/helpers.js +31 -0
- package/lib/services/aiGen/providers/azure/azure.d.ts +1 -0
- package/lib/services/aiGen/providers/azure/azure.d.ts.map +1 -0
- package/lib/services/aiGen/providers/azure/azure.js +1 -0
- package/lib/services/aiGen/providers/azure/azure.service.d.ts +14 -0
- package/lib/services/aiGen/providers/azure/azure.service.d.ts.map +1 -0
- package/lib/services/aiGen/providers/azure/azure.service.js +125 -0
- package/lib/services/aiGen/providers/azure/index.d.ts +2 -0
- package/lib/services/aiGen/providers/azure/index.d.ts.map +1 -0
- package/lib/services/aiGen/providers/azure/index.js +17 -0
- package/lib/services/aiGen/providers/baseAiGenProvider.service.d.ts +8 -0
- package/lib/services/aiGen/providers/baseAiGenProvider.service.d.ts.map +1 -0
- package/lib/services/aiGen/providers/baseAiGenProvider.service.js +12 -0
- package/lib/services/aiGen/providers/google/google.service.d.ts +10 -0
- package/lib/services/aiGen/providers/google/google.service.d.ts.map +1 -0
- package/lib/services/aiGen/providers/google/google.service.js +96 -0
- package/lib/services/aiGen/providers/google/index.d.ts +2 -0
- package/lib/services/aiGen/providers/google/index.d.ts.map +1 -0
- package/lib/services/aiGen/providers/google/index.js +17 -0
- package/lib/services/aiGen/providers/index.d.ts +8 -0
- package/lib/services/aiGen/providers/index.d.ts.map +1 -0
- package/lib/services/aiGen/providers/index.js +23 -0
- package/lib/services/aiGen/providers/kling/btypes.d.ts +73 -0
- package/lib/services/aiGen/providers/kling/btypes.d.ts.map +1 -0
- package/lib/services/aiGen/providers/kling/btypes.js +2 -0
- package/lib/services/aiGen/providers/kling/index.d.ts +3 -0
- package/lib/services/aiGen/providers/kling/index.d.ts.map +1 -0
- package/lib/services/aiGen/providers/kling/index.js +18 -0
- package/lib/services/aiGen/providers/kling/kling.service.d.ts +13 -0
- package/lib/services/aiGen/providers/kling/kling.service.d.ts.map +1 -0
- package/lib/services/aiGen/providers/kling/kling.service.js +139 -0
- package/lib/services/aiGen/providers/kling/types.d.ts +73 -0
- package/lib/services/aiGen/providers/kling/types.d.ts.map +1 -0
- package/lib/services/aiGen/providers/kling/types.js +2 -0
- package/lib/services/aiGen/providers/minimax/ctypes.d.ts +26 -0
- package/lib/services/aiGen/providers/minimax/ctypes.d.ts.map +1 -0
- package/lib/services/aiGen/providers/minimax/ctypes.js +3 -0
- package/lib/services/aiGen/providers/minimax/index.d.ts +3 -0
- package/lib/services/aiGen/providers/minimax/index.d.ts.map +1 -0
- package/lib/services/aiGen/providers/minimax/index.js +18 -0
- package/lib/services/aiGen/providers/minimax/minimax.service.d.ts +12 -0
- package/lib/services/aiGen/providers/minimax/minimax.service.d.ts.map +1 -0
- package/lib/services/aiGen/providers/minimax/minimax.service.js +115 -0
- package/lib/services/aiGen/providers/minimax/types.d.ts +26 -0
- package/lib/services/aiGen/providers/minimax/types.d.ts.map +1 -0
- package/lib/services/aiGen/providers/minimax/types.js +3 -0
- package/lib/services/aiGen/providers/openai/index.d.ts +2 -0
- package/lib/services/aiGen/providers/openai/index.d.ts.map +1 -0
- package/lib/services/aiGen/providers/openai/index.js +17 -0
- package/lib/services/aiGen/providers/openai/openai.service.d.ts +12 -0
- package/lib/services/aiGen/providers/openai/openai.service.d.ts.map +1 -0
- package/lib/services/aiGen/providers/openai/openai.service.js +97 -0
- package/lib/services/aiGen/providers/runway/dtypes.d.ts +14 -0
- package/lib/services/aiGen/providers/runway/dtypes.d.ts.map +1 -0
- package/lib/services/aiGen/providers/runway/dtypes.js +27 -0
- package/lib/services/aiGen/providers/runway/index.d.ts +3 -0
- package/lib/services/aiGen/providers/runway/index.d.ts.map +1 -0
- package/lib/services/aiGen/providers/runway/index.js +18 -0
- package/lib/services/aiGen/providers/runway/runway.service.d.ts +12 -0
- package/lib/services/aiGen/providers/runway/runway.service.d.ts.map +1 -0
- package/lib/services/aiGen/providers/runway/runway.service.js +122 -0
- package/lib/services/aiGen/providers/runway/types.d.ts +14 -0
- package/lib/services/aiGen/providers/runway/types.d.ts.map +1 -0
- package/lib/services/aiGen/providers/runway/types.js +27 -0
- package/lib/services/aiGen/providers/types.d.ts +49 -0
- package/lib/services/aiGen/providers/types.d.ts.map +1 -0
- package/lib/services/aiGen/providers/types.js +2 -0
- package/lib/services/aiGen/types.d.ts +5 -0
- package/lib/services/aiGen/types.d.ts.map +1 -0
- package/lib/services/aiGen/types.js +8 -0
- package/lib/services/firestore.service.d.ts +66 -0
- package/lib/services/firestore.service.d.ts.map +1 -0
- package/lib/services/firestore.service.js +118 -0
- package/lib/services/index.d.ts +4 -0
- package/lib/services/index.d.ts.map +1 -0
- package/lib/services/index.js +19 -0
- package/lib/services/redis.service.d.ts +19 -0
- package/lib/services/redis.service.d.ts.map +1 -0
- package/lib/services/redis.service.js +97 -0
- package/lib/utils/helpers.d.ts +6 -0
- package/lib/utils/helpers.d.ts.map +1 -0
- package/lib/utils/helpers.js +55 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.d.ts.map +1 -0
- package/lib/utils/index.js +17 -0
- package/package.json +31 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./openai.service"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseAiGenProviderService } from "../baseAiGenProvider.service";
|
|
2
|
+
import { CreditUsageParams, TextGenerationParams, TextGenerationResult, VideoGenerationParams, VideoGenerationResult, VideoStatusParams, VideoStatusResult } from "../types";
|
|
3
|
+
export declare class OpenaiService extends BaseAiGenProviderService {
|
|
4
|
+
private readonly apiVersion;
|
|
5
|
+
private client;
|
|
6
|
+
constructor();
|
|
7
|
+
generateVideo(params: VideoGenerationParams): Promise<VideoGenerationResult>;
|
|
8
|
+
checkVideoStatus({ task, outputFilename, outputFilePath, }: VideoStatusParams): Promise<VideoStatusResult | null>;
|
|
9
|
+
generateText(params: TextGenerationParams): Promise<TextGenerationResult>;
|
|
10
|
+
getCreditUsed({ modelKey, duration }: CreditUsageParams): number;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=openai.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/openai/openai.service.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAIlB,qBAAa,aAAc,SAAQ,wBAAwB;IACzD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IACxC,OAAO,CAAC,MAAM,CAAS;;IAQjB,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IAoB3B,gBAAgB,CAAC,EACrB,IAAI,EACJ,cAAc,EACd,cAAyB,GAC1B,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAwClD,YAAY,CAChB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,oBAAoB,CAAC;IA4BhC,aAAa,CAAC,EAAE,QAAQ,EAAE,QAAY,EAAE,EAAE,iBAAiB,GAAG,MAAM;CAMrE"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// openai.service.ts
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.OpenaiService = void 0;
|
|
8
|
+
const openai_1 = __importDefault(require("openai"));
|
|
9
|
+
const aiModels_1 = require("../../../../globals/aiModels");
|
|
10
|
+
const types_1 = require("../../../../globals/types");
|
|
11
|
+
const helpers_1 = require("../../helpers");
|
|
12
|
+
const baseAiGenProvider_service_1 = require("../baseAiGenProvider.service");
|
|
13
|
+
const utils_1 = require("../../../../utils");
|
|
14
|
+
const firebase_1 = require("../../../../libs/firebase");
|
|
15
|
+
class OpenaiService extends baseAiGenProvider_service_1.BaseAiGenProviderService {
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
this.apiVersion = "preview";
|
|
19
|
+
this.client = new openai_1.default({ apiKey: process.env.OPENAI_API_KEY });
|
|
20
|
+
}
|
|
21
|
+
async generateVideo(params) {
|
|
22
|
+
(0, helpers_1.validateParams)(params);
|
|
23
|
+
const modelId = aiModels_1.aiModelConfigs[params.modelKey]?.modelId || "sora-2";
|
|
24
|
+
const job = await this.client.videos.create({
|
|
25
|
+
prompt: params.prompt || "",
|
|
26
|
+
model: modelId,
|
|
27
|
+
seconds: params.duration?.toString() || "4",
|
|
28
|
+
size: params.dimensions || "720x1280",
|
|
29
|
+
});
|
|
30
|
+
if (job.status === "failed") {
|
|
31
|
+
throw new Error(`OpenAI video generation failed: ${JSON.stringify(job.error)}`);
|
|
32
|
+
}
|
|
33
|
+
return { task: job.id, status: types_1.EVideoJobStatus.TRIGGERED };
|
|
34
|
+
}
|
|
35
|
+
async checkVideoStatus({ task, outputFilename, outputFilePath = "videos", }) {
|
|
36
|
+
// Get job info from OpenAI
|
|
37
|
+
const job = await this.client.videos.retrieve(task);
|
|
38
|
+
if (job.status === "completed") {
|
|
39
|
+
// Download video content from OpenAI
|
|
40
|
+
const response = await this.client.videos.downloadContent(task);
|
|
41
|
+
const blob = await response.blob();
|
|
42
|
+
const buffer = Buffer.from(await blob.arrayBuffer());
|
|
43
|
+
// Upload to Firebase Storage
|
|
44
|
+
const filePath = `${outputFilePath}/${outputFilename}.mp4`;
|
|
45
|
+
const file = (0, firebase_1.getBucket)().file(filePath);
|
|
46
|
+
await file.save(buffer, { contentType: "video/mp4" });
|
|
47
|
+
// Generate a signed URL
|
|
48
|
+
const [signedUrl] = await file.getSignedUrl({
|
|
49
|
+
action: "read",
|
|
50
|
+
expires: "03-09-2491",
|
|
51
|
+
});
|
|
52
|
+
return {
|
|
53
|
+
status: types_1.EVideoJobStatus.COMPLETED,
|
|
54
|
+
videoUrl: signedUrl,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
if (job.status === "failed") {
|
|
58
|
+
return {
|
|
59
|
+
status: types_1.EVideoJobStatus.FAILED,
|
|
60
|
+
errorMessage: job.error
|
|
61
|
+
? `${job.error.code}: ${job.error.message}`
|
|
62
|
+
: "Unknown error",
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return { status: types_1.EVideoJobStatus.PENDING };
|
|
66
|
+
}
|
|
67
|
+
async generateText(params) {
|
|
68
|
+
const { input, modelKey, options } = params;
|
|
69
|
+
const model = aiModels_1.aiModelConfigs[modelKey]?.modelId || "gpt-4o-mini";
|
|
70
|
+
let parsedInput = [];
|
|
71
|
+
if (typeof input === "string") {
|
|
72
|
+
parsedInput = [
|
|
73
|
+
{ role: "user", content: input },
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
parsedInput = input;
|
|
78
|
+
}
|
|
79
|
+
const completion = await this.client.chat.completions.create({
|
|
80
|
+
model,
|
|
81
|
+
messages: parsedInput,
|
|
82
|
+
temperature: options?.temperature || 0.7,
|
|
83
|
+
response_format: options?.responseFormat || { type: "text" },
|
|
84
|
+
});
|
|
85
|
+
const text = completion.choices?.[0]?.message?.content?.trim() || "No response";
|
|
86
|
+
return {
|
|
87
|
+
text,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
getCreditUsed({ modelKey, duration = 5 }) {
|
|
91
|
+
const modelConfig = aiModels_1.aiModelConfigs[modelKey];
|
|
92
|
+
return modelConfig?.cost?.perSecond
|
|
93
|
+
? (0, utils_1.getCreditsFromCost)(modelConfig?.cost?.perSecond * duration)
|
|
94
|
+
: 0;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.OpenaiService = OpenaiService;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare const TGEN4_TURBO_RATIOS: readonly ["1280:720", "1584:672", "1104:832", "720:1280", "832:1104", "960:960"];
|
|
2
|
+
export type Gen4TurboRatio = (typeof TGEN4_TURBO_RATIOS)[number];
|
|
3
|
+
export declare const GEN4_TURBO_RATIOS: string[];
|
|
4
|
+
export declare const TGEN4_TURBO_DURATIONS: readonly [5, 8, 10];
|
|
5
|
+
export type Gen4TurboDuration = (typeof TGEN4_TURBO_DURATIONS)[number];
|
|
6
|
+
export declare const GEN4_TURBO_DURATIONS: number[];
|
|
7
|
+
declare const TGEN4_ALEPH_RATIOS: readonly ["1280:720", "720:1280", "1104:832", "960:960", "832:1104", "1584:672", "848:480", "640:480"];
|
|
8
|
+
export type Gen4AlephRatio = (typeof TGEN4_ALEPH_RATIOS)[number];
|
|
9
|
+
export declare const GEN4_ALEPH_RATIOS: string[];
|
|
10
|
+
export declare const TGEN4_ALEPH_DURATIONS: readonly [5];
|
|
11
|
+
export type Gen4AlephDuration = (typeof TGEN4_ALEPH_DURATIONS)[number];
|
|
12
|
+
export declare const GEN4_ALEPH_DURATIONS: number[];
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=dtypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dtypes.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/runway/dtypes.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,kBAAkB,kFAOd,CAAC;AACX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AACjE,eAAO,MAAM,iBAAiB,EAAE,MAAM,EAA4B,CAAC;AAEnE,eAAO,MAAM,qBAAqB,qBAAsB,CAAC;AACzD,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AACvE,eAAO,MAAM,oBAAoB,EAAE,MAAM,EAA+B,CAAC;AAEzE,QAAA,MAAM,kBAAkB,wGASd,CAAC;AACX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AACjE,eAAO,MAAM,iBAAiB,EAAE,MAAM,EAA4B,CAAC;AAEnE,eAAO,MAAM,qBAAqB,cAAe,CAAC;AAClD,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AACvE,eAAO,MAAM,oBAAoB,EAAE,MAAM,EAA+B,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GEN4_ALEPH_DURATIONS = exports.TGEN4_ALEPH_DURATIONS = exports.GEN4_ALEPH_RATIOS = exports.GEN4_TURBO_DURATIONS = exports.TGEN4_TURBO_DURATIONS = exports.GEN4_TURBO_RATIOS = void 0;
|
|
4
|
+
const TGEN4_TURBO_RATIOS = [
|
|
5
|
+
"1280:720", // default
|
|
6
|
+
"1584:672",
|
|
7
|
+
"1104:832",
|
|
8
|
+
"720:1280",
|
|
9
|
+
"832:1104",
|
|
10
|
+
"960:960",
|
|
11
|
+
];
|
|
12
|
+
exports.GEN4_TURBO_RATIOS = [...TGEN4_TURBO_RATIOS];
|
|
13
|
+
exports.TGEN4_TURBO_DURATIONS = [5, 8, 10];
|
|
14
|
+
exports.GEN4_TURBO_DURATIONS = [...exports.TGEN4_TURBO_DURATIONS];
|
|
15
|
+
const TGEN4_ALEPH_RATIOS = [
|
|
16
|
+
"1280:720", // default
|
|
17
|
+
"720:1280",
|
|
18
|
+
"1104:832",
|
|
19
|
+
"960:960",
|
|
20
|
+
"832:1104",
|
|
21
|
+
"1584:672",
|
|
22
|
+
"848:480",
|
|
23
|
+
"640:480",
|
|
24
|
+
];
|
|
25
|
+
exports.GEN4_ALEPH_RATIOS = [...TGEN4_ALEPH_RATIOS];
|
|
26
|
+
exports.TGEN4_ALEPH_DURATIONS = [5];
|
|
27
|
+
exports.GEN4_ALEPH_DURATIONS = [...exports.TGEN4_ALEPH_DURATIONS];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/runway/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./runway.service"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseAiGenProviderService } from "../baseAiGenProvider.service";
|
|
2
|
+
import { CreditUsageParams, VideoGenerationParams, VideoGenerationResult, VideoStatusParams, VideoStatusResult } from "../types";
|
|
3
|
+
export declare class RunwayService extends BaseAiGenProviderService {
|
|
4
|
+
private readonly baseUrl;
|
|
5
|
+
private readonly apiKey;
|
|
6
|
+
constructor();
|
|
7
|
+
private request;
|
|
8
|
+
generateVideo(params: VideoGenerationParams): Promise<VideoGenerationResult>;
|
|
9
|
+
checkVideoStatus({ task, outputFilename, outputFilePath, }: VideoStatusParams): Promise<VideoStatusResult | null>;
|
|
10
|
+
getCreditUsed({ modelKey, duration }: CreditUsageParams): number;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=runway.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runway.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/runway/runway.service.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAIlB,qBAAa,aAAc,SAAQ,wBAAwB;IACzD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiC;IACzD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;;YAUlB,OAAO;IA+Bf,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IA+C3B,gBAAgB,CAAC,EACrB,IAAI,EACJ,cAAc,EACd,cAAyB,GAC1B,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IA4DxD,aAAa,CAAC,EAAE,QAAQ,EAAE,QAAY,EAAE,EAAE,iBAAiB,GAAG,MAAM;CAIrE"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.RunwayService = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const aiModels_1 = require("../../../../globals/aiModels");
|
|
9
|
+
const helpers_1 = require("../../../../utils/helpers");
|
|
10
|
+
const firebase_1 = require("../../../../libs/firebase");
|
|
11
|
+
const helpers_2 = require("../../helpers");
|
|
12
|
+
const baseAiGenProvider_service_1 = require("../baseAiGenProvider.service");
|
|
13
|
+
const types_1 = require("../../../../globals/types");
|
|
14
|
+
class RunwayService extends baseAiGenProvider_service_1.BaseAiGenProviderService {
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
this.baseUrl = "https://api.runwayml.com/v1";
|
|
18
|
+
if (!process.env.RUNWAYML_API_SECRET) {
|
|
19
|
+
throw new Error("Missing RUNWAYML_API_SECRET in environment variables");
|
|
20
|
+
}
|
|
21
|
+
this.apiKey = process.env.RUNWAYML_API_SECRET;
|
|
22
|
+
}
|
|
23
|
+
async request(endpoint, method, body) {
|
|
24
|
+
const url = `${this.baseUrl}${endpoint}`;
|
|
25
|
+
const headers = {
|
|
26
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
27
|
+
"Content-Type": "application/json",
|
|
28
|
+
};
|
|
29
|
+
const response = await (0, axios_1.default)({
|
|
30
|
+
url,
|
|
31
|
+
method,
|
|
32
|
+
headers,
|
|
33
|
+
data: body,
|
|
34
|
+
timeout: 180000, // 3 minutes
|
|
35
|
+
validateStatus: () => true, // manually handle status
|
|
36
|
+
});
|
|
37
|
+
if (response.status < 200 || response.status >= 300) {
|
|
38
|
+
throw new Error(`Runway API Error: ${response.status} ${response.statusText} - ${JSON.stringify(response.data)}`);
|
|
39
|
+
}
|
|
40
|
+
return response.data;
|
|
41
|
+
}
|
|
42
|
+
async generateVideo(params) {
|
|
43
|
+
(0, helpers_2.validateParams)(params);
|
|
44
|
+
const modelId = aiModels_1.aiModelConfigs[params.modelKey]?.modelId;
|
|
45
|
+
if (!modelId)
|
|
46
|
+
throw new Error(`Unknown modelKey: ${params.modelKey}`);
|
|
47
|
+
let run;
|
|
48
|
+
// IMAGE → VIDEO
|
|
49
|
+
if (modelId === "gen4_turbo") {
|
|
50
|
+
const body = {
|
|
51
|
+
model: "gen4_turbo",
|
|
52
|
+
promptText: params.prompt,
|
|
53
|
+
promptImage: [{ uri: params.inputImageUrl, position: "first" }],
|
|
54
|
+
ratio: params.aspectRatio,
|
|
55
|
+
duration: params.duration,
|
|
56
|
+
};
|
|
57
|
+
run = await this.request("/image-to-video", "POST", body);
|
|
58
|
+
}
|
|
59
|
+
// VIDEO → VIDEO
|
|
60
|
+
else if (modelId === "gen4_aleph") {
|
|
61
|
+
const body = {
|
|
62
|
+
model: "gen4_aleph",
|
|
63
|
+
promptText: params.prompt,
|
|
64
|
+
videoUri: params.inputVideoUrl,
|
|
65
|
+
ratio: params.aspectRatio,
|
|
66
|
+
};
|
|
67
|
+
run = await this.request("/video-to-video", "POST", body);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
throw new Error(`Invalid params: Model ${params.modelKey} does not support this generation type`);
|
|
71
|
+
}
|
|
72
|
+
return { task: run.id, status: types_1.EVideoJobStatus.PENDING };
|
|
73
|
+
}
|
|
74
|
+
async checkVideoStatus({ task, outputFilename, outputFilePath = "videos", }) {
|
|
75
|
+
const result = await this.request(`/tasks/${task}`, "GET");
|
|
76
|
+
if (result.status === "SUCCEEDED" && result.output?.length) {
|
|
77
|
+
const videoUri = result.output[0];
|
|
78
|
+
if (!videoUri) {
|
|
79
|
+
return {
|
|
80
|
+
status: types_1.EVideoJobStatus.FAILED,
|
|
81
|
+
errorMessage: "No video returned from Runway API",
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
// Download the video as binary data
|
|
85
|
+
const videoResp = await axios_1.default.get(videoUri, {
|
|
86
|
+
responseType: "arraybuffer",
|
|
87
|
+
timeout: 180000,
|
|
88
|
+
});
|
|
89
|
+
if (videoResp.status !== 200) {
|
|
90
|
+
return {
|
|
91
|
+
status: types_1.EVideoJobStatus.FAILED,
|
|
92
|
+
errorMessage: `Failed to download video: ${videoResp.status}`,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
const buffer = Buffer.from(videoResp.data);
|
|
96
|
+
const filePath = `${outputFilePath}/${outputFilename}.mp4`;
|
|
97
|
+
const file = (0, firebase_1.getBucket)().file(filePath);
|
|
98
|
+
await file.save(buffer, { contentType: "video/mp4" });
|
|
99
|
+
const [signedUrl] = await file.getSignedUrl({
|
|
100
|
+
action: "read",
|
|
101
|
+
expires: "03-09-2491",
|
|
102
|
+
});
|
|
103
|
+
return {
|
|
104
|
+
videoUrl: signedUrl,
|
|
105
|
+
status: types_1.EVideoJobStatus.COMPLETED,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
if (result.status === "FAILED" || result.status === "CANCELLED") {
|
|
109
|
+
return {
|
|
110
|
+
status: types_1.EVideoJobStatus.FAILED,
|
|
111
|
+
errorMessage: `Failure: ${result.failure || "unknown"} Code: ${result.failureCode || "unknown"}`,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
// Still processing
|
|
115
|
+
return { status: types_1.EVideoJobStatus.PENDING };
|
|
116
|
+
}
|
|
117
|
+
getCreditUsed({ modelKey, duration = 5 }) {
|
|
118
|
+
const modelConfig = aiModels_1.aiModelConfigs[modelKey];
|
|
119
|
+
return (0, helpers_1.getCreditsFromCost)(modelConfig.cost?.perSecond ?? duration);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.RunwayService = RunwayService;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare const TGEN4_TURBO_RATIOS: readonly ["1280:720", "1584:672", "1104:832", "720:1280", "832:1104", "960:960"];
|
|
2
|
+
export type Gen4TurboRatio = (typeof TGEN4_TURBO_RATIOS)[number];
|
|
3
|
+
export declare const GEN4_TURBO_RATIOS: string[];
|
|
4
|
+
export declare const TGEN4_TURBO_DURATIONS: readonly [5, 8, 10];
|
|
5
|
+
export type Gen4TurboDuration = (typeof TGEN4_TURBO_DURATIONS)[number];
|
|
6
|
+
export declare const GEN4_TURBO_DURATIONS: number[];
|
|
7
|
+
declare const TGEN4_ALEPH_RATIOS: readonly ["1280:720", "720:1280", "1104:832", "960:960", "832:1104", "1584:672", "848:480", "640:480"];
|
|
8
|
+
export type Gen4AlephRatio = (typeof TGEN4_ALEPH_RATIOS)[number];
|
|
9
|
+
export declare const GEN4_ALEPH_RATIOS: string[];
|
|
10
|
+
export declare const TGEN4_ALEPH_DURATIONS: readonly [5];
|
|
11
|
+
export type Gen4AlephDuration = (typeof TGEN4_ALEPH_DURATIONS)[number];
|
|
12
|
+
export declare const GEN4_ALEPH_DURATIONS: number[];
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/runway/types.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,kBAAkB,kFAOd,CAAC;AACX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AACjE,eAAO,MAAM,iBAAiB,EAAE,MAAM,EAA4B,CAAC;AAEnE,eAAO,MAAM,qBAAqB,qBAAsB,CAAC;AACzD,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AACvE,eAAO,MAAM,oBAAoB,EAAE,MAAM,EAA+B,CAAC;AAEzE,QAAA,MAAM,kBAAkB,wGASd,CAAC;AACX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AACjE,eAAO,MAAM,iBAAiB,EAAE,MAAM,EAA4B,CAAC;AAEnE,eAAO,MAAM,qBAAqB,cAAe,CAAC;AAClD,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AACvE,eAAO,MAAM,oBAAoB,EAAE,MAAM,EAA+B,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GEN4_ALEPH_DURATIONS = exports.TGEN4_ALEPH_DURATIONS = exports.GEN4_ALEPH_RATIOS = exports.GEN4_TURBO_DURATIONS = exports.TGEN4_TURBO_DURATIONS = exports.GEN4_TURBO_RATIOS = void 0;
|
|
4
|
+
const TGEN4_TURBO_RATIOS = [
|
|
5
|
+
"1280:720", // default
|
|
6
|
+
"1584:672",
|
|
7
|
+
"1104:832",
|
|
8
|
+
"720:1280",
|
|
9
|
+
"832:1104",
|
|
10
|
+
"960:960",
|
|
11
|
+
];
|
|
12
|
+
exports.GEN4_TURBO_RATIOS = [...TGEN4_TURBO_RATIOS];
|
|
13
|
+
exports.TGEN4_TURBO_DURATIONS = [5, 8, 10];
|
|
14
|
+
exports.GEN4_TURBO_DURATIONS = [...exports.TGEN4_TURBO_DURATIONS];
|
|
15
|
+
const TGEN4_ALEPH_RATIOS = [
|
|
16
|
+
"1280:720", // default
|
|
17
|
+
"720:1280",
|
|
18
|
+
"1104:832",
|
|
19
|
+
"960:960",
|
|
20
|
+
"832:1104",
|
|
21
|
+
"1584:672",
|
|
22
|
+
"848:480",
|
|
23
|
+
"640:480",
|
|
24
|
+
];
|
|
25
|
+
exports.GEN4_ALEPH_RATIOS = [...TGEN4_ALEPH_RATIOS];
|
|
26
|
+
exports.TGEN4_ALEPH_DURATIONS = [5];
|
|
27
|
+
exports.GEN4_ALEPH_DURATIONS = [...exports.TGEN4_ALEPH_DURATIONS];
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ChatCompletionMessageParam } from "openai/resources/index";
|
|
2
|
+
import { ETextGenModels, EVideoGenModels } from "../../../globals/aiModels";
|
|
3
|
+
import { EVideoJobStatus, TVideoJobTask } from "../../../globals/types";
|
|
4
|
+
import { EVideoMode } from "../types";
|
|
5
|
+
export interface VideoGenerationParams {
|
|
6
|
+
prompt?: string;
|
|
7
|
+
modelKey: EVideoGenModels;
|
|
8
|
+
resolution?: string;
|
|
9
|
+
aspectRatio?: string;
|
|
10
|
+
dimensions?: string;
|
|
11
|
+
duration?: number;
|
|
12
|
+
inputVideoUrl?: string;
|
|
13
|
+
inputImageUrl?: string;
|
|
14
|
+
mode?: EVideoMode;
|
|
15
|
+
}
|
|
16
|
+
export interface VideoGenerationResult {
|
|
17
|
+
status: EVideoJobStatus;
|
|
18
|
+
task?: TVideoJobTask;
|
|
19
|
+
}
|
|
20
|
+
export interface VideoStatusResult {
|
|
21
|
+
status: EVideoJobStatus;
|
|
22
|
+
videoUrl?: string;
|
|
23
|
+
errorMessage?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface VideoStatusParams {
|
|
26
|
+
task: TVideoJobTask;
|
|
27
|
+
modelKey: EVideoGenModels;
|
|
28
|
+
outputFilename: string;
|
|
29
|
+
outputFilePath?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface TextGenerationParams {
|
|
32
|
+
input: ChatCompletionMessageParam[] | string;
|
|
33
|
+
modelKey: ETextGenModels;
|
|
34
|
+
options?: Record<string, any>;
|
|
35
|
+
}
|
|
36
|
+
export interface TextGenerationResult {
|
|
37
|
+
text: string;
|
|
38
|
+
}
|
|
39
|
+
export interface CreditUsageParams {
|
|
40
|
+
modelKey: EVideoGenModels | ETextGenModels;
|
|
41
|
+
mode?: EVideoMode;
|
|
42
|
+
duration?: number;
|
|
43
|
+
resolution?: string;
|
|
44
|
+
dimensions?: string;
|
|
45
|
+
aspectRatio?: string;
|
|
46
|
+
inputType?: "text" | "image" | "video";
|
|
47
|
+
outputType?: "text" | "image" | "video";
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/services/aiGen/providers/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,eAAe,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,eAAe,CAAC;IAExB,IAAI,CAAC,EAAE,aAAa,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CAEvB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,aAAa,CAAC;IACpB,QAAQ,EAAE,eAAe,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;CAMzB;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,0BAA0B,EAAE,GAAG,MAAM,CAAC;IAC7C,QAAQ,EAAE,cAAc,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,eAAe,GAAG,cAAc,CAAC;IAC3C,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;IACvC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;CACzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/aiGen/types.ts"],"names":[],"mappings":"AAAA,oBAAY,UAAU;IACpB,QAAQ,QAAQ;IAChB,YAAY,QAAQ;CACrB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EVideoMode = void 0;
|
|
4
|
+
var EVideoMode;
|
|
5
|
+
(function (EVideoMode) {
|
|
6
|
+
EVideoMode["STANDARD"] = "std";
|
|
7
|
+
EVideoMode["PROFESSIONAL"] = "pro";
|
|
8
|
+
})(EVideoMode || (exports.EVideoMode = EVideoMode = {}));
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import admin from "firebase-admin";
|
|
2
|
+
import { DocumentData, WhereFilterOp, OrderByDirection } from "@google-cloud/firestore";
|
|
3
|
+
import { CollectionReference, DocumentReference } from "firebase-admin/firestore";
|
|
4
|
+
import { IUserModel } from "../models/user.model";
|
|
5
|
+
import { IVideoJobModel } from "../models/video.model";
|
|
6
|
+
import { DeepPartial } from "../globals/types";
|
|
7
|
+
/**
|
|
8
|
+
* FirestoreService
|
|
9
|
+
* ----------------
|
|
10
|
+
* Centralized Firestore access with typed collections & static CRUD utilities.
|
|
11
|
+
*/
|
|
12
|
+
export declare class FirestoreService {
|
|
13
|
+
static videoJobsCol: admin.firestore.CollectionReference<IVideoJobModel, admin.firestore.DocumentData>;
|
|
14
|
+
static usersCol: admin.firestore.CollectionReference<IUserModel, admin.firestore.DocumentData>;
|
|
15
|
+
static scriptsCol: admin.firestore.CollectionReference<{
|
|
16
|
+
userId: string;
|
|
17
|
+
prompt: string;
|
|
18
|
+
durationType: import("../globals/types").EVideoDurationType;
|
|
19
|
+
videoModelKey: import("..").EVideoGenModels;
|
|
20
|
+
createdAt: Date;
|
|
21
|
+
updatedAt: Date;
|
|
22
|
+
} & {
|
|
23
|
+
summary: string;
|
|
24
|
+
scenes: {
|
|
25
|
+
sceneIndex: number;
|
|
26
|
+
duration: number;
|
|
27
|
+
videoPrompt: string;
|
|
28
|
+
description: string;
|
|
29
|
+
dialogue: string;
|
|
30
|
+
}[];
|
|
31
|
+
}, admin.firestore.DocumentData>;
|
|
32
|
+
/** Add new document with generated ID */
|
|
33
|
+
static appendNewRecord<T>(collectionRef: CollectionReference<T>, data: T): Promise<DocumentReference<T>>;
|
|
34
|
+
/** Add or overwrite a document with a specific ID */
|
|
35
|
+
static addData<T>(collectionRef: CollectionReference<T>, id: string, data: T): Promise<DocumentReference<T>>;
|
|
36
|
+
/** Get all documents from a collection */
|
|
37
|
+
static getAllData<T>(collectionRef: CollectionReference<T>): Promise<(T & {
|
|
38
|
+
id: string;
|
|
39
|
+
})[]>;
|
|
40
|
+
/** Get a single document by ID */
|
|
41
|
+
static getDataById<T>(collectionRef: CollectionReference<T>, id: string): Promise<(T & {
|
|
42
|
+
id: string;
|
|
43
|
+
}) | undefined>;
|
|
44
|
+
/** Get a user by ID (typed) */
|
|
45
|
+
static getUserById(id: string): Promise<IUserModel | undefined>;
|
|
46
|
+
/** Get a user by ID (typed) */
|
|
47
|
+
static getUserByEmail(email: string): Promise<IUserModel | undefined>;
|
|
48
|
+
/** Query collection by field */
|
|
49
|
+
static getDataByKeyField<T extends DocumentData>(collectionRef: CollectionReference<T>, fieldName: string, operator: WhereFilterOp, value: any, options?: {
|
|
50
|
+
orderByField?: keyof T | string;
|
|
51
|
+
orderDirection?: OrderByDirection;
|
|
52
|
+
limit?: number;
|
|
53
|
+
}): Promise<(T & {
|
|
54
|
+
id: string;
|
|
55
|
+
})[]>;
|
|
56
|
+
/** Update document fields (partial update) */
|
|
57
|
+
static updateData<T>(collectionRef: CollectionReference<T>, id: string, newFieldRecord: DeepPartial<T>, options?: {
|
|
58
|
+
deepMerge?: boolean;
|
|
59
|
+
}): Promise<void>;
|
|
60
|
+
private static flattenObject;
|
|
61
|
+
/** Update user document (typed helper) */
|
|
62
|
+
static updateUserData(id: string, newFieldRecord: Partial<IUserModel>): Promise<void>;
|
|
63
|
+
/** Delete document */
|
|
64
|
+
static deleteData<T>(collectionRef: CollectionReference<T>, id: string): Promise<void>;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=firestore.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firestore.service.d.ts","sourceRoot":"","sources":["../../src/services/firestore.service.ts"],"names":[],"mappings":"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"}
|