@kirrosh/zond 0.26.0 → 0.27.0
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/CHANGELOG.md +59 -0
- package/README.md +22 -21
- package/bin/zond.mjs +23 -0
- package/package.json +13 -16
- package/scripts/npm/postinstall.mjs +76 -0
- package/src/CLAUDE.md +0 -112
- package/src/bun-types.d.ts +0 -5
- package/src/cli/argv.ts +0 -122
- package/src/cli/commands/add-api.ts +0 -146
- package/src/cli/commands/api/annotate/idempotency.ts +0 -59
- package/src/cli/commands/api/annotate/index.ts +0 -880
- package/src/cli/commands/api/annotate/lifecycle.ts +0 -74
- package/src/cli/commands/api/annotate/overlay.ts +0 -206
- package/src/cli/commands/api/annotate/pagination.ts +0 -64
- package/src/cli/commands/api/annotate/prompts.ts +0 -220
- package/src/cli/commands/api/annotate/readback.ts +0 -58
- package/src/cli/commands/api/annotate/resources.ts +0 -91
- package/src/cli/commands/api/annotate/seed-bodies.ts +0 -61
- package/src/cli/commands/audit.ts +0 -786
- package/src/cli/commands/catalog.ts +0 -97
- package/src/cli/commands/check.ts +0 -361
- package/src/cli/commands/checks.ts +0 -1072
- package/src/cli/commands/ci-init.ts +0 -223
- package/src/cli/commands/clean.ts +0 -212
- package/src/cli/commands/cleanup.ts +0 -236
- package/src/cli/commands/completions.ts +0 -192
- package/src/cli/commands/coverage.ts +0 -872
- package/src/cli/commands/db.ts +0 -611
- package/src/cli/commands/describe.ts +0 -120
- package/src/cli/commands/discover.ts +0 -1356
- package/src/cli/commands/doctor.ts +0 -661
- package/src/cli/commands/fixtures.ts +0 -402
- package/src/cli/commands/generate.ts +0 -577
- package/src/cli/commands/init/agents-md.ts +0 -61
- package/src/cli/commands/init/bootstrap.ts +0 -111
- package/src/cli/commands/init/index.ts +0 -244
- package/src/cli/commands/init/skills.ts +0 -141
- package/src/cli/commands/init/templates/agents.md +0 -86
- package/src/cli/commands/init/templates/markdown.d.ts +0 -4
- package/src/cli/commands/init/templates/skills/warm-up-target.md +0 -122
- package/src/cli/commands/init/templates/skills/zond-checks.md +0 -621
- package/src/cli/commands/init/templates/skills/zond-seed.md +0 -114
- package/src/cli/commands/init/templates/skills/zond-triage.md +0 -272
- package/src/cli/commands/init/templates/skills/zond.md +0 -861
- package/src/cli/commands/init/templates/zond-config.yml +0 -14
- package/src/cli/commands/prepare-fixtures.ts +0 -97
- package/src/cli/commands/probe/_seed-bodies.ts +0 -52
- package/src/cli/commands/probe/mass-assignment.ts +0 -594
- package/src/cli/commands/probe/security.ts +0 -537
- package/src/cli/commands/probe/static.ts +0 -255
- package/src/cli/commands/probe/webhooks.ts +0 -163
- package/src/cli/commands/probe.ts +0 -535
- package/src/cli/commands/reference.ts +0 -87
- package/src/cli/commands/refresh-api.ts +0 -227
- package/src/cli/commands/remove-api.ts +0 -150
- package/src/cli/commands/report-bundle.ts +0 -310
- package/src/cli/commands/report.ts +0 -241
- package/src/cli/commands/request.ts +0 -548
- package/src/cli/commands/run.ts +0 -1142
- package/src/cli/commands/schema-from-runs.ts +0 -128
- package/src/cli/commands/secrets.ts +0 -133
- package/src/cli/commands/session.ts +0 -244
- package/src/cli/commands/use.ts +0 -74
- package/src/cli/index.ts +0 -55
- package/src/cli/json-envelope.ts +0 -108
- package/src/cli/json-schemas.ts +0 -314
- package/src/cli/output.ts +0 -40
- package/src/cli/program.ts +0 -219
- package/src/cli/resolve.ts +0 -105
- package/src/cli/runtime.ts +0 -7
- package/src/cli/safe-live.ts +0 -24
- package/src/cli/status-filter.ts +0 -114
- package/src/cli/util/api-context.ts +0 -85
- package/src/cli/version.ts +0 -8
- package/src/core/audit/persist.ts +0 -183
- package/src/core/checks/budget.ts +0 -59
- package/src/core/checks/checks/_crud-helpers.ts +0 -133
- package/src/core/checks/checks/_negative_mutator.ts +0 -133
- package/src/core/checks/checks/_readback-helpers.ts +0 -133
- package/src/core/checks/checks/content_type_conformance.ts +0 -39
- package/src/core/checks/checks/cross_call_references.ts +0 -147
- package/src/core/checks/checks/cursor_boundary_fuzzing.ts +0 -219
- package/src/core/checks/checks/ensure_resource_availability.ts +0 -62
- package/src/core/checks/checks/idempotency_replay.ts +0 -242
- package/src/core/checks/checks/ignored_auth.ts +0 -254
- package/src/core/checks/checks/index.ts +0 -68
- package/src/core/checks/checks/lifecycle_transitions.ts +0 -416
- package/src/core/checks/checks/missing_required_header.ts +0 -40
- package/src/core/checks/checks/negative_data_rejection.ts +0 -148
- package/src/core/checks/checks/not_a_server_error.ts +0 -35
- package/src/core/checks/checks/open_cors_on_sensitive.ts +0 -160
- package/src/core/checks/checks/pagination_invariants.ts +0 -419
- package/src/core/checks/checks/positive_data_acceptance.ts +0 -33
- package/src/core/checks/checks/rate_limit_headers_absent.ts +0 -77
- package/src/core/checks/checks/response_headers_conformance.ts +0 -74
- package/src/core/checks/checks/response_schema_conformance.ts +0 -30
- package/src/core/checks/checks/status_code_conformance.ts +0 -132
- package/src/core/checks/checks/unsupported_method.ts +0 -63
- package/src/core/checks/checks/use_after_free.ts +0 -78
- package/src/core/checks/index.ts +0 -30
- package/src/core/checks/mode.ts +0 -82
- package/src/core/checks/recommended-action.ts +0 -68
- package/src/core/checks/registry.ts +0 -78
- package/src/core/checks/runner.ts +0 -1461
- package/src/core/checks/sarif.ts +0 -230
- package/src/core/checks/spec-findings.ts +0 -308
- package/src/core/checks/stateful.ts +0 -121
- package/src/core/checks/types.ts +0 -305
- package/src/core/checks/zond-extensions.ts +0 -73
- package/src/core/classifier/recommended-action.ts +0 -251
- package/src/core/context/current.ts +0 -51
- package/src/core/context/session.ts +0 -78
- package/src/core/coverage/loader.ts +0 -216
- package/src/core/coverage/reasons.ts +0 -300
- package/src/core/diagnostics/db-analysis.ts +0 -666
- package/src/core/diagnostics/failure-class.ts +0 -140
- package/src/core/diagnostics/failure-hints.ts +0 -112
- package/src/core/diagnostics/spec-pointer.ts +0 -99
- package/src/core/diagnostics/suggested-fixes.ts +0 -155
- package/src/core/exporter/case-study/index.ts +0 -270
- package/src/core/exporter/curl.ts +0 -40
- package/src/core/exporter/exporter.ts +0 -48
- package/src/core/exporter/html-report/escape.ts +0 -24
- package/src/core/exporter/html-report/index.ts +0 -479
- package/src/core/exporter/html-report/script.ts +0 -100
- package/src/core/exporter/html-report/styles.ts +0 -408
- package/src/core/generator/catalog-builder.ts +0 -179
- package/src/core/generator/chunker.ts +0 -78
- package/src/core/generator/coverage-phase.ts +0 -0
- package/src/core/generator/coverage-scanner.ts +0 -87
- package/src/core/generator/data-factory.ts +0 -759
- package/src/core/generator/describe.ts +0 -302
- package/src/core/generator/endpoint-warnings.ts +0 -52
- package/src/core/generator/fixtures-builder.ts +0 -332
- package/src/core/generator/index.ts +0 -14
- package/src/core/generator/openapi-reader.ts +0 -297
- package/src/core/generator/path-param-disambig.ts +0 -140
- package/src/core/generator/resources-builder.ts +0 -898
- package/src/core/generator/schema-utils.ts +0 -112
- package/src/core/generator/serializer.ts +0 -343
- package/src/core/generator/suite-generator.ts +0 -1301
- package/src/core/generator/types.ts +0 -63
- package/src/core/identity/identity-file.ts +0 -0
- package/src/core/lint/affects.ts +0 -28
- package/src/core/lint/config.ts +0 -96
- package/src/core/lint/format.ts +0 -42
- package/src/core/lint/index.ts +0 -94
- package/src/core/lint/reporter.ts +0 -128
- package/src/core/lint/rules/consistency.ts +0 -158
- package/src/core/lint/rules/heuristics.ts +0 -97
- package/src/core/lint/rules/strictness.ts +0 -109
- package/src/core/lint/types.ts +0 -96
- package/src/core/lint/walker.ts +0 -248
- package/src/core/meta/meta-store.ts +0 -11
- package/src/core/output/README.md +0 -73
- package/src/core/output/index.ts +0 -13
- package/src/core/output/run.ts +0 -91
- package/src/core/output/types.ts +0 -122
- package/src/core/parser/dynamic-values.ts +0 -160
- package/src/core/parser/env-interpolation.ts +0 -104
- package/src/core/parser/filter.ts +0 -97
- package/src/core/parser/schema.ts +0 -359
- package/src/core/parser/types.ts +0 -117
- package/src/core/parser/variables.ts +0 -0
- package/src/core/parser/yaml-parser.ts +0 -181
- package/src/core/probe/bootstrap.ts +0 -34
- package/src/core/probe/dry-run-envelope.ts +0 -61
- package/src/core/probe/mass-assignment/classify.ts +0 -175
- package/src/core/probe/mass-assignment/cleanup.ts +0 -52
- package/src/core/probe/mass-assignment/digest.ts +0 -114
- package/src/core/probe/mass-assignment/orchestrator.ts +0 -459
- package/src/core/probe/mass-assignment/regression.ts +0 -141
- package/src/core/probe/mass-assignment/suspects.ts +0 -92
- package/src/core/probe/mass-assignment/types.ts +0 -135
- package/src/core/probe/mass-assignment-probe-class.ts +0 -198
- package/src/core/probe/mass-assignment-probe.ts +0 -27
- package/src/core/probe/mass-assignment-template.ts +0 -240
- package/src/core/probe/method-probe.ts +0 -164
- package/src/core/probe/method-shared.ts +0 -69
- package/src/core/probe/negative-probe.ts +0 -691
- package/src/core/probe/orphan-tracker.ts +0 -188
- package/src/core/probe/path-discovery.ts +0 -439
- package/src/core/probe/probe-harness.ts +0 -119
- package/src/core/probe/registry.ts +0 -89
- package/src/core/probe/runner.ts +0 -136
- package/src/core/probe/security/baseline.ts +0 -174
- package/src/core/probe/security/classify.ts +0 -341
- package/src/core/probe/security/cleanup.ts +0 -125
- package/src/core/probe/security/detectors.ts +0 -71
- package/src/core/probe/security/digest.ts +0 -104
- package/src/core/probe/security/orchestrator.ts +0 -398
- package/src/core/probe/security/regression.ts +0 -103
- package/src/core/probe/security/types.ts +0 -151
- package/src/core/probe/security-probe-class.ts +0 -207
- package/src/core/probe/security-probe.ts +0 -32
- package/src/core/probe/shared.ts +0 -531
- package/src/core/probe/static-probe-class.ts +0 -125
- package/src/core/probe/types.ts +0 -165
- package/src/core/probe/verdict-aggregator.ts +0 -33
- package/src/core/probe/webhooks-probe.ts +0 -282
- package/src/core/reporter/console.ts +0 -240
- package/src/core/reporter/index.ts +0 -22
- package/src/core/reporter/json.ts +0 -22
- package/src/core/reporter/junit.ts +0 -93
- package/src/core/reporter/ndjson.ts +0 -37
- package/src/core/reporter/types.ts +0 -15
- package/src/core/runner/assertions.ts +0 -383
- package/src/core/runner/async-pool.ts +0 -108
- package/src/core/runner/auth-path.ts +0 -8
- package/src/core/runner/ci-context.ts +0 -72
- package/src/core/runner/executor.ts +0 -652
- package/src/core/runner/expr-eval.ts +0 -41
- package/src/core/runner/form-encode.ts +0 -41
- package/src/core/runner/http-client.ts +0 -224
- package/src/core/runner/learn-drift.ts +0 -293
- package/src/core/runner/preflight-vars.ts +0 -153
- package/src/core/runner/progress-tracker.ts +0 -73
- package/src/core/runner/rate-limiter.ts +0 -185
- package/src/core/runner/run-kind.ts +0 -45
- package/src/core/runner/schema-validator.ts +0 -308
- package/src/core/runner/send-request.ts +0 -232
- package/src/core/runner/transforms.ts +0 -65
- package/src/core/runner/types.ts +0 -94
- package/src/core/secrets/registry.ts +0 -164
- package/src/core/secrets/secrets-file.ts +0 -115
- package/src/core/selectors/operation-filter.ts +0 -144
- package/src/core/setup-api.ts +0 -590
- package/src/core/severity/category.ts +0 -94
- package/src/core/severity/index.ts +0 -58
- package/src/core/spec/infer-schema.ts +0 -102
- package/src/core/spec/layers.ts +0 -154
- package/src/core/spec/merge-specs.ts +0 -156
- package/src/core/spec/schema-from-runs.ts +0 -117
- package/src/core/spec/schema-overlay.ts +0 -130
- package/src/core/util/ajv.ts +0 -13
- package/src/core/util/format-eta.ts +0 -21
- package/src/core/util/headers.ts +0 -9
- package/src/core/util/url.ts +0 -24
- package/src/core/utils.ts +0 -13
- package/src/core/workspace/config.ts +0 -129
- package/src/core/workspace/fixture-gap-report.ts +0 -84
- package/src/core/workspace/fixture-gaps.ts +0 -71
- package/src/core/workspace/manifest.ts +0 -283
- package/src/core/workspace/output-rotation.ts +0 -62
- package/src/core/workspace/root.ts +0 -96
- package/src/core/workspace/triage-path.ts +0 -87
- package/src/db/lint-runs.ts +0 -47
- package/src/db/migrate.ts +0 -128
- package/src/db/migrations/0001_run_kind.sql +0 -25
- package/src/db/migrations/0002_run_kind_request.sql +0 -59
- package/src/db/migrations/sql.d.ts +0 -4
- package/src/db/queries/collections.ts +0 -133
- package/src/db/queries/coverage.ts +0 -9
- package/src/db/queries/dashboard.ts +0 -59
- package/src/db/queries/results.ts +0 -216
- package/src/db/queries/runs.ts +0 -289
- package/src/db/queries/sessions.ts +0 -42
- package/src/db/queries/settings.ts +0 -28
- package/src/db/queries/types.ts +0 -172
- package/src/db/queries.ts +0 -75
- package/src/db/schema.ts +0 -298
|
@@ -1,408 +0,0 @@
|
|
|
1
|
-
// Single-file inline CSS for the run report.
|
|
2
|
-
// Self-contained: no @import, no external fonts. System UI stack only.
|
|
3
|
-
// Light + dark via prefers-color-scheme. Print-friendly for PDF export.
|
|
4
|
-
|
|
5
|
-
export const STYLES = `
|
|
6
|
-
:root {
|
|
7
|
-
color-scheme: light dark;
|
|
8
|
-
--bg: #fbfbfd;
|
|
9
|
-
--bg-elev: #ffffff;
|
|
10
|
-
--bg-muted: #f3f4f6;
|
|
11
|
-
--bg-code: #f6f8fa;
|
|
12
|
-
--fg: #0b0d12;
|
|
13
|
-
--fg-muted: #5b6472;
|
|
14
|
-
--border: #e5e7eb;
|
|
15
|
-
--border-strong: #d1d5db;
|
|
16
|
-
--accent: #3b82f6;
|
|
17
|
-
--accent-fg: #ffffff;
|
|
18
|
-
--pass: #10b981;
|
|
19
|
-
--pass-bg: #d1fae5;
|
|
20
|
-
--fail: #ef4444;
|
|
21
|
-
--fail-bg: #fee2e2;
|
|
22
|
-
--warn: #f59e0b;
|
|
23
|
-
--warn-bg: #fef3c7;
|
|
24
|
-
--info: #6366f1;
|
|
25
|
-
--info-bg: #e0e7ff;
|
|
26
|
-
--shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.06);
|
|
27
|
-
}
|
|
28
|
-
@media (prefers-color-scheme: dark) {
|
|
29
|
-
:root {
|
|
30
|
-
--bg: #0b0d12;
|
|
31
|
-
--bg-elev: #11141b;
|
|
32
|
-
--bg-muted: #181c25;
|
|
33
|
-
--bg-code: #0f1219;
|
|
34
|
-
--fg: #e5e7eb;
|
|
35
|
-
--fg-muted: #9aa3b2;
|
|
36
|
-
--border: #1f242f;
|
|
37
|
-
--border-strong: #2c3340;
|
|
38
|
-
--accent: #60a5fa;
|
|
39
|
-
--accent-fg: #0b0d12;
|
|
40
|
-
--pass: #34d399;
|
|
41
|
-
--pass-bg: #052e22;
|
|
42
|
-
--fail: #f87171;
|
|
43
|
-
--fail-bg: #2a0e10;
|
|
44
|
-
--warn: #fbbf24;
|
|
45
|
-
--warn-bg: #2a1d05;
|
|
46
|
-
--info: #818cf8;
|
|
47
|
-
--info-bg: #1c1c3a;
|
|
48
|
-
--shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 24px rgba(0,0,0,.4);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
* { box-sizing: border-box; }
|
|
53
|
-
html, body { margin: 0; padding: 0; }
|
|
54
|
-
body {
|
|
55
|
-
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
|
|
56
|
-
font-size: 14px;
|
|
57
|
-
line-height: 1.5;
|
|
58
|
-
background: var(--bg);
|
|
59
|
-
color: var(--fg);
|
|
60
|
-
-webkit-font-smoothing: antialiased;
|
|
61
|
-
}
|
|
62
|
-
.container { max-width: 1080px; margin: 0 auto; padding: 32px 24px 64px; }
|
|
63
|
-
.mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace; }
|
|
64
|
-
|
|
65
|
-
/* ── Hero ── */
|
|
66
|
-
.hero {
|
|
67
|
-
background: var(--bg-elev);
|
|
68
|
-
border: 1px solid var(--border);
|
|
69
|
-
border-radius: 16px;
|
|
70
|
-
padding: 28px 32px;
|
|
71
|
-
margin-bottom: 24px;
|
|
72
|
-
box-shadow: var(--shadow);
|
|
73
|
-
display: grid;
|
|
74
|
-
grid-template-columns: 1fr auto;
|
|
75
|
-
gap: 24px;
|
|
76
|
-
align-items: center;
|
|
77
|
-
}
|
|
78
|
-
.hero h1 {
|
|
79
|
-
margin: 0 0 6px;
|
|
80
|
-
font-size: 28px;
|
|
81
|
-
font-weight: 700;
|
|
82
|
-
letter-spacing: -0.02em;
|
|
83
|
-
}
|
|
84
|
-
.hero .sub {
|
|
85
|
-
font-size: 13px;
|
|
86
|
-
color: var(--fg-muted);
|
|
87
|
-
}
|
|
88
|
-
.hero .meta {
|
|
89
|
-
margin-top: 16px;
|
|
90
|
-
display: grid;
|
|
91
|
-
grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
|
|
92
|
-
gap: 10px 18px;
|
|
93
|
-
}
|
|
94
|
-
.hero .meta dt { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--fg-muted); margin: 0; }
|
|
95
|
-
.hero .meta dd { font-size: 13px; margin: 2px 0 0; word-break: break-all; }
|
|
96
|
-
.hero .meta dd.mono { font-size: 12px; }
|
|
97
|
-
|
|
98
|
-
/* Pass-rate ring */
|
|
99
|
-
.ring { position: relative; width: 140px; height: 140px; }
|
|
100
|
-
.ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
|
|
101
|
-
.ring .track { stroke: var(--border); }
|
|
102
|
-
.ring .fill { transition: stroke-dashoffset .6s ease; }
|
|
103
|
-
.ring .label {
|
|
104
|
-
position: absolute; inset: 0;
|
|
105
|
-
display: flex; flex-direction: column; align-items: center; justify-content: center;
|
|
106
|
-
text-align: center;
|
|
107
|
-
}
|
|
108
|
-
.ring .label .pct { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
|
|
109
|
-
.ring .label .lbl { font-size: 11px; color: var(--fg-muted); text-transform: uppercase; letter-spacing: .08em; }
|
|
110
|
-
|
|
111
|
-
/* ── Status badges ── */
|
|
112
|
-
.badge {
|
|
113
|
-
display: inline-flex; align-items: center; gap: 4px;
|
|
114
|
-
padding: 2px 8px; border-radius: 999px;
|
|
115
|
-
font-size: 11px; font-weight: 600;
|
|
116
|
-
background: var(--bg-muted); color: var(--fg-muted);
|
|
117
|
-
border: 1px solid var(--border);
|
|
118
|
-
white-space: nowrap;
|
|
119
|
-
}
|
|
120
|
-
.badge.pass { background: var(--pass-bg); color: var(--pass); border-color: transparent; }
|
|
121
|
-
.badge.fail { background: var(--fail-bg); color: var(--fail); border-color: transparent; }
|
|
122
|
-
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
|
|
123
|
-
.badge.info { background: var(--info-bg); color: var(--info); border-color: transparent; }
|
|
124
|
-
.badge.solid-pass { background: var(--pass); color: white; border-color: transparent; }
|
|
125
|
-
.badge.solid-fail { background: var(--fail); color: white; border-color: transparent; }
|
|
126
|
-
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
|
|
127
|
-
|
|
128
|
-
/* ── KPI strip ── */
|
|
129
|
-
.kpis {
|
|
130
|
-
display: grid;
|
|
131
|
-
grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
|
|
132
|
-
gap: 12px;
|
|
133
|
-
margin-bottom: 24px;
|
|
134
|
-
}
|
|
135
|
-
.kpi {
|
|
136
|
-
background: var(--bg-elev);
|
|
137
|
-
border: 1px solid var(--border);
|
|
138
|
-
border-radius: 12px;
|
|
139
|
-
padding: 14px 16px;
|
|
140
|
-
}
|
|
141
|
-
.kpi .n { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
|
|
142
|
-
.kpi .l { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--fg-muted); margin-top: 2px; }
|
|
143
|
-
.kpi.pass .n { color: var(--pass); }
|
|
144
|
-
.kpi.fail .n { color: var(--fail); }
|
|
145
|
-
.kpi.warn .n { color: var(--warn); }
|
|
146
|
-
|
|
147
|
-
/* ── Section ── */
|
|
148
|
-
section { margin-top: 32px; }
|
|
149
|
-
section h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; display: flex; align-items: center; gap: 10px; }
|
|
150
|
-
section h2 .count { font-size: 12px; color: var(--fg-muted); font-weight: 500; }
|
|
151
|
-
|
|
152
|
-
/* ── Filter bar ── */
|
|
153
|
-
.filters {
|
|
154
|
-
display: flex; flex-wrap: wrap; gap: 6px;
|
|
155
|
-
margin-bottom: 14px;
|
|
156
|
-
}
|
|
157
|
-
.filters button {
|
|
158
|
-
font: inherit;
|
|
159
|
-
font-size: 12px;
|
|
160
|
-
padding: 5px 10px;
|
|
161
|
-
border-radius: 999px;
|
|
162
|
-
border: 1px solid var(--border);
|
|
163
|
-
background: var(--bg-elev);
|
|
164
|
-
color: var(--fg-muted);
|
|
165
|
-
cursor: pointer;
|
|
166
|
-
transition: all .15s;
|
|
167
|
-
}
|
|
168
|
-
.filters button:hover { color: var(--fg); border-color: var(--border-strong); }
|
|
169
|
-
.filters button.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }
|
|
170
|
-
|
|
171
|
-
/* ── Failure card ── */
|
|
172
|
-
.cards { display: flex; flex-direction: column; gap: 8px; }
|
|
173
|
-
.card {
|
|
174
|
-
background: var(--bg-elev);
|
|
175
|
-
border: 1px solid var(--border);
|
|
176
|
-
border-radius: 10px;
|
|
177
|
-
overflow: hidden;
|
|
178
|
-
transition: border-color .15s;
|
|
179
|
-
}
|
|
180
|
-
.card:hover { border-color: var(--border-strong); }
|
|
181
|
-
.card.hidden { display: none; }
|
|
182
|
-
.card > .head {
|
|
183
|
-
display: flex; align-items: center; gap: 10px;
|
|
184
|
-
padding: 10px 14px;
|
|
185
|
-
cursor: pointer;
|
|
186
|
-
user-select: none;
|
|
187
|
-
background: transparent;
|
|
188
|
-
border: 0;
|
|
189
|
-
width: 100%;
|
|
190
|
-
text-align: left;
|
|
191
|
-
font: inherit;
|
|
192
|
-
color: inherit;
|
|
193
|
-
}
|
|
194
|
-
.card > .head:hover { background: var(--bg-muted); }
|
|
195
|
-
.card .chev {
|
|
196
|
-
width: 14px; height: 14px;
|
|
197
|
-
transition: transform .2s;
|
|
198
|
-
flex-shrink: 0;
|
|
199
|
-
color: var(--fg-muted);
|
|
200
|
-
}
|
|
201
|
-
.card.open .chev { transform: rotate(90deg); }
|
|
202
|
-
.card .method {
|
|
203
|
-
font-family: ui-monospace, SFMono-Regular, monospace;
|
|
204
|
-
font-size: 11px;
|
|
205
|
-
font-weight: 700;
|
|
206
|
-
padding: 2px 6px;
|
|
207
|
-
border-radius: 4px;
|
|
208
|
-
background: var(--bg-muted);
|
|
209
|
-
color: var(--fg-muted);
|
|
210
|
-
flex-shrink: 0;
|
|
211
|
-
min-width: 50px;
|
|
212
|
-
text-align: center;
|
|
213
|
-
}
|
|
214
|
-
.card .method.GET { color: #10b981; }
|
|
215
|
-
.card .method.POST { color: #3b82f6; }
|
|
216
|
-
.card .method.PUT { color: #f59e0b; }
|
|
217
|
-
.card .method.PATCH { color: #f59e0b; }
|
|
218
|
-
.card .method.DELETE { color: #ef4444; }
|
|
219
|
-
.card .name {
|
|
220
|
-
flex: 1;
|
|
221
|
-
font-size: 13px;
|
|
222
|
-
overflow: hidden;
|
|
223
|
-
text-overflow: ellipsis;
|
|
224
|
-
white-space: nowrap;
|
|
225
|
-
}
|
|
226
|
-
.card .badges { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }
|
|
227
|
-
.card .body {
|
|
228
|
-
display: none;
|
|
229
|
-
border-top: 1px solid var(--border);
|
|
230
|
-
background: var(--bg-muted);
|
|
231
|
-
}
|
|
232
|
-
.card.open .body { display: block; }
|
|
233
|
-
|
|
234
|
-
.card .actions {
|
|
235
|
-
display: flex; gap: 6px;
|
|
236
|
-
padding: 10px 14px;
|
|
237
|
-
border-bottom: 1px solid var(--border);
|
|
238
|
-
flex-wrap: wrap;
|
|
239
|
-
}
|
|
240
|
-
.btn {
|
|
241
|
-
font: inherit;
|
|
242
|
-
font-size: 12px;
|
|
243
|
-
padding: 5px 10px;
|
|
244
|
-
border: 1px solid var(--border);
|
|
245
|
-
border-radius: 6px;
|
|
246
|
-
background: var(--bg-elev);
|
|
247
|
-
color: var(--fg);
|
|
248
|
-
cursor: pointer;
|
|
249
|
-
display: inline-flex;
|
|
250
|
-
align-items: center;
|
|
251
|
-
gap: 5px;
|
|
252
|
-
transition: all .15s;
|
|
253
|
-
}
|
|
254
|
-
.btn:hover { border-color: var(--border-strong); background: var(--bg); }
|
|
255
|
-
.btn.copied { background: var(--pass-bg); color: var(--pass); border-color: transparent; }
|
|
256
|
-
|
|
257
|
-
/* Tabs */
|
|
258
|
-
.tabs { display: flex; border-bottom: 1px solid var(--border); padding: 0 14px; }
|
|
259
|
-
.tabs button {
|
|
260
|
-
font: inherit;
|
|
261
|
-
font-size: 12px;
|
|
262
|
-
background: transparent;
|
|
263
|
-
border: 0;
|
|
264
|
-
border-bottom: 2px solid transparent;
|
|
265
|
-
padding: 10px 12px;
|
|
266
|
-
margin-bottom: -1px;
|
|
267
|
-
cursor: pointer;
|
|
268
|
-
color: var(--fg-muted);
|
|
269
|
-
transition: all .15s;
|
|
270
|
-
}
|
|
271
|
-
.tabs button:hover { color: var(--fg); }
|
|
272
|
-
.tabs button.active { color: var(--fg); border-bottom-color: var(--fg); font-weight: 600; }
|
|
273
|
-
.panel { padding: 14px; display: none; }
|
|
274
|
-
.panel.active { display: block; }
|
|
275
|
-
|
|
276
|
-
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 14px; font-size: 12px; }
|
|
277
|
-
.kv dt { color: var(--fg-muted); }
|
|
278
|
-
.kv dd { margin: 0; word-break: break-all; }
|
|
279
|
-
|
|
280
|
-
pre.code {
|
|
281
|
-
margin: 6px 0 0;
|
|
282
|
-
padding: 12px 14px;
|
|
283
|
-
background: var(--bg-code);
|
|
284
|
-
border: 1px solid var(--border);
|
|
285
|
-
border-radius: 6px;
|
|
286
|
-
font-family: ui-monospace, SFMono-Regular, monospace;
|
|
287
|
-
font-size: 12px;
|
|
288
|
-
line-height: 1.55;
|
|
289
|
-
overflow-x: auto;
|
|
290
|
-
max-height: 360px;
|
|
291
|
-
overflow-y: auto;
|
|
292
|
-
white-space: pre;
|
|
293
|
-
}
|
|
294
|
-
.code-label {
|
|
295
|
-
font-size: 10px;
|
|
296
|
-
text-transform: uppercase;
|
|
297
|
-
letter-spacing: .08em;
|
|
298
|
-
color: var(--fg-muted);
|
|
299
|
-
margin-top: 12px;
|
|
300
|
-
}
|
|
301
|
-
.code-label:first-child { margin-top: 0; }
|
|
302
|
-
|
|
303
|
-
/* JSON syntax highlighting (regex-driven) */
|
|
304
|
-
.j-key { color: #b45309; }
|
|
305
|
-
.j-str { color: #047857; }
|
|
306
|
-
.j-num { color: #1d4ed8; }
|
|
307
|
-
.j-bool { color: #7c3aed; }
|
|
308
|
-
.j-null { color: #6b7280; }
|
|
309
|
-
@media (prefers-color-scheme: dark) {
|
|
310
|
-
.j-key { color: #fbbf24; }
|
|
311
|
-
.j-str { color: #34d399; }
|
|
312
|
-
.j-num { color: #60a5fa; }
|
|
313
|
-
.j-bool { color: #c084fc; }
|
|
314
|
-
.j-null { color: #9aa3b2; }
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
/* Assertion list */
|
|
318
|
-
.asserts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
|
|
319
|
-
.asserts li {
|
|
320
|
-
border: 1px solid var(--border);
|
|
321
|
-
border-radius: 6px;
|
|
322
|
-
padding: 8px 10px;
|
|
323
|
-
background: var(--bg-elev);
|
|
324
|
-
font-size: 12px;
|
|
325
|
-
}
|
|
326
|
-
.asserts li.failed { border-color: var(--fail); background: var(--fail-bg); }
|
|
327
|
-
.asserts li.passed { border-color: var(--pass); background: var(--pass-bg); }
|
|
328
|
-
.asserts .a-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
|
|
329
|
-
.asserts .a-diff { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; font-family: ui-monospace, SFMono-Regular, monospace; font-size: 11px; }
|
|
330
|
-
.asserts .a-diff .lbl { color: var(--fg-muted); }
|
|
331
|
-
|
|
332
|
-
/* Coverage matrix */
|
|
333
|
-
.cov-grid {
|
|
334
|
-
display: grid;
|
|
335
|
-
gap: 1px;
|
|
336
|
-
background: var(--border);
|
|
337
|
-
border: 1px solid var(--border);
|
|
338
|
-
border-radius: 8px;
|
|
339
|
-
overflow: hidden;
|
|
340
|
-
font-size: 11px;
|
|
341
|
-
font-family: ui-monospace, SFMono-Regular, monospace;
|
|
342
|
-
}
|
|
343
|
-
.cov-row { display: grid; grid-template-columns: 1.5fr repeat(5, 60px); }
|
|
344
|
-
.cov-cell {
|
|
345
|
-
background: var(--bg-elev);
|
|
346
|
-
padding: 6px 8px;
|
|
347
|
-
text-align: center;
|
|
348
|
-
display: flex;
|
|
349
|
-
align-items: center;
|
|
350
|
-
justify-content: center;
|
|
351
|
-
}
|
|
352
|
-
.cov-cell.head { font-weight: 600; color: var(--fg-muted); text-transform: uppercase; font-size: 10px; }
|
|
353
|
-
.cov-cell.path { justify-content: flex-start; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
354
|
-
.cov-cell.s2 { background: var(--pass-bg); color: var(--pass); font-weight: 600; }
|
|
355
|
-
.cov-cell.s4 { background: var(--warn-bg); color: var(--warn); font-weight: 600; }
|
|
356
|
-
.cov-cell.s5 { background: var(--fail-bg); color: var(--fail); font-weight: 600; }
|
|
357
|
-
.cov-cell.serr { background: var(--fail); color: white; font-weight: 600; }
|
|
358
|
-
.cov-cell.empty { color: var(--border-strong); }
|
|
359
|
-
.cov-row.reasons { grid-template-columns: 2fr repeat(3, 1fr); }
|
|
360
|
-
.cov-cell.reasons { flex-wrap: wrap; gap: 3px; padding: 6px; min-height: 32px; }
|
|
361
|
-
.cov-cell.s2.reasons { background: var(--pass-bg); }
|
|
362
|
-
.cov-cell.s4.reasons { background: var(--warn-bg); }
|
|
363
|
-
.cov-cell.su { background: var(--bg-muted); color: var(--fg-muted); }
|
|
364
|
-
.cov-cell .rchip { background: rgba(255,255,255,0.6); padding: 1px 5px; border-radius: 3px; font-size: 10px; font-weight: 500; color: var(--fg); }
|
|
365
|
-
.method-mini { font-weight: 700; color: var(--accent); margin-right: 4px; }
|
|
366
|
-
.cov-cell.path .badge { margin-left: 6px; vertical-align: middle; }
|
|
367
|
-
|
|
368
|
-
/* Footer */
|
|
369
|
-
footer {
|
|
370
|
-
margin-top: 48px;
|
|
371
|
-
padding-top: 20px;
|
|
372
|
-
border-top: 1px solid var(--border);
|
|
373
|
-
font-size: 11px;
|
|
374
|
-
color: var(--fg-muted);
|
|
375
|
-
display: flex;
|
|
376
|
-
justify-content: space-between;
|
|
377
|
-
flex-wrap: wrap;
|
|
378
|
-
gap: 8px;
|
|
379
|
-
}
|
|
380
|
-
footer a { color: var(--accent); text-decoration: none; }
|
|
381
|
-
footer a:hover { text-decoration: underline; }
|
|
382
|
-
|
|
383
|
-
/* Empty state */
|
|
384
|
-
.empty {
|
|
385
|
-
background: var(--bg-elev);
|
|
386
|
-
border: 1px dashed var(--border);
|
|
387
|
-
border-radius: 10px;
|
|
388
|
-
padding: 32px 24px;
|
|
389
|
-
text-align: center;
|
|
390
|
-
color: var(--fg-muted);
|
|
391
|
-
font-size: 13px;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
/* Print */
|
|
395
|
-
@media print {
|
|
396
|
-
.hero, .kpi, .card, .empty { box-shadow: none !important; }
|
|
397
|
-
.card { break-inside: avoid; }
|
|
398
|
-
.actions, .filters, .tabs button:not(.active) { display: none !important; }
|
|
399
|
-
.panel { display: block !important; padding: 8px 14px; }
|
|
400
|
-
body { background: white; color: black; }
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
@media (max-width: 720px) {
|
|
404
|
-
.hero { grid-template-columns: 1fr; }
|
|
405
|
-
.ring { width: 110px; height: 110px; justify-self: center; }
|
|
406
|
-
.cov-row { grid-template-columns: 1.5fr repeat(5, 1fr); }
|
|
407
|
-
}
|
|
408
|
-
`;
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import type { EndpointInfo, SecuritySchemeInfo } from "./types.ts";
|
|
2
|
-
import { compressSchema, formatParam, isAnySchema } from "./schema-utils.ts";
|
|
3
|
-
|
|
4
|
-
export interface CatalogEndpoint {
|
|
5
|
-
method: string;
|
|
6
|
-
path: string;
|
|
7
|
-
summary?: string;
|
|
8
|
-
tags: string[];
|
|
9
|
-
deprecated?: boolean;
|
|
10
|
-
parameters?: string[];
|
|
11
|
-
requestBody?: string;
|
|
12
|
-
responses: Array<{
|
|
13
|
-
status: number;
|
|
14
|
-
schema?: string;
|
|
15
|
-
}>;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface ApiCatalog {
|
|
19
|
-
generatedAt: string;
|
|
20
|
-
specSource: string;
|
|
21
|
-
specHash: string;
|
|
22
|
-
apiName?: string;
|
|
23
|
-
apiVersion?: string;
|
|
24
|
-
baseUrl?: string;
|
|
25
|
-
auth: string[];
|
|
26
|
-
endpointCount: number;
|
|
27
|
-
endpoints: CatalogEndpoint[];
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface BuildCatalogParams {
|
|
31
|
-
endpoints: EndpointInfo[];
|
|
32
|
-
securitySchemes: SecuritySchemeInfo[];
|
|
33
|
-
specSource: string;
|
|
34
|
-
specHash: string;
|
|
35
|
-
apiName?: string;
|
|
36
|
-
apiVersion?: string;
|
|
37
|
-
baseUrl?: string;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function formatSecurityScheme(s: SecuritySchemeInfo): string {
|
|
41
|
-
let desc = `${s.name}: ${s.type}`;
|
|
42
|
-
if (s.scheme) desc += `/${s.scheme}`;
|
|
43
|
-
if (s.bearerFormat) desc += ` (${s.bearerFormat})`;
|
|
44
|
-
if (s.in && s.apiKeyName) desc += ` (${s.apiKeyName} in ${s.in})`;
|
|
45
|
-
return desc;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function formatParamWithLocation(p: import("openapi-types").OpenAPIV3.ParameterObject): string {
|
|
49
|
-
const base = formatParam(p);
|
|
50
|
-
// Insert location before (req) or at the end
|
|
51
|
-
const reqSuffix = " (req)";
|
|
52
|
-
if (base.endsWith(reqSuffix)) {
|
|
53
|
-
return `${base.slice(0, -reqSuffix.length)} (${p.in}, req)`;
|
|
54
|
-
}
|
|
55
|
-
return `${base} (${p.in})`;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function buildCatalogEndpoint(ep: EndpointInfo): CatalogEndpoint {
|
|
59
|
-
const result: CatalogEndpoint = {
|
|
60
|
-
method: ep.method.toUpperCase(),
|
|
61
|
-
path: ep.path,
|
|
62
|
-
tags: ep.tags,
|
|
63
|
-
responses: [],
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
if (ep.summary) result.summary = ep.summary;
|
|
67
|
-
if (ep.deprecated) result.deprecated = true;
|
|
68
|
-
|
|
69
|
-
if (ep.parameters.length > 0) {
|
|
70
|
-
result.parameters = ep.parameters.map(formatParamWithLocation);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (ep.requestBodySchema) {
|
|
74
|
-
result.requestBody = isAnySchema(ep.requestBodySchema)
|
|
75
|
-
? "any"
|
|
76
|
-
: compressSchema(ep.requestBodySchema);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
for (const resp of ep.responses) {
|
|
80
|
-
const entry: { status: number; schema?: string } = { status: resp.statusCode };
|
|
81
|
-
if (resp.schema && !isAnySchema(resp.schema)) {
|
|
82
|
-
entry.schema = compressSchema(resp.schema);
|
|
83
|
-
}
|
|
84
|
-
result.responses.push(entry);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return result;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export function buildCatalog(params: BuildCatalogParams): ApiCatalog {
|
|
91
|
-
return {
|
|
92
|
-
generatedAt: new Date().toISOString(),
|
|
93
|
-
specSource: params.specSource,
|
|
94
|
-
specHash: params.specHash,
|
|
95
|
-
...(params.apiName ? { apiName: params.apiName } : {}),
|
|
96
|
-
...(params.apiVersion ? { apiVersion: params.apiVersion } : {}),
|
|
97
|
-
...(params.baseUrl ? { baseUrl: params.baseUrl } : {}),
|
|
98
|
-
auth: params.securitySchemes.map(formatSecurityScheme),
|
|
99
|
-
endpointCount: params.endpoints.length,
|
|
100
|
-
endpoints: params.endpoints.map(buildCatalogEndpoint),
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// --- YAML serialization ---
|
|
105
|
-
|
|
106
|
-
function yamlEscape(value: string): string {
|
|
107
|
-
if (/[:{}\[\],&*#?|<>=!%@`"']/.test(value) || value.includes("\n")) {
|
|
108
|
-
return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
109
|
-
}
|
|
110
|
-
return value;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function yamlScalar(value: unknown): string {
|
|
114
|
-
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
115
|
-
return yamlEscape(String(value));
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export function serializeCatalog(catalog: ApiCatalog): string {
|
|
119
|
-
const lines: string[] = [];
|
|
120
|
-
lines.push("# Auto-generated by zond. Regenerate with: zond catalog <spec>");
|
|
121
|
-
lines.push(`generatedAt: ${yamlScalar(catalog.generatedAt)}`);
|
|
122
|
-
lines.push(`specSource: ${yamlScalar(catalog.specSource)}`);
|
|
123
|
-
lines.push(`specHash: ${yamlScalar(catalog.specHash)}`);
|
|
124
|
-
if (catalog.apiName) lines.push(`apiName: ${yamlScalar(catalog.apiName)}`);
|
|
125
|
-
if (catalog.apiVersion) lines.push(`apiVersion: ${yamlScalar(catalog.apiVersion)}`);
|
|
126
|
-
if (catalog.baseUrl) lines.push(`baseUrl: ${yamlScalar(catalog.baseUrl)}`);
|
|
127
|
-
lines.push(`endpointCount: ${catalog.endpointCount}`);
|
|
128
|
-
|
|
129
|
-
// Auth
|
|
130
|
-
if (catalog.auth.length > 0) {
|
|
131
|
-
lines.push("auth:");
|
|
132
|
-
for (const a of catalog.auth) {
|
|
133
|
-
lines.push(` - ${yamlScalar(a)}`);
|
|
134
|
-
}
|
|
135
|
-
} else {
|
|
136
|
-
lines.push("auth: []");
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Endpoints
|
|
140
|
-
if (catalog.endpoints.length === 0) {
|
|
141
|
-
lines.push("endpoints: []");
|
|
142
|
-
return lines.join("\n") + "\n";
|
|
143
|
-
}
|
|
144
|
-
lines.push("endpoints:");
|
|
145
|
-
for (const ep of catalog.endpoints) {
|
|
146
|
-
lines.push(` - method: ${ep.method}`);
|
|
147
|
-
lines.push(` path: ${yamlScalar(ep.path)}`);
|
|
148
|
-
if (ep.summary) lines.push(` summary: ${yamlScalar(ep.summary)}`);
|
|
149
|
-
if (ep.tags.length > 0) {
|
|
150
|
-
lines.push(` tags: [${ep.tags.map(yamlScalar).join(", ")}]`);
|
|
151
|
-
}
|
|
152
|
-
if (ep.deprecated) lines.push(` deprecated: true`);
|
|
153
|
-
|
|
154
|
-
if (ep.parameters && ep.parameters.length > 0) {
|
|
155
|
-
lines.push(` parameters:`);
|
|
156
|
-
for (const p of ep.parameters) {
|
|
157
|
-
lines.push(` - ${yamlScalar(p)}`);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (ep.requestBody) {
|
|
162
|
-
lines.push(` requestBody: ${yamlScalar(ep.requestBody)}`);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (ep.responses.length > 0) {
|
|
166
|
-
lines.push(` responses:`);
|
|
167
|
-
for (const r of ep.responses) {
|
|
168
|
-
if (r.schema) {
|
|
169
|
-
lines.push(` - status: ${r.status}`);
|
|
170
|
-
lines.push(` schema: ${yamlScalar(r.schema)}`);
|
|
171
|
-
} else {
|
|
172
|
-
lines.push(` - status: ${r.status}`);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
return lines.join("\n") + "\n";
|
|
179
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import type { EndpointInfo } from "./types.ts";
|
|
2
|
-
|
|
3
|
-
const CHUNK_THRESHOLD = 30;
|
|
4
|
-
|
|
5
|
-
export interface ChunkPlan {
|
|
6
|
-
totalEndpoints: number;
|
|
7
|
-
needsChunking: boolean;
|
|
8
|
-
chunks: Array<{ tag: string; count: number }>;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Group endpoints by their first tag. TASK-36: untagged endpoints fall
|
|
13
|
-
* back to per-resource grouping (first path segment), so `/audiences` and
|
|
14
|
-
* `/audiences/{id}` land in the same `audiences` group instead of being
|
|
15
|
-
* piled into a single `untagged` bucket. Endpoints whose path has no
|
|
16
|
-
* usable first segment (e.g. `/`) keep the legacy `untagged` key.
|
|
17
|
-
*/
|
|
18
|
-
export function groupEndpointsByTag(endpoints: EndpointInfo[]): Map<string, EndpointInfo[]> {
|
|
19
|
-
return Map.groupBy(endpoints, (ep) => ep.tags[0] ?? resourceKeyFromPath(ep.path));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/** Extract the first non-templated path segment for tagless fallback. */
|
|
23
|
-
function resourceKeyFromPath(path: string): string {
|
|
24
|
-
const segments = path.split("/").filter(Boolean);
|
|
25
|
-
for (const seg of segments) {
|
|
26
|
-
// Skip templated segments like {id} — they aren't resource names.
|
|
27
|
-
if (seg.startsWith("{") && seg.endsWith("}")) continue;
|
|
28
|
-
if (seg.length === 0) continue;
|
|
29
|
-
return seg;
|
|
30
|
-
}
|
|
31
|
-
return "untagged";
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/** Decide whether to chunk, and return the tag breakdown */
|
|
35
|
-
function planChunks(endpoints: EndpointInfo[]): ChunkPlan {
|
|
36
|
-
const groups = groupEndpointsByTag(endpoints);
|
|
37
|
-
const chunks = Array.from(groups.entries())
|
|
38
|
-
.map(([tag, eps]) => ({ tag, count: eps.length }))
|
|
39
|
-
.sort((a, b) => b.count - a.count);
|
|
40
|
-
|
|
41
|
-
return {
|
|
42
|
-
totalEndpoints: endpoints.length,
|
|
43
|
-
needsChunking: endpoints.length > CHUNK_THRESHOLD,
|
|
44
|
-
chunks,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Filter endpoints by tag (case-insensitive). Accepts a single tag or a
|
|
50
|
-
* comma-separated list (TASK-239) so callers can run one generate pass for
|
|
51
|
-
* multiple tags instead of looping in the shell — looping prints
|
|
52
|
-
* "Next steps" N times and drowns real warnings.
|
|
53
|
-
*/
|
|
54
|
-
export function filterByTag(endpoints: EndpointInfo[], tag: string): EndpointInfo[] {
|
|
55
|
-
const wanted = tag
|
|
56
|
-
.split(",")
|
|
57
|
-
.map(t => t.trim().toLowerCase())
|
|
58
|
-
.filter(t => t.length > 0);
|
|
59
|
-
if (wanted.length === 0) return [];
|
|
60
|
-
const includeUntagged = wanted.includes("untagged");
|
|
61
|
-
const explicit = wanted.filter(t => t !== "untagged");
|
|
62
|
-
return endpoints.filter(ep => {
|
|
63
|
-
if (includeUntagged && ep.tags.length === 0) return true;
|
|
64
|
-
return ep.tags.some(t => explicit.includes(t.trim().toLowerCase()));
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/** Collect the unique set of tags across all endpoints (sorted, original casing). */
|
|
69
|
-
export function collectTags(endpoints: EndpointInfo[]): string[] {
|
|
70
|
-
const seen = new Map<string, string>();
|
|
71
|
-
for (const ep of endpoints) {
|
|
72
|
-
for (const t of ep.tags) {
|
|
73
|
-
const key = t.trim().toLowerCase();
|
|
74
|
-
if (!seen.has(key)) seen.set(key, t.trim());
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return Array.from(seen.values()).sort((a, b) => a.localeCompare(b));
|
|
78
|
-
}
|
|
Binary file
|