@trigger.dev/sdk 3.0.0-beta.7 → 3.0.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.
Files changed (279) hide show
  1. package/dist/commonjs/apiClient.d.ts +737 -0
  2. package/dist/commonjs/apiClient.js +692 -0
  3. package/dist/commonjs/apiClient.js.map +1 -0
  4. package/dist/commonjs/concurrencyLimit.d.ts +10 -0
  5. package/dist/commonjs/concurrencyLimit.js +17 -0
  6. package/dist/commonjs/concurrencyLimit.js.map +1 -0
  7. package/dist/commonjs/errors.d.ts +66 -0
  8. package/dist/commonjs/errors.js +109 -0
  9. package/dist/commonjs/errors.js.map +1 -0
  10. package/dist/commonjs/httpEndpoint.d.ts +87 -0
  11. package/dist/commonjs/httpEndpoint.js +130 -0
  12. package/dist/commonjs/httpEndpoint.js.map +1 -0
  13. package/dist/commonjs/index.d.ts +23 -0
  14. package/dist/commonjs/index.js +55 -0
  15. package/dist/commonjs/index.js.map +1 -0
  16. package/dist/commonjs/integrations.d.ts +11 -0
  17. package/dist/commonjs/integrations.js +3 -0
  18. package/dist/commonjs/integrations.js.map +1 -0
  19. package/dist/commonjs/io.d.ts +453 -0
  20. package/dist/commonjs/io.js +1165 -0
  21. package/dist/commonjs/io.js.map +1 -0
  22. package/dist/commonjs/ioWithIntegrations.d.ts +4 -0
  23. package/dist/commonjs/ioWithIntegrations.js +32 -0
  24. package/dist/commonjs/ioWithIntegrations.js.map +1 -0
  25. package/dist/commonjs/job.d.ts +96 -0
  26. package/dist/commonjs/job.js +210 -0
  27. package/dist/commonjs/job.js.map +1 -0
  28. package/dist/commonjs/package.json +3 -0
  29. package/dist/commonjs/retry.d.ts +20 -0
  30. package/dist/commonjs/retry.js +22 -0
  31. package/dist/commonjs/retry.js.map +1 -0
  32. package/dist/commonjs/runLocalStorage.d.ts +8 -0
  33. package/dist/commonjs/runLocalStorage.js +6 -0
  34. package/dist/commonjs/runLocalStorage.js.map +1 -0
  35. package/dist/commonjs/security.d.ts +18 -0
  36. package/dist/commonjs/security.js +41 -0
  37. package/dist/commonjs/security.js.map +1 -0
  38. package/dist/commonjs/status.d.ts +19 -0
  39. package/dist/commonjs/status.js +38 -0
  40. package/dist/commonjs/status.js.map +1 -0
  41. package/dist/commonjs/store/keyValueStore.d.ts +17 -0
  42. package/dist/commonjs/store/keyValueStore.js +138 -0
  43. package/dist/commonjs/store/keyValueStore.js.map +1 -0
  44. package/dist/commonjs/store/keyValueStoreClient.d.ts +19 -0
  45. package/dist/commonjs/store/keyValueStoreClient.js +65 -0
  46. package/dist/commonjs/store/keyValueStoreClient.js.map +1 -0
  47. package/dist/commonjs/triggerClient.d.ts +300 -0
  48. package/dist/commonjs/triggerClient.js +1366 -0
  49. package/dist/commonjs/triggerClient.js.map +1 -0
  50. package/dist/commonjs/triggers/dynamic.d.ts +56 -0
  51. package/dist/commonjs/triggers/dynamic.js +97 -0
  52. package/dist/commonjs/triggers/dynamic.js.map +1 -0
  53. package/dist/commonjs/triggers/eventTrigger.d.ts +58 -0
  54. package/dist/commonjs/triggers/eventTrigger.js +69 -0
  55. package/dist/commonjs/triggers/eventTrigger.js.map +1 -0
  56. package/dist/commonjs/triggers/externalSource.d.ts +148 -0
  57. package/dist/commonjs/triggers/externalSource.js +106 -0
  58. package/dist/commonjs/triggers/externalSource.js.map +1 -0
  59. package/dist/commonjs/triggers/invokeTrigger.d.ts +39 -0
  60. package/dist/commonjs/triggers/invokeTrigger.js +58 -0
  61. package/dist/commonjs/triggers/invokeTrigger.js.map +1 -0
  62. package/dist/commonjs/triggers/notifications.d.ts +111 -0
  63. package/dist/commonjs/triggers/notifications.js +101 -0
  64. package/dist/commonjs/triggers/notifications.js.map +1 -0
  65. package/dist/commonjs/triggers/scheduled.d.ts +145 -0
  66. package/dist/commonjs/triggers/scheduled.js +208 -0
  67. package/dist/commonjs/triggers/scheduled.js.map +1 -0
  68. package/dist/commonjs/triggers/webhook.d.ts +143 -0
  69. package/dist/commonjs/triggers/webhook.js +133 -0
  70. package/dist/commonjs/triggers/webhook.js.map +1 -0
  71. package/dist/commonjs/typed-emitter.d.ts +37 -0
  72. package/dist/commonjs/typed-emitter.js +3 -0
  73. package/dist/commonjs/typed-emitter.js.map +1 -0
  74. package/dist/commonjs/types.d.ts +204 -0
  75. package/dist/commonjs/types.js +23 -0
  76. package/dist/commonjs/types.js.map +1 -0
  77. package/dist/commonjs/utils/formatSchemaErrors.d.ts +3 -0
  78. package/dist/commonjs/utils/formatSchemaErrors.js +10 -0
  79. package/dist/commonjs/utils/formatSchemaErrors.js.map +1 -0
  80. package/dist/commonjs/utils/typedAsyncLocalStorage.d.ts +6 -0
  81. package/dist/commonjs/utils/typedAsyncLocalStorage.js +18 -0
  82. package/dist/commonjs/utils/typedAsyncLocalStorage.js.map +1 -0
  83. package/dist/commonjs/utils.d.ts +1 -0
  84. package/dist/commonjs/utils.js +11 -0
  85. package/dist/commonjs/utils.js.map +1 -0
  86. package/dist/commonjs/v3/cache.d.ts +28 -0
  87. package/dist/commonjs/v3/cache.js +63 -0
  88. package/dist/commonjs/v3/cache.js.map +1 -0
  89. package/dist/commonjs/v3/config.d.ts +4 -0
  90. package/dist/commonjs/v3/config.js +7 -0
  91. package/dist/commonjs/v3/config.js.map +1 -0
  92. package/dist/commonjs/v3/envvars.d.ts +14 -0
  93. package/dist/commonjs/v3/envvars.js +246 -0
  94. package/dist/commonjs/v3/envvars.js.map +1 -0
  95. package/dist/commonjs/v3/idempotencyKeys.d.ts +49 -0
  96. package/dist/commonjs/v3/idempotencyKeys.js +76 -0
  97. package/dist/commonjs/v3/idempotencyKeys.js.map +1 -0
  98. package/dist/commonjs/v3/index.d.ts +36 -0
  99. package/dist/commonjs/v3/index.js +79 -0
  100. package/dist/commonjs/v3/index.js.map +1 -0
  101. package/dist/commonjs/v3/retry.d.ts +15 -0
  102. package/dist/commonjs/v3/retry.js +411 -0
  103. package/dist/commonjs/v3/retry.js.map +1 -0
  104. package/dist/commonjs/v3/runs.d.ts +345 -0
  105. package/dist/commonjs/v3/runs.js +195 -0
  106. package/dist/commonjs/v3/runs.js.map +1 -0
  107. package/dist/commonjs/v3/schedules/api.d.ts +1 -0
  108. package/dist/commonjs/v3/schedules/api.js +3 -0
  109. package/dist/commonjs/v3/schedules/api.js.map +1 -0
  110. package/dist/commonjs/v3/schedules/index.d.ts +87 -0
  111. package/dist/commonjs/v3/schedules/index.js +250 -0
  112. package/dist/commonjs/v3/schedules/index.js.map +1 -0
  113. package/dist/commonjs/v3/shared.d.ts +443 -0
  114. package/dist/commonjs/v3/shared.js +547 -0
  115. package/dist/commonjs/v3/shared.js.map +1 -0
  116. package/dist/commonjs/v3/tags.d.ts +6 -0
  117. package/dist/commonjs/v3/tags.js +50 -0
  118. package/dist/commonjs/v3/tags.js.map +1 -0
  119. package/dist/commonjs/v3/tasks.d.ts +31 -0
  120. package/dist/commonjs/v3/tasks.js +35 -0
  121. package/dist/commonjs/v3/tasks.js.map +1 -0
  122. package/dist/commonjs/v3/tracer.d.ts +2 -0
  123. package/dist/commonjs/v3/tracer.js +7 -0
  124. package/dist/commonjs/v3/tracer.js.map +1 -0
  125. package/dist/commonjs/v3/usage.d.ts +77 -0
  126. package/dist/commonjs/v3/usage.js +115 -0
  127. package/dist/commonjs/v3/usage.js.map +1 -0
  128. package/dist/commonjs/v3/wait.d.ts +22 -0
  129. package/dist/commonjs/v3/wait.js +99 -0
  130. package/dist/commonjs/v3/wait.js.map +1 -0
  131. package/dist/commonjs/version.d.ts +1 -0
  132. package/dist/commonjs/version.js +5 -0
  133. package/dist/commonjs/version.js.map +1 -0
  134. package/dist/esm/apiClient.d.ts +737 -0
  135. package/dist/esm/apiClient.js +687 -0
  136. package/dist/esm/apiClient.js.map +1 -0
  137. package/dist/esm/concurrencyLimit.d.ts +10 -0
  138. package/dist/esm/concurrencyLimit.js +13 -0
  139. package/dist/esm/concurrencyLimit.js.map +1 -0
  140. package/dist/esm/errors.d.ts +66 -0
  141. package/dist/esm/errors.js +95 -0
  142. package/dist/esm/errors.js.map +1 -0
  143. package/dist/esm/httpEndpoint.d.ts +87 -0
  144. package/dist/esm/httpEndpoint.js +125 -0
  145. package/dist/esm/httpEndpoint.js.map +1 -0
  146. package/dist/esm/index.d.ts +23 -0
  147. package/dist/esm/index.js +35 -0
  148. package/dist/esm/index.js.map +1 -0
  149. package/dist/esm/integrations.d.ts +11 -0
  150. package/dist/esm/integrations.js +2 -0
  151. package/dist/esm/integrations.js.map +1 -0
  152. package/dist/esm/io.d.ts +453 -0
  153. package/dist/esm/io.js +1159 -0
  154. package/dist/esm/io.js.map +1 -0
  155. package/dist/esm/ioWithIntegrations.d.ts +4 -0
  156. package/dist/esm/ioWithIntegrations.js +29 -0
  157. package/dist/esm/ioWithIntegrations.js.map +1 -0
  158. package/dist/esm/job.d.ts +96 -0
  159. package/dist/esm/job.js +206 -0
  160. package/dist/esm/job.js.map +1 -0
  161. package/dist/esm/package.json +3 -0
  162. package/dist/esm/retry.d.ts +20 -0
  163. package/dist/esm/retry.js +19 -0
  164. package/dist/esm/retry.js.map +1 -0
  165. package/dist/esm/runLocalStorage.d.ts +8 -0
  166. package/dist/esm/runLocalStorage.js +3 -0
  167. package/dist/esm/runLocalStorage.js.map +1 -0
  168. package/dist/esm/security.d.ts +18 -0
  169. package/dist/esm/security.js +34 -0
  170. package/dist/esm/security.js.map +1 -0
  171. package/dist/esm/status.d.ts +19 -0
  172. package/dist/esm/status.js +34 -0
  173. package/dist/esm/status.js.map +1 -0
  174. package/dist/esm/store/keyValueStore.d.ts +17 -0
  175. package/dist/esm/store/keyValueStore.js +134 -0
  176. package/dist/esm/store/keyValueStore.js.map +1 -0
  177. package/dist/esm/store/keyValueStoreClient.d.ts +19 -0
  178. package/dist/esm/store/keyValueStoreClient.js +61 -0
  179. package/dist/esm/store/keyValueStoreClient.js.map +1 -0
  180. package/dist/esm/triggerClient.d.ts +300 -0
  181. package/dist/esm/triggerClient.js +1359 -0
  182. package/dist/esm/triggerClient.js.map +1 -0
  183. package/dist/esm/triggers/dynamic.d.ts +56 -0
  184. package/dist/esm/triggers/dynamic.js +93 -0
  185. package/dist/esm/triggers/dynamic.js.map +1 -0
  186. package/dist/esm/triggers/eventTrigger.d.ts +58 -0
  187. package/dist/esm/triggers/eventTrigger.js +64 -0
  188. package/dist/esm/triggers/eventTrigger.js.map +1 -0
  189. package/dist/esm/triggers/externalSource.d.ts +148 -0
  190. package/dist/esm/triggers/externalSource.js +100 -0
  191. package/dist/esm/triggers/externalSource.js.map +1 -0
  192. package/dist/esm/triggers/invokeTrigger.d.ts +39 -0
  193. package/dist/esm/triggers/invokeTrigger.js +53 -0
  194. package/dist/esm/triggers/invokeTrigger.js.map +1 -0
  195. package/dist/esm/triggers/notifications.d.ts +111 -0
  196. package/dist/esm/triggers/notifications.js +94 -0
  197. package/dist/esm/triggers/notifications.js.map +1 -0
  198. package/dist/esm/triggers/scheduled.d.ts +145 -0
  199. package/dist/esm/triggers/scheduled.js +197 -0
  200. package/dist/esm/triggers/scheduled.js.map +1 -0
  201. package/dist/esm/triggers/webhook.d.ts +143 -0
  202. package/dist/esm/triggers/webhook.js +128 -0
  203. package/dist/esm/triggers/webhook.js.map +1 -0
  204. package/dist/esm/typed-emitter.d.ts +37 -0
  205. package/dist/esm/typed-emitter.js +2 -0
  206. package/dist/esm/typed-emitter.js.map +1 -0
  207. package/dist/esm/types.d.ts +204 -0
  208. package/dist/esm/types.js +19 -0
  209. package/dist/esm/types.js.map +1 -0
  210. package/dist/esm/utils/formatSchemaErrors.d.ts +3 -0
  211. package/dist/esm/utils/formatSchemaErrors.js +7 -0
  212. package/dist/esm/utils/formatSchemaErrors.js.map +1 -0
  213. package/dist/esm/utils/typedAsyncLocalStorage.d.ts +6 -0
  214. package/dist/esm/utils/typedAsyncLocalStorage.js +14 -0
  215. package/dist/esm/utils/typedAsyncLocalStorage.js.map +1 -0
  216. package/dist/esm/utils.d.ts +1 -0
  217. package/dist/esm/utils.js +8 -0
  218. package/dist/esm/utils.js.map +1 -0
  219. package/dist/esm/v3/cache.d.ts +28 -0
  220. package/dist/esm/v3/cache.js +58 -0
  221. package/dist/esm/v3/cache.js.map +1 -0
  222. package/dist/esm/v3/config.d.ts +4 -0
  223. package/dist/esm/v3/config.js +4 -0
  224. package/dist/esm/v3/config.js.map +1 -0
  225. package/dist/esm/v3/envvars.d.ts +14 -0
  226. package/dist/esm/v3/envvars.js +238 -0
  227. package/dist/esm/v3/envvars.js.map +1 -0
  228. package/dist/esm/v3/idempotencyKeys.d.ts +49 -0
  229. package/dist/esm/v3/idempotencyKeys.js +72 -0
  230. package/dist/esm/v3/idempotencyKeys.js.map +1 -0
  231. package/dist/esm/v3/index.d.ts +36 -0
  232. package/dist/esm/v3/index.js +35 -0
  233. package/dist/esm/v3/index.js.map +1 -0
  234. package/dist/esm/v3/retry.d.ts +15 -0
  235. package/dist/esm/v3/retry.js +408 -0
  236. package/dist/esm/v3/retry.js.map +1 -0
  237. package/dist/esm/v3/runs.d.ts +345 -0
  238. package/dist/esm/v3/runs.js +192 -0
  239. package/dist/esm/v3/runs.js.map +1 -0
  240. package/dist/esm/v3/schedules/api.d.ts +1 -0
  241. package/dist/esm/v3/schedules/api.js +2 -0
  242. package/dist/esm/v3/schedules/api.js.map +1 -0
  243. package/dist/esm/v3/schedules/index.d.ts +87 -0
  244. package/dist/esm/v3/schedules/index.js +239 -0
  245. package/dist/esm/v3/schedules/index.js.map +1 -0
  246. package/dist/esm/v3/shared.d.ts +443 -0
  247. package/dist/esm/v3/shared.js +534 -0
  248. package/dist/esm/v3/shared.js.map +1 -0
  249. package/dist/esm/v3/tags.d.ts +6 -0
  250. package/dist/esm/v3/tags.js +47 -0
  251. package/dist/esm/v3/tags.js.map +1 -0
  252. package/dist/esm/v3/tasks.d.ts +31 -0
  253. package/dist/esm/v3/tasks.js +31 -0
  254. package/dist/esm/v3/tasks.js.map +1 -0
  255. package/dist/esm/v3/tracer.d.ts +2 -0
  256. package/dist/esm/v3/tracer.js +4 -0
  257. package/dist/esm/v3/tracer.js.map +1 -0
  258. package/dist/esm/v3/usage.d.ts +77 -0
  259. package/dist/esm/v3/usage.js +112 -0
  260. package/dist/esm/v3/usage.js.map +1 -0
  261. package/dist/esm/v3/wait.d.ts +22 -0
  262. package/dist/esm/v3/wait.js +96 -0
  263. package/dist/esm/v3/wait.js.map +1 -0
  264. package/dist/esm/version.d.ts +1 -0
  265. package/dist/esm/version.js +2 -0
  266. package/dist/esm/version.js.map +1 -0
  267. package/package.json +62 -47
  268. package/dist/index.d.mts +0 -2704
  269. package/dist/index.d.ts +0 -2704
  270. package/dist/index.js +0 -4886
  271. package/dist/index.js.map +0 -1
  272. package/dist/index.mjs +0 -4847
  273. package/dist/index.mjs.map +0 -1
  274. package/dist/v3/index.d.mts +0 -261
  275. package/dist/v3/index.d.ts +0 -261
  276. package/dist/v3/index.js +0 -921
  277. package/dist/v3/index.js.map +0 -1
  278. package/dist/v3/index.mjs +0 -911
  279. package/dist/v3/index.mjs.map +0 -1
