@zaes/sidc 0.1.0 → 0.2.0

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/CHANGELOG.md ADDED
@@ -0,0 +1,58 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@zaes/sidc`.
4
+
5
+ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this
6
+ project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Dates are
7
+ the npm publish dates — when a version actually became installable.
8
+
9
+ > **Version 0.1.0 was reconstructed from the commit history after the fact.** This file was
10
+ > added afterwards, so its entry summarizes what the release contained.
11
+
12
+ ---
13
+
14
+ ## [Unreleased]
15
+
16
+ ## [0.2.0] — 2026-11-16
17
+
18
+ ### Added
19
+
20
+ - **APP-6(E)'s own entities in the catalog.** The 59 entities APP-6(E) Version 2 defines and MIL-STD-2525E
21
+ Change 1 does not (cyberspace non-unit set 64, civilian dismounted individuals, NATO supply classes II and
22
+ V, Military Armoury and Base, and others) are read for an APP-6(E) code: `getEntity(symbolSet, code,
23
+ standard)` takes the code's standard (`'APP-6E'` for versions 14 and 16), and `describeSidc` passes it.
24
+ Such an entity carries `standard: 'APP-6E'`. For a 2525D or APP-6(D) code (`'2525D'`, `'APP-6D'`) the 13 of
25
+ them MIL-STD-2525D also defines are found too, under 2525D's own names and paths (`APP6E_IN_2525D`): 60 120100
26
+ is Infection › Advanced Persistent Threat (APT), not APP-6(E)'s Criminal, and 2525D spells Armored and Armory. Without the standard, or for any other, the
27
+ catalog is 2525E's as before.
28
+
29
+ ### Fixed
30
+
31
+ - **APP-6(E) symbol sets.** An APP-6(E) code (versions 14 and 16) may name the signals intelligence sets
32
+ 51-54 and the cyberspace non-unit set 64 of APP-6(E) Table A-4; they were reported as undefined.
33
+ `SYMBOL_SETS_APP6E_ONLY` lists 64.
34
+
35
+ ### Changed
36
+
37
+ - **`formatNumericSidc` refuses a field longer than its positions**, with a `RangeError` naming the
38
+ field. It kept the last digits (`entityCode: '1211000'` wrote `211000`), which is another symbol's code.
39
+
40
+ ## [0.1.0] — 2026-11-10
41
+
42
+ The first release: read, validate, write and convert MIL-STD-2525 and APP-6 symbol codes.
43
+
44
+ ### Added
45
+
46
+ - **`parseSidc`**: reads a 2525C/2525B letter code (15 characters, trailing dashes optional) or a
47
+ 2525D/2525E numeric code (20 or 30 digits), and reports rather than refuses: a well-formed code
48
+ with a value the tables do not define parses, with the value in `problems`. Versions 15
49
+ (2525E Change 1) and 16 (APP-6(E)(2)) are read as Table A-I gives them.
50
+ - **`formatNumericSidc`**: writes a numeric code from its fields.
51
+ - **The code tables**: standard identities, contexts, symbol sets, statuses, headquarters, task
52
+ force and dummy, amplifying descriptors, letter-code identities and statuses, each naming the
53
+ standard table it transcribes; `gencCountry` and the GENC country table for positions 28-30.
54
+ - **`@zaes/sidc/catalog`**: every 2525E Change 1 entity and sector modifier, with names,
55
+ hierarchy, kind (icon, frame, point, multipoint), Appendix A geometry, draw rule and icon type
56
+ (`getEntity`, `listEntities`, `listSectorModifiers`).
57
+ - **`@zaes/sidc/2525c`**: `convert2525C`, letter codes to 2525D codes through the crosswalk, with
58
+ what the conversion could not keep.
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.APP6E_IN_2525D = exports.ENTITIES_APP6E = void 0;
4
+ /** 59 entities: 4 hierarchy, 53 icon, 2 multipoint. */
5
+ exports.ENTITIES_APP6E = [
6
+ ["01", "120700", "Medical Evacuation (MEDEVAC)", "icon", "", "", "Main"],
7
+ ["05", "110600", "Satellite, General", "icon", "", "", "Main"],
8
+ ["10", "110501", "Reconnaissance and Liaison Element", "icon", "", "", "Full Frame"],
9
+ ["10", "130301", "Self-Propelled Artillery", "icon", "", "", "Main"],
10
+ ["10", "140104", "Reconnaissance Armoured", "icon", "", "", "Full Frame"],
11
+ ["10", "161900", "NATO Supply Class II", "icon", "", "", "Full Frame"],
12
+ ["10", "162200", "NATO Supply Class V", "icon", "", "", "Full Frame"],
13
+ ["10", "165800", "National Support Element (NSE)", "icon", "", "", "Main"],
14
+ ["15", "112100", "Non-Lethal Grenade Launcher", "icon", "", "", "Main"],
15
+ ["20", "111901", "Displaced Persons/Refugee/Evacuees Camp", "icon", "", "", "Full Octagon"],
16
+ ["20", "111902", "Training Camp", "icon", "", "", "Full Octagon"],
17
+ ["20", "120801", "Military Armoury", "icon", "", "", "Full Octagon"],
18
+ ["20", "120802", "Military Base", "icon", "", "", "Full Octagon"],
19
+ ["25", "380000", "Paths", "hierarchy", "", "", ""],
20
+ ["25", "380100", "Data Path Segment", "multipoint", "", "", ""],
21
+ ["25", "380200", "Data Tunnel", "multipoint", "", "", ""],
22
+ ["27", "120000", "Civilian", "hierarchy", "", "", ""],
23
+ ["27", "120100", "Activity/Task", "hierarchy", "", "", ""],
24
+ ["27", "120101", "Police", "icon", "", "", "Main"],
25
+ ["27", "120102", "Non-Governmental Organization Member or Non-Governmental Organization (NGO)", "icon", "", "", "Main"],
26
+ ["27", "120103", "Government Organization (GO)", "icon", "", "", "Main"],
27
+ ["40", "110103", "Attempted Criminal Activity", "icon", "", "", "Main"],
28
+ ["40", "110105", "Drug Related", "icon", "", "", "Main"],
29
+ ["40", "131100", "Raid on House", "icon", "", "", "Full Octagon"],
30
+ ["40", "180300", "Isolated Personnel", "icon", "", "", "Full Octagon"],
31
+ ["60", "111100", "Security Operations Centre", "icon", "", "", "Main"],
32
+ ["60", "120100", "Criminal", "icon", "", "", "Main"],
33
+ ["64", "130000", "Agent", "hierarchy", "", "", ""],
34
+ ["64", "130100", "Firewall", "icon", "", "", "Main"],
35
+ ["64", "130200", "Firmware", "icon", "", "", "Main"],
36
+ ["64", "140000", "Application", "icon", "", "", "Main"],
37
+ ["64", "140100", "Banking", "icon", "", "", "Main"],
38
+ ["64", "140300", "Search Engine", "icon", "", "", "Main"],
39
+ ["64", "140400", "Social Media", "icon", "", "", "Main"],
40
+ ["64", "140500", "Database", "icon", "", "", "Main"],
41
+ ["64", "140600", "Service", "icon", "", "", "Main"],
42
+ ["64", "150000", "Threat", "icon", "", "", "Main"],
43
+ ["64", "150100", "Malware", "icon", "", "", "Main"],
44
+ ["64", "150200", "Phishing", "icon", "", "", "Main"],
45
+ ["64", "160000", "Data", "icon", "", "", "Main"],
46
+ ["64", "160100", "Digital Currency", "icon", "", "", "Main"],
47
+ ["64", "160200", "Persona", "icon", "", "", "Main"],
48
+ ["64", "170000", "End Point", "icon", "", "", "Main"],
49
+ ["64", "170100", "Server", "icon", "", "", "Main"],
50
+ ["64", "170200", "Workstation", "icon", "", "", "Main"],
51
+ ["64", "170300", "Portable Electronic Device (PED)", "icon", "", "", "Main"],
52
+ ["64", "170301", "Mobile/Smartphone", "icon", "", "", "Main"],
53
+ ["64", "170302", "Tablet", "icon", "", "", "Main"],
54
+ ["64", "170303", "Laptop", "icon", "", "", "Main"],
55
+ ["64", "170304", "Health Monitor", "icon", "", "", "Main"],
56
+ ["64", "170305", "Smartvest", "icon", "", "", "Main"],
57
+ ["64", "170306", "Smartwatch", "icon", "", "", "Main"],
58
+ ["64", "170307", "Wearable", "icon", "", "", "Main"],
59
+ ["64", "170400", "Internet of Things Device", "icon", "", "", "Main"],
60
+ ["64", "170500", "Printer", "icon", "", "", "Main"],
61
+ ["64", "170600", "Router", "icon", "", "", "Main"],
62
+ ["64", "170700", "Switch", "icon", "", "", "Main"],
63
+ ["64", "170800", "Remote Operated Relay (ROR)", "icon", "", "", "Main"],
64
+ ["64", "180000", "Network", "icon", "", "", "Main"],
65
+ ];
66
+ /**
67
+ * Those of them MIL-STD-2525D (2014) also defines (its appendices give each an entry), by set and code, with
68
+ * 2525D's own path (its entry's Entity line, then its name, last): a 2525D or APP-6(D) code names them so. Read
69
+ * from the 2525D PDF the same way.
70
+ */
71
+ exports.APP6E_IN_2525D = {
72
+ "05110600": ["Military", "Satellite, General"],
73
+ "10130301": ["Fires", "Field Artillery", "Self-Propelled"],
74
+ "10140104": ["Protection", "Chemical Biological Radiological Nuclear Defense", "Reconnaissance Armored"],
75
+ "10161900": ["Sustainment", "NATO Supply Class II"],
76
+ "10162200": ["Sustainment", "NATO Supply Class V"],
77
+ "20111901": ["Installation", "Tented Camp", "Displaced Persons/Refugee/Evacuees Camp"],
78
+ "20111902": ["Installation", "Tented Camp", "Training Camp"],
79
+ "20120801": ["Infrastructure", "Military Infrastructure", "Military Armory"],
80
+ "20120802": ["Infrastructure", "Military Infrastructure", "Military Base"],
81
+ "40110103": ["Incident", "Criminal Activity Incident", "Attempted Criminal Activity"],
82
+ "40110105": ["Incident", "Criminal Activity Incident", "Drug Related"],
83
+ "40131100": ["Operation", "Raid on House"],
84
+ "60120100": ["Infection", "Advanced Persistent Threat (APT)"],
85
+ };
@@ -7,7 +7,7 @@ exports.listSectorModifiers = listSectorModifiers;
7
7
  exports.describeSidc = describeSidc;
8
8
  /**
9
9
  * @zaes/sidc/catalog — what every 2525E Change 1 code means: entity names and hierarchy, what kind of
10
- * drawing each is, its draw rule or icon type, and every sector modifier.
10
+ * drawing each is, its draw rule or icon type, and every sector modifier; and the entities APP-6(E) adds.
11
11
  *
12
12
  * A separate entry so that reading a code does not cost the ~175 KB of tables.
13
13
  *
@@ -15,16 +15,24 @@ exports.describeSidc = describeSidc;
15
15
  */
16
16
  const index_js_1 = require("../index.js");
17
17
  const data2525e_js_1 = require("./data2525e.js");
18
+ const dataApp6e_js_1 = require("./dataApp6e.js");
18
19
  let entities;
20
+ let app6eEntities;
19
21
  let modifiers;
20
22
  const entityKey = (symbolSet, code) => `${symbolSet}:${code}`;
21
23
  const modifierKey = (symbolSet, sector, code) => `${symbolSet}:${sector}:${code}`;
22
24
  function entityIndex() {
23
- if (entities)
24
- return entities;
25
- const rows = new Map(data2525e_js_1.ENTITIES_2525E.map((r) => [entityKey(r[0], r[1]), r]));
26
- entities = new Map();
27
- for (const [key, [symbolSet, code, name, kind, geometry, drawRule, iconType]] of rows) {
25
+ return (entities !== null && entities !== void 0 ? entities : (entities = indexRows(data2525e_js_1.ENTITIES_2525E, new Map(data2525e_js_1.ENTITIES_2525E.map((r) => [entityKey(r[0], r[1]), r])))));
26
+ }
27
+ /** APP-6(E)'s own entities, named under their headings in either table. */
28
+ function app6eIndex() {
29
+ const all = new Map([...data2525e_js_1.ENTITIES_2525E, ...dataApp6e_js_1.ENTITIES_APP6E].map((r) => [entityKey(r[0], r[1]), r]));
30
+ return (app6eEntities !== null && app6eEntities !== void 0 ? app6eEntities : (app6eEntities = new Map([...indexRows(dataApp6e_js_1.ENTITIES_APP6E, all)].map(([k, e]) => [k, { ...e, standard: 'APP-6E' }]))));
31
+ }
32
+ function indexRows(own, rows) {
33
+ const index = new Map();
34
+ for (const [symbolSet, code, name, kind, geometry, drawRule, iconType] of own) {
35
+ const key = entityKey(symbolSet, code);
28
36
  const path = [];
29
37
  const entity = rows.get(entityKey(symbolSet, code.slice(0, 2) + '0000'));
30
38
  const type = rows.get(entityKey(symbolSet, code.slice(0, 4) + '00'));
@@ -35,7 +43,7 @@ function entityIndex() {
35
43
  path.push(type[2]);
36
44
  }
37
45
  path.push(name);
38
- entities.set(key, {
46
+ index.set(key, {
39
47
  symbolSet,
40
48
  code,
41
49
  name,
@@ -46,7 +54,7 @@ function entityIndex() {
46
54
  ...(iconType ? { iconType } : {}),
47
55
  });
48
56
  }
49
- return entities;
57
+ return index;
50
58
  }
51
59
  function modifierIndex() {
52
60
  if (modifiers)
@@ -57,9 +65,35 @@ function modifierIndex() {
57
65
  ]));
58
66
  return modifiers;
59
67
  }
60
- /** The entity a symbol set and positions 11–16 name, or undefined if 2525E Change 1 has none. */
61
- function getEntity(symbolSet, code) {
62
- return entityIndex().get(entityKey(symbolSet, code));
68
+ /**
69
+ * The entity a symbol set and positions 11–16 name, or undefined if 2525E Change 1 has none. For an APP-6(E)
70
+ * code (`standard` 'APP-6E', as `parseSidc` reads versions 14 and 16), also the entities APP-6(E) adds; for a
71
+ * 2525D or APP-6(D) code ('2525D', 'APP-6D'), those of them 2525D defines as well, with 2525D's own name and path.
72
+ */
73
+ function getEntity(symbolSet, code, standard) {
74
+ const key = entityKey(symbolSet, code);
75
+ const own = entityIndex().get(key);
76
+ if (own || !standard)
77
+ return own;
78
+ if (standard === 'APP-6E')
79
+ return app6eIndex().get(key);
80
+ if (standard === '2525D' || standard === 'APP-6D')
81
+ return in2525DIndex().get(key);
82
+ return undefined;
83
+ }
84
+ let shared2525D;
85
+ /** The APP-6(E) additions 2525D defines too, with 2525D's own names and paths. */
86
+ function in2525DIndex() {
87
+ if (shared2525D)
88
+ return shared2525D;
89
+ shared2525D = new Map();
90
+ for (const [setCode, path] of Object.entries(dataApp6e_js_1.APP6E_IN_2525D)) {
91
+ const key = entityKey(setCode.slice(0, 2), setCode.slice(2));
92
+ const e = app6eIndex().get(key);
93
+ if (e)
94
+ shared2525D.set(key, { ...e, name: path[path.length - 1], path: [...path] });
95
+ }
96
+ return shared2525D;
63
97
  }
64
98
  /** Every entity, in the standard's order, optionally of one symbol set or kind. */
65
99
  function listEntities(filter = {}) {
@@ -86,7 +120,7 @@ function describeSidc(sidc) {
86
120
  return { problems: ['a 2525C letter code; convert it before describing it'] };
87
121
  const s = parsed.sidc;
88
122
  const problems = [];
89
- const entity = getEntity(s.symbolSet, s.entityCode);
123
+ const entity = getEntity(s.symbolSet, s.entityCode, s.standard);
90
124
  if (!entity)
91
125
  problems.push(`entity ${s.entityCode} is not in symbol set ${s.symbolSet}`);
92
126
  const modifier = (sector, code, identifier) => {
@@ -42,7 +42,9 @@ function parseNumericSidc(input) {
42
42
  const identity = (0, tables_js_1.lookup)(tables_js_1.STANDARD_IDENTITIES, standardIdentity);
43
43
  check(4, standardIdentity, !!identity, 'standard identity');
44
44
  const symbolSet = at(5, 6);
45
- const sets = standard === '2525D' || standard === 'APP-6D' ? [...tables_js_1.SYMBOL_SETS.filter((s) => s.value !== '50'), ...tables_js_1.SYMBOL_SETS_2525D_ONLY] : tables_js_1.SYMBOL_SETS;
45
+ // 2525D and APP-6 split signals intelligence by dimension (50-54); APP-6(E) adds 64 (Table A-4).
46
+ const legacySigint = [...tables_js_1.SYMBOL_SETS.filter((s) => s.value !== '50'), ...tables_js_1.SYMBOL_SETS_2525D_ONLY];
47
+ const sets = standard === '2525D' || standard === 'APP-6D' ? legacySigint : standard === 'APP-6E' ? [...legacySigint, ...tables_js_1.SYMBOL_SETS_APP6E_ONLY] : tables_js_1.SYMBOL_SETS;
46
48
  check(5, symbolSet, !!(0, tables_js_1.lookup)(sets, symbolSet), 'symbol set');
47
49
  const status = at(7);
48
50
  check(7, status, !!(0, tables_js_1.lookup)(tables_js_1.STATUSES, status), 'status');
@@ -87,26 +89,34 @@ function parseNumericSidc(input) {
87
89
  },
88
90
  };
89
91
  }
90
- /** Writes a 30-position 2525E SIDC (version 15 unless given). Each field is padded to its width. */
92
+ /**
93
+ * Writes a 30-position 2525E SIDC (version 15 unless given). Each field is padded to its width; a field
94
+ * longer than its width throws a RangeError naming it (cutting it would write another symbol's code).
95
+ */
91
96
  function formatNumericSidc(fields) {
92
97
  var _a;
93
- const f = (value, width) => (value !== null && value !== void 0 ? value : '').padStart(width, '0').slice(-width);
98
+ const f = (value, width, name = '') => {
99
+ const v = value !== null && value !== void 0 ? value : '';
100
+ if (v.length > width)
101
+ throw new RangeError(`formatNumericSidc: ${name || 'a field'} "${v}" is longer than its ${width} positions`);
102
+ return v.padStart(width, '0');
103
+ };
94
104
  return [
95
- f((_a = fields.version) !== null && _a !== void 0 ? _a : '15', 2),
96
- f(fields.context, 1),
97
- f(fields.standardIdentity, 1),
98
- f(fields.symbolSet, 2),
99
- f(fields.status, 1),
100
- f(fields.hqTfDummy, 1),
101
- f(fields.amplifyingDescriptor, 2),
102
- f(fields.entityCode, 6),
103
- f(fields.sector1, 2),
104
- f(fields.sector2, 2),
105
- f(fields.sector1Identifier, 1),
106
- f(fields.sector2Identifier, 1),
107
- f(fields.frameShape, 1),
105
+ f((_a = fields.version) !== null && _a !== void 0 ? _a : '15', 2, 'version'),
106
+ f(fields.context, 1, 'context'),
107
+ f(fields.standardIdentity, 1, 'standardIdentity'),
108
+ f(fields.symbolSet, 2, 'symbolSet'),
109
+ f(fields.status, 1, 'status'),
110
+ f(fields.hqTfDummy, 1, 'hqTfDummy'),
111
+ f(fields.amplifyingDescriptor, 2, 'amplifyingDescriptor'),
112
+ f(fields.entityCode, 6, 'entityCode'),
113
+ f(fields.sector1, 2, 'sector1'),
114
+ f(fields.sector2, 2, 'sector2'),
115
+ f(fields.sector1Identifier, 1, 'sector1Identifier'),
116
+ f(fields.sector2Identifier, 1, 'sector2Identifier'),
117
+ f(fields.frameShape, 1, 'frameShape'),
108
118
  '0000',
109
- f(fields.country, 3),
119
+ f(fields.country, 3, 'country'),
110
120
  ].join('');
111
121
  }
112
122
  function firstBad(code) {
@@ -5,7 +5,7 @@
5
5
  * The entity and modifier tables (A-XI onward) are generated, not typed here.
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.FRAME_SHAPES = exports.AMPLIFYING_DESCRIPTORS = exports.HQ_TF_DUMMY = exports.STATUSES = exports.SYMBOL_SETS_2525D_ONLY = exports.SYMBOL_SETS = exports.STANDARD_IDENTITIES = exports.CONTEXTS = exports.VERSIONS = void 0;
8
+ exports.FRAME_SHAPES = exports.AMPLIFYING_DESCRIPTORS = exports.HQ_TF_DUMMY = exports.STATUSES = exports.SYMBOL_SETS_APP6E_ONLY = exports.SYMBOL_SETS_2525D_ONLY = exports.SYMBOL_SETS = exports.STANDARD_IDENTITIES = exports.CONTEXTS = exports.VERSIONS = void 0;
9
9
  exports.lookup = lookup;
10
10
  /**
11
11
  * Table A-I, Version. Value 10 is shared by 2525D and APP-6(D)(1), which the standard says carry
@@ -66,7 +66,7 @@ exports.SYMBOL_SETS = [
66
66
  { value: '50', name: 'Signals Intelligence' },
67
67
  { value: '60', name: 'Cyberspace - Virtual' },
68
68
  ];
69
- /** 2525D's signals-intelligence sets (2525D Table A-IV), accepted as 2525D input only. */
69
+ /** 2525D's signals-intelligence sets (2525D Table A-III), accepted as 2525D input only. */
70
70
  exports.SYMBOL_SETS_2525D_ONLY = [
71
71
  { value: '50', name: 'Signals Intelligence – Space' },
72
72
  { value: '51', name: 'Signals Intelligence – Air' },
@@ -74,6 +74,11 @@ exports.SYMBOL_SETS_2525D_ONLY = [
74
74
  { value: '53', name: 'Signals Intelligence – Surface' },
75
75
  { value: '54', name: 'Signals Intelligence – Subsurface' },
76
76
  ];
77
+ /**
78
+ * APP-6(E)'s own set (APP-6(E) Edition E Version 2, Table A-4), accepted as APP-6(E) input only. APP-6(E)
79
+ * also keeps the five signals-intelligence sets 50-54 of 2525D (above), where 2525E has the single set 50.
80
+ */
81
+ exports.SYMBOL_SETS_APP6E_ONLY = [{ value: '64', name: 'Cyberspace – Non Unit' }];
77
82
  /** Table A-VI, Status. The same position may carry an operational condition instead (A.5.3.4.1). */
78
83
  exports.STATUSES = [
79
84
  { value: '0', name: 'Present' },
@@ -0,0 +1,82 @@
1
+ /** 59 entities: 4 hierarchy, 53 icon, 2 multipoint. */
2
+ export const ENTITIES_APP6E = [
3
+ ["01", "120700", "Medical Evacuation (MEDEVAC)", "icon", "", "", "Main"],
4
+ ["05", "110600", "Satellite, General", "icon", "", "", "Main"],
5
+ ["10", "110501", "Reconnaissance and Liaison Element", "icon", "", "", "Full Frame"],
6
+ ["10", "130301", "Self-Propelled Artillery", "icon", "", "", "Main"],
7
+ ["10", "140104", "Reconnaissance Armoured", "icon", "", "", "Full Frame"],
8
+ ["10", "161900", "NATO Supply Class II", "icon", "", "", "Full Frame"],
9
+ ["10", "162200", "NATO Supply Class V", "icon", "", "", "Full Frame"],
10
+ ["10", "165800", "National Support Element (NSE)", "icon", "", "", "Main"],
11
+ ["15", "112100", "Non-Lethal Grenade Launcher", "icon", "", "", "Main"],
12
+ ["20", "111901", "Displaced Persons/Refugee/Evacuees Camp", "icon", "", "", "Full Octagon"],
13
+ ["20", "111902", "Training Camp", "icon", "", "", "Full Octagon"],
14
+ ["20", "120801", "Military Armoury", "icon", "", "", "Full Octagon"],
15
+ ["20", "120802", "Military Base", "icon", "", "", "Full Octagon"],
16
+ ["25", "380000", "Paths", "hierarchy", "", "", ""],
17
+ ["25", "380100", "Data Path Segment", "multipoint", "", "", ""],
18
+ ["25", "380200", "Data Tunnel", "multipoint", "", "", ""],
19
+ ["27", "120000", "Civilian", "hierarchy", "", "", ""],
20
+ ["27", "120100", "Activity/Task", "hierarchy", "", "", ""],
21
+ ["27", "120101", "Police", "icon", "", "", "Main"],
22
+ ["27", "120102", "Non-Governmental Organization Member or Non-Governmental Organization (NGO)", "icon", "", "", "Main"],
23
+ ["27", "120103", "Government Organization (GO)", "icon", "", "", "Main"],
24
+ ["40", "110103", "Attempted Criminal Activity", "icon", "", "", "Main"],
25
+ ["40", "110105", "Drug Related", "icon", "", "", "Main"],
26
+ ["40", "131100", "Raid on House", "icon", "", "", "Full Octagon"],
27
+ ["40", "180300", "Isolated Personnel", "icon", "", "", "Full Octagon"],
28
+ ["60", "111100", "Security Operations Centre", "icon", "", "", "Main"],
29
+ ["60", "120100", "Criminal", "icon", "", "", "Main"],
30
+ ["64", "130000", "Agent", "hierarchy", "", "", ""],
31
+ ["64", "130100", "Firewall", "icon", "", "", "Main"],
32
+ ["64", "130200", "Firmware", "icon", "", "", "Main"],
33
+ ["64", "140000", "Application", "icon", "", "", "Main"],
34
+ ["64", "140100", "Banking", "icon", "", "", "Main"],
35
+ ["64", "140300", "Search Engine", "icon", "", "", "Main"],
36
+ ["64", "140400", "Social Media", "icon", "", "", "Main"],
37
+ ["64", "140500", "Database", "icon", "", "", "Main"],
38
+ ["64", "140600", "Service", "icon", "", "", "Main"],
39
+ ["64", "150000", "Threat", "icon", "", "", "Main"],
40
+ ["64", "150100", "Malware", "icon", "", "", "Main"],
41
+ ["64", "150200", "Phishing", "icon", "", "", "Main"],
42
+ ["64", "160000", "Data", "icon", "", "", "Main"],
43
+ ["64", "160100", "Digital Currency", "icon", "", "", "Main"],
44
+ ["64", "160200", "Persona", "icon", "", "", "Main"],
45
+ ["64", "170000", "End Point", "icon", "", "", "Main"],
46
+ ["64", "170100", "Server", "icon", "", "", "Main"],
47
+ ["64", "170200", "Workstation", "icon", "", "", "Main"],
48
+ ["64", "170300", "Portable Electronic Device (PED)", "icon", "", "", "Main"],
49
+ ["64", "170301", "Mobile/Smartphone", "icon", "", "", "Main"],
50
+ ["64", "170302", "Tablet", "icon", "", "", "Main"],
51
+ ["64", "170303", "Laptop", "icon", "", "", "Main"],
52
+ ["64", "170304", "Health Monitor", "icon", "", "", "Main"],
53
+ ["64", "170305", "Smartvest", "icon", "", "", "Main"],
54
+ ["64", "170306", "Smartwatch", "icon", "", "", "Main"],
55
+ ["64", "170307", "Wearable", "icon", "", "", "Main"],
56
+ ["64", "170400", "Internet of Things Device", "icon", "", "", "Main"],
57
+ ["64", "170500", "Printer", "icon", "", "", "Main"],
58
+ ["64", "170600", "Router", "icon", "", "", "Main"],
59
+ ["64", "170700", "Switch", "icon", "", "", "Main"],
60
+ ["64", "170800", "Remote Operated Relay (ROR)", "icon", "", "", "Main"],
61
+ ["64", "180000", "Network", "icon", "", "", "Main"],
62
+ ];
63
+ /**
64
+ * Those of them MIL-STD-2525D (2014) also defines (its appendices give each an entry), by set and code, with
65
+ * 2525D's own path (its entry's Entity line, then its name, last): a 2525D or APP-6(D) code names them so. Read
66
+ * from the 2525D PDF the same way.
67
+ */
68
+ export const APP6E_IN_2525D = {
69
+ "05110600": ["Military", "Satellite, General"],
70
+ "10130301": ["Fires", "Field Artillery", "Self-Propelled"],
71
+ "10140104": ["Protection", "Chemical Biological Radiological Nuclear Defense", "Reconnaissance Armored"],
72
+ "10161900": ["Sustainment", "NATO Supply Class II"],
73
+ "10162200": ["Sustainment", "NATO Supply Class V"],
74
+ "20111901": ["Installation", "Tented Camp", "Displaced Persons/Refugee/Evacuees Camp"],
75
+ "20111902": ["Installation", "Tented Camp", "Training Camp"],
76
+ "20120801": ["Infrastructure", "Military Infrastructure", "Military Armory"],
77
+ "20120802": ["Infrastructure", "Military Infrastructure", "Military Base"],
78
+ "40110103": ["Incident", "Criminal Activity Incident", "Attempted Criminal Activity"],
79
+ "40110105": ["Incident", "Criminal Activity Incident", "Drug Related"],
80
+ "40131100": ["Operation", "Raid on House"],
81
+ "60120100": ["Infection", "Advanced Persistent Threat (APT)"],
82
+ };
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @zaes/sidc/catalog — what every 2525E Change 1 code means: entity names and hierarchy, what kind of
3
- * drawing each is, its draw rule or icon type, and every sector modifier.
3
+ * drawing each is, its draw rule or icon type, and every sector modifier; and the entities APP-6(E) adds.
4
4
  *
5
5
  * A separate entry so that reading a code does not cost the ~175 KB of tables.
6
6
  *
@@ -8,16 +8,24 @@
8
8
  */
9
9
  import { parseSidc } from '../index.js';
10
10
  import { ENTITIES_2525E, MODIFIERS_2525E } from './data2525e.js';
11
+ import { APP6E_IN_2525D, ENTITIES_APP6E } from './dataApp6e.js';
11
12
  let entities;
13
+ let app6eEntities;
12
14
  let modifiers;
13
15
  const entityKey = (symbolSet, code) => `${symbolSet}:${code}`;
14
16
  const modifierKey = (symbolSet, sector, code) => `${symbolSet}:${sector}:${code}`;
15
17
  function entityIndex() {
16
- if (entities)
17
- return entities;
18
- const rows = new Map(ENTITIES_2525E.map((r) => [entityKey(r[0], r[1]), r]));
19
- entities = new Map();
20
- for (const [key, [symbolSet, code, name, kind, geometry, drawRule, iconType]] of rows) {
18
+ return (entities !== null && entities !== void 0 ? entities : (entities = indexRows(ENTITIES_2525E, new Map(ENTITIES_2525E.map((r) => [entityKey(r[0], r[1]), r])))));
19
+ }
20
+ /** APP-6(E)'s own entities, named under their headings in either table. */
21
+ function app6eIndex() {
22
+ const all = new Map([...ENTITIES_2525E, ...ENTITIES_APP6E].map((r) => [entityKey(r[0], r[1]), r]));
23
+ return (app6eEntities !== null && app6eEntities !== void 0 ? app6eEntities : (app6eEntities = new Map([...indexRows(ENTITIES_APP6E, all)].map(([k, e]) => [k, { ...e, standard: 'APP-6E' }]))));
24
+ }
25
+ function indexRows(own, rows) {
26
+ const index = new Map();
27
+ for (const [symbolSet, code, name, kind, geometry, drawRule, iconType] of own) {
28
+ const key = entityKey(symbolSet, code);
21
29
  const path = [];
22
30
  const entity = rows.get(entityKey(symbolSet, code.slice(0, 2) + '0000'));
23
31
  const type = rows.get(entityKey(symbolSet, code.slice(0, 4) + '00'));
@@ -28,7 +36,7 @@ function entityIndex() {
28
36
  path.push(type[2]);
29
37
  }
30
38
  path.push(name);
31
- entities.set(key, {
39
+ index.set(key, {
32
40
  symbolSet,
33
41
  code,
34
42
  name,
@@ -39,7 +47,7 @@ function entityIndex() {
39
47
  ...(iconType ? { iconType } : {}),
40
48
  });
41
49
  }
42
- return entities;
50
+ return index;
43
51
  }
44
52
  function modifierIndex() {
45
53
  if (modifiers)
@@ -50,9 +58,35 @@ function modifierIndex() {
50
58
  ]));
51
59
  return modifiers;
52
60
  }
53
- /** The entity a symbol set and positions 11–16 name, or undefined if 2525E Change 1 has none. */
54
- export function getEntity(symbolSet, code) {
55
- return entityIndex().get(entityKey(symbolSet, code));
61
+ /**
62
+ * The entity a symbol set and positions 11–16 name, or undefined if 2525E Change 1 has none. For an APP-6(E)
63
+ * code (`standard` 'APP-6E', as `parseSidc` reads versions 14 and 16), also the entities APP-6(E) adds; for a
64
+ * 2525D or APP-6(D) code ('2525D', 'APP-6D'), those of them 2525D defines as well, with 2525D's own name and path.
65
+ */
66
+ export function getEntity(symbolSet, code, standard) {
67
+ const key = entityKey(symbolSet, code);
68
+ const own = entityIndex().get(key);
69
+ if (own || !standard)
70
+ return own;
71
+ if (standard === 'APP-6E')
72
+ return app6eIndex().get(key);
73
+ if (standard === '2525D' || standard === 'APP-6D')
74
+ return in2525DIndex().get(key);
75
+ return undefined;
76
+ }
77
+ let shared2525D;
78
+ /** The APP-6(E) additions 2525D defines too, with 2525D's own names and paths. */
79
+ function in2525DIndex() {
80
+ if (shared2525D)
81
+ return shared2525D;
82
+ shared2525D = new Map();
83
+ for (const [setCode, path] of Object.entries(APP6E_IN_2525D)) {
84
+ const key = entityKey(setCode.slice(0, 2), setCode.slice(2));
85
+ const e = app6eIndex().get(key);
86
+ if (e)
87
+ shared2525D.set(key, { ...e, name: path[path.length - 1], path: [...path] });
88
+ }
89
+ return shared2525D;
56
90
  }
57
91
  /** Every entity, in the standard's order, optionally of one symbol set or kind. */
58
92
  export function listEntities(filter = {}) {
@@ -79,7 +113,7 @@ export function describeSidc(sidc) {
79
113
  return { problems: ['a 2525C letter code; convert it before describing it'] };
80
114
  const s = parsed.sidc;
81
115
  const problems = [];
82
- const entity = getEntity(s.symbolSet, s.entityCode);
116
+ const entity = getEntity(s.symbolSet, s.entityCode, s.standard);
83
117
  if (!entity)
84
118
  problems.push(`entity ${s.entityCode} is not in symbol set ${s.symbolSet}`);
85
119
  const modifier = (sector, code, identifier) => {
@@ -8,7 +8,7 @@
8
8
  * Set C 21 sector 1 modifier identifier · 22 sector 2 modifier identifier · 23 frame shape ·
9
9
  * 24–27 reserved · 28–30 country (GENC numeric)
10
10
  */
11
- import { AMPLIFYING_DESCRIPTORS, CONTEXTS, FRAME_SHAPES, HQ_TF_DUMMY, STANDARD_IDENTITIES, STATUSES, SYMBOL_SETS, SYMBOL_SETS_2525D_ONLY, VERSIONS, lookup, } from './tables.js';
11
+ import { AMPLIFYING_DESCRIPTORS, CONTEXTS, FRAME_SHAPES, HQ_TF_DUMMY, STANDARD_IDENTITIES, STATUSES, SYMBOL_SETS, SYMBOL_SETS_2525D_ONLY, SYMBOL_SETS_APP6E_ONLY, VERSIONS, lookup, } from './tables.js';
12
12
  const NUMERIC = /^[0-9A-F]+$/;
13
13
  /**
14
14
  * Reads a numeric SIDC. A code of the wrong length or with characters outside [0-9A-F] fails; a
@@ -38,7 +38,9 @@ export function parseNumericSidc(input) {
38
38
  const identity = lookup(STANDARD_IDENTITIES, standardIdentity);
39
39
  check(4, standardIdentity, !!identity, 'standard identity');
40
40
  const symbolSet = at(5, 6);
41
- const sets = standard === '2525D' || standard === 'APP-6D' ? [...SYMBOL_SETS.filter((s) => s.value !== '50'), ...SYMBOL_SETS_2525D_ONLY] : SYMBOL_SETS;
41
+ // 2525D and APP-6 split signals intelligence by dimension (50-54); APP-6(E) adds 64 (Table A-4).
42
+ const legacySigint = [...SYMBOL_SETS.filter((s) => s.value !== '50'), ...SYMBOL_SETS_2525D_ONLY];
43
+ const sets = standard === '2525D' || standard === 'APP-6D' ? legacySigint : standard === 'APP-6E' ? [...legacySigint, ...SYMBOL_SETS_APP6E_ONLY] : SYMBOL_SETS;
42
44
  check(5, symbolSet, !!lookup(sets, symbolSet), 'symbol set');
43
45
  const status = at(7);
44
46
  check(7, status, !!lookup(STATUSES, status), 'status');
@@ -83,26 +85,34 @@ export function parseNumericSidc(input) {
83
85
  },
84
86
  };
85
87
  }
86
- /** Writes a 30-position 2525E SIDC (version 15 unless given). Each field is padded to its width. */
88
+ /**
89
+ * Writes a 30-position 2525E SIDC (version 15 unless given). Each field is padded to its width; a field
90
+ * longer than its width throws a RangeError naming it (cutting it would write another symbol's code).
91
+ */
87
92
  export function formatNumericSidc(fields) {
88
93
  var _a;
89
- const f = (value, width) => (value !== null && value !== void 0 ? value : '').padStart(width, '0').slice(-width);
94
+ const f = (value, width, name = '') => {
95
+ const v = value !== null && value !== void 0 ? value : '';
96
+ if (v.length > width)
97
+ throw new RangeError(`formatNumericSidc: ${name || 'a field'} "${v}" is longer than its ${width} positions`);
98
+ return v.padStart(width, '0');
99
+ };
90
100
  return [
91
- f((_a = fields.version) !== null && _a !== void 0 ? _a : '15', 2),
92
- f(fields.context, 1),
93
- f(fields.standardIdentity, 1),
94
- f(fields.symbolSet, 2),
95
- f(fields.status, 1),
96
- f(fields.hqTfDummy, 1),
97
- f(fields.amplifyingDescriptor, 2),
98
- f(fields.entityCode, 6),
99
- f(fields.sector1, 2),
100
- f(fields.sector2, 2),
101
- f(fields.sector1Identifier, 1),
102
- f(fields.sector2Identifier, 1),
103
- f(fields.frameShape, 1),
101
+ f((_a = fields.version) !== null && _a !== void 0 ? _a : '15', 2, 'version'),
102
+ f(fields.context, 1, 'context'),
103
+ f(fields.standardIdentity, 1, 'standardIdentity'),
104
+ f(fields.symbolSet, 2, 'symbolSet'),
105
+ f(fields.status, 1, 'status'),
106
+ f(fields.hqTfDummy, 1, 'hqTfDummy'),
107
+ f(fields.amplifyingDescriptor, 2, 'amplifyingDescriptor'),
108
+ f(fields.entityCode, 6, 'entityCode'),
109
+ f(fields.sector1, 2, 'sector1'),
110
+ f(fields.sector2, 2, 'sector2'),
111
+ f(fields.sector1Identifier, 1, 'sector1Identifier'),
112
+ f(fields.sector2Identifier, 1, 'sector2Identifier'),
113
+ f(fields.frameShape, 1, 'frameShape'),
104
114
  '0000',
105
- f(fields.country, 3),
115
+ f(fields.country, 3, 'country'),
106
116
  ].join('');
107
117
  }
108
118
  function firstBad(code) {
@@ -62,7 +62,7 @@ export const SYMBOL_SETS = [
62
62
  { value: '50', name: 'Signals Intelligence' },
63
63
  { value: '60', name: 'Cyberspace - Virtual' },
64
64
  ];
65
- /** 2525D's signals-intelligence sets (2525D Table A-IV), accepted as 2525D input only. */
65
+ /** 2525D's signals-intelligence sets (2525D Table A-III), accepted as 2525D input only. */
66
66
  export const SYMBOL_SETS_2525D_ONLY = [
67
67
  { value: '50', name: 'Signals Intelligence – Space' },
68
68
  { value: '51', name: 'Signals Intelligence – Air' },
@@ -70,6 +70,11 @@ export const SYMBOL_SETS_2525D_ONLY = [
70
70
  { value: '53', name: 'Signals Intelligence – Surface' },
71
71
  { value: '54', name: 'Signals Intelligence – Subsurface' },
72
72
  ];
73
+ /**
74
+ * APP-6(E)'s own set (APP-6(E) Edition E Version 2, Table A-4), accepted as APP-6(E) input only. APP-6(E)
75
+ * also keeps the five signals-intelligence sets 50-54 of 2525D (above), where 2525E has the single set 50.
76
+ */
77
+ export const SYMBOL_SETS_APP6E_ONLY = [{ value: '64', name: 'Cyberspace – Non Unit' }];
73
78
  /** Table A-VI, Status. The same position may carry an operational condition instead (A.5.3.4.1). */
74
79
  export const STATUSES = [
75
80
  { value: '0', name: 'Present' },
@@ -0,0 +1,15 @@
1
+ /**
2
+ * APP-6(E) Version 2: the entities it defines that MIL-STD-2525E Change 1 does not (an APP-6(E) code reads
3
+ * every other entity from 2525E's tables), with their kind and icon type, read from its icon tables.
4
+ *
5
+ * Generated from the standard's text. Do not edit: correct the reading instead.
6
+ */
7
+ import type { EntityRow } from './types.js';
8
+ /** 59 entities: 4 hierarchy, 53 icon, 2 multipoint. */
9
+ export declare const ENTITIES_APP6E: readonly EntityRow[];
10
+ /**
11
+ * Those of them MIL-STD-2525D (2014) also defines (its appendices give each an entry), by set and code, with
12
+ * 2525D's own path (its entry's Entity line, then its name, last): a 2525D or APP-6(D) code names them so. Read
13
+ * from the 2525D PDF the same way.
14
+ */
15
+ export declare const APP6E_IN_2525D: Readonly<Record<string, readonly string[]>>;
@@ -1,8 +1,12 @@
1
1
  import type { NumericSidc } from '../numeric.js';
2
2
  import type { Entity, EntityKind, SectorModifier } from './types.js';
3
3
  export type { Entity, EntityKind, SectorModifier } from './types.js';
4
- /** The entity a symbol set and positions 11–16 name, or undefined if 2525E Change 1 has none. */
5
- export declare function getEntity(symbolSet: string, code: string): Entity | undefined;
4
+ /**
5
+ * The entity a symbol set and positions 11–16 name, or undefined if 2525E Change 1 has none. For an APP-6(E)
6
+ * code (`standard` 'APP-6E', as `parseSidc` reads versions 14 and 16), also the entities APP-6(E) adds; for a
7
+ * 2525D or APP-6(D) code ('2525D', 'APP-6D'), those of them 2525D defines as well, with 2525D's own name and path.
8
+ */
9
+ export declare function getEntity(symbolSet: string, code: string, standard?: string): Entity | undefined;
6
10
  /** Every entity, in the standard's order, optionally of one symbol set or kind. */
7
11
  export declare function listEntities(filter?: {
8
12
  symbolSet?: string;
@@ -29,6 +29,11 @@ export interface Entity {
29
29
  readonly drawRuleAppendix?: 'L' | 'M';
30
30
  /** How the icon fills the frame (Appendices C–K): `Main`, `Main+1`, `Full Octagon` or `Full Frame`. */
31
31
  readonly iconType?: string;
32
+ /**
33
+ * Set for an entity APP-6(E) defines and 2525E Change 1 does not: found for an APP-6(E) code, and for a
34
+ * 2525D or APP-6(D) code where 2525D defines it too.
35
+ */
36
+ readonly standard?: 'APP-6E';
32
37
  }
33
38
  export interface SectorModifier {
34
39
  /** The symbol set, or `common` for Appendix A Tables A-IX and A-X. */
@@ -59,5 +59,8 @@ export type ParseResult<T> = {
59
59
  export declare function parseNumericSidc(input: string): ParseResult<NumericSidc>;
60
60
  /** The fields a numeric SIDC is written from; anything left out is 0. */
61
61
  export type NumericSidcFields = Partial<Omit<NumericSidc, 'kind' | 'code' | 'standard' | 'standardIdentityGroup' | 'headquarters' | 'taskForce' | 'feintDummy'>>;
62
- /** Writes a 30-position 2525E SIDC (version 15 unless given). Each field is padded to its width. */
62
+ /**
63
+ * Writes a 30-position 2525E SIDC (version 15 unless given). Each field is padded to its width; a field
64
+ * longer than its width throws a RangeError naming it (cutting it would write another symbol's code).
65
+ */
63
66
  export declare function formatNumericSidc(fields: NumericSidcFields): string;
@@ -33,8 +33,13 @@ export interface StandardIdentityEntry extends CodeEntry {
33
33
  export declare const STANDARD_IDENTITIES: readonly StandardIdentityEntry[];
34
34
  /** Table A-IV, Symbol sets (2525E). 2525D's 51–54 are not here: E folded them into 50. */
35
35
  export declare const SYMBOL_SETS: readonly CodeEntry[];
36
- /** 2525D's signals-intelligence sets (2525D Table A-IV), accepted as 2525D input only. */
36
+ /** 2525D's signals-intelligence sets (2525D Table A-III), accepted as 2525D input only. */
37
37
  export declare const SYMBOL_SETS_2525D_ONLY: readonly CodeEntry[];
38
+ /**
39
+ * APP-6(E)'s own set (APP-6(E) Edition E Version 2, Table A-4), accepted as APP-6(E) input only. APP-6(E)
40
+ * also keeps the five signals-intelligence sets 50-54 of 2525D (above), where 2525E has the single set 50.
41
+ */
42
+ export declare const SYMBOL_SETS_APP6E_ONLY: readonly CodeEntry[];
38
43
  /** Table A-VI, Status. The same position may carry an operational condition instead (A.5.3.4.1). */
39
44
  export declare const STATUSES: readonly CodeEntry[];
40
45
  /** Table A-VII, Headquarters/task force/dummy: three flags, one digit. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zaes/sidc",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "author": "ZAES",
5
5
  "contributors": [
6
6
  "Edwin Sanchez <edwin.sanchez@zaes.com>"
@@ -24,6 +24,7 @@
24
24
  "files": [
25
25
  "dist",
26
26
  "README.md",
27
+ "CHANGELOG.md",
27
28
  "LICENSE",
28
29
  "THIRD-PARTY-NOTICES"
29
30
  ],