@zaes/sidc 0.0.0-stage → 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.
Files changed (39) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/LICENSE +21 -0
  3. package/README.md +24 -3
  4. package/THIRD-PARTY-NOTICES +217 -0
  5. package/dist/cjs/2525c/data2525c.js +1965 -0
  6. package/dist/cjs/2525c/index.js +178 -0
  7. package/dist/cjs/catalog/data2525e.js +2704 -0
  8. package/dist/cjs/catalog/dataApp6e.js +85 -0
  9. package/dist/cjs/catalog/index.js +137 -0
  10. package/dist/cjs/catalog/types.js +2 -0
  11. package/dist/cjs/genc.js +298 -0
  12. package/dist/cjs/index.js +49 -0
  13. package/dist/cjs/letter.js +116 -0
  14. package/dist/cjs/numeric.js +127 -0
  15. package/dist/cjs/tables.js +151 -0
  16. package/dist/esm/2525c/data2525c.js +1962 -0
  17. package/dist/esm/2525c/index.js +174 -0
  18. package/dist/esm/catalog/data2525e.js +2701 -0
  19. package/dist/esm/catalog/dataApp6e.js +82 -0
  20. package/dist/esm/catalog/index.js +130 -0
  21. package/dist/esm/catalog/types.js +1 -0
  22. package/dist/esm/genc.js +294 -0
  23. package/dist/esm/index.js +20 -0
  24. package/dist/esm/letter.js +112 -0
  25. package/dist/esm/numeric.js +123 -0
  26. package/dist/esm/package.json +3 -0
  27. package/dist/esm/tables.js +147 -0
  28. package/dist/types/2525c/data2525c.d.ts +10 -0
  29. package/dist/types/2525c/index.d.ts +22 -0
  30. package/dist/types/catalog/data2525e.d.ts +12 -0
  31. package/dist/types/catalog/dataApp6e.d.ts +15 -0
  32. package/dist/types/catalog/index.d.ts +31 -0
  33. package/dist/types/catalog/types.d.ts +46 -0
  34. package/dist/types/genc.d.ts +12 -0
  35. package/dist/types/index.d.ts +15 -0
  36. package/dist/types/letter.d.ts +51 -0
  37. package/dist/types/numeric.d.ts +66 -0
  38. package/dist/types/tables.d.ts +56 -0
  39. package/package.json +66 -6