package/dist/index.d.ts DELETED
@@ -1,2704 +0,0 @@
1
- import * as _trigger_dev_core from '@trigger.dev/core';
2
- import { AsyncMap, KeyValueStoreResponseBody, RunTaskBodyInput, CompleteTaskBodyV2Input, FailTaskBodyInput, SendEvent, SendEventOptions, StatusUpdate, UpdateTriggerSourceBodyV2, TriggerSource, UpdateWebhookBody, RegisterTriggerBodyV2, RegisterSourceEventV2, ScheduleMetadata, GetRunOptionsWithTaskDetails, GetRunsOptions, InvokeOptions, EphemeralEventDispatcherRequestBody, RuntimeEnvironmentType, DisplayProperty, TriggerMetadata, EventFilter, SuccessfulRunNotification, FailedRunNotification, HttpEndpointMetadata, RequestFilter, Prettify, HandleTriggerSource, RegisterTriggerSource, SerializableJson, ConnectionAuth, NormalizedResponse, HttpSourceResponseMetadata, IntervalOptions, CronOptions, ScheduledPayload, RegisterWebhookSource, DeserializedJson, ServerTask, CachedTask, InitialStatusUpdate, FetchRequestInit, FetchRetryOptions, FetchTimeoutOptions, FetchPollOperation, RunTaskOptions, IntegrationMetadata, IntegrationConfig, JobMetadata, RunNotification, MissingConnectionNotificationPayload, MissingConnectionResolvedNotificationPayload, ErrorWithStack, ApiEventLog, RedactString } from '@trigger.dev/core';
3
- export { ConnectionAuth, DisplayProperty, EventFilter, NormalizedRequest, OverridableRunTaskOptions, Prettify, RedactString, RegisteredOptionsDiff, RunTaskOptions, SourceEventOption } from '@trigger.dev/core';
4
- import { LogLevel, Logger } from '@trigger.dev/core-backend';
5
- export { Logger } from '@trigger.dev/core-backend';
6
- import * as zod from 'zod';
7
- import { z, ZodType, TypeOf } from 'zod';
8
- import { Buffer } from 'buffer';
9
- import { BinaryToTextEncoding, BinaryLike, KeyObject } from 'crypto';
10
-
11
- type ConcurrencyLimitOptions = {
12
- id: string;
13
- limit: number;
14
- };
15
- declare class ConcurrencyLimit {
16
- private options;
17
- constructor(options: ConcurrencyLimitOptions);
18
- get id(): string;
19
- get limit(): number;
20
- }
21
-
22
- type QueryKeyValueStoreFunction = (action: "DELETE" | "GET" | "HAS" | "SET", data: {
23
- key: string;
24
- value?: string;
25
- }) => Promise<KeyValueStoreResponseBody>;
26
- declare class KeyValueStoreClient implements AsyncMap {
27
- #private;
28
- private queryStore;
29
- private type;
30
- private namespace;
31
- constructor(queryStore: QueryKeyValueStoreFunction, type?: string | null, namespace?: string);
32
- delete(key: string): Promise<boolean>;
33
- get<T extends Json<T>>(key: string): Promise<T | undefined>;
34
- has(key: string): Promise<boolean>;
35
- set<T extends Json<T>>(key: string, value: T): Promise<T>;
36
- }
37
-
38
- type ApiClientOptions = {
39
- apiKey?: string;
40
- apiUrl?: string;
41
- logLevel?: LogLevel;
42
- };
43
- type EndpointRecord = {
44
- id: string;
45
- name: string;
46
- url: string;
47
- };
48
- declare class ApiClient {
49
- #private;
50
- constructor(options: ApiClientOptions);
51
- registerEndpoint(options: {
52
- url: string;
53
- name: string;
54
- }): Promise<EndpointRecord>;
55
- runTask(runId: string, task: RunTaskBodyInput, options?: {
56
- cachedTasksCursor?: string;
57
- }): Promise<VersionedResponseBody<{
58
- "2023-09-29": z.ZodObject<{
59
- task: z.ZodObject<{
60
- id: z.ZodString;
61
- name: z.ZodString;
62
- icon: z.ZodNullable<z.ZodOptional<z.ZodString>>;
63
- noop: z.ZodBoolean;
64
- startedAt: z.ZodNullable<z.ZodOptional<z.ZodDate>>;
65
- completedAt: z.ZodNullable<z.ZodOptional<z.ZodDate>>;
66
- delayUntil: z.ZodNullable<z.ZodOptional<z.ZodDate>>;
67
- status: z.ZodEnum<["PENDING", "WAITING", "RUNNING", "COMPLETED", "ERRORED", "CANCELED"]>;
68
- description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
69
- params: z.ZodNullable<z.ZodOptional<z.ZodType<_trigger_dev_core.DeserializedJson, z.ZodTypeDef, _trigger_dev_core.DeserializedJson>>>;
70
- properties: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
71
- label: z.ZodString;
72
- text: z.ZodString;
73
- url: z.ZodOptional<z.ZodString>;
74
- imageUrl: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
75
- }, "strip", z.ZodTypeAny, {
76
- label: string;
77
- text: string;
78
- url?: string | undefined;
79
- imageUrl?: string[] | undefined;
80
- }, {
81
- label: string;
82
- text: string;
83
- url?: string | undefined;
84
- imageUrl?: string[] | undefined;
85
- }>, "many">>>;
86
- outputProperties: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
87
- label: z.ZodString;
88
- text: z.ZodString;
89
- url: z.ZodOptional<z.ZodString>;
90
- imageUrl: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
91
- }, "strip", z.ZodTypeAny, {
92
- label: string;
93
- text: string;
94
- url?: string | undefined;
95
- imageUrl?: string[] | undefined;
96
- }, {
97
- label: string;
98
- text: string;
99
- url?: string | undefined;
100
- imageUrl?: string[] | undefined;
101
- }>, "many">>>;
102
- output: z.ZodNullable<z.ZodOptional<z.ZodType<_trigger_dev_core.DeserializedJson, z.ZodTypeDef, _trigger_dev_core.DeserializedJson>>>;
103
- context: z.ZodNullable<z.ZodOptional<z.ZodType<_trigger_dev_core.DeserializedJson, z.ZodTypeDef, _trigger_dev_core.DeserializedJson>>>;
104
- error: z.ZodNullable<z.ZodOptional<z.ZodString>>;
105
- parentId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
106
- style: z.ZodNullable<z.ZodOptional<z.ZodObject<{
107
- style: z.ZodEnum<["normal", "minimal"]>;
108
- variant: z.ZodOptional<z.ZodString>;
109
- }, "strip", z.ZodTypeAny, {
110
- style: "normal" | "minimal";
111
- variant?: string | undefined;
112
- }, {
113
- style: "normal" | "minimal";
114
- variant?: string | undefined;
115
- }>>>;
116
- operation: z.ZodNullable<z.ZodOptional<z.ZodString>>;
117
- callbackUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
118
- childExecutionMode: z.ZodNullable<z.ZodOptional<z.ZodEnum<["SEQUENTIAL", "PARALLEL"]>>>;
119
- idempotencyKey: z.ZodString;
120
- attempts: z.ZodNumber;
121
- forceYield: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
122
- }, "strip", z.ZodTypeAny, {
123
- id: string;
124
- name: string;
125
- noop: boolean;
126
- status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
127
- idempotencyKey: string;
128
- attempts: number;
129
- icon?: string | null | undefined;
130
- startedAt?: Date | null | undefined;
131
- completedAt?: Date | null | undefined;
132
- delayUntil?: Date | null | undefined;
133
- description?: string | null | undefined;
134
- params?: _trigger_dev_core.DeserializedJson | undefined;
135
- properties?: {
136
- label: string;
137
- text: string;
138
- url?: string | undefined;
139
- imageUrl?: string[] | undefined;
140
- }[] | null | undefined;
141
- outputProperties?: {
142
- label: string;
143
- text: string;
144
- url?: string | undefined;
145
- imageUrl?: string[] | undefined;
146
- }[] | null | undefined;
147
- output?: _trigger_dev_core.DeserializedJson | undefined;
148
- context?: _trigger_dev_core.DeserializedJson | undefined;
149
- error?: string | null | undefined;
150
- parentId?: string | null | undefined;
151
- style?: {
152
- style: "normal" | "minimal";
153
- variant?: string | undefined;
154
- } | null | undefined;
155
- operation?: string | null | undefined;
156
- callbackUrl?: string | null | undefined;
157
- childExecutionMode?: "SEQUENTIAL" | "PARALLEL" | null | undefined;
158
- forceYield?: boolean | null | undefined;
159
- }, {
160
- id: string;
161
- name: string;
162
- noop: boolean;
163
- status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
164
- idempotencyKey: string;
165
- attempts: number;
166
- icon?: string | null | undefined;
167
- startedAt?: Date | null | undefined;
168
- completedAt?: Date | null | undefined;
169
- delayUntil?: Date | null | undefined;
170
- description?: string | null | undefined;
171
- params?: _trigger_dev_core.DeserializedJson | undefined;
172
- properties?: {
173
- label: string;
174
- text: string;
175
- url?: string | undefined;
176
- imageUrl?: string[] | undefined;
177
- }[] | null | undefined;
178
- outputProperties?: {
179
- label: string;
180
- text: string;
181
- url?: string | undefined;
182
- imageUrl?: string[] | undefined;
183
- }[] | null | undefined;
184
- output?: _trigger_dev_core.DeserializedJson | undefined;
185
- context?: _trigger_dev_core.DeserializedJson | undefined;
186
- error?: string | null | undefined;
187
- parentId?: string | null | undefined;
188
- style?: {
189
- style: "normal" | "minimal";
190
- variant?: string | undefined;
191
- } | null | undefined;
192
- operation?: string | null | undefined;
193
- callbackUrl?: string | null | undefined;
194
- childExecutionMode?: "SEQUENTIAL" | "PARALLEL" | null | undefined;
195
- forceYield?: boolean | null | undefined;
196
- }>;
197
- cachedTasks: z.ZodOptional<z.ZodObject<{
198
- tasks: z.ZodArray<z.ZodObject<{
199
- id: z.ZodString;
200
- idempotencyKey: z.ZodString;
201
- status: z.ZodEnum<["PENDING", "WAITING", "RUNNING", "COMPLETED", "ERRORED", "CANCELED"]>;
202
- noop: z.ZodDefault<z.ZodBoolean>;
203
- output: z.ZodNullable<z.ZodOptional<z.ZodType<_trigger_dev_core.DeserializedJson, z.ZodTypeDef, _trigger_dev_core.DeserializedJson>>>;
204
- parentId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
205
- }, "strip", z.ZodTypeAny, {
206
- id: string;
207
- noop: boolean;
208
- status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
209
- idempotencyKey: string;
210
- output?: _trigger_dev_core.DeserializedJson | undefined;
211
- parentId?: string | null | undefined;
212
- }, {
213
- id: string;
214
- status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
215
- idempotencyKey: string;
216
- noop?: boolean | undefined;
217
- output?: _trigger_dev_core.DeserializedJson | undefined;
218
- parentId?: string | null | undefined;
219
- }>, "many">;
220
- cursor: z.ZodOptional<z.ZodString>;
221
- }, "strip", z.ZodTypeAny, {
222
- tasks: {
223
- id: string;
224
- noop: boolean;
225
- status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
226
- idempotencyKey: string;
227
- output?: _trigger_dev_core.DeserializedJson | undefined;
228
- parentId?: string | null | undefined;
229
- }[];
230
- cursor?: string | undefined;
231
- }, {
232
- tasks: {
233
- id: string;
234
- status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
235
- idempotencyKey: string;
236
- noop?: boolean | undefined;
237
- output?: _trigger_dev_core.DeserializedJson | undefined;
238
- parentId?: string | null | undefined;
239
- }[];
240
- cursor?: string | undefined;
241
- }>>;
242
- }, "strip", z.ZodTypeAny, {
243
- task: {
244
- id: string;
245
- name: string;
246
- noop: boolean;
247
- status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
248
- idempotencyKey: string;
249
- attempts: number;
250
- icon?: string | null | undefined;
251
- startedAt?: Date | null | undefined;
252
- completedAt?: Date | null | undefined;
253
- delayUntil?: Date | null | undefined;
254
- description?: string | null | undefined;
255
- params?: _trigger_dev_core.DeserializedJson | undefined;
256
- properties?: {
257
- label: string;
258
- text: string;
259
- url?: string | undefined;
260
- imageUrl?: string[] | undefined;
261
- }[] | null | undefined;
262
- outputProperties?: {
263
- label: string;
264
- text: string;
265
- url?: string | undefined;
266
- imageUrl?: string[] | undefined;
267
- }[] | null | undefined;
268
- output?: _trigger_dev_core.DeserializedJson | undefined;
269
- context?: _trigger_dev_core.DeserializedJson | undefined;
270
- error?: string | null | undefined;
271
- parentId?: string | null | undefined;
272
- style?: {
273
- style: "normal" | "minimal";
274
- variant?: string | undefined;
275
- } | null | undefined;
276
- operation?: string | null | undefined;
277
- callbackUrl?: string | null | undefined;
278
- childExecutionMode?: "SEQUENTIAL" | "PARALLEL" | null | undefined;
279
- forceYield?: boolean | null | undefined;
280
- };
281
- cachedTasks?: {
282
- tasks: {
283
- id: string;
284
- noop: boolean;
285
- status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
286
- idempotencyKey: string;
287
- output?: _trigger_dev_core.DeserializedJson | undefined;
288
- parentId?: string | null | undefined;
289
- }[];
290
- cursor?: string | undefined;
291
- } | undefined;
292
- }, {
293
- task: {
294
- id: string;
295
- name: string;
296
- noop: boolean;
297
- status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
298
- idempotencyKey: string;
299
- attempts: number;
300
- icon?: string | null | undefined;
301
- startedAt?: Date | null | undefined;
302
- completedAt?: Date | null | undefined;
303
- delayUntil?: Date | null | undefined;
304
- description?: string | null | undefined;
305
- params?: _trigger_dev_core.DeserializedJson | undefined;
306
- properties?: {
307
- label: string;
308
- text: string;
309
- url?: string | undefined;
310
- imageUrl?: string[] | undefined;
311
- }[] | null | undefined;
312
- outputProperties?: {
313
- label: string;
314
- text: string;
315
- url?: string | undefined;
316
- imageUrl?: string[] | undefined;
317
- }[] | null | undefined;
318
- output?: _trigger_dev_core.DeserializedJson | undefined;
319
- context?: _trigger_dev_core.DeserializedJson | undefined;
320
- error?: string | null | undefined;
321
- parentId?: string | null | undefined;
322
- style?: {
323
- style: "normal" | "minimal";
324
- variant?: string | undefined;
325
- } | null | undefined;
326
- operation?: string | null | undefined;
327
- callbackUrl?: string | null | undefined;
328
- childExecutionMode?: "SEQUENTIAL" | "PARALLEL" | null | undefined;
329
- forceYield?: boolean | null | undefined;
330
- };
331
- cachedTasks?: {
332
- tasks: {
333
- id: string;
334
- status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
335
- idempotencyKey: string;
336
- noop?: boolean | undefined;
337
- output?: _trigger_dev_core.DeserializedJson | undefined;
338
- parentId?: string | null | undefined;
339
- }[];
340
- cursor?: string | undefined;
341
- } | undefined;
342
- }>;
343
- }, z.ZodObject<{
344
- id: z.ZodString;
345
- name: z.ZodString;
346
- icon: z.ZodNullable<z.ZodOptional<z.ZodString>>;
347
- noop: z.ZodBoolean;
348
- startedAt: z.ZodNullable<z.ZodOptional<z.ZodDate>>;
349
- completedAt: z.ZodNullable<z.ZodOptional<z.ZodDate>>;
350
- delayUntil: z.ZodNullable<z.ZodOptional<z.ZodDate>>;
351
- status: z.ZodEnum<["PENDING", "WAITING", "RUNNING", "COMPLETED", "ERRORED", "CANCELED"]>;
352
- description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
353
- params: z.ZodNullable<z.ZodOptional<z.ZodType<_trigger_dev_core.DeserializedJson, z.ZodTypeDef, _trigger_dev_core.DeserializedJson>>>;
354
- properties: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
355
- label: z.ZodString;
356
- text: z.ZodString;
357
- url: z.ZodOptional<z.ZodString>;
358
- imageUrl: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
359
- }, "strip", z.ZodTypeAny, {
360
- label: string;
361
- text: string;
362
- url?: string | undefined;
363
- imageUrl?: string[] | undefined;
364
- }, {
365
- label: string;
366
- text: string;
367
- url?: string | undefined;
368
- imageUrl?: string[] | undefined;
369
- }>, "many">>>;
370
- outputProperties: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
371
- label: z.ZodString;
372
- text: z.ZodString;
373
- url: z.ZodOptional<z.ZodString>;
374
- imageUrl: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
375
- }, "strip", z.ZodTypeAny, {
376
- label: string;
377
- text: string;
378
- url?: string | undefined;
379
- imageUrl?: string[] | undefined;
380
- }, {
381
- label: string;
382
- text: string;
383
- url?: string | undefined;
384
- imageUrl?: string[] | undefined;
385
- }>, "many">>>;
386
- output: z.ZodNullable<z.ZodOptional<z.ZodType<_trigger_dev_core.DeserializedJson, z.ZodTypeDef, _trigger_dev_core.DeserializedJson>>>;
387
- context: z.ZodNullable<z.ZodOptional<z.ZodType<_trigger_dev_core.DeserializedJson, z.ZodTypeDef, _trigger_dev_core.DeserializedJson>>>;
388
- error: z.ZodNullable<z.ZodOptional<z.ZodString>>;
389
- parentId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
390
- style: z.ZodNullable<z.ZodOptional<z.ZodObject<{
391
- style: z.ZodEnum<["normal", "minimal"]>;
392
- variant: z.ZodOptional<z.ZodString>;
393
- }, "strip", z.ZodTypeAny, {
394
- style: "normal" | "minimal";
395
- variant?: string | undefined;
396
- }, {
397
- style: "normal" | "minimal";
398
- variant?: string | undefined;
399
- }>>>;
400
- operation: z.ZodNullable<z.ZodOptional<z.ZodString>>;
401
- callbackUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
402
- childExecutionMode: z.ZodNullable<z.ZodOptional<z.ZodEnum<["SEQUENTIAL", "PARALLEL"]>>>;
403
- idempotencyKey: z.ZodString;
404
- attempts: z.ZodNumber;
405
- forceYield: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
406
- }, "strip", z.ZodTypeAny, {
407
- id: string;
408
- name: string;
409
- noop: boolean;
410
- status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
411
- idempotencyKey: string;
412
- attempts: number;
413
- icon?: string | null | undefined;
414
- startedAt?: Date | null | undefined;
415
- completedAt?: Date | null | undefined;
416
- delayUntil?: Date | null | undefined;
417
- description?: string | null | undefined;
418
- params?: _trigger_dev_core.DeserializedJson | undefined;
419
- properties?: {
420
- label: string;
421
- text: string;
422
- url?: string | undefined;
423
- imageUrl?: string[] | undefined;
424
- }[] | null | undefined;
425
- outputProperties?: {
426
- label: string;
427
- text: string;
428
- url?: string | undefined;
429
- imageUrl?: string[] | undefined;
430
- }[] | null | undefined;
431
- output?: _trigger_dev_core.DeserializedJson | undefined;
432
- context?: _trigger_dev_core.DeserializedJson | undefined;
433
- error?: string | null | undefined;
434
- parentId?: string | null | undefined;
435
- style?: {
436
- style: "normal" | "minimal";
437
- variant?: string | undefined;
438
- } | null | undefined;
439
- operation?: string | null | undefined;
440
- callbackUrl?: string | null | undefined;
441
- childExecutionMode?: "SEQUENTIAL" | "PARALLEL" | null | undefined;
442
- forceYield?: boolean | null | undefined;
443
- }, {
444
- id: string;
445
- name: string;
446
- noop: boolean;
447
- status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
448
- idempotencyKey: string;
449
- attempts: number;
450
- icon?: string | null | undefined;
451
- startedAt?: Date | null | undefined;
452
- completedAt?: Date | null | undefined;
453
- delayUntil?: Date | null | undefined;
454
- description?: string | null | undefined;
455
- params?: _trigger_dev_core.DeserializedJson | undefined;
456
- properties?: {
457
- label: string;
458
- text: string;
459
- url?: string | undefined;
460
- imageUrl?: string[] | undefined;
461
- }[] | null | undefined;
462
- outputProperties?: {
463
- label: string;
464
- text: string;
465
- url?: string | undefined;
466
- imageUrl?: string[] | undefined;
467
- }[] | null | undefined;
468
- output?: _trigger_dev_core.DeserializedJson | undefined;
469
- context?: _trigger_dev_core.DeserializedJson | undefined;
470
- error?: string | null | undefined;
471
- parentId?: string | null | undefined;
472
- style?: {
473
- style: "normal" | "minimal";
474
- variant?: string | undefined;
475
- } | null | undefined;
476
- operation?: string | null | undefined;
477
- callbackUrl?: string | null | undefined;
478
- childExecutionMode?: "SEQUENTIAL" | "PARALLEL" | null | undefined;
479
- forceYield?: boolean | null | undefined;
480
- }>>>;
481
- completeTask(runId: string, id: string, task: CompleteTaskBodyV2Input): Promise<{
482
- id: string;
483
- name: string;
484
- noop: boolean;
485
- status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
486
- idempotencyKey: string;
487
- attempts: number;
488
- icon?: string | null | undefined;
489
- startedAt?: Date | null | undefined;
490
- completedAt?: Date | null | undefined;
491
- delayUntil?: Date | null | undefined;
492
- description?: string | null | undefined;
493
- params?: _trigger_dev_core.DeserializedJson | undefined;
494
- properties?: {
495
- label: string;
496
- text: string;
497
- url?: string | undefined;
498
- imageUrl?: string[] | undefined;
499
- }[] | null | undefined;
500
- outputProperties?: {
501
- label: string;
502
- text: string;
503
- url?: string | undefined;
504
- imageUrl?: string[] | undefined;
505
- }[] | null | undefined;
506
- output?: _trigger_dev_core.DeserializedJson | undefined;
507
- context?: _trigger_dev_core.DeserializedJson | undefined;
508
- error?: string | null | undefined;
509
- parentId?: string | null | undefined;
510
- style?: {
511
- style: "normal" | "minimal";
512
- variant?: string | undefined;
513
- } | null | undefined;
514
- operation?: string | null | undefined;
515
- callbackUrl?: string | null | undefined;
516
- childExecutionMode?: "SEQUENTIAL" | "PARALLEL" | null | undefined;
517
- forceYield?: boolean | null | undefined;
518
- }>;
519
- failTask(runId: string, id: string, body: FailTaskBodyInput): Promise<{
520
- id: string;
521
- name: string;
522
- noop: boolean;
523
- status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
524
- idempotencyKey: string;
525
- attempts: number;
526
- icon?: string | null | undefined;
527
- startedAt?: Date | null | undefined;
528
- completedAt?: Date | null | undefined;
529
- delayUntil?: Date | null | undefined;
530
- description?: string | null | undefined;
531
- params?: _trigger_dev_core.DeserializedJson | undefined;
532
- properties?: {
533
- label: string;
534
- text: string;
535
- url?: string | undefined;
536
- imageUrl?: string[] | undefined;
537
- }[] | null | undefined;
538
- outputProperties?: {
539
- label: string;
540
- text: string;
541
- url?: string | undefined;
542
- imageUrl?: string[] | undefined;
543
- }[] | null | undefined;
544
- output?: _trigger_dev_core.DeserializedJson | undefined;
545
- context?: _trigger_dev_core.DeserializedJson | undefined;
546
- error?: string | null | undefined;
547
- parentId?: string | null | undefined;
548
- style?: {
549
- style: "normal" | "minimal";
550
- variant?: string | undefined;
551
- } | null | undefined;
552
- operation?: string | null | undefined;
553
- callbackUrl?: string | null | undefined;
554
- childExecutionMode?: "SEQUENTIAL" | "PARALLEL" | null | undefined;
555
- forceYield?: boolean | null | undefined;
556
- }>;
557
- sendEvent(event: SendEvent, options?: SendEventOptions): Promise<{
558
- id: string;
559
- name: string;
560
- payload: ((string | number | boolean | {
561
- [key: string]: _trigger_dev_core.DeserializedJson;
562
- } | _trigger_dev_core.DeserializedJson[]) & (string | number | boolean | {
563
- [key: string]: _trigger_dev_core.DeserializedJson;
564
- } | _trigger_dev_core.DeserializedJson[] | undefined)) | null;
565
- timestamp: Date;
566
- context?: _trigger_dev_core.DeserializedJson | undefined;
567
- deliverAt?: Date | null | undefined;
568
- deliveredAt?: Date | null | undefined;
569
- cancelledAt?: Date | null | undefined;
570
- }>;
571
- sendEvents(events: SendEvent[], options?: SendEventOptions): Promise<{
572
- id: string;
573
- name: string;
574
- payload: ((string | number | boolean | {
575
- [key: string]: _trigger_dev_core.DeserializedJson;
576
- } | _trigger_dev_core.DeserializedJson[]) & (string | number | boolean | {
577
- [key: string]: _trigger_dev_core.DeserializedJson;
578
- } | _trigger_dev_core.DeserializedJson[] | undefined)) | null;
579
- timestamp: Date;
580
- context?: _trigger_dev_core.DeserializedJson | undefined;
581
- deliverAt?: Date | null | undefined;
582
- deliveredAt?: Date | null | undefined;
583
- cancelledAt?: Date | null | undefined;
584
- }[]>;
585
- cancelEvent(eventId: string): Promise<{
586
- id: string;
587
- name: string;
588
- payload: ((string | number | boolean | {
589
- [key: string]: _trigger_dev_core.DeserializedJson;
590
- } | _trigger_dev_core.DeserializedJson[]) & (string | number | boolean | {
591
- [key: string]: _trigger_dev_core.DeserializedJson;
592
- } | _trigger_dev_core.DeserializedJson[] | undefined)) | null;
593
- timestamp: Date;
594
- context?: _trigger_dev_core.DeserializedJson | undefined;
595
- deliverAt?: Date | null | undefined;
596
- deliveredAt?: Date | null | undefined;
597
- cancelledAt?: Date | null | undefined;
598
- }>;
599
- cancelRunsForEvent(eventId: string): Promise<{
600
- cancelledRunIds: string[];
601
- failedToCancelRunIds: string[];
602
- }>;
603
- updateStatus(runId: string, id: string, status: StatusUpdate): Promise<{
604
- label: string;
605
- key: string;
606
- history: {
607
- label?: string | undefined;
608
- state?: "loading" | "success" | "failure" | undefined;
609
- data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
610
- }[];
611
- data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
612
- state?: "loading" | "success" | "failure" | undefined;
613
- }>;
614
- updateSource(client: string, key: string, source: UpdateTriggerSourceBodyV2): Promise<TriggerSource>;
615
- updateWebhook(key: string, webhookData: UpdateWebhookBody): Promise<TriggerSource>;
616
- registerTrigger(client: string, id: string, key: string, payload: RegisterTriggerBodyV2, idempotencyKey?: string): Promise<RegisterSourceEventV2>;
617
- registerSchedule(client: string, id: string, key: string, payload: ScheduleMetadata): Promise<{
618
- id: string;
619
- schedule: {
620
- options: {
621
- cron: string;
622
- };
623
- type: "cron";
624
- accountId?: string | undefined;
625
- metadata?: any;
626
- } | {
627
- options: {
628
- seconds: number;
629
- };
630
- type: "interval";
631
- accountId?: string | undefined;
632
- metadata?: any;
633
- };
634
- active: boolean;
635
- metadata?: any;
636
- }>;
637
- unregisterSchedule(client: string, id: string, key: string): Promise<{
638
- ok: boolean;
639
- }>;
640
- getAuth(client: string, id: string): Promise<{
641
- type: "oauth2" | "apiKey";
642
- accessToken: string;
643
- scopes?: string[] | undefined;
644
- additionalFields?: Record<string, string> | undefined;
645
- } | undefined>;
646
- getEvent(eventId: string): Promise<{
647
- id: string;
648
- name: string;
649
- updatedAt: Date;
650
- runs: {
651
- id: string;
652
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
653
- startedAt?: Date | null | undefined;
654
- completedAt?: Date | null | undefined;
655
- }[];
656
- createdAt: Date;
657
- }>;
658
- getRun(runId: string, options?: GetRunOptionsWithTaskDetails): Promise<{
659
- id: string;
660
- startedAt: Date | null;
661
- completedAt: Date | null;
662
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
663
- updatedAt: Date | null;
664
- tasks: _trigger_dev_core.RunTaskWithSubtasks[];
665
- statuses: {
666
- label: string;
667
- key: string;
668
- history: {
669
- label?: string | undefined;
670
- state?: "loading" | "success" | "failure" | undefined;
671
- data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
672
- }[];
673
- data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
674
- state?: "loading" | "success" | "failure" | undefined;
675
- }[];
676
- output?: any;
677
- nextCursor?: string | undefined;
678
- }>;
679
- cancelRun(runId: string): Promise<{
680
- id: string;
681
- startedAt: Date | null;
682
- completedAt: Date | null;
683
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
684
- updatedAt: Date | null;
685
- tasks: _trigger_dev_core.RunTaskWithSubtasks[];
686
- statuses: {
687
- label: string;
688
- key: string;
689
- history: {
690
- label?: string | undefined;
691
- state?: "loading" | "success" | "failure" | undefined;
692
- data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
693
- }[];
694
- data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
695
- state?: "loading" | "success" | "failure" | undefined;
696
- }[];
697
- output?: any;
698
- nextCursor?: string | undefined;
699
- }>;
700
- getRunStatuses(runId: string): Promise<{
701
- statuses: {
702
- label: string;
703
- key: string;
704
- history: {
705
- label?: string | undefined;
706
- state?: "loading" | "success" | "failure" | undefined;
707
- data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
708
- }[];
709
- data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
710
- state?: "loading" | "success" | "failure" | undefined;
711
- }[];
712
- run: {
713
- id: string;
714
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
715
- output?: any;
716
- };
717
- }>;
718
- getRuns(jobSlug: string, options?: GetRunsOptions): Promise<{
719
- runs: {
720
- id: string;
721
- startedAt: Date | null;
722
- completedAt: Date | null;
723
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
724
- updatedAt: Date | null;
725
- }[];
726
- nextCursor?: string | undefined;
727
- }>;
728
- invokeJob(jobId: string, payload: any, options?: InvokeOptions): Promise<{
729
- id: string;
730
- }>;
731
- cancelRunsForJob(jobId: string): Promise<{
732
- cancelledRunIds: string[];
733
- failedToCancelRunIds: string[];
734
- }>;
735
- createEphemeralEventDispatcher(payload: EphemeralEventDispatcherRequestBody): Promise<{
736
- id: string;
737
- }>;
738
- get store(): KeyValueStoreClient;
739
- }
740
- type VersionedResponseBodyMap = {
741
- [key: string]: z.ZodTypeAny;
742
- };
743
- type VersionedResponseBody<TVersions extends VersionedResponseBodyMap, TUnversioned extends z.ZodTypeAny> = {
744
- [TVersion in keyof TVersions]: {
745
- version: TVersion;
746
- body: z.infer<TVersions[TVersion]>;
747
- };
748
- }[keyof TVersions] | {
749
- version: "unversioned";
750
- body: z.infer<TUnversioned>;
751
- };
752
-
753
- declare class TriggerStatus {
754
- private id;
755
- private io;
756
- constructor(id: string, io: IO);
757
- update(key: IntegrationTaskKey, status: StatusUpdate): Promise<{
758
- label: string;
759
- key: string;
760
- history: {
761
- label?: string | undefined;
762
- state?: "loading" | "success" | "failure" | undefined;
763
- data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
764
- }[];
765
- data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
766
- state?: "loading" | "success" | "failure" | undefined;
767
- }>;
768
- }
769
-
770
- type EventMap = {
771
- [key: string]: (...args: any[]) => void
772
- }
773
-
774
- /**
775
- * Type-safe event emitter.
776
- *
777
- * Use it like this:
778
- *
779
- * ```typescript
780
- * type MyEvents = {
781
- * error: (error: Error) => void;
782
- * message: (from: string, content: string) => void;
783
- * }
784
- *
785
- * const myEmitter = new EventEmitter() as TypedEmitter<MyEvents>;
786
- *
787
- * myEmitter.emit("error", "x") // <- Will catch this type error;
788
- * ```
789
- */
790
- interface TypedEventEmitter<Events extends EventMap> {
791
- addListener<E extends keyof Events> (event: E, listener: Events[E]): this
792
- on<E extends keyof Events> (event: E, listener: Events[E]): this
793
- once<E extends keyof Events> (event: E, listener: Events[E]): this
794
- prependListener<E extends keyof Events> (event: E, listener: Events[E]): this
795
- prependOnceListener<E extends keyof Events> (event: E, listener: Events[E]): this
796
-
797
- off<E extends keyof Events>(event: E, listener: Events[E]): this
798
- removeAllListeners<E extends keyof Events> (event?: E): this
799
- removeListener<E extends keyof Events> (event: E, listener: Events[E]): this
800
-
801
- emit<E extends keyof Events> (event: E, ...args: Parameters<Events[E]>): boolean
802
- // The sloppy `eventNames()` return type is to mitigate type incompatibilities - see #5
803
- eventNames (): (keyof Events | string | symbol)[]
804
- rawListeners<E extends keyof Events> (event: E): Events[E][]
805
- listeners<E extends keyof Events> (event: E): Events[E][]
806
- listenerCount<E extends keyof Events> (event: E): number
807
-
808
- getMaxListeners (): number
809
- setMaxListeners (maxListeners: number): this
810
- }
811
-
812
- interface TriggerContext {
813
- /** Job metadata */
814
- job: {
815
- id: string;
816
- version: string;
817
- };
818
- /** Environment metadata */
819
- environment: {
820
- slug: string;
821
- id: string;
822
- type: RuntimeEnvironmentType;
823
- };
824
- /** Organization metadata */
825
- organization: {
826
- slug: string;
827
- id: string;
828
- title: string;
829
- };
830
- /** Project metadata */
831
- project: {
832
- slug: string;
833
- id: string;
834
- name: string;
835
- };
836
- /** Run metadata */
837
- run: {
838
- id: string;
839
- isTest: boolean;
840
- startedAt: Date;
841
- isRetry: boolean;
842
- };
843
- /** Event metadata */
844
- event: {
845
- id: string;
846
- name: string;
847
- context: any;
848
- timestamp: Date;
849
- };
850
- /** Source metadata */
851
- source?: {
852
- id: string;
853
- metadata?: any;
854
- };
855
- /** Account metadata */
856
- account?: {
857
- id: string;
858
- metadata?: any;
859
- };
860
- }
861
- interface TriggerPreprocessContext {
862
- job: {
863
- id: string;
864
- version: string;
865
- };
866
- environment: {
867
- slug: string;
868
- id: string;
869
- type: RuntimeEnvironmentType;
870
- };
871
- organization: {
872
- slug: string;
873
- id: string;
874
- title: string;
875
- };
876
- run: {
877
- id: string;
878
- isTest: boolean;
879
- };
880
- event: {
881
- id: string;
882
- name: string;
883
- context: any;
884
- timestamp: Date;
885
- };
886
- account?: {
887
- id: string;
888
- metadata?: any;
889
- };
890
- }
891
- interface TaskLogger {
892
- debug(message: string, properties?: Record<string, any>): Promise<void>;
893
- info(message: string, properties?: Record<string, any>): Promise<void>;
894
- warn(message: string, properties?: Record<string, any>): Promise<void>;
895
- error(message: string, properties?: Record<string, any>): Promise<void>;
896
- }
897
- type PreprocessResults = {
898
- abort: boolean;
899
- properties: DisplayProperty[];
900
- };
901
- type TriggerEventType<TTrigger extends Trigger<any>> = TTrigger extends Trigger<infer TEventSpec> ? ReturnType<TEventSpec["parsePayload"]> : never;
902
- type TriggerInvokeType<TTrigger extends Trigger<any>> = TTrigger extends Trigger<EventSpecification<any, infer TInvoke>> ? TInvoke : any;
903
- type VerifyResult = {
904
- success: true;
905
- } | {
906
- success: false;
907
- reason?: string;
908
- };
909
- interface Trigger<TEventSpec extends EventSpecification<any>> {
910
- event: TEventSpec;
911
- toJSON(): TriggerMetadata;
912
- attachToJob(triggerClient: TriggerClient, job: Job<Trigger<TEventSpec>, any>): void;
913
- preprocessRuns: boolean;
914
- verifyPayload: (payload: ReturnType<TEventSpec["parsePayload"]>) => Promise<VerifyResult>;
915
- }
916
- type TriggerPayload<TTrigger> = TTrigger extends Trigger<EventSpecification<infer TEvent>> ? TEvent : never;
917
- declare const EventSpecificationExampleSchema: z.ZodObject<{
918
- id: z.ZodString;
919
- name: z.ZodString;
920
- icon: z.ZodOptional<z.ZodString>;
921
- payload: z.ZodAny;
922
- }, "strip", z.ZodTypeAny, {
923
- id: string;
924
- name: string;
925
- icon?: string | undefined;
926
- payload?: any;
927
- }, {
928
- id: string;
929
- name: string;
930
- icon?: string | undefined;
931
- payload?: any;
932
- }>;
933
- type EventSpecificationExample = z.infer<typeof EventSpecificationExampleSchema>;
934
- type TypedEventSpecificationExample<TEvent> = {
935
- id: string;
936
- name: string;
937
- icon?: string;
938
- payload: TEvent;
939
- };
940
- interface EventSpecification<TEvent extends any, TInvoke extends any = TEvent> {
941
- name: string | string[];
942
- title: string;
943
- source: string;
944
- icon: string;
945
- properties?: DisplayProperty[];
946
- schema?: any;
947
- examples?: Array<EventSpecificationExample>;
948
- filter?: EventFilter;
949
- parsePayload: (payload: unknown) => TEvent;
950
- parseInvokePayload?: (payload: unknown) => TInvoke;
951
- runProperties?: (payload: TEvent) => DisplayProperty[];
952
- }
953
- type EventTypeFromSpecification<TEventSpec extends EventSpecification<any>> = TEventSpec extends EventSpecification<infer TEvent> ? TEvent : never;
954
- type SchemaParserIssue = {
955
- path: PropertyKey[];
956
- message: string;
957
- };
958
- type SchemaParserResult<T> = {
959
- success: true;
960
- data: T;
961
- } | {
962
- success: false;
963
- error: {
964
- issues: SchemaParserIssue[];
965
- };
966
- };
967
- type SchemaParser<T extends unknown = unknown> = {
968
- safeParse: (a: unknown) => SchemaParserResult<T>;
969
- };
970
- type WaitForEventResult<TEvent> = {
971
- id: string;
972
- name: string;
973
- source: string;
974
- payload: TEvent;
975
- timestamp: Date;
976
- context?: any;
977
- accountId?: string;
978
- };
979
- declare function waitForEventSchema(schema: z.ZodTypeAny): z.ZodObject<{
980
- id: z.ZodString;
981
- name: z.ZodString;
982
- source: z.ZodString;
983
- payload: z.ZodTypeAny;
984
- timestamp: z.ZodDate;
985
- context: z.ZodOptional<z.ZodAny>;
986
- accountId: z.ZodOptional<z.ZodString>;
987
- }, "strip", z.ZodTypeAny, {
988
- id: string;
989
- name: string;
990
- timestamp: Date;
991
- source: string;
992
- payload?: any;
993
- context?: any;
994
- accountId?: string | undefined;
995
- }, {
996
- id: string;
997
- name: string;
998
- timestamp: Date;
999
- source: string;
1000
- payload?: any;
1001
- context?: any;
1002
- accountId?: string | undefined;
1003
- }>;
1004
- type NotificationEvents = {
1005
- runSucceeeded: (notification: SuccessfulRunNotification<any>) => void;
1006
- runFailed: (notification: FailedRunNotification) => void;
1007
- };
1008
- type NotificationsEventEmitter = TypedEventEmitter<NotificationEvents>;
1009
-
1010
- type HttpEndpointOptions<TEventSpecification extends EventSpecification<any>> = {
1011
- id: string;
1012
- enabled?: boolean;
1013
- event: TEventSpecification;
1014
- respondWith?: RespondWith;
1015
- verify: VerifyCallback;
1016
- };
1017
- type RequestOptions = {
1018
- filter?: RequestFilter;
1019
- };
1020
- declare class HttpEndpoint<TEventSpecification extends EventSpecification<any>> {
1021
- private readonly options;
1022
- constructor(options: HttpEndpointOptions<TEventSpecification>);
1023
- get id(): string;
1024
- onRequest(options?: RequestOptions): HttpTrigger<EventSpecification<Request>>;
1025
- toJSON(): HttpEndpointMetadata;
1026
- }
1027
- type TriggerOptions$1<TEventSpecification extends EventSpecification<any>> = {
1028
- endpointId: string;
1029
- event: TEventSpecification;
1030
- filter?: EventFilter;
1031
- verify: VerifyCallback;
1032
- };
1033
- declare class HttpTrigger<TEventSpecification extends EventSpecification<any>> implements Trigger<TEventSpecification> {
1034
- private readonly options;
1035
- constructor(options: TriggerOptions$1<TEventSpecification>);
1036
- toJSON(): TriggerMetadata;
1037
- get event(): TEventSpecification;
1038
- attachToJob(triggerClient: TriggerClient, job: Job<Trigger<TEventSpecification>, any>): void;
1039
- get preprocessRuns(): boolean;
1040
- verifyPayload(payload: Request): Promise<VerifyResult>;
1041
- }
1042
- type RespondWith = {
1043
- /** Only Requests that match this filter will cause the `handler` function to run.
1044
- * For example, you can use this to only respond to `GET` Requests. */
1045
- filter?: RequestFilter;
1046
- /** If you set this to `true`, the Request that comes in won't go on to Trigger any Runs.
1047
- * This is useful if you want to Respond to the Request, but don't want to Trigger any Runs. */
1048
- skipTriggeringRuns?: boolean;
1049
- /** This is a function that's called when a Request comes in.
1050
- * It's passed the Request object, and expects you to return a Response object. */
1051
- handler: (request: Request, verify: () => Promise<VerifyResult>) => Promise<Response>;
1052
- };
1053
- type VerifyCallback = (request: Request) => Promise<VerifyResult>;
1054
- type EndpointOptions = {
1055
- /** Used to uniquely identify the HTTP Endpoint inside your Project. */
1056
- id: string;
1057
- enabled?: boolean;
1058
- /** Usually you would use the domain name of the service, e.g. `cal.com`. */
1059
- source: string;
1060
- /** An optional title, displayed in the dashboard. */
1061
- title?: string;
1062
- /** An optional icon name that's displayed in the dashboard.
1063
- * Lots of company names are supported, e.g. `github`, `twilio`.
1064
- * You can also reference the name of any [Tabler icon](https://tabler-icons.io/), e.g. `brand-google-maps`, `brand-twitch`. */
1065
- icon?: string;
1066
- /** Used to provide example payloads that are accepted by the job.
1067
- * This will be available in the dashboard and can be used to trigger test runs. */
1068
- examples?: EventSpecificationExample[];
1069
- /** Properties that are displayed in the dashboard. */
1070
- properties?: DisplayProperty[];
1071
- /** This optional object allows you to immediately Respond to a Request. This is useful for some APIs where they do a `GET` Request when the webhook is first setup and expect a specific Response.
1072
-
1073
- Only use this if you really need to Respond to the Request that comes in. Most of the time you don't. */
1074
- respondWith?: RespondWith;
1075
- /** This is compulsory, and is used to verify that the received webhook is authentic.
1076
- * It's a function that expects you to return a result object like:
1077
-
1078
- In 90% of cases, you'll want to use the `verifyRequestSignature` helper function we provide.
1079
-
1080
- @example
1081
- ```ts
1082
- //if it's valid
1083
- return { success: true }
1084
- //if it's invalid, reason is optional
1085
- return { success: false, reason: "No header" }
1086
- ```
1087
-
1088
- */
1089
- verify: VerifyCallback;
1090
- };
1091
-
1092
- declare class KeyValueStore {
1093
- #private;
1094
- private apiClient;
1095
- private type;
1096
- private namespace;
1097
- constructor(apiClient: ApiClient, type?: string | null, namespace?: string);
1098
- delete(cacheKey: string | any[], key: string): Promise<boolean>;
1099
- delete(key: string): Promise<boolean>;
1100
- get<T extends Json<T> = any>(cacheKey: string | any[], key: string): Promise<T | undefined>;
1101
- get<T extends Json<T> = any>(key: string): Promise<T | undefined>;
1102
- has(cacheKey: string | any[], key: string): Promise<boolean>;
1103
- has(key: string): Promise<boolean>;
1104
- set<T extends Json<T>>(cacheKey: string | any[], key: string, value: T): Promise<T>;
1105
- set<T extends Json<T>>(key: string, value: T): Promise<T>;
1106
- }
1107
-
1108
- type HttpSourceEvent = {
1109
- url: string;
1110
- method: string;
1111
- headers: Record<string, string>;
1112
- rawBody?: Buffer | null;
1113
- };
1114
- type SmtpSourceEvent = {
1115
- from: string;
1116
- to: string;
1117
- subject: string;
1118
- body: string;
1119
- };
1120
- type SqsSourceEvent = {
1121
- body: string;
1122
- };
1123
- type ExternalSourceChannelMap = {
1124
- HTTP: {
1125
- event: Request;
1126
- register: {
1127
- url: string;
1128
- };
1129
- };
1130
- SMTP: {
1131
- event: SmtpSourceEvent;
1132
- register: {};
1133
- };
1134
- SQS: {
1135
- event: SqsSourceEvent;
1136
- register: {};
1137
- };
1138
- };
1139
- type ChannelNames = keyof ExternalSourceChannelMap;
1140
- type TriggerOptionDiff = {
1141
- desired: string[];
1142
- missing: string[];
1143
- orphaned: string[];
1144
- };
1145
- type TriggerOptionDiffs<TTriggerOptionDefinitions extends Record<string, string[]> = any> = TriggerOptionsRecordWithEvent<TriggerOptionDiff, TTriggerOptionDefinitions>;
1146
- type TriggerOptionsRecordWithEvent<TValue, TTriggerOptionDefinitions extends Record<string, string[]>> = {
1147
- event: TValue;
1148
- } & TriggerOptionRecord<TValue, TTriggerOptionDefinitions>;
1149
- type TriggerOptionRecord<TValue, TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
1150
- [K in keyof TTriggerOptionDefinitions]: TValue;
1151
- };
1152
- type RegisterFunctionEvent$1<TChannel extends ChannelNames, TParams extends any, TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
1153
- options: TriggerOptionDiffs<TTriggerOptionDefinitions>;
1154
- source: {
1155
- active: boolean;
1156
- data?: any;
1157
- secret: string;
1158
- } & ExternalSourceChannelMap[TChannel]["register"];
1159
- params: TParams;
1160
- };
1161
- type RegisterSourceEvent<TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
1162
- id: string;
1163
- source: RegisterTriggerSource;
1164
- dynamicTriggerId?: string;
1165
- options: TriggerOptionDiffs<TTriggerOptionDefinitions>;
1166
- };
1167
- type RegisterFunctionOutput$1<TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
1168
- secret?: string;
1169
- data?: SerializableJson;
1170
- options: TriggerOptionsRecordWithEvent<string[], TTriggerOptionDefinitions>;
1171
- };
1172
- 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<{
1173
- integration: TIntegration;
1174
- }>, ctx: TriggerContext) => Promise<RegisterFunctionOutput$1<TTriggerOptionDefinitions> | undefined>;
1175
- type HandlerEvent<TChannel extends ChannelNames, TParams extends any = any> = {
1176
- rawEvent: ExternalSourceChannelMap[TChannel]["event"];
1177
- source: Prettify<Omit<HandleTriggerSource, "params"> & {
1178
- params: TParams;
1179
- }>;
1180
- };
1181
- type HandlerFunction<TChannel extends ChannelNames, TParams extends any, TTriggerIntegration extends TriggerIntegration> = (event: HandlerEvent<TChannel, TParams>, logger: Logger, integration: TTriggerIntegration, auth?: ConnectionAuth) => Promise<{
1182
- events: SendEvent[];
1183
- response?: NormalizedResponse;
1184
- metadata?: HttpSourceResponseMetadata;
1185
- } | void>;
1186
- type KeyFunction$1<TParams extends any> = (params: TParams) => string;
1187
- type FilterFunction$1<TParams extends any, TTriggerOptionDefinitions extends Record<string, string[]> = any> = (params: TParams, options?: TTriggerOptionDefinitions) => EventFilter;
1188
- type ExternalSourceOptions<TChannel extends ChannelNames, TIntegration extends TriggerIntegration, TParams extends any, TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
1189
- id: string;
1190
- version: string;
1191
- schema: SchemaParser<TParams>;
1192
- optionSchema?: SchemaParser<TTriggerOptionDefinitions>;
1193
- integration: TIntegration;
1194
- register: RegisterFunction$1<TIntegration, TParams, TChannel, TTriggerOptionDefinitions>;
1195
- filter?: FilterFunction$1<TParams, TTriggerOptionDefinitions>;
1196
- handler: HandlerFunction<TChannel, TParams, TIntegration>;
1197
- key: KeyFunction$1<TParams>;
1198
- properties?: (params: TParams) => DisplayProperty[];
1199
- };
1200
- declare class ExternalSource<TIntegration extends TriggerIntegration, TParams extends any, TChannel extends ChannelNames = ChannelNames, TTriggerOptionDefinitions extends Record<string, string[]> = any> {
1201
- private options;
1202
- channel: TChannel;
1203
- constructor(channel: TChannel, options: ExternalSourceOptions<TChannel, TIntegration, TParams, TTriggerOptionDefinitions>);
1204
- handle(source: HandleTriggerSource, rawEvent: ExternalSourceChannelMap[TChannel]["event"], logger: Logger): Promise<void | {
1205
- events: {
1206
- name: string;
1207
- payload?: any;
1208
- context?: any;
1209
- id?: string | undefined;
1210
- timestamp?: Date | undefined;
1211
- source?: string | undefined;
1212
- payloadType?: "JSON" | "REQUEST" | undefined;
1213
- }[];
1214
- response?: {
1215
- status: number;
1216
- body?: any;
1217
- headers?: Record<string, string> | undefined;
1218
- } | undefined;
1219
- metadata?: _trigger_dev_core.DeserializedJson | undefined;
1220
- }>;
1221
- filter(params: TParams, options?: TTriggerOptionDefinitions): EventFilter;
1222
- properties(params: TParams): DisplayProperty[];
1223
- register(params: TParams, registerEvent: RegisterSourceEvent<TTriggerOptionDefinitions>, io: IO, ctx: TriggerContext): Promise<RegisterFunctionOutput$1<TTriggerOptionDefinitions> | undefined>;
1224
- key(params: TParams): string;
1225
- get integration(): TIntegration;
1226
- get integrationConfig(): {
1227
- id: string;
1228
- metadata: {
1229
- id: string;
1230
- name: string;
1231
- instructions?: string | undefined;
1232
- };
1233
- };
1234
- get id(): string;
1235
- get version(): string;
1236
- }
1237
- type ExternalSourceParams<TExternalSource extends ExternalSource<any, any, any>> = TExternalSource extends ExternalSource<any, infer TParams, any> ? TParams : never;
1238
- type ExternalSourceTriggerOptions<TEventSpecification extends EventSpecification<any>, TEventSource extends ExternalSource<any, any, any>, TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
1239
- event: TEventSpecification;
1240
- source: TEventSource;
1241
- params: ExternalSourceParams<TEventSource>;
1242
- options: TriggerOptionRecord<string[], TTriggerOptionDefinitions>;
1243
- };
1244
- declare class ExternalSourceTrigger<TEventSpecification extends EventSpecification<any>, TEventSource extends ExternalSource<any, any, any>> implements Trigger<TEventSpecification> {
1245
- private options;
1246
- constructor(options: ExternalSourceTriggerOptions<TEventSpecification, TEventSource>);
1247
- get event(): TEventSpecification;
1248
- toJSON(): TriggerMetadata;
1249
- attachToJob(triggerClient: TriggerClient, job: Job<Trigger<TEventSpecification>, any>): void;
1250
- get preprocessRuns(): boolean;
1251
- verifyPayload(payload: ReturnType<TEventSpecification["parsePayload"]>): Promise<{
1252
- success: true;
1253
- }>;
1254
- }
1255
- declare function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, key: K): {
1256
- result: Omit<T, K>;
1257
- ommited: T[K];
1258
- };
1259
-
1260
- /** Options for a DynamicTrigger */
1261
- type DynamicTriggerOptions<TEventSpec extends EventSpecification<any>, TExternalSource extends ExternalSource<any, any, any>> = {
1262
- /** Used to uniquely identify a DynamicTrigger */
1263
- id: string;
1264
- /** An event from an [Integration](https://trigger.dev/docs/integrations) package that you want to attach to the DynamicTrigger. The event types will come through to the payload in your Job's run. */
1265
- event: TEventSpec;
1266
- /** An external source fron an [Integration](https://trigger.dev/docs/integrations) package
1267
- * @example
1268
- * ```ts
1269
- * import { events } from "@trigger.dev/github";
1270
- *
1271
- * const dynamicOnIssueOpened = client.defineDynamicTrigger({
1272
- id: "github-issue-opened",
1273
- event: events.onIssueOpened,
1274
- source: github.sources.repo,
1275
- });
1276
- * ```
1277
- */
1278
- source: TExternalSource;
1279
- };
1280
- /** `DynamicTrigger` allows you to define a trigger that can be configured dynamically at runtime. */
1281
- declare class DynamicTrigger<TEventSpec extends EventSpecification<any>, TExternalSource extends ExternalSource<any, any, any>> implements Trigger<TEventSpec> {
1282
- #private;
1283
- source: TExternalSource;
1284
- /** `DynamicTrigger` allows you to define a trigger that can be configured dynamically at runtime.
1285
- * @param client The `TriggerClient` instance to use for registering the trigger.
1286
- * @param options The options for the dynamic trigger.
1287
- * */
1288
- constructor(client: TriggerClient, options: DynamicTriggerOptions<TEventSpec, TExternalSource>);
1289
- toJSON(): TriggerMetadata;
1290
- get id(): string;
1291
- get event(): TEventSpec;
1292
- /** Use this method to register a new configuration with the DynamicTrigger.
1293
- * @param key The key for the configuration. This will be used to identify the configuration when it is triggered.
1294
- * @param params The params for the configuration.
1295
- * @param options Options for the configuration.
1296
- * @param options.accountId The accountId to associate with the configuration.
1297
- * @param options.filter The filter to use for the configuration.
1298
- *
1299
- */
1300
- register(key: string, params: ExternalSourceParams<TExternalSource>, options?: {
1301
- accountId?: string;
1302
- filter?: EventFilter;
1303
- }): Promise<RegisterSourceEventV2>;
1304
- attachToJob(triggerClient: TriggerClient, job: Job<Trigger<TEventSpec>, any>): void;
1305
- get preprocessRuns(): boolean;
1306
- verifyPayload(payload: ReturnType<TEventSpec["parsePayload"]>): Promise<{
1307
- success: true;
1308
- }>;
1309
- }
1310
-
1311
- type ScheduledEventSpecification = EventSpecification<ScheduledPayload>;
1312
- declare class IntervalTrigger implements Trigger<ScheduledEventSpecification> {
1313
- private options;
1314
- constructor(options: IntervalOptions);
1315
- get event(): {
1316
- name: string;
1317
- title: string;
1318
- source: string;
1319
- icon: string;
1320
- examples: {
1321
- id: string;
1322
- name: string;
1323
- icon: string;
1324
- payload: {
1325
- ts: string;
1326
- lastTimestamp: string;
1327
- };
1328
- }[];
1329
- parsePayload: (data: unknown, params?: Partial<zod.ParseParams> | undefined) => {
1330
- ts: Date;
1331
- lastTimestamp?: Date | undefined;
1332
- };
1333
- properties: {
1334
- label: string;
1335
- text: string;
1336
- }[];
1337
- };
1338
- attachToJob(triggerClient: TriggerClient, job: Job<Trigger<ScheduledEventSpecification>, any>): void;
1339
- get preprocessRuns(): boolean;
1340
- verifyPayload(payload: ReturnType<ScheduledEventSpecification["parsePayload"]>): Promise<{
1341
- success: true;
1342
- }>;
1343
- toJSON(): TriggerMetadata;
1344
- }
1345
- /** `intervalTrigger()` is set as a [Job's trigger](/sdk/job) to trigger a Job at a recurring interval.
1346
- * @param options An object containing options about the interval.
1347
- */
1348
- declare function intervalTrigger(options: IntervalOptions): IntervalTrigger;
1349
- declare class CronTrigger implements Trigger<ScheduledEventSpecification> {
1350
- private options;
1351
- constructor(options: CronOptions);
1352
- get event(): {
1353
- name: string;
1354
- title: string;
1355
- source: string;
1356
- icon: string;
1357
- examples: {
1358
- id: string;
1359
- name: string;
1360
- icon: string;
1361
- payload: {
1362
- ts: string;
1363
- lastTimestamp: string;
1364
- };
1365
- }[];
1366
- parsePayload: (data: unknown, params?: Partial<zod.ParseParams> | undefined) => {
1367
- ts: Date;
1368
- lastTimestamp?: Date | undefined;
1369
- };
1370
- properties: {
1371
- label: string;
1372
- text: string;
1373
- }[];
1374
- };
1375
- attachToJob(triggerClient: TriggerClient, job: Job<Trigger<ScheduledEventSpecification>, any>): void;
1376
- get preprocessRuns(): boolean;
1377
- verifyPayload(payload: ReturnType<ScheduledEventSpecification["parsePayload"]>): Promise<{
1378
- success: true;
1379
- }>;
1380
- toJSON(): TriggerMetadata;
1381
- }
1382
- /** `cronTrigger()` is set as a [Job's trigger](https://trigger.dev/docs/sdk/job) to trigger a Job on a recurring schedule using a CRON expression.
1383
- * @param options An object containing options about the CRON schedule.
1384
- */
1385
- declare function cronTrigger(options: CronOptions): CronTrigger;
1386
- /** DynamicSchedule options
1387
- * @param id Used to uniquely identify a DynamicSchedule
1388
- */
1389
- type DynamicIntervalOptions = {
1390
- id: string;
1391
- };
1392
- /** DynamicSchedule` allows you to define a scheduled trigger that can be configured dynamically at runtime. */
1393
- declare class DynamicSchedule implements Trigger<ScheduledEventSpecification> {
1394
- private client;
1395
- private options;
1396
- /**
1397
- * @param client The `TriggerClient` instance to use for registering the trigger.
1398
- * @param options The options for the schedule.
1399
- */
1400
- constructor(client: TriggerClient, options: DynamicIntervalOptions);
1401
- get id(): string;
1402
- get event(): {
1403
- name: string;
1404
- title: string;
1405
- source: string;
1406
- icon: string;
1407
- examples: {
1408
- id: string;
1409
- name: string;
1410
- icon: string;
1411
- payload: {
1412
- ts: string;
1413
- lastTimestamp: string;
1414
- };
1415
- }[];
1416
- parsePayload: (data: unknown, params?: Partial<zod.ParseParams> | undefined) => {
1417
- ts: Date;
1418
- lastTimestamp?: Date | undefined;
1419
- };
1420
- };
1421
- register(key: string, metadata: ScheduleMetadata): Promise<{
1422
- id: string;
1423
- schedule: {
1424
- options: {
1425
- cron: string;
1426
- };
1427
- type: "cron";
1428
- accountId?: string | undefined;
1429
- metadata?: any;
1430
- } | {
1431
- options: {
1432
- seconds: number;
1433
- };
1434
- type: "interval";
1435
- accountId?: string | undefined;
1436
- metadata?: any;
1437
- };
1438
- active: boolean;
1439
- metadata?: any;
1440
- }>;
1441
- unregister(key: string): Promise<{
1442
- ok: boolean;
1443
- }>;
1444
- attachToJob(triggerClient: TriggerClient, job: Job<Trigger<ScheduledEventSpecification>, any>): void;
1445
- get preprocessRuns(): boolean;
1446
- verifyPayload(payload: ReturnType<ScheduledEventSpecification["parsePayload"]>): Promise<{
1447
- success: true;
1448
- }>;
1449
- toJSON(): TriggerMetadata;
1450
- }
1451
-
1452
- type WebhookCRUDContext<TParams extends any, TConfig extends Record<string, string[]>> = {
1453
- active: boolean;
1454
- params: TParams;
1455
- config: {
1456
- current: Partial<TConfig>;
1457
- desired: TConfig;
1458
- };
1459
- url: string;
1460
- secret: string;
1461
- };
1462
- type WebhookCRUDFunction<TIntegration extends TriggerIntegration, TParams extends any, TConfig extends Record<string, string[]>> = (options: {
1463
- io: IOWithIntegrations<{
1464
- integration: TIntegration;
1465
- }>;
1466
- ctx: WebhookCRUDContext<TParams, TConfig>;
1467
- }) => Promise<any>;
1468
- interface WebhookCRUD<TIntegration extends TriggerIntegration, TParams extends any, TConfig extends Record<string, string[]>> {
1469
- create: WebhookCRUDFunction<TIntegration, TParams, TConfig>;
1470
- read?: WebhookCRUDFunction<TIntegration, TParams, TConfig>;
1471
- update?: WebhookCRUDFunction<TIntegration, TParams, TConfig>;
1472
- delete: WebhookCRUDFunction<TIntegration, TParams, TConfig>;
1473
- }
1474
- type WebhookConfig<TConfigKeys extends string> = {
1475
- [K in TConfigKeys]: string[];
1476
- };
1477
- type RegisterFunctionEvent<TParams extends any, TConfig extends Record<string, string[]>> = {
1478
- source: {
1479
- active: boolean;
1480
- data?: any;
1481
- secret: string;
1482
- url: string;
1483
- };
1484
- params: TParams;
1485
- config: TConfig;
1486
- };
1487
- type WebhookRegisterEvent<TConfig extends Record<string, string[]>> = {
1488
- id: string;
1489
- source: RegisterWebhookSource;
1490
- dynamicTriggerId?: string;
1491
- config: TConfig;
1492
- };
1493
- type RegisterFunctionOutput<TConfig extends Record<string, string[]>> = {
1494
- secret?: string;
1495
- data?: SerializableJson;
1496
- config: TConfig;
1497
- };
1498
- type RegisterFunction<TIntegration extends TriggerIntegration, TParams extends any, TConfig extends Record<string, string[]>> = (event: RegisterFunctionEvent<TParams, TConfig>, io: IOWithIntegrations<{
1499
- integration: TIntegration;
1500
- }>, ctx: TriggerContext) => Promise<RegisterFunctionOutput<TConfig> | undefined>;
1501
- type WebhookHandlerEvent<TParams extends any = any> = {
1502
- rawEvent: Request;
1503
- source: Prettify<Omit<HandleTriggerSource, "params"> & {
1504
- params: TParams;
1505
- }>;
1506
- };
1507
- type WebhookDeliveryContext = {
1508
- key: string;
1509
- secret: string;
1510
- params: any;
1511
- };
1512
- type EventGenerator<TParams extends any, TConfig extends Record<string, string[]>, TIntegration extends TriggerIntegration> = (options: {
1513
- request: Request;
1514
- client: TriggerClient;
1515
- ctx: WebhookDeliveryContext;
1516
- }) => Promise<any>;
1517
- type KeyFunction<TParams extends any> = (params: TParams) => string;
1518
- type FilterFunction<TParams extends any, TConfig extends Record<string, string[]>> = (params: TParams, config?: TConfig) => EventFilter;
1519
- type WebhookOptions<TIntegration extends TriggerIntegration, TParams extends any, TConfig extends Record<string, string[]>> = {
1520
- id: string;
1521
- version: string;
1522
- integration: TIntegration;
1523
- schemas: {
1524
- params: SchemaParser<TParams>;
1525
- config?: SchemaParser<TConfig>;
1526
- };
1527
- key: KeyFunction<TParams>;
1528
- crud: WebhookCRUD<TIntegration, TParams, TConfig>;
1529
- filter?: FilterFunction<TParams, TConfig>;
1530
- register?: RegisterFunction<TIntegration, TParams, TConfig>;
1531
- verify?: (options: {
1532
- request: Request;
1533
- client: TriggerClient;
1534
- ctx: WebhookDeliveryContext;
1535
- }) => Promise<VerifyResult>;
1536
- generateEvents: EventGenerator<TParams, TConfig, TIntegration>;
1537
- properties?: (params: TParams) => DisplayProperty[];
1538
- };
1539
- declare class WebhookSource<TIntegration extends TriggerIntegration, TParams extends any = any, TConfig extends Record<string, string[]> = Record<string, string[]>> {
1540
- #private;
1541
- private options;
1542
- constructor(options: WebhookOptions<TIntegration, TParams, TConfig>);
1543
- generateEvents(request: Request, client: TriggerClient, ctx: WebhookDeliveryContext): Promise<any>;
1544
- filter(params: TParams, config?: TConfig): EventFilter;
1545
- properties(params: TParams): DisplayProperty[];
1546
- get crud(): WebhookCRUD<TIntegration, TParams, TConfig>;
1547
- register(params: TParams, registerEvent: WebhookRegisterEvent<TConfig>, io: IO, ctx: TriggerContext): Promise<RegisterFunctionOutput<TConfig> | undefined>;
1548
- verify(request: Request, client: TriggerClient, ctx: WebhookDeliveryContext): Promise<VerifyResult>;
1549
- key(params: TParams): string;
1550
- get integration(): TIntegration;
1551
- get integrationConfig(): {
1552
- id: string;
1553
- metadata: {
1554
- id: string;
1555
- name: string;
1556
- instructions?: string | undefined;
1557
- };
1558
- };
1559
- get id(): string;
1560
- get version(): string;
1561
- }
1562
- type GetWebhookParams<TWebhook extends WebhookSource<any, any, any>> = TWebhook extends WebhookSource<any, infer TParams, any> ? TParams : never;
1563
- type GetWebhookConfig<TWebhook extends WebhookSource<any, any, any>> = TWebhook extends WebhookSource<any, any, infer TConfig> ? TConfig : never;
1564
- type WebhookTriggerOptions<TEventSpecification extends EventSpecification<any>, TEventSource extends WebhookSource<any, any, any>, TConfig extends Record<string, string[]> = Record<string, string[]>> = {
1565
- event: TEventSpecification;
1566
- source: TEventSource;
1567
- params: GetWebhookParams<TEventSource>;
1568
- config: TConfig;
1569
- };
1570
- declare class WebhookTrigger<TEventSpecification extends EventSpecification<any>, TEventSource extends WebhookSource<any, any, any>> implements Trigger<TEventSpecification> {
1571
- private options;
1572
- constructor(options: WebhookTriggerOptions<TEventSpecification, TEventSource>);
1573
- get event(): TEventSpecification;
1574
- get source(): TEventSource;
1575
- get key(): string;
1576
- toJSON(): TriggerMetadata;
1577
- filter(eventFilter: EventFilter): WebhookTrigger<Omit<TEventSpecification, "filter"> & {
1578
- filter: EventFilter;
1579
- }, TEventSource>;
1580
- attachToJob(triggerClient: TriggerClient, job: Job<Trigger<TEventSpecification>, any>): void;
1581
- get preprocessRuns(): boolean;
1582
- verifyPayload(payload: ReturnType<TEventSpecification["parsePayload"]>): Promise<{
1583
- success: true;
1584
- }>;
1585
- }
1586
-
1587
- type TriggerClientOptions = {
1588
- /** The `id` property is used to uniquely identify the client.
1589
- */
1590
- id: string;
1591
- /** The `apiKey` property is the API Key for your Trigger.dev environment. We
1592
- recommend using an environment variable to store your API Key. */
1593
- apiKey?: string;
1594
- /** The `apiUrl` property is an optional property that specifies the API URL. You
1595
- only need to specify this if you are not using Trigger.dev Cloud and are
1596
- running your own Trigger.dev instance. */
1597
- apiUrl?: string;
1598
- /** The `logLevel` property is an optional property that specifies the level of
1599
- logging for the TriggerClient. The level is inherited by all Jobs that use this Client, unless they also specify a `logLevel`. */
1600
- logLevel?: LogLevel;
1601
- /** Very verbose log messages, defaults to false. */
1602
- verbose?: boolean;
1603
- /** Default is unset and off. If set to true it will log to the server's console as well as the Trigger.dev platform */
1604
- ioLogLocalEnabled?: boolean;
1605
- };
1606
- type AuthResolverResult = {
1607
- type: "apiKey" | "oauth";
1608
- token: string;
1609
- additionalFields?: Record<string, string>;
1610
- };
1611
- type TriggerAuthResolver = (ctx: TriggerContext, integration: TriggerIntegration) => Promise<AuthResolverResult | void | undefined>;
1612
- /** A [TriggerClient](https://trigger.dev/docs/documentation/concepts/client-adaptors) is used to connect to a specific [Project](https://trigger.dev/docs/documentation/concepts/projects) by using an [API Key](https://trigger.dev/docs/documentation/concepts/environments-apikeys). */
1613
- declare class TriggerClient {
1614
- #private;
1615
- id: string;
1616
- constructor(options: Prettify<TriggerClientOptions>);
1617
- on: <E extends keyof NotificationEvents>(event: E, listener: NotificationEvents[E]) => NotificationsEventEmitter;
1618
- handleRequest(request: Request, timeOrigin?: number): Promise<NormalizedResponse>;
1619
- defineJob<TTrigger extends Trigger<EventSpecification<any>>, TIntegrations extends Record<string, TriggerIntegration> = {}, TOutput extends any = any>(options: JobOptions<TTrigger, TIntegrations, TOutput>): Job<TTrigger, TIntegrations, TOutput>;
1620
- defineAuthResolver(integration: TriggerIntegration, resolver: TriggerAuthResolver): TriggerClient;
1621
- defineDynamicSchedule(options: DynamicIntervalOptions): DynamicSchedule;
1622
- defineDynamicTrigger<TEventSpec extends EventSpecification<any>, TExternalSource extends ExternalSource<any, any, any>>(options: DynamicTriggerOptions<TEventSpec, TExternalSource>): DynamicTrigger<TEventSpec, TExternalSource>;
1623
- /**
1624
- * An [HTTP endpoint](https://trigger.dev/docs/documentation/concepts/http-endpoints) allows you to create a [HTTP Trigger](https://trigger.dev/docs/documentation/concepts/triggers/http), which means you can trigger your Jobs from any webhooks.
1625
- * @param options The Endpoint options
1626
- * @returns An HTTP Endpoint, that can be used to create an HTTP Trigger.
1627
- * @link https://trigger.dev/docs/documentation/concepts/http-endpoints
1628
- */
1629
- defineHttpEndpoint(options: EndpointOptions, suppressWarnings?: boolean): HttpEndpoint<EventSpecification<Request, Request>>;
1630
- defineConcurrencyLimit(options: ConcurrencyLimitOptions): ConcurrencyLimit;
1631
- attach(job: Job<Trigger<any>, any>): void;
1632
- attachDynamicTrigger(trigger: DynamicTrigger<any, any>): void;
1633
- attachJobToDynamicTrigger(job: Job<Trigger<any>, any>, trigger: DynamicTrigger<any, any>): void;
1634
- attachSource(options: {
1635
- key: string;
1636
- source: ExternalSource<any, any>;
1637
- event: EventSpecification<any>;
1638
- params: any;
1639
- options?: Record<string, string[]>;
1640
- }): void;
1641
- attachDynamicSchedule(key: string): void;
1642
- attachDynamicScheduleToJob(key: string, job: Job<Trigger<any>, any>): void;
1643
- attachWebhook<TIntegration extends TriggerIntegration, TParams extends any, TConfig extends Record<string, string[]>>(options: {
1644
- key: string;
1645
- source: WebhookSource<TIntegration, TParams, TConfig>;
1646
- event: EventSpecification<any>;
1647
- params: any;
1648
- config: TConfig;
1649
- }): void;
1650
- registerTrigger(id: string, key: string, options: RegisterTriggerBodyV2, idempotencyKey?: string): Promise<{
1651
- id: string;
1652
- options: {
1653
- event: {
1654
- desired: string[];
1655
- missing: string[];
1656
- orphaned: string[];
1657
- };
1658
- } & Record<string, {
1659
- desired: string[];
1660
- missing: string[];
1661
- orphaned: string[];
1662
- }>;
1663
- source: {
1664
- key: string;
1665
- secret: string;
1666
- active: boolean;
1667
- channel: {
1668
- url: string;
1669
- type: "HTTP";
1670
- } | {
1671
- type: "SMTP";
1672
- } | {
1673
- type: "SQS";
1674
- };
1675
- params?: any;
1676
- data?: DeserializedJson | undefined;
1677
- clientId?: string | undefined;
1678
- };
1679
- dynamicTriggerId?: string | undefined;
1680
- }>;
1681
- getAuth(id: string): Promise<{
1682
- type: "oauth2" | "apiKey";
1683
- accessToken: string;
1684
- scopes?: string[] | undefined;
1685
- additionalFields?: Record<string, string> | undefined;
1686
- } | undefined>;
1687
- /** You can call this function from anywhere in your backend to send an event. The other way to send an event is by using [`io.sendEvent()`](https://trigger.dev/docs/sdk/io/sendevent) from inside a `run()` function.
1688
- * @param event The event to send.
1689
- * @param options Options for sending the event.
1690
- * @returns A promise that resolves to the event details
1691
- */
1692
- sendEvent(event: SendEvent, options?: SendEventOptions): Promise<{
1693
- id: string;
1694
- name: string;
1695
- payload: ((string | number | boolean | {
1696
- [key: string]: DeserializedJson;
1697
- } | DeserializedJson[]) & (string | number | boolean | {
1698
- [key: string]: DeserializedJson;
1699
- } | DeserializedJson[] | undefined)) | null;
1700
- timestamp: Date;
1701
- context?: DeserializedJson | undefined;
1702
- deliverAt?: Date | null | undefined;
1703
- deliveredAt?: Date | null | undefined;
1704
- cancelledAt?: Date | null | undefined;
1705
- }>;
1706
- /** You can call this function from anywhere in your backend to send multiple events. The other way to send multiple events is by using [`io.sendEvents()`](https://trigger.dev/docs/sdk/io/sendevents) from inside a `run()` function.
1707
- * @param events The events to send.
1708
- * @param options Options for sending the events.
1709
- * @returns A promise that resolves to an array of event details
1710
- */
1711
- sendEvents(events: SendEvent[], options?: SendEventOptions): Promise<{
1712
- id: string;
1713
- name: string;
1714
- payload: ((string | number | boolean | {
1715
- [key: string]: DeserializedJson;
1716
- } | DeserializedJson[]) & (string | number | boolean | {
1717
- [key: string]: DeserializedJson;
1718
- } | DeserializedJson[] | undefined)) | null;
1719
- timestamp: Date;
1720
- context?: DeserializedJson | undefined;
1721
- deliverAt?: Date | null | undefined;
1722
- deliveredAt?: Date | null | undefined;
1723
- cancelledAt?: Date | null | undefined;
1724
- }[]>;
1725
- cancelEvent(eventId: string): Promise<{
1726
- id: string;
1727
- name: string;
1728
- payload: ((string | number | boolean | {
1729
- [key: string]: DeserializedJson;
1730
- } | DeserializedJson[]) & (string | number | boolean | {
1731
- [key: string]: DeserializedJson;
1732
- } | DeserializedJson[] | undefined)) | null;
1733
- timestamp: Date;
1734
- context?: DeserializedJson | undefined;
1735
- deliverAt?: Date | null | undefined;
1736
- deliveredAt?: Date | null | undefined;
1737
- cancelledAt?: Date | null | undefined;
1738
- }>;
1739
- cancelRunsForEvent(eventId: string): Promise<{
1740
- cancelledRunIds: string[];
1741
- failedToCancelRunIds: string[];
1742
- }>;
1743
- updateStatus(runId: string, id: string, status: StatusUpdate): Promise<{
1744
- label: string;
1745
- key: string;
1746
- history: {
1747
- label?: string | undefined;
1748
- state?: "loading" | "success" | "failure" | undefined;
1749
- data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
1750
- }[];
1751
- data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
1752
- state?: "loading" | "success" | "failure" | undefined;
1753
- }>;
1754
- registerSchedule(id: string, key: string, schedule: ScheduleMetadata): Promise<{
1755
- id: string;
1756
- schedule: {
1757
- options: {
1758
- cron: string;
1759
- };
1760
- type: "cron";
1761
- accountId?: string | undefined;
1762
- metadata?: any;
1763
- } | {
1764
- options: {
1765
- seconds: number;
1766
- };
1767
- type: "interval";
1768
- accountId?: string | undefined;
1769
- metadata?: any;
1770
- };
1771
- active: boolean;
1772
- metadata?: any;
1773
- }>;
1774
- unregisterSchedule(id: string, key: string): Promise<{
1775
- ok: boolean;
1776
- }>;
1777
- getEvent(eventId: string): Promise<{
1778
- id: string;
1779
- name: string;
1780
- updatedAt: Date;
1781
- runs: {
1782
- id: string;
1783
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
1784
- startedAt?: Date | null | undefined;
1785
- completedAt?: Date | null | undefined;
1786
- }[];
1787
- createdAt: Date;
1788
- }>;
1789
- getRun(runId: string, options?: GetRunOptionsWithTaskDetails): Promise<{
1790
- id: string;
1791
- startedAt: Date | null;
1792
- completedAt: Date | null;
1793
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
1794
- updatedAt: Date | null;
1795
- tasks: _trigger_dev_core.RunTaskWithSubtasks[];
1796
- statuses: {
1797
- label: string;
1798
- key: string;
1799
- history: {
1800
- label?: string | undefined;
1801
- state?: "loading" | "success" | "failure" | undefined;
1802
- data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
1803
- }[];
1804
- data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
1805
- state?: "loading" | "success" | "failure" | undefined;
1806
- }[];
1807
- output?: any;
1808
- nextCursor?: string | undefined;
1809
- }>;
1810
- cancelRun(runId: string): Promise<{
1811
- id: string;
1812
- startedAt: Date | null;
1813
- completedAt: Date | null;
1814
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
1815
- updatedAt: Date | null;
1816
- tasks: _trigger_dev_core.RunTaskWithSubtasks[];
1817
- statuses: {
1818
- label: string;
1819
- key: string;
1820
- history: {
1821
- label?: string | undefined;
1822
- state?: "loading" | "success" | "failure" | undefined;
1823
- data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
1824
- }[];
1825
- data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
1826
- state?: "loading" | "success" | "failure" | undefined;
1827
- }[];
1828
- output?: any;
1829
- nextCursor?: string | undefined;
1830
- }>;
1831
- getRuns(jobSlug: string, options?: GetRunsOptions): Promise<{
1832
- runs: {
1833
- id: string;
1834
- startedAt: Date | null;
1835
- completedAt: Date | null;
1836
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
1837
- updatedAt: Date | null;
1838
- }[];
1839
- nextCursor?: string | undefined;
1840
- }>;
1841
- getRunStatuses(runId: string): Promise<{
1842
- statuses: {
1843
- label: string;
1844
- key: string;
1845
- history: {
1846
- label?: string | undefined;
1847
- state?: "loading" | "success" | "failure" | undefined;
1848
- data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
1849
- }[];
1850
- data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
1851
- state?: "loading" | "success" | "failure" | undefined;
1852
- }[];
1853
- run: {
1854
- id: string;
1855
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
1856
- output?: any;
1857
- };
1858
- }>;
1859
- invokeJob(jobId: string, payload: any, options?: InvokeOptions): Promise<{
1860
- id: string;
1861
- }>;
1862
- cancelRunsForJob(jobId: string): Promise<{
1863
- cancelledRunIds: string[];
1864
- failedToCancelRunIds: string[];
1865
- }>;
1866
- createEphemeralEventDispatcher(payload: EphemeralEventDispatcherRequestBody): Promise<{
1867
- id: string;
1868
- }>;
1869
- get store(): {
1870
- env: KeyValueStore;
1871
- };
1872
- authorized(apiKey?: string | null): "authorized" | "unauthorized" | "missing-client" | "missing-header";
1873
- apiKey(): string | undefined;
1874
- }
1875
-
1876
- type IOTask = ServerTask;
1877
- type IOOptions = {
1878
- id: string;
1879
- jobId: string;
1880
- apiClient: ApiClient;
1881
- client: TriggerClient;
1882
- context: TriggerContext;
1883
- timeOrigin: number;
1884
- logger?: Logger;
1885
- logLevel?: LogLevel;
1886
- jobLogger?: Logger;
1887
- jobLogLevel: LogLevel;
1888
- cachedTasks?: Array<CachedTask>;
1889
- cachedTasksCursor?: string;
1890
- yieldedExecutions?: Array<string>;
1891
- noopTasksSet?: string;
1892
- serverVersion?: string | null;
1893
- executionTimeout?: number;
1894
- };
1895
- type JsonPrimitive = string | number | boolean | null | undefined | Date | symbol;
1896
- type JsonArray = Json[];
1897
- type JsonRecord<T> = {
1898
- [Property in keyof T]: Json;
1899
- };
1900
- type Json<T = any> = JsonPrimitive | JsonArray | JsonRecord<T>;
1901
- type RunTaskErrorCallback = (error: unknown, task: IOTask, io: IO) => {
1902
- retryAt?: Date;
1903
- error?: Error;
1904
- jitter?: number;
1905
- skipRetrying?: boolean;
1906
- } | Error | undefined | void;
1907
- type IOStats = {
1908
- initialCachedTasks: number;
1909
- lazyLoadedCachedTasks: number;
1910
- executedTasks: number;
1911
- cachedTaskHits: number;
1912
- cachedTaskMisses: number;
1913
- noopCachedTaskHits: number;
1914
- noopCachedTaskMisses: number;
1915
- };
1916
- interface OutputSerializer {
1917
- serialize(value: any): string;
1918
- deserialize<T>(value: string): T;
1919
- }
1920
- declare class JSONOutputSerializer implements OutputSerializer {
1921
- serialize(value: any): string;
1922
- deserialize(value?: string): any;
1923
- }
1924
- type BackgroundFetchResponse<T> = {
1925
- status: number;
1926
- data: T;
1927
- headers: Record<string, string>;
1928
- };
1929
- declare class IO {
1930
- #private;
1931
- private _id;
1932
- private _jobId;
1933
- private _apiClient;
1934
- private _triggerClient;
1935
- private _logger;
1936
- private _jobLogger?;
1937
- private _jobLogLevel;
1938
- private _cachedTasks;
1939
- private _taskStorage;
1940
- private _cachedTasksCursor?;
1941
- private _context;
1942
- private _yieldedExecutions;
1943
- private _noopTasksBloomFilter;
1944
- private _stats;
1945
- private _serverVersion;
1946
- private _timeOrigin;
1947
- private _executionTimeout?;
1948
- private _outputSerializer;
1949
- private _visitedCacheKeys;
1950
- private _envStore;
1951
- private _jobStore;
1952
- private _runStore;
1953
- get stats(): IOStats;
1954
- constructor(options: IOOptions);
1955
- /** Used to send log messages to the [Run log](https://trigger.dev/docs/documentation/guides/viewing-runs). */
1956
- get logger(): IOLogger;
1957
- /** `io.random()` is identical to `Math.random()` when called without options but ensures your random numbers are not regenerated on resume or retry. It will return a pseudo-random floating-point number between optional `min` (default: 0, inclusive) and `max` (default: 1, exclusive). Can optionally `round` to the nearest integer.
1958
- * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
1959
- * @param min Sets the lower bound (inclusive). Can't be higher than `max`.
1960
- * @param max Sets the upper bound (exclusive). Can't be lower than `min`.
1961
- * @param round Controls rounding to the nearest integer. Any `max` integer will become inclusive when enabled. Rounding with floating-point bounds may cause unexpected skew and boundary inclusivity.
1962
- */
1963
- random(cacheKey: string | any[], { min, max, round, }?: {
1964
- min?: number;
1965
- max?: number;
1966
- round?: boolean;
1967
- }): Promise<number>;
1968
- /** `io.wait()` waits for the specified amount of time before continuing the Job. Delays work even if you're on a serverless platform with timeouts, or if your server goes down. They utilize [resumability](https://trigger.dev/docs/documentation/concepts/resumability) to ensure that the Run can be resumed after the delay.
1969
- * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
1970
- * @param seconds The number of seconds to wait. This can be very long, serverless timeouts are not an issue.
1971
- */
1972
- wait(cacheKey: string | any[], seconds: number): Promise<void>;
1973
- waitForEvent<T extends z.ZodTypeAny = z.ZodTypeAny>(cacheKey: string | any[], event: {
1974
- name: string;
1975
- schema?: T;
1976
- filter?: EventFilter;
1977
- source?: string;
1978
- contextFilter?: EventFilter;
1979
- accountId?: string;
1980
- }, options?: {
1981
- timeoutInSeconds?: number;
1982
- }): Promise<WaitForEventResult<z.output<T>>>;
1983
- /** `io.waitForRequest()` allows you to pause the execution of a run until the url provided in the callback is POSTed to.
1984
- * This is useful for integrating with external services that require a callback URL to be provided, or if you want to be able to wait until an action is performed somewhere else in your system.
1985
- * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
1986
- * @param callback A callback function that will provide the unique URL to POST to.
1987
- * @param options Options for the callback.
1988
- * @param options.timeoutInSeconds How long to wait for the request to be POSTed to the callback URL before timing out. Defaults to 1hr.
1989
- * @returns The POSTed request JSON body.
1990
- * @example
1991
- * ```ts
1992
- const result = await io.waitForRequest<{ message: string }>(
1993
- "wait-for-request",
1994
- async (url, task) => {
1995
- // Save the URL somewhere so you can POST to it later
1996
- // Or send it to an external service that will POST to it
1997
- },
1998
- { timeoutInSeconds: 60 } // wait 60 seconds
1999
- );
2000
- * ```
2001
- */
2002
- waitForRequest<T extends Json<T> | unknown = unknown>(cacheKey: string | any[], callback: (url: string) => Promise<unknown>, options?: {
2003
- timeoutInSeconds?: number;
2004
- }): Promise<T>;
2005
- /** `io.createStatus()` allows you to set a status with associated data during the Run. Statuses can be used by your UI using the react package
2006
- * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
2007
- * @param initialStatus The initial status you want this status to have. You can update it during the rub using the returned object.
2008
- * @returns a TriggerStatus object that you can call `update()` on, to update the status.
2009
- * @example
2010
- * ```ts
2011
- * client.defineJob(
2012
- //...
2013
- run: async (payload, io, ctx) => {
2014
- const generatingImages = await io.createStatus("generating-images", {
2015
- label: "Generating Images",
2016
- state: "loading",
2017
- data: {
2018
- progress: 0.1,
2019
- },
2020
- });
2021
-
2022
- //...do stuff
2023
-
2024
- await generatingImages.update("completed-generation", {
2025
- label: "Generated images",
2026
- state: "success",
2027
- data: {
2028
- progress: 1.0,
2029
- urls: ["http://..."]
2030
- },
2031
- });
2032
-
2033
- //...
2034
- });
2035
- * ```
2036
- */
2037
- createStatus(cacheKey: IntegrationTaskKey, initialStatus: InitialStatusUpdate): Promise<TriggerStatus>;
2038
- /** `io.backgroundFetch()` fetches data from a URL that can take longer that the serverless timeout. The actual `fetch` request is performed on the Trigger.dev platform, and the response is sent back to you.
2039
- * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
2040
- * @param url The URL to fetch from.
2041
- * @param requestInit The options for the request
2042
- * @param retry The options for retrying the request if it fails
2043
- * An object where the key is a status code pattern and the value is a retrying strategy.
2044
- * Supported patterns are:
2045
- * - Specific status codes: 429
2046
- * - Ranges: 500-599
2047
- * - Wildcards: 2xx, 3xx, 4xx, 5xx
2048
- */
2049
- backgroundFetch<TResponseData>(cacheKey: string | any[], url: string, requestInit?: FetchRequestInit, options?: {
2050
- retry?: FetchRetryOptions;
2051
- timeout?: FetchTimeoutOptions;
2052
- }): Promise<TResponseData>;
2053
- /** `io.backgroundPoll()` will fetch data from a URL on an interval. The actual `fetch` requests are performed on the Trigger.dev server, so you don't have to worry about serverless function timeouts.
2054
- * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
2055
- * @param params The options for the background poll
2056
- * @param params.url The URL to fetch from.
2057
- * @param params.requestInit The options for the request, like headers and method
2058
- * @param params.responseFilter An [EventFilter](https://trigger.dev/docs/documentation/guides/event-filter) that allows you to specify when to stop polling.
2059
- * @param params.interval The interval in seconds to poll the URL in seconds. Defaults to 10 seconds which is the minimum.
2060
- * @param params.timeout The timeout in seconds for each request in seconds. Defaults to 10 minutes. Minimum is 60 seconds and max is 1 hour
2061
- * @param params.requestTimeout An optional object that allows you to timeout individual fetch requests
2062
- * @param params.requestTimeout An optional object that allows you to timeout individual fetch requests
2063
- * @param params.requestTimeout.durationInMs The duration in milliseconds to timeout the request
2064
- *
2065
- * @example
2066
- * ```ts
2067
- * const result = await io.backgroundPoll<{ id: string; status: string; }>("poll", {
2068
- url: `http://localhost:3030/api/v1/runs/${run.id}`,
2069
- requestInit: {
2070
- headers: {
2071
- Accept: "application/json",
2072
- Authorization: redactString`Bearer ${process.env["TRIGGER_API_KEY"]!}`,
2073
- },
2074
- },
2075
- interval: 10,
2076
- timeout: 600,
2077
- responseFilter: {
2078
- status: [200],
2079
- body: {
2080
- status: ["SUCCESS"],
2081
- },
2082
- },
2083
- });
2084
- * ```
2085
- */
2086
- backgroundPoll<TResponseData>(cacheKey: string | any[], params: FetchPollOperation): Promise<TResponseData>;
2087
- /** `io.backgroundFetchResponse()` fetches data from a URL that can take longer that the serverless timeout. The actual `fetch` request is performed on the Trigger.dev platform, and the response is sent back to you.
2088
- * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
2089
- * @param url The URL to fetch from.
2090
- * @param requestInit The options for the request
2091
- * @param retry The options for retrying the request if it fails
2092
- * An object where the key is a status code pattern and the value is a retrying strategy.
2093
- * Supported patterns are:
2094
- * - Specific status codes: 429
2095
- * - Ranges: 500-599
2096
- * - Wildcards: 2xx, 3xx, 4xx, 5xx
2097
- */
2098
- backgroundFetchResponse<TResponseData>(cacheKey: string | any[], url: string, requestInit?: FetchRequestInit, options?: {
2099
- retry?: FetchRetryOptions;
2100
- timeout?: FetchTimeoutOptions;
2101
- }): Promise<BackgroundFetchResponse<TResponseData>>;
2102
- /** `io.sendEvent()` allows you to send an event from inside a Job run. The sent event will trigger any Jobs that are listening for that event (based on the name).
2103
- * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
2104
- * @param event The event to send. The event name must match the name of the event that your Jobs are listening for.
2105
- * @param options Options for sending the event.
2106
- */
2107
- sendEvent(cacheKey: string | any[], event: SendEvent, options?: SendEventOptions): Promise<{
2108
- id: string;
2109
- name: string;
2110
- payload: ((string | number | boolean | {
2111
- [key: string]: _trigger_dev_core.DeserializedJson;
2112
- } | _trigger_dev_core.DeserializedJson[]) & (string | number | boolean | {
2113
- [key: string]: _trigger_dev_core.DeserializedJson;
2114
- } | _trigger_dev_core.DeserializedJson[] | undefined)) | null;
2115
- timestamp: Date;
2116
- context?: _trigger_dev_core.DeserializedJson | undefined;
2117
- deliverAt?: Date | null | undefined;
2118
- deliveredAt?: Date | null | undefined;
2119
- cancelledAt?: Date | null | undefined;
2120
- }>;
2121
- /** `io.sendEvents()` allows you to send multiple events from inside a Job run. The sent events will trigger any Jobs that are listening for those events (based on the name).
2122
- * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
2123
- * @param event The events to send. The event names must match the names of the events that your Jobs are listening for.
2124
- * @param options Options for sending the events.
2125
- */
2126
- sendEvents(cacheKey: string | any[], events: SendEvent[], options?: SendEventOptions): Promise<{
2127
- id: string;
2128
- name: string;
2129
- payload: ((string | number | boolean | {
2130
- [key: string]: _trigger_dev_core.DeserializedJson;
2131
- } | _trigger_dev_core.DeserializedJson[]) & (string | number | boolean | {
2132
- [key: string]: _trigger_dev_core.DeserializedJson;
2133
- } | _trigger_dev_core.DeserializedJson[] | undefined)) | null;
2134
- timestamp: Date;
2135
- context?: _trigger_dev_core.DeserializedJson | undefined;
2136
- deliverAt?: Date | null | undefined;
2137
- deliveredAt?: Date | null | undefined;
2138
- cancelledAt?: Date | null | undefined;
2139
- }[]>;
2140
- getEvent(cacheKey: string | any[], id: string): Promise<{
2141
- id: string;
2142
- name: string;
2143
- updatedAt: Date;
2144
- runs: {
2145
- id: string;
2146
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
2147
- startedAt?: Date | null | undefined;
2148
- completedAt?: Date | null | undefined;
2149
- }[];
2150
- createdAt: Date;
2151
- }>;
2152
- /** `io.cancelEvent()` allows you to cancel an event that was previously sent with `io.sendEvent()`. This will prevent any Jobs from running that are listening for that event if the event was sent with a delay
2153
- * @param cacheKey
2154
- * @param eventId
2155
- * @returns
2156
- */
2157
- cancelEvent(cacheKey: string | any[], eventId: string): Promise<{
2158
- id: string;
2159
- name: string;
2160
- payload: ((string | number | boolean | {
2161
- [key: string]: _trigger_dev_core.DeserializedJson;
2162
- } | _trigger_dev_core.DeserializedJson[]) & (string | number | boolean | {
2163
- [key: string]: _trigger_dev_core.DeserializedJson;
2164
- } | _trigger_dev_core.DeserializedJson[] | undefined)) | null;
2165
- timestamp: Date;
2166
- context?: _trigger_dev_core.DeserializedJson | undefined;
2167
- deliverAt?: Date | null | undefined;
2168
- deliveredAt?: Date | null | undefined;
2169
- cancelledAt?: Date | null | undefined;
2170
- }>;
2171
- updateSource(cacheKey: string | any[], options: {
2172
- key: string;
2173
- } & UpdateTriggerSourceBodyV2): Promise<{
2174
- id: string;
2175
- key: string;
2176
- }>;
2177
- updateWebhook(cacheKey: string | any[], options: {
2178
- key: string;
2179
- } & UpdateWebhookBody): Promise<{
2180
- id: string;
2181
- key: string;
2182
- }>;
2183
- /** `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.
2184
- * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
2185
- * @param dynamicSchedule The [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) to register a new schedule on.
2186
- * @param id A unique id for the interval. This is used to identify and unregister the interval later.
2187
- * @param options The options for the interval.
2188
- * @returns A promise that has information about the interval.
2189
- * @deprecated Use `DynamicSchedule.register` instead.
2190
- */
2191
- registerInterval(cacheKey: string | any[], dynamicSchedule: DynamicSchedule, id: string, options: IntervalOptions): Promise<{
2192
- id: string;
2193
- schedule: {
2194
- options: {
2195
- cron: string;
2196
- };
2197
- type: "cron";
2198
- accountId?: string | undefined;
2199
- metadata?: any;
2200
- } | {
2201
- options: {
2202
- seconds: number;
2203
- };
2204
- type: "interval";
2205
- accountId?: string | undefined;
2206
- metadata?: any;
2207
- };
2208
- active: boolean;
2209
- metadata?: any;
2210
- }>;
2211
- /** `io.unregisterInterval()` allows you to unregister a [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) that was previously registered with `io.registerInterval()`.
2212
- * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
2213
- * @param dynamicSchedule The [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) to unregister a schedule on.
2214
- * @param id A unique id for the interval. This is used to identify and unregister the interval later.
2215
- * @deprecated Use `DynamicSchedule.unregister` instead.
2216
- */
2217
- unregisterInterval(cacheKey: string | any[], dynamicSchedule: DynamicSchedule, id: string): Promise<{
2218
- ok: boolean;
2219
- }>;
2220
- /** `io.registerCron()` allows you to register a [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) that will trigger any jobs it's attached to on a regular CRON schedule.
2221
- * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
2222
- * @param dynamicSchedule The [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) to register a new schedule on.
2223
- * @param id A unique id for the schedule. This is used to identify and unregister the schedule later.
2224
- * @param options The options for the CRON schedule.
2225
- * @deprecated Use `DynamicSchedule.register` instead.
2226
- */
2227
- registerCron(cacheKey: string | any[], dynamicSchedule: DynamicSchedule, id: string, options: CronOptions): Promise<{
2228
- id: string;
2229
- schedule: {
2230
- options: {
2231
- cron: string;
2232
- };
2233
- type: "cron";
2234
- accountId?: string | undefined;
2235
- metadata?: any;
2236
- } | {
2237
- options: {
2238
- seconds: number;
2239
- };
2240
- type: "interval";
2241
- accountId?: string | undefined;
2242
- metadata?: any;
2243
- };
2244
- active: boolean;
2245
- metadata?: any;
2246
- }>;
2247
- /** `io.unregisterCron()` allows you to unregister a [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) that was previously registered with `io.registerCron()`.
2248
- * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
2249
- * @param dynamicSchedule The [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) to unregister a schedule on.
2250
- * @param id A unique id for the interval. This is used to identify and unregister the interval later.
2251
- * @deprecated Use `DynamicSchedule.unregister` instead.
2252
- */
2253
- unregisterCron(cacheKey: string | any[], dynamicSchedule: DynamicSchedule, id: string): Promise<{
2254
- ok: boolean;
2255
- }>;
2256
- /** `io.registerTrigger()` allows you to register a [DynamicTrigger](https://trigger.dev/docs/sdk/dynamictrigger) with the specified trigger params.
2257
- * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
2258
- * @param trigger The [DynamicTrigger](https://trigger.dev/docs/sdk/dynamictrigger) to register.
2259
- * @param id A unique id for the trigger. This is used to identify and unregister the trigger later.
2260
- * @param params The params for the trigger.
2261
- * @deprecated Use `DynamicTrigger.register` instead.
2262
- */
2263
- registerTrigger<TTrigger extends DynamicTrigger<EventSpecification<any>, ExternalSource<any, any, any>>>(cacheKey: string | any[], trigger: TTrigger, id: string, params: ExternalSourceParams<TTrigger["source"]>): Promise<{
2264
- id: string;
2265
- key: string;
2266
- } | undefined>;
2267
- getAuth(cacheKey: string | any[], clientId?: string): Promise<ConnectionAuth | undefined>;
2268
- parallel<T extends Json<T> | void, TItem>(cacheKey: string | any[], items: Array<TItem>, callback: (item: TItem, index: number) => Promise<T>, options?: Pick<RunTaskOptions, "name" | "properties">): Promise<Array<T>>;
2269
- /** `io.runTask()` allows you to run a [Task](https://trigger.dev/docs/documentation/concepts/tasks) from inside a Job run. A Task is a resumable unit of a Run that can be retried, resumed and is logged. [Integrations](https://trigger.dev/docs/integrations) use Tasks internally to perform their actions.
2270
- *
2271
- * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
2272
- * @param callback The callback that will be called when the Task is run. The callback receives the Task and the IO as parameters.
2273
- * @param options The options of how you'd like to run and log the Task.
2274
- * @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.
2275
- * @returns A Promise that resolves with the returned value of the callback.
2276
- */
2277
- runTask<T extends Json<T> | void>(cacheKey: string | any[], callback: (task: ServerTask, io: IO) => Promise<T>, options?: RunTaskOptions & {
2278
- parseOutput?: (output: unknown) => T;
2279
- }, onError?: RunTaskErrorCallback): Promise<T>;
2280
- /**
2281
- * `io.yield()` allows you to yield execution of the current run and resume it in a new function execution. Similar to `io.wait()` but does not create a task and resumes execution immediately.
2282
- */
2283
- yield(cacheKey: string): void;
2284
- /**
2285
- * `io.brb()` is an alias of `io.yield()`
2286
- */
2287
- brb: (cacheKey: string) => void;
2288
- /** `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()](https://trigger.dev/docs/sdk/io/runtask).
2289
- * 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.
2290
- * @param tryCallback The code you wish to run
2291
- * @param catchCallback Thhis will be called if the Task fails. The callback receives the error
2292
- * @returns A Promise that resolves with the returned value or the error
2293
- */
2294
- try<TResult, TCatchResult>(tryCallback: () => Promise<TResult>, catchCallback: (error: unknown) => Promise<TCatchResult>): Promise<TResult | TCatchResult>;
2295
- get store(): {
2296
- env: KeyValueStore;
2297
- job: KeyValueStore;
2298
- run: KeyValueStore;
2299
- };
2300
- }
2301
- type CallbackFunction = (level: "DEBUG" | "INFO" | "WARN" | "ERROR" | "LOG", message: string, properties?: Record<string, any>) => Promise<void>;
2302
- declare class IOLogger implements TaskLogger {
2303
- private callback;
2304
- constructor(callback: CallbackFunction);
2305
- /** Log: essential messages */
2306
- log(message: string, properties?: Record<string, any>): Promise<void>;
2307
- /** For debugging: the least important log level */
2308
- debug(message: string, properties?: Record<string, any>): Promise<void>;
2309
- /** Info: the second least important log level */
2310
- info(message: string, properties?: Record<string, any>): Promise<void>;
2311
- /** Warnings: the third most important log level */
2312
- warn(message: string, properties?: Record<string, any>): Promise<void>;
2313
- /** Error: The second most important log level */
2314
- error(message: string, properties?: Record<string, any>): Promise<void>;
2315
- }
2316
-
2317
- interface TriggerIntegration {
2318
- id: string;
2319
- metadata: IntegrationMetadata;
2320
- authSource: "LOCAL" | "HOSTED";
2321
- cloneForRun: (io: IO, connectionKey: string, auth?: ConnectionAuth) => TriggerIntegration;
2322
- }
2323
- type IOWithIntegrations<TIntegrations extends Record<string, TriggerIntegration>> = IO & TIntegrations;
2324
- type IntegrationTaskKey = string | any[];
2325
-
2326
- type JobOptions<TTrigger extends Trigger<EventSpecification<any>>, TIntegrations extends Record<string, TriggerIntegration> = {}, TOutput extends any = any> = {
2327
- /** The `id` property is used to uniquely identify the Job. Only change this if you want to create a new Job. */
2328
- id: string;
2329
- /** The `name` of the Job that you want to appear in the dashboard and logs. You can change this without creating a new Job. */
2330
- name: string;
2331
- /** The `version` property is used to version your Job. A new version will be created if you change this property. We recommend using [semantic versioning](https://www.baeldung.com/cs/semantic-versioning), e.g. `1.0.3`. */
2332
- version: string;
2333
- /** The `trigger` property is used to define when the Job should run. There are currently the following Trigger types:
2334
- - [cronTrigger](https://trigger.dev/docs/sdk/crontrigger)
2335
- - [intervalTrigger](https://trigger.dev/docs/sdk/intervaltrigger)
2336
- - [eventTrigger](https://trigger.dev/docs/sdk/eventtrigger)
2337
- - [DynamicTrigger](https://trigger.dev/docs/sdk/dynamictrigger)
2338
- - [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule)
2339
- - integration Triggers, like webhooks. See the [integrations](https://trigger.dev/docs/integrations) page for more information. */
2340
- trigger: TTrigger;
2341
- /** The `logLevel` property is an optional property that specifies the level of
2342
- logging for the Job. The level is inherited from the client if you omit this property. */
2343
- logLevel?: LogLevel;
2344
- /** Imports the specified integrations into the Job. The integrations will be available on the `io` object in the `run()` function with the same name as the key. For example:
2345
- ```ts
2346
- client.defineJob({
2347
- //... other options
2348
- integrations: {
2349
- slack,
2350
- gh: github,
2351
- },
2352
- run: async (payload, io, ctx) => {
2353
- //slack is available on io.slack
2354
- io.slack.postMessage(...);
2355
- //github is available on io.gh
2356
- io.gh.addIssueLabels(...);
2357
- }
2358
- });
2359
- ``` */
2360
- integrations?: TIntegrations;
2361
- /**
2362
- * The `concurrencyLimit` property is used to limit the number of concurrent run executions of a job.
2363
- * Can be a number which represents the limit or a `ConcurrencyLimit` instance which can be used to
2364
- * group together multiple jobs to share the same concurrency limit.
2365
- *
2366
- * If undefined the job will be limited only by the server's global concurrency limit, or if you are using the
2367
- * Trigger.dev Cloud service, the concurrency limit of your plan.
2368
- */
2369
- concurrencyLimit?: number | ConcurrencyLimit;
2370
- /** The `enabled` property is used to enable or disable the Job. If you disable a Job, it will not run. */
2371
- enabled?: boolean;
2372
- /** This function gets called automatically when a Run is Triggered.
2373
- * This is where you put the code you want to run for a Job. You can use normal code in here and you can also use Tasks. You can return a value from this function and it will be sent back to the Trigger API.
2374
- * @param payload The payload of the event
2375
- * @param io An object that contains the integrations that you specified in the `integrations` property and other useful functions like delays and running Tasks.
2376
- * @param context An object that contains information about the Organization, Job, Run and more.
2377
- */
2378
- run: (payload: TriggerEventType<TTrigger>, io: IOWithIntegrations<TIntegrations>, context: TriggerContext) => Promise<TOutput>;
2379
- onSuccess?: (notification: SuccessfulRunNotification<TOutput, TriggerEventType<TTrigger>>) => void;
2380
- onFailure?: (notification: FailedRunNotification<TriggerEventType<TTrigger>>) => void;
2381
- };
2382
- type JobPayload<TJob> = TJob extends Job<Trigger<EventSpecification<infer TEvent>>, any> ? TEvent : never;
2383
- type JobIO<TJob> = TJob extends Job<any, infer TIntegrations> ? IOWithIntegrations<TIntegrations> : never;
2384
- /** 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. */
2385
- declare class Job<TTrigger extends Trigger<EventSpecification<any>>, TIntegrations extends Record<string, TriggerIntegration> = {}, TOutput extends any = any> {
2386
- #private;
2387
- readonly options: JobOptions<TTrigger, TIntegrations, TOutput>;
2388
- client?: TriggerClient;
2389
- constructor(options: JobOptions<TTrigger, TIntegrations, TOutput>);
2390
- /**
2391
- * Attaches the job to a client. This is called automatically when you define a job using `client.defineJob()`.
2392
- */
2393
- attachToClient(client: TriggerClient): this;
2394
- get id(): string;
2395
- get enabled(): boolean;
2396
- get name(): string;
2397
- get trigger(): TTrigger;
2398
- get version(): string;
2399
- get logLevel(): LogLevel | undefined;
2400
- get integrations(): Record<string, IntegrationConfig>;
2401
- toJSON(): JobMetadata;
2402
- invoke(cacheKey: string, payload: TriggerInvokeType<TTrigger>, options?: InvokeOptions): Promise<{
2403
- id: string;
2404
- }>;
2405
- invoke(payload: TriggerInvokeType<TTrigger>, options?: InvokeOptions): Promise<{
2406
- id: string;
2407
- }>;
2408
- invokeAndWaitForCompletion(cacheKey: string | string[], payload: TriggerInvokeType<TTrigger>, timeoutInSeconds?: number, // 1 hour
2409
- options?: Prettify<Pick<InvokeOptions, "accountId" | "context">>): Promise<RunNotification<TOutput>>;
2410
- batchInvokeAndWaitForCompletion(cacheKey: string | string[], batch: Array<{
2411
- payload: TriggerInvokeType<TTrigger>;
2412
- timeoutInSeconds?: number;
2413
- options?: Prettify<Pick<InvokeOptions, "accountId" | "context">>;
2414
- }>): Promise<Array<RunNotification<TOutput>>>;
2415
- }
2416
-
2417
- type EventTriggerOptions<TEventSpecification extends EventSpecification<any>> = {
2418
- event: TEventSpecification;
2419
- name?: string | string[];
2420
- source?: string;
2421
- filter?: EventFilter;
2422
- verify?: EventTypeFromSpecification<TEventSpecification> extends Request ? VerifyCallback : never;
2423
- };
2424
- declare class EventTrigger<TEventSpecification extends EventSpecification<any>> implements Trigger<TEventSpecification> {
2425
- #private;
2426
- constructor(options: EventTriggerOptions<TEventSpecification>);
2427
- toJSON(): TriggerMetadata;
2428
- get event(): TEventSpecification;
2429
- attachToJob(triggerClient: TriggerClient, job: Job<Trigger<TEventSpecification>, any>): void;
2430
- get preprocessRuns(): boolean;
2431
- verifyPayload(payload: ReturnType<TEventSpecification["parsePayload"]>): Promise<VerifyResult>;
2432
- }
2433
- /** Configuration options for an EventTrigger */
2434
- type TriggerOptions<TEvent> = {
2435
- /** The name of the event you are subscribing to. Must be an exact match (case sensitive). To trigger on multiple possible events, pass in an array of event names */
2436
- name: string | string[];
2437
- /** A [Zod](https://trigger.dev/docs/documentation/guides/zod) schema that defines the shape of the event payload.
2438
- * The default is `z.any()` which is `any`.
2439
- * */
2440
- schema?: SchemaParser<TEvent>;
2441
- /** You can use this to filter events based on the source. */
2442
- source?: string;
2443
- /** Used to filter which events trigger the Job
2444
- * @example
2445
- * filter:
2446
- * ```ts
2447
- * {
2448
- * name: ["John", "Jane"],
2449
- * age: [18, 21]
2450
- * }
2451
- * ```
2452
- *
2453
- * This filter would match against an event with the following data:
2454
- * ```json
2455
- * {
2456
- * "name": "Jane",
2457
- * "age": 18,
2458
- * "location": "San Francisco"
2459
- * }
2460
- * ```
2461
- */
2462
- filter?: EventFilter;
2463
- examples?: EventSpecificationExample[];
2464
- };
2465
- /** `eventTrigger()` is set as a [Job's trigger](https://trigger.dev/docs/sdk/job) to subscribe to an event a Job from [a sent event](https://trigger.dev/docs/sdk/triggerclient/instancemethods/sendevent)
2466
- * @param options options for the EventTrigger
2467
- */
2468
- declare function eventTrigger<TEvent extends any = any>(options: TriggerOptions<TEvent>): Trigger<EventSpecification<TEvent>>;
2469
-
2470
- declare function missingConnectionNotification(integrations: Array<TriggerIntegration>): MissingConnectionNotification;
2471
- declare function missingConnectionResolvedNotification(integrations: Array<TriggerIntegration>): MissingConnectionResolvedNotification;
2472
- type MissingConnectionNotificationSpecification = EventSpecification<MissingConnectionNotificationPayload>;
2473
- type MissingConnectionNotificationOptions = {
2474
- integrations: Array<TriggerIntegration>;
2475
- };
2476
- declare class MissingConnectionNotification implements Trigger<MissingConnectionNotificationSpecification> {
2477
- private options;
2478
- constructor(options: MissingConnectionNotificationOptions);
2479
- get event(): {
2480
- name: string;
2481
- title: string;
2482
- source: string;
2483
- icon: string;
2484
- parsePayload: (data: unknown, params?: Partial<zod.ParseParams> | undefined) => {
2485
- id: string;
2486
- type: "DEVELOPER";
2487
- client: {
2488
- id: string;
2489
- scopes: string[];
2490
- title: string;
2491
- updatedAt: Date;
2492
- createdAt: Date;
2493
- };
2494
- authorizationUrl: string;
2495
- } | {
2496
- id: string;
2497
- type: "EXTERNAL";
2498
- account: {
2499
- id: string;
2500
- metadata?: any;
2501
- };
2502
- client: {
2503
- id: string;
2504
- scopes: string[];
2505
- title: string;
2506
- updatedAt: Date;
2507
- createdAt: Date;
2508
- };
2509
- authorizationUrl: string;
2510
- };
2511
- properties: {
2512
- label: string;
2513
- text: string;
2514
- }[];
2515
- };
2516
- attachToJob(triggerClient: TriggerClient, job: Job<Trigger<MissingConnectionNotificationSpecification>, any>): void;
2517
- get preprocessRuns(): boolean;
2518
- verifyPayload(payload: ReturnType<MissingConnectionNotificationSpecification["parsePayload"]>): Promise<{
2519
- success: true;
2520
- }>;
2521
- toJSON(): TriggerMetadata;
2522
- }
2523
- type MissingConnectionResolvedNotificationSpecification = EventSpecification<MissingConnectionResolvedNotificationPayload>;
2524
- declare class MissingConnectionResolvedNotification implements Trigger<MissingConnectionResolvedNotificationSpecification> {
2525
- private options;
2526
- constructor(options: MissingConnectionNotificationOptions);
2527
- get event(): {
2528
- name: string;
2529
- title: string;
2530
- source: string;
2531
- icon: string;
2532
- parsePayload: (data: unknown, params?: Partial<zod.ParseParams> | undefined) => {
2533
- id: string;
2534
- type: "DEVELOPER";
2535
- client: {
2536
- id: string;
2537
- scopes: string[];
2538
- title: string;
2539
- updatedAt: Date;
2540
- createdAt: Date;
2541
- integrationIdentifier: string;
2542
- integrationAuthMethod: string;
2543
- };
2544
- expiresAt: Date;
2545
- } | {
2546
- id: string;
2547
- type: "EXTERNAL";
2548
- account: {
2549
- id: string;
2550
- metadata?: any;
2551
- };
2552
- client: {
2553
- id: string;
2554
- scopes: string[];
2555
- title: string;
2556
- updatedAt: Date;
2557
- createdAt: Date;
2558
- integrationIdentifier: string;
2559
- integrationAuthMethod: string;
2560
- };
2561
- expiresAt: Date;
2562
- };
2563
- properties: {
2564
- label: string;
2565
- text: string;
2566
- }[];
2567
- };
2568
- attachToJob(triggerClient: TriggerClient, job: Job<Trigger<MissingConnectionResolvedNotificationSpecification>, any>): void;
2569
- get preprocessRuns(): boolean;
2570
- verifyPayload(payload: ReturnType<MissingConnectionResolvedNotificationSpecification["parsePayload"]>): Promise<{
2571
- success: true;
2572
- }>;
2573
- toJSON(): TriggerMetadata;
2574
- }
2575
-
2576
- /** Configuration options for an InvokeTrigger */
2577
- type InvokeTriggerOptions<TSchema extends ZodType = z.ZodTypeAny> = {
2578
- /** A [Zod](https://trigger.dev/docs/documentation/guides/zod) schema that defines the shape of the event payload.
2579
- * The default is `z.any()` which is `any`.
2580
- * */
2581
- schema?: TSchema;
2582
- examples?: EventSpecificationExample[];
2583
- };
2584
- declare class InvokeTrigger<TSchema extends ZodType = z.ZodTypeAny> implements Trigger<EventSpecification<TypeOf<TSchema>, z.input<TSchema>>> {
2585
- #private;
2586
- constructor(options: InvokeTriggerOptions<TSchema>);
2587
- toJSON(): TriggerMetadata;
2588
- get event(): {
2589
- name: string;
2590
- title: string;
2591
- source: string;
2592
- examples: {
2593
- id: string;
2594
- name: string;
2595
- icon?: string | undefined;
2596
- payload?: any;
2597
- }[];
2598
- icon: string;
2599
- parsePayload: (rawPayload: unknown) => any;
2600
- parseInvokePayload: (rawPayload: unknown) => any;
2601
- };
2602
- attachToJob(triggerClient: TriggerClient, job: Job<Trigger<EventSpecification<ZodType<TSchema>>>, any>): void;
2603
- get preprocessRuns(): boolean;
2604
- verifyPayload(): Promise<{
2605
- success: true;
2606
- }>;
2607
- }
2608
- declare function invokeTrigger<TSchema extends ZodType = z.ZodTypeAny>(options?: InvokeTriggerOptions<TSchema>): Trigger<EventSpecification<TypeOf<TSchema>, z.input<TSchema>>>;
2609
-
2610
- declare function slugifyId(input: string): string;
2611
-
2612
- /** Easily verify webhook payloads when they're using common signing methods. */
2613
- declare function verifyRequestSignature({ request, headerName, headerEncoding, secret, algorithm, }: {
2614
- /** The web request that you want to verify. */
2615
- request: Request;
2616
- /** The name of the header that contains the signature. E.g. `X-Cal-Signature-256`. */
2617
- headerName: string;
2618
- /** The header encoding. Defaults to `hex`. */
2619
- headerEncoding?: BinaryToTextEncoding;
2620
- /** The secret that you use to hash the payload. For HttpEndpoints this will usually originally
2621
- come from the Trigger.dev dashboard and should be stored in an environment variable. */
2622
- secret: BinaryLike | KeyObject;
2623
- /** The hashing algorithm that was used to create the signature. Currently only `sha256` is
2624
- supported. */
2625
- algorithm: "sha256";
2626
- }): Promise<VerifyResult>;
2627
- declare function verifyHmacSha256(headerValue: string, headerEncoding: BinaryToTextEncoding, secret: BinaryLike | KeyObject, body: string): boolean;
2628
-
2629
- declare class ResumeWithTaskError {
2630
- task: ServerTask;
2631
- constructor(task: ServerTask);
2632
- }
2633
- declare class ResumeWithParallelTaskError {
2634
- task: ServerTask;
2635
- childErrors: Array<TriggerInternalError>;
2636
- constructor(task: ServerTask, childErrors: Array<TriggerInternalError>);
2637
- }
2638
- declare class RetryWithTaskError {
2639
- cause: ErrorWithStack;
2640
- task: ServerTask;
2641
- retryAt: Date;
2642
- constructor(cause: ErrorWithStack, task: ServerTask, retryAt: Date);
2643
- }
2644
- declare class CanceledWithTaskError {
2645
- task: ServerTask;
2646
- constructor(task: ServerTask);
2647
- }
2648
- declare class YieldExecutionError {
2649
- key: string;
2650
- constructor(key: string);
2651
- }
2652
- declare class AutoYieldExecutionError {
2653
- location: string;
2654
- timeRemaining: number;
2655
- timeElapsed: number;
2656
- constructor(location: string, timeRemaining: number, timeElapsed: number);
2657
- }
2658
- declare class AutoYieldWithCompletedTaskExecutionError {
2659
- id: string;
2660
- properties: DisplayProperty[] | undefined;
2661
- data: {
2662
- location: string;
2663
- timeRemaining: number;
2664
- timeElapsed: number;
2665
- };
2666
- output?: string | undefined;
2667
- constructor(id: string, properties: DisplayProperty[] | undefined, data: {
2668
- location: string;
2669
- timeRemaining: number;
2670
- timeElapsed: number;
2671
- }, output?: string | undefined);
2672
- }
2673
- type TriggerInternalError = ResumeWithTaskError | RetryWithTaskError | CanceledWithTaskError | YieldExecutionError | AutoYieldExecutionError | AutoYieldWithCompletedTaskExecutionError | ResumeWithParallelTaskError;
2674
- /** Use this function if you're using a `try/catch` block to catch errors.
2675
- * It checks if a thrown error is a special internal error that you should ignore.
2676
- * If this returns `true` then you must rethrow the error: `throw err;`
2677
- * @param err The error to check
2678
- * @returns `true` if the error is a Trigger Error, `false` otherwise.
2679
- */
2680
- declare function isTriggerError(err: unknown): err is TriggerInternalError;
2681
-
2682
- declare const retry: {
2683
- readonly standardBackoff: {
2684
- readonly limit: 8;
2685
- readonly factor: 1.8;
2686
- readonly minTimeoutInMs: 500;
2687
- readonly maxTimeoutInMs: 30000;
2688
- readonly randomize: true;
2689
- };
2690
- readonly exponentialBackoff: {
2691
- readonly limit: 8;
2692
- readonly factor: 2;
2693
- readonly minTimeoutInMs: 1000;
2694
- readonly maxTimeoutInMs: 30000;
2695
- readonly randomize: true;
2696
- };
2697
- };
2698
-
2699
- type Task = ServerTask;
2700
-
2701
- type SentEvent = ApiEventLog;
2702
- declare function redactString(strings: TemplateStringsArray, ...interpolations: string[]): RedactString;
2703
-
2704
- export { type AuthResolverResult, type BackgroundFetchResponse, CronTrigger, type DynamicIntervalOptions, DynamicSchedule, DynamicTrigger, type DynamicTriggerOptions, type EventSpecification, type EventSpecificationExample, EventSpecificationExampleSchema, EventTrigger, type EventTypeFromSpecification, ExternalSource, type ExternalSourceParams, ExternalSourceTrigger, type ExternalSourceTriggerOptions, type GetWebhookConfig, type GetWebhookParams, type HandlerEvent, type HttpSourceEvent, IO, IOLogger, type IOOptions, type IOStats, type IOTask, type IOWithIntegrations, type IntegrationTaskKey, IntervalTrigger, InvokeTrigger, JSONOutputSerializer, Job, type JobIO, type JobOptions, type JobPayload, type Json, MissingConnectionNotification, MissingConnectionResolvedNotification, type NotificationEvents, type NotificationsEventEmitter, type OutputSerializer, type PreprocessResults, type RunTaskErrorCallback, type SchemaParser, type SchemaParserIssue, type SchemaParserResult, type SentEvent, type Task, type TaskLogger, type Trigger, type TriggerAuthResolver, TriggerClient, type TriggerClientOptions, type TriggerContext, type TriggerEventType, type TriggerIntegration, type TriggerInvokeType, type TriggerOptionRecord, type TriggerPayload, type TriggerPreprocessContext, type TypedEventSpecificationExample, type VerifyResult, type WaitForEventResult, type WebhookConfig, type WebhookDeliveryContext, type WebhookHandlerEvent, WebhookSource, WebhookTrigger, type WebhookTriggerOptions, cronTrigger, eventTrigger, intervalTrigger, invokeTrigger, isTriggerError, missingConnectionNotification, missingConnectionResolvedNotification, omit, redactString, retry, slugifyId, verifyHmacSha256, verifyRequestSignature, waitForEventSchema };