@timbrix/cli 1.2.0 → 1.3.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 CHANGED
@@ -123,6 +123,13 @@ timbrix invoices create --org <organization-id> --api-key <api-key> --file invoi
123
123
  # List invoices for an organization (newest first)
124
124
  timbrix invoices list --org <organization-id>
125
125
  timbrix invoices list --org <organization-id> --page 2 --limit 50
126
+
127
+ # Get a single invoice by its folio fiscal (UUID)
128
+ timbrix invoices get <invoice-uuid>
129
+
130
+ # Download the timbrado XML or PDF for an invoice
131
+ timbrix invoices download <invoice-uuid> --format xml
132
+ timbrix invoices download <invoice-uuid> --format pdf --output invoice.pdf
126
133
  ```
127
134
 
128
135
  ### SAT Catalogs
@@ -0,0 +1,14 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class InvoicesDownload extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ uuid: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ static flags: {
9
+ format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
10
+ output: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ };
12
+ run(): Promise<void>;
13
+ }
14
+ //# sourceMappingURL=download.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../../src/commands/invoices/download.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAe,MAAM,aAAa,CAAA;AAMlD,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,OAAO;IACnD,OAAgB,WAAW,SAC8C;IAEzE,OAAgB,QAAQ,WAGvB;IAED,OAAgB,IAAI;;MAKnB;IAED,OAAgB,KAAK;;;MAYpB;IAEY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA+BlC"}
@@ -0,0 +1,50 @@
1
+ import { writeFileSync } from "node:fs";
2
+ import { Command, Args, Flags } from "@oclif/core";
3
+ import chalk from "chalk";
4
+ import ora from "ora";
5
+ import { createClient } from "../../utils/client.js";
6
+ import { getErrorMessage } from "../../utils/error.js";
7
+ export default class InvoicesDownload extends Command {
8
+ static description = "Download the timbrado XML or PDF representation of a CFDI 4.0 invoice";
9
+ static examples = [
10
+ "<%= config.bin %> <%= command.id %> d3bfbc57-44af-4390-a064-f0afab85e5df --format xml",
11
+ "<%= config.bin %> <%= command.id %> d3bfbc57-44af-4390-a064-f0afab85e5df --format pdf --output invoice.pdf",
12
+ ];
13
+ static args = {
14
+ uuid: Args.string({
15
+ description: "Invoice UUID (folio fiscal)",
16
+ required: true,
17
+ }),
18
+ };
19
+ static flags = {
20
+ format: Flags.string({
21
+ char: "f",
22
+ description: "File format to download",
23
+ options: ["xml", "pdf"],
24
+ required: true,
25
+ }),
26
+ output: Flags.string({
27
+ char: "o",
28
+ description: "Path to save the downloaded file (defaults to <uuid>.<format> in the current directory)",
29
+ }),
30
+ };
31
+ async run() {
32
+ const { args, flags } = await this.parse(InvoicesDownload);
33
+ const client = createClient();
34
+ const format = flags.format;
35
+ const outputPath = flags.output ?? `${args.uuid}.${format}`;
36
+ const spinner = ora(`Downloading invoice ${format.toUpperCase()}...`).start();
37
+ try {
38
+ const blob = format === "xml"
39
+ ? await client.invoices.getXml(args.uuid)
40
+ : await client.invoices.getPdf(args.uuid);
41
+ const buffer = Buffer.from(await blob.arrayBuffer());
42
+ writeFileSync(outputPath, buffer);
43
+ spinner.succeed(chalk.green(`✓ Invoice ${format.toUpperCase()} saved to: ${outputPath}`));
44
+ }
45
+ catch (error) {
46
+ spinner.fail(chalk.red(`Failed to download invoice ${format.toUpperCase()}: ${getErrorMessage(error)}`));
47
+ this.exit(1);
48
+ }
49
+ }
50
+ }
@@ -0,0 +1,10 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class InvoicesGet extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ uuid: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ run(): Promise<void>;
9
+ }
10
+ //# sourceMappingURL=get.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../src/commands/invoices/get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAQ,MAAM,aAAa,CAAA;AAM3C,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,OAAO;IAC9C,OAAgB,WAAW,SACiC;IAE5D,OAAgB,QAAQ,WAEvB;IAED,OAAgB,IAAI;;MAKnB;IAEY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAgClC"}
@@ -0,0 +1,39 @@
1
+ import { Command, Args } from "@oclif/core";
2
+ import { createClient } from "../../utils/client.js";
3
+ import { getErrorMessage } from "../../utils/error.js";
4
+ import chalk from "chalk";
5
+ import ora from "ora";
6
+ export default class InvoicesGet extends Command {
7
+ static description = "Get a single CFDI 4.0 invoice by its folio fiscal (UUID)";
8
+ static examples = [
9
+ "<%= config.bin %> <%= command.id %> d3bfbc57-44af-4390-a064-f0afab85e5df",
10
+ ];
11
+ static args = {
12
+ uuid: Args.string({
13
+ description: "Invoice UUID (folio fiscal)",
14
+ required: true,
15
+ }),
16
+ };
17
+ async run() {
18
+ const { args } = await this.parse(InvoicesGet);
19
+ const client = createClient();
20
+ const spinner = ora("Fetching invoice...").start();
21
+ try {
22
+ const invoice = await client.invoices.get(args.uuid);
23
+ spinner.stop();
24
+ this.log(chalk.cyan.bold("\nInvoice Details:"));
25
+ this.log(` ${chalk.bold("ID:")} ${invoice.id}`);
26
+ this.log(` ${chalk.bold("UUID:")} ${invoice.uuid}`);
27
+ this.log(` ${chalk.bold("Status:")} ${invoice.status === "valid" ? chalk.green(invoice.status) : chalk.red(invoice.status)}`);
28
+ this.log(` ${chalk.bold("Type:")} ${invoice.type}`);
29
+ this.log(` ${chalk.bold("Series/Folio:")} ${invoice.series}-${invoice.folioNumber}`);
30
+ this.log(` ${chalk.bold("Total:")} $${invoice.total.toFixed(2)}`);
31
+ this.log(` ${chalk.bold("Date:")} ${new Date(invoice.date).toLocaleString()}`);
32
+ this.log(` ${chalk.bold("Created:")} ${new Date(invoice.createdAt).toLocaleString()}`);
33
+ }
34
+ catch (error) {
35
+ spinner.fail(chalk.red("Failed to fetch invoice"));
36
+ this.error(getErrorMessage(error));
37
+ }
38
+ }
39
+ }
@@ -549,6 +549,89 @@
549
549
  "create.js"
550
550
  ]
551
551
  },
552
+ "invoices:download": {
553
+ "aliases": [],
554
+ "args": {
555
+ "uuid": {
556
+ "description": "Invoice UUID (folio fiscal)",
557
+ "name": "uuid",
558
+ "required": true
559
+ }
560
+ },
561
+ "description": "Download the timbrado XML or PDF representation of a CFDI 4.0 invoice",
562
+ "examples": [
563
+ "<%= config.bin %> <%= command.id %> d3bfbc57-44af-4390-a064-f0afab85e5df --format xml",
564
+ "<%= config.bin %> <%= command.id %> d3bfbc57-44af-4390-a064-f0afab85e5df --format pdf --output invoice.pdf"
565
+ ],
566
+ "flags": {
567
+ "format": {
568
+ "char": "f",
569
+ "description": "File format to download",
570
+ "name": "format",
571
+ "required": true,
572
+ "hasDynamicHelp": false,
573
+ "multiple": false,
574
+ "options": [
575
+ "xml",
576
+ "pdf"
577
+ ],
578
+ "type": "option"
579
+ },
580
+ "output": {
581
+ "char": "o",
582
+ "description": "Path to save the downloaded file (defaults to <uuid>.<format> in the current directory)",
583
+ "name": "output",
584
+ "hasDynamicHelp": false,
585
+ "multiple": false,
586
+ "type": "option"
587
+ }
588
+ },
589
+ "hasDynamicHelp": false,
590
+ "hiddenAliases": [],
591
+ "id": "invoices:download",
592
+ "pluginAlias": "@timbrix/cli",
593
+ "pluginName": "@timbrix/cli",
594
+ "pluginType": "core",
595
+ "strict": true,
596
+ "enableJsonFlag": false,
597
+ "isESM": true,
598
+ "relativePath": [
599
+ "dist",
600
+ "commands",
601
+ "invoices",
602
+ "download.js"
603
+ ]
604
+ },
605
+ "invoices:get": {
606
+ "aliases": [],
607
+ "args": {
608
+ "uuid": {
609
+ "description": "Invoice UUID (folio fiscal)",
610
+ "name": "uuid",
611
+ "required": true
612
+ }
613
+ },
614
+ "description": "Get a single CFDI 4.0 invoice by its folio fiscal (UUID)",
615
+ "examples": [
616
+ "<%= config.bin %> <%= command.id %> d3bfbc57-44af-4390-a064-f0afab85e5df"
617
+ ],
618
+ "flags": {},
619
+ "hasDynamicHelp": false,
620
+ "hiddenAliases": [],
621
+ "id": "invoices:get",
622
+ "pluginAlias": "@timbrix/cli",
623
+ "pluginName": "@timbrix/cli",
624
+ "pluginType": "core",
625
+ "strict": true,
626
+ "enableJsonFlag": false,
627
+ "isESM": true,
628
+ "relativePath": [
629
+ "dist",
630
+ "commands",
631
+ "invoices",
632
+ "get.js"
633
+ ]
634
+ },
552
635
  "invoices:list": {
553
636
  "aliases": [],
554
637
  "args": {},
@@ -1608,5 +1691,5 @@
1608
1691
  ]
1609
1692
  }
1610
1693
  },
1611
- "version": "1.2.0"
1694
+ "version": "1.3.0"
1612
1695
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timbrix/cli",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "CLI tool for Timbrix API",
5
5
  "author": "Ivan Sotelo",
6
6
  "bin": {
@@ -27,27 +27,27 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@inquirer/prompts": "^8.5.2",
30
- "@oclif/core": "^4.13.2",
31
- "@oclif/plugin-help": "^6.2.55",
32
- "@oclif/plugin-plugins": "^5.4.86",
30
+ "@oclif/core": "^4.13.5",
31
+ "@oclif/plugin-help": "^6.2.58",
32
+ "@oclif/plugin-plugins": "^5.4.87",
33
33
  "chalk": "^6.0.0",
34
34
  "cli-table3": "^0.6.5",
35
35
  "conf": "^15.1.0",
36
36
  "ky": "^2.0.2",
37
37
  "ora": "^9.4.1",
38
38
  "update-notifier": "^7.3.1",
39
- "@timbrix/sdk": "1.2.0"
39
+ "@timbrix/sdk": "1.3.0"
40
40
  },
41
41
  "devDependencies": {
42
- "@types/node": "^26.1.2",
42
+ "@types/node": "^26.2.0",
43
43
  "@types/update-notifier": "^6.0.8",
44
- "eslint": "^10.8.0",
45
- "oclif": "^4.23.29",
44
+ "eslint": "^10.8.1",
45
+ "oclif": "^4.23.30",
46
46
  "shx": "^0.4.0",
47
- "tsx": "^4.23.1",
47
+ "tsx": "^4.23.12",
48
48
  "typescript": "^6.0.3",
49
- "@repo/eslint-config": "0.1.1",
50
- "@repo/typescript-config": "0.1.0"
49
+ "@repo/typescript-config": "0.1.0",
50
+ "@repo/eslint-config": "0.1.1"
51
51
  },
52
52
  "oclif": {
53
53
  "bin": "timbrix",