imapflow 2.0.6 → 2.0.8

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 (78) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/commands/append.js +12 -12
  3. package/dist/cjs/commands/authenticate.d.ts +3 -8
  4. package/dist/cjs/commands/close.js +2 -1
  5. package/dist/cjs/commands/copy.js +4 -4
  6. package/dist/cjs/commands/create.js +2 -3
  7. package/dist/cjs/commands/delete.js +4 -4
  8. package/dist/cjs/commands/expunge.js +8 -5
  9. package/dist/cjs/commands/fetch.js +12 -10
  10. package/dist/cjs/commands/idle.js +6 -2
  11. package/dist/cjs/commands/list.js +2 -2
  12. package/dist/cjs/commands/move.js +11 -6
  13. package/dist/cjs/commands/namespace.js +1 -1
  14. package/dist/cjs/commands/quota.js +10 -9
  15. package/dist/cjs/commands/rename.js +4 -4
  16. package/dist/cjs/commands/search.js +7 -8
  17. package/dist/cjs/commands/select.js +5 -6
  18. package/dist/cjs/commands/status.js +11 -11
  19. package/dist/cjs/commands/store.js +5 -5
  20. package/dist/cjs/commands/subscribe.js +2 -17
  21. package/dist/cjs/commands/subscription.d.ts +10 -0
  22. package/dist/cjs/commands/subscription.js +29 -0
  23. package/dist/cjs/commands/unsubscribe.js +2 -17
  24. package/dist/cjs/download.d.ts +22 -0
  25. package/dist/cjs/download.js +588 -0
  26. package/dist/cjs/errors.d.ts +2 -0
  27. package/dist/cjs/handler/imap-compiler.js +1 -1
  28. package/dist/cjs/handler/imap-stream.js +4 -4
  29. package/dist/cjs/handler/parser-instance.js +2 -2
  30. package/dist/cjs/handler/token-parser.js +1 -1
  31. package/dist/cjs/imap-flow.d.ts +16 -7
  32. package/dist/cjs/imap-flow.js +247 -730
  33. package/dist/cjs/jp-decoder.js +1 -1
  34. package/dist/cjs/package-info.d.ts +1 -1
  35. package/dist/cjs/package-info.js +3 -3
  36. package/dist/cjs/search-compiler.js +5 -12
  37. package/dist/cjs/tools.d.ts +51 -10
  38. package/dist/cjs/tools.js +83 -15
  39. package/dist/cjs/types.d.ts +30 -16
  40. package/dist/esm/commands/append.js +13 -13
  41. package/dist/esm/commands/authenticate.d.ts +3 -8
  42. package/dist/esm/commands/close.js +2 -1
  43. package/dist/esm/commands/copy.js +5 -5
  44. package/dist/esm/commands/create.js +3 -4
  45. package/dist/esm/commands/delete.js +5 -5
  46. package/dist/esm/commands/expunge.js +9 -6
  47. package/dist/esm/commands/fetch.js +13 -11
  48. package/dist/esm/commands/idle.js +7 -3
  49. package/dist/esm/commands/list.js +2 -2
  50. package/dist/esm/commands/move.js +12 -7
  51. package/dist/esm/commands/namespace.js +2 -2
  52. package/dist/esm/commands/quota.js +11 -10
  53. package/dist/esm/commands/rename.js +5 -5
  54. package/dist/esm/commands/search.js +8 -9
  55. package/dist/esm/commands/select.js +6 -7
  56. package/dist/esm/commands/status.js +12 -12
  57. package/dist/esm/commands/store.js +6 -6
  58. package/dist/esm/commands/subscribe.js +2 -17
  59. package/dist/esm/commands/subscription.d.ts +10 -0
  60. package/dist/esm/commands/subscription.js +26 -0
  61. package/dist/esm/commands/unsubscribe.js +2 -17
  62. package/dist/esm/download.d.ts +22 -0
  63. package/dist/esm/download.js +581 -0
  64. package/dist/esm/errors.d.ts +2 -0
  65. package/dist/esm/handler/imap-compiler.js +1 -1
  66. package/dist/esm/handler/imap-stream.js +4 -4
  67. package/dist/esm/handler/parser-instance.js +2 -2
  68. package/dist/esm/handler/token-parser.js +1 -1
  69. package/dist/esm/imap-flow.d.ts +16 -7
  70. package/dist/esm/imap-flow.js +248 -731
  71. package/dist/esm/jp-decoder.js +1 -1
  72. package/dist/esm/package-info.d.ts +1 -1
  73. package/dist/esm/package-info.js +3 -3
  74. package/dist/esm/search-compiler.js +5 -12
  75. package/dist/esm/tools.d.ts +51 -10
  76. package/dist/esm/tools.js +78 -15
  77. package/dist/esm/types.d.ts +30 -16
  78. package/package.json +4 -4
@@ -6,7 +6,7 @@ import net from 'node:net';
6
6
  import { EventEmitter } from 'node:events';
7
7
  import { PassThrough, type Readable } from 'node:stream';
8
8
  import { AuthenticationFailure } from './errors.js';
