@t0.labs/daxta 1.1.5 → 1.1.7
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/example.html +29 -8
- package/assets/viewer.html +29 -8
- package/dist/catalog/it-case.d.ts +3 -1
- package/dist/catalog/it-case.js +36 -5
- package/dist/cli/titles.js +1 -1
- package/dist/cli/tree.js +4 -1
- package/dist/config.d.ts +1 -1
- package/package.json +1 -1
package/assets/example.html
CHANGED
|
@@ -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:
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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>`;
|
package/assets/viewer.html
CHANGED
|
@@ -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:
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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>`;
|
|
@@ -10,7 +10,9 @@ export declare function isValidItCase(name?: string): boolean;
|
|
|
10
10
|
export declare function rewriteItFromOriginal(raw: string, section?: CaseSection, method?: string, pathTemplate?: string): string | undefined;
|
|
11
11
|
/**
|
|
12
12
|
* Docs / Postman example line: the unique condition only.
|
|
13
|
-
*
|
|
13
|
+
* Ideal: `creates mock tbs when cyprus payload shape` → `cyprus payload shape`.
|
|
14
|
+
* Parametric: `should set TR companyName when value mode is sent` →
|
|
15
|
+
* `TR companyName when value mode is sent` (keep pre-when context so labels stay unique).
|
|
14
16
|
*/
|
|
15
17
|
export declare function docsScenarioClause(raw?: string): string;
|
|
16
18
|
export type ItSuggestion = {
|
package/dist/catalog/it-case.js
CHANGED
|
@@ -175,9 +175,26 @@ function rewriteItFromOriginal(raw, section, method, pathTemplate) {
|
|
|
175
175
|
return fitItName(`${outcome} when ${s}`);
|
|
176
176
|
}
|
|
177
177
|
const OUTCOME_PREFIX = /^(returns|creates|updates|upserts|inserts|merges|replaces|deletes|lists|rejects|conflicts)\s+/i;
|
|
178
|
+
/** Leading action verbs that are filler once the subject (field / country) is kept. */
|
|
179
|
+
const LEADING_ACTION = /^(set|store|keep|send|put|patch|clear|omit|include|provide|use|apply|replace|update)\s+/i;
|
|
180
|
+
/**
|
|
181
|
+
* Ideal `creates resource when …` leftovers are a short noun phrase (the resource).
|
|
182
|
+
* Field / mode context before `when` is distinguishing and must be kept.
|
|
183
|
+
*/
|
|
184
|
+
function isResourceOnlyBefore(before) {
|
|
185
|
+
if (!before)
|
|
186
|
+
return true;
|
|
187
|
+
if (/[.=_]/.test(before))
|
|
188
|
+
return false;
|
|
189
|
+
if (/\b(null|empty|value|mode|as|undefined|missing)\b/i.test(before))
|
|
190
|
+
return false;
|
|
191
|
+
return before.split(/\s+/).length <= 3;
|
|
192
|
+
}
|
|
178
193
|
/**
|
|
179
194
|
* Docs / Postman example line: the unique condition only.
|
|
180
|
-
*
|
|
195
|
+
* Ideal: `creates mock tbs when cyprus payload shape` → `cyprus payload shape`.
|
|
196
|
+
* Parametric: `should set TR companyName when value mode is sent` →
|
|
197
|
+
* `TR companyName when value mode is sent` (keep pre-when context so labels stay unique).
|
|
181
198
|
*/
|
|
182
199
|
function docsScenarioClause(raw) {
|
|
183
200
|
if (!raw)
|
|
@@ -186,10 +203,24 @@ function docsScenarioClause(raw) {
|
|
|
186
203
|
const field = s.match(/^([A-Za-z0-9_.]+)\s+-\s+(should not be\s+.+)$/i);
|
|
187
204
|
if (field)
|
|
188
205
|
return `${field[1]} ${field[2]}`.trim();
|
|
189
|
-
const
|
|
190
|
-
if (
|
|
191
|
-
|
|
192
|
-
|
|
206
|
+
const whenMatch = s.match(/^(.*?)\bwhen\s+(.+)$/i);
|
|
207
|
+
if (whenMatch) {
|
|
208
|
+
let before = whenMatch[1].trim().replace(/^should\s+/i, '');
|
|
209
|
+
const after = whenMatch[2].trim();
|
|
210
|
+
if (!after)
|
|
211
|
+
return before || 'example';
|
|
212
|
+
const hadOutcome = OUTCOME_PREFIX.test(before);
|
|
213
|
+
before = before
|
|
214
|
+
.replace(OUTCOME_PREFIX, '')
|
|
215
|
+
.replace(/^resource\s+/i, '')
|
|
216
|
+
.replace(/^error\s+/i, '')
|
|
217
|
+
.trim();
|
|
218
|
+
if (!before || (hadOutcome && isResourceOnlyBefore(before)))
|
|
219
|
+
return after;
|
|
220
|
+
before = before.replace(LEADING_ACTION, '').trim();
|
|
221
|
+
return before ? `${before} when ${after}` : after;
|
|
222
|
+
}
|
|
223
|
+
s = s.replace(/^should\s+/i, '').replace(OUTCOME_PREFIX, '').replace(/^resource\s+/i, '').trim();
|
|
193
224
|
return s || 'example';
|
|
194
225
|
}
|
|
195
226
|
/**
|
package/dist/cli/titles.js
CHANGED
|
@@ -134,7 +134,7 @@ async function runTitleCheck(options) {
|
|
|
134
134
|
console.log(` ${ui_1.c.dim('describe')} Create Mock Tbs — POST /v1/admin/mock-tbs`);
|
|
135
135
|
console.log(` ${ui_1.c.dim('→ operation title in sidebar')}`);
|
|
136
136
|
console.log(` ${ui_1.c.dim('it()')} creates mock tbs when cyprus payload shape`);
|
|
137
|
-
console.log(` ${ui_1.c.dim('→ scenario clause (
|
|
137
|
+
console.log(` ${ui_1.c.dim('→ scenario clause (when-clause; keeps pre-when field context when needed)')}`);
|
|
138
138
|
console.log(` ${ui_1.c.dim('label')} 201 — Create Mock Tbs — cyprus payload shape`);
|
|
139
139
|
console.log(` ${ui_1.c.dim('→')} ${ui_1.c.ice('exampleLabelStyle')} ${ui_1.c.dim('in')} ${ui_1.c.ice('daxta tree')} ${ui_1.c.dim('· change with')} ${ui_1.c.ice('2')} ${ui_1.c.dim('for short labels')}`);
|
|
140
140
|
const start = await (0, ui_1.readlineAsk)(` ${ui_1.c.gold('?')} Review test names now?\n` +
|
package/dist/cli/tree.js
CHANGED
|
@@ -119,9 +119,12 @@ async function pickExampleStyle(current) {
|
|
|
119
119
|
console.log('');
|
|
120
120
|
console.log(` ${ui_1.c.bold('Example / scenario labels')}`);
|
|
121
121
|
console.log(` ${ui_1.c.dim('Sidebar + OpenAPI export name for each test hit.')}`);
|
|
122
|
-
console.log(` ${ui_1.c.dim('From')} ${ui_1.c.ice('it()')} ${ui_1.c.dim('—
|
|
122
|
+
console.log(` ${ui_1.c.dim('From')} ${ui_1.c.ice('it()')} ${ui_1.c.dim('— unique scenario clause (when-clause, keeping pre-when field context when needed).')}`);
|
|
123
123
|
console.log('');
|
|
124
124
|
console.log(` ${ui_1.c.dim('sample')} ${ui_1.c.ice('creates mock tbs when cyprus payload shape')}`);
|
|
125
|
+
console.log(` ${ui_1.c.dim('→')} ${ui_1.c.ice('cyprus payload shape')}`);
|
|
126
|
+
console.log(` ${ui_1.c.dim('sample')} ${ui_1.c.ice('should set TR companyName when value mode is sent')}`);
|
|
127
|
+
console.log(` ${ui_1.c.dim('→')} ${ui_1.c.ice('TR companyName when value mode is sent')}`);
|
|
125
128
|
console.log('');
|
|
126
129
|
console.log(` ${ui_1.c.ice('1')} status-title-case ${ui_1.c.dim('(default)')}`);
|
|
127
130
|
console.log(` ${ui_1.c.dim('201 — Create Mock Tbs — cyprus payload shape')}`);
|
package/dist/config.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ export type DaxtaConfig = {
|
|
|
54
54
|
* - status-case → `201 — cyprus payload shape`
|
|
55
55
|
* - status-title-case → `201 — Create Mock Tbs — cyprus payload shape`
|
|
56
56
|
* - full → includes path + POSITIVE CASES + clause
|
|
57
|
-
*
|
|
57
|
+
* Ideal it(): docs take the when-clause. Parametric it(): pre-when field context is kept.
|
|
58
58
|
*/
|
|
59
59
|
exampleLabelStyle?: ExampleLabelStyle;
|
|
60
60
|
port?: number;
|