@dxpert/uns-naming-check
v0.1.1
Published
Check a set of Unified Namespace (UNS) topic paths for depth, casing, and collision problems - browser module, CLI, and demo page.
Maintainers
Readme
uns-naming-check
Checks a set of Unified Namespace (UNS) topic paths for the problems that quietly rot a namespace over time. It exists because a UNS is only as useful as its naming discipline, and drift (mixed casing, inconsistent depth, near-duplicate siblings) is hard to spot by eye once a namespace has hundreds of topics.
What it checks
- Inconsistent depth across paths (e.g. some paths at 4 levels, others at 5)
- Mixed casing styles across segments (kebab-case, snake_case, camelCase, PascalCase, UPPER, lower, mixed)
- Whitespace inside a segment
- Case-collisions between siblings at any level (
Line-1vsline-1read as one namespace node in most brokers, but are two distinct topics under case-sensitive MQTT) - Duplicate full paths
- Stray MQTT wildcards (
+,#) inside a stored path
Usage
Browser
Open demo/index.html directly in a browser (no server or build step needed — it's a plain ES module import). Paste topic paths, one per line, and click "Check namespace".
As a module
import { checkNamespace, checkNamespaceText } from '@dxpert/uns-naming-check';
const findings = checkNamespace([
'Acme/Montreal/Stamping/Line-1/Press-01',
'acme/montreal/stamping/line-1/press-02',
]);
// or, from raw multi-line text:
const findings2 = checkNamespaceText('Acme/Montreal/Line-1\nAcme/Montreal/Line-1');Each finding is { kind: 'fail' | 'warn' | 'pass' | 'info', label, message }. message may contain simple <code>...</code> markup; strip it with the exported plainText() helper for plain-text output.
CLI
node bin/cli.js "Acme/Montreal/Line-1/Press-01" "acme/montreal/line-1/press-01"
node bin/cli.js --file paths.txt
cat paths.txt | node bin/cli.js --jsonNo dependencies to install. Exit code is non-zero if any check finds an error.
Examples
$ node bin/cli.js --file paths.txt
[ISSUES] 7 path(s) checked - 2 error(s), 2 warning(s).
[WARN] Duplicate path: Acme/Montreal/Stamping/Line-1/Press-01 appears more than once.
[ERROR] Case-collision: Acme/Montreal/Assembly/Line-4/Robot-Cell-02 vs acme/montreal/assembly/line-4/robot-cell-02. MQTT topics are case-sensitive - these read as one namespace but are two.
[WARN] Line 5 Acme/Toronto/Packaging/Line 2/Palletizer-01: segment Line 2 contains whitespace - prefer - or _.
[WARN] Inconsistent depth: 6 path(s) at 5 levels, 1 path(s) at 3 levels. A UNS aligned to ISA-95 usually keeps one consistent depth (e.g. Enterprise/Site/Area/Line/Unit) with clear rules for shallower nodes.
[SUMMARY] 6 unique path(s) - depth(s): 5, 3 - styles: PascalCase, lower, Title-Case$ node bin/cli.js "Acme/Montreal/Stamping/Line-1/Press-01" "Acme/Montreal/Stamping/Line-1/Press-02"
[VALID] No issues found. 2 path(s), consistent depth, one naming style.
[SUMMARY] 2 unique path(s) - depth(s): 5 - styles: PascalCaseMaintained by dxpert.ai
dxpert.ai (https://dxpert.ai) builds tools and services for Industry 4.0 / digital transformation teams designing and validating industrial data layers. This checker is one of a small set of free, no-signup validators.
A free hosted version of this tool runs at dxpert.ai/tools.html — no install required.
