@nshiab/simple-data-analysis-core 2.1.10 → 2.1.12

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 (39) hide show
  1. package/esm/class/SimpleDB.d.ts +2 -1
  2. package/esm/class/SimpleDB.d.ts.map +1 -1
  3. package/esm/class/SimpleDB.js +2 -1
  4. package/esm/helpers/printTable.d.ts +2 -0
  5. package/esm/helpers/printTable.d.ts.map +1 -1
  6. package/esm/helpers/printTable.js +11 -5
  7. package/esm/helpers/publishPreparedColumns.d.ts +3 -3
  8. package/esm/helpers/publishPreparedColumns.d.ts.map +1 -1
  9. package/esm/helpers/publishPreparedColumns.js +17 -33
  10. package/esm/helpers/splitGraphemes.d.ts +2 -0
  11. package/esm/helpers/splitGraphemes.d.ts.map +1 -0
  12. package/esm/helpers/splitGraphemes.js +6 -0
  13. package/esm/helpers/wrapString.d.ts +6 -4
  14. package/esm/helpers/wrapString.d.ts.map +1 -1
  15. package/esm/helpers/wrapString.js +24 -13
  16. package/esm/methods/loadDB.d.ts.map +1 -1
  17. package/esm/methods/loadDB.js +0 -10
  18. package/esm/methods/umap.js +13 -21
  19. package/llm.md +3 -2
  20. package/llms.txt +1 -1
  21. package/package.json +2 -2
  22. package/script/class/SimpleDB.d.ts +2 -1
  23. package/script/class/SimpleDB.d.ts.map +1 -1
  24. package/script/class/SimpleDB.js +2 -1
  25. package/script/helpers/printTable.d.ts +2 -0
  26. package/script/helpers/printTable.d.ts.map +1 -1
  27. package/script/helpers/printTable.js +11 -5
  28. package/script/helpers/publishPreparedColumns.d.ts +3 -3
  29. package/script/helpers/publishPreparedColumns.d.ts.map +1 -1
  30. package/script/helpers/publishPreparedColumns.js +17 -33
  31. package/script/helpers/splitGraphemes.d.ts +2 -0
  32. package/script/helpers/splitGraphemes.d.ts.map +1 -0
  33. package/script/helpers/splitGraphemes.js +9 -0
  34. package/script/helpers/wrapString.d.ts +6 -4
  35. package/script/helpers/wrapString.d.ts.map +1 -1
  36. package/script/helpers/wrapString.js +27 -13
  37. package/script/methods/loadDB.d.ts.map +1 -1
  38. package/script/methods/loadDB.js +0 -10
  39. package/script/methods/umap.js +13 -21
@@ -604,7 +604,8 @@ export default class SimpleDB<Table extends SimpleTable = SimpleTable> extends S
604
604
  * file into the current database. The source is opened read-only and detached
605
605
  * after importing; subsequent transformations do not modify the source file.
606
606
  * Imports work with in-memory and writable persistent databases. Existing
607
- * table-name conflicts are rejected and a failed copy is rolled back.
607
+ * table-name conflicts are rejected. A failed import may leave partial changes
608
+ * in the destination database.
608
609
  *
609
610
  * DuckDB files restore embedded SDA index definitions when present. SQLite
610
611
  * imports copy data without SDA index metadata. The `__sda` schema is reserved
