emailengine-app 2.75.0 → 2.77.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.
Files changed (113) hide show
  1. package/.github/workflows/release.yaml +24 -19
  2. package/.github/workflows/test.yml +0 -10
  3. package/.ncurc.js +14 -2
  4. package/.release-please-manifest.json +3 -0
  5. package/CHANGELOG.md +38 -0
  6. package/README.md +1 -1
  7. package/config/e2e.toml +1 -1
  8. package/data/google-crawlers.json +1 -1
  9. package/encrypt.js +71 -4
  10. package/lib/address-strategies.js +18 -0
  11. package/lib/api-reference/code-samples.js +194 -0
  12. package/lib/api-reference/format.js +179 -0
  13. package/lib/api-reference/index.js +205 -0
  14. package/lib/api-reference/model.js +336 -0
  15. package/lib/api-reference/schema-tree.js +366 -0
  16. package/lib/api-routes/account-routes.js +117 -37
  17. package/lib/api-routes/behavior-notes.js +54 -0
  18. package/lib/api-routes/blocklist-routes.js +9 -9
  19. package/lib/api-routes/changes-routes.js +6 -4
  20. package/lib/api-routes/chat-routes.js +3 -3
  21. package/lib/api-routes/delivery-test-routes.js +24 -6
  22. package/lib/api-routes/export-routes.js +14 -12
  23. package/lib/api-routes/gateway-routes.js +11 -11
  24. package/lib/api-routes/license-routes.js +7 -7
  25. package/lib/api-routes/mailbox-routes.js +18 -9
  26. package/lib/api-routes/message-routes.js +55 -35
  27. package/lib/api-routes/oauth2-app-routes.js +22 -16
  28. package/lib/api-routes/outbox-routes.js +7 -7
  29. package/lib/api-routes/pubsub-routes.js +3 -3
  30. package/lib/api-routes/route-helpers.js +3 -0
  31. package/lib/api-routes/settings-routes.js +10 -9
  32. package/lib/api-routes/stats-routes.js +3 -3
  33. package/lib/api-routes/submit-routes.js +213 -56
  34. package/lib/api-routes/template-routes.js +13 -13
  35. package/lib/api-routes/token-routes.js +15 -10
  36. package/lib/api-routes/webhook-route-routes.js +5 -5
  37. package/lib/consts.js +7 -0
  38. package/lib/email-client/base-client.js +230 -31
  39. package/lib/email-client/gmail/send-request.js +16 -1
  40. package/lib/email-client/gmail-client.js +89 -5
  41. package/lib/email-client/imap-client.js +103 -1
  42. package/lib/email-client/message-builder.js +24 -7
  43. package/lib/email-client/outlook/send-request.js +18 -1
  44. package/lib/email-client/outlook-client.js +79 -4
  45. package/lib/enum-descriptions.js +130 -0
  46. package/lib/imapproxy/imap-server.js +30 -26
  47. package/lib/imapproxy/upstream-client.js +38 -0
  48. package/lib/oauth2-apps.js +9 -3
  49. package/lib/openapi/build-document.js +318 -0
  50. package/lib/openapi/index.js +95 -0
  51. package/lib/openapi/joi-schema.js +523 -0
  52. package/lib/routes-ui.js +5 -1
  53. package/lib/schemas.js +76 -17
  54. package/lib/swagger-options.js +173 -0
  55. package/lib/tokens.js +69 -5
  56. package/lib/ui-routes/admin-entities-routes.js +3 -0
  57. package/lib/ui-routes/dashboard-routes.js +2 -26
  58. package/lib/ui-routes/reference-routes.js +195 -0
  59. package/lib/ui-routes/route-helpers.js +11 -0
  60. package/package.json +19 -26
  61. package/playwright.config.js +1 -1
  62. package/prepare-bundle-deps.sh +28 -0
  63. package/release-please-config.json +11 -0
  64. package/sbom.json +0 -1
  65. package/server.js +22 -2
  66. package/static/css/flyonui.css +1 -1
  67. package/static/css/src/app.tailwind.css +90 -0
  68. package/static/js/ee-client.js +238 -8
  69. package/static/js/reference.js +736 -0
  70. package/static/js/ui.js +61 -33
  71. package/static/licenses.html +16 -16
  72. package/translations/messages.pot +13 -13
  73. package/views/config/ai.hbs +1 -1
  74. package/views/config/document-store/chat.hbs +5 -5
  75. package/views/config/document-store/index.hbs +2 -2
  76. package/views/config/document-store/pre-processing/index.hbs +1 -1
  77. package/views/config/email-processing.hbs +1 -1
  78. package/views/config/imap-proxy.hbs +1 -1
  79. package/views/config/license.hbs +1 -1
  80. package/views/config/oauth/index.hbs +3 -3
  81. package/views/config/security.hbs +1 -1
  82. package/views/config/smtp.hbs +2 -2
  83. package/views/dashboard.hbs +1 -1
  84. package/views/layout/app.hbs +18 -7
  85. package/views/partials/oauth_form.hbs +4 -4
  86. package/views/partials/reference/anchor-link.hbs +20 -0
  87. package/views/partials/reference/disclosure.hbs +37 -0
  88. package/views/partials/reference/nav.hbs +93 -0
  89. package/views/partials/reference/operation.hbs +127 -0
  90. package/views/partials/reference/params.hbs +20 -0
  91. package/views/partials/reference/schema-node.hbs +99 -0
  92. package/views/partials/reference/schema.hbs +19 -0
  93. package/views/partials/reference/section-heading.hbs +16 -0
  94. package/views/partials/reference/token-alert.hbs +24 -0
  95. package/views/partials/reference/try-field.hbs +31 -0
  96. package/views/partials/reference/try-it.hbs +78 -0
  97. package/views/partials/side_menu.hbs +1 -1
  98. package/views/partials/ui/badge.hbs +4 -2
  99. package/views/partials/ui/page-header.hbs +1 -1
  100. package/views/partials/ui/search-input.hbs +31 -0
  101. package/views/partials/ui/setting-ref.hbs +1 -1
  102. package/views/partials/ui/stat-card.hbs +4 -2
  103. package/views/partials/ui/tab.hbs +6 -1
  104. package/views/partials/ui/tabs.hbs +2 -2
  105. package/views/reference/index.hbs +76 -0
  106. package/views/reference/redirect.hbs +49 -0
  107. package/views/reference/tag.hbs +28 -0
  108. package/views/reference/token.hbs +49 -0
  109. package/views/tokens/index.hbs +9 -1
  110. package/views/webhooks/index.hbs +3 -3
  111. package/workers/api.js +37 -215
  112. package/Gruntfile.js +0 -58
  113. package/views/swagger/index.hbs +0 -82
