mailisk 1.0.3 → 2.0.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 CHANGED
@@ -58,8 +58,18 @@ This library wraps the REST API endpoints. Find out more in the [API Reference](
58
58
 
59
59
  The `searchInbox` function takes a namespace and call parameters.
60
60
 
61
- - It uses the `wait` property by default. This means the call won't timeout until a result is returned or 5 minutes pass. This is adjustable by passing the `timeout` paramter (it can also be disabled by passing `wait: false`).
62
- - It uses a default `from_timestamp` of **current timestamp - 5 seconds**. This means that older emails will be ignored. This can be overriden by passing the `from_timestamp` parameter (`from_timestmap: 0` will disable filtering by email age).
61
+ - By default it uses the `wait` flag. This means the call won't return until at least one email is received. Disabling this flag via `wait: false` can cause it to return an empty response immediately.
62
+ - The request timeout is adjustable by passing `timeout` in the request options. By default it uses a timeout of 5 minutes.
63
+ - By default `from_timestamp` is set to **current timestamp - 5 seconds**. This ensures that only new emails are returned. Without this, older emails would also be returned, potentially disrupting you if you were waiting for a specific email. This can be overriden by passing the `from_timestamp` parameter (`from_timestmap: 0` will disable filtering by email age).
64
+
65
+ ```js
66
+ // timeout of 5 minutes
67
+ await mailisk.searchInbox(namespace);
68
+ // timeout of 1 minute
69
+ await mailisk.searchInbox(namespace, {}, { timeout: 1000 * 60 });
70
+ // returns immediately, even if the result would be empty
71
+ await mailisk.searchInbox(namespace, { wait: false });
72
+ ```
63
73
 
64
74
  #### Filter by destination address
65
75
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mailisk",
3
- "version": "1.0.3",
3
+ "version": "2.0.0",
4
4
  "description": "Mailisk library for NodeJS",
5
5
  "keywords": [
6
6
  "mailisk",
@@ -52,9 +52,21 @@ export interface SearchInboxParams {
52
52
  /**
53
53
  * Filter emails by 'to' address. Address must start with this.
54
54
  *
55
- * 'foo' would return 'foobar@namespace.mailisk.net' but not 'barfoo@namespace.mailisk.net'
55
+ * 'foo' would return for 'foobar@namespace.mailisk.net' but not 'barfoo@namespace.mailisk.net'
56
56
  */
57
57
  to_addr_prefix?: string;
58
+ /**
59
+ * Filter emails by 'from' address. Address must include this.
60
+ *
61
+ * '@foo' would return for 'a@foo.com', 'b@foo.net'
62
+ */
63
+ from_addr_includes?: string;
64
+ /**
65
+ * Filter emails by subject. This is case insensitive. Subject must include this.
66
+ *
67
+ * 'password' would return for 'Password reset', 'Reset password notification' but not 'Reset'
68
+ */
69
+ subject_includes?: string;
58
70
  /**
59
71
  * Will keep the request going till at least one email would be returned.
60
72
  *
package/src/mailisk.ts CHANGED
@@ -100,9 +100,9 @@ export class MailiskClient {
100
100
  ): Promise<SearchInboxResponse> {
101
101
  let _params = { ...params };
102
102
 
103
- // default from timestamp, 5 seconds before starting this request
103
+ // default from timestamp, 15 minutes before starting this request
104
104
  if (params?.from_timestamp === undefined || params?.from_timestamp === null) {
105
- _params.from_timestamp = Math.floor(new Date().getTime() / 1000) - 5;
105
+ _params.from_timestamp = Math.floor(new Date().getTime() / 1000) - 15 * 60;
106
106
  }
107
107
 
108
108
  // by default wait for email