@t0.labs/daxta 1.1.4 → 1.1.6

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.
@@ -779,17 +779,33 @@
779
779
  margin: 0 4px 6px 18px;
780
780
  }
781
781
  .nav-op.examples-open > .nav-examples { display: flex; }
782
- .nav-ex-group { display: flex; flex-direction: column; gap: 1px; }
782
+ .nav-ex-group { display: flex; flex-direction: column; gap: 0; }
783
783
  .nav-ex-group-label {
784
784
  display: flex;
785
785
  align-items: center;
786
786
  justify-content: space-between;
787
787
  gap: 8px;
788
- padding: 6px 8px 2px;
788
+ padding: 6px 0 2px 4px;
789
789
  font: 600 10px/1.2 var(--sans);
790
790
  letter-spacing: 0.02em;
791
791
  color: var(--stone);
792
792
  }
793
+ .nav-ex-group-label.ok { color: var(--ok); }
794
+ .nav-ex-group-label.warn { color: var(--warn); }
795
+ .nav-ex-group-label.omit { color: var(--accent); }
796
+ .nav-ex-group-label.err { color: var(--err); }
797
+ .nav-ex-items {
798
+ display: flex;
799
+ flex-direction: column;
800
+ gap: 1px;
801
+ margin-left: 4px;
802
+ padding-left: 8px;
803
+ border-left: 1px solid var(--hairline);
804
+ }
805
+ .nav-ex-group.ok > .nav-ex-items { border-left-color: color-mix(in srgb, var(--ok) 40%, var(--hairline)); }
806
+ .nav-ex-group.warn > .nav-ex-items { border-left-color: color-mix(in srgb, var(--warn) 40%, var(--hairline)); }
807
+ .nav-ex-group.omit > .nav-ex-items { border-left-color: color-mix(in srgb, var(--accent) 40%, var(--hairline)); }
808
+ .nav-ex-group.err > .nav-ex-items { border-left-color: color-mix(in srgb, var(--err) 40%, var(--hairline)); }
793
809
  .nav-ex-count {
794
810
  font: 600 10px/1.4 var(--mono);
795
811
  color: inherit;
@@ -1090,10 +1106,15 @@
1090
1106
  color: var(--stone);
1091
1107
  }
1092
1108
  .export-group-items {
1093
- margin-left: 8px;
1109
+ /* Lines the rail up with the parent checkbox: 2px pad + 14px toggle + 8px gap. */
1110
+ margin-left: 24px;
1094
1111
  padding-left: 8px;
1095
1112
  border-left: 1px solid var(--hairline);
1096
1113
  }
1114
+ .export-group.ok > .export-group-items { border-left-color: color-mix(in srgb, var(--ok) 40%, var(--hairline)); }
1115
+ .export-group.warn > .export-group-items { border-left-color: color-mix(in srgb, var(--warn) 40%, var(--hairline)); }
1116
+ .export-group.omit > .export-group-items { border-left-color: color-mix(in srgb, var(--accent) 40%, var(--hairline)); }
1117
+ .export-group.err > .export-group-items { border-left-color: color-mix(in srgb, var(--err) 40%, var(--hairline)); }
1097
1118
  .export-group.collapsed > .export-group-items { display: none; }
