generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: convert to turborepo monorepo structure (#286)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: ben <ben@prologe.io>
- Loading branch information
1 parent
2c164af
commit 092c67e
Showing
294 changed files
with
10,614 additions
and
2,941 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
# vscode | ||
|
||
.turbo/* | ||
|
||
*/.turbo/* | ||
|
||
.vscode | ||
|
||
# Intellij | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,15 @@ | ||
{ | ||
"name": "fileorganizer2000", | ||
"version": "1.131.1", | ||
"description": "AI File Organizer 2000", | ||
"main": "main.js", | ||
"name": "file-organizer-2000-monorepo", | ||
"private": true, | ||
"scripts": { | ||
"dev": "node esbuild.config.mjs", | ||
"build": "node esbuild.config.mjs production", | ||
"version": "node version-bump.mjs && git add manifest.json versions.json", | ||
"test": "ts-node ./standalone/index.test.ts", | ||
"release": "node release.js" | ||
"build": "turbo run build", | ||
"dev": "turbo run dev", | ||
"lint": "turbo run lint", | ||
"test": "turbo run test" | ||
}, | ||
"author": "", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@types/node": "^16.11.6", | ||
"@types/react": "^18.3.1", | ||
"@types/react-dom": "^18.3.0", | ||
"@typescript-eslint/eslint-plugin": "5.29.0", | ||
"@typescript-eslint/parser": "5.29.0", | ||
"autoprefixer": "^10.4.20", | ||
"builtin-modules": "3.3.0", | ||
"esbuild": "0.17.3", | ||
"esbuild-postcss": "^0.0.4", | ||
"obsidian": "^1.7.2", | ||
"postcss": "^8.4.31", | ||
"tailwindcss": "^3.4.14", | ||
"tslib": "2.4.0", | ||
"turbo": "latest", | ||
"typescript": "^5.2.2" | ||
}, | ||
"dependencies": { | ||
"@ai-sdk/openai": "^0.0.40", | ||
"@ai-sdk/react": "^0.0.70", | ||
"@emotion/styled": "^11.13.0", | ||
"@tiptap/core": "^2.5.7", | ||
"@tiptap/extension-mention": "^2.5.8", | ||
"@tiptap/pm": "^2.5.7", | ||
"@tiptap/react": "^2.5.7", | ||
"@tiptap/starter-kit": "^2.5.7", | ||
"ai": "^3.4.32", | ||
"axios": "^1.6.2", | ||
"chokidar": "^3.6.0", | ||
"clsx": "^2.1.1", | ||
"compromise": "^14.14.2", | ||
"form-data": "^4.0.0", | ||
"framer-motion": "^11.5.4", | ||
"fuse.js": "^7.0.0", | ||
"jimp": "^0.22.12", | ||
"lodash": "^4.17.21", | ||
"lucide-react": "^0.441.0", | ||
"moment": "^2.29.4", | ||
"natural": "^8.0.1", | ||
"node-fetch": "^3.3.2", | ||
"ollama-ai-provider": "^0.15.2", | ||
"openai": "^4.19.0", | ||
"react": "^18.3.1", | ||
"react-dom": "^18.3.1", | ||
"react-markdown": "^9.0.1", | ||
"tailwind-merge": "^2.5.4", | ||
"tiktoken": "^1.0.15", | ||
"tippy.js": "^6.3.7", | ||
"tiptap-markdown": "^0.8.10", | ||
"ts-node": "^10.9.2", | ||
"use-debounce": "^10.0.4", | ||
"youtube-transcript": "^1.2.1", | ||
"zod": "^3.23.8", | ||
"zustand": "^5.0.1" | ||
} | ||
"packageManager": "pnpm@8.15.4" | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const dotenv_1 = __importDefault(require("dotenv")); | ||
const express_1 = __importDefault(require("express")); | ||
const multer_1 = __importDefault(require("multer")); | ||
const fs_1 = __importDefault(require("fs")); | ||
const path_1 = __importDefault(require("path")); | ||
const cors_1 = __importDefault(require("cors")); | ||
const sdk_1 = require("@deepgram/sdk"); | ||
const api_1 = require("@unkey/api"); | ||
const morgan_1 = __importDefault(require("morgan")); | ||
const child_process_1 = require("child_process"); | ||
const util_1 = __importDefault(require("util")); | ||
dotenv_1.default.config(); | ||
const app = (0, express_1.default)(); | ||
const storage = multer_1.default.diskStorage({ | ||
destination: function (req, file, cb) { | ||
const uploadDir = path_1.default.join(__dirname, '..', 'uploads'); | ||
fs_1.default.mkdirSync(uploadDir, { recursive: true }); | ||
cb(null, uploadDir); | ||
}, | ||
filename: function (req, file, cb) { | ||
const fileExtension = file.originalname.split(".").pop(); | ||
cb(null, `${file.fieldname}-${Date.now()}.${fileExtension}`); | ||
}, | ||
}); | ||
const upload = (0, multer_1.default)({ storage: storage }); | ||
const deepgram = (0, sdk_1.createClient)(process.env.DEEPGRAM_API_KEY || ""); | ||
app.use((0, morgan_1.default)("dev")); | ||
app.use((0, cors_1.default)({ | ||
origin: function (origin, callback) { | ||
console.log("Request origin:", origin); | ||
callback(null, true); | ||
}, | ||
methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"], | ||
allowedHeaders: ["Content-Type", "Authorization"], | ||
})); | ||
app.use((req, res, next) => { | ||
console.log("Incoming request:", { | ||
method: req.method, | ||
path: req.path, | ||
headers: req.headers, | ||
origin: req.get("origin"), | ||
}); | ||
next(); | ||
}); | ||
app.get("/health", (req, res) => { | ||
res.status(200).json({ status: "OK" }); | ||
}); | ||
app.get("/", (req, res) => { | ||
res.status(200).send("Audio Transcription Server"); | ||
}); | ||
app.post("/transcribe", upload.single("audio"), async (req, res) => { | ||
var _a, _b, _c, _d, _e, _f, _g; | ||
console.log("receiving file"); | ||
const authHeader = req.headers["authorization"]; | ||
const key = authHeader === null || authHeader === void 0 ? void 0 : authHeader.toString().replace("Bearer ", ""); | ||
console.log(key); | ||
if (!key) { | ||
return res.status(401).send("Unauthorized"); | ||
} | ||
const { result, error } = await (0, api_1.verifyKey)(key); | ||
console.log(result); | ||
if (error) { | ||
console.error(error); | ||
return res.status(500).send("Internal Server Error"); | ||
} | ||
if (!result.valid) { | ||
return res.status(401).send("Unauthorized"); | ||
} | ||
console.log("receiving file"); | ||
if (!req.file) { | ||
return res.status(400).send("No audio file uploaded."); | ||
} | ||
const fileExtension = (_a = req.file.filename.split(".").pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase(); | ||
const supportedFormats = [ | ||
"flac", | ||
"m4a", | ||
"mp3", | ||
"mp4", | ||
"mpeg", | ||
"mpga", | ||
"oga", | ||
"ogg", | ||
"wav", | ||
"webm", | ||
]; | ||
if (!fileExtension || !supportedFormats.includes(fileExtension)) { | ||
fs_1.default.unlinkSync(req.file.path); | ||
return res | ||
.status(400) | ||
.json({ | ||
error: `Unsupported file format: ${fileExtension}. Supported formats: ${supportedFormats.join(", ")}`, | ||
}); | ||
} | ||
console.log("file extension", fileExtension); | ||
try { | ||
const chunkDuration = 10 * 60; | ||
const audioInfo = await getAudioDuration(req.file.path); | ||
const totalDuration = audioInfo.duration; | ||
const chunks = Math.ceil(totalDuration / chunkDuration); | ||
res.setHeader("Content-Type", "text/plain"); | ||
res.setHeader("Transfer-Encoding", "chunked"); | ||
for (let i = 0; i < chunks; i++) { | ||
const start = i * chunkDuration; | ||
const end = Math.min((i + 1) * chunkDuration, totalDuration); | ||
const chunkPath = `${req.file.path}_chunk_${i}.${fileExtension}`; | ||
await splitAudio(req.file.path, chunkPath, start, end); | ||
console.log("in loop"); | ||
const { result, error } = await deepgram.listen.prerecorded.transcribeFile(fs_1.default.readFileSync(chunkPath), { | ||
model: "nova-2", | ||
smart_format: true, | ||
detect_language: true, | ||
}); | ||
if (error) { | ||
console.error("Deepgram transcription error:", error); | ||
throw new Error("Deepgram transcription failed"); | ||
} | ||
console.log((_d = (_c = (_b = result.results) === null || _b === void 0 ? void 0 : _b.channels[0]) === null || _c === void 0 ? void 0 : _c.alternatives[0]) === null || _d === void 0 ? void 0 : _d.transcript); | ||
res.write(((_g = (_f = (_e = result.results) === null || _e === void 0 ? void 0 : _e.channels[0]) === null || _f === void 0 ? void 0 : _f.alternatives[0]) === null || _g === void 0 ? void 0 : _g.transcript) + " "); | ||
fs_1.default.unlinkSync(chunkPath); | ||
} | ||
fs_1.default.unlinkSync(req.file.path); | ||
res.end(); | ||
} | ||
catch (error) { | ||
console.error("Error transcribing audio:", error); | ||
fs_1.default.unlinkSync(req.file.path); | ||
res | ||
.status(500) | ||
.json({ | ||
error: "Error transcribing audio", | ||
details: error.message, | ||
}); | ||
} | ||
}); | ||
const PORT = process.env.PORT || 3001; | ||
app.listen(PORT, () => console.log(`Server running on port ${PORT}`)); | ||
const execPromise = util_1.default.promisify(child_process_1.exec); | ||
async function getAudioDuration(filePath) { | ||
const command = `ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "${filePath}"`; | ||
const { stdout } = await execPromise(command); | ||
return { duration: parseFloat(stdout) }; | ||
} | ||
async function splitAudio(inputPath, outputPath, start, end) { | ||
const command = `ffmpeg -i "${inputPath}" -ss ${start} -to ${end} -c copy "${outputPath}"`; | ||
await execPromise(command); | ||
} |
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
audio-transcription-server/package.json → packages/audio-server/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"target": "es2018", | ||
"module": "commonjs", | ||
"outDir": "./dist", | ||
"rootDir": "./src", | ||
"composite": true | ||
}, | ||
"include": ["src/**/*"], | ||
"exclude": ["node_modules"], | ||
"references": [ | ||
{ "path": "../shared" } | ||
] | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
|
||
> @file-organizer/plugin@1.131.1 test /home/ubuntu/repos/file-organizer-2000/packages/plugin | ||
> ts-node ./standalone/index.test.ts | ||
|
||
node:internal/modules/cjs/loader:1252 | ||
throw err; | ||
^ | ||
|
||
Error: Cannot find module './index.test.ts' | ||
Require stack: | ||
- /home/ubuntu/repos/file-organizer-2000/packages/plugin/standalone/imaginaryUncacheableRequireResolveScript | ||
[90m at Function._resolveFilename (node:internal/modules/cjs/loader:1249:15)[39m | ||
[90m at Function.resolve (node:internal/modules/helpers:151:19)[39m | ||
at requireResolveNonCached (/home/ubuntu/repos/file-organizer-2000/node_modules/[4m.pnpm[24m/ts-node@10.9.2_@types+node@20.8.5_typescript@5.2.2/node_modules/[4mts-node[24m/dist/bin.js:549:16) | ||
at getProjectSearchDir (/home/ubuntu/repos/file-organizer-2000/node_modules/[4m.pnpm[24m/ts-node@10.9.2_@types+node@20.8.5_typescript@5.2.2/node_modules/[4mts-node[24m/dist/bin.js:519:40) | ||
at phase3 (/home/ubuntu/repos/file-organizer-2000/node_modules/[4m.pnpm[24m/ts-node@10.9.2_@types+node@20.8.5_typescript@5.2.2/node_modules/[4mts-node[24m/dist/bin.js:267:27) | ||
at bootstrap (/home/ubuntu/repos/file-organizer-2000/node_modules/[4m.pnpm[24m/ts-node@10.9.2_@types+node@20.8.5_typescript@5.2.2/node_modules/[4mts-node[24m/dist/bin.js:47:30) | ||
at main (/home/ubuntu/repos/file-organizer-2000/node_modules/[4m.pnpm[24m/ts-node@10.9.2_@types+node@20.8.5_typescript@5.2.2/node_modules/[4mts-node[24m/dist/bin.js:33:12) | ||
at Object.<anonymous> (/home/ubuntu/repos/file-organizer-2000/node_modules/[4m.pnpm[24m/ts-node@10.9.2_@types+node@20.8.5_typescript@5.2.2/node_modules/[4mts-node[24m/dist/bin.js:579:5) | ||
[90m at Module._compile (node:internal/modules/cjs/loader:1546:14)[39m | ||
[90m at Object..js (node:internal/modules/cjs/loader:1689:10)[39m { | ||
code: [32m'MODULE_NOT_FOUND'[39m, | ||
requireStack: [ | ||
[32m'/home/ubuntu/repos/file-organizer-2000/packages/plugin/standalone/imaginaryUncacheableRequireResolveScript'[39m | ||
] | ||
} | ||
|
||
Node.js v22.11.0 | ||
[41m[30m ELIFECYCLE [39m[49m [31mTest failed. See above for more details.[39m |
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.