@whaly/connector-sdk 0.3.2 → 0.3.4
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 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.js +17 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -187,10 +187,13 @@ 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;
|
|
196
|
+
syncedAtColumnUseLegacyStringType?: boolean;
|
|
194
197
|
}
|
|
195
198
|
|
|
196
199
|
interface ColumnMappingStoreUnsafeToSafe {
|
|
@@ -302,6 +305,8 @@ interface StateProvider {
|
|
|
302
305
|
|
|
303
306
|
declare abstract class ITarget<C extends BaseConfig = BaseConfig> {
|
|
304
307
|
config: C;
|
|
308
|
+
syncedAtColumnName: string;
|
|
309
|
+
syncedAtColumnUseLegacyStringType: boolean;
|
|
305
310
|
schemaHooks: TargetSchemaHook[];
|
|
306
311
|
syncTime: Dayjs;
|
|
307
312
|
stateProvider: StateProvider;
|
|
@@ -612,7 +617,7 @@ declare class MissingSchemaError extends Error {
|
|
|
612
617
|
}
|
|
613
618
|
|
|
614
619
|
declare const removeParasiteProperties: (record: any, schema: FlattenedSchema) => any;
|
|
615
|
-
declare const addWhalyFields: (record: any, batchDate: string) => any;
|
|
620
|
+
declare const addWhalyFields: (record: any, batchDate: string, columnName?: string) => any;
|
|
616
621
|
|
|
617
622
|
declare const flattenSchema: <T>(streamId: StreamId, schema: T) => FlattenedSchema;
|
|
618
623
|
|
|
@@ -682,7 +687,6 @@ interface CsvFileConfig {
|
|
|
682
687
|
encoding?: string;
|
|
683
688
|
separator: string;
|
|
684
689
|
fields: CsvFieldsConfig;
|
|
685
|
-
addSyncedAtColumn?: boolean;
|
|
686
690
|
}
|
|
687
691
|
interface FileStreamBaseConfig {
|
|
688
692
|
streamId: string;
|
|
@@ -839,7 +843,6 @@ declare const writeGeneratorToCSV: (generator: AsyncGenerator, outputFileName: s
|
|
|
839
843
|
* const config = CsvExtractionConfigBuilder.create()
|
|
840
844
|
* .separator(";")
|
|
841
845
|
* .encoding("latin1")
|
|
842
|
-
* .addSyncedAtColumn()
|
|
843
846
|
* .fieldsFromDict({
|
|
844
847
|
* "Product ID": { key: "product_id", type: "STRING" },
|
|
845
848
|
* "Product Name": { key: "product_name", type: "STRING" },
|
|
@@ -851,7 +854,6 @@ declare const writeGeneratorToCSV: (generator: AsyncGenerator, outputFileName: s
|
|
|
851
854
|
declare class CsvExtractionConfigBuilder {
|
|
852
855
|
private _separator;
|
|
853
856
|
private _encoding?;
|
|
854
|
-
private _addSyncedAtColumn?;
|
|
855
857
|
private _fields?;
|
|
856
858
|
private _fieldsMode?;
|
|
857
859
|
private _replicationMethod?;
|
|
@@ -859,7 +861,6 @@ declare class CsvExtractionConfigBuilder {
|
|
|
859
861
|
static create(): CsvExtractionConfigBuilder;
|
|
860
862
|
separator(sep: string): CsvExtractionConfigBuilder;
|
|
861
863
|
encoding(enc: string): CsvExtractionConfigBuilder;
|
|
862
|
-
addSyncedAtColumn(enabled?: boolean): CsvExtractionConfigBuilder;
|
|
863
864
|
fieldsFromDict(mapping: {
|
|
864
865
|
[header: string]: {
|
|
865
866
|
key: string;
|
|
@@ -1143,4 +1144,4 @@ declare class GCSStateProvider implements StateProvider {
|
|
|
1143
1144
|
writeState(state: string): Promise<void>;
|
|
1144
1145
|
}
|
|
1145
1146
|
|
|
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 };
|
|
1147
|
+
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,13 @@ 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;
|
|
196
|
+
syncedAtColumnUseLegacyStringType?: boolean;
|
|
194
197
|
}
|
|
195
198
|
|
|
196
199
|
interface ColumnMappingStoreUnsafeToSafe {
|
|
@@ -302,6 +305,8 @@ interface StateProvider {
|
|
|
302
305
|
|
|
303
306
|
declare abstract class ITarget<C extends BaseConfig = BaseConfig> {
|
|
304
307
|
config: C;
|
|
308
|
+
syncedAtColumnName: string;
|
|
309
|
+
syncedAtColumnUseLegacyStringType: boolean;
|
|
305
310
|
schemaHooks: TargetSchemaHook[];
|
|
306
311
|
syncTime: Dayjs;
|
|
307
312
|
stateProvider: StateProvider;
|
|
@@ -612,7 +617,7 @@ declare class MissingSchemaError extends Error {
|
|
|
612
617
|
}
|
|
613
618
|
|
|
614
619
|
declare const removeParasiteProperties: (record: any, schema: FlattenedSchema) => any;
|
|
615
|
-
declare const addWhalyFields: (record: any, batchDate: string) => any;
|
|
620
|
+
declare const addWhalyFields: (record: any, batchDate: string, columnName?: string) => any;
|
|
616
621
|
|
|
617
622
|
declare const flattenSchema: <T>(streamId: StreamId, schema: T) => FlattenedSchema;
|
|
618
623
|
|
|
@@ -682,7 +687,6 @@ interface CsvFileConfig {
|
|
|
682
687
|
encoding?: string;
|
|
683
688
|
separator: string;
|
|
684
689
|
fields: CsvFieldsConfig;
|
|
685
|
-
addSyncedAtColumn?: boolean;
|
|
686
690
|
}
|
|
687
691
|
interface FileStreamBaseConfig {
|
|
688
692
|
streamId: string;
|
|
@@ -839,7 +843,6 @@ declare const writeGeneratorToCSV: (generator: AsyncGenerator, outputFileName: s
|
|
|
839
843
|
* const config = CsvExtractionConfigBuilder.create()
|
|
840
844
|
* .separator(";")
|
|
841
845
|
* .encoding("latin1")
|
|
842
|
-
* .addSyncedAtColumn()
|
|
843
846
|
* .fieldsFromDict({
|
|
844
847
|
* "Product ID": { key: "product_id", type: "STRING" },
|
|
845
848
|
* "Product Name": { key: "product_name", type: "STRING" },
|
|
@@ -851,7 +854,6 @@ declare const writeGeneratorToCSV: (generator: AsyncGenerator, outputFileName: s
|
|
|
851
854
|
declare class CsvExtractionConfigBuilder {
|
|
852
855
|
private _separator;
|
|
853
856
|
private _encoding?;
|
|
854
|
-
private _addSyncedAtColumn?;
|
|
855
857
|
private _fields?;
|
|
856
858
|
private _fieldsMode?;
|
|
857
859
|
private _replicationMethod?;
|
|
@@ -859,7 +861,6 @@ declare class CsvExtractionConfigBuilder {
|
|
|
859
861
|
static create(): CsvExtractionConfigBuilder;
|
|
860
862
|
separator(sep: string): CsvExtractionConfigBuilder;
|
|
861
863
|
encoding(enc: string): CsvExtractionConfigBuilder;
|
|
862
|
-
addSyncedAtColumn(enabled?: boolean): CsvExtractionConfigBuilder;
|
|
863
864
|
fieldsFromDict(mapping: {
|
|
864
865
|
[header: string]: {
|
|
865
866
|
key: string;
|
|
@@ -1143,4 +1144,4 @@ declare class GCSStateProvider implements StateProvider {
|
|
|
1143
1144
|
writeState(state: string): Promise<void>;
|
|
1144
1145
|
}
|
|
1145
1146
|
|
|
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 };
|
|
1147
|
+
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,8 @@ 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;
|
|
1960
|
+
syncedAtColumnUseLegacyStringType;
|
|
1955
1961
|
schemaHooks;
|
|
1956
1962
|
syncTime;
|
|
1957
1963
|
stateProvider;
|
|
@@ -1967,6 +1973,8 @@ var ITarget = class _ITarget {
|
|
|
1967
1973
|
ajv;
|
|
1968
1974
|
constructor(config, stateProvider) {
|
|
1969
1975
|
this.config = config;
|
|
1976
|
+
this.syncedAtColumnName = config.syncedAtColumnName ?? DEFAULT_SYNCED_AT_COLUMN;
|
|
1977
|
+
this.syncedAtColumnUseLegacyStringType = config.syncedAtColumnUseLegacyStringType ?? false;
|
|
1970
1978
|
this.stateProvider = stateProvider;
|
|
1971
1979
|
this.schemaHooks = [];
|
|
1972
1980
|
this.streams = {};
|
|
@@ -1987,8 +1995,8 @@ var ITarget = class _ITarget {
|
|
|
1987
1995
|
analyzeSchemaChanges = (previousSchema, newSchema, streamId) => {
|
|
1988
1996
|
const changes = [];
|
|
1989
1997
|
let hasBreakingChanges = false;
|
|
1990
|
-
const prevColumns = new Set(Object.keys(previousSchema).filter((col) =>
|
|
1991
|
-
const newColumns = new Set(Object.keys(newSchema).filter((col) =>
|
|
1998
|
+
const prevColumns = new Set(Object.keys(previousSchema).filter((col) => col !== this.syncedAtColumnName));
|
|
1999
|
+
const newColumns = new Set(Object.keys(newSchema).filter((col) => col !== this.syncedAtColumnName));
|
|
1992
2000
|
for (const columnName of newColumns) {
|
|
1993
2001
|
if (!prevColumns.has(columnName)) {
|
|
1994
2002
|
changes.push(`Added column '${columnName}'`);
|
|
@@ -2046,7 +2054,7 @@ var ITarget = class _ITarget {
|
|
|
2046
2054
|
return;
|
|
2047
2055
|
}
|
|
2048
2056
|
const recordWithoutParasiteProperties = removeParasiteProperties(record, schema);
|
|
2049
|
-
const recordWithWhalyFields = addWhalyFields(recordWithoutParasiteProperties, stream.getBatchDate());
|
|
2057
|
+
const recordWithWhalyFields = addWhalyFields(recordWithoutParasiteProperties, stream.getBatchDate(), this.syncedAtColumnName);
|
|
2050
2058
|
const validateFn = stream.getCompiledValidateFn();
|
|
2051
2059
|
if (validateFn && !validateFn(recordWithWhalyFields)) {
|
|
2052
2060
|
throw new SchemaValidationError(`Stream: ${streamId} - Record is not valid according to schema.
|
|
@@ -2129,10 +2137,7 @@ var ITarget = class _ITarget {
|
|
|
2129
2137
|
throw new MissingSchemaError(`Stream: ${streamId} - Received SCHEMA message before stream state was initialized.`, streamId);
|
|
2130
2138
|
}
|
|
2131
2139
|
const schema = flattenSchema(streamId, message.schema);
|
|
2132
|
-
schema["
|
|
2133
|
-
format: "date-time",
|
|
2134
|
-
type: ["null", "string"]
|
|
2135
|
-
};
|
|
2140
|
+
schema[this.syncedAtColumnName] = this.syncedAtColumnUseLegacyStringType ? { type: ["null", "string"] } : { format: "date-time", type: ["null", "string"] };
|
|
2136
2141
|
const dbSync = streamState.getDbSync();
|
|
2137
2142
|
Object.keys(schema).forEach((fieldUnsafeKey) => {
|
|
2138
2143
|
const fieldDef = schema[fieldUnsafeKey];
|
|
@@ -2634,7 +2639,6 @@ async function* rowGeneratorFromCsv(path2, fileConfig) {
|
|
|
2634
2639
|
csvOptions.headers = false;
|
|
2635
2640
|
}
|
|
2636
2641
|
const csvStream = (0, import_csv_parser.default)(csvOptions);
|
|
2637
|
-
const syncedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2638
2642
|
let initialReadStream;
|
|
2639
2643
|
let finalInputStream;
|
|
2640
2644
|
const encodingToUse = fileConfig.encoding ? fileConfig.encoding.toLowerCase() : null;
|
|
@@ -2649,7 +2653,7 @@ async function* rowGeneratorFromCsv(path2, fileConfig) {
|
|
|
2649
2653
|
try {
|
|
2650
2654
|
for await (const row of import_stream2.Readable.from(csvStream)) {
|
|
2651
2655
|
if (!isGeneratorConfigArray) {
|
|
2652
|
-
const rowData =
|
|
2656
|
+
const rowData = {};
|
|
2653
2657
|
for (const key of configKeys) {
|
|
2654
2658
|
const keyGenerator = fileConfig.fields[key.trim()];
|
|
2655
2659
|
if (!keyGenerator) continue;
|
|
@@ -2659,7 +2663,7 @@ async function* rowGeneratorFromCsv(path2, fileConfig) {
|
|
|
2659
2663
|
yield rowData;
|
|
2660
2664
|
} else {
|
|
2661
2665
|
const rowKeys = Object.keys(row);
|
|
2662
|
-
const rowData =
|
|
2666
|
+
const rowData = {};
|
|
2663
2667
|
for (let i = 0; i < rowKeys.length; i++) {
|
|
2664
2668
|
const keyGenerator = fileConfig.fields[i];
|
|
2665
2669
|
if (!keyGenerator) continue;
|
|
@@ -2962,7 +2966,6 @@ async function processFileStreams(entries, tapState, target) {
|
|
|
2962
2966
|
var CsvExtractionConfigBuilder = class _CsvExtractionConfigBuilder {
|
|
2963
2967
|
_separator = ",";
|
|
2964
2968
|
_encoding;
|
|
2965
|
-
_addSyncedAtColumn;
|
|
2966
2969
|
_fields;
|
|
2967
2970
|
_fieldsMode;
|
|
2968
2971
|
_replicationMethod;
|
|
@@ -2978,10 +2981,6 @@ var CsvExtractionConfigBuilder = class _CsvExtractionConfigBuilder {
|
|
|
2978
2981
|
this._encoding = enc;
|
|
2979
2982
|
return this;
|
|
2980
2983
|
}
|
|
2981
|
-
addSyncedAtColumn(enabled = true) {
|
|
2982
|
-
this._addSyncedAtColumn = enabled;
|
|
2983
|
-
return this;
|
|
2984
|
-
}
|
|
2985
2984
|
fieldsFromDict(mapping) {
|
|
2986
2985
|
if (this._fieldsMode === "array") {
|
|
2987
2986
|
throw new Error("Cannot use fieldsFromDict after fieldsFromArray");
|
|
@@ -3023,9 +3022,6 @@ var CsvExtractionConfigBuilder = class _CsvExtractionConfigBuilder {
|
|
|
3023
3022
|
if (this._encoding !== void 0) {
|
|
3024
3023
|
config.encoding = this._encoding;
|
|
3025
3024
|
}
|
|
3026
|
-
if (this._addSyncedAtColumn !== void 0) {
|
|
3027
|
-
config.addSyncedAtColumn = this._addSyncedAtColumn;
|
|
3028
|
-
}
|
|
3029
3025
|
return config;
|
|
3030
3026
|
}
|
|
3031
3027
|
buildStreamConfig(streamId) {
|
|
@@ -3912,6 +3908,7 @@ var GCSStateProvider = class {
|
|
|
3912
3908
|
CounterMetric,
|
|
3913
3909
|
CsvExtractionConfigBuilder,
|
|
3914
3910
|
DEFAULT_MAX_CONCURRENT_STREAMS,
|
|
3911
|
+
DEFAULT_SYNCED_AT_COLUMN,
|
|
3915
3912
|
EXECUTION_TIME_METRIC_NAME,
|
|
3916
3913
|
ExcelExtractionConfigBuilder,
|
|
3917
3914
|
FileFormat,
|