@tak-ps/node-tak 12.30.0 → 12.31.0

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,6 +12,10 @@
12
12
 
13
13
  ### Pending
14
14
 
15
+ ### v12.31.0 - 2026-09-29
16
+
17
+ - :tada: Add `MissionProperty` API module for TAK Server 5.9+ Mission key/value properties (`list` with optional `prefix`, `get`, `set` (upsert), `delete`, `deleteAll`)
18
+
15
19
  ### v12.30.0 - 2026-09-04
16
20
 
17
21
  - :tada: Add `UserManagement` API module & `tak user-management` CLI command implementing the File User Account Management API (`createUser`, `createUsers`, `listUsers`, `userGroups`, `changePassword`, `updateUserGroups`, `updateGroupUsers`, `deleteUser`, `listGroups`, `groupUsers`)
@@ -0,0 +1,65 @@
1
+ import { Static } from '@sinclair/typebox';
2
+ import type { MissionOptions } from './mission.js';
3
+ import Commands from '../commands.js';
4
+ export declare const MissionProperty: import("@sinclair/typebox").TObject<{
5
+ key: import("@sinclair/typebox").TString;
6
+ value: import("@sinclair/typebox").TString;
7
+ }>;
8
+ export declare const MissionPropertyListInput: import("@sinclair/typebox").TObject<{
9
+ prefix: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
10
+ }>;
11
+ export declare const SetMissionProperty: import("@sinclair/typebox").TObject<{
12
+ key: import("@sinclair/typebox").TString;
13
+ value: import("@sinclair/typebox").TString;
14
+ creatorUid: import("@sinclair/typebox").TString;
15
+ }>;
16
+ export declare const TAKItem_MissionProperty: import("@sinclair/typebox").TObject<{
17
+ version: import("@sinclair/typebox").TString;
18
+ type: import("@sinclair/typebox").TString;
19
+ data: import("@sinclair/typebox").TObject<{
20
+ key: import("@sinclair/typebox").TString;
21
+ value: import("@sinclair/typebox").TString;
22
+ }>;
23
+ messages: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
24
+ nodeId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
25
+ }>;
26
+ export declare const TAKList_MissionProperty: import("@sinclair/typebox").TObject<{
27
+ version: import("@sinclair/typebox").TString;
28
+ type: import("@sinclair/typebox").TString;
29
+ data: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
30
+ key: import("@sinclair/typebox").TString;
31
+ value: import("@sinclair/typebox").TString;
32
+ }>>;
33
+ messages: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
34
+ nodeId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
35
+ }>;
36
+ /**
37
+ * Key/Value properties stored on a Mission Sync
38
+ *
39
+ * Requires TAK Server 5.9 or later
40
+ */
41
+ export default class MissionPropertyCommands extends Commands {
42
+ #private;
43
+ schema: {};
44
+ cli(): Promise<object | string>;
45
+ /**
46
+ * List properties on a Mission Sync, optionally filtered by key prefix
47
+ */
48
+ list(mission: string, query?: Static<typeof MissionPropertyListInput>, opts?: Static<typeof MissionOptions>): Promise<Static<typeof TAKList_MissionProperty>>;
49
+ /**
50
+ * Get a single property on a Mission Sync
51
+ */
52
+ get(mission: string, key: string, opts?: Static<typeof MissionOptions>): Promise<Static<typeof TAKItem_MissionProperty>>;
53
+ /**
54
+ * Create or update (upsert) a property on a Mission Sync
55
+ */
56
+ set(mission: string, body: Static<typeof SetMissionProperty>, opts?: Static<typeof MissionOptions>): Promise<Static<typeof TAKItem_MissionProperty>>;
57
+ /**
58
+ * Delete a single property on a Mission Sync
59
+ */
60
+ delete(mission: string, key: string, creatorUid: string, opts?: Static<typeof MissionOptions>): Promise<void>;
61
+ /**
62
+ * Delete all properties on a Mission Sync
63
+ */
64
+ deleteAll(mission: string, creatorUid: string, opts?: Static<typeof MissionOptions>): Promise<void>;
65
+ }
@@ -0,0 +1,114 @@
1
+ import { Type } from '@sinclair/typebox';
2
+ import { TAKItem, TAKList } from './types.js';
3
+ import Commands from '../commands.js';
4
+ import { GUIDMatch } from './mission.js';
5
+ export const MissionProperty = Type.Object({
6
+ key: Type.String(),
7
+ value: Type.String()
8
+ });
9
+ export const MissionPropertyListInput = Type.Object({
10
+ prefix: Type.Optional(Type.String({
11
+ description: 'Only return properties whose key starts with this prefix'
12
+ }))
13
+ });
14
+ export const SetMissionProperty = Type.Object({
15
+ key: Type.String(),
16
+ value: Type.String(),
17
+ creatorUid: Type.String()
18
+ });
19
+ export const TAKItem_MissionProperty = TAKItem(MissionProperty);
20
+ export const TAKList_MissionProperty = TAKList(MissionProperty);
21
+ /**
22
+ * Key/Value properties stored on a Mission Sync
23
+ *
24
+ * Requires TAK Server 5.9 or later
25
+ */
26
+ export default class MissionPropertyCommands extends Commands {
27
+ schema = {};
28
+ async cli() {
29
+ throw new Error('Unsupported Subcommand');
30
+ }
31
+ #headers(opts) {
32
+ if (opts && opts.token) {
33
+ return {
34
+ MissionAuthorization: `Bearer ${opts.token}`
35
+ };
36
+ }
37
+ else {
38
+ return {};
39
+ }
40
+ }
41
+ /**
42
+ * Property endpoints are only exposed by GUID, resolve a Mission name if needed
43
+ */
44
+ async #guid(mission, opts) {
45
+ if (GUIDMatch.test(mission))
46
+ return mission;
47
+ return (await this.api.Mission.get(mission, {}, opts)).guid;
48
+ }
49
+ /**
50
+ * List properties on a Mission Sync, optionally filtered by key prefix
51
+ */
52
+ async list(mission, query = {}, opts) {
53
+ const guid = await this.#guid(mission, opts);
54
+ const url = new URL(`/Marti/api/missions/guid/${encodeURIComponent(guid)}/properties`, this.api.url);
55
+ if (query.prefix !== undefined)
56
+ url.searchParams.append('prefix', query.prefix);
57
+ return await this.api.fetch(url, {
58
+ method: 'GET',
59
+ headers: this.#headers(opts)
60
+ });
61
+ }
62
+ /**
63
+ * Get a single property on a Mission Sync
64
+ */
65
+ async get(mission, key, opts) {
66
+ const guid = await this.#guid(mission, opts);
67
+ const url = new URL(`/Marti/api/missions/guid/${encodeURIComponent(guid)}/properties/${encodeURIComponent(key)}`, this.api.url);
68
+ return await this.api.fetch(url, {
69
+ method: 'GET',
70
+ headers: this.#headers(opts)
71
+ });
72
+ }
73
+ /**
74
+ * Create or update (upsert) a property on a Mission Sync
75
+ */
76
+ async set(mission, body, opts) {
77
+ const guid = await this.#guid(mission, opts);
78
+ const url = new URL(`/Marti/api/missions/guid/${encodeURIComponent(guid)}/properties`, this.api.url);
79
+ url.searchParams.append('creatorUid', body.creatorUid);
80
+ return await this.api.fetch(url, {
81
+ method: 'PUT',
82
+ headers: this.#headers(opts),
83
+ body: {
84
+ key: body.key,
85
+ value: body.value
86
+ }
87
+ });
88
+ }
89
+ /**
90
+ * Delete a single property on a Mission Sync
91
+ */
92
+ async delete(mission, key, creatorUid, opts) {
93
+ const guid = await this.#guid(mission, opts);
94
+ const url = new URL(`/Marti/api/missions/guid/${encodeURIComponent(guid)}/properties/${encodeURIComponent(key)}`, this.api.url);
95
+ url.searchParams.append('creatorUid', creatorUid);
96
+ await this.api.fetch(url, {
97
+ method: 'DELETE',
98
+ headers: this.#headers(opts)
99
+ });
100
+ }
101
+ /**
102
+ * Delete all properties on a Mission Sync
103
+ */
104
+ async deleteAll(mission, creatorUid, opts) {
105
+ const guid = await this.#guid(mission, opts);
106
+ const url = new URL(`/Marti/api/missions/guid/${encodeURIComponent(guid)}/properties`, this.api.url);
107
+ url.searchParams.append('creatorUid', creatorUid);
108
+ await this.api.fetch(url, {
109
+ method: 'DELETE',
110
+ headers: this.#headers(opts)
111
+ });
112
+ }
113
+ }
114
+ //# sourceMappingURL=mission-property.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mission-property.js","sourceRoot":"","sources":["../../../lib/api/mission-property.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAU,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,CAAC,MAA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ACH,KAAK,CAAC,SAAS,CACX,OAAe,EACf,UAAkB,EAClB,IAAoC;QAEpC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC7C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,4BAA4B,kBAAkB,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACrG,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;QAElD,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE;YACtB,MAAM,EAAE,QAAQ;YAChB,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;SAC/B,CAAC,CAAC;IACP,CAAC;CACJ"}
package/dist/lib/api.d.ts CHANGED
@@ -6,6 +6,7 @@ import Locate from './api/locate.js';
6
6
  import Mission, { MissionSubscriberRole } from './api/mission.js';
