faces-cli 1.5.11 → 1.5.13

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/client.js CHANGED
@@ -43,7 +43,12 @@ export class FacesClient {
43
43
  try {
44
44
  const body = await resp.json();
45
45
  const raw = body.detail ?? body.error ?? body.message ?? msg;
46
- msg = typeof raw === 'object' ? JSON.stringify(raw) : String(raw);
46
+ if (typeof raw === 'object' && raw !== null && 'message' in raw) {
47
+ msg = String(raw.message);
48
+ }
49
+ else {
50
+ msg = typeof raw === 'object' ? JSON.stringify(raw) : String(raw);
51
+ }
47
52
  }
48
53
  catch {
49
54
  // use statusText
@@ -29,7 +29,7 @@ export default class AuthWhoami extends BaseCommand {
29
29
  process.stderr.write(` status: not authenticated\n`);
30
30
  }
31
31
  if (json)
32
- process.stdout.write(JSON.stringify(diag) + '\n');
32
+ process.stdout.write(JSON.stringify(diag, null, 2) + '\n');
33
33
  process.exit(1);
34
34
  }
35
35
  // Try API key first (priority), then JWT. Always try both and report.
@@ -99,7 +99,7 @@ export default class AuthWhoami extends BaseCommand {
99
99
  }
100
100
  if (!diag.authenticated) {
101
101
  if (json)
102
- process.stdout.write(JSON.stringify(diag) + '\n');
102
+ process.stdout.write(JSON.stringify(diag, null, 2) + '\n');
103
103
  process.exit(1);
104
104
  }
105
105
  return diag;
@@ -14,7 +14,7 @@ export default class BillingTopup extends BaseCommand {
14
14
  const amount = Number.parseFloat(flags.amount);
15
15
  if (Number.isNaN(amount) || amount < 1.0)
16
16
  this.error('Minimum topup is $1.00 (--amount)');
17
- const payload = { amount };
17
+ const payload = { amount_usd: amount };
18
18
  if (flags['payment-ref'])
19
19
  payload.payment_ref = flags['payment-ref'];
20
20
  let data;
@@ -0,0 +1,10 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class FaceAttributes extends BaseCommand {
3
+ static description: string;
4
+ static flags: {
5
+ 'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
6
+ token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ 'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ };
9
+ run(): Promise<unknown>;
10
+ }
@@ -0,0 +1,30 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ import { FacesAPIError } from '../../client.js';
3
+ export default class FaceAttributes extends BaseCommand {
4
+ static description = 'List all supported attribute keys';
5
+ static flags = {
6
+ ...BaseCommand.baseFlags,
7
+ };
8
+ async run() {
9
+ const { flags } = await this.parse(FaceAttributes);
10
+ const client = this.makeClient(flags);
11
+ let data;
12
+ try {
13
+ data = await client.get('/v1/faces/attributes');
14
+ }
15
+ catch (err) {
16
+ if (err instanceof FacesAPIError)
17
+ this.error(`Error (${err.statusCode}): ${err.message}`);
18
+ throw err;
19
+ }
20
+ if (!this.jsonEnabled()) {
21
+ const response = data;
22
+ for (const category of response.data) {
23
+ this.log(`\n${category.name}`);
24
+ this.log(` ${category.facts.join(', ')}`);
25
+ }
26
+ this.log('');
27
+ }
28
+ return data;
29
+ }
30
+ }
@@ -51,6 +51,10 @@ export default class FaceCreate extends BaseCommand {
51
51
  throw err;
52
52
  }
53
53
  const face = data;
54
+ if (Array.isArray(face.warnings) && face.warnings.length > 0) {
55
+ for (const w of face.warnings)
56
+ this.warn(w);
57
+ }
54
58
  if (face.basic_facts && typeof face.basic_facts === 'object') {
55
59
  face.basic_facts = flattenBasicFacts(face.basic_facts);
56
60
  }
@@ -66,6 +66,10 @@ export default class FaceUpdate extends BaseCommand {
66
66
  }
67
67
  }
68
68
  const face = data;
69
+ if (Array.isArray(face.warnings) && face.warnings.length > 0) {
70
+ for (const w of face.warnings)
71
+ this.warn(w);
72
+ }
69
73
  if (face.basic_facts && typeof face.basic_facts === 'object') {
70
74
  face.basic_facts = flattenBasicFacts(face.basic_facts);
71
75
  }