@formant/formant-cli 0.1.0 → 0.2.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/dist/base-command.d.ts +5 -0
- package/dist/base-command.js +9 -0
- package/dist/base-command.js.map +1 -1
- package/dist/commands/devices/create.d.ts +13 -0
- package/dist/commands/devices/create.js +62 -0
- package/dist/commands/devices/create.js.map +1 -0
- package/dist/commands/devices/delete.d.ts +10 -0
- package/dist/commands/devices/delete.js +49 -0
- package/dist/commands/devices/delete.js.map +1 -0
- package/dist/commands/devices/rename.d.ts +11 -0
- package/dist/commands/devices/rename.js +42 -0
- package/dist/commands/devices/rename.js.map +1 -0
- package/dist/commands/devices/tag.d.ts +13 -0
- package/dist/commands/devices/tag.js +69 -0
- package/dist/commands/devices/tag.js.map +1 -0
- package/dist/commands/devices/untag.d.ts +13 -0
- package/dist/commands/devices/untag.js +79 -0
- package/dist/commands/devices/untag.js.map +1 -0
- package/dist/commands/org/get.d.ts +7 -0
- package/dist/commands/org/get.js +54 -0
- package/dist/commands/org/get.js.map +1 -0
- package/dist/commands/org/update.d.ts +11 -0
- package/dist/commands/org/update.js +75 -0
- package/dist/commands/org/update.js.map +1 -0
- package/oclif.manifest.json +859 -399
- package/package.json +4 -1
package/dist/base-command.d.ts
CHANGED
|
@@ -27,6 +27,11 @@ export declare abstract class BaseCommand<T extends typeof Command> extends Comm
|
|
|
27
27
|
method?: 'DELETE' | 'GET' | 'PATCH' | 'POST' | 'PUT';
|
|
28
28
|
query?: Record<string, string>;
|
|
29
29
|
}): Promise<R>;
|
|
30
|
+
/**
|
|
31
|
+
* Get the organization ID from the authenticated session.
|
|
32
|
+
* Uses the cached login token so no extra network call if already authenticated.
|
|
33
|
+
*/
|
|
34
|
+
protected getOrgId(): Promise<string>;
|
|
30
35
|
protected catch(err: Error & {
|
|
31
36
|
exitCode?: number;
|
|
32
37
|
}): Promise<void>;
|
package/dist/base-command.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Command, Flags } from '@oclif/core';
|
|
2
2
|
import { apiRequest } from './lib/api.js';
|
|
3
|
+
import { login } from './lib/auth.js';
|
|
3
4
|
/**
|
|
4
5
|
* Abstract base command for all fcli commands.
|
|
5
6
|
* Provides global --env flag, --json support, and authenticated API helpers.
|
|
@@ -47,6 +48,14 @@ export class BaseCommand extends Command {
|
|
|
47
48
|
async api(target, path, options) {
|
|
48
49
|
return apiRequest(this.env, target, path, options);
|
|
49
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Get the organization ID from the authenticated session.
|
|
53
|
+
* Uses the cached login token so no extra network call if already authenticated.
|
|
54
|
+
*/
|
|
55
|
+
async getOrgId() {
|
|
56
|
+
const auth = await login(this.env);
|
|
57
|
+
return auth.organizationId;
|
|
58
|
+
}
|
|
50
59
|
async catch(err) {
|
|
51
60
|
throw err;
|
|
52
61
|
}
|
package/dist/base-command.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-command.js","sourceRoot":"","sources":["../src/base-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,KAAK,EAAa,MAAM,aAAa,CAAA;AAEtD,OAAO,EAAiB,UAAU,EAAC,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"base-command.js","sourceRoot":"","sources":["../src/base-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,KAAK,EAAa,MAAM,aAAa,CAAA;AAEtD,OAAO,EAAiB,UAAU,EAAC,MAAM,cAAc,CAAA;AACvD,OAAO,EAAC,KAAK,EAAC,MAAM,eAAe,CAAA;AAQnC;;;GAGG;AACH,MAAM,OAAgB,WAAsC,SAAQ,OAAO;IACzE,MAAM,CAAC,cAAc,GAAG,IAAI,CAAA;IAE5B,MAAM,CAAC,SAAS,GAAG;QACjB,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC;YACjB,WAAW,EAAE,4BAA4B;YACzC,SAAS,E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C,CAAA;QAClC,OAAO,IAAI,CAAC,cAAc,CAAA;IAC5B,CAAC;IAEkB,KAAK,CAAC,KAAK,CAAC,GAAgC;QAC7D,MAAM,GAAG,CAAA;IACX,CAAC;IAED;;;OAGG;IACO,iBAAiB,CAAC,OAAe;QACzC,2EAA2E;QAC3E,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,CAAC;YAC1D,OAAO,OAAO,CAAA;QAChB,CAAC;QAED,2DAA2D;QAC3D,OAAO,GAAG,OAAO,YAAY,CAAA;IAC/B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command.js';
|
|
2
|
+
export default class DevicesCreate extends BaseCommand<typeof DevicesCreate> {
|
|
3
|
+
static args: {
|
|
4
|
+
name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
static flags: {
|
|
9
|
+
tag: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
};
|
|
11
|
+
static summary: string;
|
|
12
|
+
run(): Promise<Record<string, unknown>>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base-command.js';
|
|
3
|
+
import { formatDetail } from '../../lib/formatters.js';
|
|
4
|
+
export default class DevicesCreate extends BaseCommand {
|
|
5
|
+
static args = {
|
|
6
|
+
name: Args.string({ description: 'Name for the new device', required: true }),
|
|
7
|
+
};
|
|
8
|
+
static description = `Create a new device in your fleet.
|
|
9
|
+
|
|
10
|
+
The device is created as enabled by default. You can optionally specify tags.`;
|
|
11
|
+
static examples = [
|
|
12
|
+
'<%= config.bin %> devices create my-robot',
|
|
13
|
+
'<%= config.bin %> devices create my-robot --tag location=warehouse --tag env=prod',
|
|
14
|
+
'<%= config.bin %> devices create my-robot --json',
|
|
15
|
+
];
|
|
16
|
+
static flags = {
|
|
17
|
+
tag: Flags.string({
|
|
18
|
+
char: 't',
|
|
19
|
+
description: 'Tag to apply (key=value), can be specified multiple times',
|
|
20
|
+
multiple: true,
|
|
21
|
+
}),
|
|
22
|
+
};
|
|
23
|
+
static summary = 'Create a new device';
|
|
24
|
+
async run() {
|
|
25
|
+
const body = {
|
|
26
|
+
enabled: true,
|
|
27
|
+
name: this.args.name,
|
|
28
|
+
type: 'default',
|
|
29
|
+
};
|
|
30
|
+
if (this.flags.tag && this.flags.tag.length > 0) {
|
|
31
|
+
const tags = {};
|
|
32
|
+
for (const t of this.flags.tag) {
|
|
33
|
+
const [key, ...rest] = t.split('=');
|
|
34
|
+
const value = rest.join('=');
|
|
35
|
+
if (!key || !value) {
|
|
36
|
+
this.error(`Invalid tag format: "${t}". Use key=value.`);
|
|
37
|
+
}
|
|
38
|
+
tags[key] = value;
|
|
39
|
+
}
|
|
40
|
+
body.tags = tags;
|
|
41
|
+
}
|
|
42
|
+
const device = await this.api('admin', 'devices', {
|
|
43
|
+
body,
|
|
44
|
+
method: 'POST',
|
|
45
|
+
});
|
|
46
|
+
if (!this.jsonEnabled()) {
|
|
47
|
+
this.log(`\nDevice Created (${this.env}):\n`);
|
|
48
|
+
this.log(formatDetail(device, {
|
|
49
|
+
createdAt: 'Created',
|
|
50
|
+
enabled: 'Enabled',
|
|
51
|
+
id: 'ID',
|
|
52
|
+
name: 'Name',
|
|
53
|
+
organizationId: 'Organization',
|
|
54
|
+
tags: 'Tags',
|
|
55
|
+
type: 'Type',
|
|
56
|
+
}));
|
|
57
|
+
this.log('');
|
|
58
|
+
}
|
|
59
|
+
return device;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../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K,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;gBAC5B,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;oBACnB,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,mBAAmB,CAAC,CAAA;gBAC1D,CAAC;gBAED,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;YACnB,CAAC;YAED,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAClB,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAA0B,OAAO,EAAE,SAAS,EAAE;YACzE,IAAI;YACJ,MAAM,EAAE,MAAM;SACf,CAAC,CAAA;QAEF,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,IAAI,CAAC,GAAG,CAAC,qBAAqB,IAAI,CAAC,GAAG,MAAM,CAAC,CAAA;YAC7C,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,EAAE;gBAC5B,SAAS,EAAE,SAAS;gBACpB,OAAO,EAAE,SAAS;gBAClB,EAAE,EAAE,IAAI;gBACR,IAAI,EAAE,MAAM;gBACZ,cAAc,EAAE,cAAc;gBAC9B,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,MAAM;aACb,CAAC,CAAC,CAAA;YACH,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QACd,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command.js';
|
|
2
|
+
export default class DevicesDelete extends BaseCommand<typeof DevicesDelete> {
|
|
3
|
+
static args: {
|
|
4
|
+
id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
static summary: string;
|
|
9
|
+
run(): Promise<Record<string, unknown>>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base-command.js';
|
|
3
|
+
import { formatDetail } from '../../lib/formatters.js';
|
|
4
|
+
export default class DevicesDelete extends BaseCommand {
|
|
5
|
+
static args = {
|
|
6
|
+
id: Args.string({ description: 'Device ID (UUID)', required: true }),
|
|
7
|
+
};
|
|
8
|
+
static description = `Delete (disable) a device from your fleet.
|
|
9
|
+
|
|
10
|
+
This performs a soft-delete by disabling the device. The device and its telemetry
|
|
11
|
+
history are preserved but it will no longer appear in device listings.`;
|
|
12
|
+
static examples = [
|
|
13
|
+
'<%= config.bin %> devices delete <device-id>',
|
|
14
|
+
'<%= config.bin %> devices delete <device-id> --json',
|
|
15
|
+
];
|
|
16
|
+
static summary = 'Delete (disable) a device';
|
|
17
|
+
async run() {
|
|
18
|
+
const deviceId = this.args.id;
|
|
19
|
+
// Fetch the device first to confirm it exists and get its name
|
|
20
|
+
const device = await this.api('admin', `devices/${deviceId}`, {
|
|
21
|
+
method: 'GET',
|
|
22
|
+
});
|
|
23
|
+
if (!device.enabled) {
|
|
24
|
+
if (!this.jsonEnabled()) {
|
|
25
|
+
this.log(`\nDevice "${device.name}" (${deviceId}) is already disabled.\n`);
|
|
26
|
+
}
|
|
27
|
+
return { ...device, alreadyDisabled: true };
|
|
28
|
+
}
|
|
29
|
+
// Soft-delete: disable the device
|
|
30
|
+
const updated = await this.api('admin', `devices/${deviceId}`, {
|
|
31
|
+
body: { enabled: false },
|
|
32
|
+
method: 'PATCH',
|
|
33
|
+
});
|
|
34
|
+
if (!this.jsonEnabled()) {
|
|
35
|
+
this.log(`\nDevice Deleted (${this.env}):\n`);
|
|
36
|
+
this.log(` Device "${device.name}" (${deviceId}) has been disabled.\n`);
|
|
37
|
+
this.log(formatDetail(updated, {
|
|
38
|
+
enabled: 'Enabled',
|
|
39
|
+
id: 'ID',
|
|
40
|
+
name: 'Name',
|
|
41
|
+
type: 'Type',
|
|
42
|
+
updatedAt: 'Updated',
|
|
43
|
+
}));
|
|
44
|
+
this.log('');
|
|
45
|
+
}
|
|
46
|
+
return updated;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=delete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../../src/commands/devices/delete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAA;AAEhC,OAAO,EAAC,WAAW,EAAC,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAC,YAAY,EAAC,MAAM,yBAAyB,CAAA;AAEpD,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,WAAiC;IAC1E,MAAM,CAAU,IAAI,GAAG;QACrB,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,EAAC,WAAW,EAAE,kBAAkB,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC;KACnE,CAAA;IAED,MAAM,CAAU,WAAW,GAAG;;;uEAGuC,CAAA;IAErE,MAAM,CAAU,QAAQ,GAAG;QACzB,8CAA8C;QAC9C,qDAAqD;KACtD,CAAA;IAED,MAAM,CAAU,OAAO,GAAG,2BAA2B,CAAA;IAE9C,KAAK,CAAC,GAAG;QACd,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAA;QAE7B,+DAA+D;QAC/D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAA0B,OAAO,EAAE,WAAW,QAAQ,EAAE,EAAE;YACrF,MAAM,EAAE,KAAK;SACd,CAAC,CAAA;QAEF,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;gBACxB,IAAI,CAAC,GAAG,CAAC,aAAa,MAAM,CAAC,IAAI,MAAM,QAAQ,0BAA0B,CAAC,CAAA;YAC5E,CAAC;YAED,OAAO,EAAC,GAAG,MAAM,EAAE,eAAe,EAAE,IAAI,EAAC,CAAA;QAC3C,CAAC;QAED,kCAAkC;QAClC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,GAAG,CAA0B,OAAO,EAAE,WAAW,QAAQ,EAAE,EAAE;YACtF,IAAI,EAAE,EAAC,OAAO,EAAE,KAAK,EAAC;YACtB,MAAM,EAAE,OAAO;SAChB,CAAC,CAAA;QAEF,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,IAAI,CAAC,GAAG,CAAC,qBAAqB,IAAI,CAAC,GAAG,MAAM,CAAC,CAAA;YAC7C,IAAI,CAAC,GAAG,CAAC,aAAa,MAAM,CAAC,IAAI,MAAM,QAAQ,wBAAwB,CAAC,CAAA;YACxE,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,OAAO,EAAE;gBAC7B,OAAO,EAAE,SAAS;gBAClB,EAAE,EAAE,IAAI;gBACR,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,MAAM;gBACZ,SAAS,EAAE,SAAS;aACrB,CAAC,CAAC,CAAA;YACH,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QACd,CAAC;QAED,OAAO,OAAO,CAAA;IAChB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command.js';
|
|
2
|
+
export default class DevicesRename extends BaseCommand<typeof DevicesRename> {
|
|
3
|
+
static args: {
|
|
4
|
+
id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
6
|
+
};
|
|
7
|
+
static description: string;
|
|
8
|
+
static examples: string[];
|
|
9
|
+
static summary: string;
|
|
10
|
+
run(): Promise<Record<string, unknown>>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base-command.js';
|
|
3
|
+
import { formatDetail } from '../../lib/formatters.js';
|
|
4
|
+
export default class DevicesRename extends BaseCommand {
|
|
5
|
+
static args = {
|
|
6
|
+
id: Args.string({ description: 'Device ID (UUID)', required: true }),
|
|
7
|
+
name: Args.string({ description: 'New name for the device', required: true }),
|
|
8
|
+
};
|
|
9
|
+
static description = 'Rename a device by updating its name.';
|
|
10
|
+
static examples = [
|
|
11
|
+
'<%= config.bin %> devices rename <device-id> new-robot-name',
|
|
12
|
+
'<%= config.bin %> devices rename <device-id> new-robot-name --json',
|
|
13
|
+
];
|
|
14
|
+
static summary = 'Rename a device';
|
|
15
|
+
async run() {
|
|
16
|
+
const { id: deviceId, name: newName } = this.args;
|
|
17
|
+
// Fetch the device first to confirm it exists and get the old name
|
|
18
|
+
const device = await this.api('admin', `devices/${deviceId}`, {
|
|
19
|
+
method: 'GET',
|
|
20
|
+
});
|
|
21
|
+
const oldName = device.name;
|
|
22
|
+
const updated = await this.api('admin', `devices/${deviceId}`, {
|
|
23
|
+
body: { name: newName },
|
|
24
|
+
method: 'PATCH',
|
|
25
|
+
});
|
|
26
|
+
if (!this.jsonEnabled()) {
|
|
27
|
+
this.log(`\nDevice Renamed (${this.env}):\n`);
|
|
28
|
+
this.log(` "${oldName}" → "${newName}"\n`);
|
|
29
|
+
this.log(formatDetail(updated, {
|
|
30
|
+
enabled: 'Enabled',
|
|
31
|
+
id: 'ID',
|
|
32
|
+
name: 'Name',
|
|
33
|
+
tags: 'Tags',
|
|
34
|
+
type: 'Type',
|
|
35
|
+
updatedAt: 'Updated',
|
|
36
|
+
}));
|
|
37
|
+
this.log('');
|
|
38
|
+
}
|
|
39
|
+
return updated;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=rename.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename.js","sourceRoot":"","sources":["../../../src/commands/devices/rename.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAA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,MAAM,OAAO,QAAQ,OAAO,KAAK,CAAC,CAAA;YAC3C,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,OAAO,EAAE;gBAC7B,OAAO,EAAE,SAAS;gBAClB,EAAE,EAAE,IAAI;gBACR,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,MAAM;gBACZ,SAAS,EAAE,SAAS;aACrB,CAAC,CAAC,CAAA;YACH,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QACd,CAAC;QAED,OAAO,OAAO,CAAA;IAChB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command.js';
|
|
2
|
+
export default class DevicesTag extends BaseCommand<typeof DevicesTag> {
|
|
3
|
+
static args: {
|
|
4
|
+
id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
static flags: {
|
|
9
|
+
tag: import("@oclif/core/interfaces").OptionFlag<string[], import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
};
|
|
11
|
+
static summary: string;
|
|
12
|
+
run(): Promise<Record<string, unknown>>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base-command.js';
|
|
3
|
+
import { formatTable } from '../../lib/formatters.js';
|
|
4
|
+
export default class DevicesTag extends BaseCommand {
|
|
5
|
+
static args = {
|
|
6
|
+
id: Args.string({ description: 'Device ID (UUID)', required: true }),
|
|
7
|
+
};
|
|
8
|
+
static description = `Add or update tags on a device.
|
|
9
|
+
|
|
10
|
+
Tags are key-value pairs. If a tag key already exists, its value will be updated.
|
|
11
|
+
Specify one or more tags with --tag key=value.`;
|
|
12
|
+
static examples = [
|
|
13
|
+
'<%= config.bin %> devices tag <device-id> --tag location=warehouse',
|
|
14
|
+
'<%= config.bin %> devices tag <device-id> --tag env=prod --tag region=us-east',
|
|
15
|
+
'<%= config.bin %> devices tag <device-id> --tag location=factory --json',
|
|
16
|
+
];
|
|
17
|
+
static flags = {
|
|
18
|
+
tag: Flags.string({
|
|
19
|
+
char: 't',
|
|
20
|
+
description: 'Tag to add or update (key=value), can be specified multiple times',
|
|
21
|
+
multiple: true,
|
|
22
|
+
required: true,
|
|
23
|
+
}),
|
|
24
|
+
};
|
|
25
|
+
static summary = 'Add or update tags on a device';
|
|
26
|
+
async run() {
|
|
27
|
+
const deviceId = this.args.id;
|
|
28
|
+
// Parse the new tags
|
|
29
|
+
const newTags = {};
|
|
30
|
+
for (const t of this.flags.tag) {
|
|
31
|
+
const [key, ...rest] = t.split('=');
|
|
32
|
+
const value = rest.join('=');
|
|
33
|
+
if (!key || !value) {
|
|
34
|
+
this.error(`Invalid tag format: "${t}". Use key=value.`);
|
|
35
|
+
}
|
|
36
|
+
newTags[key] = value;
|
|
37
|
+
}
|
|
38
|
+
// Fetch current device to get existing tags
|
|
39
|
+
const device = await this.api('admin', `devices/${deviceId}`, {
|
|
40
|
+
method: 'GET',
|
|
41
|
+
});
|
|
42
|
+
const currentTags = device.tags ?? {};
|
|
43
|
+
const mergedTags = { ...currentTags, ...newTags };
|
|
44
|
+
// Patch the device with merged tags
|
|
45
|
+
const updated = await this.api('admin', `devices/${deviceId}`, {
|
|
46
|
+
body: { tags: mergedTags },
|
|
47
|
+
method: 'PATCH',
|
|
48
|
+
});
|
|
49
|
+
const updatedTags = updated.tags ?? {};
|
|
50
|
+
if (!this.jsonEnabled()) {
|
|
51
|
+
this.log(`\nTags Updated — ${device.name} (${this.env}):\n`);
|
|
52
|
+
const rows = Object.entries(updatedTags)
|
|
53
|
+
.filter(([key]) => !key.startsWith('$.'))
|
|
54
|
+
.map(([key, value]) => {
|
|
55
|
+
const isNew = key in newTags;
|
|
56
|
+
return { key, status: isNew ? '✓' : '', value };
|
|
57
|
+
});
|
|
58
|
+
const columns = [
|
|
59
|
+
{ key: 'key', label: 'KEY', width: 25 },
|
|
60
|
+
{ key: 'value', label: 'VALUE', width: 35 },
|
|
61
|
+
{ key: 'status', label: '', width: 4 },
|
|
62
|
+
];
|
|
63
|
+
this.log(formatTable(rows, columns));
|
|
64
|
+
this.log('');
|
|
65
|
+
}
|
|
66
|
+
return updated;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=tag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tag.js","sourceRoot":"","sources":["../../../src/commands/devices/tag.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AAEvC,OAAO,EAAC,WAAW,EAAC,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAc,WAAW,EAAC,MAAM,yBAAyB,CAAA;AAEhE,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,WAA8B;IACpE,MAAM,CAAU,IAAI,GAAG;QACrB,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,EAAC,WAAW,EAAE,kBAAkB,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC;KACnE,CAAA;IAED,MAAM,CAAU,WAAW,GAAG;;;+CAGe,CAAA;IAE7C,MAAM,CAAU,QAAQ,GAAG;QACzB,oEAAoE;QACpE,+EAA+E;QAC/E,yEAAyE;KAC1E,CAAA;IAED,MAAM,CAAU,KAAK,GAAG;QACtB,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC;YAChB,IAAI,EAAE,GAAG;YACT,WAAW,EAAE,mEAAmE;YAChF,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,IAAI;SACf,CAAC;KACH,CAAA;IAED,MAAM,CAAU,OAAO,GAAG,gCAAgC,CAAA;IAEnD,KAAK,CAAC,GAAG;QACd,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAA;QAE7B,qBAAqB;QACrB,MAAM,OAA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,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;iBACxC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;gBACpB,MAAM,KAAK,GAAG,GAAG,IAAI,OAAO,CAAA;gBAC5B,OAAO,EAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,EAAC,CAAA;YAC/C,CAAC,CAAC,CAAA;YAEJ,MAAM,OAAO,GAAa;gBACxB,EAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAC;gBACrC,EAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAC;gBACzC,EAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAC;aACrC,CAAA;YAED,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAA;YACpC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QACd,CAAC;QAED,OAAO,OAAO,CAAA;IAChB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command.js';
|
|
2
|
+
export default class DevicesUntag extends BaseCommand<typeof DevicesUntag> {
|
|
3
|
+
static args: {
|
|
4
|
+
id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
static flags: {
|
|
9
|
+
key: import("@oclif/core/interfaces").OptionFlag<string[], import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
};
|
|
11
|
+
static summary: string;
|
|
12
|
+
run(): Promise<Record<string, unknown>>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base-command.js';
|
|
3
|
+
import { formatTable } from '../../lib/formatters.js';
|
|
4
|
+
export default class DevicesUntag extends BaseCommand {
|
|
5
|
+
static args = {
|
|
6
|
+
id: Args.string({ description: 'Device ID (UUID)', required: true }),
|
|
7
|
+
};
|
|
8
|
+
static description = `Remove tags from a device.
|
|
9
|
+
|
|
10
|
+
Specify one or more tag keys to remove with --key.`;
|
|
11
|
+
static examples = [
|
|
12
|
+
'<%= config.bin %> devices untag <device-id> --key location',
|
|
13
|
+
'<%= config.bin %> devices untag <device-id> --key env --key region',
|
|
14
|
+
'<%= config.bin %> devices untag <device-id> --key location --json',
|
|
15
|
+
];
|
|
16
|
+
static flags = {
|
|
17
|
+
key: Flags.string({
|
|
18
|
+
char: 'k',
|
|
19
|
+
description: 'Tag key to remove, can be specified multiple times',
|
|
20
|
+
multiple: true,
|
|
21
|
+
required: true,
|
|
22
|
+
}),
|
|
23
|
+
};
|
|
24
|
+
static summary = 'Remove tags from a device';
|
|
25
|
+
async run() {
|
|
26
|
+
const deviceId = this.args.id;
|
|
27
|
+
// Fetch current device to get existing tags
|
|
28
|
+
const device = await this.api('admin', `devices/${deviceId}`, {
|
|
29
|
+
method: 'GET',
|
|
30
|
+
});
|
|
31
|
+
const currentTags = device.tags ?? {};
|
|
32
|
+
const updatedTags = { ...currentTags };
|
|
33
|
+
const removed = [];
|
|
34
|
+
const notFound = [];
|
|
35
|
+
for (const key of this.flags.key) {
|
|
36
|
+
if (key in updatedTags) {
|
|
37
|
+
delete updatedTags[key];
|
|
38
|
+
removed.push(key);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
notFound.push(key);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (removed.length === 0) {
|
|
45
|
+
if (!this.jsonEnabled()) {
|
|
46
|
+
this.log(`\nNo matching tags found on device "${device.name}".`);
|
|
47
|
+
this.log(`Keys not found: ${notFound.join(', ')}\n`);
|
|
48
|
+
}
|
|
49
|
+
return { ...device, removedTags: [], notFound };
|
|
50
|
+
}
|
|
51
|
+
// Patch the device with updated tags
|
|
52
|
+
const updated = await this.api('admin', `devices/${deviceId}`, {
|
|
53
|
+
body: { tags: updatedTags },
|
|
54
|
+
method: 'PATCH',
|
|
55
|
+
});
|
|
56
|
+
const finalTags = updated.tags ?? {};
|
|
57
|
+
if (!this.jsonEnabled()) {
|
|
58
|
+
this.log(`\nTags Removed — ${device.name} (${this.env}):\n`);
|
|
59
|
+
this.log(` Removed: ${removed.join(', ')}`);
|
|
60
|
+
if (notFound.length > 0) {
|
|
61
|
+
this.log(` Not found: ${notFound.join(', ')}`);
|
|
62
|
+
}
|
|
63
|
+
const rows = Object.entries(finalTags)
|
|
64
|
+
.filter(([key]) => !key.startsWith('$.'))
|
|
65
|
+
.map(([key, value]) => ({ key, value }));
|
|
66
|
+
if (rows.length > 0) {
|
|
67
|
+
this.log('\n Remaining tags:\n');
|
|
68
|
+
const columns = [
|
|
69
|
+
{ key: 'key', label: 'KEY', width: 25 },
|
|
70
|
+
{ key: 'value', label: 'VALUE', width: 35 },
|
|
71
|
+
];
|
|
72
|
+
this.log(formatTable(rows, columns));
|
|
73
|
+
}
|
|
74
|
+
this.log('');
|
|
75
|
+
}
|
|
76
|
+
return updated;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=untag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"untag.js","sourceRoot":"","sources":["../../../src/commands/devices/untag.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AAEvC,OAAO,EAAC,WAAW,EAAC,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAc,WAAW,EAAC,MAAM,yBAAyB,CAAA;AAEhE,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,WA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AAC;iBACxC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EAAC,GAAG,EAAE,KAAK,EAAC,CAAC,CAAC,CAAA;YAExC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACpB,IAAI,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAA;gBACjC,MAAM,OAAO,GAAa;oBACxB,EAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAC;oBACrC,EAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAC;iBAC1C,CAAA;gBAED,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAA;YACtC,CAAC;YAED,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QACd,CAAC;QAED,OAAO,OAAO,CAAA;IAChB,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command.js';
|
|
2
|
+
import { formatDetail } from '../../lib/formatters.js';
|
|
3
|
+
export default class OrgGet extends BaseCommand {
|
|
4
|
+
static description = `Get information about your organization.
|
|
5
|
+
|
|
6
|
+
Displays the organization associated with your authenticated account.
|
|
7
|
+
No ID is needed — it is resolved automatically from your credentials.`;
|
|
8
|
+
static examples = [
|
|
9
|
+
'<%= config.bin %> org get',
|
|
10
|
+
'<%= config.bin %> org get --json',
|
|
11
|
+
];
|
|
12
|
+
static summary = 'Get your organization';
|
|
13
|
+
async run() {
|
|
14
|
+
const orgId = await this.getOrgId();
|
|
15
|
+
const org = await this.api('admin', `organizations/${orgId}`, {
|
|
16
|
+
method: 'GET',
|
|
17
|
+
});
|
|
18
|
+
if (!this.jsonEnabled()) {
|
|
19
|
+
// Curated view for human output — full object available via --json
|
|
20
|
+
const summary = {
|
|
21
|
+
id: org.id,
|
|
22
|
+
name: org.name,
|
|
23
|
+
description: org.description,
|
|
24
|
+
plan: org.plan,
|
|
25
|
+
industry: org.industry,
|
|
26
|
+
website: org.website,
|
|
27
|
+
enabled: org.enabled,
|
|
28
|
+
onlineSensitivity: org.onlineSensitivity,
|
|
29
|
+
daysDataRetained: org.daysDataRetained,
|
|
30
|
+
supportTier: org.supportTier,
|
|
31
|
+
createdAt: org.createdAt,
|
|
32
|
+
updatedAt: org.updatedAt,
|
|
33
|
+
};
|
|
34
|
+
this.log(`\nOrganization (${this.env}):\n`);
|
|
35
|
+
this.log(formatDetail(summary, {
|
|
36
|
+
createdAt: 'Created',
|
|
37
|
+
daysDataRetained: 'Data Retention (days)',
|
|
38
|
+
description: 'Description',
|
|
39
|
+
enabled: 'Enabled',
|
|
40
|
+
id: 'ID',
|
|
41
|
+
industry: 'Industry',
|
|
42
|
+
name: 'Name',
|
|
43
|
+
onlineSensitivity: 'Online Sensitivity (s)',
|
|
44
|
+
plan: 'Plan',
|
|
45
|
+
supportTier: 'Support Tier',
|
|
46
|
+
updatedAt: 'Updated',
|
|
47
|
+
website: 'Website',
|
|
48
|
+
}));
|
|
49
|
+
this.log('');
|
|
50
|
+
}
|
|
51
|
+
return org;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=get.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get.js","sourceRoot":"","sources":["../../../src/commands/org/get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAC,YAAY,EAAC,MAAM,yBAAyB,CAAA;AAEpD,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,WAA0B;IAC5D,MAAM,CAAU,WAAW,GAAG;;;sEAGsC,CAAA;IAEpE,MAAM,CAAU,QAAQ,GAAG;QACzB,2BAA2B;QAC3B,kCAAkC;KACnC,CAAA;IAED,MAAM,CAAU,OAAO,GAAG,uBAA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AE,SAAS;aACnB,CAAC,CAAC,CAAA;YACH,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QACd,CAAC;QAED,OAAO,GAAG,CAAA;IACZ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command.js';
|
|
2
|
+
export default class OrgUpdate extends BaseCommand<typeof OrgUpdate> {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
description: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
};
|
|
9
|
+
static summary: string;
|
|
10
|
+
run(): Promise<Record<string, unknown>>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base-command.js';
|
|
3
|
+
import { formatDetail } from '../../lib/formatters.js';
|
|
4
|
+
export default class OrgUpdate extends BaseCommand {
|
|
5
|
+
static description = `Update your organization's details.
|
|
6
|
+
|
|
7
|
+
At least one of --name or --description must be provided.`;
|
|
8
|
+
static examples = [
|
|
9
|
+
'<%= config.bin %> org update --name "My Fleet"',
|
|
10
|
+
'<%= config.bin %> org update --description "Production robot fleet"',
|
|
11
|
+
'<%= config.bin %> org update --name "My Fleet" --description "Production robot fleet"',
|
|
12
|
+
'<%= config.bin %> org update --name "My Fleet" --json',
|
|
13
|
+
];
|
|
14
|
+
static flags = {
|
|
15
|
+
description: Flags.string({
|
|
16
|
+
char: 'd',
|
|
17
|
+
description: 'New description for the organization',
|
|
18
|
+
}),
|
|
19
|
+
name: Flags.string({
|
|
20
|
+
char: 'n',
|
|
21
|
+
description: 'New name for the organization',
|
|
22
|
+
}),
|
|
23
|
+
};
|
|
24
|
+
static summary = 'Update your organization';
|
|
25
|
+
async run() {
|
|
26
|
+
const { description, name } = this.flags;
|
|
27
|
+
if (!name && !description) {
|
|
28
|
+
this.error('Provide at least one of --name or --description.');
|
|
29
|
+
}
|
|
30
|
+
const orgId = await this.getOrgId();
|
|
31
|
+
const body = {};
|
|
32
|
+
if (name)
|
|
33
|
+
body.name = name;
|
|
34
|
+
if (description)
|
|
35
|
+
body.description = description;
|
|
36
|
+
const updated = await this.api('admin', `organizations/${orgId}`, {
|
|
37
|
+
body,
|
|
38
|
+
method: 'PATCH',
|
|
39
|
+
});
|
|
40
|
+
if (!this.jsonEnabled()) {
|
|
41
|
+
const summary = {
|
|
42
|
+
id: updated.id,
|
|
43
|
+
name: updated.name,
|
|
44
|
+
description: updated.description,
|
|
45
|
+
plan: updated.plan,
|
|
46
|
+
industry: updated.industry,
|
|
47
|
+
website: updated.website,
|
|
48
|
+
enabled: updated.enabled,
|
|
49
|
+
onlineSensitivity: updated.onlineSensitivity,
|
|
50
|
+
daysDataRetained: updated.daysDataRetained,
|
|
51
|
+
supportTier: updated.supportTier,
|
|
52
|
+
createdAt: updated.createdAt,
|
|
53
|
+
updatedAt: updated.updatedAt,
|
|
54
|
+
};
|
|
55
|
+
this.log(`\nOrganization Updated (${this.env}):\n`);
|
|
56
|
+
this.log(formatDetail(summary, {
|
|
57
|
+
createdAt: 'Created',
|
|
58
|
+
daysDataRetained: 'Data Retention (days)',
|
|
59
|
+
description: 'Description',
|
|
60
|
+
enabled: 'Enabled',
|
|
61
|
+
id: 'ID',
|
|
62
|
+
industry: 'Industry',
|
|
63
|
+
name: 'Name',
|
|
64
|
+
onlineSensitivity: 'Online Sensitivity (s)',
|
|
65
|
+
plan: 'Plan',
|
|
66
|
+
supportTier: 'Support Tier',
|
|
67
|
+
updatedAt: 'Updated',
|
|
68
|
+
website: 'Website',
|
|
69
|
+
}));
|
|
70
|
+
this.log('');
|
|
71
|
+
}
|
|
72
|
+
return updated;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingUR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