@tiangong-lca/cli 0.0.13 → 0.0.14

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/README.md CHANGED
@@ -310,7 +310,7 @@ For `lifecyclemodel save-draft`, canonical lifecyclemodel payloads are validated
310
310
 
311
311
  For `dataset evidence-search`, `plan` creates the field-level query matrix and search budget. `run` accepts normalized external search results from browser/web-search tools or a generic JSON provider endpoint, then writes `outputs/evidence-search-plan.json`, `outputs/evidence-search-results.jsonl`, `outputs/evidence-search-report.json`, and `outputs/evidence-search-declaration.json` when evidence is absent or only partial. The CLI records scope and normalization; Codex/skills still own semantic judgement and source selection.
312
312
 
313
- For `dataset validate`, `--type auto` supports mixed support scopes containing contact/source/unitgroup/flowproperty rows as well as flow/process/lifecyclemodel rows. For `dataset classification`, `children` and `path` navigate the bundled TIDAS category schemas copied from `tidas-tools`. `audit --type location` scans local rows for schema-derived location-code fields, plus TIDAS LCIA geography and lifecyclemodel connection location fields, whose values are not in `tidas_locations_category.json`; `apply --type location` applies structured decisions to a specific `target_path` when a row has multiple location fields.
313
+ For `dataset validate`, `--type auto` supports mixed support scopes containing contact/source/unitgroup/flowproperty rows as well as flow/process/lifecyclemodel rows. For `dataset classification`, `children` and `path` navigate the bundled TIDAS category schemas copied from `tidas-tools`. `audit --type location` scans local rows for schema-derived location-code fields, plus TIDAS LCIA geography and lifecyclemodel connection location fields, whose values are not in `tidas_locations_category.json`; `apply --type location` applies structured decisions to a specific `target_path` when a row has multiple location fields. When `target_path` explicitly points at a schema-derived location field such as `flowDataSet.flowInformation.geography.locationOfSupply`, location apply may create the missing parent object and field; ambiguous or non-location paths still block.
314
314
 
315
315
  For `dataset curation-queue build/next/verify`, the CLI owns entity-level Foundry import queue state. `build` writes `outputs/curation-queue-manifest.json`, `outputs/curation-queue-tasks.jsonl`, `outputs/curation-queue-locks.json`, `outputs/curation-queue-blockers.jsonl`, and per-entity `input.jsonl`, `closure.json`, and `entity-run-plan.json`. `next` returns one runnable support/flow/process task based on checkpoint state. `verify` passes only when scoped checkpoints are complete and build blockers are absent. AI authoring must return structured patches or build plans, and remote writes remain gated by deterministic apply, schema/QA, prewrite verify, and readback.
316
316
 
@@ -564,7 +564,49 @@ function resolveLocationTarget(row, decision) {
564
564
  const targets = collectLocationTargets(row.payload);
565
565
  if (!decision.targetPath)
566
566
  return targets;
567
- return targets.filter((target) => target.path === decision.targetPath || target.parentPath === decision.targetPath);
567
+ const matchingTargets = targets.filter((target) => target.path === decision.targetPath || target.parentPath === decision.targetPath);
568
+ if (matchingTargets.length > 0)
569
+ return matchingTargets;
570
+ const createdTarget = createMissingLocationTarget(row, decision.targetPath);
571
+ return createdTarget ? [createdTarget] : [];
572
+ }
573
+ function targetPathSegments(targetPath) {
574
+ return targetPath
575
+ .split('.')
576
+ .map((segment) => segment.trim())
577
+ .filter((segment) => segment.length > 0);
578
+ }
579
+ function createMissingLocationTarget(row, targetPath) {
580
+ const segments = targetPathSegments(targetPath);
581
+ const key = segments.at(-1);
582
+ if (!key || !isLocationTargetKey(key))
583
+ return null;
584
+ let cursor = row.payload;
585
+ for (const segment of segments.slice(0, -1)) {
586
+ if (!isRecord(cursor))
587
+ return null;
588
+ const existing = cursor[segment];
589
+ if (existing === undefined || existing === null) {
590
+ cursor[segment] = {};
591
+ cursor = cursor[segment];
592
+ continue;
593
+ }
594
+ if (!isRecord(existing))
595
+ return null;
596
+ cursor = existing;
597
+ }
598
+ if (!isRecord(cursor))
599
+ return null;
600
+ const existing = cursor[key];
601
+ if (existing !== undefined && existing !== null && existing !== '')
602
+ return null;
603
+ return {
604
+ path: targetPath,
605
+ parentPath: pathExpression(segments.slice(0, -1)),
606
+ parent: cursor,
607
+ key,
608
+ value: typeof existing === 'string' ? existing : '',
609
+ };
568
610
  }
