@whaly/connector-sdk 0.3.11 → 0.3.13
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 +25 -4
- package/dist/index.d.ts +25 -4
- package/dist/index.js +44 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -11195,6 +11195,20 @@ var Tap = class {
|
|
|
11195
11195
|
|
|
11196
11196
|
// src/sdk/models/tap/stream.ts
|
|
11197
11197
|
import { format as format3 } from "util";
|
|
11198
|
+
var DEFAULT_PROGRESS_LOG_PERCENT_STEP = 10;
|
|
11199
|
+
var DEFAULT_PROGRESS_LOG_FALLBACK_INTERVAL = 1e5;
|
|
11200
|
+
function getProgressLogPercentStep() {
|
|
11201
|
+
const raw = optionalEnv("PROGRESS_LOG_PERCENT_STEP", String(DEFAULT_PROGRESS_LOG_PERCENT_STEP));
|
|
11202
|
+
const n = parseInt(raw, 10);
|
|
11203
|
+
if (isNaN(n) || n <= 0) return DEFAULT_PROGRESS_LOG_PERCENT_STEP;
|
|
11204
|
+
return Math.min(n, 100);
|
|
11205
|
+
}
|
|
11206
|
+
function getProgressLogFallbackInterval() {
|
|
11207
|
+
const raw = optionalEnv("PROGRESS_LOG_FALLBACK_INTERVAL", String(DEFAULT_PROGRESS_LOG_FALLBACK_INTERVAL));
|
|
11208
|
+
const n = parseInt(raw, 10);
|
|
11209
|
+
if (isNaN(n) || n <= 0) return DEFAULT_PROGRESS_LOG_FALLBACK_INTERVAL;
|
|
11210
|
+
return n;
|
|
11211
|
+
}
|
|
11198
11212
|
var Stream = class {
|
|
11199
11213
|
// Runtime values, can't be overriden
|
|
11200
11214
|
config;
|
|
@@ -11457,6 +11471,9 @@ var Stream = class {
|
|
|
11457
11471
|
// Private sync methods:
|
|
11458
11472
|
async _syncRecords(parent) {
|
|
11459
11473
|
let rowsSent = 0;
|
|
11474
|
+
let lastLoggedPercent = 0;
|
|
11475
|
+
const progressPercentStep = getProgressLogPercentStep();
|
|
11476
|
+
const progressFallbackInterval = getProgressLogFallbackInterval();
|
|
11460
11477
|
const dryRunLimit = isDryRun() ? getDryRunLimit() : void 0;
|
|
11461
11478
|
let recordSyncedMetrics = [];
|
|
11462
11479
|
if (this.rowsSyncedMetricsConf.isEnabled() === true) {
|
|
@@ -11503,9 +11520,14 @@ var Stream = class {
|
|
|
11503
11520
|
logger.info(`\u{1F6D1} Stream: ${this.streamId} - DRY_RUN_LIMIT reached (${dryRunLimit} records), stopping.`);
|
|
11504
11521
|
break;
|
|
11505
11522
|
}
|
|
11506
|
-
if (
|
|
11507
|
-
const
|
|
11508
|
-
|
|
11523
|
+
if (this.totalRows) {
|
|
11524
|
+
const percent = Math.floor(rowsSent / this.totalRows * 100);
|
|
11525
|
+
if (percent >= lastLoggedPercent + progressPercentStep) {
|
|
11526
|
+
lastLoggedPercent = percent - percent % progressPercentStep;
|
|
11527
|
+
logger.info(`\u23F3 Stream: ${this.streamId} - ${rowsSent} records synced so far... (${percent}%)`);
|
|
11528
|
+
}
|
|
11529
|
+
} else if (rowsSent % progressFallbackInterval === 0) {
|
|
11530
|
+
logger.info(`\u23F3 Stream: ${this.streamId} - ${rowsSent} records synced so far...`);
|
|
11509
11531
|
}
|
|
11510
11532
|
}
|
|
11511
11533
|
const stateServiceInst = StateService.getInstance();
|
|
@@ -14660,11 +14682,13 @@ var MAX_RETRIES2 = 10;
|
|
|
14660
14682
|
var WhalyDocumentService = class {
|
|
14661
14683
|
axiosClient;
|
|
14662
14684
|
objectStorageId;
|
|
14685
|
+
documentSourceId;
|
|
14663
14686
|
gcsBucket;
|
|
14664
14687
|
constructor(config) {
|
|
14665
14688
|
const resolvedKey = getServiceAccountKey(config.serviceAccountKey);
|
|
14666
14689
|
const resolvedEndpoint = getApiEndpoint(config.apiEndpoint);
|
|
14667
14690
|
this.objectStorageId = config.objectStorageId;
|
|
14691
|
+
this.documentSourceId = config.documentSourceId;
|
|
14668
14692
|
const gcsBucketName = process.env["WLY_GCS_BUCKET"];
|
|
14669
14693
|
if (gcsBucketName) {
|
|
14670
14694
|
this.gcsBucket = new Storage2().bucket(gcsBucketName);
|
|
@@ -14699,12 +14723,16 @@ var WhalyDocumentService = class {
|
|
|
14699
14723
|
}
|
|
14700
14724
|
});
|
|
14701
14725
|
}
|
|
14702
|
-
/**
|
|
14726
|
+
/**
|
|
14727
|
+
* Fetch all documents belonging to the configured document source,
|
|
14728
|
+
* handling cursor-based pagination. The `document_source_id` server-side
|
|
14729
|
+
* filter scopes the result to this connector's source only.
|
|
14730
|
+
*/
|
|
14703
14731
|
async listAllDocuments() {
|
|
14704
14732
|
const documents = [];
|
|
14705
14733
|
let after;
|
|
14706
14734
|
while (true) {
|
|
14707
|
-
const params = {};
|
|
14735
|
+
const params = { document_source_id: this.documentSourceId };
|
|
14708
14736
|
if (after) params["after"] = after;
|
|
14709
14737
|
const response = await this.axiosClient.get(
|
|
14710
14738
|
"/v1/documents",
|
|
@@ -14764,19 +14792,26 @@ var WhalyDocumentService = class {
|
|
|
14764
14792
|
throw enrichAxiosError(err);
|
|
14765
14793
|
}
|
|
14766
14794
|
}
|
|
14767
|
-
/** Create a new document record. */
|
|
14795
|
+
/** Create a new document record, attached to the configured document source. */
|
|
14768
14796
|
async createDocument(payload) {
|
|
14769
14797
|
try {
|
|
14770
|
-
const response = await this.axiosClient.post("/v1/documents",
|
|
14798
|
+
const response = await this.axiosClient.post("/v1/documents", {
|
|
14799
|
+
...payload,
|
|
14800
|
+
document_source_id: this.documentSourceId
|
|
14801
|
+
});
|
|
14771
14802
|
return response.data.data ?? response.data;
|
|
14772
14803
|
} catch (err) {
|
|
14773
14804
|
throw enrichAxiosError(err);
|
|
14774
14805
|
}
|
|
14775
14806
|
}
|
|
14776
|
-
/** Update an existing document record. */
|
|
14807
|
+
/** Update an existing document record, keeping it in the configured document source. */
|
|
14777
14808
|
async updateDocument(id, payload) {
|
|
14778
14809
|
try {
|
|
14779
|
-
const response = await this.axiosClient.put(`/v1/documents/${id}`, {
|
|
14810
|
+
const response = await this.axiosClient.put(`/v1/documents/${id}`, {
|
|
14811
|
+
id,
|
|
14812
|
+
...payload,
|
|
14813
|
+
document_source_id: this.documentSourceId
|
|
14814
|
+
});
|
|
14780
14815
|
return response.data.data ?? response.data;
|
|
14781
14816
|
} catch (err) {
|
|
14782
14817
|
throw enrichAxiosError(err);
|