@goodbones/core 0.1.0-beta.7 → 0.1.0-beta.8
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/build/dts/core/campaigns.d.ts +140 -0
- package/build/dts/core/campaigns.d.ts.map +1 -0
- package/build/dts/core/ledger.d.ts +61 -0
- package/build/dts/core/ledger.d.ts.map +1 -0
- package/build/dts/core/structure.d.ts +1 -0
- package/build/dts/core/structure.d.ts.map +1 -1
- package/build/dts/domain/architecture-config.d.ts +309 -1
- package/build/dts/domain/architecture-config.d.ts.map +1 -1
- package/build/dts/domain/facts.d.ts +1 -0
- package/build/dts/domain/facts.d.ts.map +1 -1
- package/build/dts/domain/report.d.ts +15 -0
- package/build/dts/domain/report.d.ts.map +1 -0
- package/build/dts/domain/snapshot.d.ts +55 -3
- package/build/dts/domain/snapshot.d.ts.map +1 -1
- package/build/dts/domain/violation.d.ts +1 -1
- package/build/dts/domain/violation.d.ts.map +1 -1
- package/build/dts/index.d.ts +11 -3
- package/build/dts/index.d.ts.map +1 -1
- package/build/dts/infrastructure/campaign-functions.d.ts +7 -0
- package/build/dts/infrastructure/campaign-functions.d.ts.map +1 -0
- package/build/dts/infrastructure/report-source-fake.d.ts +4 -0
- package/build/dts/infrastructure/report-source-fake.d.ts.map +1 -0
- package/build/dts/infrastructure/report-source-live.d.ts +3 -0
- package/build/dts/infrastructure/report-source-live.d.ts.map +1 -0
- package/build/dts/infrastructure/syntax-matcher-fake.d.ts +10 -0
- package/build/dts/infrastructure/syntax-matcher-fake.d.ts.map +1 -0
- package/build/dts/load/policy.d.ts +14 -0
- package/build/dts/load/policy.d.ts.map +1 -1
- package/build/dts/manifest/compile.d.ts +2 -1
- package/build/dts/manifest/compile.d.ts.map +1 -1
- package/build/dts/manifest/json-schema.d.ts.map +1 -1
- package/build/dts/manifest/manifest.d.ts +362 -0
- package/build/dts/manifest/manifest.d.ts.map +1 -1
- package/build/dts/ports/campaign-predicate.d.ts +24 -0
- package/build/dts/ports/campaign-predicate.d.ts.map +1 -0
- package/build/dts/ports/language.d.ts +2 -0
- package/build/dts/ports/language.d.ts.map +1 -1
- package/build/dts/ports/report-source.d.ts +12 -0
- package/build/dts/ports/report-source.d.ts.map +1 -0
- package/build/dts/ports/syntax-matcher.d.ts +21 -0
- package/build/dts/ports/syntax-matcher.d.ts.map +1 -0
- package/build/dts/testing.d.ts +2 -0
- package/build/dts/testing.d.ts.map +1 -1
- package/build/esm/core/campaigns.js +732 -0
- package/build/esm/core/campaigns.js.map +1 -0
- package/build/esm/core/ledger.js +171 -0
- package/build/esm/core/ledger.js.map +1 -0
- package/build/esm/core/structure.js +5 -2
- package/build/esm/core/structure.js.map +1 -1
- package/build/esm/domain/architecture-config.js +133 -1
- package/build/esm/domain/architecture-config.js.map +1 -1
- package/build/esm/domain/report.js +151 -0
- package/build/esm/domain/report.js.map +1 -0
- package/build/esm/domain/snapshot.js +21 -0
- package/build/esm/domain/snapshot.js.map +1 -1
- package/build/esm/domain/violation.js.map +1 -1
- package/build/esm/index.js +7 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/infrastructure/campaign-functions.js +67 -0
- package/build/esm/infrastructure/campaign-functions.js.map +1 -0
- package/build/esm/infrastructure/report-source-fake.js +6 -0
- package/build/esm/infrastructure/report-source-fake.js.map +1 -0
- package/build/esm/infrastructure/report-source-live.js +57 -0
- package/build/esm/infrastructure/report-source-live.js.map +1 -0
- package/build/esm/infrastructure/syntax-matcher-fake.js +33 -0
- package/build/esm/infrastructure/syntax-matcher-fake.js.map +1 -0
- package/build/esm/load/policy.js +121 -1
- package/build/esm/load/policy.js.map +1 -1
- package/build/esm/manifest/compile.js +186 -1
- package/build/esm/manifest/compile.js.map +1 -1
- package/build/esm/manifest/json-schema.js +7 -3
- package/build/esm/manifest/json-schema.js.map +1 -1
- package/build/esm/manifest/manifest.js +148 -1
- package/build/esm/manifest/manifest.js.map +1 -1
- package/build/esm/ports/campaign-predicate.js +2 -0
- package/build/esm/ports/campaign-predicate.js.map +1 -0
- package/build/esm/ports/report-source.js +2 -0
- package/build/esm/ports/report-source.js.map +1 -0
- package/build/esm/ports/syntax-matcher.js +12 -0
- package/build/esm/ports/syntax-matcher.js.map +1 -0
- package/build/esm/testing.js +2 -0
- package/build/esm/testing.js.map +1 -1
- package/package.json +1 -1
- package/schema/architecture-node.schema.json +843 -0
- package/schema/architecture.schema.json +1253 -0
- package/schema/conformance.schema.json +118 -3
- package/src/core/campaigns.ts +1006 -0
- package/src/core/ledger.ts +242 -0
- package/src/core/structure.ts +10 -5
- package/src/domain/architecture-config.ts +178 -1
- package/src/domain/facts.ts +5 -0
- package/src/domain/report.ts +186 -0
- package/src/domain/snapshot.ts +52 -0
- package/src/domain/violation.ts +4 -1
- package/src/index.ts +74 -0
- package/src/infrastructure/campaign-functions.ts +98 -0
- package/src/infrastructure/report-source-fake.ts +10 -0
- package/src/infrastructure/report-source-live.ts +66 -0
- package/src/infrastructure/syntax-matcher-fake.ts +51 -0
- package/src/load/policy.ts +187 -1
- package/src/manifest/compile.ts +221 -0
- package/src/manifest/json-schema.ts +7 -3
- package/src/manifest/manifest.ts +192 -1
- package/src/ports/campaign-predicate.ts +30 -0
- package/src/ports/language.ts +6 -0
- package/src/ports/report-source.ts +21 -0
- package/src/ports/syntax-matcher.ts +42 -0
- package/src/testing.ts +2 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// A campaign's `report` term names a pattern no parser of ours sees: a type
|
|
2
|
+
// error, a lint finding from another tool, anything a program prints one
|
|
3
|
+
// line per occurrence. This is the vocabulary such a report is read into —
|
|
4
|
+
// a diagnostic with a file, a position, a code and a message — and the
|
|
5
|
+
// readers for the formats a report comes in. Pure: text in, diagnostics out.
|
|
6
|
+
// Running the command or reading the file is the report source's business.
|
|
7
|
+
const relativeTo = (repoRoot, file) => {
|
|
8
|
+
const slashed = file.replaceAll("\\", "/");
|
|
9
|
+
const root = repoRoot.replaceAll("\\", "/").replace(/\/$/, "");
|
|
10
|
+
const relative = slashed === root
|
|
11
|
+
? ""
|
|
12
|
+
: slashed.startsWith(`${root}/`)
|
|
13
|
+
? slashed.slice(root.length + 1)
|
|
14
|
+
: slashed;
|
|
15
|
+
return relative.replace(/^\.\//, "");
|
|
16
|
+
};
|
|
17
|
+
const oneBased = (value, fallback = 1) => {
|
|
18
|
+
const parsed = Number(value);
|
|
19
|
+
return Number.isFinite(parsed) && parsed >= 1 ? parsed - 1 : fallback - 1;
|
|
20
|
+
};
|
|
21
|
+
const firstLine = (message) => message.split(/\r?\n/, 1)[0]?.trim() ?? "";
|
|
22
|
+
// `src/a.ts(12,5): error TS2551: Property 'x' does not exist…`, one per
|
|
23
|
+
// line, with the continuation lines tsc indents beneath a message ignored —
|
|
24
|
+
// the first line is the message.
|
|
25
|
+
const TSC_LINE = /^(.+?)\((\d+),(\d+)\): error (TS\d+): (.*)$/;
|
|
26
|
+
const parseTsc = (text, options) => {
|
|
27
|
+
const found = [];
|
|
28
|
+
for (const line of text.split(/\r?\n/)) {
|
|
29
|
+
const match = TSC_LINE.exec(line);
|
|
30
|
+
if (match === null)
|
|
31
|
+
continue;
|
|
32
|
+
const [, file = "", row, column, code = "", message = ""] = match;
|
|
33
|
+
found.push({
|
|
34
|
+
file: relativeTo(options.repoRoot, file),
|
|
35
|
+
line: oneBased(row),
|
|
36
|
+
column: oneBased(column),
|
|
37
|
+
code,
|
|
38
|
+
message: firstLine(message),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return found;
|
|
42
|
+
};
|
|
43
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
44
|
+
const asString = (value) => (typeof value === "string" ? value : "");
|
|
45
|
+
const asNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
|
46
|
+
const parseJson = (text, format) => {
|
|
47
|
+
try {
|
|
48
|
+
return JSON.parse(text);
|
|
49
|
+
}
|
|
50
|
+
catch (cause) {
|
|
51
|
+
throw new Error(`a ${format} report is JSON, and this one does not parse: ${String(cause)}`);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
// `eslint --format json`: one object per file with its messages. A message
|
|
55
|
+
// with no `ruleId` (a parse error) carries the code `""`.
|
|
56
|
+
const parseEslint = (text, options) => {
|
|
57
|
+
const parsed = parseJson(text, "eslint");
|
|
58
|
+
if (!Array.isArray(parsed))
|
|
59
|
+
throw new Error("an eslint report is a JSON array of files");
|
|
60
|
+
const found = [];
|
|
61
|
+
for (const entry of parsed) {
|
|
62
|
+
if (!isRecord(entry) || !Array.isArray(entry.messages))
|
|
63
|
+
continue;
|
|
64
|
+
const file = relativeTo(options.repoRoot, asString(entry.filePath));
|
|
65
|
+
for (const message of entry.messages) {
|
|
66
|
+
if (!isRecord(message))
|
|
67
|
+
continue;
|
|
68
|
+
found.push({
|
|
69
|
+
file,
|
|
70
|
+
line: (asNumber(message.line) ?? 1) - 1,
|
|
71
|
+
column: (asNumber(message.column) ?? 1) - 1,
|
|
72
|
+
code: asString(message.ruleId),
|
|
73
|
+
message: firstLine(asString(message.message)),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return found;
|
|
78
|
+
};
|
|
79
|
+
// `oxlint --format json`: `{ diagnostics: [{ filename, code, message,
|
|
80
|
+
// labels: [{ span: { line, column } }] }] }`, positions one-based.
|
|
81
|
+
const parseOxlint = (text, options) => {
|
|
82
|
+
const parsed = parseJson(text, "oxlint");
|
|
83
|
+
if (!isRecord(parsed) || !Array.isArray(parsed.diagnostics)) {
|
|
84
|
+
throw new Error("an oxlint report is a JSON object with a `diagnostics` array");
|
|
85
|
+
}
|
|
86
|
+
const found = [];
|
|
87
|
+
for (const entry of parsed.diagnostics) {
|
|
88
|
+
if (!isRecord(entry))
|
|
89
|
+
continue;
|
|
90
|
+
const labels = Array.isArray(entry.labels) ? entry.labels : [];
|
|
91
|
+
const label = labels[0];
|
|
92
|
+
const span = isRecord(label) && isRecord(label.span) ? label.span : {};
|
|
93
|
+
found.push({
|
|
94
|
+
file: relativeTo(options.repoRoot, asString(entry.filename)),
|
|
95
|
+
line: (asNumber(span.line) ?? 1) - 1,
|
|
96
|
+
column: (asNumber(span.column) ?? 1) - 1,
|
|
97
|
+
code: asString(entry.code),
|
|
98
|
+
message: firstLine(asString(entry.message)),
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
return found;
|
|
102
|
+
};
|
|
103
|
+
const parseRegex = (text, options) => {
|
|
104
|
+
if (options.pattern === undefined) {
|
|
105
|
+
throw new Error("a `regex` report needs a `pattern` with named groups `file` and `line`");
|
|
106
|
+
}
|
|
107
|
+
const pattern = new RegExp(options.pattern);
|
|
108
|
+
const found = [];
|
|
109
|
+
for (const line of text.split(/\r?\n/)) {
|
|
110
|
+
const match = pattern.exec(line);
|
|
111
|
+
if (match === null)
|
|
112
|
+
continue;
|
|
113
|
+
const groups = match.groups ?? {};
|
|
114
|
+
if (groups.file === undefined)
|
|
115
|
+
continue;
|
|
116
|
+
found.push({
|
|
117
|
+
file: relativeTo(options.repoRoot, groups.file),
|
|
118
|
+
line: oneBased(groups.line),
|
|
119
|
+
column: oneBased(groups.column),
|
|
120
|
+
code: groups.code ?? "",
|
|
121
|
+
message: firstLine(groups.message ?? ""),
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
return found;
|
|
125
|
+
};
|
|
126
|
+
export const parseReport = (format, text, options) => {
|
|
127
|
+
switch (format) {
|
|
128
|
+
case "tsc":
|
|
129
|
+
return parseTsc(text, options);
|
|
130
|
+
case "eslint":
|
|
131
|
+
return parseEslint(text, options);
|
|
132
|
+
case "oxlint":
|
|
133
|
+
return parseOxlint(text, options);
|
|
134
|
+
case "regex":
|
|
135
|
+
return parseRegex(text, options);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
// The diagnostics indexed by file, which is how a per-file evaluator asks
|
|
139
|
+
// for them.
|
|
140
|
+
export const indexByFile = (diagnostics) => {
|
|
141
|
+
const byFile = new Map();
|
|
142
|
+
for (const one of diagnostics) {
|
|
143
|
+
const found = byFile.get(one.file);
|
|
144
|
+
if (found === undefined)
|
|
145
|
+
byFile.set(one.file, [one]);
|
|
146
|
+
else
|
|
147
|
+
found.push(one);
|
|
148
|
+
}
|
|
149
|
+
return byFile;
|
|
150
|
+
};
|
|
151
|
+
//# sourceMappingURL=report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.js","sourceRoot":"","sources":["../../../src/domain/report.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,yEAAyE;AACzE,2EAA2E;AAC3E,uEAAuE;AACvE,6EAA6E;AAC7E,2EAA2E;AA0B3E,MAAM,UAAU,GAAG,CAAC,QAAgB,EAAE,IAAY,EAAU,EAAE;IAC5D,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC3C,MAAM,IAAI,GAAG,QAAQ,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC/D,MAAM,QAAQ,GACZ,OAAO,KAAK,IAAI;QACd,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,CAAC;YAC9B,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;YAChC,CAAC,CAAC,OAAO,CAAC;IAChB,OAAO,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AACvC,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,CAAC,KAAyB,EAAE,QAAQ,GAAG,CAAC,EAAU,EAAE;IACnE,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,GA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AAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -24,6 +24,7 @@ const VIOLATION_KINDS = [
|
|
|
24
24
|
"member",
|
|
25
25
|
"surface",
|
|
26
26
|
"graph",
|
|
27
|
+
"campaign",
|
|
27
28
|
];
|
|
28
29
|
const Path = describe(Schema.String, "Repo-relative, with forward slashes.");
|
|
29
30
|
const FamilyCoverage = Schema.Struct({
|
|
@@ -39,6 +40,7 @@ export const SnapshotViolation = Schema.Struct({
|
|
|
39
40
|
subject: describe(Schema.NullOr(Schema.String), "The other end of the violated relationship — the resolved target, the restricted symbol, the missing sibling — or null when the file alone is the violation."),
|
|
40
41
|
message: Schema.String,
|
|
41
42
|
baselined: describe(Schema.Boolean, "Carried by the baseline, so `check` does not fail on it."),
|
|
43
|
+
ledgered: describe(Schema.Boolean, "For a campaign hit: carried by the campaign's ledger, so `check` does not fail on it."),
|
|
42
44
|
});
|
|
43
45
|
const AllowanceKind = describe(Schema.Literals(["allow", "external"]), "`allow` is a path glob under `imports.allow`; `external` a package name under `imports.external`.");
|
|
44
46
|
const Entry = describe(Schema.String, "The entry as written, after alias expansion.");
|
|
@@ -60,6 +62,24 @@ export const SnapshotVacancy = Schema.Struct({
|
|
|
60
62
|
node: describe(Schema.String, "The manifest node."),
|
|
61
63
|
allowances: describe(Schema.Finite, "Distinct entries the node wrote, `allow` and `external` together."),
|
|
62
64
|
});
|
|
65
|
+
// One campaign's burn-down: what its ledger says, and what the clock says
|
|
66
|
+
// about it. Every count is over ledger entries, which are hits by fingerprint.
|
|
67
|
+
export const SnapshotCampaign = Schema.Struct({
|
|
68
|
+
id: describe(Schema.String, "The campaign's id; its ledger is `<ledger>/<id>.json`."),
|
|
69
|
+
title: Schema.optionalKey(describe(Schema.String, "The campaign's title, when it states one.")),
|
|
70
|
+
owner: Schema.optionalKey(describe(Schema.String, "Who is running the campaign, as the manifest names them.")),
|
|
71
|
+
initial: describe(Schema.Finite, "Entries the day the ledger was written."),
|
|
72
|
+
allowed: describe(Schema.Finite, "Entries added since by `campaigns allow`, each with a regression record."),
|
|
73
|
+
count: describe(Schema.Finite, "Entries in the ledger now."),
|
|
74
|
+
fixed: describe(Schema.Finite, "Entries removed by `campaigns prune` since the ledger was written."),
|
|
75
|
+
progress: describe(Schema.Finite, "`1 - count / (initial + allowed)`: how much of everything ever ledgered has been paid down."),
|
|
76
|
+
lastProgress: describe(Schema.String, "When an entry last left the ledger, ISO 8601 — the stall clock's reading."),
|
|
77
|
+
regressions: describe(Schema.Finite, "How many times the count was allowed to go up."),
|
|
78
|
+
stalled: describe(Schema.Boolean, "Entries remain and `lastProgress` is older than the campaign's `staleAfter`."),
|
|
79
|
+
complete: describe(Schema.Boolean, "No entries remain."),
|
|
80
|
+
onComplete: describe(Schema.Literals(["keep", "remove"]), "What the manifest asks once complete: keep the campaign as a guard, or remove it."),
|
|
81
|
+
ledgered: describe(Schema.Boolean, "Whether a ledger exists. A campaign with none has been declared and not yet initialised."),
|
|
82
|
+
});
|
|
63
83
|
export const Snapshot = Schema.Struct({
|
|
64
84
|
version: describe(Schema.Literal(SNAPSHOT_VERSION), "The shape of this document."),
|
|
65
85
|
manifest: describe(Schema.Struct({
|
|
@@ -88,6 +108,7 @@ export const Snapshot = Schema.Struct({
|
|
|
88
108
|
unrestricted: describe(Schema.Array(Schema.String), "Nodes that say `unrestricted: true`."),
|
|
89
109
|
partial: describe(Schema.Array(Schema.String), "Nodes that say `partial: true`."),
|
|
90
110
|
}), 'The tiers that said "not tightened yet", by name; `limits` caps how many may.'),
|
|
111
|
+
campaigns: describe(Schema.Array(SnapshotCampaign), "Every campaign the manifest declares, in manifest order, with its burn-down. Campaign hits are not counted in `coverage` or `residue`: a campaign is scoped by construction."),
|
|
91
112
|
});
|
|
92
113
|
// Decodes a document some other run wrote — the base of a pull request, a
|
|
93
114
|
// stored one — refusing a key the shape does not declare, so a consumer never
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../../src/domain/snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAIxC,yEAAyE;AACzE,2EAA2E;AAC3E,wEAAwE;AACxE,wEAAwE;AACxE,sEAAsE;AACtE,mEAAmE;AACnE,EAAE;AACF,0EAA0E;AAC1E,6EAA6E;AAC7E,0EAA0E;AAC1E,6EAA6E;AAC7E,oDAAoD;AAEpD,MAAM,CAAC,MAAM,kBAAkB,GAC7B,sEAAsE,CAAC;AAEzE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAElC,MAAM,QAAQ,GAAG,CAAuB,MAAS,EAAE,WAAmB,EAAE,EAAE,CACxE,MAAM,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;AAEnC,MAAM,iBAAiB,GAAG,CAAC,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAU,CAAC;AAE3F,2EAA2E;AAC3E,iCAAiC;AACjC,MAAM,eAAe,GAAG;IACtB,QAAQ;IACR,QAAQ;IACR,WAAW;IACX,QAAQ;IACR,SAAS;IACT,OAAO;
|
|
1
|
+
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../../src/domain/snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAIxC,yEAAyE;AACzE,2EAA2E;AAC3E,wEAAwE;AACxE,wEAAwE;AACxE,sEAAsE;AACtE,mEAAmE;AACnE,EAAE;AACF,0EAA0E;AAC1E,6EAA6E;AAC7E,0EAA0E;AAC1E,6EAA6E;AAC7E,oDAAoD;AAEpD,MAAM,CAAC,MAAM,kBAAkB,GAC7B,sEAAsE,CAAC;AAEzE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAElC,MAAM,QAAQ,GAAG,CAAuB,MAAS,EAAE,WAAmB,EAAE,EAA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;AAC3E,4DAA4D;AAC5D,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAe,EAAE;IACjD,MAAM,SAAS,GAAG,MAAM,CAAC,oBAAoB,CAAC,QAAQ,CAGrD,CAAC;IACF,OAAO;QACL,OAAO,EAAE,8CAA8C;QACvD,GAAG,EAAE,kBAAkB;QACvB,KAAK,EAAE,sBAAsB;QAC7B,WAAW,EACT,wMAAwM;QAC1M,GAAG,SAAS,CAAC,MAAM;QACnB,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,WAAW,EAAE,CAAC;KAC7F,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"violation.js","sourceRoot":"","sources":["../../../src/domain/violation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"violation.js","sourceRoot":"","sources":["../../../src/domain/violation.ts"],"names":[],"mappings":"AAiBA,+EAA+E;AAC/E,gFAAgF;AAChF,0EAA0E;AAC1E,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,SAAoB,EAAU,EAAE,CAC5D,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,QAAQ,EAAE,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE1F,8EAA8E;AAC9E,0DAA0D;AAC1D,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,SAAoB,EAAU,EAAE,CAC5D,IAAI,SAAS,CAAC,QAAQ,KAAK,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,EAAE,SAAS,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,CAAC"}
|
package/build/esm/index.js
CHANGED
|
@@ -4,26 +4,32 @@
|
|
|
4
4
|
// live file system; a language pack implements the ports. Nothing here names a
|
|
5
5
|
// language. The fakes are under `@goodbones/core/testing`.
|
|
6
6
|
export { baselineOf, decodeBaseline, EMPTY_BASELINE, makeBaselineFilter, serializeBaseline, staleEntriesOf, unbaselined, } from "./core/baseline.js";
|
|
7
|
+
export { campaignsFailingTheirProbe, campaignsSelecting, compileCampaignRule, compileCampaignRules, evaluateCampaign, evaluateCampaigns, explainCampaign, leafTermsOf, matchKeyOf, probeInputOf, } from "./core/campaigns.js";
|
|
7
8
|
export { coverageOf, coverageShortfalls, fractionsOf, reachOf, residueOf, vacancyOf, } from "./core/coverage.js";
|
|
8
9
|
export { compileExportRule, compileExportRules, evaluateBindingEdge, evaluateSelectedBindings, exportRulesFailingTheirProbe, exportRulesSelecting, } from "./core/exports.js";
|
|
9
10
|
export { compileGraphRules, cyclesIn, EMPTY_GRAPH_RULES, evaluateGraph, graphRulesFailingTheirProbe, hasGraphRules, heightOf, } from "./core/graph.js";
|
|
10
11
|
export { compileImportRule, compileImportRules, evaluateImportEdge, evaluateResolvedEdge, evaluateSelectedEdge, probeTargetOf, rulesFailingTheirProbe, rulesSelecting, } from "./core/imports.js";
|
|
12
|
+
export { allowed, decodeLedger, EMPTY_LEDGER, entryOf, isComplete, isStalled, ledgerArithmeticHolds, ledgerOf, Ledger as LedgerSchema, newEntriesOf, progressOf, pruned, reconcile, serializeLedger, staleEntriesOf as staleLedgerEntriesOf, } from "./core/ledger.js";
|
|
11
13
|
export { compileMemberRules, evaluateMemberSite, memberRulesFailingTheirProbe, memberRulesSelecting, } from "./core/members.js";
|
|
12
14
|
export { slackOf, } from "./core/slack.js";
|
|
13
15
|
export { compileStructure, EMPTY_STRUCTURE, evaluateStructure, requiredSiblingsOf, structureRulesFailingTheirProbe, } from "./core/structure.js";
|
|
14
16
|
export { compileSurfaceRules, evaluateSurface, surfaceRulesFailingTheirProbe, surfaceRulesSelecting, } from "./core/surface.js";
|
|
15
17
|
export { ConfigInvalid, ImportUnresolved, PatternInvalid, ScopeInvalid, } from "./domain/architecture-error.js";
|
|
16
18
|
export { renderManifestPath, } from "./domain/manifest-location.js";
|
|
19
|
+
export { indexByFile, parseReport, } from "./domain/report.js";
|
|
17
20
|
export { decodeSnapshot, SNAPSHOT_SCHEMA_ID, SNAPSHOT_VERSION, snapshotJsonSchema, Snapshot as SnapshotSchema, } from "./domain/snapshot.js";
|
|
18
21
|
export { fingerprintOf, formatMessage, } from "./domain/violation.js";
|
|
22
|
+
export { loadCampaignFunctions, } from "./infrastructure/campaign-functions.js";
|
|
19
23
|
export { makeFileSystemLive } from "./infrastructure/file-system-live.js";
|
|
20
24
|
export { findManifestFile, formatManifestYaml, MANIFEST_FILENAMES, readManifestFile, } from "./infrastructure/manifest-file.js";
|
|
21
25
|
export { expandIncludes, } from "./infrastructure/manifest-include.js";
|
|
26
|
+
export { makeReportSourceLive } from "./infrastructure/report-source-live.js";
|
|
22
27
|
export { listPackageRoots, listSourceFiles, } from "./infrastructure/walk.js";
|
|
23
28
|
export { loadPolicy } from "./load/policy.js";
|
|
24
29
|
export { lowerManifest, } from "./manifest/compile.js";
|
|
25
30
|
export { expandManifest, originOf, } from "./manifest/expand.js";
|
|
26
31
|
export { candidatesOf, inferManifest, singularOf, } from "./manifest/infer.js";
|
|
27
32
|
export { MANIFEST_NODE_SCHEMA_ID, MANIFEST_SCHEMA_ID, manifestJsonSchema, manifestNodeJsonSchema, } from "./manifest/json-schema.js";
|
|
28
|
-
export { decodeManifest, Manifest as ManifestSchema, } from "./manifest/manifest.js";
|
|
33
|
+
export { decodeManifest, DEFAULT_LEDGER_DIR, durationMs, Manifest as ManifestSchema, } from "./manifest/manifest.js";
|
|
34
|
+
export { NO_REPORTS } from "./ports/report-source.js";
|
|
29
35
|
//# sourceMappingURL=index.js.map
|
package/build/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,yEAAyE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M,2BAA2B,CAAC;AACnC,OAAO,EAGL,cAAc,EAEd,kBAAkB,EAElB,UAAU,EAGV,QAAQ,IAAI,cAAc,GAC3B,MAAM,wBAAwB,CAAC;AAehC,OAAO,EAAE,UAAU,EAAsC,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
|
+
import { ConfigInvalid } from "../domain/architecture-error.js";
|
|
4
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5
|
+
const REFERENCE = /^(.+)#([A-Za-z_$][\w$]*)$/;
|
|
6
|
+
// A `fn` term is an object whose one key is `fn`.
|
|
7
|
+
const isFnTerm = (value) => "fn" in value && Object.keys(value).length === 1;
|
|
8
|
+
export const loadCampaignFunctions = async (manifestPath, rawManifest) => {
|
|
9
|
+
const functions = new Map();
|
|
10
|
+
const root = path.dirname(manifestPath);
|
|
11
|
+
const refuse = (detail) => {
|
|
12
|
+
throw new ConfigInvalid({ configPath: manifestPath, detail });
|
|
13
|
+
};
|
|
14
|
+
const imported = async (reference) => {
|
|
15
|
+
if (functions.has(reference))
|
|
16
|
+
return;
|
|
17
|
+
const parsed = REFERENCE.exec(reference);
|
|
18
|
+
if (parsed === null) {
|
|
19
|
+
return refuse(`the \`fn\` term ${JSON.stringify(reference)} is not \`module#export\`: name the ` +
|
|
20
|
+
`module (relative to the manifest) and the export, joined by \`#\`.`);
|
|
21
|
+
}
|
|
22
|
+
const [, module = "", exportName = ""] = parsed;
|
|
23
|
+
const at = path.resolve(root, module);
|
|
24
|
+
let loaded;
|
|
25
|
+
try {
|
|
26
|
+
loaded = await import(pathToFileURL(at).href);
|
|
27
|
+
}
|
|
28
|
+
catch (cause) {
|
|
29
|
+
return refuse(`the \`fn\` term ${JSON.stringify(reference)} names a module that does not load: ${String(cause)}`);
|
|
30
|
+
}
|
|
31
|
+
const found = isRecord(loaded) ? loaded[exportName] : undefined;
|
|
32
|
+
if (typeof found !== "function") {
|
|
33
|
+
return refuse(`the \`fn\` term ${JSON.stringify(reference)} names an export that is not a function ` +
|
|
34
|
+
`(${found === undefined ? "absent" : typeof found}).`);
|
|
35
|
+
}
|
|
36
|
+
functions.set(reference, found);
|
|
37
|
+
};
|
|
38
|
+
let synthesized = 0;
|
|
39
|
+
const lift = async (value) => {
|
|
40
|
+
if (Array.isArray(value)) {
|
|
41
|
+
const items = [];
|
|
42
|
+
for (const item of value)
|
|
43
|
+
items.push(await lift(item));
|
|
44
|
+
return items;
|
|
45
|
+
}
|
|
46
|
+
if (!isRecord(value))
|
|
47
|
+
return value;
|
|
48
|
+
if (isFnTerm(value)) {
|
|
49
|
+
const fn = value.fn;
|
|
50
|
+
if (typeof fn === "function") {
|
|
51
|
+
synthesized += 1;
|
|
52
|
+
const name = `<manifest>#fn${String(synthesized)}`;
|
|
53
|
+
functions.set(name, fn);
|
|
54
|
+
return { fn: name };
|
|
55
|
+
}
|
|
56
|
+
if (typeof fn === "string")
|
|
57
|
+
await imported(fn);
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
const rebuilt = {};
|
|
61
|
+
for (const [key, entry] of Object.entries(value))
|
|
62
|
+
rebuilt[key] = await lift(entry);
|
|
63
|
+
return rebuilt;
|
|
64
|
+
};
|
|
65
|
+
return { functions, manifest: await lift(rawManifest) };
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=campaign-functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"campaign-functions.js","sourceRoot":"","sources":["../../../src/infrastructure/campaign-functions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAqBhE,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE,CACpE,OAAO,K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,CAAC;gBACjB,MAAM,IAAI,GAAG,gBAAgB,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;gBACnD,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,EAAuB,CAAC,CAAC;gBAC7C,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;YACtB,CAAC;YACD,IAAI,OAAO,EAAE,KAAK,QAAQ;gBAAE,MAAM,QAAQ,CAAC,EAAE,CAAC,CAAC;YAC/C,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,OAAO,GAA4B,EAAE,CAAC;QAC5C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;YAAE,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,CAAC;QACnF,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;IAEF,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;AAC1D,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Keyed by file: a test states which diagnostics another tool reported on
|
|
2
|
+
// which file, and never runs the tool. Every spec is answered alike.
|
|
3
|
+
export const makeReportSourceFake = (staged) => ({
|
|
4
|
+
diagnosticsOf: (_spec, file) => (staged[file] ?? []).map((one) => ({ ...one, file })),
|
|
5
|
+
});
|
|
6
|
+
//# sourceMappingURL=report-source-fake.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report-source-fake.js","sourceRoot":"","sources":["../../../src/infrastructure/report-source-fake.ts"],"names":[],"mappings":"AAGA,0EAA0E;AAC1E,qEAAqE;AACrE,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,MAAyE,EAC3D,EAAE,CAAC,CAAC;IAClB,aAAa,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;CACtF,CAAC,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
import { indexByFile, parseReport } from "../domain/report.js";
|
|
5
|
+
// The report source on this host: runs a `report` term's command from the
|
|
6
|
+
// repository root, or reads the file it names, and parses the output once —
|
|
7
|
+
// a report is about the whole repository, a campaign asks per file, and the
|
|
8
|
+
// plugin asks for one file at a time across a whole lint run. Cached per
|
|
9
|
+
// spec for the life of the process: the CLI is one process per `check`, and
|
|
10
|
+
// oxlint's language server is one process per editor session, which sees the
|
|
11
|
+
// report as of when it loaded the plugin. A report the build writes to a file
|
|
12
|
+
// is the predictable form for the editor.
|
|
13
|
+
//
|
|
14
|
+
// A non-zero exit is not a failure — `tsc` exits 2 when there are errors,
|
|
15
|
+
// which is the case the term exists for. A command that cannot be spawned,
|
|
16
|
+
// or a file that is not there, is.
|
|
17
|
+
const MAX_BUFFER = 256 * 1024 * 1024;
|
|
18
|
+
const textOf = (repoRoot, spec) => {
|
|
19
|
+
if (spec.file !== undefined) {
|
|
20
|
+
const at = path.resolve(repoRoot, spec.file);
|
|
21
|
+
try {
|
|
22
|
+
return readFileSync(at, "utf8");
|
|
23
|
+
}
|
|
24
|
+
catch (cause) {
|
|
25
|
+
throw new Error(`the report file ${spec.file} cannot be read: ${String(cause)}. A \`report\` term's ` +
|
|
26
|
+
`\`file\` is written by an earlier step; run that first, or name a \`command\`.`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const command = spec.command ?? "";
|
|
30
|
+
const run = spawnSync(command, {
|
|
31
|
+
cwd: repoRoot,
|
|
32
|
+
shell: true,
|
|
33
|
+
encoding: "utf8",
|
|
34
|
+
maxBuffer: MAX_BUFFER,
|
|
35
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
36
|
+
});
|
|
37
|
+
if (run.error !== undefined) {
|
|
38
|
+
throw new Error(`the report command \`${command}\` could not be run: ${run.error.message}`);
|
|
39
|
+
}
|
|
40
|
+
return run.stdout;
|
|
41
|
+
};
|
|
42
|
+
const keyOf = (spec) => JSON.stringify(spec);
|
|
43
|
+
export const makeReportSourceLive = (repoRoot) => {
|
|
44
|
+
const cache = new Map();
|
|
45
|
+
return {
|
|
46
|
+
diagnosticsOf: (spec, file) => {
|
|
47
|
+
const key = keyOf(spec);
|
|
48
|
+
let indexed = cache.get(key);
|
|
49
|
+
if (indexed === undefined) {
|
|
50
|
+
indexed = indexByFile(parseReport(spec.format, textOf(repoRoot, spec), { repoRoot, pattern: spec.pattern }));
|
|
51
|
+
cache.set(key, indexed);
|
|
52
|
+
}
|
|
53
|
+
return indexed.get(file) ?? [];
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=report-source-live.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report-source-live.js","sourceRoot":"","sources":["../../../src/infrastructure/report-source-live.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAmB,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGhF,0EAA0E;AAC1E,4EAA4E;AAC5E,4EAA4E;AAC5E,yEAAyE;AACzE,4EAA4E;AAC5E,6EAA6E;AAC7E,8EAA8E;AAC9E,0CAA0C;AAC1C,EAAE;AACF,0EAA0E;AAC1E,2EAA2E;AAC3E,mCAAmC;AAEnC,MAAM,UAAU,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;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AE,IAAI,EAAE,EAAE;YAC5B,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;YACxB,IAAI,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC7B,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;gBAC1B,OAAO,GAAG,WAAW,CACnB,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CACtF,CAAC;gBACF,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YAC1B,CAAC;YACD,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACjC,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const ZERO = { line: 0, column: 0 };
|
|
2
|
+
// Keyed by the source text, as the extractor fake is: a core test states
|
|
3
|
+
// what a snippet's syntax yields and never the parse, which has its own
|
|
4
|
+
// tests in the matcher package. A text not staged parses to no matches; a
|
|
5
|
+
// file whose extension is not among `extensions` does not parse at all,
|
|
6
|
+
// which is the shape of a language with no matcher.
|
|
7
|
+
export const makeSyntaxMatcherFake = (staged, extensions = null) => ({
|
|
8
|
+
parse: (file, text) => {
|
|
9
|
+
if (extensions !== null && !extensions.some((extension) => file.endsWith(extension))) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
const matches = staged[text] ?? [];
|
|
13
|
+
return {
|
|
14
|
+
// A staged match's line is what a position is anchored by.
|
|
15
|
+
anchorAt: (position) => matches.find((one) => one.line === position.line)?.anchor ?? null,
|
|
16
|
+
findAll: (rule) => {
|
|
17
|
+
const asked = JSON.stringify(rule);
|
|
18
|
+
return matches
|
|
19
|
+
.filter((one) => one.rule === undefined || JSON.stringify(one.rule) === asked)
|
|
20
|
+
.map((one) => ({
|
|
21
|
+
text: one.text,
|
|
22
|
+
captures: new Map(Object.entries(one.captures ?? {})),
|
|
23
|
+
range: {
|
|
24
|
+
start: one.line === undefined ? ZERO : { line: one.line, column: 0 },
|
|
25
|
+
end: one.line === undefined ? ZERO : { line: one.line, column: one.text.length },
|
|
26
|
+
},
|
|
27
|
+
anchor: one.anchor ?? null,
|
|
28
|
+
}));
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=syntax-matcher-fake.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"syntax-matcher-fake.js","sourceRoot":"","sources":["../../../src/infrastructure/syntax-matcher-fake.ts"],"names":[],"mappings":"AAeA,MAAM,IAAI,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;AAEpC,yEAAyE;AACzE,wEAAwE;AACxE,0EAA0E;AAC1E,wEAAwE;AACxE,oDAAoD;AACpD,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,MAA4D,EAC5D,UAAU,GAAiC,IAAI,EAChC,EAAE,CAAC,CAAC;IACnB,KAAK,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;QACpB,IAAI,UAAU,KAAK,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC;YACrF,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACnC,OAAO;YACL,2DAA2D;YAC3D,QAAQ,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,CAAC,EAAE,M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