@t0.labs/daxta 0.4.16 → 0.4.18

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/dist/cli/ui.js CHANGED
@@ -1,13 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.c = void 0;
3
+ exports.c = exports.tone = void 0;
4
4
  exports.sleep = sleep;
5
+ exports.divider = divider;
6
+ exports.splash = splash;
5
7
  exports.banner = banner;
8
+ exports.phase = phase;
9
+ exports.askLine = askLine;
10
+ exports.readlineAsk = readlineAsk;
6
11
  exports.step = step;
7
12
  exports.box = box;
8
13
  exports.nextSteps = nextSteps;
14
+ const readline_1 = require("readline");
9
15
  const isTTY = Boolean(process.stdout.isTTY);
10
16
  const useColor = isTTY && !process.env.NO_COLOR && process.env.FORCE_COLOR !== '0';
17
+ const truecolor = useColor && Boolean(process.env.COLORTERM || process.env.TERM_PROGRAM);
11
18
  const ansi = {
12
19
  reset: '\x1b[0m',
13
20
  bold: '\x1b[1m',
@@ -17,12 +24,29 @@ const ansi = {
17
24
  yellow: '\x1b[33m',
18
25
  magenta: '\x1b[35m',
19
26
  red: '\x1b[31m',
27
+ white: '\x1b[37m',
20
28
  };
21
29
  function paint(code, text) {
22
30
  if (!useColor)
23
31
  return text;
24
32
  return `${code}${text}${ansi.reset}`;
25
33
  }
34
+ function rgb(r, g, b, text) {
35
+ if (!useColor)
36
+ return text;
37
+ if (!truecolor)
38
+ return paint(ansi.cyan, text);
39
+ return `\x1b[38;2;${r};${g};${b}m${text}${ansi.reset}`;
40
+ }
41
+ /** Viewer-adjacent palette: ice, gold, mint, stone. */
42
+ exports.tone = {
43
+ ice: (t) => rgb(125, 211, 252, t),
44
+ gold: (t) => rgb(232, 192, 122, t),
45
+ mint: (t) => rgb(52, 211, 153, t),
46
+ rose: (t) => rgb(251, 113, 133, t),
47
+ mist: (t) => rgb(148, 163, 184, t),
48
+ paper: (t) => rgb(248, 250, 252, t),
49
+ };
26
50
  exports.c = {
27
51
  bold: (t) => paint(ansi.bold, t),
28
52
  dim: (t) => paint(ansi.dim, t),
@@ -31,33 +55,84 @@ exports.c = {
31
55
  yellow: (t) => paint(ansi.yellow, t),
32
56
  magenta: (t) => paint(ansi.magenta, t),
33
57
  red: (t) => paint(ansi.red, t),
58
+ ice: exports.tone.ice,
59
+ gold: exports.tone.gold,
60
+ mint: exports.tone.mint,
34
61
  };
35
62
  function sleep(ms) {
36
63
  return new Promise((resolve) => setTimeout(resolve, ms));
37
64
  }
65
+ function bar(done, total, width = 16) {
66
+ const n = Math.max(1, total);
67
+ const filled = Math.round((done / n) * width);
68
+ const on = '━'.repeat(Math.max(0, filled));
69
+ const off = '─'.repeat(Math.max(0, width - filled));
70
+ return `${exports.tone.ice(on)}${exports.c.dim(off)}`;
71
+ }
72
+ function divider(width = 52) {
73
+ console.log(` ${exports.c.dim('─'.repeat(width))}`);
74
+ }
75
+ function splash(options) {
76
+ const title = 'DAxTA';
77
+ const tag = 'Document API × Test API';
78
+ const meta = `v${options.version} · ${options.project}${options.dryRun ? ' · dry-run' : ''}`;
79
+ const inner = 50;
80
+ const pad = (s) => s + ' '.repeat(Math.max(0, inner - s.length));
81
+ const top = ` ${exports.c.dim('╭' + '─'.repeat(inner + 2) + '╮')}`;
82
+ const bot = ` ${exports.c.dim('╰' + '─'.repeat(inner + 2) + '╯')}`;
83
+ const row = (body) => ` ${exports.c.dim('│')} ${body}${exports.c.dim(' │')}`;
84
+ console.log('');
85
+ console.log(top);
86
+ console.log(row(exports.c.bold(exports.tone.ice(pad(title)))));
87
+ console.log(row(exports.tone.mist(pad(tag))));
88
+ console.log(row(exports.c.dim(pad(meta))));
89
+ console.log(bot);
90
+ console.log('');
91
+ }
38
92
  function banner(title, subtitle) {
39
93
  console.log('');
40
- console.log(`${exports.c.cyan(exports.c.bold('◆'))} ${exports.c.bold(title)}${subtitle ? exports.c.dim(` ${subtitle}`) : ''}`);
41
- console.log(exports.c.dim('─'.repeat(Math.min(56, Math.max(28, title.length + 10)))));
94
+ console.log(` ${exports.tone.ice('◆')} ${exports.c.bold(title)}${subtitle ? exports.tone.mist(` ${subtitle}`) : ''}`);
95
+ divider(Math.min(52, Math.max(32, title.length + 12)));
96
+ }
97
+ function phase(index, total, label, hint) {
98
+ console.log('');
99
+ const mark = String(index).padStart(2, '0');
100
+ console.log(` ${exports.tone.gold(mark)}${exports.c.dim(`/${String(total).padStart(2, '0')}`)} ${bar(index, total)} ${exports.c.bold(label)}`);
101
+ if (hint)
102
+ console.log(` ${exports.tone.mist(hint)}`);
103
+ console.log('');
104
+ }
105
+ function askLine(label, hint) {
106
+ const q = `${exports.tone.gold('?')} ${exports.c.bold(label)}${hint ? exports.tone.mist(` — ${hint}`) : ''}`;
107
+ return ` ${q}\n ${exports.tone.ice('›')} `;
108
+ }
109
+ function readlineAsk(question) {
110
+ const rl = (0, readline_1.createInterface)({ input: process.stdin, output: process.stdout });
111
+ return new Promise((resolve) => {
112
+ rl.question(question, (answer) => {
113
+ rl.close();
114
+ resolve(answer.trim());
115
+ });
116
+ });
42
117
  }
43
- /**
44
- * Spinner while work runs → ✔ / ✖, optional detail lines, then a short pause to read.
45
- */
46
118
  async function step(label, work, options = {}) {
47
119
  const paceMs = options.paceMs ?? 0;
48
120
  const useSpinner = options.spinner !== false && isTTY;
49
121
  const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
50
122
  let i = 0;
51
123
  let timer;
124
+ const prefix = options.n != null && options.of != null
125
+ ? `${exports.c.dim(String(options.n).padStart(2, ' ') + '/' + options.of)} `
126
+ : ' ';
52
127
  if (useSpinner) {
53
- process.stdout.write(` ${exports.c.cyan(frames[0])} ${label}`);
128
+ process.stdout.write(` ${prefix}${exports.tone.ice(frames[0])} ${label}`);
54
129
  timer = setInterval(() => {
55
130
  i = (i + 1) % frames.length;
56
- process.stdout.write(`\r ${exports.c.cyan(frames[i])} ${label}`);
57
- }, 80);
131
+ process.stdout.write(`\r ${prefix}${exports.tone.ice(frames[i])} ${label}`);
132
+ }, 70);
58
133
  }
59
134
  else {
60
- console.log(` ${exports.c.cyan('▶')} ${label}`);
135
+ console.log(` ${prefix}${exports.tone.ice('▸')} ${label}`);
61
136
  }
62
137
  try {
63
138
  const result = await work();
@@ -71,13 +146,14 @@ async function step(label, work, options = {}) {
71
146
  summary = result.summary;
72
147
  details = result.details ?? [];
73
148
  }
74
- const line = summary ? `${label} ${exports.c.dim(summary)}` : label;
149
+ const line = summary ? `${label} ${exports.tone.mist(summary)}` : label;
150
+ const ok = `${prefix}${exports.tone.mint('✔')} ${line}`;
75
151
  if (useSpinner)
76
- process.stdout.write(`\r ${exports.c.green('✔')} ${line}${' '.repeat(12)}\n`);
152
+ process.stdout.write(`\r ${ok}${' '.repeat(16)}\n`);
77
153
  else
78
- console.log(` ${exports.c.green('✔')} ${line}`);
154
+ console.log(` ${ok}`);
79
155
  for (const d of details) {
80
- console.log(` ${exports.c.dim('→')} ${d}`);
156
+ console.log(` ${exports.c.dim('·')} ${d}`);
81
157
  }
82
158
  if (paceMs > 0)
83
159
  await sleep(paceMs);
@@ -86,26 +162,34 @@ async function step(label, work, options = {}) {
86
162
  if (timer)
87
163
  clearInterval(timer);
88
164
  const msg = error instanceof Error ? error.message : String(error);
165
+ const fail = `${prefix}${exports.tone.rose('✖')} ${label} ${exports.c.red(msg)}`;
89
166
  if (useSpinner)
90
- process.stdout.write(`\r ${exports.c.red('✖')} ${label} ${exports.c.red(msg)}${' '.repeat(8)}\n`);
167
+ process.stdout.write(`\r ${fail}${' '.repeat(8)}\n`);
91
168
  else
92
- console.log(` ${exports.c.red('✖')} ${label} ${msg}`);
169
+ console.log(` ${fail}`);
93
170
  throw error;
94
171
  }
95
172
  }
96
173
  function box(title, lines) {
174
+ const width = 58;
97
175
  console.log('');
98
- console.log(` ${exports.c.magenta(exports.c.bold(title))}`);
176
+ console.log(` ${exports.c.dim('╭' + '─'.repeat(width) + '╮')}`);
177
+ console.log(` ${exports.c.dim('│')} ${exports.c.bold(exports.tone.mint(title.padEnd(width - 1)))}${exports.c.dim('│')}`);
178
+ console.log(` ${exports.c.dim('│' + ' '.repeat(width) + '│')}`);
99
179
  for (const line of lines) {
100
- console.log(` ${exports.c.dim('│')} ${line}`);
180
+ const visible = line.replace(/\x1b\[[0-9;]*m/g, '');
181
+ const pad = Math.max(0, width - 1 - visible.length);
182
+ console.log(` ${exports.c.dim('│')} ${line}${' '.repeat(pad)}${exports.c.dim('│')}`);
101
183
  }
184
+ console.log(` ${exports.c.dim('╰' + '─'.repeat(width) + '╯')}`);
102
185
  console.log('');
103
186
  }
104
187
  function nextSteps(lines) {
105
- console.log(` ${exports.c.bold('Next')}`);
106
- for (const { cmd, why } of lines) {
107
- console.log(` ${exports.c.cyan('$')} ${exports.c.bold(cmd)}`);
108
- console.log(` ${exports.c.dim(why)}`);
109
- }
188
+ console.log(` ${exports.c.bold(exports.tone.ice('Next'))}`);
110
189
  console.log('');
190
+ lines.forEach((item, index) => {
191
+ console.log(` ${exports.tone.gold(String(index + 1) + '.')} ${exports.c.bold('$')} ${exports.c.bold(item.cmd)}`);
192
+ console.log(` ${exports.tone.mist(item.why)}`);
193
+ console.log('');
194
+ });
111
195
  }
@@ -34,7 +34,6 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.uninstallDaxta = uninstallDaxta;
37
- const readline_1 = require("readline");
38
37
  const fs_1 = require("fs");
39
38
  const path = __importStar(require("path"));
40
39
  const child_process_1 = require("child_process");
@@ -48,15 +47,6 @@ function readJson(filePath) {
48
47
  function writeJson(filePath, value) {
49
48
  (0, fs_1.writeFileSync)(filePath, `${JSON.stringify(value, null, 2)}\n`);
50
49
  }
51
- function prompt(question) {
52
- const rl = (0, readline_1.createInterface)({ input: process.stdin, output: process.stdout });
53
- return new Promise((resolve) => {
54
- rl.question(question, (answer) => {
55
- rl.close();
56
- resolve(answer.trim());
57
- });
58
- });
59
- }
60
50
  function detectPackageManager(cwd, pkg) {
61
51
  if ((0, fs_1.existsSync)(path.join(cwd, 'pnpm-lock.yaml')) || pkg.packageManager?.startsWith('pnpm'))
62
52
  return 'pnpm';
@@ -146,8 +136,8 @@ async function uninstallDaxta(options = {}) {
146
136
  const pm = detectPackageManager(cwd, pkg);
147
137
  (0, ui_1.banner)('DAxTA uninstall', project);
148
138
  if (!options.yes && process.stdin.isTTY) {
149
- const answer = await prompt(` ${ui_1.c.yellow('?')} Remove DAxTA from ${ui_1.c.bold(project)}?\n` +
150
- ` ${ui_1.c.dim('Y')} yes · ${ui_1.c.dim('n')} cancel\n ${ui_1.c.cyan('›')} `);
139
+ const answer = await (0, ui_1.readlineAsk)(` ${ui_1.c.gold('?')} Remove DAxTA from ${ui_1.c.bold(project)}?\n` +
140
+ ` ${ui_1.c.dim('Y yes · n cancel')}\n ${ui_1.c.ice('›')} `);
151
141
  if (answer && !/^y(es)?$/i.test(answer)) {
152
142
  console.log(` ${ui_1.c.dim('cancelled')}`);
153
143
  return;
@@ -274,8 +264,8 @@ async function uninstallDaxta(options = {}) {
274
264
  await (0, ui_1.step)('Package dependency', () => 'not listed — skip', { paceMs });
275
265
  }
276
266
  }
277
- (0, ui_1.box)('Done', [
278
- `${ui_1.c.green('✔')} DAxTA removed from ${ui_1.c.bold(project)}`,
267
+ (0, ui_1.box)('Removed', [
268
+ `${ui_1.c.mint('✔')} DAxTA unwound from ${ui_1.c.bold(project)}`,
279
269
  `${ui_1.c.dim('check')} Nest main + Jest config if anything custom remained`,
280
270
  ]);
281
271
  }
package/dist/index.d.ts CHANGED
@@ -6,5 +6,5 @@ export { dtoRequired, type FieldLocation } from './fields/dto-fields';
6
6
  export { buildFieldsFile, writeFieldsFile, readFieldsFile, type FieldsFile } from './fields/export-fields';
7
7
  export { apiDocs, apiDocsHandler, serveApiDocs, getDocsBasePath, getHtmlPath, getOutDir, getSpecJsonPath, type ApiDocsHandler, type ApiDocsOptions, } from './serve';
8
8
  export { runInteractiveCall, runFileCall, executeCall, type CallValues } from './call';
9
- export { apiTitle, parseOperationLabel, suggestOperationTitles, formatTestTitle, isValidItCase, suggestItCases, type FieldDoc, type OperationDoc, } from './catalog';
9
+ export { apiTitle, parseOperationLabel, suggestOperationTitles, suggestOperationTitleResult, formatTestTitle, isValidItCase, suggestItCases, type FieldDoc, type OperationDoc, } from './catalog';
10
10
  export { installDaxta, type InstallOptions } from './cli/install';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.installDaxta = exports.suggestItCases = exports.isValidItCase = exports.formatTestTitle = exports.suggestOperationTitles = exports.parseOperationLabel = exports.apiTitle = exports.executeCall = exports.runFileCall = exports.runInteractiveCall = exports.getSpecJsonPath = exports.getOutDir = exports.getHtmlPath = exports.getDocsBasePath = exports.serveApiDocs = exports.apiDocsHandler = exports.apiDocs = exports.readFieldsFile = exports.writeFieldsFile = exports.buildFieldsFile = exports.dtoRequired = exports.getHits = exports.clearWorkerHits = exports.flush = exports.install = exports.touchPartialMarker = exports.clearPartialMarker = exports.flushAndRebuild = exports.rebuildFromDisk = exports.loadHits = exports.buildOpenApi = exports.buildDaxtaSpec = exports.normalizeTreeLayout = exports.resolveConfig = exports.getConfig = exports.defineConfig = void 0;
3
+ exports.installDaxta = exports.suggestItCases = exports.isValidItCase = exports.formatTestTitle = exports.suggestOperationTitleResult = exports.suggestOperationTitles = exports.parseOperationLabel = exports.apiTitle = exports.executeCall = exports.runFileCall = exports.runInteractiveCall = exports.getSpecJsonPath = exports.getOutDir = exports.getHtmlPath = exports.getDocsBasePath = exports.serveApiDocs = exports.apiDocsHandler = exports.apiDocs = exports.readFieldsFile = exports.writeFieldsFile = exports.buildFieldsFile = exports.dtoRequired = exports.getHits = exports.clearWorkerHits = exports.flush = exports.install = exports.touchPartialMarker = exports.clearPartialMarker = exports.flushAndRebuild = exports.rebuildFromDisk = exports.loadHits = exports.buildOpenApi = exports.buildDaxtaSpec = exports.normalizeTreeLayout = exports.resolveConfig = exports.getConfig = exports.defineConfig = void 0;
4
4
  var config_1 = require("./config");
5
5
  Object.defineProperty(exports, "defineConfig", { enumerable: true, get: function () { return config_1.defineConfig; } });
6
6
  Object.defineProperty(exports, "getConfig", { enumerable: true, get: function () { return config_1.getConfig; } });
@@ -42,6 +42,7 @@ var catalog_1 = require("./catalog");
42
42
  Object.defineProperty(exports, "apiTitle", { enumerable: true, get: function () { return catalog_1.apiTitle; } });
43
43
  Object.defineProperty(exports, "parseOperationLabel", { enumerable: true, get: function () { return catalog_1.parseOperationLabel; } });
44
44
  Object.defineProperty(exports, "suggestOperationTitles", { enumerable: true, get: function () { return catalog_1.suggestOperationTitles; } });
45
+ Object.defineProperty(exports, "suggestOperationTitleResult", { enumerable: true, get: function () { return catalog_1.suggestOperationTitleResult; } });
45
46
  Object.defineProperty(exports, "formatTestTitle", { enumerable: true, get: function () { return catalog_1.formatTestTitle; } });
46
47
  Object.defineProperty(exports, "isValidItCase", { enumerable: true, get: function () { return catalog_1.isValidItCase; } });
47
48
  Object.defineProperty(exports, "suggestItCases", { enumerable: true, get: function () { return catalog_1.suggestItCases; } });
@@ -8,6 +8,7 @@ export type TitleFinding = {
8
8
  path: string;
9
9
  method: string;
10
10
  suggestions: string[];
11
+ auto: boolean;
11
12
  };
12
13
  export declare function scanMissingTitles(cwd?: string): TitleFinding[];
13
14
  export declare function applyTitle(cwd: string, finding: TitleFinding, title: string): boolean;
@@ -126,6 +126,7 @@ function scanMissingTitles(cwd = process.cwd()) {
126
126
  const parsed = (0, test_title_1.parseOperationLabel)(body);
127
127
  if (!parsed || parsed.title)
128
128
  continue;
129
+ const suggestion = (0, test_title_1.suggestOperationTitleResult)(parsed.method, parsed.path);
129
130
  findings.push({
130
131
  file: rel,
131
132
  line: index + 1,
@@ -134,7 +135,8 @@ function scanMissingTitles(cwd = process.cwd()) {
134
135
  quote,
135
136
  path: parsed.path,
136
137
  method: parsed.method,
137
- suggestions: (0, test_title_1.suggestOperationTitles)(parsed.method, parsed.path),
138
+ suggestions: suggestion.titles,
139
+ auto: suggestion.auto,
138
140
  });
139
141
  }
140
142
  });
@@ -165,14 +167,17 @@ function printTitleFindings(findings, paint) {
165
167
  return;
166
168
  console.log('');
167
169
  console.log(` ${paint.yellow('!')} ${paint.bold(`${findings.length} test title(s) missing a human name`)} ${paint.dim('(docs would show the path)')}`);
168
- console.log(` ${paint.dim('Format:')} ${paint.cyan('Create Mock Tbs /v1/admin/mock-tbs [POST] (integration)')}`);
170
+ console.log(` ${paint.dim('Format:')} ${paint.cyan('Create Mock Tbs — POST /v1/admin/mock-tbs')}`);
169
171
  for (const item of findings) {
170
172
  console.log('');
171
173
  console.log(` ${paint.cyan(item.file)}${paint.dim(`:${item.line}:${item.column}`)}`);
172
174
  console.log(` ${paint.dim(item.raw)}`);
173
- if (item.suggestions.length) {
175
+ if (item.suggestions.length && item.auto) {
174
176
  console.log(` ${paint.dim('suggest')} ${item.suggestions.map((name, i) => `${i + 1}:${name}`).join(' ')}`);
175
177
  }
178
+ else {
179
+ console.log(` ${paint.yellow('custom title required')} ${paint.dim('(Create Bulk / Validate … — not applied by --yes)')}`);
180
+ }
176
181
  }
177
182
  console.log('');
178
183
  console.log(` ${paint.dim('Fix interactively:')} ${paint.cyan('daxta titles')}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t0.labs/daxta",
3
- "version": "0.4.16",
3
+ "version": "0.4.18",
4
4
  "description": "DAxTA \u2014 docs from Nest integration traffic + DTO field CLI / Try-it",
5
5
  "license": "MIT",
6
6
  "repository": {