|
| 1 | +# @conjoon/extjs-dev-webmailsim Documentation |
| 2 | + |
| 3 | +**extjs-dev-webmailsim** is a **coon.js** package and is tagged as such in the |
| 4 | +`package.json`: |
| 5 | + |
| 6 | +```json |
| 7 | +{ |
| 8 | + "coon-js": { |
| 9 | + "package": { |
| 10 | + "autoLoad": { |
| 11 | + "registerController": true |
| 12 | + }, |
| 13 | + "config" : "${package.resourcePath}/extjs-dev-webmailsim.conf.json" |
| 14 | + } |
| 15 | + } |
| 16 | +} |
| 17 | +``` |
| 18 | + |
| 19 | +By default, this package's configuration can be found in this package's `resources` folder |
| 20 | +in a file named `extjs-dev-webmailsim.conf.json`. |
| 21 | + |
| 22 | +## What goes into a `extjs-dev-webmailsim` configuration? |
| 23 | + |
| 24 | +The package intercepts outgoing network requests to all urls matching a specific |
| 25 | +url-pattern. Additionally, you can configure whether the package's url intercepting should |
| 26 | +be enabled or disabled - this makes it easier to use this package in environments where |
| 27 | +you have to test for fully functional network behavior with real HTTP-requests and live- and mock-data should be used side-by-side. |
| 28 | + |
| 29 | +The configuration file for this package has various entries representing entities and their endpoints: |
| 30 | +`mailAccount`, `mailFolder`, `messageItem` and `attachment`: |
| 31 | + |
| 32 | +```json |
| 33 | +{ |
| 34 | + "attachment": { |
| 35 | + "url": "https://ddev-ms-email.ddev.site/rest-api-email/api/v.*?/MailAccounts/(.+)/MailFolders/(.+)/MessageItems/(.+)/Attachments(/.*)?", |
| 36 | + "enabled": true, |
| 37 | + "delay": 250 |
| 38 | + }, |
| 39 | + "messageItem": { |
| 40 | + "url": "https://ddev-ms-email.ddev.site/rest-api-email/api/v.*?/MailAccounts/(.+)/MailFolders/(.+)/MessageItems(/.*)?", |
| 41 | + "enabled": true, |
| 42 | + "delay": 250 |
| 43 | + }, |
| 44 | + "mailFolder": { |
| 45 | + "url": "https://ddev-ms-email.ddev.site/rest-api-email/api/v.*?/MailAccounts/(.+)/MailFolders(/.*)?", |
| 46 | + "enabled": true, |
| 47 | + "delay": 250 |
| 48 | + }, |
| 49 | + "mailAccount": { |
| 50 | + "url": "https://ddev-ms-email.ddev.site/rest-api-email/api/v.*?/MailAccounts(/d+)?", |
| 51 | + "enabled": true, |
| 52 | + "delay": 250 |
| 53 | + } |
| 54 | +} |
| 55 | +``` |
| 56 | +Each entry in the configuration can be configured with |
| 57 | + |
| 58 | +- `url` - In order to properly intercept outgoing requests to the services as described in |
| 59 | + [rest-api-mail](https://github.com/conjoon/rest-api-description), the package needs |
| 60 | + to be configured with various regular expressions representing urls to catch. |
| 61 | + The package is pre-configured. For example, HTTP-requests to the following URLs are intercepted by this package: |
| 62 | + - `https://dev-ms-email.ddev.site/rest-api-email/api/v0/MailAccounts` |
| 63 | + - `https://dev-ms-email.ddev.site/rest-api-email/api/v1/MailAccounts/dev/MailFolders/INBOX.Sent/MessageItems/123` |
| 64 | + |
| 65 | +- `enabled` - If this package is used with your development or production environment, intercepting urls can be enabled/disabled by changing the property `enabled` |
| 66 | + to either `true` or `false`. |
| 67 | +- `delay` - the delay in milliseconds to mimic network latency |
| 68 | + |
| 69 | +### Order of matching URLs |
| 70 | +The Simmanager will consider url-matching in the order the urls are configured. |
| 71 | +Make sure more specific regular expressions are defined first, followed by more common ones. |
| 72 | + |
| 73 | +For example, the url `https://dev-ms-email.ddev.site/rest-api-email/api/v1/MailAccounts/dev/MailFolders/INBOX.Sent/MessageItems/123` |
| 74 | +would be intercepted by the regular expression defined with `mailFolder` (because it is defined _at first_), although it should be intercepted by `messageItem`: |
| 75 | + |
| 76 | +```json |
| 77 | +{ |
| 78 | + "mailFolder": { |
| 79 | + "url": "https://ddev-ms-email.ddev.site/rest-api-email/api/v.*?/MailAccounts/(.+)/MailFolders(/.*)?", |
| 80 | + "enabled": true, |
| 81 | + "delay": 250 |
| 82 | + }, |
| 83 | + "messageItem": { |
| 84 | + "url": "https://ddev-ms-email.ddev.site/rest-api-email/api/v.*?/MailAccounts/(.+)/MailFolders/(.+)/MessageItems(/.*)?", |
| 85 | + "enabled": true, |
| 86 | + "delay": 250 |
| 87 | + } |
| 88 | +} |
| 89 | +``` |
| 90 | + |
| 91 | +## Response Data |
| 92 | +If a request was intercepted, static data is returned to mimic responses of backends |
| 93 | +implementing the [REST API](https://github.com/conjoon/rest-api-description). The data returned |
| 94 | +can be edited in this package's `src/data/table/MessageTable.js` and `src/data/table/AttachmentTable.js`. |
0 commit comments