@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.d.mts
CHANGED
|
@@ -147,6 +147,11 @@ declare const MIME_TYPES: Record<string, string>;
|
|
|
147
147
|
* Returns `application/octet-stream` when the extension is unknown.
|
|
148
148
|
*/
|
|
149
149
|
declare function getMimeType(filePathOrExt: string): string;
|
|
150
|
+
/**
|
|
151
|
+
* Look up the preferred file extension for a MIME type.
|
|
152
|
+
* Returns `.bin` when the MIME type is unknown.
|
|
153
|
+
*/
|
|
154
|
+
declare function getExtension(mimeType: string): string;
|
|
150
155
|
|
|
151
156
|
declare enum ReplicationMethod {
|
|
152
157
|
INCREMENTAL = "INCREMENTAL",
|
|
@@ -792,6 +797,10 @@ type JsonSchemaProperty = {
|
|
|
792
797
|
* Convert a FieldType to a JSON Schema property definition.
|
|
793
798
|
*/
|
|
794
799
|
declare function fieldTypeToJsonSchema(fieldType: FieldType): JsonSchemaProperty;
|
|
800
|
+
/**
|
|
801
|
+
* Coerces a raw cell value to match the declared FieldType at runtime.
|
|
802
|
+
*/
|
|
803
|
+
declare function coerceCellValue(value: unknown, fieldType: FieldType): string | number | null;
|
|
795
804
|
/**
|
|
796
805
|
* Convert an ExcelFieldMapping to a JSON Schema properties object.
|
|
797
806
|
*/
|
|
@@ -846,7 +855,7 @@ declare const createCellReference: (columnIndex: number, rowIndex: number) => st
|
|
|
846
855
|
/**
|
|
847
856
|
* Low-level Excel extractor: returns array of row records from a workbook.
|
|
848
857
|
*/
|
|
849
|
-
declare const extractExcelRows: (localFilePath: string, conf: ExcelExtractionConfig) => Promise<Record<string, string | null>[]>;
|
|
858
|
+
declare const extractExcelRows: (localFilePath: string, conf: ExcelExtractionConfig) => Promise<Record<string, string | number | null>[]>;
|
|
850
859
|
/**
|
|
851
860
|
* Validates an Excel file configuration.
|
|
852
861
|
*/
|
|
@@ -858,7 +867,7 @@ declare const findAllMatchingConfigs: (filename: string, configs: ExcelExtractio
|
|
|
858
867
|
/**
|
|
859
868
|
* Creates an async generator from Excel data.
|
|
860
869
|
*/
|
|
861
|
-
declare function createExcelGenerator(data: Record<string, string | null>[]): AsyncGenerator<Record<string, any>, void, unknown>;
|
|
870
|
+
declare function createExcelGenerator(data: Record<string, string | number | null>[]): AsyncGenerator<Record<string, any>, void, unknown>;
|
|
862
871
|
|
|
863
872
|
/**
|
|
864
873
|
* Builder pattern for creating Excel configurations.
|
|
@@ -1635,4 +1644,4 @@ declare class GCSStateProvider implements StateProvider {
|
|
|
1635
1644
|
writeState(state: string): Promise<void>;
|
|
1636
1645
|
}
|
|
1637
1646
|
|
|
1638
|
-
export { ALL_STREAM_ID_KEYWORD, API_CALLS_METRIC_NAME, type AssetEntry, type AssetManifest, type AssetManifestEntry, type AssetReplicationMode, AssetStream, AssetTap, AssetTarget, Authenticator, BATCH_INTERVAL_MS, type BaseConfig, type BigQueryConfig, BigQueryTarget, type BigqueryLocation, type Bookmark, type Bookmarks, CdnAssetTarget, type CdnAssetTargetConfig, type CdnFileMetadata, CdnService, type CdnServiceConfig, type CdnUploadResult, CloudStorageService, type CloudStorageServiceOptions, type ColumnMappingStoreUnsafeToSafe, CounterMetric, CsvExtractionConfigBuilder, type CsvFieldsArrayConfig, type CsvFieldsConfig, type CsvFieldsDictConfig, type CsvFileConfig, type CsvStreamConfig, DEFAULT_MAX_CONCURRENT_STREAMS, DEFAULT_SYNCED_AT_COLUMN, DocumentDownloadSkipError, type DocumentEntry, type DocumentManifest, type DocumentManifestEntry, type DocumentStatus, DocumentStream, type DocumentStreamManifest, type DocumentSummary, DocumentTap, type DownloadFilesOptions, EXECUTION_TIME_METRIC_NAME, type ErrorType, type ExcelCustomExtractorConfig, type ExcelDerivedField, type ExcelExtractionBaseConfig, type ExcelExtractionConfig, ExcelExtractionConfigBuilder, type ExcelFieldMapping, type ExcelFieldSpec, type ExcelSingleSheetExtractionConfig, type ExcelSourceColumn, type ExcelStreamConfig, type FieldType, FileFormat, FilePatterns, FileStream, type FileStreamConfig, type FileStreamEntry, FileTap, type FileTapConfig, type FlattenedSchema, GCSStateProvider, type GetConfig, type HTTPHeaders, type HTTPMethod, ITarget, ImageTransform, type InputTapState, type InternalTableField, type JSONSchemaFieldDefinition, type ListFilesOptions, MIME_TYPES, type Message, type MessageType, type MetricConfiguration, MissingFieldInSchemaError, MissingSchemaError, type PostConfig, type ProcessedAsset, type ProgressMarkers, type PropertiesMetadata, RESTStream, ROWS_SYNCED_METRIC_NAME, RecordMessage, RenameColumnStore, ReplicationMethod, ReplicationMethodMessage, type SafeColumnNameConverterFn, type Schema, SchemaMessage, SchemaValidationError, SftpService, type State, type StateHolder, StateMessage, type StateProvider, StateService, Stream, type StreamId, type StreamManifest, type StreamState, StreamWarehouseSyncService, type StreamWithTempFile, type SyncOptions, Tap, type TapState, type TargetSchemaHook, type TargetSchemaHookInput, type TempFile, type URLParams, VariableExtractors, type WarehouseTableField, type WebpTransformOptions, type WhalyDocument, WhalyDocumentService, type WhalyDocumentServiceConfig, WhalyDocumentTarget, type WhalyPaginatedResponse, type WhalyUploadResult, type WriteGeneratorToCsvOptions, _greaterThan, addDocumentSummaries, addWhalyFields, checkCsvHeaderRow, collectPaginated, countCsvLines, createCellReference, createCsvStreamConfig, createExcelGenerator, createExcelStreamConfig, createTemporaryFileStream, csvFieldsToJsonSchema, downloadFiles, emptyDocumentSummary, excelColumnToIndex, excelFieldsToJsonSchema, excelRowToIndex, extractExcelRows, extractPrimaryKeysFromCsvConfig, extractPrimaryKeysFromExcelFields, extractStateForStream, fieldTypeToJsonSchema, finalizeStateProgressMarkers, findAllMatchingConfigs, flattenSchema, getAllMetrics, getApiEndpoint, getAxiosInstance, getCdnId, getCounterMetric, getCounterMetrics, getDownloadFileApiCall, getDryRunLimit, getJSONApiCall, getJSONApiCallWithFullResponse, getMimeType, getRawJSONApiCall, getServiceAccountKey, gracefulExit, haltAndCatchFire, incrementStreamState, indexToExcelColumn, indexToExcelRow, isDryRun, listFilesRecursively, loadJson, loadSchema, logger, optionalEnv, parseCellReference, postFormDataApiCall, postJSONApiCall, postUrlEncodedApiCall, printMemoryFootprint, processFileStreams, processFromAsyncIterable, removeParasiteProperties, requireEnv, rowGeneratorFromCsv, runWithConcurrency, safePath, unzip, validateExcelConfig, writeDataToCsv, writeGeneratorToCSV };
|
|
1647
|
+
export { ALL_STREAM_ID_KEYWORD, API_CALLS_METRIC_NAME, type AssetEntry, type AssetManifest, type AssetManifestEntry, type AssetReplicationMode, AssetStream, AssetTap, AssetTarget, Authenticator, BATCH_INTERVAL_MS, type BaseConfig, type BigQueryConfig, BigQueryTarget, type BigqueryLocation, type Bookmark, type Bookmarks, CdnAssetTarget, type CdnAssetTargetConfig, type CdnFileMetadata, CdnService, type CdnServiceConfig, type CdnUploadResult, CloudStorageService, type CloudStorageServiceOptions, type ColumnMappingStoreUnsafeToSafe, CounterMetric, CsvExtractionConfigBuilder, type CsvFieldsArrayConfig, type CsvFieldsConfig, type CsvFieldsDictConfig, type CsvFileConfig, type CsvStreamConfig, DEFAULT_MAX_CONCURRENT_STREAMS, DEFAULT_SYNCED_AT_COLUMN, DocumentDownloadSkipError, type DocumentEntry, type DocumentManifest, type DocumentManifestEntry, type DocumentStatus, DocumentStream, type DocumentStreamManifest, type DocumentSummary, DocumentTap, type DownloadFilesOptions, EXECUTION_TIME_METRIC_NAME, type ErrorType, type ExcelCustomExtractorConfig, type ExcelDerivedField, type ExcelExtractionBaseConfig, type ExcelExtractionConfig, ExcelExtractionConfigBuilder, type ExcelFieldMapping, type ExcelFieldSpec, type ExcelSingleSheetExtractionConfig, type ExcelSourceColumn, type ExcelStreamConfig, type FieldType, FileFormat, FilePatterns, FileStream, type FileStreamConfig, type FileStreamEntry, FileTap, type FileTapConfig, type FlattenedSchema, GCSStateProvider, type GetConfig, type HTTPHeaders, type HTTPMethod, ITarget, ImageTransform, type InputTapState, type InternalTableField, type JSONSchemaFieldDefinition, type ListFilesOptions, MIME_TYPES, type Message, type MessageType, type MetricConfiguration, MissingFieldInSchemaError, MissingSchemaError, type PostConfig, type ProcessedAsset, type ProgressMarkers, type PropertiesMetadata, RESTStream, ROWS_SYNCED_METRIC_NAME, RecordMessage, RenameColumnStore, ReplicationMethod, ReplicationMethodMessage, type SafeColumnNameConverterFn, type Schema, SchemaMessage, SchemaValidationError, SftpService, type State, type StateHolder, StateMessage, type StateProvider, StateService, Stream, type StreamId, type StreamManifest, type StreamState, StreamWarehouseSyncService, type StreamWithTempFile, type SyncOptions, Tap, type TapState, type TargetSchemaHook, type TargetSchemaHookInput, type TempFile, type URLParams, VariableExtractors, type WarehouseTableField, type WebpTransformOptions, type WhalyDocument, WhalyDocumentService, type WhalyDocumentServiceConfig, WhalyDocumentTarget, type WhalyPaginatedResponse, type WhalyUploadResult, type WriteGeneratorToCsvOptions, _greaterThan, addDocumentSummaries, addWhalyFields, checkCsvHeaderRow, coerceCellValue, collectPaginated, countCsvLines, createCellReference, createCsvStreamConfig, createExcelGenerator, createExcelStreamConfig, createTemporaryFileStream, csvFieldsToJsonSchema, downloadFiles, emptyDocumentSummary, excelColumnToIndex, excelFieldsToJsonSchema, excelRowToIndex, extractExcelRows, extractPrimaryKeysFromCsvConfig, extractPrimaryKeysFromExcelFields, extractStateForStream, fieldTypeToJsonSchema, finalizeStateProgressMarkers, findAllMatchingConfigs, flattenSchema, getAllMetrics, getApiEndpoint, getAxiosInstance, getCdnId, getCounterMetric, getCounterMetrics, getDownloadFileApiCall, getDryRunLimit, getExtension, getJSONApiCall, getJSONApiCallWithFullResponse, getMimeType, getRawJSONApiCall, getServiceAccountKey, gracefulExit, haltAndCatchFire, incrementStreamState, indexToExcelColumn, indexToExcelRow, isDryRun, listFilesRecursively, loadJson, loadSchema, logger, optionalEnv, parseCellReference, postFormDataApiCall, postJSONApiCall, postUrlEncodedApiCall, printMemoryFootprint, processFileStreams, processFromAsyncIterable, removeParasiteProperties, requireEnv, rowGeneratorFromCsv, runWithConcurrency, safePath, unzip, validateExcelConfig, writeDataToCsv, writeGeneratorToCSV };
|
package/dist/index.d.ts
CHANGED
|
@@ -147,6 +147,11 @@ declare const MIME_TYPES: Record<string, string>;
|
|
|
147
147
|
* Returns `application/octet-stream` when the extension is unknown.
|
|
148
148
|
*/
|
|
149
149
|
declare function getMimeType(filePathOrExt: string): string;
|
|
150
|
+
/**
|
|
151
|
+
* Look up the preferred file extension for a MIME type.
|
|
152
|
+
* Returns `.bin` when the MIME type is unknown.
|
|
153
|
+
*/
|
|
154
|
+
declare function getExtension(mimeType: string): string;
|
|
150
155
|
|
|
151
156
|
declare enum ReplicationMethod {
|
|
152
157
|
INCREMENTAL = "INCREMENTAL",
|
|
@@ -792,6 +797,10 @@ type JsonSchemaProperty = {
|
|
|
792
797
|
* Convert a FieldType to a JSON Schema property definition.
|
|
793
798
|
*/
|
|
794
799
|
declare function fieldTypeToJsonSchema(fieldType: FieldType): JsonSchemaProperty;
|
|
800
|
+
/**
|
|
801
|
+
* Coerces a raw cell value to match the declared FieldType at runtime.
|
|
802
|
+
*/
|
|
803
|
+
declare function coerceCellValue(value: unknown, fieldType: FieldType): string | number | null;
|
|
795
804
|
/**
|
|
796
805
|
* Convert an ExcelFieldMapping to a JSON Schema properties object.
|
|
797
806
|
*/
|
|
@@ -846,7 +855,7 @@ declare const createCellReference: (columnIndex: number, rowIndex: number) => st
|
|
|
846
855
|
/**
|
|
847
856
|
* Low-level Excel extractor: returns array of row records from a workbook.
|
|
848
857
|
*/
|
|
849
|
-
declare const extractExcelRows: (localFilePath: string, conf: ExcelExtractionConfig) => Promise<Record<string, string | null>[]>;
|
|
858
|
+
declare const extractExcelRows: (localFilePath: string, conf: ExcelExtractionConfig) => Promise<Record<string, string | number | null>[]>;
|
|
850
859
|
/**
|
|
851
860
|
* Validates an Excel file configuration.
|
|
852
861
|
*/
|
|
@@ -858,7 +867,7 @@ declare const findAllMatchingConfigs: (filename: string, configs: ExcelExtractio
|
|
|
858
867
|
/**
|
|
859
868
|
* Creates an async generator from Excel data.
|
|
860
869
|
*/
|
|
861
|
-
declare function createExcelGenerator(data: Record<string, string | null>[]): AsyncGenerator<Record<string, any>, void, unknown>;
|
|
870
|
+
declare function createExcelGenerator(data: Record<string, string | number | null>[]): AsyncGenerator<Record<string, any>, void, unknown>;
|
|
862
871
|
|
|
863
872
|
/**
|
|
864
873
|
* Builder pattern for creating Excel configurations.
|
|
@@ -1635,4 +1644,4 @@ declare class GCSStateProvider implements StateProvider {
|
|
|
1635
1644
|
writeState(state: string): Promise<void>;
|
|
1636
1645
|
}
|
|
1637
1646
|
|
|
1638
|
-
export { ALL_STREAM_ID_KEYWORD, API_CALLS_METRIC_NAME, type AssetEntry, type AssetManifest, type AssetManifestEntry, type AssetReplicationMode, AssetStream, AssetTap, AssetTarget, Authenticator, BATCH_INTERVAL_MS, type BaseConfig, type BigQueryConfig, BigQueryTarget, type BigqueryLocation, type Bookmark, type Bookmarks, CdnAssetTarget, type CdnAssetTargetConfig, type CdnFileMetadata, CdnService, type CdnServiceConfig, type CdnUploadResult, CloudStorageService, type CloudStorageServiceOptions, type ColumnMappingStoreUnsafeToSafe, CounterMetric, CsvExtractionConfigBuilder, type CsvFieldsArrayConfig, type CsvFieldsConfig, type CsvFieldsDictConfig, type CsvFileConfig, type CsvStreamConfig, DEFAULT_MAX_CONCURRENT_STREAMS, DEFAULT_SYNCED_AT_COLUMN, DocumentDownloadSkipError, type DocumentEntry, type DocumentManifest, type DocumentManifestEntry, type DocumentStatus, DocumentStream, type DocumentStreamManifest, type DocumentSummary, DocumentTap, type DownloadFilesOptions, EXECUTION_TIME_METRIC_NAME, type ErrorType, type ExcelCustomExtractorConfig, type ExcelDerivedField, type ExcelExtractionBaseConfig, type ExcelExtractionConfig, ExcelExtractionConfigBuilder, type ExcelFieldMapping, type ExcelFieldSpec, type ExcelSingleSheetExtractionConfig, type ExcelSourceColumn, type ExcelStreamConfig, type FieldType, FileFormat, FilePatterns, FileStream, type FileStreamConfig, type FileStreamEntry, FileTap, type FileTapConfig, type FlattenedSchema, GCSStateProvider, type GetConfig, type HTTPHeaders, type HTTPMethod, ITarget, ImageTransform, type InputTapState, type InternalTableField, type JSONSchemaFieldDefinition, type ListFilesOptions, MIME_TYPES, type Message, type MessageType, type MetricConfiguration, MissingFieldInSchemaError, MissingSchemaError, type PostConfig, type ProcessedAsset, type ProgressMarkers, type PropertiesMetadata, RESTStream, ROWS_SYNCED_METRIC_NAME, RecordMessage, RenameColumnStore, ReplicationMethod, ReplicationMethodMessage, type SafeColumnNameConverterFn, type Schema, SchemaMessage, SchemaValidationError, SftpService, type State, type StateHolder, StateMessage, type StateProvider, StateService, Stream, type StreamId, type StreamManifest, type StreamState, StreamWarehouseSyncService, type StreamWithTempFile, type SyncOptions, Tap, type TapState, type TargetSchemaHook, type TargetSchemaHookInput, type TempFile, type URLParams, VariableExtractors, type WarehouseTableField, type WebpTransformOptions, type WhalyDocument, WhalyDocumentService, type WhalyDocumentServiceConfig, WhalyDocumentTarget, type WhalyPaginatedResponse, type WhalyUploadResult, type WriteGeneratorToCsvOptions, _greaterThan, addDocumentSummaries, addWhalyFields, checkCsvHeaderRow, collectPaginated, countCsvLines, createCellReference, createCsvStreamConfig, createExcelGenerator, createExcelStreamConfig, createTemporaryFileStream, csvFieldsToJsonSchema, downloadFiles, emptyDocumentSummary, excelColumnToIndex, excelFieldsToJsonSchema, excelRowToIndex, extractExcelRows, extractPrimaryKeysFromCsvConfig, extractPrimaryKeysFromExcelFields, extractStateForStream, fieldTypeToJsonSchema, finalizeStateProgressMarkers, findAllMatchingConfigs, flattenSchema, getAllMetrics, getApiEndpoint, getAxiosInstance, getCdnId, getCounterMetric, getCounterMetrics, getDownloadFileApiCall, getDryRunLimit, getJSONApiCall, getJSONApiCallWithFullResponse, getMimeType, getRawJSONApiCall, getServiceAccountKey, gracefulExit, haltAndCatchFire, incrementStreamState, indexToExcelColumn, indexToExcelRow, isDryRun, listFilesRecursively, loadJson, loadSchema, logger, optionalEnv, parseCellReference, postFormDataApiCall, postJSONApiCall, postUrlEncodedApiCall, printMemoryFootprint, processFileStreams, processFromAsyncIterable, removeParasiteProperties, requireEnv, rowGeneratorFromCsv, runWithConcurrency, safePath, unzip, validateExcelConfig, writeDataToCsv, writeGeneratorToCSV };
|
|
1647
|
+
export { ALL_STREAM_ID_KEYWORD, API_CALLS_METRIC_NAME, type AssetEntry, type AssetManifest, type AssetManifestEntry, type AssetReplicationMode, AssetStream, AssetTap, AssetTarget, Authenticator, BATCH_INTERVAL_MS, type BaseConfig, type BigQueryConfig, BigQueryTarget, type BigqueryLocation, type Bookmark, type Bookmarks, CdnAssetTarget, type CdnAssetTargetConfig, type CdnFileMetadata, CdnService, type CdnServiceConfig, type CdnUploadResult, CloudStorageService, type CloudStorageServiceOptions, type ColumnMappingStoreUnsafeToSafe, CounterMetric, CsvExtractionConfigBuilder, type CsvFieldsArrayConfig, type CsvFieldsConfig, type CsvFieldsDictConfig, type CsvFileConfig, type CsvStreamConfig, DEFAULT_MAX_CONCURRENT_STREAMS, DEFAULT_SYNCED_AT_COLUMN, DocumentDownloadSkipError, type DocumentEntry, type DocumentManifest, type DocumentManifestEntry, type DocumentStatus, DocumentStream, type DocumentStreamManifest, type DocumentSummary, DocumentTap, type DownloadFilesOptions, EXECUTION_TIME_METRIC_NAME, type ErrorType, type ExcelCustomExtractorConfig, type ExcelDerivedField, type ExcelExtractionBaseConfig, type ExcelExtractionConfig, ExcelExtractionConfigBuilder, type ExcelFieldMapping, type ExcelFieldSpec, type ExcelSingleSheetExtractionConfig, type ExcelSourceColumn, type ExcelStreamConfig, type FieldType, FileFormat, FilePatterns, FileStream, type FileStreamConfig, type FileStreamEntry, FileTap, type FileTapConfig, type FlattenedSchema, GCSStateProvider, type GetConfig, type HTTPHeaders, type HTTPMethod, ITarget, ImageTransform, type InputTapState, type InternalTableField, type JSONSchemaFieldDefinition, type ListFilesOptions, MIME_TYPES, type Message, type MessageType, type MetricConfiguration, MissingFieldInSchemaError, MissingSchemaError, type PostConfig, type ProcessedAsset, type ProgressMarkers, type PropertiesMetadata, RESTStream, ROWS_SYNCED_METRIC_NAME, RecordMessage, RenameColumnStore, ReplicationMethod, ReplicationMethodMessage, type SafeColumnNameConverterFn, type Schema, SchemaMessage, SchemaValidationError, SftpService, type State, type StateHolder, StateMessage, type StateProvider, StateService, Stream, type StreamId, type StreamManifest, type StreamState, StreamWarehouseSyncService, type StreamWithTempFile, type SyncOptions, Tap, type TapState, type TargetSchemaHook, type TargetSchemaHookInput, type TempFile, type URLParams, VariableExtractors, type WarehouseTableField, type WebpTransformOptions, type WhalyDocument, WhalyDocumentService, type WhalyDocumentServiceConfig, WhalyDocumentTarget, type WhalyPaginatedResponse, type WhalyUploadResult, type WriteGeneratorToCsvOptions, _greaterThan, addDocumentSummaries, addWhalyFields, checkCsvHeaderRow, coerceCellValue, collectPaginated, countCsvLines, createCellReference, createCsvStreamConfig, createExcelGenerator, createExcelStreamConfig, createTemporaryFileStream, csvFieldsToJsonSchema, downloadFiles, emptyDocumentSummary, excelColumnToIndex, excelFieldsToJsonSchema, excelRowToIndex, extractExcelRows, extractPrimaryKeysFromCsvConfig, extractPrimaryKeysFromExcelFields, extractStateForStream, fieldTypeToJsonSchema, finalizeStateProgressMarkers, findAllMatchingConfigs, flattenSchema, getAllMetrics, getApiEndpoint, getAxiosInstance, getCdnId, getCounterMetric, getCounterMetrics, getDownloadFileApiCall, getDryRunLimit, getExtension, getJSONApiCall, getJSONApiCallWithFullResponse, getMimeType, getRawJSONApiCall, getServiceAccountKey, gracefulExit, haltAndCatchFire, incrementStreamState, indexToExcelColumn, indexToExcelRow, isDryRun, listFilesRecursively, loadJson, loadSchema, logger, optionalEnv, parseCellReference, postFormDataApiCall, postJSONApiCall, postUrlEncodedApiCall, printMemoryFootprint, processFileStreams, processFromAsyncIterable, removeParasiteProperties, requireEnv, rowGeneratorFromCsv, runWithConcurrency, safePath, unzip, validateExcelConfig, writeDataToCsv, writeGeneratorToCSV };
|
package/dist/index.js
CHANGED
|
@@ -10367,6 +10367,7 @@ __export(index_exports, {
|
|
|
10367
10367
|
addDocumentSummaries: () => addDocumentSummaries,
|
|
10368
10368
|
addWhalyFields: () => addWhalyFields,
|
|
10369
10369
|
checkCsvHeaderRow: () => checkCsvHeaderRow,
|
|
10370
|
+
coerceCellValue: () => coerceCellValue,
|
|
10370
10371
|
collectPaginated: () => collectPaginated,
|
|
10371
10372
|
countCsvLines: () => countCsvLines,
|
|
10372
10373
|
createCellReference: () => createCellReference,
|
|
@@ -10396,6 +10397,7 @@ __export(index_exports, {
|
|
|
10396
10397
|
getCounterMetrics: () => getCounterMetrics,
|
|
10397
10398
|
getDownloadFileApiCall: () => getDownloadFileApiCall,
|
|
10398
10399
|
getDryRunLimit: () => getDryRunLimit,
|
|
10400
|
+
getExtension: () => getExtension,
|
|
10399
10401
|
getJSONApiCall: () => getJSONApiCall,
|
|
10400
10402
|
getJSONApiCallWithFullResponse: () => getJSONApiCallWithFullResponse,
|
|
10401
10403
|
getMimeType: () => getMimeType,
|
|
@@ -10972,6 +10974,16 @@ function getMimeType(filePathOrExt) {
|
|
|
10972
10974
|
const ext = filePathOrExt.startsWith(".") ? filePathOrExt.toLowerCase() : import_node_path.default.extname(filePathOrExt).toLowerCase();
|
|
10973
10975
|
return MIME_TYPES[ext] ?? "application/octet-stream";
|
|
10974
10976
|
}
|
|
10977
|
+
var EXTENSION_BY_MIME = Object.entries(MIME_TYPES).reduce(
|
|
10978
|
+
(acc, [ext, mime]) => {
|
|
10979
|
+
if (!acc[mime]) acc[mime] = ext;
|
|
10980
|
+
return acc;
|
|
10981
|
+
},
|
|
10982
|
+
{}
|
|
10983
|
+
);
|
|
10984
|
+
function getExtension(mimeType) {
|
|
10985
|
+
return EXTENSION_BY_MIME[mimeType] ?? ".bin";
|
|
10986
|
+
}
|
|
10975
10987
|
|
|
10976
10988
|
// src/sdk/models/replication.ts
|
|
10977
10989
|
var ReplicationMethod = /* @__PURE__ */ ((ReplicationMethod2) => {
|
|
@@ -12843,6 +12855,31 @@ function fieldTypeToJsonSchema(fieldType) {
|
|
|
12843
12855
|
return { type: ["null", "string"] };
|
|
12844
12856
|
}
|
|
12845
12857
|
}
|
|
12858
|
+
function coerceCellValue(value, fieldType) {
|
|
12859
|
+
if (value === null || value === void 0) {
|
|
12860
|
+
return null;
|
|
12861
|
+
}
|
|
12862
|
+
switch (fieldType) {
|
|
12863
|
+
case "STRING":
|
|
12864
|
+
return String(value);
|
|
12865
|
+
case "FLOAT": {
|
|
12866
|
+
if (typeof value === "number") return value;
|
|
12867
|
+
if (typeof value === "boolean") return value ? 1 : 0;
|
|
12868
|
+
if (typeof value === "string") {
|
|
12869
|
+
const parsed = Number(value);
|
|
12870
|
+
return isNaN(parsed) ? null : parsed;
|
|
12871
|
+
}
|
|
12872
|
+
return null;
|
|
12873
|
+
}
|
|
12874
|
+
case "TIMESTAMP": {
|
|
12875
|
+
if (value instanceof Date) return value.toISOString();
|
|
12876
|
+
if (typeof value === "string") return value === "" ? null : value;
|
|
12877
|
+
return String(value);
|
|
12878
|
+
}
|
|
12879
|
+
default:
|
|
12880
|
+
return String(value);
|
|
12881
|
+
}
|
|
12882
|
+
}
|
|
12846
12883
|
function excelFieldsToJsonSchema(fields) {
|
|
12847
12884
|
const properties = {};
|
|
12848
12885
|
for (const [key, field] of Object.entries(fields)) {
|
|
@@ -12970,10 +13007,10 @@ var extractSingleSheetRows = async (fileName, conf) => {
|
|
|
12970
13007
|
if (!variables) {
|
|
12971
13008
|
throw new Error(`No variables extracted from filename, cannot extract derived field ${key}`);
|
|
12972
13009
|
}
|
|
12973
|
-
acc[key] = variables[column.variableName]
|
|
13010
|
+
acc[key] = variables[column.variableName] ?? null;
|
|
12974
13011
|
} else {
|
|
12975
13012
|
const colIndex = excelColumnToIndex(column.column);
|
|
12976
|
-
acc[key] = row[colIndex]?.v
|
|
13013
|
+
acc[key] = coerceCellValue(row[colIndex]?.v, column.type);
|
|
12977
13014
|
}
|
|
12978
13015
|
return acc;
|
|
12979
13016
|
}, {});
|
|
@@ -13198,7 +13235,7 @@ async function* rowGeneratorFromCsv(path8, fileConfig) {
|
|
|
13198
13235
|
const keyGenerator = fileConfig.fields[key.trim()];
|
|
13199
13236
|
if (!keyGenerator) continue;
|
|
13200
13237
|
const rawValue = keyGenerator.valueTransformer ? keyGenerator.valueTransformer(row[key]) : row[key];
|
|
13201
|
-
rowData[keyGenerator.key] = rawValue === "" ? null : rawValue;
|
|
13238
|
+
rowData[keyGenerator.key] = rawValue === "" ? null : coerceCellValue(rawValue, keyGenerator.type);
|
|
13202
13239
|
}
|
|
13203
13240
|
yield rowData;
|
|
13204
13241
|
} else {
|
|
@@ -13208,7 +13245,7 @@ async function* rowGeneratorFromCsv(path8, fileConfig) {
|
|
|
13208
13245
|
const keyGenerator = fileConfig.fields[i];
|
|
13209
13246
|
if (!keyGenerator) continue;
|
|
13210
13247
|
const rawValue = keyGenerator.valueTransformer ? keyGenerator.valueTransformer(row[i]) : row[i];
|
|
13211
|
-
rowData[keyGenerator.key] = rawValue === "" ? null : rawValue;
|
|
13248
|
+
rowData[keyGenerator.key] = rawValue === "" ? null : coerceCellValue(rawValue, keyGenerator.type);
|
|
13212
13249
|
}
|
|
13213
13250
|
yield rowData;
|
|
13214
13251
|
}
|
|
@@ -14148,6 +14185,13 @@ var AssetTap = class {
|
|
|
14148
14185
|
const inspectPath = import_node_path4.default.join(this.outputDir, stream.streamId, entry.destinationPath);
|
|
14149
14186
|
await import_fs_extra4.default.ensureDir(import_node_path4.default.dirname(inspectPath));
|
|
14150
14187
|
await import_fs_extra4.default.copy(uploadPath, inspectPath);
|
|
14188
|
+
if (wasTransformed) {
|
|
14189
|
+
const baseName = import_node_path4.default.basename(entry.destinationPath, import_node_path4.default.extname(entry.destinationPath));
|
|
14190
|
+
const origExt = getExtension(entry.contentType);
|
|
14191
|
+
const originalPath = import_node_path4.default.join(this.outputDir, "originals", `${baseName}${origExt}`);
|
|
14192
|
+
await import_fs_extra4.default.ensureDir(import_node_path4.default.dirname(originalPath));
|
|
14193
|
+
await import_fs_extra4.default.copy(downloadedPath, originalPath);
|
|
14194
|
+
}
|
|
14151
14195
|
}
|
|
14152
14196
|
assetEntries.push({
|
|
14153
14197
|
sourcePath: entry.sourcePath,
|
|
@@ -15538,6 +15582,7 @@ var GCSStateProvider = class {
|
|
|
15538
15582
|
addDocumentSummaries,
|
|
15539
15583
|
addWhalyFields,
|
|
15540
15584
|
checkCsvHeaderRow,
|
|
15585
|
+
coerceCellValue,
|
|
15541
15586
|
collectPaginated,
|
|
15542
15587
|
countCsvLines,
|
|
15543
15588
|
createCellReference,
|
|
@@ -15567,6 +15612,7 @@ var GCSStateProvider = class {
|
|
|
15567
15612
|
getCounterMetrics,
|
|
15568
15613
|
getDownloadFileApiCall,
|
|
15569
15614
|
getDryRunLimit,
|
|
15615
|
+
getExtension,
|
|
15570
15616
|
getJSONApiCall,
|
|
15571
15617
|
getJSONApiCallWithFullResponse,
|
|
15572
15618
|
getMimeType,
|