@t0.labs/daxta 0.4.21 → 0.4.23
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 +176 -0
- package/assets/viewer.html +594 -269
- package/dist/build/build-spec.js +37 -1
- 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/dist/build/build-spec.js
CHANGED
|
@@ -171,6 +171,42 @@ function exampleKeyForHit(hit, index) {
|
|
|
171
171
|
const base = slug(label, index);
|
|
172
172
|
return base ? `${base}-${index}` : `example-${index + 1}`;
|
|
173
173
|
}
|
|
174
|
+
function isSuccessStatus(status) {
|
|
175
|
+
return status >= 200 && status < 300;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Seed calls in the same it() share Jest's currentTestName.
|
|
179
|
+
* SEMANTIC: create-then-assert-409 must not surface the setup 201.
|
|
180
|
+
*/
|
|
181
|
+
function selectHitsForDocs(hits) {
|
|
182
|
+
const byTest = new Map();
|
|
183
|
+
const unlabeled = [];
|
|
184
|
+
for (const hit of hits) {
|
|
185
|
+
if (!hit.test) {
|
|
186
|
+
unlabeled.push(hit);
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
const list = byTest.get(hit.test) ?? [];
|
|
190
|
+
list.push(hit);
|
|
191
|
+
byTest.set(hit.test, list);
|
|
192
|
+
}
|
|
193
|
+
const selected = [...unlabeled];
|
|
194
|
+
for (const group of byTest.values()) {
|
|
195
|
+
const section = (0, catalog_1.parseCaseSection)(group[0]?.test);
|
|
196
|
+
if (section === 'semantic' || section === 'invalid' || section === 'omitted' || section === 'auth') {
|
|
197
|
+
const errors = group.filter((hit) => !isSuccessStatus(hit.status));
|
|
198
|
+
selected.push(...(errors.length ? errors : group));
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
if (section === 'positive') {
|
|
202
|
+
const ok = group.filter((hit) => isSuccessStatus(hit.status));
|
|
203
|
+
selected.push(...(ok.length ? ok : group));
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
selected.push(...group);
|
|
207
|
+
}
|
|
208
|
+
return selected;
|
|
209
|
+
}
|
|
174
210
|
function isPrimaryHit(hit) {
|
|
175
211
|
if (!hit.test)
|
|
176
212
|
return false;
|
|
@@ -460,7 +496,7 @@ function sortOperations(entries) {
|
|
|
460
496
|
}
|
|
461
497
|
function buildSpec(hits) {
|
|
462
498
|
const grouped = new Map();
|
|
463
|
-
for (const hit of hits.filter(isPrimaryHit)) {
|
|
499
|
+
for (const hit of selectHitsForDocs(hits.filter(isPrimaryHit))) {
|
|
464
500
|
const key = `${hit.method} ${hit.path}`;
|
|
465
501
|
const opHits = grouped.get(key) ?? [];
|
|
466
502
|
opHits.push(hit);
|
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
|
}
|