@tak-ps/node-cot 14.0.0 → 14.0.2

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 CHANGED
@@ -12,7 +12,15 @@
12
12
 
13
13
  ### Pending Fixed
14
14
 
15
- ### v14.0.0 - 2025-07-10
15
+ ### v14.0.2 - 2025-07-13
16
+
17
+ - :rocket: Include .d.ts files in output
18
+
19
+ ### v14.0.1 - 2025-07-13
20
+
21
+ - :bug: Ensure `archived: true` is set on normalized features as these will result in `u-d` type CoTs
22
+
23
+ ### v14.0.0 - 2025-07-13
16
24
 
17
25
  - :rocket: Replace AJV with TypeBox for schema validation in `from_geojson`
18
26
  - :rocket: **Breaking** All parser functions now return `Promise`
@@ -0,0 +1,16 @@
1
+ import CoT from './lib/cot.js';
2
+ export * from './lib/parser.js';
3
+ export * from './lib/types/geojson.js';
4
+ export * as Feature from './lib/types/feature.js';
5
+ export * as Types from './lib/types/types.js';
6
+ export * as CoTTypes from './lib/types/cot-types.js';
7
+ export * as MilSymType from './lib/utils/2525.js';
8
+ export * from './lib/sensor.js';
9
+ export * from './lib/data-package.js';
10
+ export * from './lib/xml/basemap.js';
11
+ export * from './lib/xml/iconset.js';
12
+ export * from './lib/builders/chat.js';
13
+ export * from './lib/builders/route.js';
14
+ export * from './lib/builders/fileshare.js';
15
+ export * from './lib/builders/force-delete.js';
16
+ export default CoT;
@@ -0,0 +1,18 @@
1
+ import CoT from '../cot.js';
2
+ export type DirectChatMember = {
3
+ uid: string;
4
+ callsign: string;
5
+ };
6
+ export type DirectChatInput = {
7
+ to: DirectChatMember;
8
+ from: DirectChatMember;
9
+ message: string;
10
+ parent?: string;
11
+ chatroom?: string;
12
+ groupOwner?: boolean;
13
+ messageId?: string;
14
+ id?: string;
15
+ };
16
+ export declare class DirectChat extends CoT {
17
+ constructor(chat: DirectChatInput);
18
+ }
@@ -0,0 +1,6 @@
1
+ import CoT from '../cot.js';
2
+ import type { FileShareAttributes } from '../types/types.js';
3
+ import type { Static } from '@sinclair/typebox';
4
+ export declare class FileShare extends CoT {
5
+ constructor(fileshare: Static<typeof FileShareAttributes>);
6
+ }
@@ -0,0 +1,4 @@
1
+ import CoT from '../cot.js';
2
+ export declare class ForceDelete extends CoT {
3
+ constructor(uid: string);
4
+ }
@@ -0,0 +1,4 @@
1
+ import CoT from '../cot.js';
2
+ export declare class Route extends CoT {
3
+ constructor(cot?: CoT);
4
+ }
@@ -0,0 +1,189 @@
1
+ import type { Static } from '@sinclair/typebox';
2
+ import type { Polygon, Position } from './types/feature.js';
3
+ import type { MartiDestAttributes, LinkAttributes, CreatorAttributes, VideoAttributes, SensorAttributes, VideoConnectionEntryAttributes } from './types/types.js';
4
+ import JSONCoT, { Detail } from './types/types.js';
5
+ export type CoTOptions = {
6
+ creator?: CoT | {
7
+ uid: string;
8
+ type: string;
9
+ callsign: string;
10
+ time?: Date | string;
11
+ };
12
+ };
13
+ /**
14
+ * Convert to and from an XML CoT message
15
+ * @class
16
+ *
17
+ * @param cot A string/buffer containing the XML representation or the xml-js object tree
18
+ *
19
+ * @prop raw Raw XML-JS representation of CoT
20
+ */
21
+ export default class CoT {
22
+ raw: Static<typeof JSONCoT>;
23
+ metadata: Record<string, unknown>;
24
+ path: string;
25
+ constructor(cot: Static<typeof JSONCoT>, opts?: CoTOptions);
26
+ /**
27
+ * Returns or sets the UID of the CoT
28
+ */
29
+ uid(uid?: string): string;
30
+ /**
31
+ * Returns or sets the Callsign of the CoT
32
+ */
33
+ type(type?: string): string;
34
+ /**
35
+ * Returns or sets the Archived State of the CoT
36
+ *
37
+ * @param callsign - Optional Archive state to set
38
+ */
39
+ archived(archived?: boolean): boolean;
40
+ /**
41
+ * Returns or sets the Callsign of the CoT
42
+ *
43
+ * @param callsign - Optional Callsign to set
44
+ */
45
+ callsign(callsign?: string): string;
46
+ /**
47
+ * Return Detail Object of CoT or create one if it doesn't yet exist and pass a reference
48
+ */
49
+ detail(): Static<typeof Detail>;
50
+ /**
51
+ * Add a given Dest tag to a CoT
52
+ */
53
+ addDest(dest: Static<typeof MartiDestAttributes>): CoT;
54
+ addVideo(video: Static<typeof VideoAttributes>, connection?: Static<typeof VideoConnectionEntryAttributes>): CoT;
55
+ position(position?: Static<typeof Position>): Static<typeof Position>;
56
+ sensor(sensor?: Static<typeof SensorAttributes>): Static<typeof Polygon> | null;
57
+ creator(creator?: {
58
+ uid: string;
59
+ type: string;
60
+ callsign: string;
61
+ time: Date | string | undefined;
62
+ }): Static<typeof CreatorAttributes> | undefined;
63
+ addLink(link: Static<typeof LinkAttributes>): CoT;
64
+ is_stale(): boolean;
65
+ /**
66
+ * Determines if the CoT message represents a Tasking Message
67
+ *
68
+ * @return {boolean}
69
+ */
70
+ is_tasking(): boolean;
71
+ /**
72
+ * Determines if the CoT message represents a Chat Message
73
+ *
74
+ * @return {boolean}
75
+ */
76
+ is_chat(): boolean;
77
+ /**
78
+ * Determines if the CoT message represents a Friendly Element
79
+ *
80
+ * @return {boolean}
81
+ */
82
+ is_friend(): boolean;
83
+ /**
84
+ * Determines if the CoT message represents a Hostile Element
85
+ *
86
+ * @return {boolean}
87
+ */
88
+ is_hostile(): boolean;
89
+ /**
90
+ * Determines if the CoT message represents a Unknown Element
91
+ *
92
+ * @return {boolean}
93
+ */
94
+ is_unknown(): boolean;
95
+ /**
96
+ * Determines if the CoT message represents a Pending Element
97
+ *
98
+ * @return {boolean}
99
+ */
100
+ is_pending(): boolean;
101
+ /**
102
+ * Determines if the CoT message represents an Assumed Element
103
+ *
104
+ * @return {boolean}
105
+ */
106
+ is_assumed(): boolean;
107
+ /**
108
+ * Determines if the CoT message represents a Neutral Element
109
+ *
110
+ * @return {boolean}
111
+ */
112
+ is_neutral(): boolean;
113
+ /**
114
+ * Determines if the CoT message represents a Suspect Element
115
+ *
116
+ * @return {boolean}
117
+ */
118
+ is_suspect(): boolean;
119
+ /**
120
+ * Determines if the CoT message represents a Joker Element
121
+ *
122
+ * @return {boolean}
123
+ */
124
+ is_joker(): boolean;
125
+ /**
126
+ * Determines if the CoT message represents a Faker Element
127
+ *
128
+ * @return {boolean}
129
+ */
130
+ is_faker(): boolean;
131
+ /**
132
+ * Determines if the CoT message represents an Element
133
+ *
134
+ * @return {boolean}
135
+ */
136
+ is_atom(): boolean;
137
+ /**
138
+ * Determines if the CoT message represents an Airborne Element
139
+ *
140
+ * @return {boolean}
141
+ */
142
+ is_airborne(): boolean;
143
+ /**
144
+ * Determines if the CoT message represents a Ground Element
145
+ *
146
+ * @return {boolean}
147
+ */
148
+ is_ground(): boolean;
149
+ /**
150
+ * Determines if the CoT message represents an Installation
151
+ *
152
+ * @return {boolean}
153
+ */
154
+ is_installation(): boolean;
155
+ /**
156
+ * Determines if the CoT message represents a Vehicle
157
+ *
158
+ * @return {boolean}
159
+ */
160
+ is_vehicle(): boolean;
161
+ /**
162
+ * Determines if the CoT message represents Equipment
163
+ *
164
+ * @return {boolean}
165
+ */
166
+ is_equipment(): boolean;
167
+ /**
168
+ * Determines if the CoT message represents a Surface Element
169
+ *
170
+ * @return {boolean}
171
+ */
172
+ is_surface(): boolean;
173
+ /**
174
+ * Determines if the CoT message represents a Subsurface Element
175
+ *
176
+ * @return {boolean}
177
+ */
178
+ is_subsurface(): boolean;
179
+ /**
180
+ * Determines if the CoT message represents a UAV Element
181
+ *
182
+ * @return {boolean}
183
+ */
184
+ is_uav(): boolean;
185
+ /**
186
+ * Return a CoT Message
187
+ */
188
+ static ping(): CoT;
189
+ }
@@ -0,0 +1,248 @@
1
+ import type { Static } from '@sinclair/typebox';
2
+ import { Readable } from 'node:stream';
3
+ import CoT from './cot.js';
4
+ export declare const Parameter: import("@sinclair/typebox").TObject<{
5
+ _attributes: import("@sinclair/typebox").TObject<{
6
+ name: import("@sinclair/typebox").TString;
7
+ value: import("@sinclair/typebox").TString;
8
+ }>;
9
+ }>;
10
+ export declare const ManifestContent: import("@sinclair/typebox").TObject<{
11
+ _attributes: import("@sinclair/typebox").TObject<{
12
+ ignore: import("@sinclair/typebox").TBoolean;
13
+ zipEntry: import("@sinclair/typebox").TString;
14
+ }>;
15
+ Parameter: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
16
+ _attributes: import("@sinclair/typebox").TObject<{
17
+ name: import("@sinclair/typebox").TString;
18
+ value: import("@sinclair/typebox").TString;
19
+ }>;
20
+ }>, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
21
+ _attributes: import("@sinclair/typebox").TObject<{
22
+ name: import("@sinclair/typebox").TString;
23
+ value: import("@sinclair/typebox").TString;
24
+ }>;
25
+ }>>]>;
26
+ }>;
27
+ export declare const Group: import("@sinclair/typebox").TObject<{
28
+ _attributes: import("@sinclair/typebox").TObject<{
29
+ name: import("@sinclair/typebox").TString;
30
+ }>;
31
+ }>;
32
+ export declare const Permission: import("@sinclair/typebox").TObject<{
33
+ _attributes: import("@sinclair/typebox").TObject<{
34
+ name: import("@sinclair/typebox").TString;
35
+ }>;
36
+ }>;
37
+ export declare const Manifest: import("@sinclair/typebox").TObject<{
38
+ MissionPackageManifest: import("@sinclair/typebox").TObject<{
39
+ _attributes: import("@sinclair/typebox").TObject<{
40
+ version: import("@sinclair/typebox").TString;
41
+ }>;
42
+ Configuration: import("@sinclair/typebox").TObject<{
43
+ Parameter: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
44
+ _attributes: import("@sinclair/typebox").TObject<{
45
+ name: import("@sinclair/typebox").TString;
46
+ value: import("@sinclair/typebox").TString;
47
+ }>;
48
+ }>>;
49
+ }>;
50
+ Contents: import("@sinclair/typebox").TObject<{
51
+ Content: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
52
+ _attributes: import("@sinclair/typebox").TObject<{
53
+ ignore: import("@sinclair/typebox").TBoolean;
54
+ zipEntry: import("@sinclair/typebox").TString;
55
+ }>;
56
+ Parameter: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
57
+ _attributes: import("@sinclair/typebox").TObject<{
58
+ name: import("@sinclair/typebox").TString;
59
+ value: import("@sinclair/typebox").TString;
60
+ }>;
61
+ }>, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
62
+ _attributes: import("@sinclair/typebox").TObject<{
63
+ name: import("@sinclair/typebox").TString;
64
+ value: import("@sinclair/typebox").TString;
65
+ }>;
66
+ }>>]>;
67
+ }>, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
68
+ _attributes: import("@sinclair/typebox").TObject<{
69
+ ignore: import("@sinclair/typebox").TBoolean;
70
+ zipEntry: import("@sinclair/typebox").TString;
71
+ }>;
72
+ Parameter: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
73
+ _attributes: import("@sinclair/typebox").TObject<{
74
+ name: import("@sinclair/typebox").TString;
75
+ value: import("@sinclair/typebox").TString;
76
+ }>;
77
+ }>, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
78
+ _attributes: import("@sinclair/typebox").TObject<{
79
+ name: import("@sinclair/typebox").TString;
80
+ value: import("@sinclair/typebox").TString;
81
+ }>;
82
+ }>>]>;
83
+ }>>]>>;
84
+ }>;
85
+ Groups: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
86
+ group: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
87
+ _attributes: import("@sinclair/typebox").TObject<{
88
+ name: import("@sinclair/typebox").TString;
89
+ }>;
90
+ }>, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
91
+ _attributes: import("@sinclair/typebox").TObject<{
92
+ name: import("@sinclair/typebox").TString;
93
+ }>;
94
+ }>>]>>;
95
+ }>>;
96
+ Role: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
97
+ _attributes: import("@sinclair/typebox").TObject<{
98
+ name: import("@sinclair/typebox").TString;
99
+ }>;
100
+ Permissions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
101
+ _attributes: import("@sinclair/typebox").TObject<{
102
+ name: import("@sinclair/typebox").TString;
103
+ }>;
104
+ }>, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
105
+ _attributes: import("@sinclair/typebox").TObject<{
106
+ name: import("@sinclair/typebox").TString;
107
+ }>;
108
+ }>>]>>;
109
+ }>>;
110
+ }>;
111
+ }>;
112
+ /**
113
+ * Helper class for creating and parsing static Data Packages
114
+ * @class
115
+ *
116
+ * @prop path The local path to the Data Package working directory
117
+ * @prop destroyed Indcates that the DataPackage has been destroyed and all local files removed
118
+ * @prop version DataPackage schema version - 2 is most common
119
+ * @prop contents Array Manifest of DataPackage contents
120
+ * @prop settings Top level DataPackage settings
121
+ */
122
+ export declare class DataPackage {
123
+ #private;
124
+ path: string;
125
+ destroyed: boolean;
126
+ version: string;
127
+ contents: Array<Static<typeof ManifestContent>>;
128
+ settings: {
129
+ uid: string;
130
+ name: string;
131
+ onReceiveImport?: boolean;
132
+ onReceiveDelete?: boolean;
133
+ [k: string]: boolean | string | undefined;
134
+ };
135
+ unknown: Record<string, unknown>;
136
+ /**
137
+ * @constructor
138
+ * @param uid Unique ID of the Data Package
139
+ * @param name Human Readable name of the DataPackage
140
+ * @param opts Optional Options
141
+ */
142
+ constructor(uid?: string, name?: string, opts?: {
143
+ path?: string;
144
+ });
145
+ /**
146
+ * The Package should be imported and then removed
147
+ */
148
+ setEphemeral(): void;
149
+ /**
150
+ * The Package should be imported and the package retained
151
+ */
152
+ setPermanent(): void;
153
+ /**
154
+ * Return a string version of the Manifest document
155
+ */
156
+ manifest(): string;
157
+ /**
158
+ * Mission Sync archived are returned in DataPackage format
159
+ * Return true if the DataPackage is a MissionSync Archive
160
+ */
161
+ isMissionArchive(): boolean;
162
+ /**
163
+ * When DataPackages are uploaded to TAK Server they generally use an EUD
164
+ * calculated Hash
165
+ */
166
+ static hash(path: string): Promise<string>;
167
+ /**
168
+ * When DataPackages are uploaded to TAK Server they generally use an EUD
169
+ * calculated Hash
170
+ */
171
+ hash(entry: string): Promise<string>;
172
+ /**
173
+ * Return a DataPackage version of a raw Data Package Zip
174
+ *
175
+ * @public
176
+ * @param input path to zipped DataPackage on disk
177
+ * @param [opts] Parser Options
178
+ * @param [opts.strict] By default the DataPackage must contain a manifest file, turning strict mode off will generate a manifest based on the contents of the file
179
+ * @param [opts.cleanup] If the Zip is parsed as a DataSync successfully, remove the initial zip file
180
+ */
181
+ static parse(input: string | URL, opts?: {
182
+ strict?: boolean;
183
+ cleanup?: boolean;
184
+ }): Promise<DataPackage>;
185
+ /**
186
+ * Return CoT objects for all CoT type features in the Data Package
187
+ *
188
+ * CoTs have their `attachment_list` field populated if parseAttachments is set to true.
189
+ * While this field is populated automatically by some ATAK actions such as QuickPic
190
+ other attachment actions do not automatically populate this field other than the link
191
+ provided between a CoT and it's attachment in the MANIFEST file
192
+ */
193
+ cots(opts?: {
194
+ respectIgnore: boolean;
195
+ parseAttachments: boolean;
196
+ }): Promise<Array<CoT>>;
197
+ /**
198
+ * Return a list of files that are NOT attachments or CoT markers
199
+ * The Set returned has a list of file paths that can be passed to getFile(path)
200
+ */
201
+ files(opts?: {
202
+ respectIgnore: boolean;
203
+ }): Promise<Set<string>>;
204
+ /**
205
+ * Return attachments that are associated in the Manifest with a given CoT
206
+ * Note: this does not return files that are NOT associated with a CoT
207
+ */
208
+ attachments(opts?: {
209
+ respectIgnore: boolean;
210
+ }): Promise<Map<string, Array<Static<typeof ManifestContent>>>>;
211
+ getFileBuffer(path: string): Promise<Buffer>;
212
+ /**
213
+ * Get any file from a Package
214
+ */
215
+ getFile(path: string): Promise<Readable>;
216
+ /**
217
+ * Add any file to a Package
218
+ *
219
+ * @param file - Input ReadableStream of File at attach
220
+ * @param opts - Options
221
+ * @param opts.uid - Optional UID for the File, a UUID will be generated if not supplied
222
+ * @param opts.name - Filename for the file
223
+ * @param opts.ignore - Should the file be ignore, defaults to false
224
+ * @param opts.attachment - Should the file be associated as an attachment to a CoT. If so this should contain the UID of the CoT
225
+ */
226
+ addFile(file: Readable | Buffer | string, opts: {
227
+ uid?: string;
228
+ name: string;
229
+ ignore?: boolean;
230
+ attachment?: string;
231
+ }): Promise<void>;
232
+ /**
233
+ * Add a CoT marker to the Package
234
+ */
235
+ addCoT(cot: CoT, opts?: {
236
+ ignore: boolean;
237
+ }): Promise<void>;
238
+ /**
239
+ * Destory the underlying FS resources and prevent further mutation
240
+ */
241
+ destroy(): Promise<void>;
242
+ /**
243
+ * Compile the DataPackage into a TAK compatible ZIP File
244
+ * Note this function can be called multiple times and does not
245
+ * affect the ability of the class to continue building a Package
246
+ */
247
+ finalize(): Promise<string>;
248
+ }
@@ -0,0 +1,12 @@
1
+ import type { Static } from '@sinclair/typebox';
2
+ import { InputFeature } from '../types/feature.js';
3
+ import CoT from '../cot.js';
4
+ import type { CoTOptions } from '../cot.js';
5
+ /**
6
+ * Return an CoT Message given a GeoJSON Feature
7
+ *
8
+ * @param {Object} feature GeoJSON Point Feature
9
+ *
10
+ * @return {CoT}
11
+ */
12
+ export declare function from_geojson(feature: Static<typeof InputFeature>, opts?: CoTOptions): Promise<CoT>;
@@ -0,0 +1,11 @@
1
+ import type { Static } from '@sinclair/typebox';
2
+ import { Feature } from '../types/feature.js';
3
+ import { GeoJSONFeature } from '../types/geojson.js';
4
+ /**
5
+ * Given a generic GeoJSON Feature, convert it to a CoT Featurt
6
+ *
7
+ * @param {Object} feature GeoJSON Feature
8
+ *
9
+ * @return {CoT}
10
+ */
11
+ export declare function normalize_geojson(feature: Static<typeof GeoJSONFeature>): Promise<Static<typeof Feature>>;
@@ -76,7 +76,7 @@ export async function normalize_geojson(feature) {
76
76
  stale.setHours(stale.getHours() + 1);
77
77
  feature.properties.stale = stale;
78
78
  feature.properties.center = PointOnFeature(feature).geometry.coordinates;
79
- feature.properties.archived = feature.properties.archived || false;
79
+ feature.properties.archived = true;
80
80
  coordEach(feature.geometry, (coord) => {
81
81
  return coord.slice(0, 3);
82
82
  });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AAa,CAAC,EAAE,CAAC;QAC/C,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;YACvD,OAAO,CAAC,UAAU,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;YAC5C,MAAM;QACV,CAAC;IACL,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAC9B,OAAO,CAAC,UAAU,CAAC,OAAO,GAAG,EAAE,CAAC;IACpC,CAAC;IAED,OAAO,CAAC,UAAU,CAAC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACnD,OAAO,CAAC,UAAU,CAAC,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAEpD,MAAM,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC;IACzB,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC;IACrC,OAAO,CAAC,UAAU,CAAC,KAAK,GAAG,KAAK,CAAC;IAEjC,OAAO,CAAC,UAAU,CAAC,MAAM,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC;IAEzE,OAAO,CAAC,UAAU,CAAC,QAAQ,GAAG,IAAI,CAAC;IAEnC,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;QAClC,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,OAAO,OAAiC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { Static } from '@sinclair/typebox';
2
+ import type { Feature } from '../types/feature.js';
3
+ import CoT from '../cot.js';
4
+ /**
5
+ * Return a GeoJSON Feature from an XML CoT message
6
+ */
7
+ export declare function to_geojson(cot: CoT): Promise<Static<typeof Feature>>;
@@ -0,0 +1,53 @@
1
+ import type { Static } from '@sinclair/typebox';
2
+ import type { Feature } from './types/feature.js';
3
+ import type { GeoJSONFeature } from './types/geojson.js';
4
+ import { InputFeature } from './types/feature.js';
5
+ import CoT from './cot.js';
6
+ import type { CoTOptions } from './cot.js';
7
+ /**
8
+ * Convert to and from an XML CoT message
9
+ * @class
10
+ *
11
+ * @param cot A string/buffer containing the XML representation or the xml-js object tree
12
+ *
13
+ * @prop raw Raw XML-JS representation of CoT
14
+ */
15
+ export declare class CoTParser {
16
+ static validate(cot: CoT, opts?: {
17
+ flow: boolean;
18
+ }): CoT;
19
+ /**
20
+ * Detect difference between CoT messages
21
+ * Note: This diffs based on GeoJSON Representation of message
22
+ * So if unknown properties are present they will be excluded from the diff
23
+ */
24
+ static isDiff(aCoT: CoT, bCoT: CoT, opts?: {
25
+ diffMetadata: boolean;
26
+ diffStaleStartTime: boolean;
27
+ diffDest: boolean;
28
+ diffFlow: boolean;
29
+ }): Promise<boolean>;
30
+ static from_xml(raw: Buffer | string, opts?: CoTOptions): CoT;
31
+ static to_xml(cot: CoT): string;
32
+ /**
33
+ * Return an ATAK Compliant Protobuf
34
+ */
35
+ static to_proto(cot: CoT, version?: number): Promise<Uint8Array>;
36
+ /**
37
+ * Return a GeoJSON Feature from an XML CoT message
38
+ */
39
+ static to_geojson(cot: CoT): Promise<Static<typeof Feature>>;
40
+ /**
41
+ * Parse an ATAK compliant Protobuf to a JS Object
42
+ */
43
+ static from_proto(raw: Uint8Array, version?: number, opts?: CoTOptions): Promise<CoT>;
44
+ static normalize_geojson(feature: Static<typeof GeoJSONFeature>): Promise<Static<typeof Feature>>;
45
+ /**
46
+ * Return an CoT Message given a GeoJSON Feature
47
+ *
48
+ * @param {Object} feature GeoJSON Point Feature
49
+ *
50
+ * @return {CoT}
51
+ */
52
+ static from_geojson(feature: Static<typeof InputFeature>, opts?: CoTOptions): Promise<CoT>;
53
+ }
@@ -0,0 +1,9 @@
1
+ import type { Static } from '@sinclair/typebox';
2
+ import { Position, Polygon } from './types/feature.js';
3
+ import { SensorAttributes } from './types/types.js';
4
+ export default class Sensor {
5
+ center: Static<typeof Position>;
6
+ sensor: Static<typeof SensorAttributes>;
7
+ constructor(center: Static<typeof Position>, sensor: Static<typeof SensorAttributes>);
8
+ to_geojson(): Static<typeof Polygon> | null;
9
+ }
@@ -0,0 +1,10 @@
1
+ import type { Static, TSchema, TUnknown } from '@sinclair/typebox';
2
+ export type TypeOpts = {
3
+ verbose?: boolean;
4
+ default?: boolean;
5
+ convert?: boolean;
6
+ clean?: boolean;
7
+ };
8
+ export default class TypeValidator {
9
+ static type<T extends TSchema = TUnknown>(type: T, body: unknown, opts?: TypeOpts): Static<T>;
10
+ }