@ktmcp-cli/billingo 1.0.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/TESTING.md ADDED
@@ -0,0 +1,513 @@
1
+ # Billingo CLI - Testing & Validation Guide
2
+
3
+ This guide helps you test and validate the Billingo CLI before deployment.
4
+
5
+ ## Pre-Installation Tests
6
+
7
+ ### 1. File Structure Validation
8
+
9
+ ```bash
10
+ cd /workspace/group/ktmcp/workspace/billingo
11
+
12
+ # Verify all files exist
13
+ ls -la bin/billingo.js
14
+ ls -la src/lib/*.js
15
+ ls -la src/commands/*.js
16
+ ls -la examples/*.json
17
+
18
+ # Check executable permissions
19
+ test -x bin/billingo.js && echo "✓ CLI is executable" || echo "✗ CLI not executable"
20
+
21
+ # Verify package.json
22
+ cat package.json | grep -q '"name": "@ktmcp-cli/billingo"' && echo "✓ Package name correct"
23
+ ```
24
+
25
+ ### 2. Syntax Validation
26
+
27
+ ```bash
28
+ # Check for syntax errors in all JS files
29
+ for file in bin/*.js src/**/*.js; do
30
+ node --check "$file" && echo "✓ $file" || echo "✗ $file has syntax errors"
31
+ done
32
+ ```
33
+
34
+ ### 3. JSON Validation
35
+
36
+ ```bash
37
+ # Validate all JSON files
38
+ for file in examples/*.json; do
39
+ node -e "JSON.parse(require('fs').readFileSync('$file'))" && echo "✓ $file" || echo "✗ $file invalid"
40
+ done
41
+ ```
42
+
43
+ ## Installation Tests
44
+
45
+ ### 1. Install Dependencies
46
+
47
+ ```bash
48
+ cd /workspace/group/ktmcp/workspace/billingo
49
+ npm install
50
+ ```
51
+
52
+ Expected output:
53
+ ```
54
+ added X packages in Xs
55
+ ```
56
+
57
+ ### 2. Link CLI Globally
58
+
59
+ ```bash
60
+ npm link
61
+ ```
62
+
63
+ Expected output:
64
+ ```
65
+ added 1 package
66
+ ```
67
+
68
+ ### 3. Verify Installation
69
+
70
+ ```bash
71
+ which billingo
72
+ # Should show: /usr/local/bin/billingo or similar
73
+
74
+ billingo --version
75
+ # Should show: 1.0.0
76
+
77
+ billingo --help
78
+ # Should show full help text
79
+ ```
80
+
81
+ ## Configuration Tests
82
+
83
+ ### 1. Config Management
84
+
85
+ ```bash
86
+ # Test config set
87
+ billingo config set testKey testValue
88
+ billingo config get testKey
89
+ # Expected output: testValue
90
+
91
+ # Test config list
92
+ billingo config list
93
+ # Should show JSON with testKey
94
+
95
+ # Test config clear
96
+ billingo config clear
97
+ billingo config list
98
+ # Should show empty config
99
+ ```
100
+
101
+ ### 2. API Key Configuration
102
+
103
+ ```bash
104
+ # Set API key (use a test key if available)
105
+ billingo config set apiKey YOUR_TEST_API_KEY
106
+
107
+ # Verify it's saved
108
+ billingo config get apiKey
109
+ # Should show your API key (first few chars visible)
110
+ ```
111
+
112
+ ### 3. Environment Variable Test
113
+
114
+ ```bash
115
+ # Test with environment variable
116
+ export BILLINGO_API_KEY=test_key
117
+ billingo config get apiKey
118
+ # Should fall back to env var if not in config
119
+
120
+ unset BILLINGO_API_KEY
121
+ ```
122
+
123
+ ## Command Structure Tests
124
+
125
+ ### 1. Help Text Validation
126
+
127
+ ```bash
128
+ # Test main help
129
+ billingo --help | grep -q "Billingo API" && echo "✓ Main help works"
130
+
131
+ # Test resource help
132
+ billingo documents --help | grep -q "Manage documents" && echo "✓ Documents help works"
133
+ billingo partners --help | grep -q "Manage partners" && echo "✓ Partners help works"
134
+
135
+ # Test command help
136
+ billingo documents create --help | grep -q "Create a new document" && echo "✓ Command help works"
137
+ ```
138
+
139
+ ### 2. Alias Validation
140
+
141
+ ```bash
142
+ # Test aliases work
143
+ billingo docs --help > /tmp/docs.txt
144
+ billingo documents --help > /tmp/documents.txt
145
+ diff /tmp/docs.txt /tmp/documents.txt && echo "✓ Alias 'docs' works"
146
+
147
+ billingo banks --help > /tmp/banks.txt
148
+ billingo bank-accounts --help > /tmp/bank-accounts.txt
149
+ diff /tmp/banks.txt /tmp/bank-accounts.txt && echo "✓ Alias 'banks' works"
150
+ ```
151
+
152
+ ## API Integration Tests
153
+
154
+ **NOTE**: These tests require a valid Billingo API key and will make real API calls.
155
+
156
+ ### 1. Authentication Test
157
+
158
+ ```bash
159
+ # This should work if API key is valid
160
+ billingo organization get
161
+
162
+ # Expected: JSON output with organization details
163
+ # If error: Check API key configuration
164
+ ```
165
+
166
+ ### 2. Read-Only Operations
167
+
168
+ ```bash
169
+ # Test list operations (safe, read-only)
170
+ billingo document-blocks list --format json > /tmp/blocks.json
171
+ cat /tmp/blocks.json | grep -q '"data"' && echo "✓ Document blocks list works"
172
+
173
+ billingo partners list --page 1 --per-page 5 --format json > /tmp/partners.json
174
+ cat /tmp/partners.json | grep -q '"current_page"' && echo "✓ Partners list works"
175
+
176
+ billingo products list --format json > /tmp/products.json
177
+ cat /tmp/products.json | grep -q '"data"' && echo "✓ Products list works"
178
+
179
+ billingo bank-accounts list --format json > /tmp/accounts.json
180
+ cat /tmp/accounts.json | grep -q '"data"' && echo "✓ Bank accounts list works"
181
+ ```
182
+
183
+ ### 3. Currency Conversion Test
184
+
185
+ ```bash
186
+ # Test currency endpoint
187
+ billingo currencies convert --from HUF --to EUR --format json > /tmp/currency.json
188
+ cat /tmp/currency.json | grep -q '"currency"' && echo "✓ Currency conversion works"
189
+ ```
190
+
191
+ ### 4. Pagination Test
192
+
193
+ ```bash
194
+ # Test pagination parameters
195
+ billingo documents list --page 1 --per-page 10 --format json > /tmp/page1.json
196
+ cat /tmp/page1.json | grep -q '"current_page": 1' && echo "✓ Pagination works"
197
+ ```
198
+
199
+ ### 5. Filtering Test
200
+
201
+ ```bash
202
+ # Test document filtering
203
+ billingo documents list \
204
+ --payment-status paid \
205
+ --start-date 2024-01-01 \
206
+ --end-date 2024-12-31 \
207
+ --format json > /tmp/filtered.json
208
+
209
+ cat /tmp/filtered.json | grep -q '"data"' && echo "✓ Filtering works"
210
+ ```
211
+
212
+ ## Output Format Tests
213
+
214
+ ### 1. JSON Format
215
+
216
+ ```bash
217
+ # Test JSON output is valid
218
+ billingo organization get --format json | node -e "JSON.parse(require('fs').readFileSync('/dev/stdin').toString())" && echo "✓ JSON format valid"
219
+ ```
220
+
221
+ ### 2. Pretty Format
222
+
223
+ ```bash
224
+ # Test pretty format (default)
225
+ billingo organization get > /tmp/pretty.txt
226
+ test -s /tmp/pretty.txt && echo "✓ Pretty format produces output"
227
+ ```
228
+
229
+ ## Error Handling Tests
230
+
231
+ ### 1. Missing API Key
232
+
233
+ ```bash
234
+ # Temporarily clear API key
235
+ billingo config clear
236
+
237
+ # This should fail with clear error message
238
+ billingo organization get 2>&1 | grep -q "API key not configured" && echo "✓ Missing API key error handled"
239
+
240
+ # Restore API key
241
+ billingo config set apiKey YOUR_TEST_API_KEY
242
+ ```
243
+
244
+ ### 2. Invalid Resource ID
245
+
246
+ ```bash
247
+ # Try to get non-existent resource
248
+ billingo documents get 999999999 2>&1 | grep -q "not found" && echo "✓ 404 error handled"
249
+ ```
250
+
251
+ ### 3. Invalid Data
252
+
253
+ ```bash
254
+ # Try to create with invalid data
255
+ echo '{"invalid": "data"}' > /tmp/invalid.json
256
+ billingo documents create --file /tmp/invalid.json 2>&1 | grep -q "Error" && echo "✓ Validation error handled"
257
+ ```
258
+
259
+ ### 4. Missing Required Option
260
+
261
+ ```bash
262
+ # Try currency convert without required params
263
+ billingo currencies convert 2>&1 | grep -q "required" && echo "✓ Missing required option handled"
264
+ ```
265
+
266
+ ## File Operations Tests
267
+
268
+ ### 1. File Input Test
269
+
270
+ ```bash
271
+ # Test creating from file
272
+ cp examples/partner.json /tmp/test-partner.json
273
+
274
+ # Note: This will create a real partner - use test account
275
+ # billingo partners create --file /tmp/test-partner.json --format json > /tmp/created-partner.json
276
+ # cat /tmp/created-partner.json | grep -q '"id"' && echo "✓ File input works"
277
+ ```
278
+
279
+ ### 2. File Download Test
280
+
281
+ ```bash
282
+ # Note: Requires a valid document ID
283
+ # billingo documents download 123 --output /tmp/test-invoice.pdf
284
+ # test -f /tmp/test-invoice.pdf && echo "✓ File download works"
285
+ ```
286
+
287
+ ### 3. Inline JSON Test
288
+
289
+ ```bash
290
+ # Test inline JSON input (less destructive)
291
+ # billingo partners create --data '{"name":"Test","emails":["test@example.com"]}' 2>&1
292
+ ```
293
+
294
+ ## Exit Code Tests
295
+
296
+ ### 1. Success Exit Code
297
+
298
+ ```bash
299
+ billingo organization get > /dev/null
300
+ test $? -eq 0 && echo "✓ Success returns exit code 0"
301
+ ```
302
+
303
+ ### 2. Error Exit Code
304
+
305
+ ```bash
306
+ billingo documents get 999999999 > /dev/null 2>&1
307
+ test $? -eq 1 && echo "✓ Error returns exit code 1"
308
+ ```
309
+
310
+ ## Performance Tests
311
+
312
+ ### 1. Response Time Test
313
+
314
+ ```bash
315
+ # Test API call response time
316
+ time billingo organization get > /dev/null
317
+ # Should complete in < 2 seconds typically
318
+ ```
319
+
320
+ ### 2. Pagination Performance
321
+
322
+ ```bash
323
+ # Test large page size
324
+ time billingo documents list --per-page 100 --format json > /dev/null
325
+ # Should handle large result sets
326
+ ```
327
+
328
+ ## Integration Tests (Safe)
329
+
330
+ ### 1. Complete Read Workflow
331
+
332
+ ```bash
333
+ # Test a complete read-only workflow
334
+ billingo organization get --format json > /tmp/org.json
335
+ billingo document-blocks list --format json > /tmp/blocks.json
336
+ billingo partners list --format json > /tmp/partners.json
337
+ billingo products list --format json > /tmp/products.json
338
+ billingo documents list --format json > /tmp/documents.json
339
+
340
+ # Verify all files created
341
+ test -f /tmp/org.json && \
342
+ test -f /tmp/blocks.json && \
343
+ test -f /tmp/partners.json && \
344
+ test -f /tmp/products.json && \
345
+ test -f /tmp/documents.json && \
346
+ echo "✓ Complete read workflow successful"
347
+ ```
348
+
349
+ ## AI Agent Tests
350
+
351
+ ### 1. JSON Parsing Test
352
+
353
+ ```bash
354
+ # Test that AI agents can parse output
355
+ node << 'EOF'
356
+ const { execSync } = require('child_process');
357
+ const output = execSync('billingo organization get --format json').toString();
358
+ const data = JSON.parse(output);
359
+ console.log(data.id ? '✓ AI can parse JSON output' : '✗ JSON parse failed');
360
+ EOF
361
+ ```
362
+
363
+ ### 2. Error Message Parsing
364
+
365
+ ```bash
366
+ # Test that error messages are machine-readable
367
+ billingo documents get 999999999 2>&1 | grep -q "Error:" && echo "✓ Errors are prefixed correctly"
368
+ ```
369
+
370
+ ## Cleanup
371
+
372
+ ```bash
373
+ # Clean up test files
374
+ rm -f /tmp/*.json /tmp/*.txt /tmp/*.pdf
375
+
376
+ # Optionally unlink CLI
377
+ # npm unlink -g @ktmcp-cli/billingo
378
+ ```
379
+
380
+ ## Test Summary Checklist
381
+
382
+ ### Installation
383
+ - [ ] Files exist and have correct permissions
384
+ - [ ] No syntax errors in JavaScript files
385
+ - [ ] JSON examples are valid
386
+ - [ ] npm install succeeds
387
+ - [ ] npm link creates global command
388
+ - [ ] billingo --help shows documentation
389
+
390
+ ### Configuration
391
+ - [ ] Config set/get/list/clear work
392
+ - [ ] API key storage works
393
+ - [ ] Environment variable fallback works
394
+
395
+ ### Commands
396
+ - [ ] All commands have help text
397
+ - [ ] Aliases work correctly
398
+ - [ ] Required options are enforced
399
+ - [ ] Optional parameters work
400
+
401
+ ### API Integration
402
+ - [ ] Authentication works
403
+ - [ ] Organization endpoint works
404
+ - [ ] List operations work
405
+ - [ ] Pagination works
406
+ - [ ] Filtering works
407
+ - [ ] Currency conversion works
408
+
409
+ ### Output
410
+ - [ ] JSON format is valid JSON
411
+ - [ ] Pretty format is readable
412
+ - [ ] Errors go to stderr
413
+ - [ ] Success output goes to stdout
414
+
415
+ ### Error Handling
416
+ - [ ] Missing API key shows clear error
417
+ - [ ] 404 errors are handled
418
+ - [ ] Validation errors are shown
419
+ - [ ] Rate limits are detected
420
+ - [ ] Network errors are handled
421
+
422
+ ### Exit Codes
423
+ - [ ] Success returns 0
424
+ - [ ] Errors return 1
425
+
426
+ ### Performance
427
+ - [ ] Reasonable response times
428
+ - [ ] Handles large result sets
429
+
430
+ ## Automated Test Script
431
+
432
+ Save this as `test-cli.sh`:
433
+
434
+ ```bash
435
+ #!/bin/bash
436
+
437
+ echo "Billingo CLI Test Suite"
438
+ echo "======================="
439
+ echo ""
440
+
441
+ PASS=0
442
+ FAIL=0
443
+
444
+ test_command() {
445
+ if eval "$1" > /dev/null 2>&1; then
446
+ echo "✓ $2"
447
+ ((PASS++))
448
+ else
449
+ echo "✗ $2"
450
+ ((FAIL++))
451
+ fi
452
+ }
453
+
454
+ # Run tests
455
+ test_command "billingo --help | grep -q 'Billingo API'" "Help text"
456
+ test_command "billingo config set testKey testValue && billingo config get testKey | grep -q testValue" "Config management"
457
+ test_command "billingo --version | grep -q '1.0.0'" "Version output"
458
+
459
+ echo ""
460
+ echo "Results: $PASS passed, $FAIL failed"
461
+ exit $FAIL
462
+ ```
463
+
464
+ Run with:
465
+ ```bash
466
+ chmod +x test-cli.sh
467
+ ./test-cli.sh
468
+ ```
469
+
470
+ ## Troubleshooting
471
+
472
+ ### Command Not Found
473
+ ```bash
474
+ # Reinstall
475
+ npm unlink -g
476
+ npm link
477
+ ```
478
+
479
+ ### Permission Denied
480
+ ```bash
481
+ chmod +x bin/billingo.js
482
+ ```
483
+
484
+ ### Module Not Found
485
+ ```bash
486
+ npm install
487
+ ```
488
+
489
+ ### API Errors
490
+ ```bash
491
+ # Check API key
492
+ billingo config get apiKey
493
+
494
+ # Test connection
495
+ curl -H "X-API-KEY: YOUR_KEY" https://api.billingo.hu/v3/organization
496
+ ```
497
+
498
+ ## Next Steps
499
+
500
+ After all tests pass:
501
+ 1. Commit to version control
502
+ 2. Tag release v1.0.0
503
+ 3. Publish to npm (if public)
504
+ 4. Deploy to production
505
+ 5. Monitor error logs
506
+ 6. Gather user feedback
507
+
508
+ ## Support
509
+
510
+ For issues found during testing, check:
511
+ - [README.md](./README.md) - Usage documentation
512
+ - [Billingo API Docs](https://api.billingo.hu/v3/swagger)
513
+ - Error logs in terminal output
package/banner.png ADDED
Binary file
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Billingo CLI - Main Entry Point
5
+ *
6
+ * Production-ready CLI for Billingo API v3
7
+ * Hungarian invoicing and billing automation
8
+ */
9
+
10
+ import { Command } from 'commander';
11
+ import { readFileSync } from 'fs';
12
+ import { fileURLToPath } from 'url';
13
+ import { dirname, join } from 'path';
14
+ import chalk from 'chalk';
15
+
16
+ // Import command modules
17
+ import { registerBankAccountCommands } from '../src/commands/bank-accounts.js';
18
+ import { registerDocumentCommands } from '../src/commands/documents.js';
19
+ import { registerDocumentBlockCommands } from '../src/commands/document-blocks.js';
20
+ import { registerPartnerCommands } from '../src/commands/partners.js';
21
+ import { registerProductCommands } from '../src/commands/products.js';
22
+ import { registerCurrencyCommands } from '../src/commands/currencies.js';
23
+ import { registerOrganizationCommands } from '../src/commands/organization.js';
24
+ import { registerUtilityCommands } from '../src/commands/utilities.js';
25
+ import { registerConfigCommands } from '../src/commands/config.js';
26
+
27
+ const __filename = fileURLToPath(import.meta.url);
28
+ const __dirname = dirname(__filename);
29
+
30
+ // Load package.json
31
+ const packageJson = JSON.parse(
32
+ readFileSync(join(__dirname, '../package.json'), 'utf-8')
33
+ );
34
+
35
+ const program = new Command();
36
+
37
+ // Configure main program
38
+ program
39
+ .name('billingo')
40
+ .description(chalk.cyan('Billingo API v3 CLI - Hungarian invoicing and billing automation'))
41
+ .version(packageJson.version, '-v, --version', 'output the current version')
42
+ .addHelpText('after', `
43
+ ${chalk.bold('Examples:')}
44
+ $ billingo config set API_KEY <your-api-key>
45
+ $ billingo documents list --page 1 --per-page 25
46
+ $ billingo documents create -f invoice.json
47
+ $ billingo partners list
48
+ $ billingo bank-accounts list
49
+
50
+ ${chalk.bold('API Documentation:')}
51
+ ${chalk.blue('https://api.billingo.hu/v3/swagger')}
52
+
53
+ ${chalk.bold('Get API Key:')}
54
+ ${chalk.blue('https://app.billingo.hu/api-key')}
55
+ `);
56
+
57
+ // Register all command modules
58
+ registerConfigCommands(program);
59
+ registerBankAccountCommands(program);
60
+ registerDocumentCommands(program);
61
+ registerDocumentBlockCommands(program);
62
+ registerPartnerCommands(program);
63
+ registerProductCommands(program);
64
+ registerCurrencyCommands(program);
65
+ registerOrganizationCommands(program);
66
+ registerUtilityCommands(program);
67
+
68
+ // Global error handler
69
+ process.on('unhandledRejection', (error) => {
70
+ console.error(chalk.red('Unhandled error:'), error);
71
+ process.exit(1);
72
+ });
73
+
74
+ // Parse command line arguments
75
+ program.parse(process.argv);
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "Primary Business Account",
3
+ "account_number": "12345678-12345678-12345678",
4
+ "account_number_iban": "HU42123456781234567812345678",
5
+ "swift": "ABCDHUHB",
6
+ "currency": "HUF",
7
+ "need_qr": true
8
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "vendor_id": 1,
3
+ "partner_id": 123,
4
+ "block_id": 1,
5
+ "type": "invoice",
6
+ "fulfillment_date": "2024-01-15",
7
+ "due_date": "2024-01-30",
8
+ "payment_method": "transfer",
9
+ "language": "en",
10
+ "currency": "HUF",
11
+ "comment": "Thank you for your business",
12
+ "items": [
13
+ {
14
+ "name": "Web Development Service",
15
+ "unit_price": 50000,
16
+ "unit_price_type": "gross",
17
+ "quantity": 10,
18
+ "unit": "hour",
19
+ "vat": "27%",
20
+ "comment": "Frontend and backend development"
21
+ },
22
+ {
23
+ "name": "Consulting",
24
+ "unit_price": 75000,
25
+ "unit_price_type": "gross",
26
+ "quantity": 5,
27
+ "unit": "hour",
28
+ "vat": "27%",
29
+ "comment": "Technical consulting and architecture planning"
30
+ }
31
+ ]
32
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "Example Company Ltd.",
3
+ "address": {
4
+ "country_code": "HU",
5
+ "post_code": "1234",
6
+ "city": "Budapest",
7
+ "address": "Example Street 42"
8
+ },
9
+ "emails": [
10
+ "contact@example.com",
11
+ "accounting@example.com"
12
+ ],
13
+ "phone": "+36 1 234 5678",
14
+ "taxcode": "12345678-1-23",
15
+ "iban": "HU42123456781234567812345678",
16
+ "swift": "ABCDHUHB",
17
+ "account_number": "12345678-12345678-12345678",
18
+ "general_ledger_number": "GL123",
19
+ "comment": "Primary customer - Net 30 payment terms"
20
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "Professional Consulting Hour",
3
+ "comment": "Technical consulting and advisory services",
4
+ "currency": "HUF",
5
+ "unit": "hour",
6
+ "unit_price": 50000,
7
+ "unit_price_type": "gross",
8
+ "vat": "27%",
9
+ "entitlement": "SZOLG"
10
+ }
package/logo.png ADDED
Binary file
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@ktmcp-cli/billingo",
3
+ "version": "1.0.0",
4
+ "description": "Production-ready CLI for Billingo API v3 - Hungarian invoicing and billing",
5
+ "type": "module",
6
+ "main": "src/index.js",
7
+ "bin": {
8
+ "billingo": "./bin/billingo.js"
9
+ },
10
+ "scripts": {
11
+ "test": "echo \"Error: no test specified\" && exit 1",
12
+ "dev": "node bin/billingo.js"
13
+ },
14
+ "keywords": [
15
+ "billingo",
16
+ "invoice",
17
+ "billing",
18
+ "hungary",
19
+ "cli",
20
+ "api"
21
+ ],
22
+ "author": "KTMCP",
23
+ "license": "MIT",
24
+ "dependencies": {
25
+ "commander": "^12.0.0",
26
+ "axios": "^1.6.7",
27
+ "dotenv": "^16.4.1",
28
+ "chalk": "^5.3.0",
29
+ "ora": "^8.0.1",
30
+ "conf": "^12.0.0"
31
+ },
32
+ "engines": {
33
+ "node": ">=18.0.0"
34
+ }
35
+ }