@whaly/connector-sdk 0.3.1 → 0.3.3
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 +7 -8
- package/dist/index.d.ts +7 -8
- package/dist/index.js +21 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -187,10 +187,12 @@ interface StreamWithTempFile {
|
|
|
187
187
|
streamId: StreamId;
|
|
188
188
|
tempFile: TempFile;
|
|
189
189
|
}
|
|
190
|
+
declare const DEFAULT_SYNCED_AT_COLUMN = "_wly_synced_at";
|
|
190
191
|
interface BaseConfig {
|
|
191
192
|
connector_id: string;
|
|
192
193
|
database: string;
|
|
193
194
|
schema: string;
|
|
195
|
+
syncedAtColumnName?: string;
|
|
194
196
|
}
|
|
195
197
|
|
|
196
198
|
interface ColumnMappingStoreUnsafeToSafe {
|
|
@@ -302,6 +304,7 @@ interface StateProvider {
|
|
|
302
304
|
|
|
303
305
|
declare abstract class ITarget<C extends BaseConfig = BaseConfig> {
|
|
304
306
|
config: C;
|
|
307
|
+
syncedAtColumnName: string;
|
|
305
308
|
schemaHooks: TargetSchemaHook[];
|
|
306
309
|
syncTime: Dayjs;
|
|
307
310
|
stateProvider: StateProvider;
|
|
@@ -612,7 +615,7 @@ declare class MissingSchemaError extends Error {
|
|
|
612
615
|
}
|
|
613
616
|
|
|
614
617
|
declare const removeParasiteProperties: (record: any, schema: FlattenedSchema) => any;
|
|
615
|
-
declare const addWhalyFields: (record: any, batchDate: string) => any;
|
|
618
|
+
declare const addWhalyFields: (record: any, batchDate: string, columnName?: string) => any;
|
|
616
619
|
|
|
617
620
|
declare const flattenSchema: <T>(streamId: StreamId, schema: T) => FlattenedSchema;
|
|
618
621
|
|
|
@@ -682,7 +685,6 @@ interface CsvFileConfig {
|
|
|
682
685
|
encoding?: string;
|
|
683
686
|
separator: string;
|
|
684
687
|
fields: CsvFieldsConfig;
|
|
685
|
-
addSyncedAtColumn?: boolean;
|
|
686
688
|
}
|
|
687
689
|
interface FileStreamBaseConfig {
|
|
688
690
|
streamId: string;
|
|
@@ -765,7 +767,7 @@ declare const createCellReference: (columnIndex: number, rowIndex: number) => st
|
|
|
765
767
|
/**
|
|
766
768
|
* Low-level Excel extractor: returns array of row records from a workbook.
|
|
767
769
|
*/
|
|
768
|
-
declare const extractExcelRows: (localFilePath: string, conf: ExcelExtractionConfig) => Promise<Record<string, string>[]>;
|
|
770
|
+
declare const extractExcelRows: (localFilePath: string, conf: ExcelExtractionConfig) => Promise<Record<string, string | null>[]>;
|
|
769
771
|
/**
|
|
770
772
|
* Validates an Excel file configuration.
|
|
771
773
|
*/
|
|
@@ -777,7 +779,7 @@ declare const findAllMatchingConfigs: (filename: string, configs: ExcelExtractio
|
|
|
777
779
|
/**
|
|
778
780
|
* Creates an async generator from Excel data.
|
|
779
781
|
*/
|
|
780
|
-
declare function createExcelGenerator(data: Record<string, string>[]): AsyncGenerator<Record<string, any>, void, unknown>;
|
|
782
|
+
declare function createExcelGenerator(data: Record<string, string | null>[]): AsyncGenerator<Record<string, any>, void, unknown>;
|
|
781
783
|
|
|
782
784
|
/**
|
|
783
785
|
* Builder pattern for creating Excel configurations.
|
|
@@ -839,7 +841,6 @@ declare const writeGeneratorToCSV: (generator: AsyncGenerator, outputFileName: s
|
|
|
839
841
|
* const config = CsvExtractionConfigBuilder.create()
|
|
840
842
|
* .separator(";")
|
|
841
843
|
* .encoding("latin1")
|
|
842
|
-
* .addSyncedAtColumn()
|
|
843
844
|
* .fieldsFromDict({
|
|
844
845
|
* "Product ID": { key: "product_id", type: "STRING" },
|
|
845
846
|
* "Product Name": { key: "product_name", type: "STRING" },
|
|
@@ -851,7 +852,6 @@ declare const writeGeneratorToCSV: (generator: AsyncGenerator, outputFileName: s
|
|
|
851
852
|
declare class CsvExtractionConfigBuilder {
|
|
852
853
|
private _separator;
|
|
853
854
|
private _encoding?;
|
|
854
|
-
private _addSyncedAtColumn?;
|
|
855
855
|
private _fields?;
|
|
856
856
|
private _fieldsMode?;
|
|
857
857
|
private _replicationMethod?;
|
|
@@ -859,7 +859,6 @@ declare class CsvExtractionConfigBuilder {
|
|
|
859
859
|
static create(): CsvExtractionConfigBuilder;
|
|
860
860
|
separator(sep: string): CsvExtractionConfigBuilder;
|
|
861
861
|
encoding(enc: string): CsvExtractionConfigBuilder;
|
|
862
|
-
addSyncedAtColumn(enabled?: boolean): CsvExtractionConfigBuilder;
|
|
863
862
|
fieldsFromDict(mapping: {
|
|
864
863
|
[header: string]: {
|
|
865
864
|
key: string;
|
|
@@ -1143,4 +1142,4 @@ declare class GCSStateProvider implements StateProvider {
|
|
|
1143
1142
|
writeState(state: string): Promise<void>;
|
|
1144
1143
|
}
|
|
1145
1144
|
|
|
1146
|
-
export { ALL_STREAM_ID_KEYWORD, API_CALLS_METRIC_NAME, Authenticator, BATCH_INTERVAL_MS, type BaseConfig, type BigQueryConfig, BigQueryTarget, type BigqueryLocation, type Bookmark, type Bookmarks, CloudStorageService, type CloudStorageServiceOptions, type ColumnMappingStoreUnsafeToSafe, CounterMetric, CsvExtractionConfigBuilder, type CsvFieldsArrayConfig, type CsvFieldsConfig, type CsvFieldsDictConfig, type CsvFileConfig, type CsvStreamConfig, DEFAULT_MAX_CONCURRENT_STREAMS, 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, type InputTapState, type InternalTableField, type JSONSchemaFieldDefinition, type Message, type MessageType, type MetricConfiguration, MissingFieldInSchemaError, MissingSchemaError, type PostConfig, 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 StreamState, StreamWarehouseSyncService, type StreamWithTempFile, type SyncOptions, Tap, type TapState, type TargetSchemaHook, type TargetSchemaHookInput, type TempFile, type URLParams, VariableExtractors, type WarehouseTableField, _greaterThan, addWhalyFields, checkCsvHeaderRow, countCsvLines, createCellReference, createCsvStreamConfig, createExcelGenerator, createExcelStreamConfig, createTemporaryFileStream, csvFieldsToJsonSchema, excelColumnToIndex, excelFieldsToJsonSchema, excelRowToIndex, extractExcelRows, extractPrimaryKeysFromCsvConfig, extractPrimaryKeysFromExcelFields, extractStateForStream, fieldTypeToJsonSchema, finalizeStateProgressMarkers, findAllMatchingConfigs, flattenSchema, getAllMetrics, getAxiosInstance, getCounterMetric, getCounterMetrics, getDownloadFileApiCall, getJSONApiCall, getJSONApiCallWithFullResponse, getRawJSONApiCall, gracefulExit, haltAndCatchFire, incrementStreamState, indexToExcelColumn, indexToExcelRow, loadJson, loadSchema, logger, parseCellReference, postFormDataApiCall, postJSONApiCall, postUrlEncodedApiCall, printMemoryFootprint, processFileStreams, removeParasiteProperties, rowGeneratorFromCsv, safePath, unzip, validateExcelConfig, writeDataToCsv, writeGeneratorToCSV };
|
|
1145
|
+
export { ALL_STREAM_ID_KEYWORD, API_CALLS_METRIC_NAME, Authenticator, BATCH_INTERVAL_MS, type BaseConfig, type BigQueryConfig, BigQueryTarget, type BigqueryLocation, type Bookmark, type Bookmarks, 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, 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, type InputTapState, type InternalTableField, type JSONSchemaFieldDefinition, type Message, type MessageType, type MetricConfiguration, MissingFieldInSchemaError, MissingSchemaError, type PostConfig, 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 StreamState, StreamWarehouseSyncService, type StreamWithTempFile, type SyncOptions, Tap, type TapState, type TargetSchemaHook, type TargetSchemaHookInput, type TempFile, type URLParams, VariableExtractors, type WarehouseTableField, _greaterThan, addWhalyFields, checkCsvHeaderRow, countCsvLines, createCellReference, createCsvStreamConfig, createExcelGenerator, createExcelStreamConfig, createTemporaryFileStream, csvFieldsToJsonSchema, excelColumnToIndex, excelFieldsToJsonSchema, excelRowToIndex, extractExcelRows, extractPrimaryKeysFromCsvConfig, extractPrimaryKeysFromExcelFields, extractStateForStream, fieldTypeToJsonSchema, finalizeStateProgressMarkers, findAllMatchingConfigs, flattenSchema, getAllMetrics, getAxiosInstance, getCounterMetric, getCounterMetrics, getDownloadFileApiCall, getJSONApiCall, getJSONApiCallWithFullResponse, getRawJSONApiCall, gracefulExit, haltAndCatchFire, incrementStreamState, indexToExcelColumn, indexToExcelRow, loadJson, loadSchema, logger, parseCellReference, postFormDataApiCall, postJSONApiCall, postUrlEncodedApiCall, printMemoryFootprint, processFileStreams, removeParasiteProperties, rowGeneratorFromCsv, safePath, unzip, validateExcelConfig, writeDataToCsv, writeGeneratorToCSV };
|
package/dist/index.d.ts
CHANGED
|
@@ -187,10 +187,12 @@ interface StreamWithTempFile {
|
|
|
187
187
|
streamId: StreamId;
|
|
188
188
|
tempFile: TempFile;
|
|
189
189
|
}
|
|
190
|
+
declare const DEFAULT_SYNCED_AT_COLUMN = "_wly_synced_at";
|
|
190
191
|
interface BaseConfig {
|
|
191
192
|
connector_id: string;
|
|
192
193
|
database: string;
|
|
193
194
|
schema: string;
|
|
195
|
+
syncedAtColumnName?: string;
|
|
194
196
|
}
|
|
195
197
|
|
|
196
198
|
interface ColumnMappingStoreUnsafeToSafe {
|
|
@@ -302,6 +304,7 @@ interface StateProvider {
|
|
|
302
304
|
|
|
303
305
|
declare abstract class ITarget<C extends BaseConfig = BaseConfig> {
|
|
304
306
|
config: C;
|
|
307
|
+
syncedAtColumnName: string;
|
|
305
308
|
schemaHooks: TargetSchemaHook[];
|
|
306
309
|
syncTime: Dayjs;
|
|
307
310
|
stateProvider: StateProvider;
|
|
@@ -612,7 +615,7 @@ declare class MissingSchemaError extends Error {
|
|
|
612
615
|
}
|
|
613
616
|
|
|
614
617
|
declare const removeParasiteProperties: (record: any, schema: FlattenedSchema) => any;
|
|
615
|
-
declare const addWhalyFields: (record: any, batchDate: string) => any;
|
|
618
|
+
declare const addWhalyFields: (record: any, batchDate: string, columnName?: string) => any;
|
|
616
619
|
|
|
617
620
|
declare const flattenSchema: <T>(streamId: StreamId, schema: T) => FlattenedSchema;
|
|
618
621
|
|
|
@@ -682,7 +685,6 @@ interface CsvFileConfig {
|
|
|
682
685
|
encoding?: string;
|
|
683
686
|
separator: string;
|
|
684
687
|
fields: CsvFieldsConfig;
|
|
685
|
-
addSyncedAtColumn?: boolean;
|
|
686
688
|
}
|
|
687
689
|
interface FileStreamBaseConfig {
|
|
688
690
|
streamId: string;
|
|
@@ -765,7 +767,7 @@ declare const createCellReference: (columnIndex: number, rowIndex: number) => st
|
|
|
765
767
|
/**
|
|
766
768
|
* Low-level Excel extractor: returns array of row records from a workbook.
|
|
767
769
|
*/
|
|
768
|
-
declare const extractExcelRows: (localFilePath: string, conf: ExcelExtractionConfig) => Promise<Record<string, string>[]>;
|
|
770
|
+
declare const extractExcelRows: (localFilePath: string, conf: ExcelExtractionConfig) => Promise<Record<string, string | null>[]>;
|
|
769
771
|
/**
|
|
770
772
|
* Validates an Excel file configuration.
|
|
771
773
|
*/
|
|
@@ -777,7 +779,7 @@ declare const findAllMatchingConfigs: (filename: string, configs: ExcelExtractio
|
|
|
777
779
|
/**
|
|
778
780
|
* Creates an async generator from Excel data.
|
|
779
781
|
*/
|
|
780
|
-
declare function createExcelGenerator(data: Record<string, string>[]): AsyncGenerator<Record<string, any>, void, unknown>;
|
|
782
|
+
declare function createExcelGenerator(data: Record<string, string | null>[]): AsyncGenerator<Record<string, any>, void, unknown>;
|
|
781
783
|
|
|
782
784
|
/**
|
|
783
785
|
* Builder pattern for creating Excel configurations.
|
|
@@ -839,7 +841,6 @@ declare const writeGeneratorToCSV: (generator: AsyncGenerator, outputFileName: s
|
|
|
839
841
|
* const config = CsvExtractionConfigBuilder.create()
|
|
840
842
|
* .separator(";")
|
|
841
843
|
* .encoding("latin1")
|
|
842
|
-
* .addSyncedAtColumn()
|
|
843
844
|
* .fieldsFromDict({
|
|
844
845
|
* "Product ID": { key: "product_id", type: "STRING" },
|
|
845
846
|
* "Product Name": { key: "product_name", type: "STRING" },
|
|
@@ -851,7 +852,6 @@ declare const writeGeneratorToCSV: (generator: AsyncGenerator, outputFileName: s
|
|
|
851
852
|
declare class CsvExtractionConfigBuilder {
|
|
852
853
|
private _separator;
|
|
853
854
|
private _encoding?;
|
|
854
|
-
private _addSyncedAtColumn?;
|
|
855
855
|
private _fields?;
|
|
856
856
|
private _fieldsMode?;
|
|
857
857
|
private _replicationMethod?;
|
|
@@ -859,7 +859,6 @@ declare class CsvExtractionConfigBuilder {
|
|
|
859
859
|
static create(): CsvExtractionConfigBuilder;
|
|
860
860
|
separator(sep: string): CsvExtractionConfigBuilder;
|
|
861
861
|
encoding(enc: string): CsvExtractionConfigBuilder;
|
|
862
|
-
addSyncedAtColumn(enabled?: boolean): CsvExtractionConfigBuilder;
|
|
863
862
|
fieldsFromDict(mapping: {
|
|
864
863
|
[header: string]: {
|
|
865
864
|
key: string;
|
|
@@ -1143,4 +1142,4 @@ declare class GCSStateProvider implements StateProvider {
|
|
|
1143
1142
|
writeState(state: string): Promise<void>;
|
|
1144
1143
|
}
|
|
1145
1144
|
|
|
1146
|
-
export { ALL_STREAM_ID_KEYWORD, API_CALLS_METRIC_NAME, Authenticator, BATCH_INTERVAL_MS, type BaseConfig, type BigQueryConfig, BigQueryTarget, type BigqueryLocation, type Bookmark, type Bookmarks, CloudStorageService, type CloudStorageServiceOptions, type ColumnMappingStoreUnsafeToSafe, CounterMetric, CsvExtractionConfigBuilder, type CsvFieldsArrayConfig, type CsvFieldsConfig, type CsvFieldsDictConfig, type CsvFileConfig, type CsvStreamConfig, DEFAULT_MAX_CONCURRENT_STREAMS, 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, type InputTapState, type InternalTableField, type JSONSchemaFieldDefinition, type Message, type MessageType, type MetricConfiguration, MissingFieldInSchemaError, MissingSchemaError, type PostConfig, 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 StreamState, StreamWarehouseSyncService, type StreamWithTempFile, type SyncOptions, Tap, type TapState, type TargetSchemaHook, type TargetSchemaHookInput, type TempFile, type URLParams, VariableExtractors, type WarehouseTableField, _greaterThan, addWhalyFields, checkCsvHeaderRow, countCsvLines, createCellReference, createCsvStreamConfig, createExcelGenerator, createExcelStreamConfig, createTemporaryFileStream, csvFieldsToJsonSchema, excelColumnToIndex, excelFieldsToJsonSchema, excelRowToIndex, extractExcelRows, extractPrimaryKeysFromCsvConfig, extractPrimaryKeysFromExcelFields, extractStateForStream, fieldTypeToJsonSchema, finalizeStateProgressMarkers, findAllMatchingConfigs, flattenSchema, getAllMetrics, getAxiosInstance, getCounterMetric, getCounterMetrics, getDownloadFileApiCall, getJSONApiCall, getJSONApiCallWithFullResponse, getRawJSONApiCall, gracefulExit, haltAndCatchFire, incrementStreamState, indexToExcelColumn, indexToExcelRow, loadJson, loadSchema, logger, parseCellReference, postFormDataApiCall, postJSONApiCall, postUrlEncodedApiCall, printMemoryFootprint, processFileStreams, removeParasiteProperties, rowGeneratorFromCsv, safePath, unzip, validateExcelConfig, writeDataToCsv, writeGeneratorToCSV };
|
|
1145
|
+
export { ALL_STREAM_ID_KEYWORD, API_CALLS_METRIC_NAME, Authenticator, BATCH_INTERVAL_MS, type BaseConfig, type BigQueryConfig, BigQueryTarget, type BigqueryLocation, type Bookmark, type Bookmarks, 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, 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, type InputTapState, type InternalTableField, type JSONSchemaFieldDefinition, type Message, type MessageType, type MetricConfiguration, MissingFieldInSchemaError, MissingSchemaError, type PostConfig, 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 StreamState, StreamWarehouseSyncService, type StreamWithTempFile, type SyncOptions, Tap, type TapState, type TargetSchemaHook, type TargetSchemaHookInput, type TempFile, type URLParams, VariableExtractors, type WarehouseTableField, _greaterThan, addWhalyFields, checkCsvHeaderRow, countCsvLines, createCellReference, createCsvStreamConfig, createExcelGenerator, createExcelStreamConfig, createTemporaryFileStream, csvFieldsToJsonSchema, excelColumnToIndex, excelFieldsToJsonSchema, excelRowToIndex, extractExcelRows, extractPrimaryKeysFromCsvConfig, extractPrimaryKeysFromExcelFields, extractStateForStream, fieldTypeToJsonSchema, finalizeStateProgressMarkers, findAllMatchingConfigs, flattenSchema, getAllMetrics, getAxiosInstance, getCounterMetric, getCounterMetrics, getDownloadFileApiCall, getJSONApiCall, getJSONApiCallWithFullResponse, getRawJSONApiCall, gracefulExit, haltAndCatchFire, incrementStreamState, indexToExcelColumn, indexToExcelRow, loadJson, loadSchema, logger, parseCellReference, postFormDataApiCall, postJSONApiCall, postUrlEncodedApiCall, printMemoryFootprint, processFileStreams, removeParasiteProperties, rowGeneratorFromCsv, safePath, unzip, validateExcelConfig, writeDataToCsv, writeGeneratorToCSV };
|
package/dist/index.js
CHANGED
|
@@ -39,6 +39,7 @@ __export(index_exports, {
|
|
|
39
39
|
CounterMetric: () => CounterMetric,
|
|
40
40
|
CsvExtractionConfigBuilder: () => CsvExtractionConfigBuilder,
|
|
41
41
|
DEFAULT_MAX_CONCURRENT_STREAMS: () => DEFAULT_MAX_CONCURRENT_STREAMS,
|
|
42
|
+
DEFAULT_SYNCED_AT_COLUMN: () => DEFAULT_SYNCED_AT_COLUMN,
|
|
42
43
|
EXECUTION_TIME_METRIC_NAME: () => EXECUTION_TIME_METRIC_NAME,
|
|
43
44
|
ExcelExtractionConfigBuilder: () => ExcelExtractionConfigBuilder,
|
|
44
45
|
FileFormat: () => FileFormat,
|
|
@@ -1670,6 +1671,9 @@ var MissingSchemaError = class extends Error {
|
|
|
1670
1671
|
}
|
|
1671
1672
|
};
|
|
1672
1673
|
|
|
1674
|
+
// src/sdk/models/target/models.ts
|
|
1675
|
+
var DEFAULT_SYNCED_AT_COLUMN = "_wly_synced_at";
|
|
1676
|
+
|
|
1673
1677
|
// src/sdk/models/target/record.ts
|
|
1674
1678
|
var removeParasiteProperties = (record, schema) => {
|
|
1675
1679
|
const schemaKeys = Object.keys(schema);
|
|
@@ -1680,10 +1684,10 @@ var removeParasiteProperties = (record, schema) => {
|
|
|
1680
1684
|
});
|
|
1681
1685
|
return record;
|
|
1682
1686
|
};
|
|
1683
|
-
var addWhalyFields = (record, batchDate) => {
|
|
1687
|
+
var addWhalyFields = (record, batchDate, columnName = DEFAULT_SYNCED_AT_COLUMN) => {
|
|
1684
1688
|
return {
|
|
1685
1689
|
...record,
|
|
1686
|
-
|
|
1690
|
+
[columnName]: batchDate
|
|
1687
1691
|
};
|
|
1688
1692
|
};
|
|
1689
1693
|
|
|
@@ -1952,6 +1956,7 @@ var import_bluebird3 = __toESM(require("bluebird"));
|
|
|
1952
1956
|
var semaphore = new import_async_mutex.Semaphore(1);
|
|
1953
1957
|
var ITarget = class _ITarget {
|
|
1954
1958
|
config;
|
|
1959
|
+
syncedAtColumnName;
|
|
1955
1960
|
schemaHooks;
|
|
1956
1961
|
syncTime;
|
|
1957
1962
|
stateProvider;
|
|
@@ -1967,6 +1972,7 @@ var ITarget = class _ITarget {
|
|
|
1967
1972
|
ajv;
|
|
1968
1973
|
constructor(config, stateProvider) {
|
|
1969
1974
|
this.config = config;
|
|
1975
|
+
this.syncedAtColumnName = config.syncedAtColumnName ?? DEFAULT_SYNCED_AT_COLUMN;
|
|
1970
1976
|
this.stateProvider = stateProvider;
|
|
1971
1977
|
this.schemaHooks = [];
|
|
1972
1978
|
this.streams = {};
|
|
@@ -1987,8 +1993,8 @@ var ITarget = class _ITarget {
|
|
|
1987
1993
|
analyzeSchemaChanges = (previousSchema, newSchema, streamId) => {
|
|
1988
1994
|
const changes = [];
|
|
1989
1995
|
let hasBreakingChanges = false;
|
|
1990
|
-
const prevColumns = new Set(Object.keys(previousSchema).filter((col) =>
|
|
1991
|
-
const newColumns = new Set(Object.keys(newSchema).filter((col) =>
|
|
1996
|
+
const prevColumns = new Set(Object.keys(previousSchema).filter((col) => col !== this.syncedAtColumnName));
|
|
1997
|
+
const newColumns = new Set(Object.keys(newSchema).filter((col) => col !== this.syncedAtColumnName));
|
|
1992
1998
|
for (const columnName of newColumns) {
|
|
1993
1999
|
if (!prevColumns.has(columnName)) {
|
|
1994
2000
|
changes.push(`Added column '${columnName}'`);
|
|
@@ -2046,7 +2052,7 @@ var ITarget = class _ITarget {
|
|
|
2046
2052
|
return;
|
|
2047
2053
|
}
|
|
2048
2054
|
const recordWithoutParasiteProperties = removeParasiteProperties(record, schema);
|
|
2049
|
-
const recordWithWhalyFields = addWhalyFields(recordWithoutParasiteProperties, stream.getBatchDate());
|
|
2055
|
+
const recordWithWhalyFields = addWhalyFields(recordWithoutParasiteProperties, stream.getBatchDate(), this.syncedAtColumnName);
|
|
2050
2056
|
const validateFn = stream.getCompiledValidateFn();
|
|
2051
2057
|
if (validateFn && !validateFn(recordWithWhalyFields)) {
|
|
2052
2058
|
throw new SchemaValidationError(`Stream: ${streamId} - Record is not valid according to schema.
|
|
@@ -2129,7 +2135,7 @@ var ITarget = class _ITarget {
|
|
|
2129
2135
|
throw new MissingSchemaError(`Stream: ${streamId} - Received SCHEMA message before stream state was initialized.`, streamId);
|
|
2130
2136
|
}
|
|
2131
2137
|
const schema = flattenSchema(streamId, message.schema);
|
|
2132
|
-
schema[
|
|
2138
|
+
schema[this.syncedAtColumnName] = {
|
|
2133
2139
|
format: "date-time",
|
|
2134
2140
|
type: ["null", "string"]
|
|
2135
2141
|
};
|
|
@@ -2425,10 +2431,10 @@ var extractSingleSheetRows = async (fileName, conf) => {
|
|
|
2425
2431
|
if (!variables) {
|
|
2426
2432
|
throw new Error(`No variables extracted from filename, cannot extract derived field ${key}`);
|
|
2427
2433
|
}
|
|
2428
|
-
acc[key] = variables[column.variableName] ||
|
|
2434
|
+
acc[key] = variables[column.variableName] || null;
|
|
2429
2435
|
} else {
|
|
2430
2436
|
const colIndex = excelColumnToIndex(column.column);
|
|
2431
|
-
acc[key] = row[colIndex]?.v ||
|
|
2437
|
+
acc[key] = row[colIndex]?.v || null;
|
|
2432
2438
|
}
|
|
2433
2439
|
return acc;
|
|
2434
2440
|
}, {});
|
|
@@ -2634,7 +2640,6 @@ async function* rowGeneratorFromCsv(path2, fileConfig) {
|
|
|
2634
2640
|
csvOptions.headers = false;
|
|
2635
2641
|
}
|
|
2636
2642
|
const csvStream = (0, import_csv_parser.default)(csvOptions);
|
|
2637
|
-
const syncedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2638
2643
|
let initialReadStream;
|
|
2639
2644
|
let finalInputStream;
|
|
2640
2645
|
const encodingToUse = fileConfig.encoding ? fileConfig.encoding.toLowerCase() : null;
|
|
@@ -2649,20 +2654,22 @@ async function* rowGeneratorFromCsv(path2, fileConfig) {
|
|
|
2649
2654
|
try {
|
|
2650
2655
|
for await (const row of import_stream2.Readable.from(csvStream)) {
|
|
2651
2656
|
if (!isGeneratorConfigArray) {
|
|
2652
|
-
const rowData =
|
|
2657
|
+
const rowData = {};
|
|
2653
2658
|
for (const key of configKeys) {
|
|
2654
2659
|
const keyGenerator = fileConfig.fields[key.trim()];
|
|
2655
2660
|
if (!keyGenerator) continue;
|
|
2656
|
-
|
|
2661
|
+
const rawValue = keyGenerator.valueTransformer ? keyGenerator.valueTransformer(row[key]) : row[key];
|
|
2662
|
+
rowData[keyGenerator.key] = rawValue === "" ? null : rawValue;
|
|
2657
2663
|
}
|
|
2658
2664
|
yield rowData;
|
|
2659
2665
|
} else {
|
|
2660
2666
|
const rowKeys = Object.keys(row);
|
|
2661
|
-
const rowData =
|
|
2667
|
+
const rowData = {};
|
|
2662
2668
|
for (let i = 0; i < rowKeys.length; i++) {
|
|
2663
2669
|
const keyGenerator = fileConfig.fields[i];
|
|
2664
2670
|
if (!keyGenerator) continue;
|
|
2665
|
-
|
|
2671
|
+
const rawValue = keyGenerator.valueTransformer ? keyGenerator.valueTransformer(row[i]) : row[i];
|
|
2672
|
+
rowData[keyGenerator.key] = rawValue === "" ? null : rawValue;
|
|
2666
2673
|
}
|
|
2667
2674
|
yield rowData;
|
|
2668
2675
|
}
|
|
@@ -2960,7 +2967,6 @@ async function processFileStreams(entries, tapState, target) {
|
|
|
2960
2967
|
var CsvExtractionConfigBuilder = class _CsvExtractionConfigBuilder {
|
|
2961
2968
|
_separator = ",";
|
|
2962
2969
|
_encoding;
|
|
2963
|
-
_addSyncedAtColumn;
|
|
2964
2970
|
_fields;
|
|
2965
2971
|
_fieldsMode;
|
|
2966
2972
|
_replicationMethod;
|
|
@@ -2976,10 +2982,6 @@ var CsvExtractionConfigBuilder = class _CsvExtractionConfigBuilder {
|
|
|
2976
2982
|
this._encoding = enc;
|
|
2977
2983
|
return this;
|
|
2978
2984
|
}
|
|
2979
|
-
addSyncedAtColumn(enabled = true) {
|
|
2980
|
-
this._addSyncedAtColumn = enabled;
|
|
2981
|
-
return this;
|
|
2982
|
-
}
|
|
2983
2985
|
fieldsFromDict(mapping) {
|
|
2984
2986
|
if (this._fieldsMode === "array") {
|
|
2985
2987
|
throw new Error("Cannot use fieldsFromDict after fieldsFromArray");
|
|
@@ -3021,9 +3023,6 @@ var CsvExtractionConfigBuilder = class _CsvExtractionConfigBuilder {
|
|
|
3021
3023
|
if (this._encoding !== void 0) {
|
|
3022
3024
|
config.encoding = this._encoding;
|
|
3023
3025
|
}
|
|
3024
|
-
if (this._addSyncedAtColumn !== void 0) {
|
|
3025
|
-
config.addSyncedAtColumn = this._addSyncedAtColumn;
|
|
3026
|
-
}
|
|
3027
3026
|
return config;
|
|
3028
3027
|
}
|
|
3029
3028
|
buildStreamConfig(streamId) {
|
|
@@ -3910,6 +3909,7 @@ var GCSStateProvider = class {
|
|
|
3910
3909
|
CounterMetric,
|
|
3911
3910
|
CsvExtractionConfigBuilder,
|
|
3912
3911
|
DEFAULT_MAX_CONCURRENT_STREAMS,
|
|
3912
|
+
DEFAULT_SYNCED_AT_COLUMN,
|
|
3913
3913
|
EXECUTION_TIME_METRIC_NAME,
|
|
3914
3914
|
ExcelExtractionConfigBuilder,
|
|
3915
3915
|
FileFormat,
|