@dpuse/dpuse-tool-adaltas-csv-parser 1.0.115 → 1.0.117

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.143 | MIT | [LICENSE](licenses/downloads/@dpuse/dpuse-shared@1.0.143-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.143 — this month: 2026-10-26
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** | 126.4 kB · gzip 31.8 kB · 100.0% of the build |
89
- |     csv-parse → dist/esm/index.js | `████████████████░░░░` 78.5% · 99.2 kB |
88
+ | **dist/dpuse-tool-adaltas-csv-parser.es.js** | 127.2 kB · gzip 32.1 kB · 100.0% of the build |
89
+ |     csv-parse → dist/esm/index.js | `████████████████░░░░` 78.0% · 99.2 kB |
90
90
  |     @dpuse/dpuse-shared → dist/dpuse-shared.es.js | `██░░░░░░░░░░░░░░░░░░` 12.0% · 15.2 kB |
91
- |     src → index.ts | `█░░░░░░░░░░░░░░░░░░░` 3.7% · 4.7 kB |
92
- |     (bundler output, whitespace & JSON) | `█░░░░░░░░░░░░░░░░░░░` 5.8% · 7.3 kB |
91
+ |     src → index.ts | `█░░░░░░░░░░░░░░░░░░░` 4.3% · 5.4 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
 
@@ -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,7 +3523,7 @@ var Lr = {
3523
3523
  });
3524
3524
  }
3525
3525
  async parseText(e, t, n = !1) {
3526
- let r = Ur(e), { issues: i, parsedRecords: a, valueDelimiterId: o } = 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
3528
  issues: i,
3529
3529
  parsedRecords: a,
@@ -3532,7 +3532,7 @@ var Lr = {
3532
3532
  };
3533
3533
  }
3534
3534
  };
