@whaly/connector-sdk 0.1.0 → 0.1.1
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 +227 -186
- package/dist/index.d.ts +227 -186
- package/dist/index.js +814 -493
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +809 -486
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,31 @@
|
|
|
1
1
|
import winston from 'winston';
|
|
2
|
-
import {
|
|
2
|
+
import { AxiosInstance, AxiosRequestHeaders, AxiosResponse, AxiosRequestConfig, AxiosError } from 'axios';
|
|
3
3
|
import moment from 'moment';
|
|
4
|
+
import { Validator, ValidationError } from 'jsonschema';
|
|
4
5
|
import { WriteStream } from 'fs';
|
|
5
|
-
import {
|
|
6
|
+
import { BigQuery, Dataset, Table } from '@google-cloud/bigquery';
|
|
7
|
+
|
|
8
|
+
type StreamId = string;
|
|
9
|
+
type StreamName = string;
|
|
10
|
+
interface CatalogStreamMetadata {
|
|
11
|
+
breadcrumb: string[];
|
|
12
|
+
metadata: Record<string, any>;
|
|
13
|
+
}
|
|
14
|
+
interface CatalogStream {
|
|
15
|
+
tap_stream_id: StreamId;
|
|
16
|
+
stream: StreamName;
|
|
17
|
+
schema: any;
|
|
18
|
+
metadata: CatalogStreamMetadata[];
|
|
19
|
+
}
|
|
20
|
+
interface CatalogFile {
|
|
21
|
+
streams: CatalogStream[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type ReplicationMethod = "INCREMENTAL" | "FULL_TABLE";
|
|
25
|
+
type DestinationType = `GOOGLE_BIGQUERY` | `SNOWFLAKE`;
|
|
26
|
+
interface StateHolder {
|
|
27
|
+
state?: any;
|
|
28
|
+
}
|
|
6
29
|
|
|
7
30
|
interface StreamRelationship {
|
|
8
31
|
left: StreamId;
|
|
@@ -100,8 +123,7 @@ declare abstract class Resolver {
|
|
|
100
123
|
constructor();
|
|
101
124
|
abstract checkIfCanSync(): Promise<boolean>;
|
|
102
125
|
abstract markSyncStarted(): Promise<void>;
|
|
103
|
-
abstract
|
|
104
|
-
abstract getConfig(command: ShoreCommand): Promise<ShoreConfig>;
|
|
126
|
+
abstract getState(): Promise<StateHolder>;
|
|
105
127
|
abstract writeCatalog(catalog: CatalogFile): Promise<void>;
|
|
106
128
|
abstract writeState(state: string): Promise<void>;
|
|
107
129
|
abstract markSyncFailed(): Promise<void>;
|
|
@@ -114,6 +136,131 @@ declare abstract class Resolver {
|
|
|
114
136
|
abstract getLogFormat(): winston.Logform.Format;
|
|
115
137
|
}
|
|
116
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
|
+
|
|
117
264
|
interface FlattenedSchema {
|
|
118
265
|
[unsafePropertyName: string]: JSONSchemaFieldDefinition;
|
|
119
266
|
}
|
|
@@ -273,165 +420,6 @@ declare abstract class ITarget<C extends BaseConfig = BaseConfig> {
|
|
|
273
420
|
static uploadSingleStreamToWarehouse: (streamState: StreamState$1) => Promise<void>;
|
|
274
421
|
}
|
|
275
422
|
|
|
276
|
-
type ReplicationMethod = "INCREMENTAL" | "FULL_TABLE" | "LOG_BASED";
|
|
277
|
-
type SyncFunction<C> = (target: ITarget, catalogStream: CatalogStream, config: C, catalog: Catalog) => Promise<void>;
|
|
278
|
-
type SourceType = `HUBSPOT` | `LAGROWTHMACHINE` | `SEGMENT` | `COHORT` | `AIRTABLE` | `AIRTABLE_OAUTH` | `BUBBLE` | `PIPEDRIVE` | `LINKEDIN_ADS` | `FACEBOOK_ADS` | `SEGMENT` | `SALESFORCE` | `SALESFORCE_SANDBOX` | `RECRUITCRM` | `GOOGLE_SHEETS` | `GOOGLE_ADS` | `GOOGLE_ANALYTICS` | `SLACK` | `STRIPE` | `ORBIT` | `GITHUB_STARS` | `JAFFLE_SHOP` | `POSTGRES` | `PENNYLANE` | `PENNYLANE_REDSHIFT` | `AIRCALL` | `AIRCALL_OAUTH` | `FAST_POSTGRES_FULL_TABLE` | `WOOCOMMERCE`;
|
|
279
|
-
type DestinationType = `GOOGLE_BIGQUERY` | `SNOWFLAKE`;
|
|
280
|
-
interface ShoreConfig {
|
|
281
|
-
command: ShoreCommand;
|
|
282
|
-
destination: DestinationType;
|
|
283
|
-
config: any;
|
|
284
|
-
targetConfig: any;
|
|
285
|
-
state?: any;
|
|
286
|
-
catalog?: CatalogFile;
|
|
287
|
-
}
|
|
288
|
-
type ShoreCommand = "READ" | "DISCOVER";
|
|
289
|
-
type ResolverType = "WHALY" | "LOCAL";
|
|
290
|
-
|
|
291
|
-
type InclusionMode = "available" | "automatic" | "unsupported";
|
|
292
|
-
interface MetadataEntry {
|
|
293
|
-
selected?: boolean;
|
|
294
|
-
"replication-method"?: ReplicationMethod;
|
|
295
|
-
"replication-key"?: string;
|
|
296
|
-
"view-key-properties"?: string[];
|
|
297
|
-
"inclusion"?: InclusionMode;
|
|
298
|
-
"selected-by-default"?: boolean;
|
|
299
|
-
"valid-replication-keys"?: string[];
|
|
300
|
-
"forced-replication-method"?: ReplicationMethod;
|
|
301
|
-
"forced-replication-key"?: string;
|
|
302
|
-
"table-key-properties"?: string[];
|
|
303
|
-
"schema-name"?: string;
|
|
304
|
-
"is-view"?: boolean;
|
|
305
|
-
"row-count"?: number;
|
|
306
|
-
"database-name"?: string;
|
|
307
|
-
"sql-datatype"?: string;
|
|
308
|
-
"whaly-display-label"?: string;
|
|
309
|
-
"whaly-description"?: string;
|
|
310
|
-
"whaly-parent-stream"?: StreamId;
|
|
311
|
-
}
|
|
312
|
-
interface CatalogMetadata {
|
|
313
|
-
breadcrumb: string[];
|
|
314
|
-
metadata: MetadataEntry;
|
|
315
|
-
}
|
|
316
|
-
declare class MetadataMap extends Map<string[], MetadataEntry> {
|
|
317
|
-
private areEquals;
|
|
318
|
-
private findExistingEntry;
|
|
319
|
-
get(key: string[]): MetadataEntry | undefined;
|
|
320
|
-
set(key: string[], value: MetadataEntry): this;
|
|
321
|
-
}
|
|
322
|
-
declare class StreamMetadata {
|
|
323
|
-
metadataByBreadcrumb: MetadataMap;
|
|
324
|
-
constructor();
|
|
325
|
-
fromCatalogStreamMetadata(metadataArr: CatalogMetadata[]): this;
|
|
326
|
-
toString(): MetadataMap;
|
|
327
|
-
get(breadcrumb: string[]): MetadataEntry | undefined;
|
|
328
|
-
write(breadcrumb: string[], key: string, value: any): this;
|
|
329
|
-
private getRootBreadcrumbMetadata;
|
|
330
|
-
isStreamSelected(): boolean;
|
|
331
|
-
getKeyProperties(): string[];
|
|
332
|
-
getReplicationKey(): string | undefined;
|
|
333
|
-
getReplicationMethod(): ReplicationMethod | undefined;
|
|
334
|
-
getForcedReplicationMethod(): ReplicationMethod | undefined;
|
|
335
|
-
toList(): CatalogMetadata[];
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
type StreamId = string;
|
|
339
|
-
type StreamName = string;
|
|
340
|
-
interface CatalogStream {
|
|
341
|
-
tap_stream_id: StreamId;
|
|
342
|
-
stream: StreamName;
|
|
343
|
-
schema: any;
|
|
344
|
-
metadata: CatalogMetadata[];
|
|
345
|
-
}
|
|
346
|
-
interface CatalogFile {
|
|
347
|
-
streams: CatalogStream[];
|
|
348
|
-
}
|
|
349
|
-
declare class Catalog {
|
|
350
|
-
streams?: CatalogStream[];
|
|
351
|
-
static fromFile(fileName: string): Catalog;
|
|
352
|
-
static fromCatalogFile(catalogFile: CatalogFile): Catalog;
|
|
353
|
-
getSelectedStreams(): CatalogStream[];
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
declare const writeStateFile: (resolver: Resolver, state: string) => Promise<void>;
|
|
357
|
-
declare const writeCatalogFile: (resolver: Resolver, catalog: CatalogFile) => Promise<void>;
|
|
358
|
-
declare const loadShoreConfig: (resolver: Resolver) => Promise<ShoreConfig>;
|
|
359
|
-
declare const loadJson: (fileName: string) => any;
|
|
360
|
-
declare const loadSchema: (streamId: string) => any;
|
|
361
|
-
declare const checkRequiredConfigKeys: (args: any, requiredConfigKeys: string[]) => void;
|
|
362
|
-
|
|
363
|
-
declare const getAxiosInstance: (retryCount?: number) => AxiosInstance;
|
|
364
|
-
interface GetConfig {
|
|
365
|
-
qs?: {
|
|
366
|
-
[key: string]: any;
|
|
367
|
-
};
|
|
368
|
-
headers?: AxiosRequestHeaders;
|
|
369
|
-
retryCount?: number;
|
|
370
|
-
}
|
|
371
|
-
declare const getRawJSONApiCall: <T>(endpoint: string, config: GetConfig, privateLogging?: boolean) => Promise<AxiosResponse<T>>;
|
|
372
|
-
declare const getJSONApiCallWithFullResponse: <T>(endpoint: string, config: GetConfig, privateLogging?: boolean) => Promise<AxiosResponse<any, any, {}>>;
|
|
373
|
-
declare const getJSONApiCall: <T>(endpoint: string, config: GetConfig, privateLogging?: boolean) => Promise<T>;
|
|
374
|
-
declare const getDownloadFileApiCall: <T>(endpoint: string, config: GetConfig, output: string, privateLogging?: boolean) => Promise<{
|
|
375
|
-
outputDir: string;
|
|
376
|
-
}>;
|
|
377
|
-
interface PostConfig {
|
|
378
|
-
qs?: {
|
|
379
|
-
[key: string]: any;
|
|
380
|
-
};
|
|
381
|
-
headers?: AxiosRequestHeaders;
|
|
382
|
-
retryCount?: number;
|
|
383
|
-
}
|
|
384
|
-
declare const postJSONApiCall: <T>(endpoint: string, config: PostConfig, payload: any) => Promise<T>;
|
|
385
|
-
declare const postFormDataApiCall: <T>(endpoint: string, config: PostConfig, payload: any) => Promise<T>;
|
|
386
|
-
declare const postUrlEncodedApiCall: (endpoint: string, config: PostConfig, payload: any) => Promise<any>;
|
|
387
|
-
|
|
388
|
-
declare const BATCH_INTERVAL_MS = 100;
|
|
389
|
-
declare const logger: {
|
|
390
|
-
info: (message: string | any, ...args: any[]) => void;
|
|
391
|
-
error: (message: string | any, ...args: any[]) => void;
|
|
392
|
-
debug: (message: string | any, ...args: any[]) => void;
|
|
393
|
-
warn: (message: string | any, ...args: any[]) => void;
|
|
394
|
-
closeWinston: (cb: () => void) => void;
|
|
395
|
-
};
|
|
396
|
-
|
|
397
|
-
declare const ALL_STREAM_ID_KEYWORD = "all";
|
|
398
|
-
declare const ROWS_SYNCED_METRIC_NAME = "rows_synced_count";
|
|
399
|
-
declare const API_CALLS_METRIC_NAME = "api_calls_count";
|
|
400
|
-
declare const EXECUTION_TIME_METRIC_NAME = "execution_time_ms";
|
|
401
|
-
interface MetricConfiguration {
|
|
402
|
-
isEnabled: () => boolean;
|
|
403
|
-
getStreamIds?: () => string[];
|
|
404
|
-
}
|
|
405
|
-
declare const getCounterMetrics: (name: string, streamIds: string[]) => CounterMetric[];
|
|
406
|
-
declare const getCounterMetric: (name: string, streamId?: string) => CounterMetric;
|
|
407
|
-
declare const getAllMetrics: () => CounterMetric[];
|
|
408
|
-
declare class CounterMetric {
|
|
409
|
-
private value;
|
|
410
|
-
name: string;
|
|
411
|
-
streamId: string;
|
|
412
|
-
constructor(name: string, streamId: string);
|
|
413
|
-
increment(inc?: number): void;
|
|
414
|
-
getStreamId(): string;
|
|
415
|
-
getName(): string;
|
|
416
|
-
getValue(): number;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
declare const printMemoryFootprint: (prefix: string) => void;
|
|
420
|
-
|
|
421
|
-
declare const haltAndCatchFire: (errorType: ErrorType, errorText: string, errorDebugText: string) => Promise<void>;
|
|
422
|
-
|
|
423
|
-
declare function gracefulExit(exitCode: number): Promise<void>;
|
|
424
|
-
|
|
425
|
-
declare const findRelatedRelationships: (streamId: StreamId, allRels: StreamRelationship[]) => DirectionalRelationships;
|
|
426
|
-
|
|
427
|
-
interface HTTPHeaders {
|
|
428
|
-
[headerName: string]: any;
|
|
429
|
-
}
|
|
430
|
-
interface URLParams {
|
|
431
|
-
[paramName: string]: any;
|
|
432
|
-
}
|
|
433
|
-
type HTTPMethod = "GET" | "POST";
|
|
434
|
-
|
|
435
423
|
interface InputTapState {
|
|
436
424
|
bookmarks?: {
|
|
437
425
|
[streamId: string]: StreamState;
|
|
@@ -499,12 +487,10 @@ declare class Authenticator<C> {
|
|
|
499
487
|
* C: Type of the tap configuration
|
|
500
488
|
* P: For children Streams, this is the type of the parent
|
|
501
489
|
*/
|
|
502
|
-
declare abstract class
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
_target: ITarget;
|
|
507
|
-
rootMetadataEntry: MetadataEntry | undefined;
|
|
490
|
+
declare abstract class Stream<O = any, C = any, P = undefined> {
|
|
491
|
+
config: C;
|
|
492
|
+
tapState: InputTapState;
|
|
493
|
+
target: ITarget;
|
|
508
494
|
forcedReplicationMethod: ReplicationMethod | undefined;
|
|
509
495
|
selectedByDefault: boolean;
|
|
510
496
|
STATE_MSG_FREQUENCY: number;
|
|
@@ -516,14 +502,13 @@ declare abstract class StreamV2<O = any, C = any, P = undefined> {
|
|
|
516
502
|
forcedReplicationKey: string | undefined;
|
|
517
503
|
useStateFromStreamId: string | undefined;
|
|
518
504
|
relationships: StreamRelationship[];
|
|
519
|
-
children:
|
|
505
|
+
children: Stream<any, any, O | O[]>[];
|
|
520
506
|
isSorted: boolean;
|
|
521
507
|
isSilent: boolean;
|
|
522
508
|
childConcurrency: number;
|
|
523
509
|
rowsSyncedMetricsConf: MetricConfiguration;
|
|
524
510
|
executionTimeMetricsConf: MetricConfiguration;
|
|
525
|
-
constructor(
|
|
526
|
-
setRootMetadataEntry: (rootMetadataEntry: MetadataEntry) => void;
|
|
511
|
+
constructor(config: C, state: InputTapState, target: ITarget, childConcurrency?: number);
|
|
527
512
|
/**
|
|
528
513
|
* Sync this stream
|
|
529
514
|
* Called only for streams with no parents, aka. "root tap streams"
|
|
@@ -615,9 +600,9 @@ declare abstract class StreamV2<O = any, C = any, P = undefined> {
|
|
|
615
600
|
* R: Type of the API result
|
|
616
601
|
* NPT: Type of the "nextPageToken"
|
|
617
602
|
*/
|
|
618
|
-
declare abstract class
|
|
603
|
+
declare abstract class RESTStream<R, O, NPT, C, P = undefined> extends Stream<O, C, P> {
|
|
619
604
|
axiosInstance: AxiosInstance | undefined;
|
|
620
|
-
constructor(
|
|
605
|
+
constructor(config: C, state: InputTapState, target: ITarget, childConcurrency?: number);
|
|
621
606
|
/**
|
|
622
607
|
* Prepare an Axios request object.
|
|
623
608
|
* Pagination information can be parsed from `nextPageToken` if `nextPageToken` is not undefined.
|
|
@@ -683,20 +668,18 @@ declare abstract class RESTStreamV2<R, O, NPT, C, P = undefined> extends StreamV
|
|
|
683
668
|
}
|
|
684
669
|
|
|
685
670
|
declare const DEFAULT_MAX_CONCURRENT_STREAMS = 5;
|
|
671
|
+
type SyncOptions = {
|
|
672
|
+
include?: string[];
|
|
673
|
+
exclude?: string[];
|
|
674
|
+
};
|
|
686
675
|
declare abstract class Tap<C> {
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
676
|
+
target: ITarget;
|
|
677
|
+
config: C;
|
|
678
|
+
streams: Stream[];
|
|
679
|
+
concurrency: number;
|
|
691
680
|
abstract init(): Promise<void>;
|
|
692
|
-
abstract requiredConfigKeys(): string[];
|
|
693
681
|
constructor(target: ITarget, config: C);
|
|
694
|
-
|
|
695
|
-
sync: (catalog: Catalog) => Promise<void>;
|
|
696
|
-
generateMetadataFromStream(stream: StreamV2, parentStreamId: string | undefined): Promise<{
|
|
697
|
-
metadata: CatalogMetadata[];
|
|
698
|
-
}>;
|
|
699
|
-
initiateSync(catalog: Catalog): Promise<void>;
|
|
682
|
+
sync: (options?: SyncOptions) => Promise<void>;
|
|
700
683
|
end(): Promise<void>;
|
|
701
684
|
}
|
|
702
685
|
|
|
@@ -722,4 +705,62 @@ declare const flattenSchema: <T>(streamId: StreamId, schema: T) => FlattenedSche
|
|
|
722
705
|
declare const createTemporaryFileStream: (streamId: StreamId) => TempFile;
|
|
723
706
|
declare function safePath(path: string): string;
|
|
724
707
|
|
|
725
|
-
|
|
708
|
+
interface BigQueryConfig extends BaseConfig {
|
|
709
|
+
schema: string;
|
|
710
|
+
project_id: string;
|
|
711
|
+
loading_deck_gcs_bucket_name: string;
|
|
712
|
+
location?: BigqueryLocation;
|
|
713
|
+
}
|
|
714
|
+
type BigqueryLocation = "US" | "EU";
|
|
715
|
+
|
|
716
|
+
declare class BigQueryDBSync extends StreamWarehouseSyncService {
|
|
717
|
+
config: BigQueryConfig;
|
|
718
|
+
bqClient: BigQuery;
|
|
719
|
+
bqDataset: Dataset;
|
|
720
|
+
bqTable: Table;
|
|
721
|
+
bqStagingTable: Table;
|
|
722
|
+
tableName: string;
|
|
723
|
+
stagingTableName: string;
|
|
724
|
+
sqlTableId: string;
|
|
725
|
+
sqlStagingTableId: string;
|
|
726
|
+
constructor(config: BigQueryConfig, streamId: StreamId, database: string, schema: string, table: string, renameColumnStore: RenameColumnStore);
|
|
727
|
+
getSerializedRecord: (record: any) => string;
|
|
728
|
+
safeColumnName: (key: string) => string;
|
|
729
|
+
getWarehouseTypeFromJSONSchema: (definition: JSONSchemaFieldDefinition) => string;
|
|
730
|
+
getMergeQueries: () => string[];
|
|
731
|
+
getReplaceQueries: () => string[];
|
|
732
|
+
createDatabaseAndSchemaIfNotExists: (retryCount: number) => Promise<void>;
|
|
733
|
+
createTable: () => Promise<void>;
|
|
734
|
+
addColumns: (tableFields: InternalTableField[]) => Promise<void>;
|
|
735
|
+
createStagingArea: () => Promise<void>;
|
|
736
|
+
loadStreamInStagingArea: (localFilePath: string) => Promise<void>;
|
|
737
|
+
deleteStagingArea: () => Promise<void>;
|
|
738
|
+
getTablesInSchema: () => Promise<{
|
|
739
|
+
tableName: string;
|
|
740
|
+
}[]>;
|
|
741
|
+
getTableColumnsFromWarehouse: () => Promise<WarehouseTableField[]>;
|
|
742
|
+
runQueries: (queries: string[]) => Promise<void>;
|
|
743
|
+
/**
|
|
744
|
+
*
|
|
745
|
+
* Generate a TableField definition object that can be passed to BigQuery APIs to define a column on a table
|
|
746
|
+
*
|
|
747
|
+
* @param colName
|
|
748
|
+
* @param schemaFieldDefinition
|
|
749
|
+
* @returns
|
|
750
|
+
*/
|
|
751
|
+
private getBigqueryTableFieldFromInternalSchemaFieldDefinition;
|
|
752
|
+
private generateBigquerySchema;
|
|
753
|
+
private loadGCSFileInTable;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
declare class BigQueryTarget extends ITarget<BigQueryConfig> {
|
|
757
|
+
constructor(config: BigQueryConfig, resolver: Resolver);
|
|
758
|
+
static requiredConfigKeys: string[];
|
|
759
|
+
newDBSyncInstance: (streamId: StreamId, database: string, schema: string, table: string) => BigQueryDBSync;
|
|
760
|
+
genTableName: (key: string) => string;
|
|
761
|
+
safeColumnNameConverter: (key: string) => string;
|
|
762
|
+
validateDateRange: (record: any, schema: FlattenedSchema) => any;
|
|
763
|
+
convertNumberIntoDecimal: (record: any, schema: FlattenedSchema) => any;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
export { ALL_STREAM_ID_KEYWORD, API_CALLS_METRIC_NAME, Authenticator, BATCH_INTERVAL_MS, type BaseConfig, type BigQueryConfig, BigQueryTarget, type BigqueryLocation, type Bookmark, type Bookmarks, type CatalogFile, type CatalogMetadata, type CatalogStream, type CatalogStreamMetadata, type ColumnMappingStoreUnsafeToSafe, CounterMetric, DEFAULT_MAX_CONCURRENT_STREAMS, type DestinationType, type DirectionalRelationship, type DirectionalRelationships, EXECUTION_TIME_METRIC_NAME, type ErrorType, type FlattenedSchema, type GetConfig, type HTTPHeaders, type HTTPMethod, ITarget, type InclusionMode, type InputTapState, type InternalTableField, type JSONSchemaFieldDefinition, type Message, type MessageType, type MetadataEntry, type MetricConfiguration, MissingFieldInSchemaError, MissingSchemaError, type PostConfig, type ProgressMarkers, type PropertiesMetadata, RESTStream, ROWS_SYNCED_METRIC_NAME, RecordMessage, RenameColumnStore, type ReplicationMethod, ReplicationMethodMessage, Resolver, type SafeColumnNameConverterFn, type Schema, SchemaMessage, SchemaValidationError, type State, type StateHolder, StateMessage, StateService, Stream, type StreamId, StreamMetadata, type StreamName, type StreamRelationship, type StreamState, StreamWarehouseSyncService, type StreamWithTempFile, type SyncOptions, Tap, type TapState, type TargetSchemaHook, type TargetSchemaHookInput, type TempFile, type URLParams, type WarehouseTableField, _greaterThan, addWhalyFields, createTemporaryFileStream, extractStateForStream, finalizeStateProgressMarkers, findRelatedRelationships, flattenSchema, getAllMetrics, getAxiosInstance, getCounterMetric, getCounterMetrics, getDownloadFileApiCall, getJSONApiCall, getJSONApiCallWithFullResponse, getRawJSONApiCall, gracefulExit, haltAndCatchFire, incrementStreamState, loadJson, loadResolver, loadSchema, logger, postFormDataApiCall, postJSONApiCall, postUrlEncodedApiCall, printMemoryFootprint, removeParasiteProperties, safePath, writeStateFile };
|