@tak-ps/node-cot 2.4.0 → 2.5.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/.github/workflows/release.yml +29 -0
- package/.github/workflows/test.yml +6 -3
- package/CHANGELOG.md +4 -0
- package/index.js +1 -1
- package/lib/schema.json +83 -0
- package/{src → lib}/util.js +0 -0
- package/{src → lib}/xml.js +10 -0
- package/package.json +3 -2
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: NPM Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- '*'
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v3
|
|
13
|
+
|
|
14
|
+
- name: Get tag
|
|
15
|
+
id: tag
|
|
16
|
+
uses: dawidd6/action-get-tag@v1
|
|
17
|
+
|
|
18
|
+
- uses: actions/setup-node@v3
|
|
19
|
+
with:
|
|
20
|
+
node-version: 18
|
|
21
|
+
registry-url: https://registry.npmjs.org/
|
|
22
|
+
|
|
23
|
+
- name: npm install
|
|
24
|
+
run: npm install
|
|
25
|
+
|
|
26
|
+
- name: npm publish
|
|
27
|
+
run: npm publish
|
|
28
|
+
env:
|
|
29
|
+
NPM_TOKEN: ${{ secrets.NPM_SECRET }}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
name: Test
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
4
7
|
pull_request:
|
|
5
8
|
types:
|
|
6
9
|
- opened
|
|
@@ -25,8 +28,8 @@ jobs:
|
|
|
25
28
|
- name: Install
|
|
26
29
|
run: npm install
|
|
27
30
|
|
|
28
|
-
- name: Test
|
|
29
|
-
run: npm test
|
|
30
|
-
|
|
31
31
|
- name: Lint
|
|
32
32
|
run: npm run lint
|
|
33
|
+
|
|
34
|
+
- name: Test
|
|
35
|
+
run: npm test
|
package/CHANGELOG.md
CHANGED
package/index.js
CHANGED
package/lib/schema.json
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "object",
|
|
3
|
+
"required": [
|
|
4
|
+
"event"
|
|
5
|
+
],
|
|
6
|
+
"properties": {
|
|
7
|
+
"event": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"required": [
|
|
10
|
+
"_attributes",
|
|
11
|
+
"point"
|
|
12
|
+
],
|
|
13
|
+
"properties": {
|
|
14
|
+
"_attributes": {
|
|
15
|
+
"type": "object",
|
|
16
|
+
"required": [
|
|
17
|
+
"version",
|
|
18
|
+
"uid",
|
|
19
|
+
"type",
|
|
20
|
+
"time",
|
|
21
|
+
"start",
|
|
22
|
+
"stale"
|
|
23
|
+
],
|
|
24
|
+
"properties": {
|
|
25
|
+
"version": {
|
|
26
|
+
"type": "string"
|
|
27
|
+
},
|
|
28
|
+
"uid": {
|
|
29
|
+
"type": "string"
|
|
30
|
+
},
|
|
31
|
+
"type": {
|
|
32
|
+
"type": "string"
|
|
33
|
+
},
|
|
34
|
+
"time": {
|
|
35
|
+
"type": "string"
|
|
36
|
+
},
|
|
37
|
+
"start": {
|
|
38
|
+
"type": "string"
|
|
39
|
+
},
|
|
40
|
+
"stale": {
|
|
41
|
+
"type": "string"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"point": {
|
|
46
|
+
"type": "object",
|
|
47
|
+
"required": [
|
|
48
|
+
"_attributes"
|
|
49
|
+
],
|
|
50
|
+
"properties": {
|
|
51
|
+
"_attributes": {
|
|
52
|
+
"type": "object",
|
|
53
|
+
"required": [
|
|
54
|
+
"lat",
|
|
55
|
+
"lon",
|
|
56
|
+
"hae",
|
|
57
|
+
"ce",
|
|
58
|
+
"le"
|
|
59
|
+
],
|
|
60
|
+
"properties": {
|
|
61
|
+
"lat": {
|
|
62
|
+
"type": "number"
|
|
63
|
+
},
|
|
64
|
+
"lon": {
|
|
65
|
+
"type": "number"
|
|
66
|
+
},
|
|
67
|
+
"hae": {
|
|
68
|
+
"type": "number"
|
|
69
|
+
},
|
|
70
|
+
"ce": {
|
|
71
|
+
"type": "number"
|
|
72
|
+
},
|
|
73
|
+
"le": {
|
|
74
|
+
"type": "number"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
package/{src → lib}/util.js
RENAMED
|
File without changes
|
package/{src → lib}/xml.js
RENAMED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import xmljs from 'xml-js';
|
|
2
2
|
import Util from './util.js';
|
|
3
3
|
import PointOnFeature from '@turf/point-on-feature';
|
|
4
|
+
import AJV from 'ajv';
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
|
|
7
|
+
const ajv = (new AJV({ allErrors: true })).compile(JSON.parse(fs.readFileSync(new URL('./schema.json', import.meta.url))));
|
|
8
|
+
|
|
4
9
|
|
|
5
10
|
/**
|
|
6
11
|
* Convert to and from an XML CoT message
|
|
@@ -26,6 +31,11 @@ export default class XMLCot {
|
|
|
26
31
|
this.raw.event.point._attributes[key] = parseFloat(this.raw.event.point._attributes[key]);
|
|
27
32
|
}
|
|
28
33
|
}
|
|
34
|
+
|
|
35
|
+
if (!this.raw.event._attributes.uid) this.raw.event._attributes.uuid = Util.cot_uuid().uid;
|
|
36
|
+
|
|
37
|
+
ajv(this.raw);
|
|
38
|
+
if (ajv.errors) throw new Error(ajv.errors[0].message);
|
|
29
39
|
}
|
|
30
40
|
|
|
31
41
|
/**
|
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tak-ps/node-cot",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.5.0",
|
|
5
5
|
"description": "Lightweight JavaScript library for parsing and manipulating TAK messages",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"test": "tape test/**.test.js",
|
|
9
|
-
"lint": "eslint *.js
|
|
9
|
+
"lint": "eslint *.js lib/*.js test/*.js"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@turf/point-on-feature": "^6.5.0",
|
|
13
|
+
"ajv": "^8.11.2",
|
|
13
14
|
"protobufjs": "^7.1.2",
|
|
14
15
|
"uuid": "^9.0.0",
|
|
15
16
|
"xml-js": "^1.6.11"
|