9
- import type { AppendResponseObject, CopyResponseObject, DownloadManyOptions, DownloadManyResult, DownloadObject, DownloadOptions, ESearchResult, FetchMessageObject, FetchOptions, FetchQueryObject, IdInfoObject, ImapFlowEvents, ImapFlowOptions, InternalLogger, ListOptions, ListResponse, ListTreeResponse, MailboxCreateResponse, MailboxDeleteResponse, MailboxLockObject, MailboxLockOptions, MailboxObject, MailboxOpenOptions, MailboxRenameResponse, MessageRange, MessageRangeOptions, NamespaceObject, NamespacesObject, QuotaResponse, SearchObject, SearchOptions, SearchReturnOption, SequenceString, StatusObject, StatusQuery, StoreOptions, TlsInfo } from './types.js';
9
+ import type { AppendResponseObject, CopyResponseObject, DownloadManyOptions, DownloadManyResult, DownloadObject, DownloadNotFound, DownloadOptions, ESearchResult, FetchMessageObject, FetchOptions, FetchQueryObject, IdInfoObject, ImapFlowEvents, ImapFlowOptions, InternalLogger, ListOptions, ListResponse, ListTreeResponse, MailboxCreateResponse, MailboxDeleteResponse, MailboxLockObject, MailboxLockOptions, MailboxObject, MailboxOpenOptions, MailboxRenameResponse, MessageRange, MessageRangeOptions, NamespaceObject, NamespacesObject, QuotaResponse, SearchObject, SearchOptions, SearchReturnOption, SequenceString, StatusObject, StatusQuery, StoreOptions, TlsInfo } from './types.js';
10
10
  export type * from './types.js';
11
11
  export type { ImapFlowError } from './errors.js';
12
12
  export { AuthenticationFailure } from './errors.js';
@@ -135,6 +135,9 @@ export declare class ImapFlow extends EventEmitter {
135
135
  byeReason: string | undefined;
136
136
  /** Negotiated TLS session details, `false` for a cleartext connection */
137
137
  tls: TlsInfo | false | undefined;
138
+ /**
139
+ * Creates a client for one IMAP connection. Nothing is sent before `connect()` is called
140
+ */
138
141
  constructor(options?: ImapFlowOptions | undefined);
139
142
  /**
140
143
  * Returns byte counters for the current connection.
@@ -315,20 +318,20 @@ export declare class ImapFlow extends EventEmitter {
315
318
  *
316
319
  * @param path mailbox path to check for (unicode string). If value is an array then it is joined using current delimiter symbols. Namespace prefix is added automatically if required.
317
320
  * @param query defines requested status items
318
- * @returns status of the indicated mailbox
321
+ * @returns status of the indicated mailbox, or `false` if the server rejected the request
319
322
  *
320
323
  * @example
321
324
  * let status = await client.status('INBOX', {unseen: true});
322
325
  * console.log(status.unseen);
323
326
  * // 123
324
327
  */
325
- status(path: string | string[], query: StatusQuery): Promise<StatusObject>;
328
+ status(path: string | string[], query: StatusQuery): Promise<StatusObject | false>;
326
329
  /**
327
330
  * Starts listening for new or deleted messages from the currently opened mailbox. Only required if `disableAutoIdle` is set to `true`
328
331
  * otherwise IDLE is started by default on connection inactivity. NB! If `idle()` is called manually then it does not
329
332
  * return until IDLE is finished which means you would have to call some other command out of scope.
330
333
  *
331
- * @returns Did the operation succeed or not
334
+ * @returns `false` if IDLE failed, `undefined` otherwise
332
335
  *
333
336
  * @example
334
337
  * let mailbox = await client.mailboxOpen('INBOX');
@@ -470,6 +473,10 @@ export declare class ImapFlow extends EventEmitter {
470
473
  * ]});
471
474
  */
472
475
  search(query: SearchObject, options?: MessageRangeOptions | undefined): Promise<number[] | false | undefined>;
476
+ /**
477
+ * Search with `returnOptions` set: an ESEARCH result object from a server that supports
478
+ * ESEARCH, the plain list of numbers otherwise
479
+ */
473
480
  search(query: SearchObject, options: SearchOptions & {
474
481
  returnOptions: SearchReturnOption[];
475
482
  }): Promise<ESearchResult | number[] | false | undefined>;
@@ -540,10 +547,12 @@ export declare class ImapFlow extends EventEmitter {
540
547
  * @example
541
548
  * let mailbox = await client.mailboxOpen('INBOX');
542
549
  * // download body part nr '1.2' from latest message
543
- * let {meta, content} = await client.download('*', '1.2');
544
- * content.pipe(fs.createWriteStream(meta.filename));
550
+ * let download = await client.download('*', '1.2');
551
+ * if (download.content) {
552
+ * download.content.pipe(fs.createWriteStream(download.meta.filename));
553
+ * }
545
554
  */
546
- download(range: SequenceString, part?: string | undefined, options?: DownloadOptions | undefined): Promise<DownloadObject>;
555
+ download(range: SequenceString, part?: string | undefined, options?: DownloadOptions | undefined): Promise<DownloadObject | DownloadNotFound>;
547
556
  /**
548
557
  * Fetch multiple attachments as Buffer values
549
558
  *