@retiform/paperless-mcp 2.3.5 → 2.4.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.
Files changed (50) hide show
  1. package/README.md +301 -4
  2. package/build/api/PaperlessAPI.js +1 -6
  3. package/build/search/build-outcome.d.ts +28 -0
  4. package/build/search/build-outcome.js +31 -0
  5. package/build/search/chunk.d.ts +16 -0
  6. package/build/search/chunk.js +64 -0
  7. package/build/search/config.d.ts +120 -0
  8. package/build/search/config.js +264 -0
  9. package/build/search/embedder.d.ts +346 -0
  10. package/build/search/embedder.js +734 -0
  11. package/build/search/rank.d.ts +11 -0
  12. package/build/search/rank.js +87 -0
  13. package/build/search/store.d.ts +406 -0
  14. package/build/search/store.js +847 -0
  15. package/build/search/sync.d.ts +204 -0
  16. package/build/search/sync.js +819 -0
  17. package/build/search/webhook.d.ts +193 -0
  18. package/build/search/webhook.js +445 -0
  19. package/build/server.d.ts +29 -0
  20. package/build/server.js +77 -0
  21. package/build/tools/documents.d.ts +13 -3
  22. package/build/tools/documents.js +23 -6
  23. package/build/tools/search.d.ts +518 -0
  24. package/build/tools/search.js +1199 -0
  25. package/build/tools/utils/middlewares.d.ts +5 -0
  26. package/build/tools/utils/middlewares.js +282 -9
  27. package/package.json +10 -3
  28. package/paperless-mcp.dxt +0 -0
  29. package/build/api/documentEnhancer.test.d.ts +0 -1
  30. package/build/api/documentEnhancer.test.js +0 -80
  31. package/build/resources/documents.test.d.ts +0 -1
  32. package/build/resources/documents.test.js +0 -124
  33. package/build/server.test.d.ts +0 -1
  34. package/build/server.test.js +0 -54
  35. package/build/tools/boundedContent.test.d.ts +0 -1
  36. package/build/tools/boundedContent.test.js +0 -565
  37. package/build/tools/documents.test.d.ts +0 -1
  38. package/build/tools/documents.test.js +0 -658
  39. package/build/tools/mail.test.d.ts +0 -1
  40. package/build/tools/mail.test.js +0 -212
  41. package/build/tools/notes.test.d.ts +0 -1
  42. package/build/tools/notes.test.js +0 -177
  43. package/build/tools/schemaCompat.test.d.ts +0 -1
  44. package/build/tools/schemaCompat.test.js +0 -59
  45. package/build/tools/utils/monetary.test.d.ts +0 -1
  46. package/build/tools/utils/monetary.test.js +0 -25
  47. package/build/tools/utils/resourceUri.test.d.ts +0 -1
  48. package/build/tools/utils/resourceUri.test.js +0 -50
  49. package/build/tools/utils/selectFields.test.d.ts +0 -1
  50. package/build/tools/utils/selectFields.test.js +0 -164
