latinfo 0.5.2 → 0.5.3

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/dist/demo-data.js CHANGED
@@ -102,6 +102,8 @@ exports.DEMO_DATA = {
102
102
  '20613483374': { ruc: '20613483374', razon_social: 'GOOGLE LLC', estado: 'ACTIVO', condicion: 'NO APLICABLE', ubigeo: '-', tipo_via: '----', nombre_via: 'SIN DOM. FISCAL EN PERÚ', codigo_zona: '-', tipo_zona: '-', numero: '00', interior: '-', lote: '-', departamento: '-', manzana: '-', kilometro: '-' },
103
103
  };
104
104
  function searchDemo(query) {
105
- const q = query.toUpperCase();
106
- return Object.values(exports.DEMO_DATA).filter(r => r.razon_social.includes(q));
105
+ const tokens = query.toUpperCase().split(/\s+/).filter(Boolean);
106
+ if (tokens.length === 0)
107
+ return [];
108
+ return Object.values(exports.DEMO_DATA).filter(r => tokens.every(t => r.razon_social.includes(t) || r.estado.includes(t) || r.ruc.includes(t)));
107
109
  }
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ const path_1 = __importDefault(require("path"));
10
10
  const os_1 = __importDefault(require("os"));
11
11
  const child_process_1 = require("child_process");
12
12
  const demo_data_1 = require("./demo-data");
13
- const VERSION = '0.5.2';
13
+ const VERSION = '0.5.3';
14
14
  const API_URL = process.env.LATINFO_API_URL || 'https://api.latinfo.dev';
15
15
  const GITHUB_CLIENT_ID = process.env.GITHUB_CLIENT_ID || 'Ov23li5fcQaiCsVtaMKK';
16
16
  const CONFIG_DIR = path_1.default.join(os_1.default.homedir(), '.latinfo');
@@ -83,10 +83,18 @@ async function apiRequest(config, path) {
83
83
  headers: { Authorization: `Bearer ${config.api_key}` },
84
84
  });
85
85
  if (!res.ok) {
86
- const err = await res.json();
86
+ const text = await res.text();
87
+ let error = `API error (${res.status})`;
88
+ let message = error;
89
+ try {
90
+ const err = JSON.parse(text);
91
+ error = err.error;
92
+ message = err.message || err.error;
93
+ }
94
+ catch { }
87
95
  if (jsonFlag)
88
- jsonError(err.error, err.message || err.error);
89
- console.error(err.message || err.error);
96
+ jsonError(error, message);
97
+ console.error(message);
90
98
  process.exit(1);
91
99
  }
92
100
  return res;
@@ -295,10 +303,18 @@ async function costsLive() {
295
303
  headers: { Authorization: `Bearer ${adminSecret}` },
296
304
  });
297
305
  if (!res.ok) {
298
- const err = await res.json();
306
+ const text = await res.text();
307
+ let error = `API error (${res.status})`;
308
+ let message = error;
309
+ try {
310
+ const err = JSON.parse(text);
311
+ error = err.error;
312
+ message = err.message || err.error;
313
+ }
314
+ catch { }
299
315
  if (jsonFlag)
300
- jsonError(err.error, err.message || err.error);
301
- console.error(err.message || err.error);
316
+ jsonError(error, message);
317
+ console.error(message);
302
318
  process.exit(1);
303
319
  }
304
320
  const data = await res.json();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "latinfo",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "SUNAT RUC/DNI lookup CLI. Query Peru taxpayer data from terminal. Works without login. 18M+ records.",
5
5
  "homepage": "https://latinfo.dev",
6
6
  "repository": {