@effect-uai/elevenlabs 0.12.0 → 0.12.1
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/dist/ElevenLabsMusicGenerator.d.mts +1 -3
- package/dist/ElevenLabsMusicGenerator.d.mts.map +1 -1
- package/dist/ElevenLabsMusicGenerator.mjs +6 -4
- package/dist/ElevenLabsMusicGenerator.mjs.map +1 -1
- package/dist/ElevenLabsMusicGenerator.test.d.mts +1 -1
- package/dist/ElevenLabsMusicGenerator.test.mjs +10 -6
- package/dist/ElevenLabsMusicGenerator.test.mjs.map +1 -1
- package/dist/ElevenLabsSynthesizer.d.mts +4 -7
- package/dist/ElevenLabsSynthesizer.d.mts.map +1 -1
- package/dist/ElevenLabsSynthesizer.mjs +1 -1
- package/dist/ElevenLabsSynthesizer.mjs.map +1 -1
- package/dist/ElevenLabsTranscriber.d.mts +5 -9
- package/dist/ElevenLabsTranscriber.d.mts.map +1 -1
- package/dist/ElevenLabsTranscriber.mjs +1 -1
- package/dist/ElevenLabsTranscriber.mjs.map +1 -1
- package/dist/ElevenLabsTranscriber.test.d.mts +1 -1
- package/dist/ElevenLabsTranscriber.test.mjs +10 -5
- package/dist/ElevenLabsTranscriber.test.mjs.map +1 -1
- package/dist/codec.d.mts +4 -6
- package/dist/codec.d.mts.map +1 -1
- package/dist/codec.mjs +1 -1
- package/dist/codec.mjs.map +1 -1
- package/dist/codec.test.d.mts +1 -1
- package/dist/codec.test.mjs +19 -13
- package/dist/codec.test.mjs.map +1 -1
- package/dist/dist-C0AvqZTC.mjs +145 -0
- package/dist/dist-C0AvqZTC.mjs.map +1 -0
- package/dist/{magic-string.es-CaWgF-3p.mjs → magic-string.es-CUAnjKYC.mjs} +14 -13
- package/dist/{magic-string.es-CaWgF-3p.mjs.map → magic-string.es-CUAnjKYC.mjs.map} +1 -1
- package/dist/models.d.mts.map +1 -1
- package/dist/{musicCodec-CZni1gAQ.d.mts → musicCodec-DjmvNC4W.d.mts} +1 -2
- package/dist/musicCodec-DjmvNC4W.d.mts.map +1 -0
- package/dist/musicCodec.d.mts +1 -1
- package/dist/musicCodec.mjs.map +1 -1
- package/dist/realtimeStt.d.mts +0 -1
- package/dist/realtimeStt.d.mts.map +1 -1
- package/dist/realtimeStt.mjs.map +1 -1
- package/dist/realtimeTts.d.mts +2 -2
- package/dist/realtimeTts.d.mts.map +1 -1
- package/dist/realtimeTts.mjs.map +1 -1
- package/dist/region.d.mts.map +1 -1
- package/dist/region.mjs.map +1 -1
- package/dist/region.test.d.mts +1 -1
- package/dist/region.test.mjs +1 -1
- package/dist/region.test.mjs.map +1 -1
- package/dist/{dist-CWoAuwS9.mjs → test.DNmyFkvJ-N3QqMRwZ.mjs} +257 -381
- package/dist/test.DNmyFkvJ-N3QqMRwZ.mjs.map +1 -0
- package/package.json +5 -5
- package/src/ElevenLabsMusicGenerator.ts +7 -10
- package/src/ElevenLabsSynthesizer.ts +10 -13
- package/src/ElevenLabsTranscriber.ts +5 -8
- package/src/realtimeStt.ts +12 -14
- package/dist/dist-CWoAuwS9.mjs.map +0 -1
- package/dist/musicCodec-CZni1gAQ.d.mts.map +0 -1
- /package/dist/{chunk-uyGKjUfl.mjs → rolldown-runtime-EAsCxrDo.mjs} +0 -0
package/dist/realtimeTts.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"realtimeTts.mjs","names":[],"sources":["../src/realtimeTts.ts"],"sourcesContent":["import { Cause, Effect, Encoding, Queue, Redacted, Result, Schema, Stream } from \"effect\"\nimport * as Socket from \"effect/unstable/socket/Socket\"\nimport * as AiError from \"@effect-uai/core/AiError\"\nimport type { AudioChunk, AudioFormat } from \"@effect-uai/core/Audio\"\nimport * as JSONL from \"@effect-uai/core/JSONL\"\nimport type { CustomPronunciation } from \"@effect-uai/core/SpeechSynthesizer\"\nimport {\n defaultFormat,\n formatToOutputSlug,\n type PronunciationDictionaryLocator,\n rejectInlinePronunciations,\n type VoiceSettings,\n wirePronunciationLocators,\n wireVoiceSettings,\n} from \"./codec.js\"\nimport type { ElevenLabsTtsModel, ElevenLabsVoiceId } from \"./models.js\"\nimport { type ElevenLabsRegion, resolveHost } from \"./region.js\"\n\nexport type Config = {\n readonly apiKey: Redacted.Redacted\n readonly baseUrl?: string\n readonly region?: ElevenLabsRegion\n}\n\nexport type { VoiceSettings } from \"./codec.js\"\n\n/**\n * Incremental-text-in request for `/stream-input`. `voiceSettings`\n * applies only on the BOS frame — mid-stream voice changes are\n * rejected. `autoMode: true` (default) lets the model pick flush\n * boundaries, which is what you want for LLM-token streams.\n */\nexport type StreamSynthesizeRequest = {\n readonly model?: ElevenLabsTtsModel\n readonly voiceId: ElevenLabsVoiceId\n readonly outputFormat?: AudioFormat\n readonly languageCode?: string\n readonly voiceSettings?: VoiceSettings\n readonly autoMode?: boolean\n /** Pre-provisioned pronunciation dictionaries, sent on the BOS frame. */\n readonly pronunciationDictionaryLocators?: ReadonlyArray<PronunciationDictionaryLocator>\n /** Carried from the Common request so the WS path can reject inline\n * pronunciations (ElevenLabs has no stateless inline IPA path). */\n readonly pronunciations?: ReadonlyArray<CustomPronunciation>\n}\n\n// ---------------------------------------------------------------------------\n// URL + frame builders\n// ---------------------------------------------------------------------------\n\nexport const buildWsUrl = (cfg: Config, request: StreamSynthesizeRequest, outputFormat: string) => {\n const wsBase = resolveHost(cfg).replace(/^http/, \"ws\")\n const params = new URLSearchParams({\n output_format: outputFormat,\n auto_mode: String(request.autoMode ?? true),\n ...(request.model !== undefined && { model_id: request.model }),\n ...(request.languageCode !== undefined && { language_code: request.languageCode }),\n })\n return `${wsBase}/text-to-speech/${request.voiceId}/stream-input?${params.toString()}`\n}\n\nconst bosFrame = (cfg: Config, request: StreamSynthesizeRequest) => {\n const vs = wireVoiceSettings(request.voiceSettings)\n return JSON.stringify({\n text: \" \",\n \"xi-api-key\": Redacted.value(cfg.apiKey),\n ...(vs !== undefined && { voice_settings: vs }),\n ...wirePronunciationLocators(request.pronunciationDictionaryLocators),\n })\n}\n\nconst textFrame = (text: string) => JSON.stringify({ text: text.endsWith(\" \") ? text : `${text} ` })\nconst eosFrame = JSON.stringify({ text: \"\" })\n\n// ---------------------------------------------------------------------------\n// Wire schema (server → client) + helpers\n// ---------------------------------------------------------------------------\n\nconst ServerFrame = Schema.Struct({\n audio: Schema.optional(Schema.NullOr(Schema.String)),\n isFinal: Schema.optional(Schema.NullOr(Schema.Boolean)),\n error: Schema.optional(Schema.Unknown),\n message: Schema.optional(Schema.String),\n})\nconst decodeServerFrame = Schema.decodeUnknownEffect(ServerFrame)\n\nconst decodeAudio = (b64: string): Effect.Effect<Uint8Array, AiError.AiError> =>\n Result.match(Encoding.decodeBase64(b64), {\n onSuccess: Effect.succeed,\n onFailure: (cause) =>\n Effect.fail(\n new AiError.GenerationFailed({\n provider: \"elevenlabs\",\n raw: { message: \"failed to decode audio frame\", cause },\n }),\n ),\n })\n\nconst handleServerFrame = (queue: Queue.Queue<AudioChunk, Cause.Done>) => (raw: string) =>\n Effect.gen(function* () {\n const json = yield* JSONL.parseSafe(raw)\n if (json === undefined) return\n const decoded = yield* decodeServerFrame(json).pipe(Effect.option)\n if (decoded._tag === \"None\") return\n const frame = decoded.value\n if (frame.error !== undefined) {\n yield* Effect.logWarning(\"[elevenlabs-tts] server error frame\", {\n error: frame.error,\n message: frame.message,\n })\n return\n }\n if (frame.audio == null || frame.audio === \"\") return\n const bytes = yield* decodeAudio(frame.audio).pipe(Effect.option)\n if (bytes._tag === \"Some\") yield* Queue.offer(queue, { bytes: bytes.value })\n })\n\n// ---------------------------------------------------------------------------\n// Stream<string> → Stream<AudioChunk>. Requires `Socket.WebSocketConstructor`.\n// ---------------------------------------------------------------------------\n\nexport const streamSynthesis =\n (cfg: Config) =>\n <E, R>(\n textIn: Stream.Stream<string, E, R>,\n request: StreamSynthesizeRequest,\n ): Stream.Stream<AudioChunk, AiError.AiError | E, R | Socket.WebSocketConstructor> =>\n Stream.unwrap(\n Effect.gen(function* () {\n yield* rejectInlinePronunciations(request.pronunciations)\n const slug = yield* formatToOutputSlug(request.outputFormat ?? defaultFormat)\n // ElevenLabs closes `/stream-input` with code 1000 after delivering the\n // final audio chunk. Effect's default treats all close codes as errors,\n // which would surface as a stream failure right after the last audio\n // arrives. Whitelist standard clean-close codes.\n const socket = yield* Socket.makeWebSocket(buildWsUrl(cfg, request, slug), {\n closeCodeIsError: (code) => code !== 1000 && code !== 1001 && code !== 1005,\n })\n const queue = yield* Queue.bounded<AudioChunk, Cause.Done>(64)\n const write = yield* socket.writer\n\n // Writer fiber: BOS → drain text stream → EOS. Socket-side failures\n // end this fiber; the reader still surfaces a clean stream end via\n // `Queue.end` (in the ensuring below) when the upstream WS closes.\n yield* Effect.gen(function* () {\n yield* write(bosFrame(cfg, request))\n yield* Stream.runForEach(textIn, (text) =>\n text.length === 0 ? Effect.void : write(textFrame(text)),\n )\n yield* write(eosFrame)\n }).pipe(Effect.ignore, Effect.forkScoped)\n\n // Reader fiber. `ensuring(Queue.end)` flushes pending chunks then\n // fails the next take with `Done`, which `Stream.fromQueue` treats\n // as a clean end. (`Queue.shutdown` would CLEAR queued items and\n // interrupt pending takes — wrong for graceful teardown.)\n yield* socket\n .runString(handleServerFrame(queue))\n .pipe(Effect.ensuring(Queue.end(queue)), Effect.forkScoped)\n\n return Stream.fromQueue(queue)\n }),\n )\n"],"mappings":";;;;;;;AAkDA,MAAa,cAAc,KAAa,SAAkC,iBAAyB;CACjG,MAAM,SAAS,YAAY,
|
|
1
|
+
{"version":3,"file":"realtimeTts.mjs","names":[],"sources":["../src/realtimeTts.ts"],"sourcesContent":["import { Cause, Effect, Encoding, Queue, Redacted, Result, Schema, Stream } from \"effect\"\nimport * as Socket from \"effect/unstable/socket/Socket\"\nimport * as AiError from \"@effect-uai/core/AiError\"\nimport type { AudioChunk, AudioFormat } from \"@effect-uai/core/Audio\"\nimport * as JSONL from \"@effect-uai/core/JSONL\"\nimport type { CustomPronunciation } from \"@effect-uai/core/SpeechSynthesizer\"\nimport {\n defaultFormat,\n formatToOutputSlug,\n type PronunciationDictionaryLocator,\n rejectInlinePronunciations,\n type VoiceSettings,\n wirePronunciationLocators,\n wireVoiceSettings,\n} from \"./codec.js\"\nimport type { ElevenLabsTtsModel, ElevenLabsVoiceId } from \"./models.js\"\nimport { type ElevenLabsRegion, resolveHost } from \"./region.js\"\n\nexport type Config = {\n readonly apiKey: Redacted.Redacted\n readonly baseUrl?: string\n readonly region?: ElevenLabsRegion\n}\n\nexport type { VoiceSettings } from \"./codec.js\"\n\n/**\n * Incremental-text-in request for `/stream-input`. `voiceSettings`\n * applies only on the BOS frame — mid-stream voice changes are\n * rejected. `autoMode: true` (default) lets the model pick flush\n * boundaries, which is what you want for LLM-token streams.\n */\nexport type StreamSynthesizeRequest = {\n readonly model?: ElevenLabsTtsModel\n readonly voiceId: ElevenLabsVoiceId\n readonly outputFormat?: AudioFormat\n readonly languageCode?: string\n readonly voiceSettings?: VoiceSettings\n readonly autoMode?: boolean\n /** Pre-provisioned pronunciation dictionaries, sent on the BOS frame. */\n readonly pronunciationDictionaryLocators?: ReadonlyArray<PronunciationDictionaryLocator>\n /** Carried from the Common request so the WS path can reject inline\n * pronunciations (ElevenLabs has no stateless inline IPA path). */\n readonly pronunciations?: ReadonlyArray<CustomPronunciation>\n}\n\n// ---------------------------------------------------------------------------\n// URL + frame builders\n// ---------------------------------------------------------------------------\n\nexport const buildWsUrl = (cfg: Config, request: StreamSynthesizeRequest, outputFormat: string) => {\n const wsBase = resolveHost(cfg).replace(/^http/, \"ws\")\n const params = new URLSearchParams({\n output_format: outputFormat,\n auto_mode: String(request.autoMode ?? true),\n ...(request.model !== undefined && { model_id: request.model }),\n ...(request.languageCode !== undefined && { language_code: request.languageCode }),\n })\n return `${wsBase}/text-to-speech/${request.voiceId}/stream-input?${params.toString()}`\n}\n\nconst bosFrame = (cfg: Config, request: StreamSynthesizeRequest) => {\n const vs = wireVoiceSettings(request.voiceSettings)\n return JSON.stringify({\n text: \" \",\n \"xi-api-key\": Redacted.value(cfg.apiKey),\n ...(vs !== undefined && { voice_settings: vs }),\n ...wirePronunciationLocators(request.pronunciationDictionaryLocators),\n })\n}\n\nconst textFrame = (text: string) => JSON.stringify({ text: text.endsWith(\" \") ? text : `${text} ` })\nconst eosFrame = JSON.stringify({ text: \"\" })\n\n// ---------------------------------------------------------------------------\n// Wire schema (server → client) + helpers\n// ---------------------------------------------------------------------------\n\nconst ServerFrame = Schema.Struct({\n audio: Schema.optional(Schema.NullOr(Schema.String)),\n isFinal: Schema.optional(Schema.NullOr(Schema.Boolean)),\n error: Schema.optional(Schema.Unknown),\n message: Schema.optional(Schema.String),\n})\nconst decodeServerFrame = Schema.decodeUnknownEffect(ServerFrame)\n\nconst decodeAudio = (b64: string): Effect.Effect<Uint8Array, AiError.AiError> =>\n Result.match(Encoding.decodeBase64(b64), {\n onSuccess: Effect.succeed,\n onFailure: (cause) =>\n Effect.fail(\n new AiError.GenerationFailed({\n provider: \"elevenlabs\",\n raw: { message: \"failed to decode audio frame\", cause },\n }),\n ),\n })\n\nconst handleServerFrame = (queue: Queue.Queue<AudioChunk, Cause.Done>) => (raw: string) =>\n Effect.gen(function* () {\n const json = yield* JSONL.parseSafe(raw)\n if (json === undefined) return\n const decoded = yield* decodeServerFrame(json).pipe(Effect.option)\n if (decoded._tag === \"None\") return\n const frame = decoded.value\n if (frame.error !== undefined) {\n yield* Effect.logWarning(\"[elevenlabs-tts] server error frame\", {\n error: frame.error,\n message: frame.message,\n })\n return\n }\n if (frame.audio == null || frame.audio === \"\") return\n const bytes = yield* decodeAudio(frame.audio).pipe(Effect.option)\n if (bytes._tag === \"Some\") yield* Queue.offer(queue, { bytes: bytes.value })\n })\n\n// ---------------------------------------------------------------------------\n// Stream<string> → Stream<AudioChunk>. Requires `Socket.WebSocketConstructor`.\n// ---------------------------------------------------------------------------\n\nexport const streamSynthesis =\n (cfg: Config) =>\n <E, R>(\n textIn: Stream.Stream<string, E, R>,\n request: StreamSynthesizeRequest,\n ): Stream.Stream<AudioChunk, AiError.AiError | E, R | Socket.WebSocketConstructor> =>\n Stream.unwrap(\n Effect.gen(function* () {\n yield* rejectInlinePronunciations(request.pronunciations)\n const slug = yield* formatToOutputSlug(request.outputFormat ?? defaultFormat)\n // ElevenLabs closes `/stream-input` with code 1000 after delivering the\n // final audio chunk. Effect's default treats all close codes as errors,\n // which would surface as a stream failure right after the last audio\n // arrives. Whitelist standard clean-close codes.\n const socket = yield* Socket.makeWebSocket(buildWsUrl(cfg, request, slug), {\n closeCodeIsError: (code) => code !== 1000 && code !== 1001 && code !== 1005,\n })\n const queue = yield* Queue.bounded<AudioChunk, Cause.Done>(64)\n const write = yield* socket.writer\n\n // Writer fiber: BOS → drain text stream → EOS. Socket-side failures\n // end this fiber; the reader still surfaces a clean stream end via\n // `Queue.end` (in the ensuring below) when the upstream WS closes.\n yield* Effect.gen(function* () {\n yield* write(bosFrame(cfg, request))\n yield* Stream.runForEach(textIn, (text) =>\n text.length === 0 ? Effect.void : write(textFrame(text)),\n )\n yield* write(eosFrame)\n }).pipe(Effect.ignore, Effect.forkScoped)\n\n // Reader fiber. `ensuring(Queue.end)` flushes pending chunks then\n // fails the next take with `Done`, which `Stream.fromQueue` treats\n // as a clean end. (`Queue.shutdown` would CLEAR queued items and\n // interrupt pending takes — wrong for graceful teardown.)\n yield* socket\n .runString(handleServerFrame(queue))\n .pipe(Effect.ensuring(Queue.end(queue)), Effect.forkScoped)\n\n return Stream.fromQueue(queue)\n }),\n )\n"],"mappings":";;;;;;;AAkDA,MAAa,cAAc,KAAa,SAAkC,iBAAyB;CACjG,MAAM,SAAS,YAAY,GAAG,CAAC,CAAC,QAAQ,SAAS,IAAI;CACrD,MAAM,SAAS,IAAI,gBAAgB;EACjC,eAAe;EACf,WAAW,OAAO,QAAQ,YAAY,IAAI;EAC1C,GAAI,QAAQ,UAAU,KAAA,KAAa,EAAE,UAAU,QAAQ,MAAM;EAC7D,GAAI,QAAQ,iBAAiB,KAAA,KAA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ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"region.d.mts","names":[],"sources":["../src/region.ts"],"mappings":";;;;;;;;;;;;KAaY;;;;;;;;;;cAaC,cAAW;WACb;WACA,SAAS"}
|
package/dist/region.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"region.mjs","names":[],"sources":["../src/region.ts"],"sourcesContent":["/**\n * ElevenLabs regional residency endpoints. The default workspace runs\n * against `api.elevenlabs.io`; EU- and IN-residency workspaces run\n * against `api.{eu,in}.residency.elevenlabs.io` (REST + WSS).\n *\n * API keys are workspace-bound — a key minted in an EU workspace must\n * be used against the EU host (and vice versa). Mixing key/host\n * surfaces as `401 PERMISSION_DENIED`.\n *\n * Reference: https://elevenlabs.io/docs/overview/administration/data-residency\n */\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport type ElevenLabsRegion = \"default\" | \"eu\" | \"in\" | (string & {})\n\nconst DEFAULT_HOST = \"https://api.elevenlabs.io/v1\"\n\n/**\n * Resolve the HTTP base URL from a Config. `baseUrl` wins when set;\n * otherwise the host is computed from `region`. Unknown region strings\n * pass through as `api.{region}.residency.elevenlabs.io/v1` for forward\n * compat.\n *\n * WS code derives its `wss://` URL by substituting `http→ws` on the\n * resolved host.\n */\nexport const resolveHost = (cfg: {\n readonly baseUrl?: string\n readonly region?: ElevenLabsRegion\n}): string => {\n if (cfg.baseUrl !== undefined) return cfg.baseUrl\n if (cfg.region === undefined || cfg.region === \"default\") return DEFAULT_HOST\n return `https://api.${cfg.region}.residency.elevenlabs.io/v1`\n}\n"],"mappings":";AAeA,MAAM,eAAe;;;;;;;;;;AAWrB,MAAa,eAAe,QAGd;
|
|
1
|
+
{"version":3,"file":"region.mjs","names":[],"sources":["../src/region.ts"],"sourcesContent":["/**\n * ElevenLabs regional residency endpoints. The default workspace runs\n * against `api.elevenlabs.io`; EU- and IN-residency workspaces run\n * against `api.{eu,in}.residency.elevenlabs.io` (REST + WSS).\n *\n * API keys are workspace-bound — a key minted in an EU workspace must\n * be used against the EU host (and vice versa). Mixing key/host\n * surfaces as `401 PERMISSION_DENIED`.\n *\n * Reference: https://elevenlabs.io/docs/overview/administration/data-residency\n */\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport type ElevenLabsRegion = \"default\" | \"eu\" | \"in\" | (string & {})\n\nconst DEFAULT_HOST = \"https://api.elevenlabs.io/v1\"\n\n/**\n * Resolve the HTTP base URL from a Config. `baseUrl` wins when set;\n * otherwise the host is computed from `region`. Unknown region strings\n * pass through as `api.{region}.residency.elevenlabs.io/v1` for forward\n * compat.\n *\n * WS code derives its `wss://` URL by substituting `http→ws` on the\n * resolved host.\n */\nexport const resolveHost = (cfg: {\n readonly baseUrl?: string\n readonly region?: ElevenLabsRegion\n}): string => {\n if (cfg.baseUrl !== undefined) return cfg.baseUrl\n if (cfg.region === undefined || cfg.region === \"default\") return DEFAULT_HOST\n return `https://api.${cfg.region}.residency.elevenlabs.io/v1`\n}\n"],"mappings":";AAeA,MAAM,eAAe;;;;;;;;;;AAWrB,MAAa,eAAe,QAGd;CACZ,IAAI,IAAI,YAAY,KAAA,GAAW,OAAO,IAAI;CAC1C,IAAI,IAAI,WAAW,KAAA,KAAa,IAAI,WAAW,WAAW,OAAO;CACjE,OAAO,eAAe,IAAI,OAAO;AACnC"}
|
package/dist/region.test.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {}
|
package/dist/region.test.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as describe, r as it, t as globalExpect } from "./test.DNmyFkvJ-N3QqMRwZ.mjs";
|
|
2
2
|
import { resolveHost } from "./region.mjs";
|
|
3
3
|
//#region src/region.test.ts
|
|
4
4
|
describe("elevenlabs/region.resolveHost", () => {
|
package/dist/region.test.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"region.test.mjs","names":[],"sources":["../src/region.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\"\nimport { resolveHost } from \"./region.js\"\n\ndescribe(\"elevenlabs/region.resolveHost\", () => {\n it(\"returns default host when no region or baseUrl\", () => {\n expect(resolveHost({})).toBe(\"https://api.elevenlabs.io/v1\")\n })\n\n it(\"returns default host for region 'default'\", () => {\n expect(resolveHost({ region: \"default\" })).toBe(\"https://api.elevenlabs.io/v1\")\n })\n\n it(\"computes EU residency host for region 'eu'\", () => {\n expect(resolveHost({ region: \"eu\" })).toBe(\"https://api.eu.residency.elevenlabs.io/v1\")\n })\n\n it(\"computes IN residency host for region 'in'\", () => {\n expect(resolveHost({ region: \"in\" })).toBe(\"https://api.in.residency.elevenlabs.io/v1\")\n })\n\n it(\"passes unknown region through as residency host\", () => {\n expect(resolveHost({ region: \"ap\" })).toBe(\"https://api.ap.residency.elevenlabs.io/v1\")\n })\n\n it(\"baseUrl wins over region\", () => {\n expect(resolveHost({ baseUrl: \"http://localhost:8080/v1\", region: \"eu\" })).toBe(\n \"http://localhost:8080/v1\",\n )\n })\n})\n"],"mappings":";;;AAGA,SAAS,uCAAuC;
|
|
1
|
+
{"version":3,"file":"region.test.mjs","names":[],"sources":["../src/region.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\"\nimport { resolveHost } from \"./region.js\"\n\ndescribe(\"elevenlabs/region.resolveHost\", () => {\n it(\"returns default host when no region or baseUrl\", () => {\n expect(resolveHost({})).toBe(\"https://api.elevenlabs.io/v1\")\n })\n\n it(\"returns default host for region 'default'\", () => {\n expect(resolveHost({ region: \"default\" })).toBe(\"https://api.elevenlabs.io/v1\")\n })\n\n it(\"computes EU residency host for region 'eu'\", () => {\n expect(resolveHost({ region: \"eu\" })).toBe(\"https://api.eu.residency.elevenlabs.io/v1\")\n })\n\n it(\"computes IN residency host for region 'in'\", () => {\n expect(resolveHost({ region: \"in\" })).toBe(\"https://api.in.residency.elevenlabs.io/v1\")\n })\n\n it(\"passes unknown region through as residency host\", () => {\n expect(resolveHost({ region: \"ap\" })).toBe(\"https://api.ap.residency.elevenlabs.io/v1\")\n })\n\n it(\"baseUrl wins over region\", () => {\n expect(resolveHost({ baseUrl: \"http://localhost:8080/v1\", region: \"eu\" })).toBe(\n \"http://localhost:8080/v1\",\n )\n })\n})\n"],"mappings":";;;AAGA,SAAS,uCAAuC;CAC9C,GAAG,wDAAwD;EACzD,aAAO,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,8BAA8B;CAC7D,CAAC;CAED,GAAG,mDAAmD;EACpD,aAAO,YAAY,EAAE,QAAQ,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,8BAA8B;CAChF,CAAC;CAED,GAAG,oDAAoD;EACrD,aAAO,YAAY,EAAE,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,2CAA2C;CACxF,CAAC;CAED,GAAG,oDAAoD;EACrD,aAAO,YAAY,EAAE,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,2CAA2C;CACxF,CAAC;CAED,GAAG,yDAAyD;EAC1D,aAAO,YAAY,EAAE,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,2CAA2C;CACxF,CAAC;CAED,GAAG,kCAAkC;EACnC,aAAO,YAAY;GAAE,SAAS;GAA4B,QAAQ;EAAK,CAAC,CAAC,CAAC,CAAC,KACzE,0BACF;CACF,CAAC;AACH,CAAC"}
|