dealsystem 0.0.1 → 0.2.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.
Files changed (104) hide show
  1. package/README.md +64 -2
  2. package/dist/api/errors.d.ts +25 -0
  3. package/dist/api/errors.js +38 -0
  4. package/dist/api/http.d.ts +56 -0
  5. package/dist/api/http.js +406 -0
  6. package/dist/api/legal.d.ts +9 -0
  7. package/dist/api/legal.js +20 -0
  8. package/dist/api/oauth.d.ts +35 -0
  9. package/dist/api/oauth.js +113 -0
  10. package/dist/api/types.d.ts +142 -0
  11. package/dist/api/types.js +9 -0
  12. package/dist/auth/credentials.d.ts +28 -0
  13. package/dist/auth/credentials.js +96 -0
  14. package/dist/auth/session.d.ts +10 -0
  15. package/dist/auth/session.js +46 -0
  16. package/dist/bin.d.ts +2 -0
  17. package/dist/bin.js +4 -0
  18. package/dist/check/allowlist.d.ts +9 -0
  19. package/dist/check/allowlist.js +74 -0
  20. package/dist/check/catalog.d.ts +6 -0
  21. package/dist/check/catalog.js +410 -0
  22. package/dist/check/context.d.ts +79 -0
  23. package/dist/check/context.js +230 -0
  24. package/dist/check/fileset.d.ts +19 -0
  25. package/dist/check/fileset.js +91 -0
  26. package/dist/check/format.d.ts +25 -0
  27. package/dist/check/format.js +79 -0
  28. package/dist/check/index.d.ts +8 -0
  29. package/dist/check/index.js +9 -0
  30. package/dist/check/rule.d.ts +15 -0
  31. package/dist/check/rule.js +6 -0
  32. package/dist/check/rules/a11y.d.ts +3 -0
  33. package/dist/check/rules/a11y.js +433 -0
  34. package/dist/check/rules/privacy.d.ts +9 -0
  35. package/dist/check/rules/privacy.js +437 -0
  36. package/dist/check/rules/quality.d.ts +11 -0
  37. package/dist/check/rules/quality.js +451 -0
  38. package/dist/check/rules/schedule.d.ts +2 -0
  39. package/dist/check/rules/schedule.js +30 -0
  40. package/dist/check/rules/security.d.ts +18 -0
  41. package/dist/check/rules/security.js +744 -0
  42. package/dist/check/rules/structure.d.ts +2 -0
  43. package/dist/check/rules/structure.js +399 -0
  44. package/dist/check/run.d.ts +15 -0
  45. package/dist/check/run.js +147 -0
  46. package/dist/check/sdk.d.ts +56 -0
  47. package/dist/check/sdk.js +58 -0
  48. package/dist/check/types.d.ts +116 -0
  49. package/dist/check/types.js +2 -0
  50. package/dist/check/util/code.d.ts +19 -0
  51. package/dist/check/util/code.js +113 -0
  52. package/dist/check/util/color.d.ts +10 -0
  53. package/dist/check/util/color.js +53 -0
  54. package/dist/check/util/csp.d.ts +71 -0
  55. package/dist/check/util/csp.js +229 -0
  56. package/dist/check/util/html.d.ts +31 -0
  57. package/dist/check/util/html.js +65 -0
  58. package/dist/check/util/lines.d.ts +1 -0
  59. package/dist/check/util/lines.js +2 -0
  60. package/dist/check/util/literal.d.ts +1 -0
  61. package/dist/check/util/literal.js +3 -0
  62. package/dist/check/util/svelte.d.ts +42 -0
  63. package/dist/check/util/svelte.js +109 -0
  64. package/dist/cli/context.d.ts +40 -0
  65. package/dist/cli/context.js +107 -0
  66. package/dist/cli/io.d.ts +26 -0
  67. package/dist/cli/io.js +68 -0
  68. package/dist/cli/main.d.ts +24 -0
  69. package/dist/cli/main.js +269 -0
  70. package/dist/commands/check.d.ts +4 -0
  71. package/dist/commands/check.js +54 -0
  72. package/dist/commands/deploy.d.ts +20 -0
  73. package/dist/commands/deploy.js +315 -0
  74. package/dist/commands/dev.d.ts +29 -0
  75. package/dist/commands/dev.js +149 -0
  76. package/dist/commands/image.d.ts +12 -0
  77. package/dist/commands/image.js +291 -0
  78. package/dist/commands/login.d.ts +3 -0
  79. package/dist/commands/login.js +116 -0
  80. package/dist/commands/pull.d.ts +12 -0
  81. package/dist/commands/pull.js +178 -0
  82. package/dist/commands/site.d.ts +9 -0
  83. package/dist/commands/site.js +84 -0
  84. package/dist/commands/sync.d.ts +2 -0
  85. package/dist/commands/sync.js +126 -0
  86. package/dist/index.d.ts +10 -0
  87. package/dist/index.js +10 -0
  88. package/dist/project/agentFiles.d.ts +17 -0
  89. package/dist/project/agentFiles.js +156 -0
  90. package/dist/project/agentsBlock.d.ts +2 -0
  91. package/dist/project/agentsBlock.js +14 -0
  92. package/dist/project/siteConfig.d.ts +5 -0
  93. package/dist/project/siteConfig.js +35 -0
  94. package/dist/project/snapshot.d.ts +21 -0
  95. package/dist/project/snapshot.js +125 -0
  96. package/dist/project/svelteConfig.d.ts +4 -0
  97. package/dist/project/svelteConfig.js +74 -0
  98. package/dist/project/tar.d.ts +8 -0
  99. package/dist/project/tar.js +89 -0
  100. package/dist/project/untar.d.ts +27 -0
  101. package/dist/project/untar.js +232 -0
  102. package/dist/project/uploadFiles.d.ts +17 -0
  103. package/dist/project/uploadFiles.js +55 -0
  104. package/package.json +63 -7
