@baruchiro/paperless-mcp
Version:
Model Context Protocol (MCP) server for interacting with Paperless-NGX document management system. Enables AI assistants to manage documents, tags, correspondents, and document types through the Paperless-NGX API.
51 lines (50 loc) • 2.91 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const node_test_1 = require("node:test");
const strict_1 = __importDefault(require("node:assert/strict"));
const resourceUri_1 = require("./resourceUri");
(0, node_test_1.test)("buildDocumentResourceUri mirrors the REST download path", () => {
const uri = (0, resourceUri_1.buildDocumentResourceUri)(1, "doc.pdf");
strict_1.default.match(uri, /^paperless:\/\/documents\/1\/download(\?|$)/);
});
(0, node_test_1.test)("buildDocumentResourceUri is canonical without filenames", () => {
const uri = (0, resourceUri_1.buildDocumentResourceUri)(1, "invoice 2026.pdf");
strict_1.default.equal(uri, "paperless://documents/1/download");
});
(0, node_test_1.test)("buildDocumentResourceUri ignores reserved chars in legacy filename input", () => {
const uri = (0, resourceUri_1.buildDocumentResourceUri)(42, "weird ?#&=+name.pdf");
const url = new URL(uri);
strict_1.default.equal(url.pathname, "/42/download");
strict_1.default.equal(url.search, "");
});
(0, node_test_1.test)("buildDocumentResourceUri ignores path separators in legacy filename input", () => {
// A filename containing a slash must not become an extra path segment.
const uri = (0, resourceUri_1.buildDocumentResourceUri)(7, "sub/dir/file.pdf");
const url = new URL(uri);
strict_1.default.equal(url.pathname, "/7/download");
strict_1.default.equal(url.search, "");
});
(0, node_test_1.test)("buildDocumentResourceUri keeps unicode filenames out of the URI", () => {
const original = "Rechnüng — März.pdf";
const uri = (0, resourceUri_1.buildDocumentResourceUri)(1, original);
const url = new URL(uri);
strict_1.default.equal(url.pathname, "/1/download");
strict_1.default.equal(url.search, "");
});
(0, node_test_1.test)("buildDocumentResourceUri preserves original download intent", () => {
strict_1.default.equal((0, resourceUri_1.buildDocumentResourceUri)(1, { original: true }), "paperless://documents/1/download?original=true");
});
(0, node_test_1.test)("buildDocumentResourceUri produces a valid URL", () => {
const uri = (0, resourceUri_1.buildDocumentResourceUri)(1, "Some File.pdf");
strict_1.default.doesNotThrow(() => new URL(uri));
});
(0, node_test_1.test)("buildThumbnailResourceUri mirrors the REST thumb path", () => {
strict_1.default.equal((0, resourceUri_1.buildThumbnailResourceUri)(1), "paperless://documents/1/thumb");
strict_1.default.equal((0, resourceUri_1.buildThumbnailResourceUri)(123), "paperless://documents/123/thumb");
});
(0, node_test_1.test)("buildThumbnailResourceUri produces a valid URL", () => {
strict_1.default.doesNotThrow(() => new URL((0, resourceUri_1.buildThumbnailResourceUri)(99)));
});