1098
1119
  .export-group-toggle {
1099
1120
  display: inline-flex;
@@ -3189,7 +3210,7 @@
3189
3210
  </button>
3190
3211
  <div class="export-op-groups">${grouped
3191
3212
  .map(
3192
- ({ section, examples: rows }) => `<div class="export-group collapsed">
3213
+ ({ section, examples: rows }) => `<div class="export-group collapsed ${groupTone(section)}">
3193
3214
  <label class="export-group-head ${groupTone(section)}">
3194
3215
  <button type="button" class="export-group-toggle" aria-expanded="false" title="Show examples"><span class="chev"></span></button>
3195
3216
  <input type="checkbox" class="export-group-check" checked />
@@ -3639,14 +3660,14 @@
3639
3660
  const { groups, order } = groupScenarios(item.scenarios);
3640
3661
  return `<div class="nav-examples">${order
3641
3662
  .map(
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]
3663
+ (group) => `<div class="nav-ex-group ${groupTone(group)}">
3664
+ <div class="nav-ex-group-label ${groupTone(group)}"><span>${escapeHtml(displayGroup(group))}</span><span class="nav-ex-count">${groups[group].length}</span></div>
3665
+ <div class="nav-ex-items">${groups[group]
3645
3666
  .map(
3646
3667
  ({ scenario, index }) =>
3647
3668
  `<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>`,
3648
3669
  )
3649
- .join("")}
3670
+ .join("")}</div>
3650
3671
  </div>`,
3651
3672
  )
3652
3673
  .join("")}</div>`;
@@ -779,17 +779,33 @@
779
779
  margin: 0 4px 6px 18px;
780
780
  }
781
781
  .nav-op.examples-open > .nav-examples { display: flex; }
782
- .nav-ex-group { display: flex; flex-direction: column; gap: 1px; }
782
+ .nav-ex-group { display: flex; flex-direction: column; gap: 0; }
783
783
  .nav-ex-group-label {
784
784
  display: flex;
785
785
  align-items: center;
786
786
  justify-content: space-between;
787
787
  gap: 8px;
788
- padding: 6px 8px 2px;
788
+ padding: 6px 0 2px 4px;
789
789
  font: 600 10px/1.2 var(--sans);
790
790
  letter-spacing: 0.02em;
791
791
  color: var(--stone);
792
792
  }
793
+ .nav-ex-group-label.ok { color: var(--ok); }
794
+ .nav-ex-group-label.warn { color: var(--warn); }
795
+ .nav-ex-group-label.omit { color: var(--accent); }
796
+ .nav-ex-group-label.err { color: var(--err); }
797
+ .nav-ex-items {
798
+ display: flex;
799
+ flex-direction: column;
800
+ gap: 1px;
801
+ margin-left: 4px;
802
+ padding-left: 8px;
803
+ border-left: 1px solid var(--hairline);
804
+ }
805
+ .nav-ex-group.ok > .nav-ex-items { border-left-color: color-mix(in srgb, var(--ok) 40%, var(--hairline)); }
806
+ .nav-ex-group.warn > .nav-ex-items { border-left-color: color-mix(in srgb, var(--warn) 40%, var(--hairline)); }
807
+ .nav-ex-group.omit > .nav-ex-items { border-left-color: color-mix(in srgb, var(--accent) 40%, var(--hairline)); }
808
+ .nav-ex-group.err > .nav-ex-items { border-left-color: color-mix(in srgb, var(--err) 40%, var(--hairline)); }
793
809
  .nav-ex-count {
794
810
  font: 600 10px/1.4 var(--mono);
795
811
  color: inherit;
@@ -1090,10 +1106,15 @@
1090
1106
  color: var(--stone);
1091
1107
  }
1092
1108
  .export-group-items {
1093
- margin-left: 8px;
1109
+ /* Lines the rail up with the parent checkbox: 2px pad + 14px toggle + 8px gap. */
1110
+ margin-left: 24px;
1094
1111
  padding-left: 8px;
1095
1112
  border-left: 1px solid var(--hairline);
1096
1113
  }
1114
+ .export-group.ok > .export-group-items { border-left-color: color-mix(in srgb, var(--ok) 40%, var(--hairline)); }
1115
+ .export-group.warn > .export-group-items { border-left-color: color-mix(in srgb, var(--warn) 40%, var(--hairline)); }
1116
+ .export-group.omit > .export-group-items { border-left-color: color-mix(in srgb, var(--accent) 40%, var(--hairline)); }
1117
+ .export-group.err > .export-group-items { border-left-color: color-mix(in srgb, var(--err) 40%, var(--hairline)); }
1097
1118
  .export-group.collapsed > .export-group-items { display: none; }
1098
1119
  .export-group-toggle {
1099
1120
  display: inline-flex;
@@ -3189,7 +3210,7 @@
3189
3210
  </button>
3190
3211
  <div class="export-op-groups">${grouped
3191
3212
  .map(
3192
- ({ section, examples: rows }) => `<div class="export-group collapsed">
3213
+ ({ section, examples: rows }) => `<div class="export-group collapsed ${groupTone(section)}">
3193
3214
  <label class="export-group-head ${groupTone(section)}">
3194
3215
  <button type="button" class="export-group-toggle" aria-expanded="false" title="Show examples"><span class="chev"></span></button>
3195
3216
  <input type="checkbox" class="export-group-check" checked />
@@ -3639,14 +3660,14 @@
3639
3660
  const { groups, order } = groupScenarios(item.scenarios);
3640
3661
  return `<div class="nav-examples">${order
3641
3662
  .map(
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]
3663
+ (group) => `<div class="nav-ex-group ${groupTone(group)}">
3664
+ <div class="nav-ex-group-label ${groupTone(group)}"><span>${escapeHtml(displayGroup(group))}</span><span class="nav-ex-count">${groups[group].length}</span></div>
3665
+ <div class="nav-ex-items">${groups[group]
3645
3666
  .map(
3646
3667
  ({ scenario, index }) =>
3647
3668
  `<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>`,
3648
3669
  )
3649
- .join("")}
3670
+ .join("")}</div>
3650
3671
  </div>`,
3651
3672
  )
3652
3673
  .join("")}</div>`;
@@ -43,6 +43,7 @@ exports.dtoRequired = dtoRequired;
43
43
  * only to read reflect-metadata / class-validator / class-transformer.
44
44
  */
45
45
  const fs_1 = require("fs");
46
+ const module_1 = require("module");
46
47
  const path = __importStar(require("path"));
47
48
  require("reflect-metadata");
48
49
  const storage_1 = require("class-transformer/cjs/storage");
@@ -50,31 +51,48 @@ const class_validator_1 = require("class-validator");
50
51
  const tsImport = __importStar(require("typescript"));
51
52
  const config_1 = require("../config");
52
53
  const path_util_1 = require("../path.util");
53
- function loadTypescript() {
54
- const mod = tsImport;
55
- const candidates = [];
56
- if (mod)
57
- candidates.push(mod);
58
- if (mod.default)
59
- candidates.push(mod.default);
60
- for (const candidate of candidates) {
61
- if (typeof candidate.createSourceFile === 'function')
62
- return candidate;
63
- }
64
- try {
65
- // CJS interop: namespace import can expose enums without compiler APIs.
66
- // eslint-disable-next-line @typescript-eslint/no-require-imports
67
- const req = require('typescript');
68
- const fromReq = typeof req.createSourceFile === 'function' ? req : req.default;
69
- if (fromReq && typeof fromReq.createSourceFile === 'function')
70
- return fromReq;
54
+ let ts;
55
+ let tsResolved;
56
+ function withCompilerApi(candidate) {
57
+ const mod = candidate;
58
+ if (mod && typeof mod.createSourceFile === 'function')
59
+ return mod;
60
+ if (mod?.default && typeof mod.default.createSourceFile === 'function')
61
+ return mod.default;
62
+ return undefined;
63
+ }
64
+ function resolveTypescript() {
65
+ const direct = withCompilerApi(tsImport);
66
+ if (direct)
67
+ return direct;
68
+ // A hoisted copy can be the native TS 7 build, which ships a reduced JS surface
69
+ // without createSourceFile. Fall back to whatever the host project installed.
70
+ for (const from of [process.cwd(), __dirname]) {
71
+ try {
72
+ const loaded = (0, module_1.createRequire)(path.join(from, 'index.js'))('typescript');
73
+ const usable = withCompilerApi(loaded);
74
+ if (usable)
75
+ return usable;
76
+ }
77
+ catch {
78
+ // keep looking
79
+ }
71
80
  }
72
- catch {
73
- // ignore — fall through
81
+ return null;
82
+ }
83
+ /** Controller parsing is best-effort: without a usable compiler API we skip it. */
84
+ function ensureTypescript() {
85
+ if (tsResolved === undefined) {
86
+ tsResolved = resolveTypescript();
87
+ if (!tsResolved) {
88
+ console.warn('DAxTA: TypeScript compiler API unavailable (needs typescript >=4.9 <7) — skipping controller parsing; required/optional flags will be omitted.');
89
+ }
74
90
  }
75
- throw new Error('Could not load TypeScript compiler API (createSourceFile missing)');
91
+ if (!tsResolved)
92
+ return false;
93
+ ts = tsResolved;
94
+ return true;
76
95
  }
77
- const ts = loadTypescript();
78
96
  function controllerRoot() {
79
97
  return (0, config_1.getConfig)().controllersRoot;
80
98
  }
@@ -292,6 +310,8 @@ function parseController(filePath) {
292
310
  function getRoutes() {
293
311
  if (routeCache)
294
312
  return routeCache;
313
+ if (!ensureTypescript())
314
+ return (routeCache = []);
295
315
  const files = walkFiles(controllerRoot(), '.controller.ts');
296
316
  routeCache = files.flatMap((file) => {
297
317
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t0.labs/daxta",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "description": "DAxTA — Tested behavior. Trusted API docs. Generate API documentation from observed test execution.",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -78,7 +78,7 @@
78
78
  "class-transformer": ">=0.5.0",
79
79
  "class-validator": ">=0.14.0",
80
80
  "reflect-metadata": ">=0.1.13",
81
- "typescript": ">=4.9.0",
81
+ "typescript": ">=4.9.0 <7",
82
82
  "jest": ">=27"
83
83
  },
84
84
  "peerDependenciesMeta": {