@teamnetwork-nz/mailstore-spe-mcp 0.1.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/README.md +360 -0
- package/dist/config/env.d.ts +14 -0
- package/dist/config/env.js +45 -0
- package/dist/config/env.js.map +1 -0
- package/dist/config/schema.d.ts +86 -0
- package/dist/config/schema.js +55 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +60 -0
- package/dist/index.js.map +1 -0
- package/dist/logging/logger.d.ts +12 -0
- package/dist/logging/logger.js +80 -0
- package/dist/logging/logger.js.map +1 -0
- package/dist/mailstore/authentication.d.ts +7 -0
- package/dist/mailstore/authentication.js +15 -0
- package/dist/mailstore/authentication.js.map +1 -0
- package/dist/mailstore/capability-registry.d.ts +40 -0
- package/dist/mailstore/capability-registry.js +152 -0
- package/dist/mailstore/capability-registry.js.map +1 -0
- package/dist/mailstore/client.d.ts +33 -0
- package/dist/mailstore/client.js +274 -0
- package/dist/mailstore/client.js.map +1 -0
- package/dist/mailstore/encoder.d.ts +14 -0
- package/dist/mailstore/encoder.js +42 -0
- package/dist/mailstore/encoder.js.map +1 -0
- package/dist/mailstore/errors.d.ts +44 -0
- package/dist/mailstore/errors.js +49 -0
- package/dist/mailstore/errors.js.map +1 -0
- package/dist/mailstore/instance-resolver.d.ts +43 -0
- package/dist/mailstore/instance-resolver.js +143 -0
- package/dist/mailstore/instance-resolver.js.map +1 -0
- package/dist/mailstore/metadata.d.ts +21 -0
- package/dist/mailstore/metadata.js +50 -0
- package/dist/mailstore/metadata.js.map +1 -0
- package/dist/mailstore/operation-poller.d.ts +19 -0
- package/dist/mailstore/operation-poller.js +72 -0
- package/dist/mailstore/operation-poller.js.map +1 -0
- package/dist/mailstore/response-parser.d.ts +11 -0
- package/dist/mailstore/response-parser.js +66 -0
- package/dist/mailstore/response-parser.js.map +1 -0
- package/dist/mailstore/types.d.ts +79 -0
- package/dist/mailstore/types.js +6 -0
- package/dist/mailstore/types.js.map +1 -0
- package/dist/output/normalizers.d.ts +11 -0
- package/dist/output/normalizers.js +40 -0
- package/dist/output/normalizers.js.map +1 -0
- package/dist/output/tool-result.d.ts +30 -0
- package/dist/output/tool-result.js +24 -0
- package/dist/output/tool-result.js.map +1 -0
- package/dist/output/truncation.d.ts +17 -0
- package/dist/output/truncation.js +27 -0
- package/dist/output/truncation.js.map +1 -0
- package/dist/policy/access-mode.d.ts +16 -0
- package/dist/policy/access-mode.js +21 -0
- package/dist/policy/access-mode.js.map +1 -0
- package/dist/policy/confirmations.d.ts +24 -0
- package/dist/policy/confirmations.js +49 -0
- package/dist/policy/confirmations.js.map +1 -0
- package/dist/policy/redaction.d.ts +15 -0
- package/dist/policy/redaction.js +63 -0
- package/dist/policy/redaction.js.map +1 -0
- package/dist/policy/tool-policy.d.ts +15 -0
- package/dist/policy/tool-policy.js +2 -0
- package/dist/policy/tool-policy.js.map +1 -0
- package/dist/resources/health.d.ts +17 -0
- package/dist/resources/health.js +55 -0
- package/dist/resources/health.js.map +1 -0
- package/dist/resources/register-resources.d.ts +7 -0
- package/dist/resources/register-resources.js +37 -0
- package/dist/resources/register-resources.js.map +1 -0
- package/dist/server.d.ts +17 -0
- package/dist/server.js +62 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/compliance.d.ts +6 -0
- package/dist/tools/compliance.js +96 -0
- package/dist/tools/compliance.js.map +1 -0
- package/dist/tools/instances.d.ts +4 -0
- package/dist/tools/instances.js +197 -0
- package/dist/tools/instances.js.map +1 -0
- package/dist/tools/jobs.d.ts +2 -0
- package/dist/tools/jobs.js +125 -0
- package/dist/tools/jobs.js.map +1 -0
- package/dist/tools/maintenance.d.ts +3 -0
- package/dist/tools/maintenance.js +22 -0
- package/dist/tools/maintenance.js.map +1 -0
- package/dist/tools/platform.d.ts +4 -0
- package/dist/tools/platform.js +134 -0
- package/dist/tools/platform.js.map +1 -0
- package/dist/tools/profiles.d.ts +2 -0
- package/dist/tools/profiles.js +140 -0
- package/dist/tools/profiles.js.map +1 -0
- package/dist/tools/raw-api.d.ts +16 -0
- package/dist/tools/raw-api.js +109 -0
- package/dist/tools/raw-api.js.map +1 -0
- package/dist/tools/register-tools.d.ts +14 -0
- package/dist/tools/register-tools.js +121 -0
- package/dist/tools/register-tools.js.map +1 -0
- package/dist/tools/smtp.d.ts +2 -0
- package/dist/tools/smtp.js +39 -0
- package/dist/tools/smtp.js.map +1 -0
- package/dist/tools/stores.d.ts +2 -0
- package/dist/tools/stores.js +116 -0
- package/dist/tools/stores.js.map +1 -0
- package/dist/tools/tool.d.ts +41 -0
- package/dist/tools/tool.js +33 -0
- package/dist/tools/tool.js.map +1 -0
- package/dist/tools/users.d.ts +2 -0
- package/dist/tools/users.js +266 -0
- package/dist/tools/users.js.map +1 -0
- package/package.json +52 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ApiArgument } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Encode MailStore API arguments as an application/x-www-form-urlencoded body.
|
|
4
|
+
*
|
|
5
|
+
* Rules (§8.1):
|
|
6
|
+
* - Strings, numbers and booleans are stringified directly.
|
|
7
|
+
* - Objects and arrays (e.g. `config`, `properties`, `settings`) are serialised
|
|
8
|
+
* as JSON strings before form encoding.
|
|
9
|
+
* - `undefined` values are omitted entirely.
|
|
10
|
+
* - `null` is sent as an empty value only when the argument is explicitly
|
|
11
|
+
* provided as null (MailStore uses nullable arguments); callers that want to
|
|
12
|
+
* omit an argument should pass `undefined`, not `null`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function encodeFormBody(args?: Record<string, ApiArgument>): string;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encode MailStore API arguments as an application/x-www-form-urlencoded body.
|
|
3
|
+
*
|
|
4
|
+
* Rules (§8.1):
|
|
5
|
+
* - Strings, numbers and booleans are stringified directly.
|
|
6
|
+
* - Objects and arrays (e.g. `config`, `properties`, `settings`) are serialised
|
|
7
|
+
* as JSON strings before form encoding.
|
|
8
|
+
* - `undefined` values are omitted entirely.
|
|
9
|
+
* - `null` is sent as an empty value only when the argument is explicitly
|
|
10
|
+
* provided as null (MailStore uses nullable arguments); callers that want to
|
|
11
|
+
* omit an argument should pass `undefined`, not `null`.
|
|
12
|
+
*/
|
|
13
|
+
export function encodeFormBody(args = {}) {
|
|
14
|
+
const params = new URLSearchParams();
|
|
15
|
+
for (const [key, value] of Object.entries(args)) {
|
|
16
|
+
if (value === undefined)
|
|
17
|
+
continue;
|
|
18
|
+
params.append(key, encodeValue(value));
|
|
19
|
+
}
|
|
20
|
+
return params.toString();
|
|
21
|
+
}
|
|
22
|
+
function encodeValue(value) {
|
|
23
|
+
if (value === null)
|
|
24
|
+
return '';
|
|
25
|
+
switch (typeof value) {
|
|
26
|
+
case 'string':
|
|
27
|
+
return value;
|
|
28
|
+
case 'number':
|
|
29
|
+
if (!Number.isFinite(value)) {
|
|
30
|
+
throw new Error(`Cannot encode non-finite number argument: ${String(value)}`);
|
|
31
|
+
}
|
|
32
|
+
return String(value);
|
|
33
|
+
case 'boolean':
|
|
34
|
+
return value ? 'true' : 'false';
|
|
35
|
+
case 'object':
|
|
36
|
+
// Arrays and plain objects → JSON string.
|
|
37
|
+
return JSON.stringify(value);
|
|
38
|
+
default:
|
|
39
|
+
throw new Error(`Unsupported argument type: ${typeof value}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=encoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoder.js","sourceRoot":"","sources":["../../src/mailstore/encoder.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,cAAc,CAAC,OAAoC,EAAE;IACnE,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;IACrC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAChD,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QAClC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;AAC3B,CAAC;AAED,SAAS,WAAW,CAAC,KAAsC;IACzD,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IAC9B,QAAQ,OAAO,KAAK,EAAE,CAAC;QACrB,KAAK,QAAQ;YACX,OAAO,KAAK,CAAC;QACf,KAAK,QAAQ;YACX,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC5B,MAAM,IAAI,KAAK,CAAC,6CAA6C,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAChF,CAAC;YACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;QACvB,KAAK,SAAS;YACZ,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;QAClC,KAAK,QAAQ;YACX,0CAA0C;YAC1C,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC/B;YACE,MAAM,IAAI,KAAK,CAAC,8BAA8B,OAAO,KAAK,EAAE,CAAC,CAAC;IAClE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** Stable, MCP-facing error codes. See spec §17. */
|
|
2
|
+
export type MailStoreMcpErrorCode = 'CONFIGURATION_ERROR' | 'AUTHENTICATION_FAILED' | 'AUTHORIZATION_FAILED' | 'TLS_ERROR' | 'MAILSTORE_UNAVAILABLE' | 'MAILSTORE_API_ERROR' | 'MAILSTORE_OPERATION_FAILED' | 'MAILSTORE_OPERATION_TIMEOUT' | 'UNSUPPORTED_FUNCTION' | 'INVALID_ARGUMENT' | 'INSTANCE_NOT_FOUND' | 'AMBIGUOUS_INSTANCE' | 'OBJECT_NOT_FOUND' | 'CONFIRMATION_REQUIRED' | 'CONFIRMATION_MISMATCH' | 'ACCESS_MODE_DENIED' | 'DESTRUCTIVE_ACTION_DISABLED' | 'CONCURRENT_MODIFICATION' | 'RESULT_TOO_LARGE';
|
|
3
|
+
/**
|
|
4
|
+
* An error carrying a stable code and safe, structured details. `details` must
|
|
5
|
+
* never contain secrets, auth headers, raw stack traces, or full internal URLs
|
|
6
|
+
* with sensitive parameters — callers are responsible for keeping it clean.
|
|
7
|
+
*/
|
|
8
|
+
export declare class McpError extends Error {
|
|
9
|
+
readonly code: MailStoreMcpErrorCode;
|
|
10
|
+
readonly details?: Record<string, unknown> | undefined;
|
|
11
|
+
/** Whether the underlying operation may be safely retried. */
|
|
12
|
+
readonly retryable: boolean;
|
|
13
|
+
readonly name = "McpError";
|
|
14
|
+
constructor(code: MailStoreMcpErrorCode, message: string, details?: Record<string, unknown> | undefined,
|
|
15
|
+
/** Whether the underlying operation may be safely retried. */
|
|
16
|
+
retryable?: boolean);
|
|
17
|
+
toResponse(): {
|
|
18
|
+
code: MailStoreMcpErrorCode;
|
|
19
|
+
message: string;
|
|
20
|
+
details?: Record<string, unknown>;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/** Convenience constructors for common cases. */
|
|
24
|
+
export declare const Errors: {
|
|
25
|
+
config: (message: string, details?: Record<string, unknown>) => McpError;
|
|
26
|
+
auth: (message: string, details?: Record<string, unknown>) => McpError;
|
|
27
|
+
authorization: (message: string, details?: Record<string, unknown>) => McpError;
|
|
28
|
+
tls: (message: string, details?: Record<string, unknown>) => McpError;
|
|
29
|
+
unavailable: (message: string, details?: Record<string, unknown>) => McpError;
|
|
30
|
+
apiError: (message: string, details?: Record<string, unknown>) => McpError;
|
|
31
|
+
operationFailed: (message: string, details?: Record<string, unknown>) => McpError;
|
|
32
|
+
operationTimeout: (message: string, details?: Record<string, unknown>) => McpError;
|
|
33
|
+
unsupported: (message: string, details?: Record<string, unknown>) => McpError;
|
|
34
|
+
invalidArgument: (message: string, details?: Record<string, unknown>) => McpError;
|
|
35
|
+
instanceNotFound: (message: string, details?: Record<string, unknown>) => McpError;
|
|
36
|
+
ambiguousInstance: (message: string, details?: Record<string, unknown>) => McpError;
|
|
37
|
+
objectNotFound: (message: string, details?: Record<string, unknown>) => McpError;
|
|
38
|
+
confirmationRequired: (message: string, details?: Record<string, unknown>) => McpError;
|
|
39
|
+
confirmationMismatch: (message: string, details?: Record<string, unknown>) => McpError;
|
|
40
|
+
accessDenied: (message: string, details?: Record<string, unknown>) => McpError;
|
|
41
|
+
destructiveDisabled: (message: string, details?: Record<string, unknown>) => McpError;
|
|
42
|
+
concurrentModification: (message: string, details?: Record<string, unknown>) => McpError;
|
|
43
|
+
resultTooLarge: (message: string, details?: Record<string, unknown>) => McpError;
|
|
44
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An error carrying a stable code and safe, structured details. `details` must
|
|
3
|
+
* never contain secrets, auth headers, raw stack traces, or full internal URLs
|
|
4
|
+
* with sensitive parameters — callers are responsible for keeping it clean.
|
|
5
|
+
*/
|
|
6
|
+
export class McpError extends Error {
|
|
7
|
+
code;
|
|
8
|
+
details;
|
|
9
|
+
retryable;
|
|
10
|
+
name = 'McpError';
|
|
11
|
+
constructor(code, message, details,
|
|
12
|
+
/** Whether the underlying operation may be safely retried. */
|
|
13
|
+
retryable = false) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.code = code;
|
|
16
|
+
this.details = details;
|
|
17
|
+
this.retryable = retryable;
|
|
18
|
+
}
|
|
19
|
+
toResponse() {
|
|
20
|
+
return {
|
|
21
|
+
code: this.code,
|
|
22
|
+
message: this.message,
|
|
23
|
+
...(this.details ? { details: this.details } : {}),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** Convenience constructors for common cases. */
|
|
28
|
+
export const Errors = {
|
|
29
|
+
config: (message, details) => new McpError('CONFIGURATION_ERROR', message, details),
|
|
30
|
+
auth: (message, details) => new McpError('AUTHENTICATION_FAILED', message, details),
|
|
31
|
+
authorization: (message, details) => new McpError('AUTHORIZATION_FAILED', message, details),
|
|
32
|
+
tls: (message, details) => new McpError('TLS_ERROR', message, details),
|
|
33
|
+
unavailable: (message, details) => new McpError('MAILSTORE_UNAVAILABLE', message, details, true),
|
|
34
|
+
apiError: (message, details) => new McpError('MAILSTORE_API_ERROR', message, details),
|
|
35
|
+
operationFailed: (message, details) => new McpError('MAILSTORE_OPERATION_FAILED', message, details),
|
|
36
|
+
operationTimeout: (message, details) => new McpError('MAILSTORE_OPERATION_TIMEOUT', message, details),
|
|
37
|
+
unsupported: (message, details) => new McpError('UNSUPPORTED_FUNCTION', message, details),
|
|
38
|
+
invalidArgument: (message, details) => new McpError('INVALID_ARGUMENT', message, details),
|
|
39
|
+
instanceNotFound: (message, details) => new McpError('INSTANCE_NOT_FOUND', message, details),
|
|
40
|
+
ambiguousInstance: (message, details) => new McpError('AMBIGUOUS_INSTANCE', message, details),
|
|
41
|
+
objectNotFound: (message, details) => new McpError('OBJECT_NOT_FOUND', message, details),
|
|
42
|
+
confirmationRequired: (message, details) => new McpError('CONFIRMATION_REQUIRED', message, details),
|
|
43
|
+
confirmationMismatch: (message, details) => new McpError('CONFIRMATION_MISMATCH', message, details),
|
|
44
|
+
accessDenied: (message, details) => new McpError('ACCESS_MODE_DENIED', message, details),
|
|
45
|
+
destructiveDisabled: (message, details) => new McpError('DESTRUCTIVE_ACTION_DISABLED', message, details),
|
|
46
|
+
concurrentModification: (message, details) => new McpError('CONCURRENT_MODIFICATION', message, details),
|
|
47
|
+
resultTooLarge: (message, details) => new McpError('RESULT_TOO_LARGE', message, details),
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/mailstore/errors.ts"],"names":[],"mappings":"AAsBA;;;;GAIG;A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iC,EAAE,EAAE,CACnE,IAAI,QAAQ,CAAC,oBAAoB,EAAE,OAAO,EAAE,OAAO,CAAC;IACtD,mBAAmB,EAAE,CAAC,OAAe,EAAE,OAAiC,EAAE,EAAE,CAC1E,IAAI,QAAQ,CAAC,6BAA6B,EAAE,OAAO,EAAE,OAAO,CAAC;IAC/D,sBAAsB,EAAE,CAAC,OAAe,EAAE,OAAiC,EAAE,EAAE,CAC7E,IAAI,QAAQ,CAAC,yBAAyB,EAAE,OAAO,EAAE,OAAO,CAAC;IAC3D,cAAc,EAAE,CAAC,OAAe,EAAE,OAAiC,EAAE,EAAE,CACrE,IAAI,QAAQ,CAAC,kBAAkB,EAAE,OAAO,EAAE,OAAO,CAAC;CACrD,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Logger } from 'pino';
|
|
2
|
+
import type { IMailStoreClient } from './types.js';
|
|
3
|
+
/** Normalised summary of one MailStore SPE instance. */
|
|
4
|
+
export interface InstanceSummary {
|
|
5
|
+
instanceID: string;
|
|
6
|
+
alias?: string;
|
|
7
|
+
displayName?: string;
|
|
8
|
+
instanceHost?: string;
|
|
9
|
+
state?: string;
|
|
10
|
+
startMode?: string;
|
|
11
|
+
safeMode?: boolean;
|
|
12
|
+
/** The raw record, retained for tools that expand instance detail. */
|
|
13
|
+
raw: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Resolves a caller-supplied `instance` string to exactly one instance, using a
|
|
17
|
+
* short-lived cache of GetInstances. Never silently picks a fuzzy match; returns
|
|
18
|
+
* an AMBIGUOUS_INSTANCE error when a name maps to multiple instances.
|
|
19
|
+
*/
|
|
20
|
+
export declare class InstanceResolver {
|
|
21
|
+
private readonly client;
|
|
22
|
+
private readonly ttlSeconds;
|
|
23
|
+
private readonly logger;
|
|
24
|
+
private cache;
|
|
25
|
+
private fetchedAtMs;
|
|
26
|
+
constructor(client: IMailStoreClient, ttlSeconds: number, logger: Logger);
|
|
27
|
+
/** Force a re-fetch on the next list()/resolve() (call after create/state changes). */
|
|
28
|
+
invalidate(): void;
|
|
29
|
+
/** Return the (cached) list of instances, optionally filtered by the API. */
|
|
30
|
+
list(filter?: string, forceRefresh?: boolean): Promise<InstanceSummary[]>;
|
|
31
|
+
/**
|
|
32
|
+
* Resolve a name to exactly one instance. Precedence:
|
|
33
|
+
* 1. exact instanceID
|
|
34
|
+
* 2. exact alias
|
|
35
|
+
* 3. exact displayName
|
|
36
|
+
* 4. unambiguous case-insensitive exact match across id/alias/displayName
|
|
37
|
+
*/
|
|
38
|
+
resolve(name: string): Promise<InstanceSummary>;
|
|
39
|
+
}
|
|
40
|
+
/** Normalise the GetInstances result into InstanceSummary[]. */
|
|
41
|
+
export declare function normaliseInstanceList(result: unknown): InstanceSummary[];
|
|
42
|
+
/** Normalise one raw instance record, tolerating field-name variation. */
|
|
43
|
+
export declare function normaliseInstance(rec: Record<string, unknown>): InstanceSummary | undefined;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { Errors } from './errors.js';
|
|
2
|
+
const MAX_AMBIGUOUS_CANDIDATES = 10;
|
|
3
|
+
/**
|
|
4
|
+
* Resolves a caller-supplied `instance` string to exactly one instance, using a
|
|
5
|
+
* short-lived cache of GetInstances. Never silently picks a fuzzy match; returns
|
|
6
|
+
* an AMBIGUOUS_INSTANCE error when a name maps to multiple instances.
|
|
7
|
+
*/
|
|
8
|
+
export class InstanceResolver {
|
|
9
|
+
client;
|
|
10
|
+
ttlSeconds;
|
|
11
|
+
logger;
|
|
12
|
+
cache;
|
|
13
|
+
fetchedAtMs = 0;
|
|
14
|
+
constructor(client, ttlSeconds, logger) {
|
|
15
|
+
this.client = client;
|
|
16
|
+
this.ttlSeconds = ttlSeconds;
|
|
17
|
+
this.logger = logger;
|
|
18
|
+
}
|
|
19
|
+
/** Force a re-fetch on the next list()/resolve() (call after create/state changes). */
|
|
20
|
+
invalidate() {
|
|
21
|
+
this.fetchedAtMs = 0;
|
|
22
|
+
this.cache = undefined;
|
|
23
|
+
}
|
|
24
|
+
/** Return the (cached) list of instances, optionally filtered by the API. */
|
|
25
|
+
async list(filter = '*', forceRefresh = false) {
|
|
26
|
+
const ageMs = Date.now() - this.fetchedAtMs;
|
|
27
|
+
if (!forceRefresh && this.cache && filter === '*' && ageMs <= this.ttlSeconds * 1000) {
|
|
28
|
+
return this.cache;
|
|
29
|
+
}
|
|
30
|
+
const args = { instanceFilter: filter };
|
|
31
|
+
const result = await this.client.invokeAndWait('GetInstances', args, { retrySafe: true });
|
|
32
|
+
const instances = normaliseInstanceList(result);
|
|
33
|
+
if (filter === '*') {
|
|
34
|
+
this.cache = instances;
|
|
35
|
+
this.fetchedAtMs = Date.now();
|
|
36
|
+
}
|
|
37
|
+
return instances;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Resolve a name to exactly one instance. Precedence:
|
|
41
|
+
* 1. exact instanceID
|
|
42
|
+
* 2. exact alias
|
|
43
|
+
* 3. exact displayName
|
|
44
|
+
* 4. unambiguous case-insensitive exact match across id/alias/displayName
|
|
45
|
+
*/
|
|
46
|
+
async resolve(name) {
|
|
47
|
+
const query = name.trim();
|
|
48
|
+
if (query.length === 0) {
|
|
49
|
+
throw Errors.invalidArgument('An instance name or id is required');
|
|
50
|
+
}
|
|
51
|
+
if (query === '*' || query.includes('*')) {
|
|
52
|
+
throw Errors.invalidArgument('Wildcard instance selectors are not permitted', { instance: name });
|
|
53
|
+
}
|
|
54
|
+
const instances = await this.list('*');
|
|
55
|
+
// 1. exact instanceID (case-sensitive)
|
|
56
|
+
const byId = instances.filter((i) => i.instanceID === query);
|
|
57
|
+
if (byId.length === 1)
|
|
58
|
+
return byId[0];
|
|
59
|
+
// 2. exact alias (case-sensitive)
|
|
60
|
+
const byAlias = instances.filter((i) => i.alias === query);
|
|
61
|
+
if (byAlias.length === 1)
|
|
62
|
+
return byAlias[0];
|
|
63
|
+
// 3. exact displayName (case-sensitive)
|
|
64
|
+
const byDisplay = instances.filter((i) => i.displayName === query);
|
|
65
|
+
if (byDisplay.length === 1)
|
|
66
|
+
return byDisplay[0];
|
|
67
|
+
// 4. case-insensitive exact match across the three identity fields
|
|
68
|
+
const lower = query.toLowerCase();
|
|
69
|
+
const ciMatches = instances.filter((i) => i.instanceID.toLowerCase() === lower ||
|
|
70
|
+
i.alias?.toLowerCase() === lower ||
|
|
71
|
+
i.displayName?.toLowerCase() === lower);
|
|
72
|
+
if (ciMatches.length === 1)
|
|
73
|
+
return ciMatches[0];
|
|
74
|
+
if (ciMatches.length === 0) {
|
|
75
|
+
throw Errors.instanceNotFound(`No MailStore instance matched "${name}"`, { instance: name });
|
|
76
|
+
}
|
|
77
|
+
// Multiple matches → ambiguous.
|
|
78
|
+
throw Errors.ambiguousInstance('The instance name matched multiple MailStore instances', {
|
|
79
|
+
instance: name,
|
|
80
|
+
matches: ciMatches.slice(0, MAX_AMBIGUOUS_CANDIDATES).map((i) => ({
|
|
81
|
+
instanceID: i.instanceID,
|
|
82
|
+
...(i.alias ? { alias: i.alias } : {}),
|
|
83
|
+
...(i.displayName ? { displayName: i.displayName } : {}),
|
|
84
|
+
})),
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/** Normalise the GetInstances result into InstanceSummary[]. */
|
|
89
|
+
export function normaliseInstanceList(result) {
|
|
90
|
+
const arr = Array.isArray(result)
|
|
91
|
+
? result
|
|
92
|
+
: result && typeof result === 'object' && Array.isArray(result['instances'])
|
|
93
|
+
? result['instances']
|
|
94
|
+
: [];
|
|
95
|
+
const out = [];
|
|
96
|
+
for (const entry of arr) {
|
|
97
|
+
if (!entry || typeof entry !== 'object')
|
|
98
|
+
continue;
|
|
99
|
+
const summary = normaliseInstance(entry);
|
|
100
|
+
if (summary)
|
|
101
|
+
out.push(summary);
|
|
102
|
+
}
|
|
103
|
+
return out;
|
|
104
|
+
}
|
|
105
|
+
/** Normalise one raw instance record, tolerating field-name variation. */
|
|
106
|
+
export function normaliseInstance(rec) {
|
|
107
|
+
const instanceID = firstString(rec, ['instanceID', 'instanceId', 'id']);
|
|
108
|
+
if (!instanceID)
|
|
109
|
+
return undefined;
|
|
110
|
+
const alias = firstString(rec, ['alias']);
|
|
111
|
+
const displayName = firstString(rec, ['displayName', 'name']);
|
|
112
|
+
const instanceHost = firstString(rec, ['instanceHost', 'instanceHostName', 'host']);
|
|
113
|
+
const state = firstString(rec, ['state', 'status', 'runningState']);
|
|
114
|
+
const startMode = firstString(rec, ['startMode', 'autostart']);
|
|
115
|
+
const safeMode = firstBool(rec, ['safeMode', 'isSafeMode']);
|
|
116
|
+
return {
|
|
117
|
+
instanceID,
|
|
118
|
+
...(alias !== undefined ? { alias } : {}),
|
|
119
|
+
...(displayName !== undefined ? { displayName } : {}),
|
|
120
|
+
...(instanceHost !== undefined ? { instanceHost } : {}),
|
|
121
|
+
...(state !== undefined ? { state } : {}),
|
|
122
|
+
...(startMode !== undefined ? { startMode } : {}),
|
|
123
|
+
...(safeMode !== undefined ? { safeMode } : {}),
|
|
124
|
+
raw: rec,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function firstString(rec, keys) {
|
|
128
|
+
for (const k of keys) {
|
|
129
|
+
const v = rec[k];
|
|
130
|
+
if (typeof v === 'string' && v.length > 0)
|
|
131
|
+
return v;
|
|
132
|
+
}
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
function firstBool(rec, keys) {
|
|
136
|
+
for (const k of keys) {
|
|
137
|
+
const v = rec[k];
|
|
138
|
+
if (typeof v === 'boolean')
|
|
139
|
+
return v;
|
|
140
|
+
}
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=instance-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instance-resolver.js","sourceRoot":"","sources":["../../src/mailstore/instance-resolver.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAerC,M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
|
|
1
|
+
import type { Logger } from 'pino';
|
|
2
|
+
import type { IMailStoreClient, ApiFunctionMetadata } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* In-memory, TTL-cached metadata service. Refreshes on startup, after the TTL,
|
|
5
|
+
* on demand (administrator refresh tool), and can be invalidated when a response
|
|
6
|
+
* suggests the metadata is stale.
|
|
7
|
+
*/
|
|
8
|
+
export declare class MetadataService {
|
|
9
|
+
private readonly client;
|
|
10
|
+
private readonly ttlSeconds;
|
|
11
|
+
private readonly logger;
|
|
12
|
+
private cache;
|
|
13
|
+
private fetchedAtMs;
|
|
14
|
+
private inflight;
|
|
15
|
+
constructor(client: IMailStoreClient, ttlSeconds: number, logger: Logger);
|
|
16
|
+
/** Return cached metadata, fetching if empty or expired. */
|
|
17
|
+
get(forceRefresh?: boolean): Promise<ApiFunctionMetadata[]>;
|
|
18
|
+
/** Force a refresh on the next get(). */
|
|
19
|
+
invalidate(): void;
|
|
20
|
+
get ageSeconds(): number | undefined;
|
|
21
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory, TTL-cached metadata service. Refreshes on startup, after the TTL,
|
|
3
|
+
* on demand (administrator refresh tool), and can be invalidated when a response
|
|
4
|
+
* suggests the metadata is stale.
|
|
5
|
+
*/
|
|
6
|
+
export class MetadataService {
|
|
7
|
+
client;
|
|
8
|
+
ttlSeconds;
|
|
9
|
+
logger;
|
|
10
|
+
cache;
|
|
11
|
+
fetchedAtMs = 0;
|
|
12
|
+
inflight;
|
|
13
|
+
constructor(client, ttlSeconds, logger) {
|
|
14
|
+
this.client = client;
|
|
15
|
+
this.ttlSeconds = ttlSeconds;
|
|
16
|
+
this.logger = logger;
|
|
17
|
+
}
|
|
18
|
+
/** Return cached metadata, fetching if empty or expired. */
|
|
19
|
+
async get(forceRefresh = false) {
|
|
20
|
+
const ageMs = Date.now() - this.fetchedAtMs;
|
|
21
|
+
const expired = ageMs > this.ttlSeconds * 1000;
|
|
22
|
+
if (!forceRefresh && this.cache && !expired) {
|
|
23
|
+
return this.cache;
|
|
24
|
+
}
|
|
25
|
+
if (this.inflight)
|
|
26
|
+
return this.inflight;
|
|
27
|
+
this.inflight = this.client
|
|
28
|
+
.getMetadata()
|
|
29
|
+
.then((fns) => {
|
|
30
|
+
this.cache = fns;
|
|
31
|
+
this.fetchedAtMs = Date.now();
|
|
32
|
+
this.logger.info({ functionCount: fns.length }, 'loaded MailStore API metadata');
|
|
33
|
+
return fns;
|
|
34
|
+
})
|
|
35
|
+
.finally(() => {
|
|
36
|
+
this.inflight = undefined;
|
|
37
|
+
});
|
|
38
|
+
return this.inflight;
|
|
39
|
+
}
|
|
40
|
+
/** Force a refresh on the next get(). */
|
|
41
|
+
invalidate() {
|
|
42
|
+
this.fetchedAtMs = 0;
|
|
43
|
+
}
|
|
44
|
+
get ageSeconds() {
|
|
45
|
+
if (!this.cache)
|
|
46
|
+
return undefined;
|
|
47
|
+
return Math.floor((Date.now() - this.fetchedAtMs) / 1000);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../src/mailstore/metadata.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,OAAO,eAAe;IAMP;IACA;IACA;IAPX,KAAK,CAAoC;IACzC,WAAW,GAAG,CAAC,CAAC;IAChB,QAAQ,CAA6C;IAE7D,YACmB,MAAwB,EACxB,UAAkB,EAClB,MAAc;QAFd,WAAM,GAAN,MAAM,CAAkB;QACxB,eAAU,GAAV,UAAU,CAAQ;QAClB,WAAM,GAAN,MAAM,CAAQ;IAC9B,CAAC;IAEJ,4DAA4D;IAC5D,KAAK,CAAC,GAAG,CAAC,YAAY,GAAG,KAAK;QAC5B,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC;QAC5C,MAAM,OAAO,GAAG,KAAK,GAAG,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QAC/C,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC;YAC5C,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;QACD,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAO,IAAI,CAAC,QAAQ,CAAC;QAExC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM;aACxB,WAAW,EAAE;aACb,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;YACZ,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;YACjB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAC9B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,+BAA+B,CAAC,CAAC;YACjF,OAAO,GAAG,CAAC;QACb,CAAC,CAAC;aACD,OAAO,CAAC,GAAG,EAAE;YACZ,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC5B,CAAC,CAAC,CAAC;QAEL,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,yCAAyC;IACzC,UAAU;QACR,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;IACvB,CAAC;IAED,IAAI,UAAU;QACZ,IAAI,CAAC,IAAI,CAAC,KAAK;YAAE,OAAO,SAAS,CAAC;QAClC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,CAAC;IAC5D,CAAC;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { MailStoreOperation, MailStoreResponse } from './types.js';
|
|
2
|
+
export interface PollDeps {
|
|
3
|
+
/** Perform one get-status long-poll for the given token/version. */
|
|
4
|
+
getStatus: (token: string, lastKnownStatusVersion: number, signal: AbortSignal) => Promise<MailStoreResponse>;
|
|
5
|
+
operationTimeoutMs: number;
|
|
6
|
+
signal?: AbortSignal;
|
|
7
|
+
onProgress?: (op: MailStoreOperation) => void;
|
|
8
|
+
/** Optional sleep hook (injectable for tests). */
|
|
9
|
+
sleep?: (ms: number) => Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Poll /api/get-status until the operation reaches a terminal state or the
|
|
13
|
+
* overall operation timeout expires. Uses long polling (the server holds each
|
|
14
|
+
* request up to its long-poll window), not rapid polling. Honours cancellation
|
|
15
|
+
* via `signal`. The MailStore token is never surfaced to callers here — it stays
|
|
16
|
+
* internal to the polling loop.
|
|
17
|
+
*/
|
|
18
|
+
export declare function pollUntilTerminal(functionName: string, initialToken: string, initialStatusVersion: number, deps: PollDeps): Promise<MailStoreOperation>;
|
|
19
|
+
export declare function envelopeToOperation(functionName: string, envelope: MailStoreResponse): MailStoreOperation;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { isTerminalStatus } from './types.js';
|
|
2
|
+
import { Errors } from './errors.js';
|
|
3
|
+
const defaultSleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
4
|
+
/**
|
|
5
|
+
* Poll /api/get-status until the operation reaches a terminal state or the
|
|
6
|
+
* overall operation timeout expires. Uses long polling (the server holds each
|
|
7
|
+
* request up to its long-poll window), not rapid polling. Honours cancellation
|
|
8
|
+
* via `signal`. The MailStore token is never surfaced to callers here — it stays
|
|
9
|
+
* internal to the polling loop.
|
|
10
|
+
*/
|
|
11
|
+
export async function pollUntilTerminal(functionName, initialToken, initialStatusVersion, deps) {
|
|
12
|
+
const deadline = Date.now() + deps.operationTimeoutMs;
|
|
13
|
+
const sleep = deps.sleep ?? defaultSleep;
|
|
14
|
+
let lastKnownStatusVersion = initialStatusVersion;
|
|
15
|
+
let attempt = 0;
|
|
16
|
+
for (;;) {
|
|
17
|
+
if (deps.signal?.aborted) {
|
|
18
|
+
throw Errors.operationFailed(`Operation "${functionName}" was cancelled`, { functionName });
|
|
19
|
+
}
|
|
20
|
+
if (Date.now() >= deadline) {
|
|
21
|
+
throw Errors.operationTimeout(`Operation "${functionName}" did not complete within the configured timeout`, { functionName });
|
|
22
|
+
}
|
|
23
|
+
// Compose per-poll cancellation from the caller signal and remaining time.
|
|
24
|
+
const remaining = Math.max(1000, deadline - Date.now());
|
|
25
|
+
const pollSignal = composeSignal(deps.signal, remaining);
|
|
26
|
+
let envelope;
|
|
27
|
+
try {
|
|
28
|
+
envelope = await deps.getStatus(initialToken, lastKnownStatusVersion, pollSignal);
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
// A poll that aborts due to the remaining-time window is not fatal on its
|
|
32
|
+
// own — loop back to re-check the overall deadline. Other errors bubble.
|
|
33
|
+
if (isAbortError(err) && !deps.signal?.aborted && Date.now() < deadline) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
throw err;
|
|
37
|
+
}
|
|
38
|
+
if (typeof envelope.statusVersion === 'number') {
|
|
39
|
+
lastKnownStatusVersion = envelope.statusVersion;
|
|
40
|
+
}
|
|
41
|
+
const op = envelopeToOperation(functionName, envelope);
|
|
42
|
+
deps.onProgress?.(op);
|
|
43
|
+
if (op.completed)
|
|
44
|
+
return op;
|
|
45
|
+
// Small backoff between long-poll cycles to avoid a hot loop if the server
|
|
46
|
+
// returns immediately without a status change.
|
|
47
|
+
attempt += 1;
|
|
48
|
+
await sleep(Math.min(2000, 100 * attempt));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export function envelopeToOperation(functionName, envelope) {
|
|
52
|
+
return {
|
|
53
|
+
functionName,
|
|
54
|
+
statusCode: envelope.statusCode,
|
|
55
|
+
statusVersion: envelope.statusVersion,
|
|
56
|
+
token: envelope.token,
|
|
57
|
+
percentProgress: envelope.percentProgress,
|
|
58
|
+
statusText: envelope.statusText,
|
|
59
|
+
result: envelope.result,
|
|
60
|
+
logOutput: envelope.logOutput,
|
|
61
|
+
completed: isTerminalStatus(envelope.statusCode),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function composeSignal(outer, timeoutMs) {
|
|
65
|
+
const timeout = AbortSignal.timeout(timeoutMs);
|
|
66
|
+
return outer ? AbortSignal.any([outer, timeout]) : timeout;
|
|
67
|
+
}
|
|
68
|
+
function isAbortError(err) {
|
|
69
|
+
return (err instanceof Error &&
|
|
70
|
+
(err.name === 'AbortError' || err.name === 'TimeoutError' || err.code === 'ABORT_ERR'));
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=operation-poller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-poller.js","sourceRoot":"","sources":["../../src/mailstore/operation-poller.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAgBrC,MAAM,YAAY,GAAG,CAAC,EAAU,EAAiB,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAE1F;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,YAAoB,EACpB,YAAoB,EACpB,oBAA4B,EAC5B,IAAc;IAEd,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,kBAAkB,CAAC;IACtD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,YAAY,CAAC;IACzC,IAAI,sBAAsB,GAAG,oBAAoB,CAAC;IAClD,IAAI,OAAO,GAAG,CAAC,CAAC;IAEhB,SAAS,CAAC;QACR,IAAI,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;YACzB,MAAM,MAAM,CAAC,eAAe,CAAC,cAAc,YAAY,iBAAiB,EAAE,EAAE,YAAY,EAAE,CAAC,CAA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,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,YAAoB,EACpB,QAA2B;IAE3B,OAAO;QACL,YAAY;QACZ,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,aAAa,EAAE,QAAQ,CAAC,aAAa;QACrC,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,eAAe,EAAE,QAAQ,CAAC,eAAe;QACzC,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,SAAS,EAAE,gBAAgB,CAAC,QAAQ,CAAC,UAAU,CAAC;KACjD,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,KAA8B,EAAE,SAAiB;IACtE,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC/C,OAAO,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AAC7D,CAAC;AAED,SAAS,YAAY,CAAC,GAAY;IAChC,OAAO,CACL,GAAG,YAAY,KAAK;QACpB,CAAC,GAAG,CAAC,IAAI,KAAK,YAAY,IAAI,GAAG,CAAC,IAAI,KAAK,cAAc,IAAK,GAAyB,CAAC,IAAI,KAAK,WAAW,CAAC,CAC9G,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { MailStoreResponse, MailStoreApiError } from './types.js';
|
|
2
|
+
/** Strip a single leading UTF-8 BOM (EF BB BF / U+FEFF) if present. */
|
|
3
|
+
export declare function stripBom(text: string): string;
|
|
4
|
+
/**
|
|
5
|
+
* Parse a raw MailStore response body into the common envelope. Treats the body
|
|
6
|
+
* as untrusted: strips a BOM, parses JSON defensively, and normalises the
|
|
7
|
+
* envelope fields, tolerating undocumented variations and missing fields.
|
|
8
|
+
*/
|
|
9
|
+
export declare function parseEnvelope<T = unknown>(rawBody: string): MailStoreResponse<T>;
|
|
10
|
+
/** Extract a human-readable message from an envelope error field. */
|
|
11
|
+
export declare function errorMessage(err: MailStoreApiError | string | null): string;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { McpError } from './errors.js';
|
|
2
|
+
/** Strip a single leading UTF-8 BOM (EF BB BF / U+FEFF) if present. */
|
|
3
|
+
export function stripBom(text) {
|
|
4
|
+
if (text.charCodeAt(0) === 0xfeff)
|
|
5
|
+
return text.slice(1);
|
|
6
|
+
return text;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Parse a raw MailStore response body into the common envelope. Treats the body
|
|
10
|
+
* as untrusted: strips a BOM, parses JSON defensively, and normalises the
|
|
11
|
+
* envelope fields, tolerating undocumented variations and missing fields.
|
|
12
|
+
*/
|
|
13
|
+
export function parseEnvelope(rawBody) {
|
|
14
|
+
const text = stripBom(rawBody).trim();
|
|
15
|
+
let json;
|
|
16
|
+
try {
|
|
17
|
+
json = text.length === 0 ? {} : JSON.parse(text);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
throw new McpError('MAILSTORE_API_ERROR', 'MailStore returned a non-JSON response body', {
|
|
21
|
+
bodySnippet: text.slice(0, 200),
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
if (json === null || typeof json !== 'object' || Array.isArray(json)) {
|
|
25
|
+
// Some endpoints may return a bare value; wrap it as a succeeded result.
|
|
26
|
+
return {
|
|
27
|
+
error: null,
|
|
28
|
+
token: null,
|
|
29
|
+
statusVersion: 0,
|
|
30
|
+
statusCode: 'succeeded',
|
|
31
|
+
percentProgress: null,
|
|
32
|
+
statusText: null,
|
|
33
|
+
result: json,
|
|
34
|
+
logOutput: null,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const obj = json;
|
|
38
|
+
return {
|
|
39
|
+
error: normaliseError(obj['error']),
|
|
40
|
+
token: typeof obj['token'] === 'string' ? obj['token'] : null,
|
|
41
|
+
statusVersion: typeof obj['statusVersion'] === 'number' ? obj['statusVersion'] : 0,
|
|
42
|
+
statusCode: typeof obj['statusCode'] === 'string' ? obj['statusCode'] : 'succeeded',
|
|
43
|
+
percentProgress: typeof obj['percentProgress'] === 'number' ? obj['percentProgress'] : null,
|
|
44
|
+
statusText: typeof obj['statusText'] === 'string' ? obj['statusText'] : null,
|
|
45
|
+
result: (obj['result'] ?? null),
|
|
46
|
+
logOutput: typeof obj['logOutput'] === 'string' ? obj['logOutput'] : null,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function normaliseError(err) {
|
|
50
|
+
if (err === null || err === undefined)
|
|
51
|
+
return null;
|
|
52
|
+
if (typeof err === 'string')
|
|
53
|
+
return err.length > 0 ? err : null;
|
|
54
|
+
if (typeof err === 'object')
|
|
55
|
+
return err;
|
|
56
|
+
return String(err);
|
|
57
|
+
}
|
|
58
|
+
/** Extract a human-readable message from an envelope error field. */
|
|
59
|
+
export function errorMessage(err) {
|
|
60
|
+
if (err === null)
|
|
61
|
+
return 'Unknown MailStore error';
|
|
62
|
+
if (typeof err === 'string')
|
|
63
|
+
return err;
|
|
64
|
+
return err.message ?? err.details ?? 'Unknown MailStore error';
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=response-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-parser.js","sourceRoot":"","sources":["../../src/mailstore/response-parser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,uEAAuE;AACvE,MAAM,UAAU,QAAQ,CAAC,IAAY;IACnC,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACxD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,C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