@whaly/connector-sdk 0.3.2 → 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 +5 -6
- package/dist/index.d.ts +5 -6
- package/dist/index.js +15 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -17
- 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;
|
|
@@ -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;
|
|
@@ -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
|
};
|
|
@@ -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,7 +2654,7 @@ 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;
|
|
@@ -2659,7 +2664,7 @@ async function* rowGeneratorFromCsv(path2, fileConfig) {
|
|
|
2659
2664
|
yield rowData;
|
|
2660
2665
|
} else {
|
|
2661
2666
|
const rowKeys = Object.keys(row);
|
|
2662
|
-
const rowData =
|
|
2667
|
+
const rowData = {};
|
|
2663
2668
|
for (let i = 0; i < rowKeys.length; i++) {
|
|
2664
2669
|
const keyGenerator = fileConfig.fields[i];
|
|
2665
2670
|
if (!keyGenerator) continue;
|
|
@@ -2962,7 +2967,6 @@ async function processFileStreams(entries, tapState, target) {
|
|
|
2962
2967
|
var CsvExtractionConfigBuilder = class _CsvExtractionConfigBuilder {
|
|
2963
2968
|
_separator = ",";
|
|
2964
2969
|
_encoding;
|
|
2965
|
-
_addSyncedAtColumn;
|
|
2966
2970
|
_fields;
|
|
2967
2971
|
_fieldsMode;
|
|
2968
2972
|
_replicationMethod;
|
|
@@ -2978,10 +2982,6 @@ var CsvExtractionConfigBuilder = class _CsvExtractionConfigBuilder {
|
|
|
2978
2982
|
this._encoding = enc;
|
|
2979
2983
|
return this;
|
|
2980
2984
|
}
|
|
2981
|
-
addSyncedAtColumn(enabled = true) {
|
|
2982
|
-
this._addSyncedAtColumn = enabled;
|
|
2983
|
-
return this;
|
|
2984
|
-
}
|
|
2985
2985
|
fieldsFromDict(mapping) {
|
|
2986
2986
|
if (this._fieldsMode === "array") {
|
|
2987
2987
|
throw new Error("Cannot use fieldsFromDict after fieldsFromArray");
|
|
@@ -3023,9 +3023,6 @@ var CsvExtractionConfigBuilder = class _CsvExtractionConfigBuilder {
|
|
|
3023
3023
|
if (this._encoding !== void 0) {
|
|
3024
3024
|
config.encoding = this._encoding;
|
|
3025
3025
|
}
|
|
3026
|
-
if (this._addSyncedAtColumn !== void 0) {
|
|
3027
|
-
config.addSyncedAtColumn = this._addSyncedAtColumn;
|
|
3028
|
-
}
|
|
3029
3026
|
return config;
|
|
3030
3027
|
}
|
|
3031
3028
|
buildStreamConfig(streamId) {
|
|
@@ -3912,6 +3909,7 @@ var GCSStateProvider = class {
|
|
|
3912
3909
|
CounterMetric,
|
|
3913
3910
|
CsvExtractionConfigBuilder,
|
|
3914
3911
|
DEFAULT_MAX_CONCURRENT_STREAMS,
|
|
3912
|
+
DEFAULT_SYNCED_AT_COLUMN,
|
|
3915
3913
|
EXECUTION_TIME_METRIC_NAME,
|
|
3916
3914
|
ExcelExtractionConfigBuilder,
|
|
3917
3915
|
FileFormat,
|