@dpuse/dpuse-tool-adaltas-csv-parser 1.0.119 → 1.0.121

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.146 | MIT | [LICENSE](licenses/downloads/@dpuse/dpuse-shared@1.0.146-LICENSE.txt) |
64
+ | [@dpuse/dpuse-shared](https://github.com/dpuse/dpuse-shared) | 1.0.153 | MIT | [LICENSE](licenses/downloads/@dpuse/dpuse-shared@1.0.153-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.146 — this month: 2026-10-26
72
+ - **[@dpuse/dpuse-shared](https://github.com/dpuse/dpuse-shared)** 1.0.153 — this month: 2026-10-27
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** | 127.0 kB · gzip 31.9 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 |
88
+ | **dist/dpuse-tool-adaltas-csv-parser.es.js** | 126.5 kB · gzip 31.7 kB · 100.0% of the build |
89
+ |     csv-parse → dist/esm/index.js | `████████████████░░░░` 78.4% · 99.2 kB |
90
+ |     @dpuse/dpuse-shared → dist/dpuse-shared.es.js | `███░░░░░░░░░░░░░░░░░` 12.5% · 15.8 kB |
91
+ |     src → index.ts | `█░░░░░░░░░░░░░░░░░░░` 3.3% · 4.1 kB |
92
+ |     (bundler output, whitespace & JSON) | `█░░░░░░░░░░░░░░░░░░░` 5.8% · 7.4 kB |
93
93
 
94
94
  Bars show each row's share of its output file.
95
95
 
@@ -2950,48 +2950,87 @@ var Er = {
2950
2950
  "disabled",
2951
2951
  "oAuth2",
2952
2952
  "none"
2953
- ]), { ...Er }, $(["list"]), { ...Er };
2954
- var Dr = 2048, Or = class extends Error {
2955
- data;
2956
- locator;
2957
- constructor(e, t, n, r) {
2958
- super(e, r), this.name = "DPUseError", this.data = n, this.locator = t;
2959
- }
2960
- }, kr = class extends Or {
2961
- constructor(e, t, n, r) {
2962
- super(e, t, n, r), this.name = "FetchError";
2963
- }
2964
- };
2965
- async function Ar(e, t, n) {
2966
- let r = ` - ${e.statusText}`, i = `${t} Response status '${String(e.status)}${e.statusText ? r : ""}' received.`, a;
2967
- try {
2968
- a = await e.text();
2969
- } catch (e) {
2970
- a = `<body unavailable: ${Mr(e).message}>`;
2971
- }
2972
- return new kr(i, n, { body: Nr(a) });
2973
- }
2974
- function jr(e) {
2953
+ ]), { ...Er };
2954
+ function Dr(e) {
2975
2955
  try {
2976
2956
  e();
2977
2957
  } catch {}
2978
2958
  }
