@trigger.dev/sdk 2.2.6 → 2.2.8
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 +274 -19
- package/dist/index.js +2319 -1564
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
import * as _trigger_dev_core from '@trigger.dev/core';
|
|
2
|
-
import { RunTaskBodyInput, CompleteTaskBodyV2Input, FailTaskBodyInput, SendEvent, SendEventOptions, StatusUpdate, UpdateTriggerSourceBodyV2, TriggerSource, RegisterTriggerBodyV2, RegisterSourceEventV2, ScheduleMetadata, GetRunOptionsWithTaskDetails, GetRunsOptions, InvokeOptions, EphemeralEventDispatcherRequestBody, LogLevel, RuntimeEnvironmentType, DisplayProperty, TriggerMetadata, EventFilter, HttpEndpointMetadata, RequestFilter, Prettify, HandleTriggerSource, Logger, RegisterTriggerSource, SerializableJson, ConnectionAuth, NormalizedResponse, HttpSourceResponseMetadata, IntervalOptions, CronOptions, ScheduledPayload, DeserializedJson, ServerTask, CachedTask, InitialStatusUpdate, FetchRequestInit, FetchRetryOptions, FetchTimeoutOptions, FetchPollOperation, RunTaskOptions, IntegrationMetadata, QueueOptions, IntegrationConfig, JobMetadata, RunNotification, MissingConnectionNotificationPayload, MissingConnectionResolvedNotificationPayload, ErrorWithStack, ApiEventLog, RedactString } from '@trigger.dev/core';
|
|
2
|
+
import { AsyncMap, KeyValueStoreResponseBody, RunTaskBodyInput, CompleteTaskBodyV2Input, FailTaskBodyInput, SendEvent, SendEventOptions, StatusUpdate, UpdateTriggerSourceBodyV2, TriggerSource, UpdateWebhookBody, RegisterTriggerBodyV2, RegisterSourceEventV2, ScheduleMetadata, GetRunOptionsWithTaskDetails, GetRunsOptions, InvokeOptions, EphemeralEventDispatcherRequestBody, LogLevel, RuntimeEnvironmentType, DisplayProperty, TriggerMetadata, EventFilter, SuccessfulRunNotification, FailedRunNotification, HttpEndpointMetadata, RequestFilter, Prettify, HandleTriggerSource, Logger, RegisterTriggerSource, SerializableJson, ConnectionAuth, NormalizedResponse, HttpSourceResponseMetadata, IntervalOptions, CronOptions, ScheduledPayload, RegisterWebhookSource, DeserializedJson, ServerTask, CachedTask, InitialStatusUpdate, FetchRequestInit, FetchRetryOptions, FetchTimeoutOptions, FetchPollOperation, RunTaskOptions, IntegrationMetadata, QueueOptions, IntegrationConfig, JobMetadata, RunNotification, MissingConnectionNotificationPayload, MissingConnectionResolvedNotificationPayload, ErrorWithStack, ApiEventLog, RedactString } from '@trigger.dev/core';
|
|
3
3
|
export { ConnectionAuth, DisplayProperty, EventFilter, Logger, NormalizedRequest, OverridableRunTaskOptions, Prettify, RedactString, RegisteredOptionsDiff, RunTaskOptions, SourceEventOption } from '@trigger.dev/core';
|
|
4
4
|
import * as zod from 'zod';
|
|
5
5
|
import { z, ZodType, TypeOf } from 'zod';
|
|
6
|
+
import { BinaryToTextEncoding, BinaryLike, KeyObject } from 'crypto';
|
|
7
|
+
|
|
8
|
+
type QueryKeyValueStoreFunction = (action: "DELETE" | "GET" | "HAS" | "SET", data: {
|
|
9
|
+
key: string;
|
|
10
|
+
value?: string;
|
|
11
|
+
}) => Promise<KeyValueStoreResponseBody>;
|
|
12
|
+
declare class KeyValueStoreClient implements AsyncMap {
|
|
13
|
+
#private;
|
|
14
|
+
private queryStore;
|
|
15
|
+
private type;
|
|
16
|
+
private namespace;
|
|
17
|
+
constructor(queryStore: QueryKeyValueStoreFunction, type?: string | null, namespace?: string);
|
|
18
|
+
delete(key: string): Promise<boolean>;
|
|
19
|
+
get<T extends Json<T>>(key: string): Promise<T>;
|
|
20
|
+
has(key: string): Promise<boolean>;
|
|
21
|
+
set<T extends Json<T>>(key: string, value: T): Promise<T>;
|
|
22
|
+
}
|
|
6
23
|
|
|
7
24
|
type ApiClientOptions = {
|
|
8
25
|
apiKey?: string;
|
|
@@ -581,6 +598,7 @@ declare class ApiClient {
|
|
|
581
598
|
state?: "loading" | "success" | "failure" | undefined;
|
|
582
599
|
}>;
|
|
583
600
|
updateSource(client: string, key: string, source: UpdateTriggerSourceBodyV2): Promise<TriggerSource>;
|
|
601
|
+
updateWebhook(key: string, webhookData: UpdateWebhookBody): Promise<TriggerSource>;
|
|
584
602
|
registerTrigger(client: string, id: string, key: string, payload: RegisterTriggerBodyV2, idempotencyKey?: string): Promise<RegisterSourceEventV2>;
|
|
585
603
|
registerSchedule(client: string, id: string, key: string, payload: ScheduleMetadata): Promise<{
|
|
586
604
|
id: string;
|
|
@@ -699,6 +717,7 @@ declare class ApiClient {
|
|
|
699
717
|
createEphemeralEventDispatcher(payload: EphemeralEventDispatcherRequestBody): Promise<{
|
|
700
718
|
id: string;
|
|
701
719
|
}>;
|
|
720
|
+
get store(): KeyValueStoreClient;
|
|
702
721
|
}
|
|
703
722
|
type VersionedResponseBodyMap = {
|
|
704
723
|
[key: string]: z.ZodTypeAny;
|
|
@@ -730,6 +749,48 @@ declare class TriggerStatus {
|
|
|
730
749
|
}>;
|
|
731
750
|
}
|
|
732
751
|
|
|
752
|
+
type EventMap = {
|
|
753
|
+
[key: string]: (...args: any[]) => void
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
/**
|
|
757
|
+
* Type-safe event emitter.
|
|
758
|
+
*
|
|
759
|
+
* Use it like this:
|
|
760
|
+
*
|
|
761
|
+
* ```typescript
|
|
762
|
+
* type MyEvents = {
|
|
763
|
+
* error: (error: Error) => void;
|
|
764
|
+
* message: (from: string, content: string) => void;
|
|
765
|
+
* }
|
|
766
|
+
*
|
|
767
|
+
* const myEmitter = new EventEmitter() as TypedEmitter<MyEvents>;
|
|
768
|
+
*
|
|
769
|
+
* myEmitter.emit("error", "x") // <- Will catch this type error;
|
|
770
|
+
* ```
|
|
771
|
+
*/
|
|
772
|
+
interface TypedEventEmitter<Events extends EventMap> {
|
|
773
|
+
addListener<E extends keyof Events> (event: E, listener: Events[E]): this
|
|
774
|
+
on<E extends keyof Events> (event: E, listener: Events[E]): this
|
|
775
|
+
once<E extends keyof Events> (event: E, listener: Events[E]): this
|
|
776
|
+
prependListener<E extends keyof Events> (event: E, listener: Events[E]): this
|
|
777
|
+
prependOnceListener<E extends keyof Events> (event: E, listener: Events[E]): this
|
|
778
|
+
|
|
779
|
+
off<E extends keyof Events>(event: E, listener: Events[E]): this
|
|
780
|
+
removeAllListeners<E extends keyof Events> (event?: E): this
|
|
781
|
+
removeListener<E extends keyof Events> (event: E, listener: Events[E]): this
|
|
782
|
+
|
|
783
|
+
emit<E extends keyof Events> (event: E, ...args: Parameters<Events[E]>): boolean
|
|
784
|
+
// The sloppy `eventNames()` return type is to mitigate type incompatibilities - see #5
|
|
785
|
+
eventNames (): (keyof Events | string | symbol)[]
|
|
786
|
+
rawListeners<E extends keyof Events> (event: E): Events[E][]
|
|
787
|
+
listeners<E extends keyof Events> (event: E): Events[E][]
|
|
788
|
+
listenerCount<E extends keyof Events> (event: E): number
|
|
789
|
+
|
|
790
|
+
getMaxListeners (): number
|
|
791
|
+
setMaxListeners (maxListeners: number): this
|
|
792
|
+
}
|
|
793
|
+
|
|
733
794
|
interface TriggerContext {
|
|
734
795
|
/** Job metadata */
|
|
735
796
|
job: {
|
|
@@ -852,6 +913,12 @@ declare const EventSpecificationExampleSchema: z.ZodObject<{
|
|
|
852
913
|
payload?: any;
|
|
853
914
|
}>;
|
|
854
915
|
type EventSpecificationExample = z.infer<typeof EventSpecificationExampleSchema>;
|
|
916
|
+
type TypedEventSpecificationExample<TEvent> = {
|
|
917
|
+
id: string;
|
|
918
|
+
name: string;
|
|
919
|
+
icon?: string;
|
|
920
|
+
payload: TEvent;
|
|
921
|
+
};
|
|
855
922
|
interface EventSpecification<TEvent extends any, TInvoke extends any = TEvent> {
|
|
856
923
|
name: string | string[];
|
|
857
924
|
title: string;
|
|
@@ -916,6 +983,11 @@ declare function waitForEventSchema(schema: z.ZodTypeAny): z.ZodObject<{
|
|
|
916
983
|
context?: any;
|
|
917
984
|
accountId?: string | undefined;
|
|
918
985
|
}>;
|
|
986
|
+
type NotificationEvents = {
|
|
987
|
+
runSucceeeded: (notification: SuccessfulRunNotification<any>) => void;
|
|
988
|
+
runFailed: (notification: FailedRunNotification) => void;
|
|
989
|
+
};
|
|
990
|
+
type NotificationsEventEmitter = TypedEventEmitter<NotificationEvents>;
|
|
919
991
|
|
|
920
992
|
type HttpEndpointOptions<TEventSpecification extends EventSpecification<any>> = {
|
|
921
993
|
id: string;
|
|
@@ -1043,7 +1115,7 @@ type TriggerOptionsRecordWithEvent<TValue, TTriggerOptionDefinitions extends Rec
|
|
|
1043
1115
|
type TriggerOptionRecord<TValue, TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
|
|
1044
1116
|
[K in keyof TTriggerOptionDefinitions]: TValue;
|
|
1045
1117
|
};
|
|
1046
|
-
type RegisterFunctionEvent<TChannel extends ChannelNames, TParams extends any, TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
|
|
1118
|
+
type RegisterFunctionEvent$1<TChannel extends ChannelNames, TParams extends any, TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
|
|
1047
1119
|
options: TriggerOptionDiffs<TTriggerOptionDefinitions>;
|
|
1048
1120
|
source: {
|
|
1049
1121
|
active: boolean;
|
|
@@ -1058,14 +1130,14 @@ type RegisterSourceEvent<TTriggerOptionDefinitions extends Record<string, string
|
|
|
1058
1130
|
dynamicTriggerId?: string;
|
|
1059
1131
|
options: TriggerOptionDiffs<TTriggerOptionDefinitions>;
|
|
1060
1132
|
};
|
|
1061
|
-
type RegisterFunctionOutput<TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
|
|
1133
|
+
type RegisterFunctionOutput$1<TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
|
|
1062
1134
|
secret?: string;
|
|
1063
1135
|
data?: SerializableJson;
|
|
1064
1136
|
options: TriggerOptionsRecordWithEvent<string[], TTriggerOptionDefinitions>;
|
|
1065
1137
|
};
|
|
1066
|
-
type RegisterFunction<TIntegration extends TriggerIntegration, TParams extends any, TChannel extends ChannelNames, TTriggerOptionDefinitions extends Record<string, string[]> = any> = (event: RegisterFunctionEvent<TChannel, TParams, TTriggerOptionDefinitions>, io: IOWithIntegrations<{
|
|
1138
|
+
type RegisterFunction$1<TIntegration extends TriggerIntegration, TParams extends any, TChannel extends ChannelNames, TTriggerOptionDefinitions extends Record<string, string[]> = any> = (event: RegisterFunctionEvent$1<TChannel, TParams, TTriggerOptionDefinitions>, io: IOWithIntegrations<{
|
|
1067
1139
|
integration: TIntegration;
|
|
1068
|
-
}>, ctx: TriggerContext) => Promise<RegisterFunctionOutput<TTriggerOptionDefinitions> | undefined>;
|
|
1140
|
+
}>, ctx: TriggerContext) => Promise<RegisterFunctionOutput$1<TTriggerOptionDefinitions> | undefined>;
|
|
1069
1141
|
type HandlerEvent<TChannel extends ChannelNames, TParams extends any = any> = {
|
|
1070
1142
|
rawEvent: ExternalSourceChannelMap[TChannel]["event"];
|
|
1071
1143
|
source: Prettify<Omit<HandleTriggerSource, "params"> & {
|
|
@@ -1077,18 +1149,18 @@ type HandlerFunction<TChannel extends ChannelNames, TParams extends any, TTrigge
|
|
|
1077
1149
|
response?: NormalizedResponse;
|
|
1078
1150
|
metadata?: HttpSourceResponseMetadata;
|
|
1079
1151
|
} | void>;
|
|
1080
|
-
type KeyFunction<TParams extends any> = (params: TParams) => string;
|
|
1081
|
-
type FilterFunction<TParams extends any, TTriggerOptionDefinitions extends Record<string, string[]> = any> = (params: TParams, options?: TTriggerOptionDefinitions) => EventFilter;
|
|
1152
|
+
type KeyFunction$1<TParams extends any> = (params: TParams) => string;
|
|
1153
|
+
type FilterFunction$1<TParams extends any, TTriggerOptionDefinitions extends Record<string, string[]> = any> = (params: TParams, options?: TTriggerOptionDefinitions) => EventFilter;
|
|
1082
1154
|
type ExternalSourceOptions<TChannel extends ChannelNames, TIntegration extends TriggerIntegration, TParams extends any, TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
|
|
1083
1155
|
id: string;
|
|
1084
1156
|
version: string;
|
|
1085
1157
|
schema: SchemaParser<TParams>;
|
|
1086
1158
|
optionSchema?: SchemaParser<TTriggerOptionDefinitions>;
|
|
1087
1159
|
integration: TIntegration;
|
|
1088
|
-
register: RegisterFunction<TIntegration, TParams, TChannel, TTriggerOptionDefinitions>;
|
|
1089
|
-
filter?: FilterFunction<TParams, TTriggerOptionDefinitions>;
|
|
1160
|
+
register: RegisterFunction$1<TIntegration, TParams, TChannel, TTriggerOptionDefinitions>;
|
|
1161
|
+
filter?: FilterFunction$1<TParams, TTriggerOptionDefinitions>;
|
|
1090
1162
|
handler: HandlerFunction<TChannel, TParams, TIntegration>;
|
|
1091
|
-
key: KeyFunction<TParams>;
|
|
1163
|
+
key: KeyFunction$1<TParams>;
|
|
1092
1164
|
properties?: (params: TParams) => DisplayProperty[];
|
|
1093
1165
|
};
|
|
1094
1166
|
declare class ExternalSource<TIntegration extends TriggerIntegration, TParams extends any, TChannel extends ChannelNames = ChannelNames, TTriggerOptionDefinitions extends Record<string, string[]> = any> {
|
|
@@ -1114,7 +1186,7 @@ declare class ExternalSource<TIntegration extends TriggerIntegration, TParams ex
|
|
|
1114
1186
|
}>;
|
|
1115
1187
|
filter(params: TParams, options?: TTriggerOptionDefinitions): EventFilter;
|
|
1116
1188
|
properties(params: TParams): DisplayProperty[];
|
|
1117
|
-
register(params: TParams, registerEvent: RegisterSourceEvent<TTriggerOptionDefinitions>, io: IO, ctx: TriggerContext): Promise<RegisterFunctionOutput<TTriggerOptionDefinitions> | undefined>;
|
|
1189
|
+
register(params: TParams, registerEvent: RegisterSourceEvent<TTriggerOptionDefinitions>, io: IO, ctx: TriggerContext): Promise<RegisterFunctionOutput$1<TTriggerOptionDefinitions> | undefined>;
|
|
1118
1190
|
key(params: TParams): string;
|
|
1119
1191
|
get integration(): TIntegration;
|
|
1120
1192
|
get integrationConfig(): {
|
|
@@ -1343,6 +1415,157 @@ declare class DynamicSchedule implements Trigger<ScheduledEventSpecification> {
|
|
|
1343
1415
|
toJSON(): TriggerMetadata;
|
|
1344
1416
|
}
|
|
1345
1417
|
|
|
1418
|
+
type WebhookCRUDContext<TParams extends any, TConfig extends Record<string, string[]>> = {
|
|
1419
|
+
active: boolean;
|
|
1420
|
+
params: TParams;
|
|
1421
|
+
config: {
|
|
1422
|
+
current: Partial<TConfig>;
|
|
1423
|
+
desired: TConfig;
|
|
1424
|
+
};
|
|
1425
|
+
url: string;
|
|
1426
|
+
secret: string;
|
|
1427
|
+
};
|
|
1428
|
+
type WebhookCRUDFunction<TIntegration extends TriggerIntegration, TParams extends any, TConfig extends Record<string, string[]>> = (options: {
|
|
1429
|
+
io: IOWithIntegrations<{
|
|
1430
|
+
integration: TIntegration;
|
|
1431
|
+
}>;
|
|
1432
|
+
ctx: WebhookCRUDContext<TParams, TConfig>;
|
|
1433
|
+
}) => Promise<any>;
|
|
1434
|
+
interface WebhookCRUD<TIntegration extends TriggerIntegration, TParams extends any, TConfig extends Record<string, string[]>> {
|
|
1435
|
+
create: WebhookCRUDFunction<TIntegration, TParams, TConfig>;
|
|
1436
|
+
read?: WebhookCRUDFunction<TIntegration, TParams, TConfig>;
|
|
1437
|
+
update?: WebhookCRUDFunction<TIntegration, TParams, TConfig>;
|
|
1438
|
+
delete: WebhookCRUDFunction<TIntegration, TParams, TConfig>;
|
|
1439
|
+
}
|
|
1440
|
+
type WebhookConfig<TConfigKeys extends string> = {
|
|
1441
|
+
[K in TConfigKeys]: string[];
|
|
1442
|
+
};
|
|
1443
|
+
type RegisterFunctionEvent<TParams extends any, TConfig extends Record<string, string[]>> = {
|
|
1444
|
+
source: {
|
|
1445
|
+
active: boolean;
|
|
1446
|
+
data?: any;
|
|
1447
|
+
secret: string;
|
|
1448
|
+
url: string;
|
|
1449
|
+
};
|
|
1450
|
+
params: TParams;
|
|
1451
|
+
config: TConfig;
|
|
1452
|
+
};
|
|
1453
|
+
type WebhookRegisterEvent<TConfig extends Record<string, string[]>> = {
|
|
1454
|
+
id: string;
|
|
1455
|
+
source: RegisterWebhookSource;
|
|
1456
|
+
dynamicTriggerId?: string;
|
|
1457
|
+
config: TConfig;
|
|
1458
|
+
};
|
|
1459
|
+
type RegisterFunctionOutput<TConfig extends Record<string, string[]>> = {
|
|
1460
|
+
secret?: string;
|
|
1461
|
+
data?: SerializableJson;
|
|
1462
|
+
config: TConfig;
|
|
1463
|
+
};
|
|
1464
|
+
type RegisterFunction<TIntegration extends TriggerIntegration, TParams extends any, TConfig extends Record<string, string[]>> = (event: RegisterFunctionEvent<TParams, TConfig>, io: IOWithIntegrations<{
|
|
1465
|
+
integration: TIntegration;
|
|
1466
|
+
}>, ctx: TriggerContext) => Promise<RegisterFunctionOutput<TConfig> | undefined>;
|
|
1467
|
+
type WebhookHandlerEvent<TParams extends any = any> = {
|
|
1468
|
+
rawEvent: Request;
|
|
1469
|
+
source: Prettify<Omit<HandleTriggerSource, "params"> & {
|
|
1470
|
+
params: TParams;
|
|
1471
|
+
}>;
|
|
1472
|
+
};
|
|
1473
|
+
type WebhookDeliveryContext = {
|
|
1474
|
+
key: string;
|
|
1475
|
+
secret: string;
|
|
1476
|
+
params: any;
|
|
1477
|
+
};
|
|
1478
|
+
type EventGenerator<TParams extends any, TConfig extends Record<string, string[]>, TIntegration extends TriggerIntegration> = (options: {
|
|
1479
|
+
request: Request;
|
|
1480
|
+
client: TriggerClient;
|
|
1481
|
+
ctx: WebhookDeliveryContext;
|
|
1482
|
+
}) => Promise<any>;
|
|
1483
|
+
type KeyFunction<TParams extends any> = (params: TParams) => string;
|
|
1484
|
+
type FilterFunction<TParams extends any, TConfig extends Record<string, string[]>> = (params: TParams, config?: TConfig) => EventFilter;
|
|
1485
|
+
type WebhookOptions<TIntegration extends TriggerIntegration, TParams extends any, TConfig extends Record<string, string[]>> = {
|
|
1486
|
+
id: string;
|
|
1487
|
+
version: string;
|
|
1488
|
+
integration: TIntegration;
|
|
1489
|
+
schemas: {
|
|
1490
|
+
params: SchemaParser<TParams>;
|
|
1491
|
+
config?: SchemaParser<TConfig>;
|
|
1492
|
+
};
|
|
1493
|
+
key: KeyFunction<TParams>;
|
|
1494
|
+
crud: WebhookCRUD<TIntegration, TParams, TConfig>;
|
|
1495
|
+
filter?: FilterFunction<TParams, TConfig>;
|
|
1496
|
+
register?: RegisterFunction<TIntegration, TParams, TConfig>;
|
|
1497
|
+
verify?: (options: {
|
|
1498
|
+
request: Request;
|
|
1499
|
+
client: TriggerClient;
|
|
1500
|
+
ctx: WebhookDeliveryContext;
|
|
1501
|
+
}) => Promise<VerifyResult>;
|
|
1502
|
+
generateEvents: EventGenerator<TParams, TConfig, TIntegration>;
|
|
1503
|
+
properties?: (params: TParams) => DisplayProperty[];
|
|
1504
|
+
};
|
|
1505
|
+
declare class WebhookSource<TIntegration extends TriggerIntegration, TParams extends any = any, TConfig extends Record<string, string[]> = Record<string, string[]>> {
|
|
1506
|
+
#private;
|
|
1507
|
+
private options;
|
|
1508
|
+
constructor(options: WebhookOptions<TIntegration, TParams, TConfig>);
|
|
1509
|
+
generateEvents(request: Request, client: TriggerClient, ctx: WebhookDeliveryContext): Promise<any>;
|
|
1510
|
+
filter(params: TParams, config?: TConfig): EventFilter;
|
|
1511
|
+
properties(params: TParams): DisplayProperty[];
|
|
1512
|
+
get crud(): WebhookCRUD<TIntegration, TParams, TConfig>;
|
|
1513
|
+
register(params: TParams, registerEvent: WebhookRegisterEvent<TConfig>, io: IO, ctx: TriggerContext): Promise<RegisterFunctionOutput<TConfig> | undefined>;
|
|
1514
|
+
verify(request: Request, client: TriggerClient, ctx: WebhookDeliveryContext): Promise<VerifyResult>;
|
|
1515
|
+
key(params: TParams): string;
|
|
1516
|
+
get integration(): TIntegration;
|
|
1517
|
+
get integrationConfig(): {
|
|
1518
|
+
id: string;
|
|
1519
|
+
metadata: {
|
|
1520
|
+
id: string;
|
|
1521
|
+
name: string;
|
|
1522
|
+
instructions?: string | undefined;
|
|
1523
|
+
};
|
|
1524
|
+
};
|
|
1525
|
+
get id(): string;
|
|
1526
|
+
get version(): string;
|
|
1527
|
+
}
|
|
1528
|
+
type GetWebhookParams<TWebhook extends WebhookSource<any, any, any>> = TWebhook extends WebhookSource<any, infer TParams, any> ? TParams : never;
|
|
1529
|
+
type GetWebhookConfig<TWebhook extends WebhookSource<any, any, any>> = TWebhook extends WebhookSource<any, any, infer TConfig> ? TConfig : never;
|
|
1530
|
+
type WebhookTriggerOptions<TEventSpecification extends EventSpecification<any>, TEventSource extends WebhookSource<any, any, any>, TConfig extends Record<string, string[]> = Record<string, string[]>> = {
|
|
1531
|
+
event: TEventSpecification;
|
|
1532
|
+
source: TEventSource;
|
|
1533
|
+
params: GetWebhookParams<TEventSource>;
|
|
1534
|
+
config: TConfig;
|
|
1535
|
+
};
|
|
1536
|
+
declare class WebhookTrigger<TEventSpecification extends EventSpecification<any>, TEventSource extends WebhookSource<any, any, any>> implements Trigger<TEventSpecification> {
|
|
1537
|
+
private options;
|
|
1538
|
+
constructor(options: WebhookTriggerOptions<TEventSpecification, TEventSource>);
|
|
1539
|
+
get event(): TEventSpecification;
|
|
1540
|
+
get source(): TEventSource;
|
|
1541
|
+
get key(): string;
|
|
1542
|
+
toJSON(): TriggerMetadata;
|
|
1543
|
+
filter(eventFilter: EventFilter): WebhookTrigger<Omit<TEventSpecification, "filter"> & {
|
|
1544
|
+
filter: EventFilter;
|
|
1545
|
+
}, TEventSource>;
|
|
1546
|
+
attachToJob(triggerClient: TriggerClient, job: Job<Trigger<TEventSpecification>, any>): void;
|
|
1547
|
+
get preprocessRuns(): boolean;
|
|
1548
|
+
verifyPayload(payload: ReturnType<TEventSpecification["parsePayload"]>): Promise<{
|
|
1549
|
+
success: true;
|
|
1550
|
+
}>;
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1553
|
+
declare class KeyValueStore {
|
|
1554
|
+
#private;
|
|
1555
|
+
private apiClient;
|
|
1556
|
+
private type;
|
|
1557
|
+
private namespace;
|
|
1558
|
+
constructor(apiClient: ApiClient, type?: string | null, namespace?: string);
|
|
1559
|
+
delete(cacheKey: string | any[], key: string): Promise<boolean>;
|
|
1560
|
+
delete(key: string): Promise<boolean>;
|
|
1561
|
+
get<T extends Json<T> = any>(cacheKey: string | any[], key: string): Promise<T>;
|
|
1562
|
+
get<T extends Json<T> = any>(key: string): Promise<T>;
|
|
1563
|
+
has(cacheKey: string | any[], key: string): Promise<boolean>;
|
|
1564
|
+
has(key: string): Promise<boolean>;
|
|
1565
|
+
set<T extends Json<T>>(cacheKey: string | any[], key: string, value: T): Promise<T>;
|
|
1566
|
+
set<T extends Json<T>>(key: string, value: T): Promise<T>;
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1346
1569
|
type TriggerClientOptions = {
|
|
1347
1570
|
/** The `id` property is used to uniquely identify the client.
|
|
1348
1571
|
*/
|
|
@@ -1373,6 +1596,7 @@ declare class TriggerClient {
|
|
|
1373
1596
|
#private;
|
|
1374
1597
|
id: string;
|
|
1375
1598
|
constructor(options: Prettify<TriggerClientOptions>);
|
|
1599
|
+
on: <E extends keyof NotificationEvents>(event: E, listener: NotificationEvents[E]) => NotificationsEventEmitter;
|
|
1376
1600
|
handleRequest(request: Request, timeOrigin?: number): Promise<NormalizedResponse>;
|
|
1377
1601
|
defineJob<TTrigger extends Trigger<EventSpecification<any>>, TIntegrations extends Record<string, TriggerIntegration> = {}, TOutput extends any = any>(options: JobOptions<TTrigger, TIntegrations, TOutput>): Job<TTrigger, TIntegrations, TOutput>;
|
|
1378
1602
|
defineAuthResolver(integration: TriggerIntegration, resolver: TriggerAuthResolver): TriggerClient;
|
|
@@ -1384,7 +1608,7 @@ declare class TriggerClient {
|
|
|
1384
1608
|
* @returns An HTTP Endpoint, that can be used to create an HTTP Trigger.
|
|
1385
1609
|
* @link https://trigger.dev/docs/documentation/concepts/http-endpoints
|
|
1386
1610
|
*/
|
|
1387
|
-
defineHttpEndpoint(options: EndpointOptions): HttpEndpoint<EventSpecification<Request, Request>>;
|
|
1611
|
+
defineHttpEndpoint(options: EndpointOptions, suppressWarnings?: boolean): HttpEndpoint<EventSpecification<Request, Request>>;
|
|
1388
1612
|
attach(job: Job<Trigger<any>, any>): void;
|
|
1389
1613
|
attachDynamicTrigger(trigger: DynamicTrigger<any, any>): void;
|
|
1390
1614
|
attachJobToDynamicTrigger(job: Job<Trigger<any>, any>, trigger: DynamicTrigger<any, any>): void;
|
|
@@ -1397,6 +1621,13 @@ declare class TriggerClient {
|
|
|
1397
1621
|
}): void;
|
|
1398
1622
|
attachDynamicSchedule(key: string): void;
|
|
1399
1623
|
attachDynamicScheduleToJob(key: string, job: Job<Trigger<any>, any>): void;
|
|
1624
|
+
attachWebhook<TIntegration extends TriggerIntegration, TParams extends any, TConfig extends Record<string, string[]>>(options: {
|
|
1625
|
+
key: string;
|
|
1626
|
+
source: WebhookSource<TIntegration, TParams, TConfig>;
|
|
1627
|
+
event: EventSpecification<any>;
|
|
1628
|
+
params: any;
|
|
1629
|
+
config: TConfig;
|
|
1630
|
+
}): void;
|
|
1400
1631
|
registerTrigger(id: string, key: string, options: RegisterTriggerBodyV2, idempotencyKey?: string): Promise<{
|
|
1401
1632
|
id: string;
|
|
1402
1633
|
options: {
|
|
@@ -1612,6 +1843,9 @@ declare class TriggerClient {
|
|
|
1612
1843
|
createEphemeralEventDispatcher(payload: EphemeralEventDispatcherRequestBody): Promise<{
|
|
1613
1844
|
id: string;
|
|
1614
1845
|
}>;
|
|
1846
|
+
get store(): {
|
|
1847
|
+
env: KeyValueStore;
|
|
1848
|
+
};
|
|
1615
1849
|
authorized(apiKey?: string | null): "authorized" | "unauthorized" | "missing-client" | "missing-header";
|
|
1616
1850
|
apiKey(): string | undefined;
|
|
1617
1851
|
}
|
|
@@ -1619,6 +1853,7 @@ declare class TriggerClient {
|
|
|
1619
1853
|
type IOTask = ServerTask;
|
|
1620
1854
|
type IOOptions = {
|
|
1621
1855
|
id: string;
|
|
1856
|
+
jobId: string;
|
|
1622
1857
|
apiClient: ApiClient;
|
|
1623
1858
|
client: TriggerClient;
|
|
1624
1859
|
context: TriggerContext;
|
|
@@ -1671,6 +1906,7 @@ type BackgroundFetchResponse<T> = {
|
|
|
1671
1906
|
declare class IO {
|
|
1672
1907
|
#private;
|
|
1673
1908
|
private _id;
|
|
1909
|
+
private _jobId;
|
|
1674
1910
|
private _apiClient;
|
|
1675
1911
|
private _triggerClient;
|
|
1676
1912
|
private _logger;
|
|
@@ -1688,6 +1924,9 @@ declare class IO {
|
|
|
1688
1924
|
private _executionTimeout?;
|
|
1689
1925
|
private _outputSerializer;
|
|
1690
1926
|
private _visitedCacheKeys;
|
|
1927
|
+
private _envStore;
|
|
1928
|
+
private _jobStore;
|
|
1929
|
+
private _runStore;
|
|
1691
1930
|
get stats(): IOStats;
|
|
1692
1931
|
constructor(options: IOOptions);
|
|
1693
1932
|
/** Used to send log messages to the [Run log](https://trigger.dev/docs/documentation/guides/viewing-runs). */
|
|
@@ -1912,6 +2151,12 @@ declare class IO {
|
|
|
1912
2151
|
id: string;
|
|
1913
2152
|
key: string;
|
|
1914
2153
|
}>;
|
|
2154
|
+
updateWebhook(cacheKey: string | any[], options: {
|
|
2155
|
+
key: string;
|
|
2156
|
+
} & UpdateWebhookBody): Promise<{
|
|
2157
|
+
id: string;
|
|
2158
|
+
key: string;
|
|
2159
|
+
}>;
|
|
1915
2160
|
/** `io.registerInterval()` allows you to register a [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) that will trigger any jobs it's attached to on a regular interval.
|
|
1916
2161
|
* @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
|
|
1917
2162
|
* @param dynamicSchedule The [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) to register a new schedule on.
|
|
@@ -2024,6 +2269,11 @@ declare class IO {
|
|
|
2024
2269
|
* @returns A Promise that resolves with the returned value or the error
|
|
2025
2270
|
*/
|
|
2026
2271
|
try<TResult, TCatchResult>(tryCallback: () => Promise<TResult>, catchCallback: (error: unknown) => Promise<TCatchResult>): Promise<TResult | TCatchResult>;
|
|
2272
|
+
get store(): {
|
|
2273
|
+
env: KeyValueStore;
|
|
2274
|
+
job: KeyValueStore;
|
|
2275
|
+
run: KeyValueStore;
|
|
2276
|
+
};
|
|
2027
2277
|
}
|
|
2028
2278
|
type CallbackFunction = (level: "DEBUG" | "INFO" | "WARN" | "ERROR" | "LOG", message: string, properties?: Record<string, any>) => Promise<void>;
|
|
2029
2279
|
declare class IOLogger implements TaskLogger {
|
|
@@ -2097,6 +2347,8 @@ type JobOptions<TTrigger extends Trigger<EventSpecification<any>>, TIntegrations
|
|
|
2097
2347
|
* @param context An object that contains information about the Organization, Job, Run and more.
|
|
2098
2348
|
*/
|
|
2099
2349
|
run: (payload: TriggerEventType<TTrigger>, io: IOWithIntegrations<TIntegrations>, context: TriggerContext) => Promise<TOutput>;
|
|
2350
|
+
onSuccess?: (notification: SuccessfulRunNotification<TOutput, TriggerEventType<TTrigger>>) => void;
|
|
2351
|
+
onFailure?: (notification: FailedRunNotification<TriggerEventType<TTrigger>>) => void;
|
|
2100
2352
|
};
|
|
2101
2353
|
type JobPayload<TJob> = TJob extends Job<Trigger<EventSpecification<infer TEvent>>, any> ? TEvent : never;
|
|
2102
2354
|
type JobIO<TJob> = TJob extends Job<any, infer TIntegrations> ? IOWithIntegrations<TIntegrations> : never;
|
|
@@ -2137,6 +2389,7 @@ type EventTriggerOptions<TEventSpecification extends EventSpecification<any>> =
|
|
|
2137
2389
|
name?: string | string[];
|
|
2138
2390
|
source?: string;
|
|
2139
2391
|
filter?: EventFilter;
|
|
2392
|
+
verify?: EventTypeFromSpecification<TEventSpecification> extends Request ? VerifyCallback : never;
|
|
2140
2393
|
};
|
|
2141
2394
|
declare class EventTrigger<TEventSpecification extends EventSpecification<any>> implements Trigger<TEventSpecification> {
|
|
2142
2395
|
#private;
|
|
@@ -2145,9 +2398,7 @@ declare class EventTrigger<TEventSpecification extends EventSpecification<any>>
|
|
|
2145
2398
|
get event(): TEventSpecification;
|
|
2146
2399
|
attachToJob(triggerClient: TriggerClient, job: Job<Trigger<TEventSpecification>, any>): void;
|
|
2147
2400
|
get preprocessRuns(): boolean;
|
|
2148
|
-
verifyPayload(payload: ReturnType<TEventSpecification["parsePayload"]>): Promise<
|
|
2149
|
-
success: true;
|
|
2150
|
-
}>;
|
|
2401
|
+
verifyPayload(payload: ReturnType<TEventSpecification["parsePayload"]>): Promise<VerifyResult>;
|
|
2151
2402
|
}
|
|
2152
2403
|
/** Configuration options for an EventTrigger */
|
|
2153
2404
|
type TriggerOptions<TEvent> = {
|
|
@@ -2326,20 +2577,24 @@ declare class InvokeTrigger<TSchema extends ZodType = z.ZodTypeAny> implements T
|
|
|
2326
2577
|
}
|
|
2327
2578
|
declare function invokeTrigger<TSchema extends ZodType = z.ZodTypeAny>(options?: InvokeTriggerOptions<TSchema>): Trigger<EventSpecification<TypeOf<TSchema>, z.input<TSchema>>>;
|
|
2328
2579
|
|
|
2580
|
+
declare function slugifyId(input: string): string;
|
|
2581
|
+
|
|
2329
2582
|
/** Easily verify webhook payloads when they're using common signing methods. */
|
|
2330
|
-
declare function verifyRequestSignature({ request, headerName, secret, algorithm, }: {
|
|
2583
|
+
declare function verifyRequestSignature({ request, headerName, headerEncoding, secret, algorithm, }: {
|
|
2331
2584
|
/** The web request that you want to verify. */
|
|
2332
2585
|
request: Request;
|
|
2333
2586
|
/** The name of the header that contains the signature. E.g. `X-Cal-Signature-256`. */
|
|
2334
2587
|
headerName: string;
|
|
2588
|
+
/** The header encoding. Defaults to `hex`. */
|
|
2589
|
+
headerEncoding?: BinaryToTextEncoding;
|
|
2335
2590
|
/** The secret that you use to hash the payload. For HttpEndpoints this will usually originally
|
|
2336
2591
|
come from the Trigger.dev dashboard and should be stored in an environment variable. */
|
|
2337
|
-
secret:
|
|
2592
|
+
secret: BinaryLike | KeyObject;
|
|
2338
2593
|
/** The hashing algorithm that was used to create the signature. Currently only `sha256` is
|
|
2339
2594
|
supported. */
|
|
2340
2595
|
algorithm: "sha256";
|
|
2341
2596
|
}): Promise<VerifyResult>;
|
|
2342
|
-
declare function verifyHmacSha256(headerValue: string, secret:
|
|
2597
|
+
declare function verifyHmacSha256(headerValue: string, headerEncoding: BinaryToTextEncoding, secret: BinaryLike | KeyObject, body: string): boolean;
|
|
2343
2598
|
|
|
2344
2599
|
declare class ResumeWithTaskError {
|
|
2345
2600
|
task: ServerTask;
|
|
@@ -2416,4 +2671,4 @@ type Task = ServerTask;
|
|
|
2416
2671
|
type SentEvent = ApiEventLog;
|
|
2417
2672
|
declare function redactString(strings: TemplateStringsArray, ...interpolations: string[]): RedactString;
|
|
2418
2673
|
|
|
2419
|
-
export { AuthResolverResult, BackgroundFetchResponse, CronTrigger, DynamicIntervalOptions, DynamicSchedule, DynamicTrigger, DynamicTriggerOptions, EventSpecification, EventSpecificationExample, EventSpecificationExampleSchema, EventTrigger, EventTypeFromSpecification, ExternalSource, ExternalSourceParams, ExternalSourceTrigger, ExternalSourceTriggerOptions, HandlerEvent, HttpSourceEvent, IO, IOLogger, IOOptions, IOStats, IOTask, IOWithIntegrations, IntegrationTaskKey, IntervalTrigger, InvokeTrigger, JSONOutputSerializer, Job, JobIO, JobOptions, JobPayload, Json, MissingConnectionNotification, MissingConnectionResolvedNotification, OutputSerializer, PreprocessResults, RunTaskErrorCallback, SchemaParser, SchemaParserIssue, SchemaParserResult, SentEvent, Task, TaskLogger, Trigger, TriggerAuthResolver, TriggerClient, TriggerClientOptions, TriggerContext, TriggerEventType, TriggerIntegration, TriggerInvokeType, TriggerOptionRecord, TriggerPayload, TriggerPreprocessContext, VerifyResult, WaitForEventResult, cronTrigger, eventTrigger, intervalTrigger, invokeTrigger, isTriggerError, missingConnectionNotification, missingConnectionResolvedNotification, omit, redactString, retry, verifyHmacSha256, verifyRequestSignature, waitForEventSchema };
|
|
2674
|
+
export { AuthResolverResult, BackgroundFetchResponse, CronTrigger, DynamicIntervalOptions, DynamicSchedule, DynamicTrigger, DynamicTriggerOptions, EventSpecification, EventSpecificationExample, EventSpecificationExampleSchema, EventTrigger, EventTypeFromSpecification, ExternalSource, ExternalSourceParams, ExternalSourceTrigger, ExternalSourceTriggerOptions, GetWebhookConfig, GetWebhookParams, HandlerEvent, HttpSourceEvent, IO, IOLogger, IOOptions, IOStats, IOTask, IOWithIntegrations, IntegrationTaskKey, IntervalTrigger, InvokeTrigger, JSONOutputSerializer, Job, JobIO, JobOptions, JobPayload, Json, MissingConnectionNotification, MissingConnectionResolvedNotification, NotificationEvents, NotificationsEventEmitter, OutputSerializer, PreprocessResults, RunTaskErrorCallback, SchemaParser, SchemaParserIssue, SchemaParserResult, SentEvent, Task, TaskLogger, Trigger, TriggerAuthResolver, TriggerClient, TriggerClientOptions, TriggerContext, TriggerEventType, TriggerIntegration, TriggerInvokeType, TriggerOptionRecord, TriggerPayload, TriggerPreprocessContext, TypedEventSpecificationExample, VerifyResult, WaitForEventResult, WebhookConfig, WebhookDeliveryContext, WebhookHandlerEvent, WebhookSource, WebhookTrigger, WebhookTriggerOptions, cronTrigger, eventTrigger, intervalTrigger, invokeTrigger, isTriggerError, missingConnectionNotification, missingConnectionResolvedNotification, omit, redactString, retry, slugifyId, verifyHmacSha256, verifyRequestSignature, waitForEventSchema };
|