@@ -28,10 +28,12 @@ const {
28
28
  defaultAccountTypeSchema,
29
29
  shortMailboxesSchema,
30
30
  ACCOUNT_DISPLAY_STATES,
31
- errorResponses
31
+ apiResponses,
32
+ ENUM_DESCRIPTIONS
32
33
  } = require('../schemas');
33
34
 
34
35
  const { REDIS_PREFIX, MAX_FORM_TTL, NONCE_BYTES } = require('../consts');
36
+ const BEHAVIOR = require('./behavior-notes');
35
37
 
36
38
  // OAuth2 scope list stored on the account (accountData.oauth2.scope). Reused with a per-route
37
39
  // description/label where the same value is exposed under a different field name
@@ -177,12 +179,21 @@ async function init(args) {
177
179
 
178
180
  options: {
179
181
  description: 'Register new account',
180
- notes: 'Registers new IMAP account to be synced',
182
+ notes: ['Registers new IMAP account to be synced', BEHAVIOR.CREDENTIALS_VERIFIED_LATER],
181
183
  tags: ['api', 'Account'],
182
184
 
183
185
  plugins: {
184
- 'hapi-swagger': {
185
- responses: errorResponses(400, 401, 403, 404, 429, 500)
186
+ openapi: {
187
+ 'x-ee-behavior': [BEHAVIOR.CREDENTIALS_VERIFIED_LATER],
188
+ responses: apiResponses(
189
+ 'Returns the registered account, including the generated account ID when one was not supplied.',
190
+ 400,
191
+ 401,
192
+ 403,
193
+ 404,
194
+ 429,
195
+ 500
196
+ )
186
197
  }
187
198
  },
188
199
 
@@ -329,12 +340,13 @@ async function init(args) {
329
340
  },
330
341
  options: {
331
342
  description: 'Update account info',
332
- notes: 'Updates account information',
343
+ notes: ['Updates account information', BEHAVIOR.CREDENTIALS_VERIFIED_LATER],
333
344
  tags: ['api', 'Account'],
334
345
 
335
346
  plugins: {
336
- 'hapi-swagger': {
337
- responses: errorResponses(400, 401, 403, 404, 429, 500)
347
+ openapi: {
348
+ 'x-ee-behavior': [BEHAVIOR.CREDENTIALS_VERIFIED_LATER],
349
+ responses: apiResponses('Returns the account ID. Changed credentials take effect on the next connection.', 400, 401, 403, 404, 429, 500)
338
350
  }
339
351
  },
340
352
 
@@ -441,12 +453,21 @@ async function init(args) {
441
453
  },
442
454
  options: {
443
455
  description: 'Request reconnect',
444
- notes: 'Requests connection to be reconnected',
456
+ notes: ['Requests connection to be reconnected', BEHAVIOR.SCHEDULED_ON_WORKER],
445
457
  tags: ['api', 'Account'],
446
458
 
447
459
  plugins: {
448
- 'hapi-swagger': {
449
- responses: errorResponses(400, 401, 403, 404, 429, 500)
460
+ openapi: {
461
+ 'x-ee-behavior': [BEHAVIOR.SCHEDULED_ON_WORKER],
462
+ responses: apiResponses(
463
+ 'Returns an acknowledgement. The reconnect is requested, not completed - watch the account state for the result.',
464
+ 400,
465
+ 401,
466
+ 403,
467
+ 404,
468
+ 429,
469
+ 500
470
+ )
450
471
  }
451
472
  },
452
473
 
@@ -504,12 +525,21 @@ async function init(args) {
504
525
  },
505
526
  options: {
506
527
  description: 'Request syncing',
507
- notes: 'Immediately trigger account syncing for IMAP accounts',
528
+ notes: ['Immediately trigger account syncing for IMAP accounts', BEHAVIOR.SCHEDULED_ON_WORKER],
508
529
  tags: ['api', 'Account'],
509
530
 
510
531
  plugins: {
511
- 'hapi-swagger': {
512
- responses: errorResponses(400, 401, 403, 404, 429, 500)
532
+ openapi: {
533
+ 'x-ee-behavior': [BEHAVIOR.SCHEDULED_ON_WORKER],
534
+ responses: apiResponses(
535
+ 'Returns an acknowledgement. A full mailbox sync is scheduled and runs in the background.',
536
+ 400,
537
+ 401,
538
+ 403,
539
+ 404,
540
+ 429,
541
+ 500
542
+ )
513
543
  }
514
544
  },
515
545
 
@@ -573,8 +603,16 @@ async function init(args) {
573
603
  tags: ['api', 'Account'],
574
604
 
575
605
  plugins: {
576
- 'hapi-swagger': {
577
- responses: errorResponses(400, 401, 403, 404, 429, 500)
606
+ openapi: {
607
+ responses: apiResponses(
608
+ 'Returns a deletion marker. The account stops syncing immediately; stored data is removed in the background.',
609
+ 400,
610
+ 401,
611
+ 403,
612
+ 404,
613
+ 429,
614
+ 500
615
+ )
578
616
  }
579
617
  },
580
618
 
@@ -640,12 +678,24 @@ async function init(args) {
640
678
  },
641
679
  options: {
642
680
  description: 'Request account flush',
643
- notes: 'Deletes all email indexes from Redis and ElasticSearch and re-creates the index for that account. You can only run a single flush operation at a time, so you must wait until the previous flush has finished before initiating a new one.',
681
+ notes: [
682
+ 'Deletes all email indexes from Redis and ElasticSearch and re-creates the index for that account. You can only run a single flush operation at a time, so you must wait until the previous flush has finished before initiating a new one.',
683
+ BEHAVIOR.SCHEDULED_ON_WORKER
684
+ ],
644
685
  tags: ['api', 'Account'],
645
686
 
646
687
  plugins: {
647
- 'hapi-swagger': {
648
- responses: errorResponses(400, 401, 403, 404, 429, 500)
688
+ openapi: {
689
+ 'x-ee-behavior': [BEHAVIOR.SCHEDULED_ON_WORKER],
690
+ responses: apiResponses(
691
+ 'Returns an acknowledgement. Cached message indexes are cleared and rebuilt in the background.',
692
+ 400,
693
+ 401,
694
+ 403,
695
+ 404,
696
+ 429,
697
+ 500
698
+ )
649
699
  }
650
700
  },
651
701
 
@@ -711,8 +761,8 @@ async function init(args) {
711
761
  tags: ['api', 'Account'],
712
762
 
713
763
  plugins: {
714
- 'hapi-swagger': {
715
- responses: errorResponses(400, 401, 403, 429, 500)
764
+ openapi: {
765
+ responses: apiResponses('Returns a page of accounts with their connection states.', 400, 401, 403, 429, 500)
716
766
  }
717
767
  },
718
768
 
@@ -744,6 +794,7 @@ async function init(args) {
744
794
  .valid(...ACCOUNT_DISPLAY_STATES)
745
795
  .example('connected')
746
796
  .description('Filter accounts by state')
797
+ .meta({ enumDescriptions: ENUM_DESCRIPTIONS.accountState })
747
798
  .label('AccountState'),
748
799
  query: Joi.string().example('user@example.com').description('Filter accounts by string match').label('AccountQuery')
749
800
  }).label('AccountsFilter')
@@ -778,6 +829,7 @@ async function init(args) {
778
829
  .valid(...ACCOUNT_DISPLAY_STATES)
779
830
  .example('connected')
780
831
  .description('Account state')
832
+ .meta({ enumDescriptions: ENUM_DESCRIPTIONS.accountState })
781
833
  .label('AccountListState'),
782
834
  webhooks: Joi.string()
783
835
  .uri({
@@ -946,12 +998,13 @@ async function init(args) {
946
998
  },
947
999
  options: {
948
1000
  description: 'Get account info',
949
- notes: 'Returns stored information about the account. Passwords are not included.',
1001
+ notes: ['Returns stored information about the account. Passwords are not included.', BEHAVIOR.NO_QUOTA_ON_API_ACCOUNTS],
950
1002
  tags: ['api', 'Account'],
951
1003
 
952
1004
  plugins: {
953
- 'hapi-swagger': {
954
- responses: errorResponses(400, 401, 403, 404, 429, 500)
1005
+ openapi: {
1006
+ 'x-ee-behavior': [BEHAVIOR.NO_QUOTA_ON_API_ACCOUNTS],
1007
+ responses: apiResponses('Returns the account configuration, connection state and sync status.', 400, 401, 403, 404, 429, 500)
955
1008
  }
956
1009
  },
957
1010
 
@@ -1035,6 +1088,7 @@ async function init(args) {
1035
1088
  .valid(...ACCOUNT_DISPLAY_STATES)
1036
1089
  .example('connected')
1037
1090
  .description('Informational account state')
1091
+ .meta({ enumDescriptions: ENUM_DESCRIPTIONS.accountState })
1038
1092
  .label('AccountInfoState'),
1039
1093
 
1040
1094
  smtpStatus: Joi.object({
@@ -1106,7 +1160,10 @@ async function init(args) {
1106
1160
  id: Joi.string().description('Microsoft Graph subscription ID'),
1107
1161
  expirationDateTime: Joi.date().iso().allow(null).description('When the subscription expires'),
1108
1162
  state: Joi.object({
1109
- state: Joi.string().valid('creating', 'created', 'renewing', 'error').description('Subscription state'),
1163
+ state: Joi.string()
1164
+ .valid('creating', 'created', 'renewing', 'error')
1165
+ .description('Subscription state')
1166
+ .meta({ enumDescriptions: ENUM_DESCRIPTIONS.pubsubState }),
1110
1167
  time: Joi.number().description('Timestamp of last state change'),
1111
1168
  error: Joi.string().allow(null).description('Error message if state is error, null after a successful renewal'),
1112
1169
  retryCount: Joi.number().integer().description('How many times the subscription renewal has been retried'),
@@ -1183,8 +1240,16 @@ async function init(args) {
1183
1240
  tags: ['api', 'Account'],
1184
1241
 
1185
1242
  plugins: {
1186
- 'hapi-swagger': {
1187
- responses: errorResponses(400, 401, 403, 404, 429, 500)
1243
+ openapi: {
1244
+ responses: apiResponses(
1245
+ 'Returns a valid OAuth2 access token for the account, refreshing it first if it had expired.',
1246
+ 400,
1247
+ 401,
1248
+ 403,
1249
+ 404,
1250
+ 429,
1251
+ 500
1252
+ )
1188
1253
  }
1189
1254
  },
1190
1255
 
@@ -1251,8 +1316,8 @@ async function init(args) {
1251
1316
  tags: ['api', 'Account'],
1252
1317
 
1253
1318
  plugins: {
1254
- 'hapi-swagger': {
1255
- responses: errorResponses(400, 401, 403, 404, 429, 500)
1319
+ openapi: {
1320
+ responses: apiResponses('Returns the signatures configured on the account, as reported by the provider.', 400, 401, 403, 404, 429, 500)
1256
1321
  }
1257
1322
  },
1258
1323
 
@@ -1362,8 +1427,8 @@ async function init(args) {
1362
1427
  tags: ['api', 'Account'],
1363
1428
 
1364
1429
  plugins: {
1365
- 'hapi-swagger': {
1366
- responses: errorResponses(400, 401, 403, 404, 429, 500)
1430
+ openapi: {
1431
+ responses: apiResponses('Returns a single-use URL for the hosted authentication form.', 400, 401, 403, 404, 429, 500)
1367
1432
  }
1368
1433
  },
1369
1434
 
@@ -1448,7 +1513,7 @@ async function init(args) {
1448
1513
  },
1449
1514
  options: {
1450
1515
  description: 'Return IMAP logs for an account',
1451
- notes: 'Output is a downloadable text file',
1516
+ notes: ['Output is a downloadable text file', BEHAVIOR.IMAP_ONLY],
1452
1517
  tags: ['api', 'Logs'],
1453
1518
 
1454
1519
  auth: {
@@ -1458,9 +1523,10 @@ async function init(args) {
1458
1523
  cors: CORS_CONFIG,
1459
1524
 
1460
1525
  plugins: {
1461
- 'hapi-swagger': {
1526
+ openapi: {
1527
+ 'x-ee-behavior': [BEHAVIOR.IMAP_ONLY],
1462
1528
  produces: ['text/plain'],
1463
- responses: errorResponses(400, 401, 403, 429, 500)
1529
+ responses: apiResponses('Returns the account log as a plain text stream.', 400, 401, 403, 429, 500)
1464
1530
  }
1465
1531
  },
1466
1532
 
@@ -1496,8 +1562,15 @@ async function init(args) {
1496
1562
  tags: ['api', 'Account'],
1497
1563
 
1498
1564
  plugins: {
1499
- 'hapi-swagger': {
1500
- responses: errorResponses(400, 401, 403, 429, 500)
1565
+ openapi: {
1566
+ responses: apiResponses(
1567
+ 'Returns the outcome of the IMAP and SMTP connection tests, including per-protocol errors when a test failed.',
1568
+ 400,
1569
+ 401,
1570
+ 403,
1571
+ 429,
1572
+ 500
1573
+ )
1501
1574
  }
1502
1575
  },
1503
1576
 
@@ -1557,8 +1630,15 @@ async function init(args) {
1557
1630
  tags: ['api', 'Settings'],
1558
1631
 
1559
1632
  plugins: {
1560
- 'hapi-swagger': {
1561
- responses: errorResponses(400, 401, 403, 429, 500)
1633
+ openapi: {
1634
+ responses: apiResponses(
1635
+ 'Returns the discovered IMAP and SMTP settings for the address, or empty values when nothing could be resolved.',
1636
+ 400,
1637
+ 401,
1638
+ 403,
1639
+ 429,
1640
+ 500
1641
+ )
1562
1642
  }
1563
1643
  },
1564
1644
 
@@ -0,0 +1,54 @@
1
+ 'use strict';
2
+
3
+ // Per-operation behavior notes: the things a caller has to know that the request and
4
+ // response schemas cannot express - whether the work is asynchronous, what a 200 actually
5
+ // promises, and where a provider's API behaves differently from IMAP.
6
+ //
7
+ // Routes declare each note TWICE, on purpose:
8
+ // - appended to the route's `notes` array, which the generator joins into the standard
9
+ // `description` field, so every consumer of /swagger.json sees it;
10
+ // - listed under `plugins.openapi['x-ee-behavior']`, so the API reference can tell
11
+ // these apart from the operation's own prose and render them as a callout.
12
+ // A vendor extension alone would be invisible to Postman, Redoc and code generators, which
13
+ // is exactly the audience that would otherwise ship "a 2xx means sent". A test asserts the
14
+ // two declarations stay in step.
15
+ //
16
+ // The provider notes are transcribed by hand from the transports, and nothing enforces the
17
+ // copy. When changing one, check the code that actually implements the limit - not the
18
+ // ASCII capability matrices at the top of those files, which are comments too:
19
+ // NO_LABEL_SET_ON_GMAIL lib/email-client/gmail-client.js, prepareLabelUpdate throw
20
+ // GMAIL_DELETE_IS_TRASH lib/email-client/gmail-client.js, deleteMessage
21
+ // UPLOAD_DRAFTS_ONLY_GRAPH lib/email-client/outlook-client.js, uploadMessage
22
+ // NO_QUOTA_ON_API_ACCOUNTS getQuota on both clients
23
+
24
+ module.exports = {
25
+ // --- asynchronous work -------------------------------------------------------------
26
+ QUEUED_DELIVERY:
27
+ 'Delivery is asynchronous. A 2xx means the message was queued, not that it was sent. Failed attempts are retried with exponential backoff up to the configured deliveryAttempts; follow the outcome through the Outbox endpoints or the messageSent, messageDeliveryError and messageFailed webhooks.',
28
+
29
+ SENT_FOLDER_UPLOAD:
30
+ 'For SMTP accounts EmailEngine uploads the sent message to the Sent Mail folder after delivery. Gmail API and MS Graph accounts file sent messages themselves, so no upload is performed.',
31
+
32
+ SCHEDULED_ON_WORKER:
33
+ 'The request only schedules the work and returns before it finishes. Watch the account state, or the accountInitialized and authenticationError webhooks, for the result.',
34
+
35
+ BACKGROUND_JOB: 'Runs as a background job. Follow it either by polling the status endpoint or by waiting for the completion webhook.',
36
+
37
+ CREDENTIALS_VERIFIED_LATER:
38
+ 'Credentials are not verified while handling this request. The account connects afterwards, and an authentication failure surfaces as an authenticationError state rather than an error here. Use the account verification endpoint to test credentials up front.',
39
+
40
+ SSE_STREAM: 'A long-lived Server-Sent Events stream rather than a normal request and response. The connection stays open until the client closes it.',
41
+
42
+ // --- provider differences ----------------------------------------------------------
43
+ NO_QUOTA_ON_API_ACCOUNTS: 'Quota reporting is not available for Gmail API or MS Graph accounts; the quota field is omitted for those.',
44
+
45
+ UPLOAD_DRAFTS_ONLY_GRAPH: 'For MS Graph accounts only drafts can be uploaded, and the draft flag cannot be changed afterwards.',
46
+
47
+ NO_LABEL_SET_ON_GMAIL:
48
+ 'For Gmail API accounts the entire label set cannot be replaced in one call. Add and remove labels individually instead of using the set operation.',
49
+
50
+ GMAIL_DELETE_IS_TRASH:
51
+ 'For Gmail API accounts the message is always moved to Trash. The force option, which permanently deletes on IMAP accounts, has no effect.',
52
+
53
+ IMAP_ONLY: 'Only available for IMAP accounts. Gmail API and MS Graph accounts have no equivalent.'
54
+ };
@@ -8,7 +8,7 @@ const getSecret = require('../get-secret');
8
8
  const { lists } = require('../lists');
9
9
  const { failAction } = require('../tools');
10
10
  const { handleError } = require('./route-helpers');
11
- const { accountIdSchema, errorResponses } = require('../schemas');
11
+ const { accountIdSchema, apiResponses } = require('../schemas');
12
12
  const { REDIS_PREFIX } = require('../consts');
13
13
 
14
14
  async function init(args) {
@@ -32,8 +32,8 @@ async function init(args) {
32
32
  tags: ['api', 'Blocklists'],
33
33
 
34
34
  plugins: {
35
- 'hapi-swagger': {
36
- responses: errorResponses(400, 401, 403, 429, 500)
35
+ openapi: {
36
+ responses: apiResponses('Returns every blocklist with its entry count.', 400, 401, 403, 429, 500)
37
37
  }
38
38
  },
39
39
 
@@ -102,8 +102,8 @@ async function init(args) {
102
102
  tags: ['api', 'Blocklists'],
103
103
 
104
104
  plugins: {
105
- 'hapi-swagger': {
106
- responses: errorResponses(400, 401, 403, 404, 429, 500)
105
+ openapi: {
106
+ responses: apiResponses('Returns a page of entries on the blocklist.', 400, 401, 403, 404, 429, 500)
107
107
  }
108
108
  },
109
109
 
@@ -220,8 +220,8 @@ async function init(args) {
220
220
  tags: ['api', 'Blocklists'],
221
221
 
222
222
  plugins: {
223
- 'hapi-swagger': {
224
- responses: errorResponses(400, 401, 403, 404, 429, 500)
223
+ openapi: {
224
+ responses: apiResponses('Returns whether the address was added or was already listed.', 400, 401, 403, 404, 429, 500)
225
225
  }
226
226
  },
227
227
 
@@ -298,8 +298,8 @@ async function init(args) {
298
298
  tags: ['api', 'Blocklists'],
299
299
 
300
300
  plugins: {
301
- 'hapi-swagger': {
302
- responses: errorResponses(400, 401, 403, 404, 429, 500)
301
+ openapi: {
302
+ responses: apiResponses('Returns a deletion marker.', 400, 401, 403, 404, 429, 500)
303
303
  }
304
304
  },
305
305
 
@@ -8,7 +8,8 @@
8
8
  // on it would have been invisible.
9
9
 
10
10
  const { openChangeStream } = require('../response-stream');
11
- const { errorResponses } = require('../schemas');
11
+ const { apiResponses } = require('../schemas');
12
+ const BEHAVIOR = require('./behavior-notes');
12
13
 
13
14
  /**
14
15
  * Registers the change-stream route.
@@ -29,13 +30,14 @@ async function init(args) {
29
30
 
30
31
  options: {
31
32
  description: 'Stream state changes',
32
- notes: 'Stream account state changes as an EventSource',
33
+ notes: ['Stream account state changes as an EventSource', BEHAVIOR.SSE_STREAM],
33
34
  tags: ['api', 'Account'],
34
35
 
35
36
  plugins: {
36
- 'hapi-swagger': {
37
+ openapi: {
38
+ 'x-ee-behavior': [BEHAVIOR.SSE_STREAM],
37
39
  produces: ['text/event-stream'],
38
- responses: errorResponses(401, 403, 429, 500)
40
+ responses: apiResponses('Returns an open EventSource stream of account state changes.', 401, 403, 429, 500)
39
41
  }
40
42
  },
41
43
 
@@ -11,7 +11,7 @@ const util = require('util');
11
11
 
12
12
  const LOG_VERBOSE = getBoolean(process.env.EE_OPENAPI_VERBOSE);
13
13
 
14
- const { accountIdSchema, messageSpecialUseSchema, responseAddressSchema, responseFromAddressSchema, errorResponses } = require('../schemas');
14
+ const { accountIdSchema, messageSpecialUseSchema, responseAddressSchema, responseFromAddressSchema, apiResponses } = require('../schemas');
15
15
 
16
16
  function getDateValue(str) {
17
17
  try {
@@ -402,8 +402,8 @@ async function init(args) {
402
402
  tags: ['api', 'Deprecated endpoints (Document Store)'],
403
403
 
404
404
  plugins: {
405
- 'hapi-swagger': {
406
- responses: errorResponses(400, 401, 403, 404, 429, 500)
405
+ openapi: {
406
+ responses: apiResponses('Returns the generated answer and the messages it was drawn from.', 400, 401, 403, 404, 429, 500)
407
407
  }
408
408
  },
409
409
 
@@ -8,9 +8,10 @@ const { Account } = require('../account');
8
8
  const { Gateway } = require('../gateway');
9
9
  const getSecret = require('../get-secret');
10
10
  const { failAction, httpAgent } = require('../tools');
11
- const { accountIdSchema, errorResponses } = require('../schemas');
11
+ const { accountIdSchema, apiResponses } = require('../schemas');
12
12
  const { REDIS_PREFIX } = require('../consts');
13
13
  const packageData = require('../../package.json');
14
+ const BEHAVIOR = require('./behavior-notes');
14
15
 
15
16
  async function init(args) {
16
17
  const { server, call, CORS_CONFIG, SMTP_TEST_HOST } = args;
@@ -134,12 +135,21 @@ ${now}`,
134
135
  },
135
136
  options: {
136
137
  description: 'Create delivery test',
137
- notes: 'Initiate a delivery test',
138
+ notes: ['Initiate a delivery test', BEHAVIOR.BACKGROUND_JOB],
138
139
  tags: ['api', 'Delivery Test'],
139
140
 
140
141
  plugins: {
141
- 'hapi-swagger': {
142
- responses: errorResponses(400, 401, 403, 404, 429, 500)
142
+ openapi: {
143
+ 'x-ee-behavior': [BEHAVIOR.BACKGROUND_JOB],
144
+ responses: apiResponses(
145
+ 'Returns the ID of the started deliverability test. Poll the check endpoint for the result.',
146
+ 400,
147
+ 401,
148
+ 403,
149
+ 404,
150
+ 429,
151
+ 500
152
+ )
143
153
  }
144
154
  },
145
155
 
@@ -288,8 +298,16 @@ ${now}`,
288
298
  tags: ['api', 'Delivery Test'],
289
299
 
290
300
  plugins: {
291
- 'hapi-swagger': {
292
- responses: errorResponses(400, 401, 403, 404, 429, 500)
301
+ openapi: {
302
+ responses: apiResponses(
303
+ 'Returns the test result once it has completed, including SPF, DKIM and DMARC outcomes.',
304
+ 400,
305
+ 401,
306
+ 403,
307
+ 404,
308
+ 429,
309
+ 500
310
+ )
293
311
  }
294
312
  },
295
313
 
@@ -5,10 +5,11 @@ const { Export } = require('../export');
5
5
  const Boom = require('@hapi/boom');
6
6
  const Joi = require('joi');
7
7
  const { failAction } = require('../tools');
8
- const { accountIdSchema, exportRequestSchema, exportStatusSchema, exportListSchema, exportIdSchema, errorResponses } = require('../schemas');
8
+ const { accountIdSchema, exportRequestSchema, exportStatusSchema, exportListSchema, exportIdSchema, apiResponses } = require('../schemas');
9
9
  const getSecret = require('../get-secret');
10
10
  const { createDecryptStream } = require('../stream-encrypt');
11
11
  const { handleError } = require('./route-helpers');
12
+ const BEHAVIOR = require('./behavior-notes');
12
13
 
13
14
  async function init(args) {
14
15
  const { server, CORS_CONFIG } = args;
@@ -34,12 +35,13 @@ async function init(args) {
34
35
 
35
36
  options: {
36
37
  description: 'Create export',
37
- notes: 'Creates a new bulk message export job. The export runs asynchronously and notifies via webhook when complete.',
38
+ notes: ['Creates a new bulk message export job. The export runs asynchronously and notifies via webhook when complete.', BEHAVIOR.BACKGROUND_JOB],
38
39
  tags: ['api', 'Export (Beta)'],
39
40
 
40
41
  plugins: {
41
- 'hapi-swagger': {
42
- responses: errorResponses(400, 401, 403, 404, 429, 500)
42
+ openapi: {
43
+ 'x-ee-behavior': [BEHAVIOR.BACKGROUND_JOB],
44
+ responses: apiResponses('Returns the ID of the started export. Poll the status endpoint until it completes.', 400, 401, 403, 404, 429, 500)
43
45
  }
44
46
  },
45
47
 
@@ -97,8 +99,8 @@ async function init(args) {
97
99
  tags: ['api', 'Export (Beta)'],
98
100
 
99
101
  plugins: {
100
- 'hapi-swagger': {
101
- responses: errorResponses(400, 401, 403, 404, 429, 500)
102
+ openapi: {
103
+ responses: apiResponses('Returns the export progress, and the download size once it has completed.', 400, 401, 403, 404, 429, 500)
102
104
  }
103
105
  },
104
106
 
@@ -178,9 +180,9 @@ async function init(args) {
178
180
  tags: ['api', 'Export (Beta)'],
179
181
 
180
182
  plugins: {
181
- 'hapi-swagger': {
183
+ openapi: {
182
184
  produces: ['application/gzip'],
183
- responses: errorResponses(400, 401, 403, 404, 429, 500, 503)
185
+ responses: apiResponses('Returns the export archive as gzip-compressed NDJSON.', 400, 401, 403, 404, 429, 500, 503)
184
186
  }
185
187
  },
186
188
 
@@ -228,8 +230,8 @@ async function init(args) {
228
230
  tags: ['api', 'Export (Beta)'],
229
231
 
230
232
  plugins: {
231
- 'hapi-swagger': {
232
- responses: errorResponses(400, 401, 403, 404, 429, 500)
233
+ openapi: {
234
+ responses: apiResponses('Returns a deletion marker. Any partially written export file is removed.', 400, 401, 403, 404, 429, 500)
233
235
  }
234
236
  },
235
237
 
@@ -283,8 +285,8 @@ async function init(args) {
283
285
  tags: ['api', 'Export (Beta)'],
284
286
 
285
287
  plugins: {
286
- 'hapi-swagger': {
287
- responses: errorResponses(400, 401, 403, 429, 500)
288
+ openapi: {
289
+ responses: apiResponses('Returns the exports for the account with their progress.', 400, 401, 403, 429, 500)
288
290
  }
289
291
  },
290
292
 
@@ -6,7 +6,7 @@ const { Gateway } = require('../gateway');
6
6
  const getSecret = require('../get-secret');
7
7
  const { failAction } = require('../tools');
8
8
  const { handleError } = require('./route-helpers');
9
- const { errorResponses } = require('../schemas');
9
+ const { apiResponses } = require('../schemas');
10
10
 
11
11
  // Gateways store SMTP delivery errors, not OAuth2 errors, so the error shape differs from the
12
12
  // account-level lastErrorSchema
@@ -47,8 +47,8 @@ async function init(args) {
47
47
  tags: ['api', 'SMTP Gateway'],
48
48
 
49
49
  plugins: {
50
- 'hapi-swagger': {
51
- responses: errorResponses(400, 401, 403, 429, 500)
50
+ openapi: {
51
+ responses: apiResponses('Returns a page of configured SMTP gateways.', 400, 401, 403, 429, 500)
52
52
  }
53
53
  },
54
54
 
@@ -139,8 +139,8 @@ async function init(args) {
139
139
  tags: ['api', 'SMTP Gateway'],
140
140
 
141
141
  plugins: {
142
- 'hapi-swagger': {
143
- responses: errorResponses(400, 401, 403, 404, 429, 500)
142
+ openapi: {
143
+ responses: apiResponses('Returns the gateway configuration. The password is masked.', 400, 401, 403, 404, 429, 500)
144
144
  }
145
145
  },
146
146
 
@@ -228,8 +228,8 @@ async function init(args) {
228
228
  tags: ['api', 'SMTP Gateway'],
229
229
 
230
230
  plugins: {
231
- 'hapi-swagger': {
232
- responses: errorResponses(400, 401, 403, 429, 500)
231
+ openapi: {
232
+ responses: apiResponses('Returns the registered gateway.', 400, 401, 403, 429, 500)
233
233
  }
234
234
  },
235
235
 
@@ -309,8 +309,8 @@ async function init(args) {
309
309
  tags: ['api', 'SMTP Gateway'],
310
310
 
311
311
  plugins: {
312
- 'hapi-swagger': {
313
- responses: errorResponses(400, 401, 403, 404, 429, 500)
312
+ openapi: {
313
+ responses: apiResponses('Returns the updated gateway.', 400, 401, 403, 404, 429, 500)
314
314
  }
315
315
  },
316
316
 
@@ -389,8 +389,8 @@ async function init(args) {
389
389
  tags: ['api', 'SMTP Gateway'],
390
390
 
391
391
  plugins: {
392
- 'hapi-swagger': {
393
- responses: errorResponses(400, 401, 403, 404, 429, 500)
392
+ openapi: {
393
+ responses: apiResponses('Returns a deletion marker.', 400, 401, 403, 404, 429, 500)
394
394
  }
395
395
  },
396
396