Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion api/lib/connection-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,12 @@ export default class ConnectionPool extends Map<number | string, ConnectionClien
key: connConfig.auth.key,
cert: connConfig.auth.cert,
},{
id: connConfig.id
id: connConfig.id,
cot: {
milsym: {
augment: true
}
}
});

const connClient = new ConnectionClient(connConfig, tak);
Expand Down
18 changes: 13 additions & 5 deletions api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"jsonata": "^2.0.1",
"jsonwebtoken": "^9.0.0",
"memjs": "^1.3.0",
"milstandard-e": "^0.2.14",
"mime": "^4.0.1",
"minimist": "^1.2.7",
"moment": "^2.29.4",
Expand Down Expand Up @@ -125,4 +126,4 @@
"typescript": "^5.0.0",
"typescript-eslint": "^8.0.0"
}
}
}
90 changes: 86 additions & 4 deletions api/routes/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Err from '@openaddresses/batch-error';
import { ms2525e } from 'milstandard-e';
import Auth from '../lib/auth.js';
import Config from '../lib/config.js';
import Schema from '@openaddresses/batch-schema';
Expand All @@ -7,12 +8,57 @@ import { CoTTypes } from '@tak-ps/node-cot';
import { MilSymType } from '@tak-ps/node-cot';
import * as Default from '../lib/limits.js';

// 2525E Symbols
// <version>-<context>-<standard identity>-<symbol set>-<status>-<hq/task force/dummy>-<modifier>-<6: entity>-<2: mod1>-<2: mod2>
// Context:
// 0: Reality
// 1: Exercise
// 2: Simulation

const symbolsets: Array<{
id: string;
name: string;
}> = [];

const symbols: Array<{
id: string,
name: string,
remarks: string,
symbolset: string,
}> = [];


for (const symbolset of Object.keys(ms2525e)) {
symbolsets.push({
id: symbolset,
name: ms2525e[symbolset].name
});

for (const mainIcon of ms2525e[symbolset].mainIcon) {
let name = mainIcon.Entity
if (mainIcon["Entity Type"]) {
name += ` - ${mainIcon["Entity Type"]}`;
}

if (mainIcon["Entity Subtype"]) {
name += ` - ${mainIcon["Entity Subtype"]}`;
}

symbols.push({
id: mainIcon.Code,
name,
remarks: mainIcon.Remarks || '',
symbolset
});
}
}

export default async function router(schema: Schema, config: Config) {
const types = await CoTTypes.default.load();

await schema.get('/type/cot', {
name: 'List Types',
group: 'COTTypes',
name: '2525B/ CoT Types',
group: 'Symbology',
description: 'Get Type',
query: Type.Object({
filter: Type.String({
Expand Down Expand Up @@ -46,8 +92,8 @@ export default async function router(schema: Schema, config: Config) {
});

await schema.get('/type/cot/:type', {
name: 'Get Type',
group: 'COTTypes',
name: '2525B/ CoT Type',
group: 'Symbology',
description: 'Get Type',
params: Type.Object({
type: Type.String()
Expand Down Expand Up @@ -90,4 +136,40 @@ export default async function router(schema: Schema, config: Config) {
Err.respond(err, res);
}
});

await schema.get('/type/2525e', {
name: '2525E Types',
group: 'Symbology',
description: 'Get Type',
query: Type.Object({
filter: Type.String({
default: '',
}),
}),
res: Type.Object({
symbolsets: Type.Array(Type.Object({
id: Type.String(),
name: Type.String(),
})),
items: Type.Array(Type.Object({
id: Type.String(),
name: Type.String(),
remarks: Type.String(),
symbolset: Type.String(),
})),
})
}, async (req, res) => {
try {
await Auth.is_auth(config, req);

res.json({
symbolsets,
items: symbols.filter((symbol) => {
return symbol.name.toLowerCase().includes(req.query.filter.toLowerCase())
})
});
} catch (err) {
Err.respond(err, res);
}
});
}
Loading
Loading