569
611
  function decisionMatchesRow(decision, row) {
570
612
  if (decision.rowIndex !== null)
@@ -918,6 +960,7 @@ export const __testInternals = {
918
960
  collectLocationRefKeysFromSchema,
919
961
  collectLocationTargets,
920
962
  constText,
963
+ createMissingLocationTarget,
921
964
  currentClassification,
922
965
  decisionMatchesRow,
923
966
  decisionTargetPath,
@@ -942,6 +985,7 @@ export const __testInternals = {
942
985
  resolveLocationTarget,
943
986
  schemasDir,
944
987
  setClassification,
988
+ targetPathSegments,
945
989
  toPathEntry,
946
990
  };
947
991
  //# sourceMappingURL=dataset-classification.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dataset-classification.js","sourceRoot":"","sources":["../../../src/lib/dataset-classification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EACL,SAAS,EACT,aAAa,EACb,QAAQ,EACR,oBAAoB,EACpB,SAAS,EACT,oBAAoB,GAErB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAgNxC,MAAM,gBAAgB,GAAsD;IAC1E,OAAO,EAAE;QACP,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,8BAA8B;QAC1C,eAAe,EAAE,UAAU;QAC3B,MAAM,EAAE,cAAc;KACvB;IACD,iBAAiB,EAAE;QACjB,IAAI,EAAE,iBAAiB;QACvB,UAAU,EAAE,sCAAsC;QAClD,eAAe,EAAE,QAAQ;QACzB,MAAM,EAAE,iBAAiB;KAC1B;IACD,cAAc,EAAE;QACd,IAAI,EAAE,cAAc;QACpB,UAAU,EAAE,mCAAmC;QAC/C,eAAe,EAAE,UAAU;QAC3B,MAAM,EAAE,cAAc;KACvB;IACD,YAAY,EAAE;QACZ,IAAI,EAAE,cAAc;QACpB,UAAU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IAC5B,mBAAmB;IACnB,aAAa;IACb,WAAW;IACX,WAAW;IACX,aAAa;IACb,qBAAqB;IACrB,UAAU;IACV,iBAAiB;IACjB,WAAW;CACZ,CAAC","sourcesContent":["import { existsSync, readdirSync, readFileSync } from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { writeJsonArtifact, writeJsonLinesArtifact } from './artifacts.js';\nimport {\n cloneJson,\n firstNonEmpty,\n isRecord,\n readDatasetRowsInput,\n trimToken,\n unwrapDatasetPayload,\n type JsonObject,\n} from './dataset-local.js';\nimport { CliError } from './errors.js';\nimport { readJsonInput } from './io.js';\n\nexport type DatasetClassificationType =\n | 'contact'\n | 'flow-elementary'\n | 'flow-product'\n | 'flowproperty'\n | 'lciamethod'\n | 'location'\n | 'process'\n | 'source'\n | 'unitgroup';\n\ntype ClassificationValueKey = '@catId' | '@classId' | '@code';\n\nexport type ClassificationEntry = {\n level: number;\n code: string;\n text: string;\n value_key: ClassificationValueKey;\n};\n\nexport type ClassificationPathEntry = {\n '@level': string;\n '@classId'?: string;\n '@catId'?: string;\n '@code'?: string;\n '#text': string;\n};\n\nexport type DatasetClassificationChildrenReport = {\n schema_version: 1;\n generated_at_utc: string;\n status: 'completed' | 'blocked';\n command: 'dataset classification children';\n category_type: DatasetClassificationType;\n schema_file: string;\n parent_code: string | null;\n query: string | null;\n counts: {\n children: number;\n returned: number;\n };\n children: Array<ClassificationEntry & { path: ClassificationPathEntry[] }>;\n blockers: Array<{ code: string; message: string }>;\n files?: {\n report: string;\n };\n};\n\nexport type DatasetClassificationPathReport = {\n schema_version: 1;\n generated_at_utc: string;\n status: 'completed' | 'blocked';\n command: 'dataset classification path';\n category_type: DatasetClassificationType;\n schema_file: string;\n code: string;\n path: ClassificationPathEntry[];\n blockers: Array<{ code: string; message: string }>;\n files?: {\n report: string;\n };\n};\n\nexport type DatasetClassificationApplyReport = {\n schema_version: 1;\n generated_at_utc: string;\n status: 'completed' | 'blocked';\n command: 'dataset classification apply';\n input_path: string;\n decisions_path: string;\n out_path: string;\n default_category_type: DatasetClassificationType | null;\n counts: {\n rows: number;\n decisions: number;\n applied: number;\n blockers: number;\n };\n blockers: DatasetClassificationBlocker[];\n files: {\n classified_rows: string;\n evidence: string;\n report: string;\n };\n};\n\nexport type DatasetClassificationAuditFinding = {\n row_index: number;\n dataset_id: string | null;\n dataset_version: string | null;\n path: string;\n value: string;\n status: 'valid' | 'invalid';\n description: string | null;\n};\n\nexport type DatasetClassificationAuditReport = {\n schema_version: 1;\n generated_at_utc: string;\n status: 'completed' | 'blocked';\n command: 'dataset classification audit';\n category_type: DatasetClassificationType;\n schema_file: string;\n input_path: string;\n counts: {\n rows: number;\n location_targets: number;\n valid: number;\n invalid: number;\n };\n findings: DatasetClassificationAuditFinding[];\n blockers: DatasetClassificationBlocker[];\n files?: {\n findings: string;\n report: string;\n };\n};\n\nexport type DatasetClassificationBlocker = {\n code: string;\n message: string;\n decision_index?: number;\n row_index?: number;\n dataset_id?: string | null;\n dataset_version?: string | null;\n};\n\nexport type RunDatasetClassificationChildrenOptions = {\n type: string;\n parent?: string | null;\n query?: string | null;\n limit?: number | null;\n outDir?: string | null;\n now?: Date;\n};\n\nexport type RunDatasetClassificationPathOptions = {\n type: string;\n code: string;\n outDir?: string | null;\n now?: Date;\n};\n\nexport type RunDatasetClassificationAuditOptions = {\n inputPath: string;\n type: string;\n outDir?: string | null;\n rawInput?: unknown;\n now?: Date;\n};\n\nexport type RunDatasetClassificationApplyOptions = {\n inputPath: string;\n decisionsPath: string;\n outPath: string;\n type?: string | null;\n outDir?: string | null;\n rawInput?: unknown;\n rawDecisions?: unknown;\n now?: Date;\n};\n\ntype CategoryConfig = {\n type: DatasetClassificationType;\n schemaFile: string;\n defaultValueKey: ClassificationValueKey;\n target: 'common:category' | 'common:class' | 'location';\n};\n\ntype ClassificationNavigator = {\n entries: ClassificationEntry[];\n entriesByCode: Map<string, ClassificationEntry>;\n childMap: Map<string, ClassificationEntry[]>;\n parentMap: Map<string, ClassificationEntry | null>;\n};\n\ntype NormalizedDecision = {\n decisionIndex: number;\n rowIndex: number | null;\n datasetId: string | null;\n datasetVersion: string | null;\n categoryType: DatasetClassificationType;\n path: ClassificationPathEntry[];\n targetPath: string | null;\n basis: string | null;\n evidence: unknown;\n};\n\ntype LocationTarget = {\n path: string;\n parentPath: string;\n parent: JsonObject;\n key: string;\n value: string;\n};\n\ntype PreparedClassificationRow = {\n index: number;\n row: JsonObject;\n payload: JsonObject;\n rootKey: string | null;\n informationKey: string | null;\n id: string | null;\n version: string | null;\n};\n\nconst CATEGORY_CONFIGS: Record<DatasetClassificationType, CategoryConfig> = {\n contact: {\n type: 'contact',\n schemaFile: 'tidas_contacts_category.json',\n defaultValueKey: '@classId',\n target: 'common:class',\n },\n 'flow-elementary': {\n type: 'flow-elementary',\n schemaFile: 'tidas_flows_elementary_category.json',\n defaultValueKey: '@catId',\n target: 'common:category',\n },\n 'flow-product': {\n type: 'flow-product',\n schemaFile: 'tidas_flows_product_category.json',\n defaultValueKey: '@classId',\n target: 'common:class',\n },\n flowproperty: {\n type: 'flowproperty',\n schemaFile: 'tidas_flowproperties_category.json',\n defaultValueKey: '@classId',\n target: 'common:class',\n },\n lciamethod: {\n type: 'lciamethod',\n schemaFile: 'tidas_lciamethods_category.json',\n defaultValueKey: '@classId',\n target: 'common:class',\n },\n location: {\n type: 'location',\n schemaFile: 'tidas_locations_category.json',\n defaultValueKey: '@code',\n target: 'location',\n },\n process: {\n type: 'process',\n schemaFile: 'tidas_processes_category.json',\n defaultValueKey: '@classId',\n target: 'common:class',\n },\n source: {\n type: 'source',\n schemaFile: 'tidas_sources_category.json',\n defaultValueKey: '@classId',\n target: 'common:class',\n },\n unitgroup: {\n type: 'unitgroup',\n schemaFile: 'tidas_unitgroups_category.json',\n defaultValueKey: '@classId',\n target: 'common:class',\n },\n};\n\nconst DATASET_ROOTS = [\n { rootKey: 'contactDataSet', informationKey: 'contactInformation', type: 'contact' },\n { rootKey: 'flowDataSet', informationKey: 'flowInformation', type: 'flow-product' },\n {\n rootKey: 'flowPropertyDataSet',\n informationKey: 'flowPropertiesInformation',\n type: 'flowproperty',\n },\n { rootKey: 'LCIAMethodDataSet', informationKey: 'LCIAMethodInformation', type: 'lciamethod' },\n {\n rootKey: 'lifeCycleModelDataSet',\n informationKey: 'lifeCycleModelInformation',\n type: 'lifecyclemodel',\n },\n { rootKey: 'processDataSet', informationKey: 'processInformation', type: 'process' },\n { rootKey: 'sourceDataSet', informationKey: 'sourceInformation', type: 'source' },\n { rootKey: 'unitGroupDataSet', informationKey: 'unitGroupInformation', type: 'unitgroup' },\n] as const;\n\nconst TYPE_ALIASES: Record<string, DatasetClassificationType> = {\n contact: 'contact',\n contacts: 'contact',\n elementary: 'flow-elementary',\n elementaryflow: 'flow-elementary',\n elementaryflows: 'flow-elementary',\n 'elementary-flow': 'flow-elementary',\n 'elementary-flows': 'flow-elementary',\n flowelementary: 'flow-elementary',\n 'flow-elementary': 'flow-elementary',\n flowproduct: 'flow-product',\n flowproducts: 'flow-product',\n 'flow-product': 'flow-product',\n 'flow-products': 'flow-product',\n flows: 'flow-product',\n product: 'flow-product',\n productflow: 'flow-product',\n productflows: 'flow-product',\n 'product-flow': 'flow-product',\n 'product-flows': 'flow-product',\n flowproperties: 'flowproperty',\n flowproperty: 'flowproperty',\n lcia: 'lciamethod',\n lciamethod: 'lciamethod',\n lciamethods: 'lciamethod',\n location: 'location',\n locations: 'location',\n process: 'process',\n processes: 'process',\n source: 'source',\n sources: 'source',\n unitgroup: 'unitgroup',\n unitgroups: 'unitgroup',\n};\n\nfunction normalizeType(value: unknown): DatasetClassificationType {\n const token = trimToken(value)\n ?.toLowerCase()\n .replace(/[_\\s]+/gu, '-');\n const normalized = token ? (TYPE_ALIASES[token] ?? TYPE_ALIASES[token.replace(/-/gu, '')]) : null;\n if (!normalized) {\n throw new CliError(`Unsupported classification type: ${String(value ?? '')}`, {\n code: 'CLASSIFICATION_TYPE_UNSUPPORTED',\n exitCode: 2,\n });\n }\n return normalized;\n}\n\nfunction schemasDir(candidatesOverride?: string[]): string {\n const here = path.dirname(fileURLToPath(import.meta.url));\n const candidates = candidatesOverride ?? [\n path.resolve(here, '../../assets/tidas-schemas'),\n path.resolve(here, '../../../assets/tidas-schemas'),\n path.resolve(process.cwd(), 'assets/tidas-schemas'),\n ];\n const found = candidates.find((candidate) => existsSync(candidate));\n if (!found) {\n throw new CliError('Bundled TIDAS schemas were not found under assets/tidas-schemas.', {\n code: 'TIDAS_SCHEMAS_NOT_FOUND',\n exitCode: 2,\n });\n }\n return found;\n}\n\nfunction schemaPath(config: CategoryConfig): string {\n return path.join(schemasDir(), config.schemaFile);\n}\n\nconst FALLBACK_LOCATION_TARGET_KEYS = new Set([\n '@location',\n '@subLocation',\n 'impactLocation',\n 'impactSubLocation',\n 'interventionLocation',\n 'interventionSubLocation',\n 'intervensionSubLocation',\n 'location',\n 'locationOfSupply',\n 'subLocation',\n]);\nlet cachedLocationTargetKeys: Set<string> | null = null;\n\nfunction lastSchemaPropertyName(schemaPathSegments: string[]): string | null {\n let propertyName: string | null = null;\n for (let index = 0; index < schemaPathSegments.length - 1; index += 1) {\n if (schemaPathSegments[index] === 'properties') {\n propertyName = schemaPathSegments[index + 1]!;\n }\n }\n return propertyName;\n}\n\nfunction collectLocationRefKeysFromSchema(\n value: unknown,\n schemaPathSegments: string[],\n keys: Set<string>,\n): void {\n if (Array.isArray(value)) {\n value.forEach((item, index) =>\n collectLocationRefKeysFromSchema(item, [...schemaPathSegments, String(index)], keys),\n );\n return;\n }\n if (!isRecord(value)) return;\n\n if (value.$ref === 'tidas_locations_category.json') {\n const propertyName = lastSchemaPropertyName(schemaPathSegments);\n if (propertyName) keys.add(propertyName);\n }\n for (const [key, child] of Object.entries(value)) {\n collectLocationRefKeysFromSchema(child, [...schemaPathSegments, key], keys);\n }\n}\n\nfunction locationTargetKeys(): Set<string> {\n if (cachedLocationTargetKeys) return cachedLocationTargetKeys;\n const keys = new Set<string>();\n const dir = schemasDir();\n for (const fileName of readdirSync(dir).filter(isJsonSchemaFileName)) {\n const document = JSON.parse(readFileSync(path.join(dir, fileName), 'utf8')) as unknown;\n collectLocationRefKeysFromSchema(document, [], keys);\n }\n cachedLocationTargetKeys = new Set([...FALLBACK_LOCATION_TARGET_KEYS, ...keys]);\n return cachedLocationTargetKeys;\n}\n\nfunction isJsonSchemaFileName(fileName: string): boolean {\n return fileName.endsWith('.json');\n}\n\nfunction constText(value: unknown): string | null {\n return isRecord(value) ? firstNonEmpty(value.const) : null;\n}\n\nfunction collectEntriesFromNode(\n node: unknown,\n defaultValueKey: ClassificationValueKey,\n entries: ClassificationEntry[],\n): void {\n if (Array.isArray(node)) {\n node.forEach((entry) => collectEntriesFromNode(entry, defaultValueKey, entries));\n return;\n }\n if (!isRecord(node)) return;\n\n if (isRecord(node.properties)) {\n const properties = node.properties;\n const level = firstNonEmpty(constText(properties['@level']), '0');\n const valueKey =\n (['@classId', '@catId', '@code'] as const).find((key) => constText(properties[key])) ??\n defaultValueKey;\n const code = constText(properties[valueKey]);\n const text = constText(properties['#text']);\n if (level && code && text) {\n const parsedLevel = Number(level);\n if (Number.isInteger(parsedLevel)) {\n entries.push({ level: parsedLevel, code, text, value_key: valueKey });\n }\n }\n } else if (node.const !== undefined && typeof node.description === 'string') {\n entries.push({\n level: 0,\n code: String(node.const),\n text: node.description,\n value_key: '@code',\n });\n }\n\n for (const value of Object.values(node)) {\n if (isRecord(value) || Array.isArray(value)) {\n collectEntriesFromNode(value, defaultValueKey, entries);\n }\n }\n}\n\nfunction loadEntries(type: DatasetClassificationType): {\n config: CategoryConfig;\n schema: string;\n entries: ClassificationEntry[];\n} {\n const config = CATEGORY_CONFIGS[type];\n const schema = schemaPath(config);\n const document = JSON.parse(readFileSync(schema, 'utf8')) as unknown;\n const entries: ClassificationEntry[] = [];\n collectEntriesFromNode(document, config.defaultValueKey, entries);\n return { config, schema, entries };\n}\n\nfunction buildNavigator(entries: ClassificationEntry[]): ClassificationNavigator {\n const childMap = new Map<string, ClassificationEntry[]>();\n const parentMap = new Map<string, ClassificationEntry | null>();\n const entriesByCode = new Map<string, ClassificationEntry>();\n const lastPerLevel = new Map<number, ClassificationEntry>();\n\n for (const entry of entries) {\n entriesByCode.set(entry.code, entry);\n if (entry.level === 0) {\n const roots = childMap.get('') ?? [];\n roots.push(entry);\n childMap.set('', roots);\n parentMap.set(entry.code, null);\n } else {\n let parent: ClassificationEntry | null = null;\n for (let level = entry.level - 1; level >= 0; level -= 1) {\n parent = lastPerLevel.get(level) ?? null;\n if (parent) break;\n }\n if (parent) {\n const children = childMap.get(parent.code) ?? [];\n children.push(entry);\n childMap.set(parent.code, children);\n parentMap.set(entry.code, parent);\n }\n }\n lastPerLevel.set(entry.level, entry);\n }\n return { entries, entriesByCode, childMap, parentMap };\n}\n\nfunction navigatorFor(type: DatasetClassificationType): {\n config: CategoryConfig;\n schema: string;\n navigator: ClassificationNavigator;\n} {\n const { config, schema, entries } = loadEntries(type);\n return { config, schema, navigator: buildNavigator(entries) };\n}\n\nfunction pathForCode(navigator: ClassificationNavigator, code: string): ClassificationEntry[] {\n const entry = navigator.entriesByCode.get(code);\n if (!entry) return [];\n const pathEntries = [entry];\n let current = entry;\n while (true) {\n const parent = navigator.parentMap.get(current.code);\n if (!parent) break;\n pathEntries.push(parent);\n current = parent;\n }\n return pathEntries.reverse();\n}\n\nfunction toPathEntry(entry: ClassificationEntry): ClassificationPathEntry {\n return {\n '@level': String(entry.level),\n [entry.value_key]: entry.code,\n '#text': entry.text,\n } as ClassificationPathEntry;\n}\n\nfunction classCode(value: unknown): string | null {\n return isRecord(value)\n ? firstNonEmpty(\n value['@classId'],\n value['@catId'],\n value['@code'],\n value.class_id,\n value.classId,\n value.cat_id,\n value.catId,\n value.code,\n )\n : null;\n}\n\nfunction pathExpression(pathSegments: Array<string | number>): string {\n return pathSegments.map(String).join('.');\n}\n\nfunction normalizeTargetPath(value: unknown): string | null {\n const raw = firstNonEmpty(value);\n if (!raw) return null;\n if (raw.startsWith('/')) {\n return raw\n .split('/')\n .slice(1)\n .map((segment) => segment.replace(/~1/gu, '/').replace(/~0/gu, '~'))\n .join('.');\n }\n return raw;\n}\n\nfunction decisionTargetPath(decision: JsonObject): string | null {\n return normalizeTargetPath(\n decision.target_path ??\n decision.targetPath ??\n decision.field_path ??\n decision.fieldPath ??\n decision.location_path ??\n decision.locationPath ??\n decision.json_pointer ??\n decision.jsonPointer,\n );\n}\n\nfunction normalizePathFromClasses(\n type: DatasetClassificationType,\n classes: unknown,\n): ClassificationPathEntry[] {\n const { navigator } = navigatorFor(type);\n const rawClasses = Array.isArray(classes) ? classes : isRecord(classes) ? [classes] : [];\n if (rawClasses.length === 0) return [];\n const leafCode = classCode(rawClasses[rawClasses.length - 1]);\n if (!leafCode) return [];\n const canonical = pathForCode(navigator, leafCode);\n const rawCodes = rawClasses.map(classCode).filter(Boolean);\n const canonicalCodes = canonical.map((entry) => entry.code);\n if (\n rawCodes.length > 0 &&\n rawCodes.join('/') !== canonicalCodes.slice(0, rawCodes.length).join('/')\n ) {\n return [];\n }\n return canonical.map(toPathEntry);\n}\n\nfunction normalizePathFromDecision(\n type: DatasetClassificationType,\n decision: JsonObject,\n): ClassificationPathEntry[] {\n const explicit =\n decision.classes ??\n decision.classification_classes ??\n (isRecord(decision.classification)\n ? (decision.classification['common:class'] ??\n decision.classification['common:category'] ??\n decision.classification.classes)\n : null);\n const explicitPath = normalizePathFromClasses(type, explicit);\n if (explicitPath.length > 0) return explicitPath;\n\n const directCode = firstNonEmpty(\n decision.code,\n decision.class_id,\n decision.classId,\n decision.cat_id,\n decision.catId,\n decision.leaf_code,\n decision.leafCode,\n );\n if (directCode) {\n const { navigator } = navigatorFor(type);\n return pathForCode(navigator, directCode).map(toPathEntry);\n }\n\n const rawLabels = decision.classification_path ?? decision.classificationPath;\n const rawIds = decision.class_ids ?? decision.classIds;\n const labels: unknown[] = Array.isArray(rawLabels) ? rawLabels : [];\n const ids: unknown[] = Array.isArray(rawIds) ? rawIds : [];\n if (labels.length > 0 && labels.length === ids.length) {\n return normalizePathFromClasses(\n type,\n labels.map((label, index) => ({\n '@level': String(index),\n '@classId': ids[index],\n '#text': label,\n })),\n );\n }\n\n return [];\n}\n\nfunction normalizeDecisionType(\n decision: JsonObject,\n fallbackType: DatasetClassificationType | null,\n): DatasetClassificationType | null {\n const raw = firstNonEmpty(\n decision.category_type,\n decision.categoryType,\n decision.classification_type,\n decision.classificationType,\n decision.type,\n );\n return raw ? normalizeType(raw) : fallbackType;\n}\n\nfunction readJsonLines(filePath: string): JsonObject[] {\n return readFileSync(filePath, 'utf8')\n .split(/\\r?\\n/u)\n .map((line) => line.trim())\n .filter(Boolean)\n .map((line, index) => {\n const parsed = JSON.parse(line) as unknown;\n if (!isRecord(parsed)) {\n throw new CliError(`Classification decision line ${index + 1} is not an object.`, {\n code: 'CLASSIFICATION_DECISION_INVALID',\n exitCode: 2,\n });\n }\n return parsed;\n });\n}\n\nfunction normalizeStructuredDecisions(value: unknown): JsonObject[] {\n if (Array.isArray(value)) return value.filter(isRecord);\n if (isRecord(value) && Array.isArray(value.decisions)) return value.decisions.filter(isRecord);\n if (isRecord(value) && Array.isArray(value.rows)) return value.rows.filter(isRecord);\n return isRecord(value) ? [value] : [];\n}\n\nfunction readDecisions(pathValue: string, rawInput?: unknown): JsonObject[] {\n if (!pathValue) {\n throw new CliError('Missing required --decisions value.', {\n code: 'CLASSIFICATION_DECISIONS_REQUIRED',\n exitCode: 2,\n });\n }\n if (rawInput !== undefined) return normalizeStructuredDecisions(rawInput);\n const resolved = path.resolve(pathValue);\n if (!existsSync(resolved)) {\n throw new CliError(`Classification decisions file not found: ${resolved}`, {\n code: 'CLASSIFICATION_DECISIONS_NOT_FOUND',\n exitCode: 2,\n });\n }\n return resolved.toLowerCase().endsWith('.jsonl')\n ? readJsonLines(resolved)\n : normalizeStructuredDecisions(readJsonInput(resolved));\n}\n\nfunction prepareRows(inputPath: string, rawInput?: unknown): PreparedClassificationRow[] {\n return readDatasetRowsInput(inputPath, rawInput).map((row, index) => {\n const clonedRow = cloneJson(row);\n const payload = unwrapDatasetPayload(clonedRow);\n const descriptor = DATASET_ROOTS.find((candidate) => isRecord(payload[candidate.rootKey]));\n const root = descriptor ? (payload[descriptor.rootKey] as JsonObject) : {};\n const info =\n descriptor && isRecord(root[descriptor.informationKey])\n ? (root[descriptor.informationKey] as JsonObject)\n : {};\n const dataSetInformation = isRecord(info.dataSetInformation)\n ? (info.dataSetInformation as JsonObject)\n : {};\n const administrativeInformation = isRecord(root.administrativeInformation)\n ? (root.administrativeInformation as JsonObject)\n : {};\n const publicationAndOwnership = isRecord(administrativeInformation.publicationAndOwnership)\n ? (administrativeInformation.publicationAndOwnership as JsonObject)\n : {};\n return {\n index,\n row: clonedRow,\n payload,\n rootKey: descriptor?.rootKey ?? null,\n informationKey: descriptor?.informationKey ?? null,\n id: firstNonEmpty(clonedRow.id, dataSetInformation['common:UUID']),\n version: firstNonEmpty(clonedRow.version, publicationAndOwnership['common:dataSetVersion']),\n };\n });\n}\n\nfunction classificationContainer(\n row: PreparedClassificationRow,\n type: DatasetClassificationType,\n): JsonObject | null {\n if (CATEGORY_CONFIGS[type].target === 'location') return null;\n if (!row.rootKey || !row.informationKey) return null;\n const root = row.payload[row.rootKey];\n if (!isRecord(root)) return null;\n const info = root[row.informationKey];\n if (!isRecord(info)) return null;\n if (!isRecord(info.dataSetInformation)) info.dataSetInformation = {};\n const dataSetInformation = info.dataSetInformation as JsonObject;\n if (!isRecord(dataSetInformation.classificationInformation)) {\n dataSetInformation.classificationInformation = {};\n }\n const classificationInformation = dataSetInformation.classificationInformation as JsonObject;\n const target = CATEGORY_CONFIGS[type].target;\n if (target === 'common:category') {\n if (!isRecord(classificationInformation['common:elementaryFlowCategorization'])) {\n classificationInformation['common:elementaryFlowCategorization'] = {};\n }\n return classificationInformation['common:elementaryFlowCategorization'] as JsonObject;\n }\n if (!isRecord(classificationInformation['common:classification'])) {\n classificationInformation['common:classification'] = {};\n }\n return classificationInformation['common:classification'] as JsonObject;\n}\n\nfunction currentClassification(\n row: PreparedClassificationRow,\n type: DatasetClassificationType,\n): unknown {\n const container = classificationContainer(row, type);\n if (!container) return null;\n return CATEGORY_CONFIGS[type].target === 'common:category'\n ? container['common:category']\n : container['common:class'];\n}\n\nfunction setClassification(\n row: PreparedClassificationRow,\n type: DatasetClassificationType,\n classificationPath: ClassificationPathEntry[],\n): boolean {\n const container = classificationContainer(row, type);\n if (!container) return false;\n if (CATEGORY_CONFIGS[type].target === 'common:category') {\n container['common:category'] = cloneJson(classificationPath);\n } else {\n container['common:class'] = cloneJson(classificationPath);\n }\n return true;\n}\n\nfunction isLocationTargetKey(key: string): boolean {\n return locationTargetKeys().has(key);\n}\n\nfunction locationTargetStringValue(value: unknown): {\n parent: JsonObject | null;\n key: string | null;\n pathSuffix: Array<string | number>;\n value: string;\n} | null {\n if (typeof value === 'string') {\n return {\n parent: null,\n key: null,\n pathSuffix: [],\n value: value.trim(),\n };\n }\n if (isRecord(value) && typeof value['#text'] === 'string') {\n return {\n parent: value,\n key: '#text',\n pathSuffix: ['#text'],\n value: value['#text'].trim(),\n };\n }\n return null;\n}\n\nfunction collectLocationTargets(\n value: unknown,\n pathSegments: Array<string | number> = [],\n targets: LocationTarget[] = [],\n): LocationTarget[] {\n if (!isRecord(value)) {\n if (Array.isArray(value)) {\n value.forEach((item, index) =>\n collectLocationTargets(item, [...pathSegments, index], targets),\n );\n }\n return targets;\n }\n\n for (const [key, child] of Object.entries(value)) {\n const childPath = [...pathSegments, key];\n if (isLocationTargetKey(key)) {\n const targetValue = locationTargetStringValue(child);\n if (targetValue) {\n const leafPath = [...childPath, ...targetValue.pathSuffix];\n const parent = targetValue.pathSuffix.length > 0 ? targetValue.parent : value;\n const targetKey = targetValue.pathSuffix.length > 0 ? targetValue.key : key;\n targets.push({\n path: pathExpression(leafPath),\n parentPath: pathExpression(targetValue.pathSuffix.length > 0 ? childPath : pathSegments),\n parent: parent as JsonObject,\n key: targetKey as string,\n value: targetValue.value,\n });\n }\n }\n collectLocationTargets(child, childPath, targets);\n }\n return targets;\n}\n\nfunction locationCodeFromPath(classificationPath: ClassificationPathEntry[]): string | null {\n const leaf = classificationPath.at(-1);\n return classCode(leaf);\n}\n\nfunction resolveLocationTarget(\n row: PreparedClassificationRow,\n decision: NormalizedDecision,\n): LocationTarget[] {\n const targets = collectLocationTargets(row.payload);\n if (!decision.targetPath) return targets;\n return targets.filter(\n (target) => target.path === decision.targetPath || target.parentPath === decision.targetPath,\n );\n}\n\nfunction decisionMatchesRow(decision: NormalizedDecision, row: PreparedClassificationRow): boolean {\n if (decision.rowIndex !== null) return decision.rowIndex === row.index;\n if (!decision.datasetId || decision.datasetId !== row.id) return false;\n return !decision.datasetVersion || decision.datasetVersion === row.version;\n}\n\nfunction normalizeDecision(\n decision: JsonObject,\n decisionIndex: number,\n fallbackType: DatasetClassificationType | null,\n blockers: DatasetClassificationBlocker[],\n): NormalizedDecision | null {\n const rawRowIndex = decision.row_index ?? decision.rowIndex;\n const rowIndexText = firstNonEmpty(rawRowIndex);\n const rowIndex =\n typeof rawRowIndex === 'number'\n ? rawRowIndex\n : rowIndexText === null\n ? null\n : Number(rowIndexText);\n const validRowIndex =\n typeof rowIndex === 'number' && Number.isInteger(rowIndex) ? rowIndex : null;\n const datasetId = firstNonEmpty(\n decision.dataset_id,\n decision.datasetId,\n decision.id,\n decision.uuid,\n );\n const datasetVersion = firstNonEmpty(\n decision.dataset_version,\n decision.datasetVersion,\n decision.version,\n );\n const categoryType = normalizeDecisionType(decision, fallbackType);\n if (validRowIndex === null && !datasetId) {\n blockers.push({\n code: 'classification_decision_target_missing',\n message: 'Classification decision must target row_index or dataset_id.',\n decision_index: decisionIndex,\n });\n return null;\n }\n if (!categoryType) {\n blockers.push({\n code: 'classification_decision_type_missing',\n message:\n 'Classification decision must provide a category_type or the command must pass --type.',\n decision_index: decisionIndex,\n row_index: validRowIndex ?? undefined,\n dataset_id: datasetId,\n dataset_version: datasetVersion,\n });\n return null;\n }\n const classificationPath = normalizePathFromDecision(categoryType, decision);\n if (classificationPath.length === 0) {\n blockers.push({\n code: 'classification_decision_path_invalid',\n message:\n 'Classification decision must resolve to a valid path in the bundled TIDAS category schema.',\n decision_index: decisionIndex,\n row_index: validRowIndex ?? undefined,\n dataset_id: datasetId,\n dataset_version: datasetVersion,\n });\n return null;\n }\n return {\n decisionIndex,\n rowIndex: validRowIndex,\n datasetId,\n datasetVersion,\n categoryType,\n path: classificationPath,\n targetPath: decisionTargetPath(decision),\n basis: firstNonEmpty(decision.basis),\n evidence: decision.evidence ?? null,\n };\n}\n\nfunction maybeWriteReport<T extends { files?: { report: string } }>(\n report: T,\n outDir: string | null | undefined,\n filename: string,\n): T {\n if (!outDir) return report;\n const reportPath = path.join(path.resolve(outDir), 'outputs', filename);\n const finalReport = { ...report, files: { report: reportPath } };\n writeJsonArtifact(reportPath, finalReport);\n return finalReport;\n}\n\nexport async function runDatasetClassificationChildren(\n options: RunDatasetClassificationChildrenOptions,\n): Promise<DatasetClassificationChildrenReport> {\n const type = normalizeType(options.type);\n const { config, navigator } = navigatorFor(type);\n const parentCode = firstNonEmpty(options.parent);\n const rawChildren = navigator.childMap.get(parentCode ?? '') ?? [];\n const parentKnown = !parentCode || navigator.entriesByCode.has(parentCode);\n const query = firstNonEmpty(options.query)?.toLowerCase() ?? null;\n const filtered = query\n ? rawChildren.filter(\n (entry) =>\n entry.code.toLowerCase().includes(query) || entry.text.toLowerCase().includes(query),\n )\n : rawChildren;\n const limit = options.limit && options.limit > 0 ? options.limit : null;\n const returned = limit ? filtered.slice(0, limit) : filtered;\n const report: DatasetClassificationChildrenReport = {\n schema_version: 1,\n generated_at_utc: (options.now ?? new Date()).toISOString(),\n status: parentKnown ? 'completed' : 'blocked',\n command: 'dataset classification children',\n category_type: type,\n schema_file: config.schemaFile,\n parent_code: parentCode,\n query,\n counts: {\n children: rawChildren.length,\n returned: returned.length,\n },\n children: returned.map((entry) => ({\n ...entry,\n path: pathForCode(navigator, entry.code).map(toPathEntry),\n })),\n blockers: parentKnown\n ? []\n : [{ code: 'classification_parent_unknown', message: `Unknown parent code: ${parentCode}` }],\n };\n return maybeWriteReport(report, options.outDir, 'classification-children-report.json');\n}\n\nexport async function runDatasetClassificationPath(\n options: RunDatasetClassificationPathOptions,\n): Promise<DatasetClassificationPathReport> {\n const type = normalizeType(options.type);\n const { config, navigator } = navigatorFor(type);\n const code = firstNonEmpty(options.code);\n if (!code) {\n throw new CliError('Missing required --code value.', {\n code: 'CLASSIFICATION_CODE_REQUIRED',\n exitCode: 2,\n });\n }\n const pathEntries = pathForCode(navigator, code).map(toPathEntry);\n const report: DatasetClassificationPathReport = {\n schema_version: 1,\n generated_at_utc: (options.now ?? new Date()).toISOString(),\n status: pathEntries.length > 0 ? 'completed' : 'blocked',\n command: 'dataset classification path',\n category_type: type,\n schema_file: config.schemaFile,\n code,\n path: pathEntries,\n blockers:\n pathEntries.length > 0\n ? []\n : [\n {\n code: 'classification_code_unknown',\n message: `Unknown classification code: ${code}`,\n },\n ],\n };\n return maybeWriteReport(report, options.outDir, 'classification-path-report.json');\n}\n\nexport async function runDatasetClassificationAudit(\n options: RunDatasetClassificationAuditOptions,\n): Promise<DatasetClassificationAuditReport> {\n if (!options.inputPath) {\n throw new CliError('Missing required --input value.', {\n code: 'CLASSIFICATION_AUDIT_INPUT_REQUIRED',\n exitCode: 2,\n });\n }\n const type = normalizeType(options.type);\n if (type !== 'location') {\n throw new CliError('dataset classification audit currently supports only --type location.', {\n code: 'CLASSIFICATION_AUDIT_TYPE_UNSUPPORTED',\n exitCode: 2,\n });\n }\n const { config, navigator } = navigatorFor(type);\n const rows = prepareRows(options.inputPath, options.rawInput);\n const findings: DatasetClassificationAuditFinding[] = [];\n const blockers: DatasetClassificationBlocker[] = [];\n for (const row of rows) {\n for (const target of collectLocationTargets(row.payload)) {\n const entry = navigator.entriesByCode.get(target.value);\n const status = entry ? 'valid' : 'invalid';\n findings.push({\n row_index: row.index,\n dataset_id: row.id,\n dataset_version: row.version,\n path: target.path,\n value: target.value,\n status,\n description: entry?.text ?? null,\n });\n if (!entry) {\n blockers.push({\n code: 'location_code_invalid',\n message: 'Location value is not a code from the bundled TIDAS location schema.',\n row_index: row.index,\n dataset_id: row.id,\n dataset_version: row.version,\n });\n }\n }\n }\n const invalid = findings.filter((finding) => finding.status === 'invalid').length;\n const outDir = options.outDir ? path.resolve(options.outDir) : null;\n const findingsPath = outDir\n ? path.join(outDir, 'outputs', 'location-audit-findings.jsonl')\n : null;\n const reportPath = outDir ? path.join(outDir, 'outputs', 'location-audit-report.json') : null;\n const report: DatasetClassificationAuditReport = {\n schema_version: 1,\n generated_at_utc: (options.now ?? new Date()).toISOString(),\n status: invalid > 0 ? 'blocked' : 'completed',\n command: 'dataset classification audit',\n category_type: type,\n schema_file: config.schemaFile,\n input_path: path.resolve(options.inputPath),\n counts: {\n rows: rows.length,\n location_targets: findings.length,\n valid: findings.length - invalid,\n invalid,\n },\n findings,\n blockers,\n ...(findingsPath && reportPath\n ? {\n files: {\n findings: findingsPath,\n report: reportPath,\n },\n }\n : {}),\n };\n if (findingsPath && reportPath) {\n writeJsonLinesArtifact(findingsPath, findings);\n writeJsonArtifact(reportPath, report);\n }\n return report;\n}\n\nexport async function runDatasetClassificationApply(\n options: RunDatasetClassificationApplyOptions,\n): Promise<DatasetClassificationApplyReport> {\n if (!options.inputPath) {\n throw new CliError('Missing required --input value.', {\n code: 'CLASSIFICATION_INPUT_REQUIRED',\n exitCode: 2,\n });\n }\n if (!options.outPath) {\n throw new CliError('Missing required --out value.', {\n code: 'CLASSIFICATION_OUT_REQUIRED',\n exitCode: 2,\n });\n }\n const fallbackType = options.type ? normalizeType(options.type) : null;\n const rows = prepareRows(options.inputPath, options.rawInput);\n const rawDecisions = readDecisions(options.decisionsPath, options.rawDecisions);\n const blockers: DatasetClassificationBlocker[] = [];\n const decisions = rawDecisions\n .map((decision, index) => normalizeDecision(decision, index, fallbackType, blockers))\n .filter((decision): decision is NormalizedDecision => Boolean(decision));\n const evidence = [];\n\n for (const decision of decisions) {\n const matches = rows.filter((row) => decisionMatchesRow(decision, row));\n if (matches.length !== 1) {\n blockers.push({\n code:\n matches.length === 0\n ? 'classification_target_not_found'\n : 'classification_target_ambiguous',\n message:\n matches.length === 0\n ? 'Classification decision did not match an input row.'\n : 'Classification decision matched more than one input row.',\n decision_index: decision.decisionIndex,\n row_index: decision.rowIndex ?? undefined,\n dataset_id: decision.datasetId,\n dataset_version: decision.datasetVersion,\n });\n continue;\n }\n const row = matches[0] as PreparedClassificationRow;\n if (decision.categoryType === 'location') {\n const code = locationCodeFromPath(decision.path);\n const targetMatches = resolveLocationTarget(row, decision);\n if (!code || targetMatches.length !== 1) {\n blockers.push({\n code:\n targetMatches.length === 0 ? 'location_target_not_found' : 'location_target_ambiguous',\n message:\n targetMatches.length === 0\n ? 'Location decision did not match a location field in the input row.'\n : 'Location decision matched more than one location field; provide target_path.',\n decision_index: decision.decisionIndex,\n row_index: row.index,\n dataset_id: row.id,\n dataset_version: row.version,\n });\n continue;\n }\n const target = targetMatches[0] as LocationTarget;\n const previous = target.value;\n target.parent[target.key] = code;\n evidence.push({\n decision_index: decision.decisionIndex,\n row_index: row.index,\n dataset_id: row.id,\n dataset_version: row.version,\n category_type: decision.categoryType,\n target_path: target.path,\n previous_location: previous,\n applied_location: code,\n applied_location_path: cloneJson(decision.path),\n basis: decision.basis,\n evidence: decision.evidence,\n });\n continue;\n }\n const previous = currentClassification(row, decision.categoryType);\n if (!setClassification(row, decision.categoryType, decision.path)) {\n blockers.push({\n code: 'classification_container_missing',\n message: 'Input row does not contain a supported classification container for this type.',\n decision_index: decision.decisionIndex,\n row_index: row.index,\n dataset_id: row.id,\n dataset_version: row.version,\n });\n continue;\n }\n evidence.push({\n decision_index: decision.decisionIndex,\n row_index: row.index,\n dataset_id: row.id,\n dataset_version: row.version,\n category_type: decision.categoryType,\n previous_classification: previous,\n applied_classification: cloneJson(decision.path),\n basis: decision.basis,\n evidence: decision.evidence,\n });\n }\n\n const outDir = options.outDir\n ? path.resolve(options.outDir)\n : path.dirname(path.resolve(options.outPath));\n const evidencePath = path.join(outDir, 'outputs', 'classification-apply-evidence.jsonl');\n const reportPath = path.join(outDir, 'outputs', 'classification-apply-report.json');\n writeJsonLinesArtifact(\n options.outPath,\n rows.map((row) => row.payload),\n );\n writeJsonLinesArtifact(evidencePath, evidence);\n const report: DatasetClassificationApplyReport = {\n schema_version: 1,\n generated_at_utc: (options.now ?? new Date()).toISOString(),\n status: blockers.length > 0 ? 'blocked' : 'completed',\n command: 'dataset classification apply',\n input_path: path.resolve(options.inputPath),\n decisions_path: path.resolve(options.decisionsPath),\n out_path: path.resolve(options.outPath),\n default_category_type: fallbackType,\n counts: {\n rows: rows.length,\n decisions: rawDecisions.length,\n applied: evidence.length,\n blockers: blockers.length,\n },\n blockers,\n files: {\n classified_rows: path.resolve(options.outPath),\n evidence: evidencePath,\n report: reportPath,\n },\n };\n writeJsonArtifact(reportPath, report);\n return report;\n}\n\nexport const __testInternals = {\n buildNavigator,\n classCode,\n classificationContainer,\n collectEntriesFromNode,\n collectLocationRefKeysFromSchema,\n collectLocationTargets,\n constText,\n currentClassification,\n decisionMatchesRow,\n decisionTargetPath,\n isJsonSchemaFileName,\n lastSchemaPropertyName,\n loadEntries,\n locationCodeFromPath,\n locationTargetStringValue,\n locationTargetKeys,\n maybeWriteReport,\n navigatorFor,\n normalizeDecision,\n normalizeDecisionType,\n normalizePathFromClasses,\n normalizePathFromDecision,\n normalizeStructuredDecisions,\n normalizeTargetPath,\n normalizeType,\n pathForCode,\n prepareRows,\n readDecisions,\n resolveLocationTarget,\n schemasDir,\n setClassification,\n toPathEntry,\n};\n"]}
1
+ {"version":3,"file":"dataset-classification.js","sourceRoot":"","sources":["../../../src/lib/dataset-classification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAA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C3B,qBAAqB;IACrB,kBAAkB;IAClB,kBAAkB;IAClB,oBAAoB;IACpB,sBAAsB;IACtB,WAAW;IACX,oBAAoB;IACpB,yBAAyB;IACzB,kBAAkB;IAClB,gBAAgB;IAChB,YAAY;IACZ,iBAAiB;IACjB,qBAAqB;IACrB,wBAAwB;IACxB,yBAAyB;IACzB,4BAA4B;IAC5B,mBAAmB;IACnB,aAAa;IACb,WAAW;IACX,WAAW;IACX,aAAa;IACb,qBAAqB;IACrB,UAAU;IACV,iBAAiB;IACjB,kBAAkB;IAClB,WAAW;CACZ,CAAC","sourcesContent":["import { existsSync, readdirSync, readFileSync } from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { writeJsonArtifact, writeJsonLinesArtifact } from './artifacts.js';\nimport {\n cloneJson,\n firstNonEmpty,\n isRecord,\n readDatasetRowsInput,\n trimToken,\n unwrapDatasetPayload,\n type JsonObject,\n} from './dataset-local.js';\nimport { CliError } from './errors.js';\nimport { readJsonInput } from './io.js';\n\nexport type DatasetClassificationType =\n | 'contact'\n | 'flow-elementary'\n | 'flow-product'\n | 'flowproperty'\n | 'lciamethod'\n | 'location'\n | 'process'\n | 'source'\n | 'unitgroup';\n\ntype ClassificationValueKey = '@catId' | '@classId' | '@code';\n\nexport type ClassificationEntry = {\n level: number;\n code: string;\n text: string;\n value_key: ClassificationValueKey;\n};\n\nexport type ClassificationPathEntry = {\n '@level': string;\n '@classId'?: string;\n '@catId'?: string;\n '@code'?: string;\n '#text': string;\n};\n\nexport type DatasetClassificationChildrenReport = {\n schema_version: 1;\n generated_at_utc: string;\n status: 'completed' | 'blocked';\n command: 'dataset classification children';\n category_type: DatasetClassificationType;\n schema_file: string;\n parent_code: string | null;\n query: string | null;\n counts: {\n children: number;\n returned: number;\n };\n children: Array<ClassificationEntry & { path: ClassificationPathEntry[] }>;\n blockers: Array<{ code: string; message: string }>;\n files?: {\n report: string;\n };\n};\n\nexport type DatasetClassificationPathReport = {\n schema_version: 1;\n generated_at_utc: string;\n status: 'completed' | 'blocked';\n command: 'dataset classification path';\n category_type: DatasetClassificationType;\n schema_file: string;\n code: string;\n path: ClassificationPathEntry[];\n blockers: Array<{ code: string; message: string }>;\n files?: {\n report: string;\n };\n};\n\nexport type DatasetClassificationApplyReport = {\n schema_version: 1;\n generated_at_utc: string;\n status: 'completed' | 'blocked';\n command: 'dataset classification apply';\n input_path: string;\n decisions_path: string;\n out_path: string;\n default_category_type: DatasetClassificationType | null;\n counts: {\n rows: number;\n decisions: number;\n applied: number;\n blockers: number;\n };\n blockers: DatasetClassificationBlocker[];\n files: {\n classified_rows: string;\n evidence: string;\n report: string;\n };\n};\n\nexport type DatasetClassificationAuditFinding = {\n row_index: number;\n dataset_id: string | null;\n dataset_version: string | null;\n path: string;\n value: string;\n status: 'valid' | 'invalid';\n description: string | null;\n};\n\nexport type DatasetClassificationAuditReport = {\n schema_version: 1;\n generated_at_utc: string;\n status: 'completed' | 'blocked';\n command: 'dataset classification audit';\n category_type: DatasetClassificationType;\n schema_file: string;\n input_path: string;\n counts: {\n rows: number;\n location_targets: number;\n valid: number;\n invalid: number;\n };\n findings: DatasetClassificationAuditFinding[];\n blockers: DatasetClassificationBlocker[];\n files?: {\n findings: string;\n report: string;\n };\n};\n\nexport type DatasetClassificationBlocker = {\n code: string;\n message: string;\n decision_index?: number;\n row_index?: number;\n dataset_id?: string | null;\n dataset_version?: string | null;\n};\n\nexport type RunDatasetClassificationChildrenOptions = {\n type: string;\n parent?: string | null;\n query?: string | null;\n limit?: number | null;\n outDir?: string | null;\n now?: Date;\n};\n\nexport type RunDatasetClassificationPathOptions = {\n type: string;\n code: string;\n outDir?: string | null;\n now?: Date;\n};\n\nexport type RunDatasetClassificationAuditOptions = {\n inputPath: string;\n type: string;\n outDir?: string | null;\n rawInput?: unknown;\n now?: Date;\n};\n\nexport type RunDatasetClassificationApplyOptions = {\n inputPath: string;\n decisionsPath: string;\n outPath: string;\n type?: string | null;\n outDir?: string | null;\n rawInput?: unknown;\n rawDecisions?: unknown;\n now?: Date;\n};\n\ntype CategoryConfig = {\n type: DatasetClassificationType;\n schemaFile: string;\n defaultValueKey: ClassificationValueKey;\n target: 'common:category' | 'common:class' | 'location';\n};\n\ntype ClassificationNavigator = {\n entries: ClassificationEntry[];\n entriesByCode: Map<string, ClassificationEntry>;\n childMap: Map<string, ClassificationEntry[]>;\n parentMap: Map<string, ClassificationEntry | null>;\n};\n\ntype NormalizedDecision = {\n decisionIndex: number;\n rowIndex: number | null;\n datasetId: string | null;\n datasetVersion: string | null;\n categoryType: DatasetClassificationType;\n path: ClassificationPathEntry[];\n targetPath: string | null;\n basis: string | null;\n evidence: unknown;\n};\n\ntype LocationTarget = {\n path: string;\n parentPath: string;\n parent: JsonObject;\n key: string;\n value: string;\n};\n\ntype PreparedClassificationRow = {\n index: number;\n row: JsonObject;\n payload: JsonObject;\n rootKey: string | null;\n informationKey: string | null;\n id: string | null;\n version: string | null;\n};\n\nconst CATEGORY_CONFIGS: Record<DatasetClassificationType, CategoryConfig> = {\n contact: {\n type: 'contact',\n schemaFile: 'tidas_contacts_category.json',\n defaultValueKey: '@classId',\n target: 'common:class',\n },\n 'flow-elementary': {\n type: 'flow-elementary',\n schemaFile: 'tidas_flows_elementary_category.json',\n defaultValueKey: '@catId',\n target: 'common:category',\n },\n 'flow-product': {\n type: 'flow-product',\n schemaFile: 'tidas_flows_product_category.json',\n defaultValueKey: '@classId',\n target: 'common:class',\n },\n flowproperty: {\n type: 'flowproperty',\n schemaFile: 'tidas_flowproperties_category.json',\n defaultValueKey: '@classId',\n target: 'common:class',\n },\n lciamethod: {\n type: 'lciamethod',\n schemaFile: 'tidas_lciamethods_category.json',\n defaultValueKey: '@classId',\n target: 'common:class',\n },\n location: {\n type: 'location',\n schemaFile: 'tidas_locations_category.json',\n defaultValueKey: '@code',\n target: 'location',\n },\n process: {\n type: 'process',\n schemaFile: 'tidas_processes_category.json',\n defaultValueKey: '@classId',\n target: 'common:class',\n },\n source: {\n type: 'source',\n schemaFile: 'tidas_sources_category.json',\n defaultValueKey: '@classId',\n target: 'common:class',\n },\n unitgroup: {\n type: 'unitgroup',\n schemaFile: 'tidas_unitgroups_category.json',\n defaultValueKey: '@classId',\n target: 'common:class',\n },\n};\n\nconst DATASET_ROOTS = [\n { rootKey: 'contactDataSet', informationKey: 'contactInformation', type: 'contact' },\n { rootKey: 'flowDataSet', informationKey: 'flowInformation', type: 'flow-product' },\n {\n rootKey: 'flowPropertyDataSet',\n informationKey: 'flowPropertiesInformation',\n type: 'flowproperty',\n },\n { rootKey: 'LCIAMethodDataSet', informationKey: 'LCIAMethodInformation', type: 'lciamethod' },\n {\n rootKey: 'lifeCycleModelDataSet',\n informationKey: 'lifeCycleModelInformation',\n type: 'lifecyclemodel',\n },\n { rootKey: 'processDataSet', informationKey: 'processInformation', type: 'process' },\n { rootKey: 'sourceDataSet', informationKey: 'sourceInformation', type: 'source' },\n { rootKey: 'unitGroupDataSet', informationKey: 'unitGroupInformation', type: 'unitgroup' },\n] as const;\n\nconst TYPE_ALIASES: Record<string, DatasetClassificationType> = {\n contact: 'contact',\n contacts: 'contact',\n elementary: 'flow-elementary',\n elementaryflow: 'flow-elementary',\n elementaryflows: 'flow-elementary',\n 'elementary-flow': 'flow-elementary',\n 'elementary-flows': 'flow-elementary',\n flowelementary: 'flow-elementary',\n 'flow-elementary': 'flow-elementary',\n flowproduct: 'flow-product',\n flowproducts: 'flow-product',\n 'flow-product': 'flow-product',\n 'flow-products': 'flow-product',\n flows: 'flow-product',\n product: 'flow-product',\n productflow: 'flow-product',\n productflows: 'flow-product',\n 'product-flow': 'flow-product',\n 'product-flows': 'flow-product',\n flowproperties: 'flowproperty',\n flowproperty: 'flowproperty',\n lcia: 'lciamethod',\n lciamethod: 'lciamethod',\n lciamethods: 'lciamethod',\n location: 'location',\n locations: 'location',\n process: 'process',\n processes: 'process',\n source: 'source',\n sources: 'source',\n unitgroup: 'unitgroup',\n unitgroups: 'unitgroup',\n};\n\nfunction normalizeType(value: unknown): DatasetClassificationType {\n const token = trimToken(value)\n ?.toLowerCase()\n .replace(/[_\\s]+/gu, '-');\n const normalized = token ? (TYPE_ALIASES[token] ?? TYPE_ALIASES[token.replace(/-/gu, '')]) : null;\n if (!normalized) {\n throw new CliError(`Unsupported classification type: ${String(value ?? '')}`, {\n code: 'CLASSIFICATION_TYPE_UNSUPPORTED',\n exitCode: 2,\n });\n }\n return normalized;\n}\n\nfunction schemasDir(candidatesOverride?: string[]): string {\n const here = path.dirname(fileURLToPath(import.meta.url));\n const candidates = candidatesOverride ?? [\n path.resolve(here, '../../assets/tidas-schemas'),\n path.resolve(here, '../../../assets/tidas-schemas'),\n path.resolve(process.cwd(), 'assets/tidas-schemas'),\n ];\n const found = candidates.find((candidate) => existsSync(candidate));\n if (!found) {\n throw new CliError('Bundled TIDAS schemas were not found under assets/tidas-schemas.', {\n code: 'TIDAS_SCHEMAS_NOT_FOUND',\n exitCode: 2,\n });\n }\n return found;\n}\n\nfunction schemaPath(config: CategoryConfig): string {\n return path.join(schemasDir(), config.schemaFile);\n}\n\nconst FALLBACK_LOCATION_TARGET_KEYS = new Set([\n '@location',\n '@subLocation',\n 'impactLocation',\n 'impactSubLocation',\n 'interventionLocation',\n 'interventionSubLocation',\n 'intervensionSubLocation',\n 'location',\n 'locationOfSupply',\n 'subLocation',\n]);\nlet cachedLocationTargetKeys: Set<string> | null = null;\n\nfunction lastSchemaPropertyName(schemaPathSegments: string[]): string | null {\n let propertyName: string | null = null;\n for (let index = 0; index < schemaPathSegments.length - 1; index += 1) {\n if (schemaPathSegments[index] === 'properties') {\n propertyName = schemaPathSegments[index + 1]!;\n }\n }\n return propertyName;\n}\n\nfunction collectLocationRefKeysFromSchema(\n value: unknown,\n schemaPathSegments: string[],\n keys: Set<string>,\n): void {\n if (Array.isArray(value)) {\n value.forEach((item, index) =>\n collectLocationRefKeysFromSchema(item, [...schemaPathSegments, String(index)], keys),\n );\n return;\n }\n if (!isRecord(value)) return;\n\n if (value.$ref === 'tidas_locations_category.json') {\n const propertyName = lastSchemaPropertyName(schemaPathSegments);\n if (propertyName) keys.add(propertyName);\n }\n for (const [key, child] of Object.entries(value)) {\n collectLocationRefKeysFromSchema(child, [...schemaPathSegments, key], keys);\n }\n}\n\nfunction locationTargetKeys(): Set<string> {\n if (cachedLocationTargetKeys) return cachedLocationTargetKeys;\n const keys = new Set<string>();\n const dir = schemasDir();\n for (const fileName of readdirSync(dir).filter(isJsonSchemaFileName)) {\n const document = JSON.parse(readFileSync(path.join(dir, fileName), 'utf8')) as unknown;\n collectLocationRefKeysFromSchema(document, [], keys);\n }\n cachedLocationTargetKeys = new Set([...FALLBACK_LOCATION_TARGET_KEYS, ...keys]);\n return cachedLocationTargetKeys;\n}\n\nfunction isJsonSchemaFileName(fileName: string): boolean {\n return fileName.endsWith('.json');\n}\n\nfunction constText(value: unknown): string | null {\n return isRecord(value) ? firstNonEmpty(value.const) : null;\n}\n\nfunction collectEntriesFromNode(\n node: unknown,\n defaultValueKey: ClassificationValueKey,\n entries: ClassificationEntry[],\n): void {\n if (Array.isArray(node)) {\n node.forEach((entry) => collectEntriesFromNode(entry, defaultValueKey, entries));\n return;\n }\n if (!isRecord(node)) return;\n\n if (isRecord(node.properties)) {\n const properties = node.properties;\n const level = firstNonEmpty(constText(properties['@level']), '0');\n const valueKey =\n (['@classId', '@catId', '@code'] as const).find((key) => constText(properties[key])) ??\n defaultValueKey;\n const code = constText(properties[valueKey]);\n const text = constText(properties['#text']);\n if (level && code && text) {\n const parsedLevel = Number(level);\n if (Number.isInteger(parsedLevel)) {\n entries.push({ level: parsedLevel, code, text, value_key: valueKey });\n }\n }\n } else if (node.const !== undefined && typeof node.description === 'string') {\n entries.push({\n level: 0,\n code: String(node.const),\n text: node.description,\n value_key: '@code',\n });\n }\n\n for (const value of Object.values(node)) {\n if (isRecord(value) || Array.isArray(value)) {\n collectEntriesFromNode(value, defaultValueKey, entries);\n }\n }\n}\n\nfunction loadEntries(type: DatasetClassificationType): {\n config: CategoryConfig;\n schema: string;\n entries: ClassificationEntry[];\n} {\n const config = CATEGORY_CONFIGS[type];\n const schema = schemaPath(config);\n const document = JSON.parse(readFileSync(schema, 'utf8')) as unknown;\n const entries: ClassificationEntry[] = [];\n collectEntriesFromNode(document, config.defaultValueKey, entries);\n return { config, schema, entries };\n}\n\nfunction buildNavigator(entries: ClassificationEntry[]): ClassificationNavigator {\n const childMap = new Map<string, ClassificationEntry[]>();\n const parentMap = new Map<string, ClassificationEntry | null>();\n const entriesByCode = new Map<string, ClassificationEntry>();\n const lastPerLevel = new Map<number, ClassificationEntry>();\n\n for (const entry of entries) {\n entriesByCode.set(entry.code, entry);\n if (entry.level === 0) {\n const roots = childMap.get('') ?? [];\n roots.push(entry);\n childMap.set('', roots);\n parentMap.set(entry.code, null);\n } else {\n let parent: ClassificationEntry | null = null;\n for (let level = entry.level - 1; level >= 0; level -= 1) {\n parent = lastPerLevel.get(level) ?? null;\n if (parent) break;\n }\n if (parent) {\n const children = childMap.get(parent.code) ?? [];\n children.push(entry);\n childMap.set(parent.code, children);\n parentMap.set(entry.code, parent);\n }\n }\n lastPerLevel.set(entry.level, entry);\n }\n return { entries, entriesByCode, childMap, parentMap };\n}\n\nfunction navigatorFor(type: DatasetClassificationType): {\n config: CategoryConfig;\n schema: string;\n navigator: ClassificationNavigator;\n} {\n const { config, schema, entries } = loadEntries(type);\n return { config, schema, navigator: buildNavigator(entries) };\n}\n\nfunction pathForCode(navigator: ClassificationNavigator, code: string): ClassificationEntry[] {\n const entry = navigator.entriesByCode.get(code);\n if (!entry) return [];\n const pathEntries = [entry];\n let current = entry;\n while (true) {\n const parent = navigator.parentMap.get(current.code);\n if (!parent) break;\n pathEntries.push(parent);\n current = parent;\n }\n return pathEntries.reverse();\n}\n\nfunction toPathEntry(entry: ClassificationEntry): ClassificationPathEntry {\n return {\n '@level': String(entry.level),\n [entry.value_key]: entry.code,\n '#text': entry.text,\n } as ClassificationPathEntry;\n}\n\nfunction classCode(value: unknown): string | null {\n return isRecord(value)\n ? firstNonEmpty(\n value['@classId'],\n value['@catId'],\n value['@code'],\n value.class_id,\n value.classId,\n value.cat_id,\n value.catId,\n value.code,\n )\n : null;\n}\n\nfunction pathExpression(pathSegments: Array<string | number>): string {\n return pathSegments.map(String).join('.');\n}\n\nfunction normalizeTargetPath(value: unknown): string | null {\n const raw = firstNonEmpty(value);\n if (!raw) return null;\n if (raw.startsWith('/')) {\n return raw\n .split('/')\n .slice(1)\n .map((segment) => segment.replace(/~1/gu, '/').replace(/~0/gu, '~'))\n .join('.');\n }\n return raw;\n}\n\nfunction decisionTargetPath(decision: JsonObject): string | null {\n return normalizeTargetPath(\n decision.target_path ??\n decision.targetPath ??\n decision.field_path ??\n decision.fieldPath ??\n decision.location_path ??\n decision.locationPath ??\n decision.json_pointer ??\n decision.jsonPointer,\n );\n}\n\nfunction normalizePathFromClasses(\n type: DatasetClassificationType,\n classes: unknown,\n): ClassificationPathEntry[] {\n const { navigator } = navigatorFor(type);\n const rawClasses = Array.isArray(classes) ? classes : isRecord(classes) ? [classes] : [];\n if (rawClasses.length === 0) return [];\n const leafCode = classCode(rawClasses[rawClasses.length - 1]);\n if (!leafCode) return [];\n const canonical = pathForCode(navigator, leafCode);\n const rawCodes = rawClasses.map(classCode).filter(Boolean);\n const canonicalCodes = canonical.map((entry) => entry.code);\n if (\n rawCodes.length > 0 &&\n rawCodes.join('/') !== canonicalCodes.slice(0, rawCodes.length).join('/')\n ) {\n return [];\n }\n return canonical.map(toPathEntry);\n}\n\nfunction normalizePathFromDecision(\n type: DatasetClassificationType,\n decision: JsonObject,\n): ClassificationPathEntry[] {\n const explicit =\n decision.classes ??\n decision.classification_classes ??\n (isRecord(decision.classification)\n ? (decision.classification['common:class'] ??\n decision.classification['common:category'] ??\n decision.classification.classes)\n : null);\n const explicitPath = normalizePathFromClasses(type, explicit);\n if (explicitPath.length > 0) return explicitPath;\n\n const directCode = firstNonEmpty(\n decision.code,\n decision.class_id,\n decision.classId,\n decision.cat_id,\n decision.catId,\n decision.leaf_code,\n decision.leafCode,\n );\n if (directCode) {\n const { navigator } = navigatorFor(type);\n return pathForCode(navigator, directCode).map(toPathEntry);\n }\n\n const rawLabels = decision.classification_path ?? decision.classificationPath;\n const rawIds = decision.class_ids ?? decision.classIds;\n const labels: unknown[] = Array.isArray(rawLabels) ? rawLabels : [];\n const ids: unknown[] = Array.isArray(rawIds) ? rawIds : [];\n if (labels.length > 0 && labels.length === ids.length) {\n return normalizePathFromClasses(\n type,\n labels.map((label, index) => ({\n '@level': String(index),\n '@classId': ids[index],\n '#text': label,\n })),\n );\n }\n\n return [];\n}\n\nfunction normalizeDecisionType(\n decision: JsonObject,\n fallbackType: DatasetClassificationType | null,\n): DatasetClassificationType | null {\n const raw = firstNonEmpty(\n decision.category_type,\n decision.categoryType,\n decision.classification_type,\n decision.classificationType,\n decision.type,\n );\n return raw ? normalizeType(raw) : fallbackType;\n}\n\nfunction readJsonLines(filePath: string): JsonObject[] {\n return readFileSync(filePath, 'utf8')\n .split(/\\r?\\n/u)\n .map((line) => line.trim())\n .filter(Boolean)\n .map((line, index) => {\n const parsed = JSON.parse(line) as unknown;\n if (!isRecord(parsed)) {\n throw new CliError(`Classification decision line ${index + 1} is not an object.`, {\n code: 'CLASSIFICATION_DECISION_INVALID',\n exitCode: 2,\n });\n }\n return parsed;\n });\n}\n\nfunction normalizeStructuredDecisions(value: unknown): JsonObject[] {\n if (Array.isArray(value)) return value.filter(isRecord);\n if (isRecord(value) && Array.isArray(value.decisions)) return value.decisions.filter(isRecord);\n if (isRecord(value) && Array.isArray(value.rows)) return value.rows.filter(isRecord);\n return isRecord(value) ? [value] : [];\n}\n\nfunction readDecisions(pathValue: string, rawInput?: unknown): JsonObject[] {\n if (!pathValue) {\n throw new CliError('Missing required --decisions value.', {\n code: 'CLASSIFICATION_DECISIONS_REQUIRED',\n exitCode: 2,\n });\n }\n if (rawInput !== undefined) return normalizeStructuredDecisions(rawInput);\n const resolved = path.resolve(pathValue);\n if (!existsSync(resolved)) {\n throw new CliError(`Classification decisions file not found: ${resolved}`, {\n code: 'CLASSIFICATION_DECISIONS_NOT_FOUND',\n exitCode: 2,\n });\n }\n return resolved.toLowerCase().endsWith('.jsonl')\n ? readJsonLines(resolved)\n : normalizeStructuredDecisions(readJsonInput(resolved));\n}\n\nfunction prepareRows(inputPath: string, rawInput?: unknown): PreparedClassificationRow[] {\n return readDatasetRowsInput(inputPath, rawInput).map((row, index) => {\n const clonedRow = cloneJson(row);\n const payload = unwrapDatasetPayload(clonedRow);\n const descriptor = DATASET_ROOTS.find((candidate) => isRecord(payload[candidate.rootKey]));\n const root = descriptor ? (payload[descriptor.rootKey] as JsonObject) : {};\n const info =\n descriptor && isRecord(root[descriptor.informationKey])\n ? (root[descriptor.informationKey] as JsonObject)\n : {};\n const dataSetInformation = isRecord(info.dataSetInformation)\n ? (info.dataSetInformation as JsonObject)\n : {};\n const administrativeInformation = isRecord(root.administrativeInformation)\n ? (root.administrativeInformation as JsonObject)\n : {};\n const publicationAndOwnership = isRecord(administrativeInformation.publicationAndOwnership)\n ? (administrativeInformation.publicationAndOwnership as JsonObject)\n : {};\n return {\n index,\n row: clonedRow,\n payload,\n rootKey: descriptor?.rootKey ?? null,\n informationKey: descriptor?.informationKey ?? null,\n id: firstNonEmpty(clonedRow.id, dataSetInformation['common:UUID']),\n version: firstNonEmpty(clonedRow.version, publicationAndOwnership['common:dataSetVersion']),\n };\n });\n}\n\nfunction classificationContainer(\n row: PreparedClassificationRow,\n type: DatasetClassificationType,\n): JsonObject | null {\n if (CATEGORY_CONFIGS[type].target === 'location') return null;\n if (!row.rootKey || !row.informationKey) return null;\n const root = row.payload[row.rootKey];\n if (!isRecord(root)) return null;\n const info = root[row.informationKey];\n if (!isRecord(info)) return null;\n if (!isRecord(info.dataSetInformation)) info.dataSetInformation = {};\n const dataSetInformation = info.dataSetInformation as JsonObject;\n if (!isRecord(dataSetInformation.classificationInformation)) {\n dataSetInformation.classificationInformation = {};\n }\n const classificationInformation = dataSetInformation.classificationInformation as JsonObject;\n const target = CATEGORY_CONFIGS[type].target;\n if (target === 'common:category') {\n if (!isRecord(classificationInformation['common:elementaryFlowCategorization'])) {\n classificationInformation['common:elementaryFlowCategorization'] = {};\n }\n return classificationInformation['common:elementaryFlowCategorization'] as JsonObject;\n }\n if (!isRecord(classificationInformation['common:classification'])) {\n classificationInformation['common:classification'] = {};\n }\n return classificationInformation['common:classification'] as JsonObject;\n}\n\nfunction currentClassification(\n row: PreparedClassificationRow,\n type: DatasetClassificationType,\n): unknown {\n const container = classificationContainer(row, type);\n if (!container) return null;\n return CATEGORY_CONFIGS[type].target === 'common:category'\n ? container['common:category']\n : container['common:class'];\n}\n\nfunction setClassification(\n row: PreparedClassificationRow,\n type: DatasetClassificationType,\n classificationPath: ClassificationPathEntry[],\n): boolean {\n const container = classificationContainer(row, type);\n if (!container) return false;\n if (CATEGORY_CONFIGS[type].target === 'common:category') {\n container['common:category'] = cloneJson(classificationPath);\n } else {\n container['common:class'] = cloneJson(classificationPath);\n }\n return true;\n}\n\nfunction isLocationTargetKey(key: string): boolean {\n return locationTargetKeys().has(key);\n}\n\nfunction locationTargetStringValue(value: unknown): {\n parent: JsonObject | null;\n key: string | null;\n pathSuffix: Array<string | number>;\n value: string;\n} | null {\n if (typeof value === 'string') {\n return {\n parent: null,\n key: null,\n pathSuffix: [],\n value: value.trim(),\n };\n }\n if (isRecord(value) && typeof value['#text'] === 'string') {\n return {\n parent: value,\n key: '#text',\n pathSuffix: ['#text'],\n value: value['#text'].trim(),\n };\n }\n return null;\n}\n\nfunction collectLocationTargets(\n value: unknown,\n pathSegments: Array<string | number> = [],\n targets: LocationTarget[] = [],\n): LocationTarget[] {\n if (!isRecord(value)) {\n if (Array.isArray(value)) {\n value.forEach((item, index) =>\n collectLocationTargets(item, [...pathSegments, index], targets),\n );\n }\n return targets;\n }\n\n for (const [key, child] of Object.entries(value)) {\n const childPath = [...pathSegments, key];\n if (isLocationTargetKey(key)) {\n const targetValue = locationTargetStringValue(child);\n if (targetValue) {\n const leafPath = [...childPath, ...targetValue.pathSuffix];\n const parent = targetValue.pathSuffix.length > 0 ? targetValue.parent : value;\n const targetKey = targetValue.pathSuffix.length > 0 ? targetValue.key : key;\n targets.push({\n path: pathExpression(leafPath),\n parentPath: pathExpression(targetValue.pathSuffix.length > 0 ? childPath : pathSegments),\n parent: parent as JsonObject,\n key: targetKey as string,\n value: targetValue.value,\n });\n }\n }\n collectLocationTargets(child, childPath, targets);\n }\n return targets;\n}\n\nfunction locationCodeFromPath(classificationPath: ClassificationPathEntry[]): string | null {\n const leaf = classificationPath.at(-1);\n return classCode(leaf);\n}\n\nfunction resolveLocationTarget(\n row: PreparedClassificationRow,\n decision: NormalizedDecision,\n): LocationTarget[] {\n const targets = collectLocationTargets(row.payload);\n if (!decision.targetPath) return targets;\n const matchingTargets = targets.filter(\n (target) => target.path === decision.targetPath || target.parentPath === decision.targetPath,\n );\n if (matchingTargets.length > 0) return matchingTargets;\n const createdTarget = createMissingLocationTarget(row, decision.targetPath);\n return createdTarget ? [createdTarget] : [];\n}\n\nfunction targetPathSegments(targetPath: string): string[] {\n return targetPath\n .split('.')\n .map((segment) => segment.trim())\n .filter((segment) => segment.length > 0);\n}\n\nfunction createMissingLocationTarget(\n row: PreparedClassificationRow,\n targetPath: string,\n): LocationTarget | null {\n const segments = targetPathSegments(targetPath);\n const key = segments.at(-1);\n if (!key || !isLocationTargetKey(key)) return null;\n let cursor: unknown = row.payload;\n for (const segment of segments.slice(0, -1)) {\n if (!isRecord(cursor)) return null;\n const existing = cursor[segment];\n if (existing === undefined || existing === null) {\n cursor[segment] = {};\n cursor = cursor[segment];\n continue;\n }\n if (!isRecord(existing)) return null;\n cursor = existing;\n }\n if (!isRecord(cursor)) return null;\n const existing = cursor[key];\n if (existing !== undefined && existing !== null && existing !== '') return null;\n return {\n path: targetPath,\n parentPath: pathExpression(segments.slice(0, -1)),\n parent: cursor,\n key,\n value: typeof existing === 'string' ? existing : '',\n };\n}\n\nfunction decisionMatchesRow(decision: NormalizedDecision, row: PreparedClassificationRow): boolean {\n if (decision.rowIndex !== null) return decision.rowIndex === row.index;\n if (!decision.datasetId || decision.datasetId !== row.id) return false;\n return !decision.datasetVersion || decision.datasetVersion === row.version;\n}\n\nfunction normalizeDecision(\n decision: JsonObject,\n decisionIndex: number,\n fallbackType: DatasetClassificationType | null,\n blockers: DatasetClassificationBlocker[],\n): NormalizedDecision | null {\n const rawRowIndex = decision.row_index ?? decision.rowIndex;\n const rowIndexText = firstNonEmpty(rawRowIndex);\n const rowIndex =\n typeof rawRowIndex === 'number'\n ? rawRowIndex\n : rowIndexText === null\n ? null\n : Number(rowIndexText);\n const validRowIndex =\n typeof rowIndex === 'number' && Number.isInteger(rowIndex) ? rowIndex : null;\n const datasetId = firstNonEmpty(\n decision.dataset_id,\n decision.datasetId,\n decision.id,\n decision.uuid,\n );\n const datasetVersion = firstNonEmpty(\n decision.dataset_version,\n decision.datasetVersion,\n decision.version,\n );\n const categoryType = normalizeDecisionType(decision, fallbackType);\n if (validRowIndex === null && !datasetId) {\n blockers.push({\n code: 'classification_decision_target_missing',\n message: 'Classification decision must target row_index or dataset_id.',\n decision_index: decisionIndex,\n });\n return null;\n }\n if (!categoryType) {\n blockers.push({\n code: 'classification_decision_type_missing',\n message:\n 'Classification decision must provide a category_type or the command must pass --type.',\n decision_index: decisionIndex,\n row_index: validRowIndex ?? undefined,\n dataset_id: datasetId,\n dataset_version: datasetVersion,\n });\n return null;\n }\n const classificationPath = normalizePathFromDecision(categoryType, decision);\n if (classificationPath.length === 0) {\n blockers.push({\n code: 'classification_decision_path_invalid',\n message:\n 'Classification decision must resolve to a valid path in the bundled TIDAS category schema.',\n decision_index: decisionIndex,\n row_index: validRowIndex ?? undefined,\n dataset_id: datasetId,\n dataset_version: datasetVersion,\n });\n return null;\n }\n return {\n decisionIndex,\n rowIndex: validRowIndex,\n datasetId,\n datasetVersion,\n categoryType,\n path: classificationPath,\n targetPath: decisionTargetPath(decision),\n basis: firstNonEmpty(decision.basis),\n evidence: decision.evidence ?? null,\n };\n}\n\nfunction maybeWriteReport<T extends { files?: { report: string } }>(\n report: T,\n outDir: string | null | undefined,\n filename: string,\n): T {\n if (!outDir) return report;\n const reportPath = path.join(path.resolve(outDir), 'outputs', filename);\n const finalReport = { ...report, files: { report: reportPath } };\n writeJsonArtifact(reportPath, finalReport);\n return finalReport;\n}\n\nexport async function runDatasetClassificationChildren(\n options: RunDatasetClassificationChildrenOptions,\n): Promise<DatasetClassificationChildrenReport> {\n const type = normalizeType(options.type);\n const { config, navigator } = navigatorFor(type);\n const parentCode = firstNonEmpty(options.parent);\n const rawChildren = navigator.childMap.get(parentCode ?? '') ?? [];\n const parentKnown = !parentCode || navigator.entriesByCode.has(parentCode);\n const query = firstNonEmpty(options.query)?.toLowerCase() ?? null;\n const filtered = query\n ? rawChildren.filter(\n (entry) =>\n entry.code.toLowerCase().includes(query) || entry.text.toLowerCase().includes(query),\n )\n : rawChildren;\n const limit = options.limit && options.limit > 0 ? options.limit : null;\n const returned = limit ? filtered.slice(0, limit) : filtered;\n const report: DatasetClassificationChildrenReport = {\n schema_version: 1,\n generated_at_utc: (options.now ?? new Date()).toISOString(),\n status: parentKnown ? 'completed' : 'blocked',\n command: 'dataset classification children',\n category_type: type,\n schema_file: config.schemaFile,\n parent_code: parentCode,\n query,\n counts: {\n children: rawChildren.length,\n returned: returned.length,\n },\n children: returned.map((entry) => ({\n ...entry,\n path: pathForCode(navigator, entry.code).map(toPathEntry),\n })),\n blockers: parentKnown\n ? []\n : [{ code: 'classification_parent_unknown', message: `Unknown parent code: ${parentCode}` }],\n };\n return maybeWriteReport(report, options.outDir, 'classification-children-report.json');\n}\n\nexport async function runDatasetClassificationPath(\n options: RunDatasetClassificationPathOptions,\n): Promise<DatasetClassificationPathReport> {\n const type = normalizeType(options.type);\n const { config, navigator } = navigatorFor(type);\n const code = firstNonEmpty(options.code);\n if (!code) {\n throw new CliError('Missing required --code value.', {\n code: 'CLASSIFICATION_CODE_REQUIRED',\n exitCode: 2,\n });\n }\n const pathEntries = pathForCode(navigator, code).map(toPathEntry);\n const report: DatasetClassificationPathReport = {\n schema_version: 1,\n generated_at_utc: (options.now ?? new Date()).toISOString(),\n status: pathEntries.length > 0 ? 'completed' : 'blocked',\n command: 'dataset classification path',\n category_type: type,\n schema_file: config.schemaFile,\n code,\n path: pathEntries,\n blockers:\n pathEntries.length > 0\n ? []\n : [\n {\n code: 'classification_code_unknown',\n message: `Unknown classification code: ${code}`,\n },\n ],\n };\n return maybeWriteReport(report, options.outDir, 'classification-path-report.json');\n}\n\nexport async function runDatasetClassificationAudit(\n options: RunDatasetClassificationAuditOptions,\n): Promise<DatasetClassificationAuditReport> {\n if (!options.inputPath) {\n throw new CliError('Missing required --input value.', {\n code: 'CLASSIFICATION_AUDIT_INPUT_REQUIRED',\n exitCode: 2,\n });\n }\n const type = normalizeType(options.type);\n if (type !== 'location') {\n throw new CliError('dataset classification audit currently supports only --type location.', {\n code: 'CLASSIFICATION_AUDIT_TYPE_UNSUPPORTED',\n exitCode: 2,\n });\n }\n const { config, navigator } = navigatorFor(type);\n const rows = prepareRows(options.inputPath, options.rawInput);\n const findings: DatasetClassificationAuditFinding[] = [];\n const blockers: DatasetClassificationBlocker[] = [];\n for (const row of rows) {\n for (const target of collectLocationTargets(row.payload)) {\n const entry = navigator.entriesByCode.get(target.value);\n const status = entry ? 'valid' : 'invalid';\n findings.push({\n row_index: row.index,\n dataset_id: row.id,\n dataset_version: row.version,\n path: target.path,\n value: target.value,\n status,\n description: entry?.text ?? null,\n });\n if (!entry) {\n blockers.push({\n code: 'location_code_invalid',\n message: 'Location value is not a code from the bundled TIDAS location schema.',\n row_index: row.index,\n dataset_id: row.id,\n dataset_version: row.version,\n });\n }\n }\n }\n const invalid = findings.filter((finding) => finding.status === 'invalid').length;\n const outDir = options.outDir ? path.resolve(options.outDir) : null;\n const findingsPath = outDir\n ? path.join(outDir, 'outputs', 'location-audit-findings.jsonl')\n : null;\n const reportPath = outDir ? path.join(outDir, 'outputs', 'location-audit-report.json') : null;\n const report: DatasetClassificationAuditReport = {\n schema_version: 1,\n generated_at_utc: (options.now ?? new Date()).toISOString(),\n status: invalid > 0 ? 'blocked' : 'completed',\n command: 'dataset classification audit',\n category_type: type,\n schema_file: config.schemaFile,\n input_path: path.resolve(options.inputPath),\n counts: {\n rows: rows.length,\n location_targets: findings.length,\n valid: findings.length - invalid,\n invalid,\n },\n findings,\n blockers,\n ...(findingsPath && reportPath\n ? {\n files: {\n findings: findingsPath,\n report: reportPath,\n },\n }\n : {}),\n };\n if (findingsPath && reportPath) {\n writeJsonLinesArtifact(findingsPath, findings);\n writeJsonArtifact(reportPath, report);\n }\n return report;\n}\n\nexport async function runDatasetClassificationApply(\n options: RunDatasetClassificationApplyOptions,\n): Promise<DatasetClassificationApplyReport> {\n if (!options.inputPath) {\n throw new CliError('Missing required --input value.', {\n code: 'CLASSIFICATION_INPUT_REQUIRED',\n exitCode: 2,\n });\n }\n if (!options.outPath) {\n throw new CliError('Missing required --out value.', {\n code: 'CLASSIFICATION_OUT_REQUIRED',\n exitCode: 2,\n });\n }\n const fallbackType = options.type ? normalizeType(options.type) : null;\n const rows = prepareRows(options.inputPath, options.rawInput);\n const rawDecisions = readDecisions(options.decisionsPath, options.rawDecisions);\n const blockers: DatasetClassificationBlocker[] = [];\n const decisions = rawDecisions\n .map((decision, index) => normalizeDecision(decision, index, fallbackType, blockers))\n .filter((decision): decision is NormalizedDecision => Boolean(decision));\n const evidence = [];\n\n for (const decision of decisions) {\n const matches = rows.filter((row) => decisionMatchesRow(decision, row));\n if (matches.length !== 1) {\n blockers.push({\n code:\n matches.length === 0\n ? 'classification_target_not_found'\n : 'classification_target_ambiguous',\n message:\n matches.length === 0\n ? 'Classification decision did not match an input row.'\n : 'Classification decision matched more than one input row.',\n decision_index: decision.decisionIndex,\n row_index: decision.rowIndex ?? undefined,\n dataset_id: decision.datasetId,\n dataset_version: decision.datasetVersion,\n });\n continue;\n }\n const row = matches[0] as PreparedClassificationRow;\n if (decision.categoryType === 'location') {\n const code = locationCodeFromPath(decision.path);\n const targetMatches = resolveLocationTarget(row, decision);\n if (!code || targetMatches.length !== 1) {\n blockers.push({\n code:\n targetMatches.length === 0 ? 'location_target_not_found' : 'location_target_ambiguous',\n message:\n targetMatches.length === 0\n ? 'Location decision did not match a location field in the input row.'\n : 'Location decision matched more than one location field; provide target_path.',\n decision_index: decision.decisionIndex,\n row_index: row.index,\n dataset_id: row.id,\n dataset_version: row.version,\n });\n continue;\n }\n const target = targetMatches[0] as LocationTarget;\n const previous = target.value;\n target.parent[target.key] = code;\n evidence.push({\n decision_index: decision.decisionIndex,\n row_index: row.index,\n dataset_id: row.id,\n dataset_version: row.version,\n category_type: decision.categoryType,\n target_path: target.path,\n previous_location: previous,\n applied_location: code,\n applied_location_path: cloneJson(decision.path),\n basis: decision.basis,\n evidence: decision.evidence,\n });\n continue;\n }\n const previous = currentClassification(row, decision.categoryType);\n if (!setClassification(row, decision.categoryType, decision.path)) {\n blockers.push({\n code: 'classification_container_missing',\n message: 'Input row does not contain a supported classification container for this type.',\n decision_index: decision.decisionIndex,\n row_index: row.index,\n dataset_id: row.id,\n dataset_version: row.version,\n });\n continue;\n }\n evidence.push({\n decision_index: decision.decisionIndex,\n row_index: row.index,\n dataset_id: row.id,\n dataset_version: row.version,\n category_type: decision.categoryType,\n previous_classification: previous,\n applied_classification: cloneJson(decision.path),\n basis: decision.basis,\n evidence: decision.evidence,\n });\n }\n\n const outDir = options.outDir\n ? path.resolve(options.outDir)\n : path.dirname(path.resolve(options.outPath));\n const evidencePath = path.join(outDir, 'outputs', 'classification-apply-evidence.jsonl');\n const reportPath = path.join(outDir, 'outputs', 'classification-apply-report.json');\n writeJsonLinesArtifact(\n options.outPath,\n rows.map((row) => row.payload),\n );\n writeJsonLinesArtifact(evidencePath, evidence);\n const report: DatasetClassificationApplyReport = {\n schema_version: 1,\n generated_at_utc: (options.now ?? new Date()).toISOString(),\n status: blockers.length > 0 ? 'blocked' : 'completed',\n command: 'dataset classification apply',\n input_path: path.resolve(options.inputPath),\n decisions_path: path.resolve(options.decisionsPath),\n out_path: path.resolve(options.outPath),\n default_category_type: fallbackType,\n counts: {\n rows: rows.length,\n decisions: rawDecisions.length,\n applied: evidence.length,\n blockers: blockers.length,\n },\n blockers,\n files: {\n classified_rows: path.resolve(options.outPath),\n evidence: evidencePath,\n report: reportPath,\n },\n };\n writeJsonArtifact(reportPath, report);\n return report;\n}\n\nexport const __testInternals = {\n buildNavigator,\n classCode,\n classificationContainer,\n collectEntriesFromNode,\n collectLocationRefKeysFromSchema,\n collectLocationTargets,\n constText,\n createMissingLocationTarget,\n currentClassification,\n decisionMatchesRow,\n decisionTargetPath,\n isJsonSchemaFileName,\n lastSchemaPropertyName,\n loadEntries,\n locationCodeFromPath,\n locationTargetStringValue,\n locationTargetKeys,\n maybeWriteReport,\n navigatorFor,\n normalizeDecision,\n normalizeDecisionType,\n normalizePathFromClasses,\n normalizePathFromDecision,\n normalizeStructuredDecisions,\n normalizeTargetPath,\n normalizeType,\n pathForCode,\n prepareRows,\n readDecisions,\n resolveLocationTarget,\n schemasDir,\n setClassification,\n targetPathSegments,\n toPathEntry,\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiangong-lca/cli",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "Unified TianGong LCA CLI with direct REST adapters and low-entropy command surface.",
5
5
  "repository": {
6
6
  "type": "git",