@whaly/connector-sdk 0.1.1 → 0.3.0
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/README.md +92 -0
- package/dist/index.d.mts +568 -200
- package/dist/index.d.ts +568 -200
- package/dist/index.js +1389 -584
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1354 -579
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,49 +1,96 @@
|
|
|
1
|
-
import winston from 'winston';
|
|
2
1
|
import { AxiosInstance, AxiosRequestHeaders, AxiosResponse, AxiosRequestConfig, AxiosError } from 'axios';
|
|
3
|
-
import moment from 'moment';
|
|
4
2
|
import { Validator, ValidationError } from 'jsonschema';
|
|
3
|
+
import { Dayjs } from 'dayjs';
|
|
5
4
|
import { WriteStream } from 'fs';
|
|
5
|
+
import { WorkBook } from 'xlsx';
|
|
6
|
+
export { WorkBook } from 'xlsx';
|
|
7
|
+
import Client from 'ssh2-sftp-client';
|
|
8
|
+
export { default as SftpClient, ConnectOptions as SftpConnectOptions } from 'ssh2-sftp-client';
|
|
9
|
+
import { File } from '@google-cloud/storage';
|
|
6
10
|
import { BigQuery, Dataset, Table } from '@google-cloud/bigquery';
|
|
7
11
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
metadata: CatalogStreamMetadata[];
|
|
12
|
+
declare const loadJson: (fileName: string) => any;
|
|
13
|
+
declare const loadSchema: (streamId: string) => any;
|
|
14
|
+
|
|
15
|
+
declare const getAxiosInstance: (retryCount?: number) => AxiosInstance;
|
|
16
|
+
interface GetConfig {
|
|
17
|
+
qs?: {
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
};
|
|
20
|
+
headers?: AxiosRequestHeaders;
|
|
21
|
+
retryCount?: number;
|
|
19
22
|
}
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
declare const getRawJSONApiCall: <T>(endpoint: string, config: GetConfig, privateLogging?: boolean) => Promise<AxiosResponse<T>>;
|
|
24
|
+
declare const getJSONApiCallWithFullResponse: <T>(endpoint: string, config: GetConfig, privateLogging?: boolean) => Promise<AxiosResponse<any, any, {}>>;
|
|
25
|
+
declare const getJSONApiCall: <T>(endpoint: string, config: GetConfig, privateLogging?: boolean) => Promise<T>;
|
|
26
|
+
declare const getDownloadFileApiCall: <T>(endpoint: string, config: GetConfig, output: string, privateLogging?: boolean) => Promise<{
|
|
27
|
+
outputDir: string;
|
|
28
|
+
}>;
|
|
29
|
+
interface PostConfig {
|
|
30
|
+
qs?: {
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
};
|
|
33
|
+
headers?: AxiosRequestHeaders;
|
|
34
|
+
retryCount?: number;
|
|
22
35
|
}
|
|
36
|
+
declare const postJSONApiCall: <T>(endpoint: string, config: PostConfig, payload: any) => Promise<T>;
|
|
37
|
+
declare const postFormDataApiCall: <T>(endpoint: string, config: PostConfig, payload: any) => Promise<T>;
|
|
38
|
+
declare const postUrlEncodedApiCall: (endpoint: string, config: PostConfig, payload: any) => Promise<any>;
|
|
23
39
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
40
|
+
declare const BATCH_INTERVAL_MS = 100;
|
|
41
|
+
declare const logger: {
|
|
42
|
+
info: (message: string | any, ...args: any[]) => void;
|
|
43
|
+
error: (message: string | any, ...args: any[]) => void;
|
|
44
|
+
debug: (message: string | any, ...args: any[]) => void;
|
|
45
|
+
warn: (message: string | any, ...args: any[]) => void;
|
|
46
|
+
closeWinston: (cb: () => void) => void;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
declare const ALL_STREAM_ID_KEYWORD = "all";
|
|
50
|
+
declare const ROWS_SYNCED_METRIC_NAME = "rows_synced_count";
|
|
51
|
+
declare const API_CALLS_METRIC_NAME = "api_calls_count";
|
|
52
|
+
declare const EXECUTION_TIME_METRIC_NAME = "execution_time_ms";
|
|
53
|
+
interface MetricConfiguration {
|
|
54
|
+
isEnabled: () => boolean;
|
|
55
|
+
getStreamIds?: () => string[];
|
|
56
|
+
}
|
|
57
|
+
declare const getCounterMetrics: (name: string, streamIds: string[]) => CounterMetric[];
|
|
58
|
+
declare const getCounterMetric: (name: string, streamId?: string) => CounterMetric;
|
|
59
|
+
declare const getAllMetrics: () => CounterMetric[];
|
|
60
|
+
declare class CounterMetric {
|
|
61
|
+
private value;
|
|
62
|
+
name: string;
|
|
63
|
+
streamId: string;
|
|
64
|
+
constructor(name: string, streamId: string);
|
|
65
|
+
increment(inc?: number): void;
|
|
66
|
+
getStreamId(): string;
|
|
67
|
+
getName(): string;
|
|
68
|
+
getValue(): number;
|
|
28
69
|
}
|
|
29
70
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
71
|
+
declare const printMemoryFootprint: (prefix: string) => void;
|
|
72
|
+
|
|
73
|
+
type ErrorType = "unauthorized" | "unknown";
|
|
74
|
+
|
|
75
|
+
declare const haltAndCatchFire: (errorType: ErrorType, errorText: string, errorDebugText: string) => Promise<void>;
|
|
76
|
+
|
|
77
|
+
declare function gracefulExit(exitCode: number): Promise<void>;
|
|
78
|
+
|
|
79
|
+
declare enum ReplicationMethod {
|
|
80
|
+
INCREMENTAL = "INCREMENTAL",
|
|
81
|
+
FULL_TABLE = "FULL_TABLE",
|
|
82
|
+
APPEND = "APPEND"
|
|
36
83
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
from: string;
|
|
41
|
-
to: string;
|
|
84
|
+
|
|
85
|
+
interface HTTPHeaders {
|
|
86
|
+
[headerName: string]: any;
|
|
42
87
|
}
|
|
43
|
-
interface
|
|
44
|
-
|
|
45
|
-
right: DirectionalRelationship[];
|
|
88
|
+
interface URLParams {
|
|
89
|
+
[paramName: string]: any;
|
|
46
90
|
}
|
|
91
|
+
type HTTPMethod = "GET" | "POST";
|
|
92
|
+
|
|
93
|
+
type StreamId = string;
|
|
47
94
|
|
|
48
95
|
interface PropertiesMetadata {
|
|
49
96
|
[propName: string]: {
|
|
@@ -93,7 +140,6 @@ declare class SchemaMessage implements Message {
|
|
|
93
140
|
displayLabel: string | undefined;
|
|
94
141
|
description: string | undefined;
|
|
95
142
|
propertiesMetadata: PropertiesMetadata | undefined;
|
|
96
|
-
relationships: DirectionalRelationships;
|
|
97
143
|
constructor(opts: {
|
|
98
144
|
stream: StreamId;
|
|
99
145
|
schema: any;
|
|
@@ -101,7 +147,6 @@ declare class SchemaMessage implements Message {
|
|
|
101
147
|
bookmarkProperties?: string[];
|
|
102
148
|
displayLabel?: string;
|
|
103
149
|
description?: string;
|
|
104
|
-
relationships: DirectionalRelationships;
|
|
105
150
|
propertiesMetadata?: PropertiesMetadata | undefined;
|
|
106
151
|
});
|
|
107
152
|
toString(): string;
|
|
@@ -117,150 +162,6 @@ interface TargetSchemaHook {
|
|
|
117
162
|
writeSchema: (input: TargetSchemaHookInput) => Promise<void>;
|
|
118
163
|
}
|
|
119
164
|
|
|
120
|
-
type ErrorType = "unauthorized" | "unknown";
|
|
121
|
-
|
|
122
|
-
declare abstract class Resolver {
|
|
123
|
-
constructor();
|
|
124
|
-
abstract checkIfCanSync(): Promise<boolean>;
|
|
125
|
-
abstract markSyncStarted(): Promise<void>;
|
|
126
|
-
abstract getState(): Promise<StateHolder>;
|
|
127
|
-
abstract writeCatalog(catalog: CatalogFile): Promise<void>;
|
|
128
|
-
abstract writeState(state: string): Promise<void>;
|
|
129
|
-
abstract markSyncFailed(): Promise<void>;
|
|
130
|
-
abstract markSyncComplete(): Promise<void>;
|
|
131
|
-
abstract markDiscoveryComplete(): Promise<void>;
|
|
132
|
-
abstract flushMetrics(): Promise<void>;
|
|
133
|
-
abstract onError(errorType: ErrorType, errorText: string, errorDebugText: string): Promise<void>;
|
|
134
|
-
abstract getSchemaHooks(): TargetSchemaHook[];
|
|
135
|
-
abstract updateSourceValue(optionKey: string, optionValue: string): Promise<void>;
|
|
136
|
-
abstract getLogFormat(): winston.Logform.Format;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
declare const writeStateFile: (resolver: Resolver, state: string) => Promise<void>;
|
|
140
|
-
declare const loadJson: (fileName: string) => any;
|
|
141
|
-
declare const loadSchema: (streamId: string) => any;
|
|
142
|
-
|
|
143
|
-
declare const getAxiosInstance: (retryCount?: number) => AxiosInstance;
|
|
144
|
-
interface GetConfig {
|
|
145
|
-
qs?: {
|
|
146
|
-
[key: string]: any;
|
|
147
|
-
};
|
|
148
|
-
headers?: AxiosRequestHeaders;
|
|
149
|
-
retryCount?: number;
|
|
150
|
-
}
|
|
151
|
-
declare const getRawJSONApiCall: <T>(endpoint: string, config: GetConfig, privateLogging?: boolean) => Promise<AxiosResponse<T>>;
|
|
152
|
-
declare const getJSONApiCallWithFullResponse: <T>(endpoint: string, config: GetConfig, privateLogging?: boolean) => Promise<AxiosResponse<any, any, {}>>;
|
|
153
|
-
declare const getJSONApiCall: <T>(endpoint: string, config: GetConfig, privateLogging?: boolean) => Promise<T>;
|
|
154
|
-
declare const getDownloadFileApiCall: <T>(endpoint: string, config: GetConfig, output: string, privateLogging?: boolean) => Promise<{
|
|
155
|
-
outputDir: string;
|
|
156
|
-
}>;
|
|
157
|
-
interface PostConfig {
|
|
158
|
-
qs?: {
|
|
159
|
-
[key: string]: any;
|
|
160
|
-
};
|
|
161
|
-
headers?: AxiosRequestHeaders;
|
|
162
|
-
retryCount?: number;
|
|
163
|
-
}
|
|
164
|
-
declare const postJSONApiCall: <T>(endpoint: string, config: PostConfig, payload: any) => Promise<T>;
|
|
165
|
-
declare const postFormDataApiCall: <T>(endpoint: string, config: PostConfig, payload: any) => Promise<T>;
|
|
166
|
-
declare const postUrlEncodedApiCall: (endpoint: string, config: PostConfig, payload: any) => Promise<any>;
|
|
167
|
-
|
|
168
|
-
declare const BATCH_INTERVAL_MS = 100;
|
|
169
|
-
declare const logger: {
|
|
170
|
-
info: (message: string | any, ...args: any[]) => void;
|
|
171
|
-
error: (message: string | any, ...args: any[]) => void;
|
|
172
|
-
debug: (message: string | any, ...args: any[]) => void;
|
|
173
|
-
warn: (message: string | any, ...args: any[]) => void;
|
|
174
|
-
closeWinston: (cb: () => void) => void;
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
declare const ALL_STREAM_ID_KEYWORD = "all";
|
|
178
|
-
declare const ROWS_SYNCED_METRIC_NAME = "rows_synced_count";
|
|
179
|
-
declare const API_CALLS_METRIC_NAME = "api_calls_count";
|
|
180
|
-
declare const EXECUTION_TIME_METRIC_NAME = "execution_time_ms";
|
|
181
|
-
interface MetricConfiguration {
|
|
182
|
-
isEnabled: () => boolean;
|
|
183
|
-
getStreamIds?: () => string[];
|
|
184
|
-
}
|
|
185
|
-
declare const getCounterMetrics: (name: string, streamIds: string[]) => CounterMetric[];
|
|
186
|
-
declare const getCounterMetric: (name: string, streamId?: string) => CounterMetric;
|
|
187
|
-
declare const getAllMetrics: () => CounterMetric[];
|
|
188
|
-
declare class CounterMetric {
|
|
189
|
-
private value;
|
|
190
|
-
name: string;
|
|
191
|
-
streamId: string;
|
|
192
|
-
constructor(name: string, streamId: string);
|
|
193
|
-
increment(inc?: number): void;
|
|
194
|
-
getStreamId(): string;
|
|
195
|
-
getName(): string;
|
|
196
|
-
getValue(): number;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
declare const printMemoryFootprint: (prefix: string) => void;
|
|
200
|
-
|
|
201
|
-
declare const haltAndCatchFire: (errorType: ErrorType, errorText: string, errorDebugText: string) => Promise<void>;
|
|
202
|
-
|
|
203
|
-
declare function gracefulExit(exitCode: number): Promise<void>;
|
|
204
|
-
|
|
205
|
-
declare const findRelatedRelationships: (streamId: StreamId, allRels: StreamRelationship[]) => DirectionalRelationships;
|
|
206
|
-
|
|
207
|
-
declare const loadResolver: () => Resolver;
|
|
208
|
-
|
|
209
|
-
interface HTTPHeaders {
|
|
210
|
-
[headerName: string]: any;
|
|
211
|
-
}
|
|
212
|
-
interface URLParams {
|
|
213
|
-
[paramName: string]: any;
|
|
214
|
-
}
|
|
215
|
-
type HTTPMethod = "GET" | "POST";
|
|
216
|
-
|
|
217
|
-
type InclusionMode = "available" | "automatic" | "unsupported";
|
|
218
|
-
interface MetadataEntry {
|
|
219
|
-
selected?: boolean;
|
|
220
|
-
"replication-method"?: ReplicationMethod;
|
|
221
|
-
"replication-key"?: string;
|
|
222
|
-
"view-key-properties"?: string[];
|
|
223
|
-
"inclusion"?: InclusionMode;
|
|
224
|
-
"selected-by-default"?: boolean;
|
|
225
|
-
"valid-replication-keys"?: string[];
|
|
226
|
-
"forced-replication-method"?: ReplicationMethod;
|
|
227
|
-
"forced-replication-key"?: string;
|
|
228
|
-
"table-key-properties"?: string[];
|
|
229
|
-
"schema-name"?: string;
|
|
230
|
-
"is-view"?: boolean;
|
|
231
|
-
"row-count"?: number;
|
|
232
|
-
"database-name"?: string;
|
|
233
|
-
"sql-datatype"?: string;
|
|
234
|
-
"whaly-display-label"?: string;
|
|
235
|
-
"whaly-description"?: string;
|
|
236
|
-
"whaly-parent-stream"?: StreamId;
|
|
237
|
-
}
|
|
238
|
-
interface CatalogMetadata {
|
|
239
|
-
breadcrumb: string[];
|
|
240
|
-
metadata: MetadataEntry;
|
|
241
|
-
}
|
|
242
|
-
declare class MetadataMap extends Map<string[], MetadataEntry> {
|
|
243
|
-
private areEquals;
|
|
244
|
-
private findExistingEntry;
|
|
245
|
-
get(key: string[]): MetadataEntry | undefined;
|
|
246
|
-
set(key: string[], value: MetadataEntry): this;
|
|
247
|
-
}
|
|
248
|
-
declare class StreamMetadata {
|
|
249
|
-
metadataByBreadcrumb: MetadataMap;
|
|
250
|
-
constructor();
|
|
251
|
-
fromCatalogStreamMetadata(metadataArr: CatalogMetadata[]): this;
|
|
252
|
-
toString(): MetadataMap;
|
|
253
|
-
get(breadcrumb: string[]): MetadataEntry | undefined;
|
|
254
|
-
write(breadcrumb: string[], key: string, value: any): this;
|
|
255
|
-
private getRootBreadcrumbMetadata;
|
|
256
|
-
isStreamSelected(): boolean;
|
|
257
|
-
getKeyProperties(): string[];
|
|
258
|
-
getReplicationKey(): string | undefined;
|
|
259
|
-
getReplicationMethod(): ReplicationMethod | undefined;
|
|
260
|
-
getForcedReplicationMethod(): ReplicationMethod | undefined;
|
|
261
|
-
toList(): CatalogMetadata[];
|
|
262
|
-
}
|
|
263
|
-
|
|
264
165
|
interface FlattenedSchema {
|
|
265
166
|
[unsafePropertyName: string]: JSONSchemaFieldDefinition;
|
|
266
167
|
}
|
|
@@ -287,8 +188,9 @@ interface StreamWithTempFile {
|
|
|
287
188
|
tempFile: TempFile;
|
|
288
189
|
}
|
|
289
190
|
interface BaseConfig {
|
|
290
|
-
|
|
191
|
+
connector_id: string;
|
|
291
192
|
database: string;
|
|
193
|
+
schema: string;
|
|
292
194
|
}
|
|
293
195
|
|
|
294
196
|
interface ColumnMappingStoreUnsafeToSafe {
|
|
@@ -329,6 +231,7 @@ declare abstract class StreamWarehouseSyncService {
|
|
|
329
231
|
getcolumnNameWithTypeSuffix(colName: string, warehouseType: string | undefined): string;
|
|
330
232
|
abstract getMergeQueries: () => string[];
|
|
331
233
|
abstract getReplaceQueries: () => string[];
|
|
234
|
+
abstract getAppendQueries: () => string[];
|
|
332
235
|
abstract createDatabaseAndSchemaIfNotExists: (retryCount: number) => Promise<void>;
|
|
333
236
|
abstract createTable: () => Promise<void>;
|
|
334
237
|
abstract addColumns: (fields: InternalTableField[]) => Promise<void>;
|
|
@@ -363,7 +266,7 @@ declare class StreamState$1 {
|
|
|
363
266
|
streamId: StreamId;
|
|
364
267
|
schema?: FlattenedSchema;
|
|
365
268
|
dbSync: StreamWarehouseSyncService;
|
|
366
|
-
batchDate:
|
|
269
|
+
batchDate: Dayjs;
|
|
367
270
|
batchedRowCount: number;
|
|
368
271
|
fileToLoad: TempFile;
|
|
369
272
|
syncedRowCount: number;
|
|
@@ -386,11 +289,19 @@ declare class StreamState$1 {
|
|
|
386
289
|
setHasBeenLoadedYet(): void;
|
|
387
290
|
}
|
|
388
291
|
|
|
292
|
+
interface StateHolder {
|
|
293
|
+
state?: any;
|
|
294
|
+
}
|
|
295
|
+
interface StateProvider {
|
|
296
|
+
getState(): Promise<StateHolder>;
|
|
297
|
+
writeState(state: string): Promise<void>;
|
|
298
|
+
}
|
|
299
|
+
|
|
389
300
|
declare abstract class ITarget<C extends BaseConfig = BaseConfig> {
|
|
390
301
|
config: C;
|
|
391
302
|
schemaHooks: TargetSchemaHook[];
|
|
392
|
-
|
|
393
|
-
|
|
303
|
+
syncTime: Dayjs;
|
|
304
|
+
stateProvider: StateProvider;
|
|
394
305
|
batchedState: any;
|
|
395
306
|
flushedState: any;
|
|
396
307
|
renameColumnStore: RenameColumnStore;
|
|
@@ -398,7 +309,7 @@ declare abstract class ITarget<C extends BaseConfig = BaseConfig> {
|
|
|
398
309
|
[streamName: string]: StreamState$1;
|
|
399
310
|
};
|
|
400
311
|
validator: Validator;
|
|
401
|
-
constructor(config: C,
|
|
312
|
+
constructor(config: C, stateProvider: StateProvider);
|
|
402
313
|
static requiredConfigKeys: string[];
|
|
403
314
|
abstract newDBSyncInstance: (streamId: StreamId, database: string, schema: string, table: string) => StreamWarehouseSyncService;
|
|
404
315
|
abstract genTableName: (streamId: string) => string;
|
|
@@ -462,11 +373,9 @@ declare class StateService {
|
|
|
462
373
|
bookmarks: Bookmarks;
|
|
463
374
|
constructor();
|
|
464
375
|
static getInstance(): StateService;
|
|
465
|
-
setBookmark(streamId: StreamId,
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
getBookmark(streamId: StreamId): moment.Moment;
|
|
469
|
-
getBookmarkV2(streamId: StreamId): StreamState;
|
|
376
|
+
setBookmark(streamId: StreamId, streamState: StreamState): void;
|
|
377
|
+
setBookmarkSignpost(streamId: StreamId, signpostValue: string): void;
|
|
378
|
+
getBookmark(streamId: StreamId): StreamState;
|
|
470
379
|
clearState(): void;
|
|
471
380
|
get(): State;
|
|
472
381
|
forwardStateToTarget(target: ITarget): Promise<void>;
|
|
@@ -491,7 +400,7 @@ declare abstract class Stream<O = any, C = any, P = undefined> {
|
|
|
491
400
|
config: C;
|
|
492
401
|
tapState: InputTapState;
|
|
493
402
|
target: ITarget;
|
|
494
|
-
|
|
403
|
+
replicationMethod: ReplicationMethod | undefined;
|
|
495
404
|
selectedByDefault: boolean;
|
|
496
405
|
STATE_MSG_FREQUENCY: number;
|
|
497
406
|
streamId: StreamId;
|
|
@@ -499,16 +408,15 @@ declare abstract class Stream<O = any, C = any, P = undefined> {
|
|
|
499
408
|
displayLabel: string | undefined;
|
|
500
409
|
description: string | undefined;
|
|
501
410
|
primaryKey: string[];
|
|
502
|
-
|
|
411
|
+
replicationKey: string | undefined;
|
|
503
412
|
useStateFromStreamId: string | undefined;
|
|
504
|
-
relationships: StreamRelationship[];
|
|
505
413
|
children: Stream<any, any, O | O[]>[];
|
|
506
414
|
isSorted: boolean;
|
|
507
415
|
isSilent: boolean;
|
|
508
416
|
childConcurrency: number;
|
|
509
417
|
rowsSyncedMetricsConf: MetricConfiguration;
|
|
510
418
|
executionTimeMetricsConf: MetricConfiguration;
|
|
511
|
-
constructor(config: C,
|
|
419
|
+
constructor(config: C, tapState: InputTapState, target: ITarget, childConcurrency?: number);
|
|
512
420
|
/**
|
|
513
421
|
* Sync this stream
|
|
514
422
|
* Called only for streams with no parents, aka. "root tap streams"
|
|
@@ -545,17 +453,17 @@ declare abstract class Stream<O = any, C = any, P = undefined> {
|
|
|
545
453
|
* or `start_date` config if set,
|
|
546
454
|
* or the UNIX Epoch
|
|
547
455
|
**/
|
|
548
|
-
getStartingTimestamp():
|
|
456
|
+
getStartingTimestamp(): Dayjs;
|
|
549
457
|
/**
|
|
550
458
|
* Return the max allowable bookmark value for this stream's replication key.
|
|
551
459
|
*
|
|
552
|
-
* For timestamp-based replication keys, this defaults to `
|
|
460
|
+
* For timestamp-based replication keys, this defaults to `dayjs()`. For
|
|
553
461
|
* non-timestamp replication keys, default to `undefined`.
|
|
554
462
|
*
|
|
555
463
|
* Override this value to prevent bookmarks from being advanced in cases where we
|
|
556
464
|
* may only have a partial set of records.
|
|
557
465
|
*/
|
|
558
|
-
getReplicationKeySignpost: () => Promise<
|
|
466
|
+
getReplicationKeySignpost: () => Promise<Dayjs | undefined>;
|
|
559
467
|
/**
|
|
560
468
|
* Return the default replication method for the stream that will be used to write the catalog.
|
|
561
469
|
*/
|
|
@@ -657,7 +565,7 @@ declare abstract class RESTStream<R, O, NPT, C, P = undefined> extends Stream<O,
|
|
|
657
565
|
* TODO: Make URL + Path templatisable and replace those with Extractor (or Tap) config
|
|
658
566
|
* @returns
|
|
659
567
|
*/
|
|
660
|
-
|
|
568
|
+
getNextUrl(previousToken?: NPT, parent?: P): string;
|
|
661
569
|
/**
|
|
662
570
|
* Parse the response and return an iterator of result rows.
|
|
663
571
|
*
|
|
@@ -677,8 +585,10 @@ declare abstract class Tap<C> {
|
|
|
677
585
|
config: C;
|
|
678
586
|
streams: Stream[];
|
|
679
587
|
concurrency: number;
|
|
588
|
+
stateProvider: StateProvider;
|
|
589
|
+
tapState: InputTapState;
|
|
680
590
|
abstract init(): Promise<void>;
|
|
681
|
-
constructor(target: ITarget, config: C);
|
|
591
|
+
constructor(target: ITarget, config: C, stateProvider: StateProvider);
|
|
682
592
|
sync: (options?: SyncOptions) => Promise<void>;
|
|
683
593
|
end(): Promise<void>;
|
|
684
594
|
}
|
|
@@ -705,6 +615,453 @@ declare const flattenSchema: <T>(streamId: StreamId, schema: T) => FlattenedSche
|
|
|
705
615
|
declare const createTemporaryFileStream: (streamId: StreamId) => TempFile;
|
|
706
616
|
declare function safePath(path: string): string;
|
|
707
617
|
|
|
618
|
+
/**
|
|
619
|
+
* Field types for file processing columns.
|
|
620
|
+
* Maps to JSON Schema types via fieldTypeToJsonSchema().
|
|
621
|
+
*/
|
|
622
|
+
type FieldType = "STRING" | "FLOAT" | "TIMESTAMP";
|
|
623
|
+
declare enum FileFormat {
|
|
624
|
+
CSV = "CSV",
|
|
625
|
+
EXCEL = "EXCEL"
|
|
626
|
+
}
|
|
627
|
+
type ExcelFieldSpec = ExcelSourceColumn | ExcelDerivedField;
|
|
628
|
+
interface ExcelSourceColumn {
|
|
629
|
+
type: FieldType;
|
|
630
|
+
column: string;
|
|
631
|
+
primaryKey?: boolean;
|
|
632
|
+
}
|
|
633
|
+
interface ExcelDerivedField {
|
|
634
|
+
variableName: string;
|
|
635
|
+
primaryKey?: boolean;
|
|
636
|
+
type: FieldType;
|
|
637
|
+
}
|
|
638
|
+
interface ExcelFieldMapping {
|
|
639
|
+
[key: string]: ExcelFieldSpec;
|
|
640
|
+
}
|
|
641
|
+
type ExcelExtractionConfig = ExcelSingleSheetExtractionConfig | ExcelCustomExtractorConfig;
|
|
642
|
+
interface ExcelExtractionBaseConfig {
|
|
643
|
+
type: "single-sheet-extraction" | "processor";
|
|
644
|
+
extension: string;
|
|
645
|
+
fileNameValidator: (fileName: string) => boolean;
|
|
646
|
+
fileNameVariablesExtractor: (fileName: string, workbook?: WorkBook) => {
|
|
647
|
+
[key: string]: string | undefined;
|
|
648
|
+
};
|
|
649
|
+
tableName: string | ((fileName: string, workbook?: WorkBook, variables?: {
|
|
650
|
+
[key: string]: string | undefined;
|
|
651
|
+
}) => string);
|
|
652
|
+
replicationMethod: ReplicationMethod;
|
|
653
|
+
}
|
|
654
|
+
interface ExcelCustomExtractorConfig extends ExcelExtractionBaseConfig {
|
|
655
|
+
type: "processor";
|
|
656
|
+
processor: (workbook: WorkBook) => Promise<Record<string, string>[]>;
|
|
657
|
+
}
|
|
658
|
+
interface ExcelSingleSheetExtractionConfig extends ExcelExtractionBaseConfig {
|
|
659
|
+
type: "single-sheet-extraction";
|
|
660
|
+
columns: ExcelFieldMapping;
|
|
661
|
+
sheetName?: string;
|
|
662
|
+
numberOfRowsToSkip: number;
|
|
663
|
+
}
|
|
664
|
+
type CsvFieldsConfig = CsvFieldsArrayConfig | CsvFieldsDictConfig;
|
|
665
|
+
type CsvFieldsArrayConfig = Array<{
|
|
666
|
+
key: string;
|
|
667
|
+
valueTransformer?: (val: any) => string;
|
|
668
|
+
type: FieldType;
|
|
669
|
+
}>;
|
|
670
|
+
interface CsvFieldsDictConfig {
|
|
671
|
+
[key: string]: {
|
|
672
|
+
key: string;
|
|
673
|
+
valueTransformer?: (val: any) => string;
|
|
674
|
+
type: FieldType;
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
interface CsvFileConfig {
|
|
678
|
+
encoding?: string;
|
|
679
|
+
separator: string;
|
|
680
|
+
fields: CsvFieldsConfig;
|
|
681
|
+
addSyncedAtColumn?: boolean;
|
|
682
|
+
}
|
|
683
|
+
interface FileStreamBaseConfig {
|
|
684
|
+
streamId: string;
|
|
685
|
+
replicationMethod: ReplicationMethod;
|
|
686
|
+
primaryKeys: string[];
|
|
687
|
+
}
|
|
688
|
+
interface CsvStreamConfig extends FileStreamBaseConfig {
|
|
689
|
+
format: FileFormat.CSV;
|
|
690
|
+
csv: CsvFileConfig;
|
|
691
|
+
}
|
|
692
|
+
interface ExcelStreamConfig extends FileStreamBaseConfig {
|
|
693
|
+
format: FileFormat.EXCEL;
|
|
694
|
+
excel: ExcelExtractionConfig;
|
|
695
|
+
}
|
|
696
|
+
type FileStreamConfig = CsvStreamConfig | ExcelStreamConfig;
|
|
697
|
+
interface FileStreamEntry {
|
|
698
|
+
config: FileStreamConfig;
|
|
699
|
+
filePath: string | string[];
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
type JsonSchemaProperty = {
|
|
703
|
+
type: (string | "null")[];
|
|
704
|
+
format?: string;
|
|
705
|
+
};
|
|
706
|
+
/**
|
|
707
|
+
* Convert a FieldType to a JSON Schema property definition.
|
|
708
|
+
*/
|
|
709
|
+
declare function fieldTypeToJsonSchema(fieldType: FieldType): JsonSchemaProperty;
|
|
710
|
+
/**
|
|
711
|
+
* Convert an ExcelFieldMapping to a JSON Schema properties object.
|
|
712
|
+
*/
|
|
713
|
+
declare function excelFieldsToJsonSchema(fields: ExcelFieldMapping): {
|
|
714
|
+
type: "object";
|
|
715
|
+
properties: Record<string, JsonSchemaProperty>;
|
|
716
|
+
};
|
|
717
|
+
/**
|
|
718
|
+
* Convert a CsvFieldsConfig to a JSON Schema properties object.
|
|
719
|
+
*/
|
|
720
|
+
declare function csvFieldsToJsonSchema(config: CsvFieldsConfig): {
|
|
721
|
+
type: "object";
|
|
722
|
+
properties: Record<string, JsonSchemaProperty>;
|
|
723
|
+
};
|
|
724
|
+
/**
|
|
725
|
+
* Extract all output keys from a CsvFieldsConfig to use as composite primary keys.
|
|
726
|
+
* Useful for FULL_TABLE replication where all fields form the PK (since TRUNCATE + MERGE = INSERT).
|
|
727
|
+
*/
|
|
728
|
+
declare function extractPrimaryKeysFromCsvConfig(config: CsvFieldsConfig): string[];
|
|
729
|
+
/**
|
|
730
|
+
* Extract primary keys from an ExcelFieldMapping.
|
|
731
|
+
*/
|
|
732
|
+
declare function extractPrimaryKeysFromExcelFields(fields: ExcelFieldMapping): string[];
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* Converts an Excel column letter (A, B, C, AA, AZ, etc.) to its zero-based index.
|
|
736
|
+
*/
|
|
737
|
+
declare const excelColumnToIndex: (columnLetter: string) => number;
|
|
738
|
+
/**
|
|
739
|
+
* Converts a zero-based column index to Excel column letter(s).
|
|
740
|
+
*/
|
|
741
|
+
declare const indexToExcelColumn: (columnIndex: number) => string;
|
|
742
|
+
/**
|
|
743
|
+
* Converts an Excel row number (1-based) to zero-based array index.
|
|
744
|
+
*/
|
|
745
|
+
declare const excelRowToIndex: (rowNumber: string | number) => number;
|
|
746
|
+
/**
|
|
747
|
+
* Converts a zero-based array index to Excel row number (1-based).
|
|
748
|
+
*/
|
|
749
|
+
declare const indexToExcelRow: (index: number) => number;
|
|
750
|
+
/**
|
|
751
|
+
* Parses an Excel cell reference (like "A1", "Z24", "AA100") into column and row indices.
|
|
752
|
+
*/
|
|
753
|
+
declare const parseCellReference: (cellRef: string) => {
|
|
754
|
+
columnIndex: number;
|
|
755
|
+
rowIndex: number;
|
|
756
|
+
};
|
|
757
|
+
/**
|
|
758
|
+
* Creates an Excel cell reference from column and row indices.
|
|
759
|
+
*/
|
|
760
|
+
declare const createCellReference: (columnIndex: number, rowIndex: number) => string;
|
|
761
|
+
/**
|
|
762
|
+
* Low-level Excel extractor: returns array of row records from a workbook.
|
|
763
|
+
*/
|
|
764
|
+
declare const extractExcelRows: (localFilePath: string, conf: ExcelExtractionConfig) => Promise<Record<string, string>[]>;
|
|
765
|
+
/**
|
|
766
|
+
* Validates an Excel file configuration.
|
|
767
|
+
*/
|
|
768
|
+
declare const validateExcelConfig: (config: ExcelExtractionConfig) => void;
|
|
769
|
+
/**
|
|
770
|
+
* Finds all matching configurations for a given filename.
|
|
771
|
+
*/
|
|
772
|
+
declare const findAllMatchingConfigs: (filename: string, configs: ExcelExtractionConfig[]) => ExcelExtractionConfig[];
|
|
773
|
+
/**
|
|
774
|
+
* Creates an async generator from Excel data.
|
|
775
|
+
*/
|
|
776
|
+
declare function createExcelGenerator(data: Record<string, string>[]): AsyncGenerator<Record<string, any>, void, unknown>;
|
|
777
|
+
|
|
778
|
+
/**
|
|
779
|
+
* Builder pattern for creating Excel configurations.
|
|
780
|
+
*
|
|
781
|
+
* Sensible defaults:
|
|
782
|
+
* - fileNameValidator: accepts all files
|
|
783
|
+
* - fileNameVariablesExtractor: extracts nothing
|
|
784
|
+
* - replicationMethod: FULL_TABLE
|
|
785
|
+
*/
|
|
786
|
+
declare class ExcelExtractionConfigBuilder {
|
|
787
|
+
private config;
|
|
788
|
+
static create(): ExcelExtractionConfigBuilder;
|
|
789
|
+
extension(ext: string): ExcelExtractionConfigBuilder;
|
|
790
|
+
tableName(name: string | ((fileName: string, workbook?: WorkBook, variables?: {
|
|
791
|
+
[key: string]: string | undefined;
|
|
792
|
+
}) => string)): ExcelExtractionConfigBuilder;
|
|
793
|
+
fileValidator(validator: (filename: string) => boolean): ExcelExtractionConfigBuilder;
|
|
794
|
+
variablesExtractor(extractor: (filename: string, workbook?: WorkBook) => {
|
|
795
|
+
[key: string]: string | undefined;
|
|
796
|
+
}): ExcelExtractionConfigBuilder;
|
|
797
|
+
replicationMethod(method: ReplicationMethod): ExcelExtractionConfigBuilder;
|
|
798
|
+
columns(cols: {
|
|
799
|
+
[key: string]: ExcelFieldSpec;
|
|
800
|
+
}): ExcelExtractionConfigBuilder;
|
|
801
|
+
singleSheet(sheetName?: string, skipRows?: number): ExcelExtractionConfigBuilder;
|
|
802
|
+
processor(processorFn: (workbook: WorkBook) => Promise<Record<string, string>[]>): ExcelExtractionConfigBuilder;
|
|
803
|
+
build(): ExcelExtractionConfig;
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* Async generator that yields parsed rows from a CSV file.
|
|
808
|
+
* Supports custom separators, encoding, BOM stripping, and field transformers.
|
|
809
|
+
*/
|
|
810
|
+
declare function rowGeneratorFromCsv(path: string, fileConfig: CsvFileConfig): AsyncGenerator<Record<string, any>>;
|
|
811
|
+
/**
|
|
812
|
+
* Validates CSV header row against expected configuration.
|
|
813
|
+
*/
|
|
814
|
+
declare const checkCsvHeaderRow: (path: string, fileConfig: CsvFileConfig) => Promise<void>;
|
|
815
|
+
|
|
816
|
+
/**
|
|
817
|
+
* Writes an array of objects directly to a CSV file.
|
|
818
|
+
*/
|
|
819
|
+
declare const writeDataToCsv: (fileName: string, data: any[]) => Promise<void>;
|
|
820
|
+
/**
|
|
821
|
+
* Writes data from an async generator to CSV with batch writing (10k row batches).
|
|
822
|
+
*/
|
|
823
|
+
declare const writeGeneratorToCSV: (generator: AsyncGenerator, outputFileName: string) => Promise<number>;
|
|
824
|
+
|
|
825
|
+
/**
|
|
826
|
+
* Builder pattern for creating CSV configurations.
|
|
827
|
+
*
|
|
828
|
+
* Usage:
|
|
829
|
+
* ```ts
|
|
830
|
+
* const config = CsvExtractionConfigBuilder.create()
|
|
831
|
+
* .separator(";")
|
|
832
|
+
* .encoding("latin1")
|
|
833
|
+
* .addSyncedAtColumn()
|
|
834
|
+
* .fieldsFromDict({
|
|
835
|
+
* "Product ID": { key: "product_id", type: "STRING" },
|
|
836
|
+
* "Product Name": { key: "product_name", type: "STRING" },
|
|
837
|
+
* "Price": { key: "price", type: "FLOAT" },
|
|
838
|
+
* })
|
|
839
|
+
* .build();
|
|
840
|
+
* ```
|
|
841
|
+
*/
|
|
842
|
+
declare class CsvExtractionConfigBuilder {
|
|
843
|
+
private _separator;
|
|
844
|
+
private _encoding?;
|
|
845
|
+
private _addSyncedAtColumn?;
|
|
846
|
+
private _fields?;
|
|
847
|
+
private _fieldsMode?;
|
|
848
|
+
private _replicationMethod?;
|
|
849
|
+
private _primaryKeys?;
|
|
850
|
+
static create(): CsvExtractionConfigBuilder;
|
|
851
|
+
separator(sep: string): CsvExtractionConfigBuilder;
|
|
852
|
+
encoding(enc: string): CsvExtractionConfigBuilder;
|
|
853
|
+
addSyncedAtColumn(enabled?: boolean): CsvExtractionConfigBuilder;
|
|
854
|
+
fieldsFromDict(mapping: {
|
|
855
|
+
[header: string]: {
|
|
856
|
+
key: string;
|
|
857
|
+
valueTransformer?: (val: any) => string;
|
|
858
|
+
type: FieldType;
|
|
859
|
+
};
|
|
860
|
+
}): CsvExtractionConfigBuilder;
|
|
861
|
+
fieldsFromArray(fields: Array<{
|
|
862
|
+
key: string;
|
|
863
|
+
valueTransformer?: (val: any) => string;
|
|
864
|
+
type: FieldType;
|
|
865
|
+
}>): CsvExtractionConfigBuilder;
|
|
866
|
+
replicationMethod(method: ReplicationMethod): CsvExtractionConfigBuilder;
|
|
867
|
+
primaryKeys(keys: string[]): CsvExtractionConfigBuilder;
|
|
868
|
+
build(): CsvFileConfig;
|
|
869
|
+
buildStreamConfig(streamId: string): FileStreamConfig;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
/**
|
|
873
|
+
* FileStream bridges file processing (Excel/CSV) into the connector SDK pipeline.
|
|
874
|
+
*
|
|
875
|
+
* It extends Stream so it integrates with the standard Tap -> Stream -> Target flow.
|
|
876
|
+
* Each FileStream reads one file with one config and yields records.
|
|
877
|
+
*/
|
|
878
|
+
declare class FileStream extends Stream<Record<string, any>, FileStreamConfig> {
|
|
879
|
+
private localFilePaths;
|
|
880
|
+
constructor(config: FileStreamConfig, localFilePath: string | string[], tapState: InputTapState, target: ITarget);
|
|
881
|
+
/**
|
|
882
|
+
* Build JSON Schema from the file config's field definitions.
|
|
883
|
+
*/
|
|
884
|
+
getSchema(): Promise<Schema | undefined>;
|
|
885
|
+
/**
|
|
886
|
+
* Yield records from all file(s).
|
|
887
|
+
* When multiple file paths are provided, records are yielded sequentially from each file.
|
|
888
|
+
*/
|
|
889
|
+
_getRecords(): AsyncIterable<Record<string, any>>;
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* Create a FileStreamConfig from an ExcelExtractionConfig.
|
|
893
|
+
* Handles both single-sheet-extraction and processor config types.
|
|
894
|
+
*
|
|
895
|
+
* For single-sheet configs, primary keys are extracted from column definitions.
|
|
896
|
+
* For processor configs, primary keys default to an empty array.
|
|
897
|
+
*
|
|
898
|
+
* @param excelConfig - The Excel extraction config (single-sheet or processor)
|
|
899
|
+
* @param fileName - The base filename (used for variable extraction and table name resolution)
|
|
900
|
+
* @param localFilePath - Optional local file path; required for processor configs with dynamic table names
|
|
901
|
+
*/
|
|
902
|
+
declare function createExcelStreamConfig(excelConfig: ExcelExtractionConfig, fileName: string, localFilePath?: string): FileStreamConfig;
|
|
903
|
+
/**
|
|
904
|
+
* Create a FileStreamConfig from a CsvFileConfig.
|
|
905
|
+
*
|
|
906
|
+
* By default, uses FULL_TABLE replication and extracts all field keys as composite primary keys.
|
|
907
|
+
* Override via the options parameter.
|
|
908
|
+
*
|
|
909
|
+
* @param streamId - The stream/table name
|
|
910
|
+
* @param csvConfig - The CSV file configuration
|
|
911
|
+
* @param options - Optional overrides for replicationMethod and primaryKeys
|
|
912
|
+
*/
|
|
913
|
+
declare function createCsvStreamConfig(streamId: string, csvConfig: CsvFileConfig, options?: {
|
|
914
|
+
replicationMethod?: ReplicationMethod;
|
|
915
|
+
primaryKeys?: string[];
|
|
916
|
+
}): FileStreamConfig;
|
|
917
|
+
/**
|
|
918
|
+
* Process an array of FileStreamEntry sequentially, then signal completion to the target.
|
|
919
|
+
*
|
|
920
|
+
* This is the recommended pattern for SFTP and similar multi-file ingestion flows
|
|
921
|
+
* where FileTap isn't needed.
|
|
922
|
+
*
|
|
923
|
+
* @param entries - Array of { config, filePath } pairs
|
|
924
|
+
* @param tapState - The tap state (typically `{ bookmarks: {} }`)
|
|
925
|
+
* @param target - The target (e.g. BigQueryTarget)
|
|
926
|
+
*/
|
|
927
|
+
declare function processFileStreams(entries: FileStreamEntry[], tapState: InputTapState, target: ITarget): Promise<void>;
|
|
928
|
+
|
|
929
|
+
interface FileTapConfig {
|
|
930
|
+
[key: string]: any;
|
|
931
|
+
}
|
|
932
|
+
/**
|
|
933
|
+
* FileTap orchestrates multiple FileStreams.
|
|
934
|
+
*
|
|
935
|
+
* It extends Tap so it integrates with the standard Tap -> Stream -> Target flow.
|
|
936
|
+
* Provide file stream entries (config + file path pairs), and it creates a FileStream per entry.
|
|
937
|
+
*
|
|
938
|
+
* For simple sequential file processing without the Tap lifecycle, use processFileStreams() instead.
|
|
939
|
+
*/
|
|
940
|
+
declare class FileTap extends Tap<FileTapConfig> {
|
|
941
|
+
private entries;
|
|
942
|
+
constructor(target: ITarget, config: FileTapConfig, stateProvider: StateProvider, entries: FileStreamEntry[]);
|
|
943
|
+
/**
|
|
944
|
+
* Convenience constructor for the common case where all configs share the same file path.
|
|
945
|
+
*/
|
|
946
|
+
static fromConfigs(target: ITarget, config: FileTapConfig, stateProvider: StateProvider, fileConfigs: FileStreamConfig[], sharedFilePath: string): FileTap;
|
|
947
|
+
init(): Promise<void>;
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
/**
|
|
951
|
+
* Variable extraction utilities for common filename patterns.
|
|
952
|
+
*/
|
|
953
|
+
declare class VariableExtractors {
|
|
954
|
+
/**
|
|
955
|
+
* Returns the filename as a variable.
|
|
956
|
+
*/
|
|
957
|
+
static filename(): (filename: string) => {
|
|
958
|
+
[key: string]: string | undefined;
|
|
959
|
+
};
|
|
960
|
+
/**
|
|
961
|
+
* Extracts named capture groups from a regex pattern.
|
|
962
|
+
*/
|
|
963
|
+
static regex(pattern: RegExp): (filename: string) => {
|
|
964
|
+
[key: string]: string | undefined;
|
|
965
|
+
};
|
|
966
|
+
/**
|
|
967
|
+
* Combines multiple extraction functions.
|
|
968
|
+
*/
|
|
969
|
+
static combine(...extractors: ((filename: string) => {
|
|
970
|
+
[key: string]: string | undefined;
|
|
971
|
+
})[]): (filename: string) => {
|
|
972
|
+
[key: string]: string | undefined;
|
|
973
|
+
};
|
|
974
|
+
}
|
|
975
|
+
/**
|
|
976
|
+
* File pattern utilities for common filename validation patterns.
|
|
977
|
+
*/
|
|
978
|
+
declare class FilePatterns {
|
|
979
|
+
/**
|
|
980
|
+
* Creates a validator for files starting with a specific prefix (case-insensitive).
|
|
981
|
+
*/
|
|
982
|
+
static startsWith(prefix: string): (filename: string) => boolean;
|
|
983
|
+
/**
|
|
984
|
+
* Creates a validator for files matching a regex pattern.
|
|
985
|
+
*/
|
|
986
|
+
static regex(pattern: RegExp): (filename: string) => boolean;
|
|
987
|
+
/**
|
|
988
|
+
* Combines multiple validators with AND logic.
|
|
989
|
+
*/
|
|
990
|
+
static and(...validators: ((filename: string) => boolean)[]): (filename: string) => boolean;
|
|
991
|
+
/**
|
|
992
|
+
* Combines multiple validators with OR logic.
|
|
993
|
+
*/
|
|
994
|
+
static or(...validators: ((filename: string) => boolean)[]): (filename: string) => boolean;
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
/**
|
|
998
|
+
* Pre-instantiated SFTP client singleton.
|
|
999
|
+
* @deprecated Prefer creating your own SftpClient instance for better lifecycle control.
|
|
1000
|
+
*/
|
|
1001
|
+
declare const SftpService: Client;
|
|
1002
|
+
|
|
1003
|
+
interface CloudStorageServiceOptions {
|
|
1004
|
+
processedSuffix?: string;
|
|
1005
|
+
supportedExtensions?: string[];
|
|
1006
|
+
}
|
|
1007
|
+
/**
|
|
1008
|
+
* Service for interacting with Google Cloud Storage.
|
|
1009
|
+
* Supports file download, upload, listing, and marker-file-based processing tracking.
|
|
1010
|
+
*/
|
|
1011
|
+
declare class CloudStorageService {
|
|
1012
|
+
private storage;
|
|
1013
|
+
private bucket;
|
|
1014
|
+
private processedSuffix;
|
|
1015
|
+
private supportedExtensions;
|
|
1016
|
+
private path;
|
|
1017
|
+
constructor(bucketName: string, path?: string, opts?: CloudStorageServiceOptions);
|
|
1018
|
+
/**
|
|
1019
|
+
* Lists all files in the bucket with an optional prefix.
|
|
1020
|
+
*/
|
|
1021
|
+
listFiles(prefix?: string): Promise<string[]>;
|
|
1022
|
+
/**
|
|
1023
|
+
* Returns files that haven't been marked as processed.
|
|
1024
|
+
* Filters by supported extensions if configured.
|
|
1025
|
+
*/
|
|
1026
|
+
getUnprocessedFiles(): Promise<string[]>;
|
|
1027
|
+
/**
|
|
1028
|
+
* Creates a marker file to indicate a file has been processed.
|
|
1029
|
+
*/
|
|
1030
|
+
createMarkerFile(fileName: string): Promise<void>;
|
|
1031
|
+
/**
|
|
1032
|
+
* Downloads a file from GCS to a local tmp directory.
|
|
1033
|
+
* Returns the local path of the downloaded file.
|
|
1034
|
+
*/
|
|
1035
|
+
downloadFile(filePath: string, fileName: string): Promise<string>;
|
|
1036
|
+
/**
|
|
1037
|
+
* Uploads a local file to GCS.
|
|
1038
|
+
*/
|
|
1039
|
+
uploadFile(localPath: string, destPath: string): Promise<File>;
|
|
1040
|
+
/**
|
|
1041
|
+
* Reads a GCS object and returns its contents as a UTF-8 string.
|
|
1042
|
+
*/
|
|
1043
|
+
readObjectAsString(objectPath: string): Promise<string>;
|
|
1044
|
+
/**
|
|
1045
|
+
* Writes a string to a GCS object with JSON content type.
|
|
1046
|
+
*/
|
|
1047
|
+
writeStringObject(objectPath: string, contents: string): Promise<void>;
|
|
1048
|
+
/**
|
|
1049
|
+
* Uploads a local file to the bucket with a unique name based on prefix, streamId, and UUID.
|
|
1050
|
+
* Returns the GCS File reference.
|
|
1051
|
+
*/
|
|
1052
|
+
uploadFileWithUniqueName(filePath: string, prefix: string, streamId: string): Promise<File>;
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
/**
|
|
1056
|
+
* Extract a ZIP (or other archive) file to a target directory.
|
|
1057
|
+
* Uses the `decompress` library which supports zip, tar, gz, bz2, etc.
|
|
1058
|
+
*
|
|
1059
|
+
* @param zipFilePath - Path to the archive file
|
|
1060
|
+
* @param extractedPath - Directory to extract into (created if it doesn't exist)
|
|
1061
|
+
* @returns The output directory path
|
|
1062
|
+
*/
|
|
1063
|
+
declare const unzip: (zipFilePath: string, extractedPath: string) => Promise<string>;
|
|
1064
|
+
|
|
708
1065
|
interface BigQueryConfig extends BaseConfig {
|
|
709
1066
|
schema: string;
|
|
710
1067
|
project_id: string;
|
|
@@ -729,6 +1086,7 @@ declare class BigQueryDBSync extends StreamWarehouseSyncService {
|
|
|
729
1086
|
getWarehouseTypeFromJSONSchema: (definition: JSONSchemaFieldDefinition) => string;
|
|
730
1087
|
getMergeQueries: () => string[];
|
|
731
1088
|
getReplaceQueries: () => string[];
|
|
1089
|
+
getAppendQueries: () => string[];
|
|
732
1090
|
createDatabaseAndSchemaIfNotExists: (retryCount: number) => Promise<void>;
|
|
733
1091
|
createTable: () => Promise<void>;
|
|
734
1092
|
addColumns: (tableFields: InternalTableField[]) => Promise<void>;
|
|
@@ -754,7 +1112,7 @@ declare class BigQueryDBSync extends StreamWarehouseSyncService {
|
|
|
754
1112
|
}
|
|
755
1113
|
|
|
756
1114
|
declare class BigQueryTarget extends ITarget<BigQueryConfig> {
|
|
757
|
-
constructor(config: BigQueryConfig,
|
|
1115
|
+
constructor(config: BigQueryConfig, stateProvider: StateProvider);
|
|
758
1116
|
static requiredConfigKeys: string[];
|
|
759
1117
|
newDBSyncInstance: (streamId: StreamId, database: string, schema: string, table: string) => BigQueryDBSync;
|
|
760
1118
|
genTableName: (key: string) => string;
|
|
@@ -763,4 +1121,14 @@ declare class BigQueryTarget extends ITarget<BigQueryConfig> {
|
|
|
763
1121
|
convertNumberIntoDecimal: (record: any, schema: FlattenedSchema) => any;
|
|
764
1122
|
}
|
|
765
1123
|
|
|
766
|
-
|
|
1124
|
+
declare class GCSStateProvider implements StateProvider {
|
|
1125
|
+
private bucketName;
|
|
1126
|
+
private connectorId;
|
|
1127
|
+
private service;
|
|
1128
|
+
constructor(connectorId: string, bucketName: string);
|
|
1129
|
+
private getObjectPath;
|
|
1130
|
+
getState(): Promise<StateHolder>;
|
|
1131
|
+
writeState(state: string): Promise<void>;
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
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, 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 };
|