@tak-ps/node-cot 11.1.0 → 12.0.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.
@@ -34,7 +34,7 @@ test('Decode MultiMissionAircraft CoTs', (t) => {
34
34
  ackrequest: {
35
35
  "_attributes": {
36
36
  "uid": "814d0d4a-3339-4fd2-8e09-0556444112f3",
37
- "ackrequested": "true",
37
+ "ackrequested": true,
38
38
  "tag": "20240615_144641.jpg"
39
39
  }
40
40
  },
@@ -42,7 +42,7 @@ test('Decode MultiMissionAircraft CoTs', (t) => {
42
42
  "_attributes": {
43
43
  "filename": "20240615_144641.jpg.zip",
44
44
  "senderUrl": "https://18.254.242.65:8443/Marti/sync/content?hash=c18e00d123057a8e33107e91ab02f999ecc6f849aed2a41b84e237ff36106a4e",
45
- "sizeInBytes": "4233884",
45
+ "sizeInBytes": 4233884,
46
46
  "sha256": "c18e00d123057a8e33107e91ab02f999ecc6f849aed2a41b84e237ff36106a4e",
47
47
  "senderUid": "ANDROID-0ca41830e11d2ef3",
48
48
  "senderCallsign": "DFPC Ingalls",
@@ -66,7 +66,7 @@ test('Decode MultiMissionAircraft CoTs', (t) => {
66
66
  stale: '2024-07-02T17:13:29Z',
67
67
  ackrequest: {
68
68
  "uid": "814d0d4a-3339-4fd2-8e09-0556444112f3",
69
- "ackrequested": "true",
69
+ "ackrequested": true,
70
70
  "tag": "20240615_144641.jpg"
71
71
  },
72
72
  fileshare: {
@@ -52,15 +52,15 @@ test('Decode MultiMissionAircraft CoTs', (t) => {
52
52
  "shape":{
53
53
  "polyline":{
54
54
  "_attributes":{
55
- "closed":"true",
55
+ "closed":true,
56
56
  "fillColor":"0",
57
57
  "color":"-1"
58
58
  },
59
59
  "vertex":[
60
- {"_attributes":{"lat":"40.059445","lon":"-108.328368"}},
61
- {"_attributes":{"lat":"40.061846","lon":"-108.314776"}},
62
- {"_attributes":{"lat":"40.075499","lon":"-108.315566"}},
63
- {"_attributes":{"lat":"40.071252","lon":"-108.330782"}}
60
+ {"_attributes":{"lat":40.059445,"lon":-108.328368}},
61
+ {"_attributes":{"lat":40.061846,"lon":-108.314776}},
62
+ {"_attributes":{"lat":40.075499,"lon":-108.315566}},
63
+ {"_attributes":{"lat":40.071252,"lon":-108.330782}}
64
64
  ]
65
65
  }
66
66
  },
@@ -0,0 +1,99 @@
1
+ import test from 'tape';
2
+ import CoT from '../index.js';
3
+
4
+ test('Decode Range & Bearing', (t) => {
5
+ const cot = new CoT({
6
+ "event": {
7
+ "_attributes": {
8
+ "version": "2.0",
9
+ "uid": "ebbf42a7-ea71-43a1-baf6-e259c3d115bf",
10
+ "type": "u-rb-a",
11
+ "how": "h-e",
12
+ "time": "2024-08-30T22:28:02Z",
13
+ "start": "2024-08-30T22:28:02Z",
14
+ "stale": "2024-08-31T22:28:02Z",
15
+ "access": "Undefined"
16
+ },
17
+ "point": {
18
+ "_attributes": {
19
+ "lat": "39.0981196",
20
+ "lon": "-108.7395013",
21
+ "hae": "0.0",
22
+ "ce": "9999999.0",
23
+ "le": "9999999.0"
24
+ }
25
+ },
26
+ "detail": {
27
+ "contact": {
28
+ "_attributes": {
29
+ "callsign": "R&B 1"
30
+ }
31
+ },
32
+ "range": {
33
+ "_attributes": {
34
+ "value": "14806.869682096987"
35
+ }
36
+ },
37
+ "bearing": { "_attributes": { "value": "102.28151464168589" } },
38
+ "inclination": { "_attributes": { "value": "5.373568186490131" } },
39
+ "rangeUnits": { "_attributes": { "value": "0" } },
40
+ "bearingUnits": { "_attributes": { "value": "0" } },
41
+ "northRef": { "_attributes": { "value": "1" } },
42
+ "strokeColor": { "_attributes": { "value": "-65536" } },
43
+ "strokeWeight": { "_attributes": { "value": "3.0" } },
44
+ "strokeStyle": { "_attributes": { "value": "solid" } },
45
+ "remarks": {},
46
+ "labels_on": { "_attributes": { "value": "false" } },
47
+ "archive": {},
48
+ "link": {
49
+ "_attributes": {
50
+ "uid": "ANDROID-0ca41830e11d2ef3",
51
+ "production_time": "2024-08-30T22:26:28.264Z",
52
+ "type": "a-f-G-E-V-C",
53
+ "parent_callsign": "DFPC Ingalls Tab",
54
+ "relation": "p-p"
55
+ }
56
+ },
57
+ "color": {
58
+ "_attributes": {
59
+ "value": "-65536"
60
+ }
61
+ },
62
+ "_flow-tags_": {
63
+ "_attributes": {
64
+ "TAK-Server-e87a0e02420b44a08f6032bcf1877745": "2024-08-30T22:28:02Z"
65
+ }
66
+ }
67
+ }
68
+ }
69
+ })
70
+
71
+ if (!cot.raw.event.detail) {
72
+ t.fail('No Detail Section')
73
+ } else {
74
+ t.ok(cot.raw.event.detail['_flow-tags_']);
75
+ delete cot.raw.event.detail['_flow-tags_'];
76
+
77
+ t.deepEquals({
78
+ id: 'ebbf42a7-ea71-43a1-baf6-e259c3d115bf',
79
+ type: 'Feature',
80
+ properties: {
81
+ archived: true,
82
+ callsign: 'R&B 1',
83
+ center: [ -108.7395013, 39.0981196, 0 ],
84
+ type: 'u-rb-a',
85
+ how: 'h-e',
86
+ time: '2024-08-30T22:28:02Z',
87
+ start: '2024-08-30T22:28:02Z',
88
+ stale: '2024-08-31T22:28:02Z',
89
+ metadata: {}
90
+ },
91
+ geometry: {
92
+ type: 'Point',
93
+ coordinates: [ -108.7395013, 39.0981196, 0 ]
94
+ }
95
+ }, cot.to_geojson());
96
+ }
97
+
98
+ t.end();
99
+ });
@@ -142,7 +142,7 @@ test(`DataPackage CoT Parsing: QuickPic.zip`, async (t) => {
142
142
  Parameter: { _attributes: { name: 'uid', value: '3b758d3c-5b7a-4fba-a0dc-bbde18e895b5' } }
143
143
  }, {
144
144
  _attributes: { ignore: false, zipEntry: 'e63e920689815c961ec9d873c83f08a6/20240702_144514.jpg' },
145
- Parameter: { _attributes: { name: 'uid', value: '3b758d3c-5b7a-4fba-a0dc-bbde18e895b5' } }
145
+ Parameter: { _attributes: { name: 'uid', value: '3b758d3c-5b7a-4fba-a0dc-bbde18e895b5' } }
146
146
  }
147
147
  ]);
148
148
 
@@ -187,7 +187,7 @@ test(`DataPackage CoT Parsing: addFile,getFile`, async (t) => {
187
187
 
188
188
  const buff = await stream2buffer(await pkg.getFile('123/package.json'));
189
189
 
190
- t.equals(JSON.parse(buff.toString()).name, '@tak-ps/node-cot');
190
+ t.equals(JSON.parse(buff.toString()).name, '@tak-ps/node-cot');
191
191
 
192
192
  const cots = await pkg.cots();
193
193
 
@@ -223,7 +223,7 @@ test(`DataPackage CoT Parsing: AttachmentInManifest.zip`, async (t) => {
223
223
  Parameter: { _attributes: { name: 'uid', value: 'c7f90966-f048-41fd-8951-70cd9a380cd2' } }
224
224
  }, {
225
225
  _attributes: { ignore: false, zipEntry: '6988443373b26e519cfd1096665b8eaa/1000001544.jpg' },
226
- Parameter: { _attributes: { name: 'uid', value: 'c7f90966-f048-41fd-8951-70cd9a380cd2' } }
226
+ Parameter: { _attributes: { name: 'uid', value: 'c7f90966-f048-41fd-8951-70cd9a380cd2' } }
227
227
  }
228
228
  ]);
229
229
 
@@ -231,8 +231,10 @@ test(`DataPackage CoT Parsing: AttachmentInManifest.zip`, async (t) => {
231
231
 
232
232
  t.equal(cots.length, 1);
233
233
 
234
+ if (!cots[0].raw.event.detail) throw new Error('Detail field not set');
235
+
234
236
  t.deepEquals(
235
- cots[0].raw.event.detail.attachment_list,
237
+ cots[0].raw.event.detail.attachment_list,
236
238
  { _attributes: { hashes: '["3adefc8c1935166d3e501844549776c6fc21cc6d72f371fdda23788e6ec7181d"]' } }
237
239
  )
238
240
 
@@ -33,7 +33,7 @@ test('ForceDelete - Basic', (t) => {
33
33
  _attributes: { lat: '0.000000', lon: '0.000000', hae: '0.0', ce: '9999999.0', le: '9999999.0' }
34
34
  },
35
35
  detail: {
36
- __forceddelete: {},
36
+ __forcedelete: {},
37
37
  link: {
38
38
  _attributes: {
39
39
  uid: 'delete-uid',
@@ -3,14 +3,7 @@ import CoT from '../index.js';
3
3
 
4
4
  test('CoT.from_geojson - Point', (t) => {
5
5
  try {
6
- new CoT(
7
- {
8
- event: {
9
- // @ts-expect-error we're trying to force an error here
10
- _attributes: {}
11
- }
12
- }
13
- );
6
+ new CoT({ event: { _attributes: {} } });
14
7
  t.fail();
15
8
  } catch (err) {
16
9
  t.ok(String(err).includes('must have required property'));
package/tsconfig.json CHANGED
@@ -4,6 +4,7 @@
4
4
  },
5
5
  "compilerOptions": {
6
6
  "strict": true,
7
+ "strictNullChecks": true,
7
8
  "module": "es2022",
8
9
  "esModuleInterop": true,
9
10
  "target": "es2022",