@sdods/core 0.2.0 → 0.2.1

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.
@@ -3,6 +3,5 @@ export { analyzeProject, buildChecklist, type AnalyzeOptions } from './analyze.j
3
3
  export { proposeProject, slugify, type ProposeOptions } from './propose.js';
4
4
  export { applyProposal, importPlaywrightSpecs, type ApplyOptions, type ApplyResult, } from './apply.js';
5
5
  export { computeCoverage, parseFeatures, pomRouteSteps, type CoverageOptions } from './coverage.js';
6
- export { detectModules, moduleOfFile, moduleOfPath, canonicalAlias, MODULE_ALIASES, SIGNAL_WEIGHTS, type ModuleSignal, type ModuleVote, type DetectedModule, type DetectModulesOptions, type DetectModulesResult, } from './modules.js';
7
6
  export * from './detectors.js';
8
7
  //# sourceMappingURL=index.d.ts.map
@@ -3,6 +3,5 @@ export { analyzeProject, buildChecklist } from './analyze.js';
3
3
  export { proposeProject, slugify } from './propose.js';
4
4
  export { applyProposal, importPlaywrightSpecs, } from './apply.js';
5
5
  export { computeCoverage, parseFeatures, pomRouteSteps } from './coverage.js';
6
- export { detectModules, moduleOfFile, moduleOfPath, canonicalAlias, MODULE_ALIASES, SIGNAL_WEIGHTS, } from './modules.js';
7
6
  export * from './detectors.js';
8
7
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  import { basename } from 'node:path';
2
2
  import { stringify as toYaml } from 'yaml';
3
- import { detectModules } from './modules.js';
4
3
  import { ProjectConfigSchema, } from '@sdods/contracts';
4
+ const RESERVED_SEGMENTS = new Set(['api', 'app', 'src', 'pages']);
5
5
  export function slugify(input) {
6
6
  const s = input
7
7
  .toLowerCase()
@@ -24,6 +24,13 @@ function routeName(path) {
24
24
  .toLowerCase();
25
25
  return name || 'home';
26
26
  }
27
+ function moduleOfPath(path) {
28
+ const first = path.split('/').filter(Boolean)[0];
29
+ if (!first || first.startsWith('{'))
30
+ return 'home';
31
+ const clean = first.replace(/[^a-zA-Z0-9]+/g, '-').toLowerCase();
32
+ return RESERVED_SEGMENTS.has(clean) ? 'core' : clean;
33
+ }
27
34
  function pathToConcrete(path) {
28
35
  return path.replace(/\{[^}]+\}/g, '1');
29
36
  }
@@ -69,26 +76,48 @@ export function proposeProject(report, opts = {}) {
69
76
  }
70
77
  if (hasUi && !routes.home)
71
78
  routes.home = '/';
72
- // modules: signal fusion over route-defining files, workspaces, domain dirs and OpenAPI tags.
73
- // See analyze/modules.ts - first-URL-segment grouping is kept only as the weakest signal.
74
- const detected = detectModules(report);
75
- const nameOfPath = new Map();
76
- for (const [key, path] of Object.entries(routes))
77
- if (!nameOfPath.has(path))
78
- nameOfPath.set(path, key);
79
+ // modules: UI by first path segment, API by openapi tag or first segment
79
80
  const modules = new Map();
