latinfo 0.17.0 → 0.18.1

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.
Files changed (2) hide show
  1. package/dist/index.js +65 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -47,7 +47,7 @@ const local_search_1 = require("./local-search");
47
47
  const client_search_1 = require("./client-search");
48
48
  const odis_search_1 = require("./odis-search");
49
49
  const mphf_search_1 = require("./mphf-search");
50
- const VERSION = '0.17.0';
50
+ const VERSION = '0.18.1';
51
51
  const API_URL = process.env.LATINFO_API_URL || 'https://api.latinfo.dev';
52
52
  const GITHUB_CLIENT_ID = process.env.GITHUB_CLIENT_ID || 'Ov23li5fcQaiCsVtaMKK';
53
53
  const CONFIG_DIR = path_1.default.join(os_1.default.homedir(), '.latinfo');
@@ -748,6 +748,67 @@ function costsSimulate(usersStr, rpmStr, proPctStr) {
748
748
  printCosts({ users, pro_users: proUsers, requests, cf_tier: cfTier, cf_cost: cfCost, revenue, margin, safe: margin >= 0 });
749
749
  }
750
750
  // --- Bench ---
751
+ // --- Search server status ---
752
+ async function searchServerStatus() {
753
+ const { execSync } = await Promise.resolve().then(() => __importStar(require('child_process')));
754
+ const RUNNER = 'f3mt0@100.109.82.87';
755
+ // Test SSH
756
+ try {
757
+ execSync(`ssh -o ConnectTimeout=5 ${RUNNER} "echo OK"`, { stdio: 'pipe' });
758
+ }
759
+ catch {
760
+ console.error(' Linux Mint not reachable. Is it on?');
761
+ process.exit(1);
762
+ }
763
+ // Live loop until ready
764
+ while (true) {
765
+ // Check health
766
+ try {
767
+ const health = execSync(`ssh ${RUNNER} "curl -s http://localhost:3001/health"`, { encoding: 'utf-8', stdio: 'pipe' }).trim();
768
+ const data = JSON.parse(health);
769
+ if (data.status === 'ok') {
770
+ if (process.stdout.isTTY)
771
+ process.stdout.write('\r' + ' '.repeat(80) + '\r');
772
+ console.log(`\n Search server: READY`);
773
+ console.log(` Mode: ${data.mode || 'ram'}`);
774
+ console.log(` Sources: ${data.sources.join(', ')}`);
775
+ console.log(` Disk shards: ${data.diskShards || 0}`);
776
+ console.log(` RAM shards: ${data.ramShards || 0}`);
777
+ console.log(` RAM: ${data.ramMB || '?'} MB`);
778
+ // Quick search test per source
779
+ for (const src of data.sources) {
780
+ try {
781
+ const testResult = execSync(`ssh ${RUNNER} "curl -s 'http://localhost:3001/search?source=${src}&q=banco'"`, { encoding: 'utf-8', stdio: 'pipe' }).trim();
782
+ const testData = JSON.parse(testResult);
783
+ console.log(` Search ${src}: ${testData.results?.length || 0} results in ${testData.ms}ms`);
784
+ }
785
+ catch { }
786
+ }
787
+ return;
788
+ }
789
+ }
790
+ catch { }
791
+ // Not ready — show progress bar (overwrites same line)
792
+ try {
793
+ const diskUsage = execSync(`ssh ${RUNNER} "du -sm /tmp/latinfo-search-data/ 2>/dev/null | awk '{print \\$1}'"`, { encoding: 'utf-8', stdio: 'pipe' }).trim();
794
+ const currentMB = parseInt(diskUsage) || 0;
795
+ const totalExpected = 6400;
796
+ const pct = Math.min(Math.floor(currentMB / totalExpected * 100), 99);
797
+ const filled = Math.floor(pct * 30 / 100);
798
+ const bar = '█'.repeat(filled) + '░'.repeat(30 - filled);
799
+ const lastLog = execSync(`ssh ${RUNNER} "sudo journalctl -u latinfo-search --no-pager -n 5 2>/dev/null | grep -oE '(Shard [0-9]+|Loading [^ ]+)' | tail -1"`, { encoding: 'utf-8', stdio: 'pipe' }).trim();
800
+ if (process.stdout.isTTY) {
801
+ process.stdout.write(`\r [${bar}] ${currentMB}/${totalExpected} MB (${pct}%) — ${lastLog || '...'} `);
802
+ }
803
+ else {
804
+ console.log(` [${bar}] ${currentMB}/${totalExpected} MB (${pct}%) — ${lastLog || '...'}`);
805
+ return; // non-TTY: print once
806
+ }
807
+ }
808
+ catch { }
809
+ await new Promise(r => setTimeout(r, 10_000));
810
+ }
811
+ }
751
812
  // Seed queries used to discover real data from the API
752
813
  const SEED_QUERIES = ['banco', 'empresa', 'servicios', 'comercial', 'grupo'];
753
814
  function discoverBenchSources(filterSource) {
@@ -3168,6 +3229,9 @@ else {
3168
3229
  case 'bench':
3169
3230
  bench(args).catch(e => { console.error(e); process.exit(1); });
3170
3231
  break;
3232
+ case 'search-server':
3233
+ searchServerStatus().catch(e => { console.error(e); process.exit(1); });
3234
+ break;
3171
3235
  case 'pipe':
3172
3236
  pipe(args).catch(e => { console.error(e); process.exit(1); });
3173
3237
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "latinfo",
3
- "version": "0.17.0",
3
+ "version": "0.18.1",
4
4
  "description": "Tax registry & procurement API for Latin America. Query RUC, DNI, NIT, licitaciones from Peru & Colombia. Offline MPHF search, full OCDS data, updated daily.",
5
5
  "homepage": "https://latinfo.dev",
6
6
  "repository": {