@tak-ps/node-cot 14.23.2 → 14.24.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.
@@ -4,6 +4,7 @@ import type {
4
4
  Feature,
5
5
  Polygon,
6
6
  FeaturePropertyMission,
7
+ FeaturePropertyMissionChange,
7
8
  FeaturePropertyMissionLayer,
8
9
  } from '../types/feature.js';
9
10
  import type {
@@ -219,20 +220,40 @@ export async function to_geojson(cot: CoT): Promise<Static<typeof Feature>> {
219
220
 
220
221
  mission.missionChanges = []
221
222
  for (const change of changes) {
222
- mission.missionChanges.push({
223
- contentUid: change.MissionChange.contentUid._text,
223
+ const mc: Static<typeof FeaturePropertyMissionChange> = {
224
+ contentUid: change.MissionChange.contentUid ? change.MissionChange.contentUid._text : undefined,
224
225
  creatorUid: change.MissionChange.creatorUid._text,
225
226
  isFederatedChange: change.MissionChange.isFederatedChange._text,
226
227
  missionName: change.MissionChange.missionName._text,
227
228
  timestamp: change.MissionChange.timestamp._text,
228
229
  type: change.MissionChange.type._text,
229
- details: {
230
+ };
231
+
232
+ if (change.MissionChange.contentResource) {
233
+ const cr = change.MissionChange.contentResource;
234
+ mc.contentResource = {
235
+ expiration: cr.expiration._text,
236
+ filename: cr.filename._text,
237
+ hash: cr.hash._text,
238
+ name: cr.name._text,
239
+ size: parseInt(cr.size._text),
240
+ submissionTime: cr.submissionTime._text,
241
+ submitter: cr.submitter._text,
242
+ tool: cr.tool._text,
243
+ uid: cr.uid._text,
244
+ };
245
+ }
246
+
247
+ if (change.MissionChange.details) {
248
+ mc.details = {
230
249
  ...change.MissionChange.details._attributes,
231
250
  ...change.MissionChange.details.location
232
251
  ? change.MissionChange.details.location._attributes
233
252
  : {}
234
- }
235
- })
253
+ };
254
+ }
255
+
256
+ mission.missionChanges.push(mc)
236
257
  }
237
258
  }
238
259
 
package/lib/parser.ts CHANGED
@@ -55,7 +55,9 @@ export class CoTParser {
55
55
  if (opts.flow === undefined) opts.flow = true;
56
56
 
57
57
  checkXML(cot.raw);
58
- if (checkXML.errors) throw new Err(400, null, `${checkXML.errors[0].message} (${checkXML.errors[0].instancePath})`);
58
+ if (checkXML.errors) {
59
+ throw new Err(400, null, `${checkXML.errors[0].message} (${checkXML.errors[0].instancePath})`);
60
+ }
59
61
 
60
62
  if (opts.flow) {
61
63
  if (!cot.raw.event.detail) cot.raw.event.detail = {};
@@ -39,19 +39,30 @@ export const FeaturePropertyMissionLayer = Type.Object({
39
39
  })
40
40
 
41
41
  export const FeaturePropertyMissionChange = Type.Object({
42
- contentUid: Type.String(),
42
+ contentUid: Type.Optional(Type.String()),
43
43
  creatorUid: Type.String(),
44
44
  isFederatedChange: Type.Boolean(),
45
45
  missionName: Type.String(),
46
46
  timestamp: Type.String(),
47
47
  type: Type.String(),
48
- details: Type.Object({
48
+ contentResource: Type.Optional(Type.Object({
49
+ expiration: Type.String(),
50
+ filename: Type.String(),
51
+ hash: Type.String(),
52
+ name: Type.String(),
53
+ size: Type.Integer(),
54
+ submissionTime: Type.String(),
55
+ submitter: Type.String(),
56
+ tool: Type.String(),
57
+ uid: Type.String(),
58
+ })),
59
+ details: Type.Optional(Type.Object({
49
60
  type: Type.String(),
50
61
  callsign: Type.String(),
51
62
  color: Type.String(),
52
63
  lat: Type.String(),
53
64
  lon: Type.String()
54
- })
65
+ }))
55
66
  })
56
67
 
57
68
  export const FeaturePropertyMission = Type.Object({
@@ -208,6 +208,11 @@ export const GenericTextBoolean = Type.Object({
208
208
  _text: Type.Boolean()
209
209
  })
210
210
 
211
+ export const GenericTextInteger = Type.Object({
212
+ _text: Type.Integer()
213
+ })
214
+
215
+
211
216
  export const TrackAttributes = Type.Object({
212
217
  speed: Type.Optional(Type.String()),
213
218
  course: Type.Optional(Type.String()),
@@ -322,13 +327,27 @@ export const MissionChangeDetails = Type.Object({
322
327
  }))
323
328
  })
324
329
 
330
+ export const MissionChangeContentResource = Type.Object({
331
+ expiration: GenericText,
332
+ filename: GenericText,
333
+ hash: GenericText,
334
+ name: GenericText,
335
+ size: GenericTextInteger,
336
+ submissionTime: GenericText,
337
+ submitter: GenericText,
338
+ tool: GenericText,
339
+ uid: GenericText
340
+ });
341
+
325
342
  export const MissionChange = Type.Object({
326
343
  contentUid: Type.Optional(GenericText),
327
344
  creatorUid: GenericOptionalText,
328
345
  isFederatedChange: GenericTextBoolean,
329
346
  missionName: GenericText,
347
+ missionGuid: Type.Optional(GenericText),
330
348
  timestamp: GenericText,
331
349
  type: GenericText,
350
+ contentResource: Type.Optional(MissionChangeContentResource),
332
351
  details: Type.Optional(MissionChangeDetails)
333
352
  })
334
353
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tak-ps/node-cot",
3
3
  "type": "module",
4
- "version": "14.23.2",
4
+ "version": "14.24.0",
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",
@@ -53,10 +53,11 @@
53
53
  "xml-js": "^1.6.11"
54
54
  },
55
55
  "devDependencies": {
56
+ "@eslint/js": "^10.0.1",
56
57
  "@types/node": "^25.0.0",
57
58
  "@types/tape": "^5.6.0",
58
59
  "c8": "^10.1.3",
59
- "eslint": "^9.0.0",
60
+ "eslint": "^10.0.0",
60
61
  "tape": "^5.6.1",
61
62
  "tsx": "^4.20.3",
62
63
  "typedoc": "^0.28.0",