@bobfrankston/iflow-direct 0.1.11 → 0.1.12
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/imap-compat.d.ts +11 -1
- package/imap-compat.js +17 -3
- package/package.json +1 -1
package/imap-compat.d.ts
CHANGED
|
@@ -49,10 +49,20 @@ export declare class CompatImapClient {
|
|
|
49
49
|
getMessagesCount(mailbox: string): Promise<number>;
|
|
50
50
|
/** Get all UIDs in a mailbox */
|
|
51
51
|
getUids(mailbox: string): Promise<number[]>;
|
|
52
|
-
/** Fetch messages
|
|
52
|
+
/** Fetch messages — supports two calling conventions for compatibility:
|
|
53
|
+
*
|
|
54
|
+
* New: fetchMessages(mailbox, "100:200") — UID range string
|
|
55
|
+
* Old: fetchMessages(mailbox, endSeq, count) — sequence-number range (iflow compat)
|
|
56
|
+
*
|
|
57
|
+
* The old form computes UID range "start:end" from (end - count + 1) : end,
|
|
58
|
+
* matching the legacy iflow/imapflow fetchMessages(mailbox, end, count) API
|
|
59
|
+
* used by the puller. */
|
|
53
60
|
fetchMessages(mailbox: string, uidRange: string, options?: {
|
|
54
61
|
source?: boolean;
|
|
55
62
|
}): Promise<any[]>;
|
|
63
|
+
fetchMessages(mailbox: string, end: number, count: number, options?: {
|
|
64
|
+
source?: boolean;
|
|
65
|
+
}): Promise<any[]>;
|
|
56
66
|
/** Search messages in a mailbox */
|
|
57
67
|
searchMessages(mailbox: string, criteria: any): Promise<number[]>;
|
|
58
68
|
/** Search by header value — returns matching UIDs */
|
package/imap-compat.js
CHANGED
|
@@ -160,11 +160,25 @@ export class CompatImapClient {
|
|
|
160
160
|
await this.native.closeMailbox();
|
|
161
161
|
return uids;
|
|
162
162
|
}
|
|
163
|
-
|
|
164
|
-
|
|
163
|
+
async fetchMessages(mailbox, rangeOrEnd, countOrOptions, maybeOptions) {
|
|
164
|
+
let range;
|
|
165
|
+
let options;
|
|
166
|
+
if (typeof rangeOrEnd === "number") {
|
|
167
|
+
// Legacy (iflow) calling convention: (mailbox, endSeq, count, options?)
|
|
168
|
+
const end = rangeOrEnd;
|
|
169
|
+
const count = typeof countOrOptions === "number" ? countOrOptions : 1;
|
|
170
|
+
const start = Math.max(1, end - count + 1);
|
|
171
|
+
range = `${start}:${end}`;
|
|
172
|
+
options = maybeOptions;
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
// New calling convention: (mailbox, uidRange, options?)
|
|
176
|
+
range = rangeOrEnd;
|
|
177
|
+
options = typeof countOrOptions === "object" ? countOrOptions : undefined;
|
|
178
|
+
}
|
|
165
179
|
await this.ensureConnected();
|
|
166
180
|
await this.native.select(mailbox);
|
|
167
|
-
const msgs = await this.native.fetchMessages(
|
|
181
|
+
const msgs = await this.native.fetchMessages(range, options);
|
|
168
182
|
await this.native.closeMailbox();
|
|
169
183
|
return msgs.map(toCompatMessage);
|
|
170
184
|
}
|