@dynamic-entity/server 2.3.0 → 2.3.1

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
@@ -270,7 +270,9 @@ will name their zip `.csv`.
270
270
 
271
271
  - **CSV** — through core's dependency-free incremental parser. UTF-8, with or without a BOM.
272
272
  The separator — `,`, `;` or tab — is detected from the header line, exactly as the browser
273
- detects it, and returned as `delimiter` from a preview. A `;` file is read with a **decimal
273
+ detects it, and returned as `delimiter` from a preview. A file named `.tsv` is always split
274
+ on tabs, as in the browser; that is the one thing a name decides, and only once the bytes
275
+ have said the file is text. A `;` file is read with a **decimal
274
276
  comma** (`1,5` is one and a half), because Excel writes `;` in precisely the locales that
275
277
  use one; pass `decimal` to `runImport` to override. Generated CSV templates stay
276
278
  comma-separated, so Excel in those locales opens them as one column — offer `xlsx` there.
package/express.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { EntityFormConfig, FormRule, ImportLookups } from '@dynamic-entity/core';
2
2
  import { Request, Router, Response } from 'express';
3
- import { B as BatchInfo, I as ImportLimits, T as TemplateFormat } from './write-template-B6KIIBRw.mjs';
3
+ import { B as BatchInfo, I as ImportLimits, T as TemplateFormat } from './write-template-CzKVVjgT.mjs';
4
4
  import 'node:stream';
5
5
 
6
6
  /**
package/express.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { EntityFormConfig, FormRule, ImportLookups } from '@dynamic-entity/core';
2
2
  import { Request, Router, Response } from 'express';
3
- import { B as BatchInfo, I as ImportLimits, T as TemplateFormat } from './write-template-B6KIIBRw.js';
3
+ import { B as BatchInfo, I as ImportLimits, T as TemplateFormat } from './write-template-CzKVVjgT.js';
4
4
  import 'node:stream';
5
5
 
6
6
  /**
package/express.js CHANGED
@@ -660,13 +660,13 @@ function detectFormat(head) {
660
660
  }
661
661
  return "csv";
662
662
  }
663
- async function* csvRows(stream, limits, found) {
663
+ async function* csvRows(stream, limits, found, forced) {
664
664
  const decoder = new TextDecoder("utf-8");
665
665
  const maxHeader = limits.maxCellLength * limits.maxColumns + limits.maxColumns;
666
666
  let held = "";
667
667
  let reader = null;
668
668
  const open = (headerLine) => {
669
- found.delimiter = core.detectDelimiter(headerLine);
669
+ found.delimiter = forced ?? core.detectDelimiter(headerLine);
670
670
  return core.createCsvReader({ delimiter: found.delimiter });
671
671
  };
672
672
  for await (const chunk of stream) {
@@ -725,7 +725,8 @@ async function readSheet(options) {
725
725
  const { head, stream } = await peek(counted, MAGIC_BYTES);
726
726
  const format = detectFormat(head);
727
727
  const found = {};
728
- const rows = format === "xlsx" ? xlsxRows(stream, limits) : csvRows(stream, limits, found);
728
+ const forced = /\.tsv$/i.test(options.filename ?? "") ? " " : void 0;
729
+ const rows = format === "xlsx" ? xlsxRows(stream, limits) : csvRows(stream, limits, found, forced);
729
730
  const iterator = rows[Symbol.asyncIterator]();
730
731
  const first = await iterator.next();
731
732
  const headers = first.done ? [] : first.value.map(core.cellText);