@open-nav/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/LICENSE ADDED
@@ -0,0 +1,29 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 open-nav contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ ---
24
+
25
+ This repository vendors XML schemas, sample documents and validation message
26
+ catalogues published by the Hungarian Tax and Customs Administration
27
+ (Nemzeti Adó- és Vámhivatal) under the MIT license. Those files live under
28
+ `schemas/` and `conformance/`, retain NAV's copyright, and are covered by
29
+ `schemas/NAV-LICENCE.md`. See `schemas/README.md` for provenance.
package/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # @open-nav/cli
2
+
3
+ Command line access to the NAV **Online Számla** invoice service.
4
+
5
+ ```sh
6
+ npx @open-nav/cli --help
7
+ # or
8
+ npm install -g @open-nav/cli && open-nav --help
9
+ ```
10
+
11
+ ## Configuration
12
+
13
+ Credentials come from the environment, or from a `.env` file found by walking
14
+ up from the working directory. They are **never** accepted as command line
15
+ arguments: that would put them in shell history, in process listings, and in
16
+ the transcript of any agent that ran the command.
17
+
18
+ ```sh
19
+ cp .env.example .env # then fill it in
20
+ open-nav config # shows what is set, masks the secrets
21
+ open-nav token # end-to-end check: are the credentials real?
22
+ ```
23
+
24
+ `open-nav help config` lists every variable.
25
+
26
+ ## Built for scripts and agents
27
+
28
+ - **JSON by default when stdout is not a terminal.** No flag to remember; a
29
+ human at a terminal still gets readable text. `--json` and `--pretty`
30
+ override.
31
+ - **One envelope for every result**, so a caller can branch on `ok` alone:
32
+ ```json
33
+ { "ok": true, "command": "validate", "data": { "valid": true } }
34
+ ```
35
+ - **Exit codes that mean something**: `0` ok, `2` usage or configuration, `3`
36
+ the document failed local validation and was not sent, `4` NAV rejected it,
37
+ `5` no verdict reached (network, timeout, still processing).
38
+ - **`--describe`** prints the whole command surface as JSON — names, usage,
39
+ options, exit codes, and whether each command needs credentials. An agent
40
+ can discover what the tool can do without a man page.
41
+
42
+ ```sh
43
+ open-nav --describe | jq '.commands[] | select(.needsCredentials == false)'
44
+ ```
45
+
46
+ ## Commands
47
+
48
+ | Command | Needs credentials | What it does |
49
+ | -------------------------- | ----------------- | ---------------------------------------------------------- |
50
+ | `config` | no | Report which variables are set, masking secrets |
51
+ | `validate <file>` | no | Check an invoice against schema and business rules |
52
+ | `fault <CODE>` | no | Look up NAV's description of a fault code |
53
+ | `token` | yes | Exchange credentials for a token — the quickest smoke test |
54
+ | `taxpayer <taxNumber>` | yes | Look up a taxpayer; accepts the 11 digit written form |
55
+ | `submit <file...>` | yes | Validate, then submit; `--wait` polls for the verdict |
56
+ | `status <transactionId>` | yes | Processing status; `--wait` polls to a verdict |
57
+ | `digest --from --to` | yes | List invoices issued or received in a date range |
58
+ | `invoice <number>` | yes | Fetch one invoice in full; `--xml` prints the XML |
59
+ | `transactions --from --to` | yes | List data submissions in a time window |
60
+
61
+ ## Validating without credentials
62
+
63
+ `validate` and `fault` contact nothing. They are useful before you have a
64
+ technical user at all, and they are the fastest way to find out why NAV
65
+ rejected something:
66
+
67
+ ```sh
68
+ open-nav validate invoice.xml --operation CREATE --pretty
69
+ ```
70
+
71
+ ```text
72
+ invoice.xml: invalid (1 error, 0 warnings)
73
+
74
+ error INCORRECT_SUMMARY_CALCULATION_INVOICE_VAT_AMOUNT_SUMMARY
75
+ invoiceSummary.summaryNormal.invoiceVatAmount
76
+ is 280000.00 but the lines total 280800.00
77
+ NAV: The amount of the tax VAT rates differs from the VAT of the invoice.
78
+ ```
79
+
80
+ Findings carry NAV's own fault code and wording, in `en`, `hu` or `de` via
81
+ `--language`, so a local failure reads like the rejection it prevents.
82
+
83
+ `submit` validates before sending by default and refuses to submit a document
84
+ with errors — a rejection costs a round trip and consumes the `requestId`.
85
+ `--skip-validation` overrides that if you need it.
86
+
87
+ ## Licence
88
+
89
+ MIT. Not affiliated with NAV.
package/dist/bin.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=bin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
package/dist/bin.js ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ import { run } from './main.js';
3
+ const exitCode = await run({
4
+ argv: process.argv.slice(2),
5
+ isTty: process.stdout.isTTY === true,
6
+ });
7
+ process.exitCode = exitCode;
8
+ //# sourceMappingURL=bin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhC,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC;IACzB,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3B,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,KAAK,IAAI;CACrC,CAAC,CAAC;AACH,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { NavApiError } from '@open-nav/core';
2
+ import { type ExitCode } from './errors.js';
3
+ import { type LoadOptions } from './config.js';
4
+ import { type Format, type Writer } from './output.js';
5
+ export interface CommandContext {
6
+ format: Format;
7
+ writer: Writer;
8
+ load: LoadOptions;
9
+ /** Read a file, so tests need no filesystem. */
10
+ readFile?: (path: string) => string;
11
+ /** Write a file, creating parent directories. Injectable for tests. */
12
+ writeFile?: (path: string, contents: string) => void;
13
+ /** Write binary output, for PDFs. */
14
+ writeBinaryFile?: (path: string, contents: Buffer) => void;
15
+ /** Read binary input, for logos. */
16
+ readBinaryFile?: (path: string) => Buffer;
17
+ /** Whether a path already exists, so a download can resume. */
18
+ fileExists?: (path: string) => boolean;
19
+ }
20
+ export interface CommandDefinition {
21
+ name: string;
22
+ summary: string;
23
+ usage: string;
24
+ /** True when the command talks to NAV and therefore needs credentials. */
25
+ needsCredentials: boolean;
26
+ options?: Array<{
27
+ flag: string;
28
+ description: string;
29
+ }>;
30
+ run: (positionals: string[], flags: Record<string, string | boolean | undefined>, context: CommandContext) => Promise<ExitCode>;
31
+ }
32
+ export declare const COMMANDS: CommandDefinition[];
33
+ export declare function findCommand(name: string): CommandDefinition | undefined;
34
+ /** Machine-readable description of the whole surface, for tooling and agents. */
35
+ export declare function describeCommands(): unknown;
36
+ export { NavApiError };
37
+ //# sourceMappingURL=commands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,WAAW,EAQZ,MAAM,gBAAgB,CAAC;AAgBxB,OAAO,EAAoB,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAA+C,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;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