@tak-ps/node-cot 12.7.0 → 12.8.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/CHANGELOG.md +8 -0
- package/dist/lib/xml/basemap.js +16 -0
- package/dist/lib/xml/basemap.js.map +1 -1
- package/dist/package.json +1 -5
- package/dist/test/basemaps.test.js +2 -0
- package/dist/test/basemaps.test.js.map +1 -1
- package/lib/xml/basemap.ts +24 -0
- package/package.json +1 -5
- package/test/basemaps.test.ts +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,14 @@
|
|
|
12
12
|
|
|
13
13
|
### Pending Fixed
|
|
14
14
|
|
|
15
|
+
### v12.8.0 - 2024-10-26
|
|
16
|
+
|
|
17
|
+
- :rocket: Add `.to_json` call for Basemap XML
|
|
18
|
+
|
|
19
|
+
### v12.7.1 - 2024-10-16
|
|
20
|
+
|
|
21
|
+
- :rocket: Remove `exports` from package.json for now Ref: https://github.com/dfpc-coe/node-CoT/issues/47
|
|
22
|
+
|
|
15
23
|
### v12.7.0 - 2024-10-16
|
|
16
24
|
|
|
17
25
|
- :rocket: Add `DataPackage.files()` Fn for getting non-attachment files
|
package/dist/lib/xml/basemap.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import Err from '@openaddresses/batch-error';
|
|
1
2
|
import XMLDocument from '../xml-document.js';
|
|
2
3
|
import BasemapSchema from '../types/basemap.js';
|
|
3
4
|
import AJV from 'ajv';
|
|
@@ -18,5 +19,20 @@ export class Basemap extends XMLDocument {
|
|
|
18
19
|
const basemap = super.check(input, checkBasemap);
|
|
19
20
|
return new Basemap(basemap);
|
|
20
21
|
}
|
|
22
|
+
to_json() {
|
|
23
|
+
if (!this.raw.customMapSource)
|
|
24
|
+
throw new Err(400, null, 'Unknown Basemap Type');
|
|
25
|
+
if (!this.raw.customMapSource.url)
|
|
26
|
+
throw new Err(400, null, 'Unknown Basemap Type - Missing URL');
|
|
27
|
+
return {
|
|
28
|
+
name: this.raw.customMapSource.name ? this.raw.customMapSource.name._text : undefined,
|
|
29
|
+
url: this.raw.customMapSource.url._text,
|
|
30
|
+
minZoom: this.raw.customMapSource.minZoom ? Number(this.raw.customMapSource.minZoom._text) : undefined,
|
|
31
|
+
maxZoom: this.raw.customMapSource.maxZoom ? Number(this.raw.customMapSource.maxZoom._text) : undefined,
|
|
32
|
+
tileType: this.raw.customMapSource.tileType ? this.raw.customMapSource.tileType._text : undefined,
|
|
33
|
+
tileUpdate: this.raw.customMapSource.tileUpdate ? this.raw.customMapSource.tileUpdate._text : undefined,
|
|
34
|
+
backgroundColor: this.raw.customMapSource.backgroundColor ? this.raw.customMapSource.backgroundColor._text : undefined
|
|
35
|
+
};
|
|
36
|
+
}
|
|
21
37
|
}
|
|
22
38
|
//# sourceMappingURL=basemap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basemap.js","sourceRoot":"","sources":["../../../lib/xml/basemap.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAE7C,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAChD,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,MAAM,YAAY,GAAG,CAAC,IAAI,GAAG,CAAC;IAC1B,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,IAAI;IACjB,eAAe,EAAE,IAAI;CACxB,CAAC,CAAC;KACE,OAAO,CAAC,aAAa,CAAC,CAAC;AAI5B;;GAEG;AACH,MAAM,OAAO,OAAQ,SAAQ,WAAwB;IACjD;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,KAAa;QACtB,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAc,KAAK,EAAE,YAAY,CAAC,CAAC;QAC9D,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;CACJ"}
|
|
1
|
+
{"version":3,"file":"basemap.js","sourceRoot":"","sources":["../../../lib/xml/basemap.ts"],"names":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AC,CAAC,CAAC,CAAC,SAAS;YACtG,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS;YACtG,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;YACjG,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;YACvG,eAAe,EAAE,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;SACzH,CAAA;IACL,CAAC;CACJ"}
|
package/dist/package.json
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tak-ps/node-cot",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "12.
|
|
4
|
+
"version": "12.8.0",
|
|
5
5
|
"description": "Lightweight JavaScript library for parsing and manipulating TAK messages",
|
|
6
6
|
"author": "Nick Ingalls <nick@ingalls.ca>",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"types": "index.ts",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": "./dist/index.js",
|
|
11
|
-
"./types/": "./dist/lib/types/"
|
|
12
|
-
},
|
|
13
9
|
"scripts": {
|
|
14
10
|
"test": "ts-node-test test/",
|
|
15
11
|
"lint": "eslint *.ts lib/ test/",
|
|
@@ -8,6 +8,8 @@ for (const fixturename of await fs.readdir(new URL('./basemaps/', import.meta.ur
|
|
|
8
8
|
const fixture = String(await fs.readFile(path.join(path.parse(fileURLToPath(import.meta.url)).dir, 'basemaps/', fixturename)));
|
|
9
9
|
const container = await Basemap.parse(fixture);
|
|
10
10
|
t.ok(container.raw.customMapSource.name._text.length);
|
|
11
|
+
const json = container.to_json();
|
|
12
|
+
t.ok(json.name && json.name.length);
|
|
11
13
|
t.end();
|
|
12
14
|
});
|
|
13
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basemaps.test.js","sourceRoot":"","sources":["../../test/basemaps.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,KAAK,MAAM,WAAW,IAAI,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;IAClF,IAAI,CAAC,iBAAiB,WAAW,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;QAC7C,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;QAC/H,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAE/C,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QAErD,CA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ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import Err from '@openaddresses/batch-error';
|
|
1
2
|
import XMLDocument from '../xml-document.js';
|
|
2
3
|
import type { Static } from '@sinclair/typebox'
|
|
3
4
|
import BasemapSchema from '../types/basemap.js';
|
|
@@ -23,4 +24,27 @@ export class Basemap extends XMLDocument<BasemapType> {
|
|
|
23
24
|
const basemap = super.check<BasemapType>(input, checkBasemap);
|
|
24
25
|
return new Basemap(basemap);
|
|
25
26
|
}
|
|
27
|
+
|
|
28
|
+
to_json(): {
|
|
29
|
+
name: string | undefined
|
|
30
|
+
url: string;
|
|
31
|
+
minZoom: number | undefined;
|
|
32
|
+
maxZoom: number | undefined;
|
|
33
|
+
tileType: string | undefined;
|
|
34
|
+
tileUpdate: string | undefined;
|
|
35
|
+
backgroundColor: string | undefined;
|
|
36
|
+
} {
|
|
37
|
+
if (!this.raw.customMapSource) throw new Err(400, null, 'Unknown Basemap Type');
|
|
38
|
+
if (!this.raw.customMapSource.url) throw new Err(400, null, 'Unknown Basemap Type - Missing URL');
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
name: this.raw.customMapSource.name ? this.raw.customMapSource.name._text : undefined,
|
|
42
|
+
url: this.raw.customMapSource.url._text,
|
|
43
|
+
minZoom: this.raw.customMapSource.minZoom ? Number(this.raw.customMapSource.minZoom._text) : undefined,
|
|
44
|
+
maxZoom: this.raw.customMapSource.maxZoom ? Number(this.raw.customMapSource.maxZoom._text) : undefined,
|
|
45
|
+
tileType: this.raw.customMapSource.tileType ? this.raw.customMapSource.tileType._text : undefined,
|
|
46
|
+
tileUpdate: this.raw.customMapSource.tileUpdate ? this.raw.customMapSource.tileUpdate._text : undefined,
|
|
47
|
+
backgroundColor: this.raw.customMapSource.backgroundColor ? this.raw.customMapSource.backgroundColor._text : undefined
|
|
48
|
+
}
|
|
49
|
+
}
|
|
26
50
|
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tak-ps/node-cot",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "12.
|
|
4
|
+
"version": "12.8.0",
|
|
5
5
|
"description": "Lightweight JavaScript library for parsing and manipulating TAK messages",
|
|
6
6
|
"author": "Nick Ingalls <nick@ingalls.ca>",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"types": "index.ts",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": "./dist/index.js",
|
|
11
|
-
"./types/": "./dist/lib/types/"
|
|
12
|
-
},
|
|
13
9
|
"scripts": {
|
|
14
10
|
"test": "ts-node-test test/",
|
|
15
11
|
"lint": "eslint *.ts lib/ test/",
|
package/test/basemaps.test.ts
CHANGED