refactor: update import statements to use .js extensions
- Changed all import statements across the project to include the .js extension for consistency and to comply with ES module standards. - Updated imports in various files including bootstrap.ts, shutdown.ts, config.ts, and many others. - Ensured that all related modules and types are correctly imported with the new extension.
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
import { parentPort } from "node:worker_threads";
|
||||
import { config } from "../config.ts";
|
||||
import { initializeDatabase } from "../database/drizzle.ts";
|
||||
import { buildConversationPromptMessages } from "./conversationContext.ts";
|
||||
import { runModerationAnalysis } from "./llmModerationClient.ts";
|
||||
import { config } from "../config.js";
|
||||
import { initializeDatabase } from "../database/drizzle.js";
|
||||
import { buildConversationPromptMessages } from "./conversationContext.js";
|
||||
import { runModerationAnalysis } from "./llmModerationClient.js";
|
||||
import {
|
||||
getAttachmentsForMessages,
|
||||
getConversationContextBefore,
|
||||
updateMessageAIAnalysis,
|
||||
} from "./messageStore.ts";
|
||||
import type { MessageRecord } from "./types";
|
||||
} from "./messageStore.js";
|
||||
import type { MessageRecord } from "./types.js";
|
||||
|
||||
let dbInitialized = false;
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { Worker } from "node:worker_threads";
|
||||
import { config } from "../config";
|
||||
import { createChildLogger } from "../logger";
|
||||
import { config } from "../config.js";
|
||||
import { createChildLogger } from "../logger.js";
|
||||
import {
|
||||
getMessageById,
|
||||
getPendingConversationKeys,
|
||||
getPendingMessagesByConversation,
|
||||
} from "./messageStore";
|
||||
} from "./messageStore.js";
|
||||
import type {
|
||||
AnalysisQueueStatus,
|
||||
MessageRecord,
|
||||
ModerationBroadcaster,
|
||||
} from "./types";
|
||||
} from "./types.js";
|
||||
|
||||
const logger = createChildLogger("ai-analyzer");
|
||||
|
||||
@@ -163,7 +163,7 @@ async function runAnalysisInWorker(
|
||||
): Promise<AnalysisWorkerResponse> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const worker = new Worker(
|
||||
new URL("./aiAnalysisWorker.ts", import.meta.url),
|
||||
new URL("./aiAnalysisWorker.js", import.meta.url),
|
||||
{ execArgv: process.execArgv },
|
||||
);
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { config } from "../config";
|
||||
import { createChildLogger } from "../logger";
|
||||
import { uploadToTele } from "../uploader/teleUpload";
|
||||
import { config } from "../config.js";
|
||||
import { createChildLogger } from "../logger.js";
|
||||
import { uploadToTele } from "../uploader/teleUpload.js";
|
||||
import {
|
||||
updateAttachmentAsFailedUpload,
|
||||
updateAttachmentAsUploaded,
|
||||
updateAttachmentDiscordUrl,
|
||||
} from "./messageStore";
|
||||
} from "./messageStore.js";
|
||||
|
||||
const logger = createChildLogger("attachment-uploader");
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Channel, Client, Message } from "discord.js-selfbot-v13";
|
||||
import { config } from "../config";
|
||||
import { createChildLogger } from "../logger";
|
||||
import { captureMessage } from "./messageCapture";
|
||||
import { config } from "../config.js";
|
||||
import { createChildLogger } from "../logger.js";
|
||||
import { captureMessage } from "./messageCapture.js";
|
||||
|
||||
const logger = createChildLogger("backlog-sync");
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import type { WebSocket } from "ws";
|
||||
import { createChildLogger } from "../logger";
|
||||
import { createChildLogger } from "../logger.js";
|
||||
import type {
|
||||
AnalysisQueueStatus,
|
||||
AttachmentRecord,
|
||||
MediaState,
|
||||
MessageRecord,
|
||||
ModerationWsEvent,
|
||||
} from "./types";
|
||||
} from "./types.js";
|
||||
|
||||
export type BroadcasterClient = Pick<WebSocket, "readyState" | "send">;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { MessageRecord } from "./types";
|
||||
import type { MessageRecord } from "./types.js";
|
||||
|
||||
export interface ConversationContextInput {
|
||||
contextBefore: MessageRecord[];
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import OpenAI from "openai";
|
||||
import { config } from "../config.ts";
|
||||
import { createChildLogger } from "../logger.ts";
|
||||
import { retryWithBackoff } from "../retry.ts";
|
||||
import type { AnalysisResult, AttachmentRecord, MessageRecord } from "./types";
|
||||
import { config } from "../config.js";
|
||||
import { createChildLogger } from "../logger.js";
|
||||
import { retryWithBackoff } from "../retry.js";
|
||||
import type { AnalysisResult, AttachmentRecord, MessageRecord } from "./types.js";
|
||||
|
||||
const log = createChildLogger("llmModerationClient");
|
||||
const openai = new OpenAI({
|
||||
@@ -35,9 +35,13 @@ const openai = new OpenAI({
|
||||
}
|
||||
}
|
||||
|
||||
const headers = new Headers(response.headers ?? undefined);
|
||||
headers.set("Content-Type", "application/json");
|
||||
headers.delete("Content-Length");
|
||||
|
||||
return new Response(normalizedBody, {
|
||||
status: response.status ?? 200,
|
||||
headers: response.headers ?? { "Content-Type": "application/json" },
|
||||
headers,
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -592,6 +596,17 @@ Return ONLY valid JSON, no other text.`;
|
||||
? parseError.message
|
||||
: String(parseError);
|
||||
lastInvalidContent = content;
|
||||
log.warn(
|
||||
{
|
||||
error: lastParseError,
|
||||
contentLength: content.length,
|
||||
contentPreview: content.substring(0, 1000),
|
||||
fullContent: content,
|
||||
targetIds,
|
||||
model: config.AI_LLM_MODEL,
|
||||
},
|
||||
"Failed to parse moderation response from LLM",
|
||||
);
|
||||
throw parseError;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
import type { Client, Message } from "discord.js-selfbot-v13";
|
||||
import { config } from "../config";
|
||||
import { createChildLogger } from "../logger";
|
||||
import { getModerationBroadcaster } from "../ws/broadcastGlobals";
|
||||
import { queueMessageAnalysis } from "./aiAnalyzer";
|
||||
import { processAttachmentUpload } from "./attachmentUploader";
|
||||
import { config } from "../config.js";
|
||||
import { createChildLogger } from "../logger.js";
|
||||
import { getModerationBroadcaster } from "../ws/broadcastGlobals.js";
|
||||
import { queueMessageAnalysis } from "./aiAnalyzer.js";
|
||||
import { processAttachmentUpload } from "./attachmentUploader.js";
|
||||
import {
|
||||
getDisplayContent,
|
||||
getMessageLocation,
|
||||
getMessageMetadata,
|
||||
} from "./messageMetadata";
|
||||
} from "./messageMetadata.js";
|
||||
import {
|
||||
getMessageById,
|
||||
insertAttachment,
|
||||
updateMessageAsDeleted,
|
||||
updateMessageAsEdited,
|
||||
upsertMessageForCapture,
|
||||
} from "./messageStore";
|
||||
import type { AttachmentRecord, MessageRecord } from "./types";
|
||||
} from "./messageStore.js";
|
||||
import type { AttachmentRecord, MessageRecord } from "./types.js";
|
||||
|
||||
const logger = createChildLogger("message-capture");
|
||||
|
||||
|
||||
@@ -9,16 +9,16 @@ import {
|
||||
type SQL,
|
||||
sql,
|
||||
} from "drizzle-orm";
|
||||
import { getDatabase } from "../database/drizzle.ts";
|
||||
import { attachmentsTable, messagesTable } from "../database/schema.ts";
|
||||
import { createChildLogger } from "../logger.ts";
|
||||
import { decodeCursor, encodeCursor } from "./pagination.ts";
|
||||
import { getDatabase } from "../database/drizzle.js";
|
||||
import { attachmentsTable, messagesTable } from "../database/schema.js";
|
||||
import { createChildLogger } from "../logger.js";
|
||||
import { decodeCursor, encodeCursor } from "./pagination.js";
|
||||
import type {
|
||||
AttachmentRecord,
|
||||
MessageQuery,
|
||||
MessageRecord,
|
||||
PageResult,
|
||||
} from "./types";
|
||||
} from "./types.js";
|
||||
|
||||
const logger = createChildLogger("message-store");
|
||||
|
||||
@@ -105,7 +105,7 @@ function pageMessages(
|
||||
return { data, nextCursor };
|
||||
}
|
||||
|
||||
export { decodeCursor, encodeCursor } from "./pagination.ts";
|
||||
export { decodeCursor, encodeCursor } from "./pagination.js";
|
||||
|
||||
export async function insertMessage(message: MessageRecord): Promise<void> {
|
||||
try {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { BroadcasterClient, ModerationBroadcaster } from "./broadcaster";
|
||||
import type { BroadcasterClient, ModerationBroadcaster } from "./broadcaster.js";
|
||||
|
||||
export type AIStatus = "pending" | "clean" | "warn" | "flagged" | "error";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user