@trigger.dev/sdk 2.0.0-next.5 → 2.0.0-next.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,11 +1,20 @@
1
1
  import * as zod from 'zod';
2
2
  import { z } from 'zod';
3
3
 
4
+ /**
5
+ * Represents different log levels.
6
+ * - `"log"`: Only essential messages.
7
+ * - `"error"`: Errors and essential messages.
8
+ * - `"warn"`: Warnings, Errors and essential messages.
9
+ * - `"info"`: Info, Warnings, Errors and essential messages.
10
+ * - `"debug"`: Everything.
11
+ */
4
12
  type LogLevel = "log" | "error" | "warn" | "info" | "debug";
5
13
  declare class Logger {
6
14
  #private;
7
15
  constructor(name: string, level?: LogLevel, filteredKeys?: string[], jsonReplacer?: (key: string, value: unknown) => unknown);
8
16
  filter(...keys: string[]): Logger;
17
+ static satisfiesLogLevel(logLevel: LogLevel, setLevel: LogLevel): boolean;
9
18
  log(...args: any[]): void;
10
19
  error(...args: any[]): void;
11
20
  warn(...args: any[]): void;
@@ -733,17 +742,34 @@ declare const JobMetadataSchema: z.ZodObject<{
733
742
  }>;
734
743
  type JobMetadata = z.infer<typeof JobMetadataSchema>;
735
744
  declare const RawEventSchema: z.ZodObject<{
736
- id: z.ZodDefault<z.ZodString>;
745
+ /** The `name` property must exactly match any subscriptions you want to
746
+ trigger. */
737
747
  name: z.ZodString;
738
- source: z.ZodOptional<z.ZodString>;
748
+ /** The `payload` property will be sent to any matching Jobs and will appear
749
+ as the `payload` param of the `run()` function. You can leave this
750
+ parameter out if you just want to trigger a Job without any input data. */
739
751
  payload: z.ZodAny;
752
+ /** The optional `context` property will be sent to any matching Jobs and will
753
+ be passed through as the `context.event.context` param of the `run()`
754
+ function. This is optional but can be useful if you want to pass through
755
+ some additional context to the Job. */
740
756
  context: z.ZodOptional<z.ZodAny>;
741
- timestamp: z.ZodOptional<z.ZodString>;
757
+ /** The `id` property uniquely identify this particular event. If unset it
758
+ will be set automatically using `ulid`. */
759
+ id: z.ZodDefault<z.ZodString>;
760
+ /** This is optional, it defaults to the current timestamp. Usually you would
761
+ only set this if you have a timestamp that you wish to pass through, e.g.
762
+ you receive a timestamp from a service and you want the same timestamp to
763
+ be used in your Job. */
764
+ timestamp: z.ZodOptional<z.ZodDate>;
765
+ /** This is optional, it defaults to "trigger.dev". It can be useful to set
766
+ this as you can filter events using this in the `eventTrigger()`. */
767
+ source: z.ZodOptional<z.ZodString>;
742
768
  }, "strip", z.ZodTypeAny, {
743
769
  source?: string | undefined;
744
770
  payload?: any;
745
771
  context?: any;
746
- timestamp?: string | undefined;
772
+ timestamp?: Date | undefined;
747
773
  id: string;
748
774
  name: string;
749
775
  }, {
@@ -751,20 +777,30 @@ declare const RawEventSchema: z.ZodObject<{
751
777
  source?: string | undefined;
752
778
  payload?: any;
753
779
  context?: any;
754
- timestamp?: string | undefined;
780
+ timestamp?: Date | undefined;
755
781
  name: string;
756
782
  }>;
783
+ /** The event you wish to send to Trigger a Job */
757
784
  type SendEvent = z.input<typeof RawEventSchema>;
785
+ /** Options to control the delivery of the event */
758
786
  declare const SendEventOptionsSchema: z.ZodObject<{
759
- deliverAt: z.ZodOptional<z.ZodString>;
787
+ /** An optional Date when you want the event to trigger Jobs. The event will
788
+ be sent to the platform immediately but won't be acted upon until the
789
+ specified time. */
790
+ deliverAt: z.ZodOptional<z.ZodDate>;
791
+ /** An optional number of seconds you want to wait for the event to trigger
792
+ any relevant Jobs. The event will be sent to the platform immediately but
793
+ won't be delivered until after the elapsed number of seconds. */
760
794
  deliverAfter: z.ZodOptional<z.ZodNumber>;
795
+ /** This optional param will be used by Trigger.dev Connect, which
796
+ is coming soon. */
761
797
  accountId: z.ZodOptional<z.ZodString>;
762
798
  }, "strip", z.ZodTypeAny, {
763
- deliverAt?: string | undefined;
799
+ deliverAt?: Date | undefined;
764
800
  deliverAfter?: number | undefined;
765
801
  accountId?: string | undefined;
766
802
  }, {
767
- deliverAt?: string | undefined;
803
+ deliverAt?: Date | undefined;
768
804
  deliverAfter?: number | undefined;
769
805
  accountId?: string | undefined;
770
806
  }>;
@@ -1192,12 +1228,24 @@ declare const CreateRunBodySchema: z.ZodObject<{
1192
1228
  preprocessRuns: boolean;
1193
1229
  }>;
1194
1230
  event: z.ZodObject<{
1231
+ /** The `id` of the event that was sent.
1232
+ */
1195
1233
  id: z.ZodString;
1234
+ /** The `name` of the event that was sent. */
1196
1235
  name: z.ZodString;
1236
+ /** The `payload` of the event that was sent */
1197
1237
  payload: z.ZodType<DeserializedJson, z.ZodTypeDef, DeserializedJson>;
1238
+ /** The `context` of the event that was sent. Is `undefined` if no context was
1239
+ set when sending the event. */
1198
1240
  context: z.ZodNullable<z.ZodOptional<z.ZodType<DeserializedJson, z.ZodTypeDef, DeserializedJson>>>;
1241
+ /** The `timestamp` of the event that was sent */
1199
1242
  timestamp: z.ZodDate;
1243
+ /** The timestamp when the event will be delivered to any matching Jobs. Is
1244
+ `undefined` if `deliverAt` or `deliverAfter` wasn't set when sending the
1245
+ event. */
1200
1246
  deliverAt: z.ZodNullable<z.ZodOptional<z.ZodDate>>;
1247
+ /** The timestamp when the event was delivered. Is `undefined` if `deliverAt`
1248
+ or `deliverAfter` were set when sending the event. */
1201
1249
  deliveredAt: z.ZodNullable<z.ZodOptional<z.ZodDate>>;
1202
1250
  }, "strip", z.ZodTypeAny, {
1203
1251
  context?: DeserializedJson | undefined;
@@ -1427,13 +1475,44 @@ declare const RedactStringSchema: z.ZodObject<{
1427
1475
  type RedactString = z.infer<typeof RedactStringSchema>;
1428
1476
  type CachedTask = z.infer<typeof CachedTaskSchema>;
1429
1477
  declare const RunTaskOptionsSchema: z.ZodObject<{
1478
+ /** The name of the Task is required. This is displayed on the Task in the logs. */
1430
1479
  name: z.ZodString;
1480
+ /** The Task will wait and only start at the specified Date */
1481
+ delayUntil: z.ZodOptional<z.ZodDate>;
1482
+ /** Retry options */
1483
+ retry: z.ZodOptional<z.ZodObject<{
1484
+ /** The maximum number of times to retry the request. */
1485
+ limit: z.ZodOptional<z.ZodNumber>;
1486
+ /** The exponential factor to use when calculating the next retry time. */
1487
+ factor: z.ZodOptional<z.ZodNumber>;
1488
+ /** The minimum amount of time to wait before retrying the request. */
1489
+ minTimeoutInMs: z.ZodOptional<z.ZodNumber>;
1490
+ /** The maximum amount of time to wait before retrying the request. */
1491
+ maxTimeoutInMs: z.ZodOptional<z.ZodNumber>;
1492
+ /** Whether to randomize the retry time. */
1493
+ randomize: z.ZodOptional<z.ZodBoolean>;
1494
+ }, "strip", z.ZodTypeAny, {
1495
+ limit?: number | undefined;
1496
+ factor?: number | undefined;
1497
+ minTimeoutInMs?: number | undefined;
1498
+ maxTimeoutInMs?: number | undefined;
1499
+ randomize?: boolean | undefined;
1500
+ }, {
1501
+ limit?: number | undefined;
1502
+ factor?: number | undefined;
1503
+ minTimeoutInMs?: number | undefined;
1504
+ maxTimeoutInMs?: number | undefined;
1505
+ randomize?: boolean | undefined;
1506
+ }>>;
1507
+ /** The icon for the Task, it will appear in the logs.
1508
+ * You can use the name of a company in lowercase, e.g. "github".
1509
+ * Or any icon name that [Font Awesome](https://fontawesome.com/icons) supports. */
1431
1510
  icon: z.ZodOptional<z.ZodString>;
1511
+ /** The key for the Task that you want to appear in the logs */
1432
1512
  displayKey: z.ZodOptional<z.ZodString>;
1433
- noop: z.ZodDefault<z.ZodBoolean>;
1434
- operation: z.ZodOptional<z.ZodEnum<["fetch"]>>;
1435
- delayUntil: z.ZodOptional<z.ZodDate>;
1513
+ /** A description of the Task */
1436
1514
  description: z.ZodOptional<z.ZodString>;
1515
+ /** Properties that are displayed in the logs */
1437
1516
  properties: z.ZodOptional<z.ZodArray<z.ZodObject<{
1438
1517
  label: z.ZodString;
1439
1518
  text: z.ZodString;
@@ -1447,7 +1526,32 @@ declare const RunTaskOptionsSchema: z.ZodObject<{
1447
1526
  label: string;
1448
1527
  text: string;
1449
1528
  }>, "many">>;
1529
+ /** The input params to the Task, will be displayed in the logs */
1450
1530
  params: z.ZodAny;
1531
+ /** The style of the log entry. */
1532
+ style: z.ZodOptional<z.ZodObject<{
1533
+ style: z.ZodEnum<["normal", "minimal"]>;
1534
+ variant: z.ZodOptional<z.ZodString>;
1535
+ }, "strip", z.ZodTypeAny, {
1536
+ variant?: string | undefined;
1537
+ style: "normal" | "minimal";
1538
+ }, {
1539
+ variant?: string | undefined;
1540
+ style: "normal" | "minimal";
1541
+ }>>;
1542
+ /** Allows you to link the Integration connection in the logs. This is handled automatically in integrations. */
1543
+ connectionKey: z.ZodOptional<z.ZodString>;
1544
+ /** An operation you want to perform on the Trigger.dev platform, current only "fetch" is supported. If you wish to `fetch` use [`io.backgroundFetch()`](https://trigger.dev/docs/sdk/io/backgroundfetch) instead. */
1545
+ operation: z.ZodOptional<z.ZodEnum<["fetch"]>>;
1546
+ /** A No Operation means that the code won't be executed. This is used internally to implement features like [io.wait()](https://trigger.dev/docs/sdk/io/wait). */
1547
+ noop: z.ZodDefault<z.ZodBoolean>;
1548
+ redact: z.ZodOptional<z.ZodObject<{
1549
+ paths: z.ZodArray<z.ZodString, "many">;
1550
+ }, "strip", z.ZodTypeAny, {
1551
+ paths: string[];
1552
+ }, {
1553
+ paths: string[];
1554
+ }>>;
1451
1555
  trigger: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
1452
1556
  type: z.ZodLiteral<"dynamic">;
1453
1557
  id: z.ZodString;
@@ -1595,43 +1699,6 @@ declare const RunTaskOptionsSchema: z.ZodObject<{
1595
1699
  type: "interval";
1596
1700
  };
1597
1701
  }>]>>;
1598
- redact: z.ZodOptional<z.ZodObject<{
1599
- paths: z.ZodArray<z.ZodString, "many">;
1600
- }, "strip", z.ZodTypeAny, {
1601
- paths: string[];
1602
- }, {
1603
- paths: string[];
1604
- }>>;
1605
- connectionKey: z.ZodOptional<z.ZodString>;
1606
- style: z.ZodOptional<z.ZodObject<{
1607
- style: z.ZodEnum<["normal", "minimal"]>;
1608
- variant: z.ZodOptional<z.ZodString>;
1609
- }, "strip", z.ZodTypeAny, {
1610
- variant?: string | undefined;
1611
- style: "normal" | "minimal";
1612
- }, {
1613
- variant?: string | undefined;
1614
- style: "normal" | "minimal";
1615
- }>>;
1616
- retry: z.ZodOptional<z.ZodObject<{
1617
- limit: z.ZodOptional<z.ZodNumber>;
1618
- factor: z.ZodOptional<z.ZodNumber>;
1619
- minTimeoutInMs: z.ZodOptional<z.ZodNumber>;
1620
- maxTimeoutInMs: z.ZodOptional<z.ZodNumber>;
1621
- randomize: z.ZodOptional<z.ZodBoolean>;
1622
- }, "strip", z.ZodTypeAny, {
1623
- limit?: number | undefined;
1624
- factor?: number | undefined;
1625
- minTimeoutInMs?: number | undefined;
1626
- maxTimeoutInMs?: number | undefined;
1627
- randomize?: boolean | undefined;
1628
- }, {
1629
- limit?: number | undefined;
1630
- factor?: number | undefined;
1631
- minTimeoutInMs?: number | undefined;
1632
- maxTimeoutInMs?: number | undefined;
1633
- randomize?: boolean | undefined;
1634
- }>>;
1635
1702
  }, "strip", z.ZodTypeAny, {
1636
1703
  icon?: string | undefined;
1637
1704
  delayUntil?: Date | undefined;
@@ -1680,11 +1747,6 @@ declare const RunTaskOptionsSchema: z.ZodObject<{
1680
1747
  type: "interval";
1681
1748
  };
1682
1749
  } | undefined;
1683
- displayKey?: string | undefined;
1684
- redact?: {
1685
- paths: string[];
1686
- } | undefined;
1687
- connectionKey?: string | undefined;
1688
1750
  retry?: {
1689
1751
  limit?: number | undefined;
1690
1752
  factor?: number | undefined;
@@ -1692,6 +1754,11 @@ declare const RunTaskOptionsSchema: z.ZodObject<{
1692
1754
  maxTimeoutInMs?: number | undefined;
1693
1755
  randomize?: boolean | undefined;
1694
1756
  } | undefined;
1757
+ displayKey?: string | undefined;
1758
+ connectionKey?: string | undefined;
1759
+ redact?: {
1760
+ paths: string[];
1761
+ } | undefined;
1695
1762
  name: string;
1696
1763
  noop: boolean;
1697
1764
  }, {
@@ -1743,11 +1810,6 @@ declare const RunTaskOptionsSchema: z.ZodObject<{
1743
1810
  type: "interval";
1744
1811
  };
1745
1812
  } | undefined;
1746
- displayKey?: string | undefined;
1747
- redact?: {
1748
- paths: string[];
1749
- } | undefined;
1750
- connectionKey?: string | undefined;
1751
1813
  retry?: {
1752
1814
  limit?: number | undefined;
1753
1815
  factor?: number | undefined;
@@ -1755,17 +1817,53 @@ declare const RunTaskOptionsSchema: z.ZodObject<{
1755
1817
  maxTimeoutInMs?: number | undefined;
1756
1818
  randomize?: boolean | undefined;
1757
1819
  } | undefined;
1820
+ displayKey?: string | undefined;
1821
+ connectionKey?: string | undefined;
1822
+ redact?: {
1823
+ paths: string[];
1824
+ } | undefined;
1758
1825
  name: string;
1759
1826
  }>;
1760
1827
  type RunTaskOptions = z.input<typeof RunTaskOptionsSchema>;
1761
1828
  declare const RunTaskBodyInputSchema: z.ZodObject<z.extendShape<{
1829
+ /** The name of the Task is required. This is displayed on the Task in the logs. */
1762
1830
  name: z.ZodString;
1831
+ /** The Task will wait and only start at the specified Date */
1832
+ delayUntil: z.ZodOptional<z.ZodDate>;
1833
+ /** Retry options */
1834
+ retry: z.ZodOptional<z.ZodObject<{
1835
+ /** The maximum number of times to retry the request. */
1836
+ limit: z.ZodOptional<z.ZodNumber>;
1837
+ /** The exponential factor to use when calculating the next retry time. */
1838
+ factor: z.ZodOptional<z.ZodNumber>;
1839
+ /** The minimum amount of time to wait before retrying the request. */
1840
+ minTimeoutInMs: z.ZodOptional<z.ZodNumber>;
1841
+ /** The maximum amount of time to wait before retrying the request. */
1842
+ maxTimeoutInMs: z.ZodOptional<z.ZodNumber>;
1843
+ /** Whether to randomize the retry time. */
1844
+ randomize: z.ZodOptional<z.ZodBoolean>;
1845
+ }, "strip", z.ZodTypeAny, {
1846
+ limit?: number | undefined;
1847
+ factor?: number | undefined;
1848
+ minTimeoutInMs?: number | undefined;
1849
+ maxTimeoutInMs?: number | undefined;
1850
+ randomize?: boolean | undefined;
1851
+ }, {
1852
+ limit?: number | undefined;
1853
+ factor?: number | undefined;
1854
+ minTimeoutInMs?: number | undefined;
1855
+ maxTimeoutInMs?: number | undefined;
1856
+ randomize?: boolean | undefined;
1857
+ }>>;
1858
+ /** The icon for the Task, it will appear in the logs.
1859
+ * You can use the name of a company in lowercase, e.g. "github".
1860
+ * Or any icon name that [Font Awesome](https://fontawesome.com/icons) supports. */
1763
1861
  icon: z.ZodOptional<z.ZodString>;
1862
+ /** The key for the Task that you want to appear in the logs */
1764
1863
  displayKey: z.ZodOptional<z.ZodString>;
1765
- noop: z.ZodDefault<z.ZodBoolean>;
1766
- operation: z.ZodOptional<z.ZodEnum<["fetch"]>>;
1767
- delayUntil: z.ZodOptional<z.ZodDate>;
1864
+ /** A description of the Task */
1768
1865
  description: z.ZodOptional<z.ZodString>;
1866
+ /** Properties that are displayed in the logs */
1769
1867
  properties: z.ZodOptional<z.ZodArray<z.ZodObject<{
1770
1868
  label: z.ZodString;
1771
1869
  text: z.ZodString;
@@ -1779,7 +1877,32 @@ declare const RunTaskBodyInputSchema: z.ZodObject<z.extendShape<{
1779
1877
  label: string;
1780
1878
  text: string;
1781
1879
  }>, "many">>;
1880
+ /** The input params to the Task, will be displayed in the logs */
1782
1881
  params: z.ZodAny;
1882
+ /** The style of the log entry. */
1883
+ style: z.ZodOptional<z.ZodObject<{
1884
+ style: z.ZodEnum<["normal", "minimal"]>;
1885
+ variant: z.ZodOptional<z.ZodString>;
1886
+ }, "strip", z.ZodTypeAny, {
1887
+ variant?: string | undefined;
1888
+ style: "normal" | "minimal";
1889
+ }, {
1890
+ variant?: string | undefined;
1891
+ style: "normal" | "minimal";
1892
+ }>>;
1893
+ /** Allows you to link the Integration connection in the logs. This is handled automatically in integrations. */
1894
+ connectionKey: z.ZodOptional<z.ZodString>;
1895
+ /** An operation you want to perform on the Trigger.dev platform, current only "fetch" is supported. If you wish to `fetch` use [`io.backgroundFetch()`](https://trigger.dev/docs/sdk/io/backgroundfetch) instead. */
1896
+ operation: z.ZodOptional<z.ZodEnum<["fetch"]>>;
1897
+ /** A No Operation means that the code won't be executed. This is used internally to implement features like [io.wait()](https://trigger.dev/docs/sdk/io/wait). */
1898
+ noop: z.ZodDefault<z.ZodBoolean>;
1899
+ redact: z.ZodOptional<z.ZodObject<{
1900
+ paths: z.ZodArray<z.ZodString, "many">;
1901
+ }, "strip", z.ZodTypeAny, {
1902
+ paths: string[];
1903
+ }, {
1904
+ paths: string[];
1905
+ }>>;
1783
1906
  trigger: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
1784
1907
  type: z.ZodLiteral<"dynamic">;
1785
1908
  id: z.ZodString;
@@ -1927,43 +2050,6 @@ declare const RunTaskBodyInputSchema: z.ZodObject<z.extendShape<{
1927
2050
  type: "interval";
1928
2051
  };
1929
2052
  }>]>>;
1930
- redact: z.ZodOptional<z.ZodObject<{
1931
- paths: z.ZodArray<z.ZodString, "many">;
1932
- }, "strip", z.ZodTypeAny, {
1933
- paths: string[];
1934
- }, {
1935
- paths: string[];
1936
- }>>;
1937
- connectionKey: z.ZodOptional<z.ZodString>;
1938
- style: z.ZodOptional<z.ZodObject<{
1939
- style: z.ZodEnum<["normal", "minimal"]>;
1940
- variant: z.ZodOptional<z.ZodString>;
1941
- }, "strip", z.ZodTypeAny, {
1942
- variant?: string | undefined;
1943
- style: "normal" | "minimal";
1944
- }, {
1945
- variant?: string | undefined;
1946
- style: "normal" | "minimal";
1947
- }>>;
1948
- retry: z.ZodOptional<z.ZodObject<{
1949
- limit: z.ZodOptional<z.ZodNumber>;
1950
- factor: z.ZodOptional<z.ZodNumber>;
1951
- minTimeoutInMs: z.ZodOptional<z.ZodNumber>;
1952
- maxTimeoutInMs: z.ZodOptional<z.ZodNumber>;
1953
- randomize: z.ZodOptional<z.ZodBoolean>;
1954
- }, "strip", z.ZodTypeAny, {
1955
- limit?: number | undefined;
1956
- factor?: number | undefined;
1957
- minTimeoutInMs?: number | undefined;
1958
- maxTimeoutInMs?: number | undefined;
1959
- randomize?: boolean | undefined;
1960
- }, {
1961
- limit?: number | undefined;
1962
- factor?: number | undefined;
1963
- minTimeoutInMs?: number | undefined;
1964
- maxTimeoutInMs?: number | undefined;
1965
- randomize?: boolean | undefined;
1966
- }>>;
1967
2053
  }, {
1968
2054
  idempotencyKey: z.ZodString;
1969
2055
  parentId: z.ZodOptional<z.ZodString>;
@@ -2016,11 +2102,6 @@ declare const RunTaskBodyInputSchema: z.ZodObject<z.extendShape<{
2016
2102
  type: "interval";
2017
2103
  };
2018
2104
  } | undefined;
2019
- displayKey?: string | undefined;
2020
- redact?: {
2021
- paths: string[];
2022
- } | undefined;
2023
- connectionKey?: string | undefined;
2024
2105
  retry?: {
2025
2106
  limit?: number | undefined;
2026
2107
  factor?: number | undefined;
@@ -2028,6 +2109,11 @@ declare const RunTaskBodyInputSchema: z.ZodObject<z.extendShape<{
2028
2109
  maxTimeoutInMs?: number | undefined;
2029
2110
  randomize?: boolean | undefined;
2030
2111
  } | undefined;
2112
+ displayKey?: string | undefined;
2113
+ connectionKey?: string | undefined;
2114
+ redact?: {
2115
+ paths: string[];
2116
+ } | undefined;
2031
2117
  name: string;
2032
2118
  noop: boolean;
2033
2119
  idempotencyKey: string;
@@ -2081,11 +2167,6 @@ declare const RunTaskBodyInputSchema: z.ZodObject<z.extendShape<{
2081
2167
  type: "interval";
2082
2168
  };
2083
2169
  } | undefined;
2084
- displayKey?: string | undefined;
2085
- redact?: {
2086
- paths: string[];
2087
- } | undefined;
2088
- connectionKey?: string | undefined;
2089
2170
  retry?: {
2090
2171
  limit?: number | undefined;
2091
2172
  factor?: number | undefined;
@@ -2093,18 +2174,54 @@ declare const RunTaskBodyInputSchema: z.ZodObject<z.extendShape<{
2093
2174
  maxTimeoutInMs?: number | undefined;
2094
2175
  randomize?: boolean | undefined;
2095
2176
  } | undefined;
2177
+ displayKey?: string | undefined;
2178
+ connectionKey?: string | undefined;
2179
+ redact?: {
2180
+ paths: string[];
2181
+ } | undefined;
2096
2182
  name: string;
2097
2183
  idempotencyKey: string;
2098
2184
  }>;
2099
2185
  type RunTaskBodyInput = z.infer<typeof RunTaskBodyInputSchema>;
2100
2186
  declare const CompleteTaskBodyInputSchema: z.ZodObject<z.extendShape<Pick<z.extendShape<{
2187
+ /** The name of the Task is required. This is displayed on the Task in the logs. */
2101
2188
  name: z.ZodString;
2189
+ /** The Task will wait and only start at the specified Date */
2190
+ delayUntil: z.ZodOptional<z.ZodDate>;
2191
+ /** Retry options */
2192
+ retry: z.ZodOptional<z.ZodObject<{
2193
+ /** The maximum number of times to retry the request. */
2194
+ limit: z.ZodOptional<z.ZodNumber>;
2195
+ /** The exponential factor to use when calculating the next retry time. */
2196
+ factor: z.ZodOptional<z.ZodNumber>;
2197
+ /** The minimum amount of time to wait before retrying the request. */
2198
+ minTimeoutInMs: z.ZodOptional<z.ZodNumber>;
2199
+ /** The maximum amount of time to wait before retrying the request. */
2200
+ maxTimeoutInMs: z.ZodOptional<z.ZodNumber>;
2201
+ /** Whether to randomize the retry time. */
2202
+ randomize: z.ZodOptional<z.ZodBoolean>;
2203
+ }, "strip", z.ZodTypeAny, {
2204
+ limit?: number | undefined;
2205
+ factor?: number | undefined;
2206
+ minTimeoutInMs?: number | undefined;
2207
+ maxTimeoutInMs?: number | undefined;
2208
+ randomize?: boolean | undefined;
2209
+ }, {
2210
+ limit?: number | undefined;
2211
+ factor?: number | undefined;
2212
+ minTimeoutInMs?: number | undefined;
2213
+ maxTimeoutInMs?: number | undefined;
2214
+ randomize?: boolean | undefined;
2215
+ }>>;
2216
+ /** The icon for the Task, it will appear in the logs.
2217
+ * You can use the name of a company in lowercase, e.g. "github".
2218
+ * Or any icon name that [Font Awesome](https://fontawesome.com/icons) supports. */
2102
2219
  icon: z.ZodOptional<z.ZodString>;
2220
+ /** The key for the Task that you want to appear in the logs */
2103
2221
  displayKey: z.ZodOptional<z.ZodString>;
2104
- noop: z.ZodDefault<z.ZodBoolean>;
2105
- operation: z.ZodOptional<z.ZodEnum<["fetch"]>>;
2106
- delayUntil: z.ZodOptional<z.ZodDate>;
2222
+ /** A description of the Task */
2107
2223
  description: z.ZodOptional<z.ZodString>;
2224
+ /** Properties that are displayed in the logs */
2108
2225
  properties: z.ZodOptional<z.ZodArray<z.ZodObject<{
2109
2226
  label: z.ZodString;
2110
2227
  text: z.ZodString;
@@ -2118,7 +2235,32 @@ declare const CompleteTaskBodyInputSchema: z.ZodObject<z.extendShape<Pick<z.exte
2118
2235
  label: string;
2119
2236
  text: string;
2120
2237
  }>, "many">>;
2238
+ /** The input params to the Task, will be displayed in the logs */
2121
2239
  params: z.ZodAny;
2240
+ /** The style of the log entry. */
2241
+ style: z.ZodOptional<z.ZodObject<{
2242
+ style: z.ZodEnum<["normal", "minimal"]>;
2243
+ variant: z.ZodOptional<z.ZodString>;
2244
+ }, "strip", z.ZodTypeAny, {
2245
+ variant?: string | undefined;
2246
+ style: "normal" | "minimal";
2247
+ }, {
2248
+ variant?: string | undefined;
2249
+ style: "normal" | "minimal";
2250
+ }>>;
2251
+ /** Allows you to link the Integration connection in the logs. This is handled automatically in integrations. */
2252
+ connectionKey: z.ZodOptional<z.ZodString>;
2253
+ /** An operation you want to perform on the Trigger.dev platform, current only "fetch" is supported. If you wish to `fetch` use [`io.backgroundFetch()`](https://trigger.dev/docs/sdk/io/backgroundfetch) instead. */
2254
+ operation: z.ZodOptional<z.ZodEnum<["fetch"]>>;
2255
+ /** A No Operation means that the code won't be executed. This is used internally to implement features like [io.wait()](https://trigger.dev/docs/sdk/io/wait). */
2256
+ noop: z.ZodDefault<z.ZodBoolean>;
2257
+ redact: z.ZodOptional<z.ZodObject<{
2258
+ paths: z.ZodArray<z.ZodString, "many">;
2259
+ }, "strip", z.ZodTypeAny, {
2260
+ paths: string[];
2261
+ }, {
2262
+ paths: string[];
2263
+ }>>;
2122
2264
  trigger: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
2123
2265
  type: z.ZodLiteral<"dynamic">;
2124
2266
  id: z.ZodString;
@@ -2266,43 +2408,6 @@ declare const CompleteTaskBodyInputSchema: z.ZodObject<z.extendShape<Pick<z.exte
2266
2408
  type: "interval";
2267
2409
  };
2268
2410
  }>]>>;
