emailengine-app 2.76.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 (102) hide show
  1. package/.github/workflows/release.yaml +24 -19
  2. package/.ncurc.js +14 -2
  3. package/.release-please-manifest.json +3 -0
  4. package/CHANGELOG.md +23 -0
  5. package/README.md +1 -1
  6. package/data/google-crawlers.json +1 -1
  7. package/encrypt.js +71 -4
  8. package/lib/address-strategies.js +18 -0
  9. package/lib/api-reference/code-samples.js +194 -0
  10. package/lib/api-reference/format.js +179 -0
  11. package/lib/api-reference/index.js +205 -0
  12. package/lib/api-reference/model.js +336 -0
  13. package/lib/api-reference/schema-tree.js +366 -0
  14. package/lib/api-routes/account-routes.js +117 -37
  15. package/lib/api-routes/behavior-notes.js +54 -0
  16. package/lib/api-routes/blocklist-routes.js +9 -9
  17. package/lib/api-routes/changes-routes.js +6 -4
  18. package/lib/api-routes/chat-routes.js +3 -3
  19. package/lib/api-routes/delivery-test-routes.js +24 -6
  20. package/lib/api-routes/export-routes.js +14 -12
  21. package/lib/api-routes/gateway-routes.js +11 -11
  22. package/lib/api-routes/license-routes.js +7 -7
  23. package/lib/api-routes/mailbox-routes.js +18 -9
  24. package/lib/api-routes/message-routes.js +55 -35
  25. package/lib/api-routes/oauth2-app-routes.js +22 -16
  26. package/lib/api-routes/outbox-routes.js +7 -7
  27. package/lib/api-routes/pubsub-routes.js +3 -3
  28. package/lib/api-routes/settings-routes.js +10 -9
  29. package/lib/api-routes/stats-routes.js +3 -3
  30. package/lib/api-routes/submit-routes.js +58 -8
  31. package/lib/api-routes/template-routes.js +13 -13
  32. package/lib/api-routes/token-routes.js +15 -10
  33. package/lib/api-routes/webhook-route-routes.js +5 -5
  34. package/lib/consts.js +7 -0
  35. package/lib/email-client/base-client.js +66 -12
  36. package/lib/enum-descriptions.js +130 -0
  37. package/lib/imapproxy/imap-server.js +30 -26
  38. package/lib/imapproxy/upstream-client.js +38 -0
  39. package/lib/oauth2-apps.js +9 -3
  40. package/lib/openapi/build-document.js +318 -0
  41. package/lib/openapi/index.js +95 -0
  42. package/lib/openapi/joi-schema.js +523 -0
  43. package/lib/routes-ui.js +5 -1
  44. package/lib/schemas.js +76 -17
  45. package/lib/swagger-options.js +173 -0
  46. package/lib/tokens.js +69 -5
  47. package/lib/ui-routes/admin-entities-routes.js +3 -0
  48. package/lib/ui-routes/dashboard-routes.js +2 -26
  49. package/lib/ui-routes/reference-routes.js +195 -0
  50. package/lib/ui-routes/route-helpers.js +11 -0
  51. package/package.json +9 -11
  52. package/prepare-bundle-deps.sh +28 -0
  53. package/release-please-config.json +11 -0
  54. package/sbom.json +0 -1
  55. package/server.js +10 -2
  56. package/static/css/flyonui.css +1 -1
  57. package/static/css/src/app.tailwind.css +90 -0
  58. package/static/js/ee-client.js +238 -8
  59. package/static/js/reference.js +736 -0
  60. package/static/js/ui.js +61 -33
  61. package/static/licenses.html +4 -4
  62. package/translations/messages.pot +27 -27
  63. package/views/config/ai.hbs +1 -1
  64. package/views/config/document-store/chat.hbs +5 -5
  65. package/views/config/document-store/index.hbs +2 -2
  66. package/views/config/document-store/pre-processing/index.hbs +1 -1
  67. package/views/config/email-processing.hbs +1 -1
  68. package/views/config/imap-proxy.hbs +1 -1
  69. package/views/config/license.hbs +1 -1
  70. package/views/config/oauth/index.hbs +3 -3
  71. package/views/config/security.hbs +1 -1
  72. package/views/config/smtp.hbs +2 -2
  73. package/views/dashboard.hbs +1 -1
  74. package/views/layout/app.hbs +18 -7
  75. package/views/partials/oauth_form.hbs +4 -4
  76. package/views/partials/reference/anchor-link.hbs +20 -0
  77. package/views/partials/reference/disclosure.hbs +37 -0
  78. package/views/partials/reference/nav.hbs +93 -0
  79. package/views/partials/reference/operation.hbs +127 -0
  80. package/views/partials/reference/params.hbs +20 -0
  81. package/views/partials/reference/schema-node.hbs +99 -0
  82. package/views/partials/reference/schema.hbs +19 -0
  83. package/views/partials/reference/section-heading.hbs +16 -0
  84. package/views/partials/reference/token-alert.hbs +24 -0
  85. package/views/partials/reference/try-field.hbs +31 -0
  86. package/views/partials/reference/try-it.hbs +78 -0
  87. package/views/partials/side_menu.hbs +1 -1
  88. package/views/partials/ui/badge.hbs +4 -2
  89. package/views/partials/ui/page-header.hbs +1 -1
  90. package/views/partials/ui/search-input.hbs +31 -0
  91. package/views/partials/ui/setting-ref.hbs +1 -1
  92. package/views/partials/ui/stat-card.hbs +4 -2
  93. package/views/partials/ui/tab.hbs +6 -1
  94. package/views/partials/ui/tabs.hbs +2 -2
  95. package/views/reference/index.hbs +76 -0
  96. package/views/reference/redirect.hbs +49 -0
  97. package/views/reference/tag.hbs +28 -0
  98. package/views/reference/token.hbs +49 -0
  99. package/views/tokens/index.hbs +9 -1
  100. package/views/webhooks/index.hbs +3 -3
  101. package/workers/api.js +37 -215
  102. package/views/swagger/index.hbs +0 -82
