UNPKG

@tak-ps/node-cot

Version:

Lightweight JavaScript library for parsing and manipulating TAK messages

249 lines (248 loc) 10.7 kB
import type { Static } from '@sinclair/typebox'; import { Readable } from 'node:stream'; import CoT from './cot.js'; export declare const Parameter: import("@sinclair/typebox").TObject<{ _attributes: import("@sinclair/typebox").TObject<{ name: import("@sinclair/typebox").TString; value: import("@sinclair/typebox").TString; }>; }>; export declare const ManifestContent: import("@sinclair/typebox").TObject<{ _attributes: import("@sinclair/typebox").TObject<{ ignore: import("@sinclair/typebox").TBoolean; zipEntry: import("@sinclair/typebox").TString; }>; Parameter: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{ _attributes: import("@sinclair/typebox").TObject<{ name: import("@sinclair/typebox").TString; value: import("@sinclair/typebox").TString; }>; }>, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{ _attributes: import("@sinclair/typebox").TObject<{ name: import("@sinclair/typebox").TString; value: import("@sinclair/typebox").TString; }>; }>>]>; }>; export declare const Group: import("@sinclair/typebox").TObject<{ _attributes: import("@sinclair/typebox").TObject<{ name: import("@sinclair/typebox").TString; }>; }>; export declare const Permission: import("@sinclair/typebox").TObject<{ _attributes: import("@sinclair/typebox").TObject<{ name: import("@sinclair/typebox").TString; }>; }>; export declare const Manifest: import("@sinclair/typebox").TObject<{ MissionPackageManifest: import("@sinclair/typebox").TObject<{ _attributes: import("@sinclair/typebox").TObject<{ version: import("@sinclair/typebox").TString; }>; Configuration: import("@sinclair/typebox").TObject<{ Parameter: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{ _attributes: import("@sinclair/typebox").TObject<{ name: import("@sinclair/typebox").TString; value: import("@sinclair/typebox").TString; }>; }>>; }>; Contents: import("@sinclair/typebox").TObject<{ Content: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{ _attributes: import("@sinclair/typebox").TObject<{ ignore: import("@sinclair/typebox").TBoolean; zipEntry: import("@sinclair/typebox").TString; }>; Parameter: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{ _attributes: import("@sinclair/typebox").TObject<{ name: import("@sinclair/typebox").TString; value: import("@sinclair/typebox").TString; }>; }>, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{ _attributes: import("@sinclair/typebox").TObject<{ name: import("@sinclair/typebox").TString; value: import("@sinclair/typebox").TString; }>; }>>]>; }>, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{ _attributes: import("@sinclair/typebox").TObject<{ ignore: import("@sinclair/typebox").TBoolean; zipEntry: import("@sinclair/typebox").TString; }>; Parameter: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{ _attributes: import("@sinclair/typebox").TObject<{ name: import("@sinclair/typebox").TString; value: import("@sinclair/typebox").TString; }>; }>, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{ _attributes: import("@sinclair/typebox").TObject<{ name: import("@sinclair/typebox").TString; value: import("@sinclair/typebox").TString; }>; }>>]>; }>>]>>; }>; Groups: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{ group: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{ _attributes: import("@sinclair/typebox").TObject<{ name: import("@sinclair/typebox").TString; }>; }>, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{ _attributes: import("@sinclair/typebox").TObject<{ name: import("@sinclair/typebox").TString; }>; }>>]>>; }>>; Role: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{ _attributes: import("@sinclair/typebox").TObject<{ name: import("@sinclair/typebox").TString; }>; Permissions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{ _attributes: import("@sinclair/typebox").TObject<{ name: import("@sinclair/typebox").TString; }>; }>, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{ _attributes: import("@sinclair/typebox").TObject<{ name: import("@sinclair/typebox").TString; }>; }>>]>>; }>>; }>; }>; /** * Helper class for creating and parsing static Data Packages * @class * * @prop path The local path to the Data Package working directory * @prop destroyed Indcates that the DataPackage has been destroyed and all local files removed * @prop version DataPackage schema version - 2 is most common * @prop contents Array Manifest of DataPackage contents * @prop settings Top level DataPackage settings */ export declare class DataPackage { #private; path: string; destroyed: boolean; version: string; contents: Array<Static<typeof ManifestContent>>; settings: { uid: string; name: string; onReceiveImport?: boolean; onReceiveDelete?: boolean; [k: string]: boolean | string | undefined; }; unknown: Record<string, unknown>; /** * @constructor * @param uid Unique ID of the Data Package * @param name Human Readable name of the DataPackage * @param opts Optional Options */ constructor(uid?: string, name?: string, opts?: { path?: string; }); /** * The Package should be imported and then removed */ setEphemeral(): void; /** * The Package should be imported and the package retained */ setPermanent(): void; /** * Return a string version of the Manifest document */ manifest(): string; /** * Mission Sync archived are returned in DataPackage format * Return true if the DataPackage is a MissionSync Archive */ isMissionArchive(): boolean; /** * When DataPackages are uploaded to TAK Server they generally use an EUD * calculated Hash */ static hash(path: string): Promise<string>; /** * When DataPackages are uploaded to TAK Server they generally use an EUD * calculated Hash */ hash(entry: string): Promise<string>; /** * Return a DataPackage version of a raw Data Package Zip * * @public * @param input path to zipped DataPackage on disk * @param [opts] Parser Options * @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 * @param [opts.cleanup] If the Zip is parsed as a DataSync successfully, remove the initial zip file */ static parse(input: string | URL, opts?: { strict?: boolean; cleanup?: boolean; }): Promise<DataPackage>; /** * Return CoT objects for all CoT type features in the Data Package * * CoTs have their `attachment_list` field populated if parseAttachments is set to true. * While this field is populated automatically by some ATAK actions such as QuickPic other attachment actions do not automatically populate this field other than the link provided between a CoT and it's attachment in the MANIFEST file */ cots(opts?: { respectIgnore: boolean; parseAttachments: boolean; }): Promise<Array<CoT>>; /** * Return a list of files that are NOT attachments or CoT markers * The Set returned has a list of file paths that can be passed to getFile(path) */ files(opts?: { respectIgnore: boolean; }): Promise<Set<string>>; /** * Return attachments that are associated in the Manifest with a given CoT * Note: this does not return files that are NOT associated with a CoT */ attachments(opts?: { respectIgnore: boolean; }): Promise<Map<string, Array<Static<typeof ManifestContent>>>>; getFileBuffer(path: string): Promise<Buffer>; /** * Get any file from a Package */ getFile(path: string): Promise<Readable>; /** * Add any file to a Package * * @param file - Input ReadableStream of File at attach * @param opts - Options * @param opts.uid - Optional UID for the File, a UUID will be generated if not supplied * @param opts.name - Filename for the file * @param opts.ignore - Should the file be ignore, defaults to false * @param opts.attachment - Should the file be associated as an attachment to a CoT. If so this should contain the UID of the CoT */ addFile(file: Readable | Buffer | string, opts: { uid?: string; name: string; ignore?: boolean; attachment?: string; }): Promise<void>; /** * Add a CoT marker to the Package */ addCoT(cot: CoT, opts?: { ignore: boolean; }): Promise<void>; /** * Destory the underlying FS resources and prevent further mutation */ destroy(): Promise<void>; /** * Compile the DataPackage into a TAK compatible ZIP File * Note this function can be called multiple times and does not * affect the ability of the class to continue building a Package */ finalize(): Promise<string>; }