@eidos.space/eidos-file 0.1.0 → 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.
- package/DEVELOPER_PLATFORM.md +49 -53
- package/README.md +66 -99
- package/dist/adapter-contract-B3p-48Yb.d.mts +1149 -0
- package/dist/adapter-contract-B3p-48Yb.d.mts.map +1 -0
- package/dist/better-sqlite3.d.mts +64 -3
- package/dist/better-sqlite3.d.mts.map +1 -1
- package/dist/better-sqlite3.mjs +387 -14
- package/dist/better-sqlite3.mjs.map +1 -1
- package/dist/browser.d.mts +4 -3
- package/dist/browser.d.mts.map +1 -1
- package/dist/browser.mjs +30 -11
- package/dist/browser.mjs.map +1 -1
- package/dist/csv-WEud-i_H.mjs +376 -0
- package/dist/csv-WEud-i_H.mjs.map +1 -0
- package/dist/csv.d.mts +1 -1
- package/dist/csv.d.mts.map +1 -1
- package/dist/csv.mjs +1 -248
- package/dist/index.d.mts +312 -18
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +3237 -4
- package/dist/index.mjs.map +1 -0
- package/dist/runtime-CMdfE7Gx.mjs +5476 -0
- package/dist/runtime-CMdfE7Gx.mjs.map +1 -0
- package/dist/runtime-DCo5E0Kr.d.mts +668 -0
- package/dist/runtime-DCo5E0Kr.d.mts.map +1 -0
- package/dist/select-options-DihMTuoa.mjs +518 -0
- package/dist/select-options-DihMTuoa.mjs.map +1 -0
- package/dist/sqlite-wasm-B86yaLG6.mjs +2000 -0
- package/dist/sqlite-wasm-B86yaLG6.mjs.map +1 -0
- package/dist/temporal-CVzLU63l.d.mts +517 -0
- package/dist/temporal-CVzLU63l.d.mts.map +1 -0
- package/package.json +2 -3
- package/dist/csv.mjs.map +0 -1
- package/dist/host-CqP1MeMK.d.mts +0 -213
- package/dist/host-CqP1MeMK.d.mts.map +0 -1
- package/dist/host-D5kZAhga.mjs +0 -478
- package/dist/host-D5kZAhga.mjs.map +0 -1
- package/dist/relation-values-B0JhHBjZ.mjs +0 -232
- package/dist/relation-values-B0JhHBjZ.mjs.map +0 -1
- package/dist/runtime-C3bstvB8.d.mts +0 -465
- package/dist/runtime-C3bstvB8.d.mts.map +0 -1
- package/dist/runtime-CWC5y95G.mjs +0 -2907
- package/dist/runtime-CWC5y95G.mjs.map +0 -1
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
import { c as normalizeEidosFileDate, d as decodeEidosFileAttachmentPaths, j as EidosFileError, l as normalizeEidosFileInstant, n as parseEidosFileSelectOptions, o as isCanonicalEidosFileDate, p as encodeEidosFileAttachmentPaths } from "./select-options-DihMTuoa.mjs";
|
|
2
|
+
import { parse } from "csv-parse/browser/esm/sync";
|
|
3
|
+
//#region src/json-array-values.ts
|
|
4
|
+
function decodeEidosFileJsonArray(value) {
|
|
5
|
+
if (typeof value !== "string" || value.length === 0) return [];
|
|
6
|
+
try {
|
|
7
|
+
const parsed = JSON.parse(value);
|
|
8
|
+
if (!Array.isArray(parsed)) return [];
|
|
9
|
+
return parsed.filter((entry) => entry === null || typeof entry === "string" || typeof entry === "number" || typeof entry === "boolean");
|
|
10
|
+
} catch {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function decodeEidosFileStringArray(value) {
|
|
15
|
+
return decodeEidosFileJsonArray(value).filter((entry) => typeof entry === "string");
|
|
16
|
+
}
|
|
17
|
+
function encodeEidosFileJsonArray(values) {
|
|
18
|
+
return JSON.stringify(values);
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/field-conversion.ts
|
|
22
|
+
const MUTABLE_BASE_FIELD_TYPES = [
|
|
23
|
+
"text",
|
|
24
|
+
"number",
|
|
25
|
+
"checkbox",
|
|
26
|
+
"date",
|
|
27
|
+
"datetime",
|
|
28
|
+
"file",
|
|
29
|
+
"multi-select",
|
|
30
|
+
"rating",
|
|
31
|
+
"select",
|
|
32
|
+
"url"
|
|
33
|
+
];
|
|
34
|
+
const MUTABLE_TYPE_SET = new Set(MUTABLE_BASE_FIELD_TYPES);
|
|
35
|
+
const OPTION_COLORS = [
|
|
36
|
+
"gray",
|
|
37
|
+
"brown",
|
|
38
|
+
"pink",
|
|
39
|
+
"red",
|
|
40
|
+
"orange",
|
|
41
|
+
"yellow",
|
|
42
|
+
"green",
|
|
43
|
+
"cyan",
|
|
44
|
+
"blue",
|
|
45
|
+
"purple"
|
|
46
|
+
];
|
|
47
|
+
function isMutableEidosFileFieldType(type) {
|
|
48
|
+
return MUTABLE_TYPE_SET.has(type);
|
|
49
|
+
}
|
|
50
|
+
function decodeEidosFileMultiSelectValues(value) {
|
|
51
|
+
return Array.from(new Set(decodeEidosFileStringArray(value).filter(Boolean)));
|
|
52
|
+
}
|
|
53
|
+
function encodeEidosFileMultiSelectValues(values) {
|
|
54
|
+
return encodeEidosFileJsonArray(Array.from(new Set(values.filter(Boolean))));
|
|
55
|
+
}
|
|
56
|
+
function eidosFileFieldDisplayValues(field, value) {
|
|
57
|
+
if (value === null) return [];
|
|
58
|
+
const primitiveValue = typeof value === "boolean" ? value ? 1 : 0 : value;
|
|
59
|
+
if (field.type === "file") return decodeEidosFileAttachmentPaths(primitiveValue);
|
|
60
|
+
if (field.type === "select") return [String(primitiveValue)].filter(Boolean);
|
|
61
|
+
if (field.type === "multi-select") return decodeEidosFileMultiSelectValues(primitiveValue);
|
|
62
|
+
if (field.storageCodec === "json_array") return decodeEidosFileJsonArray(primitiveValue).flatMap((entry) => entry === null ? [] : [String(entry)]);
|
|
63
|
+
if (field.type === "checkbox") return [value === true || value === 1 || value === "1" ? "true" : "false"];
|
|
64
|
+
if (primitiveValue instanceof Uint8Array) return [];
|
|
65
|
+
const text = String(primitiveValue).trim();
|
|
66
|
+
return text ? [text] : [];
|
|
67
|
+
}
|
|
68
|
+
function optionPlan(field, rows) {
|
|
69
|
+
const existingByName = new Map(parseEidosFileSelectOptions(field.property).map((option) => [option.name, option]));
|
|
70
|
+
return Array.from(new Set(rows.flatMap((row) => eidosFileFieldDisplayValues(field, row.value)))).map((name, index) => existingByName.get(name) ?? {
|
|
71
|
+
name,
|
|
72
|
+
color: OPTION_COLORS[index % OPTION_COLORS.length]
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function defaultProperty(type, options) {
|
|
76
|
+
if (type === "select" || type === "multi-select") return { options };
|
|
77
|
+
if (type === "number") return {
|
|
78
|
+
format: "number",
|
|
79
|
+
showAs: "number",
|
|
80
|
+
color: "purple",
|
|
81
|
+
divideBy: 100,
|
|
82
|
+
showNumber: true
|
|
83
|
+
};
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
function storageCodec(type) {
|
|
87
|
+
if (type === "multi-select" || type === "file") return "json_array";
|
|
88
|
+
return "scalar";
|
|
89
|
+
}
|
|
90
|
+
function numericValue(values) {
|
|
91
|
+
if (values.length === 0) return null;
|
|
92
|
+
const parsed = Number(values[0]);
|
|
93
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
94
|
+
}
|
|
95
|
+
function checkboxValue(sourceValue, values) {
|
|
96
|
+
if (sourceValue === null) return null;
|
|
97
|
+
if (typeof sourceValue === "number" || typeof sourceValue === "bigint") return sourceValue === 0 || sourceValue === 0n ? 0 : 1;
|
|
98
|
+
const normalized = values[0]?.trim().toLowerCase();
|
|
99
|
+
if (!normalized) return 0;
|
|
100
|
+
if ([
|
|
101
|
+
"0",
|
|
102
|
+
"false",
|
|
103
|
+
"no",
|
|
104
|
+
"off",
|
|
105
|
+
"unchecked"
|
|
106
|
+
].includes(normalized)) return 0;
|
|
107
|
+
return 1;
|
|
108
|
+
}
|
|
109
|
+
function convertedValue(type, sourceValue, values) {
|
|
110
|
+
if (sourceValue === null) return null;
|
|
111
|
+
if (type === "number") return numericValue(values);
|
|
112
|
+
if (type === "checkbox") return checkboxValue(sourceValue, values);
|
|
113
|
+
if (type === "rating") {
|
|
114
|
+
const value = numericValue(values);
|
|
115
|
+
return value === null ? null : Math.min(5, Math.max(0, Math.round(value)));
|
|
116
|
+
}
|
|
117
|
+
if (type === "file") return encodeEidosFileAttachmentPaths(values);
|
|
118
|
+
if (type === "select") return values[0] || null;
|
|
119
|
+
if (type === "multi-select") return encodeEidosFileMultiSelectValues(values);
|
|
120
|
+
if (type === "date") return values.length > 0 ? normalizeEidosFileDate(values.join(", "), "Converted date") : null;
|
|
121
|
+
if (type === "datetime") return values.length > 0 ? normalizeEidosFileInstant(values.join(", "), "Converted datetime") : null;
|
|
122
|
+
return values.length > 0 ? values.join(", ") : null;
|
|
123
|
+
}
|
|
124
|
+
function planEidosFileFieldConversion(field, rows, targetType) {
|
|
125
|
+
return {
|
|
126
|
+
property: defaultProperty(targetType, targetType === "select" || targetType === "multi-select" ? optionPlan(field, rows) : []),
|
|
127
|
+
storageCodec: storageCodec(targetType),
|
|
128
|
+
values: rows.map((row) => {
|
|
129
|
+
const values = eidosFileFieldDisplayValues(field, row.value);
|
|
130
|
+
return {
|
|
131
|
+
id: row.id,
|
|
132
|
+
value: convertedValue(targetType, row.value, values)
|
|
133
|
+
};
|
|
134
|
+
})
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/csv.ts
|
|
139
|
+
const EIDOS_FILE_CSV_PREVIEW_ROW_COUNT = 5;
|
|
140
|
+
const EIDOS_FILE_CSV_INFERENCE_ROW_COUNT = 1e3;
|
|
141
|
+
function encodeCsvCell(value) {
|
|
142
|
+
return /[",\r\n]/.test(value) ? `"${value.replace(/"/g, "\"\"")}"` : value;
|
|
143
|
+
}
|
|
144
|
+
function encodeEidosFileCsvRecord(values) {
|
|
145
|
+
return `${values.map(encodeCsvCell).join(",")}\r\n`;
|
|
146
|
+
}
|
|
147
|
+
function eidosFileCsvExportHeader(columns) {
|
|
148
|
+
return encodeEidosFileCsvRecord(columns.map((column) => column.name));
|
|
149
|
+
}
|
|
150
|
+
function createEidosFileCsvRowEncoder(fields, columns) {
|
|
151
|
+
const fieldsByColumn = new Map(fields.map((field) => [field.tableColumnName, field]));
|
|
152
|
+
const resolvedFields = columns.map((column) => {
|
|
153
|
+
const field = fieldsByColumn.get(column.columnName);
|
|
154
|
+
if (!field) throw new EidosFileError("field-not-found", `Eidos File field not found: ${column.columnName}`);
|
|
155
|
+
return field;
|
|
156
|
+
});
|
|
157
|
+
return (row) => encodeEidosFileCsvRecord(resolvedFields.map((field) => {
|
|
158
|
+
return eidosFileFieldDisplayValues(field, row[field.tableColumnName] ?? null).join(", ");
|
|
159
|
+
}));
|
|
160
|
+
}
|
|
161
|
+
function invalidCsv(error) {
|
|
162
|
+
const candidate = error;
|
|
163
|
+
if (candidate.code === "CSV_QUOTE_NOT_CLOSED") return new EidosFileError("invalid-csv", `CSV parsing failed: unclosed quote at line ${candidate.lines ?? "unknown"}`);
|
|
164
|
+
if (candidate.code === "CSV_INVALID_CLOSING_QUOTE") return new EidosFileError("invalid-csv", "CSV parsing failed: invalid closing quote");
|
|
165
|
+
return new EidosFileError("invalid-csv", `CSV parsing failed: ${candidate.message ?? String(error)}`);
|
|
166
|
+
}
|
|
167
|
+
function parseCsv(content) {
|
|
168
|
+
if (!content.trim()) throw new EidosFileError("invalid-csv", "CSV file is empty");
|
|
169
|
+
let records;
|
|
170
|
+
let malformedRows = 0;
|
|
171
|
+
try {
|
|
172
|
+
records = parse(content, {
|
|
173
|
+
bom: true,
|
|
174
|
+
columns: false,
|
|
175
|
+
relax_column_count: true,
|
|
176
|
+
relax_quotes: true,
|
|
177
|
+
skip_empty_lines: true,
|
|
178
|
+
skip_records_with_error: true,
|
|
179
|
+
on_skip: () => {
|
|
180
|
+
malformedRows += 1;
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
} catch (error) {
|
|
184
|
+
throw invalidCsv(error);
|
|
185
|
+
}
|
|
186
|
+
if (records.length === 0 || records[0].length === 0) throw new EidosFileError("invalid-csv", "CSV header is missing");
|
|
187
|
+
const header = records[0].map((value) => String(value ?? "").trim());
|
|
188
|
+
const rows = [];
|
|
189
|
+
let inconsistentRows = 0;
|
|
190
|
+
for (const record of records.slice(1)) {
|
|
191
|
+
if (record.length !== header.length) {
|
|
192
|
+
inconsistentRows += 1;
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
rows.push(record.map((value) => String(value ?? "")));
|
|
196
|
+
}
|
|
197
|
+
const issues = [];
|
|
198
|
+
if (malformedRows > 0) issues.push({
|
|
199
|
+
code: "malformed-row",
|
|
200
|
+
count: malformedRows,
|
|
201
|
+
message: `${malformedRows} malformed row${malformedRows === 1 ? " was" : "s were"} skipped`
|
|
202
|
+
});
|
|
203
|
+
if (inconsistentRows > 0) issues.push({
|
|
204
|
+
code: "inconsistent-column-count",
|
|
205
|
+
count: inconsistentRows,
|
|
206
|
+
message: `${inconsistentRows} row${inconsistentRows === 1 ? " has" : "s have"} a different column count and will be skipped`
|
|
207
|
+
});
|
|
208
|
+
return {
|
|
209
|
+
header,
|
|
210
|
+
rows,
|
|
211
|
+
skippedRowCount: malformedRows + inconsistentRows,
|
|
212
|
+
issues
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
function uniqueName(name, used, fallback) {
|
|
216
|
+
const base = name.trim() || fallback;
|
|
217
|
+
let candidate = base;
|
|
218
|
+
let suffix = 2;
|
|
219
|
+
while (used.has(candidate.toLocaleLowerCase())) {
|
|
220
|
+
candidate = `${base} ${suffix}`;
|
|
221
|
+
suffix += 1;
|
|
222
|
+
}
|
|
223
|
+
used.add(candidate.toLocaleLowerCase());
|
|
224
|
+
return candidate;
|
|
225
|
+
}
|
|
226
|
+
function isIsoDate(value) {
|
|
227
|
+
return isCanonicalEidosFileDate(value);
|
|
228
|
+
}
|
|
229
|
+
function isIsoDateTime(value) {
|
|
230
|
+
try {
|
|
231
|
+
normalizeEidosFileInstant(value);
|
|
232
|
+
return true;
|
|
233
|
+
} catch {
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
function isUrl(value) {
|
|
238
|
+
try {
|
|
239
|
+
const url = new URL(value);
|
|
240
|
+
return url.protocol === "http:" || url.protocol === "https:";
|
|
241
|
+
} catch {
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
function inferType(values) {
|
|
246
|
+
const populated = values.map((value) => value.trim()).filter(Boolean);
|
|
247
|
+
if (populated.length === 0) return "text";
|
|
248
|
+
if (populated.every((value) => /^(?:true|false)$/i.test(value))) return "checkbox";
|
|
249
|
+
if (populated.every((value) => value !== "" && Number.isFinite(Number(value)))) return "number";
|
|
250
|
+
if (populated.every(isIsoDate)) return "date";
|
|
251
|
+
if (populated.every(isIsoDateTime)) return "datetime";
|
|
252
|
+
if (populated.every(isUrl)) return "url";
|
|
253
|
+
return "text";
|
|
254
|
+
}
|
|
255
|
+
function defaultTableName(fileName) {
|
|
256
|
+
return fileName.replace(/\.[^.]+$/, "").trim() || "Imported table";
|
|
257
|
+
}
|
|
258
|
+
function buildColumns(header, rows) {
|
|
259
|
+
const usedNames = /* @__PURE__ */ new Set();
|
|
260
|
+
return header.map((sourceName, sourceIndex) => {
|
|
261
|
+
const name = uniqueName(sourceName, usedNames, `Column ${sourceIndex + 1}`);
|
|
262
|
+
if (sourceIndex === 0) return {
|
|
263
|
+
sourceIndex,
|
|
264
|
+
sourceName,
|
|
265
|
+
name,
|
|
266
|
+
columnName: name,
|
|
267
|
+
type: "record-label"
|
|
268
|
+
};
|
|
269
|
+
return {
|
|
270
|
+
sourceIndex,
|
|
271
|
+
sourceName,
|
|
272
|
+
name,
|
|
273
|
+
columnName: name,
|
|
274
|
+
type: inferType(rows.slice(0, EIDOS_FILE_CSV_INFERENCE_ROW_COUNT).map((row) => row[sourceIndex] ?? ""))
|
|
275
|
+
};
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
function planEidosFileCsvImport(file, options = {}) {
|
|
279
|
+
const { plan, parsed } = buildImportPlan(file, options);
|
|
280
|
+
parsed.rows.forEach((row, rowIndex) => eidosFileCsvRowToEidosFileRow(row, rowIndex + 2, plan));
|
|
281
|
+
return plan;
|
|
282
|
+
}
|
|
283
|
+
function prepareEidosFileCsvImport(file, options = {}) {
|
|
284
|
+
const { plan, parsed } = buildImportPlan(file, options);
|
|
285
|
+
return {
|
|
286
|
+
plan,
|
|
287
|
+
rows: parsed.rows.map((row, rowIndex) => eidosFileCsvRowToEidosFileRow(row, rowIndex + 2, plan))
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
function importEidosFileCsv(eidosFile, file, options = {}) {
|
|
291
|
+
const { plan, rows } = prepareEidosFileCsvImport(file, options);
|
|
292
|
+
return {
|
|
293
|
+
table: eidosFile.importTable({
|
|
294
|
+
name: plan.tableName,
|
|
295
|
+
fields: plan.columns.map((column) => ({
|
|
296
|
+
name: column.name,
|
|
297
|
+
columnName: column.columnName,
|
|
298
|
+
type: column.type === "record-label" ? "text" : column.type,
|
|
299
|
+
isRecordLabel: column.type === "record-label"
|
|
300
|
+
}))
|
|
301
|
+
}, rows),
|
|
302
|
+
importedRowCount: rows.length,
|
|
303
|
+
skippedRowCount: plan.skippedRowCount
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
function buildImportPlan(file, options) {
|
|
307
|
+
const parsed = parseCsv(file.content);
|
|
308
|
+
return {
|
|
309
|
+
plan: createEidosFileCsvImportPlan({
|
|
310
|
+
fileName: file.name,
|
|
311
|
+
header: parsed.header,
|
|
312
|
+
inferenceRows: parsed.rows,
|
|
313
|
+
rowCount: parsed.rows.length,
|
|
314
|
+
skippedRowCount: parsed.skippedRowCount,
|
|
315
|
+
sampleRows: parsed.rows.slice(0, 5),
|
|
316
|
+
issues: parsed.issues
|
|
317
|
+
}, options),
|
|
318
|
+
parsed
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
function createEidosFileCsvImportPlan(source, options = {}) {
|
|
322
|
+
const columns = buildColumns(source.header, source.inferenceRows);
|
|
323
|
+
const overrides = new Map((options.columns ?? []).map((override) => [override.sourceIndex, override]));
|
|
324
|
+
for (const column of columns) {
|
|
325
|
+
const override = overrides.get(column.sourceIndex);
|
|
326
|
+
if (!override) continue;
|
|
327
|
+
if (override.name !== void 0) {
|
|
328
|
+
const name = override.name.trim();
|
|
329
|
+
if (!name) throw new EidosFileError("invalid-csv", "CSV field names cannot be empty");
|
|
330
|
+
column.name = name;
|
|
331
|
+
}
|
|
332
|
+
if (column.type !== "record-label" && override.type) column.type = override.type;
|
|
333
|
+
}
|
|
334
|
+
const tableName = options.tableName?.trim() || defaultTableName(source.fileName);
|
|
335
|
+
return {
|
|
336
|
+
fileName: source.fileName,
|
|
337
|
+
tableName,
|
|
338
|
+
rowCount: source.rowCount,
|
|
339
|
+
skippedRowCount: source.skippedRowCount,
|
|
340
|
+
columns,
|
|
341
|
+
sampleRows: source.sampleRows,
|
|
342
|
+
issues: source.issues
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
function convertValue(value, type, rowNumber, fieldName) {
|
|
346
|
+
const trimmed = value.trim();
|
|
347
|
+
if (!trimmed) return null;
|
|
348
|
+
if (type === "number") {
|
|
349
|
+
const number = Number(trimmed);
|
|
350
|
+
if (!Number.isFinite(number)) throw new EidosFileError("invalid-csv", `CSV row ${rowNumber}, field “${fieldName}” is not a number`);
|
|
351
|
+
return number;
|
|
352
|
+
}
|
|
353
|
+
if (type === "checkbox") {
|
|
354
|
+
if (!/^(?:true|false)$/i.test(trimmed)) throw new EidosFileError("invalid-csv", `CSV row ${rowNumber}, field “${fieldName}” is not true or false`);
|
|
355
|
+
return /^true$/i.test(trimmed) ? 1 : 0;
|
|
356
|
+
}
|
|
357
|
+
if (type === "date") {
|
|
358
|
+
if (!isIsoDate(trimmed)) throw new EidosFileError("invalid-csv", `CSV row ${rowNumber}, field “${fieldName}” is not a YYYY-MM-DD date`);
|
|
359
|
+
return trimmed;
|
|
360
|
+
}
|
|
361
|
+
if (type === "datetime") {
|
|
362
|
+
if (!isIsoDateTime(trimmed)) throw new EidosFileError("invalid-csv", `CSV row ${rowNumber}, field “${fieldName}” is not an RFC 3339 timestamp`);
|
|
363
|
+
return normalizeEidosFileInstant(trimmed, fieldName);
|
|
364
|
+
}
|
|
365
|
+
return value;
|
|
366
|
+
}
|
|
367
|
+
function eidosFileCsvRowToEidosFileRow(row, rowNumber, plan) {
|
|
368
|
+
return Object.fromEntries(plan.columns.map((column) => [column.columnName, convertValue(row[column.sourceIndex] ?? "", column.type, rowNumber, column.name)]));
|
|
369
|
+
}
|
|
370
|
+
function parseEidosFileCsvRows(file, plan) {
|
|
371
|
+
return parseCsv(file.content).rows.map((row, rowIndex) => eidosFileCsvRowToEidosFileRow(row, rowIndex + 2, plan));
|
|
372
|
+
}
|
|
373
|
+
//#endregion
|
|
374
|
+
export { planEidosFileFieldConversion as _, eidosFileCsvExportHeader as a, encodeEidosFileJsonArray as b, importEidosFileCsv as c, prepareEidosFileCsvImport as d, MUTABLE_BASE_FIELD_TYPES as f, isMutableEidosFileFieldType as g, encodeEidosFileMultiSelectValues as h, createEidosFileCsvRowEncoder as i, parseEidosFileCsvRows as l, eidosFileFieldDisplayValues as m, EIDOS_FILE_CSV_PREVIEW_ROW_COUNT as n, eidosFileCsvRowToEidosFileRow as o, decodeEidosFileMultiSelectValues as p, createEidosFileCsvImportPlan as r, encodeEidosFileCsvRecord as s, EIDOS_FILE_CSV_INFERENCE_ROW_COUNT as t, planEidosFileCsvImport as u, decodeEidosFileJsonArray as v, decodeEidosFileStringArray as y };
|
|
375
|
+
|
|
376
|
+
//# sourceMappingURL=csv-WEud-i_H.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csv-WEud-i_H.mjs","names":[],"sources":["../src/json-array-values.ts","../src/field-conversion.ts","../src/csv.ts"],"sourcesContent":["import type { EidosFileRowValue } from \"./types\"\n\nexport type EidosFileJsonArrayValue = string | number | boolean | null\n\nexport function decodeEidosFileJsonArray(\n value: EidosFileRowValue | undefined\n): EidosFileJsonArrayValue[] {\n if (typeof value !== \"string\" || value.length === 0) return []\n try {\n const parsed: unknown = JSON.parse(value)\n if (!Array.isArray(parsed)) return []\n return parsed.filter(\n (entry): entry is EidosFileJsonArrayValue =>\n entry === null ||\n typeof entry === \"string\" ||\n typeof entry === \"number\" ||\n typeof entry === \"boolean\"\n )\n } catch {\n return []\n }\n}\n\nexport function decodeEidosFileStringArray(\n value: EidosFileRowValue | undefined\n): string[] {\n return decodeEidosFileJsonArray(value).filter(\n (entry): entry is string => typeof entry === \"string\"\n )\n}\n\nexport function encodeEidosFileJsonArray(\n values: readonly EidosFileJsonArrayValue[]\n): string {\n return JSON.stringify(values)\n}\n","import type { EidosFileSqlPrimitive } from \"./connection\"\nimport {\n decodeEidosFileAttachmentPaths,\n encodeEidosFileAttachmentPaths,\n} from \"./file-values\"\nimport {\n decodeEidosFileJsonArray,\n decodeEidosFileStringArray,\n encodeEidosFileJsonArray,\n} from \"./json-array-values\"\nimport { parseEidosFileSelectOptions } from \"./select-options\"\nimport { normalizeEidosFileDate, normalizeEidosFileInstant } from \"./temporal\"\nimport type {\n EidosFileFieldInfo,\n EidosFileFieldType,\n EidosFileSelectOption,\n EidosFileStorageCodec,\n} from \"./types\"\n\nexport const MUTABLE_BASE_FIELD_TYPES = [\n \"text\",\n \"number\",\n \"checkbox\",\n \"date\",\n \"datetime\",\n \"file\",\n \"multi-select\",\n \"rating\",\n \"select\",\n \"url\",\n] as const satisfies readonly EidosFileFieldType[]\n\nexport type MutableEidosFileFieldType =\n (typeof MUTABLE_BASE_FIELD_TYPES)[number]\n\nconst MUTABLE_TYPE_SET = new Set<EidosFileFieldType>(MUTABLE_BASE_FIELD_TYPES)\nconst OPTION_COLORS = [\n \"gray\",\n \"brown\",\n \"pink\",\n \"red\",\n \"orange\",\n \"yellow\",\n \"green\",\n \"cyan\",\n \"blue\",\n \"purple\",\n]\n\nexport interface EidosFileFieldValueRow {\n id: string\n value: EidosFileSqlPrimitive\n}\n\nexport interface EidosFileFieldConversionPlan {\n property: Record<string, unknown> | null\n storageCodec: EidosFileStorageCodec\n values: Array<{ id: string; value: EidosFileSqlPrimitive }>\n}\n\nexport function isMutableEidosFileFieldType(\n type: EidosFileFieldType\n): type is MutableEidosFileFieldType {\n return MUTABLE_TYPE_SET.has(type)\n}\n\nexport function decodeEidosFileMultiSelectValues(\n value: EidosFileSqlPrimitive\n): string[] {\n return Array.from(new Set(decodeEidosFileStringArray(value).filter(Boolean)))\n}\n\nexport function encodeEidosFileMultiSelectValues(\n values: readonly string[]\n): string | null {\n return encodeEidosFileJsonArray(Array.from(new Set(values.filter(Boolean))))\n}\n\nexport function eidosFileFieldDisplayValues(\n field: EidosFileFieldInfo,\n value: EidosFileSqlPrimitive | boolean\n): string[] {\n if (value === null) return []\n const primitiveValue: EidosFileSqlPrimitive =\n typeof value === \"boolean\" ? (value ? 1 : 0) : value\n if (field.type === \"file\")\n return decodeEidosFileAttachmentPaths(primitiveValue)\n if (field.type === \"select\") {\n return [String(primitiveValue)].filter(Boolean)\n }\n if (field.type === \"multi-select\") {\n return decodeEidosFileMultiSelectValues(primitiveValue)\n }\n if (field.storageCodec === \"json_array\") {\n return decodeEidosFileJsonArray(primitiveValue).flatMap((entry) =>\n entry === null ? [] : [String(entry)]\n )\n }\n if (field.type === \"checkbox\") {\n return [value === true || value === 1 || value === \"1\" ? \"true\" : \"false\"]\n }\n if (primitiveValue instanceof Uint8Array) return []\n const text = String(primitiveValue).trim()\n return text ? [text] : []\n}\n\nfunction optionPlan(\n field: EidosFileFieldInfo,\n rows: EidosFileFieldValueRow[]\n): EidosFileSelectOption[] {\n const existingByName = new Map(\n parseEidosFileSelectOptions(field.property).map((option) => [\n option.name,\n option,\n ])\n )\n const names = Array.from(\n new Set(\n rows.flatMap((row) => eidosFileFieldDisplayValues(field, row.value))\n )\n )\n return names.map(\n (name, index) =>\n existingByName.get(name) ?? {\n name,\n color: OPTION_COLORS[index % OPTION_COLORS.length],\n }\n )\n}\n\nfunction defaultProperty(\n type: MutableEidosFileFieldType,\n options: EidosFileSelectOption[]\n): Record<string, unknown> | null {\n if (type === \"select\" || type === \"multi-select\") return { options }\n if (type === \"number\") {\n return {\n format: \"number\",\n showAs: \"number\",\n color: \"purple\",\n divideBy: 100,\n showNumber: true,\n }\n }\n return null\n}\n\nfunction storageCodec(type: MutableEidosFileFieldType): EidosFileStorageCodec {\n if (type === \"multi-select\" || type === \"file\") return \"json_array\"\n return \"scalar\"\n}\n\nfunction numericValue(values: string[]): number | null {\n if (values.length === 0) return null\n const parsed = Number(values[0])\n return Number.isFinite(parsed) ? parsed : null\n}\n\nfunction checkboxValue(\n sourceValue: EidosFileSqlPrimitive,\n values: string[]\n): number | null {\n if (sourceValue === null) return null\n if (typeof sourceValue === \"number\" || typeof sourceValue === \"bigint\") {\n return sourceValue === 0 || sourceValue === 0n ? 0 : 1\n }\n const normalized = values[0]?.trim().toLowerCase()\n if (!normalized) return 0\n if ([\"0\", \"false\", \"no\", \"off\", \"unchecked\"].includes(normalized)) return 0\n return 1\n}\n\nfunction convertedValue(\n type: MutableEidosFileFieldType,\n sourceValue: EidosFileSqlPrimitive,\n values: string[]\n): EidosFileSqlPrimitive {\n if (sourceValue === null) return null\n if (type === \"number\") return numericValue(values)\n if (type === \"checkbox\") return checkboxValue(sourceValue, values)\n if (type === \"rating\") {\n const value = numericValue(values)\n return value === null ? null : Math.min(5, Math.max(0, Math.round(value)))\n }\n if (type === \"file\") return encodeEidosFileAttachmentPaths(values)\n if (type === \"select\") {\n return values[0] || null\n }\n if (type === \"multi-select\") {\n return encodeEidosFileMultiSelectValues(values)\n }\n if (type === \"date\") {\n return values.length > 0\n ? normalizeEidosFileDate(values.join(\", \"), \"Converted date\")\n : null\n }\n if (type === \"datetime\") {\n return values.length > 0\n ? normalizeEidosFileInstant(values.join(\", \"), \"Converted datetime\")\n : null\n }\n return values.length > 0 ? values.join(\", \") : null\n}\n\nexport function planEidosFileFieldConversion(\n field: EidosFileFieldInfo,\n rows: EidosFileFieldValueRow[],\n targetType: MutableEidosFileFieldType\n): EidosFileFieldConversionPlan {\n const options =\n targetType === \"select\" || targetType === \"multi-select\"\n ? optionPlan(field, rows)\n : []\n return {\n property: defaultProperty(targetType, options),\n storageCodec: storageCodec(targetType),\n values: rows.map((row) => {\n const values = eidosFileFieldDisplayValues(field, row.value)\n return {\n id: row.id,\n value: convertedValue(targetType, row.value, values),\n }\n }),\n }\n}\n","// The browser ESM entry bundles its own byte helpers and also runs in Node.\n// Using it keeps the shared CSV runtime portable instead of leaking Node's\n// global `Buffer` requirement into Web Workers.\nimport { parse } from \"csv-parse/browser/esm/sync\"\n\nimport { EidosFileError } from \"./errors\"\nimport { eidosFileFieldDisplayValues } from \"./field-conversion\"\nimport type { EidosFileRuntime } from \"./runtime\"\nimport { isCanonicalEidosFileDate, normalizeEidosFileInstant } from \"./temporal\"\nimport type {\n EidosFileCsvExportColumn,\n EidosFileFieldInfo,\n EidosFileCsvFieldType,\n EidosFileCsvImportColumn,\n EidosFileCsvImportIssue,\n EidosFileCsvImportOptions,\n EidosFileCsvImportPlan,\n EidosFileCsvImportResult,\n EidosFileRow,\n} from \"./types\"\n\nexport const EIDOS_FILE_CSV_PREVIEW_ROW_COUNT = 5\nexport const EIDOS_FILE_CSV_INFERENCE_ROW_COUNT = 1_000\n\nfunction encodeCsvCell(value: string): string {\n return /[\",\\r\\n]/.test(value) ? `\"${value.replace(/\"/g, '\"\"')}\"` : value\n}\n\nexport function encodeEidosFileCsvRecord(values: readonly string[]): string {\n return `${values.map(encodeCsvCell).join(\",\")}\\r\\n`\n}\n\nexport function eidosFileCsvExportHeader(\n columns: readonly EidosFileCsvExportColumn[]\n): string {\n return encodeEidosFileCsvRecord(columns.map((column) => column.name))\n}\n\nexport function createEidosFileCsvRowEncoder(\n fields: readonly EidosFileFieldInfo[],\n columns: readonly EidosFileCsvExportColumn[]\n): (row: EidosFileRow) => string {\n const fieldsByColumn = new Map(\n fields.map((field) => [field.tableColumnName, field])\n )\n const resolvedFields = columns.map((column) => {\n const field = fieldsByColumn.get(column.columnName)\n if (!field) {\n throw new EidosFileError(\n \"field-not-found\",\n `Eidos File field not found: ${column.columnName}`\n )\n }\n return field\n })\n\n return (row) =>\n encodeEidosFileCsvRecord(\n resolvedFields.map((field) => {\n return eidosFileFieldDisplayValues(\n field,\n row[field.tableColumnName] ?? null\n ).join(\", \")\n })\n )\n}\n\ninterface ParsedCsv {\n header: string[]\n rows: string[][]\n skippedRowCount: number\n issues: EidosFileCsvImportIssue[]\n}\n\nfunction invalidCsv(error: unknown): EidosFileError {\n const candidate = error as { code?: string; lines?: number; message?: string }\n if (candidate.code === \"CSV_QUOTE_NOT_CLOSED\") {\n return new EidosFileError(\n \"invalid-csv\",\n `CSV parsing failed: unclosed quote at line ${candidate.lines ?? \"unknown\"}`\n )\n }\n if (candidate.code === \"CSV_INVALID_CLOSING_QUOTE\") {\n return new EidosFileError(\n \"invalid-csv\",\n \"CSV parsing failed: invalid closing quote\"\n )\n }\n return new EidosFileError(\n \"invalid-csv\",\n `CSV parsing failed: ${candidate.message ?? String(error)}`\n )\n}\n\nfunction parseCsv(content: string): ParsedCsv {\n if (!content.trim()) {\n throw new EidosFileError(\"invalid-csv\", \"CSV file is empty\")\n }\n let records: string[][]\n let malformedRows = 0\n try {\n const parseOptions = {\n bom: true,\n columns: false,\n relax_column_count: true,\n relax_quotes: true,\n skip_empty_lines: true,\n skip_records_with_error: true,\n on_skip: () => {\n malformedRows += 1\n },\n }\n records = parse(content, parseOptions) as string[][]\n } catch (error) {\n throw invalidCsv(error)\n }\n if (records.length === 0 || records[0].length === 0) {\n throw new EidosFileError(\"invalid-csv\", \"CSV header is missing\")\n }\n const header = records[0].map((value) => String(value ?? \"\").trim())\n const rows: string[][] = []\n let inconsistentRows = 0\n for (const record of records.slice(1)) {\n if (record.length !== header.length) {\n inconsistentRows += 1\n continue\n }\n rows.push(record.map((value) => String(value ?? \"\")))\n }\n const issues: EidosFileCsvImportIssue[] = []\n if (malformedRows > 0) {\n issues.push({\n code: \"malformed-row\",\n count: malformedRows,\n message: `${malformedRows} malformed row${malformedRows === 1 ? \" was\" : \"s were\"} skipped`,\n })\n }\n if (inconsistentRows > 0) {\n issues.push({\n code: \"inconsistent-column-count\",\n count: inconsistentRows,\n message: `${inconsistentRows} row${inconsistentRows === 1 ? \" has\" : \"s have\"} a different column count and will be skipped`,\n })\n }\n return {\n header,\n rows,\n skippedRowCount: malformedRows + inconsistentRows,\n issues,\n }\n}\n\nfunction uniqueName(name: string, used: Set<string>, fallback: string): string {\n const base = name.trim() || fallback\n let candidate = base\n let suffix = 2\n while (used.has(candidate.toLocaleLowerCase())) {\n candidate = `${base} ${suffix}`\n suffix += 1\n }\n used.add(candidate.toLocaleLowerCase())\n return candidate\n}\n\nfunction isIsoDate(value: string): boolean {\n return isCanonicalEidosFileDate(value)\n}\n\nfunction isIsoDateTime(value: string): boolean {\n try {\n normalizeEidosFileInstant(value)\n return true\n } catch {\n return false\n }\n}\n\nfunction isUrl(value: string): boolean {\n try {\n const url = new URL(value)\n return url.protocol === \"http:\" || url.protocol === \"https:\"\n } catch {\n return false\n }\n}\n\nfunction inferType(values: string[]): EidosFileCsvFieldType {\n const populated = values.map((value) => value.trim()).filter(Boolean)\n if (populated.length === 0) return \"text\"\n if (populated.every((value) => /^(?:true|false)$/i.test(value))) {\n return \"checkbox\"\n }\n if (\n populated.every((value) => value !== \"\" && Number.isFinite(Number(value)))\n ) {\n return \"number\"\n }\n if (populated.every(isIsoDate)) return \"date\"\n if (populated.every(isIsoDateTime)) return \"datetime\"\n if (populated.every(isUrl)) return \"url\"\n return \"text\"\n}\n\nfunction defaultTableName(fileName: string): string {\n const withoutExtension = fileName.replace(/\\.[^.]+$/, \"\").trim()\n return withoutExtension || \"Imported table\"\n}\n\nfunction buildColumns(\n header: string[],\n rows: string[][]\n): EidosFileCsvImportColumn[] {\n const usedNames = new Set<string>()\n return header.map((sourceName, sourceIndex) => {\n const name = uniqueName(sourceName, usedNames, `Column ${sourceIndex + 1}`)\n if (sourceIndex === 0) {\n return {\n sourceIndex,\n sourceName,\n name,\n columnName: name,\n type: \"record-label\",\n }\n }\n return {\n sourceIndex,\n sourceName,\n name,\n columnName: name,\n type: inferType(\n rows\n .slice(0, EIDOS_FILE_CSV_INFERENCE_ROW_COUNT)\n .map((row) => row[sourceIndex] ?? \"\")\n ),\n }\n })\n}\n\nexport function planEidosFileCsvImport(\n file: { name: string; content: string },\n options: EidosFileCsvImportOptions = {}\n): EidosFileCsvImportPlan {\n const { plan, parsed } = buildImportPlan(file, options)\n parsed.rows.forEach((row, rowIndex) =>\n eidosFileCsvRowToEidosFileRow(row, rowIndex + 2, plan)\n )\n return plan\n}\n\nexport function prepareEidosFileCsvImport(\n file: { name: string; content: string },\n options: EidosFileCsvImportOptions = {}\n): { plan: EidosFileCsvImportPlan; rows: EidosFileRow[] } {\n const { plan, parsed } = buildImportPlan(file, options)\n return {\n plan,\n rows: parsed.rows.map((row, rowIndex) =>\n eidosFileCsvRowToEidosFileRow(row, rowIndex + 2, plan)\n ),\n }\n}\n\nexport function importEidosFileCsv(\n eidosFile: EidosFileRuntime,\n file: { name: string; content: string },\n options: EidosFileCsvImportOptions = {}\n): EidosFileCsvImportResult {\n const { plan, rows } = prepareEidosFileCsvImport(file, options)\n const table = eidosFile.importTable(\n {\n name: plan.tableName,\n fields: plan.columns.map((column) => ({\n name: column.name,\n columnName: column.columnName,\n type: column.type === \"record-label\" ? \"text\" : column.type,\n isRecordLabel: column.type === \"record-label\",\n })),\n },\n rows\n )\n return {\n table,\n importedRowCount: rows.length,\n skippedRowCount: plan.skippedRowCount,\n }\n}\n\nfunction buildImportPlan(\n file: { name: string; content: string },\n options: EidosFileCsvImportOptions\n): { plan: EidosFileCsvImportPlan; parsed: ParsedCsv } {\n const parsed = parseCsv(file.content)\n const plan = createEidosFileCsvImportPlan(\n {\n fileName: file.name,\n header: parsed.header,\n inferenceRows: parsed.rows,\n rowCount: parsed.rows.length,\n skippedRowCount: parsed.skippedRowCount,\n sampleRows: parsed.rows.slice(0, EIDOS_FILE_CSV_PREVIEW_ROW_COUNT),\n issues: parsed.issues,\n },\n options\n )\n return { plan, parsed }\n}\n\nexport interface EidosFileCsvImportPlanSource {\n fileName: string\n header: string[]\n inferenceRows: string[][]\n rowCount: number\n skippedRowCount: number\n sampleRows: string[][]\n issues: EidosFileCsvImportIssue[]\n}\n\nexport function createEidosFileCsvImportPlan(\n source: EidosFileCsvImportPlanSource,\n options: EidosFileCsvImportOptions = {}\n): EidosFileCsvImportPlan {\n const columns = buildColumns(source.header, source.inferenceRows)\n const overrides = new Map(\n (options.columns ?? []).map((override) => [override.sourceIndex, override])\n )\n for (const column of columns) {\n const override = overrides.get(column.sourceIndex)\n if (!override) continue\n if (override.name !== undefined) {\n const name = override.name.trim()\n if (!name) {\n throw new EidosFileError(\n \"invalid-csv\",\n \"CSV field names cannot be empty\"\n )\n }\n column.name = name\n }\n if (column.type !== \"record-label\" && override.type)\n column.type = override.type\n }\n const tableName =\n options.tableName?.trim() || defaultTableName(source.fileName)\n return {\n fileName: source.fileName,\n tableName,\n rowCount: source.rowCount,\n skippedRowCount: source.skippedRowCount,\n columns,\n sampleRows: source.sampleRows,\n issues: source.issues,\n }\n}\n\nfunction convertValue(\n value: string,\n type: EidosFileCsvImportColumn[\"type\"],\n rowNumber: number,\n fieldName: string\n): EidosFileRow[string] {\n const trimmed = value.trim()\n if (!trimmed) return null\n if (type === \"number\") {\n const number = Number(trimmed)\n if (!Number.isFinite(number)) {\n throw new EidosFileError(\n \"invalid-csv\",\n `CSV row ${rowNumber}, field “${fieldName}” is not a number`\n )\n }\n return number\n }\n if (type === \"checkbox\") {\n if (!/^(?:true|false)$/i.test(trimmed)) {\n throw new EidosFileError(\n \"invalid-csv\",\n `CSV row ${rowNumber}, field “${fieldName}” is not true or false`\n )\n }\n return /^true$/i.test(trimmed) ? 1 : 0\n }\n if (type === \"date\") {\n if (!isIsoDate(trimmed)) {\n throw new EidosFileError(\n \"invalid-csv\",\n `CSV row ${rowNumber}, field “${fieldName}” is not a YYYY-MM-DD date`\n )\n }\n return trimmed\n }\n if (type === \"datetime\") {\n if (!isIsoDateTime(trimmed)) {\n throw new EidosFileError(\n \"invalid-csv\",\n `CSV row ${rowNumber}, field “${fieldName}” is not an RFC 3339 timestamp`\n )\n }\n return normalizeEidosFileInstant(trimmed, fieldName)\n }\n return value\n}\n\nexport function eidosFileCsvRowToEidosFileRow(\n row: string[],\n rowNumber: number,\n plan: EidosFileCsvImportPlan\n): EidosFileRow {\n return Object.fromEntries(\n plan.columns.map((column) => [\n column.columnName,\n convertValue(\n row[column.sourceIndex] ?? \"\",\n column.type,\n rowNumber,\n column.name\n ),\n ])\n )\n}\n\nexport function parseEidosFileCsvRows(\n file: { name: string; content: string },\n plan: EidosFileCsvImportPlan\n): EidosFileRow[] {\n return parseCsv(file.content).rows.map((row, rowIndex) =>\n eidosFileCsvRowToEidosFileRow(row, rowIndex + 2, plan)\n )\n}\n"],"mappings":";;;AAIA,SAAgB,yBACd,OAC2B;AAC3B,KAAI,OAAO,UAAU,YAAY,MAAM,WAAW,EAAG,QAAO,EAAE;AAC9D,KAAI;EACF,MAAM,SAAkB,KAAK,MAAM,MAAM;AACzC,MAAI,CAAC,MAAM,QAAQ,OAAO,CAAE,QAAO,EAAE;AACrC,SAAO,OAAO,QACX,UACC,UAAU,QACV,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,OAAO,UAAU,UACpB;SACK;AACN,SAAO,EAAE;;;AAIb,SAAgB,2BACd,OACU;AACV,QAAO,yBAAyB,MAAM,CAAC,QACpC,UAA2B,OAAO,UAAU,SAC9C;;AAGH,SAAgB,yBACd,QACQ;AACR,QAAO,KAAK,UAAU,OAAO;;;;ACf/B,MAAa,2BAA2B;CACtC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAKD,MAAM,mBAAmB,IAAI,IAAwB,yBAAyB;AAC9E,MAAM,gBAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAaD,SAAgB,4BACd,MACmC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SAAS,QAAQ;AACnB,MAAI,CAAC,UAAU,QAAQ,CACrB,OAAM,IAAI,eACR,eACA,WAAW,UAAU,WAAW,UAAU,4BAC3C;AAEH,SAAO;;AAET,KAAI,SAAS,YAAY;AACvB,MAAI,CAAC,cAAc,QAAQ,CACzB,OAAM,IAAI,eACR,eACA,WAAW,UAAU,WAAW,UAAU,gCAC3C;AAEH,SAAO,0BAA0B,SAAS,UAAU;;AAEtD,QAAO;;AAGT,SAAgB,8BACd,KACA,WACA,MACc;AACd,QAAO,OAAO,YACZ,KAAK,QAAQ,KAAK,WAAW,CAC3B,OAAO,YACP,aACE,IAAI,OAAO,gBAAgB,IAC3B,OAAO,MACP,WACA,OAAO,KACR,CACF,CAAC,CACH;;AAGH,SAAgB,sBACd,MACA,MACgB;AAChB,QAAO,SAAS,KAAK,QAAQ,CAAC,KAAK,KAAK,KAAK,aAC3C,8BAA8B,KAAK,WAAW,GAAG,KAAK,CACvD"}
|
package/dist/csv.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as EidosFileFieldInfo, J as EidosFileRow, S as EidosFileCsvImportResult, b as EidosFileCsvImportOptions, m as EidosFileCsvExportColumn, t as EidosFileRuntime, x as EidosFileCsvImportPlan, y as EidosFileCsvImportIssue } from "./runtime-DCo5E0Kr.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/csv.d.ts
|
|
4
4
|
declare const EIDOS_FILE_CSV_PREVIEW_ROW_COUNT = 5;
|
package/dist/csv.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csv.d.mts","names":[],"sources":["../src/csv.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"csv.d.mts","names":[],"sources":["../src/csv.ts"],"mappings":";;;cAqBa,gCAAA;AAAA,cACA,kCAAA;AAAA,iBAMG,wBAAA,CAAyB,MAAA;AAAA,iBAIzB,wBAAA,CACd,OAAA,WAAkB,wBAAA;AAAA,iBAKJ,4BAAA,CACd,MAAA,WAAiB,kBAAA,IACjB,OAAA,WAAkB,wBAAA,MAChB,GAAA,EAAK,YAAA;AAAA,iBAqMO,sBAAA,CACd,IAAA;EAAQ,IAAA;EAAc,OAAA;AAAA,GACtB,OAAA,GAAS,yBAAA,GACR,sBAAA;AAAA,iBAQa,yBAAA,CACd,IAAA;EAAQ,IAAA;EAAc,OAAA;AAAA,GACtB,OAAA,GAAS,yBAAA;EACN,IAAA,EAAM,sBAAA;EAAwB,IAAA,EAAM,YAAA;AAAA;AAAA,iBAUzB,kBAAA,CACd,SAAA,EAAW,gBAAA,EACX,IAAA;EAAQ,IAAA;EAAc,OAAA;AAAA,GACtB,OAAA,GAAS,yBAAA,GACR,wBAAA;AAAA,UAyCc,4BAAA;EACf,QAAA;EACA,MAAA;EACA,aAAA;EACA,QAAA;EACA,eAAA;EACA,UAAA;EACA,MAAA,EAAQ,uBAAA;AAAA;AAAA,iBAGM,4BAAA,CACd,MAAA,EAAQ,4BAAA,EACR,OAAA,GAAS,yBAAA,GACR,sBAAA;AAAA,iBAkFa,6BAAA,CACd,GAAA,YACA,SAAA,UACA,IAAA,EAAM,sBAAA,GACL,YAAA;AAAA,iBAca,qBAAA,CACd,IAAA;EAAQ,IAAA;EAAc,OAAA;AAAA,GACtB,IAAA,EAAM,sBAAA,GACL,YAAA"}
|