faces-cli 1.4.4 → 1.4.6
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/catalog.d.ts +1 -1
- package/dist/catalog.js +5 -5
- package/dist/commands/catalog/doctor.js +1 -1
- package/dist/commands/catalog/list.js +3 -3
- package/dist/commands/compile/upload.d.ts +17 -0
- package/dist/commands/compile/upload.js +66 -0
- package/oclif.manifest.json +817 -719
- package/package.json +1 -1
package/dist/catalog.d.ts
CHANGED
package/dist/catalog.js
CHANGED
|
@@ -15,7 +15,7 @@ function serializeFrontmatter(fm) {
|
|
|
15
15
|
lines.push(`name: ${quoteYaml(fm.name)}`);
|
|
16
16
|
if (fm.description)
|
|
17
17
|
lines.push(`description: ${quoteYaml(fm.description)}`);
|
|
18
|
-
lines.push(`
|
|
18
|
+
lines.push(`alias: ${quoteYaml(fm.alias)}`);
|
|
19
19
|
if (fm.attributes && Object.keys(fm.attributes).length > 0) {
|
|
20
20
|
lines.push('attributes:');
|
|
21
21
|
for (const [k, v] of Object.entries(fm.attributes)) {
|
|
@@ -61,14 +61,14 @@ function parseFrontmatter(content) {
|
|
|
61
61
|
fm.name = val;
|
|
62
62
|
else if (key === 'description')
|
|
63
63
|
fm.description = val;
|
|
64
|
-
else if (key === '
|
|
65
|
-
fm.
|
|
64
|
+
else if (key === 'alias')
|
|
65
|
+
fm.alias = val;
|
|
66
66
|
else if (key === 'attributes')
|
|
67
67
|
inAttributes = true;
|
|
68
68
|
}
|
|
69
69
|
if (Object.keys(attributes).length > 0)
|
|
70
70
|
fm.attributes = attributes;
|
|
71
|
-
if (!fm.name || !fm.
|
|
71
|
+
if (!fm.name || !fm.alias)
|
|
72
72
|
return { frontmatter: null, body: content };
|
|
73
73
|
return { frontmatter: fm, body };
|
|
74
74
|
}
|
|
@@ -98,7 +98,7 @@ export class CatalogService {
|
|
|
98
98
|
}
|
|
99
99
|
const fm = {
|
|
100
100
|
name: faceData.name,
|
|
101
|
-
|
|
101
|
+
alias: username,
|
|
102
102
|
};
|
|
103
103
|
if (description) {
|
|
104
104
|
fm.description = description;
|
|
@@ -56,7 +56,7 @@ export default class CatalogDoctor extends BaseCommand {
|
|
|
56
56
|
const match = content.match(/^---\n([\s\S]*?)\n---/);
|
|
57
57
|
if (match) {
|
|
58
58
|
// Quick parse for name and description
|
|
59
|
-
const fm = {
|
|
59
|
+
const fm = { alias: dirent.name };
|
|
60
60
|
for (const line of match[1].split('\n')) {
|
|
61
61
|
if (line.startsWith(' '))
|
|
62
62
|
continue;
|
|
@@ -22,13 +22,13 @@ export default class CatalogList extends BaseCommand {
|
|
|
22
22
|
this.log('(no faces in catalog — run faces catalog:doctor --fix)');
|
|
23
23
|
return entries;
|
|
24
24
|
}
|
|
25
|
-
const nameWidth = Math.max(...entries.map((e) => String(e.
|
|
25
|
+
const nameWidth = Math.max(...entries.map((e) => String(e.alias ?? '').length));
|
|
26
26
|
const displayWidth = Math.max(...entries.map((e) => String(e.name ?? '').length));
|
|
27
27
|
for (const e of entries) {
|
|
28
|
-
const
|
|
28
|
+
const alias = String(e.alias ?? '').padEnd(nameWidth);
|
|
29
29
|
const name = String(e.name ?? '').padEnd(displayWidth);
|
|
30
30
|
const desc = e.description ? ` ${String(e.description).slice(0, 60)}...` : '';
|
|
31
|
-
this.log(`${
|
|
31
|
+
this.log(`${alias} ${name}${desc}`);
|
|
32
32
|
}
|
|
33
33
|
return entries;
|
|
34
34
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base.js';
|
|
2
|
+
export default class CompileUpload extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
file: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
kind: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
perspective: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
'face-speaker': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
};
|
|
13
|
+
static args: {
|
|
14
|
+
alias: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
15
|
+
};
|
|
16
|
+
run(): Promise<unknown>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { BaseCommand } from '../../base.js';
|
|
5
|
+
import { FacesAPIError } from '../../client.js';
|
|
6
|
+
export default class CompileUpload extends BaseCommand {
|
|
7
|
+
static description = 'Upload a file (text/PDF/audio/video) to compile into a face';
|
|
8
|
+
static flags = {
|
|
9
|
+
...BaseCommand.baseFlags,
|
|
10
|
+
file: Flags.string({ description: 'File to upload', required: true }),
|
|
11
|
+
kind: Flags.string({
|
|
12
|
+
description: 'Upload kind: document or thread',
|
|
13
|
+
options: ['document', 'thread'],
|
|
14
|
+
default: 'document',
|
|
15
|
+
}),
|
|
16
|
+
perspective: Flags.string({
|
|
17
|
+
description: 'Perspective (document only)',
|
|
18
|
+
options: ['first-person', 'third-person'],
|
|
19
|
+
default: 'third-person',
|
|
20
|
+
}),
|
|
21
|
+
'face-speaker': Flags.string({
|
|
22
|
+
description: 'Speaker name to map to the face (thread only). If omitted, auto-detected from face name.',
|
|
23
|
+
}),
|
|
24
|
+
};
|
|
25
|
+
static args = {
|
|
26
|
+
alias: Args.string({ description: 'Face alias', required: true }),
|
|
27
|
+
};
|
|
28
|
+
async run() {
|
|
29
|
+
const { args, flags } = await this.parse(CompileUpload);
|
|
30
|
+
const client = this.makeClient(flags);
|
|
31
|
+
if (!fs.existsSync(flags.file))
|
|
32
|
+
this.error(`File not found: ${flags.file}`);
|
|
33
|
+
const filename = path.basename(flags.file);
|
|
34
|
+
const fileBlob = new Blob([fs.readFileSync(flags.file)], { type: 'application/octet-stream' });
|
|
35
|
+
const form = new FormData();
|
|
36
|
+
form.append('file', fileBlob, filename);
|
|
37
|
+
// type, perspective, face_speaker are query params (not form fields)
|
|
38
|
+
const params = new URLSearchParams();
|
|
39
|
+
params.set('type', flags.kind);
|
|
40
|
+
params.set('perspective', flags.perspective);
|
|
41
|
+
if (flags['face-speaker'])
|
|
42
|
+
params.set('face_speaker', flags['face-speaker']);
|
|
43
|
+
let data;
|
|
44
|
+
try {
|
|
45
|
+
data = await client.postForm(`/v1/faces/${args.alias}/upload?${params}`, form);
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
if (err instanceof FacesAPIError)
|
|
49
|
+
this.error(`Error (${err.statusCode}): ${err.message}`);
|
|
50
|
+
throw err;
|
|
51
|
+
}
|
|
52
|
+
if (!this.jsonEnabled()) {
|
|
53
|
+
this.printHuman(data);
|
|
54
|
+
const res = data;
|
|
55
|
+
if (flags.kind === 'thread' && res.thread_id) {
|
|
56
|
+
this.log(`\nNext step:`);
|
|
57
|
+
this.log(` faces compile:thread:make ${res.thread_id}`);
|
|
58
|
+
}
|
|
59
|
+
else if (flags.kind === 'document' && res.document_id) {
|
|
60
|
+
this.log(`\nNext step:`);
|
|
61
|
+
this.log(` faces compile:doc:make ${res.document_id}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return data;
|
|
65
|
+
}
|
|
66
|
+
}
|