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 +12 -2
- package/package.json +1 -1
- package/src/mailisk.interfaces.ts +13 -1
- package/src/mailisk.ts +2 -2
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
|
-
-
|
|
62
|
-
-
|
|
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
|
@@ -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,
|
|
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) -
|
|
105
|
+
_params.from_timestamp = Math.floor(new Date().getTime() / 1000) - 15 * 60;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
// by default wait for email
|