@invinite-org/invinite-data-cli 0.3.4 → 0.5.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/README.md +89 -751
- package/claude-plugin/.claude-plugin/plugin.json +1 -1
- package/claude-plugin/agents/invinite-data.md +1 -1
- package/claude-plugin/commands/analyze-earnings-call.md +5 -4
- package/claude-plugin/skills/invinite-data-cli/SKILL.md +446 -180
- package/dist/src/cli.d.ts +6 -0
- package/dist/src/cli.js +21 -31
- package/dist/src/cli.js.map +1 -1
- package/dist/src/client/api-client.d.ts +2 -4
- package/dist/src/client/api-client.js +3 -9
- package/dist/src/client/api-client.js.map +1 -1
- package/dist/src/client/pagination.d.ts +10 -0
- package/dist/src/client/pagination.js +40 -0
- package/dist/src/client/pagination.js.map +1 -1
- package/dist/src/commands/earnings.d.ts +4 -3
- package/dist/src/commands/earnings.js +163 -466
- package/dist/src/commands/earnings.js.map +1 -1
- package/dist/src/generated/cli-manifest.json +4983 -0
- package/dist/src/hand-written-commands.d.ts +43 -0
- package/dist/src/hand-written-commands.js +21 -0
- package/dist/src/hand-written-commands.js.map +1 -0
- package/dist/src/shared/errors.d.ts +5 -0
- package/dist/src/shared/errors.js +12 -0
- package/dist/src/shared/errors.js.map +1 -1
- package/dist/src/shared/options.d.ts +0 -13
- package/dist/src/shared/options.js +0 -13
- package/dist/src/shared/options.js.map +1 -1
- package/dist/src/spec-commands.d.ts +10 -0
- package/dist/src/spec-commands.js +207 -0
- package/dist/src/spec-commands.js.map +1 -0
- package/dist/src/spec-flags.d.ts +6 -0
- package/dist/src/spec-flags.js +9 -0
- package/dist/src/spec-flags.js.map +1 -0
- package/dist/src/spec-manifest.d.ts +382 -0
- package/dist/src/spec-manifest.js +65 -0
- package/dist/src/spec-manifest.js.map +1 -0
- package/package.json +7 -3
- package/dist/src/commands/company.d.ts +0 -2
- package/dist/src/commands/company.js +0 -220
- package/dist/src/commands/company.js.map +0 -1
- package/dist/src/commands/earnings-selector.d.ts +0 -15
- package/dist/src/commands/earnings-selector.js +0 -29
- package/dist/src/commands/earnings-selector.js.map +0 -1
- package/dist/src/commands/filings.d.ts +0 -2
- package/dist/src/commands/filings.js +0 -139
- package/dist/src/commands/filings.js.map +0 -1
- package/dist/src/commands/financials.d.ts +0 -2
- package/dist/src/commands/financials.js +0 -162
- package/dist/src/commands/financials.js.map +0 -1
- package/dist/src/commands/health.d.ts +0 -2
- package/dist/src/commands/health.js +0 -18
- package/dist/src/commands/health.js.map +0 -1
- package/dist/src/commands/insider-trades.d.ts +0 -2
- package/dist/src/commands/insider-trades.js +0 -56
- package/dist/src/commands/insider-trades.js.map +0 -1
- package/dist/src/commands/ipos.d.ts +0 -2
- package/dist/src/commands/ipos.js +0 -42
- package/dist/src/commands/ipos.js.map +0 -1
- package/dist/src/commands/market.d.ts +0 -2
- package/dist/src/commands/market.js +0 -34
- package/dist/src/commands/market.js.map +0 -1
- package/dist/src/commands/metadata.d.ts +0 -2
- package/dist/src/commands/metadata.js +0 -39
- package/dist/src/commands/metadata.js.map +0 -1
- package/dist/src/commands/metrics.d.ts +0 -2
- package/dist/src/commands/metrics.js +0 -158
- package/dist/src/commands/metrics.js.map +0 -1
- package/dist/src/commands/ownership.d.ts +0 -2
- package/dist/src/commands/ownership.js +0 -152
- package/dist/src/commands/ownership.js.map +0 -1
- package/dist/src/commands/segments.d.ts +0 -2
- package/dist/src/commands/segments.js +0 -64
- package/dist/src/commands/segments.js.map +0 -1
- package/dist/src/commands/usage.d.ts +0 -38
- package/dist/src/commands/usage.js +0 -82
- package/dist/src/commands/usage.js.map +0 -1
- package/dist/src/commands/webhooks.d.ts +0 -16
- package/dist/src/commands/webhooks.js +0 -186
- package/dist/src/commands/webhooks.js.map +0 -1
- package/dist/src/formatters/sparkline.d.ts +0 -2
- package/dist/src/formatters/sparkline.js +0 -11
- package/dist/src/formatters/sparkline.js.map +0 -1
- package/dist/src/formatters/tree-formatter.d.ts +0 -11
- package/dist/src/formatters/tree-formatter.js +0 -30
- package/dist/src/formatters/tree-formatter.js.map +0 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The commands `invd` writes by hand, each with WHY it is not one REST call plus one view. Every other command is
|
|
3
|
+
* generated from the manifest (`src/spec-commands.ts`); `tests/unit/command-roster.test.ts` fails on a hand-written
|
|
4
|
+
* command missing here, on an entry that registers nothing, and on an entry that is also a manifest operation.
|
|
5
|
+
* An entry is a top-level command (`group`, covering its subcommands) or one `group action`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const HAND_WRITTEN_COMMANDS: readonly [{
|
|
8
|
+
readonly command: "login";
|
|
9
|
+
readonly reason: "Clerk PKCE sign-in in the browser, then the local credential store";
|
|
10
|
+
}, {
|
|
11
|
+
readonly command: "logout";
|
|
12
|
+
readonly reason: "clears the local credential store";
|
|
13
|
+
}, {
|
|
14
|
+
readonly command: "config";
|
|
15
|
+
readonly reason: "local settings (API key, API host)";
|
|
16
|
+
}, {
|
|
17
|
+
readonly command: "plugin";
|
|
18
|
+
readonly reason: "copies the bundled Claude plugin into agent config dirs";
|
|
19
|
+
}, {
|
|
20
|
+
readonly command: "ws";
|
|
21
|
+
readonly reason: "WebSocket stream (/v1/ws); --earnings is the live transcript (src/client/earnings-live.ts)";
|
|
22
|
+
}, {
|
|
23
|
+
readonly command: "earnings transcript";
|
|
24
|
+
readonly reason: "renders the transcript as text and saves it with -o";
|
|
25
|
+
}, {
|
|
26
|
+
readonly command: "earnings press-release";
|
|
27
|
+
readonly reason: "prints the release text with --body and saves it with -o";
|
|
28
|
+
}, {
|
|
29
|
+
readonly command: "earnings audio";
|
|
30
|
+
readonly reason: "downloads the recording from its signed URL with -o";
|
|
31
|
+
}, {
|
|
32
|
+
readonly command: "earnings slides";
|
|
33
|
+
readonly reason: "downloads the deck PDF with -o, prints page markdown with --markdown";
|
|
34
|
+
}, {
|
|
35
|
+
readonly command: "earnings documents";
|
|
36
|
+
readonly reason: "downloads every document into a directory with -o";
|
|
37
|
+
}, {
|
|
38
|
+
readonly command: "earnings company-documents";
|
|
39
|
+
readonly reason: "downloads every stored file into a directory with -o";
|
|
40
|
+
}, {
|
|
41
|
+
readonly command: "earnings document";
|
|
42
|
+
readonly reason: "downloads the file, or fetches and renders its page text with --pages";
|
|
43
|
+
}];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The commands `invd` writes by hand, each with WHY it is not one REST call plus one view. Every other command is
|
|
3
|
+
* generated from the manifest (`src/spec-commands.ts`); `tests/unit/command-roster.test.ts` fails on a hand-written
|
|
4
|
+
* command missing here, on an entry that registers nothing, and on an entry that is also a manifest operation.
|
|
5
|
+
* An entry is a top-level command (`group`, covering its subcommands) or one `group action`.
|
|
6
|
+
*/
|
|
7
|
+
export const HAND_WRITTEN_COMMANDS = [
|
|
8
|
+
{ command: 'login', reason: 'Clerk PKCE sign-in in the browser, then the local credential store' },
|
|
9
|
+
{ command: 'logout', reason: 'clears the local credential store' },
|
|
10
|
+
{ command: 'config', reason: 'local settings (API key, API host)' },
|
|
11
|
+
{ command: 'plugin', reason: 'copies the bundled Claude plugin into agent config dirs' },
|
|
12
|
+
{ command: 'ws', reason: 'WebSocket stream (/v1/ws); --earnings is the live transcript (src/client/earnings-live.ts)' },
|
|
13
|
+
{ command: 'earnings transcript', reason: 'renders the transcript as text and saves it with -o' },
|
|
14
|
+
{ command: 'earnings press-release', reason: 'prints the release text with --body and saves it with -o' },
|
|
15
|
+
{ command: 'earnings audio', reason: 'downloads the recording from its signed URL with -o' },
|
|
16
|
+
{ command: 'earnings slides', reason: 'downloads the deck PDF with -o, prints page markdown with --markdown' },
|
|
17
|
+
{ command: 'earnings documents', reason: 'downloads every document into a directory with -o' },
|
|
18
|
+
{ command: 'earnings company-documents', reason: 'downloads every stored file into a directory with -o' },
|
|
19
|
+
{ command: 'earnings document', reason: 'downloads the file, or fetches and renders its page text with --pages' },
|
|
20
|
+
];
|
|
21
|
+
//# sourceMappingURL=hand-written-commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hand-written-commands.js","sourceRoot":"","sources":["../../src/hand-written-commands.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,oEAAoE,EAAE;IAClG,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,mCAAmC,EAAE;IAClE,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,oCAAoC,EAAE;IACnE,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,yDAAyD,EAAE;IACxF,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,4FAA4F,EAAE;IACvH,EAAE,OAAO,EAAE,qBAAqB,EAAE,MAAM,EAAE,qDAAqD,EAAE;IACjG,EAAE,OAAO,EAAE,wBAAwB,EAAE,MAAM,EAAE,0DAA0D,EAAE;IACzG,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,qDAAqD,EAAE;IAC5F,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,sEAAsE,EAAE;IAC9G,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,mDAAmD,EAAE;IAC9F,EAAE,OAAO,EAAE,4BAA4B,EAAE,MAAM,EAAE,sDAAsD,EAAE;IACzG,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,uEAAuE,EAAE;CACzG,CAAC"}
|
|
@@ -3,5 +3,10 @@ export declare class ApiError extends Error {
|
|
|
3
3
|
errorType: string;
|
|
4
4
|
constructor(statusCode: number, errorType: string, message: string);
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* One dim line after an `ApiError` a person can act on: a 401 points at `invd login`, a 403 whose message names the
|
|
8
|
+
* plan a route needs ("requires the PRO plan") names that plan.
|
|
9
|
+
*/
|
|
10
|
+
export declare function apiErrorHint(error: ApiError): string | undefined;
|
|
6
11
|
/** `hint` may add one dim line after an `ApiError` (e.g. which plan a route needs). */
|
|
7
12
|
export declare function withErrorHandling(fn: (...args: any[]) => Promise<void>, hint?: (error: ApiError) => string | undefined): (...args: any[]) => Promise<void>;
|
|
@@ -9,6 +9,18 @@ export class ApiError extends Error {
|
|
|
9
9
|
this.name = 'ApiError';
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* One dim line after an `ApiError` a person can act on: a 401 points at `invd login`, a 403 whose message names the
|
|
14
|
+
* plan a route needs ("requires the PRO plan") names that plan.
|
|
15
|
+
*/
|
|
16
|
+
export function apiErrorHint(error) {
|
|
17
|
+
if (error.statusCode === 401)
|
|
18
|
+
return 'Run: invd login';
|
|
19
|
+
if (error.statusCode !== 403)
|
|
20
|
+
return undefined;
|
|
21
|
+
const tier = /requires (?:the )?(\w+) plan/i.exec(error.message)?.[1];
|
|
22
|
+
return tier ? `This route needs the ${tier} plan` : undefined;
|
|
23
|
+
}
|
|
12
24
|
/** `hint` may add one dim line after an `ApiError` (e.g. which plan a route needs). */
|
|
13
25
|
export function withErrorHandling(fn, hint) {
|
|
14
26
|
return async (...args) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/shared/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,OAAO,QAAS,SAAQ,KAAK;IAExB;IACA;IAFT,YACS,UAAkB,EAClB,SAAiB,EACxB,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QAJR,eAAU,GAAV,UAAU,CAAQ;QAClB,cAAS,GAAT,SAAS,CAAQ;QAIxB,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF;AAED,uFAAuF;AACvF,MAAM,UAAU,iBAAiB,CAC/B,EAAqC,EACrC,IAA8C;IAE9C,OAAO,KAAK,EA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BACN,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC,CAAC;YAC3D,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,15 +1,2 @@
|
|
|
1
|
-
import { Option } from 'commander';
|
|
2
|
-
export declare const identifierOption: Option;
|
|
3
|
-
export declare const identifiersOption: Option;
|
|
4
|
-
export declare const periodOption: Option;
|
|
5
|
-
export declare const sortOption: Option;
|
|
6
|
-
export declare const limitOption: Option;
|
|
7
|
-
export declare const offsetOption: Option;
|
|
8
|
-
export declare const startDateOption: Option;
|
|
9
|
-
export declare const endDateOption: Option;
|
|
10
|
-
export declare const queryOption: Option;
|
|
11
|
-
export declare const cikOption: Option;
|
|
12
|
-
export declare const jsonOption: Option;
|
|
13
|
-
export declare const allOption: Option;
|
|
14
1
|
/** A comma-separated option value → trimmed, de-duplicated, non-empty items. */
|
|
15
2
|
export declare function splitList(value: string | undefined): string[];
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
import { Option } from 'commander';
|
|
2
|
-
export const identifierOption = new Option('-i, --identifier <ticker>', 'Ticker symbol or CIK').makeOptionMandatory();
|
|
3
|
-
export const identifiersOption = new Option('-i, --identifiers <tickers>', 'Comma-separated ticker symbols or CIKs').makeOptionMandatory();
|
|
4
|
-
export const periodOption = new Option('-p, --period <type>', 'Fiscal period type').choices(['quarterly', 'annual', 'ytd', 'ttm']).makeOptionMandatory();
|
|
5
|
-
export const sortOption = new Option('-s, --sort <dir>', 'Sort direction').choices(['asc', 'desc']).default('desc');
|
|
6
|
-
export const limitOption = new Option('-l, --limit <n>', 'Maximum results').default('10');
|
|
7
|
-
export const offsetOption = new Option('--offset <n>', 'Pagination offset').default('0');
|
|
8
|
-
export const startDateOption = new Option('--start-date <date>', 'Start date (YYYY-MM-DD)');
|
|
9
|
-
export const endDateOption = new Option('--end-date <date>', 'End date (YYYY-MM-DD)');
|
|
10
|
-
export const queryOption = new Option('-q, --query <text>', 'Search query').makeOptionMandatory();
|
|
11
|
-
export const cikOption = new Option('--cik <cik>', 'Institution CIK').makeOptionMandatory();
|
|
12
|
-
export const jsonOption = new Option('--json', 'Output raw JSON');
|
|
13
|
-
export const allOption = new Option('--all', 'Auto-paginate through all results');
|
|
14
1
|
/** A comma-separated option value → trimmed, de-duplicated, non-empty items. */
|
|
15
2
|
export function splitList(value) {
|
|
16
3
|
if (!value)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/shared/options.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/shared/options.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,MAAM,UAAU,SAAS,CAAC,KAAyB;IACjD,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IACtB,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACjF,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import type { Manifest } from './spec-manifest.js';
|
|
3
|
+
/**
|
|
4
|
+
* Registers every manifest operation as `invd <group> <action>` (`action: ""` → `invd <group>`): one flag per
|
|
5
|
+
* parameter (path parameters included, never positional), values validated before any request, the request through
|
|
6
|
+
* `apiGet` / `apiRequest` (keyless where the spec says so), `--all` by the operation's pagination, and the operation's
|
|
7
|
+
* view as the human output. A group a hand-written command already registered (`earnings`, whose download commands
|
|
8
|
+
* are rostered in `src/hand-written-commands.ts`) gets the generated actions attached; commander refuses a duplicate.
|
|
9
|
+
*/
|
|
10
|
+
export declare function registerSpecCommands(program: Command, manifest: Manifest): void;
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { Option } from 'commander';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { apiGet, apiRequest } from './client/api-client.js';
|
|
5
|
+
import { fetchAllCompanyPages, fetchAllTopPages } from './client/pagination.js';
|
|
6
|
+
import { flattenRows, pick } from './formatters/flatten.js';
|
|
7
|
+
import { formatJson } from './formatters/json-formatter.js';
|
|
8
|
+
import { formatKeyValue, formatTable, printPaginationHint } from './formatters/table-formatter.js';
|
|
9
|
+
import { apiErrorHint, withErrorHandling } from './shared/errors.js';
|
|
10
|
+
import { splitList } from './shared/options.js';
|
|
11
|
+
import { output } from './shared/output.js';
|
|
12
|
+
import { setJsonMode } from './shared/spinner.js';
|
|
13
|
+
import { flagName } from './spec-flags.js';
|
|
14
|
+
/**
|
|
15
|
+
* Registers every manifest operation as `invd <group> <action>` (`action: ""` → `invd <group>`): one flag per
|
|
16
|
+
* parameter (path parameters included, never positional), values validated before any request, the request through
|
|
17
|
+
* `apiGet` / `apiRequest` (keyless where the spec says so), `--all` by the operation's pagination, and the operation's
|
|
18
|
+
* view as the human output. A group a hand-written command already registered (`earnings`, whose download commands
|
|
19
|
+
* are rostered in `src/hand-written-commands.ts`) gets the generated actions attached; commander refuses a duplicate.
|
|
20
|
+
*/
|
|
21
|
+
export function registerSpecCommands(program, manifest) {
|
|
22
|
+
for (const group of manifest.groups) {
|
|
23
|
+
const operations = manifest.operations.filter(operation => operation.group === group.name);
|
|
24
|
+
const groupCommand = (program.commands.find(command => command.name() === group.name) ?? program.command(group.name))
|
|
25
|
+
.description(group.description);
|
|
26
|
+
for (const operation of operations) {
|
|
27
|
+
const command = operation.action === ''
|
|
28
|
+
? groupCommand
|
|
29
|
+
: groupCommand.command(operation.action).description(operation.summary);
|
|
30
|
+
defineOperationCommand(command, operation);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
35
|
+
function paramOption(param) {
|
|
36
|
+
const long = `--${flagName(param.name)}`;
|
|
37
|
+
const value = param.type === 'boolean' ? '' : param.type === 'array' ? ' <list>' : ' <value>';
|
|
38
|
+
const notes = [];
|
|
39
|
+
if (param.type === 'array') {
|
|
40
|
+
notes.push(param.enum ? `comma-separated: ${param.enum.join(', ')}` : 'comma-separated');
|
|
41
|
+
}
|
|
42
|
+
if (param.default !== undefined)
|
|
43
|
+
notes.push(`default: ${JSON.stringify(param.default)}`);
|
|
44
|
+
const description = [param.description ?? '', notes.length ? `(${notes.join('; ')})` : '']
|
|
45
|
+
.filter(Boolean).join(' ');
|
|
46
|
+
const option = new Option(`${param.alias ? `-${param.alias}, ` : ''}${long}${value}`, description);
|
|
47
|
+
if (param.required)
|
|
48
|
+
option.makeOptionMandatory();
|
|
49
|
+
if (param.enum && param.type !== 'array')
|
|
50
|
+
option.choices(param.enum);
|
|
51
|
+
return option;
|
|
52
|
+
}
|
|
53
|
+
const itemSchema = (type, values) => {
|
|
54
|
+
if (values && values.length > 0)
|
|
55
|
+
return z.string().refine(value => values.includes(value));
|
|
56
|
+
if (type === 'integer')
|
|
57
|
+
return z.string().regex(/^-?\d+$/);
|
|
58
|
+
if (type === 'number')
|
|
59
|
+
return z.string().refine(value => value.trim() !== '' && Number.isFinite(Number(value)));
|
|
60
|
+
return z.string();
|
|
61
|
+
};
|
|
62
|
+
/** The zod check of one parameter's raw flag value, yielding what goes on the wire. */
|
|
63
|
+
function paramSchema(param) {
|
|
64
|
+
if (param.type === 'boolean')
|
|
65
|
+
return z.boolean().transform(value => String(value));
|
|
66
|
+
if (param.type === 'array') {
|
|
67
|
+
return z.string().transform(value => splitList(value)).pipe(z.array(itemSchema(param.items, param.enum)).min(1));
|
|
68
|
+
}
|
|
69
|
+
if (param.type === 'integer' || param.type === 'number') {
|
|
70
|
+
return z.string().pipe(itemSchema(param.type, undefined)).transform(value => String(Number(value)));
|
|
71
|
+
}
|
|
72
|
+
return z.string();
|
|
73
|
+
}
|
|
74
|
+
function expectation(param) {
|
|
75
|
+
if (param.type === 'array') {
|
|
76
|
+
const item = param.enum ? `one of ${param.enum.join(', ')}` : param.items === 'string' ? 'a value' : `an ${param.items}`;
|
|
77
|
+
return `a comma-separated list, each item ${item}`;
|
|
78
|
+
}
|
|
79
|
+
if (param.type === 'integer')
|
|
80
|
+
return 'an integer';
|
|
81
|
+
if (param.type === 'number')
|
|
82
|
+
return 'a number';
|
|
83
|
+
if (param.type === 'boolean')
|
|
84
|
+
return 'no value';
|
|
85
|
+
return 'a value';
|
|
86
|
+
}
|
|
87
|
+
/** Every given flag validated and converted; refuses by flag name, before any request. */
|
|
88
|
+
function wireValues(bindings, opts) {
|
|
89
|
+
const values = new Map();
|
|
90
|
+
for (const { param, option } of bindings) {
|
|
91
|
+
const raw = opts[option.attributeName()];
|
|
92
|
+
if (raw === undefined)
|
|
93
|
+
continue;
|
|
94
|
+
const parsed = paramSchema(param).safeParse(raw);
|
|
95
|
+
if (!parsed.success) {
|
|
96
|
+
throw new Error(`--${flagName(param.name)} expects ${expectation(param)} (got ${JSON.stringify(raw)})`);
|
|
97
|
+
}
|
|
98
|
+
values.set(param.name, parsed.data);
|
|
99
|
+
}
|
|
100
|
+
return values;
|
|
101
|
+
}
|
|
102
|
+
async function readStdin() {
|
|
103
|
+
const chunks = [];
|
|
104
|
+
for await (const chunk of process.stdin)
|
|
105
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk)));
|
|
106
|
+
return Buffer.concat(chunks).toString('utf8');
|
|
107
|
+
}
|
|
108
|
+
/** `--body <json>` or `--body-file <path|->` → the parsed JSON body; `undefined` when neither was given. */
|
|
109
|
+
async function requestBody(operation, opts) {
|
|
110
|
+
const inline = typeof opts.body === 'string' ? opts.body : undefined;
|
|
111
|
+
const file = typeof opts.bodyFile === 'string' ? opts.bodyFile : undefined;
|
|
112
|
+
if (inline !== undefined && file !== undefined)
|
|
113
|
+
throw new Error('Pass --body or --body-file, not both');
|
|
114
|
+
if (inline === undefined && file === undefined) {
|
|
115
|
+
if (operation.body?.required)
|
|
116
|
+
throw new Error('This command needs a JSON body: --body <json> or --body-file <path|->');
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
const [flag, text] = inline !== undefined
|
|
120
|
+
? ['--body', inline]
|
|
121
|
+
: [`--body-file ${file}`, file === '-' ? await readStdin() : await readFile(file ?? '', 'utf8')];
|
|
122
|
+
try {
|
|
123
|
+
return JSON.parse(text);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
throw new Error(`${flag} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function nextUrlOf(operation, data) {
|
|
130
|
+
const path = operation.pagination === 'top' ? 'next_url'
|
|
131
|
+
: operation.pagination === 'perCompany' ? 'companies.0.next_url' : undefined;
|
|
132
|
+
const found = path ? pick(data, path) : undefined;
|
|
133
|
+
return typeof found === 'string' && found !== '' ? found : undefined;
|
|
134
|
+
}
|
|
135
|
+
function renderView(operation, data) {
|
|
136
|
+
if (operation.view === 'table') {
|
|
137
|
+
const found = operation.rowsPath ? pick(data, operation.rowsPath) : data;
|
|
138
|
+
const rows = Array.isArray(found) ? found : [];
|
|
139
|
+
formatTable(operation.columns ? flattenRows(rows, operation.columns) : rows.filter(isRecord), operation.columns);
|
|
140
|
+
printPaginationHint(nextUrlOf(operation, data));
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (operation.view === 'keyValue') {
|
|
144
|
+
const target = operation.rowsPath ? pick(data, operation.rowsPath) : data;
|
|
145
|
+
if (!isRecord(target)) {
|
|
146
|
+
formatTable([]);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
formatKeyValue(operation.columns ? flattenRows([target], operation.columns)[0] : target);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
formatJson(data);
|
|
153
|
+
}
|
|
154
|
+
function defineOperationCommand(command, operation) {
|
|
155
|
+
const bindings = operation.params.map(param => ({ param, option: paramOption(param) }));
|
|
156
|
+
for (const { option } of bindings)
|
|
157
|
+
command.addOption(option);
|
|
158
|
+
if (operation.body) {
|
|
159
|
+
command.option('--body <json>', `JSON request body${operation.body.required ? ' (this or --body-file is required)' : ''}`);
|
|
160
|
+
command.option('--body-file <path>', 'Read the JSON request body from a file (- = stdin)');
|
|
161
|
+
}
|
|
162
|
+
command.action(withErrorHandling(async (_opts, invoked) => {
|
|
163
|
+
const globals = invoked.optsWithGlobals();
|
|
164
|
+
const json = globals.json === true;
|
|
165
|
+
if (json)
|
|
166
|
+
setJsonMode(true);
|
|
167
|
+
if (globals.all === true && operation.pagination === 'none') {
|
|
168
|
+
throw new Error(`invd ${[operation.group, operation.action].filter(Boolean).join(' ')} does not paginate; --all has nothing to fetch`);
|
|
169
|
+
}
|
|
170
|
+
const values = wireValues(bindings, invoked.opts());
|
|
171
|
+
const body = operation.body ? await requestBody(operation, invoked.opts()) : undefined;
|
|
172
|
+
const path = operation.path.replace(/\{([^}]+)\}/g, (_match, name) => {
|
|
173
|
+
const value = values.get(name);
|
|
174
|
+
return encodeURIComponent(typeof value === 'string' ? value : '');
|
|
175
|
+
});
|
|
176
|
+
const params = {};
|
|
177
|
+
for (const param of operation.params) {
|
|
178
|
+
if (param.in === 'query')
|
|
179
|
+
params[param.name] = values.get(param.name);
|
|
180
|
+
}
|
|
181
|
+
let data = operation.method === 'get'
|
|
182
|
+
? await apiGet({ path, params, auth: operation.auth })
|
|
183
|
+
: await apiRequest({
|
|
184
|
+
auth: operation.auth,
|
|
185
|
+
method: operation.method === 'post' ? 'POST'
|
|
186
|
+
: operation.method === 'put' ? 'PUT'
|
|
187
|
+
: operation.method === 'patch' ? 'PATCH' : 'DELETE',
|
|
188
|
+
path,
|
|
189
|
+
params,
|
|
190
|
+
...(body !== undefined ? { body } : {}),
|
|
191
|
+
});
|
|
192
|
+
if (globals.all === true) {
|
|
193
|
+
const itemsPaths = operation.allItemsPath ?? [];
|
|
194
|
+
data = operation.pagination === 'top'
|
|
195
|
+
? await fetchAllTopPages(data, itemsPaths)
|
|
196
|
+
: await fetchAllCompanyPages(data, itemsPaths);
|
|
197
|
+
}
|
|
198
|
+
if (data === undefined) {
|
|
199
|
+
// A 204: nothing to show but that it worked.
|
|
200
|
+
if (!json)
|
|
201
|
+
console.log('Done.');
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
output(data, { json }, () => renderView(operation, data));
|
|
205
|
+
}, apiErrorHint));
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=spec-commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec-commands.js","sourceRoot":"","sources":["../../src/spec-commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAW,MAAM,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACnG,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,q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CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACxC,CAAC,CAAC;QAEL,IAAI,OAAO,CAAC,GAAG,KAAK,IAAI,EAAE,CAAC;YACzB,MAAM,UAAU,GAAG,SAAS,CAAC,YAAY,IAAI,EAAE,CAAC;YAChD,IAAI,GAAG,SAAS,CAAC,UAAU,KAAK,KAAK;gBACnC,CAAC,CAAC,MAAM,gBAAgB,CAAC,IAAI,EAAE,UAAU,CAAC;gBAC1C,CAAC,CAAC,MAAM,oBAAoB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QACnD,CAAC;QAED,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,6CAA6C;YAC7C,IAAI,CAAC,IAAI;gBAAE,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAChC,OAAO;QACT,CAAC;QACD,MAAM,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;IAC5D,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** A parameter's flag: `company_name` → `company-name` (shown as `--company-name`). */
|
|
2
|
+
export declare function flagName(parameterName: string): string;
|
|
3
|
+
/** Long flags `invd` owns itself: the program's globals, commander's own, and the body flags of a write. */
|
|
4
|
+
export declare const RESERVED_FLAGS: readonly string[];
|
|
5
|
+
/** Short flags commander owns (`-V`, `-h`). */
|
|
6
|
+
export declare const RESERVED_ALIASES: readonly string[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** A parameter's flag: `company_name` → `company-name` (shown as `--company-name`). */
|
|
2
|
+
export function flagName(parameterName) {
|
|
3
|
+
return parameterName.replace(/_/g, '-');
|
|
4
|
+
}
|
|
5
|
+
/** Long flags `invd` owns itself: the program's globals, commander's own, and the body flags of a write. */
|
|
6
|
+
export const RESERVED_FLAGS = ['json', 'all', 'show-cost', 'version', 'help', 'body', 'body-file'];
|
|
7
|
+
/** Short flags commander owns (`-V`, `-h`). */
|
|
8
|
+
export const RESERVED_ALIASES = ['V', 'h'];
|
|
9
|
+
//# sourceMappingURL=spec-flags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec-flags.js","sourceRoot":"","sources":["../../src/spec-flags.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,MAAM,UAAU,QAAQ,CAAC,aAAqB;IAC5C,OAAO,aAAa,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AAC1C,CAAC;AAED,4GAA4G;AAC5G,MAAM,CAAC,MAAM,cAAc,GAAsB,CAAC,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;AAEtH,+CAA+C;AAC/C,MAAM,CAAC,MAAM,gBAAgB,GAAsB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC"}
|