chore: Lint extensions folder.

This commit is contained in:
cpojer
2026-01-31 22:13:48 +09:00
parent 4f2166c503
commit 230ca789e2
221 changed files with 4006 additions and 1583 deletions

View File

@@ -37,11 +37,15 @@ export class MockProvider implements VoiceCallProvider {
if (Array.isArray(payload.events)) {
for (const evt of payload.events) {
const normalized = this.normalizeEvent(evt);
if (normalized) events.push(normalized);
if (normalized) {
events.push(normalized);
}
}
} else if (payload.event) {
const normalized = this.normalizeEvent(payload.event);
if (normalized) events.push(normalized);
if (normalized) {
events.push(normalized);
}
}
return { events, statusCode: 200 };
@@ -51,7 +55,9 @@ export class MockProvider implements VoiceCallProvider {
}
private normalizeEvent(evt: Partial<NormalizedEvent>): NormalizedEvent | null {
if (!evt.type || !evt.callId) return null;
if (!evt.type || !evt.callId) {
return null;
}
const base = {
id: evt.id || crypto.randomUUID(),

View File

@@ -123,7 +123,9 @@ export class PlivoProvider implements VoiceCallProvider {
if (flow === "xml-speak") {
const callId = this.getCallIdFromQuery(ctx);
const pending = callId ? this.pendingSpeakByCallId.get(callId) : undefined;
if (callId) this.pendingSpeakByCallId.delete(callId);
if (callId) {
this.pendingSpeakByCallId.delete(callId);
}
const xml = pending
? PlivoProvider.xmlSpeak(pending.text, pending.locale)
@@ -139,7 +141,9 @@ export class PlivoProvider implements VoiceCallProvider {
if (flow === "xml-listen") {
const callId = this.getCallIdFromQuery(ctx);
const pending = callId ? this.pendingListenByCallId.get(callId) : undefined;
if (callId) this.pendingListenByCallId.delete(callId);
if (callId) {
this.pendingListenByCallId.delete(callId);
}
const actionUrl = this.buildActionUrl(ctx, {
flow: "getinput",
@@ -393,7 +397,9 @@ export class PlivoProvider implements VoiceCallProvider {
private static normalizeNumber(numberOrSip: string): string {
const trimmed = numberOrSip.trim();
if (trimmed.toLowerCase().startsWith("sip:")) return trimmed;
if (trimmed.toLowerCase().startsWith("sip:")) {
return trimmed;
}
return trimmed.replace(/[^\d+]/g, "");
}
@@ -440,12 +446,16 @@ export class PlivoProvider implements VoiceCallProvider {
opts: { flow: string; callId?: string },
): string | null {
const base = PlivoProvider.baseWebhookUrlFromCtx(ctx);
if (!base) return null;
if (!base) {
return null;
}
const u = new URL(base);
u.searchParams.set("provider", "plivo");
u.searchParams.set("flow", opts.flow);
if (opts.callId) u.searchParams.set("callId", opts.callId);
if (opts.callId) {
u.searchParams.set("callId", opts.callId);
}
return u.toString();
}
@@ -478,7 +488,9 @@ export class PlivoProvider implements VoiceCallProvider {
for (const key of candidates) {
const value = params.get(key);
if (value && value.trim()) return value.trim();
if (value && value.trim()) {
return value.trim();
}
}
return null;
}

View File

@@ -155,7 +155,9 @@ class OpenAIRealtimeSTTSession implements RealtimeSTTSession {
this.ws.on("error", (error) => {
console.error("[RealtimeSTT] WebSocket error:", error);
if (!this.connected) reject(error);
if (!this.connected) {
reject(error);
}
});
this.ws.on("close", (code, reason) => {
@@ -258,7 +260,9 @@ class OpenAIRealtimeSTTSession implements RealtimeSTTSession {
}
sendAudio(muLawData: Buffer): void {
if (!this.connected) return;
if (!this.connected) {
return;
}
this.sendEvent({
type: "input_audio_buffer.append",
audio: muLawData.toString("base64"),

View File

@@ -205,10 +205,14 @@ function linearToMulaw(sample: number): number {
// Get sign bit
const sign = sample < 0 ? 0x80 : 0;
if (sample < 0) sample = -sample;
if (sample < 0) {
sample = -sample;
}
// Clip to prevent overflow
if (sample > CLIP) sample = CLIP;
if (sample > CLIP) {
sample = CLIP;
}
// Add bias and find segment
sample += BIAS;

View File

@@ -85,10 +85,14 @@ export class TwilioProvider implements VoiceCallProvider {
*/
private deleteStoredTwimlForProviderCall(providerCallId: string): void {
const webhookUrl = this.callWebhookUrls.get(providerCallId);
if (!webhookUrl) return;
if (!webhookUrl) {
return;
}
const callIdMatch = webhookUrl.match(/callId=([^&]+)/);
if (!callIdMatch) return;
if (!callIdMatch) {
return;
}
this.deleteStoredTwiml(callIdMatch[1]);
}
@@ -212,8 +216,12 @@ export class TwilioProvider implements VoiceCallProvider {
* Parse Twilio direction to normalized format.
*/
private static parseDirection(direction: string | null): "inbound" | "outbound" | undefined {
if (direction === "inbound") return "inbound";
if (direction === "outbound-api" || direction === "outbound-dial") return "outbound";
if (direction === "inbound") {
return "inbound";
}
if (direction === "outbound-api" || direction === "outbound-dial") {
return "outbound";
}
return undefined;
}
@@ -291,7 +299,9 @@ export class TwilioProvider implements VoiceCallProvider {
* When a call is answered, connects to media stream for bidirectional audio.
*/
private generateTwimlResponse(ctx?: WebhookContext): string {
if (!ctx) return TwilioProvider.EMPTY_TWIML;
if (!ctx) {
return TwilioProvider.EMPTY_TWIML;
}
const params = new URLSearchParams(ctx.rawBody);
const type = typeof ctx.query?.type === "string" ? ctx.query.type.trim() : undefined;
@@ -512,12 +522,16 @@ export class TwilioProvider implements VoiceCallProvider {
// Generate audio with core TTS (returns mu-law at 8kHz)
const muLawAudio = await ttsProvider.synthesizeForTelephony(text);
for (const chunk of chunkAudio(muLawAudio, CHUNK_SIZE)) {
if (signal.aborted) break;
if (signal.aborted) {
break;
}
handler.sendAudio(streamSid, chunk);
// Pace the audio to match real-time playback
await new Promise((resolve) => setTimeout(resolve, CHUNK_DELAY_MS));
if (signal.aborted) break;
if (signal.aborted) {
break;
}
}
if (!signal.aborted) {