@dpuse/dpuse-shared 1.0.149 → 1.0.151

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.
@@ -25,6 +25,7 @@ export interface PreviewConfig {
25
25
  issues?: PreviewIssue[];
26
26
  linesToSkipAtStart?: number | undefined;
27
27
  parsedRecords: ParsingRecord[];
28
+ parserId?: string | undefined;
28
29
  quoteEscapeChar?: string | undefined;
29
30
  quoteMarkId?: string | undefined;
30
31
  quoteMarkOtherCharSeq?: string | undefined;
@@ -7,6 +7,7 @@ import { ConnectionDescriptionConfig, ConnectionNodeConfig, ObjectColumnConfig }
7
7
  import { connectorActionNameSchema, connectorCategoryConfigSchema, connectorConfigSchema, connectorItemTypeConfigSchema, connectorItemTypeIdSchema, connectorUsageConfigSchema, connectorUsageIdSchema } from './connectorConfig.schema';
8
8
  import { ContentAuditConfig, DataFormatId, InferenceRecord, InferenceSummary, ParsingRecord, PreviewConfig, ValueDelimiterId } from '../../dataView';
9
9
  export { connectorConfigSchema } from './connectorConfig.schema';
10
+ export { auditObjectContentWithParser, buildPreviewConfig, type ObjectFilePreview, retrieveRecordsWithParser } from './objectParsing';
10
11
  export interface ConnectorInterface extends Component {
11
12
  abortController: AbortController | undefined;
12
13
  readonly config: ConnectorConfig;
@@ -46,9 +47,10 @@ export type ConnectorItemTypeId = InferOutput<typeof connectorItemTypeIdSchema>;
46
47
  type ConnectorUsageConfig = InferOutput<typeof connectorUsageConfigSchema>;
47
48
  export interface AuditObjectContentOptions extends EngineConnectorActionOptions {
48
49
  chunkSize: number | undefined;
50
+ dataFormatId: DataFormatId;
49
51
  encodingId: string;
50
52
  hasHeaders: boolean;
51
- parsingToolName: string | undefined;
53
+ parserId: string | undefined;
52
54
  path: string;
53
55
  supportsTransferableStreams: boolean;
54
56
  valueDelimiterId: ValueDelimiterId;
@@ -109,6 +111,7 @@ export interface PreviewObjectOptions extends EngineConnectorActionOptions {
109
111
  encodingId: string | undefined;
110
112
  extension: string | undefined;
111
113
  mimeType: string | undefined;
114
+ parserId: string | undefined;
112
115
  path: string;
113
116
  }
114
117
  export interface RemoveRecordsOptions extends EngineConnectorActionOptions {
@@ -123,7 +126,9 @@ export interface RetrieveChunksOptions extends EngineConnectorActionOptions {
123
126
  }
124
127
  export interface RetrieveRecordsOptions extends EngineConnectorActionOptions {
125
128
  chunkSize: number | undefined;
129
+ dataFormatId: DataFormatId;
126
130
  encodingId: string;
131
+ parserId: string | undefined;
127
132
  path: string;
128
133
  valueDelimiterId: ValueDelimiterId;
129
134
  }
@@ -0,0 +1,36 @@
1
+ import { FileTypeResult } from 'file-type';
2
+ import { AuditObjectContentOptions, ColumnAuditor, ConnectorUtilities, RecordRetrievalTypeId, RetrieveRecordsOptions, RetrieveRecordsSummary } from '.';
3
+ import { ContentAuditConfig, DataFormatId, ParsingRecord, PreviewConfig } from '../../dataView';
4
+ import { ToolConfig } from '../tool';
5
+ export interface ObjectFilePreview {
6
+ bytes: Uint8Array;
7
+ dataFormatId: DataFormatId | undefined;
8
+ encodingConfidenceLevel: number | undefined;
9
+ encodingId: string | undefined;
10
+ fileTypeConfig: FileTypeResult | undefined;
11
+ isComplete: boolean;
12
+ text: string | undefined;
13
+ }
14
+ export declare function buildPreviewConfig(input: {
15
+ asAt: number;
16
+ filePreview: ObjectFilePreview;
17
+ inferDataTypes: ConnectorUtilities['inferDataTypes'];
18
+ parserId: string | undefined;
19
+ startedAt: number;
20
+ toolConfigs: ToolConfig[];
21
+ }): Promise<PreviewConfig>;
22
+ export declare function retrieveRecordsWithParser(input: {
23
+ chunk: (typeId: RecordRetrievalTypeId, records: ParsingRecord[]) => void;
24
+ options: RetrieveRecordsOptions;
25
+ signal: AbortSignal;
26
+ stream: ReadableStream<Uint8Array>;
27
+ toolConfigs: ToolConfig[];
28
+ }): Promise<RetrieveRecordsSummary>;
29
+ export declare function auditObjectContentWithParser(input: {
30
+ constructColumnAuditor: (hasHeaders: boolean) => ColumnAuditor;
31
+ onProgress: (recordCount: number) => void;
32
+ options: AuditObjectContentOptions;
33
+ signal: AbortSignal;
34
+ stream: ReadableStream<Uint8Array>;
35
+ toolConfigs: ToolConfig[];
36
+ }): Promise<ContentAuditConfig>;
@@ -0,0 +1,15 @@
1
+ import { ParseTextOptions, ParseTextResult } from '.';
2
+ import { ParsingRecord, PreviewIssue, ValueDelimiterId } from '../../dataView';
3
+ export type ParseTextWithDelimiter = (text: string, delimiter: ValueDelimiterId, isComplete: boolean) => Promise<{
4
+ issues: PreviewIssue[];
5
+ records: ParsingRecord[];
6
+ }>;
7
+ /**
8
+ * Reads delimited text for a preview: detects its record delimiter, and which of the candidate value delimiters splits
9
+ * it best. The value delimiter is undefined when the text is not delimited: the best one found does not split most
10
+ * records into the same number of values, more than one, as a table's rows would be. The records parsed with it are
11
+ * still returned, so the text can be shown as a table if the user chooses. A delimiter whose parse has issues is only
12
+ * used when every delimiter's does, because a wrong delimiter can itself cause a quote error. Then the one with the
13
+ * fewest issues is used, the first on a tie, and its issues are returned, so the user learns why the text cannot be read.
14
+ */
15
+ export declare function parseDelimitedText(text: string, options: ParseTextOptions, parseTextWithDelimiter: ParseTextWithDelimiter): Promise<ParseTextResult>;
@@ -1,7 +1,12 @@
1
1
  import { InferOutput } from 'valibot';
2
+ import { DataFormatId } from '../../dataView';
2
3
  import { parserConfigSchema, toolConfigSchema } from './toolConfig.schema';
3
4
  export { toolConfigSchema } from './toolConfig.schema';
4
5
  export type ToolConfig = InferOutput<typeof toolConfigSchema>;
5
6
  export type ParserConfig = InferOutput<typeof parserConfigSchema>;
6
7
  export type { ParserInterface, ParseStreamOptions, ParseTextOptions, ParseTextResult } from './parser';
8
+ export { parseDelimitedText, type ParseTextWithDelimiter } from './delimitedText';
9
+ export declare const TOOL_NAME_PREFIX = "dpuse-tool-";
10
+ export declare function listParserToolConfigs(toolConfigs: ToolConfig[], dataFormatId: DataFormatId): ToolConfig[];
11
+ export declare function resolveParserToolConfig(toolConfigs: ToolConfig[], dataFormatId: DataFormatId, parserId?: string): ToolConfig;
7
12
  export declare function loadTool<T>(toolConfigs: ToolConfig[], toolId: string): Promise<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dpuse/dpuse-shared",
3
- "version": "1.0.149",
3
+ "version": "1.0.151",
4
4
  "private": false,
5
5
  "description": "Common constants, types and utilities used across DPUse projects.",
6
6
  "license": "MIT",
@@ -64,7 +64,7 @@
64
64
  "valibot": "^1.5.0"
65
65
  },
66
66
  "devDependencies": {
67
- "@dpuse/dpuse-development": "^1.0.133",
67
+ "@dpuse/dpuse-development": "^1.0.135",
68
68
  "@dpuse/eslint-config-dpuse": "^1.0.145",
69
69
  "@types/node": "^26.6.5",
70
70
  "@vitest/coverage-v8": "^5.0.5",