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.
- package/.github/workflows/release.yaml +24 -19
- package/.ncurc.js +14 -2
- package/.release-please-manifest.json +3 -0
- package/CHANGELOG.md +23 -0
- package/README.md +1 -1
- package/data/google-crawlers.json +1 -1
- package/encrypt.js +71 -4
- package/lib/address-strategies.js +18 -0
- package/lib/api-reference/code-samples.js +194 -0
- package/lib/api-reference/format.js +179 -0
- package/lib/api-reference/index.js +205 -0
- package/lib/api-reference/model.js +336 -0
- package/lib/api-reference/schema-tree.js +366 -0
- package/lib/api-routes/account-routes.js +117 -37
- package/lib/api-routes/behavior-notes.js +54 -0
- package/lib/api-routes/blocklist-routes.js +9 -9
- package/lib/api-routes/changes-routes.js +6 -4
- package/lib/api-routes/chat-routes.js +3 -3
- package/lib/api-routes/delivery-test-routes.js +24 -6
- package/lib/api-routes/export-routes.js +14 -12
- package/lib/api-routes/gateway-routes.js +11 -11
- package/lib/api-routes/license-routes.js +7 -7
- package/lib/api-routes/mailbox-routes.js +18 -9
- package/lib/api-routes/message-routes.js +55 -35
- package/lib/api-routes/oauth2-app-routes.js +22 -16
- package/lib/api-routes/outbox-routes.js +7 -7
- package/lib/api-routes/pubsub-routes.js +3 -3
- package/lib/api-routes/settings-routes.js +10 -9
- package/lib/api-routes/stats-routes.js +3 -3
- package/lib/api-routes/submit-routes.js +58 -8
- package/lib/api-routes/template-routes.js +13 -13
- package/lib/api-routes/token-routes.js +15 -10
- package/lib/api-routes/webhook-route-routes.js +5 -5
- package/lib/consts.js +7 -0
- package/lib/email-client/base-client.js +66 -12
- package/lib/enum-descriptions.js +130 -0
- package/lib/imapproxy/imap-server.js +30 -26
- package/lib/imapproxy/upstream-client.js +38 -0
- package/lib/oauth2-apps.js +9 -3
- package/lib/openapi/build-document.js +318 -0
- package/lib/openapi/index.js +95 -0
- package/lib/openapi/joi-schema.js +523 -0
- package/lib/routes-ui.js +5 -1
- package/lib/schemas.js +76 -17
- package/lib/swagger-options.js +173 -0
- package/lib/tokens.js +69 -5
- package/lib/ui-routes/admin-entities-routes.js +3 -0
- package/lib/ui-routes/dashboard-routes.js +2 -26
- package/lib/ui-routes/reference-routes.js +195 -0
- package/lib/ui-routes/route-helpers.js +11 -0
- package/package.json +9 -11
- package/prepare-bundle-deps.sh +28 -0
- package/release-please-config.json +11 -0
- package/sbom.json +0 -1
- package/server.js +10 -2
- package/static/css/flyonui.css +1 -1
- package/static/css/src/app.tailwind.css +90 -0
- package/static/js/ee-client.js +238 -8
- package/static/js/reference.js +736 -0
- package/static/js/ui.js +61 -33
- package/static/licenses.html +4 -4
- package/translations/messages.pot +27 -27
- package/views/config/ai.hbs +1 -1
- package/views/config/document-store/chat.hbs +5 -5
- package/views/config/document-store/index.hbs +2 -2
- package/views/config/document-store/pre-processing/index.hbs +1 -1
- package/views/config/email-processing.hbs +1 -1
- package/views/config/imap-proxy.hbs +1 -1
- package/views/config/license.hbs +1 -1
- package/views/config/oauth/index.hbs +3 -3
- package/views/config/security.hbs +1 -1
- package/views/config/smtp.hbs +2 -2
- package/views/dashboard.hbs +1 -1
- package/views/layout/app.hbs +18 -7
- package/views/partials/oauth_form.hbs +4 -4
- package/views/partials/reference/anchor-link.hbs +20 -0
- package/views/partials/reference/disclosure.hbs +37 -0
- package/views/partials/reference/nav.hbs +93 -0
- package/views/partials/reference/operation.hbs +127 -0
- package/views/partials/reference/params.hbs +20 -0
- package/views/partials/reference/schema-node.hbs +99 -0
- package/views/partials/reference/schema.hbs +19 -0
- package/views/partials/reference/section-heading.hbs +16 -0
- package/views/partials/reference/token-alert.hbs +24 -0
- package/views/partials/reference/try-field.hbs +31 -0
- package/views/partials/reference/try-it.hbs +78 -0
- package/views/partials/side_menu.hbs +1 -1
- package/views/partials/ui/badge.hbs +4 -2
- package/views/partials/ui/page-header.hbs +1 -1
- package/views/partials/ui/search-input.hbs +31 -0
- package/views/partials/ui/setting-ref.hbs +1 -1
- package/views/partials/ui/stat-card.hbs +4 -2
- package/views/partials/ui/tab.hbs +6 -1
- package/views/partials/ui/tabs.hbs +2 -2
- package/views/reference/index.hbs +76 -0
- package/views/reference/redirect.hbs +49 -0
- package/views/reference/tag.hbs +28 -0
- package/views/reference/token.hbs +49 -0
- package/views/tokens/index.hbs +9 -1
- package/views/webhooks/index.hbs +3 -3
- package/workers/api.js +37 -215
- package/views/swagger/index.hbs +0 -82
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
{{/ui/tabs}}
|
|
7
7
|
Params:
|
|
8
8
|
label - aria-label describing the strip (required)
|
|
9
|
-
|
|
9
|
+
elId - element id (optional; see ui/badge for why it is not called `id`)
|
|
10
10
|
class - extra classes on the nav, e.g. "mb-4" (optional)
|
|
11
11
|
Panels are the caller's responsibility: each ui/tab target must match a
|
|
12
12
|
tabpanel element with that id (role="tabpanel" aria-labelledby="<target>-tab").
|
|
13
13
|
The auth-method tabs in oauth_form.hbs intentionally do NOT use this partial -
|
|
14
14
|
they run a custom script instead of the FlyonUI data-tabs plugin.
|
|
15
15
|
--}}
|
|
16
|
-
<nav class="tabs tabs-bordered{{#if class}} {{class}}{{/if}}" aria-label="{{label}}" role="tablist"{{#if
|
|
16
|
+
<nav class="tabs tabs-bordered{{#if class}} {{class}}{{/if}}" aria-label="{{label}}" role="tablist"{{#if elId}} id="{{elId}}"{{/if}} data-tabs>
|
|
17
17
|
{{!-- own hash params neutralized against fallthrough into the block --}}
|
|
18
18
|
{{> @partial-block label="" id="" class=""}}
|
|
19
19
|
</nav>
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{{!--
|
|
2
|
+
API reference landing page (/admin/reference). Server-rendered from the same
|
|
3
|
+
OpenAPI document that /swagger.json serves - see lib/api-reference/.
|
|
4
|
+
--}}
|
|
5
|
+
{{> reference/token-alert}}
|
|
6
|
+
|
|
7
|
+
{{> ui/page-header title="API Reference" icon="icon-[tabler--api]" class="mb-4"
|
|
8
|
+
subtitle="Every EmailEngine REST endpoint, generated from the same schemas the API validates against."}}
|
|
9
|
+
|
|
10
|
+
{{#> ui/card title="Getting started" bodyClass="space-y-4"}}
|
|
11
|
+
|
|
12
|
+
<dl class="ee-dl">
|
|
13
|
+
<dt>Base URL</dt>
|
|
14
|
+
<dd><code class="ee-chip">{{baseUrl}}</code></dd>
|
|
15
|
+
<dt>Endpoints</dt>
|
|
16
|
+
<dd>{{operationCount}} across {{tags.length}} groups</dd>
|
|
17
|
+
<dt>API version</dt>
|
|
18
|
+
<dd>{{version}}</dd>
|
|
19
|
+
<dt>Specification</dt>
|
|
20
|
+
<dd><a href="/swagger.json" class="link link-primary" target="_blank" rel="noopener noreferrer">/swagger.json</a>
|
|
21
|
+
for Postman and code generators</dd>
|
|
22
|
+
</dl>
|
|
23
|
+
|
|
24
|
+
{{!-- The document's own info.description, not a second copy of it. This page used to
|
|
25
|
+
restate authentication, errors and request processing in its own words, which meant
|
|
26
|
+
two places to keep in step and only one of them published. Pre-escaped by
|
|
27
|
+
lib/api-reference/format.js, hence the triple stash. --}}
|
|
28
|
+
{{#if descriptionHtml}}
|
|
29
|
+
<div class="text-base-content/70 text-sm"><p>{{{descriptionHtml}}}</p></div>
|
|
30
|
+
{{/if}}
|
|
31
|
+
|
|
32
|
+
<div>
|
|
33
|
+
<h3 class="text-base-content mb-1 font-semibold">Error envelope</h3>
|
|
34
|
+
<pre class="ee-code-block"><code class="language-json">{
|
|
35
|
+
"statusCode": 400,
|
|
36
|
+
"error": "Bad Request",
|
|
37
|
+
"message": "Invalid request payload input"
|
|
38
|
+
}</code></pre>
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<div>
|
|
42
|
+
<h3 class="text-base-content mb-1 font-semibold">Code samples</h3>
|
|
43
|
+
<p class="text-base-content/70 text-sm">The snippets on each endpoint read the access token from an
|
|
44
|
+
<code class="ee-chip">EMAILENGINE_TOKEN</code> environment variable, and so does the command behind
|
|
45
|
+
<strong>Copy as curl</strong> in a Try it panel.</p>
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
<div class="flex flex-wrap gap-2">
|
|
49
|
+
{{> ui/btn href="/admin/tokens" variant="primary" size="sm" icon="icon-[tabler--key]" label="Access tokens"}}
|
|
50
|
+
{{> ui/btn href="https://learn.emailengine.app/" variant="neutral" style="soft" size="sm"
|
|
51
|
+
icon="icon-[tabler--book]" label="Documentation" external=true}}
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
{{/ui/card}}
|
|
55
|
+
|
|
56
|
+
{{> ui/section-title label="Endpoint groups" class="mt-8 mb-3"}}
|
|
57
|
+
|
|
58
|
+
<div class="grid gap-4 sm:grid-cols-2 xl:grid-cols-3">
|
|
59
|
+
{{#each tags}}
|
|
60
|
+
<a href="/admin/reference/{{slug}}"
|
|
61
|
+
class="card bg-base-100 hover:border-primary/40 border border-transparent shadow-md transition-colors">
|
|
62
|
+
<div class="card-body gap-1 p-4">
|
|
63
|
+
<div class="flex items-baseline justify-between gap-2">
|
|
64
|
+
<h3 class="text-primary font-semibold">{{name}}</h3>
|
|
65
|
+
<span class="text-base-content/40 text-xs">{{operationCount}}</span>
|
|
66
|
+
</div>
|
|
67
|
+
{{#if descriptionHtml}}
|
|
68
|
+
<p class="text-base-content/70 text-sm">{{{descriptionHtml}}}</p>
|
|
69
|
+
{{/if}}
|
|
70
|
+
</div>
|
|
71
|
+
</a>
|
|
72
|
+
{{/each}}
|
|
73
|
+
</div>
|
|
74
|
+
|
|
75
|
+
{{!-- deferred highlighting, sidebar filter and try-it runner; the page content itself is server-rendered --}}
|
|
76
|
+
<script src="/static/js/reference.js" defer></script>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{{!--
|
|
2
|
+
Compatibility shim for the retired swagger-ui page.
|
|
3
|
+
|
|
4
|
+
/admin/swagger used to deep link as `#/Tag/operationId`. A URL fragment is never sent to
|
|
5
|
+
the server, so the mapping has to happen in the browser - and a 302 would not do either,
|
|
6
|
+
since the browser carries the original fragment through to the new location. Links inside
|
|
7
|
+
this EmailEngine point at /admin/reference directly; this is for bookmarks and for links
|
|
8
|
+
written by older versions.
|
|
9
|
+
|
|
10
|
+
The content below is what remains visible if the lookup falls through or JavaScript is
|
|
11
|
+
off. The redirect normally fires first.
|
|
12
|
+
|
|
13
|
+
redirectMap is serialized by jsonForScript() in lib/api-reference/index.js, which escapes
|
|
14
|
+
`<` so the literal cannot terminate this script element.
|
|
15
|
+
--}}
|
|
16
|
+
<script>
|
|
17
|
+
(() => {
|
|
18
|
+
const map = {{{redirectMap}}};
|
|
19
|
+
const fallback = '/admin/reference';
|
|
20
|
+
|
|
21
|
+
// "#/Account/getV1AccountAccount" -> ["Account", "getV1AccountAccount"]
|
|
22
|
+
const parts = window.location.hash.replace(/^#\/?/, '').split('/').filter(Boolean);
|
|
23
|
+
const operationId = parts[parts.length - 1];
|
|
24
|
+
|
|
25
|
+
// Own-property lookups only: a bare index walks Object.prototype, so a hash ending in
|
|
26
|
+
// "toString" would resolve to a native function and navigate somewhere absurd.
|
|
27
|
+
const lookup = (table, key) => (key && Object.prototype.hasOwnProperty.call(table, key) ? table[key] : null);
|
|
28
|
+
|
|
29
|
+
// Resolve on the operation id. The tag in the old hash is ignored on purpose - tags
|
|
30
|
+
// have been renamed since those links were written - and is consulted only as a
|
|
31
|
+
// fallback for a link whose operation is gone but whose group still exists.
|
|
32
|
+
const operationSlug = lookup(map.operations, operationId);
|
|
33
|
+
const slug = operationSlug || lookup(map.tags, (parts[0] || '').toLowerCase());
|
|
34
|
+
|
|
35
|
+
window.location.replace(slug ? `/admin/reference/${slug}${operationSlug ? `#${operationId}` : ''}` : fallback);
|
|
36
|
+
})();
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
{{> ui/page-header title="API Reference" icon="icon-[tabler--api]" class="mb-4"}}
|
|
40
|
+
|
|
41
|
+
<div class="alert alert-soft alert-info flex items-start gap-3" role="alert">
|
|
42
|
+
<span class="icon-[tabler--info-circle] size-5 shrink-0"></span>
|
|
43
|
+
<div class="min-w-0 text-sm">
|
|
44
|
+
<p>The API reference has moved. You should be redirected automatically.</p>
|
|
45
|
+
<p class="mt-2">
|
|
46
|
+
{{> ui/btn href="/admin/reference" variant="primary" size="sm" icon="icon-[tabler--arrow-right]" label="Open the API Reference"}}
|
|
47
|
+
</p>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{{!--
|
|
2
|
+
API reference page for one endpoint group (/admin/reference/{tag}). Every operation
|
|
3
|
+
in the group is rendered in full - see lib/api-reference/ for the model.
|
|
4
|
+
--}}
|
|
5
|
+
{{> reference/token-alert}}
|
|
6
|
+
|
|
7
|
+
{{> ui/breadcrumb parentHref="/admin/reference" parentLabel="API Reference" current=tag.name class="mb-2"}}
|
|
8
|
+
|
|
9
|
+
{{> ui/page-header title=tag.name icon="icon-[tabler--api]" class="mb-4"}}
|
|
10
|
+
|
|
11
|
+
{{#if tag.descriptionHtml}}
|
|
12
|
+
<p class="text-base-content/70 mb-4">{{{tag.descriptionHtml}}}</p>
|
|
13
|
+
{{/if}}
|
|
14
|
+
|
|
15
|
+
{{#if tag.externalDocs}}
|
|
16
|
+
<p class="mb-4 text-sm">
|
|
17
|
+
<a href="{{tag.externalDocs.url}}" class="link link-primary" target="_blank" rel="noopener noreferrer">
|
|
18
|
+
{{#if tag.externalDocs.description}}{{tag.externalDocs.description}}{{else}}Documentation{{/if}}
|
|
19
|
+
</a>
|
|
20
|
+
</p>
|
|
21
|
+
{{/if}}
|
|
22
|
+
|
|
23
|
+
{{#each operations}}
|
|
24
|
+
{{> reference/operation}}
|
|
25
|
+
{{/each}}
|
|
26
|
+
|
|
27
|
+
{{!-- deferred highlighting, sidebar filter and try-it runner; the page content itself is server-rendered --}}
|
|
28
|
+
<script src="/static/js/reference.js" defer></script>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{{!--
|
|
2
|
+
Access-token page for the API reference (/admin/reference/token).
|
|
3
|
+
|
|
4
|
+
The single place the try-it token is entered. It is held for the browser tab only
|
|
5
|
+
(sessionStorage, see static/js/reference.js) and reused by the try-it panels on every
|
|
6
|
+
endpoint page, so it does not have to be re-entered while navigating.
|
|
7
|
+
--}}
|
|
8
|
+
{{> ui/breadcrumb parentHref="/admin/reference" parentLabel="API Reference" current="Access token" class="mb-2"}}
|
|
9
|
+
|
|
10
|
+
{{> ui/page-header title="Access token" icon="icon-[tabler--key]" class="mb-4"
|
|
11
|
+
subtitle="Enables the Try it panels on the endpoint pages."}}
|
|
12
|
+
|
|
13
|
+
{{#> ui/card id="ref-token" bodyClass="space-y-4"}}
|
|
14
|
+
|
|
15
|
+
<p class="text-base-content/70 text-sm">The token is held for this browser tab only - it is never written to permanent
|
|
16
|
+
storage, and it is only ever sent to this EmailEngine instance, by requests you trigger yourself.</p>
|
|
17
|
+
|
|
18
|
+
<div>
|
|
19
|
+
{{> reference/section-heading label="Use an existing token" class="mb-2"}}
|
|
20
|
+
<div class="flex flex-wrap items-center gap-2">
|
|
21
|
+
<input type="password" id="ref-access-token" class="input input-sm max-w-sm grow font-mono" placeholder="Paste an access token"
|
|
22
|
+
autocomplete="off" spellcheck="false">
|
|
23
|
+
{{> ui/btn id="ref-token-set" variant="primary" size="sm" icon="icon-[tabler--check]" label="Set token"}}
|
|
24
|
+
</div>
|
|
25
|
+
<p class="text-base-content/50 mt-2 text-xs">Create one on the
|
|
26
|
+
<a href="/admin/tokens" class="link link-primary">Access Tokens</a> page.</p>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<div>
|
|
30
|
+
{{> reference/section-heading label="Or mint a temporary one" class="mb-2"}}
|
|
31
|
+
<div class="flex flex-wrap items-center gap-2">
|
|
32
|
+
{{> ui/btn id="ref-token-mint" variant="primary" size="sm" icon="icon-[tabler--clock-plus]"
|
|
33
|
+
label="Mint temporary token" class="ref-token-mint"}}
|
|
34
|
+
{{!-- shown by static/js/reference.js only while a token is actually held --}}
|
|
35
|
+
<span id="ref-token-clear-wrap" class="hidden">
|
|
36
|
+
{{> ui/btn id="ref-token-clear" variant="neutral" style="text" size="sm" icon="icon-[tabler--x]" label="Clear"}}
|
|
37
|
+
</span>
|
|
38
|
+
</div>
|
|
39
|
+
<p class="text-base-content/50 mt-2 text-xs">Creates an API-scoped token that expires in one hour and activates it
|
|
40
|
+
here. It is a real token until then - it appears on the
|
|
41
|
+
<a href="/admin/tokens" class="link link-primary">Access Tokens</a> page and can be revoked there.</p>
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
<p id="ref-token-feedback" class="text-base-content/70 text-sm"></p>
|
|
45
|
+
|
|
46
|
+
{{/ui/card}}
|
|
47
|
+
|
|
48
|
+
{{!-- deferred highlighting, sidebar filter and try-it runner; the page content itself is server-rendered --}}
|
|
49
|
+
<script src="/static/js/reference.js" defer></script>
|
package/views/tokens/index.hbs
CHANGED
|
@@ -30,8 +30,16 @@
|
|
|
30
30
|
{{#each data.tokens}}
|
|
31
31
|
<tr>
|
|
32
32
|
<td>
|
|
33
|
-
<div
|
|
33
|
+
<div class="flex flex-wrap items-center gap-2">
|
|
34
|
+
<strong>{{description}}</strong>
|
|
35
|
+
{{#if expiresStr}}
|
|
36
|
+
{{> ui/badge label="Expires" variant="warning" soft=true icon="" class=""}}
|
|
37
|
+
{{/if}}
|
|
38
|
+
</div>
|
|
34
39
|
{{> ui/entity-id id=id short=idShort label="Token ID"}}
|
|
40
|
+
{{#if expiresStr}}
|
|
41
|
+
<div class="text-base-content/60 text-xs">Expires <span class="relative-time" data-time="{{expiresStr}}"></span></div>
|
|
42
|
+
{{/if}}
|
|
35
43
|
</td>
|
|
36
44
|
|
|
37
45
|
<td>
|
package/views/webhooks/index.hbs
CHANGED
|
@@ -47,12 +47,12 @@
|
|
|
47
47
|
{{#if enabled}}
|
|
48
48
|
|
|
49
49
|
{{#if webhookErrorFlag.message}}
|
|
50
|
-
{{> ui/badge label="Failing" variant="error"}}
|
|
50
|
+
{{> ui/badge label="Failing" variant="error" class="" icon="" soft=""}}
|
|
51
51
|
{{else}}
|
|
52
|
-
{{> ui/badge label="Enabled" variant="success"}}
|
|
52
|
+
{{> ui/badge label="Enabled" variant="success" class="" icon="" soft=""}}
|
|
53
53
|
{{/if}}
|
|
54
54
|
{{else}}
|
|
55
|
-
{{> ui/badge label="Disabled" variant="warning"}}
|
|
55
|
+
{{> ui/badge label="Disabled" variant="warning" class="" icon="" soft=""}}
|
|
56
56
|
{{/if}}
|
|
57
57
|
</td>
|
|
58
58
|
|
package/workers/api.js
CHANGED
|
@@ -57,13 +57,12 @@ const hapiPino = require('hapi-pino');
|
|
|
57
57
|
const Inert = require('@hapi/inert');
|
|
58
58
|
const Vision = require('@hapi/vision');
|
|
59
59
|
const Accept = require('@hapi/accept');
|
|
60
|
-
const HapiSwagger = require('hapi-swagger');
|
|
61
60
|
|
|
62
61
|
const pathlib = require('path');
|
|
63
62
|
|
|
64
63
|
const crypto = require('crypto');
|
|
65
64
|
const { registeredPublishers, openChangeStream } = require('../lib/response-stream');
|
|
66
|
-
const { oauth2Apps
|
|
65
|
+
const { oauth2Apps } = require('../lib/oauth2-apps');
|
|
67
66
|
|
|
68
67
|
const handlebars = require('handlebars');
|
|
69
68
|
const AuthBearer = require('hapi-auth-bearer-token');
|
|
@@ -79,6 +78,9 @@ const { getESClient, documentStoreFeatureEnabled } = require('../lib/document-st
|
|
|
79
78
|
const sso = require('../lib/sso');
|
|
80
79
|
|
|
81
80
|
const routesUi = require('../lib/routes-ui');
|
|
81
|
+
const specOptions = require('../lib/swagger-options');
|
|
82
|
+
const { registerOpenApiRoute } = require('../lib/openapi');
|
|
83
|
+
const { getModel: getApiReferenceModel, clearServiceUrlCache } = require('../lib/api-reference');
|
|
82
84
|
|
|
83
85
|
const { encrypt, decrypt } = require('../lib/encrypt');
|
|
84
86
|
const { Certs } = require('@postalsys/certs');
|
|
@@ -105,23 +107,15 @@ const {
|
|
|
105
107
|
const registerApiRoutes = require('../lib/api-routes');
|
|
106
108
|
const bullBoardRoutes = require('../lib/api-routes/bull-board-routes');
|
|
107
109
|
|
|
108
|
-
const {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const AccountTypeSchema = Joi.string()
|
|
118
|
-
.valid(...['imap'].concat(Object.keys(OAUTH_PROVIDERS)).concat(['oauth2', 'delegated', 'sending', 'invalid']))
|
|
119
|
-
.example('outlook')
|
|
120
|
-
.description(
|
|
121
|
-
'Account type: "imap" for IMAP accounts, an OAuth2 provider name for OAuth2 accounts, "oauth2" when the OAuth2 application is missing, "delegated" for delegated accounts, "sending" for send-only accounts, "invalid" when delegation cannot be resolved'
|
|
122
|
-
)
|
|
123
|
-
.required()
|
|
124
|
-
.label('AccountType');
|
|
110
|
+
const {
|
|
111
|
+
imapSchema,
|
|
112
|
+
smtpSchema,
|
|
113
|
+
oauth2Schema,
|
|
114
|
+
accountIdSchema,
|
|
115
|
+
apiHeadersSchema,
|
|
116
|
+
oauth2ProviderSchema: OAuth2ProviderSchema,
|
|
117
|
+
accountTypeSchema: AccountTypeSchema
|
|
118
|
+
} = require('../lib/schemas');
|
|
125
119
|
|
|
126
120
|
const SUPPORTED_LOCALES = locales.map(locale => locale.locale);
|
|
127
121
|
|
|
@@ -439,6 +433,8 @@ parentPort.on('message', message => {
|
|
|
439
433
|
if (message && message.cmd === 'settings') {
|
|
440
434
|
// Keep this worker's in-memory HTTP proxy agent in sync when proxy settings change
|
|
441
435
|
maybeReloadHttpProxyAgent(message.data);
|
|
436
|
+
// ...and the API reference's memoized serviceUrl, which its code samples embed
|
|
437
|
+
clearServiceUrlCache();
|
|
442
438
|
}
|
|
443
439
|
});
|
|
444
440
|
|
|
@@ -560,9 +556,7 @@ const init = async () => {
|
|
|
560
556
|
language: 'en' // Default language
|
|
561
557
|
}
|
|
562
558
|
},
|
|
563
|
-
headers:
|
|
564
|
-
'x-ee-timeout': headerTimeoutSchema
|
|
565
|
-
}).unknown()
|
|
559
|
+
headers: apiHeadersSchema
|
|
566
560
|
}
|
|
567
561
|
}
|
|
568
562
|
};
|
|
@@ -837,184 +831,17 @@ const init = async () => {
|
|
|
837
831
|
return h.continue;
|
|
838
832
|
});
|
|
839
833
|
|
|
840
|
-
const
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
OAS: 'v3.0',
|
|
846
|
-
|
|
847
|
-
expanded: 'list',
|
|
848
|
-
sortEndpoints: 'method',
|
|
849
|
-
sortTags: 'unsorted',
|
|
850
|
-
|
|
851
|
-
tryItOutEnabled: true,
|
|
852
|
-
|
|
853
|
-
templates: Path.join(__dirname, '..', 'views', 'swagger', 'ui'),
|
|
854
|
-
|
|
855
|
-
grouping: 'tags',
|
|
856
|
-
|
|
857
|
-
info: {
|
|
858
|
-
title: 'EmailEngine API',
|
|
859
|
-
version: packageData.version,
|
|
860
|
-
|
|
861
|
-
description: `EmailEngine provides a RESTful API for managing email accounts, sending messages, and processing email data across multiple providers.
|
|
862
|
-
|
|
863
|
-
<h3>Authentication</h3>
|
|
864
|
-
All API requests require authentication using an Access Token. You can generate and manage your tokens from the <a href="/admin/tokens" target="_parent"><strong>Access Tokens</strong></a> page.
|
|
865
|
-
|
|
866
|
-
Include your token in requests using one of these methods:
|
|
867
|
-
- Query parameter: <code>?access_token=YOUR_TOKEN</code>
|
|
868
|
-
- Authorization header: <code>Authorization: Bearer YOUR_TOKEN</code>
|
|
869
|
-
|
|
870
|
-
<h3>Request Processing</h3>
|
|
871
|
-
|
|
872
|
-
<strong>Sequential Processing:</strong> Requests to the same email account are processed sequentially to maintain data consistency. Multiple simultaneous requests will be queued.
|
|
873
|
-
|
|
874
|
-
<strong>Timeouts:</strong> Long-running operations may cause queued requests to timeout. Configure appropriate timeout values using the <code>X-EE-Timeout</code> header (in milliseconds).
|
|
834
|
+
const openApiOptions = {
|
|
835
|
+
// Spec-shaping options (tag list and order, security scheme, external docs) live in
|
|
836
|
+
// lib/swagger-options.js so the document can be reproduced outside a running server
|
|
837
|
+
...specOptions,
|
|
875
838
|
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
contact: {
|
|
882
|
-
name: 'EmailEngine Support',
|
|
883
|
-
url: 'https://learn.emailengine.app/docs/support',
|
|
884
|
-
email: 'support@emailengine.app'
|
|
885
|
-
},
|
|
886
|
-
|
|
887
|
-
license: {
|
|
888
|
-
name: 'EmailEngine License',
|
|
889
|
-
url: 'https://emailengine.dev/LICENSE_EMAILENGINE.txt'
|
|
890
|
-
}
|
|
891
|
-
},
|
|
892
|
-
|
|
893
|
-
externalDocs: {
|
|
894
|
-
description: 'EmailEngine Documentation',
|
|
895
|
-
url: 'https://learn.emailengine.app/'
|
|
896
|
-
},
|
|
897
|
-
|
|
898
|
-
securityDefinitions: {
|
|
899
|
-
bearerAuth: {
|
|
900
|
-
type: 'http',
|
|
901
|
-
scheme: 'bearer',
|
|
902
|
-
bearerFormat: 'JWT',
|
|
903
|
-
description: 'Enter your access token'
|
|
904
|
-
}
|
|
905
|
-
},
|
|
906
|
-
|
|
907
|
-
security: [{ bearerAuth: [] }],
|
|
908
|
-
|
|
909
|
-
definitionPrefix: 'useLabel',
|
|
910
|
-
|
|
911
|
-
cors: !!CORS_CONFIG,
|
|
912
|
-
cache: {
|
|
913
|
-
expiresIn: 7 * 24 * 60 * 60 * 1000
|
|
914
|
-
},
|
|
839
|
+
// The running version is the only part of `info` this worker owns - the rest is static
|
|
840
|
+
// and lives with the other document metadata in lib/swagger-options.js, so the tests
|
|
841
|
+
// see the same values a real instance serves
|
|
842
|
+
info: Object.assign({}, specOptions.info, { version: packageData.version }),
|
|
915
843
|
|
|
916
|
-
|
|
917
|
-
{
|
|
918
|
-
name: 'Account',
|
|
919
|
-
description: 'Manage email accounts, including IMAP/SMTP configuration, OAuth2 authentication, and account health monitoring'
|
|
920
|
-
},
|
|
921
|
-
{
|
|
922
|
-
name: 'Mailbox',
|
|
923
|
-
description: 'List, create, modify, and manage mailbox folders. Retrieve folder statistics and special-use designations'
|
|
924
|
-
},
|
|
925
|
-
{
|
|
926
|
-
name: 'Message',
|
|
927
|
-
description: 'Search, retrieve, update, and delete email messages. Manage flags, labels, and message content'
|
|
928
|
-
},
|
|
929
|
-
{
|
|
930
|
-
name: 'Submit',
|
|
931
|
-
description:
|
|
932
|
-
'Send emails with attachments, reply to threads, forward messages, and upload to folders. Supports both immediate and scheduled sending',
|
|
933
|
-
externalDocs: {
|
|
934
|
-
description: 'Sending Emails Documentation',
|
|
935
|
-
url: 'https://learn.emailengine.app/docs/sending'
|
|
936
|
-
}
|
|
937
|
-
},
|
|
938
|
-
{
|
|
939
|
-
name: 'Outbox',
|
|
940
|
-
description: 'Monitor and manage the email sending queue. View pending messages, retry failed deliveries, and track sending progress'
|
|
941
|
-
},
|
|
942
|
-
{
|
|
943
|
-
name: 'Delivery Test',
|
|
944
|
-
description: 'Test email deliverability and authentication. Verify SPF, DKIM signatures, DMARC alignment, and analyze potential delivery issues'
|
|
945
|
-
},
|
|
946
|
-
{
|
|
947
|
-
name: 'Access Tokens',
|
|
948
|
-
description: 'Create and manage API access tokens with customizable permissions, IP restrictions, and rate limits'
|
|
949
|
-
},
|
|
950
|
-
{
|
|
951
|
-
name: 'Settings',
|
|
952
|
-
description: 'Configure EmailEngine runtime settings including webhooks, tracking, AI features, and email processing options'
|
|
953
|
-
},
|
|
954
|
-
{
|
|
955
|
-
name: 'Templates',
|
|
956
|
-
description: 'Create and manage reusable email templates with variable substitution, HTML/text content, and attachments',
|
|
957
|
-
externalDocs: {
|
|
958
|
-
description: 'Email Templates Documentation',
|
|
959
|
-
url: 'https://learn.emailengine.app/docs/sending/templates'
|
|
960
|
-
}
|
|
961
|
-
},
|
|
962
|
-
{
|
|
963
|
-
name: 'Logs',
|
|
964
|
-
description: 'Access system and account-level logs for debugging, monitoring, and audit purposes'
|
|
965
|
-
},
|
|
966
|
-
{
|
|
967
|
-
name: 'Stats',
|
|
968
|
-
description: 'Retrieve usage statistics, performance metrics, and account activity data',
|
|
969
|
-
externalDocs: {
|
|
970
|
-
description: 'Monitoring and Analytics',
|
|
971
|
-
url: 'https://learn.emailengine.app/docs/advanced/monitoring'
|
|
972
|
-
}
|
|
973
|
-
},
|
|
974
|
-
{
|
|
975
|
-
name: 'License',
|
|
976
|
-
description: 'Manage EmailEngine licensing, view license status, and handle license-related operations'
|
|
977
|
-
},
|
|
978
|
-
{
|
|
979
|
-
name: 'Webhooks',
|
|
980
|
-
description: 'Configure webhook endpoints, manage event subscriptions, and monitor webhook delivery status',
|
|
981
|
-
externalDocs: {
|
|
982
|
-
description: 'Webhooks Guide',
|
|
983
|
-
url: 'https://learn.emailengine.app/docs/webhooks/overview'
|
|
984
|
-
}
|
|
985
|
-
},
|
|
986
|
-
{
|
|
987
|
-
name: 'OAuth2 Applications',
|
|
988
|
-
description: 'Configure OAuth2 applications for Gmail, Outlook, and other providers. Manage client credentials and authentication flows',
|
|
989
|
-
externalDocs: {
|
|
990
|
-
description: 'OAuth2 Configuration Guide',
|
|
991
|
-
url: 'https://learn.emailengine.app/docs/configuration/oauth2-configuration'
|
|
992
|
-
}
|
|
993
|
-
},
|
|
994
|
-
{
|
|
995
|
-
name: 'SMTP Gateway',
|
|
996
|
-
description: 'Configure and manage the built-in SMTP server for receiving emails and integrating with external systems'
|
|
997
|
-
},
|
|
998
|
-
{
|
|
999
|
-
name: 'Blocklists',
|
|
1000
|
-
description: 'Manage email address blocklists to prevent sending to specific recipients or domains'
|
|
1001
|
-
},
|
|
1002
|
-
{
|
|
1003
|
-
name: 'Multi Message Actions',
|
|
1004
|
-
description: 'Perform bulk operations on multiple messages simultaneously, such as marking as read, moving, or deleting'
|
|
1005
|
-
},
|
|
1006
|
-
{
|
|
1007
|
-
name: 'Export (Beta)',
|
|
1008
|
-
description:
|
|
1009
|
-
'Bulk export messages from email accounts. This feature is in beta and the API may change in future releases. Export files are encrypted at rest when a service secret is configured.'
|
|
1010
|
-
}
|
|
1011
|
-
],
|
|
1012
|
-
|
|
1013
|
-
// Custom vendor extensions for additional metadata
|
|
1014
|
-
'x-logo': {
|
|
1015
|
-
url: 'https://emailengine.dev/static/logo.png',
|
|
1016
|
-
altText: 'EmailEngine Logo'
|
|
1017
|
-
}
|
|
844
|
+
cors: !!CORS_CONFIG
|
|
1018
845
|
};
|
|
1019
846
|
|
|
1020
847
|
await server.register(AuthBearer);
|
|
@@ -1485,14 +1312,11 @@ Include your token in requests using one of these methods:
|
|
|
1485
1312
|
}
|
|
1486
1313
|
});
|
|
1487
1314
|
|
|
1488
|
-
await server.register([
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
options: swaggerOptions
|
|
1494
|
-
}
|
|
1495
|
-
]);
|
|
1315
|
+
await server.register([Inert, Vision]);
|
|
1316
|
+
|
|
1317
|
+
// Position is not load-bearing: the document is generated from the finished route table on the
|
|
1318
|
+
// first request, not at registration time
|
|
1319
|
+
registerOpenApiRoute(server, openApiOptions);
|
|
1496
1320
|
|
|
1497
1321
|
server.events.on('response', request => {
|
|
1498
1322
|
const tags = request.route && request.route.settings && request.route.settings.tags;
|
|
@@ -3166,18 +2990,16 @@ Include your token in requests using one of these methods:
|
|
|
3166
2990
|
});
|
|
3167
2991
|
}
|
|
3168
2992
|
|
|
3169
|
-
//
|
|
2993
|
+
// Warm the swagger.json cache, and with it the /admin/reference render model - which
|
|
2994
|
+
// reads the same document back and costs ~12ms to build. Doing both here keeps that
|
|
2995
|
+
// work off the first visitor's request.
|
|
3170
2996
|
setImmediate(() => {
|
|
3171
|
-
server
|
|
3172
|
-
.
|
|
3173
|
-
|
|
3174
|
-
url: '/swagger.json'
|
|
3175
|
-
})
|
|
3176
|
-
.then(res => {
|
|
3177
|
-
logger.debug({ msg: 'Triggered swagger caching request', statusCode: res.statusCode });
|
|
2997
|
+
getApiReferenceModel(server)
|
|
2998
|
+
.then(model => {
|
|
2999
|
+
logger.debug({ msg: 'Built the API reference model', operations: model.operationCount });
|
|
3178
3000
|
})
|
|
3179
3001
|
.catch(err => {
|
|
3180
|
-
logger.debug({ msg: 'Failed to
|
|
3002
|
+
logger.debug({ msg: 'Failed to build the API reference model', err });
|
|
3181
3003
|
});
|
|
3182
3004
|
});
|
|
3183
3005
|
|
package/views/swagger/index.hbs
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
{{!-- swagger-ui has no dark mode of its own (its stylesheet assumes a light
|
|
2
|
-
page), so the reference renders as a light island: data-theme pins the
|
|
3
|
-
FlyonUI tokens and color-scheme to light for this subtree even while
|
|
4
|
-
the admin chrome around it is dark --}}
|
|
5
|
-
<div data-theme="light" class="rounded-box bg-white" style="color-scheme: light">
|
|
6
|
-
<div id="swagger-ui"></div>
|
|
7
|
-
</div>
|
|
8
|
-
|
|
9
|
-
<script src="/admin/swagger/resources/swagger-ui-bundle.js"></script>
|
|
10
|
-
<script src="/admin/swagger/resources/swagger-ui-standalone-preset.js"></script>
|
|
11
|
-
<script src="/admin/swagger/resources/extend.js" type="text/javascript"></script>
|
|
12
|
-
<script>
|
|
13
|
-
function getUrlVars() {
|
|
14
|
-
const vars = [];
|
|
15
|
-
let hash;
|
|
16
|
-
const hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
|
|
17
|
-
for (let i = 0; i < hashes.length; i++) {
|
|
18
|
-
hash = hashes[i].split('=');
|
|
19
|
-
vars.push(hash[0]);
|
|
20
|
-
vars[hash[0]] = hash[1];
|
|
21
|
-
}
|
|
22
|
-
return vars;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
document.addEventListener('DOMContentLoaded', function () {
|
|
26
|
-
|
|
27
|
-
let url = window.location.search.match(/url=([^&]+)/);
|
|
28
|
-
if (url && url.length > 1) {
|
|
29
|
-
url = decodeURIComponent(url[1]);
|
|
30
|
-
} else {
|
|
31
|
-
url = "/swagger.json";
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// pull validatorUrl string or null form server
|
|
35
|
-
let validatorUrl = null;
|
|
36
|
-
validatorUrl: '//online.swagger.io/validator';
|
|
37
|
-
|
|
38
|
-
const ACCESS_TOKEN_QUERY_PARAM_NAME = 'access_token';
|
|
39
|
-
const accessToken = getUrlVars()[ACCESS_TOKEN_QUERY_PARAM_NAME];
|
|
40
|
-
|
|
41
|
-
fetch(url)
|
|
42
|
-
.then(function (response) {
|
|
43
|
-
return response.json()
|
|
44
|
-
})
|
|
45
|
-
.then(function (json) {
|
|
46
|
-
|
|
47
|
-
if (json.openapi && json.openapi.startsWith('3.')) {
|
|
48
|
-
json.servers = [{
|
|
49
|
-
url: window.location.protocol + '//' + window.location.host,
|
|
50
|
-
description: 'Current server'
|
|
51
|
-
}];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const swaggerOptions = {
|
|
55
|
-
|
|
56
|
-
// url: url + (accessToken ? (url.indexOf('?') < 0 ? '?' : '&') + ACCESS_TOKEN_QUERY_PARAM_NAME + '=' + accessToken : ''),
|
|
57
|
-
spec: json,
|
|
58
|
-
validatorUrl: validatorUrl,
|
|
59
|
-
dom_id: '#swagger-ui',
|
|
60
|
-
deepLinking: true,
|
|
61
|
-
presets: [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset],
|
|
62
|
-
plugins: [SwaggerUIBundle.plugins.DownloadUrl],
|
|
63
|
-
layout: 'StandaloneLayout',
|
|
64
|
-
docExpansion: "list",
|
|
65
|
-
tagsSorter: apisSorter.unsorted,
|
|
66
|
-
operationsSorter: operationsSorter.method,
|
|
67
|
-
|
|
68
|
-
// patch: uiCompleteScript -- Rendering
|
|
69
|
-
onComplete: function () {
|
|
70
|
-
|
|
71
|
-
},
|
|
72
|
-
tryItOutEnabled: true,
|
|
73
|
-
defaultModelsExpandDepth: 0,
|
|
74
|
-
defaultModelExpandDepth: -1
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const ui = SwaggerUIBundle(swaggerOptions);
|
|
78
|
-
|
|
79
|
-
window.ui = ui;
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
</script>
|