@arabold/docs-mcp-server 2.5.0 → 3.0.0
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/assets/index-BHI6XhAh.css +1 -0
- package/dist/assets/index-vmw9lu8_.js +70 -0
- package/dist/assets/index-vmw9lu8_.js.map +1 -0
- package/dist/index.html +14 -0
- package/dist/index.js +1 -1
- package/dist/{main-IwoXB6_B.js → main-qq21CGPf.js} +586 -2620
- package/dist/main-qq21CGPf.js.map +1 -0
- package/dist/{utils-B-zX5sgp.js → utils-DCwrdF5w.js} +2 -12
- package/dist/utils-DCwrdF5w.js.map +1 -0
- package/dist/{utils-LjYa0nIu.js → utils-DizElQoU.js} +1 -1
- package/package.json +10 -16
- package/public/assets/index-BHI6XhAh.css +1 -0
- package/public/assets/index-vmw9lu8_.js +70 -0
- package/public/assets/index-vmw9lu8_.js.map +1 -0
- package/public/index.html +14 -0
- package/dist/assets/android-icon-144x144.png +0 -0
- package/dist/assets/android-icon-192x192.png +0 -0
- package/dist/assets/android-icon-36x36.png +0 -0
- package/dist/assets/android-icon-48x48.png +0 -0
- package/dist/assets/android-icon-72x72.png +0 -0
- package/dist/assets/android-icon-96x96.png +0 -0
- package/dist/assets/apple-icon-114x114.png +0 -0
- package/dist/assets/apple-icon-120x120.png +0 -0
- package/dist/assets/apple-icon-144x144.png +0 -0
- package/dist/assets/apple-icon-152x152.png +0 -0
- package/dist/assets/apple-icon-180x180.png +0 -0
- package/dist/assets/apple-icon-57x57.png +0 -0
- package/dist/assets/apple-icon-60x60.png +0 -0
- package/dist/assets/apple-icon-72x72.png +0 -0
- package/dist/assets/apple-icon-76x76.png +0 -0
- package/dist/assets/apple-icon-precomposed.png +0 -0
- package/dist/assets/apple-icon.png +0 -0
- package/dist/assets/favicon-16x16.png +0 -0
- package/dist/assets/favicon-32x32.png +0 -0
- package/dist/assets/favicon-96x96.png +0 -0
- package/dist/assets/favicon.ico +0 -0
- package/dist/assets/main.css +0 -3
- package/dist/assets/main.js +0 -8678
- package/dist/assets/main.js.map +0 -1
- package/dist/assets/manifest.json +0 -47
- package/dist/assets/ms-icon-144x144.png +0 -0
- package/dist/assets/ms-icon-150x150.png +0 -0
- package/dist/assets/ms-icon-310x310.png +0 -0
- package/dist/assets/ms-icon-70x70.png +0 -0
- package/dist/main-IwoXB6_B.js.map +0 -1
- package/dist/utils-B-zX5sgp.js.map +0 -1
- package/public/assets/android-icon-144x144.png +0 -0
- package/public/assets/android-icon-192x192.png +0 -0
- package/public/assets/android-icon-36x36.png +0 -0
- package/public/assets/android-icon-48x48.png +0 -0
- package/public/assets/android-icon-72x72.png +0 -0
- package/public/assets/android-icon-96x96.png +0 -0
- package/public/assets/apple-icon-114x114.png +0 -0
- package/public/assets/apple-icon-120x120.png +0 -0
- package/public/assets/apple-icon-144x144.png +0 -0
- package/public/assets/apple-icon-152x152.png +0 -0
- package/public/assets/apple-icon-180x180.png +0 -0
- package/public/assets/apple-icon-57x57.png +0 -0
- package/public/assets/apple-icon-60x60.png +0 -0
- package/public/assets/apple-icon-72x72.png +0 -0
- package/public/assets/apple-icon-76x76.png +0 -0
- package/public/assets/apple-icon-precomposed.png +0 -0
- package/public/assets/apple-icon.png +0 -0
- package/public/assets/favicon-16x16.png +0 -0
- package/public/assets/favicon-32x32.png +0 -0
- package/public/assets/favicon-96x96.png +0 -0
- package/public/assets/favicon.ico +0 -0
- package/public/assets/main.css +0 -3
- package/public/assets/main.js +0 -8678
- package/public/assets/main.js.map +0 -1
- package/public/assets/manifest.json +0 -47
- package/public/assets/ms-icon-144x144.png +0 -0
- package/public/assets/ms-icon-150x150.png +0 -0
- package/public/assets/ms-icon-310x310.png +0 -0
- package/public/assets/ms-icon-70x70.png +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as normalizeEnvValue } from "./env-DONvEfR5.js";
|
|
2
2
|
import { i as setLogLevel, n as getLogLevelFromEnv, r as logger, t as LogLevel } from "./logger-BBxstTD7.js";
|
|
3
|
-
import { C as EventType,
|
|
3
|
+
import { C as EventType, E as resolveStorePath, S as PipelineJobStatus, T as getProjectRoot, _ as EventBusService, b as initTelemetry, c as parseHeaders, d as validateAuthConfig, f as validateHost, g as EmbeddingConfig, h as warnHttpUsage, i as getEventBus, o as handleEmbeddingModelChange, p as validatePort, r as ensurePlaywrightBrowsersInstalled, s as parseAuthConfig, t as createAppServerConfig, u as resolveProtocol, v as TelemetryService, w as shouldEnableTelemetry, x as telemetry, y as TelemetryEvent } from "./utils-DCwrdF5w.js";
|
|
4
4
|
import { BedrockEmbeddings } from "@langchain/aws";
|
|
5
5
|
import { GoogleGenerativeAIEmbeddings } from "@langchain/google-genai";
|
|
6
6
|
import { VertexAIEmbeddings } from "@langchain/google-vertexai";
|
|
@@ -16,6 +16,7 @@ import { hideBin } from "yargs/helpers";
|
|
|
16
16
|
import yaml from "yaml";
|
|
17
17
|
import { z } from "zod";
|
|
18
18
|
import { encode } from "@toon-format/toon";
|
|
19
|
+
import fs$1, { readFile } from "node:fs/promises";
|
|
19
20
|
import formBody from "@fastify/formbody";
|
|
20
21
|
import fastifyStatic from "@fastify/static";
|
|
21
22
|
import Fastify from "fastify";
|
|
@@ -30,7 +31,6 @@ import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mc
|
|
|
30
31
|
import { z as z$1 } from "zod/v3";
|
|
31
32
|
import { chromium } from "playwright";
|
|
32
33
|
import { lookup } from "node:dns/promises";
|
|
33
|
-
import fs$1 from "node:fs/promises";
|
|
34
34
|
import net from "node:net";
|
|
35
35
|
import os from "node:os";
|
|
36
36
|
import { minimatch } from "minimatch";
|
|
@@ -59,13 +59,10 @@ import semver from "semver";
|
|
|
59
59
|
import Fuse from "fuse.js";
|
|
60
60
|
import Database from "better-sqlite3";
|
|
61
61
|
import * as sqliteVec from "sqlite-vec";
|
|
62
|
-
import { initTRPC } from "@trpc/server";
|
|
63
62
|
import { fastifyTRPCPlugin } from "@trpc/server/adapters/fastify";
|
|
64
63
|
import { applyWSSHandler } from "@trpc/server/adapters/ws";
|
|
64
|
+
import { initTRPC } from "@trpc/server";
|
|
65
65
|
import { observable } from "@trpc/server/observable";
|
|
66
|
-
import { Fragment, jsx, jsxs } from "@kitajs/html/jsx-runtime";
|
|
67
|
-
import DOMPurify from "dompurify";
|
|
68
|
-
import { escapeHtml } from "@kitajs/html";
|
|
69
66
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
70
67
|
import { v4 } from "uuid";
|
|
71
68
|
import { exec } from "node:child_process";
|
|
@@ -3740,43 +3737,6 @@ var CancelJobTool = class {
|
|
|
3740
3737
|
}
|
|
3741
3738
|
};
|
|
3742
3739
|
//#endregion
|
|
3743
|
-
//#region src/tools/ClearCompletedJobsTool.ts
|
|
3744
|
-
/**
|
|
3745
|
-
* Tool for clearing all completed, cancelled, and failed jobs from the pipeline.
|
|
3746
|
-
* This helps keep the job queue clean by removing jobs that are no longer active.
|
|
3747
|
-
*/
|
|
3748
|
-
var ClearCompletedJobsTool = class {
|
|
3749
|
-
pipeline;
|
|
3750
|
-
/**
|
|
3751
|
-
* Creates an instance of ClearCompletedJobsTool.
|
|
3752
|
-
* @param pipeline The pipeline instance.
|
|
3753
|
-
*/
|
|
3754
|
-
constructor(pipeline) {
|
|
3755
|
-
this.pipeline = pipeline;
|
|
3756
|
-
}
|
|
3757
|
-
/**
|
|
3758
|
-
* Executes the tool to clear all completed jobs from the pipeline.
|
|
3759
|
-
* @param input - The input parameters (currently unused).
|
|
3760
|
-
* @returns A promise that resolves with the outcome of the clear operation.
|
|
3761
|
-
* @throws {ToolError} If the clear operation fails.
|
|
3762
|
-
*/
|
|
3763
|
-
async execute(_input) {
|
|
3764
|
-
try {
|
|
3765
|
-
const clearedCount = await this.pipeline.clearCompletedJobs();
|
|
3766
|
-
const message = clearedCount > 0 ? `Successfully cleared ${clearedCount} completed job${clearedCount === 1 ? "" : "s"} from the queue.` : "No completed jobs to clear.";
|
|
3767
|
-
logger.debug(message);
|
|
3768
|
-
return {
|
|
3769
|
-
message,
|
|
3770
|
-
clearedCount
|
|
3771
|
-
};
|
|
3772
|
-
} catch (error) {
|
|
3773
|
-
const errorMessage = `Failed to clear completed jobs: ${error instanceof Error ? error.message : String(error)}`;
|
|
3774
|
-
logger.error(`❌ ${errorMessage}`);
|
|
3775
|
-
throw new ToolError(errorMessage, this.constructor.name);
|
|
3776
|
-
}
|
|
3777
|
-
}
|
|
3778
|
-
};
|
|
3779
|
-
//#endregion
|
|
3780
3740
|
//#region src/utils/dom.ts
|
|
3781
3741
|
/**
|
|
3782
3742
|
* Creates a JSDOM instance with a pre-configured virtual console to suppress console noise.
|
|
@@ -9021,6 +8981,33 @@ var DocumentManagementClient = class {
|
|
|
9021
8981
|
getActiveEmbeddingConfig() {
|
|
9022
8982
|
return null;
|
|
9023
8983
|
}
|
|
8984
|
+
async getEmbeddingConfigInfo() {
|
|
8985
|
+
return this.client.getEmbeddingConfig.query();
|
|
8986
|
+
}
|
|
8987
|
+
async listVersionChunks(ref, options) {
|
|
8988
|
+
return this.client.listVersionChunks.query({
|
|
8989
|
+
library: ref.library,
|
|
8990
|
+
version: ref.version,
|
|
8991
|
+
limit: options?.limit,
|
|
8992
|
+
offset: options?.offset,
|
|
8993
|
+
filter: options?.filter
|
|
8994
|
+
});
|
|
8995
|
+
}
|
|
8996
|
+
async getVersionStats(ref) {
|
|
8997
|
+
return this.client.getVersionStats.query({
|
|
8998
|
+
library: ref.library,
|
|
8999
|
+
version: ref.version
|
|
9000
|
+
});
|
|
9001
|
+
}
|
|
9002
|
+
async getActivityHistory(days) {
|
|
9003
|
+
return this.client.getActivityHistory.query({ days });
|
|
9004
|
+
}
|
|
9005
|
+
async getVersionComposition(ref) {
|
|
9006
|
+
return this.client.getVersionComposition.query({
|
|
9007
|
+
library: ref.library,
|
|
9008
|
+
version: ref.version
|
|
9009
|
+
});
|
|
9010
|
+
}
|
|
9024
9011
|
};
|
|
9025
9012
|
//#endregion
|
|
9026
9013
|
//#region src/utils/version.ts
|
|
@@ -9711,6 +9698,13 @@ var VersionStatus = /* @__PURE__ */ function(VersionStatus) {
|
|
|
9711
9698
|
VersionStatus["UPDATING"] = "updating";
|
|
9712
9699
|
return VersionStatus;
|
|
9713
9700
|
}({});
|
|
9701
|
+
/** Normalize a VersionRef (lowercase, trim; empty string for unversioned). */
|
|
9702
|
+
function normalizeVersionRef(ref) {
|
|
9703
|
+
return {
|
|
9704
|
+
library: ref.library.trim().toLowerCase(),
|
|
9705
|
+
version: (ref.version ?? "").trim().toLowerCase()
|
|
9706
|
+
};
|
|
9707
|
+
}
|
|
9714
9708
|
/**
|
|
9715
9709
|
* Helper function to convert NULL version name to empty string for API compatibility.
|
|
9716
9710
|
* Database stores NULL for unversioned content, but APIs expect empty string.
|
|
@@ -9728,30 +9722,6 @@ function normalizeVersionName(name) {
|
|
|
9728
9722
|
function denormalizeVersionName(name) {
|
|
9729
9723
|
return name === "" ? "" : name;
|
|
9730
9724
|
}
|
|
9731
|
-
/**
|
|
9732
|
-
* Gets a human-readable description of a version status.
|
|
9733
|
-
*/
|
|
9734
|
-
function getStatusDescription(status) {
|
|
9735
|
-
return {
|
|
9736
|
-
["not_indexed"]: "Version created but not yet indexed",
|
|
9737
|
-
["queued"]: "Waiting in queue for indexing",
|
|
9738
|
-
["running"]: "Currently being indexed",
|
|
9739
|
-
["completed"]: "Successfully indexed",
|
|
9740
|
-
["failed"]: "Indexing failed",
|
|
9741
|
-
["cancelled"]: "Indexing was cancelled",
|
|
9742
|
-
["updating"]: "Re-indexing in progress"
|
|
9743
|
-
}[status] || "Unknown status";
|
|
9744
|
-
}
|
|
9745
|
-
/**
|
|
9746
|
-
* Checks if a status represents an active state (job in progress).
|
|
9747
|
-
*/
|
|
9748
|
-
function isActiveStatus(status) {
|
|
9749
|
-
return [
|
|
9750
|
-
"queued",
|
|
9751
|
-
"running",
|
|
9752
|
-
"updating"
|
|
9753
|
-
].includes(status);
|
|
9754
|
-
}
|
|
9755
9725
|
//#endregion
|
|
9756
9726
|
//#region src/store/DocumentStore.ts
|
|
9757
9727
|
/**
|
|
@@ -9902,10 +9872,16 @@ var DocumentStore = class {
|
|
|
9902
9872
|
COALESCE(v.name, '') as version,
|
|
9903
9873
|
v.id as versionId,
|
|
9904
9874
|
v.status as status,
|
|
9875
|
+
v.error_message as errorMessage,
|
|
9905
9876
|
v.progress_pages as progressPages,
|
|
9906
9877
|
v.progress_max_pages as progressMaxPages,
|
|
9907
9878
|
v.source_url as sourceUrl,
|
|
9908
|
-
|
|
9879
|
+
-- "Last indexed" = when the version was last (re)indexed. Use the
|
|
9880
|
+
-- version's updated_at (bumped on every status/progress change during
|
|
9881
|
+
-- a run, including refreshes) rather than MIN(p.created_at), which is
|
|
9882
|
+
-- the *first*-index time and never moves on refresh. Fall back to the
|
|
9883
|
+
-- oldest page for versions that predate status tracking.
|
|
9884
|
+
COALESCE(v.updated_at, MIN(p.created_at)) as indexedAt,
|
|
9909
9885
|
COUNT(d.id) as documentCount,
|
|
9910
9886
|
COUNT(DISTINCT p.url) as uniqueUrlCount
|
|
9911
9887
|
FROM versions v
|
|
@@ -10226,6 +10202,14 @@ var DocumentStore = class {
|
|
|
10226
10202
|
return `${`"${tokens.join(" ").replace(/"/g, "\"\"")}"`} OR ${escapedTokens.join(" OR ")}`;
|
|
10227
10203
|
}
|
|
10228
10204
|
/**
|
|
10205
|
+
* Escapes SQL LIKE wildcard characters (`%`, `_`) and the escape character
|
|
10206
|
+
* itself so a user-supplied filter is matched as a literal substring rather
|
|
10207
|
+
* than interpreted as a pattern. Pair with `LIKE ? ESCAPE '\'`.
|
|
10208
|
+
*/
|
|
10209
|
+
escapeLikePattern(value) {
|
|
10210
|
+
return value.replace(/[\\%_]/g, (match) => `\\${match}`);
|
|
10211
|
+
}
|
|
10212
|
+
/**
|
|
10229
10213
|
* Initializes database connection and ensures readiness
|
|
10230
10214
|
*/
|
|
10231
10215
|
async initialize() {
|
|
@@ -10558,6 +10542,7 @@ var DocumentStore = class {
|
|
|
10558
10542
|
version: row.version,
|
|
10559
10543
|
versionId: row.versionId,
|
|
10560
10544
|
status: row.status,
|
|
10545
|
+
errorMessage: row.errorMessage,
|
|
10561
10546
|
progressPages: row.progressPages,
|
|
10562
10547
|
progressMaxPages: row.progressMaxPages,
|
|
10563
10548
|
sourceUrl: row.sourceUrl,
|
|
@@ -11067,6 +11052,198 @@ var DocumentStore = class {
|
|
|
11067
11052
|
throw new ConnectionError(`Failed to fetch documents by URL ${url}`, error);
|
|
11068
11053
|
}
|
|
11069
11054
|
}
|
|
11055
|
+
/**
|
|
11056
|
+
* Lists stored chunks for a library version with pagination and an optional
|
|
11057
|
+
* case-insensitive content filter. Powers the admin dashboard's chunk explorer.
|
|
11058
|
+
*
|
|
11059
|
+
* Position (`chunkIndex`/`pageChunkCount`) is computed with window functions
|
|
11060
|
+
* over `sort_order` rather than trusted verbatim, so results stay correct
|
|
11061
|
+
* even if a page's chunks were ever stored with non-contiguous ordering.
|
|
11062
|
+
* Token counts are never fabricated: the current schema has no per-chunk
|
|
11063
|
+
* token column, so every item's `tokenCount` is `null`.
|
|
11064
|
+
*
|
|
11065
|
+
* @param library Library name (case-insensitive).
|
|
11066
|
+
* @param version Version string (empty string for unversioned).
|
|
11067
|
+
* @param options Pagination (`limit`/`offset`) and optional content `filter`.
|
|
11068
|
+
* @returns The requested page of chunks plus the total count matching the filter.
|
|
11069
|
+
*/
|
|
11070
|
+
async listVersionChunks(library, version, options) {
|
|
11071
|
+
try {
|
|
11072
|
+
const normalizedVersion = version.toLowerCase();
|
|
11073
|
+
const versionRow = this.statements.getVersionId.get(library.toLowerCase(), normalizedVersion);
|
|
11074
|
+
if (!versionRow) return {
|
|
11075
|
+
chunks: [],
|
|
11076
|
+
total: 0
|
|
11077
|
+
};
|
|
11078
|
+
const offset = options.offset ?? 0;
|
|
11079
|
+
const trimmedFilter = options.filter?.trim();
|
|
11080
|
+
const whereParams = [versionRow.id];
|
|
11081
|
+
let whereClause = "WHERE p.version_id = ?";
|
|
11082
|
+
if (trimmedFilter) {
|
|
11083
|
+
whereClause += " AND LOWER(d.content) LIKE LOWER(?) ESCAPE '\\'";
|
|
11084
|
+
whereParams.push(`%${this.escapeLikePattern(trimmedFilter)}%`);
|
|
11085
|
+
}
|
|
11086
|
+
const total = this.db.prepare(`SELECT COUNT(*) as count
|
|
11087
|
+
FROM documents d
|
|
11088
|
+
JOIN pages p ON d.page_id = p.id
|
|
11089
|
+
${whereClause}`).get(...whereParams).count;
|
|
11090
|
+
return {
|
|
11091
|
+
chunks: this.db.prepare(`SELECT
|
|
11092
|
+
d.id,
|
|
11093
|
+
d.content,
|
|
11094
|
+
(d.embedding IS NOT NULL) as has_embedding,
|
|
11095
|
+
p.url as url,
|
|
11096
|
+
p.content_type as mime_type,
|
|
11097
|
+
ROW_NUMBER() OVER (PARTITION BY d.page_id ORDER BY d.sort_order, d.id) as chunk_index,
|
|
11098
|
+
COUNT(*) OVER (PARTITION BY d.page_id) as page_chunk_count
|
|
11099
|
+
FROM documents d
|
|
11100
|
+
JOIN pages p ON d.page_id = p.id
|
|
11101
|
+
${whereClause}
|
|
11102
|
+
ORDER BY p.url, d.sort_order, d.id
|
|
11103
|
+
LIMIT ? OFFSET ?`).all(...whereParams, options.limit, offset).map((row) => ({
|
|
11104
|
+
id: String(row.id),
|
|
11105
|
+
url: row.url,
|
|
11106
|
+
content: row.content,
|
|
11107
|
+
mimeType: row.mime_type,
|
|
11108
|
+
chunkIndex: row.chunk_index,
|
|
11109
|
+
pageChunkCount: row.page_chunk_count,
|
|
11110
|
+
charCount: row.content.length,
|
|
11111
|
+
tokenCount: null,
|
|
11112
|
+
hasEmbedding: Boolean(row.has_embedding)
|
|
11113
|
+
})),
|
|
11114
|
+
total
|
|
11115
|
+
};
|
|
11116
|
+
} catch (error) {
|
|
11117
|
+
throw new ConnectionError("Failed to list version chunks", error);
|
|
11118
|
+
}
|
|
11119
|
+
}
|
|
11120
|
+
/**
|
|
11121
|
+
* Computes aggregate chunk/page/embedding statistics for a library version,
|
|
11122
|
+
* for the chunk explorer's header strip.
|
|
11123
|
+
*
|
|
11124
|
+
* `avgTokensPerChunk` is always `null`: the schema does not persist
|
|
11125
|
+
* per-chunk token counts, so this is reported as unavailable rather than
|
|
11126
|
+
* fabricated from character counts.
|
|
11127
|
+
*
|
|
11128
|
+
* @param library Library name (case-insensitive).
|
|
11129
|
+
* @param version Version string (empty string for unversioned).
|
|
11130
|
+
* @returns Aggregate statistics, or all-zero/`null` values if the version doesn't exist.
|
|
11131
|
+
*/
|
|
11132
|
+
async getVersionStats(library, version) {
|
|
11133
|
+
try {
|
|
11134
|
+
const normalizedVersion = version.toLowerCase();
|
|
11135
|
+
const versionRow = this.statements.getVersionId.get(library.toLowerCase(), normalizedVersion);
|
|
11136
|
+
if (!versionRow) return {
|
|
11137
|
+
pageCount: 0,
|
|
11138
|
+
chunkCount: 0,
|
|
11139
|
+
avgChunksPerPage: null,
|
|
11140
|
+
avgTokensPerChunk: null,
|
|
11141
|
+
embeddedChunkCount: 0
|
|
11142
|
+
};
|
|
11143
|
+
const row = this.db.prepare(`SELECT
|
|
11144
|
+
COUNT(DISTINCT p.id) as page_count,
|
|
11145
|
+
COUNT(d.id) as chunk_count,
|
|
11146
|
+
SUM(CASE WHEN d.embedding IS NOT NULL THEN 1 ELSE 0 END) as embedded_chunk_count
|
|
11147
|
+
FROM pages p
|
|
11148
|
+
LEFT JOIN documents d ON d.page_id = p.id
|
|
11149
|
+
WHERE p.version_id = ?`).get(versionRow.id);
|
|
11150
|
+
return {
|
|
11151
|
+
pageCount: row.page_count,
|
|
11152
|
+
chunkCount: row.chunk_count,
|
|
11153
|
+
avgChunksPerPage: row.page_count > 0 ? row.chunk_count / row.page_count : null,
|
|
11154
|
+
avgTokensPerChunk: null,
|
|
11155
|
+
embeddedChunkCount: row.embedded_chunk_count ?? 0
|
|
11156
|
+
};
|
|
11157
|
+
} catch (error) {
|
|
11158
|
+
throw new ConnectionError("Failed to get version stats", error);
|
|
11159
|
+
}
|
|
11160
|
+
}
|
|
11161
|
+
/**
|
|
11162
|
+
* Returns per-day indexing activity over the trailing `days`-day window,
|
|
11163
|
+
* derived from the `created_at` timestamps already stored on pages and
|
|
11164
|
+
* chunks. Days with no activity are zero-filled so the returned series is
|
|
11165
|
+
* contiguous.
|
|
11166
|
+
*
|
|
11167
|
+
* Rows are grouped by UTC calendar day to match SQLite's `date('now')`.
|
|
11168
|
+
* `created_at` reflects first insertion, so a refresh that only updates
|
|
11169
|
+
* existing pages does not inflate the counts (it is genuinely new content,
|
|
11170
|
+
* not re-touched content, that registers as activity).
|
|
11171
|
+
*
|
|
11172
|
+
* @param days - Window length in days; clamped to 1..366.
|
|
11173
|
+
*/
|
|
11174
|
+
async getActivityHistory(days) {
|
|
11175
|
+
try {
|
|
11176
|
+
const windowDays = Math.max(1, Math.min(366, Math.floor(days) || 1));
|
|
11177
|
+
const rows = this.db.prepare(`WITH RECURSIVE calendar(day) AS (
|
|
11178
|
+
SELECT date('now', '-' || (@days - 1) || ' days')
|
|
11179
|
+
UNION ALL
|
|
11180
|
+
SELECT date(day, '+1 day') FROM calendar WHERE day < date('now')
|
|
11181
|
+
)
|
|
11182
|
+
SELECT
|
|
11183
|
+
calendar.day AS date,
|
|
11184
|
+
COALESCE(pg.cnt, 0) AS pages,
|
|
11185
|
+
COALESCE(ch.cnt, 0) AS chunks
|
|
11186
|
+
FROM calendar
|
|
11187
|
+
LEFT JOIN (
|
|
11188
|
+
SELECT date(created_at) AS d, COUNT(*) AS cnt
|
|
11189
|
+
FROM pages
|
|
11190
|
+
WHERE created_at >= date('now', '-' || (@days - 1) || ' days')
|
|
11191
|
+
GROUP BY d
|
|
11192
|
+
) pg ON pg.d = calendar.day
|
|
11193
|
+
LEFT JOIN (
|
|
11194
|
+
SELECT date(created_at) AS d, COUNT(*) AS cnt
|
|
11195
|
+
FROM documents
|
|
11196
|
+
WHERE created_at >= date('now', '-' || (@days - 1) || ' days')
|
|
11197
|
+
GROUP BY d
|
|
11198
|
+
) ch ON ch.d = calendar.day
|
|
11199
|
+
ORDER BY calendar.day`).all({ days: windowDays });
|
|
11200
|
+
let totalPages = 0;
|
|
11201
|
+
let totalChunks = 0;
|
|
11202
|
+
for (const row of rows) {
|
|
11203
|
+
totalPages += row.pages;
|
|
11204
|
+
totalChunks += row.chunks;
|
|
11205
|
+
}
|
|
11206
|
+
return {
|
|
11207
|
+
days: rows.map((row) => ({
|
|
11208
|
+
date: row.date,
|
|
11209
|
+
pages: row.pages,
|
|
11210
|
+
chunks: row.chunks
|
|
11211
|
+
})),
|
|
11212
|
+
since: rows[0]?.date ?? "",
|
|
11213
|
+
until: rows[rows.length - 1]?.date ?? "",
|
|
11214
|
+
totalPages,
|
|
11215
|
+
totalChunks
|
|
11216
|
+
};
|
|
11217
|
+
} catch (error) {
|
|
11218
|
+
throw new ConnectionError("Failed to get activity history", error);
|
|
11219
|
+
}
|
|
11220
|
+
}
|
|
11221
|
+
/**
|
|
11222
|
+
* Returns a per-version content-type breakdown: pages grouped by MIME type
|
|
11223
|
+
* (`content_type`, falling back to `source_content_type`, else `unknown`),
|
|
11224
|
+
* most common first. Derived from the stored pages.
|
|
11225
|
+
*
|
|
11226
|
+
* @param library - Library name (case-insensitive).
|
|
11227
|
+
* @param version - Version name (empty string for unversioned).
|
|
11228
|
+
*/
|
|
11229
|
+
async getVersionComposition(library, version) {
|
|
11230
|
+
try {
|
|
11231
|
+
const versionRow = this.statements.getVersionId.get(library.toLowerCase(), version.toLowerCase());
|
|
11232
|
+
if (!versionRow) return { mimeTypes: [] };
|
|
11233
|
+
return { mimeTypes: this.db.prepare(`SELECT
|
|
11234
|
+
COALESCE(NULLIF(p.content_type, ''), NULLIF(p.source_content_type, ''), 'unknown') AS label,
|
|
11235
|
+
COUNT(*) AS pages
|
|
11236
|
+
FROM pages p
|
|
11237
|
+
WHERE p.version_id = ?
|
|
11238
|
+
GROUP BY label
|
|
11239
|
+
ORDER BY pages DESC, label`).all(versionRow.id).map((row) => ({
|
|
11240
|
+
label: row.label,
|
|
11241
|
+
pages: row.pages
|
|
11242
|
+
})) };
|
|
11243
|
+
} catch (error) {
|
|
11244
|
+
throw new ConnectionError("Failed to get version composition", error);
|
|
11245
|
+
}
|
|
11246
|
+
}
|
|
11070
11247
|
};
|
|
11071
11248
|
//#endregion
|
|
11072
11249
|
//#region src/store/DocumentManagementService.ts
|
|
@@ -11098,6 +11275,14 @@ var DocumentManagementService = class DocumentManagementService {
|
|
|
11098
11275
|
getActiveEmbeddingConfig() {
|
|
11099
11276
|
return this.store.getActiveEmbeddingConfig();
|
|
11100
11277
|
}
|
|
11278
|
+
async getEmbeddingConfigInfo() {
|
|
11279
|
+
const config = this.getActiveEmbeddingConfig();
|
|
11280
|
+
return config ? {
|
|
11281
|
+
provider: config.provider,
|
|
11282
|
+
model: config.model,
|
|
11283
|
+
dimensions: config.dimensions
|
|
11284
|
+
} : null;
|
|
11285
|
+
}
|
|
11101
11286
|
/**
|
|
11102
11287
|
* Normalizes a version string, converting null or undefined to an empty string
|
|
11103
11288
|
* and converting to lowercase.
|
|
@@ -11187,6 +11372,7 @@ var DocumentManagementService = class DocumentManagementService {
|
|
|
11187
11372
|
version: v.version
|
|
11188
11373
|
},
|
|
11189
11374
|
status: v.status,
|
|
11375
|
+
errorMessage: v.errorMessage,
|
|
11190
11376
|
progress: v.status === "completed" ? void 0 : {
|
|
11191
11377
|
pages: v.progressPages,
|
|
11192
11378
|
maxPages: v.progressMaxPages
|
|
@@ -11421,6 +11607,47 @@ var DocumentManagementService = class DocumentManagementService {
|
|
|
11421
11607
|
async getLibraryById(libraryId) {
|
|
11422
11608
|
return this.store.getLibraryById(libraryId);
|
|
11423
11609
|
}
|
|
11610
|
+
/**
|
|
11611
|
+
* Lists stored chunks for a library version with pagination and an optional
|
|
11612
|
+
* content filter. Powers the admin dashboard's chunk explorer.
|
|
11613
|
+
* @param ref Library/version reference; normalized before querying the store.
|
|
11614
|
+
* @param options Pagination (`limit`, defaults to 50; `offset`) and optional content `filter`.
|
|
11615
|
+
*/
|
|
11616
|
+
async listVersionChunks(ref, options = {}) {
|
|
11617
|
+
const normalized = normalizeVersionRef(ref);
|
|
11618
|
+
return this.store.listVersionChunks(normalized.library, normalized.version, {
|
|
11619
|
+
limit: options.limit ?? 50,
|
|
11620
|
+
offset: options.offset,
|
|
11621
|
+
filter: options.filter
|
|
11622
|
+
});
|
|
11623
|
+
}
|
|
11624
|
+
/**
|
|
11625
|
+
* Computes aggregate chunk/page/embedding statistics for a library version,
|
|
11626
|
+
* for the chunk explorer's header strip.
|
|
11627
|
+
* @param ref Library/version reference; normalized before querying the store.
|
|
11628
|
+
*/
|
|
11629
|
+
async getVersionStats(ref) {
|
|
11630
|
+
const normalized = normalizeVersionRef(ref);
|
|
11631
|
+
return this.store.getVersionStats(normalized.library, normalized.version);
|
|
11632
|
+
}
|
|
11633
|
+
/**
|
|
11634
|
+
* Returns per-day indexing activity across the whole store over a trailing
|
|
11635
|
+
* window, derived from stored page/chunk creation timestamps. Powers the
|
|
11636
|
+
* Overview "Indexing activity" chart.
|
|
11637
|
+
* @param days Window length in days; defaults to 90, clamped to 1..366.
|
|
11638
|
+
*/
|
|
11639
|
+
async getActivityHistory(days = 90) {
|
|
11640
|
+
return this.store.getActivityHistory(days);
|
|
11641
|
+
}
|
|
11642
|
+
/**
|
|
11643
|
+
* Computes a per-version content-type breakdown (pages grouped by MIME type)
|
|
11644
|
+
* for the library-detail Content types panel.
|
|
11645
|
+
* @param ref Library/version reference; normalized before querying the store.
|
|
11646
|
+
*/
|
|
11647
|
+
async getVersionComposition(ref) {
|
|
11648
|
+
const normalized = normalizeVersionRef(ref);
|
|
11649
|
+
return this.store.getVersionComposition(normalized.library, normalized.version);
|
|
11650
|
+
}
|
|
11424
11651
|
};
|
|
11425
11652
|
//#endregion
|
|
11426
11653
|
//#region src/store/index.ts
|
|
@@ -11650,12 +11877,50 @@ async function cleanupMcpService(mcpServer) {
|
|
|
11650
11877
|
}
|
|
11651
11878
|
}
|
|
11652
11879
|
//#endregion
|
|
11880
|
+
//#region src/services/systemInfo.ts
|
|
11881
|
+
/**
|
|
11882
|
+
* Assembles the {@link SystemInfo} snapshot from server + app configuration.
|
|
11883
|
+
* @param serverConfig - Service composition/runtime wiring for this process.
|
|
11884
|
+
* @param appConfig - Resolved application configuration (env/YAML/CLI merged).
|
|
11885
|
+
* @returns The distilled system info to thread through the tRPC context.
|
|
11886
|
+
*/
|
|
11887
|
+
function buildSystemInfo(serverConfig, appConfig) {
|
|
11888
|
+
const mcpEnabled = Boolean(serverConfig.enableMcpServer);
|
|
11889
|
+
const authEnabled = Boolean(appConfig.auth.enabled);
|
|
11890
|
+
return {
|
|
11891
|
+
version: "3.0.0",
|
|
11892
|
+
readOnly: Boolean(appConfig.app.readOnly),
|
|
11893
|
+
telemetryEnabled: Boolean(appConfig.app.telemetryEnabled),
|
|
11894
|
+
services: {
|
|
11895
|
+
web: Boolean(serverConfig.enableWebInterface),
|
|
11896
|
+
mcp: mcpEnabled,
|
|
11897
|
+
api: Boolean(serverConfig.enableApiServer),
|
|
11898
|
+
worker: Boolean(serverConfig.enableWorker)
|
|
11899
|
+
},
|
|
11900
|
+
worker: serverConfig.externalWorkerUrl ? {
|
|
11901
|
+
mode: "remote",
|
|
11902
|
+
url: serverConfig.externalWorkerUrl
|
|
11903
|
+
} : {
|
|
11904
|
+
mode: "embedded",
|
|
11905
|
+
maxConcurrency: appConfig.scraper.maxConcurrency
|
|
11906
|
+
},
|
|
11907
|
+
mcp: {
|
|
11908
|
+
enabled: mcpEnabled,
|
|
11909
|
+
endpoints: mcpEnabled ? ["/mcp", "/sse"] : []
|
|
11910
|
+
},
|
|
11911
|
+
auth: {
|
|
11912
|
+
enabled: authEnabled,
|
|
11913
|
+
issuer: authEnabled && appConfig.auth.issuerUrl ? appConfig.auth.issuerUrl : void 0
|
|
11914
|
+
}
|
|
11915
|
+
};
|
|
11916
|
+
}
|
|
11917
|
+
//#endregion
|
|
11653
11918
|
//#region src/events/trpc/router.ts
|
|
11654
11919
|
/**
|
|
11655
11920
|
* tRPC router for event subscriptions.
|
|
11656
11921
|
* Allows remote processes to subscribe to application events via tRPC.
|
|
11657
11922
|
*/
|
|
11658
|
-
var t$
|
|
11923
|
+
var t$4 = initTRPC.context().create({ transformer: superjson });
|
|
11659
11924
|
/**
|
|
11660
11925
|
* Factory to create an events router from any t instance whose context contains `eventBus`.
|
|
11661
11926
|
*/
|
|
@@ -11685,7 +11950,7 @@ subscribe: tt.procedure.input(z.object({ events: z.array(z.nativeEnum(EventType)
|
|
|
11685
11950
|
});
|
|
11686
11951
|
}) });
|
|
11687
11952
|
}
|
|
11688
|
-
createEventsRouter(t$
|
|
11953
|
+
createEventsRouter(t$4);
|
|
11689
11954
|
//#endregion
|
|
11690
11955
|
//#region src/pipeline/trpc/router.ts
|
|
11691
11956
|
/**
|
|
@@ -11695,9 +11960,13 @@ createEventsRouter(t$2);
|
|
|
11695
11960
|
* This module now exports a factory to build the router from a provided t instance,
|
|
11696
11961
|
* allowing us to compose multiple routers under a single /api endpoint.
|
|
11697
11962
|
*/
|
|
11698
|
-
var t$
|
|
11963
|
+
var t$3 = initTRPC.context().create({ transformer: superjson });
|
|
11699
11964
|
var nonEmptyTrimmed = z.string().transform((s) => s.trim()).refine((s) => s.length > 0, "must not be empty");
|
|
11700
|
-
var optionalTrimmed = z.preprocess((v) =>
|
|
11965
|
+
var optionalTrimmed = z.preprocess((v) => {
|
|
11966
|
+
if (typeof v !== "string") return v;
|
|
11967
|
+
const trimmed = v.trim();
|
|
11968
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
11969
|
+
}, z.string().min(1).optional().nullable());
|
|
11701
11970
|
var enqueueScrapeInput = z.object({
|
|
11702
11971
|
library: nonEmptyTrimmed,
|
|
11703
11972
|
version: optionalTrimmed,
|
|
@@ -11738,14 +12007,14 @@ function createPipelineRouter(trpc) {
|
|
|
11738
12007
|
})
|
|
11739
12008
|
});
|
|
11740
12009
|
}
|
|
11741
|
-
createPipelineRouter(t$
|
|
12010
|
+
createPipelineRouter(t$3);
|
|
11742
12011
|
//#endregion
|
|
11743
12012
|
//#region src/store/trpc/router.ts
|
|
11744
12013
|
/**
|
|
11745
12014
|
* tRPC router exposing document data store operations via the worker API.
|
|
11746
12015
|
* Only procedures actually used externally are included to keep surface minimal.
|
|
11747
12016
|
*/
|
|
11748
|
-
var t = initTRPC.context().create({ transformer: superjson });
|
|
12017
|
+
var t$2 = initTRPC.context().create({ transformer: superjson });
|
|
11749
12018
|
var nonEmpty = z.string().min(1).transform((s) => s.trim());
|
|
11750
12019
|
var optionalVersion = z.string().optional().nullable().transform((v) => typeof v === "string" ? v.trim() : v);
|
|
11751
12020
|
function createDataRouter(trpc) {
|
|
@@ -11822,2581 +12091,246 @@ function createDataRouter(trpc) {
|
|
|
11822
12091
|
})).mutation(async ({ ctx, input }) => {
|
|
11823
12092
|
await ctx.docService.storeScraperOptions(input.versionId, input.options);
|
|
11824
12093
|
return { ok: true };
|
|
12094
|
+
}),
|
|
12095
|
+
listVersionChunks: tt.procedure.input(z.object({
|
|
12096
|
+
library: nonEmpty,
|
|
12097
|
+
version: optionalVersion,
|
|
12098
|
+
limit: z.number().int().positive().max(200).optional(),
|
|
12099
|
+
offset: z.number().int().nonnegative().optional(),
|
|
12100
|
+
filter: z.string().optional()
|
|
12101
|
+
})).query(async ({ ctx, input }) => {
|
|
12102
|
+
return await ctx.docService.listVersionChunks({
|
|
12103
|
+
library: input.library,
|
|
12104
|
+
version: input.version ?? ""
|
|
12105
|
+
}, {
|
|
12106
|
+
limit: input.limit ?? 50,
|
|
12107
|
+
offset: input.offset,
|
|
12108
|
+
filter: input.filter
|
|
12109
|
+
});
|
|
12110
|
+
}),
|
|
12111
|
+
getVersionStats: tt.procedure.input(z.object({
|
|
12112
|
+
library: nonEmpty,
|
|
12113
|
+
version: optionalVersion
|
|
12114
|
+
})).query(async ({ ctx, input }) => {
|
|
12115
|
+
return await ctx.docService.getVersionStats({
|
|
12116
|
+
library: input.library,
|
|
12117
|
+
version: input.version ?? ""
|
|
12118
|
+
});
|
|
12119
|
+
}),
|
|
12120
|
+
getActivityHistory: tt.procedure.input(z.object({ days: z.number().int().min(1).max(366).optional() }).optional()).query(async ({ ctx, input }) => {
|
|
12121
|
+
return await ctx.docService.getActivityHistory(input?.days);
|
|
12122
|
+
}),
|
|
12123
|
+
getVersionComposition: tt.procedure.input(z.object({
|
|
12124
|
+
library: nonEmpty,
|
|
12125
|
+
version: optionalVersion
|
|
12126
|
+
})).query(async ({ ctx, input }) => {
|
|
12127
|
+
return await ctx.docService.getVersionComposition({
|
|
12128
|
+
library: input.library,
|
|
12129
|
+
version: input.version ?? ""
|
|
12130
|
+
});
|
|
12131
|
+
}),
|
|
12132
|
+
getEmbeddingConfig: tt.procedure.query(async ({ ctx }) => {
|
|
12133
|
+
return ctx.docService.getEmbeddingConfigInfo();
|
|
11825
12134
|
})
|
|
11826
12135
|
});
|
|
11827
12136
|
}
|
|
11828
|
-
createDataRouter(t);
|
|
12137
|
+
createDataRouter(t$2);
|
|
11829
12138
|
//#endregion
|
|
11830
|
-
//#region src/services/
|
|
12139
|
+
//#region src/services/systemHealthRouter.ts
|
|
11831
12140
|
/**
|
|
11832
|
-
*
|
|
11833
|
-
*
|
|
11834
|
-
*
|
|
12141
|
+
* tRPC router exposing a single `getSystemHealth` query that composes the
|
|
12142
|
+
* server's startup {@link SystemInfo} snapshot with the small amount of
|
|
12143
|
+
* cheaply-available live state (active embedding config, remote worker
|
|
12144
|
+
* connectivity). Powers the dashboard's system-health panel, sidebar status
|
|
12145
|
+
* footer, and Settings screen.
|
|
12146
|
+
*/
|
|
12147
|
+
var t$1 = initTRPC.context().create({ transformer: superjson });
|
|
12148
|
+
/**
|
|
12149
|
+
* Factory to create the system-health router from any `t` instance whose
|
|
12150
|
+
* context satisfies {@link SystemHealthTrpcContext}.
|
|
12151
|
+
*/
|
|
12152
|
+
function createSystemHealthRouter(trpc) {
|
|
12153
|
+
const tt = trpc;
|
|
12154
|
+
return tt.router({
|
|
12155
|
+
/**
|
|
12156
|
+
* Returns an honest snapshot of the running server's configuration:
|
|
12157
|
+
* which services were started, how the worker is wired, the active
|
|
12158
|
+
* embedding provider (if any), MCP/auth exposure, and app version.
|
|
12159
|
+
* Derived from startup config, not measured — nothing here is fabricated.
|
|
12160
|
+
*/
|
|
12161
|
+
getSystemHealth: tt.procedure.query(async ({ ctx }) => {
|
|
12162
|
+
const { systemInfo } = ctx;
|
|
12163
|
+
const worker = systemInfo.worker.mode === "remote" ? {
|
|
12164
|
+
mode: "remote",
|
|
12165
|
+
url: systemInfo.worker.url,
|
|
12166
|
+
connected: ctx.isWorkerConnected?.() ?? false
|
|
12167
|
+
} : {
|
|
12168
|
+
mode: "embedded",
|
|
12169
|
+
maxConcurrency: systemInfo.worker.maxConcurrency
|
|
12170
|
+
};
|
|
12171
|
+
const embeddings = await ctx.docService.getEmbeddingConfigInfo();
|
|
12172
|
+
return {
|
|
12173
|
+
version: systemInfo.version,
|
|
12174
|
+
readOnly: systemInfo.readOnly,
|
|
12175
|
+
telemetryEnabled: systemInfo.telemetryEnabled,
|
|
12176
|
+
services: systemInfo.services,
|
|
12177
|
+
worker,
|
|
12178
|
+
embeddings,
|
|
12179
|
+
mcp: systemInfo.mcp,
|
|
12180
|
+
auth: systemInfo.auth
|
|
12181
|
+
};
|
|
12182
|
+
}) });
|
|
12183
|
+
}
|
|
12184
|
+
createSystemHealthRouter(t$1);
|
|
12185
|
+
//#endregion
|
|
12186
|
+
//#region src/services/appRouter.ts
|
|
12187
|
+
/**
|
|
12188
|
+
* Canonical tRPC router builder for the merged application API.
|
|
12189
|
+
* Combines the health check, pipeline, data store, and events routers into a
|
|
12190
|
+
* single router shape. Both the Fastify HTTP mount point and the WebSocket
|
|
12191
|
+
* subscription handler in {@link ./trpcService} import from this module so the
|
|
12192
|
+
* two transports always expose identical procedures and typing.
|
|
12193
|
+
*/
|
|
12194
|
+
var t = initTRPC.context().create({ transformer: superjson });
|
|
12195
|
+
/**
|
|
12196
|
+
* Builds the merged application tRPC router (health + pipeline + data + events).
|
|
12197
|
+
* Kept as a factory (rather than only exporting a singleton) so future
|
|
12198
|
+
* transports can construct a fresh router instance if ever needed, while the
|
|
12199
|
+
* `appRouter` singleton below remains the single instance shared by the
|
|
12200
|
+
* current HTTP and WebSocket mount points.
|
|
12201
|
+
* @returns The merged tRPC router.
|
|
11835
12202
|
*/
|
|
11836
|
-
|
|
11837
|
-
const t = initTRPC.context().create({ transformer: superjson });
|
|
12203
|
+
function buildAppRouter() {
|
|
11838
12204
|
const healthRouter = t.router({ ping: t.procedure.query(async () => ({
|
|
11839
12205
|
status: "ok",
|
|
11840
12206
|
ts: Date.now()
|
|
11841
12207
|
})) });
|
|
11842
|
-
|
|
12208
|
+
return t.router({
|
|
11843
12209
|
...healthRouter._def.procedures,
|
|
11844
12210
|
...createPipelineRouter(t)._def.procedures,
|
|
11845
12211
|
...createDataRouter(t)._def.procedures,
|
|
12212
|
+
...createSystemHealthRouter(t)._def.procedures,
|
|
11846
12213
|
events: createEventsRouter(t)
|
|
11847
12214
|
});
|
|
12215
|
+
}
|
|
12216
|
+
/** The canonical merged application router instance, shared by all transports. */
|
|
12217
|
+
var appRouter = buildAppRouter();
|
|
12218
|
+
/**
|
|
12219
|
+
* Creates the request context shared by both the HTTP and WebSocket transports.
|
|
12220
|
+
* @param deps - The pipeline, document store, event bus, and system info backing this request.
|
|
12221
|
+
* @returns The context object passed to every procedure resolver.
|
|
12222
|
+
*/
|
|
12223
|
+
function createAppRouterContext(deps) {
|
|
12224
|
+
return {
|
|
12225
|
+
pipeline: deps.pipeline,
|
|
12226
|
+
docService: deps.docService,
|
|
12227
|
+
eventBus: deps.eventBus,
|
|
12228
|
+
systemInfo: deps.systemInfo,
|
|
12229
|
+
isWorkerConnected: deps.isWorkerConnected
|
|
12230
|
+
};
|
|
12231
|
+
}
|
|
12232
|
+
//#endregion
|
|
12233
|
+
//#region src/services/trpcService.ts
|
|
12234
|
+
/**
|
|
12235
|
+
* Fastify service to register unified tRPC API at /api.
|
|
12236
|
+
* Merges pipeline, data store, and events routers under a single endpoint.
|
|
12237
|
+
* Also provides WebSocket support for subscriptions.
|
|
12238
|
+
* Both mount points delegate to the single canonical router built in
|
|
12239
|
+
* {@link ../services/appRouter}, keeping HTTP and WebSocket behavior identical.
|
|
12240
|
+
*/
|
|
12241
|
+
/**
|
|
12242
|
+
* Registers the merged tRPC router on a Fastify instance under the `/api` prefix.
|
|
12243
|
+
* @param server - The Fastify instance to register the plugin on.
|
|
12244
|
+
* @param pipeline - The pipeline instance backing pipeline procedures.
|
|
12245
|
+
* @param docService - The document management service backing data procedures.
|
|
12246
|
+
* @param eventBus - The event bus backing the events subscription router.
|
|
12247
|
+
* @param systemInfo - Distilled, serializable snapshot of the server's startup configuration.
|
|
12248
|
+
* @param isWorkerConnected - Cheap connectivity check, provided only when the worker is remote.
|
|
12249
|
+
*/
|
|
12250
|
+
async function registerTrpcService(server, pipeline, docService, eventBus, systemInfo, isWorkerConnected) {
|
|
11848
12251
|
await server.register(fastifyTRPCPlugin, {
|
|
11849
12252
|
prefix: "/api",
|
|
11850
12253
|
trpcOptions: {
|
|
11851
|
-
router,
|
|
11852
|
-
createContext: async () => ({
|
|
12254
|
+
router: appRouter,
|
|
12255
|
+
createContext: async () => createAppRouterContext({
|
|
11853
12256
|
pipeline,
|
|
11854
12257
|
docService,
|
|
11855
|
-
eventBus
|
|
12258
|
+
eventBus,
|
|
12259
|
+
systemInfo,
|
|
12260
|
+
isWorkerConnected
|
|
11856
12261
|
})
|
|
11857
12262
|
}
|
|
11858
12263
|
});
|
|
11859
12264
|
}
|
|
11860
12265
|
/**
|
|
11861
|
-
*
|
|
12266
|
+
* Applies the tRPC WebSocket handler to a WebSocketServer for subscriptions.
|
|
12267
|
+
* @param wss - The WebSocket server to attach the tRPC handler to.
|
|
12268
|
+
* @param pipeline - The pipeline instance backing pipeline procedures.
|
|
12269
|
+
* @param docService - The document management service backing data procedures.
|
|
12270
|
+
* @param eventBus - The event bus backing the events subscription router.
|
|
12271
|
+
* @param systemInfo - Distilled, serializable snapshot of the server's startup configuration.
|
|
12272
|
+
* @param isWorkerConnected - Cheap connectivity check, provided only when the worker is remote.
|
|
12273
|
+
* @returns The tRPC WebSocket handler returned by `applyWSSHandler`.
|
|
11862
12274
|
*/
|
|
11863
|
-
function applyTrpcWebSocketHandler(wss, pipeline, docService, eventBus) {
|
|
11864
|
-
const t = initTRPC.context().create({ transformer: superjson });
|
|
11865
|
-
const healthRouter = t.router({ ping: t.procedure.query(async () => ({
|
|
11866
|
-
status: "ok",
|
|
11867
|
-
ts: Date.now()
|
|
11868
|
-
})) });
|
|
12275
|
+
function applyTrpcWebSocketHandler(wss, pipeline, docService, eventBus, systemInfo, isWorkerConnected) {
|
|
11869
12276
|
return applyWSSHandler({
|
|
11870
12277
|
wss,
|
|
11871
|
-
router:
|
|
11872
|
-
|
|
11873
|
-
...createPipelineRouter(t)._def.procedures,
|
|
11874
|
-
...createDataRouter(t)._def.procedures,
|
|
11875
|
-
events: createEventsRouter(t)
|
|
11876
|
-
}),
|
|
11877
|
-
createContext: () => ({
|
|
12278
|
+
router: appRouter,
|
|
12279
|
+
createContext: () => createAppRouterContext({
|
|
11878
12280
|
pipeline,
|
|
11879
12281
|
docService,
|
|
11880
|
-
eventBus
|
|
12282
|
+
eventBus,
|
|
12283
|
+
systemInfo,
|
|
12284
|
+
isWorkerConnected
|
|
11881
12285
|
})
|
|
11882
12286
|
});
|
|
11883
12287
|
}
|
|
11884
12288
|
//#endregion
|
|
11885
|
-
//#region src/
|
|
12289
|
+
//#region src/services/workerService.ts
|
|
11886
12290
|
/**
|
|
11887
|
-
*
|
|
12291
|
+
* Register worker service to enable embedded pipeline processing.
|
|
12292
|
+
* This starts the pipeline and configures callbacks for job processing.
|
|
12293
|
+
*
|
|
12294
|
+
* Note: This function is now deprecated in favor of configuring callbacks
|
|
12295
|
+
* in AppServer.setupPipelineEventBridge(). Keeping telemetry/logging here
|
|
12296
|
+
* would overwrite the event bus callbacks, breaking SSE notifications.
|
|
12297
|
+
* Telemetry and logging should be integrated into the event bus listeners instead.
|
|
11888
12298
|
*/
|
|
11889
|
-
function
|
|
11890
|
-
|
|
11891
|
-
|
|
11892
|
-
const job = payload;
|
|
11893
|
-
return {
|
|
11894
|
-
id: job.id,
|
|
11895
|
-
library: job.library,
|
|
11896
|
-
version: job.version,
|
|
11897
|
-
status: job.status,
|
|
11898
|
-
error: job.error,
|
|
11899
|
-
createdAt: job.createdAt.toISOString(),
|
|
11900
|
-
startedAt: job.startedAt?.toISOString() ?? null,
|
|
11901
|
-
finishedAt: job.finishedAt?.toISOString() ?? null,
|
|
11902
|
-
sourceUrl: job.sourceUrl
|
|
11903
|
-
};
|
|
11904
|
-
}
|
|
11905
|
-
case EventType.JOB_PROGRESS: {
|
|
11906
|
-
const { job, progress } = payload;
|
|
11907
|
-
return {
|
|
11908
|
-
id: job.id,
|
|
11909
|
-
library: job.library,
|
|
11910
|
-
version: job.version,
|
|
11911
|
-
progress: {
|
|
11912
|
-
pagesScraped: progress.pagesScraped,
|
|
11913
|
-
totalPages: progress.totalPages,
|
|
11914
|
-
totalDiscovered: progress.totalDiscovered,
|
|
11915
|
-
currentUrl: progress.currentUrl,
|
|
11916
|
-
depth: progress.depth,
|
|
11917
|
-
maxDepth: progress.maxDepth
|
|
11918
|
-
}
|
|
11919
|
-
};
|
|
11920
|
-
}
|
|
11921
|
-
case EventType.LIBRARY_CHANGE: return {};
|
|
11922
|
-
case EventType.JOB_LIST_CHANGE: return {};
|
|
11923
|
-
default: throw new Error(`Unhandled event type: ${eventType}`);
|
|
11924
|
-
}
|
|
12299
|
+
async function registerWorkerService(pipeline) {
|
|
12300
|
+
await pipeline.start();
|
|
12301
|
+
logger.debug("Worker service started");
|
|
11925
12302
|
}
|
|
11926
12303
|
/**
|
|
11927
|
-
*
|
|
12304
|
+
* Stop the worker service and cleanup resources.
|
|
11928
12305
|
*/
|
|
11929
|
-
function
|
|
11930
|
-
|
|
11931
|
-
|
|
11932
|
-
reply.raw.write(message);
|
|
11933
|
-
return true;
|
|
11934
|
-
} catch (error) {
|
|
11935
|
-
logger.error(`❌ Failed to send SSE event: ${error}`);
|
|
11936
|
-
return false;
|
|
11937
|
-
}
|
|
12306
|
+
async function stopWorkerService(pipeline) {
|
|
12307
|
+
await pipeline.stop();
|
|
12308
|
+
logger.debug("Worker service stopped");
|
|
11938
12309
|
}
|
|
12310
|
+
//#endregion
|
|
12311
|
+
//#region src/utils/banner.ts
|
|
11939
12312
|
/**
|
|
11940
|
-
*
|
|
11941
|
-
*
|
|
11942
|
-
* @param eventBus - The central event bus service instance.
|
|
12313
|
+
* ASCII art banner for console startup display.
|
|
12314
|
+
* Uses ANSI colors: gray (dim) top line, bright white bottom line.
|
|
11943
12315
|
*/
|
|
11944
|
-
|
|
11945
|
-
|
|
11946
|
-
|
|
11947
|
-
|
|
11948
|
-
|
|
11949
|
-
|
|
11950
|
-
|
|
11951
|
-
|
|
11952
|
-
|
|
11953
|
-
logger.debug("SSE client connected");
|
|
11954
|
-
const allEventTypes = [
|
|
11955
|
-
EventType.JOB_STATUS_CHANGE,
|
|
11956
|
-
EventType.JOB_PROGRESS,
|
|
11957
|
-
EventType.LIBRARY_CHANGE,
|
|
11958
|
-
EventType.JOB_LIST_CHANGE
|
|
11959
|
-
];
|
|
11960
|
-
const unsubscribers = [];
|
|
11961
|
-
for (const eventType of allEventTypes) {
|
|
11962
|
-
const unsubscribe = eventBus.on(eventType, (payload) => {
|
|
11963
|
-
try {
|
|
11964
|
-
const eventName = ServerEventName[eventType];
|
|
11965
|
-
const ssePayload = convertToSsePayload(eventType, payload);
|
|
11966
|
-
logger.debug(`SSE forwarding event: ${eventName} ${JSON.stringify(ssePayload)}`);
|
|
11967
|
-
sendSseMessage(reply, eventName, ssePayload);
|
|
11968
|
-
} catch (error) {
|
|
11969
|
-
logger.error(`❌ Failed to convert/send SSE event ${eventType}: ${error}`);
|
|
11970
|
-
}
|
|
11971
|
-
});
|
|
11972
|
-
unsubscribers.push(unsubscribe);
|
|
11973
|
-
logger.debug(`SSE listener registered for: ${ServerEventName[eventType]}`);
|
|
11974
|
-
}
|
|
11975
|
-
const cleanup = () => {
|
|
11976
|
-
for (const unsubscribe of unsubscribers) unsubscribe();
|
|
11977
|
-
};
|
|
11978
|
-
const heartbeatInterval = setInterval(() => {
|
|
11979
|
-
try {
|
|
11980
|
-
reply.raw.write(": heartbeat\n\n");
|
|
11981
|
-
} catch (_error) {
|
|
11982
|
-
logger.debug("Failed to send heartbeat, client likely disconnected");
|
|
11983
|
-
clearInterval(heartbeatInterval);
|
|
11984
|
-
}
|
|
11985
|
-
}, 3e4);
|
|
11986
|
-
request.raw.on("close", () => {
|
|
11987
|
-
logger.debug("SSE client disconnected");
|
|
11988
|
-
cleanup();
|
|
11989
|
-
clearInterval(heartbeatInterval);
|
|
11990
|
-
});
|
|
11991
|
-
request.raw.on("error", (error) => {
|
|
11992
|
-
logger.debug(`SSE connection error: ${error}`);
|
|
11993
|
-
cleanup();
|
|
11994
|
-
clearInterval(heartbeatInterval);
|
|
11995
|
-
});
|
|
11996
|
-
});
|
|
12316
|
+
var BANNER = ["\x1B[90m █▀▀ █▀█ █▀█ █ █ █▄ █ █▀▄ █▀▀ █▀▄ █▀▄ █▀█ █▀▀ █▀▀\x1B[0m", "\x1B[97m █▄█ █▀▄ █▄█ █▄█ █ ▀█ █▄▀ ██▄ █▄▀ █▄▀ █▄█ █▄▄ ▄▄█\x1B[0m"].join("\n");
|
|
12317
|
+
/**
|
|
12318
|
+
* Prints the startup banner to console.
|
|
12319
|
+
* Only call this for HTTP server startup, not stdio mode.
|
|
12320
|
+
*/
|
|
12321
|
+
function printBanner() {
|
|
12322
|
+
console.log();
|
|
12323
|
+
console.log(BANNER);
|
|
12324
|
+
console.log();
|
|
11997
12325
|
}
|
|
11998
12326
|
//#endregion
|
|
11999
|
-
//#region src/
|
|
12327
|
+
//#region src/app/AppServer.ts
|
|
12000
12328
|
/**
|
|
12001
|
-
*
|
|
12002
|
-
*
|
|
12329
|
+
* Central application server that can be configured to run different combinations of services.
|
|
12330
|
+
* This replaces the separate server implementations with a single, modular approach.
|
|
12003
12331
|
*/
|
|
12004
|
-
var PrimaryButton = ({ children, type = "button", class: className = "", disabled = false, ...rest }) => {
|
|
12005
|
-
return /* @__PURE__ */ jsx("button", {
|
|
12006
|
-
type,
|
|
12007
|
-
class: `w-full flex justify-center py-1.5 px-3 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 transition-colors duration-150 ${disabled ? "opacity-50 cursor-not-allowed" : ""} ${className}`.trim(),
|
|
12008
|
-
disabled,
|
|
12009
|
-
...rest,
|
|
12010
|
-
children
|
|
12011
|
-
});
|
|
12012
|
-
};
|
|
12013
|
-
//#endregion
|
|
12014
|
-
//#region src/web/components/AddJobButton.tsx
|
|
12015
12332
|
/**
|
|
12016
|
-
*
|
|
12017
|
-
* Encapsulates both styling and HTMX behavior.
|
|
12018
|
-
*/
|
|
12019
|
-
var AddJobButton = () => {
|
|
12020
|
-
return /* @__PURE__ */ jsx(PrimaryButton, {
|
|
12021
|
-
"hx-get": "/web/jobs/new",
|
|
12022
|
-
"hx-target": "#addJobForm",
|
|
12023
|
-
"hx-swap": "innerHTML",
|
|
12024
|
-
children: "Add New Documentation"
|
|
12025
|
-
});
|
|
12026
|
-
};
|
|
12027
|
-
//#endregion
|
|
12028
|
-
//#region src/web/components/Toast.tsx
|
|
12029
|
-
/**
|
|
12030
|
-
* Toast notification component using Flowbite styling and Alpine.js for state management.
|
|
12031
|
-
* Displays floating notifications for success, error, warning, and info messages.
|
|
12032
|
-
*/
|
|
12033
|
-
var Toast = () => {
|
|
12034
|
-
return /* @__PURE__ */ jsx("div", {
|
|
12035
|
-
"x-data": true,
|
|
12036
|
-
"x-show": "$store.toast.visible",
|
|
12037
|
-
"x-transition:enter": "transition ease-out duration-300",
|
|
12038
|
-
"x-transition:enter-start": "opacity-0 transform translate-y-2",
|
|
12039
|
-
"x-transition:enter-end": "opacity-100 transform translate-y-0",
|
|
12040
|
-
"x-transition:leave": "transition ease-in duration-200",
|
|
12041
|
-
"x-transition:leave-start": "opacity-100",
|
|
12042
|
-
"x-transition:leave-end": "opacity-0",
|
|
12043
|
-
class: "fixed top-5 right-5 z-50",
|
|
12044
|
-
style: "display: none;",
|
|
12045
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
12046
|
-
class: "flex items-center w-full max-w-xs p-4 text-gray-500 bg-white rounded-lg shadow dark:text-gray-400 dark:bg-gray-800",
|
|
12047
|
-
role: "alert",
|
|
12048
|
-
children: [
|
|
12049
|
-
/* @__PURE__ */ jsxs("div", {
|
|
12050
|
-
class: "inline-flex items-center justify-center shrink-0 w-8 h-8 rounded-lg",
|
|
12051
|
-
"x-bind:class": "{\n 'text-green-500 bg-green-100 dark:bg-green-800 dark:text-green-200': $store.toast.type === 'success',\n 'text-red-500 bg-red-100 dark:bg-red-800 dark:text-red-200': $store.toast.type === 'error',\n 'text-orange-500 bg-orange-100 dark:bg-orange-700 dark:text-orange-200': $store.toast.type === 'warning',\n 'text-blue-500 bg-blue-100 dark:bg-blue-800 dark:text-blue-200': $store.toast.type === 'info'\n }",
|
|
12052
|
-
children: [
|
|
12053
|
-
/* @__PURE__ */ jsx("svg", {
|
|
12054
|
-
"x-show": "$store.toast.type === 'success'",
|
|
12055
|
-
class: "w-5 h-5",
|
|
12056
|
-
"aria-hidden": "true",
|
|
12057
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
12058
|
-
fill: "currentColor",
|
|
12059
|
-
viewBox: "0 0 20 20",
|
|
12060
|
-
children: /* @__PURE__ */ jsx("path", { d: "M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 8.207-4 4a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L9 10.586l3.293-3.293a1 1 0 0 1 1.414 1.414Z" })
|
|
12061
|
-
}),
|
|
12062
|
-
/* @__PURE__ */ jsx("svg", {
|
|
12063
|
-
"x-show": "$store.toast.type === 'error'",
|
|
12064
|
-
class: "w-5 h-5",
|
|
12065
|
-
"aria-hidden": "true",
|
|
12066
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
12067
|
-
fill: "currentColor",
|
|
12068
|
-
viewBox: "0 0 20 20",
|
|
12069
|
-
children: /* @__PURE__ */ jsx("path", { d: "M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 11.793a1 1 0 1 1-1.414 1.414L10 11.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L8.586 10 6.293 7.707a1 1 0 0 1 1.414-1.414L10 8.586l2.293-2.293a1 1 0 0 1 1.414 1.414L11.414 10l2.293 2.293Z" })
|
|
12070
|
-
}),
|
|
12071
|
-
/* @__PURE__ */ jsx("svg", {
|
|
12072
|
-
"x-show": "$store.toast.type === 'warning'",
|
|
12073
|
-
class: "w-5 h-5",
|
|
12074
|
-
"aria-hidden": "true",
|
|
12075
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
12076
|
-
fill: "currentColor",
|
|
12077
|
-
viewBox: "0 0 20 20",
|
|
12078
|
-
children: /* @__PURE__ */ jsx("path", { d: "M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM10 15a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm1-4a1 1 0 0 1-2 0V6a1 1 0 0 1 2 0v5Z" })
|
|
12079
|
-
}),
|
|
12080
|
-
/* @__PURE__ */ jsx("svg", {
|
|
12081
|
-
"x-show": "$store.toast.type === 'info'",
|
|
12082
|
-
class: "w-5 h-5",
|
|
12083
|
-
"aria-hidden": "true",
|
|
12084
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
12085
|
-
fill: "currentColor",
|
|
12086
|
-
viewBox: "0 0 20 20",
|
|
12087
|
-
children: /* @__PURE__ */ jsx("path", { d: "M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3H8a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z" })
|
|
12088
|
-
})
|
|
12089
|
-
]
|
|
12090
|
-
}),
|
|
12091
|
-
/* @__PURE__ */ jsx("div", {
|
|
12092
|
-
class: "ml-3 text-sm font-normal",
|
|
12093
|
-
"x-text": "$store.toast.message"
|
|
12094
|
-
}),
|
|
12095
|
-
/* @__PURE__ */ jsxs("button", {
|
|
12096
|
-
type: "button",
|
|
12097
|
-
class: "ml-auto -mx-1.5 -my-1.5 bg-white text-gray-400 hover:text-gray-900 rounded-lg focus:ring-2 focus:ring-gray-300 p-1.5 hover:bg-gray-100 inline-flex items-center justify-center h-8 w-8 dark:text-gray-500 dark:hover:text-white dark:bg-gray-800 dark:hover:bg-gray-700",
|
|
12098
|
-
"x-on:click": "$store.toast.hide()",
|
|
12099
|
-
"aria-label": "Close",
|
|
12100
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
12101
|
-
class: "sr-only",
|
|
12102
|
-
children: "Close"
|
|
12103
|
-
}), /* @__PURE__ */ jsx("svg", {
|
|
12104
|
-
class: "w-3 h-3",
|
|
12105
|
-
"aria-hidden": "true",
|
|
12106
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
12107
|
-
fill: "none",
|
|
12108
|
-
viewBox: "0 0 14 14",
|
|
12109
|
-
children: /* @__PURE__ */ jsx("path", {
|
|
12110
|
-
stroke: "currentColor",
|
|
12111
|
-
"stroke-linecap": "round",
|
|
12112
|
-
"stroke-linejoin": "round",
|
|
12113
|
-
"stroke-width": "2",
|
|
12114
|
-
d: "m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"
|
|
12115
|
-
})
|
|
12116
|
-
})]
|
|
12117
|
-
})
|
|
12118
|
-
]
|
|
12119
|
-
})
|
|
12120
|
-
});
|
|
12121
|
-
};
|
|
12122
|
-
//#endregion
|
|
12123
|
-
//#region src/web/components/Layout.tsx
|
|
12124
|
-
/**
|
|
12125
|
-
* Base HTML layout component for all pages.
|
|
12126
|
-
* Includes common head elements, header, and scripts.
|
|
12127
|
-
* @param props - Component props including title, version, and children.
|
|
12128
|
-
*/
|
|
12129
|
-
var Layout = ({ title, version, children }) => {
|
|
12130
|
-
const versionString = version || "2.5.0";
|
|
12131
|
-
const versionInitializer = `versionUpdate({ currentVersion: ${versionString ? `'${versionString}'` : "null"} })`;
|
|
12132
|
-
return /* @__PURE__ */ jsxs("html", {
|
|
12133
|
-
lang: "en",
|
|
12134
|
-
children: [/* @__PURE__ */ jsxs("head", { children: [
|
|
12135
|
-
/* @__PURE__ */ jsx("meta", { charset: "UTF-8" }),
|
|
12136
|
-
/* @__PURE__ */ jsx("meta", {
|
|
12137
|
-
name: "viewport",
|
|
12138
|
-
content: "width=device-width, initial-scale=1.0"
|
|
12139
|
-
}),
|
|
12140
|
-
/* @__PURE__ */ jsx("title", {
|
|
12141
|
-
safe: true,
|
|
12142
|
-
children: title
|
|
12143
|
-
}),
|
|
12144
|
-
/* @__PURE__ */ jsx("link", {
|
|
12145
|
-
rel: "apple-touch-icon",
|
|
12146
|
-
sizes: "57x57",
|
|
12147
|
-
href: "/apple-icon-57x57.png"
|
|
12148
|
-
}),
|
|
12149
|
-
/* @__PURE__ */ jsx("link", {
|
|
12150
|
-
rel: "apple-touch-icon",
|
|
12151
|
-
sizes: "60x60",
|
|
12152
|
-
href: "/apple-icon-60x60.png"
|
|
12153
|
-
}),
|
|
12154
|
-
/* @__PURE__ */ jsx("link", {
|
|
12155
|
-
rel: "apple-touch-icon",
|
|
12156
|
-
sizes: "72x72",
|
|
12157
|
-
href: "/apple-icon-72x72.png"
|
|
12158
|
-
}),
|
|
12159
|
-
/* @__PURE__ */ jsx("link", {
|
|
12160
|
-
rel: "apple-touch-icon",
|
|
12161
|
-
sizes: "76x76",
|
|
12162
|
-
href: "/apple-icon-76x76.png"
|
|
12163
|
-
}),
|
|
12164
|
-
/* @__PURE__ */ jsx("link", {
|
|
12165
|
-
rel: "apple-touch-icon",
|
|
12166
|
-
sizes: "114x114",
|
|
12167
|
-
href: "/apple-icon-114x114.png"
|
|
12168
|
-
}),
|
|
12169
|
-
/* @__PURE__ */ jsx("link", {
|
|
12170
|
-
rel: "apple-touch-icon",
|
|
12171
|
-
sizes: "120x120",
|
|
12172
|
-
href: "/apple-icon-120x120.png"
|
|
12173
|
-
}),
|
|
12174
|
-
/* @__PURE__ */ jsx("link", {
|
|
12175
|
-
rel: "apple-touch-icon",
|
|
12176
|
-
sizes: "144x144",
|
|
12177
|
-
href: "/apple-icon-144x144.png"
|
|
12178
|
-
}),
|
|
12179
|
-
/* @__PURE__ */ jsx("link", {
|
|
12180
|
-
rel: "apple-touch-icon",
|
|
12181
|
-
sizes: "152x152",
|
|
12182
|
-
href: "/apple-icon-152x152.png"
|
|
12183
|
-
}),
|
|
12184
|
-
/* @__PURE__ */ jsx("link", {
|
|
12185
|
-
rel: "apple-touch-icon",
|
|
12186
|
-
sizes: "180x180",
|
|
12187
|
-
href: "/apple-icon-180x180.png"
|
|
12188
|
-
}),
|
|
12189
|
-
/* @__PURE__ */ jsx("link", {
|
|
12190
|
-
rel: "icon",
|
|
12191
|
-
type: "image/png",
|
|
12192
|
-
sizes: "192x192",
|
|
12193
|
-
href: "/android-icon-192x192.png"
|
|
12194
|
-
}),
|
|
12195
|
-
/* @__PURE__ */ jsx("link", {
|
|
12196
|
-
rel: "icon",
|
|
12197
|
-
type: "image/png",
|
|
12198
|
-
sizes: "32x32",
|
|
12199
|
-
href: "/favicon-32x32.png"
|
|
12200
|
-
}),
|
|
12201
|
-
/* @__PURE__ */ jsx("link", {
|
|
12202
|
-
rel: "icon",
|
|
12203
|
-
type: "image/png",
|
|
12204
|
-
sizes: "96x96",
|
|
12205
|
-
href: "/favicon-96x96.png"
|
|
12206
|
-
}),
|
|
12207
|
-
/* @__PURE__ */ jsx("link", {
|
|
12208
|
-
rel: "icon",
|
|
12209
|
-
type: "image/png",
|
|
12210
|
-
sizes: "16x16",
|
|
12211
|
-
href: "/favicon-16x16.png"
|
|
12212
|
-
}),
|
|
12213
|
-
/* @__PURE__ */ jsx("link", {
|
|
12214
|
-
rel: "shortcut icon",
|
|
12215
|
-
href: "/favicon.ico"
|
|
12216
|
-
}),
|
|
12217
|
-
/* @__PURE__ */ jsx("link", {
|
|
12218
|
-
rel: "manifest",
|
|
12219
|
-
href: "/manifest.json"
|
|
12220
|
-
}),
|
|
12221
|
-
/* @__PURE__ */ jsx("meta", {
|
|
12222
|
-
name: "msapplication-TileColor",
|
|
12223
|
-
content: "#ffffff"
|
|
12224
|
-
}),
|
|
12225
|
-
/* @__PURE__ */ jsx("meta", {
|
|
12226
|
-
name: "msapplication-TileImage",
|
|
12227
|
-
content: "/ms-icon-144x144.png"
|
|
12228
|
-
}),
|
|
12229
|
-
/* @__PURE__ */ jsx("meta", {
|
|
12230
|
-
name: "theme-color",
|
|
12231
|
-
content: "#ffffff"
|
|
12232
|
-
}),
|
|
12233
|
-
/* @__PURE__ */ jsx("link", {
|
|
12234
|
-
rel: "stylesheet",
|
|
12235
|
-
href: "/assets/main.css"
|
|
12236
|
-
}),
|
|
12237
|
-
/* @__PURE__ */ jsx("style", { children: `
|
|
12238
|
-
.htmx-indicator {
|
|
12239
|
-
display: none;
|
|
12240
|
-
}
|
|
12241
|
-
.htmx-request .htmx-indicator {
|
|
12242
|
-
display: block;
|
|
12243
|
-
}
|
|
12244
|
-
.htmx-request.htmx-indicator {
|
|
12245
|
-
display: block;
|
|
12246
|
-
}
|
|
12247
|
-
/* Default: Hide skeleton, show results container */
|
|
12248
|
-
#searchResultsContainer .search-skeleton { display: none; }
|
|
12249
|
-
#searchResultsContainer .search-results { display: block; } /* Or as needed */
|
|
12250
|
-
|
|
12251
|
-
/* Request in progress: Show skeleton, hide results */
|
|
12252
|
-
#searchResultsContainer.htmx-request .search-skeleton { display: block; } /* Or flex etc. */
|
|
12253
|
-
#searchResultsContainer.htmx-request .search-results { display: none; }
|
|
12254
|
-
|
|
12255
|
-
/* Keep button spinner logic */
|
|
12256
|
-
form .htmx-indicator .spinner { display: flex; }
|
|
12257
|
-
form .htmx-indicator .search-text { display: none; }
|
|
12258
|
-
form .spinner { display: none; }
|
|
12259
|
-
` })
|
|
12260
|
-
] }), /* @__PURE__ */ jsxs("body", {
|
|
12261
|
-
class: "bg-gray-50 dark:bg-gray-900",
|
|
12262
|
-
"hx-ext": "morph",
|
|
12263
|
-
children: [
|
|
12264
|
-
/* @__PURE__ */ jsx(Toast, {}),
|
|
12265
|
-
/* @__PURE__ */ jsx("header", {
|
|
12266
|
-
class: "bg-white border-b border-gray-200 dark:bg-gray-800 dark:border-gray-700",
|
|
12267
|
-
"x-data": versionInitializer,
|
|
12268
|
-
"x-init": "queueCheck()",
|
|
12269
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
12270
|
-
class: "container max-w-2xl mx-auto px-4 py-4",
|
|
12271
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
12272
|
-
class: "hidden sm:flex items-center justify-between",
|
|
12273
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
12274
|
-
class: "flex items-center gap-3",
|
|
12275
|
-
children: [
|
|
12276
|
-
/* @__PURE__ */ jsxs("a", {
|
|
12277
|
-
href: "https://grounded.tools",
|
|
12278
|
-
target: "_blank",
|
|
12279
|
-
rel: "noopener noreferrer",
|
|
12280
|
-
class: "text-xl font-medium text-gray-900 dark:text-white hover:text-primary-500 dark:hover:text-primary-400 transition-colors font-brand",
|
|
12281
|
-
children: [
|
|
12282
|
-
/* @__PURE__ */ jsx("span", {
|
|
12283
|
-
class: "text-primary-600 dark:text-primary-300",
|
|
12284
|
-
children: "grounded"
|
|
12285
|
-
}),
|
|
12286
|
-
/* @__PURE__ */ jsx("span", {
|
|
12287
|
-
class: "text-accent-500",
|
|
12288
|
-
children: "."
|
|
12289
|
-
}),
|
|
12290
|
-
/* @__PURE__ */ jsx("span", {
|
|
12291
|
-
class: "text-gray-900 dark:text-gray-100",
|
|
12292
|
-
children: "tools"
|
|
12293
|
-
})
|
|
12294
|
-
]
|
|
12295
|
-
}),
|
|
12296
|
-
/* @__PURE__ */ jsx("span", {
|
|
12297
|
-
class: "text-gray-400 dark:text-gray-400",
|
|
12298
|
-
children: "|"
|
|
12299
|
-
}),
|
|
12300
|
-
/* @__PURE__ */ jsx("a", {
|
|
12301
|
-
href: "/",
|
|
12302
|
-
class: "text-lg font-semibold text-gray-900 dark:text-white hover:text-primary-500 dark:hover:text-primary-400 transition-colors font-brand",
|
|
12303
|
-
children: "Docs MCP Server"
|
|
12304
|
-
}),
|
|
12305
|
-
versionString ? /* @__PURE__ */ jsxs("span", {
|
|
12306
|
-
safe: true,
|
|
12307
|
-
class: "text-sm font-normal text-gray-500 dark:text-slate-400",
|
|
12308
|
-
title: `Version ${versionString}`,
|
|
12309
|
-
children: ["v", versionString]
|
|
12310
|
-
}) : null
|
|
12311
|
-
]
|
|
12312
|
-
}), /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("span", {
|
|
12313
|
-
"x-show": "hasUpdate",
|
|
12314
|
-
"x-cloak": true,
|
|
12315
|
-
class: "inline-flex items-center gap-2 rounded-full bg-amber-100 dark:bg-amber-500/20 px-3 py-1.5 text-sm font-medium text-amber-700 dark:text-amber-300 border border-amber-200 dark:border-amber-500/30",
|
|
12316
|
-
role: "status",
|
|
12317
|
-
"aria-live": "polite",
|
|
12318
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
12319
|
-
class: "flex h-4 w-4 items-center justify-center rounded-full bg-amber-500 text-amber-800 dark:text-amber-900 text-xs font-bold",
|
|
12320
|
-
children: "!"
|
|
12321
|
-
}), /* @__PURE__ */ jsx("a", {
|
|
12322
|
-
"x-bind:href": "latestReleaseUrl",
|
|
12323
|
-
target: "_blank",
|
|
12324
|
-
rel: "noopener noreferrer",
|
|
12325
|
-
class: "hover:text-amber-800 dark:hover:text-amber-200 transition-colors",
|
|
12326
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
12327
|
-
class: "mr-1",
|
|
12328
|
-
children: "Update available"
|
|
12329
|
-
})
|
|
12330
|
-
})]
|
|
12331
|
-
}) })]
|
|
12332
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
12333
|
-
class: "sm:hidden space-y-2",
|
|
12334
|
-
children: [
|
|
12335
|
-
/* @__PURE__ */ jsx("div", {
|
|
12336
|
-
class: "flex justify-center",
|
|
12337
|
-
children: /* @__PURE__ */ jsxs("a", {
|
|
12338
|
-
href: "https://grounded.tools",
|
|
12339
|
-
target: "_blank",
|
|
12340
|
-
rel: "noopener noreferrer",
|
|
12341
|
-
class: "text-xl font-medium text-gray-900 dark:text-white hover:text-primary-500 dark:hover:text-primary-400 transition-colors font-brand",
|
|
12342
|
-
children: [
|
|
12343
|
-
/* @__PURE__ */ jsx("span", {
|
|
12344
|
-
class: "text-primary-600 dark:text-primary-300",
|
|
12345
|
-
children: "grounded"
|
|
12346
|
-
}),
|
|
12347
|
-
/* @__PURE__ */ jsx("span", {
|
|
12348
|
-
class: "text-accent-500",
|
|
12349
|
-
children: "."
|
|
12350
|
-
}),
|
|
12351
|
-
/* @__PURE__ */ jsx("span", {
|
|
12352
|
-
class: "text-gray-900 dark:text-gray-100",
|
|
12353
|
-
children: "tools"
|
|
12354
|
-
})
|
|
12355
|
-
]
|
|
12356
|
-
})
|
|
12357
|
-
}),
|
|
12358
|
-
/* @__PURE__ */ jsxs("div", {
|
|
12359
|
-
class: "flex items-center justify-center gap-2",
|
|
12360
|
-
children: [/* @__PURE__ */ jsx("a", {
|
|
12361
|
-
href: "/",
|
|
12362
|
-
class: "text-lg font-semibold text-gray-900 dark:text-white hover:text-primary-500 dark:hover:text-primary-400 transition-colors font-brand",
|
|
12363
|
-
children: "Docs MCP Server"
|
|
12364
|
-
}), versionString ? /* @__PURE__ */ jsxs("span", {
|
|
12365
|
-
safe: true,
|
|
12366
|
-
class: "text-sm font-normal text-gray-500 dark:text-slate-400",
|
|
12367
|
-
title: `Version ${versionString}`,
|
|
12368
|
-
children: ["v", versionString]
|
|
12369
|
-
}) : null]
|
|
12370
|
-
}),
|
|
12371
|
-
/* @__PURE__ */ jsx("div", {
|
|
12372
|
-
class: "flex justify-center",
|
|
12373
|
-
children: /* @__PURE__ */ jsxs("span", {
|
|
12374
|
-
"x-show": "hasUpdate",
|
|
12375
|
-
"x-cloak": true,
|
|
12376
|
-
class: "inline-flex items-center gap-2 rounded-full bg-amber-100 dark:bg-amber-500/20 px-3 py-1.5 text-sm font-medium text-amber-700 dark:text-amber-300 border border-amber-200 dark:border-amber-500/30",
|
|
12377
|
-
role: "status",
|
|
12378
|
-
"aria-live": "polite",
|
|
12379
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
12380
|
-
class: "flex h-4 w-4 items-center justify-center rounded-full bg-amber-500 text-amber-800 dark:text-amber-900 text-xs font-bold",
|
|
12381
|
-
children: "!"
|
|
12382
|
-
}), /* @__PURE__ */ jsx("a", {
|
|
12383
|
-
"x-bind:href": "latestReleaseUrl",
|
|
12384
|
-
target: "_blank",
|
|
12385
|
-
rel: "noopener noreferrer",
|
|
12386
|
-
class: "hover:text-amber-800 dark:hover:text-amber-200 transition-colors",
|
|
12387
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
12388
|
-
class: "mr-1",
|
|
12389
|
-
children: "Update available"
|
|
12390
|
-
})
|
|
12391
|
-
})]
|
|
12392
|
-
})
|
|
12393
|
-
})
|
|
12394
|
-
]
|
|
12395
|
-
})]
|
|
12396
|
-
})
|
|
12397
|
-
}),
|
|
12398
|
-
/* @__PURE__ */ jsx("div", {
|
|
12399
|
-
class: "container max-w-2xl mx-auto px-4 py-6",
|
|
12400
|
-
children: /* @__PURE__ */ jsx("main", { children })
|
|
12401
|
-
}),
|
|
12402
|
-
/* @__PURE__ */ jsx("script", {
|
|
12403
|
-
type: "module",
|
|
12404
|
-
src: "/assets/main.js"
|
|
12405
|
-
})
|
|
12406
|
-
]
|
|
12407
|
-
})]
|
|
12408
|
-
});
|
|
12409
|
-
};
|
|
12410
|
-
//#endregion
|
|
12411
|
-
//#region src/web/routes/index.tsx
|
|
12412
|
-
/**
|
|
12413
|
-
* Registers the root route that serves the main HTML page.
|
|
12414
|
-
* @param server - The Fastify instance.
|
|
12415
|
-
*/
|
|
12416
|
-
function registerIndexRoute(server) {
|
|
12417
|
-
server.get("/", async (_, reply) => {
|
|
12418
|
-
reply.type("text/html");
|
|
12419
|
-
return "<!DOCTYPE html>" + /* @__PURE__ */ jsxs(Layout, {
|
|
12420
|
-
title: "MCP Docs",
|
|
12421
|
-
children: [
|
|
12422
|
-
/* @__PURE__ */ jsx("div", {
|
|
12423
|
-
id: "analytics-stats",
|
|
12424
|
-
"hx-get": "/web/stats",
|
|
12425
|
-
"hx-trigger": "load, library-change from:body",
|
|
12426
|
-
"hx-swap": "morph:innerHTML",
|
|
12427
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
12428
|
-
class: "grid grid-cols-1 sm:grid-cols-3 gap-4 mb-4 animate-pulse",
|
|
12429
|
-
children: [
|
|
12430
|
-
/* @__PURE__ */ jsx("div", { class: "p-4 bg-white rounded-lg shadow dark:bg-gray-800 border border-gray-300 dark:border-gray-600 h-20" }),
|
|
12431
|
-
/* @__PURE__ */ jsx("div", { class: "p-4 bg-white rounded-lg shadow dark:bg-gray-800 border border-gray-300 dark:border-gray-600 h-20" }),
|
|
12432
|
-
/* @__PURE__ */ jsx("div", { class: "p-4 bg-white rounded-lg shadow dark:bg-gray-800 border border-gray-300 dark:border-gray-600 h-20" })
|
|
12433
|
-
]
|
|
12434
|
-
})
|
|
12435
|
-
}),
|
|
12436
|
-
/* @__PURE__ */ jsxs("section", {
|
|
12437
|
-
class: "mb-4 p-4 bg-white rounded-lg shadow dark:bg-gray-800 border border-gray-300 dark:border-gray-600",
|
|
12438
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
12439
|
-
class: "flex items-center justify-between mb-2",
|
|
12440
|
-
children: [/* @__PURE__ */ jsx("h2", {
|
|
12441
|
-
class: "text-xl font-semibold text-gray-900 dark:text-white",
|
|
12442
|
-
children: "Job Queue"
|
|
12443
|
-
}), /* @__PURE__ */ jsx("button", {
|
|
12444
|
-
id: "clear-completed-btn",
|
|
12445
|
-
type: "button",
|
|
12446
|
-
class: "text-xs px-3 py-1.5 text-gray-400 bg-gray-50 border border-gray-200 rounded-lg cursor-not-allowed focus:ring-4 focus:outline-none transition-colors duration-150 dark:bg-gray-700 dark:text-gray-500 dark:border-gray-600",
|
|
12447
|
-
title: "Clear all completed, cancelled, and failed jobs",
|
|
12448
|
-
"hx-post": "/web/jobs/clear-completed",
|
|
12449
|
-
"hx-trigger": "click",
|
|
12450
|
-
"hx-on": "htmx:afterRequest: document.dispatchEvent(new Event('job-list-refresh'))",
|
|
12451
|
-
"hx-swap": "none",
|
|
12452
|
-
disabled: true,
|
|
12453
|
-
children: "Clear Completed Jobs"
|
|
12454
|
-
})]
|
|
12455
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
12456
|
-
id: "job-queue",
|
|
12457
|
-
"hx-get": "/web/jobs",
|
|
12458
|
-
"hx-trigger": "load, job-status-change from:body, job-progress from:body, job-list-change from:body, job-list-refresh from:body",
|
|
12459
|
-
"hx-swap": "morph:innerHTML",
|
|
12460
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
12461
|
-
class: "animate-pulse",
|
|
12462
|
-
children: [
|
|
12463
|
-
/* @__PURE__ */ jsx("div", { class: "h-[0.8em] bg-gray-200 rounded-full dark:bg-gray-700 w-48 mb-4" }),
|
|
12464
|
-
/* @__PURE__ */ jsx("div", { class: "h-[0.8em] bg-gray-200 rounded-full dark:bg-gray-700 w-full mb-2.5" }),
|
|
12465
|
-
/* @__PURE__ */ jsx("div", { class: "h-[0.8em] bg-gray-200 rounded-full dark:bg-gray-700 w-full mb-2.5" })
|
|
12466
|
-
]
|
|
12467
|
-
})
|
|
12468
|
-
})]
|
|
12469
|
-
}),
|
|
12470
|
-
/* @__PURE__ */ jsx("section", {
|
|
12471
|
-
class: "mb-8",
|
|
12472
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
12473
|
-
id: "addJobForm",
|
|
12474
|
-
children: /* @__PURE__ */ jsx(AddJobButton, {})
|
|
12475
|
-
})
|
|
12476
|
-
}),
|
|
12477
|
-
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h2", {
|
|
12478
|
-
class: "text-xl font-semibold mb-2 text-gray-900 dark:text-white",
|
|
12479
|
-
children: "Indexed Documentation"
|
|
12480
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
12481
|
-
id: "indexed-docs",
|
|
12482
|
-
"hx-get": "/web/libraries",
|
|
12483
|
-
"hx-trigger": "load, library-change from:body",
|
|
12484
|
-
"hx-swap": "morph:innerHTML",
|
|
12485
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
12486
|
-
class: "animate-pulse",
|
|
12487
|
-
children: [
|
|
12488
|
-
/* @__PURE__ */ jsx("div", { class: "h-[0.8em] bg-gray-200 rounded-full dark:bg-gray-700 w-48 mb-4" }),
|
|
12489
|
-
/* @__PURE__ */ jsx("div", { class: "h-[0.8em] bg-gray-200 rounded-full dark:bg-gray-700 w-full mb-2.5" }),
|
|
12490
|
-
/* @__PURE__ */ jsx("div", { class: "h-[0.8em] bg-gray-200 rounded-full dark:bg-gray-700 w-full mb-2.5" })
|
|
12491
|
-
]
|
|
12492
|
-
})
|
|
12493
|
-
})] })
|
|
12494
|
-
]
|
|
12495
|
-
});
|
|
12496
|
-
});
|
|
12497
|
-
}
|
|
12498
|
-
//#endregion
|
|
12499
|
-
//#region src/web/routes/jobs/cancel.tsx
|
|
12500
|
-
/**
|
|
12501
|
-
* Registers the API route for cancelling jobs.
|
|
12502
|
-
* @param server - The Fastify instance.
|
|
12503
|
-
* @param cancelJobTool - The tool instance for cancelling jobs.
|
|
12504
|
-
*/
|
|
12505
|
-
function registerCancelJobRoute(server, cancelJobTool) {
|
|
12506
|
-
server.post("/web/jobs/:jobId/cancel", async (request, reply) => {
|
|
12507
|
-
const { jobId } = request.params;
|
|
12508
|
-
try {
|
|
12509
|
-
await cancelJobTool.execute({ jobId });
|
|
12510
|
-
return {
|
|
12511
|
-
success: true,
|
|
12512
|
-
message: "Job cancelled successfully"
|
|
12513
|
-
};
|
|
12514
|
-
} catch (error) {
|
|
12515
|
-
if (error instanceof ToolError) {
|
|
12516
|
-
reply.status(400);
|
|
12517
|
-
return {
|
|
12518
|
-
success: false,
|
|
12519
|
-
message: error.message
|
|
12520
|
-
};
|
|
12521
|
-
} else {
|
|
12522
|
-
reply.status(500);
|
|
12523
|
-
return {
|
|
12524
|
-
success: false,
|
|
12525
|
-
message: "Internal server error"
|
|
12526
|
-
};
|
|
12527
|
-
}
|
|
12528
|
-
}
|
|
12529
|
-
});
|
|
12530
|
-
}
|
|
12531
|
-
//#endregion
|
|
12532
|
-
//#region src/web/routes/jobs/clear-completed.tsx
|
|
12533
|
-
/**
|
|
12534
|
-
* Registers the API route for clearing completed jobs.
|
|
12535
|
-
* @param server - The Fastify instance.
|
|
12536
|
-
* @param clearCompletedJobsTool - The tool instance for clearing completed jobs.
|
|
12537
|
-
*/
|
|
12538
|
-
function registerClearCompletedJobsRoute(server, clearCompletedJobsTool) {
|
|
12539
|
-
server.post("/web/jobs/clear-completed", async (_, reply) => {
|
|
12540
|
-
try {
|
|
12541
|
-
await clearCompletedJobsTool.execute({});
|
|
12542
|
-
reply.type("application/json");
|
|
12543
|
-
return {
|
|
12544
|
-
success: true,
|
|
12545
|
-
message: "Completed jobs cleared successfully"
|
|
12546
|
-
};
|
|
12547
|
-
} catch (error) {
|
|
12548
|
-
if (error instanceof ToolError) {
|
|
12549
|
-
reply.code(400);
|
|
12550
|
-
return {
|
|
12551
|
-
success: false,
|
|
12552
|
-
message: error.message
|
|
12553
|
-
};
|
|
12554
|
-
} else {
|
|
12555
|
-
reply.code(500);
|
|
12556
|
-
return {
|
|
12557
|
-
success: false,
|
|
12558
|
-
message: `Internal server error: ${error instanceof Error ? error.message : String(error)}`
|
|
12559
|
-
};
|
|
12560
|
-
}
|
|
12561
|
-
}
|
|
12562
|
-
});
|
|
12563
|
-
}
|
|
12564
|
-
//#endregion
|
|
12565
|
-
//#region src/web/components/VersionBadge.tsx
|
|
12566
|
-
var VersionBadge = ({ version }) => {
|
|
12567
|
-
if (!version) return null;
|
|
12568
|
-
return /* @__PURE__ */ jsx("span", {
|
|
12569
|
-
class: "bg-primary-100 text-primary-800 text-xs font-medium me-2 px-1.5 py-0.5 rounded dark:bg-primary-900 dark:text-primary-300",
|
|
12570
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
12571
|
-
safe: true,
|
|
12572
|
-
children: version
|
|
12573
|
-
})
|
|
12574
|
-
});
|
|
12575
|
-
};
|
|
12576
|
-
//#endregion
|
|
12577
|
-
//#region src/web/components/StatusBadge.tsx
|
|
12578
|
-
/**
|
|
12579
|
-
* StatusBadge component displays version status with appropriate styling.
|
|
12580
|
-
* Uses database VersionStatus and helper functions for proper display.
|
|
12581
|
-
*/
|
|
12582
|
-
/**
|
|
12583
|
-
* Get CSS classes for status badge based on status type.
|
|
12584
|
-
*/
|
|
12585
|
-
function getStatusClasses(status) {
|
|
12586
|
-
const baseClasses = "px-1.5 py-0.5 text-xs font-medium rounded";
|
|
12587
|
-
switch (status) {
|
|
12588
|
-
case VersionStatus.COMPLETED: return `${baseClasses} bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-300`;
|
|
12589
|
-
case VersionStatus.RUNNING:
|
|
12590
|
-
case VersionStatus.UPDATING: return `${baseClasses} bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300`;
|
|
12591
|
-
case VersionStatus.QUEUED: return `${baseClasses} bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300`;
|
|
12592
|
-
case VersionStatus.FAILED: return `${baseClasses} bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-300`;
|
|
12593
|
-
case VersionStatus.CANCELLED: return `${baseClasses} bg-gray-100 text-gray-800 dark:bg-gray-900 dark:text-gray-300`;
|
|
12594
|
-
case VersionStatus.NOT_INDEXED:
|
|
12595
|
-
default: return `${baseClasses} bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400`;
|
|
12596
|
-
}
|
|
12597
|
-
}
|
|
12598
|
-
var StatusBadge = ({ status, showDescription = true }) => /* @__PURE__ */ jsx("span", {
|
|
12599
|
-
class: getStatusClasses(status),
|
|
12600
|
-
children: showDescription ? getStatusDescription(status) : status
|
|
12601
|
-
});
|
|
12602
|
-
//#endregion
|
|
12603
|
-
//#region src/web/components/ProgressBar.tsx
|
|
12604
|
-
var ProgressBar = ({ progress, showText = true }) => {
|
|
12605
|
-
const isIndeterminate = progress.totalDiscovered === 1;
|
|
12606
|
-
const percentage = progress.totalPages > 0 ? Math.round(progress.pages / progress.totalPages * 100) : 0;
|
|
12607
|
-
const getProgressText = () => {
|
|
12608
|
-
if (isIndeterminate) return "Discovering pages...";
|
|
12609
|
-
const baseText = `${progress.pages}/${progress.totalPages} pages (${percentage}%)`;
|
|
12610
|
-
if (progress.totalDiscovered > progress.totalPages) return `${baseText} • ${progress.totalDiscovered} total`;
|
|
12611
|
-
return baseText;
|
|
12612
|
-
};
|
|
12613
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
12614
|
-
class: "w-full",
|
|
12615
|
-
children: [showText && /* @__PURE__ */ jsxs("div", {
|
|
12616
|
-
class: "flex justify-between text-xs text-gray-600 dark:text-gray-400 mb-1",
|
|
12617
|
-
children: [/* @__PURE__ */ jsx("span", { children: "Progress" }), /* @__PURE__ */ jsx("span", {
|
|
12618
|
-
safe: true,
|
|
12619
|
-
children: getProgressText()
|
|
12620
|
-
})]
|
|
12621
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
12622
|
-
class: "w-full bg-gray-200 rounded-full h-2 dark:bg-gray-700",
|
|
12623
|
-
children: isIndeterminate ? /* @__PURE__ */ jsx("div", {
|
|
12624
|
-
class: "bg-blue-600 h-2 rounded-full animate-pulse",
|
|
12625
|
-
style: "width: 30%"
|
|
12626
|
-
}) : /* @__PURE__ */ jsx("div", {
|
|
12627
|
-
class: "bg-blue-600 h-2 rounded-full transition-all duration-300",
|
|
12628
|
-
style: `width: ${percentage}%`
|
|
12629
|
-
})
|
|
12630
|
-
})]
|
|
12631
|
-
});
|
|
12632
|
-
};
|
|
12633
|
-
//#endregion
|
|
12634
|
-
//#region src/web/components/LoadingSpinner.tsx
|
|
12635
|
-
/**
|
|
12636
|
-
* Renders an SVG loading spinner icon.
|
|
12637
|
-
* Used for indicating loading states in buttons or other elements.
|
|
12638
|
-
*/
|
|
12639
|
-
var LoadingSpinner = ({ class: className = "text-white" }) => /* @__PURE__ */ jsxs("svg", {
|
|
12640
|
-
class: `animate-spin h-4 w-4 ${className}`,
|
|
12641
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
12642
|
-
fill: "none",
|
|
12643
|
-
viewBox: "0 0 24 24",
|
|
12644
|
-
children: [/* @__PURE__ */ jsx("circle", {
|
|
12645
|
-
class: "opacity-25",
|
|
12646
|
-
cx: "12",
|
|
12647
|
-
cy: "12",
|
|
12648
|
-
r: "10",
|
|
12649
|
-
stroke: "currentColor",
|
|
12650
|
-
"stroke-width": "4"
|
|
12651
|
-
}), /* @__PURE__ */ jsx("path", {
|
|
12652
|
-
class: "opacity-75",
|
|
12653
|
-
fill: "currentColor",
|
|
12654
|
-
d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
12655
|
-
})]
|
|
12656
|
-
});
|
|
12657
|
-
//#endregion
|
|
12658
|
-
//#region src/web/components/JobItem.tsx
|
|
12659
|
-
/**
|
|
12660
|
-
* Renders a single job item with its details and status.
|
|
12661
|
-
* @param props - Component props including the job information.
|
|
12662
|
-
*/
|
|
12663
|
-
var JobItem = ({ job }) => {
|
|
12664
|
-
job.dbStatus || job.status;
|
|
12665
|
-
const isActiveJob = job.dbStatus ? isActiveStatus(job.dbStatus) : job.status === PipelineJobStatus.QUEUED || job.status === PipelineJobStatus.RUNNING;
|
|
12666
|
-
return /* @__PURE__ */ jsx("div", {
|
|
12667
|
-
id: `job-item-${job.id}`,
|
|
12668
|
-
class: "block p-3 bg-gray-50 dark:bg-gray-700 rounded-lg border border-gray-200 dark:border-gray-600",
|
|
12669
|
-
"data-job-id": job.id,
|
|
12670
|
-
"x-data": "{ jobId: $el.dataset.jobId, confirming: $el.dataset.confirming === 'true', isStopping: false }",
|
|
12671
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
12672
|
-
class: "flex items-start justify-between",
|
|
12673
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
12674
|
-
class: "flex-1",
|
|
12675
|
-
children: [
|
|
12676
|
-
/* @__PURE__ */ jsxs("p", {
|
|
12677
|
-
class: "text-sm font-medium text-gray-900 dark:text-white",
|
|
12678
|
-
children: [
|
|
12679
|
-
/* @__PURE__ */ jsx("span", {
|
|
12680
|
-
safe: true,
|
|
12681
|
-
children: job.library
|
|
12682
|
-
}),
|
|
12683
|
-
" ",
|
|
12684
|
-
/* @__PURE__ */ jsx(VersionBadge, { version: job.version })
|
|
12685
|
-
]
|
|
12686
|
-
}),
|
|
12687
|
-
/* @__PURE__ */ jsx("div", {
|
|
12688
|
-
class: "text-xs text-gray-500 dark:text-gray-400 mt-1",
|
|
12689
|
-
children: job.startedAt ? /* @__PURE__ */ jsxs("div", { children: [
|
|
12690
|
-
"Last Indexed:",
|
|
12691
|
-
" ",
|
|
12692
|
-
/* @__PURE__ */ jsx("span", {
|
|
12693
|
-
safe: true,
|
|
12694
|
-
children: new Date(job.startedAt).toLocaleString()
|
|
12695
|
-
})
|
|
12696
|
-
] }) : null
|
|
12697
|
-
}),
|
|
12698
|
-
job.progress && job.progress.totalPages > 0 && isActiveJob ? /* @__PURE__ */ jsx("div", {
|
|
12699
|
-
class: "mt-2",
|
|
12700
|
-
children: /* @__PURE__ */ jsx(ProgressBar, { progress: job.progress })
|
|
12701
|
-
}) : null,
|
|
12702
|
-
job.errorMessage || job.error ? /* @__PURE__ */ jsxs("div", {
|
|
12703
|
-
class: "mt-2 p-2 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded text-xs",
|
|
12704
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
12705
|
-
class: "font-medium text-red-800 dark:text-red-300 mb-1",
|
|
12706
|
-
children: "Error:"
|
|
12707
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
12708
|
-
safe: true,
|
|
12709
|
-
class: "text-red-700 dark:text-red-400",
|
|
12710
|
-
children: job.errorMessage || job.error
|
|
12711
|
-
})]
|
|
12712
|
-
}) : null
|
|
12713
|
-
]
|
|
12714
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
12715
|
-
class: "flex flex-col items-end gap-2 ml-4",
|
|
12716
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
12717
|
-
class: "flex items-center gap-2",
|
|
12718
|
-
children: [job.dbStatus ? /* @__PURE__ */ jsx(StatusBadge, { status: job.dbStatus }) : /* @__PURE__ */ jsx("span", {
|
|
12719
|
-
class: `px-1.5 py-0.5 text-xs font-medium rounded ${job.status === PipelineJobStatus.COMPLETED ? "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-300" : job.error ? "bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-300" : "bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-300"}`,
|
|
12720
|
-
children: job.status
|
|
12721
|
-
}), isActiveJob && /* @__PURE__ */ jsxs("button", {
|
|
12722
|
-
type: "button",
|
|
12723
|
-
class: "font-medium rounded-lg text-xs p-1 text-center inline-flex items-center transition-colors duration-150 ease-in-out",
|
|
12724
|
-
title: "Stop this job",
|
|
12725
|
-
"x-bind:class": `confirming ? 'bg-red-600 text-white border-red-600 focus:ring-4 focus:outline-none focus:ring-red-300 dark:bg-red-700 dark:border-red-700 dark:focus:ring-red-800' : 'border border-gray-300 bg-white text-red-600 hover:bg-red-50 focus:ring-4 focus:outline-none focus:ring-red-100 dark:border-gray-600 dark:bg-gray-800 dark:text-red-400 dark:hover:bg-gray-700 dark:focus:ring-red-900'`,
|
|
12726
|
-
"x-on:click": "\n if (confirming) {\n isStopping = true;\n window.confirmationManager.clear($root.id);\n fetch('/web/jobs/' + jobId + '/cancel', {\n method: 'POST',\n headers: { 'Accept': 'application/json' },\n })\n .then(r => r.json())\n .then(() => {\n confirming = false;\n isStopping = false;\n document.dispatchEvent(new CustomEvent('job-list-refresh'));\n })\n .catch(() => { isStopping = false; });\n } else {\n confirming = true;\n isStopping = false;\n window.confirmationManager.start($root.id);\n }\n ",
|
|
12727
|
-
"x-bind:disabled": "isStopping",
|
|
12728
|
-
children: [
|
|
12729
|
-
/* @__PURE__ */ jsxs("span", {
|
|
12730
|
-
"x-show": "!confirming && !isStopping",
|
|
12731
|
-
children: [/* @__PURE__ */ jsx("svg", {
|
|
12732
|
-
class: "w-4 h-4",
|
|
12733
|
-
"aria-hidden": "true",
|
|
12734
|
-
fill: "currentColor",
|
|
12735
|
-
viewBox: "0 0 20 20",
|
|
12736
|
-
children: /* @__PURE__ */ jsx("rect", {
|
|
12737
|
-
x: "5",
|
|
12738
|
-
y: "5",
|
|
12739
|
-
width: "10",
|
|
12740
|
-
height: "10",
|
|
12741
|
-
rx: "2"
|
|
12742
|
-
})
|
|
12743
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
12744
|
-
class: "sr-only",
|
|
12745
|
-
children: "Stop job"
|
|
12746
|
-
})]
|
|
12747
|
-
}),
|
|
12748
|
-
/* @__PURE__ */ jsx("span", {
|
|
12749
|
-
"x-show": "confirming && !isStopping",
|
|
12750
|
-
class: "px-2",
|
|
12751
|
-
children: "Cancel?"
|
|
12752
|
-
}),
|
|
12753
|
-
/* @__PURE__ */ jsxs("span", {
|
|
12754
|
-
"x-show": "isStopping",
|
|
12755
|
-
children: [/* @__PURE__ */ jsx(LoadingSpinner, {}), /* @__PURE__ */ jsx("span", {
|
|
12756
|
-
class: "sr-only",
|
|
12757
|
-
children: "Stopping..."
|
|
12758
|
-
})]
|
|
12759
|
-
})
|
|
12760
|
-
]
|
|
12761
|
-
})]
|
|
12762
|
-
}), job.error ? /* @__PURE__ */ jsx("span", {
|
|
12763
|
-
class: "bg-red-100 text-red-800 text-xs font-medium px-1.5 py-0.5 rounded dark:bg-red-900 dark:text-red-300",
|
|
12764
|
-
children: "Error"
|
|
12765
|
-
}) : null]
|
|
12766
|
-
})]
|
|
12767
|
-
})
|
|
12768
|
-
});
|
|
12769
|
-
};
|
|
12770
|
-
//#endregion
|
|
12771
|
-
//#region src/web/components/JobList.tsx
|
|
12772
|
-
/**
|
|
12773
|
-
* Renders a list of JobItem components or a message if the list is empty.
|
|
12774
|
-
* Also renders an out-of-band swap for the "Clear Completed Jobs" button state.
|
|
12775
|
-
* @param props - Component props including the array of jobs.
|
|
12776
|
-
*/
|
|
12777
|
-
var JobList = ({ jobs }) => {
|
|
12778
|
-
const hasJobs = jobs.length > 0;
|
|
12779
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
|
|
12780
|
-
id: "job-list",
|
|
12781
|
-
class: "space-y-2 animate-[fadeSlideIn_0.2s_ease-out]",
|
|
12782
|
-
children: hasJobs ? jobs.map((job) => /* @__PURE__ */ jsx(JobItem, { job })) : /* @__PURE__ */ jsx("p", {
|
|
12783
|
-
class: "text-center text-gray-500 dark:text-gray-400",
|
|
12784
|
-
children: "No pending jobs."
|
|
12785
|
-
})
|
|
12786
|
-
}), /* @__PURE__ */ jsx("button", {
|
|
12787
|
-
id: "clear-completed-btn",
|
|
12788
|
-
"hx-swap-oob": "true",
|
|
12789
|
-
type: "button",
|
|
12790
|
-
class: `text-xs px-3 py-1.5 rounded-lg focus:ring-4 focus:outline-none transition-colors duration-150 ${hasJobs ? "text-gray-700 bg-gray-100 border border-gray-300 hover:bg-gray-200 focus:ring-gray-100 dark:bg-gray-600 dark:text-gray-300 dark:border-gray-500 dark:hover:bg-gray-700 dark:focus:ring-gray-700" : "text-gray-400 bg-gray-50 border border-gray-200 cursor-not-allowed dark:bg-gray-700 dark:text-gray-500 dark:border-gray-600"}`,
|
|
12791
|
-
title: "Clear all completed, cancelled, and failed jobs",
|
|
12792
|
-
"hx-post": "/web/jobs/clear-completed",
|
|
12793
|
-
"hx-trigger": "click",
|
|
12794
|
-
"hx-on": "htmx:afterRequest: document.dispatchEvent(new Event('job-list-refresh'))",
|
|
12795
|
-
"hx-swap": "none",
|
|
12796
|
-
disabled: !hasJobs,
|
|
12797
|
-
children: "Clear Completed Jobs"
|
|
12798
|
-
})] });
|
|
12799
|
-
};
|
|
12800
|
-
//#endregion
|
|
12801
|
-
//#region src/web/routes/jobs/list.tsx
|
|
12802
|
-
/**
|
|
12803
|
-
* Registers the API route for listing jobs.
|
|
12804
|
-
* @param server - The Fastify instance.
|
|
12805
|
-
* @param listJobsTool - The tool instance for listing jobs.
|
|
12806
|
-
*/
|
|
12807
|
-
function registerJobListRoutes(server, listJobsTool) {
|
|
12808
|
-
server.get("/web/jobs", async () => {
|
|
12809
|
-
return /* @__PURE__ */ jsx(JobList, { jobs: (await listJobsTool.execute({})).jobs });
|
|
12810
|
-
});
|
|
12811
|
-
}
|
|
12812
|
-
//#endregion
|
|
12813
|
-
//#region src/web/components/AddVersionButton.tsx
|
|
12814
|
-
/**
|
|
12815
|
-
* A reusable button component for adding a new version to a library.
|
|
12816
|
-
* Encapsulates both styling and HTMX behavior.
|
|
12817
|
-
*/
|
|
12818
|
-
var AddVersionButton = ({ libraryName }) => {
|
|
12819
|
-
return /* @__PURE__ */ jsx(PrimaryButton, {
|
|
12820
|
-
"hx-get": `/web/libraries/${encodeURIComponent(libraryName)}/add-version-form`,
|
|
12821
|
-
"hx-target": "#add-version-form-container",
|
|
12822
|
-
"hx-swap": "innerHTML",
|
|
12823
|
-
children: "Add New Version"
|
|
12824
|
-
});
|
|
12825
|
-
};
|
|
12826
|
-
//#endregion
|
|
12827
|
-
//#region src/web/components/Alert.tsx
|
|
12828
|
-
/**
|
|
12829
|
-
* Reusable Alert component using Flowbite styling.
|
|
12830
|
-
* Displays messages with appropriate colors and icons based on the type.
|
|
12831
|
-
* @param props - Component props including type, title (optional), and message.
|
|
12832
|
-
*/
|
|
12833
|
-
var Alert = ({ type, title, message }) => {
|
|
12834
|
-
let iconSvg;
|
|
12835
|
-
let colorClasses;
|
|
12836
|
-
let defaultTitle;
|
|
12837
|
-
switch (type) {
|
|
12838
|
-
case "success":
|
|
12839
|
-
defaultTitle = "Success:";
|
|
12840
|
-
colorClasses = "text-green-800 border-green-300 bg-green-50 dark:bg-gray-800 dark:text-green-400 dark:border-green-800";
|
|
12841
|
-
iconSvg = /* @__PURE__ */ jsx("svg", {
|
|
12842
|
-
class: "shrink-0 inline w-4 h-4 me-3",
|
|
12843
|
-
"aria-hidden": "true",
|
|
12844
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
12845
|
-
fill: "currentColor",
|
|
12846
|
-
viewBox: "0 0 20 20",
|
|
12847
|
-
children: /* @__PURE__ */ jsx("path", { d: "M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm9.5 9.5A9.5 9.5 0 0 1 10 19a9.46 9.46 0 0 1-1.671-.14c-.165-.05-.3-.19-.42-.335l-.165-.165c-.19-.2-.3-.425-.3-.655A4.2 4.2 0 0 1 4.5 10a4.25 4.25 0 0 1 7.462-2.882l1.217 1.217a3.175 3.175 0 0 0 4.5.01l.106-.106a.934.934 0 0 0 .1-.36ZM10 11a1 1 0 1 0 0 2 1 1 0 0 0 0-2Z" })
|
|
12848
|
-
});
|
|
12849
|
-
break;
|
|
12850
|
-
case "error":
|
|
12851
|
-
defaultTitle = "Error:";
|
|
12852
|
-
colorClasses = "text-red-800 border-red-300 bg-red-50 dark:bg-gray-800 dark:text-red-400 dark:border-red-800";
|
|
12853
|
-
iconSvg = /* @__PURE__ */ jsx("svg", {
|
|
12854
|
-
class: "shrink-0 inline w-4 h-4 me-3",
|
|
12855
|
-
"aria-hidden": "true",
|
|
12856
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
12857
|
-
fill: "currentColor",
|
|
12858
|
-
viewBox: "0 0 20 20",
|
|
12859
|
-
children: /* @__PURE__ */ jsx("path", { d: "M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3h-1a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z" })
|
|
12860
|
-
});
|
|
12861
|
-
break;
|
|
12862
|
-
case "warning":
|
|
12863
|
-
defaultTitle = "Warning:";
|
|
12864
|
-
colorClasses = "text-yellow-800 border-yellow-300 bg-yellow-50 dark:bg-gray-800 dark:text-yellow-300 dark:border-yellow-800";
|
|
12865
|
-
iconSvg = /* @__PURE__ */ jsx("svg", {
|
|
12866
|
-
class: "shrink-0 inline w-4 h-4 me-3",
|
|
12867
|
-
"aria-hidden": "true",
|
|
12868
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
12869
|
-
fill: "currentColor",
|
|
12870
|
-
viewBox: "0 0 20 20",
|
|
12871
|
-
children: /* @__PURE__ */ jsx("path", { d: "M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3h-1a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z" })
|
|
12872
|
-
});
|
|
12873
|
-
break;
|
|
12874
|
-
default:
|
|
12875
|
-
defaultTitle = "Info:";
|
|
12876
|
-
colorClasses = "text-blue-800 border-blue-300 bg-blue-50 dark:bg-gray-800 dark:text-blue-400 dark:border-blue-800";
|
|
12877
|
-
iconSvg = /* @__PURE__ */ jsx("svg", {
|
|
12878
|
-
class: "shrink-0 inline w-4 h-4 me-3",
|
|
12879
|
-
"aria-hidden": "true",
|
|
12880
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
12881
|
-
fill: "currentColor",
|
|
12882
|
-
viewBox: "0 0 20 20",
|
|
12883
|
-
children: /* @__PURE__ */ jsx("path", { d: "M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3H8a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z" })
|
|
12884
|
-
});
|
|
12885
|
-
break;
|
|
12886
|
-
}
|
|
12887
|
-
const displayTitle = title ?? defaultTitle;
|
|
12888
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
12889
|
-
class: `flex items-center p-4 mb-4 text-sm border rounded-lg ${colorClasses}`,
|
|
12890
|
-
role: "alert",
|
|
12891
|
-
children: [
|
|
12892
|
-
iconSvg,
|
|
12893
|
-
/* @__PURE__ */ jsx("span", {
|
|
12894
|
-
class: "sr-only",
|
|
12895
|
-
children: "Info"
|
|
12896
|
-
}),
|
|
12897
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
12898
|
-
displayTitle ? /* @__PURE__ */ jsx("span", {
|
|
12899
|
-
class: "font-medium",
|
|
12900
|
-
safe: true,
|
|
12901
|
-
children: displayTitle
|
|
12902
|
-
}) : null,
|
|
12903
|
-
" ",
|
|
12904
|
-
message
|
|
12905
|
-
] })
|
|
12906
|
-
]
|
|
12907
|
-
});
|
|
12908
|
-
};
|
|
12909
|
-
//#endregion
|
|
12910
|
-
//#region src/web/components/Tooltip.tsx
|
|
12911
|
-
/**
|
|
12912
|
-
* Reusable Tooltip component using Alpine.js for state management.
|
|
12913
|
-
* Displays a help icon that shows a tooltip on hover/focus.
|
|
12914
|
-
*
|
|
12915
|
-
* @param props - Component props including text and optional position.
|
|
12916
|
-
*/
|
|
12917
|
-
var Tooltip = ({ text, position = "top" }) => {
|
|
12918
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
12919
|
-
class: "relative ml-1.5 flex items-center",
|
|
12920
|
-
"x-data": "{ isVisible: false }",
|
|
12921
|
-
children: [/* @__PURE__ */ jsx("button", {
|
|
12922
|
-
type: "button",
|
|
12923
|
-
class: "text-gray-400 hover:text-gray-500 dark:text-gray-500 dark:hover:text-gray-400 focus:outline-none flex items-center",
|
|
12924
|
-
"aria-label": "Help",
|
|
12925
|
-
"x-on:mouseenter": "isVisible = true",
|
|
12926
|
-
"x-on:mouseleave": "isVisible = false",
|
|
12927
|
-
"x-on:focus": "isVisible = true",
|
|
12928
|
-
"x-on:blur": "isVisible = false",
|
|
12929
|
-
tabindex: "0",
|
|
12930
|
-
children: /* @__PURE__ */ jsx("svg", {
|
|
12931
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
12932
|
-
fill: "none",
|
|
12933
|
-
viewBox: "0 0 24 24",
|
|
12934
|
-
"stroke-width": "1.5",
|
|
12935
|
-
stroke: "currentColor",
|
|
12936
|
-
class: "w-4 h-4",
|
|
12937
|
-
children: /* @__PURE__ */ jsx("path", {
|
|
12938
|
-
"stroke-linecap": "round",
|
|
12939
|
-
"stroke-linejoin": "round",
|
|
12940
|
-
d: "M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"
|
|
12941
|
-
})
|
|
12942
|
-
})
|
|
12943
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
12944
|
-
"x-show": "isVisible",
|
|
12945
|
-
"x-cloak": true,
|
|
12946
|
-
class: `absolute z-10 w-64 p-2 text-sm text-gray-500 bg-white border border-gray-200 rounded-lg shadow-sm dark:bg-gray-800 dark:border-gray-600 dark:text-gray-400 ${{
|
|
12947
|
-
top: "bottom-full left-1/2 transform -translate-x-1/2 -translate-y-1 mb-1",
|
|
12948
|
-
right: "left-full top-1/2 transform -translate-y-1/2 translate-x-1 ml-1",
|
|
12949
|
-
bottom: "top-full left-1/2 transform -translate-x-1/2 translate-y-1 mt-1",
|
|
12950
|
-
left: "right-full top-1/2 transform -translate-y-1/2 -translate-x-1 mr-1"
|
|
12951
|
-
}[position]}`,
|
|
12952
|
-
children: text
|
|
12953
|
-
})]
|
|
12954
|
-
});
|
|
12955
|
-
};
|
|
12956
|
-
//#endregion
|
|
12957
|
-
//#region src/web/components/ScrapeFormContent.tsx
|
|
12958
|
-
/**
|
|
12959
|
-
* Renders the form fields for queuing a new scrape job.
|
|
12960
|
-
* Includes basic fields (URL, Library, Version) and advanced options.
|
|
12961
|
-
* Supports pre-filling values when adding a new version to an existing library.
|
|
12962
|
-
*/
|
|
12963
|
-
var ScrapeFormContent = ({ defaultExcludePatterns, initialValues, mode = "new", scraperConfig }) => {
|
|
12964
|
-
const isAddVersionMode = mode === "add-version";
|
|
12965
|
-
const urlValue = initialValues?.url || "";
|
|
12966
|
-
const libraryValue = initialValues?.library || "";
|
|
12967
|
-
const maxPagesValue = initialValues?.maxPages?.toString() || "";
|
|
12968
|
-
const maxDepthValue = initialValues?.maxDepth?.toString() || "";
|
|
12969
|
-
const scopeValue = initialValues?.scope || "subpages";
|
|
12970
|
-
const includePatternsValue = initialValues?.includePatterns || "";
|
|
12971
|
-
const scrapeModeValue = initialValues?.scrapeMode || ScrapeMode.Auto;
|
|
12972
|
-
const followRedirectsValue = initialValues?.followRedirects ?? true;
|
|
12973
|
-
const ignoreErrorsValue = initialValues?.ignoreErrors ?? true;
|
|
12974
|
-
const preserveHashesValue = initialValues?.preserveHashes ?? scraperConfig?.preserveHashes ?? false;
|
|
12975
|
-
const excludePatternsText = initialValues?.excludePatterns !== void 0 ? initialValues.excludePatterns : defaultExcludePatterns?.join("\n") || "";
|
|
12976
|
-
const headersJson = JSON.stringify(initialValues?.headers || []);
|
|
12977
|
-
const closeButtonAttrs = isAddVersionMode ? {
|
|
12978
|
-
"hx-get": `/web/libraries/${encodeURIComponent(libraryValue)}/add-version-button`,
|
|
12979
|
-
"hx-target": "#add-version-form-container",
|
|
12980
|
-
"hx-swap": "innerHTML"
|
|
12981
|
-
} : {
|
|
12982
|
-
"hx-get": "/web/jobs/new-button",
|
|
12983
|
-
"hx-target": "#addJobForm",
|
|
12984
|
-
"hx-swap": "innerHTML"
|
|
12985
|
-
};
|
|
12986
|
-
const formTarget = isAddVersionMode ? "#add-version-form-container" : "#addJobForm";
|
|
12987
|
-
const title = isAddVersionMode ? "Add New Version" : "Add New Documentation";
|
|
12988
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
12989
|
-
class: "mt-4 p-4 bg-white dark:bg-gray-800 rounded-lg shadow border border-gray-300 dark:border-gray-600 relative animate-[fadeSlideIn_0.2s_ease-out]",
|
|
12990
|
-
children: [
|
|
12991
|
-
/* @__PURE__ */ jsx("button", {
|
|
12992
|
-
type: "button",
|
|
12993
|
-
...closeButtonAttrs,
|
|
12994
|
-
class: "absolute top-3 right-3 p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-full hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors duration-150",
|
|
12995
|
-
title: "Close",
|
|
12996
|
-
children: /* @__PURE__ */ jsx("svg", {
|
|
12997
|
-
class: "w-5 h-5",
|
|
12998
|
-
fill: "none",
|
|
12999
|
-
stroke: "currentColor",
|
|
13000
|
-
viewBox: "0 0 24 24",
|
|
13001
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
13002
|
-
children: /* @__PURE__ */ jsx("path", {
|
|
13003
|
-
"stroke-linecap": "round",
|
|
13004
|
-
"stroke-linejoin": "round",
|
|
13005
|
-
"stroke-width": "2",
|
|
13006
|
-
d: "M6 18L18 6M6 6l12 12"
|
|
13007
|
-
})
|
|
13008
|
-
})
|
|
13009
|
-
}),
|
|
13010
|
-
/* @__PURE__ */ jsx("h3", {
|
|
13011
|
-
class: "text-xl font-semibold text-gray-900 dark:text-white mb-2 pr-8",
|
|
13012
|
-
children: title
|
|
13013
|
-
}),
|
|
13014
|
-
/* @__PURE__ */ jsxs("form", {
|
|
13015
|
-
"hx-post": "/web/jobs/scrape",
|
|
13016
|
-
"hx-target": formTarget,
|
|
13017
|
-
"hx-swap": "innerHTML",
|
|
13018
|
-
class: "space-y-2",
|
|
13019
|
-
"data-initial-url": urlValue,
|
|
13020
|
-
"data-initial-headers": headersJson,
|
|
13021
|
-
"x-data": "{\n url: '',\n hasPath: false,\n headers: [],\n checkUrlPath() {\n try {\n const url = new URL(this.url);\n this.hasPath = url.pathname !== '/' && url.pathname !== '';\n } catch (e) {\n this.hasPath = false;\n }\n }\n }",
|
|
13022
|
-
"x-init": "\n url = $el.dataset.initialUrl || '';\n headers = JSON.parse($el.dataset.initialHeaders || '[]');\n checkUrlPath();\n ",
|
|
13023
|
-
children: [
|
|
13024
|
-
/* @__PURE__ */ jsx("input", {
|
|
13025
|
-
type: "hidden",
|
|
13026
|
-
name: "formMode",
|
|
13027
|
-
value: mode
|
|
13028
|
-
}),
|
|
13029
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
13030
|
-
/* @__PURE__ */ jsxs("div", {
|
|
13031
|
-
class: "flex items-center",
|
|
13032
|
-
children: [/* @__PURE__ */ jsx("label", {
|
|
13033
|
-
for: "url",
|
|
13034
|
-
class: "block text-sm font-medium text-gray-700 dark:text-gray-300",
|
|
13035
|
-
children: "URL"
|
|
13036
|
-
}), /* @__PURE__ */ jsx(Tooltip, { text: /* @__PURE__ */ jsxs("div", { children: [
|
|
13037
|
-
/* @__PURE__ */ jsx("p", { children: "Enter the URL of the documentation you want to scrape." }),
|
|
13038
|
-
/* @__PURE__ */ jsxs("p", {
|
|
13039
|
-
class: "mt-2",
|
|
13040
|
-
children: [
|
|
13041
|
-
"For local files/folders, you must use the",
|
|
13042
|
-
" ",
|
|
13043
|
-
/* @__PURE__ */ jsx("code", { children: "file://" }),
|
|
13044
|
-
" prefix and ensure the path is accessible to the server."
|
|
13045
|
-
]
|
|
13046
|
-
}),
|
|
13047
|
-
/* @__PURE__ */ jsxs("p", {
|
|
13048
|
-
class: "mt-2",
|
|
13049
|
-
children: [
|
|
13050
|
-
"If running in Docker, ",
|
|
13051
|
-
/* @__PURE__ */ jsx("b", { children: "mount the folder" }),
|
|
13052
|
-
" (see README for details)."
|
|
13053
|
-
]
|
|
13054
|
-
})
|
|
13055
|
-
] }) })]
|
|
13056
|
-
}),
|
|
13057
|
-
/* @__PURE__ */ jsx("input", {
|
|
13058
|
-
type: "url",
|
|
13059
|
-
name: "url",
|
|
13060
|
-
id: "url",
|
|
13061
|
-
required: true,
|
|
13062
|
-
"x-model": "url",
|
|
13063
|
-
"x-on:input": "checkUrlPath",
|
|
13064
|
-
"x-on:paste": "$nextTick(() => checkUrlPath())",
|
|
13065
|
-
placeholder: "https://docs.example.com/library/",
|
|
13066
|
-
class: "mt-0.5 block w-full px-2 py-1 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white"
|
|
13067
|
-
}),
|
|
13068
|
-
/* @__PURE__ */ jsx("div", {
|
|
13069
|
-
"x-show": "hasPath && !(url.startsWith('file://'))",
|
|
13070
|
-
"x-cloak": true,
|
|
13071
|
-
"x-transition:enter": "transition ease-out duration-300",
|
|
13072
|
-
"x-transition:enter-start": "opacity-0 transform -translate-y-2",
|
|
13073
|
-
"x-transition:enter-end": "opacity-100 transform translate-y-0",
|
|
13074
|
-
class: "mt-2",
|
|
13075
|
-
children: /* @__PURE__ */ jsx(Alert, {
|
|
13076
|
-
type: "info",
|
|
13077
|
-
message: "By default, only subpages under the given URL will be scraped. To scrape the whole website, adjust the 'Scope' option in Advanced Options."
|
|
13078
|
-
})
|
|
13079
|
-
})
|
|
13080
|
-
] }),
|
|
13081
|
-
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("div", {
|
|
13082
|
-
class: "flex items-center",
|
|
13083
|
-
children: [/* @__PURE__ */ jsx("label", {
|
|
13084
|
-
for: "library",
|
|
13085
|
-
class: "block text-sm font-medium text-gray-700 dark:text-gray-300",
|
|
13086
|
-
children: "Library Name"
|
|
13087
|
-
}), /* @__PURE__ */ jsx(Tooltip, { text: "The name of the library you're documenting. This will be used when searching." })]
|
|
13088
|
-
}), isAddVersionMode ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("input", {
|
|
13089
|
-
type: "hidden",
|
|
13090
|
-
name: "library",
|
|
13091
|
-
value: libraryValue
|
|
13092
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
13093
|
-
class: "mt-0.5 px-2 py-1 text-sm text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 rounded-md border border-gray-300 dark:border-gray-600",
|
|
13094
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
13095
|
-
safe: true,
|
|
13096
|
-
children: libraryValue
|
|
13097
|
-
})
|
|
13098
|
-
})] }) : /* @__PURE__ */ jsx("input", {
|
|
13099
|
-
type: "text",
|
|
13100
|
-
name: "library",
|
|
13101
|
-
id: "library",
|
|
13102
|
-
required: true,
|
|
13103
|
-
value: libraryValue,
|
|
13104
|
-
placeholder: "e.g. react, vue, express",
|
|
13105
|
-
class: "mt-0.5 block w-full px-2 py-1 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white"
|
|
13106
|
-
})] }),
|
|
13107
|
-
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("div", {
|
|
13108
|
-
class: "flex items-center",
|
|
13109
|
-
children: [/* @__PURE__ */ jsx("label", {
|
|
13110
|
-
for: "version",
|
|
13111
|
-
class: "block text-sm font-medium text-gray-700 dark:text-gray-300",
|
|
13112
|
-
children: "Version (optional)"
|
|
13113
|
-
}), /* @__PURE__ */ jsx(Tooltip, { text: "Specify the version of the library documentation you're indexing (e.g. 2.0.0). Leave empty or enter 'latest' to index without a specific version. This allows for version-specific searches." })]
|
|
13114
|
-
}), /* @__PURE__ */ jsx("input", {
|
|
13115
|
-
type: "text",
|
|
13116
|
-
name: "version",
|
|
13117
|
-
id: "version",
|
|
13118
|
-
placeholder: "e.g. 2.0.0 or leave empty for latest",
|
|
13119
|
-
class: "mt-0.5 block w-full max-w-sm px-2 py-1 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white"
|
|
13120
|
-
})] }),
|
|
13121
|
-
/* @__PURE__ */ jsxs("div", {
|
|
13122
|
-
class: "bg-gray-50 dark:bg-gray-900 p-2 rounded-md",
|
|
13123
|
-
"data-should-open": isAddVersionMode && (maxPagesValue || maxDepthValue || scopeValue !== "subpages" || includePatternsValue || excludePatternsText || scrapeModeValue !== ScrapeMode.Auto || preserveHashesValue) ? "true" : "false",
|
|
13124
|
-
"x-data": "{ open: false }",
|
|
13125
|
-
"x-init": "open = $el.dataset.shouldOpen === 'true'",
|
|
13126
|
-
children: [/* @__PURE__ */ jsxs("button", {
|
|
13127
|
-
type: "button",
|
|
13128
|
-
class: "w-full flex items-center gap-1.5 cursor-pointer text-sm font-medium text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 transition-colors",
|
|
13129
|
-
"x-on:click": "open = !open",
|
|
13130
|
-
children: [/* @__PURE__ */ jsx("svg", {
|
|
13131
|
-
class: "w-4 h-4 transform transition-transform duration-200",
|
|
13132
|
-
"x-bind:class": "{ 'rotate-90': open }",
|
|
13133
|
-
fill: "none",
|
|
13134
|
-
stroke: "currentColor",
|
|
13135
|
-
viewBox: "0 0 24 24",
|
|
13136
|
-
children: /* @__PURE__ */ jsx("path", {
|
|
13137
|
-
"stroke-linecap": "round",
|
|
13138
|
-
"stroke-linejoin": "round",
|
|
13139
|
-
"stroke-width": "2",
|
|
13140
|
-
d: "M9 5l7 7-7 7"
|
|
13141
|
-
})
|
|
13142
|
-
}), /* @__PURE__ */ jsx("span", { children: "Advanced Options" })]
|
|
13143
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
13144
|
-
"x-show": "open",
|
|
13145
|
-
"x-cloak": true,
|
|
13146
|
-
"x-collapse": true,
|
|
13147
|
-
class: "mt-2 space-y-2",
|
|
13148
|
-
children: [
|
|
13149
|
-
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("div", {
|
|
13150
|
-
class: "flex items-center",
|
|
13151
|
-
children: [/* @__PURE__ */ jsx("label", {
|
|
13152
|
-
for: "maxPages",
|
|
13153
|
-
class: "block text-sm font-medium text-gray-700 dark:text-gray-300",
|
|
13154
|
-
children: "Max Pages"
|
|
13155
|
-
}), /* @__PURE__ */ jsx(Tooltip, { text: `The maximum number of pages to scrape. Default is ${scraperConfig?.maxPages ?? 1e3}. Setting this too high may result in longer processing times.` })]
|
|
13156
|
-
}), /* @__PURE__ */ jsx("input", {
|
|
13157
|
-
type: "number",
|
|
13158
|
-
name: "maxPages",
|
|
13159
|
-
id: "maxPages",
|
|
13160
|
-
min: "1",
|
|
13161
|
-
placeholder: scraperConfig?.maxPages?.toString() || "1000",
|
|
13162
|
-
value: maxPagesValue,
|
|
13163
|
-
class: "mt-0.5 block w-full max-w-sm px-2 py-1 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white"
|
|
13164
|
-
})] }),
|
|
13165
|
-
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("div", {
|
|
13166
|
-
class: "flex items-center",
|
|
13167
|
-
children: [/* @__PURE__ */ jsx("label", {
|
|
13168
|
-
for: "maxDepth",
|
|
13169
|
-
class: "block text-sm font-medium text-gray-700 dark:text-gray-300",
|
|
13170
|
-
children: "Max Depth"
|
|
13171
|
-
}), /* @__PURE__ */ jsx(Tooltip, { text: `How many links deep the scraper should follow. Default is ${scraperConfig?.maxDepth || 3}. Higher values capture more content but increase processing time.` })]
|
|
13172
|
-
}), /* @__PURE__ */ jsx("input", {
|
|
13173
|
-
type: "number",
|
|
13174
|
-
name: "maxDepth",
|
|
13175
|
-
id: "maxDepth",
|
|
13176
|
-
min: "0",
|
|
13177
|
-
placeholder: scraperConfig?.maxDepth?.toString() || "3",
|
|
13178
|
-
value: maxDepthValue,
|
|
13179
|
-
class: "mt-0.5 block w-full max-w-sm px-2 py-1 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white"
|
|
13180
|
-
})] }),
|
|
13181
|
-
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("div", {
|
|
13182
|
-
class: "flex items-center",
|
|
13183
|
-
children: [/* @__PURE__ */ jsx("label", {
|
|
13184
|
-
for: "scope",
|
|
13185
|
-
class: "block text-sm font-medium text-gray-700 dark:text-gray-300",
|
|
13186
|
-
children: "Scope"
|
|
13187
|
-
}), /* @__PURE__ */ jsx(Tooltip, { text: /* @__PURE__ */ jsxs("div", { children: ["Controls which pages are scraped:", /* @__PURE__ */ jsxs("ul", {
|
|
13188
|
-
class: "list-disc pl-5",
|
|
13189
|
-
children: [
|
|
13190
|
-
/* @__PURE__ */ jsx("li", { children: "'Subpages' only scrapes under the given URL path," }),
|
|
13191
|
-
/* @__PURE__ */ jsx("li", { children: "'Hostname' scrapes all content on the same host (e.g., all of docs.example.com)," }),
|
|
13192
|
-
/* @__PURE__ */ jsx("li", { children: "'Domain' scrapes all content on the domain and its subdomains (e.g., all of example.com)." })
|
|
13193
|
-
]
|
|
13194
|
-
})] }) })]
|
|
13195
|
-
}), /* @__PURE__ */ jsxs("select", {
|
|
13196
|
-
name: "scope",
|
|
13197
|
-
id: "scope",
|
|
13198
|
-
class: "mt-0.5 block w-full max-w-sm pl-2 pr-10 py-1 text-base border border-gray-300 dark:border-gray-600 focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white",
|
|
13199
|
-
children: [
|
|
13200
|
-
/* @__PURE__ */ jsx("option", {
|
|
13201
|
-
value: "subpages",
|
|
13202
|
-
selected: scopeValue === "subpages",
|
|
13203
|
-
children: "Subpages (Default)"
|
|
13204
|
-
}),
|
|
13205
|
-
/* @__PURE__ */ jsx("option", {
|
|
13206
|
-
value: "hostname",
|
|
13207
|
-
selected: scopeValue === "hostname",
|
|
13208
|
-
children: "Hostname"
|
|
13209
|
-
}),
|
|
13210
|
-
/* @__PURE__ */ jsx("option", {
|
|
13211
|
-
value: "domain",
|
|
13212
|
-
selected: scopeValue === "domain",
|
|
13213
|
-
children: "Domain"
|
|
13214
|
-
})
|
|
13215
|
-
]
|
|
13216
|
-
})] }),
|
|
13217
|
-
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("div", {
|
|
13218
|
-
class: "flex items-center",
|
|
13219
|
-
children: [/* @__PURE__ */ jsx("label", {
|
|
13220
|
-
for: "includePatterns",
|
|
13221
|
-
class: "block text-sm font-medium text-gray-700 dark:text-gray-300",
|
|
13222
|
-
children: "Include Patterns"
|
|
13223
|
-
}), /* @__PURE__ */ jsx(Tooltip, { text: "Glob or regex patterns for URLs to include. One per line or comma-separated. Regex patterns must be wrapped in slashes, e.g. /pattern/." })]
|
|
13224
|
-
}), /* @__PURE__ */ jsx("textarea", {
|
|
13225
|
-
name: "includePatterns",
|
|
13226
|
-
id: "includePatterns",
|
|
13227
|
-
rows: "2",
|
|
13228
|
-
placeholder: "e.g. docs/* or /api\\/v1.*/",
|
|
13229
|
-
class: "mt-0.5 block w-full max-w-sm px-2 py-1 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white",
|
|
13230
|
-
safe: true,
|
|
13231
|
-
children: includePatternsValue
|
|
13232
|
-
})] }),
|
|
13233
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
13234
|
-
/* @__PURE__ */ jsxs("div", {
|
|
13235
|
-
class: "flex items-center",
|
|
13236
|
-
children: [/* @__PURE__ */ jsx("label", {
|
|
13237
|
-
for: "excludePatterns",
|
|
13238
|
-
class: "block text-sm font-medium text-gray-700 dark:text-gray-300",
|
|
13239
|
-
children: "Exclude Patterns"
|
|
13240
|
-
}), /* @__PURE__ */ jsx(Tooltip, { text: "Glob or regex patterns for URLs to exclude. One per line or comma-separated. Exclude takes precedence over include. Regex patterns must be wrapped in slashes, e.g. /pattern/. Edit or clear this field to customize exclusions." })]
|
|
13241
|
-
}),
|
|
13242
|
-
/* @__PURE__ */ jsx("textarea", {
|
|
13243
|
-
name: "excludePatterns",
|
|
13244
|
-
id: "excludePatterns",
|
|
13245
|
-
rows: "5",
|
|
13246
|
-
safe: true,
|
|
13247
|
-
class: "mt-0.5 block w-full max-w-sm px-2 py-1 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white font-mono text-xs",
|
|
13248
|
-
children: excludePatternsText
|
|
13249
|
-
}),
|
|
13250
|
-
/* @__PURE__ */ jsx("p", {
|
|
13251
|
-
class: "mt-1 text-xs text-gray-500 dark:text-gray-400",
|
|
13252
|
-
children: isAddVersionMode ? "Patterns from previous version. Edit as needed." : "Default patterns are pre-filled. Edit to customize or clear to exclude nothing."
|
|
13253
|
-
})
|
|
13254
|
-
] }),
|
|
13255
|
-
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("div", {
|
|
13256
|
-
class: "flex items-center",
|
|
13257
|
-
children: [/* @__PURE__ */ jsx("label", {
|
|
13258
|
-
for: "scrapeMode",
|
|
13259
|
-
class: "block text-sm font-medium text-gray-700 dark:text-gray-300",
|
|
13260
|
-
children: "Scrape Mode"
|
|
13261
|
-
}), /* @__PURE__ */ jsx(Tooltip, { text: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("ul", {
|
|
13262
|
-
class: "list-disc pl-5",
|
|
13263
|
-
children: [
|
|
13264
|
-
/* @__PURE__ */ jsx("li", { children: "'Auto' automatically selects the best method," }),
|
|
13265
|
-
/* @__PURE__ */ jsx("li", { children: "'Fetch' uses simple HTTP requests (faster but may miss dynamic content)," }),
|
|
13266
|
-
/* @__PURE__ */ jsx("li", { children: "'Playwright' uses a headless browser (slower but better for JS-heavy sites)." })
|
|
13267
|
-
]
|
|
13268
|
-
}) }) })]
|
|
13269
|
-
}), /* @__PURE__ */ jsxs("select", {
|
|
13270
|
-
name: "scrapeMode",
|
|
13271
|
-
id: "scrapeMode",
|
|
13272
|
-
class: "mt-0.5 block w-full max-w-sm pl-2 pr-10 py-1 text-base border border-gray-300 dark:border-gray-600 focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white",
|
|
13273
|
-
children: [
|
|
13274
|
-
/* @__PURE__ */ jsx("option", {
|
|
13275
|
-
value: ScrapeMode.Auto,
|
|
13276
|
-
selected: scrapeModeValue === ScrapeMode.Auto,
|
|
13277
|
-
children: "Auto (Default)"
|
|
13278
|
-
}),
|
|
13279
|
-
/* @__PURE__ */ jsx("option", {
|
|
13280
|
-
value: ScrapeMode.Fetch,
|
|
13281
|
-
selected: scrapeModeValue === ScrapeMode.Fetch,
|
|
13282
|
-
children: "Fetch"
|
|
13283
|
-
}),
|
|
13284
|
-
/* @__PURE__ */ jsx("option", {
|
|
13285
|
-
value: ScrapeMode.Playwright,
|
|
13286
|
-
selected: scrapeModeValue === ScrapeMode.Playwright,
|
|
13287
|
-
children: "Playwright"
|
|
13288
|
-
})
|
|
13289
|
-
]
|
|
13290
|
-
})] }),
|
|
13291
|
-
/* @__PURE__ */ jsxs("div", {
|
|
13292
|
-
class: "flex items-center",
|
|
13293
|
-
children: [
|
|
13294
|
-
/* @__PURE__ */ jsx("input", {
|
|
13295
|
-
id: "preserveHashes",
|
|
13296
|
-
name: "preserveHashes",
|
|
13297
|
-
type: "checkbox",
|
|
13298
|
-
checked: preserveHashesValue,
|
|
13299
|
-
class: "h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700"
|
|
13300
|
-
}),
|
|
13301
|
-
/* @__PURE__ */ jsx("label", {
|
|
13302
|
-
for: "preserveHashes",
|
|
13303
|
-
class: "ml-1 block text-sm text-gray-900 dark:text-gray-300",
|
|
13304
|
-
children: "Preserve Hash Routes"
|
|
13305
|
-
}),
|
|
13306
|
-
/* @__PURE__ */ jsx(Tooltip, { text: "Enable this for documentation sites that use hash fragments as client-side routes rather than same-page anchors." })
|
|
13307
|
-
]
|
|
13308
|
-
}),
|
|
13309
|
-
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("div", {
|
|
13310
|
-
class: "flex items-center mb-1",
|
|
13311
|
-
children: [/* @__PURE__ */ jsx("label", {
|
|
13312
|
-
class: "block text-sm font-medium text-gray-700 dark:text-gray-300",
|
|
13313
|
-
children: "Custom HTTP Headers"
|
|
13314
|
-
}), /* @__PURE__ */ jsx(Tooltip, { text: "Add custom HTTP headers (e.g., for authentication). These will be sent with every HTTP request." })]
|
|
13315
|
-
}), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("template", {
|
|
13316
|
-
"x-for": "(header, idx) in headers",
|
|
13317
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
13318
|
-
class: "flex space-x-2 mb-1",
|
|
13319
|
-
children: [
|
|
13320
|
-
/* @__PURE__ */ jsx("input", {
|
|
13321
|
-
type: "text",
|
|
13322
|
-
class: "w-1/3 px-2 py-1 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white text-xs",
|
|
13323
|
-
placeholder: "Header Name",
|
|
13324
|
-
"x-model": "header.name",
|
|
13325
|
-
required: true
|
|
13326
|
-
}),
|
|
13327
|
-
/* @__PURE__ */ jsx("span", {
|
|
13328
|
-
class: "text-gray-500",
|
|
13329
|
-
children: ":"
|
|
13330
|
-
}),
|
|
13331
|
-
/* @__PURE__ */ jsx("input", {
|
|
13332
|
-
type: "text",
|
|
13333
|
-
class: "w-1/2 px-2 py-1 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white text-xs",
|
|
13334
|
-
placeholder: "Header Value",
|
|
13335
|
-
"x-model": "header.value",
|
|
13336
|
-
required: true
|
|
13337
|
-
}),
|
|
13338
|
-
/* @__PURE__ */ jsx("button", {
|
|
13339
|
-
type: "button",
|
|
13340
|
-
class: "text-red-500 hover:text-red-700 text-xs",
|
|
13341
|
-
"x-on:click": "headers.splice(idx, 1)",
|
|
13342
|
-
children: "Remove"
|
|
13343
|
-
}),
|
|
13344
|
-
/* @__PURE__ */ jsx("input", {
|
|
13345
|
-
type: "hidden",
|
|
13346
|
-
name: "header[]",
|
|
13347
|
-
"x-bind:value": "header.name && header.value ? header.name + ':' + header.value : ''"
|
|
13348
|
-
})
|
|
13349
|
-
]
|
|
13350
|
-
})
|
|
13351
|
-
}), /* @__PURE__ */ jsx("button", {
|
|
13352
|
-
type: "button",
|
|
13353
|
-
class: "mt-1 px-2 py-0.5 bg-primary-100 dark:bg-primary-900 text-primary-700 dark:text-primary-200 rounded text-xs",
|
|
13354
|
-
"x-on:click": "headers.push({ name: '', value: '' })",
|
|
13355
|
-
children: "+ Add Header"
|
|
13356
|
-
})] })] }),
|
|
13357
|
-
/* @__PURE__ */ jsxs("div", {
|
|
13358
|
-
class: "flex items-center",
|
|
13359
|
-
children: [/* @__PURE__ */ jsx("input", {
|
|
13360
|
-
id: "followRedirects",
|
|
13361
|
-
name: "followRedirects",
|
|
13362
|
-
type: "checkbox",
|
|
13363
|
-
checked: followRedirectsValue,
|
|
13364
|
-
class: "h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700"
|
|
13365
|
-
}), /* @__PURE__ */ jsx("label", {
|
|
13366
|
-
for: "followRedirects",
|
|
13367
|
-
class: "ml-1 block text-sm text-gray-900 dark:text-gray-300",
|
|
13368
|
-
children: "Follow Redirects"
|
|
13369
|
-
})]
|
|
13370
|
-
}),
|
|
13371
|
-
/* @__PURE__ */ jsxs("div", {
|
|
13372
|
-
class: "flex items-center",
|
|
13373
|
-
children: [/* @__PURE__ */ jsx("input", {
|
|
13374
|
-
id: "ignoreErrors",
|
|
13375
|
-
name: "ignoreErrors",
|
|
13376
|
-
type: "checkbox",
|
|
13377
|
-
checked: ignoreErrorsValue,
|
|
13378
|
-
class: "h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700"
|
|
13379
|
-
}), /* @__PURE__ */ jsx("label", {
|
|
13380
|
-
for: "ignoreErrors",
|
|
13381
|
-
class: "ml-1 block text-sm text-gray-900 dark:text-gray-300",
|
|
13382
|
-
children: "Ignore Errors During Scraping"
|
|
13383
|
-
})]
|
|
13384
|
-
})
|
|
13385
|
-
]
|
|
13386
|
-
})]
|
|
13387
|
-
}),
|
|
13388
|
-
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("button", {
|
|
13389
|
-
type: "submit",
|
|
13390
|
-
class: "w-full flex justify-center py-1.5 px-3 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500",
|
|
13391
|
-
children: "Start Indexing"
|
|
13392
|
-
}) })
|
|
13393
|
-
]
|
|
13394
|
-
}),
|
|
13395
|
-
/* @__PURE__ */ jsx("div", {
|
|
13396
|
-
id: "job-response",
|
|
13397
|
-
class: "mt-2 text-sm"
|
|
13398
|
-
})
|
|
13399
|
-
]
|
|
13400
|
-
});
|
|
13401
|
-
};
|
|
13402
|
-
//#endregion
|
|
13403
|
-
//#region src/web/components/ScrapeForm.tsx
|
|
13404
|
-
/**
|
|
13405
|
-
* Wrapper component for the ScrapeFormContent.
|
|
13406
|
-
* Provides a container div, often used as a target for HTMX OOB swaps.
|
|
13407
|
-
*/
|
|
13408
|
-
var ScrapeForm = ({ defaultExcludePatterns, scraperConfig }) => /* @__PURE__ */ jsx("div", {
|
|
13409
|
-
id: "scrape-form-container",
|
|
13410
|
-
class: "animate-[fadeSlideIn_0.2s_ease-out]",
|
|
13411
|
-
children: /* @__PURE__ */ jsx(ScrapeFormContent, {
|
|
13412
|
-
defaultExcludePatterns,
|
|
13413
|
-
scraperConfig
|
|
13414
|
-
})
|
|
13415
|
-
});
|
|
13416
|
-
//#endregion
|
|
13417
|
-
//#region src/web/routes/jobs/new.tsx
|
|
13418
|
-
/**
|
|
13419
|
-
* Registers the API routes for creating new jobs.
|
|
13420
|
-
* @param server - The Fastify instance.
|
|
13421
|
-
* @param scrapeTool - The tool instance for scraping documents.
|
|
13422
|
-
*/
|
|
13423
|
-
function registerNewJobRoutes(server, scrapeTool, scraperConfig) {
|
|
13424
|
-
server.get("/web/jobs/new", async () => {
|
|
13425
|
-
return /* @__PURE__ */ jsx(ScrapeForm, {
|
|
13426
|
-
defaultExcludePatterns: DEFAULT_EXCLUSION_PATTERNS,
|
|
13427
|
-
scraperConfig
|
|
13428
|
-
});
|
|
13429
|
-
});
|
|
13430
|
-
server.get("/web/jobs/new-button", async () => {
|
|
13431
|
-
return /* @__PURE__ */ jsx(AddJobButton, {});
|
|
13432
|
-
});
|
|
13433
|
-
server.post("/web/jobs/scrape", async (request, reply) => {
|
|
13434
|
-
const body = request.body;
|
|
13435
|
-
reply.type("text/html");
|
|
13436
|
-
try {
|
|
13437
|
-
if (!body.url || !body.library) {
|
|
13438
|
-
reply.status(400);
|
|
13439
|
-
return /* @__PURE__ */ jsx(Alert, {
|
|
13440
|
-
type: "error",
|
|
13441
|
-
title: "Validation Error:",
|
|
13442
|
-
message: "URL and Library Name are required."
|
|
13443
|
-
});
|
|
13444
|
-
}
|
|
13445
|
-
function parsePatterns(input) {
|
|
13446
|
-
if (input === void 0) return void 0;
|
|
13447
|
-
if (input.trim() === "") return [];
|
|
13448
|
-
return input.split(/\n|,/).map((s) => s.trim()).filter((s) => s.length > 0);
|
|
13449
|
-
}
|
|
13450
|
-
function parseHeaders(input) {
|
|
13451
|
-
if (!input) return void 0;
|
|
13452
|
-
const arr = Array.isArray(input) ? input : [input];
|
|
13453
|
-
const headers = {};
|
|
13454
|
-
for (const entry of arr) {
|
|
13455
|
-
const idx = entry.indexOf(":");
|
|
13456
|
-
if (idx > 0) {
|
|
13457
|
-
const name = entry.slice(0, idx).trim();
|
|
13458
|
-
const value = entry.slice(idx + 1).trim();
|
|
13459
|
-
if (name) headers[name] = value;
|
|
13460
|
-
}
|
|
13461
|
-
}
|
|
13462
|
-
return Object.keys(headers).length > 0 ? headers : void 0;
|
|
13463
|
-
}
|
|
13464
|
-
const normalizedVersion = !body.version || body.version.trim() === "" || body.version.trim().toLowerCase() === "latest" ? null : body.version.trim();
|
|
13465
|
-
const scrapeOptions = {
|
|
13466
|
-
url: body.url,
|
|
13467
|
-
library: body.library,
|
|
13468
|
-
version: normalizedVersion,
|
|
13469
|
-
waitForCompletion: false,
|
|
13470
|
-
options: {
|
|
13471
|
-
maxPages: body.maxPages ? Number.parseInt(body.maxPages, 10) : void 0,
|
|
13472
|
-
maxDepth: body.maxDepth ? Number.parseInt(body.maxDepth, 10) : void 0,
|
|
13473
|
-
scope: body.scope,
|
|
13474
|
-
scrapeMode: body.scrapeMode,
|
|
13475
|
-
preserveHashes: body.preserveHashes === "on",
|
|
13476
|
-
followRedirects: body.followRedirects === "on",
|
|
13477
|
-
ignoreErrors: body.ignoreErrors === "on",
|
|
13478
|
-
includePatterns: parsePatterns(body.includePatterns),
|
|
13479
|
-
excludePatterns: parsePatterns(body.excludePatterns),
|
|
13480
|
-
headers: parseHeaders(body["header[]"])
|
|
13481
|
-
}
|
|
13482
|
-
};
|
|
13483
|
-
if ("jobId" in await scrapeTool.execute(scrapeOptions)) {
|
|
13484
|
-
const versionDisplay = normalizedVersion || "latest";
|
|
13485
|
-
reply.header("HX-Trigger", JSON.stringify({ toast: {
|
|
13486
|
-
message: `Indexing started for ${body.library}@${versionDisplay}`,
|
|
13487
|
-
type: "success"
|
|
13488
|
-
} }));
|
|
13489
|
-
if (body.formMode === "add-version") return /* @__PURE__ */ jsx(AddVersionButton, { libraryName: body.library });
|
|
13490
|
-
return /* @__PURE__ */ jsx(AddJobButton, {});
|
|
13491
|
-
}
|
|
13492
|
-
return /* @__PURE__ */ jsx(Alert, {
|
|
13493
|
-
type: "warning",
|
|
13494
|
-
message: "Job finished unexpectedly quickly."
|
|
13495
|
-
});
|
|
13496
|
-
} catch (error) {
|
|
13497
|
-
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
13498
|
-
logger.error(`❌ Scrape job submission failed: ${error}`);
|
|
13499
|
-
if (error instanceof ValidationError) reply.status(400);
|
|
13500
|
-
else reply.status(500);
|
|
13501
|
-
return /* @__PURE__ */ jsx(Alert, {
|
|
13502
|
-
type: "error",
|
|
13503
|
-
title: "Error:",
|
|
13504
|
-
message: /* @__PURE__ */ jsx("span", {
|
|
13505
|
-
safe: true,
|
|
13506
|
-
children: errorMessage
|
|
13507
|
-
})
|
|
13508
|
-
});
|
|
13509
|
-
}
|
|
13510
|
-
});
|
|
13511
|
-
}
|
|
13512
|
-
//#endregion
|
|
13513
|
-
//#region src/web/components/VersionDetailsRow.tsx
|
|
13514
|
-
/**
|
|
13515
|
-
* Renders details for a single library version in a row format.
|
|
13516
|
-
* Includes version, stats, and optional delete/refresh buttons.
|
|
13517
|
-
* @param props - Component props including version, libraryName, showDelete, and showRefresh flags.
|
|
13518
|
-
*/
|
|
13519
|
-
var VersionDetailsRow = ({ version, libraryName, showDelete = true, showRefresh = false }) => {
|
|
13520
|
-
const indexedDate = version.indexedAt ? new Date(version.indexedAt).toLocaleDateString() : "N/A";
|
|
13521
|
-
const versionLabel = version.ref.version || "Latest";
|
|
13522
|
-
const versionParam = version.ref.version || "";
|
|
13523
|
-
const preserveHashes = version.preserveHashes ?? false;
|
|
13524
|
-
const rowId = `row-${libraryName.replace(/[^a-zA-Z0-9-_]/g, "-")}-${versionParam.replace(/[^a-zA-Z0-9-_]/g, "-")}`;
|
|
13525
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
13526
|
-
id: rowId,
|
|
13527
|
-
class: "flex justify-between items-center py-1 border-b border-gray-200 dark:border-gray-600 last:border-b-0",
|
|
13528
|
-
"data-library-name": libraryName,
|
|
13529
|
-
"data-version-param": versionParam,
|
|
13530
|
-
"data-is-refreshing": isActiveStatus(version.status) ? "true" : "false",
|
|
13531
|
-
"x-data": "{ \n library: $el.dataset.libraryName, \n version: $el.dataset.versionParam, \n confirming: $el.dataset.confirming === 'true', \n isDeleting: false,\n isRefreshing: $el.dataset.isRefreshing === 'true',\n setRefreshing(val) {\n this.isRefreshing = !!val;\n this.$el.dataset.isRefreshing = val ? 'true' : 'false';\n },\n init() {\n const rowId = this.$el.id;\n const myLibrary = this.library;\n const myVersion = this.version;\n \n document.body.addEventListener('job-status-change', (e) => {\n const job = e.detail;\n const jobVersion = job.version || '';\n if (job.library === myLibrary && jobVersion === myVersion) {\n const newValue = ['queued', 'running'].includes(job.status);\n const el = document.getElementById(rowId);\n if (el) {\n el.dispatchEvent(new CustomEvent('set-refreshing', { detail: newValue, bubbles: true }));\n }\n }\n });\n }\n }",
|
|
13532
|
-
"x-on:set-refreshing": "setRefreshing($event.detail)",
|
|
13533
|
-
children: [
|
|
13534
|
-
/* @__PURE__ */ jsx("span", {
|
|
13535
|
-
class: "text-sm text-gray-900 dark:text-white w-1/4 truncate",
|
|
13536
|
-
title: versionLabel,
|
|
13537
|
-
children: version.ref.version ? /* @__PURE__ */ jsx(VersionBadge, { version: version.ref.version }) : /* @__PURE__ */ jsx("span", {
|
|
13538
|
-
class: "text-gray-600 dark:text-gray-400",
|
|
13539
|
-
children: "Latest"
|
|
13540
|
-
})
|
|
13541
|
-
}),
|
|
13542
|
-
/* @__PURE__ */ jsxs("div", {
|
|
13543
|
-
class: "flex space-x-2 text-sm text-gray-600 dark:text-gray-400 w-3/4 justify-end items-center",
|
|
13544
|
-
children: [
|
|
13545
|
-
/* @__PURE__ */ jsxs("span", {
|
|
13546
|
-
title: "Number of unique pages indexed",
|
|
13547
|
-
children: [
|
|
13548
|
-
"Pages:",
|
|
13549
|
-
" ",
|
|
13550
|
-
/* @__PURE__ */ jsx("span", {
|
|
13551
|
-
class: "font-semibold",
|
|
13552
|
-
safe: true,
|
|
13553
|
-
children: version.counts.uniqueUrls.toLocaleString()
|
|
13554
|
-
})
|
|
13555
|
-
]
|
|
13556
|
-
}),
|
|
13557
|
-
/* @__PURE__ */ jsxs("span", {
|
|
13558
|
-
title: "Number of indexed snippets",
|
|
13559
|
-
children: [
|
|
13560
|
-
"Chunks:",
|
|
13561
|
-
" ",
|
|
13562
|
-
/* @__PURE__ */ jsx("span", {
|
|
13563
|
-
class: "font-semibold",
|
|
13564
|
-
safe: true,
|
|
13565
|
-
children: version.counts.documents.toLocaleString()
|
|
13566
|
-
})
|
|
13567
|
-
]
|
|
13568
|
-
}),
|
|
13569
|
-
/* @__PURE__ */ jsxs("span", {
|
|
13570
|
-
title: "Date last indexed",
|
|
13571
|
-
children: [
|
|
13572
|
-
"Last Update:",
|
|
13573
|
-
" ",
|
|
13574
|
-
/* @__PURE__ */ jsx("span", {
|
|
13575
|
-
class: "font-semibold",
|
|
13576
|
-
safe: true,
|
|
13577
|
-
children: indexedDate
|
|
13578
|
-
})
|
|
13579
|
-
]
|
|
13580
|
-
})
|
|
13581
|
-
]
|
|
13582
|
-
}),
|
|
13583
|
-
/* @__PURE__ */ jsxs("div", {
|
|
13584
|
-
class: "flex items-center ml-2 space-x-1",
|
|
13585
|
-
children: [showRefresh && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("template", {
|
|
13586
|
-
"x-if": "!isRefreshing",
|
|
13587
|
-
children: /* @__PURE__ */ jsxs("button", {
|
|
13588
|
-
type: "button",
|
|
13589
|
-
class: "font-medium rounded-lg text-sm p-1 w-6 h-6 text-center inline-flex items-center justify-center transition-colors duration-150 ease-in-out text-gray-500 border border-gray-300 hover:bg-gray-100 hover:text-gray-700 focus:ring-4 focus:outline-none focus:ring-gray-200 dark:border-gray-600 dark:text-gray-400 dark:hover:text-white dark:focus:ring-gray-700 dark:hover:bg-gray-600",
|
|
13590
|
-
title: "Refresh this version (re-scrape changed pages)",
|
|
13591
|
-
"x-on:click": "\n isRefreshing = true;\n $root.dataset.isRefreshing = 'true';\n $el.dispatchEvent(new CustomEvent('trigger-refresh', { bubbles: true }));\n ",
|
|
13592
|
-
"hx-post": `/web/libraries/${encodeURIComponent(libraryName)}/versions/${encodeURIComponent(versionParam)}/refresh`,
|
|
13593
|
-
"hx-swap": "none",
|
|
13594
|
-
"hx-trigger": "trigger-refresh",
|
|
13595
|
-
"hx-vals": JSON.stringify({ preserveHashes }),
|
|
13596
|
-
children: [/* @__PURE__ */ jsx("svg", {
|
|
13597
|
-
class: "w-4 h-4",
|
|
13598
|
-
"aria-hidden": "true",
|
|
13599
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
13600
|
-
fill: "none",
|
|
13601
|
-
viewBox: "0 0 24 24",
|
|
13602
|
-
children: /* @__PURE__ */ jsx("path", {
|
|
13603
|
-
stroke: "currentColor",
|
|
13604
|
-
"stroke-linecap": "round",
|
|
13605
|
-
"stroke-linejoin": "round",
|
|
13606
|
-
"stroke-width": "2",
|
|
13607
|
-
d: "M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
|
|
13608
|
-
})
|
|
13609
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
13610
|
-
class: "sr-only",
|
|
13611
|
-
children: "Refresh version"
|
|
13612
|
-
})]
|
|
13613
|
-
})
|
|
13614
|
-
}), /* @__PURE__ */ jsx("template", {
|
|
13615
|
-
"x-if": "isRefreshing",
|
|
13616
|
-
children: /* @__PURE__ */ jsxs("button", {
|
|
13617
|
-
type: "button",
|
|
13618
|
-
class: "font-medium rounded-lg text-sm p-1 w-6 h-6 text-center inline-flex items-center justify-center transition-colors duration-150 ease-in-out text-gray-500 border border-gray-300 dark:border-gray-600 dark:text-gray-400",
|
|
13619
|
-
title: "Refresh in progress...",
|
|
13620
|
-
disabled: true,
|
|
13621
|
-
children: [/* @__PURE__ */ jsx(LoadingSpinner, { class: "text-gray-500 dark:text-gray-400" }), /* @__PURE__ */ jsx("span", {
|
|
13622
|
-
class: "sr-only",
|
|
13623
|
-
children: "Refreshing..."
|
|
13624
|
-
})]
|
|
13625
|
-
})
|
|
13626
|
-
})] }), showDelete && /* @__PURE__ */ jsxs("button", {
|
|
13627
|
-
type: "button",
|
|
13628
|
-
class: "font-medium rounded-lg text-sm p-1 min-w-6 h-6 text-center inline-flex items-center justify-center transition-colors duration-150 ease-in-out",
|
|
13629
|
-
title: "Remove this version",
|
|
13630
|
-
"x-bind:class": `confirming ? 'bg-red-600 text-white border-red-600 focus:ring-4 focus:outline-none focus:ring-red-300 dark:bg-red-700 dark:border-red-700 dark:focus:ring-red-800' : 'text-red-700 border border-red-700 hover:bg-red-700 hover:text-white focus:ring-4 focus:outline-none focus:ring-red-300 dark:border-red-500 dark:text-red-500 dark:hover:text-white dark:focus:ring-red-800 dark:hover:bg-red-500'`,
|
|
13631
|
-
"x-bind:disabled": "isDeleting",
|
|
13632
|
-
"x-on:click": "\n if (confirming) {\n isDeleting = true;\n window.confirmationManager.clear($root.id);\n $el.dispatchEvent(new CustomEvent('confirmed-delete', { bubbles: true }));\n } else {\n confirming = true;\n isDeleting = false;\n window.confirmationManager.start($root.id);\n }\n ",
|
|
13633
|
-
"hx-delete": `/web/libraries/${encodeURIComponent(libraryName)}/versions/${encodeURIComponent(versionParam)}`,
|
|
13634
|
-
"hx-target": `#${rowId}`,
|
|
13635
|
-
"hx-swap": "outerHTML",
|
|
13636
|
-
"hx-trigger": "confirmed-delete",
|
|
13637
|
-
children: [
|
|
13638
|
-
/* @__PURE__ */ jsxs("span", {
|
|
13639
|
-
"x-show": "!confirming && !isDeleting",
|
|
13640
|
-
children: [/* @__PURE__ */ jsx("svg", {
|
|
13641
|
-
class: "w-4 h-4",
|
|
13642
|
-
"aria-hidden": "true",
|
|
13643
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
13644
|
-
fill: "none",
|
|
13645
|
-
viewBox: "0 0 18 20",
|
|
13646
|
-
children: /* @__PURE__ */ jsx("path", {
|
|
13647
|
-
stroke: "currentColor",
|
|
13648
|
-
"stroke-linecap": "round",
|
|
13649
|
-
"stroke-linejoin": "round",
|
|
13650
|
-
"stroke-width": "2",
|
|
13651
|
-
d: "M1 5h16M7 8v8m4-8v8M7 1h4a1 1 0 0 1 1 1v3H6V2a1 1 0 0 1-1-1ZM3 5h12v13a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V5Z"
|
|
13652
|
-
})
|
|
13653
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
13654
|
-
class: "sr-only",
|
|
13655
|
-
children: "Remove version"
|
|
13656
|
-
})]
|
|
13657
|
-
}),
|
|
13658
|
-
/* @__PURE__ */ jsxs("span", {
|
|
13659
|
-
"x-show": "confirming && !isDeleting",
|
|
13660
|
-
class: "mx-1",
|
|
13661
|
-
children: ["Confirm?", /* @__PURE__ */ jsx("span", {
|
|
13662
|
-
class: "sr-only",
|
|
13663
|
-
children: "Confirm delete"
|
|
13664
|
-
})]
|
|
13665
|
-
}),
|
|
13666
|
-
/* @__PURE__ */ jsxs("span", {
|
|
13667
|
-
"x-show": "isDeleting",
|
|
13668
|
-
children: [/* @__PURE__ */ jsx(LoadingSpinner, {}), /* @__PURE__ */ jsx("span", {
|
|
13669
|
-
class: "sr-only",
|
|
13670
|
-
children: "Loading..."
|
|
13671
|
-
})]
|
|
13672
|
-
})
|
|
13673
|
-
]
|
|
13674
|
-
})]
|
|
13675
|
-
})
|
|
13676
|
-
]
|
|
13677
|
-
});
|
|
13678
|
-
};
|
|
13679
|
-
//#endregion
|
|
13680
|
-
//#region src/web/components/LibraryDetailCard.tsx
|
|
13681
|
-
/**
|
|
13682
|
-
* Renders a card displaying library details and its versions.
|
|
13683
|
-
* Includes Delete and Refresh buttons for each version, and an "Add New Version" button.
|
|
13684
|
-
* @param props - Component props including the library information.
|
|
13685
|
-
*/
|
|
13686
|
-
var LibraryDetailCard = ({ library }) => {
|
|
13687
|
-
const versions = library.versions || [];
|
|
13688
|
-
const latestVersion = versions[0];
|
|
13689
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
13690
|
-
class: "block p-4 bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-300 dark:border-gray-600 mb-4",
|
|
13691
|
-
children: [
|
|
13692
|
-
/* @__PURE__ */ jsx("div", {
|
|
13693
|
-
class: "flex justify-between items-start mb-1",
|
|
13694
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
13695
|
-
class: "min-w-0",
|
|
13696
|
-
children: [/* @__PURE__ */ jsx("h3", {
|
|
13697
|
-
class: "text-lg font-medium text-gray-900 dark:text-white",
|
|
13698
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
13699
|
-
safe: true,
|
|
13700
|
-
children: library.name
|
|
13701
|
-
})
|
|
13702
|
-
}), latestVersion?.sourceUrl ? /* @__PURE__ */ jsx("div", {
|
|
13703
|
-
class: "text-sm text-gray-500 dark:text-gray-400 truncate",
|
|
13704
|
-
children: /* @__PURE__ */ jsx("a", {
|
|
13705
|
-
href: latestVersion.sourceUrl,
|
|
13706
|
-
target: "_blank",
|
|
13707
|
-
class: "hover:underline",
|
|
13708
|
-
title: latestVersion.sourceUrl,
|
|
13709
|
-
safe: true,
|
|
13710
|
-
children: latestVersion.sourceUrl
|
|
13711
|
-
})
|
|
13712
|
-
}) : null]
|
|
13713
|
-
})
|
|
13714
|
-
}),
|
|
13715
|
-
/* @__PURE__ */ jsx("div", {
|
|
13716
|
-
class: "mt-2",
|
|
13717
|
-
id: "version-list",
|
|
13718
|
-
"hx-get": `/web/libraries/${encodeURIComponent(library.name)}/versions-list`,
|
|
13719
|
-
"hx-trigger": "library-change from:body",
|
|
13720
|
-
"hx-swap": "morph:innerHTML",
|
|
13721
|
-
children: versions.length > 0 ? versions.map((v) => {
|
|
13722
|
-
const adapted = {
|
|
13723
|
-
id: -1,
|
|
13724
|
-
ref: {
|
|
13725
|
-
library: library.name,
|
|
13726
|
-
version: v.version
|
|
13727
|
-
},
|
|
13728
|
-
status: v.status,
|
|
13729
|
-
progress: v.progress,
|
|
13730
|
-
counts: {
|
|
13731
|
-
documents: v.documentCount,
|
|
13732
|
-
uniqueUrls: v.uniqueUrlCount
|
|
13733
|
-
},
|
|
13734
|
-
indexedAt: v.indexedAt,
|
|
13735
|
-
sourceUrl: v.sourceUrl ?? void 0,
|
|
13736
|
-
preserveHashes: v.preserveHashes
|
|
13737
|
-
};
|
|
13738
|
-
return /* @__PURE__ */ jsx(VersionDetailsRow, {
|
|
13739
|
-
libraryName: library.name,
|
|
13740
|
-
version: adapted,
|
|
13741
|
-
showDelete: true,
|
|
13742
|
-
showRefresh: true
|
|
13743
|
-
});
|
|
13744
|
-
}) : /* @__PURE__ */ jsx("p", {
|
|
13745
|
-
class: "text-sm text-gray-500 dark:text-gray-400 italic",
|
|
13746
|
-
children: "No versions indexed."
|
|
13747
|
-
})
|
|
13748
|
-
}),
|
|
13749
|
-
/* @__PURE__ */ jsx("div", {
|
|
13750
|
-
id: "add-version-form-container",
|
|
13751
|
-
class: "mt-4",
|
|
13752
|
-
children: /* @__PURE__ */ jsx(AddVersionButton, { libraryName: library.name })
|
|
13753
|
-
})
|
|
13754
|
-
]
|
|
13755
|
-
});
|
|
13756
|
-
};
|
|
13757
|
-
//#endregion
|
|
13758
|
-
//#region src/web/components/LibrarySearchCard.tsx
|
|
13759
|
-
/**
|
|
13760
|
-
* Renders the search form card for a specific library.
|
|
13761
|
-
* Includes a version dropdown and query input.
|
|
13762
|
-
* @param props - Component props including the library information.
|
|
13763
|
-
*/
|
|
13764
|
-
var LibrarySearchCard = ({ library }) => {
|
|
13765
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
13766
|
-
class: "block p-4 bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-300 dark:border-gray-600 mb-4",
|
|
13767
|
-
children: [/* @__PURE__ */ jsxs("h2", {
|
|
13768
|
-
class: "text-xl font-semibold mb-2 text-gray-900 dark:text-white",
|
|
13769
|
-
safe: true,
|
|
13770
|
-
children: [
|
|
13771
|
-
"Search ",
|
|
13772
|
-
library.name,
|
|
13773
|
-
" Documentation"
|
|
13774
|
-
]
|
|
13775
|
-
}), /* @__PURE__ */ jsxs("form", {
|
|
13776
|
-
"hx-get": `/web/libraries/${encodeURIComponent(library.name)}/search`,
|
|
13777
|
-
"hx-target": "#searchResultsContainer .search-results",
|
|
13778
|
-
"hx-swap": "innerHTML",
|
|
13779
|
-
"hx-indicator": "#searchResultsContainer",
|
|
13780
|
-
class: "flex space-x-2",
|
|
13781
|
-
children: [
|
|
13782
|
-
/* @__PURE__ */ jsxs("select", {
|
|
13783
|
-
name: "version",
|
|
13784
|
-
class: "w-40 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500",
|
|
13785
|
-
children: [
|
|
13786
|
-
/* @__PURE__ */ jsx("option", {
|
|
13787
|
-
value: "",
|
|
13788
|
-
children: "Latest"
|
|
13789
|
-
}),
|
|
13790
|
-
" ",
|
|
13791
|
-
library.versions.map((version) => /* @__PURE__ */ jsx("option", {
|
|
13792
|
-
value: version.version || "latest",
|
|
13793
|
-
safe: true,
|
|
13794
|
-
children: version.version || "Latest"
|
|
13795
|
-
}))
|
|
13796
|
-
]
|
|
13797
|
-
}),
|
|
13798
|
-
/* @__PURE__ */ jsx("input", {
|
|
13799
|
-
type: "text",
|
|
13800
|
-
name: "query",
|
|
13801
|
-
placeholder: "Search query...",
|
|
13802
|
-
required: true,
|
|
13803
|
-
class: "flex-grow bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
|
13804
|
-
}),
|
|
13805
|
-
/* @__PURE__ */ jsxs("button", {
|
|
13806
|
-
type: "submit",
|
|
13807
|
-
class: "text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800 relative",
|
|
13808
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
13809
|
-
class: "search-text",
|
|
13810
|
-
children: "Search"
|
|
13811
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
13812
|
-
class: "spinner absolute inset-0 flex items-center justify-center",
|
|
13813
|
-
children: /* @__PURE__ */ jsx(LoadingSpinner, {})
|
|
13814
|
-
})]
|
|
13815
|
-
})
|
|
13816
|
-
]
|
|
13817
|
-
})]
|
|
13818
|
-
});
|
|
13819
|
-
};
|
|
13820
|
-
//#endregion
|
|
13821
|
-
//#region src/web/components/SearchResultItem.tsx
|
|
13822
|
-
/**
|
|
13823
|
-
* Renders a single search result item.
|
|
13824
|
-
* Converts markdown content to HTML using unified for markdown MIME types.
|
|
13825
|
-
* For other content types, renders as preformatted text.
|
|
13826
|
-
* @param props - Component props including the search result data.
|
|
13827
|
-
*/
|
|
13828
|
-
var SearchResultItem = async ({ result }) => {
|
|
13829
|
-
const isMarkdown = result.mimeType ? MimeTypeUtils.isMarkdown(result.mimeType) || MimeTypeUtils.isSupportedDocument(result.mimeType) : true;
|
|
13830
|
-
const purifier = DOMPurify(createJSDOM("").window);
|
|
13831
|
-
let contentElement;
|
|
13832
|
-
if (isMarkdown) {
|
|
13833
|
-
const file = await unified().use(remarkParse).use(remarkGfm).use(remarkHtml).process(result.content);
|
|
13834
|
-
const rawHtml = String(file);
|
|
13835
|
-
contentElement = /* @__PURE__ */ jsx("div", {
|
|
13836
|
-
class: "format dark:format-invert max-w-none",
|
|
13837
|
-
children: purifier.sanitize(rawHtml)
|
|
13838
|
-
});
|
|
13839
|
-
} else contentElement = /* @__PURE__ */ jsx("div", {
|
|
13840
|
-
class: "format dark:format-invert max-w-none",
|
|
13841
|
-
children: /* @__PURE__ */ jsx("pre", { children: /* @__PURE__ */ jsx("code", { children: escapeHtml(result.content) }) })
|
|
13842
|
-
});
|
|
13843
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
13844
|
-
class: "block px-4 py-2 bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-300 dark:border-gray-600 mb-2",
|
|
13845
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
13846
|
-
class: "text-sm text-gray-600 dark:text-gray-400 mb-1 flex items-center gap-2 min-w-0",
|
|
13847
|
-
children: [/* @__PURE__ */ jsx("a", {
|
|
13848
|
-
href: result.url,
|
|
13849
|
-
target: "_blank",
|
|
13850
|
-
rel: "noopener noreferrer",
|
|
13851
|
-
class: "underline underline-offset-4 flex-1 truncate",
|
|
13852
|
-
title: result.url,
|
|
13853
|
-
safe: true,
|
|
13854
|
-
children: result.url
|
|
13855
|
-
}), result.sourceMimeType || result.mimeType ? /* @__PURE__ */ jsx("span", {
|
|
13856
|
-
class: "text-xs opacity-75 font-mono",
|
|
13857
|
-
safe: true,
|
|
13858
|
-
children: result.sourceMimeType || result.mimeType
|
|
13859
|
-
}) : null]
|
|
13860
|
-
}), contentElement]
|
|
13861
|
-
});
|
|
13862
|
-
};
|
|
13863
|
-
//#endregion
|
|
13864
|
-
//#region src/web/components/SearchResultList.tsx
|
|
13865
|
-
/**
|
|
13866
|
-
* Renders the list of search results using SearchResultItem.
|
|
13867
|
-
* Displays a message if no results are found.
|
|
13868
|
-
* @param props - Component props including the array of search results.
|
|
13869
|
-
*/
|
|
13870
|
-
var SearchResultList = ({ results }) => {
|
|
13871
|
-
if (results.length === 0) return /* @__PURE__ */ jsx("p", {
|
|
13872
|
-
class: "text-gray-500 dark:text-gray-400 italic",
|
|
13873
|
-
children: "No results found."
|
|
13874
|
-
});
|
|
13875
|
-
return /* @__PURE__ */ jsx("div", {
|
|
13876
|
-
class: "space-y-2",
|
|
13877
|
-
children: results.map((result) => /* @__PURE__ */ jsx(SearchResultItem, { result }))
|
|
13878
|
-
});
|
|
13879
|
-
};
|
|
13880
|
-
//#endregion
|
|
13881
|
-
//#region src/web/components/SearchResultSkeletonItem.tsx
|
|
13882
|
-
/**
|
|
13883
|
-
* Renders a skeleton placeholder for a search result item.
|
|
13884
|
-
* Used to indicate loading state while search results are being fetched.
|
|
13885
|
-
*/
|
|
13886
|
-
var SearchResultSkeletonItem = () => /* @__PURE__ */ jsxs("div", {
|
|
13887
|
-
class: "block px-4 py-2 bg-white dark:bg-gray-800 rounded-lg shadow-sm mb-2 animate-pulse",
|
|
13888
|
-
children: [
|
|
13889
|
-
/* @__PURE__ */ jsx("div", { class: "h-[0.8em] bg-gray-200 dark:bg-gray-700 rounded w-3/4 mb-2" }),
|
|
13890
|
-
/* @__PURE__ */ jsx("div", { class: "h-[0.8em] bg-gray-200 dark:bg-gray-700 rounded w-full mb-2" }),
|
|
13891
|
-
/* @__PURE__ */ jsx("div", { class: "h-[0.8em] bg-gray-200 dark:bg-gray-700 rounded w-5/6" })
|
|
13892
|
-
]
|
|
13893
|
-
});
|
|
13894
|
-
//#endregion
|
|
13895
|
-
//#region src/web/routes/libraries/detail.tsx
|
|
13896
|
-
/**
|
|
13897
|
-
* Registers the route for displaying library details.
|
|
13898
|
-
* @param server - The Fastify instance.
|
|
13899
|
-
* @param listLibrariesTool - The tool instance for listing libraries.
|
|
13900
|
-
* @param searchTool - The tool instance for searching documentation.
|
|
13901
|
-
* @param scrapeTool - The tool instance for scraping documentation.
|
|
13902
|
-
* @param docService - The document management service for getting scraper options.
|
|
13903
|
-
*/
|
|
13904
|
-
function registerLibraryDetailRoutes(server, listLibrariesTool, searchTool, scrapeTool, docService) {
|
|
13905
|
-
server.get("/libraries/:libraryName", async (request, reply) => {
|
|
13906
|
-
const { libraryName } = request.params;
|
|
13907
|
-
try {
|
|
13908
|
-
const libraryInfo = (await listLibrariesTool.execute()).libraries.find((lib) => lib.name.toLowerCase() === libraryName.toLowerCase());
|
|
13909
|
-
if (!libraryInfo) {
|
|
13910
|
-
reply.status(404).send("Library not found");
|
|
13911
|
-
return;
|
|
13912
|
-
}
|
|
13913
|
-
reply.type("text/html; charset=utf-8");
|
|
13914
|
-
return "<!DOCTYPE html>" + /* @__PURE__ */ jsxs(Layout, {
|
|
13915
|
-
title: `MCP Docs - ${libraryInfo.name}`,
|
|
13916
|
-
children: [
|
|
13917
|
-
/* @__PURE__ */ jsx(LibraryDetailCard, { library: libraryInfo }),
|
|
13918
|
-
/* @__PURE__ */ jsx(LibrarySearchCard, { library: libraryInfo }),
|
|
13919
|
-
/* @__PURE__ */ jsxs("div", {
|
|
13920
|
-
id: "searchResultsContainer",
|
|
13921
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
13922
|
-
class: "search-skeleton space-y-2",
|
|
13923
|
-
children: [
|
|
13924
|
-
/* @__PURE__ */ jsx(SearchResultSkeletonItem, {}),
|
|
13925
|
-
/* @__PURE__ */ jsx(SearchResultSkeletonItem, {}),
|
|
13926
|
-
/* @__PURE__ */ jsx(SearchResultSkeletonItem, {})
|
|
13927
|
-
]
|
|
13928
|
-
}), /* @__PURE__ */ jsx("div", { class: "search-results" })]
|
|
13929
|
-
})
|
|
13930
|
-
]
|
|
13931
|
-
});
|
|
13932
|
-
} catch (error) {
|
|
13933
|
-
server.log.error(error, `Failed to load library details for ${libraryName}`);
|
|
13934
|
-
reply.status(500).send("Internal Server Error");
|
|
13935
|
-
}
|
|
13936
|
-
});
|
|
13937
|
-
server.get("/web/libraries/:libraryName/search", async (request, reply) => {
|
|
13938
|
-
const { libraryName } = request.params;
|
|
13939
|
-
const { query, version } = request.query;
|
|
13940
|
-
if (!query) {
|
|
13941
|
-
reply.status(400).send("Search query is required.");
|
|
13942
|
-
return;
|
|
13943
|
-
}
|
|
13944
|
-
const versionParam = version === "latest" ? void 0 : version;
|
|
13945
|
-
try {
|
|
13946
|
-
const searchResult = await searchTool.execute({
|
|
13947
|
-
library: libraryName,
|
|
13948
|
-
query,
|
|
13949
|
-
version: versionParam,
|
|
13950
|
-
limit: 10
|
|
13951
|
-
});
|
|
13952
|
-
reply.type("text/html; charset=utf-8");
|
|
13953
|
-
return /* @__PURE__ */ jsx(SearchResultList, { results: searchResult.results });
|
|
13954
|
-
} catch (error) {
|
|
13955
|
-
server.log.error(error, `Failed to search library ${libraryName}`);
|
|
13956
|
-
reply.type("text/html; charset=utf-8");
|
|
13957
|
-
return /* @__PURE__ */ jsx(Alert, {
|
|
13958
|
-
type: "error",
|
|
13959
|
-
message: error instanceof Error ? error.message : "An unexpected error occurred during the search."
|
|
13960
|
-
});
|
|
13961
|
-
}
|
|
13962
|
-
});
|
|
13963
|
-
server.get("/web/libraries/:libraryName/versions-list", async (request, reply) => {
|
|
13964
|
-
const { libraryName } = request.params;
|
|
13965
|
-
try {
|
|
13966
|
-
const libraryInfo = (await listLibrariesTool.execute()).libraries.find((lib) => lib.name.toLowerCase() === libraryName.toLowerCase());
|
|
13967
|
-
if (!libraryInfo) {
|
|
13968
|
-
reply.status(404).send("Library not found");
|
|
13969
|
-
return;
|
|
13970
|
-
}
|
|
13971
|
-
const versions = libraryInfo.versions || [];
|
|
13972
|
-
reply.type("text/html; charset=utf-8");
|
|
13973
|
-
if (versions.length === 0) return /* @__PURE__ */ jsx("p", {
|
|
13974
|
-
class: "text-sm text-gray-500 dark:text-gray-400 italic",
|
|
13975
|
-
children: "No versions indexed."
|
|
13976
|
-
});
|
|
13977
|
-
return /* @__PURE__ */ jsx(Fragment, { children: versions.map((v) => {
|
|
13978
|
-
const adapted = {
|
|
13979
|
-
id: -1,
|
|
13980
|
-
ref: {
|
|
13981
|
-
library: libraryInfo.name,
|
|
13982
|
-
version: v.version
|
|
13983
|
-
},
|
|
13984
|
-
status: v.status,
|
|
13985
|
-
progress: v.progress,
|
|
13986
|
-
counts: {
|
|
13987
|
-
documents: v.documentCount,
|
|
13988
|
-
uniqueUrls: v.uniqueUrlCount
|
|
13989
|
-
},
|
|
13990
|
-
indexedAt: v.indexedAt,
|
|
13991
|
-
sourceUrl: v.sourceUrl ?? void 0,
|
|
13992
|
-
preserveHashes: v.preserveHashes
|
|
13993
|
-
};
|
|
13994
|
-
return /* @__PURE__ */ jsx(VersionDetailsRow, {
|
|
13995
|
-
libraryName: libraryInfo.name,
|
|
13996
|
-
version: adapted,
|
|
13997
|
-
showDelete: true,
|
|
13998
|
-
showRefresh: true
|
|
13999
|
-
});
|
|
14000
|
-
}) });
|
|
14001
|
-
} catch (error) {
|
|
14002
|
-
logger.error(`Failed to fetch versions for ${libraryName}: ${error}`);
|
|
14003
|
-
reply.status(500).send("Internal Server Error");
|
|
14004
|
-
}
|
|
14005
|
-
});
|
|
14006
|
-
server.get("/web/libraries/:libraryName/add-version-button", async (request, reply) => {
|
|
14007
|
-
const { libraryName } = request.params;
|
|
14008
|
-
reply.type("text/html; charset=utf-8");
|
|
14009
|
-
return /* @__PURE__ */ jsx(AddVersionButton, { libraryName });
|
|
14010
|
-
});
|
|
14011
|
-
server.get("/web/libraries/:libraryName/add-version-form", async (request, reply) => {
|
|
14012
|
-
const { libraryName } = request.params;
|
|
14013
|
-
try {
|
|
14014
|
-
const libraryInfo = (await listLibrariesTool.execute()).libraries.find((lib) => lib.name.toLowerCase() === libraryName.toLowerCase());
|
|
14015
|
-
if (!libraryInfo) {
|
|
14016
|
-
reply.status(404).send("Library not found");
|
|
14017
|
-
return;
|
|
14018
|
-
}
|
|
14019
|
-
const latestVersion = (libraryInfo.versions || [])[0];
|
|
14020
|
-
let initialValues = { library: libraryName };
|
|
14021
|
-
if (latestVersion) {
|
|
14022
|
-
const libSummary = (await docService.listLibraries()).find((s) => s.library.toLowerCase() === libraryName.toLowerCase());
|
|
14023
|
-
if (libSummary) {
|
|
14024
|
-
const versionSummary = libSummary.versions.find((v) => v.ref.version === (latestVersion.version || "") || !latestVersion.version && v.ref.version === "");
|
|
14025
|
-
if (versionSummary) {
|
|
14026
|
-
const scraperConfig = await docService.getScraperOptions(versionSummary.id);
|
|
14027
|
-
if (scraperConfig) {
|
|
14028
|
-
const opts = scraperConfig.options;
|
|
14029
|
-
initialValues = {
|
|
14030
|
-
library: libraryName,
|
|
14031
|
-
url: scraperConfig.sourceUrl,
|
|
14032
|
-
maxPages: opts.maxPages,
|
|
14033
|
-
maxDepth: opts.maxDepth,
|
|
14034
|
-
scope: opts.scope,
|
|
14035
|
-
includePatterns: opts.includePatterns?.join("\n"),
|
|
14036
|
-
excludePatterns: opts.excludePatterns?.join("\n"),
|
|
14037
|
-
scrapeMode: opts.scrapeMode,
|
|
14038
|
-
headers: opts.headers ? Object.entries(opts.headers).map(([name, value]) => ({
|
|
14039
|
-
name,
|
|
14040
|
-
value
|
|
14041
|
-
})) : void 0,
|
|
14042
|
-
followRedirects: opts.followRedirects,
|
|
14043
|
-
ignoreErrors: opts.ignoreErrors,
|
|
14044
|
-
preserveHashes: opts.preserveHashes
|
|
14045
|
-
};
|
|
14046
|
-
}
|
|
14047
|
-
}
|
|
14048
|
-
}
|
|
14049
|
-
}
|
|
14050
|
-
reply.type("text/html; charset=utf-8");
|
|
14051
|
-
return /* @__PURE__ */ jsx(ScrapeFormContent, {
|
|
14052
|
-
initialValues,
|
|
14053
|
-
mode: "add-version"
|
|
14054
|
-
});
|
|
14055
|
-
} catch (error) {
|
|
14056
|
-
logger.error(`Failed to load add-version form for ${libraryName}: ${error}`);
|
|
14057
|
-
reply.type("text/html; charset=utf-8");
|
|
14058
|
-
return /* @__PURE__ */ jsx(Alert, {
|
|
14059
|
-
type: "error",
|
|
14060
|
-
message: "Failed to load the add version form."
|
|
14061
|
-
});
|
|
14062
|
-
}
|
|
14063
|
-
});
|
|
14064
|
-
}
|
|
14065
|
-
//#endregion
|
|
14066
|
-
//#region src/web/components/LibraryItem.tsx
|
|
14067
|
-
/**
|
|
14068
|
-
* Renders a card for a single library, listing its versions with details.
|
|
14069
|
-
* Uses VersionDetailsRow to display each version.
|
|
14070
|
-
* @param props - Component props including the library information.
|
|
14071
|
-
*/
|
|
14072
|
-
var LibraryItem = ({ library }) => {
|
|
14073
|
-
const versions = library.versions || [];
|
|
14074
|
-
const latestVersion = versions[0];
|
|
14075
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
14076
|
-
id: `library-item-${library.name}`,
|
|
14077
|
-
class: "block px-4 py-2 bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-300 dark:border-gray-600",
|
|
14078
|
-
children: [
|
|
14079
|
-
/* @__PURE__ */ jsx("h3", {
|
|
14080
|
-
class: "text-lg font-medium text-gray-900 dark:text-white",
|
|
14081
|
-
children: /* @__PURE__ */ jsx("a", {
|
|
14082
|
-
href: `/libraries/${encodeURIComponent(library.name)}`,
|
|
14083
|
-
class: "hover:underline",
|
|
14084
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
14085
|
-
safe: true,
|
|
14086
|
-
children: library.name
|
|
14087
|
-
})
|
|
14088
|
-
})
|
|
14089
|
-
}),
|
|
14090
|
-
latestVersion?.sourceUrl ? /* @__PURE__ */ jsx("div", {
|
|
14091
|
-
class: "text-sm text-gray-500 dark:text-gray-400 overflow-hidden h-5 @container",
|
|
14092
|
-
children: /* @__PURE__ */ jsx("a", {
|
|
14093
|
-
href: latestVersion.sourceUrl,
|
|
14094
|
-
target: "_blank",
|
|
14095
|
-
class: "inline-block whitespace-nowrap hover:underline hover:animate-[scrollText_2s_ease-in-out_forwards]",
|
|
14096
|
-
title: latestVersion.sourceUrl,
|
|
14097
|
-
safe: true,
|
|
14098
|
-
children: latestVersion.sourceUrl
|
|
14099
|
-
})
|
|
14100
|
-
}) : null,
|
|
14101
|
-
/* @__PURE__ */ jsx("div", {
|
|
14102
|
-
class: "mt-2",
|
|
14103
|
-
children: versions.length > 0 ? versions.map((v) => {
|
|
14104
|
-
const adapted = {
|
|
14105
|
-
id: -1,
|
|
14106
|
-
ref: {
|
|
14107
|
-
library: library.name,
|
|
14108
|
-
version: v.version
|
|
14109
|
-
},
|
|
14110
|
-
status: v.status,
|
|
14111
|
-
progress: v.progress,
|
|
14112
|
-
counts: {
|
|
14113
|
-
documents: v.documentCount,
|
|
14114
|
-
uniqueUrls: v.uniqueUrlCount
|
|
14115
|
-
},
|
|
14116
|
-
indexedAt: v.indexedAt,
|
|
14117
|
-
sourceUrl: v.sourceUrl ?? void 0
|
|
14118
|
-
};
|
|
14119
|
-
return /* @__PURE__ */ jsx(VersionDetailsRow, {
|
|
14120
|
-
libraryName: library.name,
|
|
14121
|
-
version: adapted
|
|
14122
|
-
});
|
|
14123
|
-
}) : /* @__PURE__ */ jsx("p", {
|
|
14124
|
-
class: "text-sm text-gray-500 dark:text-gray-400 italic",
|
|
14125
|
-
children: "No versions indexed."
|
|
14126
|
-
})
|
|
14127
|
-
})
|
|
14128
|
-
]
|
|
14129
|
-
});
|
|
14130
|
-
};
|
|
14131
|
-
//#endregion
|
|
14132
|
-
//#region src/web/components/LibraryList.tsx
|
|
14133
|
-
/**
|
|
14134
|
-
* Renders a list of LibraryItem components.
|
|
14135
|
-
* @param props - Component props including the array of libraries.
|
|
14136
|
-
*/
|
|
14137
|
-
var LibraryList = ({ libraries }) => {
|
|
14138
|
-
if (libraries.length === 0) return /* @__PURE__ */ jsx(Alert, {
|
|
14139
|
-
type: "info",
|
|
14140
|
-
title: "Welcome!",
|
|
14141
|
-
message: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
14142
|
-
"To get started, click",
|
|
14143
|
-
" ",
|
|
14144
|
-
/* @__PURE__ */ jsx("span", {
|
|
14145
|
-
class: "font-semibold",
|
|
14146
|
-
children: "Add New Documentation"
|
|
14147
|
-
}),
|
|
14148
|
-
" above and enter the URL of a documentation site to index. For more information, check the",
|
|
14149
|
-
" ",
|
|
14150
|
-
/* @__PURE__ */ jsx("a", {
|
|
14151
|
-
href: "https://grounded.tools",
|
|
14152
|
-
target: "_blank",
|
|
14153
|
-
rel: "noopener noreferrer",
|
|
14154
|
-
class: "font-medium underline hover:no-underline",
|
|
14155
|
-
children: "official website"
|
|
14156
|
-
}),
|
|
14157
|
-
"."
|
|
14158
|
-
] })
|
|
14159
|
-
});
|
|
14160
|
-
return /* @__PURE__ */ jsx("div", {
|
|
14161
|
-
id: "library-list",
|
|
14162
|
-
class: "space-y-2 animate-[fadeSlideIn_0.2s_ease-out]",
|
|
14163
|
-
children: libraries.map((library) => /* @__PURE__ */ jsx(LibraryItem, { library }))
|
|
14164
|
-
});
|
|
14165
|
-
};
|
|
14166
|
-
//#endregion
|
|
14167
|
-
//#region src/web/routes/libraries/list.tsx
|
|
14168
|
-
/**
|
|
14169
|
-
* Registers the API routes for library management.
|
|
14170
|
-
* @param server - The Fastify instance.
|
|
14171
|
-
* @param listLibrariesTool - The tool instance for listing libraries.
|
|
14172
|
-
* @param removeTool - The tool instance for removing library versions.
|
|
14173
|
-
* @param refreshVersionTool - The tool instance for refreshing library versions.
|
|
14174
|
-
*/
|
|
14175
|
-
function registerLibrariesRoutes(server, listLibrariesTool, removeTool, refreshVersionTool) {
|
|
14176
|
-
server.get("/web/libraries", async (_request, reply) => {
|
|
14177
|
-
try {
|
|
14178
|
-
const result = await listLibrariesTool.execute();
|
|
14179
|
-
reply.type("text/html; charset=utf-8");
|
|
14180
|
-
return /* @__PURE__ */ jsx(LibraryList, { libraries: result.libraries });
|
|
14181
|
-
} catch (error) {
|
|
14182
|
-
logger.error(`Failed to list libraries: ${error}`);
|
|
14183
|
-
reply.status(500).send("Internal Server Error");
|
|
14184
|
-
}
|
|
14185
|
-
});
|
|
14186
|
-
server.delete("/web/libraries/:libraryName/versions/:versionParam", async (request, reply) => {
|
|
14187
|
-
const { libraryName, versionParam } = request.params;
|
|
14188
|
-
const version = versionParam === "latest" ? void 0 : versionParam;
|
|
14189
|
-
try {
|
|
14190
|
-
await removeTool.execute({
|
|
14191
|
-
library: libraryName,
|
|
14192
|
-
version
|
|
14193
|
-
});
|
|
14194
|
-
if (!(await listLibrariesTool.execute()).libraries.some((lib) => lib.name.toLowerCase() === libraryName.toLowerCase())) reply.header("HX-Redirect", "/");
|
|
14195
|
-
reply.status(204).send();
|
|
14196
|
-
} catch (error) {
|
|
14197
|
-
logger.error(`Failed to remove ${libraryName}@${versionParam}: ${error}`);
|
|
14198
|
-
reply.status(500).send({ message: error.message || "Failed to remove version." });
|
|
14199
|
-
}
|
|
14200
|
-
});
|
|
14201
|
-
server.post("/web/libraries/:libraryName/versions/:versionParam/refresh", async (request, reply) => {
|
|
14202
|
-
const { libraryName, versionParam } = request.params;
|
|
14203
|
-
const version = versionParam === "latest" || versionParam === "" ? void 0 : versionParam;
|
|
14204
|
-
const preserveHashes = request.body?.preserveHashes === true || request.body?.preserveHashes === "true" ? true : request.body?.preserveHashes === false || request.body?.preserveHashes === "false" ? false : void 0;
|
|
14205
|
-
try {
|
|
14206
|
-
await refreshVersionTool.execute({
|
|
14207
|
-
library: libraryName,
|
|
14208
|
-
version,
|
|
14209
|
-
preserveHashes,
|
|
14210
|
-
waitForCompletion: false
|
|
14211
|
-
});
|
|
14212
|
-
const versionDisplay = version || "latest";
|
|
14213
|
-
reply.header("HX-Trigger", JSON.stringify({ toast: {
|
|
14214
|
-
message: `Refresh started for ${libraryName}@${versionDisplay}`,
|
|
14215
|
-
type: "success"
|
|
14216
|
-
} }));
|
|
14217
|
-
reply.status(204).send();
|
|
14218
|
-
} catch (error) {
|
|
14219
|
-
logger.error(`Failed to refresh ${libraryName}@${versionParam}: ${error}`);
|
|
14220
|
-
const errorMessage = error instanceof Error ? error.message : "Failed to refresh version.";
|
|
14221
|
-
reply.header("HX-Trigger", JSON.stringify({ toast: {
|
|
14222
|
-
message: errorMessage,
|
|
14223
|
-
type: "error"
|
|
14224
|
-
} }));
|
|
14225
|
-
reply.status(500).send();
|
|
14226
|
-
}
|
|
14227
|
-
});
|
|
14228
|
-
}
|
|
14229
|
-
//#endregion
|
|
14230
|
-
//#region src/web/components/AnalyticsCards.tsx
|
|
14231
|
-
/**
|
|
14232
|
-
* Formats a number for display, using K, M, B suffixes for large numbers.
|
|
14233
|
-
*/
|
|
14234
|
-
function formatNumber(num) {
|
|
14235
|
-
if (num >= 1e9) return `${(num / 1e9).toFixed(1)}B`;
|
|
14236
|
-
if (num >= 1e6) return `${(num / 1e6).toFixed(1)}M`;
|
|
14237
|
-
if (num >= 1e3) return `${(num / 1e3).toFixed(1)}K`;
|
|
14238
|
-
return num.toString();
|
|
14239
|
-
}
|
|
14240
|
-
/**
|
|
14241
|
-
* Displays three analytics cards: Total Chunks, Active Libraries, and Indexed Pages.
|
|
14242
|
-
*/
|
|
14243
|
-
var AnalyticsCards = ({ totalChunks, activeLibraries, activeVersions, indexedPages }) => /* @__PURE__ */ jsxs("div", {
|
|
14244
|
-
class: "grid grid-cols-1 sm:grid-cols-3 gap-4 mb-4 animate-[fadeSlideIn_0.2s_ease-out]",
|
|
14245
|
-
children: [
|
|
14246
|
-
/* @__PURE__ */ jsx("div", {
|
|
14247
|
-
class: "p-4 bg-white rounded-lg shadow dark:bg-gray-800 border border-gray-300 dark:border-gray-600",
|
|
14248
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
14249
|
-
class: "flex items-center",
|
|
14250
|
-
children: /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
|
|
14251
|
-
class: "text-sm font-medium text-gray-500 dark:text-gray-400",
|
|
14252
|
-
children: "Total Knowledge Base"
|
|
14253
|
-
}), /* @__PURE__ */ jsxs("p", {
|
|
14254
|
-
class: "text-xl font-semibold text-gray-900 dark:text-white",
|
|
14255
|
-
safe: true,
|
|
14256
|
-
children: [formatNumber(totalChunks), " Chunks"]
|
|
14257
|
-
})] })
|
|
14258
|
-
})
|
|
14259
|
-
}),
|
|
14260
|
-
/* @__PURE__ */ jsx("div", {
|
|
14261
|
-
class: "p-4 bg-white rounded-lg shadow dark:bg-gray-800 border border-gray-300 dark:border-gray-600",
|
|
14262
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
14263
|
-
class: "flex items-center",
|
|
14264
|
-
children: /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
|
|
14265
|
-
class: "text-sm font-medium text-gray-500 dark:text-gray-400",
|
|
14266
|
-
children: "Libraries / Versions"
|
|
14267
|
-
}), /* @__PURE__ */ jsxs("p", {
|
|
14268
|
-
class: "text-xl font-semibold text-gray-900 dark:text-white",
|
|
14269
|
-
children: [
|
|
14270
|
-
activeLibraries,
|
|
14271
|
-
" / ",
|
|
14272
|
-
activeVersions
|
|
14273
|
-
]
|
|
14274
|
-
})] })
|
|
14275
|
-
})
|
|
14276
|
-
}),
|
|
14277
|
-
/* @__PURE__ */ jsx("div", {
|
|
14278
|
-
class: "p-4 bg-white rounded-lg shadow dark:bg-gray-800 border border-gray-300 dark:border-gray-600",
|
|
14279
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
14280
|
-
class: "flex items-center",
|
|
14281
|
-
children: /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
|
|
14282
|
-
class: "text-sm font-medium text-gray-500 dark:text-gray-400",
|
|
14283
|
-
children: "Indexed Pages"
|
|
14284
|
-
}), /* @__PURE__ */ jsx("p", {
|
|
14285
|
-
class: "text-xl font-semibold text-gray-900 dark:text-white",
|
|
14286
|
-
safe: true,
|
|
14287
|
-
children: formatNumber(indexedPages)
|
|
14288
|
-
})] })
|
|
14289
|
-
})
|
|
14290
|
-
})
|
|
14291
|
-
]
|
|
14292
|
-
});
|
|
14293
|
-
//#endregion
|
|
14294
|
-
//#region src/web/routes/stats.tsx
|
|
14295
|
-
/**
|
|
14296
|
-
* Registers the API route for analytics stats.
|
|
14297
|
-
* @param server - The Fastify instance.
|
|
14298
|
-
* @param docService - The document management service for querying library data.
|
|
14299
|
-
*/
|
|
14300
|
-
function registerStatsRoute(server, docService) {
|
|
14301
|
-
server.get("/web/stats", async (_request, reply) => {
|
|
14302
|
-
try {
|
|
14303
|
-
const libraries = await docService.listLibraries();
|
|
14304
|
-
let totalChunks = 0;
|
|
14305
|
-
let indexedPages = 0;
|
|
14306
|
-
let activeVersions = 0;
|
|
14307
|
-
for (const lib of libraries) {
|
|
14308
|
-
activeVersions += lib.versions.length;
|
|
14309
|
-
for (const version of lib.versions) {
|
|
14310
|
-
totalChunks += version.counts.documents;
|
|
14311
|
-
indexedPages += version.counts.uniqueUrls;
|
|
14312
|
-
}
|
|
14313
|
-
}
|
|
14314
|
-
const activeLibraries = libraries.length;
|
|
14315
|
-
reply.type("text/html; charset=utf-8");
|
|
14316
|
-
return /* @__PURE__ */ jsx(AnalyticsCards, {
|
|
14317
|
-
totalChunks,
|
|
14318
|
-
activeLibraries,
|
|
14319
|
-
activeVersions,
|
|
14320
|
-
indexedPages
|
|
14321
|
-
});
|
|
14322
|
-
} catch (error) {
|
|
14323
|
-
logger.error(`Failed to fetch stats: ${error}`);
|
|
14324
|
-
reply.status(500).send("Internal Server Error");
|
|
14325
|
-
}
|
|
14326
|
-
});
|
|
14327
|
-
}
|
|
14328
|
-
//#endregion
|
|
14329
|
-
//#region src/services/webService.ts
|
|
14330
|
-
/**
|
|
14331
|
-
* Register web interface routes on a Fastify server instance.
|
|
14332
|
-
* This includes all human-facing UI routes.
|
|
14333
|
-
* Note: Static file serving and form body parsing are handled by AppServer.
|
|
14334
|
-
*/
|
|
14335
|
-
async function registerWebService(server, docService, pipeline, eventBus, appConfig) {
|
|
14336
|
-
const listLibrariesTool = new ListLibrariesTool(docService);
|
|
14337
|
-
const listJobsTool = new ListJobsTool(pipeline);
|
|
14338
|
-
const scrapeTool = new ScrapeTool(pipeline, appConfig.scraper);
|
|
14339
|
-
const removeTool = new RemoveTool(docService, pipeline);
|
|
14340
|
-
const refreshVersionTool = new RefreshVersionTool(pipeline);
|
|
14341
|
-
const searchTool = new SearchTool(docService);
|
|
14342
|
-
const cancelJobTool = new CancelJobTool(pipeline);
|
|
14343
|
-
const clearCompletedJobsTool = new ClearCompletedJobsTool(pipeline);
|
|
14344
|
-
registerIndexRoute(server);
|
|
14345
|
-
registerLibrariesRoutes(server, listLibrariesTool, removeTool, refreshVersionTool);
|
|
14346
|
-
registerLibraryDetailRoutes(server, listLibrariesTool, searchTool, scrapeTool, docService);
|
|
14347
|
-
registerJobListRoutes(server, listJobsTool);
|
|
14348
|
-
registerNewJobRoutes(server, scrapeTool, appConfig.scraper);
|
|
14349
|
-
registerCancelJobRoute(server, cancelJobTool);
|
|
14350
|
-
registerClearCompletedJobsRoute(server, clearCompletedJobsTool);
|
|
14351
|
-
registerEventsRoute(server, eventBus);
|
|
14352
|
-
registerStatsRoute(server, docService);
|
|
14353
|
-
}
|
|
14354
|
-
//#endregion
|
|
14355
|
-
//#region src/services/workerService.ts
|
|
14356
|
-
/**
|
|
14357
|
-
* Register worker service to enable embedded pipeline processing.
|
|
14358
|
-
* This starts the pipeline and configures callbacks for job processing.
|
|
14359
|
-
*
|
|
14360
|
-
* Note: This function is now deprecated in favor of configuring callbacks
|
|
14361
|
-
* in AppServer.setupPipelineEventBridge(). Keeping telemetry/logging here
|
|
14362
|
-
* would overwrite the event bus callbacks, breaking SSE notifications.
|
|
14363
|
-
* Telemetry and logging should be integrated into the event bus listeners instead.
|
|
14364
|
-
*/
|
|
14365
|
-
async function registerWorkerService(pipeline) {
|
|
14366
|
-
await pipeline.start();
|
|
14367
|
-
logger.debug("Worker service started");
|
|
14368
|
-
}
|
|
14369
|
-
/**
|
|
14370
|
-
* Stop the worker service and cleanup resources.
|
|
14371
|
-
*/
|
|
14372
|
-
async function stopWorkerService(pipeline) {
|
|
14373
|
-
await pipeline.stop();
|
|
14374
|
-
logger.debug("Worker service stopped");
|
|
14375
|
-
}
|
|
14376
|
-
//#endregion
|
|
14377
|
-
//#region src/utils/banner.ts
|
|
14378
|
-
/**
|
|
14379
|
-
* ASCII art banner for console startup display.
|
|
14380
|
-
* Uses ANSI colors: gray (dim) top line, bright white bottom line.
|
|
14381
|
-
*/
|
|
14382
|
-
var BANNER = ["\x1B[90m █▀▀ █▀█ █▀█ █ █ █▄ █ █▀▄ █▀▀ █▀▄ █▀▄ █▀█ █▀▀ █▀▀\x1B[0m", "\x1B[97m █▄█ █▀▄ █▄█ █▄█ █ ▀█ █▄▀ ██▄ █▄▀ █▄▀ █▄█ █▄▄ ▄▄█\x1B[0m"].join("\n");
|
|
14383
|
-
/**
|
|
14384
|
-
* Prints the startup banner to console.
|
|
14385
|
-
* Only call this for HTTP server startup, not stdio mode.
|
|
14386
|
-
*/
|
|
14387
|
-
function printBanner() {
|
|
14388
|
-
console.log();
|
|
14389
|
-
console.log(BANNER);
|
|
14390
|
-
console.log();
|
|
14391
|
-
}
|
|
14392
|
-
//#endregion
|
|
14393
|
-
//#region src/app/AppServer.ts
|
|
14394
|
-
/**
|
|
14395
|
-
* Central application server that can be configured to run different combinations of services.
|
|
14396
|
-
* This replaces the separate server implementations with a single, modular approach.
|
|
14397
|
-
*/
|
|
14398
|
-
/**
|
|
14399
|
-
* Central application server that provides modular service composition.
|
|
12333
|
+
* Central application server that provides modular service composition.
|
|
14400
12334
|
*/
|
|
14401
12335
|
var AppServer = class AppServer {
|
|
14402
12336
|
docService;
|
|
@@ -14407,6 +12341,7 @@ var AppServer = class AppServer {
|
|
|
14407
12341
|
authManager = null;
|
|
14408
12342
|
serverConfig;
|
|
14409
12343
|
appConfig;
|
|
12344
|
+
systemInfo;
|
|
14410
12345
|
remoteEventProxy = null;
|
|
14411
12346
|
wss = null;
|
|
14412
12347
|
constructor(docService, pipeline, eventBus, serverConfig, appConfig) {
|
|
@@ -14415,9 +12350,19 @@ var AppServer = class AppServer {
|
|
|
14415
12350
|
this.eventBus = eventBus;
|
|
14416
12351
|
this.serverConfig = serverConfig;
|
|
14417
12352
|
this.appConfig = appConfig;
|
|
12353
|
+
this.systemInfo = buildSystemInfo(serverConfig, appConfig);
|
|
14418
12354
|
this.server = Fastify({ logger: false });
|
|
14419
12355
|
}
|
|
14420
12356
|
/**
|
|
12357
|
+
* Builds a cheap, synchronous connectivity check for the remote worker.
|
|
12358
|
+
* Returns `undefined` when the worker is embedded (the field is only
|
|
12359
|
+
* meaningful — and only ever populated — in remote worker mode).
|
|
12360
|
+
*/
|
|
12361
|
+
buildIsWorkerConnected() {
|
|
12362
|
+
if (!this.serverConfig.externalWorkerUrl) return;
|
|
12363
|
+
return () => this.remoteEventProxy?.isActive() ?? false;
|
|
12364
|
+
}
|
|
12365
|
+
/**
|
|
14421
12366
|
* Validate the server configuration for invalid service combinations.
|
|
14422
12367
|
*/
|
|
14423
12368
|
validateConfig() {
|
|
@@ -14437,7 +12382,7 @@ var AppServer = class AppServer {
|
|
|
14437
12382
|
if (this.appConfig.app.telemetryEnabled && shouldEnableTelemetry()) try {
|
|
14438
12383
|
if (telemetry.isEnabled()) {
|
|
14439
12384
|
telemetry.setGlobalContext({
|
|
14440
|
-
appVersion: "
|
|
12385
|
+
appVersion: "3.0.0",
|
|
14441
12386
|
appPlatform: process.platform,
|
|
14442
12387
|
appNodeVersion: process.version,
|
|
14443
12388
|
appServicesEnabled: this.getActiveServicesList(),
|
|
@@ -14580,7 +12525,6 @@ var AppServer = class AppServer {
|
|
|
14580
12525
|
if (request.url.includes("/oauth") || request.url.includes("/auth") || request.url.includes("/register")) logger.debug(`${request.method} ${request.url} - Headers: ${JSON.stringify(request.headers)}`);
|
|
14581
12526
|
});
|
|
14582
12527
|
if (this.appConfig.auth.enabled && this.authManager) await this.setupAuthMetadataEndpoint();
|
|
14583
|
-
if (this.serverConfig.enableWebInterface) await this.enableWebInterface();
|
|
14584
12528
|
if (this.serverConfig.enableMcpServer) await this.enableMcpServer();
|
|
14585
12529
|
if (this.serverConfig.enableApiServer) await this.enableTrpcApi();
|
|
14586
12530
|
if (this.serverConfig.enableWorker) await this.enableWorker();
|
|
@@ -14597,13 +12541,6 @@ var AppServer = class AppServer {
|
|
|
14597
12541
|
}
|
|
14598
12542
|
}
|
|
14599
12543
|
/**
|
|
14600
|
-
* Enable web interface service.
|
|
14601
|
-
*/
|
|
14602
|
-
async enableWebInterface() {
|
|
14603
|
-
await registerWebService(this.server, this.docService, this.pipeline, this.eventBus, this.appConfig);
|
|
14604
|
-
logger.debug("Web interface service enabled");
|
|
14605
|
-
}
|
|
14606
|
-
/**
|
|
14607
12544
|
* Enable MCP server service.
|
|
14608
12545
|
*/
|
|
14609
12546
|
async enableMcpServer() {
|
|
@@ -14614,7 +12551,7 @@ var AppServer = class AppServer {
|
|
|
14614
12551
|
* Enable Pipeline RPC (tRPC) service.
|
|
14615
12552
|
*/
|
|
14616
12553
|
async enableTrpcApi() {
|
|
14617
|
-
await registerTrpcService(this.server, this.pipeline, this.docService, this.eventBus);
|
|
12554
|
+
await registerTrpcService(this.server, this.pipeline, this.docService, this.eventBus, this.systemInfo, this.buildIsWorkerConnected());
|
|
14618
12555
|
logger.debug("API server (tRPC) enabled");
|
|
14619
12556
|
}
|
|
14620
12557
|
/**
|
|
@@ -14629,7 +12566,7 @@ var AppServer = class AppServer {
|
|
|
14629
12566
|
this.wss?.emit("connection", ws, request);
|
|
14630
12567
|
});
|
|
14631
12568
|
});
|
|
14632
|
-
applyTrpcWebSocketHandler(this.wss, this.pipeline, this.docService, this.eventBus);
|
|
12569
|
+
applyTrpcWebSocketHandler(this.wss, this.pipeline, this.docService, this.eventBus, this.systemInfo, this.buildIsWorkerConnected());
|
|
14633
12570
|
logger.debug("WebSocket server initialized for tRPC subscriptions");
|
|
14634
12571
|
}
|
|
14635
12572
|
/**
|
|
@@ -14640,14 +12577,43 @@ var AppServer = class AppServer {
|
|
|
14640
12577
|
logger.debug("Worker service enabled");
|
|
14641
12578
|
}
|
|
14642
12579
|
/**
|
|
14643
|
-
* Setup static file serving with root prefix as fallback
|
|
12580
|
+
* Setup static file serving with root prefix as fallback, plus a SPA
|
|
12581
|
+
* fallback so client-side routing works for the React admin dashboard.
|
|
14644
12582
|
*/
|
|
14645
12583
|
async setupStaticFiles() {
|
|
12584
|
+
const publicRoot = path.join(getProjectRoot(), "public");
|
|
12585
|
+
const indexHtmlPath = path.join(publicRoot, "index.html");
|
|
12586
|
+
const serveSpaShell = this.createSpaShellHandler(indexHtmlPath);
|
|
14646
12587
|
await this.server.register(fastifyStatic, {
|
|
14647
|
-
root:
|
|
12588
|
+
root: publicRoot,
|
|
14648
12589
|
prefix: "/",
|
|
14649
12590
|
index: false
|
|
14650
12591
|
});
|
|
12592
|
+
this.server.get("/", serveSpaShell);
|
|
12593
|
+
this.server.setNotFoundHandler(async (request, reply) => {
|
|
12594
|
+
if (request.method !== "GET" || request.url.startsWith("/api")) {
|
|
12595
|
+
reply.code(404).send({ error: "Not Found" });
|
|
12596
|
+
return;
|
|
12597
|
+
}
|
|
12598
|
+
await serveSpaShell(request, reply);
|
|
12599
|
+
});
|
|
12600
|
+
}
|
|
12601
|
+
/**
|
|
12602
|
+
* Creates a request handler that responds with the built SPA's
|
|
12603
|
+
* `index.html`, falling back to a 404 if the file cannot be read (e.g. the
|
|
12604
|
+
* frontend has not been built yet).
|
|
12605
|
+
*/
|
|
12606
|
+
createSpaShellHandler(indexHtmlPath) {
|
|
12607
|
+
let cachedHtml = null;
|
|
12608
|
+
return async (_request, reply) => {
|
|
12609
|
+
try {
|
|
12610
|
+
if (cachedHtml === null) cachedHtml = await readFile(indexHtmlPath, "utf-8");
|
|
12611
|
+
reply.type("text/html").send(cachedHtml);
|
|
12612
|
+
} catch (error) {
|
|
12613
|
+
logger.error(`❌ Failed to serve SPA shell from ${indexHtmlPath}: ${error}`);
|
|
12614
|
+
reply.code(404).send({ error: "Not Found" });
|
|
12615
|
+
}
|
|
12616
|
+
};
|
|
14651
12617
|
}
|
|
14652
12618
|
/**
|
|
14653
12619
|
* Initialize OAuth2/OIDC authentication manager.
|
|
@@ -14685,7 +12651,7 @@ var AppServer = class AppServer {
|
|
|
14685
12651
|
const isWorkerOnly = this.serverConfig.enableWorker && !this.serverConfig.enableWebInterface && !this.serverConfig.enableMcpServer;
|
|
14686
12652
|
const isWebOnly = this.serverConfig.enableWebInterface && !this.serverConfig.enableWorker && !this.serverConfig.enableMcpServer;
|
|
14687
12653
|
const isMcpOnly = this.serverConfig.enableMcpServer && !this.serverConfig.enableWebInterface && !this.serverConfig.enableWorker;
|
|
14688
|
-
if (isWorkerOnly) logger.info(`🚀 Worker available at ${address}`);
|
|
12654
|
+
if (isWorkerOnly) logger.info(`🚀 Worker available at ${address}/api`);
|
|
14689
12655
|
else if (isWebOnly) logger.info(`🚀 Web interface available at ${address}`);
|
|
14690
12656
|
else if (isMcpOnly) logger.info(`🚀 MCP server available at ${address}`);
|
|
14691
12657
|
else logger.info(`🚀 Grounded Docs available at ${address}`);
|
|
@@ -18453,7 +16419,7 @@ function createWebCommand(cli) {
|
|
|
18453
16419
|
}) : await PipelineFactory.createPipeline(docService, eventBus, pipelineOptions), eventBus, createAppServerConfig({
|
|
18454
16420
|
enableWebInterface: true,
|
|
18455
16421
|
enableMcpServer: false,
|
|
18456
|
-
enableApiServer:
|
|
16422
|
+
enableApiServer: true,
|
|
18457
16423
|
enableWorker: !serverUrl,
|
|
18458
16424
|
port: appConfig.server.ports.web,
|
|
18459
16425
|
externalWorkerUrl: serverUrl,
|
|
@@ -18550,7 +16516,7 @@ function createCli(argv) {
|
|
|
18550
16516
|
let globalEventBus = null;
|
|
18551
16517
|
let globalTelemetryService = null;
|
|
18552
16518
|
const commandStartTimes = /* @__PURE__ */ new Map();
|
|
18553
|
-
const cli = registerGlobalOutputOptions(yargs(hideBin(argv))).scriptName("docs-mcp-server").strict().usage("Usage: $0 <command> [options]").version("
|
|
16519
|
+
const cli = registerGlobalOutputOptions(yargs(hideBin(argv))).scriptName("docs-mcp-server").strict().usage("Usage: $0 <command> [options]").version("3.0.0").option("verbose", {
|
|
18554
16520
|
type: "boolean",
|
|
18555
16521
|
description: "Enable verbose (debug) logging",
|
|
18556
16522
|
default: false
|
|
@@ -18600,7 +16566,7 @@ function createCli(argv) {
|
|
|
18600
16566
|
if (shouldEnableTelemetry() && telemetry.isEnabled()) {
|
|
18601
16567
|
const commandName = argv._[0]?.toString() || "default";
|
|
18602
16568
|
telemetry.setGlobalContext({
|
|
18603
|
-
appVersion: "
|
|
16569
|
+
appVersion: "3.0.0",
|
|
18604
16570
|
appPlatform: process.platform,
|
|
18605
16571
|
appNodeVersion: process.version,
|
|
18606
16572
|
appInterface: "cli",
|
|
@@ -18740,4 +16706,4 @@ async function runCli() {
|
|
|
18740
16706
|
//#endregion
|
|
18741
16707
|
export { cleanupCliCommand, runCli };
|
|
18742
16708
|
|
|
18743
|
-
//# sourceMappingURL=main-
|
|
16709
|
+
//# sourceMappingURL=main-qq21CGPf.js.map
|