imapflow 1.0.163 → 1.0.164

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.0.164](https://github.com/postalsys/imapflow/compare/v1.0.163...v1.0.164) (2024-07-09)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **api:** Add fetchAll method ([#207](https://github.com/postalsys/imapflow/issues/207)) ([bc09998](https://github.com/postalsys/imapflow/commit/bc09998270006ea6ff8430b3461619dd9b3e91c8))
9
+
3
10
  ## [1.0.163](https://github.com/postalsys/imapflow/compare/v1.0.162...v1.0.163) (2024-07-06)
4
11
 
5
12
 
package/lib/imap-flow.js CHANGED
@@ -2010,7 +2010,7 @@ class ImapFlow extends EventEmitter {
2010
2010
  }
2011
2011
 
2012
2012
  /**
2013
- * Delete messages from currently opened mailbox. Method does not indicate info about deleted messages,
2013
+ * Delete messages from the currently opened mailbox. Method does not indicate info about deleted messages,
2014
2014
  * instead you should be using {@link ImapFlow#expunge} event for this
2015
2015
  *
2016
2016
  * @param {SequenceString | Number[] | SearchObject} range Range to filter the messages
@@ -2121,7 +2121,7 @@ class ImapFlow extends EventEmitter {
2121
2121
  }
2122
2122
 
2123
2123
  /**
2124
- * Search messages from currently opened mailbox
2124
+ * Search messages from the currently opened mailbox
2125
2125
  *
2126
2126
  * @param {SearchObject} query Query to filter the messages
2127
2127
  * @param {Object} [options]
@@ -2240,7 +2240,7 @@ class ImapFlow extends EventEmitter {
2240
2240
  */
2241
2241
 
2242
2242
  /**
2243
- * Fetch messages from currently opened mailbox
2243
+ * Fetch messages from the currently opened mailbox
2244
2244
  *
2245
2245
  * @param {SequenceString | Number[] | SearchObject} range Range of messages to fetch
2246
2246
  * @param {FetchQueryObject} query Fetch query
@@ -2353,7 +2353,38 @@ class ImapFlow extends EventEmitter {
2353
2353
  }
2354
2354
 
2355
2355
  /**
2356
- * Fetch a single message from currently opened mailbox
2356
+ * Fetch messages from the currently opened mailbox.
2357
+ *
2358
+ * This method will fetch all messages before resolving the promise, unlike .fetch(), which
2359
+ * is an async generator. Do not use large ranges like 1:*, as this might exhaust all available
2360
+ * memory if the mailbox contains a large number of emails.
2361
+ * @param {SequenceString | Number[] | SearchObject} range Range of messages to fetch
2362
+ * @param {FetchQueryObject} query Fetch query
2363
+ * @param {Object} [options]
2364
+ * @param {Boolean} [options.uid] If `true` then uses UID numbers instead of sequence numbers for `range`
2365
+ * @param {BigInt} [options.changedSince] If set then only messages with a higher modseq value are returned. Ignored if server does not support `CONDSTORE` extension.
2366
+ * @param {Boolean} [options.binary=false] If `true` then requests a binary response if the server supports this
2367
+ * @returns {Promise<FetchMessageObject[]>} Array of Message data object
2368
+ *
2369
+ * @example
2370
+ * let mailbox = await client.mailboxOpen('INBOX');
2371
+ * // fetch UID for all messages in a mailbox
2372
+ * const messages = await client.fetchAll('1:*', {uid: true});
2373
+ * for (let msg of messages){
2374
+ * console.log(msg.uid);
2375
+ * }
2376
+ */
2377
+ async fetchAll(range, query, options) {
2378
+ const results = [];
2379
+ const generator = this.fetch(range, query, options);
2380
+ for await (const message of generator) {
2381
+ results.push(message);
2382
+ }
2383
+ return results;
2384
+ }
2385
+
2386
+ /**
2387
+ * Fetch a single message from the currently opened mailbox
2357
2388
  *
2358
2389
  * @param {SequenceString} seq Single UID or sequence number of the message to fetch for
2359
2390
  * @param {FetchQueryObject} query Fetch query
package/lib/types.d.ts CHANGED
@@ -355,7 +355,7 @@ declare module "imapflow" {
355
355
  unchangedSince?: bigint;
356
356
  }): Promise<Boolean>;
357
357
  /**
358
- * Delete messages from currently opened mailbox. Method does not indicate info about deleted messages,
358
+ * Delete messages from the currently opened mailbox. Method does not indicate info about deleted messages,
359
359
  * instead you should be using {@link ImapFlow#expunge} event for this
360
360
  * @example
361
361
  * let mailbox = await client.mailboxOpen('INBOX');
@@ -410,7 +410,7 @@ declare module "imapflow" {
410
410
  uid?: boolean;
411
411
  }): Promise<CopyResponseObject>;
412
412
  /**
413
- * Search messages from currently opened mailbox
413
+ * Search messages from the currently opened mailbox
414
414
  * @example
415
415
  * let mailbox = await client.mailboxOpen('INBOX');
416
416
  * // find all unseen messages
@@ -431,7 +431,7 @@ declare module "imapflow" {
431
431
  uid?: boolean;
432
432
  }): Promise<Number[]>;
433
433
  /**
434
- * Fetch messages from currently opened mailbox
434
+ * Fetch messages from the currently opened mailbox
435
435
  * @example
436
436
  * let mailbox = await client.mailboxOpen('INBOX');
437
437
  * // fetch UID for all messages in a mailbox
@@ -452,7 +452,32 @@ declare module "imapflow" {
452
452
  binary?: boolean;
453
453
  }): void;
454
454
  /**
455
- * Fetch a single message from currently opened mailbox
455
+ * Fetch messages from the currently opened mailbox.
456
+ *
457
+ * This method will fetch all messages before resolving the promise, unlike .fetch(), which
458
+ * is an async generator. Do not use large ranges like 1:*, as this might exhaust all available
459
+ * memory if the mailbox contains a large number of emails.
460
+ * @example
461
+ * let mailbox = await client.mailboxOpen('INBOX');
462
+ * // fetch UID for all messages in a mailbox
463
+ * const messages = await client.fetchAll('1:*', {uid: true});
464
+ * for (let msg of messages){
465
+ * console.log(msg.uid);
466
+ * }
467
+ * @param range - Range of messages to fetch
468
+ * @param query - Fetch query
469
+ * @param [options.uid] - If `true` then uses UID numbers instead of sequence numbers for `range`
470
+ * @param [options.changedSince] - If set then only messages with a higher modseq value are returned. Ignored if server does not support `CONDSTORE` extension.
471
+ * @param [options.binary = false] - If `true` then requests a binary response if the server supports this
472
+ * @returns Array of Message data object
473
+ */
474
+ fetchAll(range: SequenceString | Number[] | SearchObject, query: FetchQueryObject, options?: {
475
+ uid?: boolean;
476
+ changedSince?: bigint;
477
+ binary?: boolean;
478
+ }): Promise<FetchMessageObject[]>;
479
+ /**
480
+ * Fetch a single message from the currently opened mailbox
456
481
  * @example
457
482
  * let mailbox = await client.mailboxOpen('INBOX');
458
483
  * // fetch UID for the last email in the selected mailbox
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imapflow",
3
- "version": "1.0.163",
3
+ "version": "1.0.164",
4
4
  "description": "IMAP Client for Node",
5
5
  "main": "./lib/imap-flow.js",
6
6
  "scripts": {