@sendproof/core 0.1.0-alpha.1 → 0.1.0-alpha.2
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/assets/api.js +2 -1
- package/assets/app.css +612 -1
- package/assets/app.js +89 -13
- package/assets/bar-fit.js +91 -0
- package/assets/commands.js +27 -4
- package/assets/dialog.css +125 -0
- package/assets/dialog.js +191 -0
- package/assets/fields/lookup-source.js +5 -2
- package/assets/fields/lookup.js +3 -2
- package/assets/i18n.js +13 -2
- package/assets/icons.js +18 -0
- package/assets/index.html +1 -0
- package/assets/journeys/compare.js +225 -0
- package/assets/journeys/expressions.js +89 -0
- package/assets/journeys/index.js +7 -0
- package/assets/journeys/run.js +152 -0
- package/assets/journeys/steps.js +163 -0
- package/assets/journeys-code.js +193 -0
- package/assets/journeys-dialog-model.js +172 -0
- package/assets/journeys-dialogs.js +301 -0
- package/assets/journeys-model.js +259 -0
- package/assets/journeys-runs.js +109 -0
- package/assets/journeys-session.js +135 -0
- package/assets/journeys-view.js +961 -0
- package/assets/journeys.js +962 -0
- package/assets/locales/ar-journeys.js +468 -0
- package/assets/locales/ar.js +2 -0
- package/assets/locales/cs-journeys.js +468 -0
- package/assets/locales/cs.js +2 -0
- package/assets/locales/da-journeys.js +465 -0
- package/assets/locales/da.js +2 -0
- package/assets/locales/de-journeys.js +465 -0
- package/assets/locales/de.js +2 -0
- package/assets/locales/el-journeys.js +465 -0
- package/assets/locales/el.js +2 -0
- package/assets/locales/en-journeys.js +467 -0
- package/assets/locales/en.js +2 -0
- package/assets/locales/es-journeys.js +467 -0
- package/assets/locales/es.js +2 -0
- package/assets/locales/fa-journeys.js +465 -0
- package/assets/locales/fa.js +2 -0
- package/assets/locales/fi-journeys.js +465 -0
- package/assets/locales/fi.js +2 -0
- package/assets/locales/fr-journeys.js +467 -0
- package/assets/locales/fr.js +2 -0
- package/assets/locales/he-journeys.js +468 -0
- package/assets/locales/he.js +2 -0
- package/assets/locales/hi-journeys.js +465 -0
- package/assets/locales/hi.js +2 -0
- package/assets/locales/id-journeys.js +466 -0
- package/assets/locales/id.js +2 -0
- package/assets/locales/it-journeys.js +467 -0
- package/assets/locales/it.js +2 -0
- package/assets/locales/ja-journeys.js +466 -0
- package/assets/locales/ja.js +2 -0
- package/assets/locales/ko-journeys.js +465 -0
- package/assets/locales/ko.js +2 -0
- package/assets/locales/nb-journeys.js +465 -0
- package/assets/locales/nb.js +2 -0
- package/assets/locales/nl-journeys.js +465 -0
- package/assets/locales/nl.js +2 -0
- package/assets/locales/pl-journeys.js +468 -0
- package/assets/locales/pl.js +2 -0
- package/assets/locales/pt-BR-journeys.js +467 -0
- package/assets/locales/pt-BR.js +2 -0
- package/assets/locales/pt-PT-journeys.js +467 -0
- package/assets/locales/pt-PT.js +2 -0
- package/assets/locales/ru-journeys.js +468 -0
- package/assets/locales/ru.js +2 -0
- package/assets/locales/sv-journeys.js +465 -0
- package/assets/locales/sv.js +2 -0
- package/assets/locales/th-journeys.js +466 -0
- package/assets/locales/th.js +2 -0
- package/assets/locales/tr-journeys.js +468 -0
- package/assets/locales/tr.js +2 -0
- package/assets/locales/uk-journeys.js +468 -0
- package/assets/locales/uk.js +2 -0
- package/assets/locales/vi-journeys.js +466 -0
- package/assets/locales/vi.js +2 -0
- package/assets/locales/zh-Hans-journeys.js +466 -0
- package/assets/locales/zh-Hans.js +2 -0
- package/assets/locales/zh-Hant-journeys.js +466 -0
- package/assets/locales/zh-Hant.js +2 -0
- package/assets/manifest.json +349 -104
- package/assets/markdown.js +27 -2
- package/assets/request-editor.js +7 -1
- package/assets/result-states.js +2 -2
- package/assets/results.js +41 -14
- package/assets/router.js +25 -1
- package/assets/seeded-menu.js +2 -1
- package/assets/shortcuts-sheet.js +3 -1
- package/assets/shortcuts.js +6 -0
- package/assets/sidebar.js +54 -5
- package/assets/signin.js +6 -3
- package/assets/styles.css +8 -2
- package/assets/toast.js +29 -0
- package/assets/vendor/arazzo-runtime-expression.js +136 -0
- package/assets/vendor/json-pointer.js +48 -0
- package/assets/vendor/jsonpath-rfc9535.js +15 -0
- package/assets/view.js +11 -3
- package/assets/views.css +7 -0
- package/dist/index.d.ts +7 -3
- package/dist/index.js +217 -26
- package/dist/journey-builder.d.ts +178 -0
- package/dist/journey-builder.js +169 -0
- package/dist/journeys.d.ts +24 -0
- package/dist/journeys.js +157 -0
- package/dist/node-http.d.ts +2 -0
- package/dist/node-http.js +17 -0
- package/dist/sessions.d.ts +43 -0
- package/dist/sessions.js +145 -0
- package/dist/statements.js +2 -2
- package/dist/stores/tables.d.ts +213 -0
- package/dist/stores/tables.js +213 -0
- package/dist/types.d.ts +34 -2
- package/package.json +1 -1
package/assets/markdown.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// A small, safe CommonMark subset for OpenAPI descriptions: paragraphs, bullet and numbered
|
|
2
|
-
// lists, headings, **bold**, *emphasis*, `code` and http(s) links. Everything else
|
|
2
|
+
// lists, headings, GitHub tables, **bold**, *emphasis*, `code` and http(s) links. Everything else
|
|
3
|
+
// is escaped.
|
|
3
4
|
import { esc } from './components.js';
|
|
4
5
|
|
|
5
6
|
/** Inline markup only, for one-line descriptions. */
|
|
@@ -11,11 +12,35 @@ export function inline(text) {
|
|
|
11
12
|
.replace(/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g, '<a class="link" href="$2" target="_blank" rel="noopener noreferrer">$1</a>');
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
/**
|
|
15
|
+
/** A table's delimiter row, such as `| --- | :---: |`. */
|
|
16
|
+
const DELIMITER = /^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/;
|
|
17
|
+
|
|
18
|
+
/** A table row's cells: outer pipes dropped, split on pipes that aren't escaped (`\|`). */
|
|
19
|
+
function cells(line) {
|
|
20
|
+
const row = line.trim().replace(/^\|/, '').replace(/(^|[^\\])\|$/, '$1');
|
|
21
|
+
return row.split(/(?<!\\)\|/).map(cell => cell.trim().replace(/\\\|/g, '|'));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** A GitHub table: header, delimiter row (which sets each column's alignment) and body rows. */
|
|
25
|
+
function table(lines) {
|
|
26
|
+
const head = cells(lines[0]);
|
|
27
|
+
const align = cells(lines[1]).map(cell => cell.startsWith(':') && cell.endsWith(':') ? 'center' : cell.endsWith(':') ? 'end' : '');
|
|
28
|
+
const cell = (tag, text, index) => `<${tag}${align[index] ? ` style="text-align:${align[index]}"` : ''}>${inline(text ?? '')}</${tag}>`;
|
|
29
|
+
const body = lines.slice(2).map(line => { const row = cells(line); return `<tr>${head.map((_, index) => cell('td', row[index], index)).join('')}</tr>`; }).join('');
|
|
30
|
+
return `<div class="md-table"><table><thead><tr>${head.map((text, index) => cell('th', text, index)).join('')}</tr></thead>${body ? `<tbody>${body}</tbody>` : ''}</table></div>`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Block markup: paragraphs, lists, headings and tables. */
|
|
15
34
|
export function markdown(text) {
|
|
16
35
|
const blocks = String(text ?? '').replace(/\r\n/g, '\n').trim().split(/\n\s*\n/);
|
|
17
36
|
return blocks.map(block => {
|
|
18
37
|
const lines = block.split('\n');
|
|
38
|
+
// A table may follow a paragraph's lines without a blank line between them.
|
|
39
|
+
const delimiter = lines.findIndex((line, index) => index > 0 && line.includes('-') && DELIMITER.test(line) && lines[index - 1].includes('|'));
|
|
40
|
+
if (delimiter > 0) {
|
|
41
|
+
const before = lines.slice(0, delimiter - 1);
|
|
42
|
+
return `${before.length ? `<p>${before.map(inline).join(' ')}</p>` : ''}${table(lines.slice(delimiter - 1))}`;
|
|
43
|
+
}
|
|
19
44
|
if (lines.every(line => /^\s*[-*+]\s+/.test(line))) return `<ul>${lines.map(line => `<li>${inline(line.replace(/^\s*[-*+]\s+/, ''))}</li>`).join('')}</ul>`;
|
|
20
45
|
if (lines.every(line => /^\s*\d+[.)]\s+/.test(line))) return `<ol>${lines.map(line => `<li>${inline(line.replace(/^\s*\d+[.)]\s+/, ''))}</li>`).join('')}</ol>`;
|
|
21
46
|
const heading = /^(#{1,6})\s+(.*)$/.exec(lines[0]);
|
package/assets/request-editor.js
CHANGED
|
@@ -43,7 +43,7 @@ export function requestExample(source, document) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/** Own request editor rendering and conversion into a prepared request. */
|
|
46
|
-
export function createRequestEditor({ state, basePath, $, onLookupPreview, onHeadersChange, sensitiveNames = () => [], onFilled = () => {} }) {
|
|
46
|
+
export function createRequestEditor({ state, basePath, $, onLookupPreview, onHeadersChange, sensitiveNames = () => [], onFilled = () => {}, onRendered = () => {} }) {
|
|
47
47
|
let includeCookie = true;
|
|
48
48
|
|
|
49
49
|
function validationError(issues) {
|
|
@@ -218,7 +218,13 @@ export function createRequestEditor({ state, basePath, $, onLookupPreview, onHea
|
|
|
218
218
|
return `<div class="section-label"><span id="body-legend">${esc(t('req.body'))} ${name ? `<a class="schema-link" href="#model/${encodeURIComponent(name.replace(/\[\]$/, ''))}" data-model="${esc(name.replace(/\[\]$/, ''))}" title="${esc(t('req.openModel', { name }))}">${esc(name)}</a>` : ''}</span><span class="rule" aria-hidden="true"></span>${switcher}</div>`;
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
+
/** Draws the operation, then lets a journey step mark its bound fields (onRendered). */
|
|
221
222
|
function renderOperation() {
|
|
223
|
+
renderOperationNow();
|
|
224
|
+
onRendered();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function renderOperationNow() {
|
|
222
228
|
state.forms.forEach(form => form.destroy());
|
|
223
229
|
state.forms = [];
|
|
224
230
|
state.bodyForm = null;
|
package/assets/result-states.js
CHANGED
|
@@ -76,7 +76,7 @@ export const runningHeader = (preview, identity) =>
|
|
|
76
76
|
<button type="button" class="btn btn-ghost btn-sm" data-action="cancel-request" ${shortcutAttrs('escape')}>${esc(t('bar.cancel'))} ${shortcutHint('escape')}</button>`;
|
|
77
77
|
|
|
78
78
|
/** The head row for a response, with Copy as cURL and the next step. */
|
|
79
|
-
export function responseHeader(result, { resourceLabel, match = '' } = {}) {
|
|
79
|
+
export function responseHeader(result, { resourceLabel, match = '', plain = false } = {}) {
|
|
80
80
|
const ok = result.status < 400;
|
|
81
81
|
const location = header(result, 'location');
|
|
82
82
|
let resource;
|
|
@@ -88,7 +88,7 @@ export function responseHeader(result, { resourceLabel, match = '' } = {}) {
|
|
|
88
88
|
}
|
|
89
89
|
const tracedPill = !result.preview && result.traceId
|
|
90
90
|
? `<span class="pill pill-ok">${icon('send', true)}${esc(t('res.traced'))}</span>` : pill(result.preview);
|
|
91
|
-
const action = result.preview && ok
|
|
91
|
+
const action = plain ? '' : result.preview && ok
|
|
92
92
|
? `<button type="button" class="btn btn-sm" data-action="send" ${shortcutAttrs('send')}>${icon('send', true)}${esc(t('res.sendForReal'))}</button>`
|
|
93
93
|
: resource ? `<a class="btn btn-sm result-open" href="${esc(resource)}" target="_blank" rel="noopener noreferrer" data-location-open ${shortcutAttrs('follow-response')}>${esc(resourceLabel || t('res.openResource'))} ${shortcutHint('follow-response')}</a>` : '';
|
|
94
94
|
return `${tracedPill}<span class="status-code ${statusTone(result.status)}">${icon(ok ? 'check' : result.status === 401 ? 'lock' : 'alert', true)}<bdi class="ltr">${esc(statusText(result.status))}</bdi></span>${metrics(result)}${match}<span class="spacer"></span>
|
package/assets/results.js
CHANGED
|
@@ -26,7 +26,7 @@ const CREDENTIAL = /authorization|cookie|password|passwd|secret|token|api[-_]?ke
|
|
|
26
26
|
/** Execute requests and render the result pane. */
|
|
27
27
|
export function createResults({
|
|
28
28
|
state, basePath, $, readRequest, sensitiveNames, renderOperation, issues, onFollowUp, selectView,
|
|
29
|
-
schemaName = () => '', fillable = () => false, onCompleted = () => {},
|
|
29
|
+
schemaName = () => '', fillable = () => false, onCompleted = () => {}, journey = () => null, databaseExtra = () => '',
|
|
30
30
|
}) {
|
|
31
31
|
let active;
|
|
32
32
|
let confirmation;
|
|
@@ -65,7 +65,11 @@ export function createResults({
|
|
|
65
65
|
dock.innerHTML = previewDock(entry);
|
|
66
66
|
}
|
|
67
67
|
const blocked = state.result?.blocked && state.result.operation === state.op ? storeName(state.result.blocked.store) : undefined;
|
|
68
|
-
|
|
68
|
+
// A journey step draws its own bar (mocks 134–137): its status, Run to end and Preview step N.
|
|
69
|
+
const hooks = journey();
|
|
70
|
+
bar?.classList?.toggle('j7-actions', !!hooks);
|
|
71
|
+
if (hooks && dock) dock.hidden = true;
|
|
72
|
+
if (bar && !confirmation) bar.innerHTML = hooks ? hooks.bar() : actionBar(state.op, previewAvailable(), { unavailable: entry, blocked });
|
|
69
73
|
}
|
|
70
74
|
|
|
71
75
|
/** Preview pressed (or ⌘↵) on an operation marked preview: false: point at the reason instead. */
|
|
@@ -184,6 +188,9 @@ export function createResults({
|
|
|
184
188
|
|
|
185
189
|
async function run(preview, confirmed = false) {
|
|
186
190
|
if (active) return;
|
|
191
|
+
// In a journey run a step carries its session, may Preview a GET inside it, and a Send run was
|
|
192
|
+
// confirmed once when it started (journeys.md, "Running a journey").
|
|
193
|
+
const hooks = journey()?.run?.(preview) ?? null;
|
|
187
194
|
let controller;
|
|
188
195
|
let started;
|
|
189
196
|
let target;
|
|
@@ -197,9 +204,10 @@ export function createResults({
|
|
|
197
204
|
cancelConfirmation();
|
|
198
205
|
request = readRequest();
|
|
199
206
|
}
|
|
200
|
-
if (preview && unavailable() && nudgeDock()) return;
|
|
201
|
-
if (preview && !previewAvailable()) throw new Error(t('res.previewUnavailable'));
|
|
202
|
-
|
|
207
|
+
if (preview && !hooks?.allowPreview && unavailable() && nudgeDock()) return;
|
|
208
|
+
if (preview && !previewAvailable() && !hooks?.allowPreview) throw new Error(t('res.previewUnavailable'));
|
|
209
|
+
for (const [name, value] of Object.entries(hooks?.headers ?? {})) request.headers.set(name, value);
|
|
210
|
+
if (!preview && !isReadOnly(state.op) && !confirmed && !hooks?.skipConfirm) {
|
|
203
211
|
issues?.clear();
|
|
204
212
|
askForConfirmation(request);
|
|
205
213
|
return;
|
|
@@ -226,7 +234,7 @@ export function createResults({
|
|
|
226
234
|
if (elapsed) elapsed.textContent = formatDuration(performance.now() - started);
|
|
227
235
|
}, 250);
|
|
228
236
|
try {
|
|
229
|
-
const observedSend = !preview && previewAvailable() && tracedSendEnabled(state.cap);
|
|
237
|
+
const observedSend = !preview && (hooks?.observedSend ?? (previewAvailable() && tracedSendEnabled(state.cap)));
|
|
230
238
|
const result = await execute(request, preview, basePath, controller.signal, { observedSend });
|
|
231
239
|
if (active !== controller || state.op !== operation || state.documentUrl !== documentUrl) return;
|
|
232
240
|
state.running = undefined;
|
|
@@ -248,6 +256,7 @@ export function createResults({
|
|
|
248
256
|
if (result.status >= 400) showValidationErrors(result.body);
|
|
249
257
|
if (state.resultTab !== 'Response' && !captured(result) && ['Database', 'Side effects', 'Logs'].includes(state.resultTab) && !rejectedEarly(result))
|
|
250
258
|
state.resultTab = 'Response';
|
|
259
|
+
else if (hooks) state.resultTab = 'Expected';
|
|
251
260
|
else if (preview && result.status < 400 && result.changes?.length) state.resultTab = 'Database';
|
|
252
261
|
if (recordHistory) state.history.unshift({ op: operation, body, params, headers: draftHeaders, preview, when: Date.now(), status: result.status });
|
|
253
262
|
state.history.length = Math.min(state.history.length, 50);
|
|
@@ -255,6 +264,7 @@ export function createResults({
|
|
|
255
264
|
renderResult();
|
|
256
265
|
if (result.blocked || preview) renderBar();
|
|
257
266
|
setView('response');
|
|
267
|
+
hooks?.onResult?.(result, { preview, operation });
|
|
258
268
|
onCompleted(result, { preview, operation });
|
|
259
269
|
} finally {
|
|
260
270
|
clearInterval(timer);
|
|
@@ -280,20 +290,28 @@ export function createResults({
|
|
|
280
290
|
renderResult();
|
|
281
291
|
setView('response');
|
|
282
292
|
} else if (error.name !== 'AbortError' && (!controller || !controller.signal.aborted)) showError(error);
|
|
293
|
+
hooks?.onError?.(error);
|
|
283
294
|
}
|
|
284
295
|
}
|
|
285
296
|
|
|
286
297
|
function renderTabs(result) {
|
|
287
298
|
const counts = state.running ? resultCounts(null) : resultCounts(result);
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
299
|
+
const expected = journey()?.expected;
|
|
300
|
+
// In a journey step Expected leads and keeps its count; the other tabs give up theirs (they're
|
|
301
|
+
// inside each tab) so all six fit the result pane at its default width (mock 134).
|
|
302
|
+
const tabs = expected ? ['Expected', ...RESULT_TABS] : RESULT_TABS;
|
|
303
|
+
$('.response .tabs').classList?.toggle('j7-rtabs', !!expected);
|
|
304
|
+
$('.response .tabs').innerHTML = tabs.map((tab, index) => tabButton(tab === 'Expected' ? expected.label : resultTabLabel(tab), {
|
|
305
|
+
selected: tab === state.resultTab, count: tab === 'Expected' ? expected.count : expected ? undefined : counts[index],
|
|
306
|
+
flag: tab === 'Expected' ? expected.flag : undefined, id: `result-tab-${tab.replaceAll(' ', '-')}`,
|
|
307
|
+
controls: 'result', shortcut: index < 5 ? 'result-tab-' + index : undefined, data: `data-result-tab="${tab}"`,
|
|
291
308
|
})).join('');
|
|
292
309
|
$('.response .tabs [aria-selected="true"]')?.scrollIntoView?.({ block: 'nearest', inline: 'nearest' });
|
|
293
310
|
}
|
|
294
311
|
|
|
295
312
|
/** The content of the selected tab for the current result. */
|
|
296
313
|
function tabContent(tab, result, ctx) {
|
|
314
|
+
if (tab === 'Expected') return journey()?.expected?.render() ?? '';
|
|
297
315
|
if (!result) return beforeRun(tab, ctx);
|
|
298
316
|
if (result.network) return tab === 'Response' ? networkError(result) : beforeRun(tab, ctx);
|
|
299
317
|
if (result.error) return tab === 'Response' ? requestError(result) : beforeRun(tab, ctx);
|
|
@@ -315,6 +333,8 @@ export function createResults({
|
|
|
315
333
|
function renderResult() {
|
|
316
334
|
const result = state.result;
|
|
317
335
|
const head = $('.resp-head');
|
|
336
|
+
const hooks = journey();
|
|
337
|
+
if (state.resultTab === 'Expected' && !hooks?.expected) state.resultTab = 'Response';
|
|
318
338
|
if (state.running) head.innerHTML = runningHeader(state.running.preview, state.cap.identity?.name);
|
|
319
339
|
else if (result?.network) head.innerHTML = networkHeader(result);
|
|
320
340
|
else if (result?.error) head.innerHTML = errorHeader();
|
|
@@ -322,24 +342,31 @@ export function createResults({
|
|
|
322
342
|
else {
|
|
323
343
|
// The schema match sits in the status line, after status, time and size (mock 100).
|
|
324
344
|
const viewContext = { document: state.doc, operation: state.op, operations: state.ops, basePath, onFollowUp, capabilities: state.cap };
|
|
325
|
-
head
|
|
345
|
+
// A journey step's head is the mock's quiet one: the mode, status, time and size, Copy as cURL and Re-run.
|
|
346
|
+
head.innerHTML = result ? responseHeader(result, { match: !hooks?.plainHead && (result.raw || result.body !== undefined) ? matchButton(result, viewContext) : '', plain: !!hooks?.plainHead }) + (hooks?.headExtra?.() ?? '') : hooks?.idleHead?.() ?? idleHeader();
|
|
326
347
|
if (result) bindMatch(head, result, viewContext);
|
|
327
348
|
}
|
|
328
349
|
renderTabs(result);
|
|
329
350
|
const bar = $('.result-bar');
|
|
330
|
-
if (bar) bar.innerHTML = resultBar(result, { running: !!state.running, identity: state.cap.identity?.name });
|
|
351
|
+
if (bar) bar.innerHTML = hooks?.resultBar?.(result, { running: !!state.running }) ?? resultBar(result, { running: !!state.running, identity: state.cap.identity?.name });
|
|
331
352
|
const panel = $('#result');
|
|
332
353
|
const tab = state.resultTab;
|
|
333
354
|
const wasBlocked = !!state.op && !!state.blockedOps?.[`${state.op.method} ${state.op.path}`];
|
|
334
|
-
if (state.running) panel.innerHTML = loadingBody(tab, state.running.preview, { blocked: state.running.preview && wasBlocked }) + `<span class="sr-only">${esc(t('res.loading'))}</span>`;
|
|
355
|
+
if (state.running) panel.innerHTML = (tab === 'Expected' && hooks?.expected?.loading ? hooks.expected.loading() : loadingBody(tab, state.running.preview, { blocked: state.running.preview && wasBlocked })) + `<span class="sr-only">${esc(t('res.loading'))}</span>`;
|
|
335
356
|
else {
|
|
336
357
|
panel.innerHTML = `<div class="result-body">${tabContent(tab, result, context())}</div>`;
|
|
337
358
|
const container = panel.querySelector('.result-body');
|
|
338
359
|
const viewContext = { document: state.doc, operation: state.op, operations: state.ops, basePath, onFollowUp, capabilities: state.cap };
|
|
339
|
-
if (
|
|
360
|
+
if (tab === 'Expected') hooks?.expected?.bind?.(container);
|
|
361
|
+
else if (result?.blocked && tab === 'Response') bindBlocked(container, result, context());
|
|
340
362
|
else if (result?.blocked && tab !== 'Headers') { /* A designed state with no captured data to bind. */ }
|
|
341
363
|
else if (result && !result.error && tab === 'Response') bindResponseViewer(container, result, viewContext);
|
|
342
|
-
else if (result && !result.error && tab === 'Database' && captured(result) && result.changes?.length)
|
|
364
|
+
else if (result && !result.error && tab === 'Database' && captured(result) && result.changes?.length) {
|
|
365
|
+
// Copy as C# (journeys): this Preview's writes as an ExpectWrites block, in the banner.
|
|
366
|
+
const extra = databaseExtra();
|
|
367
|
+
if (extra) container.querySelector('.banner')?.insertAdjacentHTML('beforeend', `<div class="j7-banner-acts">${extra}</div>`);
|
|
368
|
+
bindDatabase(container, result);
|
|
369
|
+
}
|
|
343
370
|
else if (result && !result.error && showsCapture(tab, result)) bindCapturePane(container, tab, result, viewContext);
|
|
344
371
|
}
|
|
345
372
|
panel.scrollTop = 0;
|
package/assets/router.js
CHANGED
|
@@ -8,16 +8,23 @@
|
|
|
8
8
|
// #model/<Name>?from=docs/<operationId>&via=<Model>,<Model>
|
|
9
9
|
// a model opened from an operation (`from` is docs/… or
|
|
10
10
|
// op/…) or from a $ref followed through other models (`via`)
|
|
11
|
+
// #journeys Journeys mode, where it was left
|
|
12
|
+
// #journey/<workflowId> a journey's overview
|
|
13
|
+
// #journey/<workflowId>/step/<stepId> a step of the open run, on its operation's own screen
|
|
14
|
+
// #journey/<workflowId>/run/<runId> a run's summary
|
|
11
15
|
//
|
|
12
16
|
// Expanding a schema inline is not navigation and never changes the address.
|
|
13
17
|
|
|
14
18
|
/**
|
|
15
19
|
* @typedef {object} Route
|
|
16
|
-
* @property {'overview'|'op'|'docs'|'model'} kind
|
|
20
|
+
* @property {'overview'|'op'|'docs'|'model'|'journeys'|'journey'|'jstep'|'jrun'} kind
|
|
17
21
|
* @property {string} [id] operation id (or "METHOD /path") for op and docs
|
|
18
22
|
* @property {string} [name] model name for model
|
|
19
23
|
* @property {{kind: 'op'|'docs', id: string}} [from] the operation a model was opened from
|
|
20
24
|
* @property {string[]} [via] models followed on the way, nearest to the operation first
|
|
25
|
+
* @property {string} [journey] workflowId for journey, jstep and jrun
|
|
26
|
+
* @property {string} [step] stepId for jstep
|
|
27
|
+
* @property {string} [run] runId for jrun
|
|
21
28
|
*/
|
|
22
29
|
|
|
23
30
|
const OVERVIEW = Object.freeze({ kind: 'overview' });
|
|
@@ -33,6 +40,16 @@ export function parseRoute(hash) {
|
|
|
33
40
|
let key = '';
|
|
34
41
|
try { key = decodeURIComponent(slash < 0 ? '' : path.slice(slash + 1)); } catch { return OVERVIEW; }
|
|
35
42
|
if ((kind === 'op' || kind === 'docs') && key) return { kind, id: key };
|
|
43
|
+
if (kind === 'journeys') return { kind: 'journeys' };
|
|
44
|
+
if (kind === 'journey' && key) {
|
|
45
|
+
let parts;
|
|
46
|
+
try { parts = path.slice(slash + 1).split('/').map(decodeURIComponent); } catch { return OVERVIEW; }
|
|
47
|
+
const [journey, sub, value] = parts;
|
|
48
|
+
if (sub === 'step' && value) return { kind: 'jstep', journey, step: value };
|
|
49
|
+
if (sub === 'run' && value) return { kind: 'jrun', journey, run: value };
|
|
50
|
+
if (journey && !sub) return { kind: 'journey', journey };
|
|
51
|
+
return OVERVIEW;
|
|
52
|
+
}
|
|
36
53
|
if (kind === 'model' && key) {
|
|
37
54
|
const route = { kind, name: key };
|
|
38
55
|
const from = /^(op|docs)\/(.+)$/.exec(query.get('from') ?? '');
|
|
@@ -48,6 +65,10 @@ export function parseRoute(hash) {
|
|
|
48
65
|
export function formatRoute(route) {
|
|
49
66
|
const encode = encodeURIComponent;
|
|
50
67
|
if (route.kind === 'op' || route.kind === 'docs') return `#${route.kind}/${encode(route.id)}`;
|
|
68
|
+
if (route.kind === 'journeys') return '#journeys';
|
|
69
|
+
if (route.kind === 'journey') return `#journey/${encode(route.journey)}`;
|
|
70
|
+
if (route.kind === 'jstep') return `#journey/${encode(route.journey)}/step/${encode(route.step)}`;
|
|
71
|
+
if (route.kind === 'jrun') return `#journey/${encode(route.journey)}/run/${encode(route.run)}`;
|
|
51
72
|
if (route.kind !== 'model') return '#overview';
|
|
52
73
|
const query = [];
|
|
53
74
|
if (route.from) query.push(`from=${route.from.kind}/${encode(route.from.id)}`);
|
|
@@ -55,6 +76,9 @@ export function formatRoute(route) {
|
|
|
55
76
|
return `#model/${encode(route.name)}${query.length ? '?' + query.join('&') : ''}`;
|
|
56
77
|
}
|
|
57
78
|
|
|
79
|
+
/** True for the routes of Journeys mode. */
|
|
80
|
+
export const isJourneyRoute = route => ['journeys', 'journey', 'jstep', 'jrun'].includes(route?.kind);
|
|
81
|
+
|
|
58
82
|
/** Whether two routes are the same page. */
|
|
59
83
|
export const sameRoute = (a, b) => formatRoute(a) === formatRoute(b);
|
|
60
84
|
|
package/assets/seeded-menu.js
CHANGED
|
@@ -12,7 +12,7 @@ const initials = name => String(name || '?').trim().split(/\s+/).slice(0, 2).map
|
|
|
12
12
|
* Opens the menu under `button`. `onSignedIn()` runs after the API accepted the sign-in; failures
|
|
13
13
|
* are shown inside the menu and nothing else changes.
|
|
14
14
|
*/
|
|
15
|
-
export async function openSeededMenu(button, { capabilities, onSignedIn }) {
|
|
15
|
+
export async function openSeededMenu(button, { capabilities, onSignedIn, confirmPersona }) {
|
|
16
16
|
const provider = personasProvider(capabilities);
|
|
17
17
|
if (!provider) return;
|
|
18
18
|
const pop = openPopoverAt(button, `<div class="pop seeded-pop" role="menu" aria-label="${esc(t('auth.out.seeded'))}">
|
|
@@ -55,6 +55,7 @@ export async function openSeededMenu(button, { capabilities, onSignedIn }) {
|
|
|
55
55
|
const item = event.target.closest('[data-seeded]');
|
|
56
56
|
const user = item && users[Number(item.dataset.seeded)];
|
|
57
57
|
if (!user?.email) return;
|
|
58
|
+
if (confirmPersona && !(await confirmPersona(user))) return;
|
|
58
59
|
item.setAttribute('aria-busy', 'true');
|
|
59
60
|
try {
|
|
60
61
|
const response = await fetch(`${provider.url.replace(/\/$/, '')}/${encodeURIComponent(user.email)}`, { method: 'POST', credentials: 'include', redirect: 'error' });
|
|
@@ -36,7 +36,9 @@ export function showShortcuts(overlay) {
|
|
|
36
36
|
const input = overlay.querySelector('input');
|
|
37
37
|
const dismiss = overlay.querySelector('.dialog-head button');
|
|
38
38
|
const body = overlay.querySelector('.dialog-body');
|
|
39
|
-
|
|
39
|
+
// Journeys shortcuts are listed only where Journeys mode exists (the mode switch is drawn).
|
|
40
|
+
const journeys = !!document.querySelector('[data-mode]');
|
|
41
|
+
const all = Object.entries(SHORTCUTS).filter(([, definition]) => definition.group && (definition.chord || definition.sequence) && (!definition.journeys || journeys));
|
|
40
42
|
if (app) app.inert = true;
|
|
41
43
|
|
|
42
44
|
function render() {
|
package/assets/shortcuts.js
CHANGED
|
@@ -22,6 +22,12 @@ export const SHORTCUTS = {
|
|
|
22
22
|
'sidebar-operations': { group: 'Navigate', sequence: ['G', 'O'], icon: 'list' },
|
|
23
23
|
'sidebar-models': { group: 'Navigate', sequence: ['G', 'M'], icon: 'box' },
|
|
24
24
|
'goto-operation': { group: 'Navigate', icon: 'search' },
|
|
25
|
+
// Journeys mode (v7): the mode switch, and moving between a run's steps.
|
|
26
|
+
'mode-spec': { group: 'Navigate', sequence: ['G', 'S'], icon: 'braces', journeys: true },
|
|
27
|
+
'mode-journeys': { group: 'Navigate', sequence: ['G', 'J'], icon: 'route', journeys: true },
|
|
28
|
+
'step-previous': { group: 'Navigate', chord: '[', journeys: true },
|
|
29
|
+
'step-next': { group: 'Navigate', chord: ']', journeys: true },
|
|
30
|
+
'run-to-end': { group: 'Request', chord: keys('Mod', 'Alt', 'Enter'), icon: 'forward', journeys: true },
|
|
25
31
|
docs: { group: 'Navigate', chord: 'D', icon: 'book' },
|
|
26
32
|
'model-back': { group: 'Navigate', chord: keys('Alt', 'ArrowLeft'), icon: 'arrow-left' },
|
|
27
33
|
'focus-pane': { group: 'Navigate', chord: keys('Mod', '[') },
|
package/assets/sidebar.js
CHANGED
|
@@ -57,8 +57,8 @@ export function loadNavState(storage, documentUrl) {
|
|
|
57
57
|
try {
|
|
58
58
|
const value = JSON.parse(storage?.getItem(navStorageKey(documentUrl)) || 'null');
|
|
59
59
|
const clean = source => Object.fromEntries(Object.entries(source && typeof source === 'object' ? source : {}).filter(([, flag]) => typeof flag === 'boolean'));
|
|
60
|
-
return { ops: clean(value?.ops), models: clean(value?.models) };
|
|
61
|
-
} catch { return { ops: {}, models: {} }; }
|
|
60
|
+
return { ops: clean(value?.ops), models: clean(value?.models), journeys: clean(value?.journeys) };
|
|
61
|
+
} catch { return { ops: {}, models: {}, journeys: {} }; }
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
/** Writes the remembered group state; storage that is full or blocked is ignored. */
|
|
@@ -77,9 +77,9 @@ export function operationGroups(ops, document) {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
/** Sidebar rendering and its small amount of state. */
|
|
80
|
-
export function createSidebar({ state, $, storage = globalThis.localStorage }) {
|
|
80
|
+
export function createSidebar({ state, $, storage = globalThis.localStorage, journeys }) {
|
|
81
81
|
let tab = 'operations';
|
|
82
|
-
let nav = { ops: {}, models: {} };
|
|
82
|
+
let nav = { ops: {}, models: {}, journeys: {} };
|
|
83
83
|
let loadedFor;
|
|
84
84
|
|
|
85
85
|
bindDeprecationTips();
|
|
@@ -198,10 +198,51 @@ export function createSidebar({ state, $, storage = globalThis.localStorage }) {
|
|
|
198
198
|
<button type="button" class="btn btn-ghost btn-xs" data-action="toggle-groups" title="${esc(t(everyGroupClosed ? 'side.expandAll' : 'side.collapseAll'))}">${icon('chevrons-ud', true)}<span class="lbl">${esc(t(everyGroupClosed ? 'side.expandAll' : 'side.collapseAll'))}</span></button>`;
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
+
/**
|
|
202
|
+
* Journeys mode (mocks v7): the head row in place of the tabs, the journeys list with the open
|
|
203
|
+
* run's rail, and Run all and Collapse all in the bar. `journeys` (from journeys.js) draws them.
|
|
204
|
+
*/
|
|
205
|
+
function renderJourneys(query) {
|
|
206
|
+
const tabs = $('.sidebar .tabs');
|
|
207
|
+
const head = $('[data-journeys-head]');
|
|
208
|
+
if (tabs) tabs.hidden = true;
|
|
209
|
+
if (head) { head.hidden = false; head.innerHTML = journeys.head(); }
|
|
210
|
+
const noticeSlot = $('[data-auth-notice]');
|
|
211
|
+
if (noticeSlot) noticeSlot.hidden = true;
|
|
212
|
+
const input = $('#filter');
|
|
213
|
+
const placeholder = t('jr.filter');
|
|
214
|
+
if (input) { input.placeholder = placeholder; input.disabled = !journeys.filterable(); }
|
|
215
|
+
const label = $('[data-filter-label]');
|
|
216
|
+
if (label) label.textContent = placeholder;
|
|
217
|
+
const end = $('[data-filter-end]');
|
|
218
|
+
if (end) end.innerHTML = query
|
|
219
|
+
? `<button type="button" class="btn btn-ghost btn-icon btn-xs" data-action="clear-filter" aria-label="${esc(t('side.clearFilter'))}">${icon('x', true)}</button>`
|
|
220
|
+
: shortcutHint('filter');
|
|
221
|
+
const list = $('.nav');
|
|
222
|
+
list.removeAttribute('aria-labelledby');
|
|
223
|
+
list.setAttribute('aria-label', t('jr.mode.journeys'));
|
|
224
|
+
list.removeAttribute('role');
|
|
225
|
+
const scroll = list.scrollTop;
|
|
226
|
+
list.innerHTML = journeys.list(query, key => isCollapsed('journeys', key)) || (query ? noMatch(query, journeys.names()) : '');
|
|
227
|
+
list.scrollTop = scroll;
|
|
228
|
+
$('.side-bar').innerHTML = journeys.foot(keys => keys.every(key => isCollapsed('journeys', key)));
|
|
229
|
+
}
|
|
230
|
+
|
|
201
231
|
/** Re-renders the tabs' counts, the notice, the filter's end slot, the list and the foot bar. */
|
|
202
232
|
function render() {
|
|
203
233
|
const input = $('#filter');
|
|
204
234
|
const query = (input?.value || '').trim().toLowerCase();
|
|
235
|
+
if (journeys?.active()) { renderJourneys(query); return; }
|
|
236
|
+
const tabsRow = $('.sidebar .tabs');
|
|
237
|
+
if (tabsRow?.hidden) {
|
|
238
|
+
tabsRow.hidden = false;
|
|
239
|
+
const head = $('[data-journeys-head]');
|
|
240
|
+
if (head) head.hidden = true;
|
|
241
|
+
if (input) input.disabled = false;
|
|
242
|
+
const list = $('.nav');
|
|
243
|
+
list.removeAttribute('aria-label');
|
|
244
|
+
list.setAttribute('role', 'tabpanel');
|
|
245
|
+
}
|
|
205
246
|
for (const button of document.querySelectorAll('[data-side-tab]')) {
|
|
206
247
|
const selected = button.dataset.sideTab === tab;
|
|
207
248
|
button.setAttribute('aria-selected', String(selected));
|
|
@@ -247,11 +288,19 @@ export function createSidebar({ state, $, storage = globalThis.localStorage }) {
|
|
|
247
288
|
list.hidden = !expand;
|
|
248
289
|
heading.setAttribute('aria-expanded', String(expand));
|
|
249
290
|
heading.querySelector('use').setAttribute('href', expand ? '#i-chevron-down' : '#i-chevron-right');
|
|
250
|
-
if (heading.dataset.groupKind === 'ops') render();
|
|
291
|
+
if (heading.dataset.groupKind === 'ops' || heading.dataset.groupKind === 'journeys') render();
|
|
251
292
|
}
|
|
252
293
|
|
|
253
294
|
/** Collapses every operation group, or opens them all when they are all collapsed. */
|
|
254
295
|
function toggleAll() {
|
|
296
|
+
if (journeys?.active()) {
|
|
297
|
+
const keys = journeys.groupKeys();
|
|
298
|
+
const collapse = !keys.every(key => isCollapsed('journeys', key));
|
|
299
|
+
for (const key of keys) remember('journeys', key, collapse);
|
|
300
|
+
render();
|
|
301
|
+
$('[data-action="toggle-groups"]')?.focus();
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
255
304
|
const collapse = !groups().every(([name]) => isCollapsed('ops', name));
|
|
256
305
|
for (const [name] of groups()) remember('ops', name, collapse);
|
|
257
306
|
render();
|
package/assets/signin.js
CHANGED
|
@@ -105,7 +105,7 @@ function serverErrorPanel(failure) {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
/** Render configured authentication providers and optional development personas. */
|
|
108
|
-
export async function showSignIn(root, capabilities, onSignedIn, onCancel) {
|
|
108
|
+
export async function showSignIn(root, capabilities, onSignedIn, onCancel, { confirmPersona } = {}) {
|
|
109
109
|
const controller = new AbortController();
|
|
110
110
|
let active = true;
|
|
111
111
|
const providers = Array.isArray(capabilities.authProviders) ? capabilities.authProviders : [];
|
|
@@ -247,10 +247,13 @@ export async function showSignIn(root, capabilities, onSignedIn, onCancel) {
|
|
|
247
247
|
if (!Array.isArray(users)) throw new Error(t('signin.accountsInvalid'));
|
|
248
248
|
if (!active) return;
|
|
249
249
|
container.innerHTML = users.map(personaMarkup).join('') || `<div class="persona-row"><span class="faint">${esc(t('signin.noAccounts'))}</span></div>`;
|
|
250
|
-
container.onclick = event => {
|
|
250
|
+
container.onclick = async event => {
|
|
251
251
|
const button = event.target.closest('[data-persona]');
|
|
252
252
|
const user = button && users[Number(button.dataset.persona)];
|
|
253
|
-
if (user?.email)
|
|
253
|
+
if (!user?.email) return;
|
|
254
|
+
// Switching persona ends a held Preview session (journeys.js asks first); declining stays put.
|
|
255
|
+
if (confirmPersona && !(await confirmPersona(user))) return;
|
|
256
|
+
signIn(`${personas.url.replace(/\/$/, '')}/${encodeURIComponent(user.email)}`, null, button);
|
|
254
257
|
};
|
|
255
258
|
} catch (failure) {
|
|
256
259
|
if (active) container.innerHTML = `<div class="persona-row" role="alert"><span style="color:var(--danger)">${esc(failure.message)}</span></div>`;
|
package/assets/styles.css
CHANGED
|
@@ -516,10 +516,16 @@ fieldset { border: 0; padding: 0; margin: 0; min-inline-size: 0; }
|
|
|
516
516
|
.param-holder[data-half] > div > .field { grid-column: auto; }
|
|
517
517
|
.param-holder[data-half="start"] > div > .field { grid-column: 1; }
|
|
518
518
|
.field { display: grid; grid-template-rows: auto auto auto auto; row-gap: 0; min-inline-size: 0; padding-block-end: 0.75rem; }
|
|
519
|
+
/* A label never gets squeezed below its text: the chips beside it give way first, the type, then
|
|
520
|
+
"optional", then the Fixed or bound chip (Clear, an action, stays). */
|
|
519
521
|
.label { display: flex; align-items: center; gap: 0.375rem; min-inline-size: 0; min-block-size: 1.5rem; margin-block-end: 0.375rem; font-size: var(--fs-base); font-weight: 500; }
|
|
520
|
-
.label .name { min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
522
|
+
.label .name { flex: 0 0 auto; max-inline-size: 100%; min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
523
|
+
.label > :is(.opt, .bind7) { flex: 0 1 auto; min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
524
|
+
.label > .opt { flex-shrink: 4; }
|
|
521
525
|
.label .opt { font-weight: 400; color: var(--text-3); font-size: var(--fs-sm); }
|
|
522
|
-
.label .end { margin-inline-start: auto; display: flex; align-items: center; gap: 0.625rem; flex:
|
|
526
|
+
.label .end { margin-inline-start: auto; display: flex; align-items: center; gap: 0.625rem; flex: 0 1 auto; min-inline-size: 0; }
|
|
527
|
+
.label .end > * { flex: none; }
|
|
528
|
+
.label .end > .type { flex: 0 10 auto; min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; }
|
|
523
529
|
.label .type { font: 400 var(--fs-sm)/1 var(--mono); color: var(--text-3); white-space: nowrap; direction: ltr; }
|
|
524
530
|
.field-clear { block-size: 1.5rem; padding-inline: 0.3125rem; margin-inline: -0.3125rem 0; border: 0; border-radius: var(--r-sm); background: none; color: var(--accent-text); font: 500 var(--fs-sm)/1 var(--font); cursor: pointer; }
|
|
525
531
|
.field-clear:hover { background: var(--accent-soft); }
|
package/assets/toast.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// A quiet note that says what the workbench just did on the person's behalf (for example, signing
|
|
2
|
+
// them in as the persona a journey runs as). It never asks for anything: it fades after a few
|
|
3
|
+
// seconds, has a close button, and is announced politely to screen readers. One at a time.
|
|
4
|
+
import { esc, icon } from './components.js';
|
|
5
|
+
import { t } from './i18n.js';
|
|
6
|
+
|
|
7
|
+
const SHOWN_MS = 7000;
|
|
8
|
+
let current = null;
|
|
9
|
+
|
|
10
|
+
/** Shows `text` as a note at the bottom of the window. `glyph` is an icon name. Returns a function that closes it. */
|
|
11
|
+
export function showToast(text, { glyph = 'info', duration = SHOWN_MS } = {}) {
|
|
12
|
+
const doc = globalThis.document;
|
|
13
|
+
current?.close();
|
|
14
|
+
const host = doc.createElement('div');
|
|
15
|
+
host.className = 'toast';
|
|
16
|
+
host.setAttribute('role', 'status');
|
|
17
|
+
host.innerHTML = `${icon(glyph, true)}<span class="toast-text">${esc(text)}</span><button class="btn btn-ghost btn-icon btn-xs toast-close" type="button" aria-label="${esc(t('dialog.close'))}">${icon('x', true)}</button>`;
|
|
18
|
+
doc.body.append(host);
|
|
19
|
+
let timer = null;
|
|
20
|
+
const close = () => {
|
|
21
|
+
clearTimeout(timer);
|
|
22
|
+
host.remove();
|
|
23
|
+
if (current?.host === host) current = null;
|
|
24
|
+
};
|
|
25
|
+
host.querySelector('.toast-close').addEventListener('click', close);
|
|
26
|
+
if (duration > 0) timer = setTimeout(close, duration);
|
|
27
|
+
current = { host, close };
|
|
28
|
+
return close;
|
|
29
|
+
}
|