2269
- redact: z.ZodOptional<z.ZodObject<{
2270
- paths: z.ZodArray<z.ZodString, "many">;
2271
- }, "strip", z.ZodTypeAny, {
2272
- paths: string[];
2273
- }, {
2274
- paths: string[];
2275
- }>>;
2276
- connectionKey: z.ZodOptional<z.ZodString>;
2277
- style: z.ZodOptional<z.ZodObject<{
2278
- style: z.ZodEnum<["normal", "minimal"]>;
2279
- variant: z.ZodOptional<z.ZodString>;
2280
- }, "strip", z.ZodTypeAny, {
2281
- variant?: string | undefined;
2282
- style: "normal" | "minimal";
2283
- }, {
2284
- variant?: string | undefined;
2285
- style: "normal" | "minimal";
2286
- }>>;
2287
- retry: z.ZodOptional<z.ZodObject<{
2288
- limit: z.ZodOptional<z.ZodNumber>;
2289
- factor: z.ZodOptional<z.ZodNumber>;
2290
- minTimeoutInMs: z.ZodOptional<z.ZodNumber>;
2291
- maxTimeoutInMs: z.ZodOptional<z.ZodNumber>;
2292
- randomize: z.ZodOptional<z.ZodBoolean>;
2293
- }, "strip", z.ZodTypeAny, {
2294
- limit?: number | undefined;
2295
- factor?: number | undefined;
2296
- minTimeoutInMs?: number | undefined;
2297
- maxTimeoutInMs?: number | undefined;
2298
- randomize?: boolean | undefined;
2299
- }, {
2300
- limit?: number | undefined;
2301
- factor?: number | undefined;
2302
- minTimeoutInMs?: number | undefined;
2303
- maxTimeoutInMs?: number | undefined;
2304
- randomize?: boolean | undefined;
2305
- }>>;
2306
2411
  }, {
2307
2412
  idempotencyKey: z.ZodString;
2308
2413
  parentId: z.ZodOptional<z.ZodString>;
@@ -2689,9 +2794,13 @@ declare const ErrorWithStackSchema: z.ZodObject<{
2689
2794
  }>;
2690
2795
  type ErrorWithStack = z.infer<typeof ErrorWithStackSchema>;
2691
2796
 
2797
+ /** A property that is displayed in the logs */
2692
2798
  declare const DisplayPropertySchema: z.ZodObject<{
2799
+ /** The label for the property */
2693
2800
  label: z.ZodString;
2801
+ /** The value of the property */
2694
2802
  text: z.ZodString;
2803
+ /** The URL to link to when the property is clicked */
2695
2804
  url: z.ZodOptional<z.ZodString>;
2696
2805
  }, "strip", z.ZodTypeAny, {
2697
2806
  url?: string | undefined;
@@ -2782,14 +2891,19 @@ declare const ScheduledPayloadSchema: z.ZodObject<{
2782
2891
  }>;
2783
2892
  type ScheduledPayload = z.infer<typeof ScheduledPayloadSchema>;
2784
2893
  declare const IntervalOptionsSchema: z.ZodObject<{
2894
+ /** The number of seconds for the interval. Min = 60, Max = 86400 (1 day) */
2785
2895
  seconds: z.ZodNumber;
2786
2896
  }, "strip", z.ZodTypeAny, {
2787
2897
  seconds: number;
2788
2898
  }, {
2789
2899
  seconds: number;
2790
2900
  }>;
2901
+ /** Interval options */
2791
2902
  type IntervalOptions = z.infer<typeof IntervalOptionsSchema>;
2792
2903
  declare const CronOptionsSchema: z.ZodObject<{
2904
+ /** A CRON expression that defines the schedule. A useful tool when writing CRON
2905
+ expressions is [crontab guru](https://crontab.guru). Note that the timezone
2906
+ used is UTC. */
2793
2907
  cron: z.ZodString;
2794
2908
  }, "strip", z.ZodTypeAny, {
2795
2909
  cron: string;
@@ -2798,14 +2912,18 @@ declare const CronOptionsSchema: z.ZodObject<{
2798
2912
  }>;
2799
2913
  type CronOptions = z.infer<typeof CronOptionsSchema>;
2800
2914
  declare const ScheduleMetadataSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
2915
+ /** An interval reoccurs at the specified number of seconds */
2801
2916
  type: z.ZodLiteral<"interval">;
2917
+ /** An object containing options about the interval. */
2802
2918
  options: z.ZodObject<{
2919
+ /** The number of seconds for the interval. Min = 60, Max = 86400 (1 day) */
2803
2920
  seconds: z.ZodNumber;
2804
2921
  }, "strip", z.ZodTypeAny, {
2805
2922
  seconds: number;
2806
2923
  }, {
2807
2924
  seconds: number;
2808
2925
  }>;
2926
+ /** Any additional metadata about the schedule. */
2809
2927
  metadata: z.ZodAny;
2810
2928
  }, "strip", z.ZodTypeAny, {
2811
2929
  metadata?: any;
@@ -2822,6 +2940,9 @@ declare const ScheduleMetadataSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
2822
2940
  }>, z.ZodObject<{
2823
2941
  type: z.ZodLiteral<"cron">;
2824
2942
  options: z.ZodObject<{
2943
+ /** A CRON expression that defines the schedule. A useful tool when writing CRON
2944
+ expressions is [crontab guru](https://crontab.guru). Note that the timezone
2945
+ used is UTC. */
2825
2946
  cron: z.ZodString;
2826
2947
  }, "strip", z.ZodTypeAny, {
2827
2948
  cron: string;
@@ -3089,8 +3210,11 @@ declare const MissingConnectionResolvedNotificationPayloadSchema: z.ZodDiscrimin
3089
3210
  }>]>;
3090
3211
  type MissingConnectionResolvedNotificationPayload = z.infer<typeof MissingConnectionResolvedNotificationPayloadSchema>;
3091
3212
 
3213
+ /** The options for a fetch request */
3092
3214
  declare const FetchRequestInitSchema: z.ZodObject<{
3215
+ /** The HTTP method to use for the request. */
3093
3216
  method: z.ZodOptional<z.ZodString>;
3217
+ /** Any headers to send with the request. Note that you can use [redactString](https://trigger.dev/docs/sdk/redactString) to prevent sensitive information from being stored (e.g. in the logs), like API keys and tokens. */
3094
3218
  headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodObject<{
3095
3219
  __redactedString: z.ZodLiteral<true>;
3096
3220
  strings: z.ZodArray<z.ZodString, "many">;
@@ -3104,6 +3228,7 @@ declare const FetchRequestInitSchema: z.ZodObject<{
3104
3228
  strings: string[];
3105
3229
  interpolations: string[];
3106
3230
  }>]>>>;
3231
+ /** The body of the request. */
3107
3232
  body: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodType<ArrayBuffer, z.ZodTypeDef, ArrayBuffer>]>>;
3108
3233
  }, "strip", z.ZodTypeAny, {
3109
3234
  method?: string | undefined;
@@ -3122,11 +3247,16 @@ declare const FetchRequestInitSchema: z.ZodObject<{
3122
3247
  }> | undefined;
3123
3248
  body?: string | ArrayBuffer | undefined;
3124
3249
  }>;
3250
+ /** The options for a fetch request */
3125
3251
  type FetchRequestInit = z.infer<typeof FetchRequestInitSchema>;
3126
3252
  declare const FetchRetryOptionsSchema: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<"strategy", [z.ZodObject<{
3253
+ /** The `headers` strategy retries the request using info from the response headers. */
3127
3254
  strategy: z.ZodLiteral<"headers">;
3255
+ /** The header to use to determine the maximum number of times to retry the request. */
3128
3256
  limitHeader: z.ZodString;
3257
+ /** The header to use to determine the number of remaining retries. */
3129
3258
  remainingHeader: z.ZodString;
3259
+ /** The header to use to determine the time when the number of remaining retries will be reset. */
3130
3260
  resetHeader: z.ZodString;
3131
3261
  }, "strip", z.ZodTypeAny, {
3132
3262
  strategy: "headers";
@@ -3145,6 +3275,7 @@ declare const FetchRetryOptionsSchema: z.ZodRecord<z.ZodString, z.ZodDiscriminat
3145
3275
  maxTimeoutInMs: z.ZodOptional<z.ZodNumber>;
3146
3276
  randomize: z.ZodOptional<z.ZodBoolean>;
3147
3277
  }, {
3278
+ /** The `backoff` strategy retries the request with an exponential backoff. */
3148
3279
  strategy: z.ZodLiteral<"backoff">;
3149
3280
  }>, "strip", z.ZodTypeAny, {
3150
3281
  limit?: number | undefined;
@@ -3161,8 +3292,17 @@ declare const FetchRetryOptionsSchema: z.ZodRecord<z.ZodString, z.ZodDiscriminat
3161
3292
  randomize?: boolean | undefined;
3162
3293
  strategy: "backoff";
3163
3294
  }>]>>;
3295
+ /** An object where the key is a status code pattern and the value is a retrying strategy. Supported patterns are:
3296
+ - Specific status codes: 429
3297
+ - Ranges: 500-599
3298
+ - Wildcards: 2xx, 3xx, 4xx, 5xx
3299
+ */
3164
3300
  type FetchRetryOptions = z.infer<typeof FetchRetryOptionsSchema>;
3165
3301
 
3302
+ type Prettify<T> = {
3303
+ [K in keyof T]: T[K];
3304
+ } & {};
3305
+
3166
3306
  type ApiClientOptions = {
3167
3307
  apiKey?: string;
3168
3308
  apiUrl?: string;
@@ -3491,7 +3631,7 @@ declare class ExternalSource<TIntegration extends TriggerIntegration<Integration
3491
3631
  source?: string | undefined;
3492
3632
  payload?: any;
3493
3633
  context?: any;
3494
- timestamp?: string | undefined;
3634
+ timestamp?: Date | undefined;
3495
3635
  name: string;
3496
3636
  }[];
3497
3637
  response?: {
@@ -3558,15 +3698,29 @@ declare class DynamicTrigger<TEventSpec extends EventSpecification<any>, TExtern
3558
3698
  }
3559
3699
 
3560
3700
  type TriggerClientOptions = {
3701
+ /** The `id` property is used to uniquely identify the client.
3702
+ */
3561
3703
  id: string;
3704
+ /** The `apiKey` property is the API Key for your Trigger.dev environment. We
3705
+ recommend using an environment variable to store your API Key. */
3562
3706
  apiKey?: string;
3707
+ /** The `apiUrl` property is an optional property that specifies the API URL. You
3708
+ only need to specify this if you are not using Trigger.dev Cloud and are
3709
+ running your own Trigger.dev instance. */
3563
3710
  apiUrl?: string;
3711
+ /** The `logLevel` property is an optional property that specifies the level of
3712
+ logging for the TriggerClient. The level is inherited by all Jobs that use this Client, unless they also specify a `logLevel`. */
3564
3713
  logLevel?: LogLevel;
3714
+ /** Very verbose log messages, defaults to false. */
3715
+ verbose?: boolean;
3716
+ /** Default is unset and off. If set to true it will log to the server's console as well as the Trigger.dev platform */
3717
+ ioLogLocalEnabled?: boolean;
3565
3718
  };
3719
+ /** 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). */
3566
3720
  declare class TriggerClient {
3567
3721
  #private;
3568
3722
  id: string;
3569
- constructor(options: TriggerClientOptions);
3723
+ constructor(options: Prettify<TriggerClientOptions>);
3570
3724
  handleRequest(request: Request): Promise<NormalizedResponse>;
3571
3725
  attach(job: Job<Trigger<any>, any>): void;
3572
3726
  attachDynamicTrigger(trigger: DynamicTrigger<any, any>): void;
@@ -3607,6 +3761,11 @@ declare class TriggerClient {
3607
3761
  type: "oauth2";
3608
3762
  accessToken: string;
3609
3763
  } | undefined>;
3764
+ /** You can call this function from anywhere in your code 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.
3765
+ * @param event The event to send.
3766
+ * @param options Options for sending the event.
3767
+ * @returns A promise that resolves to the event details
3768
+ */
3610
3769
  sendEvent(event: SendEvent, options?: SendEventOptions): Promise<{
3611
3770
  context?: DeserializedJson | undefined;
3612
3771
  deliverAt?: Date | null | undefined;
@@ -3765,6 +3924,8 @@ type IOOptions = {
3765
3924
  context: TriggerContext;
3766
3925
  logger?: Logger;
3767
3926
  logLevel?: LogLevel;
3927
+ jobLogger?: Logger;
3928
+ jobLogLevel: LogLevel;
3768
3929
  cachedTasks?: Array<CachedTask>;
3769
3930
  };
3770
3931
  declare class IO {
@@ -3773,13 +3934,36 @@ declare class IO {
3773
3934
  private _apiClient;
3774
3935
  private _triggerClient;
3775
3936
  private _logger;
3937
+ private _jobLogger?;
3938
+ private _jobLogLevel;
3776
3939
  private _cachedTasks;
3777
3940
  private _taskStorage;
3778
3941
  private _context;
3779
3942
  constructor(options: IOOptions);
3943
+ /** Used to send log messages to the [Run log](https://trigger.dev/docs/documentation/guides/viewing-runs). */
3780
3944
  get logger(): IOLogger;
3945
+ /** `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.
3946
+ * @param key Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
3947
+ * @param seconds The number of seconds to wait. This can be very long, serverless timeouts are not an issue.
3948
+ */
3781
3949
  wait(key: string | any[], seconds: number): Promise<void>;
3950
+ /** `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.
3951
+ * @param key Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
3952
+ * @param url The URL to fetch from.
3953
+ * @param requestInit The options for the request
3954
+ * @param retry The options for retrying the request if it fails
3955
+ * An object where the key is a status code pattern and the value is a retrying strategy.
3956
+ * Supported patterns are:
3957
+ * - Specific status codes: 429
3958
+ * - Ranges: 500-599
3959
+ * - Wildcards: 2xx, 3xx, 4xx, 5xx
3960
+ */
3782
3961
  backgroundFetch<TResponseData>(key: string | any[], url: string, requestInit?: FetchRequestInit, retry?: FetchRetryOptions): Promise<TResponseData>;
3962
+ /** `io.sendEvent()` allows you to send an event from inside a Job run. The sent even will trigger any Jobs that are listening for that event (based on the name).
3963
+ * @param key Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
3964
+ * @param event The event to send. The event name must match the name of the event that your Jobs are listening for.
3965
+ * @param options Options for sending the event.
3966
+ */
3783
3967
  sendEvent(key: string | any[], event: SendEvent, options?: SendEventOptions): Promise<{
3784
3968
  context?: DeserializedJson | undefined;
3785
3969
  deliverAt?: Date | null | undefined;
@@ -3795,6 +3979,13 @@ declare class IO {
3795
3979
  id: string;
3796
3980
  key: string;
3797
3981
  }>;
3982
+ /** `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.
3983
+ * @param key Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
3984
+ * @param dynamicSchedule The [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) to register a new schedule on.
3985
+ * @param id A unique id for the interval. This is used to identify and unregister the interval later.
3986
+ * @param options The options for the interval.
3987
+ * @returns A promise that has information about the interval.
3988
+ */
3798
3989
  registerInterval(key: string | any[], dynamicSchedule: DynamicSchedule, id: string, options: IntervalOptions): Promise<{
3799
3990
  metadata?: any;
3800
3991
  id: string;
@@ -3813,9 +4004,20 @@ declare class IO {
3813
4004
  };
3814
4005
  active: boolean;
3815
4006
  }>;
4007
+ /** `io.unregisterInterval()` allows you to unregister a [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) that was previously registered with `io.registerInterval()`.
4008
+ * @param key Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
4009
+ * @param dynamicSchedule The [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) to unregister a schedule on.
4010
+ * @param id A unique id for the interval. This is used to identify and unregister the interval later.
4011
+ */
3816
4012
  unregisterInterval(key: string | any[], dynamicSchedule: DynamicSchedule, id: string): Promise<{
3817
4013
  ok: boolean;
3818
4014
  }>;
4015
+ /** `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.
4016
+ * @param key Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
4017
+ * @param dynamicSchedule The [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) to register a new schedule on.
4018
+ * @param id A unique id for the schedule. This is used to identify and unregister the schedule later.
4019
+ * @param options The options for the CRON schedule.
4020
+ */
3819
4021
  registerCron(key: string | any[], dynamicSchedule: DynamicSchedule, id: string, options: CronOptions): Promise<{
3820
4022
  metadata?: any;
3821
4023
  id: string;
@@ -3834,28 +4036,59 @@ declare class IO {
3834
4036
  };
3835
4037
  active: boolean;
3836
4038
  }>;
4039
+ /** `io.unregisterCron()` allows you to unregister a [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) that was previously registered with `io.registerCron()`.
4040
+ * @param key Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
4041
+ * @param dynamicSchedule The [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) to unregister a schedule on.
4042
+ * @param id A unique id for the interval. This is used to identify and unregister the interval later.
4043
+ */
3837
4044
  unregisterCron(key: string | any[], dynamicSchedule: DynamicSchedule, id: string): Promise<{
3838
4045
  ok: boolean;
3839
4046
  }>;
4047
+ /** `io.registerTrigger()` allows you to register a [DynamicTrigger](https://trigger.dev/docs/sdk/dynamictrigger) with the specified trigger params.
4048
+ * @param key Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
4049
+ * @param trigger The [DynamicTrigger](https://trigger.dev/docs/sdk/dynamictrigger) to register.
4050
+ * @param id A unique id for the trigger. This is used to identify and unregister the trigger later.
4051
+ * @param params The params for the trigger.
4052
+ */
3840
4053
  registerTrigger<TTrigger extends DynamicTrigger<EventSpecification<any>, ExternalSource<any, any, any>>>(key: string | any[], trigger: TTrigger, id: string, params: ExternalSourceParams<TTrigger["source"]>): Promise<{
3841
4054
  id: string;
3842
4055
  key: string;
3843
4056
  } | undefined>;
3844
4057
  getAuth(key: string | any[], clientId?: string): Promise<ConnectionAuth | undefined>;
4058
+ /** `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.
4059
+ *
4060
+ * @param key Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
4061
+ * @param options The options of how you'd like to run and log the Task. Name is required.
4062
+ * @param callback The callback that will be called when the Task is run. The callback receives the Task and the IO as parameters.
4063
+ = * @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.
4064
+ * @returns A Promise that resolves with the returned value of the callback.
4065
+ */
3845
4066
  runTask<TResult extends SerializableJson | void = void>(key: string | any[], options: RunTaskOptions, callback: (task: IOTask, io: IO) => Promise<TResult>, onError?: (error: unknown, task: IOTask, io: IO) => {
3846
4067
  retryAt: Date;
3847
4068
  error?: Error;
3848
4069
  jitter?: number;
3849
4070
  } | undefined | void): Promise<TResult>;
4071
+ /** `io.try()` allows you to run Tasks and catch any errors that are thrown, it's similar to a normal `try/catch` block but works with [io.runTask()](/sdk/io/runtask).
4072
+ * 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.
4073
+ * @param tryCallback The code you wish to run
4074
+ * @param catchCallback Thhis will be called if the Task fails. The callback receives the error
4075
+ * @returns A Promise that resolves with the returned value or the error
4076
+ */
3850
4077
  try<TResult, TCatchResult>(tryCallback: () => Promise<TResult>, catchCallback: (error: unknown) => Promise<TCatchResult>): Promise<TResult | TCatchResult>;
3851
4078
  }
3852
- type CallbackFunction = (level: "DEBUG" | "INFO" | "WARN" | "ERROR", message: string, properties?: Record<string, any>) => Promise<void>;
4079
+ type CallbackFunction = (level: "DEBUG" | "INFO" | "WARN" | "ERROR" | "LOG", message: string, properties?: Record<string, any>) => Promise<void>;
3853
4080
  declare class IOLogger implements TaskLogger {
3854
4081
  private callback;
3855
4082
  constructor(callback: CallbackFunction);
4083
+ /** Log: essential messages */
4084
+ log(message: string, properties?: Record<string, any>): Promise<void>;
4085
+ /** For debugging: the least important log level */
3856
4086
  debug(message: string, properties?: Record<string, any>): Promise<void>;
4087
+ /** Info: the second least important log level */
3857
4088
  info(message: string, properties?: Record<string, any>): Promise<void>;
4089
+ /** Warnings: the third most important log level */
3858
4090
  warn(message: string, properties?: Record<string, any>): Promise<void>;
4091
+ /** Error: The second most important log level */
3859
4092
  error(message: string, properties?: Record<string, any>): Promise<void>;
3860
4093
  }
3861
4094
 
@@ -3909,28 +4142,69 @@ type ExtractIntegrations<TIntegrations extends Record<string, TriggerIntegration
3909
4142
  type IOWithIntegrations<TIntegrations extends Record<string, TriggerIntegration<IntegrationClient<any, any>>>> = IO & ExtractIntegrations<TIntegrations>;
3910
4143
 
3911
4144
  type JobOptions<TTrigger extends Trigger<EventSpecification<any>>, TIntegrations extends Record<string, TriggerIntegration<IntegrationClient<any, any>>> = {}> = {
4145
+ /** The `id` property is used to uniquely identify the Job. Only change this if you want to create a new Job. */
3912
4146
  id: string;
4147
+ /** The `name` of the Job that you want to appear in the dashboard and logs. You can change this without creating a new Job. */
3913
4148
  name: string;
4149
+ /** 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`. */
3914
4150
  version: string;
4151
+ /** The `trigger` property is used to define when the Job should run. There are currently the following Trigger types:
4152
+ - [cronTrigger](https://trigger.dev/docs/sdk/crontrigger)
4153
+ - [intervalTrigger](https://trigger.dev/docs/sdk/intervaltrigger)
4154
+ - [eventTrigger](https://trigger.dev/docs/sdk/eventtrigger)
4155
+ - [DynamicTrigger](https://trigger.dev/docs/sdk/dynamictrigger)
4156
+ - [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule)
4157
+ - integration Triggers, like webhooks. See the [integrations](https://trigger.dev/docs/integrations) page for more information. */
3915
4158
  trigger: TTrigger;
4159
+ /** The `logLevel` property is an optional property that specifies the level of
4160
+ logging for the Job. The level is inherited from the client if you omit this property. */
3916
4161
  logLevel?: LogLevel;
4162
+ /** 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:
4163
+ ```ts
4164
+ new Job(client, {
4165
+ //... other options
4166
+ integrations: {
4167
+ slack,
4168
+ gh: github,
4169
+ },
4170
+ run: async (payload, io, ctx) => {
4171
+ //slack is available on io.slack
4172
+ io.slack.postMessage(...);
4173
+ //github is available on io.gh
4174
+ io.gh.addIssueLabels(...);
4175
+ }
4176
+ });
4177
+ ``` */
3917
4178
  integrations?: TIntegrations;
4179
+ /** The `queue` property is used to specify a custom queue. If you use an Object and specify the `maxConcurrent` option, you can control how many simulataneous runs can happen. */
3918
4180
  queue?: QueueOptions | string;
3919
4181
  startPosition?: "initial" | "latest";
4182
+ /** The `enabled` property is used to enable or disable the Job. If you disable a Job, it will not run. */
3920
4183
  enabled?: boolean;
3921
- run: (event: TriggerEventType<TTrigger>, io: IOWithIntegrations<TIntegrations>, ctx: TriggerContext) => Promise<any>;
4184
+ /** This function gets called automatically when a Run is Triggered.
4185
+ * 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.
4186
+ * @param payload The payload of the event
4187
+ * @param io An object that contains the integrations that you specified in the `integrations` property and other useful functions like delays and running Tasks.
4188
+ * @param context An object that contains information about the Organization, Job, Run and more.
4189
+ */
4190
+ run: (payload: TriggerEventType<TTrigger>, io: IOWithIntegrations<TIntegrations>, context: TriggerContext) => Promise<any>;
3922
4191
  };
4192
+ /** 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. */
3923
4193
  declare class Job<TTrigger extends Trigger<EventSpecification<any>>, TIntegrations extends Record<string, TriggerIntegration<IntegrationClient<any, any>>> = {}> {
3924
4194
  #private;
3925
4195
  readonly options: JobOptions<TTrigger, TIntegrations>;
3926
4196
  client: TriggerClient;
3927
- constructor(client: TriggerClient, options: JobOptions<TTrigger, TIntegrations>);
4197
+ constructor(
4198
+ /** An instance of [TriggerClient](/sdk/triggerclient) that is used to send events
4199
+ to the Trigger API. */
4200
+ client: TriggerClient, options: JobOptions<TTrigger, TIntegrations>);
3928
4201
  get id(): string;
3929
4202
  get enabled(): boolean;
3930
4203
  get name(): string;
3931
4204
  get trigger(): TTrigger;
3932
4205
  get version(): string;
3933
4206
  get integrations(): Record<string, IntegrationConfig>;
4207
+ get logLevel(): LogLevel | undefined;
3934
4208
  toJSON(): JobMetadata;
3935
4209
  }
3936
4210
 
@@ -4066,6 +4340,12 @@ declare class RetryWithTaskError {
4066
4340
  retryAt: Date;
4067
4341
  constructor(cause: ErrorWithStack, task: ServerTask, retryAt: Date);
4068
4342
  }
4343
+ /** Use this function if you're using a `try/catch` block to catch errors.
4344
+ * It checks if a thrown error is a special internal error that you should ignore.
4345
+ * If this returns `true` then you must rethrow the error: `throw err;`
4346
+ * @param err The error to check
4347
+ * @returns `true` if the error is a Trigger Error, `false` otherwise.
4348
+ */
4069
4349
  declare function isTriggerError(err: unknown): err is ResumeWithTaskError | RetryWithTaskError;
4070
4350
 
4071
4351
  type Task = ServerTask;