@kawapress/plugin-openapi 0.1.0 → 0.2.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/package.json +3 -3
- package/src/components/KawaOpenApiCard.vue +2 -1
- package/src/components/KawaOpenApiEndpoint.vue +3 -2
- package/src/components/KawaOpenApiJourney.vue +412 -53
- package/src/components/KawaOpenApiMap.vue +2 -1
- package/src/components/KawaOpenApiPath.vue +16 -0
- package/src/components/journey.ts +401 -0
- package/src/components/openapi.css +205 -50
- package/src/data/components.ts +129 -111
- package/src/index.ts +3 -2
- package/src/options.ts +56 -8
- package/src/pages.ts +34 -6
- package/src/read/arazzo.ts +1 -0
- package/src/render/labels.ts +137 -15
- package/src/render/pages.ts +30 -6
- package/src/service.ts +53 -25
- package/src/types.ts +15 -4
- package/src/vite.ts +7 -5
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
.kawa-openapi-endpoint__path {
|
|
126
126
|
min-width: 0;
|
|
127
127
|
font-size: 0.9375rem;
|
|
128
|
-
overflow-wrap:
|
|
128
|
+
overflow-wrap: break-word;
|
|
129
129
|
background: none;
|
|
130
130
|
padding: 0;
|
|
131
131
|
}
|
|
@@ -179,7 +179,7 @@
|
|
|
179
179
|
|
|
180
180
|
.kawa-openapi-try textarea { resize: vertical; }
|
|
181
181
|
.kawa-openapi-try__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
|
|
182
|
-
.kawa-openapi-try__target { font-size: 0.8125rem; color: var(--kawa-c-text-2); background: none; overflow-wrap:
|
|
182
|
+
.kawa-openapi-try__target { font-size: 0.8125rem; color: var(--kawa-c-text-2); background: none; overflow-wrap: break-word; }
|
|
183
183
|
|
|
184
184
|
.kawa-openapi-try__output {
|
|
185
185
|
padding: 0.5rem 0.75rem;
|
|
@@ -302,12 +302,18 @@
|
|
|
302
302
|
/* ----------------------------------------------------------------- tabs */
|
|
303
303
|
.kawa-openapi-tabs { margin: 0.75rem 0 1.25rem; }
|
|
304
304
|
|
|
305
|
+
/*
|
|
306
|
+
* The strip scrolls sideways, which also clips anything drawn past its box.
|
|
307
|
+
* It reaches 0.375rem into the gutter on both sides so a tab's focus ring has
|
|
308
|
+
* room, and draws its divider as a background that stays within the text column.
|
|
309
|
+
*/
|
|
305
310
|
.kawa-openapi-tabs__list {
|
|
306
311
|
display: flex;
|
|
307
312
|
gap: 1.25rem;
|
|
308
313
|
overflow-x: auto;
|
|
309
|
-
margin
|
|
310
|
-
|
|
314
|
+
margin: 0 -0.375rem 0.75rem;
|
|
315
|
+
padding-inline: 0.375rem;
|
|
316
|
+
background: linear-gradient(var(--kawa-c-divider) 0 0) 50% 100% / calc(100% - 0.75rem) 1px no-repeat;
|
|
311
317
|
scrollbar-width: none;
|
|
312
318
|
}
|
|
313
319
|
|
|
@@ -331,11 +337,24 @@
|
|
|
331
337
|
.kawa-openapi-tabs__tab[aria-selected='true']::after {
|
|
332
338
|
content: '';
|
|
333
339
|
position: absolute;
|
|
334
|
-
inset: auto 0
|
|
340
|
+
inset: auto 0 0;
|
|
335
341
|
height: 2px;
|
|
342
|
+
border-radius: 1px;
|
|
336
343
|
background: currentColor;
|
|
337
344
|
}
|
|
338
345
|
|
|
346
|
+
/* A rounded ring around the label, clear of the underline below it. */
|
|
347
|
+
.kawa-openapi-tabs .kawa-openapi-tabs__tab:focus-visible { outline: none; }
|
|
348
|
+
|
|
349
|
+
.kawa-openapi-tabs__tab:focus-visible::before {
|
|
350
|
+
content: '';
|
|
351
|
+
position: absolute;
|
|
352
|
+
inset: 0.125rem -0.25rem 0.3125rem;
|
|
353
|
+
border-radius: 0.375rem;
|
|
354
|
+
box-shadow: 0 0 0 2px var(--kawa-c-brand);
|
|
355
|
+
pointer-events: none;
|
|
356
|
+
}
|
|
357
|
+
|
|
339
358
|
.kawa-openapi-responses__description { margin-bottom: 0.5rem; color: var(--kawa-c-text-2); }
|
|
340
359
|
.kawa-openapi-responses__description :where(p) { margin: 0; }
|
|
341
360
|
.kawa-openapi-responses__empty { margin: 0; color: var(--kawa-c-text-3); }
|
|
@@ -388,87 +407,220 @@
|
|
|
388
407
|
|
|
389
408
|
.kawa-openapi-map__cell + .kawa-openapi-map__cell { margin-top: 0.625rem; }
|
|
390
409
|
.kawa-openapi-map__cell .kawa-openapi-badge { margin: 0; }
|
|
391
|
-
.kawa-openapi-map__path { font: 0.75rem var(--kawa-font-mono); overflow-wrap:
|
|
410
|
+
.kawa-openapi-map__path { font: 0.75rem var(--kawa-font-mono); overflow-wrap: break-word; }
|
|
392
411
|
.kawa-openapi-map__cell:hover .kawa-openapi-map__path { color: var(--kawa-c-brand); }
|
|
393
412
|
.kawa-openapi-map__cell.is-deprecated .kawa-openapi-map__path { text-decoration: line-through; }
|
|
394
413
|
.kawa-openapi-map__gap { color: var(--kawa-c-text-3); }
|
|
395
414
|
|
|
396
415
|
/* -------------------------------------------------------------- journey */
|
|
397
416
|
.kawa-openapi-journey { margin: 0.75rem 0 1.5rem; }
|
|
398
|
-
.kawa-openapi-journey__toolbar { display: flex; justify-content: flex-end; margin-bottom: 0.75rem; }
|
|
399
417
|
|
|
400
|
-
.kawa-openapi-
|
|
401
|
-
|
|
418
|
+
.kawa-openapi-journey__toolbar {
|
|
419
|
+
display: flex;
|
|
420
|
+
flex-wrap: wrap;
|
|
421
|
+
align-items: center;
|
|
422
|
+
gap: 0.5rem;
|
|
423
|
+
margin-bottom: 0.75rem;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
.kawa-openapi-journey__spacer { flex: 1; }
|
|
427
|
+
.kawa-openapi-journey__progress { font-size: 0.8125rem; color: var(--kawa-c-text-2); }
|
|
428
|
+
|
|
429
|
+
.kawa-openapi-journey__console {
|
|
402
430
|
display: grid;
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
list-style: none;
|
|
431
|
+
grid-template-columns: minmax(0, 15rem) minmax(0, 1fr);
|
|
432
|
+
gap: 1rem;
|
|
433
|
+
align-items: start;
|
|
407
434
|
}
|
|
408
435
|
|
|
409
|
-
.kawa-openapi-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
436
|
+
.kawa-openapi-journey__side { display: grid; gap: 0.75rem; position: sticky; top: calc(var(--nagi-nav-height, 0px) + 1rem); }
|
|
437
|
+
|
|
438
|
+
.kawa-openapi-journey__panel {
|
|
439
|
+
padding: 0.625rem 0.75rem;
|
|
440
|
+
border: 1px solid var(--kawa-c-divider);
|
|
441
|
+
border-radius: var(--kawa-radius);
|
|
442
|
+
background: var(--kawa-c-bg-elv);
|
|
415
443
|
}
|
|
416
444
|
|
|
417
|
-
.kawa-openapi-
|
|
418
|
-
|
|
445
|
+
.kawa-openapi-journey__panel-title { margin-bottom: 0.5rem; font-size: 0.75rem; font-weight: 600; color: var(--kawa-c-text-2); }
|
|
446
|
+
|
|
447
|
+
.kawa-openapi-journey__value {
|
|
419
448
|
display: grid;
|
|
420
|
-
|
|
421
|
-
|
|
449
|
+
gap: 0.125rem;
|
|
450
|
+
margin-top: 0.375rem;
|
|
451
|
+
padding: 0.375rem 0.5rem;
|
|
452
|
+
border: 1px solid transparent;
|
|
453
|
+
border-radius: 0.375rem;
|
|
454
|
+
font-size: 0.8125rem;
|
|
455
|
+
transition: transform 0.25s, box-shadow 0.25s;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
.kawa-openapi-journey__value.is-empty { border: 1px dashed var(--kawa-c-border); color: var(--kawa-c-text-3); }
|
|
459
|
+
.kawa-openapi-journey__value.is-input { border: 1px dashed var(--kawa-c-text-3); }
|
|
460
|
+
.kawa-openapi-journey__value.is-landed { animation: kawa-openapi-land 0.6s ease-out; }
|
|
461
|
+
.kawa-openapi-journey__value-name { font: 600 0.75rem var(--kawa-font-mono); }
|
|
462
|
+
.kawa-openapi-journey__value-name small { font-weight: 400; color: var(--kawa-c-text-3); }
|
|
463
|
+
.kawa-openapi-journey__value-text { font: 0.75rem var(--kawa-font-mono); overflow-wrap: anywhere; }
|
|
464
|
+
.kawa-openapi-journey__value small { font-size: 0.6875rem; color: var(--kawa-c-text-3); }
|
|
465
|
+
.kawa-openapi-journey__value-wait { font-size: 0.75rem; }
|
|
466
|
+
|
|
467
|
+
.kawa-openapi-journey__value input {
|
|
468
|
+
width: 100%;
|
|
469
|
+
padding: 0.1875rem 0.375rem;
|
|
470
|
+
border: 1px solid var(--kawa-c-border);
|
|
471
|
+
border-radius: 0.3125rem;
|
|
472
|
+
font: 0.75rem var(--kawa-font-mono);
|
|
473
|
+
color: var(--kawa-c-text-1);
|
|
474
|
+
background: var(--kawa-c-bg);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
@keyframes kawa-openapi-land {
|
|
478
|
+
from { transform: translateX(-0.5rem); box-shadow: 0 0 0 3px color-mix(in oklch, var(--kawa-c-brand) 35%, transparent); }
|
|
479
|
+
to { transform: none; box-shadow: none; }
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
.kawa-openapi-journey__calls { margin-top: 1rem; }
|
|
483
|
+
|
|
484
|
+
.kawa-openapi-journey__log {
|
|
485
|
+
display: grid;
|
|
486
|
+
grid-template-columns: 1fr 1fr;
|
|
487
|
+
gap: 0.25rem;
|
|
488
|
+
max-height: 16rem;
|
|
489
|
+
overflow-y: auto;
|
|
490
|
+
font: 0.6875rem var(--kawa-font-mono);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
.kawa-openapi-journey__lane { text-align: center; color: var(--kawa-c-text-3); border-bottom: 1px solid var(--kawa-c-divider); padding-bottom: 0.125rem; }
|
|
494
|
+
.kawa-openapi-journey__no-calls { grid-column: 1 / -1; color: var(--kawa-c-text-3); font-family: inherit; }
|
|
495
|
+
.kawa-openapi-journey__call { grid-column: 1; padding: 0.125rem 0.375rem; border-radius: 0.25rem; overflow-wrap: anywhere; }
|
|
496
|
+
.kawa-openapi-journey__call.is-request { background: color-mix(in oklch, var(--kawa-c-text-1) 7%, transparent); }
|
|
497
|
+
.kawa-openapi-journey__call.is-request span::after { content: ' →'; color: var(--kawa-c-text-3); }
|
|
498
|
+
.kawa-openapi-journey__call.is-response,
|
|
499
|
+
.kawa-openapi-journey__call.is-error { grid-column: 2; text-align: start; }
|
|
500
|
+
.kawa-openapi-journey__call.is-response span::before,
|
|
501
|
+
.kawa-openapi-journey__call.is-error span::before { content: '← '; color: var(--kawa-c-text-3); }
|
|
502
|
+
.kawa-openapi-journey__call.is-response { color: var(--kawa-c-success); background: color-mix(in oklch, var(--kawa-c-success) 12%, transparent); }
|
|
503
|
+
.kawa-openapi-journey__call.is-error { color: var(--kawa-c-danger); background: color-mix(in oklch, var(--kawa-c-danger) 12%, transparent); }
|
|
504
|
+
|
|
505
|
+
.kawa-openapi-journey__steps { display: grid; gap: 0.625rem; margin: 0; padding: 0; list-style: none; }
|
|
506
|
+
|
|
507
|
+
.kawa-openapi-journey__step {
|
|
508
|
+
min-width: 0;
|
|
422
509
|
margin: 0;
|
|
510
|
+
padding: 0.625rem 0.75rem;
|
|
511
|
+
border: 1px solid var(--kawa-c-divider);
|
|
512
|
+
border-radius: var(--kawa-radius);
|
|
513
|
+
background: var(--kawa-c-bg-elv);
|
|
423
514
|
}
|
|
424
515
|
|
|
516
|
+
.kawa-openapi-journey__step.is-current { border-color: var(--kawa-c-brand); box-shadow: 0 0 0 1px var(--kawa-c-brand); }
|
|
517
|
+
.kawa-openapi-journey__step.is-failed { border-color: var(--kawa-c-danger); }
|
|
518
|
+
|
|
519
|
+
.kawa-openapi-journey__head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
|
|
520
|
+
.kawa-openapi-journey__path { font: 0.8125rem var(--kawa-font-mono); overflow-wrap: anywhere; }
|
|
521
|
+
.kawa-openapi-journey__title { font-weight: 600; color: var(--kawa-c-brand); text-decoration: none; }
|
|
522
|
+
.kawa-openapi-journey__title:hover { text-decoration: underline; }
|
|
523
|
+
.kawa-openapi-journey__summary { margin-inline-start: auto; font: 0.75rem var(--kawa-font-mono); color: var(--kawa-c-success); overflow-wrap: anywhere; }
|
|
524
|
+
.kawa-openapi-journey__step.is-failed .kawa-openapi-journey__summary { color: var(--kawa-c-danger); }
|
|
525
|
+
|
|
425
526
|
.kawa-openapi-journey__dot {
|
|
426
|
-
position: relative;
|
|
427
|
-
z-index: 1;
|
|
428
527
|
display: grid;
|
|
429
528
|
place-items: center;
|
|
430
|
-
width:
|
|
431
|
-
height:
|
|
529
|
+
width: 1.5rem;
|
|
530
|
+
height: 1.5rem;
|
|
432
531
|
border: 2px solid var(--kawa-c-border);
|
|
433
532
|
border-radius: 50%;
|
|
434
|
-
font-size: 0.
|
|
533
|
+
font-size: 0.75rem;
|
|
435
534
|
font-weight: 700;
|
|
436
535
|
color: var(--kawa-c-text-2);
|
|
437
536
|
background: var(--kawa-c-bg);
|
|
438
537
|
transition: border-color 0.2s, background-color 0.2s, color 0.2s;
|
|
439
538
|
}
|
|
440
539
|
|
|
441
|
-
.kawa-openapi-journey__step.is-
|
|
540
|
+
.kawa-openapi-journey__step.is-current .kawa-openapi-journey__dot { border-color: var(--kawa-c-brand); color: var(--kawa-c-brand); }
|
|
442
541
|
.kawa-openapi-journey__step.is-done .kawa-openapi-journey__dot { border-color: var(--kawa-c-success); color: var(--kawa-c-bg); background: var(--kawa-c-success); }
|
|
542
|
+
.kawa-openapi-journey__step.is-failed .kawa-openapi-journey__dot { border-color: var(--kawa-c-danger); color: var(--kawa-c-danger); }
|
|
443
543
|
|
|
444
|
-
.kawa-openapi-journey__card {
|
|
445
|
-
min-width: 0;
|
|
446
|
-
padding: 0.75rem 0.875rem;
|
|
447
|
-
border: 1px solid var(--kawa-c-divider);
|
|
448
|
-
border-radius: var(--kawa-radius);
|
|
449
|
-
background: var(--kawa-c-bg-elv);
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
.kawa-openapi-journey__head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
|
|
453
|
-
.kawa-openapi-journey__head code { background: none; padding: 0; overflow-wrap: anywhere; }
|
|
454
|
-
.kawa-openapi-journey__title { font-weight: 600; text-decoration: none; }
|
|
455
|
-
.kawa-openapi-journey__spacer { flex: 1; }
|
|
456
|
-
.kawa-openapi-journey__state { font: 0.75rem var(--kawa-font-mono); color: var(--kawa-c-text-3); }
|
|
457
|
-
.kawa-openapi-journey__step.is-done .kawa-openapi-journey__state { color: var(--kawa-c-success); }
|
|
458
544
|
.kawa-openapi-journey__description { margin-top: 0.375rem; font-size: 0.875rem; color: var(--kawa-c-text-2); }
|
|
459
545
|
.kawa-openapi-journey__description :where(p) { margin: 0; }
|
|
460
546
|
.kawa-openapi-journey__flows { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; font-size: 0.8125rem; }
|
|
461
|
-
.kawa-openapi-journey__params { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem; margin-top: 0.5rem; font-size: 0.8125rem; }
|
|
462
|
-
.kawa-openapi-journey__label { font-size: 0.75rem; color: var(--kawa-c-text-2); margin-bottom: 0.25rem; }
|
|
463
547
|
|
|
464
548
|
.kawa-openapi-journey__io {
|
|
465
549
|
display: grid;
|
|
466
550
|
grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
|
|
467
|
-
gap: 0.
|
|
551
|
+
gap: 0.625rem;
|
|
468
552
|
margin-top: 0.625rem;
|
|
469
553
|
}
|
|
470
554
|
|
|
471
|
-
.kawa-openapi-
|
|
555
|
+
.kawa-openapi-journey__box { min-width: 0; }
|
|
556
|
+
.kawa-openapi-journey__box-title { margin-bottom: 0.25rem; font-size: 0.75rem; color: var(--kawa-c-text-2); }
|
|
557
|
+
|
|
558
|
+
.kawa-openapi-journey__box pre,
|
|
559
|
+
.kawa-openapi-journey__code {
|
|
560
|
+
margin: 0;
|
|
561
|
+
padding: 0.5rem 0.625rem;
|
|
562
|
+
border-radius: 0.375rem;
|
|
563
|
+
font: 0.75rem/1.6 var(--kawa-font-mono);
|
|
564
|
+
background: var(--kawa-c-bg-soft);
|
|
565
|
+
overflow-x: auto;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
.kawa-openapi-journey__box pre code,
|
|
569
|
+
.kawa-openapi-journey__code code { padding: 0; background: none; font: inherit; }
|
|
570
|
+
.kawa-openapi-journey__box .kawa-openapi-method { font-size: inherit; }
|
|
571
|
+
|
|
572
|
+
.kawa-openapi-journey__t--key { color: var(--kawa-c-text-2); }
|
|
573
|
+
.kawa-openapi-journey__t--string { color: var(--kawa-c-success); }
|
|
574
|
+
.kawa-openapi-journey__t--number,
|
|
575
|
+
.kawa-openapi-journey__t--literal { color: var(--kawa-c-info); }
|
|
576
|
+
.kawa-openapi-journey__t--punct,
|
|
577
|
+
.kawa-openapi-journey__t--note { color: var(--kawa-c-text-3); }
|
|
578
|
+
.kawa-openapi-journey__t--input { outline: 1px dashed var(--kawa-c-text-3); border-radius: 0.25rem; }
|
|
579
|
+
.kawa-openapi-journey__t--output { color: var(--kawa-c-text-1); }
|
|
580
|
+
.kawa-openapi-journey__t--outlined { outline: 2px solid currentcolor; outline-offset: 1px; border-radius: 0.25rem; }
|
|
581
|
+
|
|
582
|
+
.kawa-openapi-journey__t--missing {
|
|
583
|
+
padding: 0 0.25rem;
|
|
584
|
+
border-radius: 0.25rem;
|
|
585
|
+
color: var(--kawa-c-danger);
|
|
586
|
+
background: color-mix(in oklch, var(--kawa-c-danger) 14%, transparent);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
.kawa-openapi-journey__t--ok { font-weight: 700; color: var(--kawa-c-success); }
|
|
590
|
+
.kawa-openapi-journey__t--error { font-weight: 700; color: var(--kawa-c-danger); }
|
|
591
|
+
|
|
592
|
+
.kawa-openapi-journey__problem {
|
|
593
|
+
margin-top: 0.5rem;
|
|
594
|
+
padding: 0.5rem 0.625rem;
|
|
595
|
+
border-inline-start: 3px solid var(--kawa-c-danger);
|
|
596
|
+
border-radius: 0.25rem;
|
|
597
|
+
font-size: 0.8125rem;
|
|
598
|
+
background: color-mix(in oklch, var(--kawa-c-danger) 8%, transparent);
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
.kawa-openapi-journey__problem div + div { margin-top: 0.25rem; }
|
|
602
|
+
.kawa-openapi-journey__actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.625rem; }
|
|
603
|
+
.kawa-openapi-journey__closed { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.375rem; font-size: 0.8125rem; color: var(--kawa-c-text-3); }
|
|
604
|
+
|
|
605
|
+
.kawa-openapi-button--ghost { border-style: dashed; color: var(--kawa-c-text-2); background: transparent; }
|
|
606
|
+
.kawa-openapi-button--primary:hover { filter: brightness(1.08); }
|
|
607
|
+
|
|
608
|
+
.kawa-openapi-journey__finish {
|
|
609
|
+
margin-top: 1rem;
|
|
610
|
+
padding: 0.75rem 0.875rem;
|
|
611
|
+
border: 1px solid var(--kawa-c-success);
|
|
612
|
+
border-radius: var(--kawa-radius);
|
|
613
|
+
background: color-mix(in oklch, var(--kawa-c-success) 6%, var(--kawa-c-bg));
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
.kawa-openapi-journey__finish-head { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: baseline; }
|
|
617
|
+
.kawa-openapi-journey__finish-head span { font-size: 0.875rem; color: var(--kawa-c-text-2); }
|
|
618
|
+
.kawa-openapi-journey__code-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0.625rem 0 0.375rem; font-size: 0.8125rem; color: var(--kawa-c-text-2); }
|
|
619
|
+
|
|
620
|
+
@media (max-width: 860px) {
|
|
621
|
+
.kawa-openapi-journey__console { grid-template-columns: minmax(0, 1fr); }
|
|
622
|
+
.kawa-openapi-journey__side { position: static; }
|
|
623
|
+
}
|
|
472
624
|
|
|
473
625
|
/* ------------------------------------------------------- card and ref */
|
|
474
626
|
.kawa-openapi-card {
|
|
@@ -482,7 +634,8 @@
|
|
|
482
634
|
|
|
483
635
|
.kawa-openapi-card__head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-bottom: 0.375rem; }
|
|
484
636
|
.kawa-openapi-card__head code { background: none; padding: 0; }
|
|
485
|
-
.kawa-openapi-card__title { font-weight: 600; text-decoration: none; }
|
|
637
|
+
.kawa-openapi-card__title { font-weight: 600; color: var(--kawa-c-brand); text-decoration: none; }
|
|
638
|
+
.kawa-openapi-card__title:hover { text-decoration: underline; }
|
|
486
639
|
.kawa-openapi-card__summary { color: var(--kawa-c-text-2); margin-bottom: 0.375rem; }
|
|
487
640
|
.kawa-openapi-card__summary :where(p) { margin: 0; }
|
|
488
641
|
|
|
@@ -496,7 +649,7 @@
|
|
|
496
649
|
|
|
497
650
|
.kawa-openapi-card__name { font-family: var(--kawa-font-mono); }
|
|
498
651
|
.kawa-openapi-card__note { color: var(--kawa-c-text-2); text-align: end; }
|
|
499
|
-
.kawa-openapi-card__more { display: inline-block; margin-top: 0.375rem; font-size: 0.8125rem; }
|
|
652
|
+
.kawa-openapi-card__more { display: inline-block; margin-top: 0.375rem; font-size: 0.8125rem; color: var(--kawa-c-brand); }
|
|
500
653
|
|
|
501
654
|
.kawa-openapi-ref {
|
|
502
655
|
position: relative;
|
|
@@ -545,6 +698,8 @@
|
|
|
545
698
|
}
|
|
546
699
|
|
|
547
700
|
@media (prefers-reduced-motion: reduce) {
|
|
548
|
-
.kawa-openapi-journey__dot
|
|
701
|
+
.kawa-openapi-journey__dot,
|
|
702
|
+
.kawa-openapi-journey__value { transition: none; }
|
|
703
|
+
.kawa-openapi-journey__value.is-landed { animation: none; }
|
|
549
704
|
}
|
|
550
705
|
}
|
package/src/data/components.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ValidationMessagesData } from '../components/validate'
|
|
1
|
+
import type { Rule, ValidationMessagesData } from '../components/validate'
|
|
2
2
|
import type { ResolvedOpenApiOptions } from '../options'
|
|
3
3
|
import type { SchemaTable } from '../read/example'
|
|
4
4
|
import type { OpenApiLabels } from '../render/labels'
|
|
@@ -6,10 +6,9 @@ import type { OpenApiLinks } from '../render/routes'
|
|
|
6
6
|
import type { LoadedApi } from '../service'
|
|
7
7
|
import type { OpenApiAction, OpenApiOperation, OpenApiParameter, OpenApiResponse, OpenApiWorkflow, WorkflowValue } from '../types'
|
|
8
8
|
import type { BodyContext, BodyData, FieldRow } from './body'
|
|
9
|
-
import type { PayloadData } from './payload'
|
|
10
9
|
import type { RequestExample } from './samples'
|
|
11
10
|
import { EXPRESSION_KEY, isExpression, outputValue, referencesOf } from '../read/arazzo'
|
|
12
|
-
import { isObject } from '../read/document'
|
|
11
|
+
import { isObject, readPointer } from '../read/document'
|
|
13
12
|
import { exampleOf, resolveNode } from '../read/example'
|
|
14
13
|
import { emptyNode } from '../read/schema'
|
|
15
14
|
import { operationKey } from '../snapshot/snapshot'
|
|
@@ -401,33 +400,36 @@ export interface JourneyStepData {
|
|
|
401
400
|
title: string
|
|
402
401
|
href: string
|
|
403
402
|
webhook: boolean
|
|
404
|
-
|
|
405
|
-
|
|
403
|
+
/** Whether the operation needs a token, for the exported code. */
|
|
404
|
+
auth: boolean
|
|
405
|
+
parameters: { name: string, in: string, value: WorkflowValue }[]
|
|
406
|
+
/** The request body template, with runtime expressions under `$kawa`. */
|
|
407
|
+
body?: unknown
|
|
408
|
+
/** Mock validation of the request body. */
|
|
409
|
+
rule?: Rule
|
|
406
410
|
status: string
|
|
407
|
-
response
|
|
408
|
-
|
|
411
|
+
/** The example of the success response. */
|
|
412
|
+
response?: unknown
|
|
413
|
+
/** Values this step's response gives to later steps. */
|
|
414
|
+
outputs: { key: string, name: string, pointer: string }[]
|
|
415
|
+
/** Slot keys the step reads from earlier steps. */
|
|
416
|
+
needs: string[]
|
|
417
|
+
/** The 4xx responses of the operation with their examples, for requests that cannot work. */
|
|
418
|
+
errors: { status: string, body?: unknown }[]
|
|
409
419
|
}
|
|
410
420
|
|
|
411
421
|
export interface JourneyData {
|
|
412
422
|
id: string
|
|
423
|
+
base: string
|
|
424
|
+
inputs: { name: string, description: string, value: unknown }[]
|
|
425
|
+
/** Slot key → colour index, for every step output. */
|
|
426
|
+
marks: Record<string, number>
|
|
413
427
|
steps: JourneyStepData[]
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
get: string
|
|
417
|
-
receive: string
|
|
418
|
-
respond: string
|
|
419
|
-
run: string
|
|
420
|
-
runAgain: string
|
|
421
|
-
pending: string
|
|
422
|
-
running: string
|
|
423
|
-
done: string
|
|
424
|
-
parameters: string
|
|
425
|
-
}
|
|
428
|
+
messages: ValidationMessagesData
|
|
429
|
+
text: OpenApiLabels['journey']
|
|
426
430
|
markdown: string
|
|
427
431
|
}
|
|
428
432
|
|
|
429
|
-
/** Colour index of `$inputs` values. */
|
|
430
|
-
export const INPUT_MARK = -1
|
|
431
433
|
const MARK_COLOURS = 5
|
|
432
434
|
|
|
433
435
|
export function buildJourneyData(workflow: OpenApiWorkflow, context: DataContext): JourneyData {
|
|
@@ -435,28 +437,35 @@ export function buildJourneyData(workflow: OpenApiWorkflow, context: DataContext
|
|
|
435
437
|
const { labels, schemas } = context
|
|
436
438
|
const operations = new Map(model.operations.map(operation => [operation.id, operation]))
|
|
437
439
|
const stepIndex = new Map(workflow.steps.map((step, index) => [step.id, index]))
|
|
438
|
-
const marks
|
|
440
|
+
const marks: Record<string, number> = {}
|
|
439
441
|
for (const step of workflow.steps) {
|
|
440
|
-
for (const
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
marks.set(key, marks.size % MARK_COLOURS)
|
|
442
|
+
for (const output of step.outputs) {
|
|
443
|
+
if (output.pointer !== undefined) {
|
|
444
|
+
marks[`${step.id}.${output.name}`] = Object.keys(marks).length % MARK_COLOURS
|
|
444
445
|
}
|
|
445
446
|
}
|
|
446
447
|
}
|
|
447
|
-
const responses = new Map<string, unknown>()
|
|
448
|
-
const responseOf = (stepId: string): unknown => responses.get(stepId)
|
|
449
448
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
449
|
+
// Inputs start from their schema's default or example, else from the example of the request field they fill.
|
|
450
|
+
const inputValues = new Map<string, unknown>(workflow.inputs.filter(input => input.example !== undefined).map(input => [input.name, input.example]))
|
|
451
|
+
for (const step of workflow.steps) {
|
|
452
|
+
const operation = operations.get(step.operation)!
|
|
453
|
+
for (const parameter of step.parameters) {
|
|
454
|
+
if (parameter.value.kind === 'input' && !inputValues.has(parameter.value.name)) {
|
|
455
|
+
const example = operation.parameters.find(item => item.name === parameter.name)?.example
|
|
456
|
+
if (example !== undefined) {
|
|
457
|
+
inputValues.set(parameter.value.name, example)
|
|
458
|
+
}
|
|
459
|
+
}
|
|
453
460
|
}
|
|
454
|
-
|
|
455
|
-
|
|
461
|
+
for (const [pointer, name] of inputPointers(step.payload, '')) {
|
|
462
|
+
if (!inputValues.has(name)) {
|
|
463
|
+
const example = readPointer(operation.requestBody?.example, pointer)
|
|
464
|
+
if (example !== undefined) {
|
|
465
|
+
inputValues.set(name, example)
|
|
466
|
+
}
|
|
467
|
+
}
|
|
456
468
|
}
|
|
457
|
-
const producer = workflow.steps[stepIndex.get(value.step)!]
|
|
458
|
-
const found = producer ? outputValue(producer, value.output, responseOf(producer.id)) : undefined
|
|
459
|
-
return { value: found ?? `$steps.${value.step}.outputs.${value.output}`, mark: marks.get(`${value.step}.${value.output}`) }
|
|
460
469
|
}
|
|
461
470
|
|
|
462
471
|
const steps = workflow.steps.map((step, index): JourneyStepData => {
|
|
@@ -464,41 +473,8 @@ export function buildJourneyData(workflow: OpenApiWorkflow, context: DataContext
|
|
|
464
473
|
const response = operation.responses.find(item => item.status === step.status)
|
|
465
474
|
?? operation.responses.find(item => item.status.startsWith('2'))
|
|
466
475
|
?? operation.responses[0]
|
|
467
|
-
const
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
const parameters = step.parameters.map((parameter) => {
|
|
471
|
-
const resolved = resolve(parameter.value)
|
|
472
|
-
return {
|
|
473
|
-
name: parameter.name,
|
|
474
|
-
in: parameter.in ?? operation.parameters.find(item => item.name === parameter.name)?.in ?? 'query',
|
|
475
|
-
value: typeof resolved.value === 'string' ? resolved.value : JSON.stringify(resolved.value),
|
|
476
|
-
...(resolved.mark !== undefined ? { mark: resolved.mark } : {}),
|
|
477
|
-
}
|
|
478
|
-
})
|
|
479
|
-
|
|
480
|
-
let request: PayloadData | undefined
|
|
481
|
-
if (step.payload !== undefined || operation.requestBody) {
|
|
482
|
-
const requestMarks = new Map<string, number>()
|
|
483
|
-
const payload = step.payload === undefined
|
|
484
|
-
? operation.requestBody?.example
|
|
485
|
-
: substitute(step.payload, '', requestMarks, resolve)
|
|
486
|
-
request = buildPayload(payload, operation.requestBody?.schema, { schemas, direction: 'request', labels, modelHref: () => undefined, marks: requestMarks, bare: true })
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
const responseMarks = new Map<string, number>()
|
|
490
|
-
for (const output of step.outputs) {
|
|
491
|
-
const mark = marks.get(`${step.id}.${output.name}`)
|
|
492
|
-
if (mark !== undefined && output.pointer !== undefined) {
|
|
493
|
-
responseMarks.set(output.pointer, mark)
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
const flows = referencesOf(step)
|
|
497
|
-
.filter((reference, position, all) => all.findIndex(item => item.step === reference.step && item.output === reference.output) === position)
|
|
498
|
-
.map(reference => ({ mark: marks.get(`${reference.step}.${reference.output}`)!, text: labels.fromStep(stepIndex.get(reference.step)! + 1, reference.output) }))
|
|
499
|
-
const inputs = inputsOf(step)
|
|
500
|
-
flows.push(...inputs.map(name => ({ mark: INPUT_MARK, text: labels.fromInput(name) })))
|
|
501
|
-
|
|
476
|
+
const body = step.payload === undefined ? operation.requestBody?.example : step.payload
|
|
477
|
+
const needs = [...new Set(referencesOf(step).map(reference => `${reference.step}.${reference.output}`))]
|
|
502
478
|
return {
|
|
503
479
|
index,
|
|
504
480
|
id: step.id,
|
|
@@ -508,40 +484,91 @@ export function buildJourneyData(workflow: OpenApiWorkflow, context: DataContext
|
|
|
508
484
|
title: operation.summary || operation.id,
|
|
509
485
|
href: context.links.operation(operation.id) ?? '',
|
|
510
486
|
webhook: operation.webhook,
|
|
511
|
-
|
|
512
|
-
|
|
487
|
+
auth: operation.security.length > 0,
|
|
488
|
+
parameters: step.parameters.map(parameter => ({
|
|
489
|
+
name: parameter.name,
|
|
490
|
+
in: parameter.in ?? operation.parameters.find(item => item.name === parameter.name)?.in ?? 'query',
|
|
491
|
+
value: parameter.value,
|
|
492
|
+
})),
|
|
493
|
+
...(body !== undefined ? { body } : {}),
|
|
494
|
+
...(operation.requestBody && body !== undefined ? { rule: ruleOf(operation.requestBody.schema, schemas, 'request') } : {}),
|
|
513
495
|
status: response?.status ?? '',
|
|
514
|
-
...(
|
|
515
|
-
|
|
496
|
+
...(response?.body?.example !== undefined ? { response: response.body.example } : {}),
|
|
497
|
+
outputs: step.outputs.filter(output => output.pointer !== undefined).map(output => ({ key: `${step.id}.${output.name}`, name: output.name, pointer: output.pointer! })),
|
|
498
|
+
needs,
|
|
499
|
+
errors: operation.responses.filter(item => item.status.startsWith('4')).map(item => ({ status: item.status, ...(item.body?.example !== undefined ? { body: item.body.example } : {}) })),
|
|
516
500
|
}
|
|
517
501
|
})
|
|
518
502
|
|
|
519
|
-
const markdown = steps.map(step => [
|
|
520
|
-
`### ${step.index + 1}. ${step.title}`,
|
|
521
|
-
`\`${step.method} ${step.path}\` — [${labels.viewOperation}](${context.pageLinks.operation(workflow.steps[step.index].operation)})`,
|
|
522
|
-
step.flows.map(flow => `- ${flow.text}`).join('\n'),
|
|
523
|
-
step.parameters.length ? `${labels.parameters}: ${step.parameters.map(parameter => `\`${parameter.name}=${parameter.value}\``).join(', ')}` : '',
|
|
524
|
-
step.request ? `${step.webhook ? labels.receive : labels.sendLabel}:\n\n${payloadMarkdown(step.request)}` : '',
|
|
525
|
-
step.response ? `${step.webhook ? labels.respond : labels.getLabel} (${step.status}):\n\n${payloadMarkdown(step.response)}` : '',
|
|
526
|
-
].filter(Boolean).join('\n\n')).join('\n\n')
|
|
527
|
-
|
|
528
503
|
return {
|
|
529
504
|
id: workflow.id,
|
|
505
|
+
base: model.servers[0]?.url ?? '',
|
|
506
|
+
inputs: workflow.inputs.map(input => ({ name: input.name, description: input.description, value: inputValues.get(input.name) ?? '' })),
|
|
507
|
+
marks,
|
|
530
508
|
steps,
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
509
|
+
messages: labels.validation,
|
|
510
|
+
text: labels.journey,
|
|
511
|
+
markdown: journeyMarkdown(workflow, steps, stepIndex, context),
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/** The steps as Markdown, with the example requests and responses, for llms and the page `.md`. */
|
|
516
|
+
function journeyMarkdown(workflow: OpenApiWorkflow, steps: JourneyStepData[], stepIndex: Map<string, number>, context: DataContext): string {
|
|
517
|
+
const { labels, schemas } = context
|
|
518
|
+
const operations = new Map(context.api.model.operations.map(operation => [operation.id, operation]))
|
|
519
|
+
const examples = new Map<string, unknown>()
|
|
520
|
+
const resolve = (value: WorkflowValue): unknown => {
|
|
521
|
+
if (value.kind === 'literal') {
|
|
522
|
+
return value.value
|
|
523
|
+
}
|
|
524
|
+
if (value.kind === 'input') {
|
|
525
|
+
return `$inputs.${value.name}`
|
|
526
|
+
}
|
|
527
|
+
const producer = workflow.steps[stepIndex.get(value.step)!]
|
|
528
|
+
return (producer ? outputValue(producer, value.output, examples.get(producer.id)) : undefined) ?? `$steps.${value.step}.outputs.${value.output}`
|
|
544
529
|
}
|
|
530
|
+
return steps.map((step) => {
|
|
531
|
+
const source = workflow.steps[step.index]
|
|
532
|
+
const operation = operations.get(source.operation)!
|
|
533
|
+
examples.set(step.id, step.response)
|
|
534
|
+
const flows = [
|
|
535
|
+
...step.needs.map((key) => {
|
|
536
|
+
const [from, output] = key.split('.') as [string, string]
|
|
537
|
+
return labels.fromStep(stepIndex.get(from)! + 1, output)
|
|
538
|
+
}),
|
|
539
|
+
...inputsOf(source).map(name => labels.fromInput(name)),
|
|
540
|
+
]
|
|
541
|
+
const request = step.body === undefined ? undefined : buildPayload(substitute(step.body, resolve), operation.requestBody?.schema, { schemas, direction: 'request', labels, modelHref: () => undefined, bare: true })
|
|
542
|
+
const response = step.response === undefined ? undefined : buildPayload(step.response, operation.responses.find(item => item.status === step.status)?.body?.schema, { schemas, direction: 'response', labels, modelHref: () => undefined, bare: true })
|
|
543
|
+
return [
|
|
544
|
+
`### ${step.index + 1}. ${step.title}`,
|
|
545
|
+
`\`${step.method} ${step.path}\` — [${labels.viewOperation}](${context.pageLinks.operation(source.operation)})`,
|
|
546
|
+
source.description ? prose(source.description) : '',
|
|
547
|
+
flows.map(flow => `- ${flow}`).join('\n'),
|
|
548
|
+
step.parameters.length ? `**${labels.parameters}** ${step.parameters.map(parameter => `\`${parameter.name}=${String(resolve(parameter.value))}\``).join(', ')}` : '',
|
|
549
|
+
request ? `**${step.webhook ? labels.receive : labels.sendLabel}**\n\n${payloadMarkdown(request)}` : '',
|
|
550
|
+
response ? `**${step.webhook ? labels.respond : labels.getLabel} · ${step.status}**\n\n${payloadMarkdown(response)}` : '',
|
|
551
|
+
].filter(Boolean).join('\n\n')
|
|
552
|
+
}).join('\n\n')
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
function prose(markdown: string): string {
|
|
556
|
+
return markdown.trim()
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/** JSON pointers of a payload template that hold `$inputs` values, with the input names. */
|
|
560
|
+
function inputPointers(value: unknown, pointer: string): [string, string][] {
|
|
561
|
+
if (isExpression(value)) {
|
|
562
|
+
const expression = value[EXPRESSION_KEY]
|
|
563
|
+
return expression.kind === 'input' ? [[pointer, expression.name]] : []
|
|
564
|
+
}
|
|
565
|
+
if (Array.isArray(value)) {
|
|
566
|
+
return value.flatMap((item, index) => inputPointers(item, `${pointer}/${index}`))
|
|
567
|
+
}
|
|
568
|
+
if (isObject(value)) {
|
|
569
|
+
return Object.entries(value).flatMap(([key, item]) => inputPointers(item, `${pointer}/${key.replaceAll('~', '~0').replaceAll('/', '~1')}`))
|
|
570
|
+
}
|
|
571
|
+
return []
|
|
545
572
|
}
|
|
546
573
|
|
|
547
574
|
/** Names of the workflow inputs a step reads, in order. */
|
|
@@ -566,25 +593,16 @@ function inputsOf(step: OpenApiWorkflow['steps'][number]): string[] {
|
|
|
566
593
|
return [...names]
|
|
567
594
|
}
|
|
568
595
|
|
|
569
|
-
/**
|
|
570
|
-
function substitute(
|
|
571
|
-
value: unknown,
|
|
572
|
-
pointer: string,
|
|
573
|
-
marks: Map<string, number>,
|
|
574
|
-
resolve: (value: WorkflowValue) => { value: unknown, mark?: number },
|
|
575
|
-
): unknown {
|
|
596
|
+
/** A payload template with every expression replaced by an example value. */
|
|
597
|
+
function substitute(value: unknown, resolve: (value: WorkflowValue) => unknown): unknown {
|
|
576
598
|
if (isExpression(value)) {
|
|
577
|
-
|
|
578
|
-
if (resolved.mark !== undefined) {
|
|
579
|
-
marks.set(pointer, resolved.mark)
|
|
580
|
-
}
|
|
581
|
-
return resolved.value
|
|
599
|
+
return resolve(value[EXPRESSION_KEY])
|
|
582
600
|
}
|
|
583
601
|
if (Array.isArray(value)) {
|
|
584
|
-
return value.map(
|
|
602
|
+
return value.map(item => substitute(item, resolve))
|
|
585
603
|
}
|
|
586
604
|
if (isObject(value)) {
|
|
587
|
-
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, substitute(item,
|
|
605
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, substitute(item, resolve)]))
|
|
588
606
|
}
|
|
589
607
|
return value
|
|
590
608
|
}
|