@@ -1,164 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const node_test_1 = require("node:test");
16
- const strict_1 = __importDefault(require("node:assert/strict"));
17
- const selectFields_1 = require("./selectFields");
18
- const LEGACY_SELECT_FIELD = {
19
- id: 2,
20
- name: "Retention period",
21
- data_type: "select",
22
- extra_data: { select_options: ["1 year", "7 years", "2 years"], default_currency: null },
23
- document_count: 10,
24
- };
25
- const OBJECT_SELECT_FIELD = {
26
- id: 3,
27
- name: "Priority",
28
- data_type: "select",
29
- extra_data: {
30
- select_options: [
31
- { id: "abc123", label: "Low" },
32
- { id: "def456", label: "High" },
33
- ],
34
- },
35
- document_count: 5,
36
- };
37
- const STRING_FIELD = {
38
- id: 4,
39
- name: "Reference",
40
- data_type: "string",
41
- document_count: 1,
42
- };
43
- (0, node_test_1.describe)("resolveSelectCustomFieldValue", () => {
44
- (0, node_test_1.test)("translates a label to its zero-based index (pre-2.17 string options)", () => {
45
- strict_1.default.equal((0, selectFields_1.resolveSelectCustomFieldValue)(LEGACY_SELECT_FIELD, "1 year"), 0);
46
- strict_1.default.equal((0, selectFields_1.resolveSelectCustomFieldValue)(LEGACY_SELECT_FIELD, "7 years"), 1);
47
- strict_1.default.equal((0, selectFields_1.resolveSelectCustomFieldValue)(LEGACY_SELECT_FIELD, "2 years"), 2);
48
- });
49
- (0, node_test_1.test)("translates a label to its zero-based index (2.17+ object options)", () => {
50
- strict_1.default.equal((0, selectFields_1.resolveSelectCustomFieldValue)(OBJECT_SELECT_FIELD, "Low"), 0);
51
- strict_1.default.equal((0, selectFields_1.resolveSelectCustomFieldValue)(OBJECT_SELECT_FIELD, "High"), 1);
52
- });
53
- (0, node_test_1.test)("passes through an already-encoded index (pre-2.17)", () => {
54
- strict_1.default.equal((0, selectFields_1.resolveSelectCustomFieldValue)(LEGACY_SELECT_FIELD, 1), 1);
55
- });
56
- (0, node_test_1.test)("maps an option id back to its zero-based index (2.17+ round-trip)", () => {
57
- strict_1.default.equal((0, selectFields_1.resolveSelectCustomFieldValue)(OBJECT_SELECT_FIELD, "def456"), 1);
58
- });
59
- (0, node_test_1.test)("resolves both the label and the option id to the same index", () => {
60
- strict_1.default.equal((0, selectFields_1.resolveSelectCustomFieldValue)(OBJECT_SELECT_FIELD, "Low"), 0);
61
- strict_1.default.equal((0, selectFields_1.resolveSelectCustomFieldValue)(OBJECT_SELECT_FIELD, "abc123"), 0);
62
- });
63
- (0, node_test_1.test)("returns null unchanged so the field can be cleared", () => {
64
- strict_1.default.equal((0, selectFields_1.resolveSelectCustomFieldValue)(LEGACY_SELECT_FIELD, null), null);
65
- });
66
- (0, node_test_1.test)("leaves non-select field values untouched", () => {
67
- strict_1.default.equal((0, selectFields_1.resolveSelectCustomFieldValue)(STRING_FIELD, "1 year"), "1 year");
68
- });
69
- (0, node_test_1.test)("throws an actionable error listing valid options for an unknown value", () => {
70
- strict_1.default.throws(() => (0, selectFields_1.resolveSelectCustomFieldValue)(LEGACY_SELECT_FIELD, "forever"), (err) => {
71
- strict_1.default.match(err.message, /forever/);
72
- strict_1.default.match(err.message, /Retention period/);
73
- strict_1.default.match(err.message, /1 year/);
74
- strict_1.default.match(err.message, /7 years/);
75
- return true;
76
- });
77
- });
78
- (0, node_test_1.test)("rejects an out-of-range index rather than forwarding it", () => {
79
- strict_1.default.throws(() => (0, selectFields_1.resolveSelectCustomFieldValue)(LEGACY_SELECT_FIELD, 9));
80
- });
81
- (0, node_test_1.test)("throws on a value that matches one option's label and another's id", () => {
82
- const collidingField = {
83
- id: 5,
84
- name: "Collision",
85
- data_type: "select",
86
- extra_data: {
87
- select_options: [
88
- { id: "High", label: "Low" },
89
- { id: "xyz789", label: "High" },
90
- ],
91
- },
92
- document_count: 0,
93
- };
94
- strict_1.default.throws(() => (0, selectFields_1.resolveSelectCustomFieldValue)(collidingField, "High"), /Ambiguous/);
95
- });
96
- });
97
- (0, node_test_1.describe)("resolveSelectCustomFieldValue with stored encoding (bulk_edit path)", () => {
98
- (0, node_test_1.test)("translates a label to the option id on 2.17+ object options", () => {
99
- strict_1.default.equal((0, selectFields_1.resolveSelectCustomFieldValue)(OBJECT_SELECT_FIELD, "Low", "stored"), "abc123");
100
- strict_1.default.equal((0, selectFields_1.resolveSelectCustomFieldValue)(OBJECT_SELECT_FIELD, "High", "stored"), "def456");
101
- });
102
- (0, node_test_1.test)("translates a label to the index on pre-2.17 string options (no id to store)", () => {
103
- strict_1.default.equal((0, selectFields_1.resolveSelectCustomFieldValue)(LEGACY_SELECT_FIELD, "7 years", "stored"), 1);
104
- });
105
- (0, node_test_1.test)("passes an already-stored option id through unchanged", () => {
106
- strict_1.default.equal((0, selectFields_1.resolveSelectCustomFieldValue)(OBJECT_SELECT_FIELD, "def456", "stored"), "def456");
107
- });
108
- (0, node_test_1.test)("maps an option index to its stored id (2.17+)", () => {
109
- strict_1.default.equal((0, selectFields_1.resolveSelectCustomFieldValue)(OBJECT_SELECT_FIELD, 1, "stored"), "def456");
110
- });
111
- });
112
- function apiReturning(fields) {
113
- const requestedIds = [];
114
- const fieldMap = new Map(fields.map((field) => [field.id, field]));
115
- const api = {
116
- getCustomField: (id) => __awaiter(this, void 0, void 0, function* () {
117
- requestedIds.push(id);
118
- const field = fieldMap.get(id);
119
- if (!field)
120
- throw new Error(`custom field ${id} not found`);
121
- return field;
122
- }),
123
- };
124
- return { api, requestedIds };
125
- }
126
- (0, node_test_1.describe)("resolveSelectCustomFieldValues", () => {
127
- (0, node_test_1.test)("returns undefined/empty input unchanged without fetching definitions", () => __awaiter(void 0, void 0, void 0, function* () {
128
- const { api, requestedIds } = apiReturning([]);
129
- strict_1.default.equal(yield (0, selectFields_1.resolveSelectCustomFieldValues)(api, undefined), undefined);
130
- strict_1.default.deepEqual(yield (0, selectFields_1.resolveSelectCustomFieldValues)(api, []), []);
131
- strict_1.default.deepEqual(requestedIds, []);
132
- }));
133
- (0, node_test_1.test)("resolves select labels and leaves other fields untouched", () => __awaiter(void 0, void 0, void 0, function* () {
134
- const { api } = apiReturning([LEGACY_SELECT_FIELD, STRING_FIELD]);
135
- const resolved = yield (0, selectFields_1.resolveSelectCustomFieldValues)(api, [
136
- { field: 2, value: "2 years" },
137
- { field: 4, value: "INV-001" },
138
- ]);
139
- strict_1.default.deepEqual(resolved, [
140
- { field: 2, value: 2 },
141
- { field: 4, value: "INV-001" },
142
- ]);
143
- }));
144
- (0, node_test_1.test)("applies the stored encoding (option id) when requested", () => __awaiter(void 0, void 0, void 0, function* () {
145
- const { api } = apiReturning([OBJECT_SELECT_FIELD]);
146
- const resolved = yield (0, selectFields_1.resolveSelectCustomFieldValues)(api, [{ field: 3, value: "High" }], "stored");
147
- strict_1.default.deepEqual(resolved, [{ field: 3, value: "def456" }]);
148
- }));
149
- (0, node_test_1.test)("fetches each referenced field definition only once", () => __awaiter(void 0, void 0, void 0, function* () {
150
- const { api, requestedIds } = apiReturning([LEGACY_SELECT_FIELD]);
151
- yield (0, selectFields_1.resolveSelectCustomFieldValues)(api, [
152
- { field: 2, value: "1 year" },
153
- { field: 2, value: "7 years" },
154
- ]);
155
- strict_1.default.deepEqual(requestedIds, [2]);
156
- }));
157
- (0, node_test_1.test)("passes the value through when the field definition cannot be fetched", () => __awaiter(void 0, void 0, void 0, function* () {
158
- const { api } = apiReturning([]);
159
- const resolved = yield (0, selectFields_1.resolveSelectCustomFieldValues)(api, [
160
- { field: 99, value: "whatever" },
161
- ]);
162
- strict_1.default.deepEqual(resolved, [{ field: 99, value: "whatever" }]);
163
- }));
164
- });