@timbrix/cli 1.3.1 → 1.4.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.
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/customers/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAA;AAO5C,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,OAAO;IAClD,OAAgB,WAAW,SAA0B;IAErD,OAAgB,QAAQ,WAGvB;IAED,OAAgB,KAAK;;;;;;;;;;;;;;;;;MAsDpB;IAEY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA+JlC"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/customers/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAA;AAO5C,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,OAAO;IAClD,OAAgB,WAAW,SAA0B;IAErD,OAAgB,QAAQ,WAGvB;IAED,OAAgB,KAAK;;;;;;;;;;;;;;;;;MAsDpB;IAEY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAkKlC"}
@@ -154,7 +154,7 @@ export default class CustomersCreate extends Command {
154
154
  default: "MEX",
155
155
  }));
156
156
  const spinner = ora("Creating customer...").start();
157
- const customer = await client.customers.create(flags.org, {
157
+ const customer = await client.customers.create({
158
158
  legalName,
159
159
  taxId,
160
160
  taxSystem,
@@ -170,7 +170,7 @@ export default class CustomersCreate extends Command {
170
170
  addressZip,
171
171
  addressState,
172
172
  addressCountry,
173
- });
173
+ }, flags.org);
174
174
  spinner.succeed(chalk.green("✓ Customer created successfully!"));
175
175
  this.log(chalk.gray("\nCustomer Details:"));
176
176
  this.log(` ${chalk.bold("ID:")} ${customer.id}`);
@@ -41,7 +41,7 @@ export default class CustomersDelete extends Command {
41
41
  }
42
42
  const spinner = ora("Deleting customer...").start();
43
43
  try {
44
- await client.customers.delete(flags.org, flags.id);
44
+ await client.customers.delete(flags.id, flags.org);
45
45
  spinner.succeed(chalk.green("✓ Customer deleted successfully!"));
46
46
  }
47
47
  catch (error) {
@@ -3,7 +3,7 @@ export default class InvoicesCreate extends Command {
3
3
  static description: string;
4
4
  static examples: string[];
5
5
  static flags: {
6
- org: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
6
+ org: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
7
  "api-key": import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
8
8
  file: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
9
9
  output: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/invoices/create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAA;AAO5C,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,OAAO;IACjD,OAAgB,WAAW,SAG4C;IAEvE,OAAgB,QAAQ,WAGvB;IAED,OAAgB,KAAK;;;;;MAoBpB;IAEY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA8ClC"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/invoices/create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAA;AAO5C,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,OAAO;IACjD,OAAgB,WAAW,SAImD;IAE9E,OAAgB,QAAQ,WAGvB;IAED,OAAgB,KAAK;;;;;MAoBpB;IAEY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA8ClC"}
@@ -7,16 +7,16 @@ import { getErrorMessage } from "../../utils/error.js";
7
7
  export default class InvoicesCreate extends Command {
8
8
  static description = "Create and stamp (timbrar) a CFDI 4.0 invoice via the configured PAC. " +
9
9
  "This command authenticates with --api-key instead of the `timbrix login` " +
10
- "session the key must belong to the organization passed via --org.";
10
+ "session. --org is optional omit it to resolve the organization from " +
11
+ "the API key itself, or pass it to match the key's organization explicitly.";
11
12
  static examples = [
12
- "<%= config.bin %> <%= command.id %> --org org-id --api-key sk_live_... --file invoice.json",
13
+ "<%= config.bin %> <%= command.id %> --api-key sk_live_... --file invoice.json",
13
14
  "<%= config.bin %> <%= command.id %> --org org-id --api-key sk_live_... --file invoice.json --output invoice.xml",
14
15
  ];
15
16
  static flags = {
16
17
  org: Flags.string({
17
18
  char: "o",
18
- description: "Organization ID (must match the API key's organization)",
19
- required: true,
19
+ description: "Organization ID (must match the API key's organization). Optional — if omitted, the organization is resolved from the API key itself.",
20
20
  }),
21
21
  "api-key": Flags.string({
22
22
  description: "Timbrix API key (needs the write:invoices scope)",
@@ -44,7 +44,7 @@ export default class InvoicesCreate extends Command {
44
44
  }
45
45
  const spinner = ora("Stamping invoice...").start();
46
46
  try {
47
- const invoice = await client.invoices.create(flags.org, payload);
47
+ const invoice = await client.invoices.create(payload, flags.org);
48
48
  spinner.succeed(chalk.green("✓ Invoice stamped successfully!"));
49
49
  this.log(chalk.gray("\nInvoice Details:"));
50
50
  this.log(` ${chalk.bold("ID:")} ${invoice.id}`);
@@ -1 +1 @@
1
- {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/invoices/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAA;AAQ5C,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,OAAO;IAC/C,OAAgB,WAAW,SACmC;IAE9D,OAAgB,QAAQ,WAGvB;IAED,OAAgB,KAAK;;;;MAcpB;IAEY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA4DlC"}
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/invoices/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAA;AAQ5C,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,OAAO;IAC/C,OAAgB,WAAW,SACmC;IAE9D,OAAgB,QAAQ,WAGvB;IAED,OAAgB,KAAK;;;;MAcpB;IAEY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA+DlC"}
@@ -30,10 +30,10 @@ export default class InvoicesList extends Command {
30
30
  const client = createClient();
31
31
  const spinner = ora("Fetching invoices...").start();
32
32
  try {
33
- const result = await client.invoices.list(flags.org, {
33
+ const result = await client.invoices.list({
34
34
  page: flags.page,
35
35
  limit: flags.limit,
36
- });
36
+ }, flags.org);
37
37
  spinner.stop();
38
38
  if (result.data.length === 0) {
39
39
  this.log(chalk.yellow("No invoices found"));
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/products/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAA;AAO5C,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,OAAO;IACjD,OAAgB,WAAW,SAAoC;IAE/D,OAAgB,QAAQ,WAGvB;IAED,OAAgB,KAAK;;;;;;;;;MAiCpB;IAEY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAwFlC"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/products/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAA;AAO5C,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,OAAO;IACjD,OAAgB,WAAW,SAAoC;IAE/D,OAAgB,QAAQ,WAGvB;IAED,OAAgB,KAAK;;;;;;;;;MAiCpB;IAEY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA2FlC"}
@@ -84,7 +84,7 @@ export default class ProductsCreate extends Command {
84
84
  default: "Elemento",
85
85
  }));
86
86
  const spinner = ora("Creating product...").start();
87
- const product = await client.products.create(flags.org, {
87
+ const product = await client.products.create({
88
88
  description,
89
89
  productKey: productKey,
90
90
  price: parseFloat(priceRaw),
@@ -93,7 +93,7 @@ export default class ProductsCreate extends Command {
93
93
  unitKey,
94
94
  unitName,
95
95
  taxes: [{ type: "IVA", rate: 0.16 }],
96
- });
96
+ }, flags.org);
97
97
  spinner.succeed(chalk.green("✓ Product created successfully!"));
98
98
  this.log(chalk.gray("\nProduct Details:"));
99
99
  this.log(` ${chalk.bold("ID:")} ${product.id}`);
@@ -41,7 +41,7 @@ export default class ProductsDelete extends Command {
41
41
  }
42
42
  const spinner = ora("Deleting product...").start();
43
43
  try {
44
- await client.products.delete(flags.org, flags.id);
44
+ await client.products.delete(flags.id, flags.org);
45
45
  spinner.succeed(chalk.green("✓ Product deleted successfully!"));
46
46
  }
47
47
  catch (error) {
@@ -24,7 +24,7 @@ export default class ProductsGet extends Command {
24
24
  const client = createClient();
25
25
  const spinner = ora("Fetching product...").start();
26
26
  try {
27
- const product = await client.products.get(flags.org, flags.id);
27
+ const product = await client.products.get(flags.id, flags.org);
28
28
  spinner.stop();
29
29
  this.log(chalk.bold("\nProduct Details:"));
30
30
  this.log(` ${chalk.bold("ID:")} ${product.id}`);
@@ -37,7 +37,7 @@ export default class ProductsImport extends Command {
37
37
  const buffer = readFileSync(flags.file);
38
38
  const filename = basename(flags.file);
39
39
  const blob = new Blob([buffer], { type: "text/csv" });
40
- const result = await client.products.importCsv(flags.org, blob, filename);
40
+ const result = await client.products.importCsv(blob, filename, flags.org);
41
41
  spinner.succeed(chalk.green("✓ Import finished"));
42
42
  this.log(chalk.gray("\nImport Summary:"));
43
43
  this.log(` ${chalk.bold("Total rows:")} ${result.totalRows}`);
@@ -1 +1 @@
1
- {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/products/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAA;AAQ5C,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,OAAO;IAC/C,OAAgB,WAAW,SAAmD;IAE9E,OAAgB,QAAQ,WAIvB;IAED,OAAgB,KAAK;;;;;MAkBpB;IAEY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAmDlC"}
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/products/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAA;AAQ5C,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,OAAO;IAC/C,OAAgB,WAAW,SAAmD;IAE9E,OAAgB,QAAQ,WAIvB;IAED,OAAgB,KAAK;;;;;MAkBpB;IAEY,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAsDlC"}
@@ -35,11 +35,11 @@ export default class ProductsList extends Command {
35
35
  const client = createClient();
36
36
  const spinner = ora("Fetching products...").start();
37
37
  try {
38
- const products = await client.products.list(flags.org, {
38
+ const products = await client.products.list({
39
39
  description: flags.description,
40
40
  sku: flags.sku,
41
41
  productKey: flags["product-key"],
42
- });
42
+ }, flags.org);
43
43
  spinner.stop();
44
44
  if (products.length === 0) {
45
45
  this.log(chalk.yellow("No products found"));
@@ -69,7 +69,7 @@ export default class ProductsUpdate extends Command {
69
69
  }
70
70
  const spinner = ora("Updating product...").start();
71
71
  try {
72
- const product = await client.products.update(flags.org, flags.id, updates);
72
+ const product = await client.products.update(flags.id, updates, flags.org);
73
73
  spinner.succeed(chalk.green("✓ Product updated successfully!"));
74
74
  this.log(chalk.gray("\nUpdated Product:"));
75
75
  this.log(` ${chalk.bold("ID:")} ${product.id}`);
@@ -492,17 +492,16 @@
492
492
  "invoices:create": {
493
493
  "aliases": [],
494
494
  "args": {},
495
- "description": "Create and stamp (timbrar) a CFDI 4.0 invoice via the configured PAC. This command authenticates with --api-key instead of the `timbrix login` session — the key must belong to the organization passed via --org.",
495
+ "description": "Create and stamp (timbrar) a CFDI 4.0 invoice via the configured PAC. This command authenticates with --api-key instead of the `timbrix login` session. --org is optional omit it to resolve the organization from the API key itself, or pass it to match the key's organization explicitly.",
496
496
  "examples": [
497
- "<%= config.bin %> <%= command.id %> --org org-id --api-key sk_live_... --file invoice.json",
497
+ "<%= config.bin %> <%= command.id %> --api-key sk_live_... --file invoice.json",
498
498
  "<%= config.bin %> <%= command.id %> --org org-id --api-key sk_live_... --file invoice.json --output invoice.xml"
499
499
  ],
500
500
  "flags": {
501
501
  "org": {
502
502
  "char": "o",
503
- "description": "Organization ID (must match the API key's organization)",
503
+ "description": "Organization ID (must match the API key's organization). Optional — if omitted, the organization is resolved from the API key itself.",
504
504
  "name": "org",
505
- "required": true,
506
505
  "hasDynamicHelp": false,
507
506
  "multiple": false,
508
507
  "type": "option"
@@ -1691,5 +1690,5 @@
1691
1690
  ]
1692
1691
  }
1693
1692
  },
1694
- "version": "1.3.1"
1693
+ "version": "1.4.0"
1695
1694
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timbrix/cli",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "description": "CLI tool for Timbrix API",
5
5
  "author": "Ivan Sotelo",
6
6
  "bin": {
@@ -36,7 +36,7 @@
36
36
  "ky": "^2.0.2",
37
37
  "ora": "^9.4.1",
38
38
  "update-notifier": "^7.3.1",
39
- "@timbrix/sdk": "1.4.0"
39
+ "@timbrix/sdk": "2.0.0"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/node": "^26.2.0",