7
7
  import MissionInvite, { MissionInviteType } from './api/mission-invite.js';
8
8
  import MissionLog from './api/mission-log.js';
9
+ import MissionProperty from './api/mission-property.js';
9
10
  import MissionLayer, { MissionLayerType } from './api/mission-layer.js';
10
11
  import Credentials from './api/credentials.js';
11
12
  import Security from './api/security.js';
@@ -37,6 +38,7 @@ export default class TAKAPI {
37
38
  Iconsets: Iconsets;
38
39
  Mission: Mission;
39
40
  MissionLog: MissionLog;
41
+ MissionProperty: MissionProperty;
40
42
  MissionInvite: MissionInvite;
41
43
  MissionLayer: MissionLayer;
42
44
  Credentials: Credentials;
@@ -64,4 +66,4 @@ export default class TAKAPI {
64
66
  */
65
67
  fetch(url: URL, opts?: any, raw?: boolean): Promise<any>;
66
68
  }
67
- export { OAuth, Package, Certificate, Query, Locate, Mission, MissionInvite, MissionLog, MissionLayer, Client, Credentials, Security, Contacts, Profile, Files, Iconsets, Injectors, Repeater, Group, Subscription, Video, Export, UserManagement, MissionSubscriberRole, MissionLayerType, MissionInviteType };
69
+ export { OAuth, Package, Certificate, Query, Locate, Mission, MissionInvite, MissionLog, MissionProperty, MissionLayer, Client, Credentials, Security, Contacts, Profile, Files, Iconsets, Injectors, Repeater, Group, Subscription, Video, Export, UserManagement, MissionSubscriberRole, MissionLayerType, MissionInviteType };
package/dist/lib/api.js CHANGED
@@ -6,6 +6,7 @@ import Locate from './api/locate.js';
6
6
  import Mission, { MissionSubscriberRole } from './api/mission.js';
7
7
  import MissionInvite, { MissionInviteType } from './api/mission-invite.js';
8
8
  import MissionLog from './api/mission-log.js';
9
+ import MissionProperty from './api/mission-property.js';
9
10
  import MissionLayer, { MissionLayerType } from './api/mission-layer.js';
10
11
  import Credentials from './api/credentials.js';
11
12
  import Security from './api/security.js';
@@ -64,6 +65,7 @@ export const CommandList = {
64
65
  mission: 'Mission',
65
66
  'mission-invite': 'MissionInvite',
66
67
  'mission-log': 'MissionLog',
68
+ 'mission-property': 'MissionProperty',
67
69
  'mission-layer': 'MissionLayer',
68
70
  credential: 'Credentials',
69
71
  certificate: 'Certificate',
@@ -94,6 +96,7 @@ export default class TAKAPI {
94
96
  Iconsets;
95
97
  Mission;
96
98
  MissionLog;
99
+ MissionProperty;
97
100
  MissionInvite;
98
101
  MissionLayer;
99
102
  Credentials;
@@ -124,6 +127,7 @@ export default class TAKAPI {
124
127
  this.Iconsets = new Iconsets(this);
125
128
  this.Mission = new Mission(this);
126
129
  this.MissionLog = new MissionLog(this);
130
+ this.MissionProperty = new MissionProperty(this);
127
131
  this.MissionInvite = new MissionInvite(this);
128
132
  this.MissionLayer = new MissionLayer(this);
129
133
  this.Client = new Client(this);
@@ -211,5 +215,5 @@ export default class TAKAPI {
211
215
  function isPlainObject(value) {
212
216
  return value?.constructor === Object;
213
217
  }
214
- export { OAuth, Package, Certificate, Query, Locate, Mission, MissionInvite, MissionLog, MissionLayer, Client, Credentials, Security, Contacts, Profile, Files, Iconsets, Injectors, Repeater, Group, Subscription, Video, Export, UserManagement, MissionSubscriberRole, MissionLayerType, MissionInviteType };
218
+ export { OAuth, Package, Certificate, Query, Locate, Mission, MissionInvite, MissionLog, MissionProperty, MissionLayer, Client, Credentials, Security, Contacts, Profile, Files, Iconsets, Injectors, Repeater, Group, Subscription, Video, Export, UserManagement, MissionSubscriberRole, MissionLayerType, MissionInviteType };
215
219
  //# sourceMappingURL=api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../../lib/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,gBAAgB,CAAC;AACnC,OAAO,OAAO,MAAM,kBAAkB,CAAC;AACvC,OAAO,WAAW,MAAM,sBAAsB,CAAC;AAC/C,OAAO,KAAK,MAAM,gBAAgB,CAAC;AACnC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,OAAO,EAAE,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,aAAa,EAAE,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAC9C,OAAO,YAAY,EAAE,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,WAAW,MAAM,sBAAsB,CAAC;AAC/C,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,OAAO,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,MAAM,gBAAgB,CAAC;AACnC,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAC3C,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAClD,OAAO,KAAK,MAAM,gBAAgB,CAAC;AACnC,OAAO,MAAM,MAAM,iBAA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EAAE,GAAG,IAAI,gBAAgB,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;YACzE,CAAC;YAED,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,KAAK,kBAAkB,EAAE,CAAC;gBACzD,OAAO,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;YAC5B,CAAC;iBAAM,CAAC;gBACJ,OAAO,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;YAC5B,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,IAAI,GAAG,YAAY,GAAG;gBAAE,MAAM,GAAG,CAAC;YAClC,MAAM,IAAI,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC;QACpD,CAAC;IACL,CAAC;CACJ;AAED,SAAS,aAAa,CAAC,KAAa;IAChC,OAAQ,KAAK,EAAE,WAAW,KAAK,MAAM,CAAC;AAC1C,CAAC;AAED,OAAO,EACH,KAAK,EACL,OAAO,EACP,WAAW,EACX,KAAK,EACL,MAAM,EACN,OAAO,EACP,aAAa,EACb,UAAU,EACV,eAAe,EACf,YAAY,EACZ,MAAM,EACN,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,KAAK,EACL,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,KAAK,EACL,YAAY,EACZ,KAAK,EACL,MAAM,EACN,cAAc,EACd,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACpB,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,73 @@
1
+ import test from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { Readable } from 'node:stream';
4
+ import { Client } from 'undici';
5
+ import TAKAPI from '../lib/api.js';
6
+ import { APIAuthCertificate } from '../lib/auth.js';
7
+ const GUID = '9ba05e1d-970f-49e1-a153-7216fecf5279';
8
+ function mockResponse(statusCode, contentType, body) {
9
+ return {
10
+ statusCode,
11
+ headers: { 'content-type': contentType },
12
+ body: Readable.from([Buffer.from(body)]),
13
+ trailers: {}
14
+ };
15
+ }
16
+ async function capture(response, fn) {
17
+ const originalRequest = Client.prototype.request;
18
+ const requests = [];
19
+ Client.prototype.request = async function (opts) {
20
+ requests.push(opts);
21
+ return mockResponse(200, response ? 'application/json' : 'text/plain', response);
22
+ };
23
+ try {
24
+ const api = new TAKAPI(new URL('https://tak.example.com'), new APIAuthCertificate('cert', 'key'));
25
+ const result = await fn(api);
26
+ return { requests, result };
27
+ }
28
+ finally {
29
+ Client.prototype.request = originalRequest;
30
+ }
31
+ }
32
+ const ITEM = JSON.stringify({ version: '3', type: 'com.bbn.marti.sync.model.MissionProperty', data: { key: 'test.hello', value: 'world' } });
33
+ const LIST = JSON.stringify({ version: '3', type: 'com.bbn.marti.sync.model.MissionProperty', data: [{ key: 'test.hello', value: 'world' }] });
34
+ test('MissionProperty.list uses the guid properties endpoint with a prefix filter', async () => {
35
+ const { requests, result } = await capture(LIST, (api) => api.MissionProperty.list(GUID, { prefix: 'test.' }));
36
+ assert.equal(requests.length, 1);
37
+ assert.equal(requests[0].method, 'GET');
38
+ assert.equal(requests[0].path, `/Marti/api/missions/guid/${GUID}/properties?prefix=test.`);
39
+ assert.deepEqual(result.data, [{ key: 'test.hello', value: 'world' }]);
40
+ });
41
+ test('MissionProperty.get encodes the key in the path', async () => {
42
+ const { requests } = await capture(ITEM, (api) => api.MissionProperty.get(GUID, 'a b'));
43
+ assert.equal(requests[0].method, 'GET');
44
+ assert.equal(requests[0].path, `/Marti/api/missions/guid/${GUID}/properties/a%20b`);
45
+ });
46
+ test('MissionProperty.set PUTs key/value with creatorUid as a query param', async () => {
47
+ const { requests } = await capture(ITEM, (api) => api.MissionProperty.set(GUID, {
48
+ key: 'test.hello',
49
+ value: 'world',
50
+ creatorUid: 'alice'
51
+ }));
52
+ assert.equal(requests[0].method, 'PUT');
53
+ assert.equal(requests[0].path, `/Marti/api/missions/guid/${GUID}/properties?creatorUid=alice`);
54
+ assert.deepEqual(JSON.parse(String(requests[0].body)), { key: 'test.hello', value: 'world' });
55
+ });
56
+ test('MissionProperty.delete removes a single key', async () => {
57
+ const { requests } = await capture('', (api) => api.MissionProperty.delete(GUID, 'test.hello', 'alice'));
58
+ assert.equal(requests[0].method, 'DELETE');
59
+ assert.equal(requests[0].path, `/Marti/api/missions/guid/${GUID}/properties/test.hello?creatorUid=alice`);
60
+ });
61
+ test('MissionProperty.deleteAll removes every key', async () => {
62
+ const { requests } = await capture('', (api) => api.MissionProperty.deleteAll(GUID, 'alice'));
63
+ assert.equal(requests[0].method, 'DELETE');
64
+ assert.equal(requests[0].path, `/Marti/api/missions/guid/${GUID}/properties?creatorUid=alice`);
65
+ });
66
+ test('MissionProperty resolves a mission name to its GUID first', async () => {
67
+ const MISSION = JSON.stringify({ version: '3', type: 'Mission', data: [{ name: 'kv-test', guid: GUID }] });
68
+ const { requests } = await capture(MISSION, (api) => api.MissionProperty.list('kv-test'));
69
+ assert.equal(requests.length, 2);
70
+ assert.equal(requests[0].path, '/Marti/api/missions/kv-test');
71
+ assert.equal(requests[1].path, `/Marti/api/missions/guid/${GUID}/properties`);
72
+ });
73
+ //# sourceMappingURL=mission-property.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mission-property.test.js","sourceRoot":"","sources":["../../test/mission-property.test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,MAAM,MAAM,eAAe,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAIpD,MAAM,IAAI,GAAG,sCAAsC,CAAC;AAEpD,SAAS,YAAY,CAAC,UAAkB,EAAE,WAAmB,EAAE,IAAY;IACvE,OAAO;QACH,UAAU;QAC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AAE;IAC3D,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,OAAO,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IAE9F,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC3C,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,4BAA4B,IAAI,8BAA8B,CAAC,CAAC;AACnG,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,2DAA2D,EAAE,KAAK,IAAI,EAAE;IACzE,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;IAC3G,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAE1F,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACjC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,6BAA6B,CAAC,CAAC;IAC9D,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,4BAA4B,IAAI,aAAa,CAAC,CAAC;AAClF,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"root":["../cli.ts","../index.ts","../test/certificate.test.ts","../test/default.test.ts","../test/findCoT.test.ts","../test/html-error.test.ts","../test/mission-layer.test.ts","../test/mission.test.ts","../test/pipeline.test.ts","../test/queue.test.ts","../test/uploadPackage.test.ts","../test/user-management.test.ts","../lib/api.ts","../lib/auth.ts","../lib/commands.ts","../lib/fetch.ts","../lib/multipart.ts","../lib/stream.ts","../lib/api/certificate.ts","../lib/api/client.ts","../lib/api/contacts.ts","../lib/api/credentials.ts","../lib/api/export.ts","../lib/api/files.ts","../lib/api/groups.ts","../lib/api/iconsets.ts","../lib/api/injectors.ts","../lib/api/locate.ts","../lib/api/mission-invite.ts","../lib/api/mission-layer.ts","../lib/api/mission-log.ts","../lib/api/mission.ts","../lib/api/oauth.ts","../lib/api/package.ts","../lib/api/profile.ts","../lib/api/query.ts","../lib/api/repeater.ts","../lib/api/security.ts","../lib/api/subscriptions.ts","../lib/api/types.ts","../lib/api/user-management.ts","../lib/api/video.ts","../lib/utils/html-error.ts","../lib/utils/queue.ts"],"version":"6.0.3"}
1
+ {"root":["../cli.ts","../index.ts","../test/certificate.test.ts","../test/default.test.ts","../test/findCoT.test.ts","../test/html-error.test.ts","../test/mission-layer.test.ts","../test/mission-property.test.ts","../test/mission.test.ts","../test/pipeline.test.ts","../test/queue.test.ts","../test/uploadPackage.test.ts","../test/user-management.test.ts","../lib/api.ts","../lib/auth.ts","../lib/commands.ts","../lib/fetch.ts","../lib/multipart.ts","../lib/stream.ts","../lib/api/certificate.ts","../lib/api/client.ts","../lib/api/contacts.ts","../lib/api/credentials.ts","../lib/api/export.ts","../lib/api/files.ts","../lib/api/groups.ts","../lib/api/iconsets.ts","../lib/api/injectors.ts","../lib/api/locate.ts","../lib/api/mission-invite.ts","../lib/api/mission-layer.ts","../lib/api/mission-log.ts","../lib/api/mission-property.ts","../lib/api/mission.ts","../lib/api/oauth.ts","../lib/api/package.ts","../lib/api/profile.ts","../lib/api/query.ts","../lib/api/repeater.ts","../lib/api/security.ts","../lib/api/subscriptions.ts","../lib/api/types.ts","../lib/api/user-management.ts","../lib/api/video.ts","../lib/utils/html-error.ts","../lib/utils/queue.ts"],"version":"6.0.3"}
@@ -0,0 +1,155 @@
1
+ import { Type, Static } from '@sinclair/typebox';
2
+ import { TAKItem, TAKList } from './types.js';
3
+ import type { MissionOptions } from './mission.js';
4
+ import Commands from '../commands.js';
5
+ import { GUIDMatch } from './mission.js';
6
+
7
+ export const MissionProperty = Type.Object({
8
+ key: Type.String(),
9
+ value: Type.String()
10
+ });
11
+
12
+ export const MissionPropertyListInput = Type.Object({
13
+ prefix: Type.Optional(Type.String({
14
+ description: 'Only return properties whose key starts with this prefix'
15
+ }))
16
+ });
17
+
18
+ export const SetMissionProperty = Type.Object({
19
+ key: Type.String(),
20
+ value: Type.String(),
21
+ creatorUid: Type.String()
22
+ });
23
+
24
+ export const TAKItem_MissionProperty = TAKItem(MissionProperty);
25
+ export const TAKList_MissionProperty = TAKList(MissionProperty);
26
+
27
+ /**
28
+ * Key/Value properties stored on a Mission Sync
29
+ *
30
+ * Requires TAK Server 5.9 or later
31
+ */
32
+ export default class MissionPropertyCommands extends Commands {
33
+ schema = {}
34
+
35
+ async cli(): Promise<object | string> {
36
+ throw new Error('Unsupported Subcommand');
37
+ }
38
+
39
+ #headers(opts?: Static<typeof MissionOptions>): object {
40
+ if (opts && opts.token) {
41
+ return {
42
+ MissionAuthorization: `Bearer ${opts.token}`
43
+ }
44
+ } else {
45
+ return {};
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Property endpoints are only exposed by GUID, resolve a Mission name if needed
51
+ */
52
+ async #guid(
53
+ mission: string,
54
+ opts?: Static<typeof MissionOptions>
55
+ ): Promise<string> {
56
+ if (GUIDMatch.test(mission)) return mission;
57
+
58
+ return (await this.api.Mission.get(mission, {}, opts)).guid;
59
+ }
60
+
61
+ /**
62
+ * List properties on a Mission Sync, optionally filtered by key prefix
63
+ */
64
+ async list(
65
+ mission: string,
66
+ query: Static<typeof MissionPropertyListInput> = {},
67
+ opts?: Static<typeof MissionOptions>
68
+ ): Promise<Static<typeof TAKList_MissionProperty>> {
69
+ const guid = await this.#guid(mission, opts);
70
+ const url = new URL(`/Marti/api/missions/guid/${encodeURIComponent(guid)}/properties`, this.api.url);
71
+
72
+ if (query.prefix !== undefined) url.searchParams.append('prefix', query.prefix);
73
+
74
+ return await this.api.fetch(url, {
75
+ method: 'GET',
76
+ headers: this.#headers(opts)
77
+ });
78
+ }
79
+
80
+ /**
81
+ * Get a single property on a Mission Sync
82
+ */
83
+ async get(
84
+ mission: string,
85
+ key: string,
86
+ opts?: Static<typeof MissionOptions>
87
+ ): Promise<Static<typeof TAKItem_MissionProperty>> {
88
+ const guid = await this.#guid(mission, opts);
89
+ const url = new URL(`/Marti/api/missions/guid/${encodeURIComponent(guid)}/properties/${encodeURIComponent(key)}`, this.api.url);
90
+
91
+ return await this.api.fetch(url, {
92
+ method: 'GET',
93
+ headers: this.#headers(opts)
94
+ });
95
+ }
96
+
97
+ /**
98
+ * Create or update (upsert) a property on a Mission Sync
99
+ */
100
+ async set(
101
+ mission: string,
102
+ body: Static<typeof SetMissionProperty>,
103
+ opts?: Static<typeof MissionOptions>
104
+ ): Promise<Static<typeof TAKItem_MissionProperty>> {
105
+ const guid = await this.#guid(mission, opts);
106
+ const url = new URL(`/Marti/api/missions/guid/${encodeURIComponent(guid)}/properties`, this.api.url);
107
+ url.searchParams.append('creatorUid', body.creatorUid);
108
+
109
+ return await this.api.fetch(url, {
110
+ method: 'PUT',
111
+ headers: this.#headers(opts),
112
+ body: {
113
+ key: body.key,
114
+ value: body.value
115
+ }
116
+ });
117
+ }
118
+
119
+ /**
120
+ * Delete a single property on a Mission Sync
121
+ */
122
+ async delete(
123
+ mission: string,
124
+ key: string,
125
+ creatorUid: string,
126
+ opts?: Static<typeof MissionOptions>
127
+ ): Promise<void> {
128
+ const guid = await this.#guid(mission, opts);
129
+ const url = new URL(`/Marti/api/missions/guid/${encodeURIComponent(guid)}/properties/${encodeURIComponent(key)}`, this.api.url);
130
+ url.searchParams.append('creatorUid', creatorUid);
131
+
132
+ await this.api.fetch(url, {
133
+ method: 'DELETE',
134
+ headers: this.#headers(opts)
135
+ });
136
+ }
137
+
138
+ /**
139
+ * Delete all properties on a Mission Sync
140
+ */
141
+ async deleteAll(
142
+ mission: string,
143
+ creatorUid: string,
144
+ opts?: Static<typeof MissionOptions>
145
+ ): Promise<void> {
146
+ const guid = await this.#guid(mission, opts);
147
+ const url = new URL(`/Marti/api/missions/guid/${encodeURIComponent(guid)}/properties`, this.api.url);
148
+ url.searchParams.append('creatorUid', creatorUid);
149
+
150
+ await this.api.fetch(url, {
151
+ method: 'DELETE',
152
+ headers: this.#headers(opts)
153
+ });
154
+ }
155
+ }
package/lib/api.ts CHANGED
@@ -6,6 +6,7 @@ import Locate from './api/locate.js';
6
6
  import Mission, { MissionSubscriberRole } from './api/mission.js';
7
7
  import MissionInvite, { MissionInviteType } from './api/mission-invite.js';
8
8
  import MissionLog from './api/mission-log.js';
9
+ import MissionProperty from './api/mission-property.js';
9
10
  import MissionLayer, { MissionLayerType } from './api/mission-layer.js';
10
11
  import Credentials from './api/credentials.js';
11
12
  import Security from './api/security.js';
@@ -76,6 +77,7 @@ export const CommandList: Record<string, keyof TAKAPI> = {
76
77
  mission: 'Mission',
77
78
  'mission-invite': 'MissionInvite',
78
79
  'mission-log': 'MissionLog',
80
+ 'mission-property': 'MissionProperty',
79
81
  'mission-layer': 'MissionLayer',
80
82
  credential: 'Credentials',
81
83
  certificate: 'Certificate',
@@ -107,6 +109,7 @@ export default class TAKAPI {
107
109
  Iconsets: Iconsets;
108
110
  Mission: Mission;
109
111
  MissionLog: MissionLog;
112
+ MissionProperty: MissionProperty;
110
113
  MissionInvite: MissionInvite;
111
114
  MissionLayer: MissionLayer;
112
115
  Credentials: Credentials;
@@ -139,6 +142,7 @@ export default class TAKAPI {
139
142
  this.Iconsets = new Iconsets(this);
140
143
  this.Mission = new Mission(this);
141
144
  this.MissionLog = new MissionLog(this);
145
+ this.MissionProperty = new MissionProperty(this);
142
146
  this.MissionInvite = new MissionInvite(this);
143
147
  this.MissionLayer = new MissionLayer(this);
144
148
  this.Client = new Client(this);
@@ -246,6 +250,7 @@ export {
246
250
  Mission,
247
251
  MissionInvite,
248
252
  MissionLog,
253
+ MissionProperty,
249
254
  MissionLayer,
250
255
  Client,
251
256
  Credentials,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tak-ps/node-tak",
3
3
  "type": "module",
4
- "version": "12.30.0",
4
+ "version": "12.31.0",
5
5
  "description": "Lightweight JavaScript library for communicating with TAK Server",
6
6
  "author": "Nick Ingalls <nick@ingalls.ca>",
7
7
  "main": "dist/index.js",
@@ -0,0 +1,95 @@
1
+ import test from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { Readable } from 'node:stream';
4
+ import { Client } from 'undici';
5
+ import type { Dispatcher } from 'undici';
6
+ import TAKAPI from '../lib/api.js';
7
+ import { APIAuthCertificate } from '../lib/auth.js';
8
+
9
+ type RequestArgs = Parameters<Client['request']>[0];
10
+
11
+ const GUID = '9ba05e1d-970f-49e1-a153-7216fecf5279';
12
+
13
+ function mockResponse(statusCode: number, contentType: string, body: string): Dispatcher.ResponseData {
14
+ return {
15
+ statusCode,
16
+ headers: { 'content-type': contentType },
17
+ body: Readable.from([Buffer.from(body)]),
18
+ trailers: {}
19
+ } as unknown as Dispatcher.ResponseData;
20
+ }
21
+
22
+ async function capture(
23
+ response: string,
24
+ fn: (api: TAKAPI) => Promise<unknown>
25
+ ): Promise<{ requests: RequestArgs[], result: unknown }> {
26
+ const originalRequest = Client.prototype.request;
27
+ const requests: RequestArgs[] = [];
28
+
29
+ Client.prototype.request = async function(opts: RequestArgs): Promise<Dispatcher.ResponseData> {
30
+ requests.push(opts);
31
+ return mockResponse(200, response ? 'application/json' : 'text/plain', response);
32
+ };
33
+
34
+ try {
35
+ const api = new TAKAPI(new URL('https://tak.example.com'), new APIAuthCertificate('cert', 'key'));
36
+ const result = await fn(api);
37
+ return { requests, result };
38
+ } finally {
39
+ Client.prototype.request = originalRequest;
40
+ }
41
+ }
42
+
43
+ const ITEM = JSON.stringify({ version: '3', type: 'com.bbn.marti.sync.model.MissionProperty', data: { key: 'test.hello', value: 'world' } });
44
+ const LIST = JSON.stringify({ version: '3', type: 'com.bbn.marti.sync.model.MissionProperty', data: [{ key: 'test.hello', value: 'world' }] });
45
+
46
+ test('MissionProperty.list uses the guid properties endpoint with a prefix filter', async () => {
47
+ const { requests, result } = await capture(LIST, (api) => api.MissionProperty.list(GUID, { prefix: 'test.' }));
48
+
49
+ assert.equal(requests.length, 1);
50
+ assert.equal(requests[0].method, 'GET');
51
+ assert.equal(requests[0].path, `/Marti/api/missions/guid/${GUID}/properties?prefix=test.`);
52
+ assert.deepEqual((result as { data: unknown }).data, [{ key: 'test.hello', value: 'world' }]);
53
+ });
54
+
55
+ test('MissionProperty.get encodes the key in the path', async () => {
56
+ const { requests } = await capture(ITEM, (api) => api.MissionProperty.get(GUID, 'a b'));
57
+
58
+ assert.equal(requests[0].method, 'GET');
59
+ assert.equal(requests[0].path, `/Marti/api/missions/guid/${GUID}/properties/a%20b`);
60
+ });
61
+
62
+ test('MissionProperty.set PUTs key/value with creatorUid as a query param', async () => {
63
+ const { requests } = await capture(ITEM, (api) => api.MissionProperty.set(GUID, {
64
+ key: 'test.hello',
65
+ value: 'world',
66
+ creatorUid: 'alice'
67
+ }));
68
+
69
+ assert.equal(requests[0].method, 'PUT');
70
+ assert.equal(requests[0].path, `/Marti/api/missions/guid/${GUID}/properties?creatorUid=alice`);
71
+ assert.deepEqual(JSON.parse(String(requests[0].body)), { key: 'test.hello', value: 'world' });
72
+ });
73
+
74
+ test('MissionProperty.delete removes a single key', async () => {
75
+ const { requests } = await capture('', (api) => api.MissionProperty.delete(GUID, 'test.hello', 'alice'));
76
+
77
+ assert.equal(requests[0].method, 'DELETE');
78
+ assert.equal(requests[0].path, `/Marti/api/missions/guid/${GUID}/properties/test.hello?creatorUid=alice`);
79
+ });
80
+
81
+ test('MissionProperty.deleteAll removes every key', async () => {
82
+ const { requests } = await capture('', (api) => api.MissionProperty.deleteAll(GUID, 'alice'));
83
+
84
+ assert.equal(requests[0].method, 'DELETE');
85
+ assert.equal(requests[0].path, `/Marti/api/missions/guid/${GUID}/properties?creatorUid=alice`);
86
+ });
87
+
88
+ test('MissionProperty resolves a mission name to its GUID first', async () => {
89
+ const MISSION = JSON.stringify({ version: '3', type: 'Mission', data: [{ name: 'kv-test', guid: GUID }] });
90
+ const { requests } = await capture(MISSION, (api) => api.MissionProperty.list('kv-test'));
91
+
92
+ assert.equal(requests.length, 2);
93
+ assert.equal(requests[0].path, '/Marti/api/missions/kv-test');
94
+ assert.equal(requests[1].path, `/Marti/api/missions/guid/${GUID}/properties`);
95
+ });