@mcp-z/mcp-outlook 2.4.1 → 2.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/cjs/constants.d.cts +1 -0
- package/dist/cjs/constants.d.ts +1 -0
- package/dist/cjs/constants.js +4 -0
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/email/querying/next-link.d.cts +5 -0
- package/dist/cjs/email/querying/next-link.d.ts +5 -0
- package/dist/cjs/email/querying/next-link.js +30 -0
- package/dist/cjs/email/querying/next-link.js.map +1 -0
- package/dist/cjs/email/querying/pagination-token.d.cts +3 -4
- package/dist/cjs/email/querying/pagination-token.d.ts +3 -4
- package/dist/cjs/email/querying/pagination-token.js +71 -49
- package/dist/cjs/email/querying/pagination-token.js.map +1 -1
- package/dist/cjs/email/querying/paging-decisions.d.cts +14 -0
- package/dist/cjs/email/querying/paging-decisions.d.ts +14 -0
- package/dist/cjs/email/querying/paging-decisions.js +91 -0
- package/dist/cjs/email/querying/paging-decisions.js.map +1 -0
- package/dist/cjs/email/querying/search-execution.js +130 -88
- package/dist/cjs/email/querying/search-execution.js.map +1 -1
- package/dist/cjs/lib/create-store.js +1 -1
- package/dist/cjs/lib/create-store.js.map +1 -1
- package/dist/cjs/mcp/tools/message-search.d.cts +1 -1
- package/dist/cjs/mcp/tools/message-search.d.ts +1 -1
- package/dist/cjs/mcp/tools/message-search.js +1 -1
- package/dist/cjs/mcp/tools/message-search.js.map +1 -1
- package/dist/cjs/mcp/tools/messages-export-csv.js +10 -6
- package/dist/cjs/mcp/tools/messages-export-csv.js.map +1 -1
- package/dist/cjs/setup/config.d.cts +2 -6
- package/dist/cjs/setup/config.d.ts +2 -6
- package/dist/cjs/setup/config.js +22 -0
- package/dist/cjs/setup/config.js.map +1 -1
- package/dist/cjs/setup/http.js +2 -1
- package/dist/cjs/setup/http.js.map +1 -1
- package/dist/cjs/setup/oauth-microsoft.d.cts +6 -1
- package/dist/cjs/setup/oauth-microsoft.d.ts +6 -1
- package/dist/cjs/setup/oauth-microsoft.js +5 -1
- package/dist/cjs/setup/oauth-microsoft.js.map +1 -1
- package/dist/cjs/setup/runtime.d.cts +1 -1
- package/dist/cjs/setup/runtime.d.ts +1 -1
- package/dist/cjs/setup/runtime.js +11 -6
- package/dist/cjs/setup/runtime.js.map +1 -1
- package/dist/cjs/setup/version-help.js +1 -1
- package/dist/cjs/setup/version-help.js.map +1 -1
- package/dist/esm/constants.d.ts +1 -0
- package/dist/esm/constants.js +2 -0
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/email/querying/next-link.d.ts +5 -0
- package/dist/esm/email/querying/next-link.js +22 -0
- package/dist/esm/email/querying/next-link.js.map +1 -0
- package/dist/esm/email/querying/pagination-token.d.ts +3 -4
- package/dist/esm/email/querying/pagination-token.js +22 -44
- package/dist/esm/email/querying/pagination-token.js.map +1 -1
- package/dist/esm/email/querying/paging-decisions.d.ts +14 -0
- package/dist/esm/email/querying/paging-decisions.js +21 -0
- package/dist/esm/email/querying/paging-decisions.js.map +1 -0
- package/dist/esm/email/querying/search-execution.js +82 -77
- package/dist/esm/email/querying/search-execution.js.map +1 -1
- package/dist/esm/lib/create-store.js +1 -1
- package/dist/esm/lib/create-store.js.map +1 -1
- package/dist/esm/mcp/tools/message-search.d.ts +1 -1
- package/dist/esm/mcp/tools/message-search.js +1 -1
- package/dist/esm/mcp/tools/message-search.js.map +1 -1
- package/dist/esm/mcp/tools/messages-export-csv.js +10 -6
- package/dist/esm/mcp/tools/messages-export-csv.js.map +1 -1
- package/dist/esm/setup/config.d.ts +2 -6
- package/dist/esm/setup/config.js +24 -6
- package/dist/esm/setup/config.js.map +1 -1
- package/dist/esm/setup/http.js +2 -1
- package/dist/esm/setup/http.js.map +1 -1
- package/dist/esm/setup/oauth-microsoft.d.ts +6 -1
- package/dist/esm/setup/oauth-microsoft.js +6 -2
- package/dist/esm/setup/oauth-microsoft.js.map +1 -1
- package/dist/esm/setup/runtime.d.ts +1 -1
- package/dist/esm/setup/runtime.js +11 -5
- package/dist/esm/setup/runtime.js.map +1 -1
- package/dist/esm/setup/version-help.js +3 -7
- package/dist/esm/setup/version-help.js.map +1 -1
- package/package.json +10 -4
package/README.md
CHANGED
|
@@ -173,6 +173,10 @@ HTTP only. Requires a public base URL. CSV export and `/files` are disabled in D
|
|
|
173
173
|
}
|
|
174
174
|
```
|
|
175
175
|
|
|
176
|
+
In `--auth=dcr` mode, every request to `/mcp` needs a bearer token issued by the server's own `/oauth/register` and `/oauth/authorize` flow; a request without a valid one gets 401 with a `WWW-Authenticate` challenge that points clients to it.
|
|
177
|
+
|
|
178
|
+
In `--auth=dcr` mode, `/oauth/register` accepts anonymous registrations with no limit, and stored registrations do not expire. If you expose the server to the internet, limit that endpoint in your reverse proxy.
|
|
179
|
+
|
|
176
180
|
## How to use
|
|
177
181
|
|
|
178
182
|
```bash
|
|
@@ -214,7 +218,7 @@ See [`server.json`](https://github.com/mcp-z/mcp-outlook/blob/master/server.json
|
|
|
214
218
|
|
|
215
219
|
OAuth tokens (`TOKEN_STORE_URI`) and DCR registrations (`DCR_STORE_URI`) are stored through [keyv-registry](https://www.npmjs.com/package/keyv-registry), which picks an adapter from the URI protocol.
|
|
216
220
|
|
|
217
|
-
`file://`
|
|
221
|
+
The default is a JSON file under `~/.mcp-z/` (`file+shared://`), written under a lock so several mcp-z servers and the cli can share `.mcp-z/tokens.json` without undoing each other's sign-ins; upgrade them together, because an older one still rewrites the whole file. `file://` (keyv-file) and `memory://` also work with no extra setup.
|
|
218
222
|
|
|
219
223
|
Any other backend needs its adapter installed alongside this server. Adapters are resolved with `require()`, so a globally installed server finds a globally installed adapter:
|
|
220
224
|
|
package/dist/cjs/constants.d.cts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* rather than externally configured since this server knows its own requirements.
|
|
6
6
|
*/
|
|
7
7
|
export declare const MS_SCOPE = "openid profile offline_access https://graph.microsoft.com/User.Read https://graph.microsoft.com/Mail.ReadWrite https://graph.microsoft.com/Mail.Send https://graph.microsoft.com/MailboxSettings.ReadWrite";
|
|
8
|
+
export declare const SHARED_FILE_PROTOCOL = "file+shared:";
|
|
8
9
|
export declare const CHUNK_SIZE = 10;
|
|
9
10
|
export declare const MAX_BATCH_SIZE = 500;
|
|
10
11
|
export declare const MAX_PAGE_SIZE = 1000;
|
package/dist/cjs/constants.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* rather than externally configured since this server knows its own requirements.
|
|
6
6
|
*/
|
|
7
7
|
export declare const MS_SCOPE = "openid profile offline_access https://graph.microsoft.com/User.Read https://graph.microsoft.com/Mail.ReadWrite https://graph.microsoft.com/Mail.Send https://graph.microsoft.com/MailboxSettings.ReadWrite";
|
|
8
|
+
export declare const SHARED_FILE_PROTOCOL = "file+shared:";
|
|
8
9
|
export declare const CHUNK_SIZE = 10;
|
|
9
10
|
export declare const MAX_BATCH_SIZE = 500;
|
|
10
11
|
export declare const MAX_PAGE_SIZE = 1000;
|
package/dist/cjs/constants.js
CHANGED
|
@@ -25,10 +25,14 @@ _export(exports, {
|
|
|
25
25
|
},
|
|
26
26
|
get MS_SCOPE () {
|
|
27
27
|
return MS_SCOPE;
|
|
28
|
+
},
|
|
29
|
+
get SHARED_FILE_PROTOCOL () {
|
|
30
|
+
return SHARED_FILE_PROTOCOL;
|
|
28
31
|
}
|
|
29
32
|
});
|
|
30
33
|
var _email = require("@mcp-z/email");
|
|
31
34
|
var MS_SCOPE = 'openid profile offline_access https://graph.microsoft.com/User.Read https://graph.microsoft.com/Mail.ReadWrite https://graph.microsoft.com/Mail.Send https://graph.microsoft.com/MailboxSettings.ReadWrite';
|
|
35
|
+
var SHARED_FILE_PROTOCOL = 'file+shared:';
|
|
32
36
|
var CHUNK_SIZE = _email.EMAIL_CHUNK_SIZE;
|
|
33
37
|
var MAX_BATCH_SIZE = _email.EMAIL_MAX_BATCH_SIZE;
|
|
34
38
|
var MAX_PAGE_SIZE = 1000; // Maximum number of items per page
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/open-source/ai/mcp-z/mcp-outlook/src/constants.ts"],"sourcesContent":["/**\n * Outlook MCP Server Constants\n *\n * These scopes are required for Microsoft Outlook functionality and are hardcoded\n * rather than externally configured since this server knows its own requirements.\n */\n\nimport { EMAIL_CHUNK_SIZE, EMAIL_MAX_BATCH_SIZE } from '@mcp-z/email';\n\n// Microsoft OAuth scopes required for Outlook operations\nexport const MS_SCOPE = 'openid profile offline_access https://graph.microsoft.com/User.Read https://graph.microsoft.com/Mail.ReadWrite https://graph.microsoft.com/Mail.Send https://graph.microsoft.com/MailboxSettings.ReadWrite';\n\n// Batch processing configuration (from shared email constants)\nexport const CHUNK_SIZE = EMAIL_CHUNK_SIZE;\nexport const MAX_BATCH_SIZE = EMAIL_MAX_BATCH_SIZE;\n\n// Pagination configuration\nexport const MAX_PAGE_SIZE = 1000; // Maximum number of items per page\n"],"names":["CHUNK_SIZE","MAX_BATCH_SIZE","MAX_PAGE_SIZE","MS_SCOPE","EMAIL_CHUNK_SIZE","EMAIL_MAX_BATCH_SIZE"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/open-source/ai/mcp-z/mcp-outlook/src/constants.ts"],"sourcesContent":["/**\n * Outlook MCP Server Constants\n *\n * These scopes are required for Microsoft Outlook functionality and are hardcoded\n * rather than externally configured since this server knows its own requirements.\n */\n\nimport { EMAIL_CHUNK_SIZE, EMAIL_MAX_BATCH_SIZE } from '@mcp-z/email';\n\n// Microsoft OAuth scopes required for Outlook operations\nexport const MS_SCOPE = 'openid profile offline_access https://graph.microsoft.com/User.Read https://graph.microsoft.com/Mail.ReadWrite https://graph.microsoft.com/Mail.Send https://graph.microsoft.com/MailboxSettings.ReadWrite';\n\n// Default token and DCR stores: a JSON file several processes can share\nexport const SHARED_FILE_PROTOCOL = 'file+shared:';\n\n// Batch processing configuration (from shared email constants)\nexport const CHUNK_SIZE = EMAIL_CHUNK_SIZE;\nexport const MAX_BATCH_SIZE = EMAIL_MAX_BATCH_SIZE;\n\n// Pagination configuration\nexport const MAX_PAGE_SIZE = 1000; // Maximum number of items per page\n"],"names":["CHUNK_SIZE","MAX_BATCH_SIZE","MAX_PAGE_SIZE","MS_SCOPE","SHARED_FILE_PROTOCOL","EMAIL_CHUNK_SIZE","EMAIL_MAX_BATCH_SIZE"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;QAWYA;eAAAA;;QACAC;eAAAA;;QAGAC;eAAAA;;QAVAC;eAAAA;;QAGAC;eAAAA;;;qBAN0C;AAGhD,IAAMD,WAAW;AAGjB,IAAMC,uBAAuB;AAG7B,IAAMJ,aAAaK,uBAAgB;AACnC,IAAMJ,iBAAiBK,2BAAoB;AAG3C,IAAMJ,gBAAgB,MAAM,mCAAmC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check an `@odata.nextLink` and return its path and query after the version (`/me/messages?...`),
|
|
3
|
+
* as the URL parser writes them. Microsoft says to follow the whole link and not to rebuild it, so nothing is decoded or reordered.
|
|
4
|
+
*/
|
|
5
|
+
export declare function checkNextLink(link: string): string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check an `@odata.nextLink` and return its path and query after the version (`/me/messages?...`),
|
|
3
|
+
* as the URL parser writes them. Microsoft says to follow the whole link and not to rebuild it, so nothing is decoded or reordered.
|
|
4
|
+
*/
|
|
5
|
+
export declare function checkNextLink(link: string): string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "checkNextLink", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return checkNextLink;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _server = require("@mcp-z/server");
|
|
12
|
+
var GRAPH_HOST = 'graph.microsoft.com';
|
|
13
|
+
var GRAPH_VERSION_PATH = '/v1.0';
|
|
14
|
+
var MESSAGES_PATH = "".concat(GRAPH_VERSION_PATH, "/me/messages");
|
|
15
|
+
function refuse(reason) {
|
|
16
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InternalError, "Microsoft Graph returned a next-page link that cannot be followed (".concat(reason, "); results would be incomplete"));
|
|
17
|
+
}
|
|
18
|
+
function checkNextLink(link) {
|
|
19
|
+
var url;
|
|
20
|
+
try {
|
|
21
|
+
url = new URL(link);
|
|
22
|
+
} catch (unused) {
|
|
23
|
+
return refuse('not a URL');
|
|
24
|
+
}
|
|
25
|
+
if (url.protocol !== 'https:') return refuse("scheme ".concat(url.protocol.slice(0, -1)));
|
|
26
|
+
if (url.host !== GRAPH_HOST) return refuse("host ".concat(url.host));
|
|
27
|
+
if (url.pathname !== MESSAGES_PATH) return refuse("path ".concat(url.pathname));
|
|
28
|
+
return url.pathname.slice(GRAPH_VERSION_PATH.length) + url.search;
|
|
29
|
+
}
|
|
30
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/open-source/ai/mcp-z/mcp-outlook/src/email/querying/next-link.ts"],"sourcesContent":["import { ProtocolError, ProtocolErrorCode } from '@mcp-z/server';\n\nconst GRAPH_HOST = 'graph.microsoft.com';\nconst GRAPH_VERSION_PATH = '/v1.0';\nconst MESSAGES_PATH = `${GRAPH_VERSION_PATH}/me/messages`;\n\nfunction refuse(reason: string): never {\n throw new ProtocolError(ProtocolErrorCode.InternalError, `Microsoft Graph returned a next-page link that cannot be followed (${reason}); results would be incomplete`);\n}\n\n/**\n * Check an `@odata.nextLink` and return its path and query after the version (`/me/messages?...`),\n * as the URL parser writes them. Microsoft says to follow the whole link and not to rebuild it, so nothing is decoded or reordered.\n */\nexport function checkNextLink(link: string): string {\n let url: URL;\n try {\n url = new URL(link);\n } catch {\n return refuse('not a URL');\n }\n if (url.protocol !== 'https:') return refuse(`scheme ${url.protocol.slice(0, -1)}`);\n if (url.host !== GRAPH_HOST) return refuse(`host ${url.host}`);\n if (url.pathname !== MESSAGES_PATH) return refuse(`path ${url.pathname}`);\n return url.pathname.slice(GRAPH_VERSION_PATH.length) + url.search;\n}\n"],"names":["checkNextLink","GRAPH_HOST","GRAPH_VERSION_PATH","MESSAGES_PATH","refuse","reason","ProtocolError","ProtocolErrorCode","InternalError","link","url","URL","protocol","slice","host","pathname","length","search"],"mappings":";;;;+BAcgBA;;;eAAAA;;;sBAdiC;AAEjD,IAAMC,aAAa;AACnB,IAAMC,qBAAqB;AAC3B,IAAMC,gBAAgB,AAAC,GAAqB,OAAnBD,oBAAmB;AAE5C,SAASE,OAAOC,MAAc;IAC5B,MAAM,IAAIC,qBAAa,CAACC,yBAAiB,CAACC,aAAa,EAAE,AAAC,sEAA4E,OAAPH,QAAO;AACxI;AAMO,SAASL,cAAcS,IAAY;IACxC,IAAIC;IACJ,IAAI;QACFA,MAAM,IAAIC,IAAIF;IAChB,EAAE,eAAM;QACN,OAAOL,OAAO;IAChB;IACA,IAAIM,IAAIE,QAAQ,KAAK,UAAU,OAAOR,OAAO,AAAC,UAAmC,OAA1BM,IAAIE,QAAQ,CAACC,KAAK,CAAC,GAAG,CAAC;IAC9E,IAAIH,IAAII,IAAI,KAAKb,YAAY,OAAOG,OAAO,AAAC,QAAgB,OAATM,IAAII,IAAI;IAC3D,IAAIJ,IAAIK,QAAQ,KAAKZ,eAAe,OAAOC,OAAO,AAAC,QAAoB,OAAbM,IAAIK,QAAQ;IACtE,OAAOL,IAAIK,QAAQ,CAACF,KAAK,CAACX,mBAAmBc,MAAM,IAAIN,IAAIO,MAAM;AACnE"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
export declare const FIRST_PAGE_SKIP_TOKEN = "__mcp_outlook_first_page__";
|
|
2
1
|
export interface DecodeNextPageTokenResult {
|
|
3
|
-
|
|
2
|
+
/** Path and query of the Graph next-page link that fetches the page, absent for the first page. */
|
|
3
|
+
link?: string;
|
|
4
4
|
offset: number;
|
|
5
5
|
mode?: string;
|
|
6
|
-
legacy: boolean;
|
|
7
6
|
}
|
|
8
7
|
export declare function encodeNextPageToken(params: {
|
|
9
|
-
|
|
8
|
+
link?: string;
|
|
10
9
|
offset: number;
|
|
11
10
|
mode?: string;
|
|
12
11
|
}): string;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
export declare const FIRST_PAGE_SKIP_TOKEN = "__mcp_outlook_first_page__";
|
|
2
1
|
export interface DecodeNextPageTokenResult {
|
|
3
|
-
|
|
2
|
+
/** Path and query of the Graph next-page link that fetches the page, absent for the first page. */
|
|
3
|
+
link?: string;
|
|
4
4
|
offset: number;
|
|
5
5
|
mode?: string;
|
|
6
|
-
legacy: boolean;
|
|
7
6
|
}
|
|
8
7
|
export declare function encodeNextPageToken(params: {
|
|
9
|
-
|
|
8
|
+
link?: string;
|
|
10
9
|
offset: number;
|
|
11
10
|
mode?: string;
|
|
12
11
|
}): string;
|
|
@@ -9,9 +9,6 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
get FIRST_PAGE_SKIP_TOKEN () {
|
|
13
|
-
return FIRST_PAGE_SKIP_TOKEN;
|
|
14
|
-
},
|
|
15
12
|
get decodeNextPageToken () {
|
|
16
13
|
return decodeNextPageToken;
|
|
17
14
|
},
|
|
@@ -20,62 +17,87 @@ _export(exports, {
|
|
|
20
17
|
}
|
|
21
18
|
});
|
|
22
19
|
var _server = require("@mcp-z/server");
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
function _define_property(obj, key, value) {
|
|
21
|
+
if (key in obj) {
|
|
22
|
+
Object.defineProperty(obj, key, {
|
|
23
|
+
value: value,
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true
|
|
27
|
+
});
|
|
28
|
+
} else obj[key] = value;
|
|
29
|
+
return obj;
|
|
30
|
+
}
|
|
31
|
+
function _object_spread(target) {
|
|
32
|
+
for(var i = 1; i < arguments.length; i++){
|
|
33
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
34
|
+
var ownKeys = Object.keys(source);
|
|
35
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
36
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
37
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
ownKeys.forEach(function(key) {
|
|
41
|
+
_define_property(target, key, source[key]);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return target;
|
|
45
|
+
}
|
|
46
|
+
function ownKeys(object, enumerableOnly) {
|
|
47
|
+
var keys = Object.keys(object);
|
|
48
|
+
if (Object.getOwnPropertySymbols) {
|
|
49
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
50
|
+
if (enumerableOnly) {
|
|
51
|
+
symbols = symbols.filter(function(sym) {
|
|
52
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
keys.push.apply(keys, symbols);
|
|
56
|
+
}
|
|
57
|
+
return keys;
|
|
58
|
+
}
|
|
59
|
+
function _object_spread_props(target, source) {
|
|
60
|
+
source = source != null ? source : {};
|
|
61
|
+
if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
62
|
+
else {
|
|
63
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
64
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return target;
|
|
68
|
+
}
|
|
69
|
+
var PREFIX = 'v3:';
|
|
25
70
|
function encodeNextPageToken(params) {
|
|
26
|
-
var _params_skipToken;
|
|
27
|
-
var sanitizedOffset = Math.max(0, Math.trunc(params.offset));
|
|
28
71
|
var payload = {
|
|
29
|
-
v:
|
|
30
|
-
|
|
31
|
-
offset: sanitizedOffset
|
|
72
|
+
v: 3,
|
|
73
|
+
offset: Math.max(0, Math.trunc(params.offset))
|
|
32
74
|
};
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var serialized = JSON.stringify(payload);
|
|
37
|
-
return "".concat(PREFIX).concat(base64UrlEncode(serialized));
|
|
75
|
+
if (params.link) payload.link = params.link;
|
|
76
|
+
if (typeof params.mode === 'string' && params.mode.length > 0) payload.mode = params.mode;
|
|
77
|
+
return "".concat(PREFIX).concat(Buffer.from(JSON.stringify(payload), 'utf8').toString('base64url'));
|
|
38
78
|
}
|
|
39
79
|
function decodeNextPageToken(token) {
|
|
40
|
-
if (!token) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
legacy: true
|
|
44
|
-
};
|
|
45
|
-
}
|
|
80
|
+
if (!token) return {
|
|
81
|
+
offset: 0
|
|
82
|
+
};
|
|
46
83
|
if (!token.startsWith(PREFIX)) {
|
|
47
|
-
|
|
48
|
-
skipToken: token,
|
|
49
|
-
offset: 0,
|
|
50
|
-
legacy: true
|
|
51
|
-
};
|
|
84
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InvalidParams, 'pageToken was issued by an earlier mcp-outlook version and cannot be used; repeat the search without pageToken');
|
|
52
85
|
}
|
|
53
|
-
var encoded = token.slice(PREFIX.length);
|
|
54
86
|
try {
|
|
55
|
-
var
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
mode:
|
|
66
|
-
|
|
67
|
-
};
|
|
87
|
+
var parsed = JSON.parse(Buffer.from(token.slice(PREFIX.length), 'base64url').toString('utf8'));
|
|
88
|
+
if (parsed.v !== 3) throw new Error('unsupported token version');
|
|
89
|
+
var link = parsed.link, offset = parsed.offset, mode = parsed.mode;
|
|
90
|
+
if (link !== undefined && (typeof link !== 'string' || link === '')) throw new Error('invalid link');
|
|
91
|
+
if (typeof offset !== 'number' || !Number.isInteger(offset) || offset < 0) throw new Error('invalid offset');
|
|
92
|
+
return _object_spread(_object_spread_props(_object_spread({}, typeof link === 'string' && {
|
|
93
|
+
link: link
|
|
94
|
+
}), {
|
|
95
|
+
offset: offset
|
|
96
|
+
}), typeof mode === 'string' && {
|
|
97
|
+
mode: mode
|
|
98
|
+
});
|
|
68
99
|
} catch (unused) {
|
|
69
100
|
throw new _server.ProtocolError(_server.ProtocolErrorCode.InvalidParams, 'Invalid pageToken');
|
|
70
101
|
}
|
|
71
102
|
}
|
|
72
|
-
function base64UrlEncode(value) {
|
|
73
|
-
return Buffer.from(value, 'utf8').toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
74
|
-
}
|
|
75
|
-
function base64UrlDecode(value) {
|
|
76
|
-
var padded = value.replace(/-/g, '+').replace(/_/g, '/');
|
|
77
|
-
var padLength = (4 - padded.length % 4) % 4;
|
|
78
|
-
var normalized = padded + '='.repeat(padLength);
|
|
79
|
-
return Buffer.from(normalized, 'base64').toString('utf8');
|
|
80
|
-
}
|
|
81
103
|
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/open-source/ai/mcp-z/mcp-outlook/src/email/querying/pagination-token.ts"],"sourcesContent":["import { ProtocolError, ProtocolErrorCode } from '@mcp-z/server';\n\nconst PREFIX = '
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/open-source/ai/mcp-z/mcp-outlook/src/email/querying/pagination-token.ts"],"sourcesContent":["import { ProtocolError, ProtocolErrorCode } from '@mcp-z/server';\n\nconst PREFIX = 'v3:';\n\ninterface V3Payload {\n v: 3;\n link?: string;\n offset: number;\n mode?: string;\n}\n\nexport interface DecodeNextPageTokenResult {\n /** Path and query of the Graph next-page link that fetches the page, absent for the first page. */\n link?: string;\n offset: number;\n mode?: string;\n}\n\nexport function encodeNextPageToken(params: { link?: string; offset: number; mode?: string }): string {\n const payload: V3Payload = { v: 3, offset: Math.max(0, Math.trunc(params.offset)) };\n if (params.link) payload.link = params.link;\n if (typeof params.mode === 'string' && params.mode.length > 0) payload.mode = params.mode;\n return `${PREFIX}${Buffer.from(JSON.stringify(payload), 'utf8').toString('base64url')}`;\n}\n\nexport function decodeNextPageToken(token: string | undefined): DecodeNextPageTokenResult {\n if (!token) return { offset: 0 };\n\n if (!token.startsWith(PREFIX)) {\n throw new ProtocolError(ProtocolErrorCode.InvalidParams, 'pageToken was issued by an earlier mcp-outlook version and cannot be used; repeat the search without pageToken');\n }\n\n try {\n const parsed = JSON.parse(Buffer.from(token.slice(PREFIX.length), 'base64url').toString('utf8')) as Record<string, unknown>;\n if (parsed.v !== 3) throw new Error('unsupported token version');\n const { link, offset, mode } = parsed;\n if (link !== undefined && (typeof link !== 'string' || link === '')) throw new Error('invalid link');\n if (typeof offset !== 'number' || !Number.isInteger(offset) || offset < 0) throw new Error('invalid offset');\n return {\n ...(typeof link === 'string' && { link }),\n offset,\n ...(typeof mode === 'string' && { mode }),\n };\n } catch {\n throw new ProtocolError(ProtocolErrorCode.InvalidParams, 'Invalid pageToken');\n }\n}\n"],"names":["decodeNextPageToken","encodeNextPageToken","PREFIX","params","payload","v","offset","Math","max","trunc","link","mode","length","Buffer","from","JSON","stringify","toString","token","startsWith","ProtocolError","ProtocolErrorCode","InvalidParams","parsed","parse","slice","Error","undefined","Number","isInteger"],"mappings":";;;;;;;;;;;QAyBgBA;eAAAA;;QAPAC;eAAAA;;;sBAlBiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEjD,IAAMC,SAAS;AAgBR,SAASD,oBAAoBE,MAAwD;IAC1F,IAAMC,UAAqB;QAAEC,GAAG;QAAGC,QAAQC,KAAKC,GAAG,CAAC,GAAGD,KAAKE,KAAK,CAACN,OAAOG,MAAM;IAAG;IAClF,IAAIH,OAAOO,IAAI,EAAEN,QAAQM,IAAI,GAAGP,OAAOO,IAAI;IAC3C,IAAI,OAAOP,OAAOQ,IAAI,KAAK,YAAYR,OAAOQ,IAAI,CAACC,MAAM,GAAG,GAAGR,QAAQO,IAAI,GAAGR,OAAOQ,IAAI;IACzF,OAAO,AAAC,GAAWE,OAATX,QAA4E,OAAnEW,OAAOC,IAAI,CAACC,KAAKC,SAAS,CAACZ,UAAU,QAAQa,QAAQ,CAAC;AAC3E;AAEO,SAASjB,oBAAoBkB,KAAyB;IAC3D,IAAI,CAACA,OAAO,OAAO;QAAEZ,QAAQ;IAAE;IAE/B,IAAI,CAACY,MAAMC,UAAU,CAACjB,SAAS;QAC7B,MAAM,IAAIkB,qBAAa,CAACC,yBAAiB,CAACC,aAAa,EAAE;IAC3D;IAEA,IAAI;QACF,IAAMC,SAASR,KAAKS,KAAK,CAACX,OAAOC,IAAI,CAACI,MAAMO,KAAK,CAACvB,OAAOU,MAAM,GAAG,aAAaK,QAAQ,CAAC;QACxF,IAAIM,OAAOlB,CAAC,KAAK,GAAG,MAAM,IAAIqB,MAAM;QACpC,IAAQhB,OAAuBa,OAAvBb,MAAMJ,SAAiBiB,OAAjBjB,QAAQK,OAASY,OAATZ;QACtB,IAAID,SAASiB,aAAc,CAAA,OAAOjB,SAAS,YAAYA,SAAS,EAAC,GAAI,MAAM,IAAIgB,MAAM;QACrF,IAAI,OAAOpB,WAAW,YAAY,CAACsB,OAAOC,SAAS,CAACvB,WAAWA,SAAS,GAAG,MAAM,IAAIoB,MAAM;QAC3F,OAAO,uDACD,OAAOhB,SAAS,YAAY;YAAEA,MAAAA;QAAK;YACvCJ,QAAAA;YACI,OAAOK,SAAS,YAAY;YAAEA,MAAAA;QAAK;IAE3C,EAAE,eAAM;QACN,MAAM,IAAIS,qBAAa,CAACC,yBAAiB,CAACC,aAAa,EAAE;IAC3D;AACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Token that resumes inside the page fetched by `link`, one message past the last one taken. */
|
|
2
|
+
export declare function midPageToken(params: {
|
|
3
|
+
link?: string;
|
|
4
|
+
pageStart: number;
|
|
5
|
+
index: number;
|
|
6
|
+
mode: 'search' | 'filter';
|
|
7
|
+
}): string;
|
|
8
|
+
/** Which collection a page token resumes: a fallback-filter token resumes the filter collection, anything else the search. */
|
|
9
|
+
export declare function resumeCollection(mode: string | undefined): 'search' | 'filter';
|
|
10
|
+
/** Cut a batch to what still fits under maxItems; truncated when rows were cut or a link remains at the limit. */
|
|
11
|
+
export declare function cutToMaxItems<T>(rows: T[], taken: number, maxItems: number, hasMore: boolean): {
|
|
12
|
+
rows: T[];
|
|
13
|
+
truncated: boolean;
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Token that resumes inside the page fetched by `link`, one message past the last one taken. */
|
|
2
|
+
export declare function midPageToken(params: {
|
|
3
|
+
link?: string;
|
|
4
|
+
pageStart: number;
|
|
5
|
+
index: number;
|
|
6
|
+
mode: 'search' | 'filter';
|
|
7
|
+
}): string;
|
|
8
|
+
/** Which collection a page token resumes: a fallback-filter token resumes the filter collection, anything else the search. */
|
|
9
|
+
export declare function resumeCollection(mode: string | undefined): 'search' | 'filter';
|
|
10
|
+
/** Cut a batch to what still fits under maxItems; truncated when rows were cut or a link remains at the limit. */
|
|
11
|
+
export declare function cutToMaxItems<T>(rows: T[], taken: number, maxItems: number, hasMore: boolean): {
|
|
12
|
+
rows: T[];
|
|
13
|
+
truncated: boolean;
|
|
14
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get cutToMaxItems () {
|
|
13
|
+
return cutToMaxItems;
|
|
14
|
+
},
|
|
15
|
+
get midPageToken () {
|
|
16
|
+
return midPageToken;
|
|
17
|
+
},
|
|
18
|
+
get resumeCollection () {
|
|
19
|
+
return resumeCollection;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
var _paginationtokents = require("./pagination-token.js");
|
|
23
|
+
function _define_property(obj, key, value) {
|
|
24
|
+
if (key in obj) {
|
|
25
|
+
Object.defineProperty(obj, key, {
|
|
26
|
+
value: value,
|
|
27
|
+
enumerable: true,
|
|
28
|
+
configurable: true,
|
|
29
|
+
writable: true
|
|
30
|
+
});
|
|
31
|
+
} else obj[key] = value;
|
|
32
|
+
return obj;
|
|
33
|
+
}
|
|
34
|
+
function _object_spread(target) {
|
|
35
|
+
for(var i = 1; i < arguments.length; i++){
|
|
36
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
37
|
+
var ownKeys = Object.keys(source);
|
|
38
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
39
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
40
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
ownKeys.forEach(function(key) {
|
|
44
|
+
_define_property(target, key, source[key]);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return target;
|
|
48
|
+
}
|
|
49
|
+
function ownKeys(object, enumerableOnly) {
|
|
50
|
+
var keys = Object.keys(object);
|
|
51
|
+
if (Object.getOwnPropertySymbols) {
|
|
52
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
53
|
+
if (enumerableOnly) {
|
|
54
|
+
symbols = symbols.filter(function(sym) {
|
|
55
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
keys.push.apply(keys, symbols);
|
|
59
|
+
}
|
|
60
|
+
return keys;
|
|
61
|
+
}
|
|
62
|
+
function _object_spread_props(target, source) {
|
|
63
|
+
source = source != null ? source : {};
|
|
64
|
+
if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
65
|
+
else {
|
|
66
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
67
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return target;
|
|
71
|
+
}
|
|
72
|
+
function midPageToken(params) {
|
|
73
|
+
return (0, _paginationtokents.encodeNextPageToken)(_object_spread_props(_object_spread({}, params.link && {
|
|
74
|
+
link: params.link
|
|
75
|
+
}), {
|
|
76
|
+
offset: params.pageStart + params.index + 1,
|
|
77
|
+
mode: params.mode
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
function resumeCollection(mode) {
|
|
81
|
+
return mode === 'filter' ? 'filter' : 'search';
|
|
82
|
+
}
|
|
83
|
+
function cutToMaxItems(rows, taken, maxItems, hasMore) {
|
|
84
|
+
var kept = rows.slice(0, Math.max(0, maxItems - taken));
|
|
85
|
+
var truncated = kept.length < rows.length || taken + kept.length >= maxItems && hasMore;
|
|
86
|
+
return {
|
|
87
|
+
rows: kept,
|
|
88
|
+
truncated: truncated
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/open-source/ai/mcp-z/mcp-outlook/src/email/querying/paging-decisions.ts"],"sourcesContent":["import { encodeNextPageToken } from './pagination-token.ts';\n\n/** Token that resumes inside the page fetched by `link`, one message past the last one taken. */\nexport function midPageToken(params: { link?: string; pageStart: number; index: number; mode: 'search' | 'filter' }): string {\n return encodeNextPageToken({ ...(params.link && { link: params.link }), offset: params.pageStart + params.index + 1, mode: params.mode });\n}\n\n/** Which collection a page token resumes: a fallback-filter token resumes the filter collection, anything else the search. */\nexport function resumeCollection(mode: string | undefined): 'search' | 'filter' {\n return mode === 'filter' ? 'filter' : 'search';\n}\n\n/** Cut a batch to what still fits under maxItems; truncated when rows were cut or a link remains at the limit. */\nexport function cutToMaxItems<T>(rows: T[], taken: number, maxItems: number, hasMore: boolean): { rows: T[]; truncated: boolean } {\n const kept = rows.slice(0, Math.max(0, maxItems - taken));\n const truncated = kept.length < rows.length || (taken + kept.length >= maxItems && hasMore);\n return { rows: kept, truncated };\n}\n"],"names":["cutToMaxItems","midPageToken","resumeCollection","params","encodeNextPageToken","link","offset","pageStart","index","mode","rows","taken","maxItems","hasMore","kept","slice","Math","max","truncated","length"],"mappings":";;;;;;;;;;;QAagBA;eAAAA;;QAVAC;eAAAA;;QAKAC;eAAAA;;;iCARoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAG7B,SAASD,aAAaE,MAAsF;IACjH,OAAOC,IAAAA,sCAAmB,EAAC,wCAAMD,OAAOE,IAAI,IAAI;QAAEA,MAAMF,OAAOE,IAAI;IAAC;QAAIC,QAAQH,OAAOI,SAAS,GAAGJ,OAAOK,KAAK,GAAG;QAAGC,MAAMN,OAAOM,IAAI;;AACxI;AAGO,SAASP,iBAAiBO,IAAwB;IACvD,OAAOA,SAAS,WAAW,WAAW;AACxC;AAGO,SAAST,cAAiBU,IAAS,EAAEC,KAAa,EAAEC,QAAgB,EAAEC,OAAgB;IAC3F,IAAMC,OAAOJ,KAAKK,KAAK,CAAC,GAAGC,KAAKC,GAAG,CAAC,GAAGL,WAAWD;IAClD,IAAMO,YAAYJ,KAAKK,MAAM,GAAGT,KAAKS,MAAM,IAAKR,QAAQG,KAAKK,MAAM,IAAIP,YAAYC;IACnF,OAAO;QAAEH,MAAMI;QAAMI,WAAAA;IAAU;AACjC"}
|