@trigger.dev/sdk 2.2.7 → 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 +224 -19
- package/dist/index.js +2258 -1569
- package/dist/index.js.map +1 -1
- package/package.json +3 -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, SuccessfulRunNotification, FailedRunNotification, 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;
|
|
@@ -894,6 +913,12 @@ declare const EventSpecificationExampleSchema: z.ZodObject<{
|
|
|
894
913
|
payload?: any;
|
|
895
914
|
}>;
|
|
896
915
|
type EventSpecificationExample = z.infer<typeof EventSpecificationExampleSchema>;
|
|
916
|
+
type TypedEventSpecificationExample<TEvent> = {
|
|
917
|
+
id: string;
|
|
918
|
+
name: string;
|
|
919
|
+
icon?: string;
|
|
920
|
+
payload: TEvent;
|
|
921
|
+
};
|
|
897
922
|
interface EventSpecification<TEvent extends any, TInvoke extends any = TEvent> {
|
|
898
923
|
name: string | string[];
|
|
899
924
|
title: string;
|
|
@@ -1090,7 +1115,7 @@ type TriggerOptionsRecordWithEvent<TValue, TTriggerOptionDefinitions extends Rec
|
|
|
1090
1115
|
type TriggerOptionRecord<TValue, TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
|
|
1091
1116
|
[K in keyof TTriggerOptionDefinitions]: TValue;
|
|
1092
1117
|
};
|
|
1093
|
-
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> = {
|
|
1094
1119
|
options: TriggerOptionDiffs<TTriggerOptionDefinitions>;
|
|
1095
1120
|
source: {
|
|
1096
1121
|
active: boolean;
|
|
@@ -1105,14 +1130,14 @@ type RegisterSourceEvent<TTriggerOptionDefinitions extends Record<string, string
|
|
|
1105
1130
|
dynamicTriggerId?: string;
|
|
1106
1131
|
options: TriggerOptionDiffs<TTriggerOptionDefinitions>;
|
|
1107
1132
|
};
|
|
1108
|
-
type RegisterFunctionOutput<TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
|
|
1133
|
+
type RegisterFunctionOutput$1<TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
|
|
1109
1134
|
secret?: string;
|
|
1110
1135
|
data?: SerializableJson;
|
|
1111
1136
|
options: TriggerOptionsRecordWithEvent<string[], TTriggerOptionDefinitions>;
|
|
1112
1137
|
};
|
|
1113
|
-
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<{
|
|
1114
1139
|
integration: TIntegration;
|
|
1115
|
-
}>, ctx: TriggerContext) => Promise<RegisterFunctionOutput<TTriggerOptionDefinitions> | undefined>;
|
|
1140
|
+
}>, ctx: TriggerContext) => Promise<RegisterFunctionOutput$1<TTriggerOptionDefinitions> | undefined>;
|
|
1116
1141
|
type HandlerEvent<TChannel extends ChannelNames, TParams extends any = any> = {
|
|
1117
1142
|
rawEvent: ExternalSourceChannelMap[TChannel]["event"];
|
|
1118
1143
|
source: Prettify<Omit<HandleTriggerSource, "params"> & {
|
|
@@ -1124,18 +1149,18 @@ type HandlerFunction<TChannel extends ChannelNames, TParams extends any, TTrigge
|
|
|
1124
1149
|
response?: NormalizedResponse;
|
|
1125
1150
|
metadata?: HttpSourceResponseMetadata;
|
|
1126
1151
|
} | void>;
|
|
1127
|
-
type KeyFunction<TParams extends any> = (params: TParams) => string;
|
|
1128
|
-
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;
|
|
1129
1154
|
type ExternalSourceOptions<TChannel extends ChannelNames, TIntegration extends TriggerIntegration, TParams extends any, TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
|
|
1130
1155
|
id: string;
|
|
1131
1156
|
version: string;
|
|
1132
1157
|
schema: SchemaParser<TParams>;
|
|
1133
1158
|
optionSchema?: SchemaParser<TTriggerOptionDefinitions>;
|
|
1134
1159
|
integration: TIntegration;
|
|
1135
|
-
register: RegisterFunction<TIntegration, TParams, TChannel, TTriggerOptionDefinitions>;
|
|
1136
|
-
filter?: FilterFunction<TParams, TTriggerOptionDefinitions>;
|
|
1160
|
+
register: RegisterFunction$1<TIntegration, TParams, TChannel, TTriggerOptionDefinitions>;
|
|
1161
|
+
filter?: FilterFunction$1<TParams, TTriggerOptionDefinitions>;
|
|
1137
1162
|
handler: HandlerFunction<TChannel, TParams, TIntegration>;
|
|
1138
|
-
key: KeyFunction<TParams>;
|
|
1163
|
+
key: KeyFunction$1<TParams>;
|
|
1139
1164
|
properties?: (params: TParams) => DisplayProperty[];
|
|
1140
1165
|
};
|
|
1141
1166
|
declare class ExternalSource<TIntegration extends TriggerIntegration, TParams extends any, TChannel extends ChannelNames = ChannelNames, TTriggerOptionDefinitions extends Record<string, string[]> = any> {
|
|
@@ -1161,7 +1186,7 @@ declare class ExternalSource<TIntegration extends TriggerIntegration, TParams ex
|
|
|
1161
1186
|
}>;
|
|
1162
1187
|
filter(params: TParams, options?: TTriggerOptionDefinitions): EventFilter;
|
|
1163
1188
|
properties(params: TParams): DisplayProperty[];
|
|
1164
|
-
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>;
|
|
1165
1190
|
key(params: TParams): string;
|
|
1166
1191
|
get integration(): TIntegration;
|
|
1167
1192
|
get integrationConfig(): {
|
|
@@ -1390,6 +1415,157 @@ declare class DynamicSchedule implements Trigger<ScheduledEventSpecification> {
|
|
|
1390
1415
|
toJSON(): TriggerMetadata;
|
|
1391
1416
|
}
|
|
1392
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
|
+
|
|
1393
1569
|
type TriggerClientOptions = {
|
|
1394
1570
|
/** The `id` property is used to uniquely identify the client.
|
|
1395
1571
|
*/
|
|
@@ -1432,7 +1608,7 @@ declare class TriggerClient {
|
|
|
1432
1608
|
* @returns An HTTP Endpoint, that can be used to create an HTTP Trigger.
|
|
1433
1609
|
* @link https://trigger.dev/docs/documentation/concepts/http-endpoints
|
|
1434
1610
|
*/
|
|
1435
|
-
defineHttpEndpoint(options: EndpointOptions): HttpEndpoint<EventSpecification<Request, Request>>;
|
|
1611
|
+
defineHttpEndpoint(options: EndpointOptions, suppressWarnings?: boolean): HttpEndpoint<EventSpecification<Request, Request>>;
|
|
1436
1612
|
attach(job: Job<Trigger<any>, any>): void;
|
|
1437
1613
|
attachDynamicTrigger(trigger: DynamicTrigger<any, any>): void;
|
|
1438
1614
|
attachJobToDynamicTrigger(job: Job<Trigger<any>, any>, trigger: DynamicTrigger<any, any>): void;
|
|
@@ -1445,6 +1621,13 @@ declare class TriggerClient {
|
|
|
1445
1621
|
}): void;
|
|
1446
1622
|
attachDynamicSchedule(key: string): void;
|
|
1447
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;
|
|
1448
1631
|
registerTrigger(id: string, key: string, options: RegisterTriggerBodyV2, idempotencyKey?: string): Promise<{
|
|
1449
1632
|
id: string;
|
|
1450
1633
|
options: {
|
|
@@ -1660,6 +1843,9 @@ declare class TriggerClient {
|
|
|
1660
1843
|
createEphemeralEventDispatcher(payload: EphemeralEventDispatcherRequestBody): Promise<{
|
|
1661
1844
|
id: string;
|
|
1662
1845
|
}>;
|
|
1846
|
+
get store(): {
|
|
1847
|
+
env: KeyValueStore;
|
|
1848
|
+
};
|
|
1663
1849
|
authorized(apiKey?: string | null): "authorized" | "unauthorized" | "missing-client" | "missing-header";
|
|
1664
1850
|
apiKey(): string | undefined;
|
|
1665
1851
|
}
|
|
@@ -1667,6 +1853,7 @@ declare class TriggerClient {
|
|
|
1667
1853
|
type IOTask = ServerTask;
|
|
1668
1854
|
type IOOptions = {
|
|
1669
1855
|
id: string;
|
|
1856
|
+
jobId: string;
|
|
1670
1857
|
apiClient: ApiClient;
|
|
1671
1858
|
client: TriggerClient;
|
|
1672
1859
|
context: TriggerContext;
|
|
@@ -1719,6 +1906,7 @@ type BackgroundFetchResponse<T> = {
|
|
|
1719
1906
|
declare class IO {
|
|
1720
1907
|
#private;
|
|
1721
1908
|
private _id;
|
|
1909
|
+
private _jobId;
|
|
1722
1910
|
private _apiClient;
|
|
1723
1911
|
private _triggerClient;
|
|
1724
1912
|
private _logger;
|
|
@@ -1736,6 +1924,9 @@ declare class IO {
|
|
|
1736
1924
|
private _executionTimeout?;
|
|
1737
1925
|
private _outputSerializer;
|
|
1738
1926
|
private _visitedCacheKeys;
|
|
1927
|
+
private _envStore;
|
|
1928
|
+
private _jobStore;
|
|
1929
|
+
private _runStore;
|
|
1739
1930
|
get stats(): IOStats;
|
|
1740
1931
|
constructor(options: IOOptions);
|
|
1741
1932
|
/** Used to send log messages to the [Run log](https://trigger.dev/docs/documentation/guides/viewing-runs). */
|
|
@@ -1960,6 +2151,12 @@ declare class IO {
|
|
|
1960
2151
|
id: string;
|
|
1961
2152
|
key: string;
|
|
1962
2153
|
}>;
|
|
2154
|
+
updateWebhook(cacheKey: string | any[], options: {
|
|
2155
|
+
key: string;
|
|
2156
|
+
} & UpdateWebhookBody): Promise<{
|
|
2157
|
+
id: string;
|
|
2158
|
+
key: string;
|
|
2159
|
+
}>;
|
|
1963
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.
|
|
1964
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.
|
|
1965
2162
|
* @param dynamicSchedule The [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) to register a new schedule on.
|
|
@@ -2072,6 +2269,11 @@ declare class IO {
|
|
|
2072
2269
|
* @returns A Promise that resolves with the returned value or the error
|
|
2073
2270
|
*/
|
|
2074
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
|
+
};
|
|
2075
2277
|
}
|
|
2076
2278
|
type CallbackFunction = (level: "DEBUG" | "INFO" | "WARN" | "ERROR" | "LOG", message: string, properties?: Record<string, any>) => Promise<void>;
|
|
2077
2279
|
declare class IOLogger implements TaskLogger {
|
|
@@ -2187,6 +2389,7 @@ type EventTriggerOptions<TEventSpecification extends EventSpecification<any>> =
|
|
|
2187
2389
|
name?: string | string[];
|
|
2188
2390
|
source?: string;
|
|
2189
2391
|
filter?: EventFilter;
|
|
2392
|
+
verify?: EventTypeFromSpecification<TEventSpecification> extends Request ? VerifyCallback : never;
|
|
2190
2393
|
};
|
|
2191
2394
|
declare class EventTrigger<TEventSpecification extends EventSpecification<any>> implements Trigger<TEventSpecification> {
|
|
2192
2395
|
#private;
|
|
@@ -2195,9 +2398,7 @@ declare class EventTrigger<TEventSpecification extends EventSpecification<any>>
|
|
|
2195
2398
|
get event(): TEventSpecification;
|
|
2196
2399
|
attachToJob(triggerClient: TriggerClient, job: Job<Trigger<TEventSpecification>, any>): void;
|
|
2197
2400
|
get preprocessRuns(): boolean;
|
|
2198
|
-
verifyPayload(payload: ReturnType<TEventSpecification["parsePayload"]>): Promise<
|
|
2199
|
-
success: true;
|
|
2200
|
-
}>;
|
|
2401
|
+
verifyPayload(payload: ReturnType<TEventSpecification["parsePayload"]>): Promise<VerifyResult>;
|
|
2201
2402
|
}
|
|
2202
2403
|
/** Configuration options for an EventTrigger */
|
|
2203
2404
|
type TriggerOptions<TEvent> = {
|
|
@@ -2376,20 +2577,24 @@ declare class InvokeTrigger<TSchema extends ZodType = z.ZodTypeAny> implements T
|
|
|
2376
2577
|
}
|
|
2377
2578
|
declare function invokeTrigger<TSchema extends ZodType = z.ZodTypeAny>(options?: InvokeTriggerOptions<TSchema>): Trigger<EventSpecification<TypeOf<TSchema>, z.input<TSchema>>>;
|
|
2378
2579
|
|
|
2580
|
+
declare function slugifyId(input: string): string;
|
|
2581
|
+
|
|
2379
2582
|
/** Easily verify webhook payloads when they're using common signing methods. */
|
|
2380
|
-
declare function verifyRequestSignature({ request, headerName, secret, algorithm, }: {
|
|
2583
|
+
declare function verifyRequestSignature({ request, headerName, headerEncoding, secret, algorithm, }: {
|
|
2381
2584
|
/** The web request that you want to verify. */
|
|
2382
2585
|
request: Request;
|
|
2383
2586
|
/** The name of the header that contains the signature. E.g. `X-Cal-Signature-256`. */
|
|
2384
2587
|
headerName: string;
|
|
2588
|
+
/** The header encoding. Defaults to `hex`. */
|
|
2589
|
+
headerEncoding?: BinaryToTextEncoding;
|
|
2385
2590
|
/** The secret that you use to hash the payload. For HttpEndpoints this will usually originally
|
|
2386
2591
|
come from the Trigger.dev dashboard and should be stored in an environment variable. */
|
|
2387
|
-
secret:
|
|
2592
|
+
secret: BinaryLike | KeyObject;
|
|
2388
2593
|
/** The hashing algorithm that was used to create the signature. Currently only `sha256` is
|
|
2389
2594
|
supported. */
|
|
2390
2595
|
algorithm: "sha256";
|
|
2391
2596
|
}): Promise<VerifyResult>;
|
|
2392
|
-
declare function verifyHmacSha256(headerValue: string, secret:
|
|
2597
|
+
declare function verifyHmacSha256(headerValue: string, headerEncoding: BinaryToTextEncoding, secret: BinaryLike | KeyObject, body: string): boolean;
|
|
2393
2598
|
|
|
2394
2599
|
declare class ResumeWithTaskError {
|
|
2395
2600
|
task: ServerTask;
|
|
@@ -2466,4 +2671,4 @@ type Task = ServerTask;
|
|
|
2466
2671
|
type SentEvent = ApiEventLog;
|
|
2467
2672
|
declare function redactString(strings: TemplateStringsArray, ...interpolations: string[]): RedactString;
|
|
2468
2673
|
|
|
2469
|
-
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, NotificationEvents, NotificationsEventEmitter, 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 };
|