@hunt-labs/bytekit-cli 0.1.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/client.d.ts +13 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +20 -0
- package/dist/client.js.map +1 -0
- package/dist/commands/account.d.ts +6 -0
- package/dist/commands/account.d.ts.map +1 -0
- package/dist/commands/account.js +96 -0
- package/dist/commands/account.js.map +1 -0
- package/dist/commands/bulk.d.ts +6 -0
- package/dist/commands/bulk.d.ts.map +1 -0
- package/dist/commands/bulk.js +56 -0
- package/dist/commands/bulk.js.map +1 -0
- package/dist/commands/fetch.d.ts +6 -0
- package/dist/commands/fetch.d.ts.map +1 -0
- package/dist/commands/fetch.js +80 -0
- package/dist/commands/fetch.js.map +1 -0
- package/dist/commands/monitors.d.ts +6 -0
- package/dist/commands/monitors.d.ts.map +1 -0
- package/dist/commands/monitors.js +115 -0
- package/dist/commands/monitors.js.map +1 -0
- package/dist/commands/recordings.d.ts +6 -0
- package/dist/commands/recordings.d.ts.map +1 -0
- package/dist/commands/recordings.js +37 -0
- package/dist/commands/recordings.js.map +1 -0
- package/dist/commands/scrape.d.ts +6 -0
- package/dist/commands/scrape.d.ts.map +1 -0
- package/dist/commands/scrape.js +79 -0
- package/dist/commands/scrape.js.map +1 -0
- package/dist/commands/screenshots.d.ts +6 -0
- package/dist/commands/screenshots.d.ts.map +1 -0
- package/dist/commands/screenshots.js +41 -0
- package/dist/commands/screenshots.js.map +1 -0
- package/dist/commands/search.d.ts +6 -0
- package/dist/commands/search.d.ts.map +1 -0
- package/dist/commands/search.js +58 -0
- package/dist/commands/search.js.map +1 -0
- package/dist/commands/sitemap.d.ts +6 -0
- package/dist/commands/sitemap.d.ts.map +1 -0
- package/dist/commands/sitemap.js +37 -0
- package/dist/commands/sitemap.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/url-lines.d.ts +13 -0
- package/dist/lib/url-lines.d.ts.map +1 -0
- package/dist/lib/url-lines.js +35 -0
- package/dist/lib/url-lines.js.map +1 -0
- package/dist/output.d.ts +11 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +44 -0
- package/dist/output.js.map +1 -0
- package/package.json +35 -0
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RapidCrawl } from '@hunt-labs/bytekit-sdk';
|
|
2
|
+
export interface GlobalOptions {
|
|
3
|
+
key?: string | undefined;
|
|
4
|
+
baseUrl?: string | undefined;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Build an authenticated SDK client from global CLI options.
|
|
8
|
+
*
|
|
9
|
+
* Resolution order for apiKey: --key flag → RAPIDCRAWL_API_KEY env var.
|
|
10
|
+
* Throws a descriptive error when no key is available.
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildClient(opts: GlobalOptions): RapidCrawl;
|
|
13
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,aAAa,GAAG,UAAU,CAa3D"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RapidCrawl } from '@hunt-labs/bytekit-sdk';
|
|
2
|
+
/**
|
|
3
|
+
* Build an authenticated SDK client from global CLI options.
|
|
4
|
+
*
|
|
5
|
+
* Resolution order for apiKey: --key flag → RAPIDCRAWL_API_KEY env var.
|
|
6
|
+
* Throws a descriptive error when no key is available.
|
|
7
|
+
*/
|
|
8
|
+
export function buildClient(opts) {
|
|
9
|
+
const apiKey = opts.key ?? process.env['RAPIDCRAWL_API_KEY'];
|
|
10
|
+
if (!apiKey) {
|
|
11
|
+
console.error('Error: API key required. Pass --key or set RAPIDCRAWL_API_KEY.');
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
const baseUrl = opts.baseUrl ?? process.env['RAPIDCRAWL_BASE_URL'];
|
|
15
|
+
return new RapidCrawl({
|
|
16
|
+
apiKey,
|
|
17
|
+
...(baseUrl !== undefined ? { baseUrl } : {}),
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAOpD;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,IAAmB;IAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAC7D,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,CAAC,KAAK,CAAC,gEAAgE,CAAC,CAAC;QAChF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;IAEnE,OAAO,IAAI,UAAU,CAAC;QACpB,MAAM;QACN,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9C,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/commands/account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAG/D,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,aAAa,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAqG9F"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { buildClient } from '../client.js';
|
|
3
|
+
import { printResult, handleError } from '../output.js';
|
|
4
|
+
export function makeAccountCommand(getGlobal) {
|
|
5
|
+
const cmd = new Command('account').description('Account and API key operations');
|
|
6
|
+
const apiKeysCmd = new Command('api-keys').description('API key management');
|
|
7
|
+
apiKeysCmd
|
|
8
|
+
.command('create')
|
|
9
|
+
.description('Create a new API key')
|
|
10
|
+
.requiredOption('--name <name>', 'Display name for the key')
|
|
11
|
+
.action(async (opts) => {
|
|
12
|
+
const g = getGlobal();
|
|
13
|
+
const client = buildClient(g);
|
|
14
|
+
try {
|
|
15
|
+
const result = await client.account.apiKeys.create({ name: opts.name });
|
|
16
|
+
printResult(result, g.json);
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
handleError(err);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
apiKeysCmd
|
|
23
|
+
.command('list')
|
|
24
|
+
.description('List all API keys')
|
|
25
|
+
.action(async () => {
|
|
26
|
+
const g = getGlobal();
|
|
27
|
+
const client = buildClient(g);
|
|
28
|
+
try {
|
|
29
|
+
const result = await client.account.apiKeys.list();
|
|
30
|
+
printResult(result, g.json);
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
handleError(err);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
apiKeysCmd
|
|
37
|
+
.command('get <id>')
|
|
38
|
+
.description('Get an API key by ID')
|
|
39
|
+
.action(async (id) => {
|
|
40
|
+
const g = getGlobal();
|
|
41
|
+
const client = buildClient(g);
|
|
42
|
+
try {
|
|
43
|
+
const result = await client.account.apiKeys.get(id);
|
|
44
|
+
printResult(result, g.json);
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
handleError(err);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
apiKeysCmd
|
|
51
|
+
.command('update <id>')
|
|
52
|
+
.description('Update an API key')
|
|
53
|
+
.requiredOption('--name <name>', 'New display name')
|
|
54
|
+
.action(async (id, opts) => {
|
|
55
|
+
const g = getGlobal();
|
|
56
|
+
const client = buildClient(g);
|
|
57
|
+
try {
|
|
58
|
+
const result = await client.account.apiKeys.update(id, { name: opts.name });
|
|
59
|
+
printResult(result, g.json);
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
handleError(err);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
apiKeysCmd
|
|
66
|
+
.command('revoke <id>')
|
|
67
|
+
.description('Revoke an API key (idempotent)')
|
|
68
|
+
.action(async (id) => {
|
|
69
|
+
const g = getGlobal();
|
|
70
|
+
const client = buildClient(g);
|
|
71
|
+
try {
|
|
72
|
+
const result = await client.account.apiKeys.revoke(id);
|
|
73
|
+
printResult(result, g.json);
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
handleError(err);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
cmd.addCommand(apiKeysCmd);
|
|
80
|
+
cmd
|
|
81
|
+
.command('get')
|
|
82
|
+
.description('Get the authenticated account')
|
|
83
|
+
.action(async () => {
|
|
84
|
+
const g = getGlobal();
|
|
85
|
+
const client = buildClient(g);
|
|
86
|
+
try {
|
|
87
|
+
const result = await client.account.get();
|
|
88
|
+
printResult(result, g.json);
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
handleError(err);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
return cmd;
|
|
95
|
+
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AAC;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bulk.d.ts","sourceRoot":"","sources":["../../src/commands/bulk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAI/D,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,aAAa,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CA0D3F"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { buildClient } from '../client.js';
|
|
3
|
+
import { printResult, handleError } from '../output.js';
|
|
4
|
+
import { parseUrlLines } from '../lib/url-lines.js';
|
|
5
|
+
export function makeBulkCommand(getGlobal) {
|
|
6
|
+
const cmd = new Command('bulk').description('Bulk screenshot operations');
|
|
7
|
+
const screenshotsCmd = new Command('screenshots').description('Bulk screenshot sub-resources');
|
|
8
|
+
screenshotsCmd
|
|
9
|
+
.command('list <id>')
|
|
10
|
+
.description('List screenshots in a bulk job')
|
|
11
|
+
.action(async (id) => {
|
|
12
|
+
const g = getGlobal();
|
|
13
|
+
const client = buildClient(g);
|
|
14
|
+
try {
|
|
15
|
+
const result = await client.bulk.screenshots.list(id);
|
|
16
|
+
printResult(result, g.json);
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
handleError(err);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
cmd.addCommand(screenshotsCmd);
|
|
23
|
+
cmd
|
|
24
|
+
.command('create')
|
|
25
|
+
.description('Create a bulk screenshots job')
|
|
26
|
+
.requiredOption('--file <path>', 'Path to newline-delimited file of URLs (plain URL or {"url":"..."} per line)')
|
|
27
|
+
.requiredOption('--webhook-url <url>', 'HTTPS webhook URL notified when the job completes')
|
|
28
|
+
.action(async (opts) => {
|
|
29
|
+
const g = getGlobal();
|
|
30
|
+
const client = buildClient(g);
|
|
31
|
+
try {
|
|
32
|
+
const urls = parseUrlLines(opts.file);
|
|
33
|
+
const result = await client.bulk.create({ urls, webhook_url: opts.webhookUrl });
|
|
34
|
+
printResult(result, g.json);
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
handleError(err);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
cmd
|
|
41
|
+
.command('get <id>')
|
|
42
|
+
.description('Get a bulk job status')
|
|
43
|
+
.action(async (id) => {
|
|
44
|
+
const g = getGlobal();
|
|
45
|
+
const client = buildClient(g);
|
|
46
|
+
try {
|
|
47
|
+
const result = await client.bulk.get(id);
|
|
48
|
+
printResult(result, g.json);
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
handleError(err);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return cmd;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=bulk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bulk.js","sourceRoot":"","sources":["../../src/commands/bulk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAsB,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,UAAU,eAAe,CAAC,SAAkD;IAChF,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,4BAA4B,CAAC,CAAC;IAE1E,MAAM,cAAc,GAAG,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC,WAAW,CAAC,+BAA+B,CAAC,CAAC;IAE/F,cAAc;SACX,OAAO,CAAC,WAAW,CAAC;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SACA,OAAO,CAAC,UAAU,CAAC;SACnB,WAAW,CAAC,uBAAuB,CAAC;SACpC,MAAM,CAAC,KAAK,EAAE,EAAU,EAAE,EAAE;QAC3B,MAAM,CAAC,GAAG,SAAS,EAAE,CAAC;QACtB,MAAM,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QAC9B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAA2C,CAAC,CAAC;YAClF,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QAC9B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,WAAW,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/commands/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAI/D,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,aAAa,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAkF5F"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { buildClient } from '../client.js';
|
|
3
|
+
import { printResult, handleError } from '../output.js';
|
|
4
|
+
import { parseUrlLines } from '../lib/url-lines.js';
|
|
5
|
+
export function makeFetchCommand(getGlobal) {
|
|
6
|
+
const cmd = new Command('fetch').description('Fetch URL content operations');
|
|
7
|
+
const bulkCmd = new Command('bulk').description('Bulk fetch operations');
|
|
8
|
+
bulkCmd
|
|
9
|
+
.command('create')
|
|
10
|
+
.description('Create a bulk fetch job')
|
|
11
|
+
.requiredOption('--file <path>', 'Path to newline-delimited file of URLs (plain URL or {"url":"..."} per line)')
|
|
12
|
+
.requiredOption('--webhook-url <url>', 'HTTPS webhook URL notified when the job completes')
|
|
13
|
+
.action(async (opts) => {
|
|
14
|
+
const g = getGlobal();
|
|
15
|
+
const client = buildClient(g);
|
|
16
|
+
try {
|
|
17
|
+
const urls = parseUrlLines(opts.file);
|
|
18
|
+
const result = await client.fetch.bulk.create({ urls, webhook_url: opts.webhookUrl });
|
|
19
|
+
printResult(result, g.json);
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
handleError(err);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
bulkCmd
|
|
26
|
+
.command('get <id>')
|
|
27
|
+
.description('Get a bulk fetch job')
|
|
28
|
+
.action(async (id) => {
|
|
29
|
+
const g = getGlobal();
|
|
30
|
+
const client = buildClient(g);
|
|
31
|
+
try {
|
|
32
|
+
const result = await client.fetch.bulk.get(id);
|
|
33
|
+
printResult(result, g.json);
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
handleError(err);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
cmd.addCommand(bulkCmd);
|
|
40
|
+
cmd
|
|
41
|
+
.command('create')
|
|
42
|
+
.description('Fetch URL content (POST)')
|
|
43
|
+
.requiredOption('--url <url>', 'URL to fetch')
|
|
44
|
+
.option('--format <format>', 'Response format')
|
|
45
|
+
.action(async (opts) => {
|
|
46
|
+
const g = getGlobal();
|
|
47
|
+
const client = buildClient(g);
|
|
48
|
+
try {
|
|
49
|
+
const result = await client.fetch.create({
|
|
50
|
+
url: opts.url,
|
|
51
|
+
...(opts.format !== undefined ? { format: opts.format } : {}),
|
|
52
|
+
});
|
|
53
|
+
printResult(result, g.json);
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
handleError(err);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
cmd
|
|
60
|
+
.command('get')
|
|
61
|
+
.description('Fetch URL content (GET via query params)')
|
|
62
|
+
.requiredOption('--url <url>', 'URL to fetch')
|
|
63
|
+
.option('--format <format>', 'Response format')
|
|
64
|
+
.action(async (opts) => {
|
|
65
|
+
const g = getGlobal();
|
|
66
|
+
const client = buildClient(g);
|
|
67
|
+
try {
|
|
68
|
+
const result = await client.fetch.get({
|
|
69
|
+
url: opts.url,
|
|
70
|
+
...(opts.format !== undefined ? { format: opts.format } : {}),
|
|
71
|
+
});
|
|
72
|
+
printResult(result, g.json);
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
handleError(err);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
return cmd;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=fetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/commands/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAsB,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,UAAU,gBAAgB,CAAC,SAAkD;IACjF,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,8BAA8B,CAAC,CAAC;IAE7E,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,uBAAuB,CAAC,CAAC;IAEzE,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,yBAAyB,CAAC;SACtC,cAAc,CACb,eAAe,EACf,8EAA8E,CAC/E;SACA,cAAc,CAAC,qBAAqB,EAAE,mDAAmD,CAAC;SAC1F,MAAM,CAAC,KAAK,EAAE,IAA0C,EAAE,EAAE;QAC3D,MAAM,CAAC,G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OAAO,GAAG,EAAE,CAAC;YACb,WAAW,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monitors.d.ts","sourceRoot":"","sources":["../../src/commands/monitors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAG/D,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,aAAa,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CA2H/F"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { buildClient } from '../client.js';
|
|
3
|
+
import { printResult, handleError } from '../output.js';
|
|
4
|
+
export function makeMonitorsCommand(getGlobal) {
|
|
5
|
+
const cmd = new Command('monitors').description('Page-change monitor operations');
|
|
6
|
+
const capturesCmd = new Command('captures').description('Monitor capture sub-resources');
|
|
7
|
+
capturesCmd
|
|
8
|
+
.command('list <id>')
|
|
9
|
+
.description('List captures for a monitor')
|
|
10
|
+
.action(async (id) => {
|
|
11
|
+
const g = getGlobal();
|
|
12
|
+
const client = buildClient(g);
|
|
13
|
+
try {
|
|
14
|
+
const result = await client.monitors.captures.list(id);
|
|
15
|
+
printResult(result, g.json);
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
handleError(err);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
cmd.addCommand(capturesCmd);
|
|
22
|
+
cmd
|
|
23
|
+
.command('create')
|
|
24
|
+
.description('Create a page-change monitor')
|
|
25
|
+
.requiredOption('--url <url>', 'URL to monitor')
|
|
26
|
+
.requiredOption('--interval-type <type>', 'Check interval: hourly, daily, weekly, or cron')
|
|
27
|
+
.requiredOption('--webhook-url <url>', 'HTTPS webhook URL notified on change')
|
|
28
|
+
.option('--cron <expr>', 'Cron expression (required when --interval-type is cron, e.g. "0 * * * *")')
|
|
29
|
+
.action(async (opts) => {
|
|
30
|
+
const g = getGlobal();
|
|
31
|
+
const client = buildClient(g);
|
|
32
|
+
const body = {
|
|
33
|
+
url: opts.url,
|
|
34
|
+
interval_type: opts.intervalType,
|
|
35
|
+
webhook_url: opts.webhookUrl,
|
|
36
|
+
};
|
|
37
|
+
if (opts.cron !== undefined)
|
|
38
|
+
body['cron_expression'] = opts.cron;
|
|
39
|
+
try {
|
|
40
|
+
const result = await client.monitors.create(body);
|
|
41
|
+
printResult(result, g.json);
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
handleError(err);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
cmd
|
|
48
|
+
.command('list')
|
|
49
|
+
.description('List all monitors')
|
|
50
|
+
.action(async () => {
|
|
51
|
+
const g = getGlobal();
|
|
52
|
+
const client = buildClient(g);
|
|
53
|
+
try {
|
|
54
|
+
const result = await client.monitors.list();
|
|
55
|
+
printResult(result, g.json);
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
handleError(err);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
cmd
|
|
62
|
+
.command('get <id>')
|
|
63
|
+
.description('Get a monitor by ID')
|
|
64
|
+
.action(async (id) => {
|
|
65
|
+
const g = getGlobal();
|
|
66
|
+
const client = buildClient(g);
|
|
67
|
+
try {
|
|
68
|
+
const result = await client.monitors.get(id);
|
|
69
|
+
printResult(result, g.json);
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
handleError(err);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
cmd
|
|
76
|
+
.command('update <id>')
|
|
77
|
+
.description('Update a monitor')
|
|
78
|
+
.option('--interval-type <type>', 'New check interval: hourly, daily, weekly, or cron')
|
|
79
|
+
.option('--cron <expr>', 'New cron expression (when interval-type is cron, e.g. "0 * * * *")')
|
|
80
|
+
.option('--webhook-url <url>', 'New HTTPS webhook URL')
|
|
81
|
+
.action(async (id, opts) => {
|
|
82
|
+
const g = getGlobal();
|
|
83
|
+
const client = buildClient(g);
|
|
84
|
+
const body = {};
|
|
85
|
+
if (opts.intervalType !== undefined)
|
|
86
|
+
body['interval_type'] = opts.intervalType;
|
|
87
|
+
if (opts.cron !== undefined)
|
|
88
|
+
body['cron_expression'] = opts.cron;
|
|
89
|
+
if (opts.webhookUrl !== undefined)
|
|
90
|
+
body['webhook_url'] = opts.webhookUrl;
|
|
91
|
+
try {
|
|
92
|
+
const result = await client.monitors.update(id, body);
|
|
93
|
+
printResult(result, g.json);
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
handleError(err);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
cmd
|
|
100
|
+
.command('delete <id>')
|
|
101
|
+
.description('Delete a monitor')
|
|
102
|
+
.action(async (id) => {
|
|
103
|
+
const g = getGlobal();
|
|
104
|
+
const client = buildClient(g);
|
|
105
|
+
try {
|
|
106
|
+
const result = await client.monitors.delete(id);
|
|
107
|
+
printResult(result, g.json);
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
handleError(err);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
return cmd;
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=monitors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monitors.js","sourceRoot":"","sources":["../../src/commands/monitors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAsB,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAExD,MAAM,UAAU,mBAAmB,CAAC,SAAkD;IACpF,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC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,CAAC,KAAK,EAAE,EAAU,EAAE,EAAE;QAC3B,MAAM,CAAC,GAAG,SAAS,EAAE,CAAC;QACtB,MAAM,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QAC9B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,MAAM,CACzC,EAAkD,CACnD,CAAC;YACF,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QAC9B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,WAAW,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recordings.d.ts","sourceRoot":"","sources":["../../src/commands/recordings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAG/D,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,aAAa,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAmCjG"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { buildClient } from '../client.js';
|
|
3
|
+
import { printResult, handleError } from '../output.js';
|
|
4
|
+
export function makeRecordingsCommand(getGlobal) {
|
|
5
|
+
const cmd = new Command('recordings').description('Recording operations');
|
|
6
|
+
cmd
|
|
7
|
+
.command('create')
|
|
8
|
+
.description('Start a page recording')
|
|
9
|
+
.requiredOption('--url <url>', 'URL to record')
|
|
10
|
+
.action(async (opts) => {
|
|
11
|
+
const g = getGlobal();
|
|
12
|
+
const client = buildClient(g);
|
|
13
|
+
try {
|
|
14
|
+
const result = await client.recordings.create({ url: opts.url });
|
|
15
|
+
printResult(result, g.json);
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
handleError(err);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
cmd
|
|
22
|
+
.command('get <id>')
|
|
23
|
+
.description('Get a recording by ID')
|
|
24
|
+
.action(async (id) => {
|
|
25
|
+
const g = getGlobal();
|
|
26
|
+
const client = buildClient(g);
|
|
27
|
+
try {
|
|
28
|
+
const result = await client.recordings.get(id);
|
|
29
|
+
printResult(result, g.json);
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
handleError(err);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return cmd;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=recordings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recordings.js","sourceRoot":"","sources":["../../src/commands/recordings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAsB,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAExD,MAAM,UAAU,qBAAqB,CAAC,SAAkD;IACtF,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC,WAAW,CAAC,sBAAsB,CAAC,CAAC;IAE1E,GAAG;SACA,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,wBAAwB,CAAC;SACrC,cAAc,CAAC,aAAa,EAAE,eAAe,CAAC;SAC9C,MAAM,CAAC,KAAK,EAAE,IAAqB,EAAE,EAAE;QACtC,MAAM,CAAC,GAAG,SAAS,EAAE,CAAC;QACtB,MAAM,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QAC9B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;YACjE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QAC9B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,WAAW,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,GAAG;SACA,OAAO,CAAC,UAAU,CAAC;SACnB,WAAW,CAAC,uBAAuB,CAAC;SACpC,MAAM,CAAC,KAAK,EAAE,EAAU,EAAE,EAAE;QAC3B,MAAM,CAAC,GAAG,SAAS,EAAE,CAAC;QACtB,MAAM,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QAC9B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,GAAG,CACxC,EAAiD,CAClD,CAAC;YACF,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QAC9B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,WAAW,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scrape.d.ts","sourceRoot":"","sources":["../../src/commands/scrape.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAI/D,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,aAAa,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAkF7F"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { buildClient } from '../client.js';
|
|
3
|
+
import { printResult, handleError } from '../output.js';
|
|
4
|
+
import { parseUrlLines } from '../lib/url-lines.js';
|
|
5
|
+
export function makeScrapeCommand(getGlobal) {
|
|
6
|
+
const cmd = new Command('scrape').description('Scrape URL content');
|
|
7
|
+
const bulkCmd = new Command('bulk').description('Bulk scrape operations');
|
|
8
|
+
bulkCmd
|
|
9
|
+
.command('create')
|
|
10
|
+
.description('Create a bulk scrape job')
|
|
11
|
+
.requiredOption('--file <path>', 'Path to newline-delimited file of URLs (plain URL or {"url":"..."} per line)')
|
|
12
|
+
.requiredOption('--webhook-url <url>', 'HTTPS webhook URL notified when the job completes')
|
|
13
|
+
.action(async (opts) => {
|
|
14
|
+
const g = getGlobal();
|
|
15
|
+
const client = buildClient(g);
|
|
16
|
+
try {
|
|
17
|
+
// readFileSync throws ENOENT on missing file — caught by handleError below
|
|
18
|
+
const urls = parseUrlLines(opts.file);
|
|
19
|
+
const result = await client.scrape.bulk.create({ urls, webhook_url: opts.webhookUrl });
|
|
20
|
+
printResult(result, g.json);
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
handleError(err);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
bulkCmd
|
|
27
|
+
.command('get <id>')
|
|
28
|
+
.description('Get a bulk scrape job')
|
|
29
|
+
.action(async (id) => {
|
|
30
|
+
const g = getGlobal();
|
|
31
|
+
const client = buildClient(g);
|
|
32
|
+
try {
|
|
33
|
+
const result = await client.scrape.bulk.get(id);
|
|
34
|
+
printResult(result, g.json);
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
handleError(err);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
cmd.addCommand(bulkCmd);
|
|
41
|
+
cmd
|
|
42
|
+
.command('create')
|
|
43
|
+
.description('Create a scrape job')
|
|
44
|
+
.requiredOption('--url <url>', 'URL to scrape')
|
|
45
|
+
.option('--format <format>', 'Output format (e.g. markdown, html); sent as the formats array')
|
|
46
|
+
.action(async (opts) => {
|
|
47
|
+
const g = getGlobal();
|
|
48
|
+
const client = buildClient(g);
|
|
49
|
+
const body = { url: opts.url };
|
|
50
|
+
// The v1 scrape validator expects `formats` (array), not `format` (string).
|
|
51
|
+
// Omit the key entirely when --format is not provided so we never send
|
|
52
|
+
// formats: ["undefined"].
|
|
53
|
+
if (opts.format !== undefined)
|
|
54
|
+
body['formats'] = [opts.format];
|
|
55
|
+
try {
|
|
56
|
+
const result = await client.scrape.create(body);
|
|
57
|
+
printResult(result, g.json);
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
handleError(err);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
cmd
|
|
64
|
+
.command('get <id>')
|
|
65
|
+
.description('Get a scrape job by ID')
|
|
66
|
+
.action(async (id) => {
|
|
67
|
+
const g = getGlobal();
|
|
68
|
+
const client = buildClient(g);
|
|
69
|
+
try {
|
|
70
|
+
const result = await client.scrape.get(id);
|
|
71
|
+
printResult(result, g.json);
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
handleError(err);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
return cmd;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=scrape.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scrape.js","sourceRoot":"","sources":["../../src/commands/scrape.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAsB,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,UAAU,iBAAiB,CAAC,SAAkD;IAClF,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC;IAEpE,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,wBAAwB,CAAC,CAAC;IAE1E,OAAO;SACJ,OAAO,CA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;QAC9B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,WAAW,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenshots.d.ts","sourceRoot":"","sources":["../../src/commands/screenshots.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAG/D,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,aAAa,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GACjD,OAAO,CAsCT"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { buildClient } from '../client.js';
|
|
3
|
+
import { printResult, handleError } from '../output.js';
|
|
4
|
+
export function makeScreenshotsCommand(getGlobal) {
|
|
5
|
+
const cmd = new Command('screenshots').description('Screenshot operations');
|
|
6
|
+
cmd
|
|
7
|
+
.command('create')
|
|
8
|
+
.description('Capture a screenshot')
|
|
9
|
+
.requiredOption('--url <url>', 'URL to screenshot')
|
|
10
|
+
.option('--full-page', 'Capture the full page (default: viewport only)')
|
|
11
|
+
.action(async (opts) => {
|
|
12
|
+
const g = getGlobal();
|
|
13
|
+
const client = buildClient(g);
|
|
14
|
+
const body = { url: opts.url };
|
|
15
|
+
if (opts.fullPage === true)
|
|
16
|
+
body['full_page'] = true;
|
|
17
|
+
try {
|
|
18
|
+
const result = await client.screenshots.create(body);
|
|
19
|
+
printResult(result, g.json);
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
handleError(err);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
cmd
|
|
26
|
+
.command('get <id>')
|
|
27
|
+
.description('Get a screenshot by ID')
|
|
28
|
+
.action(async (id) => {
|
|
29
|
+
const g = getGlobal();
|
|
30
|
+
const client = buildClient(g);
|
|
31
|
+
try {
|
|
32
|
+
const result = await client.screenshots.get(id);
|
|
33
|
+
printResult(result, g.json);
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
handleError(err);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return cmd;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=screenshots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenshots.js","sourceRoot":"","sources":["../../src/commands/screenshots.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAsB,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAExD,MAAM,UAAU,sBAAsB,CACpC,SAAkD;IAElD,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC,WAAW,CAAC,uBAAuB,CAAC,CAAC;IAE5E,GAAG;SACA,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,sBAAsB,CAAC;SACnC,cAAc,CAAC,aAAa,EAAE,mBAAmB,CAAC;SAClD,MAAM,CAAC,aAAa,EAAE,gDAAgD,CAAC;SACvE,MAAM,CAAC,KAAK,EAAE,IAAyC,EAAE,EAAE;QAC1D,MAAM,CAAC,GAAG,SAAS,EAAE,CAAC;QACtB,MAAM,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QAC9B,MAAM,IAAI,GAA4B,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC;QACxD,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI;YAAE,IAAI,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;QACrD,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACrD,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QAC9B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,WAAW,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,GAAG;SACA,OAAO,CAAC,UAAU,CAAC;SACnB,WAAW,CAAC,wBAAwB,CAAC;SACrC,MAAM,CAAC,KAAK,EAAE,EAAU,EAAE,EAAE;QAC3B,MAAM,CAAC,GAAG,SAAS,EAAE,CAAC;QACtB,MAAM,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QAC9B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,GAAG,CACzC,EAAkD,CACnD,CAAC;YACF,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QAC9B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,WAAW,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/commands/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAiB/D,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,aAAa,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAiD7F"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { buildClient } from '../client.js';
|
|
3
|
+
import { printResult, handleError } from '../output.js';
|
|
4
|
+
/**
|
|
5
|
+
* Render search results as a human-readable table (position, title, url, snippet).
|
|
6
|
+
*
|
|
7
|
+
* The CLI never surfaces provider-specific fields — only the ranked result
|
|
8
|
+
* columns the API returns.
|
|
9
|
+
*/
|
|
10
|
+
function renderTable(response) {
|
|
11
|
+
for (const result of response.results) {
|
|
12
|
+
console.log(`${result.position}. ${result.title}`);
|
|
13
|
+
console.log(` ${result.url}`);
|
|
14
|
+
console.log(` ${result.snippet}`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export function makeSearchCommand(getGlobal) {
|
|
18
|
+
return new Command('search')
|
|
19
|
+
.description('Run a web search and return ranked results')
|
|
20
|
+
.argument('<query>', 'Search query')
|
|
21
|
+
.option('--type <type>', 'Search index to query: web (default), news, or images')
|
|
22
|
+
.option('--limit <n>', 'Maximum number of results to return (1–100)')
|
|
23
|
+
.option('--country <code>', 'Two-letter country code to localize results (e.g. us, de)')
|
|
24
|
+
.option('--language <code>', 'Two-letter language code for results (e.g. en, fr)')
|
|
25
|
+
.option('--date-range <window>', 'Restrict results to a recency window: any (default), hour, day, week, month, or year')
|
|
26
|
+
.action(async (query, opts) => {
|
|
27
|
+
const g = getGlobal();
|
|
28
|
+
const client = buildClient(g);
|
|
29
|
+
// Build SearchOpts from the positional arg plus any provided flags.
|
|
30
|
+
// Omit absent optionals so we never send undefined/NaN over the wire.
|
|
31
|
+
// type/date_range are passed through verbatim; the API validates the
|
|
32
|
+
// allowed values, so the CLI stays additive and forward-compatible.
|
|
33
|
+
const body = { query };
|
|
34
|
+
if (opts.type !== undefined)
|
|
35
|
+
body.type = opts.type;
|
|
36
|
+
if (opts.limit !== undefined)
|
|
37
|
+
body.limit = Number(opts.limit);
|
|
38
|
+
if (opts.country !== undefined)
|
|
39
|
+
body.country = opts.country;
|
|
40
|
+
if (opts.language !== undefined)
|
|
41
|
+
body.language = opts.language;
|
|
42
|
+
if (opts.dateRange !== undefined)
|
|
43
|
+
body.date_range = opts.dateRange;
|
|
44
|
+
try {
|
|
45
|
+
const result = await client.search.query(body);
|
|
46
|
+
if (g.json) {
|
|
47
|
+
printResult(result, true);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
renderTable(result);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
handleError(err);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../src/commands/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,OAAO,EAAE,WAAW,EAAsB,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAExD;;;;;GAKG;AACH,SAAS,WAAW,CAAC,QAAwB;IAC3C,KAAK,MAAM,MAAM,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;QACtC,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;QACnD,OAAO,CAAC,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;QAChC,OAAO,CAAC,GAAG,CAAC,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IACtC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,SAAkD;IAClF,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC;SACzB,WAAW,CAAC,4CAA4C,CAAC;SACzD,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC;SACnC,MAAM,CAAC,eAAe,EAAE,uDAAuD,CAAC;SAChF,MAAM,CAAC,aAAa,EAAE,6CAA6C,CAAC;SACpE,MAAM,CAAC,kBAAkB,EAAE,2DAA2D,CAAC;SACvF,MAAM,CAAC,mBAAmB,EAAE,oDAAoD,CAAC;SACjF,MAAM,CACL,uBAAuB,EACvB,sFAAsF,CACv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":["../../src/commands/sitemap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAG/D,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,aAAa,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAiC9F"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { buildClient } from '../client.js';
|
|
3
|
+
import { printResult, handleError } from '../output.js';
|
|
4
|
+
export function makeSitemapCommand(getGlobal) {
|
|
5
|
+
const cmd = new Command('sitemap').description('Sitemap crawl operations');
|
|
6
|
+
cmd
|
|
7
|
+
.command('create')
|
|
8
|
+
.description('Start a sitemap crawl')
|
|
9
|
+
.requiredOption('--url <url>', 'Root URL to crawl')
|
|
10
|
+
.action(async (opts) => {
|
|
11
|
+
const g = getGlobal();
|
|
12
|
+
const client = buildClient(g);
|
|
13
|
+
try {
|
|
14
|
+
const result = await client.sitemap.create({ url: opts.url });
|
|
15
|
+
printResult(result, g.json);
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
handleError(err);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
cmd
|
|
22
|
+
.command('get <id>')
|
|
23
|
+
.description('Get a sitemap job by ID')
|
|
24
|
+
.action(async (id) => {
|
|
25
|
+
const g = getGlobal();
|
|
26
|
+
const client = buildClient(g);
|
|
27
|
+
try {
|
|
28
|
+
const result = await client.sitemap.get(id);
|
|
29
|
+
printResult(result, g.json);
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
handleError(err);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return cmd;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=sitemap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sitemap.js","source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AAC;YACxF,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QAC9B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,WAAW,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoBpC,6GAA6G;AAC7G,wBAAgB,YAAY,IAAI,OAAO,CAgCtC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import { makeScrapeCommand } from './commands/scrape.js';
|
|
5
|
+
import { makeScreenshotsCommand } from './commands/screenshots.js';
|
|
6
|
+
import { makeRecordingsCommand } from './commands/recordings.js';
|
|
7
|
+
import { makeBulkCommand } from './commands/bulk.js';
|
|
8
|
+
import { makeFetchCommand } from './commands/fetch.js';
|
|
9
|
+
import { makeMonitorsCommand } from './commands/monitors.js';
|
|
10
|
+
import { makeSitemapCommand } from './commands/sitemap.js';
|
|
11
|
+
import { makeSearchCommand } from './commands/search.js';
|
|
12
|
+
import { makeAccountCommand } from './commands/account.js';
|
|
13
|
+
// Resolve version from package.json at runtime (supports compiled output).
|
|
14
|
+
const require = createRequire(import.meta.url);
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
16
|
+
const pkg = require('../package.json');
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
18
|
+
const version = typeof pkg.version === 'string' ? pkg.version : '0.1.0';
|
|
19
|
+
/** Construct the root CLI program. Exported so tests can inspect identity/structure without parsing argv. */
|
|
20
|
+
export function buildProgram() {
|
|
21
|
+
const program = new Command();
|
|
22
|
+
program
|
|
23
|
+
.name('bytekit')
|
|
24
|
+
.description('ByteKit CLI — capture, scrape, monitor')
|
|
25
|
+
.version(version)
|
|
26
|
+
.option('--key <key>', 'API key (or set RAPIDCRAWL_API_KEY)')
|
|
27
|
+
.option('--base-url <url>', 'Base URL override (or set RAPIDCRAWL_BASE_URL)')
|
|
28
|
+
.option('--json', 'Output raw JSON');
|
|
29
|
+
/** Read global options from the root program instance. */
|
|
30
|
+
const getGlobal = () => {
|
|
31
|
+
const opts = program.opts();
|
|
32
|
+
return {
|
|
33
|
+
key: opts.key,
|
|
34
|
+
baseUrl: opts.baseUrl,
|
|
35
|
+
json: opts.json === true,
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
program.addCommand(makeScrapeCommand(getGlobal));
|
|
39
|
+
program.addCommand(makeScreenshotsCommand(getGlobal));
|
|
40
|
+
program.addCommand(makeRecordingsCommand(getGlobal));
|
|
41
|
+
program.addCommand(makeBulkCommand(getGlobal));
|
|
42
|
+
program.addCommand(makeFetchCommand(getGlobal));
|
|
43
|
+
program.addCommand(makeMonitorsCommand(getGlobal));
|
|
44
|
+
program.addCommand(makeSitemapCommand(getGlobal));
|
|
45
|
+
program.addCommand(makeSearchCommand(getGlobal));
|
|
46
|
+
program.addCommand(makeAccountCommand(getGlobal));
|
|
47
|
+
return program;
|
|
48
|
+
}
|
|
49
|
+
// Only parse argv when run as the entrypoint, not when imported by tests.
|
|
50
|
+
if (process.argv[1] && import.meta.url === `file://${process.argv[1]}`) {
|
|
51
|
+
buildProgram().parse(process.argv);
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,E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AO,CAAC,IAAI,EAAsD,CAAC;QAChF,OAAO;YACL,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI,EAAE,IAAI,CAAC,IAAI,KAAK,IAAI;SACzB,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,CAAC;IACjD,OAAO,CAAC,UAAU,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC,CAAC;IACtD,OAAO,CAAC,UAAU,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,CAAC;IACrD,OAAO,CAAC,UAAU,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC;IAC/C,OAAO,CAAC,UAAU,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC;IAChD,OAAO,CAAC,UAAU,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC,CAAC;IACnD,OAAO,CAAC,UAAU,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,CAAC;IAClD,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,CAAC;IACjD,OAAO,CAAC,UAAU,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,CAAC;IAElD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,0EAA0E;AAC1E,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,UAAU,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACvE,YAAY,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read a newline-delimited file of URLs and return a flat array of URL strings.
|
|
3
|
+
*
|
|
4
|
+
* Each non-blank line is either a plain URL or a JSON object of the form
|
|
5
|
+
* `{"url":"https://..."}`. Both forms normalize to the bare URL string, because
|
|
6
|
+
* the v1 bulk endpoints (`/v1/bulk`, `/v1/scrape/bulk`, `/v1/fetch/bulk`) expect
|
|
7
|
+
* `urls` to be an array of URL strings — NOT an array of objects.
|
|
8
|
+
*
|
|
9
|
+
* Throws on a missing file (ENOENT from readFileSync) — callers surface this via
|
|
10
|
+
* their handleError path.
|
|
11
|
+
*/
|
|
12
|
+
export declare function parseUrlLines(file: string): string[];
|
|
13
|
+
//# sourceMappingURL=url-lines.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-lines.d.ts","sourceRoot":"","sources":["../../src/lib/url-lines.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAmBpD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
/**
|
|
3
|
+
* Read a newline-delimited file of URLs and return a flat array of URL strings.
|
|
4
|
+
*
|
|
5
|
+
* Each non-blank line is either a plain URL or a JSON object of the form
|
|
6
|
+
* `{"url":"https://..."}`. Both forms normalize to the bare URL string, because
|
|
7
|
+
* the v1 bulk endpoints (`/v1/bulk`, `/v1/scrape/bulk`, `/v1/fetch/bulk`) expect
|
|
8
|
+
* `urls` to be an array of URL strings — NOT an array of objects.
|
|
9
|
+
*
|
|
10
|
+
* Throws on a missing file (ENOENT from readFileSync) — callers surface this via
|
|
11
|
+
* their handleError path.
|
|
12
|
+
*/
|
|
13
|
+
export function parseUrlLines(file) {
|
|
14
|
+
return readFileSync(file, 'utf8')
|
|
15
|
+
.split('\n')
|
|
16
|
+
.map((l) => l.trim())
|
|
17
|
+
.filter((l) => l.length > 0)
|
|
18
|
+
.map((line) => {
|
|
19
|
+
try {
|
|
20
|
+
const parsed = JSON.parse(line);
|
|
21
|
+
if (parsed !== null && typeof parsed === 'object' && 'url' in parsed) {
|
|
22
|
+
const url = parsed.url;
|
|
23
|
+
if (typeof url === 'string')
|
|
24
|
+
return url;
|
|
25
|
+
}
|
|
26
|
+
// Parsed as JSON but not a {url:string} object — fall back to the raw line.
|
|
27
|
+
return line;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// Not JSON — treat the whole line as a plain URL string.
|
|
31
|
+
return line;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=url-lines.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-lines.js","sourceRoot":"","sources":["../../src/lib/url-lines.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC;SAC9B,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SACpB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;SAC3B,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACZ,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAY,CAAC;YAC3C,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,IAAI,MAAM,EAAE,CAAC;gBACrE,MAAM,GAAG,GAAY,MAAM,CAAC,GAAG,CAAC;gBAChC,IAAI,OAAO,GAAG,KAAK,QAAQ;oBAAE,OAAO,GAAG,CAAC;YAC1C,CAAC;YACD,4EAA4E;YAC5E,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,yDAAyD;YACzD,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/output.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Print a result to stdout.
|
|
3
|
+
*
|
|
4
|
+
* With --json: raw JSON. Without: key-value pairs for objects, or the value as-is.
|
|
5
|
+
*/
|
|
6
|
+
export declare function printResult(data: unknown, jsonMode: boolean): void;
|
|
7
|
+
/**
|
|
8
|
+
* Handle a CLI command error: print to stderr and exit 1.
|
|
9
|
+
*/
|
|
10
|
+
export declare function handleError(err: unknown): never;
|
|
11
|
+
//# sourceMappingURL=output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI,CAqBlE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,KAAK,CAa/C"}
|
package/dist/output.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Print a result to stdout.
|
|
3
|
+
*
|
|
4
|
+
* With --json: raw JSON. Without: key-value pairs for objects, or the value as-is.
|
|
5
|
+
*/
|
|
6
|
+
export function printResult(data, jsonMode) {
|
|
7
|
+
if (jsonMode) {
|
|
8
|
+
console.log(JSON.stringify(data, null, 2));
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if (data === null || data === undefined) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (typeof data === 'object' && !Array.isArray(data)) {
|
|
15
|
+
const obj = data;
|
|
16
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
18
|
+
const display = typeof value === 'object' ? JSON.stringify(value) : String(value);
|
|
19
|
+
console.log(`${key}: ${display}`);
|
|
20
|
+
}
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
console.log(JSON.stringify(data, null, 2));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Handle a CLI command error: print to stderr and exit 1.
|
|
27
|
+
*/
|
|
28
|
+
export function handleError(err) {
|
|
29
|
+
if (err instanceof Error) {
|
|
30
|
+
const hasStatus = 'status' in err && typeof err.status === 'number';
|
|
31
|
+
if (hasStatus) {
|
|
32
|
+
const apiErr = err;
|
|
33
|
+
console.error(`Error: ${apiErr.message} (status: ${apiErr.status})`);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
console.error(`Error: ${err.message}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
console.error(`Error: ${String(err)}`);
|
|
41
|
+
}
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,IAAa,EAAE,QAAiB;IAC1D,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC3C,OAAO;IACT,CAAC;IAED,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxC,OAAO;IACT,CAAC;IAED,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACrD,MAAM,GAAG,GAAG,IAA+B,CAAC;QAC5C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YAC/C,gEAAgE;YAChE,MAAM,OAAO,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAClF,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,KAAK,OAAO,EAAE,CAAC,CAAC;QACpC,CAAC;QACD,OAAO;IACT,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,GAAY;IACtC,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;QACzB,MAAM,SAAS,GAAG,QAAQ,IAAI,GAAG,IAAI,OAAQ,GAA2B,CAAC,MAAM,KAAK,QAAQ,CAAC;QAC7F,IAAI,SAAS,EAAE,CAAC;YACd,MAAM,MAAM,GAAG,GAAiC,CAAC;YACjD,OAAO,CAAC,KAAK,CAAC,UAAU,MAAM,CAAC,OAAO,aAAa,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QACvE,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,UAAU,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hunt-labs/bytekit-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "ByteKit CLI — wraps @hunt-labs/bytekit-sdk as shell subcommands",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/Hunt-Labs-Inc/ByteKit.git",
|
|
12
|
+
"directory": "packages/cli"
|
|
13
|
+
},
|
|
14
|
+
"bin": {
|
|
15
|
+
"bytekit": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"main": "./dist/index.js",
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"commander": "^12.0.0",
|
|
23
|
+
"@hunt-labs/bytekit-sdk": "0.1.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/node": "^22.0.0",
|
|
27
|
+
"typescript": "^5.0.0",
|
|
28
|
+
"vitest": "^1.0.0"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsc",
|
|
32
|
+
"typecheck": "tsc --noEmit",
|
|
33
|
+
"test": "vitest run"
|
|
34
|
+
}
|
|
35
|
+
}
|