@dpuse/dpuse-shared 1.0.229 → 1.0.230

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.
@@ -1,6 +1,11 @@
1
1
  import { ParsedRecord, SampleIssue, ValueDelimiterId } from '../../dataView';
2
- import { ParseTextOptions, ParseTextResult } from '.';
3
- export type ParseTextWithDelimiter = (text: string, delimiter: ValueDelimiterId, isComplete: boolean) => Promise<{
2
+ import { ParsePreviewOptions, ParsePreviewResult } from '.';
3
+ export interface DelimitedPreview {
4
+ bytes: Uint8Array;
5
+ encodingId: string;
6
+ text: string;
7
+ }
8
+ export type ParsePreviewWithDelimiter = (preview: DelimitedPreview, delimiter: ValueDelimiterId, isComplete: boolean) => Promise<{
4
9
  issues: SampleIssue[];
5
10
  records: ParsedRecord[];
6
11
  }>;
@@ -11,5 +16,7 @@ export type ParseTextWithDelimiter = (text: string, delimiter: ValueDelimiterId,
11
16
  * still returned, so the text can be shown as a table if the user chooses. A delimiter whose parse has issues is only
12
17
  * used when every delimiter's does, because a wrong delimiter can itself cause a quote error. Then the one with the
13
18
  * fewest issues is used, the first on a tie, and its issues are returned, so the user learns why the text cannot be read.
19
+ * The bytes are decoded once, with the decoder 'parseStream' uses, both to find the record delimiter and for a parser
20
+ * that reads text.
14
21
  */
15
- export declare function parseDelimitedText(text: string, options: ParseTextOptions, parseTextWithDelimiter: ParseTextWithDelimiter): Promise<ParseTextResult>;
22
+ export declare function parseDelimitedPreview(bytes: Uint8Array, options: ParsePreviewOptions, parseWithDelimiter: ParsePreviewWithDelimiter): Promise<ParsePreviewResult>;
@@ -6,10 +6,10 @@ export type ToolConfig = InferOutput<typeof toolConfigSchema>;
6
6
  export type ParserConfig = InferOutput<typeof parserConfigSchema>;
7
7
  export type { FilePreviewerInterface, FilePreviewResult } from './filePreviewer';
8
8
  export type { BuildStructureIndexOptions, ListStructureEntriesOptions, ListStructureEntriesResult, ParserInterface } from './parser';
9
- export type { ParseStreamOptions, ParseStreamSummary, ParseTextOptions, ParseTextResult, StructureCheckpoint } from './parser';
9
+ export type { ParsePreviewOptions, ParsePreviewResult, ParseStreamOptions, ParseStreamSummary, StructureCheckpoint } from './parser';
10
10
  export type { StructureContainerKindId, StructureEntry, StructureIndex, StructureKindId, StructureNode } from './parser';
11
11
  export type { StructuredParserInterface, StructureLocator, StructurePath } from './parser';
12
- export { parseDelimitedText, type ParseTextWithDelimiter } from './delimitedText';
12
+ export { type DelimitedPreview, parseDelimitedPreview, type ParsePreviewWithDelimiter } from './delimitedText';
13
13
  export declare const TOOL_NAME_PREFIX = "dpuse-tool-";
14
14
  export declare function listParserToolConfigs(toolConfigs: ToolConfig[], dataFormatId: DataFormatId): ToolConfig[];
15
15
  export declare function resolveParserToolConfig(toolConfigs: ToolConfig[], dataFormatId: DataFormatId, parserId?: string): ToolConfig;
@@ -2,19 +2,20 @@ import { DataFormatId, ParsedRecord, RecordDelimiterId, SampleIssue, ValueDelimi
2
2
  import { ParsedRecordsChunk, RetrieveRecordsSummary } from '../connector';
3
3
  export interface ParserInterface {
4
4
  parseStream: (stream: ReadableStream<Uint8Array>, options: ParseStreamOptions) => AsyncGenerator<ParsedRecordsChunk, ParseStreamSummary, undefined>;
5
- parseText: (text: string, options: ParseTextOptions) => Promise<ParseTextResult>;
5
+ parsePreview: (bytes: Uint8Array, options: ParsePreviewOptions) => Promise<ParsePreviewResult>;
6
6
  }
7
7
  export interface StructuredParserInterface extends ParserInterface {
8
8
  buildStructureIndex: (stream: ReadableStream<Uint8Array>, options: BuildStructureIndexOptions) => Promise<StructureIndex>;
9
9
  listStructureEntries: (stream: ReadableStream<Uint8Array>, options: ListStructureEntriesOptions) => Promise<ListStructureEntriesResult>;
10
10
  }
11
- export interface ParseTextOptions {
11
+ export interface ParsePreviewOptions {
12
12
  dataFormatId: DataFormatId;
13
+ encodingId: string;
13
14
  isComplete: boolean;
14
15
  structurePath?: StructurePath | undefined;
15
16
  valueDelimiterIds: ValueDelimiterId[];
16
17
  }
17
- export interface ParseTextResult {
18
+ export interface ParsePreviewResult {
18
19
  hasHeaders?: boolean | undefined;
19
20
  issues: SampleIssue[];
20
21
  parsedRecords: ParsedRecord[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dpuse/dpuse-shared",
3
- "version": "1.0.229",
3
+ "version": "1.0.230",
4
4
  "private": false,
5
5
  "description": "Common constants, types and utilities used across DPUse projects.",
6
6
  "license": "MIT",