@tak-ps/node-tak
Version:
Lightweight JavaScript library for communicating with TAK Server
44 lines • 1.34 kB
JavaScript
import { Type } from '@sinclair/typebox';
import Commands, { CommandOutputFormat } from '../commands.js';
export const Contact = Type.Object({
filterGroups: Type.Any(), // I'm not familiar with this one
notes: Type.String(),
callsign: Type.String(),
team: Type.String(),
role: Type.String(),
takv: Type.String(),
uid: Type.String()
});
export default class ContactCommands extends Commands {
schema = {
list: {
description: 'List Contacts',
params: Type.Object({}),
query: Type.Object({}),
formats: [CommandOutputFormat.JSON]
}
};
async cli(args) {
if (args._[3] === 'list') {
const list = await this.list();
if (args.format === 'json') {
return list;
}
else {
return list.map((contact) => {
return `${contact.callsign || '<No Callsign Set>'} (${contact.notes.trim()})`;
}).join('\n');
}
}
else {
throw new Error('Unsupported Subcommand');
}
}
async list() {
const url = new URL(`/Marti/api/contacts/all`, this.api.url);
return await this.api.fetch(url, {
method: 'GET'
});
}
}
//# sourceMappingURL=contacts.js.map