@@ -0,0 +1,230 @@
1
+ // Gemeinsamer, zwischengespeicherter Zugriff der Regeln auf Quelle und Ausgabe.
2
+ import { buildCspDirectives } from '@dealsystem/site/config';
3
+ import { readSiteConfig, SITE_CONFIG_FILE } from '../project/siteConfig.js';
4
+ import { codeWithoutComments, isScriptFile, isSvelteFile } from './util/code.js';
5
+ import { parseHtml } from './util/html.js';
6
+ import { LineIndex } from './util/lines.js';
7
+ import { parseModule } from './util/literal.js';
8
+ import { parseSvelte } from './util/svelte.js';
9
+ function isProbablyText(bytes) {
10
+ const n = Math.min(bytes.length, 8000);
11
+ for (let i = 0; i < n; i++)
12
+ if (bytes[i] === 0)
13
+ return false;
14
+ return true;
15
+ }
16
+ const TEXT_EXTENSIONS = [
17
+ '.svelte',
18
+ '.ts',
19
+ '.js',
20
+ '.mjs',
21
+ '.cjs',
22
+ '.mts',
23
+ '.cts',
24
+ '.json',
25
+ '.html',
26
+ '.htm',
27
+ '.css',
28
+ '.scss',
29
+ '.sass',
30
+ '.less',
31
+ '.md',
32
+ '.txt',
33
+ '.xml',
34
+ '.svg',
35
+ '.webmanifest',
36
+ '.yml',
37
+ '.yaml',
38
+ '.env',
39
+ ];
40
+ export function isTextPath(path) {
41
+ const base = path.split('/').pop() ?? path;
42
+ return base.startsWith('.env') || TEXT_EXTENSIONS.some((ext) => base.endsWith(ext));
43
+ }
44
+ class BaseContext {
45
+ files;
46
+ options;
47
+ texts = new Map();
48
+ lineIndexes = new Map();
49
+ constructor(files, options) {
50
+ this.files = files;
51
+ this.options = options;
52
+ }
53
+ paths() {
54
+ return this.files.list().map((f) => f.path);
55
+ }
56
+ text(path) {
57
+ if (!this.texts.has(path))
58
+ this.texts.set(path, this.files.readText(path));
59
+ return this.texts.get(path) ?? null;
60
+ }
61
+ /**
62
+ * Alle Textdateien (nach Endung; Binärdateien werden übersprungen). Mit `anyExtension` zählt jede Datei
63
+ * ohne Null-Bytes bis 5 MB (für die Secret-Suche: Schlüssel stehen auch in `.pem` oder ohne Endung).
64
+ */
65
+ textFiles(filter = () => true, anyExtension = false) {
66
+ return this.files
67
+ .list()
68
+ .filter((entry) => {
69
+ const p = entry.path;
70
+ if (!filter(p))
71
+ return false;
72
+ if (anyExtension ? entry.size > 5 * 1024 * 1024 : !isTextPath(p))
73
+ return false;
74
+ const bytes = this.files.readBytes(p);
75
+ return bytes !== null && isProbablyText(bytes);
76
+ })
77
+ .map((entry) => entry.path);
78
+ }
79
+ lines(path) {
80
+ let idx = this.lineIndexes.get(path);
81
+ if (!idx) {
82
+ idx = new LineIndex(this.text(path) ?? '');
83
+ this.lineIndexes.set(path, idx);
84
+ }
85
+ return idx;
86
+ }
87
+ /** Fund an einem Zeichen-Offset. */
88
+ at(path, offset, message, fix) {
89
+ const pos = this.lines(path).at(offset);
90
+ return { file: path, line: pos.line, column: pos.column, message, ...(fix !== undefined ? { fix } : {}) };
91
+ }
92
+ }
93
+ export class SourceContext extends BaseContext {
94
+ codes = new Map();
95
+ svelteAsts = new Map();
96
+ modules = new Map();
97
+ siteConfigResult;
98
+ /** Text mit ausgeblendeten Kommentaren. */
99
+ code(path) {
100
+ let c = this.codes.get(path);
101
+ if (c === undefined) {
102
+ c = codeWithoutComments(path, this.text(path) ?? '');
103
+ this.codes.set(path, c);
104
+ }
105
+ return c;
106
+ }
107
+ svelte(path) {
108
+ if (!this.svelteAsts.has(path))
109
+ this.svelteAsts.set(path, parseSvelte(this.text(path) ?? ''));
110
+ return this.svelteAsts.get(path) ?? null;
111
+ }
112
+ module(path) {
113
+ const text = this.text(path);
114
+ if (text === null)
115
+ return null;
116
+ let mod = this.modules.get(path);
117
+ if (!mod) {
118
+ mod = parseModule(path, text);
119
+ this.modules.set(path, mod);
120
+ }
121
+ return mod;
122
+ }
123
+ /** Svelte-Dateien unter `src/`. */
124
+ svelteFiles() {
125
+ return this.paths().filter((p) => p.startsWith('src/') && isSvelteFile(p));
126
+ }
127
+ /** Skript- und Svelte-Dateien unter `src/` (ohne erzeugte Typen). */
128
+ codeFiles() {
129
+ return this.paths().filter((p) => p.startsWith('src/') && (isSvelteFile(p) || isScriptFile(p)) && !p.includes('/_generated/'));
130
+ }
131
+ /** HTML-Dateien der Quelle (`src/app.html`, `static/**.html`). */
132
+ htmlFiles() {
133
+ return this.paths().filter((p) => p.endsWith('.html') && (p.startsWith('src/') || p.startsWith('static/')));
134
+ }
135
+ /** CSS-Dateien der Quelle. */
136
+ cssFiles() {
137
+ return this.paths().filter((p) => /\.(css|scss|sass|less)$/.test(p));
138
+ }
139
+ siteConfig() {
140
+ this.siteConfigResult ??= readSiteConfig(this.text(SITE_CONFIG_FILE));
141
+ return this.siteConfigResult;
142
+ }
143
+ svelteConfigPath() {
144
+ return ['svelte.config.js', 'svelte.config.ts'].find((p) => this.files.has(p)) ?? null;
145
+ }
146
+ json(path) {
147
+ const text = this.text(path);
148
+ if (text === null)
149
+ return { data: null, error: 'fehlt' };
150
+ try {
151
+ const data = JSON.parse(text);
152
+ if (typeof data !== 'object' || data === null || Array.isArray(data))
153
+ return { data: null, error: 'kein Objekt' };
154
+ return { data: data, error: null };
155
+ }
156
+ catch (e) {
157
+ return { data: null, error: e.message };
158
+ }
159
+ }
160
+ /** Installierte Version von `@dealsystem/site` laut Lockfile. */
161
+ sdkVersion() {
162
+ const lock = this.json('package-lock.json').data;
163
+ const packages = lock?.packages;
164
+ const version = packages?.['node_modules/@dealsystem/site']?.version;
165
+ return typeof version === 'string' ? version : null;
166
+ }
167
+ }
168
+ export class OutputContext extends BaseContext {
169
+ docs = new Map();
170
+ /**
171
+ * Deklaration für die erwartete CSP: aus `options.external` (Build-Host, aus dem Manifest) oder aus der Quelle
172
+ * desselben Laufs. `strict`: Abweichungen sind Fehler (neues SDK), sonst Warnungen. `null`: unbekannt.
173
+ */
174
+ declared = null;
175
+ /** Erwartete CSP der fertigen Seiten; `null`, wenn die Deklaration unbekannt ist. */
176
+ expectedCsp(apiOrigin) {
177
+ if (!this.declared)
178
+ return null;
179
+ // Ob im CRM eine Google-Ads-Kennung steht, weiß die Prüfung nicht: Die festen Ads-Hosts von Google
180
+ // (`GOOGLE_ADS_CSP`, nur über `<Tracking>` nach Einwilligung) sind deshalb erlaubt, aber nicht verlangt.
181
+ return {
182
+ csp: buildCspDirectives(this.declared.external, apiOrigin, { googleAds: true }),
183
+ strict: this.declared.strict,
184
+ };
185
+ }
186
+ html(path) {
187
+ let doc = this.docs.get(path);
188
+ if (!doc) {
189
+ doc = parseHtml(this.text(path) ?? '');
190
+ this.docs.set(path, doc);
191
+ }
192
+ return doc;
193
+ }
194
+ /** Alle HTML-Seiten der Ausgabe. */
195
+ pages() {
196
+ return this.paths().filter((p) => p.endsWith('.html'));
197
+ }
198
+ /** Seiten ohne Fehler- und Ausweichseiten (404.html, 200.html, index.html der SPA-Ausweiche). */
199
+ contentPages() {
200
+ return this.pages().filter((p) => !['404.html', '200.html', 'fallback.html'].includes(p));
201
+ }
202
+ /** Host der Seite, falls bekannt. */
203
+ siteHost() {
204
+ if (!this.options.siteUrl)
205
+ return null;
206
+ try {
207
+ return new URL(this.options.siteUrl).host.toLowerCase();
208
+ }
209
+ catch {
210
+ return null;
211
+ }
212
+ }
213
+ }
214
+ /** Route einer Ausgabe-Datei: `index.html` → `/`, `a/index.html` und `a.html` → `/a`. */
215
+ export function routeOfPage(path) {
216
+ let p = path.replace(/\.html$/, '');
217
+ if (p === 'index')
218
+ return '/';
219
+ if (p.endsWith('/index'))
220
+ p = p.slice(0, -'/index'.length);
221
+ return `/${p}`;
222
+ }
223
+ /** Route einer Quell-Datei unter `src/routes` ohne Gruppen: `src/routes/(app)/a/+page.svelte` → `/a`. */
224
+ export function routeOfSource(path) {
225
+ const parts = path
226
+ .split('/')
227
+ .slice(2, -1)
228
+ .filter((s) => !(s.startsWith('(') && s.endsWith(')')));
229
+ return `/${parts.join('/')}`;
230
+ }
@@ -0,0 +1,19 @@
1
+ import type { FileEntry, FileSet } from './types.js';
2
+ /** Ordner, die nie zur Quelle gehören (Abhängigkeiten, Build-Zwischenstände, lokale Kopien). */
3
+ export declare const IGNORED_DIRS: ReadonlySet<string>;
4
+ export interface WalkOptions {
5
+ /** Ordnernamen, die übersprungen werden (auf jeder Ebene). Standard: keine. */
6
+ ignoreDirs?: ReadonlySet<string>;
7
+ /** Zusätzlicher Filter auf den relativen Pfad. */
8
+ include?: (path: string) => boolean;
9
+ }
10
+ export interface WalkResult {
11
+ files: FileEntry[];
12
+ /** Symlinks und andere Sonderdateien, die übersprungen wurden. */
13
+ skipped: string[];
14
+ }
15
+ export declare function walkDir(root: string, options?: WalkOptions): WalkResult;
16
+ /** Dateimenge über einen Ordner. Inhalte werden beim ersten Lesen zwischengespeichert. */
17
+ export declare function createDirFileSet(root: string, options?: WalkOptions): FileSet;
18
+ /** Dateimenge aus dem Speicher (Tests, Werkzeuge). */
19
+ export declare function createMemoryFileSet(input: Record<string, string | Uint8Array>): FileSet;
@@ -0,0 +1,91 @@
1
+ // Dateimengen für den Regelkatalog: ein Ordner auf der Platte oder eine Speicher-Variante.
2
+ // Nur reguläre Dateien; Symlinks werden nie verfolgt (ein Tarball darf keine enthalten).
3
+ import { lstatSync, readdirSync, readFileSync } from 'node:fs';
4
+ import { join } from 'node:path';
5
+ /** Ordner, die nie zur Quelle gehören (Abhängigkeiten, Build-Zwischenstände, lokale Kopien). */
6
+ export const IGNORED_DIRS = new Set([
7
+ 'node_modules',
8
+ '.git',
9
+ '.svelte-kit',
10
+ 'build',
11
+ '.dealsystem',
12
+ '.vercel',
13
+ '.netlify',
14
+ '.output',
15
+ ]);
16
+ export function walkDir(root, options = {}) {
17
+ const files = [];
18
+ const skipped = [];
19
+ const ignore = options.ignoreDirs ?? new Set();
20
+ const visit = (abs, rel) => {
21
+ const entries = readdirSync(abs, { withFileTypes: true }).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
22
+ for (const entry of entries) {
23
+ const childRel = rel ? `${rel}/${entry.name}` : entry.name;
24
+ const childAbs = join(abs, entry.name);
25
+ if (entry.isSymbolicLink()) {
26
+ skipped.push(childRel);
27
+ continue;
28
+ }
29
+ if (entry.isDirectory()) {
30
+ if (ignore.has(entry.name))
31
+ continue;
32
+ visit(childAbs, childRel);
33
+ continue;
34
+ }
35
+ if (!entry.isFile()) {
36
+ skipped.push(childRel);
37
+ continue;
38
+ }
39
+ if (options.include && !options.include(childRel))
40
+ continue;
41
+ files.push({ path: childRel, size: lstatSync(childAbs).size });
42
+ }
43
+ };
44
+ visit(root, '');
45
+ files.sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));
46
+ return { files, skipped };
47
+ }
48
+ /** Dateimenge über einen Ordner. Inhalte werden beim ersten Lesen zwischengespeichert. */
49
+ export function createDirFileSet(root, options = { ignoreDirs: IGNORED_DIRS }) {
50
+ const { files } = walkDir(root, options);
51
+ const byPath = new Set(files.map((f) => f.path));
52
+ const cache = new Map();
53
+ const bytes = (path) => {
54
+ if (!byPath.has(path))
55
+ return null;
56
+ let data = cache.get(path);
57
+ if (!data) {
58
+ data = readFileSync(join(root, ...path.split('/')));
59
+ cache.set(path, data);
60
+ }
61
+ return data;
62
+ };
63
+ return {
64
+ list: () => files,
65
+ has: (path) => byPath.has(path),
66
+ readBytes: bytes,
67
+ readText: (path) => {
68
+ const data = bytes(path);
69
+ return data ? Buffer.from(data).toString('utf8') : null;
70
+ },
71
+ };
72
+ }
73
+ /** Dateimenge aus dem Speicher (Tests, Werkzeuge). */
74
+ export function createMemoryFileSet(input) {
75
+ const entries = new Map();
76
+ for (const [path, value] of Object.entries(input)) {
77
+ entries.set(path, typeof value === 'string' ? Buffer.from(value, 'utf8') : value);
78
+ }
79
+ const files = [...entries.entries()]
80
+ .map(([path, data]) => ({ path, size: data.byteLength }))
81
+ .sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));
82
+ return {
83
+ list: () => files,
84
+ has: (path) => entries.has(path),
85
+ readBytes: (path) => entries.get(path) ?? null,
86
+ readText: (path) => {
87
+ const data = entries.get(path);
88
+ return data ? Buffer.from(data).toString('utf8') : null;
89
+ },
90
+ };
91
+ }
@@ -0,0 +1,25 @@
1
+ import type { CheckResult, Finding } from './types.js';
2
+ export declare function formatLocation(f: Pick<Finding, 'file' | 'line'>): string;
3
+ /** Eine Zeile je Fund. */
4
+ export declare function formatFinding(f: Finding): string;
5
+ export declare function formatCheckText(result: CheckResult): string;
6
+ /** Feste Feldreihenfolge, damit `--json` zwischen Läufen und Versionen gleich aussieht. */
7
+ export declare function findingToJson(f: Finding): Finding;
8
+ export declare function checkResultToJson(result: CheckResult): CheckResult;
9
+ export interface BuildReportFinding {
10
+ rule: string;
11
+ file: string | null;
12
+ line: number | null;
13
+ message: string;
14
+ fix: string;
15
+ }
16
+ export interface BuildReportCheck {
17
+ ruleSetVersion: string;
18
+ errors: BuildReportFinding[];
19
+ warnings: BuildReportFinding[];
20
+ }
21
+ /**
22
+ * `check`-Teil von `POST /api/internal/self-site/build/{versionId}/report`. Mehrere Läufe (Quelle vor dem
23
+ * Build, Ausgabe danach) werden zusammengeführt. Höchstens `limit` Funde je Liste (Core kappt bei 200).
24
+ */
25
+ export declare function toBuildReportCheck(results: CheckResult[], limit?: number): BuildReportCheck;
@@ -0,0 +1,79 @@
1
+ // Ausgabe des Prüfergebnisses: als Text („Datei:Zeile – Problem – so behebst du es“), als stabiles JSON und
2
+ // als `check`-Teil des Build-Reports an den Core (5.3).
3
+ export function formatLocation(f) {
4
+ if (!f.file)
5
+ return '(Projekt)';
6
+ return f.line ? `${f.file}:${f.line}` : f.file;
7
+ }
8
+ /** Eine Zeile je Fund. */
9
+ export function formatFinding(f) {
10
+ const tag = f.severity === 'error' ? 'Fehler' : 'Warnung';
11
+ return `${formatLocation(f)} – ${f.message} – ${f.fix} [${f.rule}, ${tag}]`;
12
+ }
13
+ export function formatCheckText(result) {
14
+ const lines = [];
15
+ for (const f of [...result.errors, ...result.warnings])
16
+ lines.push(formatFinding(f));
17
+ const warnings = `${result.warnings.length} Warnung${result.warnings.length === 1 ? '' : 'en'}`;
18
+ const both = result.stages.includes('source') && result.stages.includes('output');
19
+ if (!result.passed) {
20
+ lines.push(`Prüfung fehlgeschlagen: ${result.errors.length} Fehler, ${warnings}.`);
21
+ }
22
+ else if (both) {
23
+ // Die eine Zeile, die ein Agent zitieren darf, wenn er „geprüft“ sagt.
24
+ lines.push(`Prüfung bestanden: Quelltext und fertige Seite geprüft, 0 Fehler, ${warnings}.`);
25
+ }
26
+ else if (result.stages.includes('source')) {
27
+ lines.push(`Quelltext geprüft: 0 Fehler, ${warnings}. Die fertige Seite ist noch NICHT geprüft. ` +
28
+ 'Vollständig geprüft ist erst nach `npm run build` und `npx dealsystem check --output build`.');
29
+ }
30
+ else {
31
+ lines.push(`Fertige Seite geprüft: 0 Fehler, ${warnings}. Der Quelltext ist nicht geprüft.`);
32
+ }
33
+ return lines.join('\n');
34
+ }
35
+ /** Feste Feldreihenfolge, damit `--json` zwischen Läufen und Versionen gleich aussieht. */
36
+ export function findingToJson(f) {
37
+ return {
38
+ rule: f.rule,
39
+ severity: f.severity,
40
+ file: f.file,
41
+ line: f.line,
42
+ column: f.column,
43
+ message: f.message,
44
+ fix: f.fix,
45
+ };
46
+ }
47
+ export function checkResultToJson(result) {
48
+ return {
49
+ passed: result.passed,
50
+ ruleSetVersion: result.ruleSetVersion,
51
+ stages: [...result.stages],
52
+ errors: result.errors.map(findingToJson),
53
+ warnings: result.warnings.map(findingToJson),
54
+ };
55
+ }
56
+ /**
57
+ * `check`-Teil von `POST /api/internal/self-site/build/{versionId}/report`. Mehrere Läufe (Quelle vor dem
58
+ * Build, Ausgabe danach) werden zusammengeführt. Höchstens `limit` Funde je Liste (Core kappt bei 200).
59
+ */
60
+ export function toBuildReportCheck(results, limit = 200) {
61
+ const pick = (f) => ({
62
+ rule: f.rule,
63
+ file: f.file,
64
+ line: f.line,
65
+ message: f.message,
66
+ fix: f.fix,
67
+ });
68
+ return {
69
+ ruleSetVersion: results[0]?.ruleSetVersion ?? '',
70
+ errors: results
71
+ .flatMap((r) => r.errors)
72
+ .slice(0, limit)
73
+ .map(pick),
74
+ warnings: results
75
+ .flatMap((r) => r.warnings)
76
+ .slice(0, limit)
77
+ .map(pick),
78
+ };
79
+ }
@@ -0,0 +1,8 @@
1
+ export { runCheck, RuleSetMismatchError, RULE_IMPLEMENTATIONS } from './run.js';
2
+ export { RULES, RULE_SET_VERSION, DEFAULT_SDK_RANGE, getRule } from './catalog.js';
3
+ export { ALLOWED_PACKAGES, ALTERNATIVES, isAllowedPackage } from './allowlist.js';
4
+ export { createDirFileSet, createMemoryFileSet, IGNORED_DIRS } from './fileset.js';
5
+ export { checkResultToJson, findingToJson, formatCheckText, formatFinding, toBuildReportCheck, type BuildReportCheck, type BuildReportFinding, } from './format.js';
6
+ export { SECRET_PATTERNS } from './rules/security.js';
7
+ export { OUTPUT_LIMITS } from './rules/quality.js';
8
+ export type { CheckOptions, CheckPlugin, CheckResult, CheckStage, FileEntry, FileSet, Finding, PluginInput, RawFinding, RuleMeta, Severity, } from './types.js';
@@ -0,0 +1,9 @@
1
+ // Einstiegspunkt `dealsystem/check`: Regelkatalog als Bibliothek für CLI und Build-Host.
2
+ // Ohne Netz, ohne Browser, ohne Ausführen von Projektcode.
3
+ export { runCheck, RuleSetMismatchError, RULE_IMPLEMENTATIONS } from './run.js';
4
+ export { RULES, RULE_SET_VERSION, DEFAULT_SDK_RANGE, getRule } from './catalog.js';
5
+ export { ALLOWED_PACKAGES, ALTERNATIVES, isAllowedPackage } from './allowlist.js';
6
+ export { createDirFileSet, createMemoryFileSet, IGNORED_DIRS } from './fileset.js';
7
+ export { checkResultToJson, findingToJson, formatCheckText, formatFinding, toBuildReportCheck, } from './format.js';
8
+ export { SECRET_PATTERNS } from './rules/security.js';
9
+ export { OUTPUT_LIMITS } from './rules/quality.js';
@@ -0,0 +1,15 @@
1
+ import type { OutputContext, SourceContext } from './context.js';
2
+ import type { RawFinding } from './types.js';
3
+ export interface SourceRule {
4
+ id: string;
5
+ stage: 'source';
6
+ run(ctx: SourceContext): RawFinding[];
7
+ }
8
+ export interface OutputRule {
9
+ id: string;
10
+ stage: 'output';
11
+ run(ctx: OutputContext): RawFinding[];
12
+ }
13
+ export type RuleImpl = SourceRule | OutputRule;
14
+ export declare function sourceRule(id: string, run: (ctx: SourceContext) => RawFinding[]): SourceRule;
15
+ export declare function outputRule(id: string, run: (ctx: OutputContext) => RawFinding[]): OutputRule;
@@ -0,0 +1,6 @@
1
+ export function sourceRule(id, run) {
2
+ return { id, stage: 'source', run };
3
+ }
4
+ export function outputRule(id, run) {
5
+ return { id, stage: 'output', run };
6
+ }
@@ -0,0 +1,3 @@
1
+ import { type OutputRule, type SourceRule } from '../rule.js';
2
+ export declare const a11ySourceRules: SourceRule[];
3
+ export declare const a11yOutputRules: OutputRule[];