@t0.labs/daxta 0.4.22 → 0.4.24
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/empty.html +159 -0
- package/assets/example.html +3708 -0
- package/assets/viewer.html +148 -57
- package/dist/serve/index.js +4 -1
- package/dist/serve/middleware.js +3 -2
- package/dist/serve/paths.d.ts +2 -0
- package/dist/serve/paths.js +17 -0
- package/package.json +1 -1
package/assets/viewer.html
CHANGED
|
@@ -59,27 +59,6 @@
|
|
|
59
59
|
}
|
|
60
60
|
body.searching .topnav { z-index: 30; }
|
|
61
61
|
.brand-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; justify-self: start; }
|
|
62
|
-
.logo-mark {
|
|
63
|
-
width: 20px;
|
|
64
|
-
height: 20px;
|
|
65
|
-
border-radius: 4px;
|
|
66
|
-
background: var(--obsidian);
|
|
67
|
-
color: var(--white);
|
|
68
|
-
font: 600 11px/20px var(--sans);
|
|
69
|
-
text-align: center;
|
|
70
|
-
flex: none;
|
|
71
|
-
}
|
|
72
|
-
.logo-name {
|
|
73
|
-
font-size: 13px;
|
|
74
|
-
font-weight: 600;
|
|
75
|
-
letter-spacing: -0.02em;
|
|
76
|
-
}
|
|
77
|
-
.nav-divider {
|
|
78
|
-
width: 1px;
|
|
79
|
-
height: 16px;
|
|
80
|
-
background: var(--hairline);
|
|
81
|
-
flex: none;
|
|
82
|
-
}
|
|
83
62
|
.workspace { display: none; }
|
|
84
63
|
.brand { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--charcoal); }
|
|
85
64
|
.ver-select {
|
|
@@ -553,16 +532,87 @@
|
|
|
553
532
|
gap: 2px;
|
|
554
533
|
min-width: 0;
|
|
555
534
|
}
|
|
535
|
+
.nav-expand {
|
|
536
|
+
flex: none;
|
|
537
|
+
width: 24px;
|
|
538
|
+
height: 24px;
|
|
539
|
+
border: 0;
|
|
540
|
+
border-radius: 4px;
|
|
541
|
+
background: transparent;
|
|
542
|
+
color: var(--stone);
|
|
543
|
+
cursor: pointer;
|
|
544
|
+
display: inline-flex;
|
|
545
|
+
align-items: center;
|
|
546
|
+
justify-content: center;
|
|
547
|
+
padding: 0;
|
|
548
|
+
}
|
|
549
|
+
.nav-expand:hover { color: var(--obsidian); background: var(--inset); }
|
|
550
|
+
.nav-expand .chev {
|
|
551
|
+
width: 6px;
|
|
552
|
+
height: 6px;
|
|
553
|
+
border-right: 1.5px solid currentColor;
|
|
554
|
+
border-bottom: 1.5px solid currentColor;
|
|
555
|
+
transform: rotate(-45deg);
|
|
556
|
+
margin-top: -2px;
|
|
557
|
+
}
|
|
558
|
+
.nav-op.examples-open > .nav-op-row .nav-expand .chev {
|
|
559
|
+
transform: rotate(45deg);
|
|
560
|
+
margin-top: 0;
|
|
561
|
+
}
|
|
562
|
+
.nav-expand:disabled { opacity: 0.25; cursor: default; }
|
|
563
|
+
.nav-examples {
|
|
564
|
+
display: none;
|
|
565
|
+
flex-direction: column;
|
|
566
|
+
gap: 4px;
|
|
567
|
+
margin: 0 4px 6px 18px;
|
|
568
|
+
padding-left: 8px;
|
|
569
|
+
border-left: 1px solid var(--hairline);
|
|
570
|
+
}
|
|
571
|
+
.nav-op.examples-open > .nav-examples { display: flex; }
|
|
572
|
+
.nav-ex-group { display: flex; flex-direction: column; gap: 1px; }
|
|
573
|
+
.nav-ex-group-label {
|
|
574
|
+
display: flex;
|
|
575
|
+
align-items: center;
|
|
576
|
+
justify-content: space-between;
|
|
577
|
+
gap: 8px;
|
|
578
|
+
padding: 6px 8px 2px;
|
|
579
|
+
font: 600 10px/1.2 var(--sans);
|
|
580
|
+
letter-spacing: 0.02em;
|
|
581
|
+
color: var(--stone);
|
|
582
|
+
}
|
|
583
|
+
.nav-ex-count {
|
|
584
|
+
font: 600 10px/1.4 var(--mono);
|
|
585
|
+
color: var(--stone);
|
|
586
|
+
}
|
|
587
|
+
.nav-example {
|
|
588
|
+
display: block;
|
|
589
|
+
width: 100%;
|
|
590
|
+
border: 0;
|
|
591
|
+
background: transparent;
|
|
592
|
+
text-align: left;
|
|
593
|
+
padding: 4px 8px;
|
|
594
|
+
border-radius: 4px;
|
|
595
|
+
cursor: pointer;
|
|
596
|
+
font-size: 11px;
|
|
597
|
+
line-height: 1.35;
|
|
598
|
+
color: var(--stone);
|
|
599
|
+
overflow: hidden;
|
|
600
|
+
text-overflow: ellipsis;
|
|
601
|
+
white-space: nowrap;
|
|
602
|
+
}
|
|
603
|
+
.nav-example:hover { background: var(--inset); color: var(--charcoal); }
|
|
604
|
+
.nav-example.on { color: var(--obsidian); background: var(--inset); }
|
|
556
605
|
.nav-ex-total {
|
|
557
606
|
flex: none;
|
|
558
607
|
min-width: 16px;
|
|
559
|
-
margin-right:
|
|
608
|
+
margin-right: 2px;
|
|
560
609
|
padding: 1px 5px;
|
|
561
610
|
border-radius: 4px;
|
|
562
611
|
background: var(--obsidian);
|
|
563
612
|
color: var(--white);
|
|
564
613
|
font: 600 10px/1.4 var(--mono);
|
|
565
614
|
text-align: center;
|
|
615
|
+
cursor: pointer;
|
|
566
616
|
}
|
|
567
617
|
.nav-title {
|
|
568
618
|
font-size: 12px;
|
|
@@ -1149,9 +1199,6 @@
|
|
|
1149
1199
|
<body>
|
|
1150
1200
|
<header class="topnav">
|
|
1151
1201
|
<div class="brand-wrap">
|
|
1152
|
-
<span class="logo-mark">N</span>
|
|
1153
|
-
<span class="logo-name">Notary</span>
|
|
1154
|
-
<span class="nav-divider"></span>
|
|
1155
1202
|
<div class="brand" id="brand">API</div>
|
|
1156
1203
|
<select class="ver-select" id="ver-select" aria-label="API version"></select>
|
|
1157
1204
|
</div>
|
|
@@ -2514,11 +2561,6 @@
|
|
|
2514
2561
|
"INVALID CASES",
|
|
2515
2562
|
"OMITTED CASES",
|
|
2516
2563
|
"SEMANTIC ERROR CASES - AUTH",
|
|
2517
|
-
"Success",
|
|
2518
|
-
"Business errors",
|
|
2519
|
-
"Invalid input",
|
|
2520
|
-
"Missing fields",
|
|
2521
|
-
"Auth",
|
|
2522
2564
|
"Other",
|
|
2523
2565
|
];
|
|
2524
2566
|
const METHOD_ORDER = { get: 0, post: 1, put: 2, patch: 3, delete: 4 };
|
|
@@ -2688,39 +2730,23 @@
|
|
|
2688
2730
|
};
|
|
2689
2731
|
|
|
2690
2732
|
const GROUP_LABEL = {
|
|
2691
|
-
"POSITIVE CASES": "
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
"
|
|
2695
|
-
"
|
|
2696
|
-
"INVALID CASES": "Invalid input",
|
|
2697
|
-
"Invalid input": "Invalid input",
|
|
2698
|
-
"OMITTED CASES": "Invalid input",
|
|
2699
|
-
"Missing fields": "Invalid input",
|
|
2700
|
-
"SEMANTIC ERROR CASES - AUTH": "Auth",
|
|
2701
|
-
Auth: "Auth",
|
|
2702
|
-
AUTH: "Auth",
|
|
2733
|
+
"POSITIVE CASES": "Positive cases",
|
|
2734
|
+
"SEMANTIC ERROR CASES": "False positive cases",
|
|
2735
|
+
"INVALID CASES": "Invalid cases",
|
|
2736
|
+
"OMITTED CASES": "Omitted cases",
|
|
2737
|
+
"SEMANTIC ERROR CASES - AUTH": "False positive cases — Auth",
|
|
2703
2738
|
Other: "Other",
|
|
2704
2739
|
};
|
|
2705
2740
|
|
|
2706
|
-
const displayGroup = (group) =>
|
|
2707
|
-
const groupTone = (label) =>
|
|
2708
|
-
const upper = String(label).toUpperCase();
|
|
2709
|
-
if (upper.includes("SUCCESS") || upper.includes("POSITIVE")) return "ok";
|
|
2710
|
-
if (upper.includes("ERROR") || upper.includes("INVALID") || upper.includes("AUTH") || upper.includes("BUSINESS")) return "err";
|
|
2711
|
-
return "";
|
|
2712
|
-
};
|
|
2741
|
+
const displayGroup = (group) => GROUP_LABEL[group] || group || "Other";
|
|
2742
|
+
const groupTone = (label) => (String(label).toLowerCase() === "positive cases" ? "ok" : "err");
|
|
2713
2743
|
const statusOk = (status) => Number(status) >= 200 && Number(status) < 300;
|
|
2714
2744
|
|
|
2715
2745
|
const groupedDropdown = (scenarios, selected) => {
|
|
2716
2746
|
const { groups, order } = groupScenarios(scenarios);
|
|
2717
2747
|
const current = scenarios[selected];
|
|
2718
2748
|
const q = exampleQuery.trim().toLowerCase();
|
|
2719
|
-
const kind = current
|
|
2720
|
-
? displayGroup(current.group)
|
|
2721
|
-
.toLowerCase()
|
|
2722
|
-
.replace(/\b\w/g, (ch) => ch.toUpperCase())
|
|
2723
|
-
: "";
|
|
2749
|
+
const kind = current ? displayGroup(current.group) : "";
|
|
2724
2750
|
const ok = current ? statusOk(current.status) : false;
|
|
2725
2751
|
return `<div class="dd ${exampleOpen ? "open" : ""}" id="scenario-dd">
|
|
2726
2752
|
<button type="button" class="dd-toggle" id="scenario-toggle">
|
|
@@ -2761,6 +2787,30 @@
|
|
|
2761
2787
|
const apiVersions = [...new Set(ops.map((item) => treePathSegments(item)[0]).filter(Boolean))];
|
|
2762
2788
|
let activeVersion = apiVersions[0] || "";
|
|
2763
2789
|
const expandedFolders = new Set(apiVersions.map((version) => "/" + version));
|
|
2790
|
+
const expandedExampleOps = new Set();
|
|
2791
|
+
|
|
2792
|
+
const scenarioNavLabel = (scenario) => {
|
|
2793
|
+
const status = scenario.status != null ? String(scenario.status) : "";
|
|
2794
|
+
const name = scenario.name || "example";
|
|
2795
|
+
return status ? status + " " + name : name;
|
|
2796
|
+
};
|
|
2797
|
+
|
|
2798
|
+
const renderNavExamples = (item) => {
|
|
2799
|
+
const { groups, order } = groupScenarios(item.scenarios);
|
|
2800
|
+
return `<div class="nav-examples">${order
|
|
2801
|
+
.map(
|
|
2802
|
+
(group) => `<div class="nav-ex-group">
|
|
2803
|
+
<div class="nav-ex-group-label"><span>${escapeHtml(displayGroup(group))}</span><span class="nav-ex-count">${groups[group].length}</span></div>
|
|
2804
|
+
${groups[group]
|
|
2805
|
+
.map(
|
|
2806
|
+
({ scenario, index }) =>
|
|
2807
|
+
`<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>`,
|
|
2808
|
+
)
|
|
2809
|
+
.join("")}
|
|
2810
|
+
</div>`,
|
|
2811
|
+
)
|
|
2812
|
+
.join("")}</div>`;
|
|
2813
|
+
};
|
|
2764
2814
|
|
|
2765
2815
|
const kv = (label, value) => {
|
|
2766
2816
|
if (value === undefined || value === "") return "";
|
|
@@ -2813,15 +2863,21 @@
|
|
|
2813
2863
|
const opsHtml = [...node.ops]
|
|
2814
2864
|
.sort((left, right) => (METHOD_ORDER[left.method] ?? 99) - (METHOD_ORDER[right.method] ?? 99))
|
|
2815
2865
|
.map((item) => {
|
|
2816
|
-
const
|
|
2817
|
-
|
|
2866
|
+
const hasExamples = Array.isArray(item.scenarios) && item.scenarios.length > 0;
|
|
2867
|
+
const examplesOpen = expandedExampleOps.has(item.id);
|
|
2868
|
+
const exampleCount = hasExamples ? item.scenarios.length : 0;
|
|
2869
|
+
return `<div class="nav-op ${item.id === currentId ? "active" : ""} ${examplesOpen ? "examples-open" : ""}" data-op-id="${escapeAttr(item.id)}">
|
|
2818
2870
|
<div class="nav-op-row">
|
|
2819
2871
|
<button type="button" class="nav-item" data-id="${escapeAttr(item.id)}" title="${escapeAttr(item.path)}">
|
|
2820
2872
|
<span class="method ${item.method}">${item.method}</span>
|
|
2821
2873
|
<span class="nav-title">${escapeAttr(item.title)}</span>
|
|
2822
2874
|
</button>
|
|
2823
|
-
${
|
|
2875
|
+
${hasExamples ? `<span class="nav-ex-total" title="${exampleCount} examples">${exampleCount}</span>` : ""}
|
|
2876
|
+
<button type="button" class="nav-expand" data-expand-id="${escapeAttr(item.id)}" title="Examples" aria-label="Toggle examples" aria-expanded="${examplesOpen ? "true" : "false"}" ${hasExamples ? "" : "disabled"}>
|
|
2877
|
+
<span class="chev"></span>
|
|
2878
|
+
</button>
|
|
2824
2879
|
</div>
|
|
2880
|
+
${hasExamples ? renderNavExamples(item) : ""}
|
|
2825
2881
|
</div>`;
|
|
2826
2882
|
})
|
|
2827
2883
|
.join("");
|
|
@@ -2880,6 +2936,40 @@
|
|
|
2880
2936
|
nav.querySelectorAll(".nav-item").forEach((button) => {
|
|
2881
2937
|
button.onclick = () => select(button.dataset.id);
|
|
2882
2938
|
});
|
|
2939
|
+
nav.querySelectorAll(".nav-expand").forEach((button) => {
|
|
2940
|
+
button.onclick = (event) => {
|
|
2941
|
+
event.stopPropagation();
|
|
2942
|
+
if (button.disabled) return;
|
|
2943
|
+
const opId = button.dataset.expandId;
|
|
2944
|
+
if (expandedExampleOps.has(opId)) expandedExampleOps.delete(opId);
|
|
2945
|
+
else expandedExampleOps.add(opId);
|
|
2946
|
+
const wrap = button.closest(".nav-op");
|
|
2947
|
+
if (wrap) {
|
|
2948
|
+
wrap.classList.toggle("examples-open", expandedExampleOps.has(opId));
|
|
2949
|
+
button.setAttribute("aria-expanded", expandedExampleOps.has(opId) ? "true" : "false");
|
|
2950
|
+
}
|
|
2951
|
+
};
|
|
2952
|
+
});
|
|
2953
|
+
nav.querySelectorAll(".nav-ex-total").forEach((badge) => {
|
|
2954
|
+
badge.onclick = (event) => {
|
|
2955
|
+
event.stopPropagation();
|
|
2956
|
+
const wrap = badge.closest(".nav-op");
|
|
2957
|
+
const opId = wrap && wrap.dataset.opId;
|
|
2958
|
+
if (!opId) return;
|
|
2959
|
+
if (expandedExampleOps.has(opId)) expandedExampleOps.delete(opId);
|
|
2960
|
+
else expandedExampleOps.add(opId);
|
|
2961
|
+
renderNav();
|
|
2962
|
+
};
|
|
2963
|
+
});
|
|
2964
|
+
nav.querySelectorAll(".nav-example").forEach((button) => {
|
|
2965
|
+
button.onclick = (event) => {
|
|
2966
|
+
event.stopPropagation();
|
|
2967
|
+
const opId = button.dataset.id;
|
|
2968
|
+
const index = Number(button.dataset.scenario);
|
|
2969
|
+
expandedExampleOps.add(opId);
|
|
2970
|
+
select(opId, Number.isFinite(index) ? index : 0);
|
|
2971
|
+
};
|
|
2972
|
+
});
|
|
2883
2973
|
nav.querySelectorAll(".tree-folder-toggle").forEach((button) => {
|
|
2884
2974
|
button.onclick = (event) => {
|
|
2885
2975
|
event.stopPropagation();
|
|
@@ -3265,6 +3355,7 @@
|
|
|
3265
3355
|
syncHeaderGroupForOp(selected.op);
|
|
3266
3356
|
const version = treePathSegments(selected)[0];
|
|
3267
3357
|
if (version) activeVersion = version;
|
|
3358
|
+
expandedExampleOps.add(id);
|
|
3268
3359
|
}
|
|
3269
3360
|
renderNav();
|
|
3270
3361
|
renderMain();
|
package/dist/serve/index.js
CHANGED
|
@@ -122,7 +122,10 @@ function serveApiDocs(options = {}) {
|
|
|
122
122
|
}
|
|
123
123
|
if (url.pathname === '/' || url.pathname === docsBase || url.pathname === `${docsBase}/`) {
|
|
124
124
|
if (!(0, fs_1.existsSync)(htmlPath)) {
|
|
125
|
-
send(res,
|
|
125
|
+
send(res, 200, (0, paths_1.readEmptyDocsHtml)(), {
|
|
126
|
+
'content-type': 'text/html; charset=utf-8',
|
|
127
|
+
'cache-control': 'no-store',
|
|
128
|
+
});
|
|
126
129
|
return;
|
|
127
130
|
}
|
|
128
131
|
send(res, 200, (0, fs_1.readFileSync)(htmlPath), {
|
package/dist/serve/middleware.js
CHANGED
|
@@ -175,8 +175,9 @@ function apiDocsHandler(options = {}) {
|
|
|
175
175
|
}
|
|
176
176
|
const htmlPath = (0, paths_1.getHtmlPath)();
|
|
177
177
|
if (!(0, fs_1.existsSync)(htmlPath)) {
|
|
178
|
-
write(res,
|
|
179
|
-
'content-type': 'text/
|
|
178
|
+
write(res, 200, (0, paths_1.readEmptyDocsHtml)(), {
|
|
179
|
+
'content-type': 'text/html; charset=utf-8',
|
|
180
|
+
'cache-control': 'no-store',
|
|
180
181
|
});
|
|
181
182
|
return;
|
|
182
183
|
}
|
package/dist/serve/paths.d.ts
CHANGED
|
@@ -5,5 +5,7 @@ export declare function getHitsJsonPath(): string;
|
|
|
5
5
|
/** Try-it env/headers — outside outDir so rebuild does not wipe it. */
|
|
6
6
|
export declare function getViewerStorePath(): string;
|
|
7
7
|
export declare function getViewerAssetPath(): string;
|
|
8
|
+
export declare function getEmptyViewerAssetPath(): string;
|
|
9
|
+
export declare function readEmptyDocsHtml(): Buffer;
|
|
8
10
|
export declare function getFaviconAssetPath(): string;
|
|
9
11
|
export declare function getDocsBasePath(): string;
|
package/dist/serve/paths.js
CHANGED
|
@@ -39,8 +39,11 @@ exports.getSpecJsonPath = getSpecJsonPath;
|
|
|
39
39
|
exports.getHitsJsonPath = getHitsJsonPath;
|
|
40
40
|
exports.getViewerStorePath = getViewerStorePath;
|
|
41
41
|
exports.getViewerAssetPath = getViewerAssetPath;
|
|
42
|
+
exports.getEmptyViewerAssetPath = getEmptyViewerAssetPath;
|
|
43
|
+
exports.readEmptyDocsHtml = readEmptyDocsHtml;
|
|
42
44
|
exports.getFaviconAssetPath = getFaviconAssetPath;
|
|
43
45
|
exports.getDocsBasePath = getDocsBasePath;
|
|
46
|
+
const fs_1 = require("fs");
|
|
44
47
|
const path = __importStar(require("path"));
|
|
45
48
|
const config_1 = require("../config");
|
|
46
49
|
function getOutDir() {
|
|
@@ -62,6 +65,20 @@ function getViewerStorePath() {
|
|
|
62
65
|
function getViewerAssetPath() {
|
|
63
66
|
return path.join(__dirname, '..', '..', 'assets', 'viewer.html');
|
|
64
67
|
}
|
|
68
|
+
function getEmptyViewerAssetPath() {
|
|
69
|
+
return path.join(__dirname, '..', '..', 'assets', 'empty.html');
|
|
70
|
+
}
|
|
71
|
+
const EMPTY_DOCS_FALLBACK = `<!doctype html><html lang="en"><head><meta charset="utf-8"/><title>Notary</title></head><body style="font:13px/1.45 system-ui;background:#fafafa;color:#111;margin:0;padding:48px 24px">
|
|
72
|
+
<p style="font:600 10px/1 ui-monospace,monospace;letter-spacing:.08em;text-transform:uppercase;color:#666">Waiting</p>
|
|
73
|
+
<h1 style="font-size:22px;letter-spacing:-.04em">No documentation yet</h1>
|
|
74
|
+
<p>Run your integration tests, then refresh this page.</p>
|
|
75
|
+
</body></html>`;
|
|
76
|
+
function readEmptyDocsHtml() {
|
|
77
|
+
const file = getEmptyViewerAssetPath();
|
|
78
|
+
if ((0, fs_1.existsSync)(file))
|
|
79
|
+
return (0, fs_1.readFileSync)(file);
|
|
80
|
+
return Buffer.from(EMPTY_DOCS_FALLBACK);
|
|
81
|
+
}
|
|
65
82
|
function getFaviconAssetPath() {
|
|
66
83
|
return path.join(__dirname, '..', '..', 'assets', 'favicon.png');
|
|
67
84
|
}
|