@whaly/connector-sdk 0.3.8 → 0.3.10
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/dist/index.d.mts +12 -3
- package/dist/index.d.ts +12 -3
- package/dist/index.js +50 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -10853,6 +10853,16 @@ function getMimeType(filePathOrExt) {
|
|
|
10853
10853
|
const ext = filePathOrExt.startsWith(".") ? filePathOrExt.toLowerCase() : path.extname(filePathOrExt).toLowerCase();
|
|
10854
10854
|
return MIME_TYPES[ext] ?? "application/octet-stream";
|
|
10855
10855
|
}
|
|
10856
|
+
var EXTENSION_BY_MIME = Object.entries(MIME_TYPES).reduce(
|
|
10857
|
+
(acc, [ext, mime]) => {
|
|
10858
|
+
if (!acc[mime]) acc[mime] = ext;
|
|
10859
|
+
return acc;
|
|
10860
|
+
},
|
|
10861
|
+
{}
|
|
10862
|
+
);
|
|
10863
|
+
function getExtension(mimeType) {
|
|
10864
|
+
return EXTENSION_BY_MIME[mimeType] ?? ".bin";
|
|
10865
|
+
}
|
|
10856
10866
|
|
|
10857
10867
|
// src/sdk/models/replication.ts
|
|
10858
10868
|
var ReplicationMethod = /* @__PURE__ */ ((ReplicationMethod2) => {
|
|
@@ -12724,6 +12734,31 @@ function fieldTypeToJsonSchema(fieldType) {
|
|
|
12724
12734
|
return { type: ["null", "string"] };
|
|
12725
12735
|
}
|
|
12726
12736
|
}
|
|
12737
|
+
function coerceCellValue(value, fieldType) {
|
|
12738
|
+
if (value === null || value === void 0) {
|
|
12739
|
+
return null;
|
|
12740
|
+
}
|
|
12741
|
+
switch (fieldType) {
|
|
12742
|
+
case "STRING":
|
|
12743
|
+
return String(value);
|
|
12744
|
+
case "FLOAT": {
|
|
12745
|
+
if (typeof value === "number") return value;
|
|
12746
|
+
if (typeof value === "boolean") return value ? 1 : 0;
|
|
12747
|
+
if (typeof value === "string") {
|
|
12748
|
+
const parsed = Number(value);
|
|
12749
|
+
return isNaN(parsed) ? null : parsed;
|
|
12750
|
+
}
|
|
12751
|
+
return null;
|
|
12752
|
+
}
|
|
12753
|
+
case "TIMESTAMP": {
|
|
12754
|
+
if (value instanceof Date) return value.toISOString();
|
|
12755
|
+
if (typeof value === "string") return value === "" ? null : value;
|
|
12756
|
+
return String(value);
|
|
12757
|
+
}
|
|
12758
|
+
default:
|
|
12759
|
+
return String(value);
|
|
12760
|
+
}
|
|
12761
|
+
}
|
|
12727
12762
|
function excelFieldsToJsonSchema(fields) {
|
|
12728
12763
|
const properties = {};
|
|
12729
12764
|
for (const [key, field] of Object.entries(fields)) {
|
|
@@ -12851,10 +12886,10 @@ var extractSingleSheetRows = async (fileName, conf) => {
|
|
|
12851
12886
|
if (!variables) {
|
|
12852
12887
|
throw new Error(`No variables extracted from filename, cannot extract derived field ${key}`);
|
|
12853
12888
|
}
|
|
12854
|
-
acc[key] = variables[column.variableName]
|
|
12889
|
+
acc[key] = variables[column.variableName] ?? null;
|
|
12855
12890
|
} else {
|
|
12856
12891
|
const colIndex = excelColumnToIndex(column.column);
|
|
12857
|
-
acc[key] = row[colIndex]?.v
|
|
12892
|
+
acc[key] = coerceCellValue(row[colIndex]?.v, column.type);
|
|
12858
12893
|
}
|
|
12859
12894
|
return acc;
|
|
12860
12895
|
}, {});
|
|
@@ -13079,7 +13114,7 @@ async function* rowGeneratorFromCsv(path8, fileConfig) {
|
|
|
13079
13114
|
const keyGenerator = fileConfig.fields[key.trim()];
|
|
13080
13115
|
if (!keyGenerator) continue;
|
|
13081
13116
|
const rawValue = keyGenerator.valueTransformer ? keyGenerator.valueTransformer(row[key]) : row[key];
|
|
13082
|
-
rowData[keyGenerator.key] = rawValue === "" ? null : rawValue;
|
|
13117
|
+
rowData[keyGenerator.key] = rawValue === "" ? null : coerceCellValue(rawValue, keyGenerator.type);
|
|
13083
13118
|
}
|
|
13084
13119
|
yield rowData;
|
|
13085
13120
|
} else {
|
|
@@ -13089,7 +13124,7 @@ async function* rowGeneratorFromCsv(path8, fileConfig) {
|
|
|
13089
13124
|
const keyGenerator = fileConfig.fields[i];
|
|
13090
13125
|
if (!keyGenerator) continue;
|
|
13091
13126
|
const rawValue = keyGenerator.valueTransformer ? keyGenerator.valueTransformer(row[i]) : row[i];
|
|
13092
|
-
rowData[keyGenerator.key] = rawValue === "" ? null : rawValue;
|
|
13127
|
+
rowData[keyGenerator.key] = rawValue === "" ? null : coerceCellValue(rawValue, keyGenerator.type);
|
|
13093
13128
|
}
|
|
13094
13129
|
yield rowData;
|
|
13095
13130
|
}
|
|
@@ -14029,6 +14064,13 @@ var AssetTap = class {
|
|
|
14029
14064
|
const inspectPath = path5.join(this.outputDir, stream.streamId, entry.destinationPath);
|
|
14030
14065
|
await fs6.ensureDir(path5.dirname(inspectPath));
|
|
14031
14066
|
await fs6.copy(uploadPath, inspectPath);
|
|
14067
|
+
if (wasTransformed) {
|
|
14068
|
+
const baseName = path5.basename(entry.destinationPath, path5.extname(entry.destinationPath));
|
|
14069
|
+
const origExt = getExtension(entry.contentType);
|
|
14070
|
+
const originalPath = path5.join(this.outputDir, "originals", `${baseName}${origExt}`);
|
|
14071
|
+
await fs6.ensureDir(path5.dirname(originalPath));
|
|
14072
|
+
await fs6.copy(downloadedPath, originalPath);
|
|
14073
|
+
}
|
|
14032
14074
|
}
|
|
14033
14075
|
assetEntries.push({
|
|
14034
14076
|
sourcePath: entry.sourcePath,
|
|
@@ -15418,6 +15460,7 @@ export {
|
|
|
15418
15460
|
addDocumentSummaries,
|
|
15419
15461
|
addWhalyFields,
|
|
15420
15462
|
checkCsvHeaderRow,
|
|
15463
|
+
coerceCellValue,
|
|
15421
15464
|
collectPaginated,
|
|
15422
15465
|
countCsvLines,
|
|
15423
15466
|
createCellReference,
|
|
@@ -15447,6 +15490,7 @@ export {
|
|
|
15447
15490
|
getCounterMetrics,
|
|
15448
15491
|
getDownloadFileApiCall,
|
|
15449
15492
|
getDryRunLimit,
|
|
15493
|
+
getExtension,
|
|
15450
15494
|
getJSONApiCall,
|
|
15451
15495
|
getJSONApiCallWithFullResponse,
|
|
15452
15496
|
getMimeType,
|