2979
- function Mr(e) {
2980
- if (e instanceof Error) return e;
2981
- if (typeof e == "string") return Error(e);
2982
- if (typeof e == "number" || typeof e == "boolean" || typeof e == "bigint") return Error(String(e));
2983
- if (typeof e == "symbol") return Error(e.description ?? "Unknown error");
2984
- if (typeof e == "object") try {
2985
- return Error(JSON.stringify(e));
2986
- } catch {
2987
- return /* @__PURE__ */ Error("Unknown error");
2959
+ $([
2960
+ "arrow",
2961
+ "avro",
2962
+ "dtv",
2963
+ "json",
2964
+ "jsonl",
2965
+ "markdown",
2966
+ "ods",
2967
+ "parquet",
2968
+ "sav",
2969
+ "sqlite",
2970
+ "xlsx",
2971
+ "xml"
2972
+ ]), { ...Er };
2973
+ async function Or(e, t, n) {
2974
+ let r = kr(e), { issues: i, parsedRecords: a, valueDelimiterId: o } = await Ar(e, t.valueDelimiterIds, t.isComplete, n);
2975
+ return {
2976
+ issues: i,
2977
+ parsedRecords: a,
2978
+ recordDelimiterId: r,
2979
+ valueDelimiterId: o
2980
+ };
2981
+ }
2982
+ function kr(e) {
2983
+ let t = (e.match(/\r\n/g) ?? []).length, n = (e.match(/(?<!\r)\n/g) ?? []).length, r = (e.match(/\r(?!\n)/g) ?? []).length;
2984
+ return t >= n && t >= r ? "\r\n" : n >= t && n >= r ? "\n" : r >= t && r >= n ? "\r" : "\n";
2985
+ }
2986
+ async function Ar(e, t, n, r) {
2987
+ let i, a, o, s = [], c, l = !1;
2988
+ for (let u of t) {
2989
+ let { issues: t, records: d } = await r(e, u, n);
2990
+ if (t.length > 0) {
2991
+ c = jr(c, {
2992
+ delimiter: u,
2993
+ issues: t,
2994
+ records: d
2995
+ });
2996
+ continue;
2997
+ }
2998
+ if (l = !0, d.length === 0) continue;
2999
+ let { averageValueCount: f, sumOfValueCountDiffs: p } = Mr(d);
3000
+ (!o || p <= o) && (!a || f > a) && (i = u, a = f, o = p, s = d);
2988
3001
  }
2989
- return /* @__PURE__ */ Error("Unknown error");
3002
+ if (!l && c != null) {
3003
+ let { delimiter: e, issues: t, records: n } = c;
3004
+ return {
3005
+ issues: t,
3006
+ parsedRecords: n,
3007
+ valueDelimiterId: Nr(n) ? e : void 0
3008
+ };
3009
+ }
3010
+ return {
3011
+ issues: [],
3012
+ parsedRecords: s,
3013
+ valueDelimiterId: i != null && Nr(s) ? i : void 0
3014
+ };
3015
+ }
3016
+ function jr(e, t) {
3017
+ return e == null || t.issues.length < e.issues.length ? t : e;
3018
+ }
3019
+ function Mr(e) {
3020
+ let t = 0, n = 0, r;
3021
+ for (let i of e) r != null && (n += Math.abs(i.length - r)), r = i.length, t += i.length;
3022
+ return {
3023
+ averageValueCount: t / e.length,
3024
+ sumOfValueCountDiffs: n
3025
+ };
2990
3026
  }
2991
3027
  function Nr(e) {
2992
- if (e != null && e !== "") return e.length > Dr ? `${e.slice(0, Dr)}... [truncated]` : e;
3028
+ let t = /* @__PURE__ */ new Map();
3029
+ for (let n of e) t.set(n.length, (t.get(n.length) ?? 0) + 1);
3030
+ let [n = 0, r = 0] = [...t].toSorted((e, t) => t[1] - e[1])[0] ?? [];
3031
+ return n > 1 && r * 2 > e.length;
2993
3032
  }
2994
- $([
3033
+ $(["list"]), { ...Er }, $([
2995
3034
  "list",
2996
3035
  "render",
2997
3036
  "setColorMode"
@@ -3465,86 +3504,100 @@ var Lr = {
3465
3504
  to_line: -1,
3466
3505
  trim: !1
3467
3506
  }, Rr = 4, zr = 50, Br = 1e4, Vr = class {
3468
- async parseStream(e, t, n, r, i) {
3469
- return new Promise((a, o) => {
3470
- let s, c, l, u = !1, d = !1, f = () => {
3471
- if (d) return;
3472
- d = !0;
3473
- let e = s;
3474
- s = void 0, l = void 0, e != null && (jr(() => e.removeAllListeners()), jr(() => e.end())), jr(() => void c?.cancel()), c = void 0;
3475
- };
3476
- r.signal.addEventListener("abort", f, { once: !0 });
3477
- let p = (e) => {
3478
- u || (u = !0, f(), r.signal.aborted || r.abort(e), o(e instanceof Error ? e : Error(String(e))));
3507
+ async parseStream(e, t, n) {
3508
+ return new Promise((r, i) => {
3509
+ let a, o, s, c = !1, l = !1, u = () => {
3510
+ if (l) return;
3511
+ l = !0;
3512
+ let e = a;
3513
+ a = void 0, s = void 0, e != null && (Dr(() => e.removeAllListeners()), Dr(() => e.end())), Dr(() => void o?.cancel()), o = void 0;
3514
+ }, d = (e) => {
3515
+ c || (c = !0, u(), i(e instanceof Error ? e : Error(String(e))));
3479
3516
  };
3480
- (async () => {
3481
- s = ar({
3517
+ t.abortSignal.addEventListener("abort", () => {
3518
+ d(t.abortSignal.reason);
3519
+ }, { once: !0 }), (async () => {
3520
+ t.abortSignal.throwIfAborted(), a = ar({
3482
3521
  ...Lr,
3483
- ...t,
3484
3522
  cast: (e, t) => ({
3485
3523
  value: e,
3486
- wasValueQuoted: t.quoting
3487
- })
3488
- }), l = Hr({
3489
- chunk: i,
3490
- chunkSize: e.chunkSize ?? Br
3491
- }), s.on("readable", () => {
3524
+ valueWasQuoted: t.quoting
3525
+ }),
3526
+ delimiter: t.valueDelimiterId,
3527
+ relax_column_count: !0
3528
+ });
3529
+ let i = Hr({
3530
+ chunk: n,
3531
+ chunkSize: t.chunkSize ?? Br
3532
+ });
3533
+ s = i, a.on("readable", () => {
3492
3534
  try {
3493
- if (s == null || l == null) return;
3535
+ if (a == null || s == null) return;
3494
3536
  let e;
3495
- for (; (e = s.read()) != null;) {
3496
- if (u) return;
3497
- r.signal.throwIfAborted(), l.push(e);
3537
+ for (; (e = a.read()) != null;) {
3538
+ if (c) return;
3539
+ t.abortSignal.throwIfAborted(), s.push(e);
3498
3540
  }
3499
3541
  } catch (e) {
3500
- p(e);
3542
+ d(e);
3501
3543
  }
3502
- }), s.on("error", (e) => {
3503
- p(e);
3504
- }), s.on("end", () => {
3505
- u || (l?.flush(), a(Ur(s)));
3544
+ }), a.on("error", (e) => {
3545
+ d(e);
3506
3546
  });
3507
- let o = await fetch(encodeURI(n), { signal: r.signal });
3508
- if (!o.ok || o.body == null) throw await Ar(o, `Failed to fetch '${n}' file.`, "dpuse-connector-file-store-emulator|Connector|retrieve");
3509
- c = o.body.getReader();
3510
- let d = new TextDecoder(Ir(e.encodingId)), f = await c.read();
3511
- for (; !f.done;) {
3512
- if (u) return;
3513
- r.signal.throwIfAborted();
3514
- let e = d.decode(f.value, { stream: !0 });
3515
- e.length > 0 && s.write(e), f = await c.read();
3547
+ let l = async (e) => {
3548
+ try {
3549
+ await i.drain(), r(e);
3550
+ } catch (e) {
3551
+ d(e);
3552
+ }
3553
+ };
3554
+ a.on("end", () => {
3555
+ c || (i.flush(), l(Ur(a)));
3556
+ }), o = e.getReader();
3557
+ let u = new TextDecoder(Ir(t.encodingId)), f = 0, p = !1, m = await o.read();
3558
+ for (; !m.done;) {
3559
+ if (c) return;
3560
+ t.abortSignal.throwIfAborted(), f += m.value.length;
3561
+ let e = u.decode(m.value, { stream: !0 });
3562
+ e.length > 0 && (a.write(e), p = !0), await i.drain(), m = await o.read();
3516
3563
  }
3517
- if (u) return;
3518
- let m = d.decode();
3519
- m.length > 0 && s.write(m), s.end();
3564
+ if (c) return;
3565
+ let h = u.decode();
3566
+ h.length > 0 && (a.write(h), p = !0), p ? a.end() : (a.removeAllListeners(), a = void 0, r({
3567
+ byteCount: f,
3568
+ commentLineCount: 0,
3569
+ emptyLineCount: 0,
3570
+ lineCount: 0,
3571
+ nonUniformRecordCount: 0,
3572
+ recordCount: 0
3573
+ }));
3520
3574
  })().catch((e) => {
3521
- p(e);
3575
+ d(e);
3522
3576
  });
3523
3577
  });
3524
3578
  }
3525
- async parseText(e, t, n = !1) {
3526
- let r = Wr(e), { issues: i, parsedRecords: a, valueDelimiterId: o } = await Gr(e, t, n);
3527
- return {
3528
- issues: i,
3529
- parsedRecords: a,
3530
- recordDelimiterId: r,
3531
- valueDelimiterId: o
3532
- };
3579
+ async parseText(e, t) {
3580
+ return await Or(e, t, Wr);
3533
3581
  }
3534
3582
  };
3535
3583
  function Hr(e) {
3536
- let t = Math.max(1, Math.floor(e.chunkSize)), n = [], r = o(), i = 0, a = () => {
3537
- if (i === 0) return;
3538
- let t = r;
3539
- t.length = i, r = o(), i = 0, e.chunk("parsingRecordArray", t), n.length < Rr && n.push(t);
3584
+ let t = Math.max(1, Math.floor(e.chunkSize)), n = [], r = [], i = s(), a = 0, o = () => {
3585
+ if (a === 0) return;
3586
+ let t = i;
3587
+ t.length = a, i = s(), a = 0;
3588
+ let o = e.chunk("parsingRecordArray", t);
3589
+ o instanceof Promise ? r.push(o) : n.length < Rr && n.push(t);
3540
3590
  };
3541
3591
  return {
3542
- flush: a,
3592
+ drain: async () => {
3593
+ for (; r.length > 0;) await Promise.all(r.splice(0));
3594
+ },
3595
+ flush: o,
3543
3596
  push: (e) => {
3544
- r[i++] = e, i >= t && a();
3597
+ i[a++] = e, a >= t && o();
3545
3598
  }
3546
3599
  };
3547
- function o() {
3600
+ function s() {
3548
3601
  let e = n.pop();
3549
3602
  if (e != null) return e.length = 0, e;
3550
3603
  let r = Array.from({ length: t });
@@ -3561,52 +3614,15 @@ function Ur(e) {
3561
3614
  recordCount: e?.info.records ?? -1
3562
3615
  };
3563
3616
  }
3564
- function Wr(e) {
3565
- let t = (e.match(/\r\n/g) ?? []).length, n = (e.match(/(?<!\r)\n/g) ?? []).length, r = (e.match(/\r(?!\n)/g) ?? []).length;
3566
- return t >= n && t >= r ? "\r\n" : n >= t && n >= r ? "\n" : r >= t && r >= n ? "\r" : "\n";
3567
- }
3568
- async function Gr(e, t, n) {
3569
- let r, i, a, o = [], s, c = !1;
3570
- for (let l of 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
- });
3578
- continue;
3579
- }
3580
- if (c = !0, u.length === 0) continue;
3581
- let { averageValueCount: d, sumOfValueCountDiffs: f } = Yr(u);
3582
- (!a || f <= a) && (!i || d > i) && (r = l, i = d, a = f, o = u);
3583
- }
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
- }
3592
- return {
3593
- issues: [],
3594
- parsedRecords: o,
3595
- valueDelimiterId: r != null && Xr(o) ? r : void 0
3596
- };
3597
- }
3598
- function Kr(e, t) {
3599
- return e == null || t.issues.length < e.issues.length ? t : e;
3600
- }
3601
- function qr(e, t, n) {
3617
+ function Wr(e, t, n) {
3602
3618
  return new Promise((r) => {
3603
3619
  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));
3620
+ e == null || !n && e.code === "CSV_QUOTE_NOT_CLOSED" || (i.push(Gr(e, o + 1)), e.lines != null && (o = e.lines));
3605
3621
  }, c = ar({
3606
3622
  ...Lr,
3607
3623
  cast: (e, t) => ({
3608
3624
  value: e,
3609
- wasValueQuoted: t.quoting
3625
+ valueWasQuoted: t.quoting
3610
3626
  }),
3611
3627
  delimiter: t,
3612
3628
  info: !0,
@@ -3631,7 +3647,7 @@ function qr(e, t, n) {
3631
3647
  }), c.write(e), c.end();
3632
3648
  });
3633
3649
  }
3634
- function Jr(e, t) {
3650
+ function Gr(e, t) {
3635
3651
  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
3652
  return {
3637
3653
  endLineNumber: n != null && n > t ? n : void 0,
@@ -3644,18 +3660,4 @@ function Jr(e, t) {
3644
3660
  value: i != null && i.length > zr ? `${i.slice(0, zr)}…` : i
3645
3661
  };
3646
3662
  }
3647
- function Yr(e) {
3648
- let t = 0, n = 0, r;
3649
- for (let i of e) r != null && (n += Math.abs(i.length - r)), r = i.length, t += i.length;
3650
- return {
3651
- averageValueCount: t / e.length,
3652
- sumOfValueCountDiffs: n
3653
- };
3654
- }
3655
- function Xr(e) {
3656
- let t = /* @__PURE__ */ new Map();
3657
- for (let n of e) t.set(n.length, (t.get(n.length) ?? 0) + 1);
3658
- let [n = 0, r = 0] = [...t].toSorted((e, t) => t[1] - e[1])[0] ?? [];
3659
- return n > 1 && r * 2 > e.length;
3660
- }
3661
3663
  export { Vr as Tool };