vidspotai-shared 1.0.31 → 1.0.32
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/index.d.ts +0 -1
- package/lib/globals/index.d.ts.map +1 -1
- package/lib/globals/index.js +0 -1
- package/lib/models/user.model.d.ts +0 -2
- package/lib/models/user.model.d.ts.map +1 -1
- package/lib/models/video.model.d.ts +0 -9
- package/lib/models/video.model.d.ts.map +1 -1
- package/lib/services/aiGen/aiGenFactory.service.d.ts.map +1 -1
- package/lib/services/aiGen/aiGenFactory.service.js +12 -36
- package/lib/services/aiGen/providers/google/google.service.js +1 -1
- package/lib/services/aiGen/providers/kling/kling.service.d.ts +2 -7
- package/lib/services/aiGen/providers/kling/kling.service.d.ts.map +1 -1
- package/lib/services/aiGen/providers/kling/kling.service.js +10 -126
- package/lib/services/aiGen/providers/kling/types.d.ts +0 -13
- package/lib/services/aiGen/providers/kling/types.d.ts.map +1 -1
- package/lib/services/aiGen/providers/runway/runway.service.d.ts.map +1 -1
- package/lib/services/aiGen/providers/runway/runway.service.js +4 -16
- package/lib/services/aiGen/providers/types.d.ts +0 -6
- package/lib/services/aiGen/providers/types.d.ts.map +1 -1
- package/lib/services/credit.service.d.ts +0 -1
- package/lib/services/credit.service.d.ts.map +1 -1
- package/lib/services/credit.service.js +0 -17
- package/lib/services/index.d.ts +0 -1
- package/lib/services/index.d.ts.map +1 -1
- package/lib/services/index.js +0 -1
- package/lib/utils/helpers.js +2 -2
- package/lib/utils/index.d.ts +0 -1
- package/lib/utils/index.d.ts.map +1 -1
- package/lib/utils/index.js +0 -1
- package/lib/utils/logger.d.ts +1 -2
- package/lib/utils/logger.d.ts.map +1 -1
- package/lib/utils/logger.js +0 -2
- package/package.json +1 -1
package/lib/globals/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/globals/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/globals/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
|
package/lib/globals/index.js
CHANGED
|
@@ -18,5 +18,4 @@ __exportStar(require("./aiModels"), exports);
|
|
|
18
18
|
__exportStar(require("./config"), exports);
|
|
19
19
|
__exportStar(require("./plans"), exports);
|
|
20
20
|
__exportStar(require("./schemas"), exports);
|
|
21
|
-
__exportStar(require("./ttsModels"), exports);
|
|
22
21
|
__exportStar(require("./types"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.model.d.ts","sourceRoot":"","sources":["../../src/models/user.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EACL,SAAS,EACT,kBAAkB,EAElB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,YAAY,CAAC;IACtC,SAAS,EAAE,UAAU,CAAC;IACtB,SAAS,EAAE,UAAU,CAAC;IACtB,QAAQ,EAAE,YAAY,GAAG,UAAU,GAAG,WAAW,GAAG,MAAM,CAAC;IAC3D,aAAa,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,YAAY,CAAC,EAAE,iBAAiB,CAAC;IACjC,gBA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ideoScene {
|
|
|
10
10
|
outputVideoUrl?: string;
|
|
11
11
|
inputVideoUrl?: string;
|
|
12
12
|
inputImageUrl?: string;
|
|
13
|
-
inputAudioUrl?: string;
|
|
14
13
|
status: EVideoSceneStatus;
|
|
15
14
|
creditsUsed?: number;
|
|
16
15
|
errorMessage?: string;
|
|
@@ -40,19 +39,11 @@ export interface IVideoJobModel {
|
|
|
40
39
|
};
|
|
41
40
|
duration?: number;
|
|
42
41
|
mode?: EVideoMode;
|
|
43
|
-
audio?: boolean;
|
|
44
42
|
dimensions?: string;
|
|
45
43
|
resolution?: string;
|
|
46
44
|
aspectRatio?: string;
|
|
47
45
|
inputVideoUrl?: string;
|
|
48
46
|
inputImageUrl?: string;
|
|
49
|
-
inputAudioUrl?: string;
|
|
50
|
-
contentType?: "video" | "avatar-video";
|
|
51
|
-
ttsText?: string;
|
|
52
|
-
ttsProvider?: string;
|
|
53
|
-
ttsVoiceId?: string;
|
|
54
|
-
ttsLanguageCode?: string;
|
|
55
|
-
generatedAudioUrl?: string;
|
|
56
47
|
createdAt: FieldValue;
|
|
57
48
|
updatedAt: FieldValue;
|
|
58
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"video.model.d.ts","sourceRoot":"","sources":["../../src/models/video.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,
|
|
1
|
+
{"version":3,"file":"video.model.d.ts","sourceRoot":"","sources":["../../src/models/video.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAe,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,MAAM,WAAW,WAAW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U,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IAGvB,SAAS,EAAE,UAAU,CAAC;IACtB,SAAS,EAAE,UAAU,CAAC;CACvB"}
|
|
@@ -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,cAAc,EACd,eAAe,EACf,WAAW,EACZ,MAAM,wBAAwB,CAAC;
|
|
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,cAAc,EACd,eAAe,EACf,WAAW,EACZ,MAAM,wBAAwB,CAAC;AAUhC,KAAK,uBAAuB,GAAG,UAAU,wBAAwB,CAAC;AAElE,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,eAAe,EACf,uBAAuB,CAqBxB,CAAC;AAUF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,cAAc,EAAE,uBAAuB,CAQzE,CAAC;AAEJ,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,WAAW,GACpB,wBAAwB,CAY1B"}
|
|
@@ -7,52 +7,28 @@ const kling_service_1 = require("./providers/kling/kling.service");
|
|
|
7
7
|
const minimax_service_1 = require("./providers/minimax/minimax.service");
|
|
8
8
|
const openai_service_1 = require("./providers/openai/openai.service");
|
|
9
9
|
const runway_service_1 = require("./providers/runway/runway.service");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const pixverse_service_1 = require("./providers/pixverse/pixverse.service");
|
|
13
|
-
const bytedance_service_1 = require("./providers/bytedance/bytedance.service");
|
|
10
|
+
const alibaba_1 = require("./providers/alibaba/alibaba");
|
|
11
|
+
const azure_1 = require("./providers/azure");
|
|
14
12
|
exports.videoServicesMap = {
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
"pixverse-v5.5": pixverse_service_1.PixVerseService,
|
|
18
|
-
"pixverse-v5": pixverse_service_1.PixVerseService,
|
|
19
|
-
// --- ByteDance ---
|
|
20
|
-
"bytedance-seedance-1.5-pro": bytedance_service_1.ByteDanceService,
|
|
21
|
-
"bytedance-seedance-1.0-pro-fast": bytedance_service_1.ByteDanceService,
|
|
22
|
-
"bytedance-seedance-1.0-pro": bytedance_service_1.ByteDanceService,
|
|
23
|
-
// --- Google ---
|
|
24
|
-
"google-veo-3.1": google_service_1.GoogleService,
|
|
25
|
-
"google-veo-3.1-fast": google_service_1.GoogleService,
|
|
13
|
+
"google-veo-3.1-preview": google_service_1.GoogleService,
|
|
14
|
+
"google-veo-3.1-fast-preview": google_service_1.GoogleService,
|
|
26
15
|
"google-veo-3": google_service_1.GoogleService,
|
|
27
|
-
"google-veo-3-fast": google_service_1.GoogleService,
|
|
28
16
|
"google-veo-2": google_service_1.GoogleService,
|
|
29
|
-
|
|
30
|
-
"runway-gen4.5": runway_service_1.RunwayService,
|
|
17
|
+
"google-veo-3-fast": google_service_1.GoogleService,
|
|
31
18
|
"runway-gen4-turbo": runway_service_1.RunwayService,
|
|
32
19
|
"runway-gen4-aleph": runway_service_1.RunwayService,
|
|
33
|
-
|
|
34
|
-
"kling-
|
|
35
|
-
"kling-v2.5-turbo": kling_service_1.KlingService,
|
|
20
|
+
"kling-v1": kling_service_1.KlingService,
|
|
21
|
+
"kling-v1.6": kling_service_1.KlingService,
|
|
36
22
|
"kling-v2-master": kling_service_1.KlingService,
|
|
37
|
-
"kling-v2.1": kling_service_1.KlingService,
|
|
38
23
|
"kling-v2.1-master": kling_service_1.KlingService,
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
// "kling-v1": KlingService,
|
|
42
|
-
// --- MiniMax ---
|
|
43
|
-
"minimax-hailuo-2.3-fast": minimax_service_1.MinimaxService,
|
|
44
|
-
"minimax-hailuo-2.3": minimax_service_1.MinimaxService,
|
|
24
|
+
"T2V-01": minimax_service_1.MinimaxService,
|
|
25
|
+
"T2V-01-Director": minimax_service_1.MinimaxService,
|
|
45
26
|
"minimax-hailuo-02": minimax_service_1.MinimaxService,
|
|
46
|
-
|
|
47
|
-
// "T2V-01": MinimaxService,
|
|
48
|
-
// --- Azure ---
|
|
49
|
-
// "azure-sora": AzureService,
|
|
50
|
-
// --- OpenAI ---
|
|
27
|
+
"azure-sora": azure_1.AzureService,
|
|
51
28
|
"openai-sora-2": openai_service_1.OpenaiService,
|
|
52
29
|
"openai-sora-2-pro": openai_service_1.OpenaiService,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
// "alibaba-wan-2.2": AlibabaService,
|
|
30
|
+
"alibaba-wan-2.5": alibaba_1.AlibabaService,
|
|
31
|
+
"alibaba-wan-2.2": alibaba_1.AlibabaService,
|
|
56
32
|
};
|
|
57
33
|
// export const imageServicesMap: Record<imageGenModel, BaseAiGenProviderService> = {
|
|
58
34
|
// "openai-dalle-3": DalleService,
|
|
@@ -24,7 +24,7 @@ class GoogleService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
24
24
|
(0, helpers_2.validateParams)(params);
|
|
25
25
|
const modelConfig = aiModels_1.aiModelConfigs[params.modelKey];
|
|
26
26
|
const modelId = modelConfig.modelId;
|
|
27
|
-
|
|
27
|
+
console.log("GoogleService.generateVideo - modelId:", modelId, params);
|
|
28
28
|
const request = {
|
|
29
29
|
model: modelId,
|
|
30
30
|
prompt: params.prompt,
|
|
@@ -2,16 +2,11 @@ import { BaseAiGenProviderService } from "../baseAiGenProvider.service";
|
|
|
2
2
|
import { CreditUsageParams, VideoGenerationParams, VideoGenerationResult, VideoStatusParams, VideoStatusResult } from "../types";
|
|
3
3
|
export declare class KlingService extends BaseAiGenProviderService {
|
|
4
4
|
private readonly baseUrl;
|
|
5
|
-
private readonly
|
|
6
|
-
private readonly statusTimeout;
|
|
5
|
+
private readonly timeout;
|
|
7
6
|
constructor();
|
|
8
7
|
private request;
|
|
9
8
|
generateVideo(params: VideoGenerationParams): Promise<VideoGenerationResult>;
|
|
10
|
-
|
|
11
|
-
private requestWithTimeoutRetry;
|
|
12
|
-
checkVideoStatus(params: VideoStatusParams): Promise<VideoStatusResult>;
|
|
13
|
-
private checkRegularVideoStatus;
|
|
14
|
-
private checkAvatarVideoStatus;
|
|
9
|
+
checkVideoStatus({ task, outputFilename, outputFilePath, }: VideoStatusParams): Promise<VideoStatusResult>;
|
|
15
10
|
encodeJwtToken(): string;
|
|
16
11
|
getCreditUsed({ modelKey, mode, duration, }: CreditUsageParams): number;
|
|
17
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kling.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/kling/kling.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"kling.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/kling/kling.service.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAWlB,qBAAa,YAAa,SAAQ,wBAAwB;IACxD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuC;IAC/D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;;YAWnB,OAAO;IA6Bf,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IA8B3B,gBAAgB,CAAC,EACrB,IAAI,EACJ,cAAc,EACd,cAAyB,GAC1B,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA8DjD,cAAc,IAAI,MAAM;IAexB,aAAa,CAAC,EACZ,QAAQ,EACR,IAA8B,EAC9B,QAAY,GACb,EAAE,iBAAiB,GAAG,MAAM;CAK9B"}
|
|
@@ -10,7 +10,6 @@ const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
|
10
10
|
const aiModels_1 = require("../../../../globals/aiModels");
|
|
11
11
|
const types_1 = require("../../../../globals/types");
|
|
12
12
|
const firebase_1 = require("../../../../libs/firebase");
|
|
13
|
-
const logger_1 = require("../../../../utils/logger");
|
|
14
13
|
const helpers_1 = require("../../helpers");
|
|
15
14
|
const types_2 = require("../../types");
|
|
16
15
|
const baseAiGenProvider_service_1 = require("../baseAiGenProvider.service");
|
|
@@ -19,13 +18,12 @@ class KlingService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
19
18
|
constructor() {
|
|
20
19
|
super();
|
|
21
20
|
this.baseUrl = "https://api-singapore.klingai.com";
|
|
22
|
-
this.
|
|
23
|
-
this.statusTimeout = 60000; // 1 min — status/poll should be fast
|
|
21
|
+
this.timeout = 60000; // 1 min
|
|
24
22
|
if (!process.env.KLING_SECRET_KEY || !process.env.KLING_ACCESS_KEY) {
|
|
25
23
|
throw new Error("Missing KLING_SECRET_KEY or KLING_ACCESS_KEY in environment variables");
|
|
26
24
|
}
|
|
27
25
|
}
|
|
28
|
-
async request(endpoint, method, body
|
|
26
|
+
async request(endpoint, method, body) {
|
|
29
27
|
const config = {
|
|
30
28
|
method,
|
|
31
29
|
url: `${this.baseUrl}${endpoint}`,
|
|
@@ -33,7 +31,7 @@ class KlingService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
33
31
|
Authorization: `Bearer ${this.encodeJwtToken()}`,
|
|
34
32
|
"Content-Type": "application/json",
|
|
35
33
|
},
|
|
36
|
-
timeout,
|
|
34
|
+
timeout: this.timeout,
|
|
37
35
|
data: body,
|
|
38
36
|
};
|
|
39
37
|
const response = await axios_1.default.request(config);
|
|
@@ -44,9 +42,6 @@ class KlingService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
44
42
|
}
|
|
45
43
|
async generateVideo(params) {
|
|
46
44
|
(0, helpers_1.validateParams)(params);
|
|
47
|
-
if (params.modelKey === "kling-avatar") {
|
|
48
|
-
return this.generateAvatarVideo(params);
|
|
49
|
-
}
|
|
50
45
|
const modelId = aiModels_1.aiModelConfigs[params.modelKey]?.modelId;
|
|
51
46
|
if (!modelId)
|
|
52
47
|
throw new Error(`Unknown modelKey: ${params.modelKey}`);
|
|
@@ -58,75 +53,14 @@ class KlingService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
58
53
|
mode: params.mode || types_2.EVideoMode.STANDARD,
|
|
59
54
|
};
|
|
60
55
|
const starttime = Date.now();
|
|
61
|
-
const task = await this.
|
|
62
|
-
|
|
63
|
-
modelKey: params.modelKey,
|
|
64
|
-
taskId: task.data.task_id,
|
|
65
|
-
durationMs: Date.now() - starttime,
|
|
66
|
-
});
|
|
67
|
-
return { task: task.data.task_id, status: types_1.EVideoSceneStatus.TRIGGERED };
|
|
68
|
-
}
|
|
69
|
-
async generateAvatarVideo(params) {
|
|
70
|
-
if (!params.inputImageUrl) {
|
|
71
|
-
throw new Error("inputImageUrl (avatar face image) is required for Kling Avatar generation");
|
|
72
|
-
}
|
|
73
|
-
if (!params.inputAudioUrl) {
|
|
74
|
-
throw new Error("inputAudioUrl (audio file) is required for Kling Avatar generation");
|
|
75
|
-
}
|
|
76
|
-
const request = {
|
|
77
|
-
image: params.inputImageUrl,
|
|
78
|
-
sound_file: params.inputAudioUrl,
|
|
79
|
-
prompt: params.prompt,
|
|
80
|
-
mode: params.mode || "std",
|
|
81
|
-
};
|
|
82
|
-
const starttime = Date.now();
|
|
83
|
-
// Use requestWithTimeoutRetry so transient Kling server slowness doesn't fail the job outright.
|
|
84
|
-
// generateTimeout (2 min) gives enough headroom; up to 4 attempts before giving up.
|
|
85
|
-
const task = await this.requestWithTimeoutRetry("/v1/videos/avatar/image2video", "POST", request, 4, this.generateTimeout);
|
|
86
|
-
logger_1.logger.info("Kling generateAvatarVideo submitted", {
|
|
87
|
-
taskId: task.data.task_id,
|
|
88
|
-
durationMs: Date.now() - starttime,
|
|
89
|
-
});
|
|
56
|
+
const task = await this.request("/v1/videos/text2video", "POST", request);
|
|
57
|
+
console.log(`Kling generateVideo API call took ${Date.now() - starttime} ms`, task ? `(task ID: ${task.data.task_id})` : "(failed)");
|
|
90
58
|
return { task: task.data.task_id, status: types_1.EVideoSceneStatus.TRIGGERED };
|
|
91
59
|
}
|
|
92
|
-
async
|
|
93
|
-
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
94
|
-
try {
|
|
95
|
-
return await this.request(endpoint, method, body, timeout);
|
|
96
|
-
}
|
|
97
|
-
catch (err) {
|
|
98
|
-
const isTimeout = err.code === "ECONNABORTED" || err.message?.includes("timeout");
|
|
99
|
-
const isNetworkError = err.code === "ECONNRESET" ||
|
|
100
|
-
err.code === "ECONNREFUSED" ||
|
|
101
|
-
err.code === "ENOTFOUND" ||
|
|
102
|
-
err.code === "ERR_NETWORK" ||
|
|
103
|
-
err?.name === "AggregateError";
|
|
104
|
-
const isRetryable = isTimeout || isNetworkError;
|
|
105
|
-
if (!isRetryable || attempt === maxAttempts)
|
|
106
|
-
throw err;
|
|
107
|
-
logger_1.logger.warn("Kling request failed with transient error — retrying", {
|
|
108
|
-
endpoint,
|
|
109
|
-
attempt,
|
|
110
|
-
maxAttempts,
|
|
111
|
-
timeoutMs: timeout,
|
|
112
|
-
errorCode: err.code,
|
|
113
|
-
errorName: err?.name,
|
|
114
|
-
});
|
|
115
|
-
await new Promise((r) => setTimeout(r, 1000));
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
throw new Error("Unreachable");
|
|
119
|
-
}
|
|
120
|
-
async checkVideoStatus(params) {
|
|
121
|
-
if (params.modelKey === "kling-avatar") {
|
|
122
|
-
return this.checkAvatarVideoStatus(params);
|
|
123
|
-
}
|
|
124
|
-
return this.checkRegularVideoStatus(params);
|
|
125
|
-
}
|
|
126
|
-
async checkRegularVideoStatus({ task, outputFilename, outputFilePath = "videos", }) {
|
|
60
|
+
async checkVideoStatus({ task, outputFilename, outputFilePath = "videos", }) {
|
|
127
61
|
const startTime = Date.now();
|
|
128
|
-
const result = await this.
|
|
129
|
-
|
|
62
|
+
const result = await this.request(`/v1/videos/text2video/${task}`, "GET");
|
|
63
|
+
console.log(`Kling checkVideoStatus API call took ${Date.now() - startTime} ms`);
|
|
130
64
|
if (!result) {
|
|
131
65
|
return {
|
|
132
66
|
status: types_1.EVideoSceneStatus.FAILED,
|
|
@@ -144,53 +78,10 @@ class KlingService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
144
78
|
// console.log("Kling video URL:", videoUrl);
|
|
145
79
|
const filePath = `${outputFilePath}/${outputFilename}.mp4`;
|
|
146
80
|
const file = (0, firebase_1.getBucket)().file(filePath);
|
|
147
|
-
// Download video using axios
|
|
81
|
+
// Download video using axios
|
|
148
82
|
const videoResp = await axios_1.default.get(videoUrl, {
|
|
149
83
|
responseType: "arraybuffer",
|
|
150
|
-
timeout: this.
|
|
151
|
-
});
|
|
152
|
-
const buffer = Buffer.from(videoResp.data);
|
|
153
|
-
await file.save(buffer, { contentType: "video/mp4" });
|
|
154
|
-
const [signedUrl] = await file.getSignedUrl({
|
|
155
|
-
action: "read",
|
|
156
|
-
expires: "03-09-2491",
|
|
157
|
-
});
|
|
158
|
-
return {
|
|
159
|
-
videoUrl: signedUrl,
|
|
160
|
-
status: types_1.EVideoSceneStatus.COMPLETED,
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
if (result.data.task_status === "failed") {
|
|
164
|
-
return {
|
|
165
|
-
status: types_1.EVideoSceneStatus.FAILED,
|
|
166
|
-
errorMessage: `${result.code}: ${result.message}`,
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
return { status: types_1.EVideoSceneStatus.PENDING };
|
|
170
|
-
}
|
|
171
|
-
async checkAvatarVideoStatus({ task, outputFilename, outputFilePath = "videos", }) {
|
|
172
|
-
const startTime = Date.now();
|
|
173
|
-
const result = await this.requestWithTimeoutRetry(`/v1/videos/avatar/image2video/${task}`, "GET");
|
|
174
|
-
logger_1.logger.info("Kling checkAvatarVideoStatus polled", { task, durationMs: Date.now() - startTime, status: result?.data?.task_status });
|
|
175
|
-
if (!result) {
|
|
176
|
-
return {
|
|
177
|
-
status: types_1.EVideoSceneStatus.FAILED,
|
|
178
|
-
errorMessage: "No response from Kling Avatar API",
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
if (result.data.task_status === "succeed") {
|
|
182
|
-
const videoUrl = result.data.task_result?.videos?.[0]?.url;
|
|
183
|
-
if (!videoUrl) {
|
|
184
|
-
return {
|
|
185
|
-
status: types_1.EVideoSceneStatus.FAILED,
|
|
186
|
-
errorMessage: "No video URL in avatar response",
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
const filePath = `${outputFilePath}/${outputFilename}.mp4`;
|
|
190
|
-
const file = (0, firebase_1.getBucket)().file(filePath);
|
|
191
|
-
const videoResp = await axios_1.default.get(videoUrl, {
|
|
192
|
-
responseType: "arraybuffer",
|
|
193
|
-
timeout: this.generateTimeout,
|
|
84
|
+
timeout: this.timeout,
|
|
194
85
|
});
|
|
195
86
|
const buffer = Buffer.from(videoResp.data);
|
|
196
87
|
await file.save(buffer, { contentType: "video/mp4" });
|
|
@@ -225,13 +116,6 @@ class KlingService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
225
116
|
}
|
|
226
117
|
getCreditUsed({ modelKey, mode = types_2.EVideoMode.PROFESSIONAL, duration = 5, }) {
|
|
227
118
|
const modelConfig = aiModels_1.aiModelConfigs[modelKey];
|
|
228
|
-
// Avatar: per-second pricing based on mode
|
|
229
|
-
if (modelKey === "kling-avatar") {
|
|
230
|
-
const perSecond = modelConfig?.cost?.[mode]?.perSecond
|
|
231
|
-
?? modelConfig?.cost?.["std"]?.perSecond
|
|
232
|
-
?? 0.014;
|
|
233
|
-
return (0, helpers_2.getCreditsFromCost)(perSecond * duration);
|
|
234
|
-
}
|
|
235
119
|
const cost = modelConfig?.cost?.table?.[mode]?.[duration];
|
|
236
120
|
return (0, helpers_2.getCreditsFromCost)(cost ?? 1);
|
|
237
121
|
}
|
|
@@ -68,19 +68,6 @@ export interface TaskResult {
|
|
|
68
68
|
export interface VideoResult {
|
|
69
69
|
id: string;
|
|
70
70
|
url: string;
|
|
71
|
-
watermark_url?: string;
|
|
72
71
|
duration: string;
|
|
73
72
|
}
|
|
74
|
-
export interface KlingAvatarGenerateRequest {
|
|
75
|
-
image: string;
|
|
76
|
-
audio_id?: string;
|
|
77
|
-
sound_file?: string;
|
|
78
|
-
prompt?: string;
|
|
79
|
-
mode?: "std" | "pro";
|
|
80
|
-
watermark_info?: {
|
|
81
|
-
enabled: boolean;
|
|
82
|
-
};
|
|
83
|
-
callback_url?: string;
|
|
84
|
-
external_task_id?: string;
|
|
85
|
-
}
|
|
86
73
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/kling/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,WAAW,GAAG,YAAY,GAAG,SAAS,GAAG,QAAQ,CAAC;IAC/D,SAAS,EAAE,QAAQ,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;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CAAC;IACnB,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,UAAU,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,QAAQ,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,UAAU,CAAC;CAC1B;AAED,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,YAAY,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE3E,MAAM,WAAW,QAAQ;IACvB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/kling/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,WAAW,GAAG,YAAY,GAAG,SAAS,GAAG,QAAQ,CAAC;IAC/D,SAAS,EAAE,QAAQ,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,QAAQ;IACvB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,MAAM,cAAc,GACtB,UAAU,GACV,YAAY,GACZ,iBAAiB,GACj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AAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,QAAQ,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,UAAU,CAAC;CAC1B;AAED,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,YAAY,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE3E,MAAM,WAAW,QAAQ;IACvB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runway.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/runway/runway.service.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAGlB,qBAAa,aAAc,SAAQ,wBAAwB;IACzD,OAAO,CAAC,QAAQ,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"runway.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/runway/runway.service.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAGlB,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;IAuC3B,gBAAgB,CAAC,EACrB,IAAI,EACJ,cAAc,EACd,cAAyB,GAC1B,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA4DjD,aAAa,CAAC,EAAE,QAAQ,EAAE,QAAY,EAAE,EAAE,iBAAiB,GAAG,MAAM;CAIrE"}
|
|
@@ -14,7 +14,7 @@ const baseAiGenProvider_service_1 = require("../baseAiGenProvider.service");
|
|
|
14
14
|
class RunwayService extends baseAiGenProvider_service_1.BaseAiGenProviderService {
|
|
15
15
|
constructor() {
|
|
16
16
|
super();
|
|
17
|
-
this.baseUrl = "https://api.
|
|
17
|
+
this.baseUrl = "https://api.runwayml.com/v1";
|
|
18
18
|
if (!process.env.RUNWAYML_API_SECRET) {
|
|
19
19
|
throw new Error("Missing RUNWAYML_API_SECRET in environment variables");
|
|
20
20
|
}
|
|
@@ -25,7 +25,6 @@ class RunwayService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
25
25
|
const headers = {
|
|
26
26
|
Authorization: `Bearer ${this.apiKey}`,
|
|
27
27
|
"Content-Type": "application/json",
|
|
28
|
-
"X-Runway-Version": "2024-11-06",
|
|
29
28
|
};
|
|
30
29
|
const response = await (0, axios_1.default)({
|
|
31
30
|
url,
|
|
@@ -46,19 +45,8 @@ class RunwayService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
46
45
|
if (!modelId)
|
|
47
46
|
throw new Error(`Unknown modelKey: ${params.modelKey}`);
|
|
48
47
|
let run;
|
|
49
|
-
//
|
|
50
|
-
if (modelId === "
|
|
51
|
-
const ratio = (params.aspectRatio || "1280x720").replace("x", ":");
|
|
52
|
-
const body = {
|
|
53
|
-
model: "gen4.5",
|
|
54
|
-
promptText: params.prompt,
|
|
55
|
-
ratio,
|
|
56
|
-
duration: params.duration || 5,
|
|
57
|
-
};
|
|
58
|
-
run = await this.request("/text_to_video", "POST", body);
|
|
59
|
-
}
|
|
60
|
-
// IMAGE → VIDEO (gen4_turbo)
|
|
61
|
-
else if (modelId === "gen4_turbo") {
|
|
48
|
+
// IMAGE → VIDEO
|
|
49
|
+
if (modelId === "gen4_turbo") {
|
|
62
50
|
const body = {
|
|
63
51
|
model: "gen4_turbo",
|
|
64
52
|
promptText: params.prompt,
|
|
@@ -68,7 +56,7 @@ class RunwayService extends baseAiGenProvider_service_1.BaseAiGenProviderService
|
|
|
68
56
|
};
|
|
69
57
|
run = await this.request("/image-to-video", "POST", body);
|
|
70
58
|
}
|
|
71
|
-
// VIDEO → VIDEO
|
|
59
|
+
// VIDEO → VIDEO
|
|
72
60
|
else if (modelId === "gen4_aleph") {
|
|
73
61
|
const body = {
|
|
74
62
|
model: "gen4_aleph",
|
|
@@ -10,12 +10,8 @@ export interface VideoGenerationParams {
|
|
|
10
10
|
duration?: number;
|
|
11
11
|
inputVideoUrl?: string;
|
|
12
12
|
inputImageUrl?: string;
|
|
13
|
-
inputAudioUrl?: string;
|
|
14
13
|
mode?: EVideoMode;
|
|
15
14
|
type?: "text-to-video" | "image-to-video" | "video-to-video";
|
|
16
|
-
audio?: boolean;
|
|
17
|
-
negativePrompt?: string;
|
|
18
|
-
multiClip?: boolean;
|
|
19
15
|
}
|
|
20
16
|
export interface VideoGenerationResult {
|
|
21
17
|
status: EVideoSceneStatus.TRIGGERED;
|
|
@@ -49,7 +45,5 @@ export interface CreditUsageParams {
|
|
|
49
45
|
aspectRatio?: string;
|
|
50
46
|
inputType?: "text" | "image" | "video";
|
|
51
47
|
outputType?: "text" | "image" | "video";
|
|
52
|
-
audio?: boolean;
|
|
53
|
-
multiClip?: boolean;
|
|
54
48
|
}
|
|
55
49
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/services/aiGen/providers/types.ts"],"names":[],"mappings":"AACA,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AAS,CAAC;IACpC,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,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;IAEnC,KAAK,EAAE,GAAG,CAAC;IACX,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credit.service.d.ts","sourceRoot":"","sources":["../../src/services/credit.service.ts"],"names":[],"mappings":"AAGA,qBAAa,aAAa;WACX,cAAc,CACzB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"credit.service.d.ts","sourceRoot":"","sources":["../../src/services/credit.service.ts"],"names":[],"mappings":"AAGA,qBAAa,aAAa;WACX,cAAc,CACzB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,IAAI,CAAC;CAwBjB"}
|
|
@@ -25,22 +25,5 @@ class CreditService {
|
|
|
25
25
|
});
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
|
-
static async refundCredits(userId, creditsToRefund) {
|
|
29
|
-
if (creditsToRefund <= 0)
|
|
30
|
-
return;
|
|
31
|
-
await firebase_1.firestore.runTransaction(async (tx) => {
|
|
32
|
-
const userRef = firestore_service_1.FirestoreService.usersCol.doc(userId);
|
|
33
|
-
const snap = await tx.get(userRef);
|
|
34
|
-
if (!snap.exists) {
|
|
35
|
-
throw new Error("USER_NOT_FOUND");
|
|
36
|
-
}
|
|
37
|
-
const consumed = snap.data()?.credits?.consumed ?? 0;
|
|
38
|
-
// Never let consumed go below 0
|
|
39
|
-
const newConsumed = Math.max(0, consumed - creditsToRefund);
|
|
40
|
-
tx.update(userRef, {
|
|
41
|
-
"credits.consumed": newConsumed,
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
28
|
}
|
|
46
29
|
exports.CreditService = CreditService;
|
package/lib/services/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,OAAO,CAAC;AACtB,cAAc,kBAAkB,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,OAAO,CAAC;AACtB,cAAc,kBAAkB,CAAC"}
|
package/lib/services/index.js
CHANGED
package/lib/utils/helpers.js
CHANGED
|
@@ -49,8 +49,8 @@ const getPriceIdByType = (type, freq = types_1.ERENEWAL_FREQUENCY.MONTHLY) => {
|
|
|
49
49
|
};
|
|
50
50
|
exports.getPriceIdByType = getPriceIdByType;
|
|
51
51
|
const getCreditsFromCost = (cost) => {
|
|
52
|
-
const margin = 0.2;
|
|
53
|
-
const costPerCredit = 0.1;
|
|
52
|
+
const margin = 0.2;
|
|
53
|
+
const costPerCredit = 0.1;
|
|
54
54
|
const minCredits = 10;
|
|
55
55
|
if (cost <= 0)
|
|
56
56
|
return 0;
|
package/lib/utils/index.d.ts
CHANGED
package/lib/utils/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
|
package/lib/utils/index.js
CHANGED
|
@@ -16,4 +16,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./helpers"), exports);
|
|
18
18
|
__exportStar(require("./logger"), exports);
|
|
19
|
-
__exportStar(require("./ttsUtils"), exports);
|
package/lib/utils/logger.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AA0B1C;;GAEG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAsExD"}
|
package/lib/utils/logger.js
CHANGED
|
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.logger = void 0;
|
|
7
6
|
exports.createLogger = createLogger;
|
|
8
7
|
const winston_1 = __importDefault(require("winston"));
|
|
9
8
|
const winston_slack_webhook_transport_1 = __importDefault(require("winston-slack-webhook-transport"));
|
|
@@ -84,4 +83,3 @@ function createLogger(serviceName) {
|
|
|
84
83
|
exitOnError: false,
|
|
85
84
|
});
|
|
86
85
|
}
|
|
87
|
-
exports.logger = createLogger("shared");
|