vidspotai-shared 1.0.41 → 1.0.42

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.
@@ -1 +1 @@
1
- {"version":3,"file":"minimax.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/minimax/minimax.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;AAUlB,qBAAa,cAAe,SAAQ,wBAAwB;IAC1D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA4B;IAEpD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;;YAUlB,OAAO;IAiCf,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IA4B3B,gBAAgB,CAAC,EACrB,IAAI,EACJ,cAAc,EACd,cAAyB,GAC1B,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA6EjD,aAAa,CAAC,EACZ,QAAQ,EACR,UAAmB,EACnB,QAAY,EACZ,SAAiB,GAClB,EAAE,iBAAiB,GAAG,MAAM;CAW9B"}
1
+ {"version":3,"file":"minimax.service.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/minimax/minimax.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;AAiClB,qBAAa,cAAe,SAAQ,wBAAwB;IAC1D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA4B;IAEpD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;;YAUlB,OAAO;IAiCf,aAAa,CACjB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC;IA4B3B,gBAAgB,CAAC,EACrB,IAAI,EACJ,cAAc,EACd,cAAyB,GAC1B,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA6EjD,aAAa,CAAC,EACZ,QAAQ,EACR,UAAmB,EACnB,QAAY,EACZ,SAAiB,GAClB,EAAE,iBAAiB,GAAG,MAAM;CAW9B"}
@@ -12,6 +12,28 @@ const helpers_1 = require("../../helpers");
12
12
  const baseAiGenProvider_service_1 = require("../baseAiGenProvider.service");
13
13
  const helpers_2 = require("../../../../utils/helpers");
14
14
  const logger_1 = require("../../../../utils/logger");
15
+ /**
16
+ * Maps Minimax base_resp status codes to user-facing error messages.
17
+ * Raw codes like "1026 input new_sensitive" are never shown to users.
18
+ */
19
+ function minimaxStatusToUserMessage(code, msg) {
20
+ const lower = msg.toLowerCase();
21
+ switch (code) {
22
+ case 1026:
23
+ // Input (prompt or image) flagged by content moderation
24
+ return "Your request was declined because the prompt or input image contains content that violates the content policy. Please modify your prompt or use a different image and try again.";
25
+ case 1027:
26
+ // Generated output flagged by content moderation
27
+ return "Your request was declined because the generated content was flagged for sensitive material. Please adjust your prompt and try again.";
28
+ case 1002:
29
+ return "The request was rejected due to a rate limit or quota issue. Please try again in a moment.";
30
+ case 1004:
31
+ return "Authorization failed for the video generation service. Please contact support.";
32
+ default:
33
+ // Unknown code — return the raw message so ops can see it but strip internal codes
34
+ return msg || `Generation failed (code ${code})`;
35
+ }
36
+ }
15
37
  class MinimaxService extends baseAiGenProvider_service_1.BaseAiGenProviderService {
16
38
  constructor() {
17
39
  super();
@@ -64,7 +86,7 @@ class MinimaxService extends baseAiGenProvider_service_1.BaseAiGenProviderServic
64
86
  if (result.status === "Fail") {
65
87
  return {
66
88
  status: types_1.EVideoSceneStatus.FAILED,
67
- errorMessage: `${result.base_resp.status_code} ${result.base_resp.status_msg}`,
89
+ errorMessage: minimaxStatusToUserMessage(result.base_resp.status_code, result.base_resp.status_msg),
68
90
  };
69
91
  }
70
92
  else if (result.status === "Success") {
@@ -1 +1 @@
1
- {"version":3,"file":"elevenlabs.service.d.ts","sourceRoot":"","sources":["../../../../src/services/tts/providers/elevenlabs.service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEzF,qBAAa,iBAAkB,SAAQ,sBAAsB;IAC3D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkC;IAE1D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;;IAW1B,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IAmCrD,SAAS,IAAI,eAAe,EAAE;IAI9B,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAGpD"}
1
+ {"version":3,"file":"elevenlabs.service.d.ts","sourceRoot":"","sources":["../../../../src/services/tts/providers/elevenlabs.service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEzF,qBAAa,iBAAkB,SAAQ,sBAAsB;IAC3D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkC;IAE1D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;;IAW1B,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IAuDrD,SAAS,IAAI,eAAe,EAAE;IAI9B,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAGpD"}
@@ -23,28 +23,48 @@ class ElevenLabsService extends types_1.BaseTtsProviderService {
23
23
  const languageCode = params.languageCode
24
24
  ? this.mapLanguageCode(params.languageCode)
25
25
  : undefined;
26
- const response = await axios_1.default.post(`${this.baseUrl}/text-to-speech/${voiceId}`, {
27
- text: params.text,
28
- model_id: elevenlabs_1.elevenlabsConfig.modelId,
29
- language_code: languageCode,
30
- voice_settings: {
31
- stability: 0.5,
32
- similarity_boost: 0.75,
33
- },
34
- }, {
35
- headers: {
36
- "xi-api-key": this.apiKey,
37
- "Content-Type": "application/json",
38
- Accept: "audio/mpeg",
39
- },
40
- responseType: "arraybuffer",
41
- timeout: 60000,
42
- });
43
- return {
44
- audioBuffer: Buffer.from(response.data),
45
- mimeType: "audio/mpeg",
46
- extension: "mp3",
47
- };
26
+ try {
27
+ const response = await axios_1.default.post(`${this.baseUrl}/text-to-speech/${voiceId}`, {
28
+ text: params.text,
29
+ model_id: elevenlabs_1.elevenlabsConfig.modelId,
30
+ language_code: languageCode,
31
+ voice_settings: {
32
+ stability: 0.5,
33
+ similarity_boost: 0.75,
34
+ },
35
+ }, {
36
+ headers: {
37
+ "xi-api-key": this.apiKey,
38
+ "Content-Type": "application/json",
39
+ Accept: "audio/mpeg",
40
+ },
41
+ responseType: "arraybuffer",
42
+ timeout: 60000,
43
+ });
44
+ return {
45
+ audioBuffer: Buffer.from(response.data),
46
+ mimeType: "audio/mpeg",
47
+ extension: "mp3",
48
+ };
49
+ }
50
+ catch (err) {
51
+ // responseType:"arraybuffer" causes error bodies to arrive as Buffer/ArrayBuffer,
52
+ // making err.message just "Request failed with status code N". Decode it here so
53
+ // the actual ElevenLabs reason (e.g. invalid voice, unsupported language_code) is visible.
54
+ if (err.response?.data) {
55
+ let detail = "";
56
+ try {
57
+ const bodyStr = Buffer.from(err.response.data).toString("utf8");
58
+ const parsed = JSON.parse(bodyStr);
59
+ detail = parsed?.detail?.message ?? parsed?.detail ?? bodyStr;
60
+ }
61
+ catch {
62
+ detail = Buffer.from(err.response.data).toString("utf8");
63
+ }
64
+ throw new Error(`ElevenLabs TTS ${err.response.status}: ${detail} [voiceId=${voiceId}, languageCode=${languageCode ?? "none"}, textLen=${params.text?.length ?? 0}]`);
65
+ }
66
+ throw err;
67
+ }
48
68
  }
49
69
  getVoices() {
50
70
  return voices_1.ELEVENLABS_VOICES;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vidspotai-shared",
3
- "version": "1.0.41",
3
+ "version": "1.0.42",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "exports": {