faces-cli 1.5.12 → 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
|
-
|
|
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
|
|
@@ -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
|
}
|