@whaly/connector-sdk 0.3.13 → 0.4.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/dist/index.mjs CHANGED
@@ -10864,6 +10864,32 @@ function getExtension(mimeType) {
10864
10864
  return EXTENSION_BY_MIME[mimeType] ?? ".bin";
10865
10865
  }
10866
10866
 
10867
+ // src/sdk/service/runInput.ts
10868
+ function getInputFiles(env = process.env) {
10869
+ const list = env.WLY_FILE_URIS;
10870
+ if (list) {
10871
+ const parsed = JSON.parse(list);
10872
+ if (!Array.isArray(parsed) || !parsed.every((item) => typeof item === "string")) {
10873
+ throw new Error("WLY_FILE_URIS must be a JSON array of strings");
10874
+ }
10875
+ if (parsed.length > 0) {
10876
+ return parsed;
10877
+ }
10878
+ }
10879
+ return env.FILE_URI ? [env.FILE_URI] : [];
10880
+ }
10881
+ function getEmailMetadata(env = process.env) {
10882
+ const raw = env.WLY_EMAIL_METADATA;
10883
+ if (!raw) {
10884
+ return void 0;
10885
+ }
10886
+ return JSON.parse(raw);
10887
+ }
10888
+ function getRunTrigger(env = process.env) {
10889
+ const trigger = env.WLY_RUN_TRIGGER;
10890
+ return trigger === "EMAIL" || trigger === "REPLAY" ? trigger : "MANUAL";
10891
+ }
10892
+
10867
10893
  // src/sdk/models/replication.ts
10868
10894
  var ReplicationMethod = /* @__PURE__ */ ((ReplicationMethod2) => {
10869
10895
  ReplicationMethod2["INCREMENTAL"] = "INCREMENTAL";
@@ -13454,10 +13480,24 @@ function createCsvStreamConfig(streamId, csvConfig, options) {
13454
13480
  async function processFileStreams(entries, tapState, target) {
13455
13481
  for (const entry of entries) {
13456
13482
  const stream = new FileStream(entry.config, entry.filePath, tapState, target);
13457
- await stream.sync();
13483
+ try {
13484
+ await stream.sync();
13485
+ } catch (err) {
13486
+ throw new FileProcessingError(entry.filePath, entry.config.streamId, err);
13487
+ }
13458
13488
  }
13459
13489
  await target.complete();
13460
13490
  }
13491
+ var FileProcessingError = class extends Error {
13492
+ constructor(filePath, streamId, cause) {
13493
+ const files = Array.isArray(filePath) ? filePath.join(", ") : filePath;
13494
+ super(`Processing ${files} (stream ${streamId}) failed: ${cause instanceof Error ? cause.message : String(cause)}`);
13495
+ this.filePath = filePath;
13496
+ this.streamId = streamId;
13497
+ this.cause = cause;
13498
+ this.name = "FileProcessingError";
13499
+ }
13500
+ };
13461
13501
 
13462
13502
  // src/sdk/file-processing/csv/config-builder.ts
13463
13503
  var CsvExtractionConfigBuilder = class _CsvExtractionConfigBuilder {
@@ -13583,6 +13623,16 @@ var VariableExtractors = class {
13583
13623
  return match?.groups ?? {};
13584
13624
  };
13585
13625
  }
13626
+ /**
13627
+ * Extracts named capture groups from the subject of the email that started the run, for
13628
+ * scheduled reports whose date only appears in the subject. Empty for manual uploads.
13629
+ */
13630
+ static emailSubject(pattern) {
13631
+ return () => {
13632
+ const subject = getEmailMetadata()?.subject;
13633
+ return subject ? subject.match(pattern)?.groups ?? {} : {};
13634
+ };
13635
+ }
13586
13636
  /**
13587
13637
  * Combines multiple extraction functions.
13588
13638
  */
@@ -15577,6 +15627,7 @@ export {
15577
15627
  ExcelExtractionConfigBuilder,
15578
15628
  FileFormat,
15579
15629
  FilePatterns,
15630
+ FileProcessingError,
15580
15631
  FileStream,
15581
15632
  FileTap,
15582
15633
  GCSStateProvider,
@@ -15638,11 +15689,14 @@ export {
15638
15689
  getCounterMetrics,
15639
15690
  getDownloadFileApiCall,
15640
15691
  getDryRunLimit,
15692
+ getEmailMetadata,
15641
15693
  getExtension,
15694
+ getInputFiles,
15642
15695
  getJSONApiCall,
15643
15696
  getJSONApiCallWithFullResponse,
15644
15697
  getMimeType,
15645
15698
  getRawJSONApiCall,
15699
+ getRunTrigger,
15646
15700
  getServiceAccountKey,
15647
15701
  gracefulExit,
15648
15702
  haltAndCatchFire,