@trigger.dev/sdk 2.0.14 → 2.1.0-beta.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.d.ts +106 -103
- package/dist/index.js +153 -166
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _trigger_dev_core from '@trigger.dev/core';
|
|
2
|
-
import { RunTaskBodyInput, CompleteTaskBodyInput, FailTaskBodyInput, SendEvent, SendEventOptions,
|
|
3
|
-
export { EventFilter, Logger, NormalizedRequest, RedactString } from '@trigger.dev/core';
|
|
2
|
+
import { RunTaskBodyInput, CompleteTaskBodyInput, FailTaskBodyInput, SendEvent, SendEventOptions, UpdateTriggerSourceBodyV2, TriggerSource, RegisterTriggerBodyV2, RegisterSourceEventV2, ScheduleMetadata, GetRunOptionsWithTaskDetails, GetRunsOptions, LogLevel, RuntimeEnvironmentType, DisplayProperty, TriggerMetadata, EventFilter, Prettify, HandleTriggerSource, Logger, RegisterTriggerSource, SerializableJson, ConnectionAuth, NormalizedResponse, HttpSourceResponseMetadata, DeserializedJson, IntervalOptions, CronOptions, ScheduledPayload, ServerTask, CachedTask, FetchRequestInit, FetchRetryOptions, RunTaskOptions, IntegrationMetadata, QueueOptions, IntegrationConfig, JobMetadata, MissingConnectionNotificationPayload, MissingConnectionResolvedNotificationPayload, ErrorWithStack, ApiEventLog, RedactString } from '@trigger.dev/core';
|
|
3
|
+
export { ConnectionAuth, DisplayProperty, EventFilter, Logger, NormalizedRequest, Prettify, RedactString, RegisteredOptionsDiff, RunTaskOptions, SourceEventOption } from '@trigger.dev/core';
|
|
4
4
|
import * as zod from 'zod';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
|
|
@@ -145,8 +145,8 @@ declare class ApiClient {
|
|
|
145
145
|
deliveredAt?: Date | null | undefined;
|
|
146
146
|
cancelledAt?: Date | null | undefined;
|
|
147
147
|
}>;
|
|
148
|
-
updateSource(client: string, key: string, source:
|
|
149
|
-
registerTrigger(client: string, id: string, key: string, payload:
|
|
148
|
+
updateSource(client: string, key: string, source: UpdateTriggerSourceBodyV2): Promise<TriggerSource>;
|
|
149
|
+
registerTrigger(client: string, id: string, key: string, payload: RegisterTriggerBodyV2): Promise<RegisterSourceEventV2>;
|
|
150
150
|
registerSchedule(client: string, id: string, key: string, payload: ScheduleMetadata): Promise<{
|
|
151
151
|
id: string;
|
|
152
152
|
schedule: {
|
|
@@ -351,10 +351,20 @@ type ExternalSourceChannelMap = {
|
|
|
351
351
|
};
|
|
352
352
|
};
|
|
353
353
|
type ChannelNames = keyof ExternalSourceChannelMap;
|
|
354
|
-
type
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
354
|
+
type TriggerOptionDiff = {
|
|
355
|
+
desired: string[];
|
|
356
|
+
missing: string[];
|
|
357
|
+
orphaned: string[];
|
|
358
|
+
};
|
|
359
|
+
type TriggerOptionDiffs<TTriggerOptionDefinitions extends Record<string, string[]> = any> = TriggerOptionsRecordWithEvent<TriggerOptionDiff, TTriggerOptionDefinitions>;
|
|
360
|
+
type TriggerOptionsRecordWithEvent<TValue, TTriggerOptionDefinitions extends Record<string, string[]>> = {
|
|
361
|
+
event: TValue;
|
|
362
|
+
} & TriggerOptionRecord<TValue, TTriggerOptionDefinitions>;
|
|
363
|
+
type TriggerOptionRecord<TValue, TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
|
|
364
|
+
[K in keyof TTriggerOptionDefinitions]: TValue;
|
|
365
|
+
};
|
|
366
|
+
type RegisterFunctionEvent<TChannel extends ChannelNames, TParams extends any, TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
|
|
367
|
+
options: TriggerOptionDiffs<TTriggerOptionDefinitions>;
|
|
358
368
|
source: {
|
|
359
369
|
active: boolean;
|
|
360
370
|
data?: any;
|
|
@@ -362,36 +372,49 @@ type RegisterFunctionEvent<TChannel extends ChannelNames, TParams extends any> =
|
|
|
362
372
|
} & ExternalSourceChannelMap[TChannel]["register"];
|
|
363
373
|
params: TParams;
|
|
364
374
|
};
|
|
365
|
-
type
|
|
375
|
+
type RegisterSourceEvent<TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
|
|
376
|
+
id: string;
|
|
377
|
+
source: RegisterTriggerSource;
|
|
378
|
+
dynamicTriggerId?: string;
|
|
379
|
+
options: TriggerOptionDiffs<TTriggerOptionDefinitions>;
|
|
380
|
+
};
|
|
381
|
+
type RegisterFunctionOutput<TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
|
|
382
|
+
secret?: string;
|
|
383
|
+
data?: SerializableJson;
|
|
384
|
+
options: TriggerOptionsRecordWithEvent<string[], TTriggerOptionDefinitions>;
|
|
385
|
+
};
|
|
386
|
+
type RegisterFunction<TIntegration extends TriggerIntegration, TParams extends any, TChannel extends ChannelNames, TTriggerOptionDefinitions extends Record<string, string[]> = any> = (event: RegisterFunctionEvent<TChannel, TParams, TTriggerOptionDefinitions>, io: IOWithIntegrations<{
|
|
366
387
|
integration: TIntegration;
|
|
367
|
-
}>, ctx: TriggerContext) => Promise<
|
|
388
|
+
}>, ctx: TriggerContext) => Promise<RegisterFunctionOutput<TTriggerOptionDefinitions> | undefined>;
|
|
368
389
|
type HandlerEvent<TChannel extends ChannelNames, TParams extends any = any> = {
|
|
369
390
|
rawEvent: ExternalSourceChannelMap[TChannel]["event"];
|
|
370
|
-
source: HandleTriggerSource & {
|
|
391
|
+
source: Prettify<Omit<HandleTriggerSource, "params"> & {
|
|
371
392
|
params: TParams;
|
|
372
|
-
}
|
|
393
|
+
}>;
|
|
373
394
|
};
|
|
374
|
-
type HandlerFunction<TChannel extends ChannelNames, TParams extends any> = (event: HandlerEvent<TChannel, TParams>, logger: Logger) => Promise<{
|
|
395
|
+
type HandlerFunction<TChannel extends ChannelNames, TParams extends any, TTriggerIntegration extends TriggerIntegration> = (event: HandlerEvent<TChannel, TParams>, logger: Logger, integration: TTriggerIntegration, auth?: ConnectionAuth) => Promise<{
|
|
375
396
|
events: SendEvent[];
|
|
376
397
|
response?: NormalizedResponse;
|
|
398
|
+
metadata?: HttpSourceResponseMetadata;
|
|
377
399
|
} | void>;
|
|
378
400
|
type KeyFunction<TParams extends any> = (params: TParams) => string;
|
|
379
|
-
type FilterFunction<TParams extends any> = (params: TParams) => EventFilter;
|
|
380
|
-
type ExternalSourceOptions<TChannel extends ChannelNames, TIntegration extends TriggerIntegration
|
|
401
|
+
type FilterFunction<TParams extends any, TTriggerOptionDefinitions extends Record<string, string[]> = any> = (params: TParams, options?: TTriggerOptionDefinitions) => EventFilter;
|
|
402
|
+
type ExternalSourceOptions<TChannel extends ChannelNames, TIntegration extends TriggerIntegration, TParams extends any, TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
|
|
381
403
|
id: string;
|
|
382
404
|
version: string;
|
|
383
405
|
schema: z.Schema<TParams>;
|
|
406
|
+
optionSchema?: z.Schema<TTriggerOptionDefinitions>;
|
|
384
407
|
integration: TIntegration;
|
|
385
|
-
register: RegisterFunction<TIntegration, TParams, TChannel>;
|
|
386
|
-
filter?: FilterFunction<TParams>;
|
|
387
|
-
handler: HandlerFunction<TChannel, TParams>;
|
|
408
|
+
register: RegisterFunction<TIntegration, TParams, TChannel, TTriggerOptionDefinitions>;
|
|
409
|
+
filter?: FilterFunction<TParams, TTriggerOptionDefinitions>;
|
|
410
|
+
handler: HandlerFunction<TChannel, TParams, TIntegration>;
|
|
388
411
|
key: KeyFunction<TParams>;
|
|
389
412
|
properties?: (params: TParams) => DisplayProperty[];
|
|
390
413
|
};
|
|
391
|
-
declare class ExternalSource<TIntegration extends TriggerIntegration
|
|
414
|
+
declare class ExternalSource<TIntegration extends TriggerIntegration, TParams extends any, TChannel extends ChannelNames = ChannelNames, TTriggerOptionDefinitions extends Record<string, string[]> = any> {
|
|
392
415
|
private options;
|
|
393
416
|
channel: TChannel;
|
|
394
|
-
constructor(channel: TChannel, options: ExternalSourceOptions<TChannel, TIntegration, TParams>);
|
|
417
|
+
constructor(channel: TChannel, options: ExternalSourceOptions<TChannel, TIntegration, TParams, TTriggerOptionDefinitions>);
|
|
395
418
|
handle(source: HandleTriggerSource, rawEvent: ExternalSourceChannelMap[TChannel]["event"], logger: Logger): Promise<void | {
|
|
396
419
|
events: {
|
|
397
420
|
name: string;
|
|
@@ -406,14 +429,11 @@ declare class ExternalSource<TIntegration extends TriggerIntegration<Integration
|
|
|
406
429
|
body?: any;
|
|
407
430
|
headers?: Record<string, string> | undefined;
|
|
408
431
|
} | undefined;
|
|
432
|
+
metadata?: _trigger_dev_core.DeserializedJson | undefined;
|
|
409
433
|
}>;
|
|
410
|
-
filter(params: TParams): EventFilter;
|
|
434
|
+
filter(params: TParams, options?: TTriggerOptionDefinitions): EventFilter;
|
|
411
435
|
properties(params: TParams): DisplayProperty[];
|
|
412
|
-
register(params: TParams, registerEvent: RegisterSourceEvent
|
|
413
|
-
registeredEvents: string[];
|
|
414
|
-
secret?: string | undefined;
|
|
415
|
-
data?: _trigger_dev_core.SerializableJson;
|
|
416
|
-
} | undefined>;
|
|
436
|
+
register(params: TParams, registerEvent: RegisterSourceEvent<TTriggerOptionDefinitions>, io: IO, ctx: TriggerContext): Promise<RegisterFunctionOutput<TTriggerOptionDefinitions> | undefined>;
|
|
417
437
|
key(params: TParams): string;
|
|
418
438
|
get integration(): TIntegration;
|
|
419
439
|
get integrationConfig(): {
|
|
@@ -430,10 +450,11 @@ declare class ExternalSource<TIntegration extends TriggerIntegration<Integration
|
|
|
430
450
|
type ExternalSourceParams<TExternalSource extends ExternalSource<any, any, any>> = TExternalSource extends ExternalSource<any, infer TParams, any> ? TParams & {
|
|
431
451
|
filter?: EventFilter;
|
|
432
452
|
} : never;
|
|
433
|
-
type ExternalSourceTriggerOptions<TEventSpecification extends EventSpecification<any>, TEventSource extends ExternalSource<any, any, any
|
|
453
|
+
type ExternalSourceTriggerOptions<TEventSpecification extends EventSpecification<any>, TEventSource extends ExternalSource<any, any, any>, TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
|
|
434
454
|
event: TEventSpecification;
|
|
435
455
|
source: TEventSource;
|
|
436
456
|
params: ExternalSourceParams<TEventSource>;
|
|
457
|
+
options: TriggerOptionRecord<string[], TTriggerOptionDefinitions>;
|
|
437
458
|
};
|
|
438
459
|
declare class ExternalSourceTrigger<TEventSpecification extends EventSpecification<any>, TEventSource extends ExternalSource<any, any, any>> implements Trigger<TEventSpecification> {
|
|
439
460
|
private options;
|
|
@@ -480,12 +501,12 @@ declare class DynamicTrigger<TEventSpec extends EventSpecification<any>, TExtern
|
|
|
480
501
|
toJSON(): TriggerMetadata;
|
|
481
502
|
get id(): string;
|
|
482
503
|
get event(): TEventSpec;
|
|
483
|
-
registeredTriggerForParams(params: ExternalSourceParams<TExternalSource>):
|
|
504
|
+
registeredTriggerForParams(params: ExternalSourceParams<TExternalSource>): RegisterTriggerBodyV2;
|
|
484
505
|
/** Use this method to register a new configuration with the DynamicTrigger.
|
|
485
506
|
* @param key The key for the configuration. This will be used to identify the configuration when it is triggered.
|
|
486
507
|
* @param params The params for the configuration.
|
|
487
508
|
*/
|
|
488
|
-
register(key: string, params: ExternalSourceParams<TExternalSource>): Promise<
|
|
509
|
+
register(key: string, params: ExternalSourceParams<TExternalSource>): Promise<RegisterSourceEventV2>;
|
|
489
510
|
attachToJob(triggerClient: TriggerClient, job: Job<Trigger<TEventSpec>, any>): void;
|
|
490
511
|
get preprocessRuns(): boolean;
|
|
491
512
|
}
|
|
@@ -523,10 +544,22 @@ declare class TriggerClient {
|
|
|
523
544
|
source: ExternalSource<any, any>;
|
|
524
545
|
event: EventSpecification<any>;
|
|
525
546
|
params: any;
|
|
547
|
+
options?: Record<string, string[]>;
|
|
526
548
|
}): void;
|
|
527
549
|
attachDynamicSchedule(key: string, job: Job<Trigger<any>, any>): void;
|
|
528
|
-
registerTrigger(id: string, key: string, options:
|
|
550
|
+
registerTrigger(id: string, key: string, options: RegisterTriggerBodyV2): Promise<{
|
|
529
551
|
id: string;
|
|
552
|
+
options: {
|
|
553
|
+
event: {
|
|
554
|
+
desired: string[];
|
|
555
|
+
missing: string[];
|
|
556
|
+
orphaned: string[];
|
|
557
|
+
};
|
|
558
|
+
} & Record<string, {
|
|
559
|
+
desired: string[];
|
|
560
|
+
missing: string[];
|
|
561
|
+
orphaned: string[];
|
|
562
|
+
}>;
|
|
530
563
|
source: {
|
|
531
564
|
key: string;
|
|
532
565
|
secret: string;
|
|
@@ -540,12 +573,9 @@ declare class TriggerClient {
|
|
|
540
573
|
type: "SQS";
|
|
541
574
|
};
|
|
542
575
|
params?: any;
|
|
543
|
-
data?:
|
|
576
|
+
data?: DeserializedJson | undefined;
|
|
544
577
|
clientId?: string | undefined;
|
|
545
578
|
};
|
|
546
|
-
events: string[];
|
|
547
|
-
missingEvents: string[];
|
|
548
|
-
orphanedEvents: string[];
|
|
549
579
|
dynamicTriggerId?: string | undefined;
|
|
550
580
|
}>;
|
|
551
581
|
getAuth(id: string): Promise<{
|
|
@@ -563,12 +593,12 @@ declare class TriggerClient {
|
|
|
563
593
|
id: string;
|
|
564
594
|
name: string;
|
|
565
595
|
payload: ((string | number | boolean | {
|
|
566
|
-
[key: string]:
|
|
567
|
-
} |
|
|
568
|
-
[key: string]:
|
|
569
|
-
} |
|
|
596
|
+
[key: string]: DeserializedJson;
|
|
597
|
+
} | DeserializedJson[]) & (string | number | boolean | {
|
|
598
|
+
[key: string]: DeserializedJson;
|
|
599
|
+
} | DeserializedJson[] | undefined)) | null;
|
|
570
600
|
timestamp: Date;
|
|
571
|
-
context?:
|
|
601
|
+
context?: DeserializedJson | undefined;
|
|
572
602
|
deliverAt?: Date | null | undefined;
|
|
573
603
|
deliveredAt?: Date | null | undefined;
|
|
574
604
|
cancelledAt?: Date | null | undefined;
|
|
@@ -577,12 +607,12 @@ declare class TriggerClient {
|
|
|
577
607
|
id: string;
|
|
578
608
|
name: string;
|
|
579
609
|
payload: ((string | number | boolean | {
|
|
580
|
-
[key: string]:
|
|
581
|
-
} |
|
|
582
|
-
[key: string]:
|
|
583
|
-
} |
|
|
610
|
+
[key: string]: DeserializedJson;
|
|
611
|
+
} | DeserializedJson[]) & (string | number | boolean | {
|
|
612
|
+
[key: string]: DeserializedJson;
|
|
613
|
+
} | DeserializedJson[] | undefined)) | null;
|
|
584
614
|
timestamp: Date;
|
|
585
|
-
context?:
|
|
615
|
+
context?: DeserializedJson | undefined;
|
|
586
616
|
deliverAt?: Date | null | undefined;
|
|
587
617
|
deliveredAt?: Date | null | undefined;
|
|
588
618
|
cancelledAt?: Date | null | undefined;
|
|
@@ -642,7 +672,7 @@ declare class TriggerClient {
|
|
|
642
672
|
}>;
|
|
643
673
|
authorized(apiKey?: string | null): "authorized" | "unauthorized" | "missing-client" | "missing-header";
|
|
644
674
|
apiKey(): string | undefined;
|
|
645
|
-
defineJob<TTrigger extends Trigger<EventSpecification<any>>, TIntegrations extends Record<string, TriggerIntegration
|
|
675
|
+
defineJob<TTrigger extends Trigger<EventSpecification<any>>, TIntegrations extends Record<string, TriggerIntegration> = {}>(options: JobOptions<TTrigger, TIntegrations>): Job<TTrigger, TIntegrations>;
|
|
646
676
|
}
|
|
647
677
|
|
|
648
678
|
type ScheduledEventSpecification = EventSpecification<ScheduledPayload>;
|
|
@@ -787,6 +817,17 @@ type IOOptions = {
|
|
|
787
817
|
jobLogLevel: LogLevel;
|
|
788
818
|
cachedTasks?: Array<CachedTask>;
|
|
789
819
|
};
|
|
820
|
+
type JsonPrimitive = string | number | boolean | null | undefined | Date | symbol;
|
|
821
|
+
type JsonArray = Json[];
|
|
822
|
+
type JsonRecord<T> = {
|
|
823
|
+
[Property in keyof T]: Json;
|
|
824
|
+
};
|
|
825
|
+
type Json<T = any> = JsonPrimitive | JsonArray | JsonRecord<T>;
|
|
826
|
+
type RunTaskErrorCallback = (error: unknown, task: IOTask, io: IO) => {
|
|
827
|
+
retryAt: Date;
|
|
828
|
+
error?: Error;
|
|
829
|
+
jitter?: number;
|
|
830
|
+
} | Error | undefined | void;
|
|
790
831
|
declare class IO {
|
|
791
832
|
#private;
|
|
792
833
|
private _id;
|
|
@@ -870,7 +911,7 @@ declare class IO {
|
|
|
870
911
|
}>;
|
|
871
912
|
updateSource(key: string | any[], options: {
|
|
872
913
|
key: string;
|
|
873
|
-
} &
|
|
914
|
+
} & UpdateTriggerSourceBodyV2): Promise<{
|
|
874
915
|
id: string;
|
|
875
916
|
key: string;
|
|
876
917
|
}>;
|
|
@@ -958,11 +999,7 @@ declare class IO {
|
|
|
958
999
|
= * @param onError The callback that will be called when the Task fails. The callback receives the error, the Task and the IO as parameters. If you wish to retry then return an object with a `retryAt` property.
|
|
959
1000
|
* @returns A Promise that resolves with the returned value of the callback.
|
|
960
1001
|
*/
|
|
961
|
-
runTask<
|
|
962
|
-
retryAt: Date;
|
|
963
|
-
error?: Error;
|
|
964
|
-
jitter?: number;
|
|
965
|
-
} | Error | undefined | void): Promise<TResult>;
|
|
1002
|
+
runTask<T extends Json<T> | void>(key: string | any[], callback: (task: ServerTask, io: IO) => Promise<T>, options?: RunTaskOptions, onError?: RunTaskErrorCallback): Promise<T>;
|
|
966
1003
|
/** `io.try()` allows you to run Tasks and catch any errors that are thrown, it's similar to a normal `try/catch` block but works with [io.runTask()](/sdk/io/runtask).
|
|
967
1004
|
* A regular `try/catch` block on its own won't work as expected with Tasks. Internally `runTask()` throws some special errors to control flow execution. This is necessary to deal with resumability, serverless timeouts, and retrying Tasks.
|
|
968
1005
|
* @param tryCallback The code you wish to run
|
|
@@ -987,60 +1024,16 @@ declare class IOLogger implements TaskLogger {
|
|
|
987
1024
|
error(message: string, properties?: Record<string, any>): Promise<void>;
|
|
988
1025
|
}
|
|
989
1026
|
|
|
990
|
-
|
|
991
|
-
type ClientFactory<TClient> = (auth: ConnectionAuth) => TClient;
|
|
992
|
-
interface TriggerIntegration<TIntegrationClient extends IntegrationClient<any, any> = IntegrationClient<any, any>> {
|
|
993
|
-
client: TIntegrationClient;
|
|
1027
|
+
interface TriggerIntegration {
|
|
994
1028
|
id: string;
|
|
995
1029
|
metadata: IntegrationMetadata;
|
|
1030
|
+
authSource: "LOCAL" | "HOSTED";
|
|
1031
|
+
cloneForRun: (io: IO, connectionKey: string, auth?: ConnectionAuth) => TriggerIntegration;
|
|
996
1032
|
}
|
|
997
|
-
type
|
|
998
|
-
|
|
999
|
-
client: TClient;
|
|
1000
|
-
tasks?: TTasks;
|
|
1001
|
-
auth: any;
|
|
1002
|
-
} | {
|
|
1003
|
-
usesLocalAuth: false;
|
|
1004
|
-
clientFactory: ClientFactory<TClient>;
|
|
1005
|
-
tasks?: TTasks;
|
|
1006
|
-
};
|
|
1007
|
-
type AuthenticatedTask<TClient, TParams, TResult, TAuth = ConnectionAuth> = {
|
|
1008
|
-
run: (params: TParams, client: TClient, task: ServerTask, io: IO, auth: TAuth) => Promise<TResult>;
|
|
1009
|
-
init: (params: TParams) => RunTaskOptions;
|
|
1010
|
-
onError?: (error: unknown, task: ServerTask) => {
|
|
1011
|
-
retryAt: Date;
|
|
1012
|
-
error?: Error;
|
|
1013
|
-
} | Error | undefined | void;
|
|
1014
|
-
};
|
|
1015
|
-
declare function authenticatedTask<TClient, TParams, TResult>(options: {
|
|
1016
|
-
run: (params: TParams, client: TClient, task: ServerTask, io: IO) => Promise<TResult>;
|
|
1017
|
-
init: (params: TParams) => RunTaskOptions;
|
|
1018
|
-
}): AuthenticatedTask<TClient, TParams, TResult>;
|
|
1019
|
-
type ExtractRunFunction<T> = T extends AuthenticatedTask<any, infer TParams, infer TResult, infer TAuth> ? (key: string, params: TParams) => Promise<TResult> : never;
|
|
1020
|
-
type ExtractTasks<TTasks extends Record<string, AuthenticatedTask<any, any, any, any>>> = {
|
|
1021
|
-
[key in keyof TTasks]: ExtractRunFunction<TTasks[key]>;
|
|
1022
|
-
};
|
|
1023
|
-
type ExtractIntegrationClientClient<TIntegrationClient extends IntegrationClient<any, any>> = TIntegrationClient extends {
|
|
1024
|
-
usesLocalAuth: true;
|
|
1025
|
-
client: infer TClient;
|
|
1026
|
-
} ? {
|
|
1027
|
-
client: TClient;
|
|
1028
|
-
runTask: IntegrationRunTaskFunction<TClient>;
|
|
1029
|
-
} : TIntegrationClient extends {
|
|
1030
|
-
usesLocalAuth: false;
|
|
1031
|
-
clientFactory: ClientFactory<infer TClient>;
|
|
1032
|
-
} ? {
|
|
1033
|
-
client: TClient;
|
|
1034
|
-
runTask: IntegrationRunTaskFunction<TClient>;
|
|
1035
|
-
} : never;
|
|
1036
|
-
type ExtractIntegrationClient<TIntegrationClient extends IntegrationClient<any, any>> = ExtractIntegrationClientClient<TIntegrationClient> & ExtractTasks<TIntegrationClient["tasks"]>;
|
|
1037
|
-
type IntegrationIO<TIntegration extends TriggerIntegration<IntegrationClient<any, any>>> = ExtractIntegrationClient<TIntegration["client"]>;
|
|
1038
|
-
type ExtractIntegrations<TIntegrations extends Record<string, TriggerIntegration<IntegrationClient<any, any>>>> = {
|
|
1039
|
-
[key in keyof TIntegrations]: ExtractIntegrationClient<TIntegrations[key]["client"]>;
|
|
1040
|
-
};
|
|
1041
|
-
type IOWithIntegrations<TIntegrations extends Record<string, TriggerIntegration<IntegrationClient<any, any>>>> = IO & ExtractIntegrations<TIntegrations>;
|
|
1033
|
+
type IOWithIntegrations<TIntegrations extends Record<string, TriggerIntegration>> = IO & TIntegrations;
|
|
1034
|
+
type IntegrationTaskKey = string | any[];
|
|
1042
1035
|
|
|
1043
|
-
type JobOptions<TTrigger extends Trigger<EventSpecification<any>>, TIntegrations extends Record<string, TriggerIntegration
|
|
1036
|
+
type JobOptions<TTrigger extends Trigger<EventSpecification<any>>, TIntegrations extends Record<string, TriggerIntegration> = {}> = {
|
|
1044
1037
|
/** The `id` property is used to uniquely identify the Job. Only change this if you want to create a new Job. */
|
|
1045
1038
|
id: string;
|
|
1046
1039
|
/** The `name` of the Job that you want to appear in the dashboard and logs. You can change this without creating a new Job. */
|
|
@@ -1091,7 +1084,7 @@ type JobOptions<TTrigger extends Trigger<EventSpecification<any>>, TIntegrations
|
|
|
1091
1084
|
type JobPayload<TJob> = TJob extends Job<Trigger<EventSpecification<infer TEvent>>, any> ? TEvent : never;
|
|
1092
1085
|
type JobIO<TJob> = TJob extends Job<any, infer TIntegrations> ? IOWithIntegrations<TIntegrations> : never;
|
|
1093
1086
|
/** 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. */
|
|
1094
|
-
declare class Job<TTrigger extends Trigger<EventSpecification<any>>, TIntegrations extends Record<string, TriggerIntegration
|
|
1087
|
+
declare class Job<TTrigger extends Trigger<EventSpecification<any>>, TIntegrations extends Record<string, TriggerIntegration> = {}> {
|
|
1095
1088
|
#private;
|
|
1096
1089
|
readonly options: JobOptions<TTrigger, TIntegrations>;
|
|
1097
1090
|
client: TriggerClient;
|
|
@@ -1282,9 +1275,19 @@ declare class CanceledWithTaskError {
|
|
|
1282
1275
|
*/
|
|
1283
1276
|
declare function isTriggerError(err: unknown): err is ResumeWithTaskError | RetryWithTaskError | CanceledWithTaskError;
|
|
1284
1277
|
|
|
1278
|
+
declare const retry: {
|
|
1279
|
+
readonly standardBackoff: {
|
|
1280
|
+
readonly limit: 8;
|
|
1281
|
+
readonly factor: 1.8;
|
|
1282
|
+
readonly minTimeoutInMs: 500;
|
|
1283
|
+
readonly maxTimeoutInMs: 30000;
|
|
1284
|
+
readonly randomize: true;
|
|
1285
|
+
};
|
|
1286
|
+
};
|
|
1287
|
+
|
|
1285
1288
|
type Task = ServerTask;
|
|
1286
1289
|
|
|
1287
1290
|
type SentEvent = ApiEventLog;
|
|
1288
1291
|
declare function redactString(strings: TemplateStringsArray, ...interpolations: string[]): RedactString;
|
|
1289
1292
|
|
|
1290
|
-
export {
|
|
1293
|
+
export { CronTrigger, DynamicIntervalOptions, DynamicSchedule, DynamicTrigger, DynamicTriggerOptions, EventSpecification, EventSpecificationExample, EventTrigger, EventTypeFromSpecification, ExternalSource, ExternalSourceParams, ExternalSourceTrigger, ExternalSourceTriggerOptions, HandlerEvent, HttpSourceEvent, IO, IOLogger, IOOptions, IOTask, IOWithIntegrations, IntegrationTaskKey, IntervalTrigger, Job, JobIO, JobOptions, JobPayload, Json, MissingConnectionNotification, MissingConnectionResolvedNotification, PreprocessResults, RunTaskErrorCallback, SentEvent, Task, TaskLogger, Trigger, TriggerClient, TriggerClientOptions, TriggerContext, TriggerEventType, TriggerIntegration, TriggerOptionRecord, TriggerPayload, TriggerPreprocessContext, cronTrigger, eventTrigger, intervalTrigger, isTriggerError, missingConnectionNotification, missingConnectionResolvedNotification, omit, redactString, retry };
|