From 7172c506244edaf7af9350ed1e58bfab342ed24f Mon Sep 17 00:00:00 2001 From: Jakob Vogelsang Date: Fri, 20 Oct 2023 19:32:57 +0200 Subject: [PATCH] feat(LN): add describe Log --- describe/LN.spec.ts | 4 ++++ describe/LN.ts | 17 +++++++++++++++++ utils.ts | 2 ++ 3 files changed, 23 insertions(+) diff --git a/describe/LN.spec.ts b/describe/LN.spec.ts index 9bb8fd8b..bb552590 100644 --- a/describe/LN.spec.ts +++ b/describe/LN.spec.ts @@ -14,6 +14,8 @@ const scl = new DOMParser().parseFromString( on + + @@ -55,6 +57,8 @@ const scl = new DOMParser().parseFromString( + + diff --git a/describe/LN.ts b/describe/LN.ts index acdb4c25..7a942fe5 100644 --- a/describe/LN.ts +++ b/describe/LN.ts @@ -20,6 +20,7 @@ import { describeVal, compareBySGroup } from "./Val.js"; export interface LNDescription extends NamingDescription { reports: Record; logControls: Record; + logs: Record; inputs?: InputsDescription; lnType: LNodeTypeDescription; } @@ -90,6 +91,21 @@ function logControls(element: Element): Record { >; } +function logs(element: Element): Record { + const unsortedLogs: Record = {}; + + Array.from(element.children) + .filter((child) => child.tagName === "Log") + .forEach((log) => { + const name = log.getAttribute("name"); + const logDescription = describeNaming(log); + if (name && !unsortedLogs[name] && logDescription) + unsortedLogs[name] = logDescription; + }); + + return sortRecord(unsortedLogs) as Record; +} + /** Returns leaf data attribute (BDA or DA) from * LNodeTypeDescription containing vals * @param path - parent DOI/SDI/DAI name attributes @@ -160,6 +176,7 @@ export function LN(element: Element): LNDescription | undefined { ...describeNaming(element), reports: reportControls(element), logControls: logControls(element), + logs: logs(element), lnType, }; diff --git a/utils.ts b/utils.ts index f43e1935..cfbd830e 100644 --- a/utils.ts +++ b/utils.ts @@ -1,12 +1,14 @@ import { DADescription } from "./describe/DADescription.js"; import { DODescription } from "./describe/DODescription.js"; import { LogControlDescription } from "./describe/LogControl.js"; +import { NamingDescription } from "./describe/Naming.js"; import { ReportControlDescription } from "./describe/ReportControl.js"; import { SDODescription } from "./describe/SDODescription.js"; type SortedObjects = | DADescription | LogControlDescription + | NamingDescription | SDODescription | ReportControlDescription | DODescription;