@@ -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
 
@@ -3,7 +3,7 @@
3
3
  const Joi = require('joi');
4
4
  const { failAction } = require('../tools');
5
5
  const { handleError } = require('./route-helpers');
6
- const { licenseSchema, errorResponses } = require('../schemas');
6
+ const { licenseSchema, apiResponses } = require('../schemas');
7
7
 
8
8
  async function init(args) {
9
9
  const { server, call, CORS_CONFIG } = args;
@@ -31,8 +31,8 @@ async function init(args) {
31
31
  tags: ['api', 'License'],
32
32
 
33
33
  plugins: {
34
- 'hapi-swagger': {
35
- responses: errorResponses(401, 403, 429, 500)
34
+ openapi: {
35
+ responses: apiResponses('Returns the active license and its expiry, or an empty object when unlicensed.', 401, 403, 429, 500)
36
36
  }
37
37
  },
38
38
 
@@ -72,8 +72,8 @@ async function init(args) {
72
72
  tags: ['api', 'License'],
73
73
 
74
74
  plugins: {
75
- 'hapi-swagger': {
76
- responses: errorResponses(401, 403, 429, 500)
75
+ openapi: {
76
+ responses: apiResponses('Returns an empty license object. EmailEngine drops to limited mode.', 401, 403, 429, 500)
77
77
  }
78
78
  },
79
79
 
@@ -117,8 +117,8 @@ async function init(args) {
117
117
  tags: ['api', 'License'],
118
118
 
119
119
  plugins: {
120
- 'hapi-swagger': {
121
- responses: errorResponses(400, 401, 403, 429, 500)
120
+ openapi: {
121
+ responses: apiResponses('Returns the registered license.', 400, 401, 403, 429, 500)
122
122
  }
123
123
  },
124
124
 
@@ -7,7 +7,7 @@ const { Account } = require('../account');
7
7
  const getSecret = require('../get-secret');
8
8
  const { failAction } = require('../tools');
9
9
  const { handleError } = require('./route-helpers');
10
- const { accountIdSchema, mailboxesSchema, errorResponses } = require('../schemas');
10
+ const { accountIdSchema, mailboxesSchema, apiResponses } = require('../schemas');
11
11
 
12
12
  async function init(args) {
13
13
  const { server, call, CORS_CONFIG, FLAG_SORT_ORDER } = args;
@@ -56,8 +56,17 @@ async function init(args) {
56
56
  tags: ['api', 'Mailbox'],
57
57
 
58
58
  plugins: {
59
- 'hapi-swagger': {
60
- responses: errorResponses(400, 401, 403, 404, 429, 500, 503)
59
+ openapi: {
60
+ responses: apiResponses(
61
+ 'Returns the account folder tree, including special-use designations and message counts.',
62
+ 400,
63
+ 401,
64
+ 403,
65
+ 404,
66
+ 429,
67
+ 500,
68
+ 503
69
+ )
61
70
  }
62
71
  },
63
72
 
@@ -135,8 +144,8 @@ async function init(args) {
135
144
  tags: ['api', 'Mailbox'],
136
145
 
137
146
  plugins: {
138
- 'hapi-swagger': {
139
- responses: errorResponses(400, 401, 403, 404, 429, 500, 503)
147
+ openapi: {
148
+ responses: apiResponses('Returns the created folder and its path.', 400, 401, 403, 404, 429, 500, 503)
140
149
  }
141
150
  },
142
151
 
@@ -216,8 +225,8 @@ async function init(args) {
216
225
  tags: ['api', 'Mailbox'],
217
226
 
218
227
  plugins: {
219
- 'hapi-swagger': {
220
- responses: errorResponses(400, 401, 403, 404, 429, 500, 503)
228
+ openapi: {
229
+ responses: apiResponses('Returns the renamed folder with its old and new paths.', 400, 401, 403, 404, 429, 500, 503)
221
230
  }
222
231
  },
223
232
 
@@ -298,8 +307,8 @@ async function init(args) {
298
307
  tags: ['api', 'Mailbox'],
299
308
 
300
309
  plugins: {
301
- 'hapi-swagger': {
302
- responses: errorResponses(400, 401, 403, 404, 429, 500, 503)
310
+ openapi: {
311
+ responses: apiResponses('Returns the deleted folder path.', 400, 401, 403, 404, 429, 500, 503)
303
312
  }
304
313
  },
305
314