@arela/uploader 1.1.0 → 1.1.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arela/uploader",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "CLI to upload files/directories to Arela",
5
5
  "bin": {
6
6
  "arela": "./src/index.js"
@@ -311,6 +311,9 @@ export class IdentifyCommand {
311
311
  return {
312
312
  processed: 0,
313
313
  detected: 0,
314
+ // Must include every field totalStats accumulates — omitting proformas
315
+ // made `totalStats.proformas += undefined` = NaN in the final summary.
316
+ proformas: 0,
314
317
  errors: 0,
315
318
  };
316
319
  }
@@ -37,10 +37,10 @@ class Config {
37
37
  const __dirname = path.dirname(__filename);
38
38
  const packageJsonPath = path.resolve(__dirname, '../../package.json');
39
39
  const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
40
- return packageJson.version || '1.1.0';
40
+ return packageJson.version || '1.1.2';
41
41
  } catch (error) {
42
42
  console.warn('⚠️ Could not read package.json version, using fallback');
43
- return '1.1.0';
43
+ return '1.1.2';
44
44
  }
45
45
  }
46
46
 
@@ -145,8 +145,15 @@ export const codigoAceptacionExtractor = {
145
145
  },
146
146
  };
147
147
 
148
- // 7) Num. E-Document: collects all 13-char alphanumeric codes following
149
- // `NUM. E-DOCUMENT` / `NUMERO DE E-DOCUMENT` labels.
148
+ // 7) Num. E-Document: collects all 13-char codes following
149
+ // `NUM. E-DOCUMENT` / `NUMERO DE E-DOCUMENT` labels. Real eDocument
150
+ // numbers START WITH A DIGIT (e.g. "0438261FSSN86"); MVE acuse folios
151
+ // ("MNVA26002Q3V5") are also listed under the same label and kept —
152
+ // downstream consumers filter them. The old bare [A-Z0-9]{13} also
153
+ // captured 13-letter words (TRANSPORTISTA), truncated tokens
154
+ // (IDENTIFICACIO[N], CURP prefixes) and RFCs.
155
+ const EDOC_RE = /(?<![A-Z0-9])(?:\d[A-Z0-9]{12}|MNVA[A-Z0-9]{9})(?![A-Z0-9])/g;
156
+
150
157
  export const numEDocumentoExtractor = {
151
158
  field: 'numEDocumento',
152
159
  extract: (source) => {
@@ -160,14 +167,14 @@ export const numEDocumentoExtractor = {
160
167
  if (!hasTitle) continue;
161
168
 
162
169
  // Codes on the title line itself
163
- const codesInLine = line.match(/[A-Z0-9]{13}/g) || [];
170
+ const codesInLine = line.match(EDOC_RE) || [];
164
171
  extractedCodes.push(...codesInLine);
165
172
 
166
173
  // Codes on the next few lines (e.g. CLAVE/COMPL. table rows)
167
174
  for (let j = 1; j <= 10 && i + j < lines.length; j++) {
168
175
  const nextLine = lines[i + j];
169
176
  if (/NUMERO|OBSERVACIONES/i.test(nextLine)) break;
170
- const codesInNextLine = nextLine.match(/[A-Z0-9]{13}/g) || [];
177
+ const codesInNextLine = nextLine.match(EDOC_RE) || [];
171
178
  extractedCodes.push(...codesInNextLine);
172
179
  }
173
180
  }
@@ -64,16 +64,21 @@ function toRegExp(clue) {
64
64
  return re;
65
65
  }
66
66
 
67
- // Cap the text a single regex runs on. Real extracted document text is far
68
- // below this; the cap only bounds pathological/crafted inputs so an allowed
69
- // (quadratic) pattern can't blow up on a megabyte-scale adversarial string.
70
- const MATCH_INPUT_CAP = 1_000_000;
67
+ // Bound the text a single regex runs on so an allowed (quadratic) pattern
68
+ // can't blow up on a megabyte-scale adversarial string. Real documents can
69
+ // legitimately exceed the cap (edocument XMLs embed multi-MB base64 PDFs with
70
+ // signature tags AFTER the blob), so instead of truncating we sample a HEAD +
71
+ // TAIL window — signatures live at the extremes, the blob in the middle.
72
+ // (Parity with the API TS engine.)
73
+ const MATCH_HEAD_CAP = 1_000_000;
74
+ const MATCH_TAIL_CAP = 262_144;
71
75
 
72
76
  function clueTarget(clue, ctx) {
73
77
  // FILENAME_REGEX tests the file name; every other kind tests the content.
74
78
  const raw =
75
79
  clue.kind === 'FILENAME_REGEX' ? (ctx.fileName ?? '') : (ctx.source ?? '');
76
- return raw.length > MATCH_INPUT_CAP ? raw.slice(0, MATCH_INPUT_CAP) : raw;
80
+ if (raw.length <= MATCH_HEAD_CAP + MATCH_TAIL_CAP) return raw;
81
+ return `${raw.slice(0, MATCH_HEAD_CAP)}\n${raw.slice(-MATCH_TAIL_CAP)}`;
77
82
  }
78
83
 
79
84
  /**
@@ -81,6 +81,10 @@ export class LoggingService {
81
81
  */
82
82
  info(message) {
83
83
  this.writeLog(message, 'info');
84
+ // Echo to console: run banners, stats and the 🧩 observability lines were
85
+ // file-only, so operators watching the terminal never saw them (the v1
86
+ // canary summary was invisible until someone grepped arela-upload.log).
87
+ console.log(message);
84
88
  }
85
89
 
86
90
  /**
@@ -89,9 +93,7 @@ export class LoggingService {
89
93
  */
90
94
  warn(message) {
91
95
  this.writeLog(message, 'warn');
92
- if (this.isVerbose) {
93
- console.warn(`⚠️ ${message}`);
94
- }
96
+ console.warn(`⚠️ ${message}`);
95
97
  }
96
98
 
97
99
  /**