UNPKG

@tak-ps/node-cot

Version:

Lightweight JavaScript library for parsing and manipulating TAK messages

190 lines (189 loc) 5.05 kB
import type { Static } from '@sinclair/typebox'; import type { Polygon, Position } from './types/feature.js'; import type { MartiDestAttributes, LinkAttributes, CreatorAttributes, VideoAttributes, SensorAttributes, VideoConnectionEntryAttributes } from './types/types.js'; import JSONCoT, { Detail } from './types/types.js'; export type CoTOptions = { creator?: CoT | { uid: string; type: string; callsign: string; time?: Date | string; }; }; /** * Convert to and from an XML CoT message * @class * * @param cot A string/buffer containing the XML representation or the xml-js object tree * * @prop raw Raw XML-JS representation of CoT */ export default class CoT { raw: Static<typeof JSONCoT>; metadata: Record<string, unknown>; path: string; constructor(cot: Static<typeof JSONCoT>, opts?: CoTOptions); /** * Returns or sets the UID of the CoT */ uid(uid?: string): string; /** * Returns or sets the Callsign of the CoT */ type(type?: string): string; /** * Returns or sets the Archived State of the CoT * * @param callsign - Optional Archive state to set */ archived(archived?: boolean): boolean; /** * Returns or sets the Callsign of the CoT * * @param callsign - Optional Callsign to set */ callsign(callsign?: string): string; /** * Return Detail Object of CoT or create one if it doesn't yet exist and pass a reference */ detail(): Static<typeof Detail>; /** * Add a given Dest tag to a CoT */ addDest(dest: Static<typeof MartiDestAttributes>): CoT; addVideo(video: Static<typeof VideoAttributes>, connection?: Static<typeof VideoConnectionEntryAttributes>): CoT; position(position?: Static<typeof Position>): Static<typeof Position>; sensor(sensor?: Static<typeof SensorAttributes>): Static<typeof Polygon> | null; creator(creator?: { uid: string; type: string; callsign: string; time: Date | string | undefined; }): Static<typeof CreatorAttributes> | undefined; addLink(link: Static<typeof LinkAttributes>): CoT; is_stale(): boolean; /** * Determines if the CoT message represents a Tasking Message * * @return {boolean} */ is_tasking(): boolean; /** * Determines if the CoT message represents a Chat Message * * @return {boolean} */ is_chat(): boolean; /** * Determines if the CoT message represents a Friendly Element * * @return {boolean} */ is_friend(): boolean; /** * Determines if the CoT message represents a Hostile Element * * @return {boolean} */ is_hostile(): boolean; /** * Determines if the CoT message represents a Unknown Element * * @return {boolean} */ is_unknown(): boolean; /** * Determines if the CoT message represents a Pending Element * * @return {boolean} */ is_pending(): boolean; /** * Determines if the CoT message represents an Assumed Element * * @return {boolean} */ is_assumed(): boolean; /** * Determines if the CoT message represents a Neutral Element * * @return {boolean} */ is_neutral(): boolean; /** * Determines if the CoT message represents a Suspect Element * * @return {boolean} */ is_suspect(): boolean; /** * Determines if the CoT message represents a Joker Element * * @return {boolean} */ is_joker(): boolean; /** * Determines if the CoT message represents a Faker Element * * @return {boolean} */ is_faker(): boolean; /** * Determines if the CoT message represents an Element * * @return {boolean} */ is_atom(): boolean; /** * Determines if the CoT message represents an Airborne Element * * @return {boolean} */ is_airborne(): boolean; /** * Determines if the CoT message represents a Ground Element * * @return {boolean} */ is_ground(): boolean; /** * Determines if the CoT message represents an Installation * * @return {boolean} */ is_installation(): boolean; /** * Determines if the CoT message represents a Vehicle * * @return {boolean} */ is_vehicle(): boolean; /** * Determines if the CoT message represents Equipment * * @return {boolean} */ is_equipment(): boolean; /** * Determines if the CoT message represents a Surface Element * * @return {boolean} */ is_surface(): boolean; /** * Determines if the CoT message represents a Subsurface Element * * @return {boolean} */ is_subsurface(): boolean; /** * Determines if the CoT message represents a UAV Element * * @return {boolean} */ is_uav(): boolean; /** * Return a CoT Message */ static ping(): CoT; }