@dpuse/dpuse-tool-adaltas-csv-parser 1.0.114 → 1.0.116

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/README.md CHANGED
@@ -61,7 +61,7 @@ License data is updated each time `npm run document` is run, using [license-chec
61
61
 
62
62
  | Dependency | Version | License(s) | Document |
63
63
  | :----------------------------------------------------------- | :-----: | :--------- | :-------------------------------------------------------------------- |
64
- | [@dpuse/dpuse-shared](https://github.com/dpuse/dpuse-shared) | 1.0.136 | MIT | [LICENSE](licenses/downloads/@dpuse/dpuse-shared@1.0.136-LICENSE.txt) |
64
+ | [@dpuse/dpuse-shared](https://github.com/dpuse/dpuse-shared) | 1.0.144 | MIT | [LICENSE](licenses/downloads/@dpuse/dpuse-shared@1.0.144-LICENSE.txt) |
65
65
  | [csv-parse](https://github.com/adaltas/node-csv) | 7.0.3 | MIT | [LICENSE](licenses/downloads/csv-parse@7.0.3-LICENSE.txt) |
66
66
  | [valibot](https://github.com/open-circle/valibot) | 1.5.0 | MIT | [LICENSE](licenses/downloads/valibot@1.5.0-LICENSE.txt) |
67
67
 
@@ -69,7 +69,7 @@ License data is updated each time `npm run document` is run, using [license-chec
69
69
 
70
70
  The dependency tree below shows how each package in the table above is reached — direct and transitive — along with its installed version, release date, and update status. A package that does not ship itself, such as one whose parts are bundled separately, is left out and what ships beneath it is shown in its place. Packages flagged ❗ have a newer version available; ⚠️ indicates a package that hasn't been updated in the last 6 months or longer. Neither flag necessarily indicates a problem: we let new releases stabilise before upgrading, and some packages are mature and stable (have limited or no dependencies), so they require no active development.
71
71
 
72
- - **[@dpuse/dpuse-shared](https://github.com/dpuse/dpuse-shared)** 1.0.136 — this month: 2026-10-25
72
+ - **[@dpuse/dpuse-shared](https://github.com/dpuse/dpuse-shared)** 1.0.144 — this month: 2026-10-26
73
73
  - **[valibot](https://github.com/open-circle/valibot)** 1.5.0 — 1 mth ago: 2026-09-09
74
74
  - **[csv-parse](https://github.com/adaltas/node-csv)** 7.0.3 — 1 mth ago: 2026-09-25
75
75
 
@@ -85,11 +85,11 @@ _Note: Sonda's Vite reports currently exclude CSS files, since Vite does not gen
85
85
 
86
86
  | Chunk/Module/File | Composition |
87
87
  | :-------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------- |
88
- | **dist/dpuse-tool-adaltas-csv-parser.es.js** | 125.9 kB · gzip 31.6 kB · 100.0% of the build |
89
- |     csv-parse → dist/esm/index.js | `████████████████░░░░` 78.8% · 99.2 kB |
90
- |     @dpuse/dpuse-shared → dist/dpuse-shared.es.js | `██░░░░░░░░░░░░░░░░░░` 12.1% · 15.2 kB |
91
- |     src → index.ts | `█░░░░░░░░░░░░░░░░░░░` 3.4% · 4.3 kB |
92
- |     (bundler output, whitespace & JSON) | `█░░░░░░░░░░░░░░░░░░░` 5.7% · 7.2 kB |
88
+ | **dist/dpuse-tool-adaltas-csv-parser.es.js** | 127.0 kB · gzip 32.0 kB · 100.0% of the build |
89
+ |     csv-parse → dist/esm/index.js | `████████████████░░░░` 78.1% · 99.2 kB |
90
+ |     @dpuse/dpuse-shared → dist/dpuse-shared.es.js | `██░░░░░░░░░░░░░░░░░░` 12.0% · 15.2 kB |
91
+ |     src → index.ts | `█░░░░░░░░░░░░░░░░░░░` 4.2% · 5.3 kB |
92
+ |     (bundler output, whitespace & JSON) | `█░░░░░░░░░░░░░░░░░░░` 5.7% · 7.3 kB |
93
93
 
94
94
  Bars show each row's share of its output file.
95
95
 
@@ -2900,7 +2900,7 @@ var Tr = {
2900
2900
  status: /* @__PURE__ */ Z(Cr),
2901
2901
  statusId: /* @__PURE__ */ Z(Sr)
2902
2902
  };
2903
- ({ ...Tr }), J({ en: "Apache Arrow" }), J({ en: "Apache Avro" }), J({ en: "Data Positioning Events" }), J({ en: "Delimited Text" }), J({ en: "JSON" }), J({ en: "JSON Lines" }), J({ en: "Markdown" }), J({ en: "OpenDocument Spreadsheet" }), J({ en: "Apache Parquet" }), J({ en: "SPSS" }), J({ en: "SQLite" }), J({ en: "Plain Text" }), J({ en: "XLSM" }), J({ en: "XLSX" }), J({ en: "XML" }), J({ en: "Newline" }), J({ en: "Carriage Return" }), J({ en: "Carriage Return/Newline" }), J({ en: "Colon" }), J({ en: "Comma" }), J({ en: "Exclamation Mark" }), J({ en: "Record Separator" }), J({ en: "Semicolon" }), J({ en: "Space" }), J({ en: "Tab" }), J({ en: "Underscore" }), J({ en: "Unit Separator" }), J({ en: "Vertical Bar" }), $([
2903
+ ({ ...Tr }), J({ en: "Arrow" }), J({ en: "Avro" }), J({ en: "Delimited text (CSV, TAB, TSV…)" }), J({ en: "JSON" }), J({ en: "JSON Lines (JSONL)" }), J({ en: "Markdown (MD)" }), J({ en: "OpenDocument spreadsheet (ODS)" }), J({ en: "Parquet" }), J({ en: "SPSS (SAV)" }), J({ en: "SQLite" }), J({ en: "Excel (XLSX, XLSM)" }), J({ en: "XML" }), J({ en: "Newline" }), J({ en: "Carriage Return" }), J({ en: "Carriage Return/Newline" }), J({ en: "Colon" }), J({ en: "Comma" }), J({ en: "Exclamation Mark" }), J({ en: "Record Separator" }), J({ en: "Semicolon" }), J({ en: "Space" }), J({ en: "Tab" }), J({ en: "Underscore" }), J({ en: "Unit Separator" }), J({ en: "Vertical Bar" }), $([
2904
2904
  "app",
2905
2905
  "engine",
2906
2906
  "connector",
@@ -3464,7 +3464,7 @@ var Lr = {
3464
3464
  skip_records_with_error: !1,
3465
3465
  to_line: -1,
3466
3466
  trim: !1
3467
- }, Rr = 4, zr = 1e4, Br = class {
3467
+ }, Rr = 4, zr = 50, Br = 1e4, Vr = class {
3468
3468
  async parseStream(e, t, n, r, i) {
3469
3469
  return new Promise((a, o) => {
3470
3470
  let s, c, l, u = !1, d = !1, f = () => {
@@ -3485,9 +3485,9 @@ var Lr = {
3485
3485
  value: e,
3486
3486
  wasValueQuoted: t.quoting
3487
3487
  })
3488
- }), l = Vr({
3488
+ }), l = Hr({
3489
3489
  chunk: i,
3490
- chunkSize: e.chunkSize ?? zr
3490
+ chunkSize: e.chunkSize ?? Br
3491
3491
  }), s.on("readable", () => {
3492
3492
  try {
3493
3493
  if (s == null || l == null) return;
@@ -3502,7 +3502,7 @@ var Lr = {
3502
3502
  }), s.on("error", (e) => {
3503
3503
  p(e);
3504
3504
  }), s.on("end", () => {
3505
- u || (l?.flush(), a(Hr(s)));
3505
+ u || (l?.flush(), a(Ur(s)));
3506
3506
  });
3507
3507
  let o = await fetch(encodeURI(n), { signal: r.signal });
3508
3508
  if (!o.ok || o.body == null) throw await Ar(o, `Failed to fetch '${n}' file.`, "dpuse-connector-file-store-emulator|Connector|retrieve");
@@ -3523,15 +3523,16 @@ var Lr = {
3523
3523
  });
3524
3524
  }
3525
3525
  async parseText(e, t, n = !1) {
3526
- let r = Ur(e), { parsedRecords: i, valueDelimiterId: a } = await Wr(e, t, n);
3526
+ let r = Wr(e), { issues: i, parsedRecords: a, valueDelimiterId: o } = await Gr(e, t, n);
3527
3527
  return {
3528
- parsedRecords: i,
3528
+ issues: i,
3529
+ parsedRecords: a,
3529
3530
  recordDelimiterId: r,
3530
- valueDelimiterId: a
3531
+ valueDelimiterId: o
3531
3532
  };
3532
3533
  }
3533
3534
  };
3534
- function Vr(e) {
3535
+ function Hr(e) {
3535
3536
  let t = Math.max(1, Math.floor(e.chunkSize)), n = [], r = o(), i = 0, a = () => {
3536
3537
  if (i === 0) return;
3537
3538
  let t = r;
@@ -3550,7 +3551,7 @@ function Vr(e) {
3550
3551
  return r.length = 0, r;
3551
3552
  }
3552
3553
  }
3553
- function Hr(e) {
3554
+ function Ur(e) {
3554
3555
  return {
3555
3556
  byteCount: e?.info.bytes ?? -1,
3556
3557
  commentLineCount: e?.info.comment_lines ?? -1,
@@ -3560,52 +3561,90 @@ function Hr(e) {
3560
3561
  recordCount: e?.info.records ?? -1
3561
3562
  };
3562
3563
  }
3563
- function Ur(e) {
3564
+ function Wr(e) {
3564
3565
  let t = (e.match(/\r\n/g) ?? []).length, n = (e.match(/(?<!\r)\n/g) ?? []).length, r = (e.match(/\r(?!\n)/g) ?? []).length;
3565
3566
  return t >= n && t >= r ? "\r\n" : n >= t && n >= r ? "\n" : r >= t && r >= n ? "\r" : "\n";
3566
3567
  }
3567
- async function Wr(e, t, n) {
3568
+ async function Gr(e, t, n) {
3568
3569
  let r, i, a, o = [], s, c = !1;
3569
3570
  for (let l of t) {
3570
- let { error: t, records: u } = await Gr(e, l, n);
3571
- if (t != null) {
3572
- s ??= t;
3571
+ let { issues: t, records: u } = await qr(e, l, n);
3572
+ if (t.length > 0) {
3573
+ s = Kr(s, {
3574
+ delimiter: l,
3575
+ issues: t,
3576
+ records: u
3577
+ });
3573
3578
  continue;
3574
3579
  }
3575
3580
  if (c = !0, u.length === 0) continue;
3576
- let { averageValueCount: d, sumOfValueCountDiffs: f } = Kr(u);
3581
+ let { averageValueCount: d, sumOfValueCountDiffs: f } = Yr(u);
3577
3582
  (!a || f <= a) && (!i || d > i) && (r = l, i = d, a = f, o = u);
3578
3583
  }
3579
- if (!c && s != null) throw s;
3584
+ if (!c && s != null) {
3585
+ let { delimiter: e, issues: t, records: n } = s;
3586
+ return {
3587
+ issues: t,
3588
+ parsedRecords: n,
3589
+ valueDelimiterId: Xr(n) ? e : void 0
3590
+ };
3591
+ }
3580
3592
  return {
3593
+ issues: [],
3581
3594
  parsedRecords: o,
3582
- valueDelimiterId: r != null && qr(o) ? r : void 0
3595
+ valueDelimiterId: r != null && Xr(o) ? r : void 0
3583
3596
  };
3584
3597
  }
3585
- function Gr(e, t, n) {
3598
+ function Kr(e, t) {
3599
+ return e == null || t.issues.length < e.issues.length ? t : e;
3600
+ }
3601
+ function qr(e, t, n) {
3586
3602
  return new Promise((r) => {
3587
- let i = [], a = ar({
3603
+ let i = [], a = [], o = 0, s = (e) => {
3604
+ e == null || !n && e.code === "CSV_QUOTE_NOT_CLOSED" || (i.push(Jr(e, o + 1)), e.lines != null && (o = e.lines));
3605
+ }, c = ar({
3588
3606
  ...Lr,
3589
3607
  cast: (e, t) => ({
3590
3608
  value: e,
3591
3609
  wasValueQuoted: t.quoting
3592
3610
  }),
3593
3611
  delimiter: t,
3594
- relax_column_count: !0
3612
+ info: !0,
3613
+ on_skip: (e) => {
3614
+ s(e);
3615
+ },
3616
+ relax_column_count: !0,
3617
+ skip_records_with_error: !0
3595
3618
  });
3596
- a.on("data", (e) => {
3597
- i.push(e);
3598
- }), a.on("error", (e) => {
3599
- r(!n && e.code === "CSV_QUOTE_NOT_CLOSED" ? { records: i } : {
3600
- error: e,
3601
- records: i
3619
+ c.on("data", ({ info: e, record: t }) => {
3620
+ a.push(t), o = e.lines;
3621
+ }), c.on("error", (e) => {
3622
+ s(e), r({
3623
+ issues: i,
3624
+ records: a
3625
+ });
3626
+ }), c.on("end", () => {
3627
+ r({
3628
+ issues: i,
3629
+ records: a
3602
3630
  });
3603
- }), a.on("end", () => {
3604
- r({ records: i });
3605
- }), a.write(e), a.end();
3631
+ }), c.write(e), c.end();
3606
3632
  });
3607
3633
  }
3608
- function Kr(e) {
3634
+ function Jr(e, t) {
3635
+ let n = e.lines, r = e.code === "CSV_INVALID_CLOSING_QUOTE" ? /got "(.*?)" at line/u.exec(e.message)?.[1] : void 0, i = typeof e.field == "string" ? e.field : r;
3636
+ return {
3637
+ endLineNumber: n != null && n > t ? n : void 0,
3638
+ fieldNumber: e.index == null ? void 0 : e.index + 1,
3639
+ id: e.code ?? "CSV_UNKNOWN_ERROR",
3640
+ lineNumber: n == null ? void 0 : Math.min(t, n),
3641
+ message: e.message,
3642
+ recordNumber: e.records == null ? void 0 : e.records + 1,
3643
+ severityId: "error",
3644
+ value: i != null && i.length > zr ? `${i.slice(0, zr)}…` : i
3645
+ };
3646
+ }
3647
+ function Yr(e) {
3609
3648
  let t = 0, n = 0, r;
3610
3649
  for (let i of e) r != null && (n += Math.abs(i.length - r)), r = i.length, t += i.length;
3611
3650
  return {
@@ -3613,10 +3652,10 @@ function Kr(e) {
3613
3652
  sumOfValueCountDiffs: n
3614
3653
  };
3615
3654
  }
3616
- function qr(e) {
3655
+ function Xr(e) {
3617
3656
  let t = /* @__PURE__ */ new Map();
3618
3657
  for (let n of e) t.set(n.length, (t.get(n.length) ?? 0) + 1);
3619
3658
  let [n = 0, r = 0] = [...t].toSorted((e, t) => t[1] - e[1])[0] ?? [];
3620
3659
  return n > 1 && r * 2 > e.length;
3621
3660
  }
3622
- export { Br as Tool };
3661
+ export { Vr as Tool };