@whaly/connector-sdk 0.3.11 → 0.3.12

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.mjs CHANGED
@@ -14660,11 +14660,13 @@ var MAX_RETRIES2 = 10;
14660
14660
  var WhalyDocumentService = class {
14661
14661
  axiosClient;
14662
14662
  objectStorageId;
14663
+ documentSourceId;
14663
14664
  gcsBucket;
14664
14665
  constructor(config) {
14665
14666
  const resolvedKey = getServiceAccountKey(config.serviceAccountKey);
14666
14667
  const resolvedEndpoint = getApiEndpoint(config.apiEndpoint);
14667
14668
  this.objectStorageId = config.objectStorageId;
14669
+ this.documentSourceId = config.documentSourceId;
14668
14670
  const gcsBucketName = process.env["WLY_GCS_BUCKET"];
14669
14671
  if (gcsBucketName) {
14670
14672
  this.gcsBucket = new Storage2().bucket(gcsBucketName);
@@ -14699,12 +14701,16 @@ var WhalyDocumentService = class {
14699
14701
  }
14700
14702
  });
14701
14703
  }
14702
- /** Fetch all documents from the API, handling cursor-based pagination. */
14704
+ /**
14705
+ * Fetch all documents belonging to the configured document source,
14706
+ * handling cursor-based pagination. The `document_source_id` server-side
14707
+ * filter scopes the result to this connector's source only.
14708
+ */
14703
14709
  async listAllDocuments() {
14704
14710
  const documents = [];
14705
14711
  let after;
14706
14712
  while (true) {
14707
- const params = {};
14713
+ const params = { document_source_id: this.documentSourceId };
14708
14714
  if (after) params["after"] = after;
14709
14715
  const response = await this.axiosClient.get(
14710
14716
  "/v1/documents",
@@ -14764,19 +14770,26 @@ var WhalyDocumentService = class {
14764
14770
  throw enrichAxiosError(err);
14765
14771
  }
14766
14772
  }
14767
- /** Create a new document record. */
14773
+ /** Create a new document record, attached to the configured document source. */
14768
14774
  async createDocument(payload) {
14769
14775
  try {
14770
- const response = await this.axiosClient.post("/v1/documents", payload);
14776
+ const response = await this.axiosClient.post("/v1/documents", {
14777
+ ...payload,
14778
+ document_source_id: this.documentSourceId
14779
+ });
14771
14780
  return response.data.data ?? response.data;
14772
14781
  } catch (err) {
14773
14782
  throw enrichAxiosError(err);
14774
14783
  }
14775
14784
  }
14776
- /** Update an existing document record. */
14785
+ /** Update an existing document record, keeping it in the configured document source. */
14777
14786
  async updateDocument(id, payload) {
14778
14787
  try {
14779
- const response = await this.axiosClient.put(`/v1/documents/${id}`, { id, ...payload });
14788
+ const response = await this.axiosClient.put(`/v1/documents/${id}`, {
14789
+ id,
14790
+ ...payload,
14791
+ document_source_id: this.documentSourceId
14792
+ });
14780
14793
  return response.data.data ?? response.data;
14781
14794
  } catch (err) {
14782
14795
  throw enrichAxiosError(err);