typed-csv 1.0.0

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.
@@ -0,0 +1,60 @@
1
+ interface CsvLoaderOptions {
2
+ delimiter?: string;
3
+ quote?: string;
4
+ escape?: string;
5
+ bom?: boolean;
6
+ comment?: string | false;
7
+ trim?: boolean;
8
+ /** Generate TypeScript declaration file (.d.ts) */
9
+ emitTypes?: boolean;
10
+ /** Output directory for generated type files (relative to output path) */
11
+ typesOutputDir?: string;
12
+ /** Write .d.ts files to disk (useful for dev server) */
13
+ writeToDisk?: boolean;
14
+ /** Base directory for resolving referenced CSV files (default: directory of current file) */
15
+ refBaseDir?: string;
16
+ /** Primary key field name for referenced tables (default: 'id') */
17
+ defaultPrimaryKey?: string;
18
+ /** Current file path (used to resolve relative references) */
19
+ currentFilePath?: string;
20
+ /**
21
+ * When false, reference fields store parsed IDs instead of resolved objects.
22
+ * Used by csvToModule to emit accessor-based code with lazy resolution.
23
+ * Default: true (resolves references eagerly by loading referenced CSV files).
24
+ */
25
+ resolveReferences?: boolean;
26
+ }
27
+
28
+ interface CsvRollupOptions extends CsvLoaderOptions {
29
+ /** Include pattern for CSV files (default: /\.csv$/) */
30
+ include?: RegExp | string | Array<RegExp | string>;
31
+ /** Exclude pattern for CSV files */
32
+ exclude?: RegExp | string | Array<RegExp | string>;
33
+ /** Base directory for resolving referenced CSV files (default: directory of current file) */
34
+ refBaseDir?: string;
35
+ /** Primary key field name for referenced tables (default: 'id') */
36
+ defaultPrimaryKey?: string;
37
+ }
38
+ interface TransformResult {
39
+ code: string;
40
+ map: null;
41
+ }
42
+ interface EmitFileOptions {
43
+ type: "asset";
44
+ fileName: string;
45
+ source: string;
46
+ }
47
+ interface PluginContext {
48
+ emitFile: (options: EmitFileOptions) => string;
49
+ }
50
+ interface RollupPlugin {
51
+ name: string;
52
+ transform: (this: PluginContext, code: string, id: string) => TransformResult | null;
53
+ }
54
+ /**
55
+ * Rollup plugin for loading CSV files with typed-csv validation.
56
+ * Works with both Vite and Tsup (esbuild).
57
+ */
58
+ declare function csvLoader(options?: CsvRollupOptions): RollupPlugin;
59
+
60
+ export { type CsvRollupOptions, csvLoader, csvLoader as default };
@@ -0,0 +1,60 @@
1
+ interface CsvLoaderOptions {
2
+ delimiter?: string;
3
+ quote?: string;
4
+ escape?: string;
5
+ bom?: boolean;
6
+ comment?: string | false;
7
+ trim?: boolean;
8
+ /** Generate TypeScript declaration file (.d.ts) */
9
+ emitTypes?: boolean;
10
+ /** Output directory for generated type files (relative to output path) */
11
+ typesOutputDir?: string;
12
+ /** Write .d.ts files to disk (useful for dev server) */
13
+ writeToDisk?: boolean;
14
+ /** Base directory for resolving referenced CSV files (default: directory of current file) */
15
+ refBaseDir?: string;
16
+ /** Primary key field name for referenced tables (default: 'id') */
17
+ defaultPrimaryKey?: string;
18
+ /** Current file path (used to resolve relative references) */
19
+ currentFilePath?: string;
20
+ /**
21
+ * When false, reference fields store parsed IDs instead of resolved objects.
22
+ * Used by csvToModule to emit accessor-based code with lazy resolution.
23
+ * Default: true (resolves references eagerly by loading referenced CSV files).
24
+ */
25
+ resolveReferences?: boolean;
26
+ }
27
+
28
+ interface CsvRollupOptions extends CsvLoaderOptions {
29
+ /** Include pattern for CSV files (default: /\.csv$/) */
30
+ include?: RegExp | string | Array<RegExp | string>;
31
+ /** Exclude pattern for CSV files */
32
+ exclude?: RegExp | string | Array<RegExp | string>;
33
+ /** Base directory for resolving referenced CSV files (default: directory of current file) */
34
+ refBaseDir?: string;
35
+ /** Primary key field name for referenced tables (default: 'id') */
36
+ defaultPrimaryKey?: string;
37
+ }
38
+ interface TransformResult {
39
+ code: string;
40
+ map: null;
41
+ }
42
+ interface EmitFileOptions {
43
+ type: "asset";
44
+ fileName: string;
45
+ source: string;
46
+ }
47
+ interface PluginContext {
48
+ emitFile: (options: EmitFileOptions) => string;
49
+ }
50
+ interface RollupPlugin {
51
+ name: string;
52
+ transform: (this: PluginContext, code: string, id: string) => TransformResult | null;
53
+ }
54
+ /**
55
+ * Rollup plugin for loading CSV files with typed-csv validation.
56
+ * Works with both Vite and Tsup (esbuild).
57
+ */
58
+ declare function csvLoader(options?: CsvRollupOptions): RollupPlugin;
59
+
60
+ export { type CsvRollupOptions, csvLoader, csvLoader as default };