emailengine-app 2.77.0 → 2.79.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/test.yml +80 -0
- package/.ncurc.js +23 -13
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +60 -0
- package/bin/emailengine.js +1 -1
- package/config/e2e.toml +2 -1
- package/config/test.toml +2 -1
- package/data/google-crawlers.json +1 -1
- package/encrypt.js +1 -1
- package/lib/account/expected-identity.js +88 -0
- package/lib/account.js +145 -61
- package/lib/api-reference/format.js +105 -4
- package/lib/api-reference/index.js +24 -7
- package/lib/api-reference/model.js +148 -21
- package/lib/api-reference/schema-tree.js +282 -28
- package/lib/api-routes/account-routes.js +99 -36
- package/lib/api-routes/behavior-notes.js +3 -0
- package/lib/api-routes/blocklist-routes.js +21 -47
- package/lib/api-routes/chat-routes.js +10 -12
- package/lib/api-routes/delivery-test-routes.js +6 -26
- package/lib/api-routes/export-routes.js +2 -0
- package/lib/api-routes/gateway-routes.js +52 -11
- package/lib/api-routes/license-routes.js +2 -0
- package/lib/api-routes/mailbox-routes.js +29 -26
- package/lib/api-routes/message-routes.js +27 -21
- package/lib/api-routes/oauth2-app-routes.js +11 -29
- package/lib/api-routes/operation-impact.js +80 -0
- package/lib/api-routes/outbox-routes.js +15 -5
- package/lib/api-routes/permission-map.js +397 -0
- package/lib/api-routes/route-helpers.js +223 -9
- package/lib/api-routes/route-metadata.js +28 -0
- package/lib/api-routes/settings-routes.js +30 -25
- package/lib/api-routes/stats-routes.js +2 -2
- package/lib/api-routes/submit-routes.js +53 -31
- package/lib/api-routes/template-routes.js +3 -0
- package/lib/api-routes/token-routes.js +319 -33
- package/lib/api-routes/webhook-route-routes.js +14 -4
- package/lib/append-list.js +3 -14
- package/lib/arf-detect.js +23 -1
- package/lib/auth-token.js +80 -8
- package/lib/autodetect-imap-settings.js +40 -16
- package/lib/base32.js +30 -0
- package/lib/bounce-detect.js +182 -62
- package/lib/consts.js +10 -0
- package/lib/db.js +20 -2
- package/lib/delivery-error.js +30 -1
- package/lib/egress-filter.js +89 -8
- package/lib/email-client/base-client.js +35 -113
- package/lib/email-client/gmail-client.js +22 -13
- package/lib/email-client/imap/listing-diff.js +3 -3
- package/lib/email-client/imap/mailbox.js +28 -93
- package/lib/email-client/imap/subconnection.js +10 -7
- package/lib/email-client/imap/sync-operations.js +46 -46
- package/lib/email-client/imap-client.js +39 -28
- package/lib/email-client/message-builder.js +15 -15
- package/lib/email-client/notification-handler.js +1 -1
- package/lib/email-client/outlook/graph-api.js +10 -4
- package/lib/email-client/outlook-client.js +54 -55
- package/lib/email-client/smtp-pool-manager.js +1 -1
- package/lib/enum-descriptions.js +92 -2
- package/lib/export.js +2 -2
- package/lib/field-usage.js +133 -0
- package/lib/gateway.js +2 -2
- package/lib/get-raw-email.js +1 -1
- package/lib/imapproxy/imap-core/lib/commands/authenticate-plain.js +3 -3
- package/lib/imapproxy/imap-core/lib/commands/id.js +2 -13
- package/lib/imapproxy/imap-core/lib/commands/starttls.js +1 -1
- package/lib/imapproxy/imap-core/lib/imap-command.js +21 -5
- package/lib/imapproxy/imap-core/lib/imap-connection.js +17 -7
- package/lib/imapproxy/imap-core/lib/imap-server.js +2 -2
- package/lib/imapproxy/imap-server.js +40 -10
- package/lib/license-beacon.js +5 -10
- package/lib/lists.js +49 -1
- package/lib/llm-pre-process.js +6 -6
- package/lib/logger.js +5 -1
- package/lib/metrics-collector.js +2 -2
- package/lib/msgpack.js +62 -0
- package/lib/oauth/decode-jwt-payload.js +39 -0
- package/lib/oauth/gmail.js +9 -12
- package/lib/oauth/mail-ru.js +5 -7
- package/lib/oauth/outlook-identity.js +61 -0
- package/lib/oauth/outlook.js +9 -9
- package/lib/oauth/pubsub/google.js +25 -10
- package/lib/oauth/retry-setup.js +38 -0
- package/lib/oauth/scope-checker.js +1 -1
- package/lib/oauth2-apps.js +224 -295
- package/lib/openapi/build-document.js +15 -7
- package/lib/openapi/joi-schema.js +20 -0
- package/lib/outbox.js +145 -14
- package/lib/pre-process.js +9 -9
- package/lib/queue-stats.js +49 -0
- package/lib/read-env-value.js +37 -0
- package/lib/reconnection-manager.js +2 -2
- package/lib/rewrite-text-nodes.js +4 -3
- package/lib/routes-ui.js +4 -0
- package/lib/schemas.js +223 -155
- package/lib/settings.js +84 -5
- package/lib/sub-script.js +2 -1
- package/lib/swagger-options.js +2 -1
- package/lib/templates.js +5 -5
- package/lib/threads.js +2 -2
- package/lib/token-audit-log.js +208 -0
- package/lib/token-permission-view.js +219 -0
- package/lib/token-permissions.js +172 -0
- package/lib/tokens.js +100 -16
- package/lib/tools.js +259 -85
- package/lib/totp.js +67 -0
- package/lib/ui-routes/account-routes.js +122 -26
- package/lib/ui-routes/admin-config-routes.js +20 -17
- package/lib/ui-routes/admin-entities-routes.js +66 -22
- package/lib/ui-routes/auth-routes.js +36 -48
- package/lib/ui-routes/export-routes.js +10 -4
- package/lib/ui-routes/oauth-config-routes.js +5 -5
- package/lib/ui-routes/reference-routes.js +11 -8
- package/lib/ui-routes/route-helpers.js +79 -2
- package/lib/ui-routes/settings-page.js +1 -1
- package/lib/ui-routes/smtp-test-routes.js +1 -1
- package/lib/ui-routes/suppression-list-routes.js +294 -0
- package/lib/ui-routes/unsubscribe-routes.js +19 -29
- package/lib/utils/is-email.js +34 -0
- package/lib/utils/network.js +2 -2
- package/lib/utils/to-camel-case.js +17 -0
- package/lib/web-safe-html.js +1 -1
- package/lib/webhook-egress.js +37 -0
- package/lib/webhook-routing.js +80 -0
- package/lib/webhooks.js +21 -15
- package/package.json +26 -27
- package/sbom.json +1 -0
- package/server.js +81 -42
- package/static/css/flyonui.css +1 -1
- package/static/css/public.css +3 -0
- package/static/css/src/app.tailwind.css +159 -9
- package/static/js/app.js +69 -0
- package/static/js/reference.js +741 -10
- package/static/js/ui.js +43 -0
- package/static/licenses.html +698 -1590
- package/translations/README.md +64 -0
- package/translations/de.mo +0 -0
- package/translations/de.po +164 -120
- package/translations/en.po +200 -161
- package/translations/et.mo +0 -0
- package/translations/et.po +163 -120
- package/translations/fr.mo +0 -0
- package/translations/fr.po +163 -120
- package/translations/ja.mo +0 -0
- package/translations/ja.po +163 -120
- package/translations/messages.pot +94 -64
- package/translations/nl.mo +0 -0
- package/translations/nl.po +164 -120
- package/translations/pl.mo +0 -0
- package/translations/pl.po +163 -120
- package/views/account-identity-error.hbs +34 -0
- package/views/accounts/account.hbs +69 -7
- package/views/accounts/browse.hbs +18 -35
- package/views/accounts/edit.hbs +1 -0
- package/views/accounts/register/imap.hbs +12 -2
- package/views/config/logging.hbs +6 -0
- package/views/config/oauth/app.hbs +0 -2
- package/views/config/security.hbs +13 -0
- package/views/layout/app.hbs +29 -5
- package/views/oauth-scope-error.hbs +1 -1
- package/views/partials/oauth_form.hbs +0 -15
- package/views/partials/reference/disclosure.hbs +8 -2
- package/views/partials/reference/nav.hbs +36 -9
- package/views/partials/reference/operation.hbs +48 -14
- package/views/partials/reference/params.hbs +17 -1
- package/views/partials/reference/schema-node.hbs +112 -54
- package/views/partials/reference/schema-tools.hbs +25 -0
- package/views/partials/reference/token-alert.hbs +35 -10
- package/views/partials/reference/try-it.hbs +84 -11
- package/views/partials/side_menu.hbs +1 -0
- package/views/partials/ui/checkbox.hbs +2 -2
- package/views/partials/ui/tabs.hbs +7 -1
- package/views/reference/index.hbs +1 -1
- package/views/reference/token.hbs +4 -0
- package/views/suppression-lists/index.hbs +85 -0
- package/views/suppression-lists/list.hbs +87 -0
- package/views/templates/index.hbs +8 -2
- package/views/tokens/index.hbs +31 -4
- package/views/tokens/new.hbs +324 -2
- package/workers/api.js +299 -140
- package/workers/documents.js +46 -26
- package/workers/export.js +20 -8
- package/workers/imap-proxy.js +2 -2
- package/workers/imap.js +13 -7
- package/workers/smtp.js +13 -7
- package/workers/submit.js +41 -31
- package/workers/webhooks.js +60 -37
- package/lib/feature-flags.js +0 -48
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
const settings = require('../settings');
|
|
15
15
|
const { buildModel } = require('./model');
|
|
16
16
|
const { buildCodeSamples } = require('./code-samples');
|
|
17
|
+
const { operationUrl } = require('./format');
|
|
17
18
|
|
|
18
19
|
const SPEC_URL = '/swagger.json';
|
|
19
20
|
|
|
@@ -97,14 +98,30 @@ function withSamples(operation, baseUrl) {
|
|
|
97
98
|
|
|
98
99
|
// Navigation model shared by every reference page: all tags, with the active one marked.
|
|
99
100
|
// activeSlug is null on the overview page, which the nav marks instead.
|
|
101
|
+
//
|
|
102
|
+
// Every tag carries its operations, not only the active one. Below the layout's lg breakpoint
|
|
103
|
+
// the nav is a disclosure, where tapping a group opens its list in place instead of loading
|
|
104
|
+
// its page (views/partials/reference/nav.hbs), so the rows of a group you are not on have to
|
|
105
|
+
// already be there. The active tag's entries are in-page anchors - the same links the scroll
|
|
106
|
+
// spy tracks - and every other tag's carry the page they live on.
|
|
100
107
|
function buildNav(model, activeSlug) {
|
|
101
|
-
return model.tags.map(tag =>
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
+
return model.tags.map(tag => {
|
|
109
|
+
const active = tag.slug === activeSlug;
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
name: tag.name,
|
|
113
|
+
slug: tag.slug,
|
|
114
|
+
url: tag.url,
|
|
115
|
+
operationCount: tag.operationCount,
|
|
116
|
+
active,
|
|
117
|
+
operations: tag.operations.map(operation => ({
|
|
118
|
+
summary: operation.summary || operation.path,
|
|
119
|
+
// The active tag's entries have to stay bare fragments: initScrollSpy matches
|
|
120
|
+
// them literally, as a[href="#<id>"], to mark the operation being read.
|
|
121
|
+
url: active ? `#${operation.id}` : operationUrl(tag.slug, operation.id)
|
|
122
|
+
}))
|
|
123
|
+
};
|
|
124
|
+
});
|
|
108
125
|
}
|
|
109
126
|
|
|
110
127
|
// Serializes a value for embedding in a <script> element. JSON.stringify escapes quotes but
|
|
@@ -6,15 +6,66 @@
|
|
|
6
6
|
// API worker and shared by every request. Anything that depends on the request (the
|
|
7
7
|
// base URL used in the code samples) is applied later, in lib/api-reference/index.js.
|
|
8
8
|
|
|
9
|
-
const { formatDescription, slugify, methodVariant, constraintList, stringifyExample } = require('./format');
|
|
10
|
-
const { buildSchemaTree, buildExample, typeLabel, enumInfo, requiredFirst } = require('./schema-tree');
|
|
9
|
+
const { formatDescription, slugify, tagUrl, operationUrl, methodVariant, constraintList, stringifyExample } = require('./format');
|
|
10
|
+
const { buildSchemaTree, buildExample, typeLabel, enumInfo, requiredFirst, rowExample, itemExampleFor } = require('./schema-tree');
|
|
11
11
|
const { readCodeSamples } = require('./code-samples');
|
|
12
12
|
const { NOTES_SEPARATOR } = require('../openapi');
|
|
13
|
+
const { IMPACT, resolveImpact } = require('../api-routes/operation-impact');
|
|
13
14
|
|
|
14
15
|
const METHOD_ORDER = ['get', 'post', 'put', 'patch', 'delete', 'options', 'head'];
|
|
15
16
|
|
|
16
17
|
const JSON_CONTENT_TYPE = 'application/json';
|
|
17
18
|
|
|
19
|
+
// What the Try it panel says before you press Send, keyed on the operation's resolved impact.
|
|
20
|
+
// The resolution - declared `x-ee-impact` if there is one, otherwise the HTTP method default -
|
|
21
|
+
// belongs to lib/api-routes/operation-impact.js, because the token permission model narrows on
|
|
22
|
+
// the same value. Deriving the method default here as well is how a route ends up classified one
|
|
23
|
+
// way for this banner and another way for access control.
|
|
24
|
+
//
|
|
25
|
+
// Every panel used to carry the same warning - "requests run against this instance with real
|
|
26
|
+
// data" - on all 82 operations, 42 of which only read. A warning that fires on GET /v1/stats
|
|
27
|
+
// is how a reader learns to skim past the one on DELETE /v1/account/{account}, and it
|
|
28
|
+
// described the mechanism (this is a real POST) rather than the consequence. Weight now
|
|
29
|
+
// tracks consequence: nothing on a read, one muted line on an ordinary write, a real warning
|
|
30
|
+
// where the effect cannot be taken back.
|
|
31
|
+
// `warn` picks the rendering in reference/try-it: an alert box when true, one muted line
|
|
32
|
+
// otherwise. A boolean rather than a level string because the template can branch on it with
|
|
33
|
+
// a plain {{#if}}, and this codebase has no comparison helper to test a string against.
|
|
34
|
+
// `confirm` puts a confirmation step in front of Send, on the operations whose effect cannot
|
|
35
|
+
// be taken back. Every field arrives prefilled from the schema example, so
|
|
36
|
+
// DELETE /v1/account/{account} sits one click from a real deletion with nothing in between.
|
|
37
|
+
//
|
|
38
|
+
// Sending is behind the same dialog, and the draft submit is the reason. Its body is
|
|
39
|
+
// entirely optional overrides - the stored draft already carries its own recipients, and
|
|
40
|
+
// lib/api-routes/submit-routes.js says as much - so Send there mails people the reader never
|
|
41
|
+
// typed and cannot see anywhere in the panel. Handing that a lighter treatment than a DELETE
|
|
42
|
+
// would have the guard weakest exactly where the request says least about itself.
|
|
43
|
+
//
|
|
44
|
+
// The dialog shows the resolved request, method and path with the values actually in the
|
|
45
|
+
// form, plus the body when there is one: "delete this account?" is a weaker question than
|
|
46
|
+
// "DELETE /v1/account/user123?".
|
|
47
|
+
const TRY_IMPACT = {
|
|
48
|
+
[IMPACT.DESTRUCTIVE]: { warn: true, confirm: true, text: 'This permanently removes data from this instance. It cannot be undone from here.' },
|
|
49
|
+
[IMPACT.SENDS]: { warn: true, confirm: true, text: 'This sends real email. Messages reach the recipients in the request, not a sandbox.' },
|
|
50
|
+
[IMPACT.READONLY]: null, // reads only, so the panel says nothing at all
|
|
51
|
+
[IMPACT.WRITE]: { warn: false, text: 'Runs against live data on this instance.' }
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
function tryImpact(operation, method) {
|
|
55
|
+
// An unresolvable impact lands on the same `null` as READONLY, which is safe only because a
|
|
56
|
+
// route cannot declare a bad impact and reach a release: test/api-reference-test.js asserts
|
|
57
|
+
// every declaration against DECLARABLE_IMPACTS.
|
|
58
|
+
return TRY_IMPACT[resolveImpact(operation['x-ee-impact'], method)] || null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// A parameter group this long, whose members are all the same type and carry no
|
|
62
|
+
// documentation of their own, is one decision rather than N of them. GET /v1/settings takes
|
|
63
|
+
// 87 boolean query parameters that select which settings come back; rendered a row each they
|
|
64
|
+
// were roughly 260 lines of page at the same visual weight as parameters that carry a real
|
|
65
|
+
// choice, and they pushed the response schema three screens down. Matched on shape rather
|
|
66
|
+
// than on the endpoint, so anything similar added later is covered too.
|
|
67
|
+
const FLAG_GROUP_MIN = 12;
|
|
68
|
+
|
|
18
69
|
function statusVariant(code) {
|
|
19
70
|
const numeric = Number(code);
|
|
20
71
|
if (numeric >= 200 && numeric < 300) {
|
|
@@ -48,6 +99,7 @@ function pickContent(content) {
|
|
|
48
99
|
|
|
49
100
|
function buildParameter(spec, parameter, operationId) {
|
|
50
101
|
const schema = parameter.schema || {};
|
|
102
|
+
const enums = enumInfo(schema);
|
|
51
103
|
|
|
52
104
|
const view = {
|
|
53
105
|
name: parameter.name,
|
|
@@ -56,17 +108,25 @@ function buildParameter(spec, parameter, operationId) {
|
|
|
56
108
|
required: !!parameter.required,
|
|
57
109
|
typeLabel: typeLabel(spec, schema),
|
|
58
110
|
descriptionHtml: formatDescription(parameter.description || schema.description),
|
|
111
|
+
usageHtml: formatDescription(schema['x-meta'] && schema['x-meta'].usage),
|
|
59
112
|
constraints: constraintList(schema),
|
|
60
113
|
deprecated: !!parameter.deprecated,
|
|
114
|
+
// Shown on the row, under the same rules a schema property gets. A parameter is
|
|
115
|
+
// built with a tree node's field names on purpose - reference/params renders it
|
|
116
|
+
// through reference/schema-node - so the example belongs here too. Nothing
|
|
117
|
+
// inherits: a parameter has no ancestor to inherit from.
|
|
118
|
+
example: rowExample(schema, { itemExample: itemExampleFor(spec, schema, []), enums }),
|
|
61
119
|
// Booleans and enums render as a select in the try-it form, not a text field
|
|
62
120
|
isBoolean: schema.type === 'boolean'
|
|
63
121
|
};
|
|
64
122
|
|
|
65
|
-
|
|
66
|
-
if (enums) {
|
|
123
|
+
if (enums && enums.values.length) {
|
|
67
124
|
view.enumValues = enums.values;
|
|
68
125
|
view.enumDocumented = enums.documented;
|
|
69
126
|
}
|
|
127
|
+
if (enums && enums.alsoAccepts.length) {
|
|
128
|
+
view.alsoAccepts = enums.alsoAccepts;
|
|
129
|
+
}
|
|
70
130
|
|
|
71
131
|
if (typeof schema.default !== 'undefined') {
|
|
72
132
|
view.defaultValue = typeof schema.default === 'string' ? schema.default : JSON.stringify(schema.default);
|
|
@@ -88,6 +148,32 @@ function buildParameter(spec, parameter, operationId) {
|
|
|
88
148
|
return view;
|
|
89
149
|
}
|
|
90
150
|
|
|
151
|
+
// Names of a parameter group that is a flag list rather than N documented parameters, or
|
|
152
|
+
// null when the group is anything else. See FLAG_GROUP_MIN.
|
|
153
|
+
//
|
|
154
|
+
// The boolean and default-false tests are not incidental: reference/params renders the group
|
|
155
|
+
// under a fixed sentence telling the reader to set the ones they want to `true`. A predicate
|
|
156
|
+
// looser than that sentence would eventually match a group of undocumented strings and
|
|
157
|
+
// describe it wrongly, having also dropped each member's type, default and anchor. Predicate
|
|
158
|
+
// and prose have to mean the same thing.
|
|
159
|
+
function flagNames(parameters) {
|
|
160
|
+
if (parameters.length < FLAG_GROUP_MIN) {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const uniform = parameters.every(
|
|
165
|
+
parameter =>
|
|
166
|
+
parameter.typeLabel === 'boolean' &&
|
|
167
|
+
parameter.defaultValue === 'false' &&
|
|
168
|
+
!parameter.descriptionHtml &&
|
|
169
|
+
!parameter.required &&
|
|
170
|
+
!parameter.deprecated &&
|
|
171
|
+
!parameter.enumValues
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
return uniform ? parameters.map(parameter => parameter.name) : null;
|
|
175
|
+
}
|
|
176
|
+
|
|
91
177
|
function buildBody(spec, requestBody, operationId) {
|
|
92
178
|
if (!requestBody) {
|
|
93
179
|
return null;
|
|
@@ -99,14 +185,39 @@ function buildBody(spec, requestBody, operationId) {
|
|
|
99
185
|
}
|
|
100
186
|
|
|
101
187
|
const schema = picked.media.schema;
|
|
102
|
-
|
|
188
|
+
// Whether the route declared the whole payload itself, in which case neither view is
|
|
189
|
+
// synthesized and there is nothing to offer a second tab for
|
|
190
|
+
const curated = typeof picked.media.example !== 'undefined';
|
|
191
|
+
const exampleValue = curated ? picked.media.example : buildExample(spec, schema);
|
|
192
|
+
const tree = buildSchemaTree(spec, schema, `${operationId}.body`);
|
|
193
|
+
|
|
194
|
+
// The curated payload answers "what does a normal call look like" and is the right
|
|
195
|
+
// default. It cannot also answer "what else can I send", because an object-level
|
|
196
|
+
// `.example()` stops the descent, so every key its author left out is invisible: 10 of
|
|
197
|
+
// 71 fields on POST /v1/account/{account}/submit, 8 of 62 on PUT /v1/account/{account},
|
|
198
|
+
// 466 of 651 across all request bodies. The complete view fills the rest in from the
|
|
199
|
+
// per-property examples, curated values still winning wherever they exist.
|
|
200
|
+
//
|
|
201
|
+
// Only offered when it actually differs, which is 8 bodies of the document's 34 - on the
|
|
202
|
+
// rest the typical payload already names every field and a second identical tab would be
|
|
203
|
+
// a control that does nothing.
|
|
204
|
+
const completeValue = curated ? undefined : buildExample(spec, schema, { complete: true });
|
|
205
|
+
const exampleJson = stringifyExample(exampleValue);
|
|
206
|
+
const completeJson = stringifyExample(completeValue);
|
|
103
207
|
|
|
104
208
|
return {
|
|
105
209
|
contentType: picked.contentType,
|
|
106
210
|
descriptionHtml: formatDescription(requestBody.description),
|
|
107
|
-
tree
|
|
211
|
+
tree,
|
|
212
|
+
scopeId: `${operationId}-body-schema`,
|
|
108
213
|
exampleValue,
|
|
109
|
-
exampleJson
|
|
214
|
+
exampleJson,
|
|
215
|
+
completeJson: completeJson !== exampleJson ? completeJson : '',
|
|
216
|
+
// Panel ids for the two views. Built here for the same reason the response tab ids
|
|
217
|
+
// are: ui/tabs neutralizes its own hash params inside the partial block, which puts
|
|
218
|
+
// the operation id out of reach for composing them there.
|
|
219
|
+
exampleTabId: `${operationId}-body-example`,
|
|
220
|
+
completeTabId: `${operationId}-body-example-full`
|
|
110
221
|
};
|
|
111
222
|
}
|
|
112
223
|
|
|
@@ -125,18 +236,21 @@ function buildResponses(spec, responses, operationId) {
|
|
|
125
236
|
const schema = picked && picked.media.schema;
|
|
126
237
|
const exampleValue = picked && typeof picked.media.example !== 'undefined' ? picked.media.example : buildExample(spec, schema);
|
|
127
238
|
|
|
239
|
+
// Property trees are built for success responses only. The document has 474
|
|
240
|
+
// non-2xx responses sharing 8 distinct shapes - all variations on the
|
|
241
|
+
// {statusCode, error, message} envelope - so expanding them per operation
|
|
242
|
+
// added 2,400 of a tag page's 4,400 tree nodes and a quarter of its bytes to
|
|
243
|
+
// restate the same thing. The error envelope is documented once on the
|
|
244
|
+
// landing page, and each response still carries its own example.
|
|
245
|
+
const tree = schema && variant === 'success' ? buildSchemaTree(spec, schema, `${operationId}.resp.${code}`) : null;
|
|
246
|
+
|
|
128
247
|
return {
|
|
129
248
|
code,
|
|
130
249
|
variant,
|
|
131
250
|
descriptionHtml: formatDescription(response.description),
|
|
132
251
|
contentType: picked ? picked.contentType : null,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
// {statusCode, error, message} envelope - so expanding them per operation
|
|
136
|
-
// added 2,400 of a tag page's 4,400 tree nodes and a quarter of its bytes to
|
|
137
|
-
// restate the same thing. The error envelope is documented once on the
|
|
138
|
-
// landing page, and each response still carries its own example.
|
|
139
|
-
tree: schema && variant === 'success' ? buildSchemaTree(spec, schema, `${operationId}.resp.${code}`) : null,
|
|
252
|
+
tree,
|
|
253
|
+
scopeId: `${operationId}-resp-${code}-schema`,
|
|
140
254
|
exampleJson: schema ? stringifyExample(exampleValue) : ''
|
|
141
255
|
};
|
|
142
256
|
});
|
|
@@ -156,6 +270,13 @@ function buildOperation(spec, path, method, operation, tagName) {
|
|
|
156
270
|
|
|
157
271
|
const parameters = (operation.parameters || []).map(parameter => buildParameter(spec, parameter, id));
|
|
158
272
|
|
|
273
|
+
// Path parameters keep their order in the path, which is the only order that makes
|
|
274
|
+
// sense for them. The other two are grouped required-first: GET /v1/settings carries
|
|
275
|
+
// 87 query parameters, and the handful that are mandatory should not be buried.
|
|
276
|
+
const pathParams = parameters.filter(parameter => parameter.in === 'path');
|
|
277
|
+
const queryParams = requiredFirst(parameters.filter(parameter => parameter.in === 'query'));
|
|
278
|
+
const headerParams = requiredFirst(parameters.filter(parameter => parameter.in === 'header'));
|
|
279
|
+
|
|
159
280
|
const body = buildBody(spec, operation.requestBody, id);
|
|
160
281
|
|
|
161
282
|
// Behavior notes (lib/api-routes/behavior-notes.js): things the schemas cannot express,
|
|
@@ -182,18 +303,22 @@ function buildOperation(spec, path, method, operation, tagName) {
|
|
|
182
303
|
method: method.toLowerCase(),
|
|
183
304
|
methodLabel: method.toUpperCase(),
|
|
184
305
|
methodVariant: methodVariant(method),
|
|
306
|
+
// What the Try it panel warns about, if anything
|
|
307
|
+
tryImpact: tryImpact(operation, method),
|
|
185
308
|
path,
|
|
186
309
|
summary: operation.summary || '',
|
|
187
310
|
descriptionHtml: formatDescription(prose.join('\n\n')),
|
|
188
311
|
deprecated: !!operation.deprecated,
|
|
189
312
|
tag: tagName,
|
|
190
313
|
tagSlug: slugify(tagName),
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
314
|
+
pathParams,
|
|
315
|
+
queryParams,
|
|
316
|
+
headerParams,
|
|
317
|
+
// Set only when the group is really a flag list; reference/params renders those as a
|
|
318
|
+
// chip grid instead of a row each. Query only: flagNames() needs an optional group,
|
|
319
|
+
// and lib/openapi/build-document.js marks every path parameter required, while the
|
|
320
|
+
// largest header group in the document is two entries.
|
|
321
|
+
queryFlags: flagNames(queryParams),
|
|
197
322
|
body,
|
|
198
323
|
responses: buildResponses(spec, operation.responses, id)
|
|
199
324
|
};
|
|
@@ -268,6 +393,7 @@ function buildModel(spec) {
|
|
|
268
393
|
tagsByName.set(tag.name, {
|
|
269
394
|
name: tag.name,
|
|
270
395
|
slug: slugify(tag.name),
|
|
396
|
+
url: tagUrl(slugify(tag.name)),
|
|
271
397
|
descriptionHtml: formatDescription(tag.description),
|
|
272
398
|
externalDocs: tag.externalDocs && tag.externalDocs.url ? tag.externalDocs : null,
|
|
273
399
|
operations: []
|
|
@@ -290,6 +416,7 @@ function buildModel(spec) {
|
|
|
290
416
|
tagsByName.set(tagName, {
|
|
291
417
|
name: tagName,
|
|
292
418
|
slug: slugify(tagName),
|
|
419
|
+
url: tagUrl(slugify(tagName)),
|
|
293
420
|
descriptionHtml: '',
|
|
294
421
|
externalDocs: null,
|
|
295
422
|
operations: []
|
|
@@ -326,7 +453,7 @@ function buildModel(spec) {
|
|
|
326
453
|
summary: operation.summary,
|
|
327
454
|
tag: operation.tag,
|
|
328
455
|
search: searchCorpus(operation),
|
|
329
|
-
url:
|
|
456
|
+
url: operationUrl(operation.tagSlug, operation.id)
|
|
330
457
|
}))
|
|
331
458
|
};
|
|
332
459
|
}
|