@tak-ps/node-cot 14.59.0 → 14.60.1
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/.github/workflows/doc.yml +5 -0
- package/.oxlintrc.json +100 -0
- package/CHANGELOG.md +9 -0
- package/README.md +17 -0
- package/cli.ts +21 -22
- package/dist/cli.js +18 -19
- package/dist/cli.js.map +1 -1
- package/dist/lib/builders/chat.d.ts +4 -4
- package/dist/lib/builders/chat.js +3 -6
- package/dist/lib/builders/chat.js.map +1 -1
- package/dist/lib/builders/route.js +2 -2
- package/dist/lib/cot.js +44 -56
- package/dist/lib/cot.js.map +1 -1
- package/dist/lib/data-package.d.ts +3 -3
- package/dist/lib/data-package.js +68 -81
- package/dist/lib/data-package.js.map +1 -1
- package/dist/lib/parser/from_geojson.js +24 -30
- package/dist/lib/parser/from_geojson.js.map +1 -1
- package/dist/lib/parser/normalize_geojson.js +22 -22
- package/dist/lib/parser/normalize_geojson.js.map +1 -1
- package/dist/lib/parser/to_geojson.js +94 -86
- package/dist/lib/parser/to_geojson.js.map +1 -1
- package/dist/lib/parser-normalize.d.ts +5 -0
- package/dist/lib/parser-normalize.js +25 -8
- package/dist/lib/parser-normalize.js.map +1 -1
- package/dist/lib/parser.js +96 -81
- package/dist/lib/parser.js.map +1 -1
- package/dist/lib/sensor.js +11 -5
- package/dist/lib/sensor.js.map +1 -1
- package/dist/lib/type.js +5 -10
- package/dist/lib/type.js.map +1 -1
- package/dist/lib/types/cot-types.js +4 -4
- package/dist/lib/types/cot-types.js.map +1 -1
- package/dist/lib/types/feature.d.ts +755 -755
- package/dist/lib/types/types.d.ts +55 -9
- package/dist/lib/types/types.js +18 -3
- package/dist/lib/types/types.js.map +1 -1
- package/dist/lib/utils/2525.js +139 -92
- package/dist/lib/utils/2525.js.map +1 -1
- package/dist/lib/utils/color.js +1 -1
- package/dist/lib/utils/color.js.map +1 -1
- package/dist/lib/utils/type.js +5 -10
- package/dist/lib/utils/type.js.map +1 -1
- package/dist/lib/utils/util.d.ts +5 -0
- package/dist/lib/utils/util.js +25 -16
- package/dist/lib/utils/util.js.map +1 -1
- package/dist/lib/xml/basemap.js +10 -9
- package/dist/lib/xml/basemap.js.map +1 -1
- package/dist/lib/xml/iconset.js +1 -1
- package/dist/lib/xml/iconset.js.map +1 -1
- package/dist/lib/xml-document.d.ts +1 -1
- package/dist/lib/xml-document.js +6 -3
- package/dist/lib/xml-document.js.map +1 -1
- package/dist/package.json +8 -8
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/lib/builders/chat.ts +3 -3
- package/lib/builders/route.ts +2 -2
- package/lib/cot.ts +42 -47
- package/lib/data-package.ts +72 -76
- package/lib/parser/from_geojson.ts +24 -29
- package/lib/parser/normalize_geojson.ts +22 -26
- package/lib/parser/to_geojson.ts +105 -94
- package/lib/parser-normalize.ts +30 -9
- package/lib/parser.ts +121 -92
- package/lib/sensor.ts +12 -5
- package/lib/type.ts +5 -5
- package/lib/types/cot-types.ts +4 -4
- package/lib/types/types.ts +20 -3
- package/lib/utils/2525.ts +147 -96
- package/lib/utils/color.ts +1 -1
- package/lib/utils/type.ts +5 -5
- package/lib/utils/util.ts +31 -15
- package/lib/xml/basemap.ts +10 -9
- package/lib/xml/iconset.ts +1 -1
- package/lib/xml-document.ts +7 -4
- package/package.json +8 -8
- package/eslint.config.js +0 -15
package/lib/utils/2525.ts
CHANGED
|
@@ -33,77 +33,136 @@ export enum StandardIdentity {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export const SID_MAP: Record<string, string> = {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
// pending
|
|
37
|
+
P: "00",
|
|
38
|
+
// unknown
|
|
39
|
+
U: "01",
|
|
40
|
+
// assumed friend
|
|
41
|
+
A: "02",
|
|
42
|
+
// friend
|
|
43
|
+
F: "03",
|
|
44
|
+
// neutral
|
|
45
|
+
N: "04",
|
|
46
|
+
// suspect
|
|
47
|
+
S: "05",
|
|
48
|
+
// hostile
|
|
49
|
+
H: "06",
|
|
50
|
+
// exercise pending
|
|
51
|
+
G: "10",
|
|
52
|
+
// exercise unknown
|
|
53
|
+
W: "11",
|
|
54
|
+
// exercise assumed friend
|
|
55
|
+
M: "12",
|
|
56
|
+
// exercise friend
|
|
57
|
+
D: "13",
|
|
58
|
+
// exercise neutral
|
|
59
|
+
L: "14",
|
|
60
|
+
// joker
|
|
61
|
+
J: "15",
|
|
62
|
+
// faker
|
|
63
|
+
K: "16",
|
|
50
64
|
};
|
|
51
65
|
|
|
52
66
|
export const STATUS_MAP: Record<string, string> = {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
67
|
+
// present
|
|
68
|
+
P: "0",
|
|
69
|
+
// anticipated/planned
|
|
70
|
+
A: "1",
|
|
71
|
+
// present fully capable
|
|
72
|
+
C: "2",
|
|
73
|
+
// present damaged
|
|
74
|
+
D: "3",
|
|
75
|
+
// present destroyed
|
|
76
|
+
X: "4",
|
|
77
|
+
// present full to capacity
|
|
78
|
+
F: "5",
|
|
59
79
|
};
|
|
60
80
|
|
|
61
81
|
export const DIM_MAP: Record<string, string> = {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
82
|
+
// Space
|
|
83
|
+
P: '05',
|
|
84
|
+
// Air
|
|
85
|
+
A: '01',
|
|
86
|
+
// Ground
|
|
87
|
+
G: '10',
|
|
88
|
+
// SeaSurface
|
|
89
|
+
S: '30',
|
|
90
|
+
// SubSurface
|
|
91
|
+
U: '35',
|
|
92
|
+
// SOF
|
|
93
|
+
F: '10',
|
|
94
|
+
// Unknown
|
|
95
|
+
Z: '10',
|
|
96
|
+
// Unknown
|
|
97
|
+
X: '10'
|
|
70
98
|
}
|
|
71
99
|
|
|
72
100
|
export const SID_REVERSE_MAP: Record<string, string> = {
|
|
73
|
-
|
|
74
|
-
'
|
|
75
|
-
|
|
76
|
-
'
|
|
77
|
-
|
|
78
|
-
'
|
|
79
|
-
|
|
80
|
-
'
|
|
81
|
-
|
|
82
|
-
'
|
|
83
|
-
|
|
84
|
-
'
|
|
85
|
-
|
|
86
|
-
'
|
|
101
|
+
// pending
|
|
102
|
+
'00': 'p',
|
|
103
|
+
// unknown
|
|
104
|
+
'01': 'u',
|
|
105
|
+
// assumed friend
|
|
106
|
+
'02': 'a',
|
|
107
|
+
// friend
|
|
108
|
+
'03': 'f',
|
|
109
|
+
// neutral
|
|
110
|
+
'04': 'n',
|
|
111
|
+
// suspect
|
|
112
|
+
'05': 's',
|
|
113
|
+
// hostile
|
|
114
|
+
'06': 'h',
|
|
115
|
+
// exercise pending
|
|
116
|
+
'10': 'p',
|
|
117
|
+
// exercise unknown
|
|
118
|
+
'11': 'u',
|
|
119
|
+
// exercise assumed friend
|
|
120
|
+
'12': 'a',
|
|
121
|
+
// exercise friend
|
|
122
|
+
'13': 'f',
|
|
123
|
+
// exercise neutral
|
|
124
|
+
'14': 'n',
|
|
125
|
+
// joker
|
|
126
|
+
'15': 'j',
|
|
127
|
+
// faker
|
|
128
|
+
'16': 'k',
|
|
87
129
|
};
|
|
88
130
|
|
|
89
131
|
export const SYMBOL_SET_DIM_MAP: Record<string, string> = {
|
|
90
|
-
|
|
91
|
-
'
|
|
92
|
-
|
|
93
|
-
'
|
|
94
|
-
|
|
95
|
-
'
|
|
96
|
-
|
|
97
|
-
'
|
|
98
|
-
|
|
99
|
-
'
|
|
100
|
-
|
|
101
|
-
'
|
|
102
|
-
|
|
103
|
-
'
|
|
104
|
-
|
|
105
|
-
'
|
|
106
|
-
|
|
132
|
+
// Air
|
|
133
|
+
'01': 'A',
|
|
134
|
+
// Air Missile
|
|
135
|
+
'02': 'A',
|
|
136
|
+
// Space
|
|
137
|
+
'05': 'P',
|
|
138
|
+
// Space Missile
|
|
139
|
+
'06': 'P',
|
|
140
|
+
// Land Unit
|
|
141
|
+
'10': 'G',
|
|
142
|
+
// Land Civilian Unit/Organization
|
|
143
|
+
'11': 'G',
|
|
144
|
+
// Land Equipment
|
|
145
|
+
'15': 'G',
|
|
146
|
+
// Land Installation
|
|
147
|
+
'20': 'G',
|
|
148
|
+
// Dismounted Individual
|
|
149
|
+
'27': 'G',
|
|
150
|
+
// Sea Surface
|
|
151
|
+
'30': 'S',
|
|
152
|
+
// Sea Subsurface
|
|
153
|
+
'35': 'U',
|
|
154
|
+
// Mine Warfare
|
|
155
|
+
'36': 'U',
|
|
156
|
+
// Signals Intelligence - Space
|
|
157
|
+
'50': 'P',
|
|
158
|
+
// Signals Intelligence - Air
|
|
159
|
+
'51': 'A',
|
|
160
|
+
// Signals Intelligence - Land
|
|
161
|
+
'52': 'G',
|
|
162
|
+
// Signals Intelligence - Surface
|
|
163
|
+
'53': 'S',
|
|
164
|
+
// Signals Intelligence - Subsurface
|
|
165
|
+
'54': 'U',
|
|
107
166
|
};
|
|
108
167
|
|
|
109
168
|
/**
|
|
@@ -120,18 +179,16 @@ export default class Type2525 {
|
|
|
120
179
|
* @param cotType - Cursor On Target Type to test
|
|
121
180
|
*/
|
|
122
181
|
static is2525BConvertable(cotType: string): boolean {
|
|
123
|
-
return
|
|
182
|
+
return /^a-[PUAFNSHJKOXpuafnshjkox]-[PAGSUFXZ](-\w+)*$/.test(cotType);
|
|
124
183
|
}
|
|
125
184
|
|
|
126
185
|
static domain(cotType: string): Domain {
|
|
127
186
|
const unknownDomain = cotType.split('-')[0];
|
|
128
187
|
|
|
129
188
|
const d = enumFromStringValue<Domain>(Domain, unknownDomain);
|
|
130
|
-
if (d)
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
throw new Error('Domain could not be determined');
|
|
134
|
-
}
|
|
189
|
+
if (d === undefined) throw new Error('Domain could not be determined');
|
|
190
|
+
|
|
191
|
+
return d;
|
|
135
192
|
}
|
|
136
193
|
|
|
137
194
|
static standardIdentity(cotType: string): StandardIdentity {
|
|
@@ -142,11 +199,7 @@ export default class Type2525 {
|
|
|
142
199
|
|
|
143
200
|
const si = enumFromStringValue(StandardIdentity, unknownIdentity);
|
|
144
201
|
|
|
145
|
-
|
|
146
|
-
return si;
|
|
147
|
-
} else {
|
|
148
|
-
return StandardIdentity.NONE;
|
|
149
|
-
}
|
|
202
|
+
return si ?? StandardIdentity.NONE;
|
|
150
203
|
}
|
|
151
204
|
|
|
152
205
|
/**
|
|
@@ -158,21 +211,21 @@ export default class Type2525 {
|
|
|
158
211
|
const str_sidc = this.to2525B(cotType);
|
|
159
212
|
|
|
160
213
|
// Handle Short Codes Manually
|
|
161
|
-
if (
|
|
214
|
+
if (/^S[A-Z]{3}-{11}/.test(str_sidc)) {
|
|
162
215
|
const AFF = str_sidc[1].toUpperCase()
|
|
163
216
|
const DIM = str_sidc[2].toUpperCase()
|
|
164
217
|
const STS = str_sidc[3].toUpperCase()
|
|
165
218
|
|
|
166
219
|
return VERSION_2525D + SID_MAP[AFF] + DIM_MAP[DIM] + STATUS_MAP[STS] + '0000000000000';
|
|
167
|
-
}
|
|
168
|
-
const convert = convertLetterSidc2NumberSidc(str_sidc);
|
|
220
|
+
}
|
|
169
221
|
|
|
170
|
-
|
|
171
|
-
throw new Error(`Could not convert 2525B SIDC to 2525D`);
|
|
172
|
-
}
|
|
222
|
+
const convert = convertLetterSidc2NumberSidc(str_sidc);
|
|
173
223
|
|
|
174
|
-
|
|
224
|
+
if (!convert.sidc) {
|
|
225
|
+
throw new Error(`Could not convert 2525B SIDC to 2525D`);
|
|
175
226
|
}
|
|
227
|
+
|
|
228
|
+
return convert.sidc;
|
|
176
229
|
}
|
|
177
230
|
|
|
178
231
|
/**
|
|
@@ -185,17 +238,17 @@ export default class Type2525 {
|
|
|
185
238
|
throw new TypeError("CoT to 2525B can only be applied to well-formed Atom type CoT Events.")
|
|
186
239
|
}
|
|
187
240
|
|
|
188
|
-
const m2525bChars = cotType.
|
|
189
|
-
const m2525bBattleDim = m2525bChars
|
|
241
|
+
const m2525bChars = cotType.slice(4).replaceAll(/[^A-Z0-9]+/g, "");
|
|
242
|
+
const m2525bBattleDim = m2525bChars[0];
|
|
190
243
|
|
|
191
|
-
const cotAffiliation = cotType
|
|
244
|
+
const cotAffiliation = cotType[2];
|
|
192
245
|
const m2525bAffiliation = (cotAffiliation === "o" || cotAffiliation === "x")
|
|
193
246
|
? "U"
|
|
194
247
|
: cotAffiliation.toUpperCase();
|
|
195
248
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
249
|
+
const m2525bFuncId = m2525bChars.length > 1
|
|
250
|
+
? m2525bChars.slice(1).padEnd(6, "-").slice(0, 6)
|
|
251
|
+
: "------";
|
|
199
252
|
|
|
200
253
|
return `S${m2525bAffiliation}${m2525bBattleDim}P${m2525bFuncId}-----`;
|
|
201
254
|
}
|
|
@@ -206,7 +259,7 @@ export default class Type2525 {
|
|
|
206
259
|
* @param sidc - Numeric SIDC to test
|
|
207
260
|
*/
|
|
208
261
|
static isNumericSIDCConvertable(sidc: string): boolean {
|
|
209
|
-
return
|
|
262
|
+
return /^1[0-3]\d{18}$/.test(sidc);
|
|
210
263
|
}
|
|
211
264
|
|
|
212
265
|
/**
|
|
@@ -220,8 +273,8 @@ export default class Type2525 {
|
|
|
220
273
|
throw new Error("Numeric SIDC to CoT can only be applied to well-formed 2525D/2525E SIDCs.");
|
|
221
274
|
}
|
|
222
275
|
|
|
223
|
-
const affiliation = SID_REVERSE_MAP[sidc.
|
|
224
|
-
const dimension = SYMBOL_SET_DIM_MAP[sidc.
|
|
276
|
+
const affiliation = SID_REVERSE_MAP[sidc.slice(2, 4)] || 'u';
|
|
277
|
+
const dimension = SYMBOL_SET_DIM_MAP[sidc.slice(4, 6)] || 'G';
|
|
225
278
|
|
|
226
279
|
return `a-${affiliation}-${dimension}`;
|
|
227
280
|
}
|
|
@@ -267,7 +320,7 @@ export default class Type2525 {
|
|
|
267
320
|
* @param sidc - SIDC to test
|
|
268
321
|
*/
|
|
269
322
|
static isTypeConvertable(sidc: string): boolean {
|
|
270
|
-
return
|
|
323
|
+
return /^S[PUAFNSHGWMDLJK-][PAGSUFXZ-][AP-][A-Z0-9-]{10}[AECGNS-]$/.test(sidc)
|
|
271
324
|
}
|
|
272
325
|
|
|
273
326
|
/**
|
|
@@ -280,24 +333,22 @@ export default class Type2525 {
|
|
|
280
333
|
throw new Error("2525B to CoT can only be applied to well-formed warfighting 2525B SIDCs.");
|
|
281
334
|
}
|
|
282
335
|
|
|
283
|
-
const m2525bAffiliation = sidc
|
|
336
|
+
const m2525bAffiliation = sidc[1];
|
|
284
337
|
const cotAffiliation = ["G", "W", "M", "D", "L"].includes(m2525bAffiliation)
|
|
285
338
|
? "f"
|
|
286
339
|
: m2525bAffiliation === "-"
|
|
287
340
|
? "o"
|
|
288
341
|
: m2525bAffiliation.toLowerCase();
|
|
289
342
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
343
|
+
const cotBattleDim = sidc[2];
|
|
344
|
+
const cotFuncId = Array.from(sidc.slice(4, 10).replaceAll(/[^A-Z0-9]+/g, ""))
|
|
345
|
+
.map((x) => `-${x}`)
|
|
346
|
+
.join("");
|
|
294
347
|
|
|
295
348
|
return `a-${cotAffiliation}-${cotBattleDim}${cotFuncId}`;
|
|
296
349
|
}
|
|
297
350
|
}
|
|
298
351
|
|
|
299
|
-
function enumFromStringValue<T> (enm:
|
|
300
|
-
return
|
|
301
|
-
? value as unknown as T
|
|
302
|
-
: undefined;
|
|
352
|
+
function enumFromStringValue<T extends string> (enm: Record<string, T>, value: string): T | undefined {
|
|
353
|
+
return Object.values(enm).find((v) => v === value);
|
|
303
354
|
}
|
package/lib/utils/color.ts
CHANGED
package/lib/utils/type.ts
CHANGED
|
@@ -18,11 +18,11 @@ export default class TypeValidator {
|
|
|
18
18
|
body: unknown,
|
|
19
19
|
opts?: TypeOpts
|
|
20
20
|
): Static<T> {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
opts ??= {};
|
|
22
|
+
opts.verbose ??= false;
|
|
23
|
+
opts.default ??= true;
|
|
24
|
+
opts.convert ??= true;
|
|
25
|
+
opts.clean ??= true;
|
|
26
26
|
|
|
27
27
|
if (opts.default) {
|
|
28
28
|
Value.Default(type, body)
|
package/lib/utils/util.ts
CHANGED
|
@@ -10,6 +10,18 @@ import type {
|
|
|
10
10
|
* Helper functions for generating CoT data
|
|
11
11
|
* @class
|
|
12
12
|
*/
|
|
13
|
+
export function jsonClone<T>(value: T): T {
|
|
14
|
+
// oxlint-disable-next-line typescript/no-unsafe-return
|
|
15
|
+
return JSON.parse(JSON.stringify(value));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Coerce numeric values that may not have passed through schema coercion
|
|
20
|
+
*/
|
|
21
|
+
export function toNumber(value: number | string): number {
|
|
22
|
+
return typeof value === 'number' ? value : Number(value);
|
|
23
|
+
}
|
|
24
|
+
|
|
13
25
|
export default class Util {
|
|
14
26
|
/**
|
|
15
27
|
* Return an event._attributes object with as many defaults as possible
|
|
@@ -61,9 +73,9 @@ export default class Util {
|
|
|
61
73
|
static cot_track_attr(course?: number, speed?: number, slope?: number): Static<typeof TrackAttributes> {
|
|
62
74
|
const attr: Static<typeof TrackAttributes> = {};
|
|
63
75
|
|
|
64
|
-
if (course) attr.course = String(course);
|
|
65
|
-
if (speed) attr.speed = String(speed);
|
|
66
|
-
if (slope) attr.slope = String(slope);
|
|
76
|
+
if (course !== undefined && course !== 0) attr.course = String(course);
|
|
77
|
+
if (speed !== undefined && speed !== 0) attr.speed = String(speed);
|
|
78
|
+
if (slope !== undefined && slope !== 0) attr.slope = String(slope);
|
|
67
79
|
|
|
68
80
|
return attr;
|
|
69
81
|
}
|
|
@@ -117,24 +129,28 @@ export default class Util {
|
|
|
117
129
|
} {
|
|
118
130
|
const now = Date.now();
|
|
119
131
|
|
|
132
|
+
const dates = {
|
|
133
|
+
time: (new Date(time === '' ? now : time ?? now)).toISOString(),
|
|
134
|
+
start: (new Date(start === '' ? now : start ?? now)).toISOString()
|
|
135
|
+
};
|
|
136
|
+
|
|
120
137
|
if (stale === undefined || stale === null) {
|
|
121
138
|
return {
|
|
122
|
-
|
|
123
|
-
start: (new Date(start || now)).toISOString(),
|
|
139
|
+
...dates,
|
|
124
140
|
stale: (new Date(new Date(now).getTime() + 20 * 1000)).toISOString()
|
|
125
141
|
};
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
start: (new Date(start || now)).toISOString(),
|
|
130
|
-
stale: (new Date(new Date(now).getTime() + Number(stale))).toISOString()
|
|
131
|
-
};
|
|
132
|
-
} else {
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (typeof stale === 'number') {
|
|
133
145
|
return {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
stale: String(stale)
|
|
146
|
+
...dates,
|
|
147
|
+
stale: (new Date(new Date(now).getTime() + stale)).toISOString()
|
|
137
148
|
};
|
|
138
149
|
}
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
...dates,
|
|
153
|
+
stale: String(stale)
|
|
154
|
+
};
|
|
139
155
|
}
|
|
140
156
|
}
|
package/lib/xml/basemap.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Err from '@openaddresses/batch-error';
|
|
2
2
|
import XMLDocument from '../xml-document.js';
|
|
3
|
+
import { toNumber } from '../utils/util.js';
|
|
3
4
|
import type { Static } from '@sinclair/typebox'
|
|
4
5
|
import BasemapSchema from '../types/basemap.js';
|
|
5
6
|
import AJV from 'ajv';
|
|
@@ -35,18 +36,18 @@ export class Basemap extends XMLDocument<BasemapType> {
|
|
|
35
36
|
backgroundColor: string | undefined;
|
|
36
37
|
serverParts: string | undefined;
|
|
37
38
|
} {
|
|
38
|
-
if (
|
|
39
|
-
if (
|
|
39
|
+
if (this.raw.customMapSource === undefined) throw new Err(400, null, 'Unknown Basemap Type');
|
|
40
|
+
if (this.raw.customMapSource.url === undefined) throw new Err(400, null, 'Unknown Basemap Type - Missing URL');
|
|
40
41
|
|
|
41
42
|
return {
|
|
42
|
-
name: this.raw.customMapSource.name
|
|
43
|
+
name: this.raw.customMapSource.name?._text,
|
|
43
44
|
url: this.raw.customMapSource.url._text,
|
|
44
|
-
minZoom: this.raw.customMapSource.minZoom ?
|
|
45
|
-
maxZoom: this.raw.customMapSource.maxZoom ?
|
|
46
|
-
tileType: this.raw.customMapSource.tileType
|
|
47
|
-
tileUpdate: this.raw.customMapSource.tileUpdate
|
|
48
|
-
backgroundColor: this.raw.customMapSource.backgroundColor
|
|
49
|
-
serverParts: this.raw.customMapSource.serverParts
|
|
45
|
+
minZoom: this.raw.customMapSource.minZoom !== undefined ? toNumber(this.raw.customMapSource.minZoom._text) : undefined,
|
|
46
|
+
maxZoom: this.raw.customMapSource.maxZoom !== undefined ? toNumber(this.raw.customMapSource.maxZoom._text) : undefined,
|
|
47
|
+
tileType: this.raw.customMapSource.tileType?._text,
|
|
48
|
+
tileUpdate: this.raw.customMapSource.tileUpdate?._text,
|
|
49
|
+
backgroundColor: this.raw.customMapSource.backgroundColor?._text,
|
|
50
|
+
serverParts: this.raw.customMapSource.serverParts?._text,
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
}
|
package/lib/xml/iconset.ts
CHANGED
|
@@ -46,7 +46,7 @@ export class Iconset extends XMLDocument<IconsetType> {
|
|
|
46
46
|
uid: this.raw.iconset._attributes.uid,
|
|
47
47
|
version: this.raw.iconset._attributes.version,
|
|
48
48
|
name: this.raw.iconset._attributes.name,
|
|
49
|
-
skip_resize: this.raw.iconset._attributes.skip_resize
|
|
49
|
+
skip_resize: this.raw.iconset._attributes.skip_resize ?? false,
|
|
50
50
|
default_group: this.raw.iconset._attributes.default_group,
|
|
51
51
|
default_friendly: this.raw.iconset._attributes.default_friendly,
|
|
52
52
|
default_hostile: this.raw.iconset._attributes.default_hostile,
|
package/lib/xml-document.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Err from '@openaddresses/batch-error';
|
|
2
2
|
import type { ValidateFunction } from 'ajv';
|
|
3
|
-
import
|
|
3
|
+
import { xml2js, js2xml, type Element } from '@tak-ps/xml-js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Core XML Document support used for XML fortatted DataPackages documents
|
|
@@ -13,16 +13,19 @@ export default class XMLDocument<T> {
|
|
|
13
13
|
this.raw = raw;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
// oxlint-disable-next-line typescript/no-unnecessary-type-parameters
|
|
17
|
+
static check<U>(input: string, check: ValidateFunction): U {
|
|
18
|
+
const xml = xml2js(input, { compact: true })
|
|
18
19
|
|
|
19
20
|
check(xml);
|
|
20
21
|
if (check.errors) throw new Err(400, null, `${check.errors[0].message} (${check.errors[0].instancePath})`);
|
|
21
22
|
|
|
23
|
+
// oxlint-disable-next-line typescript/no-unsafe-type-assertion
|
|
22
24
|
return xml as U;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
to_xml(): string {
|
|
26
|
-
|
|
28
|
+
// oxlint-disable-next-line typescript/no-unsafe-type-assertion
|
|
29
|
+
return js2xml(this.raw as Element, { compact: true });
|
|
27
30
|
}
|
|
28
31
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tak-ps/node-cot",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "14.
|
|
4
|
+
"version": "14.60.1",
|
|
5
5
|
"description": "Lightweight JavaScript library for parsing and manipulating TAK messages",
|
|
6
6
|
"author": "Nick Ingalls <nick@ingalls.ca>",
|
|
7
7
|
"types": "index.ts",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"test": "c8 --reporter=lcov --reporter html tsx --test test/*.ts",
|
|
24
|
-
"lint": "
|
|
24
|
+
"lint": "oxlint --type-aware --deny-warnings --report-unused-disable-directives",
|
|
25
25
|
"doc": "typedoc index.ts",
|
|
26
|
-
"build": "tsc --build && cp package.json dist/ && cp ./lib/types/*.xml ./dist/lib/types/ && mkdir -p ./dist/lib/proto/ && cp lib/proto/* ./dist/lib/proto/",
|
|
26
|
+
"build": "node node_modules/typescript7/bin/tsc --build && cp package.json dist/ && cp ./lib/types/*.xml ./dist/lib/types/ && mkdir -p ./dist/lib/proto/ && cp lib/proto/* ./dist/lib/proto/",
|
|
27
27
|
"pretest": "npm run lint"
|
|
28
28
|
},
|
|
29
29
|
"engines": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"ajv": "^8.12.0",
|
|
46
46
|
"color": "^5.0.0",
|
|
47
47
|
"geomagnetism": "^0.2.0",
|
|
48
|
-
"json-diff-ts": "^
|
|
48
|
+
"json-diff-ts": "^5.0.0",
|
|
49
49
|
"mil-std-2525": "^0.2.8",
|
|
50
50
|
"milstandard-e": "^0.2.14",
|
|
51
51
|
"milsymbol": "^3.0.2",
|
|
@@ -53,14 +53,14 @@
|
|
|
53
53
|
"protobufjs": "^8.0.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@eslint/js": "^10.0.1",
|
|
57
56
|
"@types/node": "^26.0.0",
|
|
58
57
|
"c8": "^12.0.0",
|
|
59
|
-
"
|
|
58
|
+
"oxlint": "^1.94.0",
|
|
59
|
+
"oxlint-tsgolint": "^7.0.2007",
|
|
60
60
|
"tsx": "^4.20.3",
|
|
61
61
|
"typedoc": "^0.28.0",
|
|
62
|
-
"typescript": "
|
|
63
|
-
"
|
|
62
|
+
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
63
|
+
"typescript7": "npm:typescript@^7.0.2"
|
|
64
64
|
},
|
|
65
65
|
"repository": {
|
|
66
66
|
"type": "git",
|
package/eslint.config.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import eslint from '@eslint/js';
|
|
2
|
-
import tseslint from 'typescript-eslint';
|
|
3
|
-
|
|
4
|
-
export default tseslint.config(
|
|
5
|
-
{
|
|
6
|
-
ignores: ['dist/**', 'docs/**', 'coverage/**']
|
|
7
|
-
},
|
|
8
|
-
eslint.configs.recommended,
|
|
9
|
-
...tseslint.configs.recommended,
|
|
10
|
-
{
|
|
11
|
-
"rules": {
|
|
12
|
-
"@typescript-eslint/no-explicit-any": "warn"
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
);
|