claude-code-jsonl-validator 0.1.3-beta.13 → 0.1.3-beta.15

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/dist/cli.cjs CHANGED
@@ -20,7 +20,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
20
20
  value: mod,
21
21
  enumerable: true
22
22
  }) : target, mod));
23
- const require_validate = require("./validate-D7JiHavJ.cjs");
23
+ const require_validate = require("./validate-CpJSBIyD.cjs");
24
24
  let node_fs = require("node:fs");
25
25
  let node_fs_promises = require("node:fs/promises");
26
26
  let node_readline = require("node:readline");
@@ -30,7 +30,8 @@ node_path = __toESM(node_path, 1);
30
30
  /** `.jsonl` を再帰収集する。 */
31
31
  async function collectJsonl(dir) {
32
32
  const out = [];
33
- for (const entry of await (0, node_fs_promises.readdir)(dir)) {
33
+ const entries = await (0, node_fs_promises.readdir)(dir);
34
+ for (const entry of entries) {
34
35
  const full = node_path.default.join(dir, entry);
35
36
  if ((await (0, node_fs_promises.stat)(full)).isDirectory()) out.push(...await collectJsonl(full));
36
37
  else if (entry.endsWith(".jsonl")) out.push(full);
@@ -44,7 +45,8 @@ async function main() {
44
45
  process.exit(2);
45
46
  }
46
47
  const findings = [];
47
- for (const file of await collectJsonl(corpus)) {
48
+ const files = await collectJsonl(corpus);
49
+ for (const file of files) {
48
50
  const rl = (0, node_readline.createInterface)({
49
51
  input: (0, node_fs.createReadStream)(file, { encoding: "utf8" }),
50
52
  crlfDelay: Infinity
@@ -61,7 +63,8 @@ async function main() {
61
63
  }
62
64
  }
63
65
  const report = require_validate.aggregateReport(findings);
64
- for (const [type, bucket] of [...report].toSorted(([a], [b]) => a.localeCompare(b))) {
66
+ const sortedReport = [...report].toSorted(([a], [b]) => a.localeCompare(b));
67
+ for (const [type, bucket] of sortedReport) {
65
68
  console.log(`\n[${type}] ${bucket.length} finding(s)`);
66
69
  const byKind = /* @__PURE__ */ new Map();
67
70
  for (const f of bucket) byKind.set(f.kind, (byKind.get(f.kind) ?? 0) + 1);
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { n as hasFindings, r as validateLine, t as aggregateReport } from "./validate-BC7LgJjI.js";
2
+ import { n as hasFindings, r as validateLine, t as aggregateReport } from "./validate-PqQ452Uy.js";
3
3
  import { createReadStream } from "node:fs";
4
4
  import { readdir, stat } from "node:fs/promises";
5
5
  import { createInterface } from "node:readline";
@@ -8,7 +8,8 @@ import path from "node:path";
8
8
  /** `.jsonl` を再帰収集する。 */
9
9
  async function collectJsonl(dir) {
10
10
  const out = [];
11
- for (const entry of await readdir(dir)) {
11
+ const entries = await readdir(dir);
12
+ for (const entry of entries) {
12
13
  const full = path.join(dir, entry);
13
14
  if ((await stat(full)).isDirectory()) out.push(...await collectJsonl(full));
14
15
  else if (entry.endsWith(".jsonl")) out.push(full);
@@ -22,7 +23,8 @@ async function main() {
22
23
  process.exit(2);
23
24
  }
24
25
  const findings = [];
25
- for (const file of await collectJsonl(corpus)) {
26
+ const files = await collectJsonl(corpus);
27
+ for (const file of files) {
26
28
  const rl = createInterface({
27
29
  input: createReadStream(file, { encoding: "utf8" }),
28
30
  crlfDelay: Infinity
@@ -39,7 +41,8 @@ async function main() {
39
41
  }
40
42
  }
41
43
  const report = aggregateReport(findings);
42
- for (const [type, bucket] of [...report].toSorted(([a], [b]) => a.localeCompare(b))) {
44
+ const sortedReport = [...report].toSorted(([a], [b]) => a.localeCompare(b));
45
+ for (const [type, bucket] of sortedReport) {
43
46
  console.log(`\n[${type}] ${bucket.length} finding(s)`);
44
47
  const byKind = /* @__PURE__ */ new Map();
45
48
  for (const f of bucket) byKind.set(f.kind, (byKind.get(f.kind) ?? 0) + 1);
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","names":[],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { createReadStream } from 'node:fs'\nimport { readdir, stat } from 'node:fs/promises'\nimport { createInterface } from 'node:readline'\nimport path from 'node:path'\nimport { validateLine, aggregateReport, hasFindings, type Finding } from './validate'\n\n/** `.jsonl` を再帰収集する。 */\nasync function collectJsonl(dir: string): Promise<string[]> {\n const out: string[] = []\n for (const entry of await readdir(dir)) {\n const full = path.join(dir, entry)\n const st = await stat(full)\n if (st.isDirectory()) out.push(...(await collectJsonl(full)))\n else if (entry.endsWith('.jsonl')) out.push(full)\n }\n return out\n}\n\nasync function main(): Promise<void> {\n const corpus = process.argv[2]\n if (!corpus) {\n console.error('Usage: claude-code-jsonl-validator <corpus-dir>')\n process.exit(2)\n }\n\n const findings: Finding[] = []\n for (const file of await collectJsonl(corpus)) {\n const rl = createInterface({\n input: createReadStream(file, { encoding: 'utf8' }),\n crlfDelay: Infinity,\n })\n for await (const raw of rl) {\n if (raw.trim() === '') continue\n let obj: unknown\n try {\n obj = JSON.parse(raw)\n } catch {\n continue // 構文エラーは parser 側の責務。ここでは無視\n }\n findings.push(...validateLine(obj))\n }\n }\n\n const report = aggregateReport(findings)\n for (const [type, bucket] of [...report].toSorted(([a], [b]) => a.localeCompare(b))) {\n console.log(`\\n[${type}] ${bucket.length} finding(s)`)\n const byKind = new Map<string, number>()\n for (const f of bucket) byKind.set(f.kind, (byKind.get(f.kind) ?? 0) + 1)\n for (const [kind, n] of byKind) console.log(` ${kind}: ${n}`)\n // 代表例を数件表示\n for (const f of bucket.slice(0, 5)) console.log(` - ${f.message}`)\n }\n\n if (hasFindings(report)) {\n console.error('\\nRegression detected. See findings above.')\n process.exit(1)\n }\n console.log('\\nNo regressions. All lines match known schemas.')\n}\n\nmain().catch((error: unknown) => {\n console.error(error)\n process.exit(1)\n})\n"],"mappings":";;;;;;;;AAQA,eAAe,aAAa,KAAgC;CAC1D,MAAM,MAAgB,CAAC;CACvB,KAAK,MAAM,SAAS,MAAM,QAAQ,GAAG,GAAG;EACtC,MAAM,OAAO,KAAK,KAAK,KAAK,KAAK;EAEjC,KAAI,MADa,K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A4C;EAC1D,QAAQ,KAAK,CAAC;CAChB;CACA,QAAQ,IAAI,kDAAkD;AAChE;AAEA,KAAK,CAAC,CAAC,OAAO,UAAmB;CAC/B,QAAQ,MAAM,KAAK;CACnB,QAAQ,KAAK,CAAC;AAChB,CAAC"}
1
+ {"version":3,"file":"cli.js","names":[],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { createReadStream } from 'node:fs'\nimport { readdir, stat } from 'node:fs/promises'\nimport { createInterface } from 'node:readline'\nimport path from 'node:path'\nimport { validateLine, aggregateReport, hasFindings, type Finding } from './validate'\n\n/** `.jsonl` を再帰収集する。 */\nasync function collectJsonl(dir: string): Promise<string[]> {\n const out: string[] = []\n const entries = await readdir(dir)\n for (const entry of entries) {\n const full = path.join(dir, entry)\n const st = await stat(full)\n if (st.isDirectory()) out.push(...(await collectJsonl(full)))\n else if (entry.endsWith('.jsonl')) out.push(full)\n }\n return out\n}\n\nasync function main(): Promise<void> {\n const corpus = process.argv[2]\n if (!corpus) {\n console.error('Usage: claude-code-jsonl-validator <corpus-dir>')\n process.exit(2)\n }\n\n const findings: Finding[] = []\n const files = await collectJsonl(corpus)\n for (const file of files) {\n const rl = createInterface({\n input: createReadStream(file, { encoding: 'utf8' }),\n crlfDelay: Infinity,\n })\n for await (const raw of rl) {\n if (raw.trim() === '') continue\n let obj: unknown\n try {\n obj = JSON.parse(raw)\n } catch {\n continue // 構文エラーは parser 側の責務。ここでは無視\n }\n findings.push(...validateLine(obj))\n }\n }\n\n const report = aggregateReport(findings)\n const sortedReport = [...report].toSorted(([a], [b]) => a.localeCompare(b))\n for (const [type, bucket] of sortedReport) {\n console.log(`\\n[${type}] ${bucket.length} finding(s)`)\n const byKind = new Map<string, number>()\n for (const f of bucket) byKind.set(f.kind, (byKind.get(f.kind) ?? 0) + 1)\n for (const [kind, n] of byKind) console.log(` ${kind}: ${n}`)\n // 代表例を数件表示\n for (const f of bucket.slice(0, 5)) console.log(` - ${f.message}`)\n }\n\n if (hasFindings(report)) {\n console.error('\\nRegression detected. See findings above.')\n process.exit(1)\n }\n console.log('\\nNo regressions. All lines match known schemas.')\n}\n\nmain().catch((error: unknown) => {\n console.error(error)\n process.exit(1)\n})\n"],"mappings":";;;;;;;;AAQA,eAAe,aAAa,KAAgC;CAC1D,MAAM,MAAgB,CAAC;CACvB,MAAM,UAAU,MAAM,QAAQ,GAAG;CACjC,KAAK,MAAM,SAAS,SAAS;EAC3B,MAAM,OAAO,KAAK,KAAK,KAAK,KAAK;EAEjC,KAAI,MADa,KAAK,IAAI,EAAA,CACnB,YAAY,GAAG,IAAI,KAAK,GAAI,MAAM,aAAa,IAAI,CAAE;OACvD,IAAI,MAAM,SAAS,QAAQ,GAAG,IAAI,KAAK,IAAI;CAClD;CACA,OAAO;AACT;AAEA,eAAe,OAAsB;CACnC,MAAM,SAAS,QAAQ,KAAK;CAC5B,IAAI,CAAC,QAAQ;EACX,QAAQ,MAAM,iDAAiD;EAC/D,QAAQ,KAAK,CAAC;CAChB;CAEA,MAAM,WAAsB,CAAC;CAC7B,MAAM,QAAQ,MAAM,aAAa,MAAM;CACvC,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,KAAK,gBAAgB;GACzB,OAAO,iBAAiB,MAAM,EAAE,UAAU,OAAO,CAAC;GAClD,WAAW;EACb,CAAC;EACD,WAAW,MAAM,OAAO,IAAI;GAC1B,IAAI,IAAI,KAAK,MAAM,IAAI;GACvB,IAAI;GACJ,IAAI;IACF,MAAM,KAAK,MAAM,GAAG;GACtB,QAAQ;IACN;GACF;GACA,SAAS,KAAK,GAAG,aAAa,GAAG,CAAC;EACpC;CACF;CAEA,MAAM,SAAS,gBAAgB,QAAQ;CACvC,MAAM,eAAe,CAAC,GAAG,MAAM,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;CAC1E,KAAK,MAAM,CAAC,MAAM,WAAW,cAAc;EACzC,QAAQ,IAAI,MAAM,KAAK,IAAI,OAAO,OAAO,YAAY;EACrD,MAAM,yBAAS,IAAI,IAAoB;EACvC,KAAK,MAAM,KAAK,QAAQ,OAAO,IAAI,EAAE,OAAO,OAAO,IAAI,EAAE,IAAI,KAAK,KAAK,CAAC;EACxE,KAAK,MAAM,CAAC,MAAM,MAAM,QAAQ,QAAQ,IAAI,KAAK,KAAK,IAAI,GAAG;EAE7D,KAAK,MAAM,KAAK,OAAO,MAAM,GAAG,CAAC,GAAG,QAAQ,IAAI,SAAS,EAAE,SAAS;CACtE;CAEA,IAAI,YAAY,MAAM,GAAG;EACvB,QAAQ,MAAM,4CAA4C;EAC1D,QAAQ,KAAK,CAAC;CAChB;CACA,QAAQ,IAAI,kDAAkD;AAChE;AAEA,KAAK,CAAC,CAAC,OAAO,UAAmB;CAC/B,QAAQ,MAAM,KAAK;CACnB,QAAQ,KAAK,CAAC;AAChB,CAAC"}
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_validate = require("./validate-D7JiHavJ.cjs");
2
+ const require_validate = require("./validate-CpJSBIyD.cjs");
3
3
  exports.aggregateReport = require_validate.aggregateReport;
4
4
  exports.hasFindings = require_validate.hasFindings;
5
5
  exports.validateLine = require_validate.validateLine;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/validate.ts"],"mappings":";KAGY;;UAOK;;EAEf;EACA,MAAM;;EAEN;EACA;;;;;;;wBAiBc,aAAa,eAAe;;;;;;wBAoD5B,gBAAgB,UAAU,YAAY,YAAY;;;;;;wBAelD,YAAY,QAAQ,YAAY"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/validate.ts"],"mappings":";KAGY;;UAOK;;EAEf;EACA,MAAM;;EAEN;EACA;;;;;;;wBAgBc,aAAa,eAAe;;;;;;wBAoD5B,gBAAgB,UAAU,YAAY,YAAY;;;;;;wBAgBlD,YAAY,QAAQ,YAAY"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/validate.ts"],"mappings":";KAGY;;UAOK;;EAEf;EACA,MAAM;;EAEN;EACA;;;;;;;wBAiBc,aAAa,eAAe;;;;;;wBAoD5B,gBAAgB,UAAU,YAAY,YAAY;;;;;;wBAelD,YAAY,QAAQ,YAAY"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/validate.ts"],"mappings":";KAGY;;UAOK;;EAEf;EACA,MAAM;;EAEN;EACA;;;;;;;wBAgBc,aAAa,eAAe;;;;;;wBAoD5B,gBAAgB,UAAU,YAAY,YAAY;;;;;;wBAgBlD,YAAY,QAAQ,YAAY"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { t as aggregateReport, n as hasFindings, r as validateLine } from "./validate-BC7LgJjI.js";
1
+ export { t as aggregateReport, n as hasFindings, r as validateLine } from "./validate-PqQ452Uy.js";
@@ -3,8 +3,7 @@ let claude_code_jsonl_generator = require("claude-code-jsonl-generator");
3
3
  /** 既知 type のスキーマが宣言しているトップレベルキー集合を取り出す。 */
4
4
  function knownKeysOf(type) {
5
5
  const schema = claude_code_jsonl_generator.entrySchemas[type];
6
- if (!schema?.shape) return void 0;
7
- return new Set(Object.keys(schema.shape));
6
+ return schema?.shape ? new Set(Object.keys(schema.shape)) : void 0;
8
7
  }
9
8
  /**
10
9
  * 1 行 (パース済み JSON) を検証して findings を返す。
@@ -12,7 +11,6 @@ function knownKeysOf(type) {
12
11
  * @param obj - パース済みの生 JSON
13
12
  */
14
13
  function validateLine(obj) {
15
- const findings = [];
16
14
  if (typeof obj !== "object" || obj === null || Array.isArray(obj)) return [{
17
15
  type: "<no-type>",
18
16
  kind: "no-type",
@@ -25,6 +23,7 @@ function validateLine(obj) {
25
23
  kind: "no-type",
26
24
  message: "missing string \"type\""
27
25
  }];
26
+ const findings = [];
28
27
  const schema = (0, claude_code_jsonl_generator.knownTypeSchema)(type);
29
28
  if (schema === void 0) return [{
30
29
  type,
@@ -3,8 +3,7 @@ import { entrySchemas, knownTypeSchema } from "claude-code-jsonl-generator";
3
3
  /** 既知 type のスキーマが宣言しているトップレベルキー集合を取り出す。 */
4
4
  function knownKeysOf(type) {
5
5
  const schema = entrySchemas[type];
6
- if (!schema?.shape) return void 0;
7
- return new Set(Object.keys(schema.shape));
6
+ return schema?.shape ? new Set(Object.keys(schema.shape)) : void 0;
8
7
  }
9
8
  /**
10
9
  * 1 行 (パース済み JSON) を検証して findings を返す。
@@ -12,7 +11,6 @@ function knownKeysOf(type) {
12
11
  * @param obj - パース済みの生 JSON
13
12
  */
14
13
  function validateLine(obj) {
15
- const findings = [];
16
14
  if (typeof obj !== "object" || obj === null || Array.isArray(obj)) return [{
17
15
  type: "<no-type>",
18
16
  kind: "no-type",
@@ -25,6 +23,7 @@ function validateLine(obj) {
25
23
  kind: "no-type",
26
24
  message: "missing string \"type\""
27
25
  }];
26
+ const findings = [];
28
27
  const schema = knownTypeSchema(type);
29
28
  if (schema === void 0) return [{
30
29
  type,
@@ -74,4 +73,4 @@ function hasFindings(report) {
74
73
  }
75
74
  export { hasFindings as n, validateLine as r, aggregateReport as t };
76
75
 
77
- //# sourceMappingURL=validate-BC7LgJjI.js.map
76
+ //# sourceMappingURL=validate-PqQ452Uy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-PqQ452Uy.js","names":[],"sources":["../src/validate.ts"],"sourcesContent":["import { entrySchemas, knownTypeSchema } from 'claude-code-jsonl-generator'\n\n/** 検出種別。 */\nexport type FindingKind =\n | 'no-type'\n | 'unknown-type'\n | 'schema-mismatch'\n | 'unknown-field'\n\n/** 1 件の検出。 */\nexport interface Finding {\n /** 対象 type (type 無しの場合は '<no-type>')。 */\n type: string\n kind: FindingKind\n /** unknown-field のときのフィールド名。 */\n field?: string\n message: string\n}\n\n/** 既知 type のスキーマが宣言しているトップレベルキー集合を取り出す。 */\nfunction knownKeysOf(type: string): Set<string> | undefined {\n const schema = (\n entrySchemas as Record<string, { shape?: Record<string, unknown> } | undefined>\n )[type]\n return schema?.shape ? new Set(Object.keys(schema.shape)) : undefined\n}\n\n/**\n * 1 行 (パース済み JSON) を検証して findings を返す。\n *\n * @param obj - パース済みの生 JSON\n */\nexport function validateLine(obj: unknown): Finding[] {\n if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) {\n return [{ type: '<no-type>', kind: 'no-type', message: 'not a JSON object' }]\n }\n const record = obj as Record<string, unknown>\n const type = record.type\n if (typeof type !== 'string') {\n return [{ type: '<no-type>', kind: 'no-type', message: 'missing string \"type\"' }]\n }\n\n const findings: Finding[] = []\n const schema = knownTypeSchema(type)\n if (schema === undefined) {\n return [{ type, kind: 'unknown-type', message: `unknown type \"${type}\"` }]\n }\n\n // スキーマ検証 (必須欠落・型不一致)\n const parsed = schema.safeParse(record)\n if (!parsed.success) {\n for (const issue of parsed.error.issues) {\n findings.push({\n type,\n kind: 'schema-mismatch',\n field: issue.path.join('.') || undefined,\n message: `${issue.path.join('.')}: ${issue.message}`,\n })\n }\n }\n\n // 未知フィールド検出 (スキーマが列挙するキー以外)\n const known = knownKeysOf(type)\n if (known) {\n for (const key of Object.keys(record)) {\n if (!known.has(key)) {\n findings.push({\n type,\n kind: 'unknown-field',\n field: key,\n message: `unknown field \"${key}\" on type \"${type}\"`,\n })\n }\n }\n }\n\n return findings\n}\n\n/**\n * findings を type ごとに集計する。\n *\n * @param findings - 全 findings\n */\nexport function aggregateReport(findings: Finding[]): Map<string, Finding[]> {\n const report = new Map<string, Finding[]>()\n // eslint-disable-next-line unicorn/prefer-group-by -- Map.groupBy は ES2024 であり、公開パッケージの lib ターゲット (ES2023) を変えないため\n for (const f of findings) {\n const bucket = report.get(f.type) ?? []\n bucket.push(f)\n report.set(f.type, bucket)\n }\n return report\n}\n\n/**\n * レポートに 1 件でも finding があれば true。\n *\n * @param report - 集計済みレポート\n */\nexport function hasFindings(report: Map<string, Finding[]>): boolean {\n for (const bucket of report.values()) {\n if (bucket.length > 0) return true\n }\n return false\n}\n"],"mappings":";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,KAAK,CAAC;EACtC,OAAO,KAAK,CAAC;EACb,OAAO,IAAI,EAAE,MAAM,MAAM;CAC3B;CACA,OAAO;AACT;;;;;;AAOA,SAAgB,YAAY,QAAyC;CACnE,KAAK,MAAM,UAAU,OAAO,OAAO,GACjC,IAAI,OAAO,SAAS,GAAG,OAAO;CAEhC,OAAO;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-code-jsonl-validator",
3
- "version": "0.1.3-beta.13",
3
+ "version": "0.1.3-beta.15",
4
4
  "description": "Regression-check real Claude Code JSONL corpora against known schemas",
5
5
  "keywords": [
6
6
  "claude-code",
@@ -38,7 +38,7 @@
38
38
  }
39
39
  },
40
40
  "dependencies": {
41
- "claude-code-jsonl-generator": "0.1.3-beta.13",
41
+ "claude-code-jsonl-generator": "0.1.3-beta.15",
42
42
  "zod": "4.6.7"
43
43
  },
44
44
  "scripts": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"validate-BC7LgJjI.js","names":[],"sources":["../src/validate.ts"],"sourcesContent":["import { entrySchemas, knownTypeSchema } from 'claude-code-jsonl-generator'\n\n/** 検出種別。 */\nexport type FindingKind =\n | 'no-type'\n | 'unknown-type'\n | 'schema-mismatch'\n | 'unknown-field'\n\n/** 1 件の検出。 */\nexport interface Finding {\n /** 対象 type (type 無しの場合は '<no-type>')。 */\n type: string\n kind: FindingKind\n /** unknown-field のときのフィールド名。 */\n field?: string\n message: string\n}\n\n/** 既知 type のスキーマが宣言しているトップレベルキー集合を取り出す。 */\nfunction knownKeysOf(type: string): Set<string> | undefined {\n const schema = (\n entrySchemas as Record<string, { shape?: Record<string, unknown> } | undefined>\n )[type]\n if (!schema?.shape) return undefined\n return new Set(Object.keys(schema.shape))\n}\n\n/**\n * 1 行 (パース済み JSON) を検証して findings を返す。\n *\n * @param obj - パース済みの生 JSON\n */\nexport function validateLine(obj: unknown): Finding[] {\n const findings: Finding[] = []\n if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) {\n return [{ type: '<no-type>', kind: 'no-type', message: 'not a JSON object' }]\n }\n const record = obj as Record<string, unknown>\n const type = record.type\n if (typeof type !== 'string') {\n return [{ type: '<no-type>', kind: 'no-type', message: 'missing string \"type\"' }]\n }\n\n const schema = knownTypeSchema(type)\n if (schema === undefined) {\n return [{ type, kind: 'unknown-type', message: `unknown type \"${type}\"` }]\n }\n\n // スキーマ検証 (必須欠落・型不一致)\n const parsed = schema.safeParse(record)\n if (!parsed.success) {\n for (const issue of parsed.error.issues) {\n findings.push({\n type,\n kind: 'schema-mismatch',\n field: issue.path.join('.') || undefined,\n message: `${issue.path.join('.')}: ${issue.message}`,\n })\n }\n }\n\n // 未知フィールド検出 (スキーマが列挙するキー以外)\n const known = knownKeysOf(type)\n if (known) {\n for (const key of Object.keys(record)) {\n if (!known.has(key)) {\n findings.push({\n type,\n kind: 'unknown-field',\n field: key,\n message: `unknown field \"${key}\" on type \"${type}\"`,\n })\n }\n }\n }\n\n return findings\n}\n\n/**\n * findings を type ごとに集計する。\n *\n * @param findings - 全 findings\n */\nexport function aggregateReport(findings: Finding[]): Map<string, Finding[]> {\n const report = new Map<string, Finding[]>()\n for (const f of findings) {\n const bucket = report.get(f.type) ?? []\n bucket.push(f)\n report.set(f.type, bucket)\n }\n return report\n}\n\n/**\n * レポートに 1 件でも finding があれば true。\n *\n * @param report - 集計済みレポート\n */\nexport function hasFindings(report: Map<string, Finding[]>): boolean {\n for (const bucket of report.values()) {\n if (bucket.length > 0) return true\n }\n return false\n}\n"],"mappings":";;;AAoBA,SAAS,YAAY,MAAuC;CAC1D,MAAM,SACJ,aACA;CACF,IAAI,CAAC,QAAQ,OAAO,OAAO,KAAA;CAC3B,OAAO,IAAI,IAAI,OAAO,KAAK,OAAO,KAAK,CAAC;AAC1C;;;;;;AAOA,SAAgB,aAAa,KAAyB;CACpD,MAAM,WAAsB,CAAC;CAC7B,IAAI,OAAO,QAAQ,YAAY,QAAQ,QAAQ,MAAM,QAAQ,GAAG,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