@trigger.dev/sdk 2.0.0-next.20 → 2.0.0-next.22
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 +8 -2
- package/dist/index.js +26 -25
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3512,6 +3512,7 @@ interface Trigger<TEventSpec extends EventSpecification<any>> {
|
|
|
3512
3512
|
attachToJob(triggerClient: TriggerClient, job: Job<Trigger<TEventSpec>, any>): void;
|
|
3513
3513
|
preprocessRuns: boolean;
|
|
3514
3514
|
}
|
|
3515
|
+
type TriggerPayload<TTrigger> = TTrigger extends Trigger<EventSpecification<infer TEvent>> ? TEvent : never;
|
|
3515
3516
|
type EventSpecificationExample = {
|
|
3516
3517
|
id: string;
|
|
3517
3518
|
name: string;
|
|
@@ -3640,7 +3641,9 @@ declare class ExternalSource<TIntegration extends TriggerIntegration<Integration
|
|
|
3640
3641
|
get id(): string;
|
|
3641
3642
|
get version(): string;
|
|
3642
3643
|
}
|
|
3643
|
-
type ExternalSourceParams<TExternalSource extends ExternalSource<any, any, any>> = TExternalSource extends ExternalSource<any, infer TParams, any> ? TParams
|
|
3644
|
+
type ExternalSourceParams<TExternalSource extends ExternalSource<any, any, any>> = TExternalSource extends ExternalSource<any, infer TParams, any> ? TParams & {
|
|
3645
|
+
filter?: EventFilter;
|
|
3646
|
+
} : never;
|
|
3644
3647
|
type ExternalSourceTriggerOptions<TEventSpecification extends EventSpecification<any>, TEventSource extends ExternalSource<any, any, any>> = {
|
|
3645
3648
|
event: TEventSpecification;
|
|
3646
3649
|
source: TEventSource;
|
|
@@ -4206,6 +4209,7 @@ type ExtractIntegrationClientClient<TIntegrationClient extends IntegrationClient
|
|
|
4206
4209
|
runTask: IntegrationRunTaskFunction<TClient>;
|
|
4207
4210
|
} : never;
|
|
4208
4211
|
type ExtractIntegrationClient<TIntegrationClient extends IntegrationClient<any, any>> = ExtractIntegrationClientClient<TIntegrationClient> & ExtractTasks<TIntegrationClient["tasks"]>;
|
|
4212
|
+
type IntegrationIO<TIntegration extends TriggerIntegration<IntegrationClient<any, any>>> = ExtractIntegrationClient<TIntegration["client"]>;
|
|
4209
4213
|
type ExtractIntegrations<TIntegrations extends Record<string, TriggerIntegration<IntegrationClient<any, any>>>> = {
|
|
4210
4214
|
[key in keyof TIntegrations]: ExtractIntegrationClient<TIntegrations[key]["client"]>;
|
|
4211
4215
|
};
|
|
@@ -4259,6 +4263,8 @@ type JobOptions<TTrigger extends Trigger<EventSpecification<any>>, TIntegrations
|
|
|
4259
4263
|
*/
|
|
4260
4264
|
run: (payload: TriggerEventType<TTrigger>, io: IOWithIntegrations<TIntegrations>, context: TriggerContext) => Promise<any>;
|
|
4261
4265
|
};
|
|
4266
|
+
type JobPayload<TJob> = TJob extends Job<Trigger<EventSpecification<infer TEvent>>, any> ? TEvent : never;
|
|
4267
|
+
type JobIO<TJob> = TJob extends Job<any, infer TIntegrations> ? IOWithIntegrations<TIntegrations> : never;
|
|
4262
4268
|
/** A [Job](https://trigger.dev/docs/documentation/concepts/jobs) is used to define the [Trigger](https://trigger.dev/docs/documentation/concepts/triggers), metadata, and what happens when it runs. */
|
|
4263
4269
|
declare class Job<TTrigger extends Trigger<EventSpecification<any>>, TIntegrations extends Record<string, TriggerIntegration<IntegrationClient<any, any>>> = {}> {
|
|
4264
4270
|
#private;
|
|
@@ -4455,4 +4461,4 @@ type Task = ServerTask;
|
|
|
4455
4461
|
type SentEvent = ApiEventLog;
|
|
4456
4462
|
declare function redactString(strings: TemplateStringsArray, ...interpolations: string[]): RedactString;
|
|
4457
4463
|
|
|
4458
|
-
export { AuthenticatedTask, ClientFactory, CronTrigger, DynamicIntervalOptions, DynamicSchedule, DynamicTrigger, DynamicTriggerOptions, EventFilter, EventSpecification, EventSpecificationExample, EventTrigger, EventTypeFromSpecification, ExternalSource, ExternalSourceParams, ExternalSourceTrigger, ExternalSourceTriggerOptions, HandlerEvent, HttpSourceEvent, IO, IOLogger, IOOptions, IOTask, IOWithIntegrations, IntegrationClient, IntervalTrigger, Job, JobOptions, Logger, MissingConnectionNotification, MissingConnectionResolvedNotification, NormalizedRequest, PreprocessResults, RedactString, SentEvent, Task, TaskLogger, Trigger, TriggerClient, TriggerClientOptions, TriggerContext, TriggerEventType, TriggerIntegration, TriggerPreprocessContext, authenticatedTask, cronTrigger, eventTrigger, intervalTrigger, isTriggerError, missingConnectionNotification, missingConnectionResolvedNotification, omit, redactString };
|
|
4464
|
+
export { AuthenticatedTask, ClientFactory, CronTrigger, DynamicIntervalOptions, DynamicSchedule, DynamicTrigger, DynamicTriggerOptions, EventFilter, EventSpecification, EventSpecificationExample, EventTrigger, EventTypeFromSpecification, ExternalSource, ExternalSourceParams, ExternalSourceTrigger, ExternalSourceTriggerOptions, HandlerEvent, HttpSourceEvent, IO, IOLogger, IOOptions, IOTask, IOWithIntegrations, IntegrationClient, IntegrationIO, IntervalTrigger, Job, JobIO, JobOptions, JobPayload, Logger, MissingConnectionNotification, MissingConnectionResolvedNotification, NormalizedRequest, PreprocessResults, RedactString, SentEvent, Task, TaskLogger, Trigger, TriggerClient, TriggerClientOptions, TriggerContext, TriggerEventType, TriggerIntegration, TriggerPayload, TriggerPreprocessContext, authenticatedTask, cronTrigger, eventTrigger, intervalTrigger, isTriggerError, missingConnectionNotification, missingConnectionResolvedNotification, omit, redactString };
|
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(
|
|
1042
|
-
const result = {
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
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
|
-
|
|
1051
|
-
|
|
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
|
-
|
|
1866
|
-
|
|
1867
|
-
if (onErrorResult
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
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)
|