From 0ab1ee5996e040dd9232a6210f67e84c073cd2ba Mon Sep 17 00:00:00 2001 From: Jannis R Date: Fri, 17 Dec 2021 21:21:58 +0100 Subject: [PATCH] parsePidFiltersTree [todo] --- index.js | 2 ++ parse/pid-filters-tree.js | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 9e534ef65..3f14c4882 100644 --- a/index.js +++ b/index.js @@ -617,6 +617,8 @@ const createClient = (profile, userAgent, opt = {}) => { }, }) + if (!Array.isArray(res.jnyTreeNodeL)) return null + const ctx = {profile, opt, common, res} return profile.parsePidFiltersTree(ctx, res.jnyTreeNodeL) } diff --git a/parse/pid-filters-tree.js b/parse/pid-filters-tree.js index 565dce1e3..217d2c6dd 100644 --- a/parse/pid-filters-tree.js +++ b/parse/pid-filters-tree.js @@ -1,5 +1,13 @@ 'use strict' +const nodeKinds = new Map() +// todo: are these correct? +nodeKinds.set('P', 'product') // usually level 0, pid filter begins with `P:` "Produkt"? +nodeKinds.set('C', 'category') // usually level 1, pid filter begins with `G:` "Gruppe"? +nodeKinds.set('O', 'operator') // usually level 2, pid filter begins with `B:` "Betreiber"? +nodeKinds.set('L', 'line') // usually level 3, pid filter begins with `L:` "Linie"? +nodeKinds.set('D', 'direction') // usually level 4, pid filter begins with `R:` "Richtung"? + const parsePidFiltersTree = (ctx, jnyTreeNodeL) => { const parsedNodes = new WeakMap() // raw node -> parsed node const parseNode = (idx) => { @@ -7,13 +15,13 @@ const parsePidFiltersTree = (ctx, jnyTreeNodeL) => { if (!_) throw new Error(`missing node ${idx}`) // todo: don't let this happen if (parsedNodes.has(_)) return parsedNodes.get(_) - // todo: what is _.type? // todo: what is _.stat.rt? nr of children with realtime data? // todo: what is _.stat.ont? // todo: what is _.stat.cncl? nr of canceled children? // todo: what is _.stat.delGrpL & _.stat.delCntL? // todo: what is _.stat.him? nr of children with HIM messages? const node = { + kind: nodeKinds.has(_.type) ? nodeKinds.get(_.type) : null, name: _.name, pidFilter: _.pid, // todo [breaking]: rename field? // todo [breaking]: rename field?