3535
- function Vr(e) {
3535
+ function Hr(e) {
3536
3536
  let t = Math.max(1, Math.floor(e.chunkSize)), n = [], r = o(), i = 0, a = () => {
3537
3537
  if (i === 0) return;
3538
3538
  let t = r;
@@ -3551,7 +3551,7 @@ function Vr(e) {
3551
3551
  return r.length = 0, r;
3552
3552
  }
3553
3553
  }
3554
- function Hr(e) {
3554
+ function Ur(e) {
3555
3555
  return {
3556
3556
  byteCount: e?.info.bytes ?? -1,
3557
3557
  commentLineCount: e?.info.comment_lines ?? -1,
@@ -3561,16 +3561,16 @@ function Hr(e) {
3561
3561
  recordCount: e?.info.records ?? -1
3562
3562
  };
3563
3563
  }
3564
- function Ur(e) {
3564
+ function Wr(e) {
3565
3565
  let t = (e.match(/\r\n/g) ?? []).length, n = (e.match(/(?<!\r)\n/g) ?? []).length, r = (e.match(/\r(?!\n)/g) ?? []).length;
3566
3566
  return t >= n && t >= r ? "\r\n" : n >= t && n >= r ? "\n" : r >= t && r >= n ? "\r" : "\n";
3567
3567
  }
3568
- async function Wr(e, t, n) {
3568
+ async function Gr(e, t, n) {
3569
3569
  let r, i, a, o = [], s, c = !1;
3570
3570
  for (let l of t) {
3571
- let { issues: t, records: u } = await Kr(e, l, n);
3571
+ let { issues: t, records: u } = await qr(e, l, n);
3572
3572
  if (t.length > 0) {
3573
- s = Gr(s, {
3573
+ s = Kr(s, {
3574
3574
  delimiter: l,
3575
3575
  issues: t,
3576
3576
  records: u
@@ -3578,7 +3578,7 @@ async function Wr(e, t, n) {
3578
3578
  continue;
3579
3579
  }
3580
3580
  if (c = !0, u.length === 0) continue;
3581
- let { averageValueCount: d, sumOfValueCountDiffs: f } = qr(u);
3581
+ let { averageValueCount: d, sumOfValueCountDiffs: f } = Yr(u);
3582
3582
  (!a || f <= a) && (!i || d > i) && (r = l, i = d, a = f, o = u);
3583
3583
  }
3584
3584
  if (!c && s != null) {
@@ -3586,56 +3586,69 @@ async function Wr(e, t, n) {
3586
3586
  return {
3587
3587
  issues: t,
3588
3588
  parsedRecords: n,
3589
- valueDelimiterId: Jr(n) ? e : void 0
3589
+ valueDelimiterId: Xr(n) ? e : void 0
3590
3590
  };
3591
3591
  }
3592
3592
  return {
3593
3593
  issues: [],
3594
3594
  parsedRecords: o,
3595
- valueDelimiterId: r != null && Jr(o) ? r : void 0
3595
+ valueDelimiterId: r != null && Xr(o) ? r : void 0
3596
3596
  };
3597
3597
  }
3598
- function Gr(e, t) {
3598
+ function Kr(e, t) {
3599
3599
  return e == null || t.issues.length < e.issues.length ? t : e;
3600
3600
  }
3601
- function Kr(e, t, n) {
3601
+ function qr(e, t, n) {
3602
3602
  return new Promise((r) => {
3603
- let i = [], a = [], o = (e) => {
3604
- e == null || !n && e.code === "CSV_QUOTE_NOT_CLOSED" || i.push({
3605
- id: e.code ?? "CSV_UNKNOWN_ERROR",
3606
- lineNumber: e.lines,
3607
- message: e.message,
3608
- severityId: "error"
3609
- });
3610
- }, s = ar({
3603
+ let i = [], a = [], o = 0, s = (e) => {
3604
+ if (e == null || !n && e.code === "CSV_QUOTE_NOT_CLOSED") return;
3605
+ let t = Jr(e, o + 1);
3606
+ e.lines != null && (o = e.lines);
3607
+ let r = i.at(-1);
3608
+ r != null && t.id === "CSV_QUOTE_NOT_CLOSED" && r.recordNumber === t.recordNumber ? r.endLineNumber = t.endLineNumber ?? t.lineNumber : i.push(t);
3609
+ }, c = ar({
3611
3610
  ...Lr,
3612
3611
  cast: (e, t) => ({
3613
3612
  value: e,
3614
3613
  wasValueQuoted: t.quoting
3615
3614
  }),
3616
3615
  delimiter: t,
3616
+ info: !0,
3617
3617
  on_skip: (e) => {
3618
- o(e);
3618
+ s(e);
3619
3619
  },
3620
3620
  relax_column_count: !0,
3621
3621
  skip_records_with_error: !0
3622
3622
  });
3623
- s.on("data", (e) => {
3624
- a.push(e);
3625
- }), s.on("error", (e) => {
3626
- o(e), r({
3623
+ c.on("data", ({ info: e, record: t }) => {
3624
+ a.push(t), o = e.lines;
3625
+ }), c.on("error", (e) => {
3626
+ s(e), r({
3627
3627
  issues: i,
3628
3628
  records: a
3629
3629
  });
3630
- }), s.on("end", () => {
3630
+ }), c.on("end", () => {
3631
3631
  r({
3632
3632
  issues: i,
3633
3633
  records: a
3634
3634
  });
3635
- }), s.write(e), s.end();
3635
+ }), c.write(e), c.end();
3636
3636
  });
3637
3637
  }
3638
- function qr(e) {
3638
+ function Jr(e, t) {
3639
+ 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;
3640
+ return {
3641
+ endLineNumber: n != null && n > t ? n : void 0,
3642
+ fieldNumber: e.index == null ? void 0 : e.index + 1,
3643
+ id: e.code ?? "CSV_UNKNOWN_ERROR",
3644
+ lineNumber: n == null ? void 0 : Math.min(t, n),
3645
+ message: e.message,
3646
+ recordNumber: e.records == null ? void 0 : e.records + 1,
3647
+ severityId: "error",
3648
+ value: i != null && i.length > zr ? `${i.slice(0, zr)}…` : i
3649
+ };
3650
+ }
3651
+ function Yr(e) {
3639
3652
  let t = 0, n = 0, r;
3640
3653
  for (let i of e) r != null && (n += Math.abs(i.length - r)), r = i.length, t += i.length;
3641
3654
  return {
@@ -3643,10 +3656,10 @@ function qr(e) {
3643
3656
  sumOfValueCountDiffs: n
3644
3657
  };
3645
3658
  }
3646
- function Jr(e) {
3659
+ function Xr(e) {
3647
3660
  let t = /* @__PURE__ */ new Map();
3648
3661
  for (let n of e) t.set(n.length, (t.get(n.length) ?? 0) + 1);
3649
3662
  let [n = 0, r = 0] = [...t].toSorted((e, t) => t[1] - e[1])[0] ?? [];
3650
3663
  return n > 1 && r * 2 > e.length;
3651
3664
  }
3652
- export { Br as Tool };
3665
+ export { Vr as Tool };