@hasna/microservices 0.0.16 → 0.0.17
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/README.md +143 -23
- package/bin/index.js +711 -13998
- package/bin/mcp.js +228 -10987
- package/dist/index.js +166 -10056
- package/package.json +25 -25
- package/microservices/microservice-ads/package.json +0 -28
- package/microservices/microservice-ads/src/cli/index.ts +0 -605
- package/microservices/microservice-ads/src/db/campaigns.ts +0 -797
- package/microservices/microservice-ads/src/db/database.ts +0 -91
- package/microservices/microservice-ads/src/db/migrations.ts +0 -60
- package/microservices/microservice-ads/src/index.ts +0 -39
- package/microservices/microservice-ads/src/mcp/index.ts +0 -480
- package/microservices/microservice-analytics/package.json +0 -28
- package/microservices/microservice-analytics/src/cli/index.ts +0 -373
- package/microservices/microservice-analytics/src/db/analytics.ts +0 -564
- package/microservices/microservice-analytics/src/db/database.ts +0 -91
- package/microservices/microservice-analytics/src/db/migrations.ts +0 -50
- package/microservices/microservice-analytics/src/index.ts +0 -37
- package/microservices/microservice-analytics/src/mcp/index.ts +0 -334
- package/microservices/microservice-assets/package.json +0 -28
- package/microservices/microservice-assets/src/cli/index.ts +0 -375
- package/microservices/microservice-assets/src/db/assets.ts +0 -370
- package/microservices/microservice-assets/src/db/database.ts +0 -91
- package/microservices/microservice-assets/src/db/migrations.ts +0 -51
- package/microservices/microservice-assets/src/index.ts +0 -32
- package/microservices/microservice-assets/src/mcp/index.ts +0 -346
- package/microservices/microservice-bookkeeping/package.json +0 -28
- package/microservices/microservice-bookkeeping/src/cli/index.ts +0 -386
- package/microservices/microservice-bookkeeping/src/db/bookkeeping.ts +0 -591
- package/microservices/microservice-bookkeeping/src/db/database.ts +0 -91
- package/microservices/microservice-bookkeeping/src/db/migrations.ts +0 -52
- package/microservices/microservice-bookkeeping/src/index.ts +0 -32
- package/microservices/microservice-bookkeeping/src/mcp/index.ts +0 -284
- package/microservices/microservice-calendar/package.json +0 -28
- package/microservices/microservice-calendar/src/cli/index.ts +0 -287
- package/microservices/microservice-calendar/src/db/calendar.ts +0 -328
- package/microservices/microservice-calendar/src/db/database.ts +0 -91
- package/microservices/microservice-calendar/src/db/migrations.ts +0 -47
- package/microservices/microservice-calendar/src/index.ts +0 -24
- package/microservices/microservice-calendar/src/mcp/index.ts +0 -226
- package/microservices/microservice-company/package.json +0 -28
- package/microservices/microservice-company/src/cli/index.ts +0 -1126
- package/microservices/microservice-company/src/db/company.ts +0 -854
- package/microservices/microservice-company/src/db/database.ts +0 -91
- package/microservices/microservice-company/src/db/migrations.ts +0 -214
- package/microservices/microservice-company/src/db/workflow-migrations.ts +0 -44
- package/microservices/microservice-company/src/index.ts +0 -60
- package/microservices/microservice-company/src/lib/audit.ts +0 -168
- package/microservices/microservice-company/src/lib/finance.ts +0 -299
- package/microservices/microservice-company/src/lib/settings.ts +0 -85
- package/microservices/microservice-company/src/lib/workflows.ts +0 -698
- package/microservices/microservice-company/src/mcp/index.ts +0 -991
- package/microservices/microservice-compliance/package.json +0 -28
- package/microservices/microservice-compliance/src/cli/index.ts +0 -467
- package/microservices/microservice-compliance/src/db/compliance.ts +0 -633
- package/microservices/microservice-compliance/src/db/database.ts +0 -91
- package/microservices/microservice-compliance/src/db/migrations.ts +0 -63
- package/microservices/microservice-compliance/src/index.ts +0 -46
- package/microservices/microservice-compliance/src/mcp/index.ts +0 -438
- package/microservices/microservice-contacts/package.json +0 -28
- package/microservices/microservice-contacts/src/cli/index.ts +0 -393
- package/microservices/microservice-contacts/src/db/companies.ts +0 -167
- package/microservices/microservice-contacts/src/db/contacts.ts +0 -249
- package/microservices/microservice-contacts/src/db/database.ts +0 -91
- package/microservices/microservice-contacts/src/db/migrations.ts +0 -71
- package/microservices/microservice-contacts/src/db/relationships.ts +0 -53
- package/microservices/microservice-contacts/src/index.ts +0 -42
- package/microservices/microservice-contacts/src/mcp/index.ts +0 -303
- package/microservices/microservice-contracts/package.json +0 -28
- package/microservices/microservice-contracts/src/cli/index.ts +0 -770
- package/microservices/microservice-contracts/src/db/contracts.ts +0 -925
- package/microservices/microservice-contracts/src/db/database.ts +0 -91
- package/microservices/microservice-contracts/src/db/migrations.ts +0 -141
- package/microservices/microservice-contracts/src/index.ts +0 -43
- package/microservices/microservice-contracts/src/mcp/index.ts +0 -617
- package/microservices/microservice-crm/package.json +0 -28
- package/microservices/microservice-crm/src/cli/index.ts +0 -396
- package/microservices/microservice-crm/src/db/database.ts +0 -91
- package/microservices/microservice-crm/src/db/migrations.ts +0 -66
- package/microservices/microservice-crm/src/db/pipeline.ts +0 -397
- package/microservices/microservice-crm/src/index.ts +0 -34
- package/microservices/microservice-crm/src/mcp/index.ts +0 -294
- package/microservices/microservice-documents/package.json +0 -28
- package/microservices/microservice-documents/src/cli/index.ts +0 -246
- package/microservices/microservice-documents/src/db/database.ts +0 -91
- package/microservices/microservice-documents/src/db/documents.ts +0 -316
- package/microservices/microservice-documents/src/db/migrations.ts +0 -49
- package/microservices/microservice-documents/src/index.ts +0 -24
- package/microservices/microservice-documents/src/mcp/index.ts +0 -202
- package/microservices/microservice-domains/package.json +0 -28
- package/microservices/microservice-domains/src/cli/index.ts +0 -1111
- package/microservices/microservice-domains/src/db/database.ts +0 -91
- package/microservices/microservice-domains/src/db/domains.ts +0 -1164
- package/microservices/microservice-domains/src/db/migrations.ts +0 -60
- package/microservices/microservice-domains/src/index.ts +0 -65
- package/microservices/microservice-domains/src/lib/brandsight.ts +0 -350
- package/microservices/microservice-domains/src/lib/godaddy.ts +0 -338
- package/microservices/microservice-domains/src/lib/namecheap.ts +0 -262
- package/microservices/microservice-domains/src/lib/registrar.ts +0 -355
- package/microservices/microservice-domains/src/mcp/index.ts +0 -781
- package/microservices/microservice-expenses/package.json +0 -28
- package/microservices/microservice-expenses/src/cli/index.ts +0 -267
- package/microservices/microservice-expenses/src/db/database.ts +0 -91
- package/microservices/microservice-expenses/src/db/expenses.ts +0 -345
- package/microservices/microservice-expenses/src/db/migrations.ts +0 -45
- package/microservices/microservice-expenses/src/index.ts +0 -25
- package/microservices/microservice-expenses/src/mcp/index.ts +0 -196
- package/microservices/microservice-habits/package.json +0 -28
- package/microservices/microservice-habits/src/cli/index.ts +0 -315
- package/microservices/microservice-habits/src/db/database.ts +0 -91
- package/microservices/microservice-habits/src/db/habits.ts +0 -451
- package/microservices/microservice-habits/src/db/migrations.ts +0 -46
- package/microservices/microservice-habits/src/index.ts +0 -31
- package/microservices/microservice-habits/src/mcp/index.ts +0 -313
- package/microservices/microservice-health/package.json +0 -28
- package/microservices/microservice-health/src/cli/index.ts +0 -484
- package/microservices/microservice-health/src/db/database.ts +0 -91
- package/microservices/microservice-health/src/db/health.ts +0 -708
- package/microservices/microservice-health/src/db/migrations.ts +0 -70
- package/microservices/microservice-health/src/index.ts +0 -63
- package/microservices/microservice-health/src/mcp/index.ts +0 -437
- package/microservices/microservice-hiring/package.json +0 -28
- package/microservices/microservice-hiring/src/cli/index.ts +0 -741
- package/microservices/microservice-hiring/src/db/database.ts +0 -91
- package/microservices/microservice-hiring/src/db/hiring.ts +0 -1085
- package/microservices/microservice-hiring/src/db/migrations.ts +0 -89
- package/microservices/microservice-hiring/src/index.ts +0 -80
- package/microservices/microservice-hiring/src/lib/scoring.ts +0 -206
- package/microservices/microservice-hiring/src/mcp/index.ts +0 -709
- package/microservices/microservice-inventory/package.json +0 -28
- package/microservices/microservice-inventory/src/cli/index.ts +0 -365
- package/microservices/microservice-inventory/src/db/database.ts +0 -91
- package/microservices/microservice-inventory/src/db/inventory.ts +0 -393
- package/microservices/microservice-inventory/src/db/migrations.ts +0 -54
- package/microservices/microservice-inventory/src/index.ts +0 -28
- package/microservices/microservice-inventory/src/mcp/index.ts +0 -250
- package/microservices/microservice-invoices/dashboard/index.html +0 -12
- package/microservices/microservice-invoices/dashboard/package.json +0 -29
- package/microservices/microservice-invoices/dashboard/tsconfig.json +0 -14
- package/microservices/microservice-invoices/dashboard/vite.config.ts +0 -15
- package/microservices/microservice-invoices/package.json +0 -31
- package/microservices/microservice-invoices/src/cli/index.ts +0 -308
- package/microservices/microservice-invoices/src/db/business.ts +0 -241
- package/microservices/microservice-invoices/src/db/clients.ts +0 -127
- package/microservices/microservice-invoices/src/db/database.ts +0 -91
- package/microservices/microservice-invoices/src/db/invoices.ts +0 -345
- package/microservices/microservice-invoices/src/db/migrations.ts +0 -184
- package/microservices/microservice-invoices/src/index.ts +0 -56
- package/microservices/microservice-invoices/src/mcp/index.ts +0 -242
- package/microservices/microservice-invoices/src/server/index.ts +0 -162
- package/microservices/microservice-leads/package.json +0 -28
- package/microservices/microservice-leads/src/cli/index.ts +0 -596
- package/microservices/microservice-leads/src/db/database.ts +0 -91
- package/microservices/microservice-leads/src/db/leads.ts +0 -520
- package/microservices/microservice-leads/src/db/lists.ts +0 -151
- package/microservices/microservice-leads/src/db/migrations.ts +0 -93
- package/microservices/microservice-leads/src/index.ts +0 -65
- package/microservices/microservice-leads/src/lib/enrichment.ts +0 -202
- package/microservices/microservice-leads/src/lib/scoring.ts +0 -134
- package/microservices/microservice-leads/src/mcp/index.ts +0 -533
- package/microservices/microservice-notes/package.json +0 -28
- package/microservices/microservice-notes/src/cli/index.ts +0 -63
- package/microservices/microservice-notes/src/db/database.ts +0 -91
- package/microservices/microservice-notes/src/db/migrations.ts +0 -40
- package/microservices/microservice-notes/src/db/notes.ts +0 -114
- package/microservices/microservice-notes/src/index.ts +0 -2
- package/microservices/microservice-notes/src/mcp/index.ts +0 -37
- package/microservices/microservice-notifications/package.json +0 -28
- package/microservices/microservice-notifications/src/cli/index.ts +0 -349
- package/microservices/microservice-notifications/src/db/database.ts +0 -91
- package/microservices/microservice-notifications/src/db/migrations.ts +0 -62
- package/microservices/microservice-notifications/src/db/notifications.ts +0 -509
- package/microservices/microservice-notifications/src/index.ts +0 -41
- package/microservices/microservice-notifications/src/mcp/index.ts +0 -422
- package/microservices/microservice-payments/package.json +0 -28
- package/microservices/microservice-payments/src/cli/index.ts +0 -609
- package/microservices/microservice-payments/src/db/database.ts +0 -91
- package/microservices/microservice-payments/src/db/migrations.ts +0 -81
- package/microservices/microservice-payments/src/db/payments.ts +0 -1204
- package/microservices/microservice-payments/src/index.ts +0 -51
- package/microservices/microservice-payments/src/mcp/index.ts +0 -683
- package/microservices/microservice-payroll/package.json +0 -28
- package/microservices/microservice-payroll/src/cli/index.ts +0 -643
- package/microservices/microservice-payroll/src/db/database.ts +0 -91
- package/microservices/microservice-payroll/src/db/migrations.ts +0 -95
- package/microservices/microservice-payroll/src/db/payroll.ts +0 -1377
- package/microservices/microservice-payroll/src/index.ts +0 -48
- package/microservices/microservice-payroll/src/mcp/index.ts +0 -666
- package/microservices/microservice-products/package.json +0 -28
- package/microservices/microservice-products/src/cli/index.ts +0 -416
- package/microservices/microservice-products/src/db/categories.ts +0 -154
- package/microservices/microservice-products/src/db/database.ts +0 -91
- package/microservices/microservice-products/src/db/migrations.ts +0 -58
- package/microservices/microservice-products/src/db/pricing-tiers.ts +0 -66
- package/microservices/microservice-products/src/db/products.ts +0 -452
- package/microservices/microservice-products/src/index.ts +0 -53
- package/microservices/microservice-products/src/mcp/index.ts +0 -453
- package/microservices/microservice-projects/package.json +0 -28
- package/microservices/microservice-projects/src/cli/index.ts +0 -480
- package/microservices/microservice-projects/src/db/database.ts +0 -91
- package/microservices/microservice-projects/src/db/migrations.ts +0 -65
- package/microservices/microservice-projects/src/db/projects.ts +0 -715
- package/microservices/microservice-projects/src/index.ts +0 -57
- package/microservices/microservice-projects/src/mcp/index.ts +0 -501
- package/microservices/microservice-proposals/package.json +0 -28
- package/microservices/microservice-proposals/src/cli/index.ts +0 -400
- package/microservices/microservice-proposals/src/db/database.ts +0 -91
- package/microservices/microservice-proposals/src/db/migrations.ts +0 -52
- package/microservices/microservice-proposals/src/db/proposals.ts +0 -532
- package/microservices/microservice-proposals/src/index.ts +0 -37
- package/microservices/microservice-proposals/src/mcp/index.ts +0 -375
- package/microservices/microservice-reading/package.json +0 -28
- package/microservices/microservice-reading/src/cli/index.ts +0 -464
- package/microservices/microservice-reading/src/db/database.ts +0 -91
- package/microservices/microservice-reading/src/db/migrations.ts +0 -59
- package/microservices/microservice-reading/src/db/reading.ts +0 -524
- package/microservices/microservice-reading/src/index.ts +0 -51
- package/microservices/microservice-reading/src/mcp/index.ts +0 -368
- package/microservices/microservice-shipping/package.json +0 -28
- package/microservices/microservice-shipping/src/cli/index.ts +0 -606
- package/microservices/microservice-shipping/src/db/database.ts +0 -91
- package/microservices/microservice-shipping/src/db/migrations.ts +0 -69
- package/microservices/microservice-shipping/src/db/shipping.ts +0 -1093
- package/microservices/microservice-shipping/src/index.ts +0 -53
- package/microservices/microservice-shipping/src/mcp/index.ts +0 -533
- package/microservices/microservice-social/package.json +0 -29
- package/microservices/microservice-social/src/cli/index.ts +0 -1583
- package/microservices/microservice-social/src/db/database.ts +0 -91
- package/microservices/microservice-social/src/db/migrations.ts +0 -160
- package/microservices/microservice-social/src/db/social.ts +0 -1076
- package/microservices/microservice-social/src/index.ts +0 -46
- package/microservices/microservice-social/src/lib/audience.ts +0 -353
- package/microservices/microservice-social/src/lib/content-ai.ts +0 -278
- package/microservices/microservice-social/src/lib/media.ts +0 -311
- package/microservices/microservice-social/src/lib/mentions.ts +0 -434
- package/microservices/microservice-social/src/lib/metrics-sync.ts +0 -264
- package/microservices/microservice-social/src/lib/publisher.ts +0 -377
- package/microservices/microservice-social/src/lib/scheduler.ts +0 -229
- package/microservices/microservice-social/src/lib/sentiment.ts +0 -256
- package/microservices/microservice-social/src/lib/threads.ts +0 -291
- package/microservices/microservice-social/src/mcp/index.ts +0 -1425
- package/microservices/microservice-social/src/server/index.ts +0 -441
- package/microservices/microservice-subscriptions/package.json +0 -28
- package/microservices/microservice-subscriptions/src/cli/index.ts +0 -715
- package/microservices/microservice-subscriptions/src/db/database.ts +0 -91
- package/microservices/microservice-subscriptions/src/db/migrations.ts +0 -125
- package/microservices/microservice-subscriptions/src/db/subscriptions.ts +0 -1256
- package/microservices/microservice-subscriptions/src/index.ts +0 -41
- package/microservices/microservice-subscriptions/src/mcp/index.ts +0 -631
- package/microservices/microservice-timesheets/package.json +0 -28
- package/microservices/microservice-timesheets/src/cli/index.ts +0 -373
- package/microservices/microservice-timesheets/src/db/database.ts +0 -91
- package/microservices/microservice-timesheets/src/db/locale.ts +0 -217
- package/microservices/microservice-timesheets/src/db/migrations.ts +0 -74
- package/microservices/microservice-timesheets/src/db/timesheets.ts +0 -447
- package/microservices/microservice-timesheets/src/index.ts +0 -44
- package/microservices/microservice-timesheets/src/mcp/index.ts +0 -269
- package/microservices/microservice-transcriber/package.json +0 -29
- package/microservices/microservice-transcriber/src/cli/index.ts +0 -1593
- package/microservices/microservice-transcriber/src/db/annotations.ts +0 -37
- package/microservices/microservice-transcriber/src/db/comments.ts +0 -166
- package/microservices/microservice-transcriber/src/db/database.ts +0 -91
- package/microservices/microservice-transcriber/src/db/migrations.ts +0 -118
- package/microservices/microservice-transcriber/src/db/proofread.ts +0 -119
- package/microservices/microservice-transcriber/src/db/transcripts.ts +0 -395
- package/microservices/microservice-transcriber/src/index.ts +0 -43
- package/microservices/microservice-transcriber/src/lib/config.ts +0 -77
- package/microservices/microservice-transcriber/src/lib/diff.ts +0 -91
- package/microservices/microservice-transcriber/src/lib/downloader.ts +0 -638
- package/microservices/microservice-transcriber/src/lib/feeds.ts +0 -62
- package/microservices/microservice-transcriber/src/lib/live.ts +0 -94
- package/microservices/microservice-transcriber/src/lib/notion.ts +0 -129
- package/microservices/microservice-transcriber/src/lib/proofread.ts +0 -296
- package/microservices/microservice-transcriber/src/lib/providers.ts +0 -713
- package/microservices/microservice-transcriber/src/lib/summarizer.ts +0 -147
- package/microservices/microservice-transcriber/src/lib/translator.ts +0 -75
- package/microservices/microservice-transcriber/src/lib/webhook.ts +0 -37
- package/microservices/microservice-transcriber/src/mcp/index.ts +0 -1330
- package/microservices/microservice-transcriber/src/server/index.ts +0 -199
- package/microservices/microservice-travel/package.json +0 -28
- package/microservices/microservice-travel/src/cli/index.ts +0 -505
- package/microservices/microservice-travel/src/db/database.ts +0 -91
- package/microservices/microservice-travel/src/db/migrations.ts +0 -77
- package/microservices/microservice-travel/src/db/travel.ts +0 -802
- package/microservices/microservice-travel/src/index.ts +0 -60
- package/microservices/microservice-travel/src/mcp/index.ts +0 -495
- package/microservices/microservice-wiki/package.json +0 -28
- package/microservices/microservice-wiki/src/cli/index.ts +0 -345
- package/microservices/microservice-wiki/src/db/database.ts +0 -91
- package/microservices/microservice-wiki/src/db/migrations.ts +0 -55
- package/microservices/microservice-wiki/src/db/wiki.ts +0 -395
- package/microservices/microservice-wiki/src/index.ts +0 -32
- package/microservices/microservice-wiki/src/mcp/index.ts +0 -344
|
@@ -1,395 +0,0 @@
|
|
|
1
|
-
import { getDatabase } from "./database.js";
|
|
2
|
-
|
|
3
|
-
export type TranscriptStatus = "pending" | "processing" | "completed" | "failed";
|
|
4
|
-
export type TranscriptProvider = "elevenlabs" | "openai" | "deepgram";
|
|
5
|
-
export type TranscriptSourceType = "file" | "youtube" | "vimeo" | "wistia" | "url" | "translated";
|
|
6
|
-
|
|
7
|
-
export interface TranscriptWord {
|
|
8
|
-
text: string;
|
|
9
|
-
start: number;
|
|
10
|
-
end: number;
|
|
11
|
-
type?: string;
|
|
12
|
-
speaker_id?: string;
|
|
13
|
-
logprob?: number; // log probability from ElevenLabs; confidence = Math.exp(logprob)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface TranscriptSpeakerSegment {
|
|
17
|
-
speaker_id: string;
|
|
18
|
-
start: number;
|
|
19
|
-
end: number;
|
|
20
|
-
text: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface TranscriptSegment {
|
|
24
|
-
start: number;
|
|
25
|
-
end: number;
|
|
26
|
-
text: string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface TranscriptChapterSegment {
|
|
30
|
-
title: string;
|
|
31
|
-
start_time: number;
|
|
32
|
-
end_time: number;
|
|
33
|
-
text: string;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface TranscriptMetadata {
|
|
37
|
-
model?: string;
|
|
38
|
-
words?: TranscriptWord[];
|
|
39
|
-
segments?: TranscriptSegment[];
|
|
40
|
-
speakers?: TranscriptSpeakerSegment[];
|
|
41
|
-
chapters?: TranscriptChapterSegment[];
|
|
42
|
-
language_probability?: number;
|
|
43
|
-
trim_start?: number;
|
|
44
|
-
trim_end?: number;
|
|
45
|
-
diarized?: boolean;
|
|
46
|
-
summary?: string;
|
|
47
|
-
highlights?: Array<{ quote: string; speaker?: string; context: string }>;
|
|
48
|
-
meeting_notes?: string;
|
|
49
|
-
cost_usd?: number;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface Transcript {
|
|
53
|
-
id: string;
|
|
54
|
-
title: string | null;
|
|
55
|
-
source_url: string | null;
|
|
56
|
-
source_type: TranscriptSourceType;
|
|
57
|
-
provider: TranscriptProvider;
|
|
58
|
-
language: string;
|
|
59
|
-
status: TranscriptStatus;
|
|
60
|
-
transcript_text: string | null;
|
|
61
|
-
error_message: string | null;
|
|
62
|
-
metadata: TranscriptMetadata;
|
|
63
|
-
created_at: string;
|
|
64
|
-
updated_at: string;
|
|
65
|
-
duration_seconds: number | null;
|
|
66
|
-
word_count: number | null;
|
|
67
|
-
source_transcript_id: string | null;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export interface CreateTranscriptInput {
|
|
71
|
-
source_url: string;
|
|
72
|
-
source_type: TranscriptSourceType;
|
|
73
|
-
provider?: TranscriptProvider;
|
|
74
|
-
language?: string;
|
|
75
|
-
title?: string;
|
|
76
|
-
source_transcript_id?: string;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export interface UpdateTranscriptInput {
|
|
80
|
-
title?: string;
|
|
81
|
-
status?: TranscriptStatus;
|
|
82
|
-
transcript_text?: string;
|
|
83
|
-
error_message?: string | null;
|
|
84
|
-
metadata?: TranscriptMetadata;
|
|
85
|
-
duration_seconds?: number;
|
|
86
|
-
word_count?: number;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export interface ListTranscriptsOptions {
|
|
90
|
-
status?: TranscriptStatus;
|
|
91
|
-
provider?: TranscriptProvider;
|
|
92
|
-
source_type?: TranscriptSourceType;
|
|
93
|
-
limit?: number;
|
|
94
|
-
offset?: number;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
interface TranscriptRow {
|
|
98
|
-
id: string;
|
|
99
|
-
title: string | null;
|
|
100
|
-
source_url: string | null;
|
|
101
|
-
source_type: string;
|
|
102
|
-
provider: string;
|
|
103
|
-
language: string;
|
|
104
|
-
status: string;
|
|
105
|
-
transcript_text: string | null;
|
|
106
|
-
error_message: string | null;
|
|
107
|
-
metadata: string;
|
|
108
|
-
created_at: string;
|
|
109
|
-
updated_at: string;
|
|
110
|
-
duration_seconds: number | null;
|
|
111
|
-
word_count: number | null;
|
|
112
|
-
source_transcript_id: string | null;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function rowToTranscript(row: TranscriptRow): Transcript {
|
|
116
|
-
return {
|
|
117
|
-
...row,
|
|
118
|
-
source_type: row.source_type as TranscriptSourceType,
|
|
119
|
-
provider: row.provider as TranscriptProvider,
|
|
120
|
-
status: row.status as TranscriptStatus,
|
|
121
|
-
metadata: JSON.parse(row.metadata || "{}"),
|
|
122
|
-
source_transcript_id: row.source_transcript_id ?? null,
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function now(): string {
|
|
127
|
-
return new Date().toISOString();
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export function createTranscript(input: CreateTranscriptInput): Transcript {
|
|
131
|
-
const db = getDatabase();
|
|
132
|
-
const id = crypto.randomUUID();
|
|
133
|
-
const ts = now();
|
|
134
|
-
|
|
135
|
-
db.prepare(`
|
|
136
|
-
INSERT INTO transcripts (id, title, source_url, source_type, provider, language, status, metadata, created_at, updated_at, source_transcript_id)
|
|
137
|
-
VALUES (?, ?, ?, ?, ?, ?, 'pending', '{}', ?, ?, ?)
|
|
138
|
-
`).run(
|
|
139
|
-
id,
|
|
140
|
-
input.title ?? null,
|
|
141
|
-
input.source_url,
|
|
142
|
-
input.source_type,
|
|
143
|
-
input.provider ?? "elevenlabs",
|
|
144
|
-
input.language ?? "en",
|
|
145
|
-
ts,
|
|
146
|
-
ts,
|
|
147
|
-
input.source_transcript_id ?? null
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
return getTranscript(id)!;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export function getTranscript(id: string): Transcript | null {
|
|
154
|
-
const db = getDatabase();
|
|
155
|
-
const row = db.prepare("SELECT * FROM transcripts WHERE id = ?").get(id) as TranscriptRow | null;
|
|
156
|
-
return row ? rowToTranscript(row) : null;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
export function updateTranscript(id: string, input: UpdateTranscriptInput): Transcript | null {
|
|
160
|
-
const db = getDatabase();
|
|
161
|
-
const existing = getTranscript(id);
|
|
162
|
-
if (!existing) return null;
|
|
163
|
-
|
|
164
|
-
const fields: string[] = ["updated_at = ?"];
|
|
165
|
-
const values: unknown[] = [now()];
|
|
166
|
-
|
|
167
|
-
if (input.title !== undefined) { fields.push("title = ?"); values.push(input.title); }
|
|
168
|
-
if (input.status !== undefined) { fields.push("status = ?"); values.push(input.status); }
|
|
169
|
-
if (input.transcript_text !== undefined) { fields.push("transcript_text = ?"); values.push(input.transcript_text); }
|
|
170
|
-
if (input.error_message !== undefined) { fields.push("error_message = ?"); values.push(input.error_message); }
|
|
171
|
-
if (input.metadata !== undefined) { fields.push("metadata = ?"); values.push(JSON.stringify(input.metadata)); }
|
|
172
|
-
if (input.duration_seconds !== undefined) { fields.push("duration_seconds = ?"); values.push(input.duration_seconds); }
|
|
173
|
-
if (input.word_count !== undefined) { fields.push("word_count = ?"); values.push(input.word_count); }
|
|
174
|
-
|
|
175
|
-
values.push(id);
|
|
176
|
-
db.prepare(`UPDATE transcripts SET ${fields.join(", ")} WHERE id = ?`).run(...values);
|
|
177
|
-
|
|
178
|
-
return getTranscript(id);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
export function deleteTranscript(id: string): boolean {
|
|
182
|
-
const db = getDatabase();
|
|
183
|
-
const result = db.prepare("DELETE FROM transcripts WHERE id = ?").run(id);
|
|
184
|
-
return result.changes > 0;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
export function listTranscripts(options: ListTranscriptsOptions = {}): Transcript[] {
|
|
188
|
-
const db = getDatabase();
|
|
189
|
-
const conditions: string[] = [];
|
|
190
|
-
const values: unknown[] = [];
|
|
191
|
-
|
|
192
|
-
if (options.status) { conditions.push("status = ?"); values.push(options.status); }
|
|
193
|
-
if (options.provider) { conditions.push("provider = ?"); values.push(options.provider); }
|
|
194
|
-
if (options.source_type) { conditions.push("source_type = ?"); values.push(options.source_type); }
|
|
195
|
-
|
|
196
|
-
const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
197
|
-
const limit = options.limit ?? 50;
|
|
198
|
-
const offset = options.offset ?? 0;
|
|
199
|
-
|
|
200
|
-
const rows = db
|
|
201
|
-
.prepare(`SELECT * FROM transcripts ${where} ORDER BY created_at DESC LIMIT ? OFFSET ?`)
|
|
202
|
-
.all(...values, limit, offset) as TranscriptRow[];
|
|
203
|
-
|
|
204
|
-
return rows.map(rowToTranscript);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
export function searchTranscripts(query: string): Transcript[] {
|
|
208
|
-
const db = getDatabase();
|
|
209
|
-
const q = `%${query}%`;
|
|
210
|
-
const rows = db
|
|
211
|
-
.prepare(`
|
|
212
|
-
SELECT * FROM transcripts
|
|
213
|
-
WHERE transcript_text LIKE ?
|
|
214
|
-
OR title LIKE ?
|
|
215
|
-
OR source_url LIKE ?
|
|
216
|
-
ORDER BY created_at DESC
|
|
217
|
-
LIMIT 50
|
|
218
|
-
`)
|
|
219
|
-
.all(q, q, q) as TranscriptRow[];
|
|
220
|
-
return rows.map(rowToTranscript);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Rename speakers in a transcript. Replaces labels in transcript_text,
|
|
225
|
-
* metadata.speakers[].speaker_id, and metadata.words[].speaker_id.
|
|
226
|
-
*/
|
|
227
|
-
export function renameSpeakers(
|
|
228
|
-
id: string,
|
|
229
|
-
mapping: Record<string, string> // e.g. {"Speaker 1": "Andrej Karpathy", "Speaker 2": "Sarah Guo"}
|
|
230
|
-
): Transcript | null {
|
|
231
|
-
const t = getTranscript(id);
|
|
232
|
-
if (!t) return null;
|
|
233
|
-
|
|
234
|
-
// Replace in transcript_text
|
|
235
|
-
let text = t.transcript_text ?? "";
|
|
236
|
-
for (const [from, to] of Object.entries(mapping)) {
|
|
237
|
-
text = text.replaceAll(`${from}:`, `${to}:`);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// Replace in metadata.speakers
|
|
241
|
-
const speakers = t.metadata.speakers?.map((s) => ({
|
|
242
|
-
...s,
|
|
243
|
-
speaker_id: mapping[s.speaker_id] ?? mapping[s.speaker_id.replace(/speaker_(\d+)/, (_, n) => `Speaker ${parseInt(n) + 1}`)] ?? s.speaker_id,
|
|
244
|
-
}));
|
|
245
|
-
|
|
246
|
-
// Replace in metadata.words
|
|
247
|
-
const words = t.metadata.words?.map((w) => {
|
|
248
|
-
if (!w.speaker_id) return w;
|
|
249
|
-
const label = w.speaker_id.replace(/speaker_(\d+)/, (_, n) => `Speaker ${parseInt(n) + 1}`);
|
|
250
|
-
const newId = mapping[label] ?? mapping[w.speaker_id] ?? w.speaker_id;
|
|
251
|
-
return { ...w, speaker_id: newId };
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
return updateTranscript(id, {
|
|
255
|
-
transcript_text: text,
|
|
256
|
-
metadata: { ...t.metadata, speakers, words },
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* Find a completed transcript by source URL (for duplicate detection).
|
|
262
|
-
*/
|
|
263
|
-
export function findBySourceUrl(sourceUrl: string): Transcript | null {
|
|
264
|
-
const db = getDatabase();
|
|
265
|
-
const row = db
|
|
266
|
-
.prepare("SELECT * FROM transcripts WHERE source_url = ? AND status = 'completed' ORDER BY created_at DESC LIMIT 1")
|
|
267
|
-
.get(sourceUrl) as TranscriptRow | null;
|
|
268
|
-
return row ? rowToTranscript(row) : null;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
// ---------------------------------------------------------------------------
|
|
272
|
-
// Tags
|
|
273
|
-
// ---------------------------------------------------------------------------
|
|
274
|
-
|
|
275
|
-
export function addTags(transcriptId: string, tags: string[]): string[] {
|
|
276
|
-
const db = getDatabase();
|
|
277
|
-
const stmt = db.prepare("INSERT OR IGNORE INTO transcript_tags (transcript_id, tag) VALUES (?, ?)");
|
|
278
|
-
for (const tag of tags) {
|
|
279
|
-
stmt.run(transcriptId, tag.toLowerCase().trim());
|
|
280
|
-
}
|
|
281
|
-
return getTags(transcriptId);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
export function removeTags(transcriptId: string, tags: string[]): string[] {
|
|
285
|
-
const db = getDatabase();
|
|
286
|
-
const stmt = db.prepare("DELETE FROM transcript_tags WHERE transcript_id = ? AND tag = ?");
|
|
287
|
-
for (const tag of tags) {
|
|
288
|
-
stmt.run(transcriptId, tag.toLowerCase().trim());
|
|
289
|
-
}
|
|
290
|
-
return getTags(transcriptId);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
export function getTags(transcriptId: string): string[] {
|
|
294
|
-
const db = getDatabase();
|
|
295
|
-
const rows = db
|
|
296
|
-
.prepare("SELECT tag FROM transcript_tags WHERE transcript_id = ? ORDER BY tag")
|
|
297
|
-
.all(transcriptId) as { tag: string }[];
|
|
298
|
-
return rows.map((r) => r.tag);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
export function listAllTags(): Array<{ tag: string; count: number }> {
|
|
302
|
-
const db = getDatabase();
|
|
303
|
-
return db
|
|
304
|
-
.prepare("SELECT tag, COUNT(*) as count FROM transcript_tags GROUP BY tag ORDER BY count DESC")
|
|
305
|
-
.all() as Array<{ tag: string; count: number }>;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
export function listTranscriptsByTag(tag: string, limit = 50): Transcript[] {
|
|
309
|
-
const db = getDatabase();
|
|
310
|
-
const rows = db
|
|
311
|
-
.prepare(`
|
|
312
|
-
SELECT t.* FROM transcripts t
|
|
313
|
-
JOIN transcript_tags tt ON t.id = tt.transcript_id
|
|
314
|
-
WHERE tt.tag = ?
|
|
315
|
-
ORDER BY t.created_at DESC LIMIT ?
|
|
316
|
-
`)
|
|
317
|
-
.all(tag.toLowerCase().trim(), limit) as TranscriptRow[];
|
|
318
|
-
return rows.map(rowToTranscript);
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
export interface SearchMatch {
|
|
322
|
-
transcript_id: string;
|
|
323
|
-
title: string | null;
|
|
324
|
-
timestamp: string | null; // [MM:SS] if word timestamps available
|
|
325
|
-
excerpt: string; // matching text with surrounding context
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
/**
|
|
329
|
-
* Search transcripts with surrounding context and timestamps.
|
|
330
|
-
* Returns excerpts with `contextSentences` sentences before/after each match.
|
|
331
|
-
*/
|
|
332
|
-
export function searchWithContext(query: string, contextSentences = 2): SearchMatch[] {
|
|
333
|
-
const transcripts = searchTranscripts(query);
|
|
334
|
-
const matches: SearchMatch[] = [];
|
|
335
|
-
|
|
336
|
-
for (const t of transcripts) {
|
|
337
|
-
if (!t.transcript_text) continue;
|
|
338
|
-
|
|
339
|
-
// Split into sentences
|
|
340
|
-
const sentences = t.transcript_text.split(/(?<=[.!?])\s+|(?<=\n)\s*/g).filter(Boolean);
|
|
341
|
-
const q = query.toLowerCase();
|
|
342
|
-
|
|
343
|
-
for (let i = 0; i < sentences.length; i++) {
|
|
344
|
-
if (!sentences[i].toLowerCase().includes(q)) continue;
|
|
345
|
-
|
|
346
|
-
// Gather context window
|
|
347
|
-
const start = Math.max(0, i - contextSentences);
|
|
348
|
-
const end = Math.min(sentences.length, i + contextSentences + 1);
|
|
349
|
-
const excerpt = sentences.slice(start, end).join(" ");
|
|
350
|
-
|
|
351
|
-
// Find timestamp from word data
|
|
352
|
-
let timestamp: string | null = null;
|
|
353
|
-
if (t.metadata?.words) {
|
|
354
|
-
const matchWords = query.toLowerCase().split(/\s+/);
|
|
355
|
-
const firstWord = matchWords[0];
|
|
356
|
-
const wordEntry = t.metadata.words.find((w) => w.text.toLowerCase().includes(firstWord));
|
|
357
|
-
if (wordEntry) {
|
|
358
|
-
const m = Math.floor(wordEntry.start / 60);
|
|
359
|
-
const s = Math.floor(wordEntry.start % 60);
|
|
360
|
-
timestamp = `[${m}:${String(s).padStart(2, "0")}]`;
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
matches.push({
|
|
365
|
-
transcript_id: t.id,
|
|
366
|
-
title: t.title,
|
|
367
|
-
timestamp,
|
|
368
|
-
excerpt: excerpt.length > 300 ? excerpt.slice(0, 300) + "…" : excerpt,
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
break; // one match per transcript
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
return matches;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
export function countTranscripts(): { total: number; by_status: Record<string, number>; by_provider: Record<string, number> } {
|
|
379
|
-
const db = getDatabase();
|
|
380
|
-
const total = (db.prepare("SELECT COUNT(*) as n FROM transcripts").get() as { n: number }).n;
|
|
381
|
-
|
|
382
|
-
const byStatus = db
|
|
383
|
-
.prepare("SELECT status, COUNT(*) as n FROM transcripts GROUP BY status")
|
|
384
|
-
.all() as { status: string; n: number }[];
|
|
385
|
-
|
|
386
|
-
const byProvider = db
|
|
387
|
-
.prepare("SELECT provider, COUNT(*) as n FROM transcripts GROUP BY provider")
|
|
388
|
-
.all() as { provider: string; n: number }[];
|
|
389
|
-
|
|
390
|
-
return {
|
|
391
|
-
total,
|
|
392
|
-
by_status: Object.fromEntries(byStatus.map((r) => [r.status, r.n])),
|
|
393
|
-
by_provider: Object.fromEntries(byProvider.map((r) => [r.provider, r.n])),
|
|
394
|
-
};
|
|
395
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
createTranscript,
|
|
3
|
-
getTranscript,
|
|
4
|
-
updateTranscript,
|
|
5
|
-
deleteTranscript,
|
|
6
|
-
listTranscripts,
|
|
7
|
-
searchTranscripts,
|
|
8
|
-
countTranscripts,
|
|
9
|
-
renameSpeakers,
|
|
10
|
-
findBySourceUrl,
|
|
11
|
-
addTags,
|
|
12
|
-
removeTags,
|
|
13
|
-
getTags,
|
|
14
|
-
listAllTags,
|
|
15
|
-
listTranscriptsByTag,
|
|
16
|
-
searchWithContext,
|
|
17
|
-
type SearchMatch,
|
|
18
|
-
type Transcript,
|
|
19
|
-
type TranscriptStatus,
|
|
20
|
-
type TranscriptProvider,
|
|
21
|
-
type TranscriptSourceType,
|
|
22
|
-
type TranscriptMetadata,
|
|
23
|
-
type TranscriptWord,
|
|
24
|
-
type TranscriptSegment,
|
|
25
|
-
type TranscriptSpeakerSegment,
|
|
26
|
-
type TranscriptChapterSegment,
|
|
27
|
-
type CreateTranscriptInput,
|
|
28
|
-
type UpdateTranscriptInput,
|
|
29
|
-
type ListTranscriptsOptions,
|
|
30
|
-
} from "./db/transcripts.js";
|
|
31
|
-
|
|
32
|
-
export { getDatabase, closeDatabase } from "./db/database.js";
|
|
33
|
-
export { createAnnotation, getAnnotation, listAnnotations, deleteAnnotation, type Annotation } from "./db/annotations.js";
|
|
34
|
-
export { prepareAudio, detectSourceType, getVideoInfo, downloadAudio, downloadVideo, createClip, getAudioOutputDir, normalizeFilename, getAudioDuration, splitAudioIntoChunks, isPlaylistUrl, getPlaylistUrls, checkYtDlp, type TrimOptions, type VideoInfo, type VideoChapter, type DownloadResult, type DownloadAudioOptions, type DownloadAudioResult } from "./lib/downloader.js";
|
|
35
|
-
export { transcribeFile, checkProviders, estimateCost, toSrt, toVtt, toAss, toMarkdown, segmentByChapters, formatWithConfidence, type AssStyle } from "./lib/providers.js";
|
|
36
|
-
export { getConfig, setConfig, resetConfig, CONFIG_DEFAULTS, CONFIG_KEYS, type TranscriberConfig, type ConfigKey } from "./lib/config.js";
|
|
37
|
-
export { summarizeText, extractHighlights, generateMeetingNotes, getDefaultSummaryProvider, type SummaryProvider, type Highlight } from "./lib/summarizer.js";
|
|
38
|
-
export { translateText } from "./lib/translator.js";
|
|
39
|
-
export { wordDiff, formatDiff, diffStats, type DiffEntry } from "./lib/diff.js";
|
|
40
|
-
export { fetchFeedEpisodes, type FeedEpisode, type Feed } from "./lib/feeds.js";
|
|
41
|
-
export { fireWebhook, type WebhookPayload } from "./lib/webhook.js";
|
|
42
|
-
export { pushToNotion } from "./lib/notion.js";
|
|
43
|
-
export { startLiveTranscription, type LiveTranscribeOptions } from "./lib/live.js";
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Persistent config for microservice-transcriber.
|
|
3
|
-
* Stored as JSON alongside data.db in the .microservices directory.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
7
|
-
import { dirname, join, resolve } from "node:path";
|
|
8
|
-
|
|
9
|
-
export interface TranscriberConfig {
|
|
10
|
-
defaultProvider: "elevenlabs" | "openai" | "deepgram";
|
|
11
|
-
defaultLanguage: string;
|
|
12
|
-
defaultFormat: "txt" | "srt" | "vtt" | "json";
|
|
13
|
-
diarize: boolean;
|
|
14
|
-
vocab: string[]; // custom vocabulary hints for transcription accuracy
|
|
15
|
-
feeds: Array<{ url: string; title: string | null; lastChecked: string | null }>;
|
|
16
|
-
webhook: string | null; // URL to POST when transcription completes
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const CONFIG_DEFAULTS: TranscriberConfig = {
|
|
20
|
-
defaultProvider: "elevenlabs",
|
|
21
|
-
defaultLanguage: "en",
|
|
22
|
-
defaultFormat: "txt",
|
|
23
|
-
diarize: false,
|
|
24
|
-
vocab: [],
|
|
25
|
-
feeds: [],
|
|
26
|
-
webhook: null,
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
function getConfigPath(): string {
|
|
30
|
-
if (process.env["MICROSERVICES_DIR"]) {
|
|
31
|
-
return join(process.env["MICROSERVICES_DIR"], "microservice-transcriber", "config.json");
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
let dir = resolve(process.cwd());
|
|
35
|
-
while (true) {
|
|
36
|
-
const msDir = join(dir, ".microservices");
|
|
37
|
-
if (existsSync(msDir)) return join(msDir, "microservice-transcriber", "config.json");
|
|
38
|
-
const parent = dirname(dir);
|
|
39
|
-
if (parent === dir) break;
|
|
40
|
-
dir = parent;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
|
|
44
|
-
return join(home, ".microservices", "microservice-transcriber", "config.json");
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function getConfig(): TranscriberConfig {
|
|
48
|
-
const path = getConfigPath();
|
|
49
|
-
if (!existsSync(path)) return { ...CONFIG_DEFAULTS };
|
|
50
|
-
try {
|
|
51
|
-
const raw = JSON.parse(readFileSync(path, "utf8"));
|
|
52
|
-
return { ...CONFIG_DEFAULTS, ...raw };
|
|
53
|
-
} catch {
|
|
54
|
-
return { ...CONFIG_DEFAULTS };
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export function setConfig(updates: Partial<TranscriberConfig>): TranscriberConfig {
|
|
59
|
-
const current = getConfig();
|
|
60
|
-
const next = { ...current, ...updates };
|
|
61
|
-
const path = getConfigPath();
|
|
62
|
-
const dir = dirname(path);
|
|
63
|
-
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
64
|
-
writeFileSync(path, JSON.stringify(next, null, 2), "utf8");
|
|
65
|
-
return next;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function resetConfig(): TranscriberConfig {
|
|
69
|
-
const path = getConfigPath();
|
|
70
|
-
const dir = dirname(path);
|
|
71
|
-
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
72
|
-
writeFileSync(path, JSON.stringify(CONFIG_DEFAULTS, null, 2), "utf8");
|
|
73
|
-
return { ...CONFIG_DEFAULTS };
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export const CONFIG_KEYS = ["defaultProvider", "defaultLanguage", "defaultFormat", "diarize", "vocab", "webhook"] as const;
|
|
77
|
-
export type ConfigKey = (typeof CONFIG_KEYS)[number];
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Simple word-level diff for comparing two transcripts.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export interface DiffEntry {
|
|
6
|
-
type: "equal" | "added" | "removed";
|
|
7
|
-
text: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Compute a word-level diff between two texts.
|
|
12
|
-
* Uses a simple longest common subsequence approach.
|
|
13
|
-
*/
|
|
14
|
-
export function wordDiff(textA: string, textB: string): DiffEntry[] {
|
|
15
|
-
const wordsA = textA.split(/\s+/).filter(Boolean);
|
|
16
|
-
const wordsB = textB.split(/\s+/).filter(Boolean);
|
|
17
|
-
|
|
18
|
-
// LCS table
|
|
19
|
-
const m = wordsA.length;
|
|
20
|
-
const n = wordsB.length;
|
|
21
|
-
const dp: number[][] = Array.from({ length: m + 1 }, () => Array(n + 1).fill(0));
|
|
22
|
-
|
|
23
|
-
for (let i = 1; i <= m; i++) {
|
|
24
|
-
for (let j = 1; j <= n; j++) {
|
|
25
|
-
if (wordsA[i - 1] === wordsB[j - 1]) {
|
|
26
|
-
dp[i][j] = dp[i - 1][j - 1] + 1;
|
|
27
|
-
} else {
|
|
28
|
-
dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Backtrack to build diff
|
|
34
|
-
const result: DiffEntry[] = [];
|
|
35
|
-
let i = m, j = n;
|
|
36
|
-
|
|
37
|
-
while (i > 0 || j > 0) {
|
|
38
|
-
if (i > 0 && j > 0 && wordsA[i - 1] === wordsB[j - 1]) {
|
|
39
|
-
result.unshift({ type: "equal", text: wordsA[i - 1] });
|
|
40
|
-
i--; j--;
|
|
41
|
-
} else if (j > 0 && (i === 0 || dp[i][j - 1] >= dp[i - 1][j])) {
|
|
42
|
-
result.unshift({ type: "added", text: wordsB[j - 1] });
|
|
43
|
-
j--;
|
|
44
|
-
} else {
|
|
45
|
-
result.unshift({ type: "removed", text: wordsA[i - 1] });
|
|
46
|
-
i--;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Merge consecutive entries of the same type
|
|
51
|
-
const merged: DiffEntry[] = [];
|
|
52
|
-
for (const entry of result) {
|
|
53
|
-
const last = merged[merged.length - 1];
|
|
54
|
-
if (last && last.type === entry.type) {
|
|
55
|
-
last.text += " " + entry.text;
|
|
56
|
-
} else {
|
|
57
|
-
merged.push({ ...entry });
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return merged;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Format a diff for terminal display.
|
|
66
|
-
*/
|
|
67
|
-
export function formatDiff(entries: DiffEntry[]): string {
|
|
68
|
-
return entries
|
|
69
|
-
.map((e) => {
|
|
70
|
-
if (e.type === "equal") return e.text;
|
|
71
|
-
if (e.type === "added") return `[+${e.text}+]`;
|
|
72
|
-
return `[-${e.text}-]`;
|
|
73
|
-
})
|
|
74
|
-
.join(" ");
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Compute diff stats.
|
|
79
|
-
*/
|
|
80
|
-
export function diffStats(entries: DiffEntry[]): { equal: number; added: number; removed: number; similarity: number } {
|
|
81
|
-
const equalWords = entries.filter((e) => e.type === "equal").reduce((n, e) => n + e.text.split(/\s+/).length, 0);
|
|
82
|
-
const addedWords = entries.filter((e) => e.type === "added").reduce((n, e) => n + e.text.split(/\s+/).length, 0);
|
|
83
|
-
const removedWords = entries.filter((e) => e.type === "removed").reduce((n, e) => n + e.text.split(/\s+/).length, 0);
|
|
84
|
-
const total = equalWords + addedWords + removedWords;
|
|
85
|
-
return {
|
|
86
|
-
equal: equalWords,
|
|
87
|
-
added: addedWords,
|
|
88
|
-
removed: removedWords,
|
|
89
|
-
similarity: total > 0 ? Math.round((equalWords / total) * 100) : 100,
|
|
90
|
-
};
|
|
91
|
-
}
|