@@ -0,0 +1,66 @@
1
+ /**
2
+ * The numeric SIDC of MIL-STD-2525D and 2525E (Appendix A, A.5): 20 positions in 2525D, 30 in
3
+ * 2525E. A 20-position code read as 2525E has an all-zero Set C.
4
+ *
5
+ * Set A 1–2 version · 3 context · 4 standard identity · 5–6 symbol set · 7 status ·
6
+ * 8 headquarters/task force/dummy · 9–10 amplifying descriptor
7
+ * Set B 11–16 entity, entity type, entity subtype · 17–18 sector 1 modifier · 19–20 sector 2 modifier
8
+ * Set C 21 sector 1 modifier identifier · 22 sector 2 modifier identifier · 23 frame shape ·
9
+ * 24–27 reserved · 28–30 country (GENC numeric)
10
+ */
11
+ import { type NumericStandard, type StandardIdentityGroup } from './tables.js';
12
+ export interface NumericSidc {
13
+ readonly kind: 'numeric';
14
+ /** The code as given, 20 or 30 positions. */
15
+ readonly code: string;
16
+ /** The standard named by the version; undefined for a reserved version. */
17
+ readonly standard: NumericStandard | undefined;
18
+ readonly version: string;
19
+ readonly context: string;
20
+ readonly standardIdentity: string;
21
+ readonly standardIdentityGroup: StandardIdentityGroup | undefined;
22
+ readonly symbolSet: string;
23
+ readonly status: string;
24
+ readonly hqTfDummy: string;
25
+ readonly headquarters: boolean;
26
+ readonly taskForce: boolean;
27
+ readonly feintDummy: boolean;
28
+ readonly amplifyingDescriptor: string;
29
+ /** Positions 11–16. */
30
+ readonly entityCode: string;
31
+ readonly sector1: string;
32
+ readonly sector2: string;
33
+ /** Position 21: '0' means the symbol set's own sector 1 modifiers; more is a common-modifier table (Appendix B). */
34
+ readonly sector1Identifier: string;
35
+ readonly sector2Identifier: string;
36
+ /** Position 23. */
37
+ readonly frameShape: string;
38
+ /** Positions 28–30, GENC numeric; '000' when absent. */
39
+ readonly country: string;
40
+ }
41
+ export interface Problem {
42
+ /** 1-based first position the problem is about. */
43
+ readonly position: number;
44
+ readonly message: string;
45
+ }
46
+ export type ParseResult<T> = {
47
+ ok: true;
48
+ sidc: T;
49
+ problems: readonly Problem[];
50
+ } | {
51
+ ok: false;
52
+ problems: readonly Problem[];
53
+ };
54
+ /**
55
+ * Reads a numeric SIDC. A code of the wrong length or with characters outside [0-9A-F] fails; a
56
+ * well-formed code with values the tables don't define parses, with each one listed in `problems`,
57
+ * so a caller can decide whether to draw it.
58
+ */
59
+ export declare function parseNumericSidc(input: string): ParseResult<NumericSidc>;
60
+ /** The fields a numeric SIDC is written from; anything left out is 0. */
61
+ export type NumericSidcFields = Partial<Omit<NumericSidc, 'kind' | 'code' | 'standard' | 'standardIdentityGroup' | 'headquarters' | 'taskForce' | 'feintDummy'>>;
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
+ */
66
+ export declare function formatNumericSidc(fields: NumericSidcFields): string;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * The fixed code tables of the numeric SIDC, transcribed from MIL-STD-2525E Change 1, Appendix A.
3
+ * Each table names its source so a reviewer can check it against the standard line by line.
4
+ * The entity and modifier tables (A-XI onward) are generated, not typed here.
5
+ */
6
+ /** A code value and what the standard calls it. */
7
+ export interface CodeEntry<V extends string = string> {
8
+ readonly value: V;
9
+ readonly name: string;
10
+ }
11
+ /** The standard a numeric SIDC's version (positions 1–2) belongs to. */
12
+ export type NumericStandard = '2525D' | '2525E' | 'APP-6D' | 'APP-6E';
13
+ export interface VersionEntry extends CodeEntry {
14
+ readonly standard: NumericStandard;
15
+ /** The edition's release, as Table A-I gives it. */
16
+ readonly released: string;
17
+ }
18
+ /**
19
+ * Table A-I, Version. Value 10 is shared by 2525D and APP-6(D)(1), which the standard says carry
20
+ * the same versioning; `standard` gives the US one. 12, APP-6(D)(2), was withdrawn but codes
21
+ * carrying it may still exist. 17–3F are reserved.
22
+ */
23
+ export declare const VERSIONS: readonly VersionEntry[];
24
+ /** Table A-II, first position: the context. */
25
+ export declare const CONTEXTS: readonly CodeEntry[];
26
+ /** The four frame families of Table A-III. */
27
+ export type StandardIdentityGroup = 'Unknown' | 'Friend' | 'Neutral' | 'Hostile';
28
+ export interface StandardIdentityEntry extends CodeEntry {
29
+ /** Table A-III: which frame family the identity draws with. */
30
+ readonly group: StandardIdentityGroup;
31
+ }
32
+ /** Table A-II, second position: the standard identity, with its Table A-III group. */
33
+ export declare const STANDARD_IDENTITIES: readonly StandardIdentityEntry[];
34
+ /** Table A-IV, Symbol sets (2525E). 2525D's 51–54 are not here: E folded them into 50. */
35
+ export declare const SYMBOL_SETS: readonly CodeEntry[];
36
+ /** 2525D's signals-intelligence sets (2525D Table A-III), accepted as 2525D input only. */
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[];
43
+ /** Table A-VI, Status. The same position may carry an operational condition instead (A.5.3.4.1). */
44
+ export declare const STATUSES: readonly CodeEntry[];
45
+ /** Table A-VII, Headquarters/task force/dummy: three flags, one digit. */
46
+ export declare const HQ_TF_DUMMY: readonly CodeEntry[];
47
+ export type AmplifierKind = 'none' | 'echelon' | 'mobility' | 'towedArray' | 'leadership';
48
+ export interface AmplifierEntry extends CodeEntry {
49
+ readonly kind: AmplifierKind;
50
+ }
51
+ /** Table A-VIII, Amplifying descriptor (positions 9–10): echelon, mobility, towed array or leadership. */
52
+ export declare const AMPLIFYING_DESCRIPTORS: readonly AmplifierEntry[];
53
+ /** Table A-LX, Frame shape (position 23): overrides the frame the symbol set would draw. */
54
+ export declare const FRAME_SHAPES: readonly CodeEntry[];
55
+ /** Looks a value up in one of the tables above. */
56
+ export declare function lookup<E extends CodeEntry>(table: readonly E[], value: string): E | undefined;
package/package.json CHANGED
@@ -1,6 +1,66 @@
1
- {
2
- "name": "@zaes/sidc",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
1
+ {
2
+ "name": "@zaes/sidc",
3
+ "version": "0.2.0",
4
+ "author": "ZAES",
5
+ "contributors": [
6
+ "Edwin Sanchez <edwin.sanchez@zaes.com>"
7
+ ],
8
+ "description": "MIL-STD-2525C, 2525D and 2525E symbol identification codes (SIDC): read, validate and write them. No dependencies.",
9
+ "keywords": [
10
+ "mil-std-2525",
11
+ "mil-std-2525e",
12
+ "mil-std-2525d",
13
+ "mil-std-2525c",
14
+ "app-6",
15
+ "sidc",
16
+ "military-symbols",
17
+ "military-symbology",
18
+ "symbology"
19
+ ],
20
+ "license": "MIT AND Apache-2.0",
21
+ "main": "dist/cjs/index.js",
22
+ "module": "dist/esm/index.js",
23
+ "types": "dist/types/index.d.ts",
24
+ "files": [
25
+ "dist",
26
+ "README.md",
27
+ "CHANGELOG.md",
28
+ "LICENSE",
29
+ "THIRD-PARTY-NOTICES"
30
+ ],
31
+ "sideEffects": false,
32
+ "engines": {
33
+ "node": ">=18"
34
+ },
35
+ "exports": {
36
+ ".": {
37
+ "types": "./dist/types/index.d.ts",
38
+ "import": "./dist/esm/index.js",
39
+ "require": "./dist/cjs/index.js"
40
+ },
41
+ "./catalog": {
42
+ "types": "./dist/types/catalog/index.d.ts",
43
+ "import": "./dist/esm/catalog/index.js",
44
+ "require": "./dist/cjs/catalog/index.js"
45
+ },
46
+ "./2525c": {
47
+ "types": "./dist/types/2525c/index.d.ts",
48
+ "import": "./dist/esm/2525c/index.js",
49
+ "require": "./dist/cjs/2525c/index.js"
50
+ },
51
+ "./package.json": "./package.json"
52
+ },
53
+ "publishConfig": {
54
+ "access": "public"
55
+ },
56
+ "typesVersions": {
57
+ "*": {
58
+ "catalog": [
59
+ "dist/types/catalog/index.d.ts"
60
+ ],
61
+ "2525c": [
62
+ "dist/types/2525c/index.d.ts"
63
+ ]
64
+ }
65
+ }
66
+ }