latinfo 0.5.1 → 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.1';
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;
@@ -138,7 +146,7 @@ async function ruc(rucNumber) {
138
146
  Zona: ${[demo.codigo_zona, demo.tipo_zona].filter(v => v && v !== '-').join(' ')}
139
147
  `.trim());
140
148
  }
141
- process.stderr.write(`Demo data (${Object.keys(demo_data_1.DEMO_DATA).length} records). Run 'latinfo login' for 11M+ records.\n`);
149
+ process.stderr.write(`Demo data (${Object.keys(demo_data_1.DEMO_DATA).length} records). Run 'latinfo login' for 18M+ records.\n`);
142
150
  }
143
151
  else {
144
152
  if (jsonFlag)
@@ -218,7 +226,7 @@ async function search(query) {
218
226
  console.log(`\n${results.length} result(s)`);
219
227
  }
220
228
  }
221
- process.stderr.write(`Demo data (${Object.keys(demo_data_1.DEMO_DATA).length} records). Run 'latinfo login' for 11M+ records.\n`);
229
+ process.stderr.write(`Demo data (${Object.keys(demo_data_1.DEMO_DATA).length} records). Run 'latinfo login' for 18M+ records.\n`);
222
230
  return;
223
231
  }
224
232
  const res = await apiRequest(config, `/pe/search?q=${encodeURIComponent(query)}`);
@@ -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();
@@ -394,7 +410,7 @@ QUICK START (no login needed)
394
410
  latinfo ruc 20131312955 --json # SUNAT, JSON output
395
411
 
396
412
  Works instantly with ${Object.keys(demo_data_1.DEMO_DATA).length} embedded records. Run 'latinfo login'
397
- for 11M+ records and DNI lookup.
413
+ for 18M+ records and DNI lookup.
398
414
 
399
415
  AUTH
400
416
  Config file: ~/.latinfo/config.json
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "latinfo",
3
- "version": "0.5.1",
4
- "description": "SUNAT RUC/DNI lookup CLI. Query Peru taxpayer data from terminal. Works without login. 11M+ records.",
3
+ "version": "0.5.3",
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": {
7
7
  "type": "git",