@t0.labs/daxta 1.1.2 → 1.1.3

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.
@@ -718,22 +718,24 @@ function mergeSpecs(existing, fresh) {
718
718
  function countOperations(spec) {
719
719
  return Object.values(spec.paths).reduce((count, pathItem) => count + Object.keys(pathItem).length, 0);
720
720
  }
721
+ function pngDataUri(filePath) {
722
+ return (0, fs_1.existsSync)(filePath) ? `data:image/png;base64,${(0, fs_1.readFileSync)(filePath).toString('base64')}` : '';
723
+ }
721
724
  function toStandaloneHtml(spec) {
722
725
  const template = (0, fs_1.readFileSync)((0, paths_1.getViewerAssetPath)(), 'utf8');
723
- const faviconPath = (0, paths_1.getFaviconAssetPath)();
724
- const faviconUri = (0, fs_1.existsSync)(faviconPath)
725
- ? `data:image/png;base64,${(0, fs_1.readFileSync)(faviconPath).toString('base64')}`
726
- : '';
726
+ const faviconUri = pngDataUri((0, paths_1.getFaviconAssetPath)());
727
+ const faviconLightUri = pngDataUri((0, paths_1.getFaviconLightAssetPath)()) || faviconUri;
727
728
  return template
728
729
  .replace('__SPEC_JSON__', JSON.stringify(spec).replace(/</g, '\\u003c'))
729
- .replaceAll('__FAVICON_DATA_URI__', faviconUri);
730
+ .replaceAll('__FAVICON_DATA_URI__', faviconUri)
731
+ .replaceAll('__FAVICON_LIGHT_DATA_URI__', faviconLightUri);
730
732
  }
731
733
  function viewerTemplateNewerThanHtml() {
732
734
  if (!(0, fs_1.existsSync)((0, paths_1.getHtmlPath)()))
733
735
  return true;
734
736
  const htmlMtime = (0, fs_1.statSync)((0, paths_1.getHtmlPath)()).mtimeMs;
735
737
  const newerThan = (filePath) => (0, fs_1.existsSync)(filePath) && (0, fs_1.statSync)(filePath).mtimeMs > htmlMtime;
736
- return newerThan((0, paths_1.getViewerAssetPath)()) || newerThan((0, paths_1.getFaviconAssetPath)());
738
+ return newerThan((0, paths_1.getViewerAssetPath)()) || newerThan((0, paths_1.getFaviconAssetPath)()) || newerThan((0, paths_1.getFaviconLightAssetPath)());
737
739
  }
738
740
  function applyViewerMeta(spec) {
739
741
  const info = specInfo();
@@ -13,21 +13,23 @@ async function pickFromSuggestions(finding, extra, validate) {
13
13
  if (extra)
14
14
  console.log(` ${ui_1.c.dim(extra)}`);
15
15
  if (!suggestions.length) {
16
- console.log(` ${ui_1.c.gold('no auto suggestion')} ${ui_1.c.dim('— type a title, or s to skip')}`);
16
+ console.log(` ${ui_1.c.gold('no auto suggestion')} ${ui_1.c.dim('— type a title, or s to skip one, n to skip all')}`);
17
17
  }
18
18
  suggestions.forEach((name, index) => {
19
19
  const mark = index === 0 ? ui_1.c.dim(' recommended') : '';
20
20
  console.log(` ${ui_1.c.ice(String(index + 1))} ${name}${mark}`);
21
21
  });
22
22
  console.log(suggestions.length
23
- ? ` ${ui_1.c.dim('Enter = 1')} ${ui_1.c.dim('·')} ${ui_1.c.ice('a')} remaining auto ${ui_1.c.dim('·')} ${ui_1.c.ice('s')} skip ${ui_1.c.dim('·')} ${ui_1.c.ice('c')} custom`
24
- : ` ${ui_1.c.ice('c')} custom ${ui_1.c.dim('·')} ${ui_1.c.ice('s')} skip`);
23
+ ? ` ${ui_1.c.dim('Enter = 1')} ${ui_1.c.dim('·')} ${ui_1.c.ice('a')} remaining auto ${ui_1.c.dim('·')} ${ui_1.c.ice('s')} skip one ${ui_1.c.dim('·')} ${ui_1.c.ice('n')} skip all ${ui_1.c.dim('·')} ${ui_1.c.ice('c')} custom`
24
+ : ` ${ui_1.c.ice('c')} custom ${ui_1.c.dim('·')} ${ui_1.c.ice('s')} skip one ${ui_1.c.dim('·')} ${ui_1.c.ice('n')} skip all`);
25
25
  const answer = (await (0, ui_1.readlineAsk)(` ${ui_1.c.ice('›')} `)).trim();
26
26
  const lower = answer.toLowerCase();
27
27
  if (!answer)
28
28
  return suggestions[0] ? suggestions[0] : 'skip';
29
29
  if (lower === 's')
30
30
  return 'skip';
31
+ if (lower === 'n' || lower === 'no' || lower === 'skip-all' || lower === 'skipall')
32
+ return 'skip-all';
31
33
  if (lower === 'a' || lower === 'all')
32
34
  return 'all';
33
35
  if (lower === 'y' || lower === 'yes')
@@ -133,7 +135,14 @@ async function runTitleCheck(options) {
133
135
  console.log(` ${ui_1.c.dim('it()+')} creates mock tbs when cyprus payload shape`);
134
136
  console.log(` ${ui_1.c.dim('it()-')} returns error when tax id already exists`);
135
137
  console.log(` ${ui_1.c.dim('label')} 201 — cyprus payload shape`);
136
- console.log(` ${ui_1.c.gold(String(total))} to review — ${ui_1.c.ice('y')} one recommended, ${ui_1.c.ice('a')} all remaining, ${ui_1.c.ice('s')} skip.`);
138
+ const start = await (0, ui_1.readlineAsk)(` ${ui_1.c.gold('?')} Review test names now?\n` +
139
+ ` ${ui_1.c.dim('Y')} yes · ${ui_1.c.dim('n')} skip all\n ${ui_1.c.ice('›')} `);
140
+ if (!start || /^n(o)?$/i.test(start)) {
141
+ console.log(` ${ui_1.c.dim('skipped')} ${ui_1.c.ice('daxta titles')} ${ui_1.c.dim('anytime')}`);
142
+ console.log('');
143
+ return 0;
144
+ }
145
+ console.log(` ${ui_1.c.gold(String(total))} to review — ${ui_1.c.ice('y')} one recommended, ${ui_1.c.ice('a')} all remaining, ${ui_1.c.ice('s')} skip one, ${ui_1.c.ice('n')} skip all.`);
137
146
  let written = 0;
138
147
  let skipped = 0;
139
148
  for (let i = 0; i < report.titles.length; i += 1) {
@@ -145,6 +154,14 @@ async function runTitleCheck(options) {
145
154
  skipped += rest.skipped;
146
155
  for (const pending of rest.pending) {
147
156
  const customChoice = await pickFromSuggestions(pending, `docs would show ${pending.path} — custom title required`, test_title_1.isHumanOperationTitle);
157
+ if (customChoice === 'skip-all') {
158
+ skipped += rest.pending.length;
159
+ console.log(` ${ui_1.c.dim('skipped remaining')}`);
160
+ console.log('');
161
+ console.log(` ${ui_1.c.mint('✔')} ${written} updated ${ui_1.c.dim(`${skipped} skipped`)}`);
162
+ console.log('');
163
+ return options.strict && skipped > 0 ? 1 : 0;
164
+ }
148
165
  if (!customChoice || customChoice === 'skip' || customChoice === 'all') {
149
166
  skipped += 1;
150
167
  continue;
@@ -161,6 +178,14 @@ async function runTitleCheck(options) {
161
178
  console.log('');
162
179
  return options.strict && skipped > 0 ? 1 : 0;
163
180
  }
181
+ if (choice === 'skip-all') {
182
+ skipped += report.titles.length - i + report.cases.length;
183
+ console.log(` ${ui_1.c.dim('skipped remaining')}`);
184
+ console.log('');
185
+ console.log(` ${ui_1.c.mint('✔')} ${written} updated ${ui_1.c.dim(`${skipped} skipped`)}`);
186
+ console.log('');
187
+ return options.strict && skipped > 0 ? 1 : 0;
188
+ }
164
189
  if (!choice || choice === 'skip') {
165
190
  skipped += 1;
166
191
  continue;
@@ -183,6 +208,11 @@ async function runTitleCheck(options) {
183
208
  skipped += rest.skipped;
184
209
  break;
185
210
  }
211
+ if (choice === 'skip-all') {
212
+ skipped += report.cases.length - i;
213
+ console.log(` ${ui_1.c.dim('skipped remaining')}`);
214
+ break;
215
+ }
186
216
  if (!choice || choice === 'skip') {
187
217
  skipped += 1;
188
218
  continue;
@@ -47,9 +47,18 @@ const path = __importStar(require("path"));
47
47
  require("reflect-metadata");
48
48
  const storage_1 = require("class-transformer/cjs/storage");
49
49
  const class_validator_1 = require("class-validator");
50
- const ts = __importStar(require("typescript"));
50
+ const tsImport = __importStar(require("typescript"));
51
51
  const config_1 = require("../config");
52
52
  const path_util_1 = require("../path.util");
53
+ function loadTypescript() {
54
+ const mod = tsImport;
55
+ if (mod.ScriptTarget && mod.ScriptTarget.Latest != null)
56
+ return mod;
57
+ if (mod.default?.ScriptTarget && mod.default.ScriptTarget.Latest != null)
58
+ return mod.default;
59
+ return mod;
60
+ }
61
+ const ts = loadTypescript();
53
62
  function controllerRoot() {
54
63
  return (0, config_1.getConfig)().controllersRoot;
55
64
  }
@@ -182,7 +191,8 @@ function loadDto(filePath, exportName) {
182
191
  }
183
192
  function parseController(filePath) {
184
193
  const text = (0, fs_1.readFileSync)(filePath, 'utf8');
185
- const source = ts.createSourceFile(filePath, text, ts.ScriptTarget.Latest, true);
194
+ const scriptTarget = ts.ScriptTarget?.Latest ?? 99;
195
+ const source = ts.createSourceFile(filePath, text, scriptTarget, true);
186
196
  const imports = collectImports(source, filePath);
187
197
  const routes = [];
188
198
  for (const stmt of source.statements) {
@@ -8,6 +8,7 @@ export declare function getViewerAssetPath(): string;
8
8
  export declare function getEmptyViewerAssetPath(): string;
9
9
  export declare function readEmptyDocsHtml(): Buffer;
10
10
  export declare function getFaviconAssetPath(): string;
11
+ export declare function getFaviconLightAssetPath(): string;
11
12
  export declare function getDocsBasePath(): string;
12
13
  /** App-origin URL where generated API docs are served (e.g. `http://localhost:3000/docs`). */
13
14
  export declare function getApiDocUrl(): string;
@@ -42,6 +42,7 @@ exports.getViewerAssetPath = getViewerAssetPath;
42
42
  exports.getEmptyViewerAssetPath = getEmptyViewerAssetPath;
43
43
  exports.readEmptyDocsHtml = readEmptyDocsHtml;
44
44
  exports.getFaviconAssetPath = getFaviconAssetPath;
45
+ exports.getFaviconLightAssetPath = getFaviconLightAssetPath;
45
46
  exports.getDocsBasePath = getDocsBasePath;
46
47
  exports.getApiDocUrl = getApiDocUrl;
47
48
  exports.getApiDocs = getApiDocs;
@@ -82,8 +83,14 @@ function readEmptyDocsHtml() {
82
83
  return Buffer.from(EMPTY_DOCS_FALLBACK);
83
84
  }
84
85
  function getFaviconAssetPath() {
86
+ const dark = path.join(__dirname, '..', '..', 'assets', 'logo-dark.png');
87
+ if ((0, fs_1.existsSync)(dark))
88
+ return dark;
85
89
  return path.join(__dirname, '..', '..', 'assets', 'favicon.png');
86
90
  }
91
+ function getFaviconLightAssetPath() {
92
+ return path.join(__dirname, '..', '..', 'assets', 'logo-light.png');
93
+ }
87
94
  function getDocsBasePath() {
88
95
  return (0, config_1.normalizeDocsPath)(process.env.DAXTA_DOCS_PATH || (0, config_1.getConfig)().docsPath || config_1.DEFAULT_DOCS_PATH);
89
96
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t0.labs/daxta",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "DAxTA — Tested behavior. Trusted API docs. Generate API documentation from observed test execution.",
5
5
  "license": "MIT",
6
6
  "author": {