@beel_es/cli 0.1.1 → 0.1.2
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 +1 -1
- package/dist/index.js +31 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ npx @beel_es/cli invoices export-excel --output invoices.xlsx
|
|
|
36
36
|
npx @beel_es/cli --live invoices list # production
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
`--data` accepts inline JSON, `@file.json`, or `-` for stdin. Binary responses (PDF, ZIP, Excel) require `--output <path>`.
|
|
39
|
+
`--data` accepts inline JSON, `@file.json`, or `-` for stdin. It is only **required** for endpoints whose request body is mandatory (e.g. `invoices create`); for lifecycle actions with an optional body (e.g. `invoices mark-paid`) it is optional, and verbs with no body (e.g. `invoices issue`) don't expose it at all. Each command's `--help` shows whether `--data` is required or optional. Binary responses (PDF, ZIP, Excel) require `--output <path>`.
|
|
40
40
|
|
|
41
41
|
Discover everything with `--help` at any level: `beel --help`, `beel invoices --help`, `beel invoices list --help` (flags, enums and defaults come from the API spec).
|
|
42
42
|
|
package/dist/index.js
CHANGED
|
@@ -10797,7 +10797,7 @@ var require_package = __commonJS({
|
|
|
10797
10797
|
"package.json"(exports, module) {
|
|
10798
10798
|
module.exports = {
|
|
10799
10799
|
name: "@beel_es/cli",
|
|
10800
|
-
version: "0.1.
|
|
10800
|
+
version: "0.1.2",
|
|
10801
10801
|
description: "Agent-first CLI for the BeeL invoicing API. Commands are derived at startup from the embedded OpenAPI spec. Run with npx @beel_es/cli \u2014 no install needed.",
|
|
10802
10802
|
license: "MIT",
|
|
10803
10803
|
type: "module",
|
|
@@ -10964,7 +10964,22 @@ function printJson(data) {
|
|
|
10964
10964
|
process.stdout.write(`${JSON.stringify(data, null, 2)}
|
|
10965
10965
|
`);
|
|
10966
10966
|
}
|
|
10967
|
+
var INFO_CODES = /* @__PURE__ */ new Set(["commander.help", "commander.helpDisplayed", "commander.version"]);
|
|
10968
|
+
function commanderErrorToContract(error) {
|
|
10969
|
+
if (INFO_CODES.has(error.code) || error.exitCode === 0) {
|
|
10970
|
+
return { contract: null, exit: error.exitCode };
|
|
10971
|
+
}
|
|
10972
|
+
return { contract: { code: "USAGE_ERROR", message: stripErrorPrefix(error.message) }, exit: EXIT.USAGE };
|
|
10973
|
+
}
|
|
10974
|
+
function stripErrorPrefix(message) {
|
|
10975
|
+
return message.replace(/^error:\s*/i, "");
|
|
10976
|
+
}
|
|
10967
10977
|
function fail(error) {
|
|
10978
|
+
if (error instanceof CommanderError) {
|
|
10979
|
+
const { contract, exit } = commanderErrorToContract(error);
|
|
10980
|
+
if (contract) writeError({ code: contract.code, message: contract.message });
|
|
10981
|
+
process.exit(exit);
|
|
10982
|
+
}
|
|
10968
10983
|
if (error instanceof UsageError) {
|
|
10969
10984
|
writeError({ code: "USAGE_ERROR", message: error.message });
|
|
10970
10985
|
process.exit(EXIT.USAGE);
|
|
@@ -11081,10 +11096,11 @@ function buildQueryParams(doc, rawParams) {
|
|
|
11081
11096
|
function deriveBody(doc, operation) {
|
|
11082
11097
|
const requestBody = resolveRef(doc, operation.requestBody);
|
|
11083
11098
|
const content = requestBody?.content;
|
|
11084
|
-
if (!content) return null;
|
|
11085
|
-
|
|
11086
|
-
if ("
|
|
11087
|
-
return
|
|
11099
|
+
if (!content) return { kind: null, required: false };
|
|
11100
|
+
const required = requestBody?.required === true;
|
|
11101
|
+
if ("application/json" in content) return { kind: "json", required };
|
|
11102
|
+
if ("multipart/form-data" in content) return { kind: "multipart", required };
|
|
11103
|
+
return { kind: null, required: false };
|
|
11088
11104
|
}
|
|
11089
11105
|
function deriveBinaryResponse(doc, operation) {
|
|
11090
11106
|
const responses = operation.responses ?? {};
|
|
@@ -11107,6 +11123,7 @@ function buildManifest(doc) {
|
|
|
11107
11123
|
const operation = pathItem[method];
|
|
11108
11124
|
if (!operation || typeof operation.operationId !== "string") continue;
|
|
11109
11125
|
const group = deriveGroup(path);
|
|
11126
|
+
const body = deriveBody(doc, operation);
|
|
11110
11127
|
commands.push({
|
|
11111
11128
|
group,
|
|
11112
11129
|
action: deriveAction(group, operation.operationId, method, path),
|
|
@@ -11116,7 +11133,8 @@ function buildManifest(doc) {
|
|
|
11116
11133
|
operationId: operation.operationId,
|
|
11117
11134
|
pathParams: extractPathParams(path),
|
|
11118
11135
|
queryParams: buildQueryParams(doc, [...sharedParams, ...operation.parameters ?? []]),
|
|
11119
|
-
body:
|
|
11136
|
+
body: body.kind,
|
|
11137
|
+
bodyRequired: body.required,
|
|
11120
11138
|
binaryResponse: deriveBinaryResponse(doc, operation)
|
|
11121
11139
|
});
|
|
11122
11140
|
}
|
|
@@ -11260,7 +11278,10 @@ function registerCommand(group, spec) {
|
|
|
11260
11278
|
else sub.option(flag, description);
|
|
11261
11279
|
}
|
|
11262
11280
|
if (spec.body === "json") {
|
|
11263
|
-
|
|
11281
|
+
const hint = spec.bodyRequired ? "JSON body (required)" : "JSON body (optional)";
|
|
11282
|
+
const description = `${hint}: inline, @file.json, or - for stdin`;
|
|
11283
|
+
if (spec.bodyRequired) sub.requiredOption("--data <json>", description);
|
|
11284
|
+
else sub.option("--data <json>", description);
|
|
11264
11285
|
}
|
|
11265
11286
|
if (spec.binaryResponse) {
|
|
11266
11287
|
sub.requiredOption("--output <path>", "Write the binary response to this file");
|
|
@@ -11511,6 +11532,9 @@ var { version } = require_package();
|
|
|
11511
11532
|
var program2 = new Command("beel").description(
|
|
11512
11533
|
"BeeL invoicing API CLI. JSON output on stdout, errors on stderr. Sandbox by default; pass --live for production."
|
|
11513
11534
|
).version(version).option("--live", "Use the live (production) API key instead of the test one");
|
|
11535
|
+
program2.exitOverride();
|
|
11536
|
+
program2.configureOutput({ outputError: () => {
|
|
11537
|
+
} });
|
|
11514
11538
|
registerLogin(program2);
|
|
11515
11539
|
registerConfig(program2);
|
|
11516
11540
|
registerRequest(program2);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beel_es/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Agent-first CLI for the BeeL invoicing API. Commands are derived at startup from the embedded OpenAPI spec. Run with npx @beel_es/cli — no install needed.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|