80
- for (const m of detected.modules) {
81
- modules.set(m.name, {
82
- name: m.name,
83
- layers: m.layers,
84
- // module.routes are route NAMES (keys of the project `routes` map), not paths
85
- routes: [...new Set(m.routes.map((p) => nameOfPath.get(p) ?? routeName(p)))],
86
- endpoints: m.endpoints,
87
- testingTypes: m.testingTypes,
88
- tags: m.tags,
89
- });
81
+ const ensure = (m, layer) => {
82
+ const key = slugify(m);
83
+ const mod = modules.get(key) ?? {
84
+ name: key,
85
+ layers: [],
86
+ routes: [],
87
+ endpoints: [],
88
+ testingTypes: ['functional', 'smoke', 'regression'],
89
+ tags: [`@${key}`],
90
+ };
91
+ if (!mod.layers.includes(layer))
92
+ mod.layers.push(layer);
93
+ modules.set(key, mod);
94
+ return mod;
95
+ };
96
+ for (const [key, path] of Object.entries(routes)) {
97
+ const mod = ensure(moduleOfPath(path), 'ui');
98
+ if (!mod.routes.includes(key))
99
+ mod.routes.push(key);
100
+ }
101
+ const endpointSet = new Set();
102
+ for (const e of openapiEndpoints) {
103
+ const mod = ensure(e.tag ?? moduleOfPath(e.path), 'api');
104
+ if (!mod.endpoints.includes(e.path))
105
+ mod.endpoints.push(e.path);
106
+ if (!mod.testingTypes.includes('contract'))
107
+ mod.testingTypes.push('contract');
108
+ endpointSet.add(e.path);
109
+ }
110
+ for (const r of apiRoutes) {
111
+ if (endpointSet.has(r.path))
112
+ continue;
113
+ const mod = ensure(moduleOfPath(r.path.replace(/^\/api\//, '/')), 'api');
114
+ if (!mod.endpoints.includes(r.path))
115
+ mod.endpoints.push(r.path);
116
+ endpointSet.add(r.path);
90
117
  }
91
- const endpointSet = new Set(detected.modules.flatMap((m) => m.endpoints));
118
+ const authModule = [...modules.values()].find((m) => /auth|login|account|session/.test(m.name));
119
+ if (authModule && !authModule.testingTypes.includes('data-driven'))
120
+ authModule.testingTypes.push('data-driven');
92
121
  // envs
93
122
  const detectedEnvNames = [
94
123
  ...new Set(report.envs.map((e) => e.name).filter((n) => n !== 'example')),
@@ -254,15 +283,6 @@ export function proposeProject(report, opts = {}) {
254
283
  coverageMap,
255
284
  checklist,
256
285
  notes,
257
- detectedModules: detected.modules.map((m) => ({
258
- name: m.name,
259
- confidence: m.confidence,
260
- signals: m.signals,
261
- routes: m.routes.length,
262
- endpoints: m.endpoints.length,
263
- evidence: m.evidence,
264
- })),
265
- ignoredTargets: detected.ignored,
266
286
  };
267
287
  }
268
288
  function titleCase(s) {
@@ -37,10 +37,7 @@ export class ScenarioMeta {
37
37
  pickleLine: init.pickleLine,
38
38
  exampleIndex: null,
39
39
  tags,
40
- // `featureUri`, not `init.featureUri`: playwright-bdd hands us a repo-root-relative path,
41
- // and moduleForFeature resolves its argument against project.root, so passing the raw
42
- // value yields projects/<slug>/projects/<slug>/... and matches no module.
43
- module: moduleForFeature(config.project, featureUri)?.name,
40
+ module: moduleForFeature(config.project, init.featureUri)?.name,
44
41
  process: process.env.SDODS_PROCESS || undefined,
45
42
  retry: testInfo.retry,
46
43
  workerIndex: testInfo.workerIndex,
@@ -1,4 +1,3 @@
1
- import { attachmentNames } from '@sdods/contracts';
2
1
  import { AfterScenario, AfterStep, BeforeScenario, BeforeStep } from '../fixtures/test.js';
3
2
  /**
4
3
  * Screenshot narrative hooks. Tag-filtered so API scenarios never instantiate a page.
@@ -33,14 +32,5 @@ AfterScenario({ name: 'sdods:finalize' }, async ({ scenario, apiContext, heal, $
33
32
  apiCalls: apiContext.history.length,
34
33
  heals: heal.events.length,
35
34
  });
36
- // Publish the scenario identity to the report. Ingest already understands this attachment
37
- // (parseAttachmentName -> kind 'meta') and prefers its `module` over the directory guess in
38
- // moduleFromUri(), which is wrong whenever a module's `path` differs from its `name` -
39
- // demo-shop's `posts-api` lives in features/api/, so the guess yields "api" and never joins
40
- // to modules.name. Without this attach the meta branch only ever fired in tests.
41
- await $testInfo.attach(attachmentNames.meta, {
42
- body: JSON.stringify(scenario.data),
43
- contentType: 'application/json',
44
- });
45
35
  });
46
36
  //# sourceMappingURL=hooks.js.map
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.2.0";
1
+ export declare const VERSION = "0.2.1";
2
2
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.2.0';
1
+ export const VERSION = '0.2.1';
2
2
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdods/core",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "SDODS runtime: configuration, project registry, fixtures, step libraries, data providers, screenshot narratives and self-healing locators.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "SDODS <admin@sdods.com>",
@@ -42,7 +42,7 @@
42
42
  "playwright-bdd": ">=9"
43
43
  },
44
44
  "dependencies": {
45
- "@sdods/contracts": "0.2.0",
45
+ "@sdods/contracts": "0.2.1",
46
46
  "@cucumber/gherkin": "^42.0.1",
47
47
  "@cucumber/messages": "^34.2.1",
48
48
  "@faker-js/faker": "^10.6.0",
@@ -59,7 +59,7 @@
59
59
  "ts-morph": "^28.0.0",
60
60
  "yaml": "^2.9.0",
61
61
  "zod": "^4.5.4",
62
- "@sdods/db": "0.2.0"
62
+ "@sdods/db": "0.2.1"
63
63
  },
64
64
  "homepage": "https://sdods.com",
65
65
  "bugs": {
@@ -1,74 +0,0 @@
1
- import type { AnalysisReport, Evidence, Layer } from '@sdods/contracts';
2
- /**
3
- * Module detection by signal fusion.
4
- *
5
- * Every detector casts weighted votes for "which module owns this route/endpoint"; the
6
- * resolver keeps the strongest vote per target, then drops noise, merges aliases and splits
7
- * oversized modules. Replaces the two independent first-URL-segment groupers that used to
8
- * live in propose.ts and mcp/tools/analyze.ts.
9
- *
10
- * The ordering matters more than any individual rule. Measured against
11
- * cypress-realworld-app (17 routes): first-URL-segment yields 14 groups, the source-file
12
- * signal alone yields 8, and `backend/auth.ts` collapses /checkAuth + /login + /logout into
13
- * one module without consulting the alias table at all.
14
- */
15
- export type ModuleSignal = 'openapi-tag' | 'workspace' | 'framework-module' | 'domain-dir' | 'source-file' | 'har' | 'route-segment' | 'alias';
16
- export declare const SIGNAL_WEIGHTS: Record<ModuleSignal, number>;
17
- export interface ModuleVote {
18
- /** the thing being assigned: a route or endpoint path */
19
- target: string;
20
- kind: 'route' | 'endpoint';
21
- module: string;
22
- weight: number;
23
- signal: ModuleSignal;
24
- layer: Layer;
25
- evidence: Evidence;
26
- }
27
- export interface DetectedModule {
28
- name: string;
29
- layers: Layer[];
30
- routes: string[];
31
- endpoints: string[];
32
- testingTypes: string[];
33
- tags: string[];
34
- /** mean weight of the winning votes; 0..1 */
35
- confidence: number;
36
- signals: ModuleSignal[];
37
- evidence: Evidence[];
38
- /** populated by the split pass; recorded in the report, not yet emitted to yaml */
39
- children?: DetectedModule[];
40
- }
41
- export interface DetectModulesOptions {
42
- /** a module with more targets than this splits into children (default 12) */
43
- splitAfter?: number;
44
- /** a module with this many targets or fewer merges into an alias sibling (default 1) */
45
- mergeBelow?: number;
46
- maxModules?: number;
47
- }
48
- export interface DetectModulesResult {
49
- modules: DetectedModule[];
50
- votes: ModuleVote[];
51
- /** targets deliberately not turned into modules, with the reason */
52
- ignored: Array<{
53
- target: string;
54
- reason: string;
55
- }>;
56
- }
57
- /**
58
- * Synonyms folded onto a canonical module name. Merges only; an alias never creates a module,
59
- * which is why the weight is the lowest in the table.
60
- */
61
- export declare const MODULE_ALIASES: Record<string, string[]>;
62
- export declare function canonicalAlias(name: string): string | undefined;
63
- /** Today's rule, kept: demoted to a weak signal, and reused as the sub-module split rule. */
64
- export declare function moduleOfPath(path: string): string;
65
- /**
66
- * Module name from the file that defines a route. Returns undefined when the file names a role
67
- * rather than a domain (`backend/app.ts`), so a weaker signal can take over.
68
- *
69
- * `backend/auth.ts` -> auth; `bankaccount-routes.ts` -> bankaccount;
70
- * `TransactionsContainer.tsx` -> transactions; `backend/app.ts` -> undefined.
71
- */
72
- export declare function moduleOfFile(file: string): string | undefined;
73
- export declare function detectModules(report: AnalysisReport, opts?: DetectModulesOptions): DetectModulesResult;
74
- //# sourceMappingURL=modules.d.ts.map
@@ -1,314 +0,0 @@
1
- import { slugify } from './propose.js';
2
- export const SIGNAL_WEIGHTS = {
3
- 'openapi-tag': 1.0,
4
- workspace: 0.9,
5
- 'framework-module': 0.85,
6
- 'domain-dir': 0.8,
7
- 'source-file': 0.7,
8
- har: 0.5,
9
- 'route-segment': 0.3,
10
- alias: 0.2,
11
- };
12
- /** Path segments that never name a domain. */
13
- const RESERVED_SEGMENTS = new Set(['api', 'app', 'src', 'pages']);
14
- /** Basenames that name a file's role, not its domain. */
15
- const GENERIC_BASENAMES = new Set(['index', 'app', 'main', 'server', 'routes', 'route', 'router']);
16
- /** Directories that group by layer, not by domain. */
17
- const GENERIC_DIRS = new Set([
18
- 'src',
19
- 'backend',
20
- 'frontend',
21
- 'api',
22
- 'lib',
23
- 'app',
24
- 'pages',
25
- 'containers',
26
- 'views',
27
- 'components',
28
- 'routes',
29
- 'server',
30
- ]);
31
- /** Directories that conventionally hold one subdirectory per domain. */
32
- const DOMAIN_DIR_RE = /(?:^|\/)(?:src\/)?(?:modules|features|domains|containers|views|pages|apps|services)\/([^/]+)\//;
33
- /** Route-param and route-group directories: `[id]`, `[...slug]`, `{id}`, `:id`, `(marketing)`. */
34
- const DYNAMIC_DIR_RE = /^(?:\[.*\]|\{.*\}|:.+|\(.*\))$/;
35
- /** Suffixes that describe a file's role and should be stripped before naming a module. */
36
- const ROLE_SUFFIX_RE = /[-_.]?(routes?|router|controller|container|service|module|handler|page|view|screen|api)$/i;
37
- /**
38
- * Synonyms folded onto a canonical module name. Merges only; an alias never creates a module,
39
- * which is why the weight is the lowest in the table.
40
- */
41
- export const MODULE_ALIASES = {
42
- auth: [
43
- 'login',
44
- 'signin',
45
- 'sign-in',
46
- 'logout',
47
- 'signout',
48
- 'sign-out',
49
- 'signup',
50
- 'sign-up',
51
- 'register',
52
- 'session',
53
- 'checkauth',
54
- 'check-auth',
55
- 'oauth',
56
- 'sso',
57
- 'identity',
58
- ],
59
- user: ['users', 'profile', 'profiles', 'me', 'account', 'accounts'],
60
- admin: ['administration', 'backoffice', 'back-office'],
61
- search: ['searches', 'query'],
62
- };
63
- const ALIAS_TO_CANONICAL = (() => {
64
- const out = {};
65
- for (const [canonical, names] of Object.entries(MODULE_ALIASES)) {
66
- for (const n of names)
67
- out[n] = canonical;
68
- }
69
- return out;
70
- })();
71
- export function canonicalAlias(name) {
72
- return ALIAS_TO_CANONICAL[name];
73
- }
74
- /** Today's rule, kept: demoted to a weak signal, and reused as the sub-module split rule. */
75
- export function moduleOfPath(path) {
76
- const first = path.split('/').filter(Boolean)[0];
77
- if (!first || first.startsWith('{'))
78
- return 'home';
79
- const clean = first.replace(/[^a-zA-Z0-9]+/g, '-').toLowerCase();
80
- return RESERVED_SEGMENTS.has(clean) ? 'core' : clean;
81
- }
82
- /**
83
- * Module name from the file that defines a route. Returns undefined when the file names a role
84
- * rather than a domain (`backend/app.ts`), so a weaker signal can take over.
85
- *
86
- * `backend/auth.ts` -> auth; `bankaccount-routes.ts` -> bankaccount;
87
- * `TransactionsContainer.tsx` -> transactions; `backend/app.ts` -> undefined.
88
- */
89
- export function moduleOfFile(file) {
90
- const parts = file.replace(/\\/g, '/').split('/').filter(Boolean);
91
- const base = (parts.pop() ?? '').replace(/\.[^.]+$/, '');
92
- let name = base.replace(ROLE_SUFFIX_RE, '');
93
- if (!name || GENERIC_BASENAMES.has(name.toLowerCase())) {
94
- // File-router frameworks put the domain further up: `app/products/[id]/page.tsx` is the
95
- // `products` module, not `id`. Walk past dynamic segments and route groups.
96
- name = '';
97
- while (parts.length) {
98
- const dir = parts.pop();
99
- if (DYNAMIC_DIR_RE.test(dir))
100
- continue;
101
- if (GENERIC_DIRS.has(dir.toLowerCase()))
102
- return undefined;
103
- name = dir;
104
- break;
105
- }
106
- if (!name)
107
- return undefined;
108
- }
109
- // split camelCase/PascalCase before slugify so TransactionsContainer -> transactions
110
- const slug = slugify(name.replace(/([a-z0-9])([A-Z])/g, '$1-$2'));
111
- if (!slug || slug === 'app' || GENERIC_DIRS.has(slug))
112
- return undefined;
113
- return slug;
114
- }
115
- /**
116
- * Routes that carry no domain information and must not become modules.
117
- *
118
- * A path that is uninformative on its own is still fine when its defining file names a domain:
119
- * `GET /{username}` in `backend/contact-routes.ts` is the `contact` module, and dropping it
120
- * would lose a real module. So parameter-only and root routes are noise only when the file
121
- * cannot name them either. Catch-all and optional-group routes are never valid test targets.
122
- */
123
- function noiseReason(r) {
124
- const p = r.path;
125
- if (/^\/?\*/.test(p))
126
- return 'catch-all route';
127
- if (/\(.*\)\?/.test(p))
128
- return 'optional-group route';
129
- if (moduleOfFile(r.file))
130
- return undefined;
131
- const segs = p.split('/').filter(Boolean);
132
- // a UI root path is a real, nameable screen (home); an API root carries nothing
133
- if (segs.length === 0)
134
- return r.kind === 'page' ? undefined : 'root route in a generic file';
135
- if (segs.length === 1 && /^[{:]/.test(segs[0]))
136
- return 'bare parameter route in a generic file';
137
- return undefined;
138
- }
139
- function layerOf(r) {
140
- return r.kind === 'api' ? 'api' : 'ui';
141
- }
142
- function longestWorkspaceMatch(file, workspaces) {
143
- let best;
144
- for (const w of workspaces) {
145
- const prefix = w.replace(/\/?\*+$/, '').replace(/\/$/, '');
146
- if (!prefix)
147
- continue;
148
- if (file === prefix || file.startsWith(`${prefix}/`)) {
149
- if (!best || prefix.length > best.length)
150
- best = prefix;
151
- }
152
- }
153
- if (!best)
154
- return undefined;
155
- // the workspace dir itself is generic (packages/, apps/) - name the package under it
156
- const rest = file.slice(best.length).split('/').filter(Boolean)[0];
157
- return rest ? slugify(rest) : undefined;
158
- }
159
- export function detectModules(report, opts = {}) {
160
- const splitAfter = opts.splitAfter ?? 12;
161
- const mergeBelow = opts.mergeBelow ?? 1;
162
- const maxModules = opts.maxModules ?? 30;
163
- const votes = [];
164
- const ignored = [];
165
- const cast = (v) => {
166
- if (v.module)
167
- votes.push(v);
168
- };
169
- // S1 openapi-tag (1.0) - the authoritative API grouping when a spec exists
170
- const tagged = new Set();
171
- for (const spec of report.openapi) {
172
- for (const e of spec.endpoints) {
173
- if (!e.tag)
174
- continue;
175
- tagged.add(e.path);
176
- cast({
177
- target: e.path,
178
- kind: 'endpoint',
179
- module: slugify(e.tag),
180
- weight: SIGNAL_WEIGHTS['openapi-tag'],
181
- signal: 'openapi-tag',
182
- layer: 'api',
183
- evidence: { file: spec.file, snippet: `tag: ${e.tag}` },
184
- });
185
- }
186
- }
187
- const workspaces = report.packageManager.workspaces ?? [];
188
- for (const r of report.routes) {
189
- if (tagged.has(r.path))
190
- continue;
191
- const reason = noiseReason(r);
192
- if (reason) {
193
- ignored.push({ target: r.path, reason });
194
- continue;
195
- }
196
- const kind = r.kind === 'api' ? 'endpoint' : 'route';
197
- const layer = layerOf(r);
198
- const ev = { file: r.file, line: r.line, snippet: r.path };
199
- // S2 workspace (0.9)
200
- const ws = longestWorkspaceMatch(r.file, workspaces);
201
- if (ws) {
202
- cast({ target: r.path, kind, module: ws, weight: SIGNAL_WEIGHTS.workspace, signal: 'workspace', layer, evidence: ev });
203
- }
204
- // S3 domain-dir (0.8)
205
- const dd = DOMAIN_DIR_RE.exec(r.file.replace(/\\/g, '/'));
206
- if (dd?.[1] && !GENERIC_DIRS.has(dd[1].toLowerCase())) {
207
- cast({ target: r.path, kind, module: slugify(dd[1]), weight: SIGNAL_WEIGHTS['domain-dir'], signal: 'domain-dir', layer, evidence: ev });
208
- }
209
- // S4 source-file (0.7) - the primary signal
210
- const mf = moduleOfFile(r.file);
211
- if (mf) {
212
- cast({ target: r.path, kind, module: mf, weight: SIGNAL_WEIGHTS['source-file'], signal: 'source-file', layer, evidence: ev });
213
- }
214
- // S5 route-segment (0.3) - today's rule, kept as the floor so nothing goes unassigned
215
- cast({ target: r.path, kind, module: moduleOfPath(r.path), weight: SIGNAL_WEIGHTS['route-segment'], signal: 'route-segment', layer, evidence: ev });
216
- }
217
- // resolve: strongest vote per target
218
- const winners = new Map();
219
- for (const v of votes) {
220
- const cur = winners.get(v.target);
221
- if (!cur || v.weight > cur.weight)
222
- winners.set(v.target, v);
223
- }
224
- // build modules
225
- const acc = new Map();
226
- for (const v of winners.values()) {
227
- const m = acc.get(v.module) ??
228
- { routes: new Set(), endpoints: new Set(), layers: new Set(), signals: new Set(), evidence: [], weights: [], contract: false };
229
- if (v.kind === 'endpoint')
230
- m.endpoints.add(v.target);
231
- else
232
- m.routes.add(v.target);
233
- m.layers.add(v.layer);
234
- m.signals.add(v.signal);
235
- m.weights.push(v.weight);
236
- if (v.signal === 'openapi-tag')
237
- m.contract = true;
238
- if (m.evidence.length < 5)
239
- m.evidence.push(v.evidence);
240
- acc.set(v.module, m);
241
- }
242
- // alias merge - folds signin/signup (generic App.tsx) into auth (backend/auth.ts)
243
- for (const [name, m] of [...acc.entries()]) {
244
- const canonical = canonicalAlias(name);
245
- const size = m.routes.size + m.endpoints.size;
246
- if (canonical && canonical !== name && acc.has(canonical)) {
247
- const t = acc.get(canonical);
248
- for (const r of m.routes)
249
- t.routes.add(r);
250
- for (const e of m.endpoints)
251
- t.endpoints.add(e);
252
- for (const l of m.layers)
253
- t.layers.add(l);
254
- t.signals.add('alias');
255
- t.weights.push(...m.weights);
256
- for (const e of m.evidence)
257
- if (t.evidence.length < 5)
258
- t.evidence.push(e);
259
- acc.delete(name);
260
- }
261
- else if (size <= mergeBelow && !canonical && acc.size > 1) {
262
- // a singleton that nothing claims stays put rather than inventing a bucket;
263
- // it is the caller's job (detect.ignore) to drop it if it is noise.
264
- }
265
- }
266
- let modules = [...acc.entries()].map(([name, m]) => {
267
- const testingTypes = ['functional', 'smoke', 'regression'];
268
- if (m.contract)
269
- testingTypes.push('contract');
270
- if (canonicalAlias(name) === 'auth' || name === 'auth')
271
- testingTypes.push('data-driven');
272
- const targets = [...m.routes, ...m.endpoints];
273
- const mod = {
274
- name,
275
- layers: [...m.layers],
276
- routes: [...m.routes],
277
- endpoints: [...m.endpoints],
278
- testingTypes,
279
- tags: [`@${name}`],
280
- confidence: m.weights.length ? m.weights.reduce((a, b) => a + b, 0) / m.weights.length : 0,
281
- signals: [...m.signals],
282
- evidence: m.evidence,
283
- };
284
- // split pass: reuse the old first-segment rule where it is actually correct
285
- if (targets.length > splitAfter) {
286
- const groups = new Map();
287
- for (const t of targets) {
288
- const k = moduleOfPath(t);
289
- groups.set(k, [...(groups.get(k) ?? []), t]);
290
- }
291
- if (groups.size > 1) {
292
- mod.children = [...groups.entries()].map(([childName, ts]) => ({
293
- name: childName,
294
- layers: mod.layers,
295
- routes: ts.filter((t) => m.routes.has(t)),
296
- endpoints: ts.filter((t) => m.endpoints.has(t)),
297
- testingTypes: mod.testingTypes,
298
- tags: [`@${name}`, `@${name}/${childName}`],
299
- confidence: mod.confidence,
300
- signals: ['route-segment'],
301
- evidence: [],
302
- }));
303
- }
304
- }
305
- return mod;
306
- });
307
- modules.sort((a, b) => b.confidence - a.confidence ||
308
- b.routes.length + b.endpoints.length - (a.routes.length + a.endpoints.length) ||
309
- a.name.localeCompare(b.name));
310
- if (modules.length > maxModules)
311
- modules = modules.slice(0, maxModules);
312
- return { modules, votes, ignored };
313
- }
314
- //# sourceMappingURL=modules.js.map
@@ -1,37 +0,0 @@
1
- import { type PlaywrightTestConfig } from '@playwright/test';
2
- import { type BrowserName, type Layer } from '@sdods/contracts';
3
- import type { ProjectRegistry } from './registry.js';
4
- export interface PlaywrightSelection {
5
- project?: string;
6
- env?: string;
7
- layers?: string[];
8
- browsers?: string[];
9
- tags?: string;
10
- runId?: string;
11
- lint?: boolean;
12
- allure?: boolean;
13
- reporters?: string[];
14
- reporterMode?: 'default' | 'server' | 'quiet';
15
- }
16
- export interface SdodsUseOption {
17
- project: string;
18
- layer: Layer;
19
- browser?: BrowserName;
20
- }
21
- export declare const DASHBOARD_REPORTER = "@sdods/core/reporters/dashboard";
22
- /** Convenience for `playwright.config.ts`: read the selection from SDODS_* env vars. */
23
- export declare function selectionFromEnv(env?: NodeJS.ProcessEnv): PlaywrightSelection;
24
- export interface GeneratedProject {
25
- name: string;
26
- project: string;
27
- layer: Layer;
28
- browser?: BrowserName;
29
- }
30
- /** Names (and identity) of the Playwright projects a selection would produce, without side effects. */
31
- export declare function listGeneratedProjects(registry: ProjectRegistry, sel: PlaywrightSelection): GeneratedProject[];
32
- /**
33
- * Build the Playwright config for a selection of projects × layers × browsers.
34
- * One `defineBddConfig` per project × layer; browsers reuse the generated testDir.
35
- */
36
- export declare function buildPlaywrightConfig(registry: ProjectRegistry, sel?: PlaywrightSelection): PlaywrightTestConfig;
37
- //# sourceMappingURL=playwright.d.ts.map