@@ -1 +1 @@
1
- {"version":3,"file":"SimpleDB.d.ts","sourceRoot":"","sources":["../../src/class/SimpleDB.ts"],"names":[],"mappings":"AAGA,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAG3C,OAAO,MAAM,MAAM,aAAa,CAAC;AA6BjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,MAAM,CAAC,OAAO,OAAO,QAAQ,CAAC,KAAK,SAAS,WAAW,GAAG,WAAW,CACnE,SAAQ,MAAM;;IACd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkEG;IACH,QAAQ,CAAC,gBAAgB,EAAE,IAAI,GAAG,KAAK,CAAC;IACxC;;;;;;;;;;OAUG;IACH,MAAM,EAAE,OAAO,CAAC;IAChB;;;;;;;;;;OAUG;IACH,UAAU,EAAE,OAAO,CAAC;IACpB;;;;;OAKG;IACH,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B;;;;;OAKG;IACH,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC;;;;;OAKG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;;;;OAKG;IACH,WAAW,EAAE,OAAO,CAAC;IACrB;;;;;;OAMG;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IAKzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuCG;IACG,OAAO,CACX,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAO,GACxD,OAAO,CAAC,IAAI,CAAC;IAKhB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;IAU9B;;;;;;;;;;;;;;;OAeG;IACG,KAAK,IAAI,OAAO,CAAC,QAAQ,CAAC;CA8GjC"}
@@ -857,7 +857,8 @@ class SimpleDB extends Simple {
857
857
  * file into the current database. The source is opened read-only and detached
858
858
  * after importing; subsequent transformations do not modify the source file.
859
859
  * Imports work with in-memory and writable persistent databases. Existing
860
- * table-name conflicts are rejected and a failed copy is rolled back.
860
+ * table-name conflicts are rejected. A failed import may leave partial changes
861
+ * in the destination database.
861
862
  *
862
863
  * DuckDB files restore embedded SDA index definitions when present. SQLite
863
864
  * imports copy data without SDA index metadata. The `__sda` schema is reserved
@@ -3,6 +3,8 @@
3
3
  * within headers and cells. Unlike `console.table()`, this function properly
4
4
  * handles multi-line content, making it ideal for displaying data with long
5
5
  * column names and text values.
6
+ * Widths count graphemes, keeping combining accents with their letters. Wide
7
+ * characters and emoji are not measured by their terminal display width.
6
8
  *
7
9
  * @example
8
10
  * ```typescript
@@ -1 +1 @@
1
- {"version":3,"file":"printTable.d.ts","sourceRoot":"","sources":["../../src/helpers/printTable.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,IAAI,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,EAAE,EAClC,OAAO,CAAC,EAAE;IACR,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GACA,IAAI,CAgNN"}
1
+ {"version":3,"file":"printTable.d.ts","sourceRoot":"","sources":["../../src/helpers/printTable.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,IAAI,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,EAAE,EAClC,OAAO,CAAC,EAAE;IACR,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GACA,IAAI,CAqNN"}
@@ -1,10 +1,13 @@
1
1
  import LogValue from "./LogValue.js";
2
+ import splitGraphemes from "./splitGraphemes.js";
2
3
  import wrapString from "./wrapString.js";
3
4
  /**
4
5
  * Prints a formatted table to the console with support for word wrapping
5
6
  * within headers and cells. Unlike `console.table()`, this function properly
6
7
  * handles multi-line content, making it ideal for displaying data with long
7
8
  * column names and text values.
9
+ * Widths count graphemes, keeping combining accents with their letters. Wide
10
+ * characters and emoji are not measured by their terminal display width.
8
11
  *
9
12
  * @example
10
13
  * ```typescript
@@ -73,7 +76,7 @@ export default function printTable(data, options) {
73
76
  // First, seed widths from header names.
74
77
  const columnWidths = {};
75
78
  for (const col of columns) {
76
- columnWidths[col] = Math.max(...col.split("\n").map((line) => line.length));
79
+ columnWidths[col] = Math.max(...col.split("\n").map((line) => splitGraphemes(line).length));
77
80
  }
78
81
  // Format every cell, track the longest raw line per column, and
79
82
  // store the formatted strings for the wrapping step that follows.
@@ -88,8 +91,9 @@ export default function printTable(data, options) {
88
91
  const lines = value.split("\n");
89
92
  let longestLine = 0;
90
93
  for (const line of lines) {
91
- if (line.length > longestLine)
92
- longestLine = line.length;
94
+ const length = splitGraphemes(line).length;
95
+ if (length > longestLine)
96
+ longestLine = length;
93
97
  }
94
98
  if (longestLine > columnWidths[col]) {
95
99
  columnWidths[col] = longestLine;
@@ -103,7 +107,9 @@ export default function printTable(data, options) {
103
107
  }
104
108
  // Use the same newline and word wrapping rules for headers and cells.
105
109
  const wrapCell = (value, width) => {
106
- const lines = value.split("\n").flatMap((line) => line.length <= width ? [line] : wrapString(line, width).split("\n"));
110
+ const lines = value.split("\n").flatMap((line) => splitGraphemes(line).length <= width
111
+ ? [line]
112
+ : wrapString(line, width).split("\n"));
107
113
  return lines.length > 0 ? lines : [""];
108
114
  };
109
115
  const wrappedHeaders = columns.map((col) => wrapCell(col, columnWidths[col]));
@@ -151,7 +157,7 @@ export default function printTable(data, options) {
151
157
  const createBottomBorder = () => createBorderLine("└", "┴", "┘");
152
158
  // Helper function to pad a string to a specific width
153
159
  const pad = (str, width) => {
154
- return str + " ".repeat(Math.max(0, width - str.length));
160
+ return str + " ".repeat(Math.max(0, width - splitGraphemes(str).length));
155
161
  };
156
162
  // Print top border
157
163
  console.log(createTopBorder());
@@ -15,10 +15,10 @@ type PublicationResult = {
15
15
  rowIdColumn: string;
16
16
  };
17
17
  /**
18
- * Atomically publishes validated algorithm outputs from a prepared numeric
18
+ * Publishes validated algorithm outputs from a prepared numeric
19
19
  * feature snapshot. New outputs are appended, while replacements retain the
20
- * source column's position. Existing native DuckDB indexes are recreated in
21
- * the same transaction because CREATE OR REPLACE drops them.
20
+ * source column's position. Existing native DuckDB indexes are recreated after
21
+ * table replacement because CREATE OR REPLACE drops them.
22
22
  *
23
23
  * Output expressions are trusted internal SQL. They may reference `p`, the
24
24
  * prepared relation alias, and `r` when a result relation is supplied. The
@@ -1 +1 @@
1
- {"version":3,"file":"publishPreparedColumns.d.ts","sourceRoot":"","sources":["../../src/helpers/publishPreparedColumns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAM3E,KAAK,iBAAiB,GAAG;IACvB,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,UAAU,EAAE,MAAM,CAAC;IACnB,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,qDAAqD;IACrD,QAAQ,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAA8B,sBAAsB,CAClD,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,IAAI,CACZ,uBAAuB,EACrB,UAAU,GACV,aAAa,GACb,eAAe,GACf,iBAAiB,CACpB,EACD,OAAO,EAAE;IACP,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IAC9C,OAAO,EAAE,iBAAiB,EAAE,CAAC;IAC7B,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC5B,GACA,OAAO,CAAC,IAAI,CAAC,CAwFf"}
1
+ {"version":3,"file":"publishPreparedColumns.d.ts","sourceRoot":"","sources":["../../src/helpers/publishPreparedColumns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAM3E,KAAK,iBAAiB,GAAG;IACvB,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,UAAU,EAAE,MAAM,CAAC;IACnB,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,qDAAqD;IACrD,QAAQ,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAA8B,sBAAsB,CAClD,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,IAAI,CACZ,uBAAuB,EACrB,UAAU,GACV,aAAa,GACb,eAAe,GACf,iBAAiB,CACpB,EACD,OAAO,EAAE;IACP,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IAC9C,OAAO,EAAE,iBAAiB,EAAE,CAAC;IAC7B,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC5B,GACA,OAAO,CAAC,IAAI,CAAC,CA0Ef"}
@@ -3,10 +3,10 @@ import mergeOptions from "./mergeOptions.js";
3
3
  import queryDB from "./queryDB.js";
4
4
  import quoteIdentifier from "./quoteIdentifier.js";
5
5
  /**
6
- * Atomically publishes validated algorithm outputs from a prepared numeric
6
+ * Publishes validated algorithm outputs from a prepared numeric
7
7
  * feature snapshot. New outputs are appended, while replacements retain the
8
- * source column's position. Existing native DuckDB indexes are recreated in
9
- * the same transaction because CREATE OR REPLACE drops them.
8
+ * source column's position. Existing native DuckDB indexes are recreated after
9
+ * table replacement because CREATE OR REPLACE drops them.
10
10
  *
11
11
  * Output expressions are trusted internal SQL. They may reference `p`, the
12
12
  * prepared relation alias, and `r` when a result relation is supplied. The
@@ -48,39 +48,23 @@ export default async function publishPreparedColumns(table, prepared, options) {
48
48
  ? ""
49
49
  : ` JOIN ${q(options.result.relation)} r
50
50
  ON p.${q(prepared.rowIdColumn)} = r.${q(options.result.rowIdColumn)}`;
51
- await connection.run("BEGIN TRANSACTION");
52
- try {
53
- await queryDB(table, `CREATE OR REPLACE ${prepared.sourceTemporary ? "TEMP " : ""}TABLE ${source} AS
54
- SELECT ${select.join(", ")}
55
- FROM ${q(prepared.relation)} p${resultJoin}
56
- ORDER BY p.${q(prepared.rowIdColumn)}`, mergeOptions(table, {
57
- table: table.name,
58
- method: options.method,
59
- parameters: options.parameters,
60
- noClean: true,
61
- }));
62
- for (const sql of indexes) {
63
- try {
64
- await connection.run(sql);
65
- }
66
- catch (error) {
67
- const detail = error instanceof Error ? ` ${error.message}` : "";
68
- throw new Error(`${options.method} could not restore an existing DuckDB index while publishing its output. Remove or rebuild indexes that do not support the output column types.${detail}`, { cause: error });
69
- }
70
- }
71
- await connection.run("COMMIT");
72
- }
73
- catch (error) {
51
+ await queryDB(table, `CREATE OR REPLACE ${prepared.sourceTemporary ? "TEMP " : ""}TABLE ${source} AS
52
+ SELECT ${select.join(", ")}
53
+ FROM ${q(prepared.relation)} p${resultJoin}
54
+ ORDER BY p.${q(prepared.rowIdColumn)}`, mergeOptions(table, {
55
+ table: table.name,
56
+ method: options.method,
57
+ parameters: options.parameters,
58
+ noClean: true,
59
+ }));
60
+ for (const sql of indexes) {
74
61
  try {
75
- await connection.run("ROLLBACK");
62
+ await connection.run(sql);
76
63
  }
77
- catch {
78
- // DuckDB may already abort the transaction after an index-build error.
79
- // Preserve the publication error that explains why the operation failed.
64
+ catch (error) {
65
+ const detail = error instanceof Error ? ` ${error.message}` : "";
66
+ throw new Error(`${options.method} could not restore an existing DuckDB index while publishing its output. Remove or rebuild indexes that do not support the output column types.${detail}`, { cause: error });
80
67
  }
81
- // UNIQUE violations can be deferred until COMMIT, which may also fail for
82
- // unrelated reasons. Preserve that diagnostic instead of blaming indexes.
83
- throw error;
84
68
  }
85
69
  }
86
70
  function validateOutputs(sourceColumns, outputs) {
@@ -0,0 +1,2 @@
1
+ export default function splitGraphemes(text: string): string[];
2
+ //# sourceMappingURL=splitGraphemes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"splitGraphemes.d.ts","sourceRoot":"","sources":["../../src/helpers/splitGraphemes.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAE7D"}
@@ -0,0 +1,6 @@
1
+ const segmenter = new Intl.Segmenter(undefined, { granularity: "grapheme" });
2
+ // Keep combining characters attached to their base without normalizing text.
3
+ // Grapheme counts are not terminal display widths for wide characters or emoji.
4
+ export default function splitGraphemes(text) {
5
+ return Array.from(segmenter.segment(text), ({ segment }) => segment);
6
+ }
@@ -1,8 +1,10 @@
1
1
  /**
2
2
  * Wraps a string to a specified maximum width, attempting to break at word
3
3
  * boundaries when possible. If a single word exceeds the maximum width, it
4
- * will be broken at the character boundary. This function is primarily used
5
- * for preparing text to be displayed in console tables.
4
+ * will be broken at a grapheme boundary, keeping combining accents with their
5
+ * letters. This function is primarily used for preparing text to be displayed
6
+ * in console tables. Widths count graphemes, not terminal columns for wide
7
+ * characters or emoji.
6
8
  *
7
9
  * @example
8
10
  * ```typescript
@@ -26,10 +28,10 @@
26
28
  *
27
29
  * @param str - The string to wrap.
28
30
  *
29
- * @param maxWidth - The maximum width of each line.
31
+ * @param maxWidth - The maximum number of graphemes in each line.
30
32
  *
31
33
  * @param wordWrap - If true, attempts to break at word boundaries. If false,
32
- * breaks at character boundaries. Defaults to `true`.
34
+ * breaks at grapheme boundaries. Defaults to `true`.
33
35
  *
34
36
  * @returns The wrapped string with newline characters inserted at appropriate
35
37
  * positions.
@@ -1 +1 @@
1
- {"version":3,"file":"wrapString.d.ts","sourceRoot":"","sources":["../../src/helpers/wrapString.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,QAAQ,UAAO,GACd,MAAM,CAqDR"}
1
+ {"version":3,"file":"wrapString.d.ts","sourceRoot":"","sources":["../../src/helpers/wrapString.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,QAAQ,UAAO,GACd,MAAM,CA6DR"}
@@ -1,8 +1,11 @@
1
+ import splitGraphemes from "./splitGraphemes.js";
1
2
  /**
2
3
  * Wraps a string to a specified maximum width, attempting to break at word
3
4
  * boundaries when possible. If a single word exceeds the maximum width, it
4
- * will be broken at the character boundary. This function is primarily used
5
- * for preparing text to be displayed in console tables.
5
+ * will be broken at a grapheme boundary, keeping combining accents with their
6
+ * letters. This function is primarily used for preparing text to be displayed
7
+ * in console tables. Widths count graphemes, not terminal columns for wide
8
+ * characters or emoji.
6
9
  *
7
10
  * @example
8
11
  * ```typescript
@@ -26,56 +29,64 @@
26
29
  *
27
30
  * @param str - The string to wrap.
28
31
  *
29
- * @param maxWidth - The maximum width of each line.
32
+ * @param maxWidth - The maximum number of graphemes in each line.
30
33
  *
31
34
  * @param wordWrap - If true, attempts to break at word boundaries. If false,
32
- * breaks at character boundaries. Defaults to `true`.
35
+ * breaks at grapheme boundaries. Defaults to `true`.
33
36
  *
34
37
  * @returns The wrapped string with newline characters inserted at appropriate
35
38
  * positions.
36
39
  */
37
40
  export default function wrapString(str, maxWidth, wordWrap = true) {
38
- if (str.length <= maxWidth) {
41
+ const graphemes = splitGraphemes(str);
42
+ if (graphemes.length <= maxWidth) {
39
43
  return str;
40
44
  }
41
45
  if (!wordWrap) {
42
- // Simple character-based wrapping
46
+ // Simple grapheme-based wrapping
43
47
  const lines = [];
44
- for (let i = 0; i < str.length; i += maxWidth) {
45
- lines.push(str.slice(i, i + maxWidth));
48
+ for (let i = 0; i < graphemes.length; i += maxWidth) {
49
+ lines.push(graphemes.slice(i, i + maxWidth).join(""));
46
50
  }
47
51
  return lines.join("\n");
48
52
  }
49
53
  // Word-aware wrapping
50
54
  const lines = [];
51
55
  let currentLine = "";
56
+ let currentWidth = 0;
52
57
  const words = str.split(/(\s+)/); // Split but keep whitespace
53
58
  for (const word of words) {
59
+ const wordGraphemes = splitGraphemes(word);
60
+ const wordWidth = wordGraphemes.length;
54
61
  // If adding this word would exceed maxWidth
55
- if (currentLine.length + word.length > maxWidth) {
62
+ if (currentWidth + wordWidth > maxWidth) {
56
63
  // If current line is not empty, save it
57
64
  if (currentLine.length > 0) {
58
65
  lines.push(currentLine.trimEnd());
59
66
  currentLine = "";
67
+ currentWidth = 0;
60
68
  }
61
69
  // If the word itself is longer than maxWidth, break it
62
- if (word.length > maxWidth) {
63
- for (let i = 0; i < word.length; i += maxWidth) {
64
- const chunk = word.slice(i, i + maxWidth);
65
- if (i + maxWidth < word.length) {
70
+ if (wordWidth > maxWidth) {
71
+ for (let i = 0; i < wordWidth; i += maxWidth) {
72
+ const chunk = wordGraphemes.slice(i, i + maxWidth).join("");
73
+ if (i + maxWidth < wordWidth) {
66
74
  lines.push(chunk);
67
75
  }
68
76
  else {
69
77
  currentLine = chunk;
78
+ currentWidth = wordWidth - i;
70
79
  }
71
80
  }
72
81
  }
73
82
  else {
74
83
  currentLine = word;
84
+ currentWidth = wordWidth;
75
85
  }
76
86
  }
77
87
  else {
78
88
  currentLine += word;
89
+ currentWidth += wordWidth;
79
90
  }
80
91
  }
81
92
  // Add any remaining text
@@ -1 +1 @@
1
- {"version":3,"file":"loadDB.d.ts","sourceRoot":"","sources":["../../src/methods/loadDB.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AAYjD,wBAA8B,MAAM,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,iBA0E/D"}
1
+ {"version":3,"file":"loadDB.d.ts","sourceRoot":"","sources":["../../src/methods/loadDB.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AAYjD,wBAA8B,MAAM,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,iBAkE/D"}
@@ -24,7 +24,6 @@ export default async function loadDB(sdb, file) {
24
24
  if (type === "sqlite")
25
25
  await queryDbFile(sdb, "INSTALL sqlite; LOAD sqlite;");
26
26
  await queryDbFile(sdb, `ATTACH '${cleanPath(file)}' AS ${source} (TYPE ${type}, READ_ONLY);`);
27
- let inTransaction = false;
28
27
  try {
29
28
  const indexes = type === "duckdb" ? await readDbMetadata(sdb, name) : {};
30
29
  await readDbMetadata(sdb, destination);
@@ -50,20 +49,11 @@ export default async function loadDB(sdb, file) {
50
49
  throw new Error(`loadDB() cannot import existing tables: ${[...names].join(", ")}.`);
51
50
  }
52
51
  const mergedIndexes = { ...getDbIndexes(sdb), ...indexes };
53
- await queryDbFile(sdb, "BEGIN TRANSACTION;");
54
- inTransaction = true;
55
52
  await queryDbFile(sdb, `DROP TABLE IF EXISTS ${target}.__sda.metadata;
56
53
  COPY FROM DATABASE ${source} TO ${target};`);
57
54
  await writeDbMetadata(sdb, destination, mergedIndexes);
58
- await queryDbFile(sdb, "COMMIT;");
59
- inTransaction = false;
60
55
  await setDbProps(sdb, indexes);
61
56
  }
62
- catch (error) {
63
- if (inTransaction)
64
- await queryDbFile(sdb, "ROLLBACK;");
65
- throw error;
66
- }
67
57
  finally {
68
58
  await queryDbFile(sdb, `DETACH ${source};`);
69
59
  }
@@ -105,28 +105,20 @@ async function execute(table, columns, options) {
105
105
  await appendColumnBatches(connection, layoutName, [INTEGER, DOUBLE, DOUBLE], count, (column, start, end) => Array.from({ length: end - start }, (_, row) => column === 0
106
106
  ? start + row
107
107
  : coordinates[2 * (start + row) + column - 1]));
108
- // Publish in one statement: failed fits never add partial columns. Existing
109
- // native indexes must be restored because CREATE OR REPLACE drops them.
108
+ // Replace the table and recreate existing native indexes, which
109
+ // CREATE OR REPLACE drops.
110
110
  const indexes = (await connection.runAndReadAll("SELECT sql FROM duckdb_indexes() WHERE table_oid=$1", [sourceOid])).getRowsJS().map((row) => String(row[0]));
111
- await connection.run("BEGIN TRANSACTION");
112
- try {
113
- await queryDB(table, `CREATE OR REPLACE ${sourceTemporary ? "TEMP " : ""}TABLE ${source} AS
114
- SELECT ${prepared.sourceColumns.map((c) => `s.${q(c)}`).join(",")}, l.x AS "umapX", l.y AS "umapY"
115
- FROM ${snapshot} s JOIN ${names.rows} r ON s.${ordinal}=r.ordinal
116
- JOIN ${layout} l ON r.vertex=l.vertex ORDER BY s.${ordinal}`, mergeOptions(table, {
117
- table: table.name,
118
- method: "umap()",
119
- parameters: { columns, options },
120
- noClean: true,
121
- }));
122
- for (const sql of indexes)
123
- await connection.run(sql);
124
- await connection.run("COMMIT");
125
- }
126
- catch (error) {
127
- await connection.run("ROLLBACK");
128
- throw error;
129
- }
111
+ await queryDB(table, `CREATE OR REPLACE ${sourceTemporary ? "TEMP " : ""}TABLE ${source} AS
112
+ SELECT ${prepared.sourceColumns.map((c) => `s.${q(c)}`).join(",")}, l.x AS "umapX", l.y AS "umapY"
113
+ FROM ${snapshot} s JOIN ${names.rows} r ON s.${ordinal}=r.ordinal
114
+ JOIN ${layout} l ON r.vertex=l.vertex ORDER BY s.${ordinal}`, mergeOptions(table, {
115
+ table: table.name,
116
+ method: "umap()",
117
+ parameters: { columns, options },
118
+ noClean: true,
119
+ }));
120
+ for (const sql of indexes)
121
+ await connection.run(sql);
130
122
  }
131
123
  finally {
132
124
  for (const relation of scratch) {
package/llm.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # The Simple Data Analysis (Core) Library
2
2
 
3
3
  - Package: `@nshiab/simple-data-analysis-core`
4
- - Version: `2.1.10`
4
+ - Version: `2.1.12`
5
5
 
6
6
  To install the library with Deno, use:
7
7
 
@@ -446,7 +446,8 @@ Imports a copy of a `.db` or `.duckdb` (DuckDB) or `.sqlite` (SQLite) file into
446
446
  the current database. The source is opened read-only and detached after
447
447
  importing; subsequent transformations do not modify the source file. Imports
448
448
  work with in-memory and writable persistent databases. Existing table-name
449
- conflicts are rejected and a failed copy is rolled back.
449
+ conflicts are rejected. A failed import may leave partial changes in the
450
+ destination database.
450
451
 
451
452
  DuckDB files restore embedded SDA index definitions when present. SQLite imports
452
453
  copy data without SDA index metadata. The `__sda` schema is reserved for SDA
package/llms.txt CHANGED
@@ -3,7 +3,7 @@
3
3
  > Lightweight DuckDB-powered TypeScript library for tabular, SQL, CSV, Parquet, and geospatial data analysis on Deno, Node.js, and Bun.
4
4
 
5
5
  - Package: `@nshiab/simple-data-analysis-core`
6
- - Version: `2.1.10`
6
+ - Version: `2.1.12`
7
7
 
8
8
  Install with Deno: `deno add jsr:@nshiab/simple-data-analysis-core`
9
9
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nshiab/simple-data-analysis-core",
3
- "version": "2.1.10",
3
+ "version": "2.1.12",
4
4
  "description": "Lightweight DuckDB-powered TypeScript library for tabular, SQL, CSV, Parquet, and geospatial data analysis on Deno, Node.js, and Bun.",
5
5
  "keywords": [
6
6
  "data-analysis",
@@ -39,7 +39,7 @@
39
39
  "access": "public"
40
40
  },
41
41
  "dependencies": {
42
- "@duckdb/node-api": "1.5.5-r.5"
42
+ "@duckdb/node-api": "1.5.6-r.1"
43
43
  },
44
44
  "_generatedBy": "dnt@dev"
45
45
  }
@@ -604,7 +604,8 @@ export default class SimpleDB<Table extends SimpleTable = SimpleTable> extends S
604
604
  * file into the current database. The source is opened read-only and detached
605
605
  * after importing; subsequent transformations do not modify the source file.
606
606
  * Imports work with in-memory and writable persistent databases. Existing
607
- * table-name conflicts are rejected and a failed copy is rolled back.
607
+ * table-name conflicts are rejected. A failed import may leave partial changes
608
+ * in the destination database.
608
609
  *
609
610
  * DuckDB files restore embedded SDA index definitions when present. SQLite
610
611
  * imports copy data without SDA index metadata. The `__sda` schema is reserved
@@ -1 +1 @@
1
- {"version":3,"file":"SimpleDB.d.ts","sourceRoot":"","sources":["../../src/class/SimpleDB.ts"],"names":[],"mappings":"AAGA,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAG3C,OAAO,MAAM,MAAM,aAAa,CAAC;AA6BjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,MAAM,CAAC,OAAO,OAAO,QAAQ,CAAC,KAAK,SAAS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;IAMvD;;;;;;;;;;;;OAYG;IACG,aAAa,IAAI,OAAO,CAC5B;QACE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,EAAE,CACJ;IAeD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACG,WAAW,CACf,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;QACP,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,KAAK,CAAC,EAAE,MAAM,CAAC;KACX,GACL,OAAO,CACN;QACA,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,EAAE,GACD,IAAI,CACP;IAaD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACG,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuCG;IACG,OAAO,CACX,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAO,GACxD,OAAO,CAAC,IAAI,CAAC;IAKhB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;IAU9B;;;;;;;;;;;;;;;OAeG;IACG,KAAK,IAAI,OAAO,CAAC,QAAQ,CAAC;CA8GjC"}
@@ -895,7 +895,8 @@ class SimpleDB extends Simple_js_1.default {
895
895
  * file into the current database. The source is opened read-only and detached
896
896
  * after importing; subsequent transformations do not modify the source file.
897
897
  * Imports work with in-memory and writable persistent databases. Existing
898
- * table-name conflicts are rejected and a failed copy is rolled back.
898
+ * table-name conflicts are rejected. A failed import may leave partial changes
899
+ * in the destination database.
899
900
  *
900
901
  * DuckDB files restore embedded SDA index definitions when present. SQLite
901
902
  * imports copy data without SDA index metadata. The `__sda` schema is reserved
@@ -3,6 +3,8 @@
3
3
  * within headers and cells. Unlike `console.table()`, this function properly
4
4
  * handles multi-line content, making it ideal for displaying data with long
5
5
  * column names and text values.
6
+ * Widths count graphemes, keeping combining accents with their letters. Wide
7
+ * characters and emoji are not measured by their terminal display width.
6
8
  *
7
9
  * @example
8
10
  * ```typescript
@@ -1 +1 @@
1
- {"version":3,"file":"printTable.d.ts","sourceRoot":"","sources":["../../src/helpers/printTable.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,IAAI,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,EAAE,EAClC,OAAO,CAAC,EAAE;IACR,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GACA,IAAI,CAgNN"}
1
+ {"version":3,"file":"printTable.d.ts","sourceRoot":"","sources":["../../src/helpers/printTable.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,IAAI,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,EAAE,EAClC,OAAO,CAAC,EAAE;IACR,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GACA,IAAI,CAqNN"}
@@ -5,12 +5,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.default = printTable;
7
7
  const LogValue_js_1 = __importDefault(require("./LogValue.js"));
8
+ const splitGraphemes_js_1 = __importDefault(require("./splitGraphemes.js"));
8
9
  const wrapString_js_1 = __importDefault(require("./wrapString.js"));
9
10
  /**
10
11
  * Prints a formatted table to the console with support for word wrapping
11
12
  * within headers and cells. Unlike `console.table()`, this function properly
12
13
  * handles multi-line content, making it ideal for displaying data with long
13
14
  * column names and text values.
15
+ * Widths count graphemes, keeping combining accents with their letters. Wide
16
+ * characters and emoji are not measured by their terminal display width.
14
17
  *
15
18
  * @example
16
19
  * ```typescript
@@ -79,7 +82,7 @@ function printTable(data, options) {
79
82
  // First, seed widths from header names.
80
83
  const columnWidths = {};
81
84
  for (const col of columns) {
82
- columnWidths[col] = Math.max(...col.split("\n").map((line) => line.length));
85
+ columnWidths[col] = Math.max(...col.split("\n").map((line) => (0, splitGraphemes_js_1.default)(line).length));
83
86
  }
84
87
  // Format every cell, track the longest raw line per column, and
85
88
  // store the formatted strings for the wrapping step that follows.
@@ -94,8 +97,9 @@ function printTable(data, options) {
94
97
  const lines = value.split("\n");
95
98
  let longestLine = 0;
96
99
  for (const line of lines) {
97
- if (line.length > longestLine)
98
- longestLine = line.length;
100
+ const length = (0, splitGraphemes_js_1.default)(line).length;
101
+ if (length > longestLine)
102
+ longestLine = length;
99
103
  }
100
104
  if (longestLine > columnWidths[col]) {
101
105
  columnWidths[col] = longestLine;
@@ -109,7 +113,9 @@ function printTable(data, options) {
109
113
  }
110
114
  // Use the same newline and word wrapping rules for headers and cells.
111
115
  const wrapCell = (value, width) => {
112
- const lines = value.split("\n").flatMap((line) => line.length <= width ? [line] : (0, wrapString_js_1.default)(line, width).split("\n"));
116
+ const lines = value.split("\n").flatMap((line) => (0, splitGraphemes_js_1.default)(line).length <= width
117
+ ? [line]
118
+ : (0, wrapString_js_1.default)(line, width).split("\n"));
113
119
  return lines.length > 0 ? lines : [""];
114
120
  };
115
121
  const wrappedHeaders = columns.map((col) => wrapCell(col, columnWidths[col]));
@@ -157,7 +163,7 @@ function printTable(data, options) {
157
163
  const createBottomBorder = () => createBorderLine("└", "┴", "┘");
158
164
  // Helper function to pad a string to a specific width
159
165
  const pad = (str, width) => {
160
- return str + " ".repeat(Math.max(0, width - str.length));
166
+ return str + " ".repeat(Math.max(0, width - (0, splitGraphemes_js_1.default)(str).length));
161
167
  };
162
168
  // Print top border
163
169
  console.log(createTopBorder());
@@ -15,10 +15,10 @@ type PublicationResult = {
15
15
  rowIdColumn: string;
16
16
  };
17
17
  /**
18
- * Atomically publishes validated algorithm outputs from a prepared numeric
18
+ * Publishes validated algorithm outputs from a prepared numeric
19
19
  * feature snapshot. New outputs are appended, while replacements retain the
20
- * source column's position. Existing native DuckDB indexes are recreated in
21
- * the same transaction because CREATE OR REPLACE drops them.
20
+ * source column's position. Existing native DuckDB indexes are recreated after
21
+ * table replacement because CREATE OR REPLACE drops them.
22
22
  *
23
23
  * Output expressions are trusted internal SQL. They may reference `p`, the
24
24
  * prepared relation alias, and `r` when a result relation is supplied. The
@@ -1 +1 @@
1
- {"version":3,"file":"publishPreparedColumns.d.ts","sourceRoot":"","sources":["../../src/helpers/publishPreparedColumns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAM3E,KAAK,iBAAiB,GAAG;IACvB,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,UAAU,EAAE,MAAM,CAAC;IACnB,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,qDAAqD;IACrD,QAAQ,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAA8B,sBAAsB,CAClD,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,IAAI,CACZ,uBAAuB,EACrB,UAAU,GACV,aAAa,GACb,eAAe,GACf,iBAAiB,CACpB,EACD,OAAO,EAAE;IACP,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IAC9C,OAAO,EAAE,iBAAiB,EAAE,CAAC;IAC7B,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC5B,GACA,OAAO,CAAC,IAAI,CAAC,CAwFf"}
1
+ {"version":3,"file":"publishPreparedColumns.d.ts","sourceRoot":"","sources":["../../src/helpers/publishPreparedColumns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAM3E,KAAK,iBAAiB,GAAG;IACvB,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,UAAU,EAAE,MAAM,CAAC;IACnB,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,qDAAqD;IACrD,QAAQ,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAA8B,sBAAsB,CAClD,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,IAAI,CACZ,uBAAuB,EACrB,UAAU,GACV,aAAa,GACb,eAAe,GACf,iBAAiB,CACpB,EACD,OAAO,EAAE;IACP,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IAC9C,OAAO,EAAE,iBAAiB,EAAE,CAAC;IAC7B,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC5B,GACA,OAAO,CAAC,IAAI,CAAC,CA0Ef"}
@@ -9,10 +9,10 @@ const mergeOptions_js_1 = __importDefault(require("./mergeOptions.js"));
9
9
  const queryDB_js_1 = __importDefault(require("./queryDB.js"));
10
10
  const quoteIdentifier_js_1 = __importDefault(require("./quoteIdentifier.js"));
11
11
  /**
12
- * Atomically publishes validated algorithm outputs from a prepared numeric
12
+ * Publishes validated algorithm outputs from a prepared numeric
13
13
  * feature snapshot. New outputs are appended, while replacements retain the
14
- * source column's position. Existing native DuckDB indexes are recreated in
15
- * the same transaction because CREATE OR REPLACE drops them.
14
+ * source column's position. Existing native DuckDB indexes are recreated after
15
+ * table replacement because CREATE OR REPLACE drops them.
16
16
  *
17
17
  * Output expressions are trusted internal SQL. They may reference `p`, the
18
18
  * prepared relation alias, and `r` when a result relation is supplied. The
@@ -54,39 +54,23 @@ async function publishPreparedColumns(table, prepared, options) {
54
54
  ? ""
55
55
  : ` JOIN ${q(options.result.relation)} r
56
56
  ON p.${q(prepared.rowIdColumn)} = r.${q(options.result.rowIdColumn)}`;
57
- await connection.run("BEGIN TRANSACTION");
58
- try {
59
- await (0, queryDB_js_1.default)(table, `CREATE OR REPLACE ${prepared.sourceTemporary ? "TEMP " : ""}TABLE ${source} AS
60
- SELECT ${select.join(", ")}
61
- FROM ${q(prepared.relation)} p${resultJoin}
62
- ORDER BY p.${q(prepared.rowIdColumn)}`, (0, mergeOptions_js_1.default)(table, {
63
- table: table.name,
64
- method: options.method,
65
- parameters: options.parameters,
66
- noClean: true,
67
- }));
68
- for (const sql of indexes) {
69
- try {
70
- await connection.run(sql);
71
- }
72
- catch (error) {
73
- const detail = error instanceof Error ? ` ${error.message}` : "";
74
- throw new Error(`${options.method} could not restore an existing DuckDB index while publishing its output. Remove or rebuild indexes that do not support the output column types.${detail}`, { cause: error });
75
- }
76
- }
77
- await connection.run("COMMIT");
78
- }
79
- catch (error) {
57
+ await (0, queryDB_js_1.default)(table, `CREATE OR REPLACE ${prepared.sourceTemporary ? "TEMP " : ""}TABLE ${source} AS
58
+ SELECT ${select.join(", ")}
59
+ FROM ${q(prepared.relation)} p${resultJoin}
60
+ ORDER BY p.${q(prepared.rowIdColumn)}`, (0, mergeOptions_js_1.default)(table, {
61
+ table: table.name,
62
+ method: options.method,
63
+ parameters: options.parameters,
64
+ noClean: true,
65
+ }));
66
+ for (const sql of indexes) {
80
67
  try {
81
- await connection.run("ROLLBACK");
68
+ await connection.run(sql);
82
69
  }
83
- catch {
84
- // DuckDB may already abort the transaction after an index-build error.
85
- // Preserve the publication error that explains why the operation failed.
70
+ catch (error) {
71
+ const detail = error instanceof Error ? ` ${error.message}` : "";
72
+ throw new Error(`${options.method} could not restore an existing DuckDB index while publishing its output. Remove or rebuild indexes that do not support the output column types.${detail}`, { cause: error });
86
73
  }
87
- // UNIQUE violations can be deferred until COMMIT, which may also fail for
88
- // unrelated reasons. Preserve that diagnostic instead of blaming indexes.
89
- throw error;
90
74
  }
91
75
  }
92
76
  function validateOutputs(sourceColumns, outputs) {
@@ -0,0 +1,2 @@
1
+ export default function splitGraphemes(text: string): string[];
2
+ //# sourceMappingURL=splitGraphemes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"splitGraphemes.d.ts","sourceRoot":"","sources":["../../src/helpers/splitGraphemes.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAE7D"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = splitGraphemes;
4
+ const segmenter = new Intl.Segmenter(undefined, { granularity: "grapheme" });
5
+ // Keep combining characters attached to their base without normalizing text.
6
+ // Grapheme counts are not terminal display widths for wide characters or emoji.
7
+ function splitGraphemes(text) {
8
+ return Array.from(segmenter.segment(text), ({ segment }) => segment);
9
+ }
@@ -1,8 +1,10 @@
1
1
  /**
2
2
  * Wraps a string to a specified maximum width, attempting to break at word
3
3
  * boundaries when possible. If a single word exceeds the maximum width, it
4
- * will be broken at the character boundary. This function is primarily used
5
- * for preparing text to be displayed in console tables.
4
+ * will be broken at a grapheme boundary, keeping combining accents with their
5
+ * letters. This function is primarily used for preparing text to be displayed
6
+ * in console tables. Widths count graphemes, not terminal columns for wide
7
+ * characters or emoji.
6
8
  *
7
9
  * @example
8
10
  * ```typescript
@@ -26,10 +28,10 @@
26
28
  *
27
29
  * @param str - The string to wrap.
28
30
  *
29
- * @param maxWidth - The maximum width of each line.
31
+ * @param maxWidth - The maximum number of graphemes in each line.
30
32
  *
31
33
  * @param wordWrap - If true, attempts to break at word boundaries. If false,
32
- * breaks at character boundaries. Defaults to `true`.
34
+ * breaks at grapheme boundaries. Defaults to `true`.
33
35
  *
34
36
  * @returns The wrapped string with newline characters inserted at appropriate
35
37
  * positions.
@@ -1 +1 @@
1
- {"version":3,"file":"wrapString.d.ts","sourceRoot":"","sources":["../../src/helpers/wrapString.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,QAAQ,UAAO,GACd,MAAM,CAqDR"}
1
+ {"version":3,"file":"wrapString.d.ts","sourceRoot":"","sources":["../../src/helpers/wrapString.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,QAAQ,UAAO,GACd,MAAM,CA6DR"}
@@ -1,11 +1,17 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.default = wrapString;
7
+ const splitGraphemes_js_1 = __importDefault(require("./splitGraphemes.js"));
4
8
  /**
5
9
  * Wraps a string to a specified maximum width, attempting to break at word
6
10
  * boundaries when possible. If a single word exceeds the maximum width, it
7
- * will be broken at the character boundary. This function is primarily used
8
- * for preparing text to be displayed in console tables.
11
+ * will be broken at a grapheme boundary, keeping combining accents with their
12
+ * letters. This function is primarily used for preparing text to be displayed
13
+ * in console tables. Widths count graphemes, not terminal columns for wide
14
+ * characters or emoji.
9
15
  *
10
16
  * @example
11
17
  * ```typescript
@@ -29,56 +35,64 @@ exports.default = wrapString;
29
35
  *
30
36
  * @param str - The string to wrap.
31
37
  *
32
- * @param maxWidth - The maximum width of each line.
38
+ * @param maxWidth - The maximum number of graphemes in each line.
33
39
  *
34
40
  * @param wordWrap - If true, attempts to break at word boundaries. If false,
35
- * breaks at character boundaries. Defaults to `true`.
41
+ * breaks at grapheme boundaries. Defaults to `true`.
36
42
  *
37
43
  * @returns The wrapped string with newline characters inserted at appropriate
38
44
  * positions.
39
45
  */
40
46
  function wrapString(str, maxWidth, wordWrap = true) {
41
- if (str.length <= maxWidth) {
47
+ const graphemes = (0, splitGraphemes_js_1.default)(str);
48
+ if (graphemes.length <= maxWidth) {
42
49
  return str;
43
50
  }
44
51
  if (!wordWrap) {
45
- // Simple character-based wrapping
52
+ // Simple grapheme-based wrapping
46
53
  const lines = [];
47
- for (let i = 0; i < str.length; i += maxWidth) {
48
- lines.push(str.slice(i, i + maxWidth));
54
+ for (let i = 0; i < graphemes.length; i += maxWidth) {
55
+ lines.push(graphemes.slice(i, i + maxWidth).join(""));
49
56
  }
50
57
  return lines.join("\n");
51
58
  }
52
59
  // Word-aware wrapping
53
60
  const lines = [];
54
61
  let currentLine = "";
62
+ let currentWidth = 0;
55
63
  const words = str.split(/(\s+)/); // Split but keep whitespace
56
64
  for (const word of words) {
65
+ const wordGraphemes = (0, splitGraphemes_js_1.default)(word);
66
+ const wordWidth = wordGraphemes.length;
57
67
  // If adding this word would exceed maxWidth
58
- if (currentLine.length + word.length > maxWidth) {
68
+ if (currentWidth + wordWidth > maxWidth) {
59
69
  // If current line is not empty, save it
60
70
  if (currentLine.length > 0) {
61
71
  lines.push(currentLine.trimEnd());
62
72
  currentLine = "";
73
+ currentWidth = 0;
63
74
  }
64
75
  // If the word itself is longer than maxWidth, break it
65
- if (word.length > maxWidth) {
66
- for (let i = 0; i < word.length; i += maxWidth) {
67
- const chunk = word.slice(i, i + maxWidth);
68
- if (i + maxWidth < word.length) {
76
+ if (wordWidth > maxWidth) {
77
+ for (let i = 0; i < wordWidth; i += maxWidth) {
78
+ const chunk = wordGraphemes.slice(i, i + maxWidth).join("");
79
+ if (i + maxWidth < wordWidth) {
69
80
  lines.push(chunk);
70
81
  }
71
82
  else {
72
83
  currentLine = chunk;
84
+ currentWidth = wordWidth - i;
73
85
  }
74
86
  }
75
87
  }
76
88
  else {
77
89
  currentLine = word;
90
+ currentWidth = wordWidth;
78
91
  }
79
92
  }
80
93
  else {
81
94
  currentLine += word;
95
+ currentWidth += wordWidth;
82
96
  }
83
97
  }
84
98
  // Add any remaining text
@@ -1 +1 @@
1
- {"version":3,"file":"loadDB.d.ts","sourceRoot":"","sources":["../../src/methods/loadDB.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AAYjD,wBAA8B,MAAM,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,iBA0E/D"}
1
+ {"version":3,"file":"loadDB.d.ts","sourceRoot":"","sources":["../../src/methods/loadDB.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AAYjD,wBAA8B,MAAM,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,iBAkE/D"}
@@ -30,7 +30,6 @@ async function loadDB(sdb, file) {
30
30
  if (type === "sqlite")
31
31
  await (0, queryDbFile_js_1.default)(sdb, "INSTALL sqlite; LOAD sqlite;");
32
32
  await (0, queryDbFile_js_1.default)(sdb, `ATTACH '${(0, cleanPath_js_1.default)(file)}' AS ${source} (TYPE ${type}, READ_ONLY);`);
33
- let inTransaction = false;
34
33
  try {
35
34
  const indexes = type === "duckdb" ? await (0, readDbMetadata_js_1.default)(sdb, name) : {};
36
35
  await (0, readDbMetadata_js_1.default)(sdb, destination);
@@ -56,20 +55,11 @@ async function loadDB(sdb, file) {
56
55
  throw new Error(`loadDB() cannot import existing tables: ${[...names].join(", ")}.`);
57
56
  }
58
57
  const mergedIndexes = { ...(0, getDbIndexes_js_1.default)(sdb), ...indexes };
59
- await (0, queryDbFile_js_1.default)(sdb, "BEGIN TRANSACTION;");
60
- inTransaction = true;
61
58
  await (0, queryDbFile_js_1.default)(sdb, `DROP TABLE IF EXISTS ${target}.__sda.metadata;
62
59
  COPY FROM DATABASE ${source} TO ${target};`);
63
60
  await (0, writeDbMetadata_js_1.default)(sdb, destination, mergedIndexes);
64
- await (0, queryDbFile_js_1.default)(sdb, "COMMIT;");
65
- inTransaction = false;
66
61
  await (0, setDbProps_js_1.default)(sdb, indexes);
67
62
  }
68
- catch (error) {
69
- if (inTransaction)
70
- await (0, queryDbFile_js_1.default)(sdb, "ROLLBACK;");
71
- throw error;
72
- }
73
63
  finally {
74
64
  await (0, queryDbFile_js_1.default)(sdb, `DETACH ${source};`);
75
65
  }
@@ -111,28 +111,20 @@ async function execute(table, columns, options) {
111
111
  await (0, appendColumnBatches_js_1.default)(connection, layoutName, [node_api_1.INTEGER, node_api_1.DOUBLE, node_api_1.DOUBLE], count, (column, start, end) => Array.from({ length: end - start }, (_, row) => column === 0
112
112
  ? start + row
113
113
  : coordinates[2 * (start + row) + column - 1]));
114
- // Publish in one statement: failed fits never add partial columns. Existing
115
- // native indexes must be restored because CREATE OR REPLACE drops them.
114
+ // Replace the table and recreate existing native indexes, which
115
+ // CREATE OR REPLACE drops.
116
116
  const indexes = (await connection.runAndReadAll("SELECT sql FROM duckdb_indexes() WHERE table_oid=$1", [sourceOid])).getRowsJS().map((row) => String(row[0]));
117
- await connection.run("BEGIN TRANSACTION");
118
- try {
119
- await (0, queryDB_js_1.default)(table, `CREATE OR REPLACE ${sourceTemporary ? "TEMP " : ""}TABLE ${source} AS
120
- SELECT ${prepared.sourceColumns.map((c) => `s.${q(c)}`).join(",")}, l.x AS "umapX", l.y AS "umapY"
121
- FROM ${snapshot} s JOIN ${names.rows} r ON s.${ordinal}=r.ordinal
122
- JOIN ${layout} l ON r.vertex=l.vertex ORDER BY s.${ordinal}`, (0, mergeOptions_js_1.default)(table, {
123
- table: table.name,
124
- method: "umap()",
125
- parameters: { columns, options },
126
- noClean: true,
127
- }));
128
- for (const sql of indexes)
129
- await connection.run(sql);
130
- await connection.run("COMMIT");
131
- }
132
- catch (error) {
133
- await connection.run("ROLLBACK");
134
- throw error;
135
- }
117
+ await (0, queryDB_js_1.default)(table, `CREATE OR REPLACE ${sourceTemporary ? "TEMP " : ""}TABLE ${source} AS
118
+ SELECT ${prepared.sourceColumns.map((c) => `s.${q(c)}`).join(",")}, l.x AS "umapX", l.y AS "umapY"
119
+ FROM ${snapshot} s JOIN ${names.rows} r ON s.${ordinal}=r.ordinal
120
+ JOIN ${layout} l ON r.vertex=l.vertex ORDER BY s.${ordinal}`, (0, mergeOptions_js_1.default)(table, {
121
+ table: table.name,
122
+ method: "umap()",
123
+ parameters: { columns, options },
124
+ noClean: true,
125
+ }));
126
+ for (const sql of indexes)
127
+ await connection.run(sql);
136
128
  }
137
129
  finally {
138
130
  for (const relation of scratch) {