@t0.labs/daxta 1.1.3 → 1.1.5
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/README.md +123 -55
- package/assets/example.html +584 -93
- package/assets/viewer.html +583 -92
- package/dist/build/build-spec.js +165 -15
- package/dist/catalog/index.d.ts +1 -0
- package/dist/catalog/index.js +23 -10
- package/dist/catalog/it-case.js +2 -0
- package/dist/catalog/test-title.js +7 -5
- package/dist/cli/install.js +18 -16
- package/dist/cli/titles.js +7 -5
- package/dist/cli/tree.js +14 -4
- package/dist/cli/uninstall.js +2 -1
- package/dist/config.d.ts +24 -1
- package/dist/config.js +69 -2
- package/dist/fields/dto-fields.js +42 -6
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -1
- package/dist/jest/global-setup.js +1 -0
- package/dist/jest/global-teardown.js +4 -0
- package/dist/jest/reporter.d.ts +2 -0
- package/dist/jest/reporter.js +23 -2
- package/dist/recorder/index.d.ts +6 -0
- package/dist/recorder/index.js +36 -3
- package/dist/serve/index.d.ts +1 -1
- package/dist/serve/index.js +2 -1
- package/dist/serve/middleware.d.ts +3 -4
- package/dist/serve/middleware.js +14 -13
- package/dist/serve/paths.d.ts +2 -0
- package/dist/serve/paths.js +5 -0
- package/dist/serve/viewer-store.d.ts +5 -2
- package/dist/serve/viewer-store.js +9 -4
- package/package.json +2 -2
package/assets/viewer.html
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<title>API Documentation</title>
|
|
7
|
-
<link rel="icon" id="favicon" href="
|
|
8
|
-
<link rel="apple-touch-icon" href="
|
|
7
|
+
<link rel="icon" id="favicon" href="__FAVICON_LIGHT_DATA_URI__" />
|
|
8
|
+
<link rel="apple-touch-icon" href="__FAVICON_LIGHT_DATA_URI__" />
|
|
9
9
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
10
10
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
11
11
|
<link href="https://fonts.googleapis.com/css2?family=Geist+Mono:wght@400;500;600&family=Geist:wght@400;500;600&display=swap" rel="stylesheet" />
|
|
@@ -111,6 +111,10 @@
|
|
|
111
111
|
max-width: 100%;
|
|
112
112
|
}
|
|
113
113
|
.ep-name {
|
|
114
|
+
display: flex;
|
|
115
|
+
align-items: baseline;
|
|
116
|
+
gap: 8px;
|
|
117
|
+
min-width: 0;
|
|
114
118
|
font-size: 14px;
|
|
115
119
|
font-weight: 600;
|
|
116
120
|
letter-spacing: -0.02em;
|
|
@@ -119,6 +123,18 @@
|
|
|
119
123
|
text-overflow: ellipsis;
|
|
120
124
|
color: var(--obsidian);
|
|
121
125
|
}
|
|
126
|
+
.ep-status {
|
|
127
|
+
flex: none;
|
|
128
|
+
font: 600 14px/1.4 var(--mono);
|
|
129
|
+
letter-spacing: -0.02em;
|
|
130
|
+
color: var(--ok);
|
|
131
|
+
}
|
|
132
|
+
.ep-status.err { color: var(--err); }
|
|
133
|
+
.ep-label {
|
|
134
|
+
min-width: 0;
|
|
135
|
+
overflow: hidden;
|
|
136
|
+
text-overflow: ellipsis;
|
|
137
|
+
}
|
|
122
138
|
.prefix-bar {
|
|
123
139
|
display: flex;
|
|
124
140
|
flex-wrap: wrap;
|
|
@@ -519,8 +535,7 @@
|
|
|
519
535
|
margin-top: 8px;
|
|
520
536
|
}
|
|
521
537
|
.env-kv.base-url .env-cell[data-field="key"] {
|
|
522
|
-
|
|
523
|
-
pointer-events: none;
|
|
538
|
+
font-weight: 600;
|
|
524
539
|
}
|
|
525
540
|
.env-add {
|
|
526
541
|
height: 32px;
|
|
@@ -764,33 +779,17 @@
|
|
|
764
779
|
margin: 0 4px 6px 18px;
|
|
765
780
|
}
|
|
766
781
|
.nav-op.examples-open > .nav-examples { display: flex; }
|
|
767
|
-
.nav-ex-group { display: flex; flex-direction: column; gap:
|
|
768
|
-
.nav-ex-items {
|
|
769
|
-
display: flex;
|
|
770
|
-
flex-direction: column;
|
|
771
|
-
gap: 1px;
|
|
772
|
-
margin-left: 4px;
|
|
773
|
-
padding-left: 0;
|
|
774
|
-
border-left: 1px solid var(--hairline);
|
|
775
|
-
}
|
|
776
|
-
.nav-ex-group.ok > .nav-ex-items { border-left-color: color-mix(in srgb, var(--ok) 40%, var(--hairline)); }
|
|
777
|
-
.nav-ex-group.warn > .nav-ex-items { border-left-color: color-mix(in srgb, var(--warn) 40%, var(--hairline)); }
|
|
778
|
-
.nav-ex-group.omit > .nav-ex-items { border-left-color: color-mix(in srgb, var(--accent) 40%, var(--hairline)); }
|
|
779
|
-
.nav-ex-group.err > .nav-ex-items { border-left-color: color-mix(in srgb, var(--err) 40%, var(--hairline)); }
|
|
782
|
+
.nav-ex-group { display: flex; flex-direction: column; gap: 1px; }
|
|
780
783
|
.nav-ex-group-label {
|
|
781
784
|
display: flex;
|
|
782
785
|
align-items: center;
|
|
783
786
|
justify-content: space-between;
|
|
784
787
|
gap: 8px;
|
|
785
|
-
padding: 6px
|
|
788
|
+
padding: 6px 8px 2px;
|
|
786
789
|
font: 600 10px/1.2 var(--sans);
|
|
787
|
-
letter-spacing: 0.
|
|
788
|
-
color: var(--
|
|
790
|
+
letter-spacing: 0.02em;
|
|
791
|
+
color: var(--stone);
|
|
789
792
|
}
|
|
790
|
-
.nav-ex-group-label.ok { color: var(--ok); }
|
|
791
|
-
.nav-ex-group-label.warn { color: var(--warn); }
|
|
792
|
-
.nav-ex-group-label.omit { color: var(--accent); }
|
|
793
|
-
.nav-ex-group-label.err { color: var(--err); }
|
|
794
793
|
.nav-ex-count {
|
|
795
794
|
font: 600 10px/1.4 var(--mono);
|
|
796
795
|
color: inherit;
|
|
@@ -842,12 +841,18 @@
|
|
|
842
841
|
inset: 0;
|
|
843
842
|
background: rgba(232, 232, 232, 0.72);
|
|
844
843
|
backdrop-filter: blur(2px);
|
|
845
|
-
z-index:
|
|
844
|
+
z-index: 400;
|
|
846
845
|
align-items: center;
|
|
847
846
|
justify-content: center;
|
|
848
847
|
padding: 24px;
|
|
849
848
|
}
|
|
850
849
|
body.exporting .export-backdrop { display: flex; }
|
|
850
|
+
body.exporting { overflow: hidden; }
|
|
851
|
+
/** The backdrop covers the viewport, but focus and scroll still reach the page behind it. */
|
|
852
|
+
body.exporting > *:not(.export-backdrop) {
|
|
853
|
+
pointer-events: none;
|
|
854
|
+
user-select: none;
|
|
855
|
+
}
|
|
851
856
|
.export-modal {
|
|
852
857
|
width: min(560px, 100%);
|
|
853
858
|
max-height: min(720px, calc(100vh - 48px));
|
|
@@ -902,28 +907,160 @@
|
|
|
902
907
|
.export-toolbar {
|
|
903
908
|
display: flex;
|
|
904
909
|
flex-wrap: wrap;
|
|
905
|
-
|
|
910
|
+
align-items: center;
|
|
911
|
+
gap: 6px;
|
|
906
912
|
padding: 10px 20px;
|
|
907
913
|
border-bottom: 1px solid var(--hairline);
|
|
908
914
|
}
|
|
915
|
+
.export-tool-label {
|
|
916
|
+
font: 600 10px/1.6 var(--sans);
|
|
917
|
+
letter-spacing: 0.08em;
|
|
918
|
+
text-transform: uppercase;
|
|
919
|
+
color: var(--stone);
|
|
920
|
+
margin-right: 2px;
|
|
921
|
+
}
|
|
922
|
+
.export-tool-sep {
|
|
923
|
+
width: 1px;
|
|
924
|
+
height: 16px;
|
|
925
|
+
margin: 0 4px;
|
|
926
|
+
background: var(--hairline);
|
|
927
|
+
}
|
|
928
|
+
.export-tool-sep[hidden] { display: none; }
|
|
929
|
+
.export-tool-chips {
|
|
930
|
+
display: inline-flex;
|
|
931
|
+
flex-wrap: wrap;
|
|
932
|
+
gap: 6px;
|
|
933
|
+
min-width: 0;
|
|
934
|
+
}
|
|
935
|
+
.section-chip {
|
|
936
|
+
display: inline-flex;
|
|
937
|
+
align-items: center;
|
|
938
|
+
gap: 6px;
|
|
939
|
+
padding: 3px 9px;
|
|
940
|
+
border: 1px solid var(--hairline);
|
|
941
|
+
border-radius: 999px;
|
|
942
|
+
background: var(--paper);
|
|
943
|
+
color: var(--charcoal);
|
|
944
|
+
font: 500 12px/1.5 var(--sans);
|
|
945
|
+
cursor: pointer;
|
|
946
|
+
transition: border-color 0.12s ease, background 0.12s ease;
|
|
947
|
+
}
|
|
948
|
+
.section-chip .dot {
|
|
949
|
+
width: 6px;
|
|
950
|
+
height: 6px;
|
|
951
|
+
border-radius: 50%;
|
|
952
|
+
background: currentColor;
|
|
953
|
+
flex: none;
|
|
954
|
+
}
|
|
955
|
+
.section-chip.ok .dot { background: var(--ok); }
|
|
956
|
+
.section-chip.warn .dot { background: var(--warn); }
|
|
957
|
+
.section-chip.omit .dot { background: var(--accent); }
|
|
958
|
+
.section-chip.err .dot { background: var(--err); }
|
|
959
|
+
.section-chip.plain { color: var(--obsidian); }
|
|
960
|
+
.section-chip:hover { background: var(--inset); }
|
|
961
|
+
.section-chip .dot { opacity: 0.35; }
|
|
962
|
+
.section-chip.on .dot,
|
|
963
|
+
.section-chip.part .dot { opacity: 1; }
|
|
964
|
+
.section-chip.part .dot {
|
|
965
|
+
background: none;
|
|
966
|
+
border: 1.5px solid currentColor;
|
|
967
|
+
}
|
|
968
|
+
.section-chip.on { color: var(--obsidian); }
|
|
969
|
+
.section-chip.ok.on { border-color: color-mix(in srgb, var(--ok) 55%, var(--hairline)); background: color-mix(in srgb, var(--ok) 10%, var(--paper)); }
|
|
970
|
+
.section-chip.warn.on { border-color: color-mix(in srgb, var(--warn) 55%, var(--hairline)); background: color-mix(in srgb, var(--warn) 10%, var(--paper)); }
|
|
971
|
+
.section-chip.omit.on { border-color: color-mix(in srgb, var(--accent) 55%, var(--hairline)); background: color-mix(in srgb, var(--accent) 10%, var(--paper)); }
|
|
972
|
+
.section-chip.err.on { border-color: color-mix(in srgb, var(--err) 55%, var(--hairline)); background: color-mix(in srgb, var(--err) 10%, var(--paper)); }
|
|
973
|
+
.section-chip.ok.part .dot { color: var(--ok); }
|
|
974
|
+
.section-chip.warn.part .dot { color: var(--warn); }
|
|
975
|
+
.section-chip.omit.part .dot { color: var(--accent); }
|
|
976
|
+
.section-chip.err.part .dot { color: var(--err); }
|
|
909
977
|
.export-body {
|
|
910
978
|
flex: 1;
|
|
911
979
|
overflow: auto;
|
|
912
980
|
padding: 8px 12px 16px;
|
|
913
981
|
}
|
|
982
|
+
.export-folder { margin: 0; }
|
|
983
|
+
.export-folder.collapsed > .export-folder-children { display: none; }
|
|
984
|
+
.export-folder-head {
|
|
985
|
+
display: flex;
|
|
986
|
+
align-items: center;
|
|
987
|
+
gap: 8px;
|
|
988
|
+
width: 100%;
|
|
989
|
+
padding: 6px 4px;
|
|
990
|
+
border: 0;
|
|
991
|
+
background: none;
|
|
992
|
+
text-align: left;
|
|
993
|
+
font: 500 12px/1.4 var(--sans);
|
|
994
|
+
color: var(--charcoal);
|
|
995
|
+
cursor: pointer;
|
|
996
|
+
}
|
|
997
|
+
.export-folder-head:hover { background: var(--inset); }
|
|
998
|
+
.export-folder-head .chev {
|
|
999
|
+
width: 6px;
|
|
1000
|
+
height: 6px;
|
|
1001
|
+
flex: none;
|
|
1002
|
+
border-right: 1.5px solid currentColor;
|
|
1003
|
+
border-bottom: 1.5px solid currentColor;
|
|
1004
|
+
transform: rotate(45deg);
|
|
1005
|
+
margin-top: -3px;
|
|
1006
|
+
opacity: 0.7;
|
|
1007
|
+
transition: transform 0.15s ease;
|
|
1008
|
+
}
|
|
1009
|
+
.export-folder.collapsed > .export-folder-head .chev {
|
|
1010
|
+
transform: rotate(-45deg);
|
|
1011
|
+
margin-top: -2px;
|
|
1012
|
+
}
|
|
1013
|
+
.export-folder-name {
|
|
1014
|
+
overflow: hidden;
|
|
1015
|
+
text-overflow: ellipsis;
|
|
1016
|
+
white-space: nowrap;
|
|
1017
|
+
}
|
|
1018
|
+
.export-folder-children {
|
|
1019
|
+
margin-left: 7px;
|
|
1020
|
+
padding-left: 8px;
|
|
1021
|
+
border-left: 1px solid var(--hairline);
|
|
1022
|
+
}
|
|
914
1023
|
.export-op {
|
|
915
|
-
padding:
|
|
916
|
-
border-bottom: 1px solid var(--hairline);
|
|
1024
|
+
padding: 0;
|
|
917
1025
|
}
|
|
918
1026
|
.export-op:last-child { border-bottom: 0; }
|
|
1027
|
+
.export-op.collapsed > .export-op-groups { display: none; }
|
|
919
1028
|
.export-op-title {
|
|
920
1029
|
display: flex;
|
|
921
1030
|
align-items: center;
|
|
922
1031
|
gap: 8px;
|
|
923
|
-
|
|
1032
|
+
width: 100%;
|
|
1033
|
+
padding: 6px 4px;
|
|
1034
|
+
border: 0;
|
|
1035
|
+
background: none;
|
|
1036
|
+
text-align: left;
|
|
924
1037
|
font-size: 12px;
|
|
925
1038
|
color: var(--obsidian);
|
|
1039
|
+
cursor: pointer;
|
|
926
1040
|
}
|
|
1041
|
+
.export-op-title:hover { background: var(--inset); }
|
|
1042
|
+
.export-op-title .chev {
|
|
1043
|
+
width: 6px;
|
|
1044
|
+
height: 6px;
|
|
1045
|
+
flex: none;
|
|
1046
|
+
border-right: 1.5px solid currentColor;
|
|
1047
|
+
border-bottom: 1.5px solid currentColor;
|
|
1048
|
+
transform: rotate(45deg);
|
|
1049
|
+
margin-top: -3px;
|
|
1050
|
+
opacity: 0.7;
|
|
1051
|
+
transition: transform 0.15s ease;
|
|
1052
|
+
}
|
|
1053
|
+
.export-op.collapsed > .export-op-title .chev {
|
|
1054
|
+
transform: rotate(-45deg);
|
|
1055
|
+
margin-top: -2px;
|
|
1056
|
+
}
|
|
1057
|
+
.export-op-count {
|
|
1058
|
+
margin-left: auto;
|
|
1059
|
+
flex: none;
|
|
1060
|
+
font: 600 10px/1.4 var(--mono);
|
|
1061
|
+
color: var(--stone);
|
|
1062
|
+
}
|
|
1063
|
+
.export-op-groups { padding: 2px 0 8px; }
|
|
927
1064
|
.export-op-title .path {
|
|
928
1065
|
font-family: var(--mono);
|
|
929
1066
|
font-size: 11px;
|
|
@@ -932,6 +1069,58 @@
|
|
|
932
1069
|
text-overflow: ellipsis;
|
|
933
1070
|
white-space: nowrap;
|
|
934
1071
|
}
|
|
1072
|
+
.export-group { margin: 0 0 6px; }
|
|
1073
|
+
.export-group:last-child { margin-bottom: 0; }
|
|
1074
|
+
.export-group-head {
|
|
1075
|
+
display: flex;
|
|
1076
|
+
align-items: center;
|
|
1077
|
+
gap: 8px;
|
|
1078
|
+
padding: 4px 4px 4px 2px;
|
|
1079
|
+
font: 600 10px/1.2 var(--sans);
|
|
1080
|
+
letter-spacing: 0.04em;
|
|
1081
|
+
cursor: pointer;
|
|
1082
|
+
color: var(--charcoal);
|
|
1083
|
+
}
|
|
1084
|
+
.export-group-head.ok { color: var(--ok); }
|
|
1085
|
+
.export-group-head.warn { color: var(--warn); }
|
|
1086
|
+
.export-group-head.omit { color: var(--accent); }
|
|
1087
|
+
.export-group-head.err { color: var(--err); }
|
|
1088
|
+
.export-group-count {
|
|
1089
|
+
font: 600 10px/1.4 var(--mono);
|
|
1090
|
+
color: var(--stone);
|
|
1091
|
+
}
|
|
1092
|
+
.export-group-items {
|
|
1093
|
+
margin-left: 8px;
|
|
1094
|
+
padding-left: 8px;
|
|
1095
|
+
border-left: 1px solid var(--hairline);
|
|
1096
|
+
}
|
|
1097
|
+
.export-group.collapsed > .export-group-items { display: none; }
|
|
1098
|
+
.export-group-toggle {
|
|
1099
|
+
display: inline-flex;
|
|
1100
|
+
align-items: center;
|
|
1101
|
+
justify-content: center;
|
|
1102
|
+
width: 14px;
|
|
1103
|
+
height: 14px;
|
|
1104
|
+
padding: 0;
|
|
1105
|
+
border: 0;
|
|
1106
|
+
background: none;
|
|
1107
|
+
color: inherit;
|
|
1108
|
+
cursor: pointer;
|
|
1109
|
+
}
|
|
1110
|
+
.export-group-toggle .chev {
|
|
1111
|
+
width: 6px;
|
|
1112
|
+
height: 6px;
|
|
1113
|
+
border-right: 1.5px solid currentColor;
|
|
1114
|
+
border-bottom: 1.5px solid currentColor;
|
|
1115
|
+
transform: rotate(45deg);
|
|
1116
|
+
margin-top: -3px;
|
|
1117
|
+
opacity: 0.7;
|
|
1118
|
+
transition: transform 0.15s ease;
|
|
1119
|
+
}
|
|
1120
|
+
.export-group.collapsed .export-group-toggle .chev {
|
|
1121
|
+
transform: rotate(-45deg);
|
|
1122
|
+
margin-top: -2px;
|
|
1123
|
+
}
|
|
935
1124
|
.export-ex {
|
|
936
1125
|
display: flex;
|
|
937
1126
|
align-items: flex-start;
|
|
@@ -1533,14 +1722,16 @@
|
|
|
1533
1722
|
<div class="export-options">
|
|
1534
1723
|
<label class="export-check">
|
|
1535
1724
|
<input type="checkbox" id="export-include-tryit" checked />
|
|
1536
|
-
<span>Include env + headers <span style="color:var(--stone)">(Collection uses <code>{{baseUrl}}</code> / <code>{{vars}}</code> + environment file)</span></span>
|
|
1725
|
+
<span>Include env + headers <span style="color:var(--stone)">(Collection uses <code id="export-base-var">{{baseUrl}}</code> / <code>{{vars}}</code> + environment file)</span></span>
|
|
1537
1726
|
</label>
|
|
1538
1727
|
<div class="export-tryit-meta" id="export-tryit-meta">—</div>
|
|
1539
1728
|
</div>
|
|
1540
1729
|
<div class="export-toolbar">
|
|
1541
|
-
<
|
|
1542
|
-
<button type="button" class="
|
|
1543
|
-
<button type="button" class="
|
|
1730
|
+
<span class="export-tool-label">Examples</span>
|
|
1731
|
+
<button type="button" class="section-chip plain" id="export-all">All</button>
|
|
1732
|
+
<button type="button" class="section-chip plain" id="export-none">None</button>
|
|
1733
|
+
<span class="export-tool-sep" id="export-sections-sep" hidden></span>
|
|
1734
|
+
<span class="export-tool-chips" id="export-sections"></span>
|
|
1544
1735
|
</div>
|
|
1545
1736
|
<div class="export-body" id="export-body"></div>
|
|
1546
1737
|
<div class="export-foot">
|
|
@@ -1771,17 +1962,72 @@
|
|
|
1771
1962
|
|
|
1772
1963
|
const defaultHeaderValues = collectDefaultHeaderValues();
|
|
1773
1964
|
|
|
1965
|
+
/**
|
|
1966
|
+
* Env name for a base URL: loopback → local, host keyword → that keyword,
|
|
1967
|
+
* otherwise the first non-generic subdomain, falling back to production.
|
|
1968
|
+
*/
|
|
1969
|
+
const envNameFromUrl = (url) => {
|
|
1970
|
+
let host = String(url || "").trim();
|
|
1971
|
+
try {
|
|
1972
|
+
host = new URL(host).hostname;
|
|
1973
|
+
} catch {
|
|
1974
|
+
host = host.replace(/^[a-z]+:\/\//i, "").split("/")[0].split(":")[0];
|
|
1975
|
+
}
|
|
1976
|
+
host = host.toLowerCase();
|
|
1977
|
+
if (!host) return "local";
|
|
1978
|
+
if (["localhost", "127.0.0.1", "0.0.0.0", "::1"].includes(host) || host.endsWith(".local")) return "local";
|
|
1979
|
+
const keywords = [
|
|
1980
|
+
[/\bstag(e|ing)\b/, "staging"],
|
|
1981
|
+
[/\b(dev|development)\b/, "development"],
|
|
1982
|
+
[/\b(test|testing)\b/, "test"],
|
|
1983
|
+
[/\bqa\b/, "qa"],
|
|
1984
|
+
[/\bsandbox\b/, "sandbox"],
|
|
1985
|
+
[/\b(preprod|pre-prod|uat)\b/, "uat"],
|
|
1986
|
+
[/\b(prod|production)\b/, "production"],
|
|
1987
|
+
];
|
|
1988
|
+
const labels = host.split(".");
|
|
1989
|
+
for (const [pattern, name] of keywords) {
|
|
1990
|
+
if (labels.some((label) => pattern.test(label))) return name;
|
|
1991
|
+
}
|
|
1992
|
+
const generic = new Set(["api", "www", "app", "gateway", "edge"]);
|
|
1993
|
+
return labels.slice(0, -2).filter((label) => label && !generic.has(label))[0] || "production";
|
|
1994
|
+
};
|
|
1995
|
+
|
|
1996
|
+
/** Envs come from spec.servers (built per env preset); viewer.envPresets only overrides/extends. */
|
|
1774
1997
|
const configuredPresets = (() => {
|
|
1775
|
-
const
|
|
1776
|
-
|
|
1777
|
-
|
|
1998
|
+
const presets = {};
|
|
1999
|
+
for (const server of Array.isArray(spec.servers) ? spec.servers : []) {
|
|
2000
|
+
const url = String((server && server.url) || "").replace(/\/$/, "");
|
|
2001
|
+
if (!url) continue;
|
|
2002
|
+
const name = String((server && server.description) || "").trim() || envNameFromUrl(url);
|
|
2003
|
+
if (!presets[name]) presets[name] = { baseUrl: url };
|
|
2004
|
+
}
|
|
2005
|
+
const overrides = viewer.envPresets;
|
|
2006
|
+
if (overrides && typeof overrides === "object") {
|
|
2007
|
+
for (const [name, preset] of Object.entries(overrides)) {
|
|
2008
|
+
if (!name || !preset || typeof preset !== "object") continue;
|
|
2009
|
+
const baseUrl = String(preset.baseUrl || (presets[name] && presets[name].baseUrl) || defaultBaseUrl).replace(/\/$/, "");
|
|
2010
|
+
presets[name] = { ...preset, baseUrl: baseUrl || defaultBaseUrl };
|
|
2011
|
+
}
|
|
2012
|
+
}
|
|
2013
|
+
if (!Object.keys(presets).length) presets[envNameFromUrl(defaultBaseUrl)] = { baseUrl: defaultBaseUrl };
|
|
2014
|
+
return presets;
|
|
1778
2015
|
})();
|
|
1779
2016
|
|
|
2017
|
+
const DEFAULT_BASE_URL_KEY = "baseUrl";
|
|
2018
|
+
|
|
2019
|
+
/** The base URL variable can be renamed per env (e.g. ONBOARDING_SERVICE) for Postman. */
|
|
2020
|
+
const baseUrlKeyOf = (env) => {
|
|
2021
|
+
const key = env && typeof env.baseUrlKey === "string" ? env.baseUrlKey.trim() : "";
|
|
2022
|
+
return key || DEFAULT_BASE_URL_KEY;
|
|
2023
|
+
};
|
|
2024
|
+
|
|
1780
2025
|
const setEnvBaseUrl = (env, baseUrl) => {
|
|
1781
2026
|
const variables = env.variables || (env.variables = []);
|
|
1782
|
-
const
|
|
2027
|
+
const key = baseUrlKeyOf(env);
|
|
2028
|
+
const row = variables.find((entry) => entry.key === key);
|
|
1783
2029
|
if (row) row.value = baseUrl;
|
|
1784
|
-
else variables.unshift({ key
|
|
2030
|
+
else variables.unshift({ key, value: baseUrl });
|
|
1785
2031
|
};
|
|
1786
2032
|
|
|
1787
2033
|
const buildHeaderTemplate = () => {
|
|
@@ -1838,11 +2084,12 @@
|
|
|
1838
2084
|
const envFromPreset = (preset) => {
|
|
1839
2085
|
const template = buildHeaderTemplate();
|
|
1840
2086
|
const baseUrl = String((preset && preset.baseUrl) || defaultBaseUrl).replace(/\/$/, "") || defaultBaseUrl;
|
|
1841
|
-
const
|
|
2087
|
+
const baseUrlKey = baseUrlKeyOf(preset);
|
|
2088
|
+
const variables = [{ key: baseUrlKey, value: baseUrl }, ...template.variables.map((row) => ({ ...row }))];
|
|
1842
2089
|
const known = new Set(variables.map((row) => row.key));
|
|
1843
2090
|
if (preset && preset.variables && typeof preset.variables === "object") {
|
|
1844
2091
|
for (const [key, value] of Object.entries(preset.variables)) {
|
|
1845
|
-
if (!key || key ===
|
|
2092
|
+
if (!key || key === baseUrlKey) continue;
|
|
1846
2093
|
if (known.has(key)) {
|
|
1847
2094
|
const row = variables.find((entry) => entry.key === key);
|
|
1848
2095
|
if (row) row.value = String(value ?? "");
|
|
@@ -1856,7 +2103,7 @@
|
|
|
1856
2103
|
for (const [group, rows] of Object.entries(template.headerGroups)) {
|
|
1857
2104
|
headerGroups[group] = rows.map((row) => ({ ...row }));
|
|
1858
2105
|
}
|
|
1859
|
-
return { variables, headerGroups };
|
|
2106
|
+
return { variables, headerGroups, baseUrlKey };
|
|
1860
2107
|
};
|
|
1861
2108
|
|
|
1862
2109
|
const buildDefaultStore = () => {
|
|
@@ -1887,12 +2134,16 @@
|
|
|
1887
2134
|
const envs = {};
|
|
1888
2135
|
for (const [name, env] of Object.entries(saved.envs)) {
|
|
1889
2136
|
const base = cloneDefaultEnv();
|
|
2137
|
+
const baseUrlKey = baseUrlKeyOf(env);
|
|
1890
2138
|
const variables = Array.isArray(env.variables)
|
|
1891
2139
|
? env.variables.map((row) => ({ key: String(row.key || ""), value: String(row.value ?? "") }))
|
|
1892
2140
|
: base.variables.map((row) => ({ ...row }));
|
|
1893
2141
|
const known = new Set(variables.map((row) => row.key).filter(Boolean));
|
|
1894
2142
|
for (const row of base.variables) {
|
|
1895
|
-
if (row.key
|
|
2143
|
+
if (!row.key || known.has(row.key)) continue;
|
|
2144
|
+
// A renamed base URL variable already covers the default `baseUrl` row.
|
|
2145
|
+
if (row.key === DEFAULT_BASE_URL_KEY && baseUrlKey !== DEFAULT_BASE_URL_KEY) continue;
|
|
2146
|
+
variables.push({ ...row });
|
|
1896
2147
|
}
|
|
1897
2148
|
const defaultsByKey = Object.fromEntries((base.variables || []).filter((row) => row.key).map((row) => [row.key, row.value ?? ""]));
|
|
1898
2149
|
for (const row of variables) {
|
|
@@ -1905,7 +2156,7 @@
|
|
|
1905
2156
|
if (!headerGroups[group]) headerGroups[group] = rows.map((row) => ({ ...row }));
|
|
1906
2157
|
}
|
|
1907
2158
|
if (!Object.keys(headerGroups).length) headerGroups.default = [{ key: "content-type", value: "application/json" }];
|
|
1908
|
-
envs[name] = { variables, headerGroups };
|
|
2159
|
+
envs[name] = { variables, headerGroups, baseUrlKey };
|
|
1909
2160
|
}
|
|
1910
2161
|
// Seed any config presets that are missing from the saved store (don't wipe existing).
|
|
1911
2162
|
for (const [name, preset] of Object.entries(configuredPresets)) {
|
|
@@ -2077,7 +2328,12 @@
|
|
|
2077
2328
|
if (document.getElementById("env-wrap")?.classList.contains("open")) renderEnvPop();
|
|
2078
2329
|
};
|
|
2079
2330
|
|
|
2080
|
-
const
|
|
2331
|
+
const activeBaseUrlKey = () => baseUrlKeyOf(activeEnvConfig());
|
|
2332
|
+
|
|
2333
|
+
const currentBaseUrl = () => {
|
|
2334
|
+
const vars = varMap();
|
|
2335
|
+
return String(interpolate(vars[activeBaseUrlKey()] || defaultBaseUrl, vars) || defaultBaseUrl).replace(/\/$/, "");
|
|
2336
|
+
};
|
|
2081
2337
|
|
|
2082
2338
|
const envLabel = () => store.activeEnv + " · " + store.activeGroup;
|
|
2083
2339
|
|
|
@@ -2085,14 +2341,14 @@
|
|
|
2085
2341
|
const trigger = document.getElementById("env-trigger");
|
|
2086
2342
|
if (!trigger) return;
|
|
2087
2343
|
trigger.textContent = envLabel();
|
|
2088
|
-
const base = varMap()
|
|
2344
|
+
const base = varMap()[activeBaseUrlKey()] || "";
|
|
2089
2345
|
trigger.title = base ? store.activeEnv + " · " + base + " · " + store.activeGroup : envLabel();
|
|
2090
2346
|
};
|
|
2091
2347
|
|
|
2092
2348
|
const presetBaseUrl = (name) => {
|
|
2093
2349
|
const env = store.envs[name];
|
|
2094
2350
|
if (!env) return "";
|
|
2095
|
-
const row = (env.variables || []).find((entry) => entry.key ===
|
|
2351
|
+
const row = (env.variables || []).find((entry) => entry.key === baseUrlKeyOf(env));
|
|
2096
2352
|
return row ? String(row.value || "") : "";
|
|
2097
2353
|
};
|
|
2098
2354
|
|
|
@@ -2131,7 +2387,7 @@
|
|
|
2131
2387
|
<button type="button" class="ghost-btn" id="dup-env" title="Duplicate preset">⧉</button>
|
|
2132
2388
|
<button type="button" class="ghost-btn" id="remove-env" title="Remove preset" ${canRemoveEnv ? "" : "disabled"}>×</button>
|
|
2133
2389
|
</div>
|
|
2134
|
-
<div class="env-base-line"><span
|
|
2390
|
+
<div class="env-base-line"><span>${escapeAttr(baseUrlKeyOf(env))}</span> · ${escapeAttr(activeBase)}</div>
|
|
2135
2391
|
${
|
|
2136
2392
|
quickPresets.length
|
|
2137
2393
|
? `<div class="env-quick">${quickPresets
|
|
@@ -2147,10 +2403,10 @@
|
|
|
2147
2403
|
<div class="env-label">Variables</div>
|
|
2148
2404
|
${(env.variables || [])
|
|
2149
2405
|
.map(
|
|
2150
|
-
(row, index) => `<div class="env-kv ${row.key ===
|
|
2151
|
-
<input class="env-cell" data-field="key" spellcheck="false" value="${escapeAttr(row.key)}" ${row.key ===
|
|
2406
|
+
(row, index) => `<div class="env-kv ${row.key === baseUrlKeyOf(env) ? "base-url" : ""}" data-var="${index}">
|
|
2407
|
+
<input class="env-cell" data-field="key" spellcheck="false" value="${escapeAttr(row.key)}" title="${row.key === baseUrlKeyOf(env) ? "Base URL variable — rename it to match your Postman collection" : escapeAttr(row.key)}" />
|
|
2152
2408
|
<input class="env-cell" data-field="value" spellcheck="false" value="${escapeAttr(row.value)}" />
|
|
2153
|
-
<button type="button" class="ghost-btn" data-remove-var="${index}" ${row.key ===
|
|
2409
|
+
<button type="button" class="ghost-btn" data-remove-var="${index}" ${row.key === baseUrlKeyOf(env) ? "disabled" : ""}>×</button>
|
|
2154
2410
|
</div>`,
|
|
2155
2411
|
)
|
|
2156
2412
|
.join("")}
|
|
@@ -2281,11 +2537,19 @@
|
|
|
2281
2537
|
input.oninput = () => {
|
|
2282
2538
|
const index = Number(row.dataset.var);
|
|
2283
2539
|
const field = input.dataset.field;
|
|
2284
|
-
|
|
2285
|
-
|
|
2540
|
+
const env = activeEnvConfig();
|
|
2541
|
+
if (!env.variables[index] || (field !== "key" && field !== "value")) return;
|
|
2542
|
+
const wasBaseUrl = env.variables[index].key === baseUrlKeyOf(env);
|
|
2543
|
+
env.variables[index][field] = input.value;
|
|
2544
|
+
// Renaming the base URL row (e.g. to ONBOARDING_SERVICE) retargets the whole env.
|
|
2545
|
+
if (field === "key" && wasBaseUrl) {
|
|
2546
|
+
env.baseUrlKey = input.value.trim() || DEFAULT_BASE_URL_KEY;
|
|
2547
|
+
const label = document.querySelector(".env-base-line span");
|
|
2548
|
+
if (label) label.textContent = env.baseUrlKey;
|
|
2549
|
+
}
|
|
2286
2550
|
persistStore();
|
|
2287
2551
|
syncEnvTrigger();
|
|
2288
|
-
if (
|
|
2552
|
+
if (wasBaseUrl) renderMain();
|
|
2289
2553
|
};
|
|
2290
2554
|
input.onchange = () => renderMain();
|
|
2291
2555
|
});
|
|
@@ -2345,7 +2609,7 @@
|
|
|
2345
2609
|
document.documentElement.setAttribute("data-theme", next);
|
|
2346
2610
|
localStorage.setItem("daxta-theme", next);
|
|
2347
2611
|
const fav = document.getElementById("favicon");
|
|
2348
|
-
if (fav) fav.setAttribute("href", next === "light" ? "
|
|
2612
|
+
if (fav) fav.setAttribute("href", next === "light" ? "__FAVICON_DATA_URI__" : "__FAVICON_LIGHT_DATA_URI__");
|
|
2349
2613
|
const themeLabel = document.getElementById("theme-label");
|
|
2350
2614
|
if (themeLabel) themeLabel.textContent = next === "light" ? "Light" : "Dark";
|
|
2351
2615
|
};
|
|
@@ -2601,10 +2865,11 @@
|
|
|
2601
2865
|
}));
|
|
2602
2866
|
// Ensure header template vars referenced as {{x}} appear even if missing from variables list.
|
|
2603
2867
|
const known = new Set(values.map((row) => row.key));
|
|
2604
|
-
|
|
2605
|
-
|
|
2868
|
+
const baseKey = baseUrlKeyOf(env);
|
|
2869
|
+
if (!known.has(baseKey)) {
|
|
2870
|
+
known.add(baseKey);
|
|
2606
2871
|
values.unshift({
|
|
2607
|
-
key:
|
|
2872
|
+
key: baseKey,
|
|
2608
2873
|
value: String(presetBaseUrl(store.activeEnv) || defaultBaseUrl || ""),
|
|
2609
2874
|
type: "default",
|
|
2610
2875
|
enabled: true,
|
|
@@ -2706,11 +2971,13 @@
|
|
|
2706
2971
|
|
|
2707
2972
|
/**
|
|
2708
2973
|
* Postman Collection v2.1 — nested folders + named examples.
|
|
2709
|
-
* When includeTryIt, requests use
|
|
2974
|
+
* When includeTryIt, requests use the env's base URL variable and the active header group;
|
|
2975
|
+
* the env file is downloaded separately.
|
|
2710
2976
|
*/
|
|
2711
2977
|
const buildPostmanCollection = (openapi, includeTryIt) => {
|
|
2712
|
-
const
|
|
2713
|
-
const
|
|
2978
|
+
const baseVar = "{{" + activeBaseUrlKey() + "}}";
|
|
2979
|
+
const specServer = (openapi.servers && openapi.servers[0] && openapi.servers[0].url) || baseVar;
|
|
2980
|
+
const serverUrl = includeTryIt ? baseVar : specServer;
|
|
2714
2981
|
const root = [];
|
|
2715
2982
|
|
|
2716
2983
|
for (const [urlPath, pathItem] of Object.entries(openapi.paths || {})) {
|
|
@@ -2802,41 +3069,232 @@
|
|
|
2802
3069
|
};
|
|
2803
3070
|
};
|
|
2804
3071
|
|
|
3072
|
+
/** Keeps tab order and screen readers inside the dialog while it is open. */
|
|
3073
|
+
const setBackgroundInert = (inert) => {
|
|
3074
|
+
for (const node of document.body.children) {
|
|
3075
|
+
if (node.id === "export-backdrop") continue;
|
|
3076
|
+
if (inert) node.setAttribute("inert", "");
|
|
3077
|
+
else node.removeAttribute("inert");
|
|
3078
|
+
}
|
|
3079
|
+
};
|
|
3080
|
+
|
|
2805
3081
|
const closeExportModal = () => {
|
|
2806
3082
|
document.body.classList.remove("exporting");
|
|
3083
|
+
setBackgroundInert(false);
|
|
2807
3084
|
};
|
|
2808
3085
|
|
|
2809
3086
|
const syncExportTryItUi = () => {
|
|
2810
3087
|
const meta = document.getElementById("export-tryit-meta");
|
|
2811
3088
|
if (meta) meta.textContent = store.activeEnv + " · " + store.activeGroup;
|
|
3089
|
+
const baseVar = document.getElementById("export-base-var");
|
|
3090
|
+
if (baseVar) baseVar.textContent = "{{" + activeBaseUrlKey() + "}}";
|
|
3091
|
+
};
|
|
3092
|
+
|
|
3093
|
+
/** Scenario names double as example summaries, so they carry the case section. */
|
|
3094
|
+
const exampleSectionLookup = (item) => {
|
|
3095
|
+
const byName = new Map();
|
|
3096
|
+
for (const scenario of item.scenarios || []) {
|
|
3097
|
+
if (scenario && scenario.name) byName.set(scenario.name, scenario.group || "Other");
|
|
3098
|
+
}
|
|
3099
|
+
return (example) => byName.get(example.summary) || "Other";
|
|
3100
|
+
};
|
|
3101
|
+
|
|
3102
|
+
const groupExamplesBySection = (item, examples) => {
|
|
3103
|
+
const sectionOf = exampleSectionLookup(item);
|
|
3104
|
+
const bySection = new Map();
|
|
3105
|
+
for (const example of examples) {
|
|
3106
|
+
const section = sectionOf(example);
|
|
3107
|
+
if (!bySection.has(section)) bySection.set(section, []);
|
|
3108
|
+
bySection.get(section).push(example);
|
|
3109
|
+
}
|
|
3110
|
+
const order = GROUP_ORDER.filter((name) => bySection.has(name)).concat(
|
|
3111
|
+
[...bySection.keys()].filter((name) => !GROUP_ORDER.includes(name)),
|
|
3112
|
+
);
|
|
3113
|
+
return order.map((section) => ({ section, examples: bySection.get(section) }));
|
|
3114
|
+
};
|
|
3115
|
+
|
|
3116
|
+
const sectionCheckboxes = (section) => [
|
|
3117
|
+
...document.querySelectorAll(`#export-body .export-group-items input[data-section="${CSS.escape(section)}"]`),
|
|
3118
|
+
];
|
|
3119
|
+
|
|
3120
|
+
/** Chips mirror what is checked below: filled = all of it, outlined-part = some. */
|
|
3121
|
+
const syncExportSectionChips = () => {
|
|
3122
|
+
document.querySelectorAll("[data-export-section]").forEach((chip) => {
|
|
3123
|
+
const boxes = sectionCheckboxes(chip.dataset.exportSection);
|
|
3124
|
+
const checked = boxes.filter((box) => box.checked).length;
|
|
3125
|
+
chip.classList.toggle("on", boxes.length > 0 && checked === boxes.length);
|
|
3126
|
+
chip.classList.toggle("part", checked > 0 && checked < boxes.length);
|
|
3127
|
+
chip.setAttribute("aria-pressed", checked === boxes.length && boxes.length > 0 ? "true" : "false");
|
|
3128
|
+
});
|
|
3129
|
+
};
|
|
3130
|
+
|
|
3131
|
+
const syncExportGroupChecks = () => {
|
|
3132
|
+
document.querySelectorAll("#export-body .export-group").forEach((group) => {
|
|
3133
|
+
const head = group.querySelector(".export-group-check");
|
|
3134
|
+
const boxes = [...group.querySelectorAll(".export-group-items input[type=checkbox]")];
|
|
3135
|
+
if (!head || !boxes.length) return;
|
|
3136
|
+
const checked = boxes.filter((box) => box.checked).length;
|
|
3137
|
+
head.checked = checked === boxes.length;
|
|
3138
|
+
head.indeterminate = checked > 0 && checked < boxes.length;
|
|
3139
|
+
});
|
|
3140
|
+
syncExportSectionChips();
|
|
3141
|
+
};
|
|
3142
|
+
|
|
3143
|
+
/** Chips sit side by side, so the repeated "cases" tail only adds noise. */
|
|
3144
|
+
const shortGroup = (section) => displayGroup(section).replace(/\s+cases\b/gi, "").trim();
|
|
3145
|
+
|
|
3146
|
+
const renderExportSectionButtons = (sections) => {
|
|
3147
|
+
const host = document.getElementById("export-sections");
|
|
3148
|
+
if (!host) return;
|
|
3149
|
+
const separator = document.getElementById("export-sections-sep");
|
|
3150
|
+
if (separator) separator.hidden = !sections.length;
|
|
3151
|
+
host.innerHTML = sections
|
|
3152
|
+
.map(
|
|
3153
|
+
(section) =>
|
|
3154
|
+
`<button type="button" class="section-chip ${groupTone(section)}" data-export-section="${escapeAttr(section)}" aria-pressed="true" title="${escapeAttr(displayGroup(section))} — click to toggle"><span class="dot"></span>${escapeHtml(shortGroup(section))}</button>`,
|
|
3155
|
+
)
|
|
3156
|
+
.join("");
|
|
3157
|
+
host.querySelectorAll("[data-export-section]").forEach((chip) => {
|
|
3158
|
+
chip.onclick = () => {
|
|
3159
|
+
const boxes = sectionCheckboxes(chip.dataset.exportSection);
|
|
3160
|
+
const next = !boxes.every((box) => box.checked);
|
|
3161
|
+
boxes.forEach((box) => {
|
|
3162
|
+
box.checked = next;
|
|
3163
|
+
});
|
|
3164
|
+
syncExportGroupChecks();
|
|
3165
|
+
};
|
|
3166
|
+
});
|
|
3167
|
+
syncExportSectionChips();
|
|
2812
3168
|
};
|
|
2813
3169
|
|
|
2814
3170
|
const openExportModal = () => {
|
|
2815
3171
|
const body = document.getElementById("export-body");
|
|
2816
|
-
const
|
|
2817
|
-
|
|
2818
|
-
|
|
3172
|
+
const sections = new Set();
|
|
3173
|
+
const exportable = ops
|
|
3174
|
+
.map((item) => ({ item, examples: listOperationExamples(item.op) }))
|
|
3175
|
+
.filter((entry) => entry.examples.length);
|
|
3176
|
+
const examplesById = new Map(exportable.map((entry) => [entry.item.id, entry.examples]));
|
|
3177
|
+
|
|
3178
|
+
const renderOpBlock = (item) => {
|
|
3179
|
+
const examples = examplesById.get(item.id) || [];
|
|
2819
3180
|
if (!examples.length) return "";
|
|
2820
|
-
|
|
2821
|
-
|
|
3181
|
+
const grouped = groupExamplesBySection(item, examples);
|
|
3182
|
+
for (const { section } of grouped) sections.add(section);
|
|
3183
|
+
return `<div class="export-op collapsed" data-op="${escapeAttr(item.id)}">
|
|
3184
|
+
<button type="button" class="export-op-title" aria-expanded="false" title="Show sections">
|
|
3185
|
+
<span class="chev"></span>
|
|
2822
3186
|
<span class="method ${item.method}">${item.method}</span>
|
|
2823
|
-
<span class="path" title="${escapeAttr(item.path)}">${escapeAttr(item.
|
|
2824
|
-
|
|
2825
|
-
|
|
3187
|
+
<span class="path" title="${escapeAttr(item.path)}">${escapeAttr(item.title)}</span>
|
|
3188
|
+
<span class="export-op-count">${examples.length}</span>
|
|
3189
|
+
</button>
|
|
3190
|
+
<div class="export-op-groups">${grouped
|
|
2826
3191
|
.map(
|
|
2827
|
-
(
|
|
2828
|
-
<
|
|
2829
|
-
|
|
3192
|
+
({ section, examples: rows }) => `<div class="export-group collapsed">
|
|
3193
|
+
<label class="export-group-head ${groupTone(section)}">
|
|
3194
|
+
<button type="button" class="export-group-toggle" aria-expanded="false" title="Show examples"><span class="chev"></span></button>
|
|
3195
|
+
<input type="checkbox" class="export-group-check" checked />
|
|
3196
|
+
<span>${escapeHtml(displayGroup(section))}</span>
|
|
3197
|
+
<span class="export-group-count">${rows.length}</span>
|
|
3198
|
+
</label>
|
|
3199
|
+
<div class="export-group-items">${rows
|
|
3200
|
+
.map(
|
|
3201
|
+
(example) => `<div class="export-ex">
|
|
3202
|
+
<input type="checkbox" id="ex-${escapeAttr(item.id)}-${escapeAttr(example.key)}" data-op="${escapeAttr(item.id)}" data-key="${escapeAttr(example.key)}" data-section="${escapeAttr(section)}" checked />
|
|
3203
|
+
<label for="ex-${escapeAttr(item.id)}-${escapeAttr(example.key)}">${escapeAttr(example.summary)}</label>
|
|
3204
|
+
</div>`,
|
|
3205
|
+
)
|
|
3206
|
+
.join("")}</div>
|
|
2830
3207
|
</div>`,
|
|
2831
3208
|
)
|
|
2832
|
-
.join("")}
|
|
3209
|
+
.join("")}</div>
|
|
2833
3210
|
</div>`;
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
3211
|
+
};
|
|
3212
|
+
|
|
3213
|
+
/** Same folder tree as the sidebar, so the export mirrors what the docs show. */
|
|
3214
|
+
const countExamples = (node) =>
|
|
3215
|
+
node.ops.reduce((total, item) => total + (examplesById.get(item.id) || []).length, 0) +
|
|
3216
|
+
Object.values(node.children).reduce((total, child) => total + countExamples(child), 0);
|
|
3217
|
+
|
|
3218
|
+
const renderExportNode = (node) => {
|
|
3219
|
+
const opsHtml = [...node.ops]
|
|
3220
|
+
.sort((left, right) => (METHOD_ORDER[left.method] ?? 99) - (METHOD_ORDER[right.method] ?? 99))
|
|
3221
|
+
.map(renderOpBlock)
|
|
3222
|
+
.join("");
|
|
3223
|
+
const foldersHtml = Object.entries(node.children)
|
|
3224
|
+
.map(([name, child]) => {
|
|
3225
|
+
const total = countExamples(child);
|
|
3226
|
+
if (!total) return "";
|
|
3227
|
+
return `<div class="export-folder collapsed">
|
|
3228
|
+
<button type="button" class="export-folder-head" aria-expanded="false">
|
|
3229
|
+
<span class="chev"></span>
|
|
3230
|
+
<span class="export-folder-name">${escapeHtml(name)}</span>
|
|
3231
|
+
<span class="export-op-count">${total}</span>
|
|
3232
|
+
</button>
|
|
3233
|
+
<div class="export-folder-children">${renderExportNode(child)}</div>
|
|
3234
|
+
</div>`;
|
|
3235
|
+
})
|
|
3236
|
+
.join("");
|
|
3237
|
+
return opsHtml + foldersHtml;
|
|
3238
|
+
};
|
|
3239
|
+
|
|
3240
|
+
const tree = renderExportNode(buildPathTree(exportable.map((entry) => entry.item)));
|
|
3241
|
+
body.innerHTML = tree || `<div class="export-empty">No recorded examples yet — export will include schemas only.</div>`;
|
|
3242
|
+
|
|
3243
|
+
body.querySelectorAll(".export-folder").forEach((folder) => {
|
|
3244
|
+
const toggle = folder.querySelector(".export-folder-head");
|
|
3245
|
+
if (!toggle) return;
|
|
3246
|
+
toggle.onclick = () => {
|
|
3247
|
+
const collapsed = folder.classList.toggle("collapsed");
|
|
3248
|
+
toggle.setAttribute("aria-expanded", collapsed ? "false" : "true");
|
|
3249
|
+
};
|
|
3250
|
+
});
|
|
3251
|
+
|
|
3252
|
+
const ordered = GROUP_ORDER.filter((name) => sections.has(name)).concat(
|
|
3253
|
+
[...sections].filter((name) => !GROUP_ORDER.includes(name)),
|
|
3254
|
+
);
|
|
3255
|
+
renderExportSectionButtons(ordered);
|
|
3256
|
+
|
|
3257
|
+
body.querySelectorAll(".export-op").forEach((block) => {
|
|
3258
|
+
const toggle = block.querySelector(".export-op-title");
|
|
3259
|
+
if (!toggle) return;
|
|
3260
|
+
toggle.onclick = () => {
|
|
3261
|
+
const collapsed = block.classList.toggle("collapsed");
|
|
3262
|
+
toggle.setAttribute("aria-expanded", collapsed ? "false" : "true");
|
|
3263
|
+
toggle.title = collapsed ? "Show sections" : "Hide sections";
|
|
3264
|
+
};
|
|
3265
|
+
});
|
|
3266
|
+
|
|
3267
|
+
body.querySelectorAll(".export-group").forEach((group) => {
|
|
3268
|
+
const head = group.querySelector(".export-group-check");
|
|
3269
|
+
const boxes = [...group.querySelectorAll(".export-group-items input[type=checkbox]")];
|
|
3270
|
+
if (head) {
|
|
3271
|
+
head.onchange = () => {
|
|
3272
|
+
boxes.forEach((box) => {
|
|
3273
|
+
box.checked = head.checked;
|
|
3274
|
+
});
|
|
3275
|
+
head.indeterminate = false;
|
|
3276
|
+
};
|
|
3277
|
+
}
|
|
3278
|
+
boxes.forEach((box) => {
|
|
3279
|
+
box.onchange = syncExportGroupChecks;
|
|
3280
|
+
});
|
|
3281
|
+
const toggle = group.querySelector(".export-group-toggle");
|
|
3282
|
+
if (toggle) {
|
|
3283
|
+
toggle.onclick = (event) => {
|
|
3284
|
+
// Sits inside the <label>, so stop the click from flipping the group checkbox.
|
|
3285
|
+
event.preventDefault();
|
|
3286
|
+
event.stopPropagation();
|
|
3287
|
+
const collapsed = group.classList.toggle("collapsed");
|
|
3288
|
+
toggle.setAttribute("aria-expanded", collapsed ? "false" : "true");
|
|
3289
|
+
toggle.title = collapsed ? "Show examples" : "Hide examples";
|
|
3290
|
+
};
|
|
3291
|
+
}
|
|
3292
|
+
});
|
|
3293
|
+
|
|
3294
|
+
syncExportGroupChecks();
|
|
2838
3295
|
syncExportTryItUi();
|
|
2839
3296
|
document.body.classList.add("exporting");
|
|
3297
|
+
setBackgroundInert(true);
|
|
2840
3298
|
};
|
|
2841
3299
|
|
|
2842
3300
|
const collectSelectedExamples = () => {
|
|
@@ -2893,22 +3351,18 @@
|
|
|
2893
3351
|
if (event.target.id === "export-backdrop") closeExportModal();
|
|
2894
3352
|
});
|
|
2895
3353
|
document.getElementById("export-modal").addEventListener("click", (event) => event.stopPropagation());
|
|
3354
|
+
const exampleCheckboxes = () => document.querySelectorAll("#export-body .export-group-items input[type=checkbox]");
|
|
2896
3355
|
document.getElementById("export-all").addEventListener("click", () => {
|
|
2897
|
-
|
|
3356
|
+
exampleCheckboxes().forEach((input) => {
|
|
2898
3357
|
input.checked = true;
|
|
2899
3358
|
});
|
|
3359
|
+
syncExportGroupChecks();
|
|
2900
3360
|
});
|
|
2901
3361
|
document.getElementById("export-none").addEventListener("click", () => {
|
|
2902
|
-
|
|
3362
|
+
exampleCheckboxes().forEach((input) => {
|
|
2903
3363
|
input.checked = false;
|
|
2904
3364
|
});
|
|
2905
|
-
|
|
2906
|
-
document.getElementById("export-success").addEventListener("click", () => {
|
|
2907
|
-
document.querySelectorAll("#export-body input[type=checkbox]").forEach((input) => {
|
|
2908
|
-
const label = document.querySelector(`label[for="${CSS.escape(input.id)}"]`);
|
|
2909
|
-
const text = label ? label.textContent || "" : "";
|
|
2910
|
-
input.checked = /^2\d\d\b/.test(text.trim());
|
|
2911
|
-
});
|
|
3365
|
+
syncExportGroupChecks();
|
|
2912
3366
|
});
|
|
2913
3367
|
document.getElementById("export-confirm").addEventListener("click", () => {
|
|
2914
3368
|
runExportDownload();
|
|
@@ -3137,7 +3591,7 @@
|
|
|
3137
3591
|
rows
|
|
3138
3592
|
.map(
|
|
3139
3593
|
({ scenario, index }) =>
|
|
3140
|
-
`<button type="button" class="dd-item ${index === selected ? "on" : ""}" data-index="${index}"><span class="st ${statusOk(scenario.status) ? "ok" : "err"}">${escapeHtml(String(scenario.status))}</span><span>${escapeHtml(scenario
|
|
3594
|
+
`<button type="button" class="dd-item ${index === selected ? "on" : ""}" data-index="${index}"><span class="st ${statusOk(scenario.status) ? "ok" : "err"}">${escapeHtml(String(scenario.status))}</span><span>${escapeHtml(scenarioClause(scenario))}</span></button>`,
|
|
3141
3595
|
)
|
|
3142
3596
|
.join("");
|
|
3143
3597
|
})
|
|
@@ -3157,25 +3611,42 @@
|
|
|
3157
3611
|
let activeVersion = apiVersions[0] || "";
|
|
3158
3612
|
const expandedFolders = new Set(apiVersions.map((version) => "/" + version));
|
|
3159
3613
|
const expandedExampleOps = new Set();
|
|
3614
|
+
/** `${opId}::${group}` entries the user opened; groups start collapsed. */
|
|
3615
|
+
const expandedExampleGroups = new Set();
|
|
3616
|
+
const exampleGroupKey = (opId, group) => `${opId}::${group}`;
|
|
3617
|
+
const isExampleGroupCollapsed = (opId, group) => !expandedExampleGroups.has(exampleGroupKey(opId, group));
|
|
3160
3618
|
|
|
3161
3619
|
const scenarioNavLabel = (scenario) => {
|
|
3620
|
+
const name = scenario.name || "example";
|
|
3162
3621
|
const status = scenario.status != null ? String(scenario.status) : "";
|
|
3622
|
+
if (status && !name.startsWith(`${status} `) && !name.startsWith(`${status} —`)) {
|
|
3623
|
+
return `${status} — ${name}`;
|
|
3624
|
+
}
|
|
3625
|
+
return name;
|
|
3626
|
+
};
|
|
3627
|
+
const scenarioClause = (scenario) => {
|
|
3163
3628
|
const name = scenario.name || "example";
|
|
3164
|
-
|
|
3629
|
+
const status = scenario.status != null ? String(scenario.status) : "";
|
|
3630
|
+
const dashed = `${status} — `;
|
|
3631
|
+
if (status && name.startsWith(dashed)) return name.slice(dashed.length);
|
|
3632
|
+
const spaced = `${status} `;
|
|
3633
|
+
if (status && name.startsWith(spaced)) return name.slice(spaced.length).trim();
|
|
3634
|
+
if (status && name.startsWith(`${status} `)) return name.slice(status.length).trim();
|
|
3635
|
+
return name;
|
|
3165
3636
|
};
|
|
3166
3637
|
|
|
3167
3638
|
const renderNavExamples = (item) => {
|
|
3168
3639
|
const { groups, order } = groupScenarios(item.scenarios);
|
|
3169
3640
|
return `<div class="nav-examples">${order
|
|
3170
3641
|
.map(
|
|
3171
|
-
(group) => `<div class="nav-ex-group
|
|
3172
|
-
<div class="nav-ex-group-label
|
|
3173
|
-
|
|
3642
|
+
(group) => `<div class="nav-ex-group">
|
|
3643
|
+
<div class="nav-ex-group-label"><span>${escapeHtml(displayGroup(group))}</span><span class="nav-ex-count">${groups[group].length}</span></div>
|
|
3644
|
+
${groups[group]
|
|
3174
3645
|
.map(
|
|
3175
3646
|
({ scenario, index }) =>
|
|
3176
3647
|
`<button type="button" class="nav-example ${item.id === currentId && index === scenarioIndex ? "on" : ""}" data-id="${escapeAttr(item.id)}" data-scenario="${index}" title="${escapeAttr(scenarioNavLabel(scenario))}">${escapeHtml(scenarioNavLabel(scenario))}</button>`,
|
|
3177
3648
|
)
|
|
3178
|
-
.join("")}
|
|
3649
|
+
.join("")}
|
|
3179
3650
|
</div>`,
|
|
3180
3651
|
)
|
|
3181
3652
|
.join("")}</div>`;
|
|
@@ -3316,6 +3787,18 @@
|
|
|
3316
3787
|
renderNav();
|
|
3317
3788
|
};
|
|
3318
3789
|
});
|
|
3790
|
+
nav.querySelectorAll(".nav-ex-group-label").forEach((button) => {
|
|
3791
|
+
button.onclick = (event) => {
|
|
3792
|
+
event.stopPropagation();
|
|
3793
|
+
const key = exampleGroupKey(button.dataset.groupOp, button.dataset.groupName);
|
|
3794
|
+
const collapsed = expandedExampleGroups.has(key);
|
|
3795
|
+
if (collapsed) expandedExampleGroups.delete(key);
|
|
3796
|
+
else expandedExampleGroups.add(key);
|
|
3797
|
+
const group = button.closest(".nav-ex-group");
|
|
3798
|
+
if (group) group.classList.toggle("collapsed", collapsed);
|
|
3799
|
+
button.setAttribute("aria-expanded", collapsed ? "false" : "true");
|
|
3800
|
+
};
|
|
3801
|
+
});
|
|
3319
3802
|
nav.querySelectorAll(".nav-example").forEach((button) => {
|
|
3320
3803
|
button.onclick = (event) => {
|
|
3321
3804
|
event.stopPropagation();
|
|
@@ -3583,7 +4066,13 @@
|
|
|
3583
4066
|
|
|
3584
4067
|
const schemas = schemasInline(fields, displayEmpty ? undefined : displayBody);
|
|
3585
4068
|
const epName = document.getElementById("ep-name");
|
|
3586
|
-
if (epName)
|
|
4069
|
+
if (epName) {
|
|
4070
|
+
const exampleLabel = scenario.name ? scenarioClause(scenario) : "";
|
|
4071
|
+
epName.innerHTML = exampleLabel
|
|
4072
|
+
? `<span class="ep-status ${recordedOk ? "" : "err"}">${escapeHtml(String(scenario.status))}</span>` +
|
|
4073
|
+
`<span class="ep-label" title="${escapeAttr(exampleLabel)}">${escapeHtml(exampleLabel)}</span>`
|
|
4074
|
+
: `<span class="ep-label" title="${escapeAttr(item.title)}">${escapeHtml(item.title)}</span>`;
|
|
4075
|
+
}
|
|
3587
4076
|
document.title = item.title + (title ? " · " + title : "");
|
|
3588
4077
|
|
|
3589
4078
|
document.getElementById("main").innerHTML = `
|
|
@@ -3738,6 +4227,8 @@
|
|
|
3738
4227
|
const version = treePathSegments(selected)[0];
|
|
3739
4228
|
if (version) activeVersion = version;
|
|
3740
4229
|
expandedExampleOps.add(id);
|
|
4230
|
+
const scenario = (selected.scenarios || [])[scenarioIndex];
|
|
4231
|
+
if (scenario) expandedExampleGroups.add(exampleGroupKey(id, scenario.group || "Other"));
|
|
3741
4232
|
}
|
|
3742
4233
|
renderPrefixBar();
|
|
3743
4234
|
renderNav();
|