@trigger.dev/sdk 2.0.0-next.20 → 2.0.0-next.21

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.ts CHANGED
@@ -3640,7 +3640,9 @@ declare class ExternalSource<TIntegration extends TriggerIntegration<Integration
3640
3640
  get id(): string;
3641
3641
  get version(): string;
3642
3642
  }
3643
- type ExternalSourceParams<TExternalSource extends ExternalSource<any, any, any>> = TExternalSource extends ExternalSource<any, infer TParams, any> ? TParams : never;
3643
+ type ExternalSourceParams<TExternalSource extends ExternalSource<any, any, any>> = TExternalSource extends ExternalSource<any, infer TParams, any> ? TParams & {
3644
+ filter?: EventFilter;
3645
+ } : never;
3644
3646
  type ExternalSourceTriggerOptions<TEventSpecification extends EventSpecification<any>, TEventSource extends ExternalSource<any, any, any>> = {
3645
3647
  event: TEventSpecification;
3646
3648
  source: TEventSource;
package/dist/index.js CHANGED
@@ -1038,24 +1038,18 @@ var GetEventSchema = import_zod13.z.object({
1038
1038
  });
1039
1039
 
1040
1040
  // ../internal/src/utils.ts
1041
- function deepMergeFilters(filter, other) {
1042
- const result = {
1043
- ...filter
1044
- };
1045
- for (const key in other) {
1046
- if (other.hasOwnProperty(key)) {
1047
- const otherValue = other[key];
1048
- if (typeof otherValue === "object" && !Array.isArray(otherValue) && otherValue !== null) {
1041
+ function deepMergeFilters(...filters) {
1042
+ const result = {};
1043
+ for (const filter of filters) {
1044
+ for (const key in filter) {
1045
+ if (filter.hasOwnProperty(key)) {
1049
1046
  const filterValue = filter[key];
1050
- if (filterValue && typeof filterValue === "object" && !Array.isArray(filterValue)) {
1051
- result[key] = deepMergeFilters(filterValue, otherValue);
1047
+ const existingValue = result[key];
1048
+ if (existingValue && typeof existingValue === "object" && typeof filterValue === "object" && !Array.isArray(existingValue) && !Array.isArray(filterValue) && existingValue !== null && filterValue !== null) {
1049
+ result[key] = deepMergeFilters(existingValue, filterValue);
1052
1050
  } else {
1053
- result[key] = {
1054
- ...other[key]
1055
- };
1051
+ result[key] = filterValue;
1056
1052
  }
1057
- } else {
1058
- result[key] = other[key];
1059
1053
  }
1060
1054
  }
1061
1055
  }
@@ -1862,16 +1856,23 @@ var IO = class {
1862
1856
  throw error;
1863
1857
  }
1864
1858
  if (onError) {
1865
- const onErrorResult = onError(error, task, this);
1866
- if (onErrorResult) {
1867
- if (onErrorResult instanceof Error) {
1868
- error = onErrorResult;
1869
- } else {
1870
- const parsedError2 = ErrorWithStackSchema.safeParse(onErrorResult.error);
1871
- throw new RetryWithTaskError(parsedError2.success ? parsedError2.data : {
1872
- message: "Unknown error"
1873
- }, task, onErrorResult.retryAt);
1859
+ try {
1860
+ const onErrorResult = onError(error, task, this);
1861
+ if (onErrorResult) {
1862
+ if (onErrorResult instanceof Error) {
1863
+ error = onErrorResult;
1864
+ } else {
1865
+ const parsedError2 = ErrorWithStackSchema.safeParse(onErrorResult.error);
1866
+ throw new RetryWithTaskError(parsedError2.success ? parsedError2.data : {
1867
+ message: "Unknown error"
1868
+ }, task, onErrorResult.retryAt);
1869
+ }
1870
+ }
1871
+ } catch (innerError) {
1872
+ if (isTriggerError(innerError)) {
1873
+ throw innerError;
1874
1874
  }
1875
+ error = innerError;
1875
1876
  }
1876
1877
  }
1877
1878
  const parsedError = ErrorWithStackSchema.safeParse(error);
@@ -2756,7 +2757,7 @@ var ExternalSourceTrigger = class {
2756
2757
  title: "External Source",
2757
2758
  rule: {
2758
2759
  event: this.event.name,
2759
- payload: deepMergeFilters(this.options.source.filter(this.options.params), this.event.filter ?? {}),
2760
+ payload: deepMergeFilters(this.options.source.filter(this.options.params), this.event.filter ?? {}, this.options.params.filter ?? {}),
2760
2761
  source: this.event.source
2761
2762
  },
2762
2763
  properties: this.options.source.properties(this.options.params)