@trigger.dev/sdk 2.0.0-next.7 → 2.0.0-next.9
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 +304 -158
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ declare class Logger {
|
|
|
24
24
|
|
|
25
25
|
declare const EventMatcherSchema: z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodArray<z.ZodNumber, "many">, z.ZodArray<z.ZodBoolean, "many">]>;
|
|
26
26
|
type EventMatcher = z.infer<typeof EventMatcherSchema>;
|
|
27
|
+
/** A filter for matching against data */
|
|
27
28
|
type EventFilter = {
|
|
28
29
|
[key: string]: EventMatcher | EventFilter;
|
|
29
30
|
};
|
|
@@ -1475,13 +1476,44 @@ declare const RedactStringSchema: z.ZodObject<{
|
|
|
1475
1476
|
type RedactString = z.infer<typeof RedactStringSchema>;
|
|
1476
1477
|
type CachedTask = z.infer<typeof CachedTaskSchema>;
|
|
1477
1478
|
declare const RunTaskOptionsSchema: z.ZodObject<{
|
|
1479
|
+
/** The name of the Task is required. This is displayed on the Task in the logs. */
|
|
1478
1480
|
name: z.ZodString;
|
|
1481
|
+
/** The Task will wait and only start at the specified Date */
|
|
1482
|
+
delayUntil: z.ZodOptional<z.ZodDate>;
|
|
1483
|
+
/** Retry options */
|
|
1484
|
+
retry: z.ZodOptional<z.ZodObject<{
|
|
1485
|
+
/** The maximum number of times to retry the request. */
|
|
1486
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
1487
|
+
/** The exponential factor to use when calculating the next retry time. */
|
|
1488
|
+
factor: z.ZodOptional<z.ZodNumber>;
|
|
1489
|
+
/** The minimum amount of time to wait before retrying the request. */
|
|
1490
|
+
minTimeoutInMs: z.ZodOptional<z.ZodNumber>;
|
|
1491
|
+
/** The maximum amount of time to wait before retrying the request. */
|
|
1492
|
+
maxTimeoutInMs: z.ZodOptional<z.ZodNumber>;
|
|
1493
|
+
/** Whether to randomize the retry time. */
|
|
1494
|
+
randomize: z.ZodOptional<z.ZodBoolean>;
|
|
1495
|
+
}, "strip", z.ZodTypeAny, {
|
|
1496
|
+
limit?: number | undefined;
|
|
1497
|
+
factor?: number | undefined;
|
|
1498
|
+
minTimeoutInMs?: number | undefined;
|
|
1499
|
+
maxTimeoutInMs?: number | undefined;
|
|
1500
|
+
randomize?: boolean | undefined;
|
|
1501
|
+
}, {
|
|
1502
|
+
limit?: number | undefined;
|
|
1503
|
+
factor?: number | undefined;
|
|
1504
|
+
minTimeoutInMs?: number | undefined;
|
|
1505
|
+
maxTimeoutInMs?: number | undefined;
|
|
1506
|
+
randomize?: boolean | undefined;
|
|
1507
|
+
}>>;
|
|
1508
|
+
/** The icon for the Task, it will appear in the logs.
|
|
1509
|
+
* You can use the name of a company in lowercase, e.g. "github".
|
|
1510
|
+
* Or any icon name that [Font Awesome](https://fontawesome.com/icons) supports. */
|
|
1479
1511
|
icon: z.ZodOptional<z.ZodString>;
|
|
1512
|
+
/** The key for the Task that you want to appear in the logs */
|
|
1480
1513
|
displayKey: z.ZodOptional<z.ZodString>;
|
|
1481
|
-
|
|
1482
|
-
operation: z.ZodOptional<z.ZodEnum<["fetch"]>>;
|
|
1483
|
-
delayUntil: z.ZodOptional<z.ZodDate>;
|
|
1514
|
+
/** A description of the Task */
|
|
1484
1515
|
description: z.ZodOptional<z.ZodString>;
|
|
1516
|
+
/** Properties that are displayed in the logs */
|
|
1485
1517
|
properties: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1486
1518
|
label: z.ZodString;
|
|
1487
1519
|
text: z.ZodString;
|
|
@@ -1495,7 +1527,32 @@ declare const RunTaskOptionsSchema: z.ZodObject<{
|
|
|
1495
1527
|
label: string;
|
|
1496
1528
|
text: string;
|
|
1497
1529
|
}>, "many">>;
|
|
1530
|
+
/** The input params to the Task, will be displayed in the logs */
|
|
1498
1531
|
params: z.ZodAny;
|
|
1532
|
+
/** The style of the log entry. */
|
|
1533
|
+
style: z.ZodOptional<z.ZodObject<{
|
|
1534
|
+
style: z.ZodEnum<["normal", "minimal"]>;
|
|
1535
|
+
variant: z.ZodOptional<z.ZodString>;
|
|
1536
|
+
}, "strip", z.ZodTypeAny, {
|
|
1537
|
+
variant?: string | undefined;
|
|
1538
|
+
style: "normal" | "minimal";
|
|
1539
|
+
}, {
|
|
1540
|
+
variant?: string | undefined;
|
|
1541
|
+
style: "normal" | "minimal";
|
|
1542
|
+
}>>;
|
|
1543
|
+
/** Allows you to link the Integration connection in the logs. This is handled automatically in integrations. */
|
|
1544
|
+
connectionKey: z.ZodOptional<z.ZodString>;
|
|
1545
|
+
/** 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. */
|
|
1546
|
+
operation: z.ZodOptional<z.ZodEnum<["fetch"]>>;
|
|
1547
|
+
/** 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). */
|
|
1548
|
+
noop: z.ZodDefault<z.ZodBoolean>;
|
|
1549
|
+
redact: z.ZodOptional<z.ZodObject<{
|
|
1550
|
+
paths: z.ZodArray<z.ZodString, "many">;
|
|
1551
|
+
}, "strip", z.ZodTypeAny, {
|
|
1552
|
+
paths: string[];
|
|
1553
|
+
}, {
|
|
1554
|
+
paths: string[];
|
|
1555
|
+
}>>;
|
|
1499
1556
|
trigger: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
1500
1557
|
type: z.ZodLiteral<"dynamic">;
|
|
1501
1558
|
id: z.ZodString;
|
|
@@ -1643,48 +1700,6 @@ declare const RunTaskOptionsSchema: z.ZodObject<{
|
|
|
1643
1700
|
type: "interval";
|
|
1644
1701
|
};
|
|
1645
1702
|
}>]>>;
|
|
1646
|
-
redact: z.ZodOptional<z.ZodObject<{
|
|
1647
|
-
paths: z.ZodArray<z.ZodString, "many">;
|
|
1648
|
-
}, "strip", z.ZodTypeAny, {
|
|
1649
|
-
paths: string[];
|
|
1650
|
-
}, {
|
|
1651
|
-
paths: string[];
|
|
1652
|
-
}>>;
|
|
1653
|
-
connectionKey: z.ZodOptional<z.ZodString>;
|
|
1654
|
-
style: z.ZodOptional<z.ZodObject<{
|
|
1655
|
-
style: z.ZodEnum<["normal", "minimal"]>;
|
|
1656
|
-
variant: z.ZodOptional<z.ZodString>;
|
|
1657
|
-
}, "strip", z.ZodTypeAny, {
|
|
1658
|
-
variant?: string | undefined;
|
|
1659
|
-
style: "normal" | "minimal";
|
|
1660
|
-
}, {
|
|
1661
|
-
variant?: string | undefined;
|
|
1662
|
-
style: "normal" | "minimal";
|
|
1663
|
-
}>>;
|
|
1664
|
-
retry: z.ZodOptional<z.ZodObject<{
|
|
1665
|
-
/** The maximum number of times to retry the request. */
|
|
1666
|
-
limit: z.ZodOptional<z.ZodNumber>;
|
|
1667
|
-
/** The exponential factor to use when calculating the next retry time. */
|
|
1668
|
-
factor: z.ZodOptional<z.ZodNumber>;
|
|
1669
|
-
/** The minimum amount of time to wait before retrying the request. */
|
|
1670
|
-
minTimeoutInMs: z.ZodOptional<z.ZodNumber>;
|
|
1671
|
-
/** The maximum amount of time to wait before retrying the request. */
|
|
1672
|
-
maxTimeoutInMs: z.ZodOptional<z.ZodNumber>;
|
|
1673
|
-
/** Whether to randomize the retry time. */
|
|
1674
|
-
randomize: z.ZodOptional<z.ZodBoolean>;
|
|
1675
|
-
}, "strip", z.ZodTypeAny, {
|
|
1676
|
-
limit?: number | undefined;
|
|
1677
|
-
factor?: number | undefined;
|
|
1678
|
-
minTimeoutInMs?: number | undefined;
|
|
1679
|
-
maxTimeoutInMs?: number | undefined;
|
|
1680
|
-
randomize?: boolean | undefined;
|
|
1681
|
-
}, {
|
|
1682
|
-
limit?: number | undefined;
|
|
1683
|
-
factor?: number | undefined;
|
|
1684
|
-
minTimeoutInMs?: number | undefined;
|
|
1685
|
-
maxTimeoutInMs?: number | undefined;
|
|
1686
|
-
randomize?: boolean | undefined;
|
|
1687
|
-
}>>;
|
|
1688
1703
|
}, "strip", z.ZodTypeAny, {
|
|
1689
1704
|
icon?: string | undefined;
|
|
1690
1705
|
delayUntil?: Date | undefined;
|
|
@@ -1733,11 +1748,6 @@ declare const RunTaskOptionsSchema: z.ZodObject<{
|
|
|
1733
1748
|
type: "interval";
|
|
1734
1749
|
};
|
|
1735
1750
|
} | undefined;
|
|
1736
|
-
displayKey?: string | undefined;
|
|
1737
|
-
redact?: {
|
|
1738
|
-
paths: string[];
|
|
1739
|
-
} | undefined;
|
|
1740
|
-
connectionKey?: string | undefined;
|
|
1741
1751
|
retry?: {
|
|
1742
1752
|
limit?: number | undefined;
|
|
1743
1753
|
factor?: number | undefined;
|
|
@@ -1745,6 +1755,11 @@ declare const RunTaskOptionsSchema: z.ZodObject<{
|
|
|
1745
1755
|
maxTimeoutInMs?: number | undefined;
|
|
1746
1756
|
randomize?: boolean | undefined;
|
|
1747
1757
|
} | undefined;
|
|
1758
|
+
displayKey?: string | undefined;
|
|
1759
|
+
connectionKey?: string | undefined;
|
|
1760
|
+
redact?: {
|
|
1761
|
+
paths: string[];
|
|
1762
|
+
} | undefined;
|
|
1748
1763
|
name: string;
|
|
1749
1764
|
noop: boolean;
|
|
1750
1765
|
}, {
|
|
@@ -1796,11 +1811,6 @@ declare const RunTaskOptionsSchema: z.ZodObject<{
|
|
|
1796
1811
|
type: "interval";
|
|
1797
1812
|
};
|
|
1798
1813
|
} | undefined;
|
|
1799
|
-
displayKey?: string | undefined;
|
|
1800
|
-
redact?: {
|
|
1801
|
-
paths: string[];
|
|
1802
|
-
} | undefined;
|
|
1803
|
-
connectionKey?: string | undefined;
|
|
1804
1814
|
retry?: {
|
|
1805
1815
|
limit?: number | undefined;
|
|
1806
1816
|
factor?: number | undefined;
|
|
@@ -1808,17 +1818,53 @@ declare const RunTaskOptionsSchema: z.ZodObject<{
|
|
|
1808
1818
|
maxTimeoutInMs?: number | undefined;
|
|
1809
1819
|
randomize?: boolean | undefined;
|
|
1810
1820
|
} | undefined;
|
|
1821
|
+
displayKey?: string | undefined;
|
|
1822
|
+
connectionKey?: string | undefined;
|
|
1823
|
+
redact?: {
|
|
1824
|
+
paths: string[];
|
|
1825
|
+
} | undefined;
|
|
1811
1826
|
name: string;
|
|
1812
1827
|
}>;
|
|
1813
1828
|
type RunTaskOptions = z.input<typeof RunTaskOptionsSchema>;
|
|
1814
1829
|
declare const RunTaskBodyInputSchema: z.ZodObject<z.extendShape<{
|
|
1830
|
+
/** The name of the Task is required. This is displayed on the Task in the logs. */
|
|
1815
1831
|
name: z.ZodString;
|
|
1832
|
+
/** The Task will wait and only start at the specified Date */
|
|
1833
|
+
delayUntil: z.ZodOptional<z.ZodDate>;
|
|
1834
|
+
/** Retry options */
|
|
1835
|
+
retry: z.ZodOptional<z.ZodObject<{
|
|
1836
|
+
/** The maximum number of times to retry the request. */
|
|
1837
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
1838
|
+
/** The exponential factor to use when calculating the next retry time. */
|
|
1839
|
+
factor: z.ZodOptional<z.ZodNumber>;
|
|
1840
|
+
/** The minimum amount of time to wait before retrying the request. */
|
|
1841
|
+
minTimeoutInMs: z.ZodOptional<z.ZodNumber>;
|
|
1842
|
+
/** The maximum amount of time to wait before retrying the request. */
|
|
1843
|
+
maxTimeoutInMs: z.ZodOptional<z.ZodNumber>;
|
|
1844
|
+
/** Whether to randomize the retry time. */
|
|
1845
|
+
randomize: z.ZodOptional<z.ZodBoolean>;
|
|
1846
|
+
}, "strip", z.ZodTypeAny, {
|
|
1847
|
+
limit?: number | undefined;
|
|
1848
|
+
factor?: number | undefined;
|
|
1849
|
+
minTimeoutInMs?: number | undefined;
|
|
1850
|
+
maxTimeoutInMs?: number | undefined;
|
|
1851
|
+
randomize?: boolean | undefined;
|
|
1852
|
+
}, {
|
|
1853
|
+
limit?: number | undefined;
|
|
1854
|
+
factor?: number | undefined;
|
|
1855
|
+
minTimeoutInMs?: number | undefined;
|
|
1856
|
+
maxTimeoutInMs?: number | undefined;
|
|
1857
|
+
randomize?: boolean | undefined;
|
|
1858
|
+
}>>;
|
|
1859
|
+
/** The icon for the Task, it will appear in the logs.
|
|
1860
|
+
* You can use the name of a company in lowercase, e.g. "github".
|
|
1861
|
+
* Or any icon name that [Font Awesome](https://fontawesome.com/icons) supports. */
|
|
1816
1862
|
icon: z.ZodOptional<z.ZodString>;
|
|
1863
|
+
/** The key for the Task that you want to appear in the logs */
|
|
1817
1864
|
displayKey: z.ZodOptional<z.ZodString>;
|
|
1818
|
-
|
|
1819
|
-
operation: z.ZodOptional<z.ZodEnum<["fetch"]>>;
|
|
1820
|
-
delayUntil: z.ZodOptional<z.ZodDate>;
|
|
1865
|
+
/** A description of the Task */
|
|
1821
1866
|
description: z.ZodOptional<z.ZodString>;
|
|
1867
|
+
/** Properties that are displayed in the logs */
|
|
1822
1868
|
properties: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1823
1869
|
label: z.ZodString;
|
|
1824
1870
|
text: z.ZodString;
|
|
@@ -1832,7 +1878,32 @@ declare const RunTaskBodyInputSchema: z.ZodObject<z.extendShape<{
|
|
|
1832
1878
|
label: string;
|
|
1833
1879
|
text: string;
|
|
1834
1880
|
}>, "many">>;
|
|
1881
|
+
/** The input params to the Task, will be displayed in the logs */
|
|
1835
1882
|
params: z.ZodAny;
|
|
1883
|
+
/** The style of the log entry. */
|
|
1884
|
+
style: z.ZodOptional<z.ZodObject<{
|
|
1885
|
+
style: z.ZodEnum<["normal", "minimal"]>;
|
|
1886
|
+
variant: z.ZodOptional<z.ZodString>;
|
|
1887
|
+
}, "strip", z.ZodTypeAny, {
|
|
1888
|
+
variant?: string | undefined;
|
|
1889
|
+
style: "normal" | "minimal";
|
|
1890
|
+
}, {
|
|
1891
|
+
variant?: string | undefined;
|
|
1892
|
+
style: "normal" | "minimal";
|
|
1893
|
+
}>>;
|
|
1894
|
+
/** Allows you to link the Integration connection in the logs. This is handled automatically in integrations. */
|
|
1895
|
+
connectionKey: z.ZodOptional<z.ZodString>;
|
|
1896
|
+
/** 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. */
|
|
1897
|
+
operation: z.ZodOptional<z.ZodEnum<["fetch"]>>;
|
|
1898
|
+
/** 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). */
|
|
1899
|
+
noop: z.ZodDefault<z.ZodBoolean>;
|
|
1900
|
+
redact: z.ZodOptional<z.ZodObject<{
|
|
1901
|
+
paths: z.ZodArray<z.ZodString, "many">;
|
|
1902
|
+
}, "strip", z.ZodTypeAny, {
|
|
1903
|
+
paths: string[];
|
|
1904
|
+
}, {
|
|
1905
|
+
paths: string[];
|
|
1906
|
+
}>>;
|
|
1836
1907
|
trigger: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
1837
1908
|
type: z.ZodLiteral<"dynamic">;
|
|
1838
1909
|
id: z.ZodString;
|
|
@@ -1980,48 +2051,6 @@ declare const RunTaskBodyInputSchema: z.ZodObject<z.extendShape<{
|
|
|
1980
2051
|
type: "interval";
|
|
1981
2052
|
};
|
|
1982
2053
|
}>]>>;
|
|
1983
|
-
redact: z.ZodOptional<z.ZodObject<{
|
|
1984
|
-
paths: z.ZodArray<z.ZodString, "many">;
|
|
1985
|
-
}, "strip", z.ZodTypeAny, {
|
|
1986
|
-
paths: string[];
|
|
1987
|
-
}, {
|
|
1988
|
-
paths: string[];
|
|
1989
|
-
}>>;
|
|
1990
|
-
connectionKey: z.ZodOptional<z.ZodString>;
|
|
1991
|
-
style: z.ZodOptional<z.ZodObject<{
|
|
1992
|
-
style: z.ZodEnum<["normal", "minimal"]>;
|
|
1993
|
-
variant: z.ZodOptional<z.ZodString>;
|
|
1994
|
-
}, "strip", z.ZodTypeAny, {
|
|
1995
|
-
variant?: string | undefined;
|
|
1996
|
-
style: "normal" | "minimal";
|
|
1997
|
-
}, {
|
|
1998
|
-
variant?: string | undefined;
|
|
1999
|
-
style: "normal" | "minimal";
|
|
2000
|
-
}>>;
|
|
2001
|
-
retry: z.ZodOptional<z.ZodObject<{
|
|
2002
|
-
/** The maximum number of times to retry the request. */
|
|
2003
|
-
limit: z.ZodOptional<z.ZodNumber>;
|
|
2004
|
-
/** The exponential factor to use when calculating the next retry time. */
|
|
2005
|
-
factor: z.ZodOptional<z.ZodNumber>;
|
|
2006
|
-
/** The minimum amount of time to wait before retrying the request. */
|
|
2007
|
-
minTimeoutInMs: z.ZodOptional<z.ZodNumber>;
|
|
2008
|
-
/** The maximum amount of time to wait before retrying the request. */
|
|
2009
|
-
maxTimeoutInMs: z.ZodOptional<z.ZodNumber>;
|
|
2010
|
-
/** Whether to randomize the retry time. */
|
|
2011
|
-
randomize: z.ZodOptional<z.ZodBoolean>;
|
|
2012
|
-
}, "strip", z.ZodTypeAny, {
|
|
2013
|
-
limit?: number | undefined;
|
|
2014
|
-
factor?: number | undefined;
|
|
2015
|
-
minTimeoutInMs?: number | undefined;
|
|
2016
|
-
maxTimeoutInMs?: number | undefined;
|
|
2017
|
-
randomize?: boolean | undefined;
|
|
2018
|
-
}, {
|
|
2019
|
-
limit?: number | undefined;
|
|
2020
|
-
factor?: number | undefined;
|
|
2021
|
-
minTimeoutInMs?: number | undefined;
|
|
2022
|
-
maxTimeoutInMs?: number | undefined;
|
|
2023
|
-
randomize?: boolean | undefined;
|
|
2024
|
-
}>>;
|
|
2025
2054
|
}, {
|
|
2026
2055
|
idempotencyKey: z.ZodString;
|
|
2027
2056
|
parentId: z.ZodOptional<z.ZodString>;
|
|
@@ -2074,11 +2103,6 @@ declare const RunTaskBodyInputSchema: z.ZodObject<z.extendShape<{
|
|
|
2074
2103
|
type: "interval";
|
|
2075
2104
|
};
|
|
2076
2105
|
} | undefined;
|
|
2077
|
-
displayKey?: string | undefined;
|
|
2078
|
-
redact?: {
|
|
2079
|
-
paths: string[];
|
|
2080
|
-
} | undefined;
|
|
2081
|
-
connectionKey?: string | undefined;
|
|
2082
2106
|
retry?: {
|
|
2083
2107
|
limit?: number | undefined;
|
|
2084
2108
|
factor?: number | undefined;
|
|
@@ -2086,6 +2110,11 @@ declare const RunTaskBodyInputSchema: z.ZodObject<z.extendShape<{
|
|
|
2086
2110
|
maxTimeoutInMs?: number | undefined;
|
|
2087
2111
|
randomize?: boolean | undefined;
|
|
2088
2112
|
} | undefined;
|
|
2113
|
+
displayKey?: string | undefined;
|
|
2114
|
+
connectionKey?: string | undefined;
|
|
2115
|
+
redact?: {
|
|
2116
|
+
paths: string[];
|
|
2117
|
+
} | undefined;
|
|
2089
2118
|
name: string;
|
|
2090
2119
|
noop: boolean;
|
|
2091
2120
|
idempotencyKey: string;
|
|
@@ -2139,11 +2168,6 @@ declare const RunTaskBodyInputSchema: z.ZodObject<z.extendShape<{
|
|
|
2139
2168
|
type: "interval";
|
|
2140
2169
|
};
|
|
2141
2170
|
} | undefined;
|
|
2142
|
-
displayKey?: string | undefined;
|
|
2143
|
-
redact?: {
|
|
2144
|
-
paths: string[];
|
|
2145
|
-
} | undefined;
|
|
2146
|
-
connectionKey?: string | undefined;
|
|
2147
2171
|
retry?: {
|
|
2148
2172
|
limit?: number | undefined;
|
|
2149
2173
|
factor?: number | undefined;
|
|
@@ -2151,18 +2175,54 @@ declare const RunTaskBodyInputSchema: z.ZodObject<z.extendShape<{
|
|
|
2151
2175
|
maxTimeoutInMs?: number | undefined;
|
|
2152
2176
|
randomize?: boolean | undefined;
|
|
2153
2177
|
} | undefined;
|
|
2178
|
+
displayKey?: string | undefined;
|
|
2179
|
+
connectionKey?: string | undefined;
|
|
2180
|
+
redact?: {
|
|
2181
|
+
paths: string[];
|
|
2182
|
+
} | undefined;
|
|
2154
2183
|
name: string;
|
|
2155
2184
|
idempotencyKey: string;
|
|
2156
2185
|
}>;
|
|
2157
2186
|
type RunTaskBodyInput = z.infer<typeof RunTaskBodyInputSchema>;
|
|
2158
2187
|
declare const CompleteTaskBodyInputSchema: z.ZodObject<z.extendShape<Pick<z.extendShape<{
|
|
2188
|
+
/** The name of the Task is required. This is displayed on the Task in the logs. */
|
|
2159
2189
|
name: z.ZodString;
|
|
2190
|
+
/** The Task will wait and only start at the specified Date */
|
|
2191
|
+
delayUntil: z.ZodOptional<z.ZodDate>;
|
|
2192
|
+
/** Retry options */
|
|
2193
|
+
retry: z.ZodOptional<z.ZodObject<{
|
|
2194
|
+
/** The maximum number of times to retry the request. */
|
|
2195
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
2196
|
+
/** The exponential factor to use when calculating the next retry time. */
|
|
2197
|
+
factor: z.ZodOptional<z.ZodNumber>;
|
|
2198
|
+
/** The minimum amount of time to wait before retrying the request. */
|
|
2199
|
+
minTimeoutInMs: z.ZodOptional<z.ZodNumber>;
|
|
2200
|
+
/** The maximum amount of time to wait before retrying the request. */
|
|
2201
|
+
maxTimeoutInMs: z.ZodOptional<z.ZodNumber>;
|
|
2202
|
+
/** Whether to randomize the retry time. */
|
|
2203
|
+
randomize: z.ZodOptional<z.ZodBoolean>;
|
|
2204
|
+
}, "strip", z.ZodTypeAny, {
|
|
2205
|
+
limit?: number | undefined;
|
|
2206
|
+
factor?: number | undefined;
|
|
2207
|
+
minTimeoutInMs?: number | undefined;
|
|
2208
|
+
maxTimeoutInMs?: number | undefined;
|
|
2209
|
+
randomize?: boolean | undefined;
|
|
2210
|
+
}, {
|
|
2211
|
+
limit?: number | undefined;
|
|
2212
|
+
factor?: number | undefined;
|
|
2213
|
+
minTimeoutInMs?: number | undefined;
|
|
2214
|
+
maxTimeoutInMs?: number | undefined;
|
|
2215
|
+
randomize?: boolean | undefined;
|
|
2216
|
+
}>>;
|
|
2217
|
+
/** The icon for the Task, it will appear in the logs.
|
|
2218
|
+
* You can use the name of a company in lowercase, e.g. "github".
|
|
2219
|
+
* Or any icon name that [Font Awesome](https://fontawesome.com/icons) supports. */
|
|
2160
2220
|
icon: z.ZodOptional<z.ZodString>;
|
|
2221
|
+
/** The key for the Task that you want to appear in the logs */
|
|
2161
2222
|
displayKey: z.ZodOptional<z.ZodString>;
|
|
2162
|
-
|
|
2163
|
-
operation: z.ZodOptional<z.ZodEnum<["fetch"]>>;
|
|
2164
|
-
delayUntil: z.ZodOptional<z.ZodDate>;
|
|
2223
|
+
/** A description of the Task */
|
|
2165
2224
|
description: z.ZodOptional<z.ZodString>;
|
|
2225
|
+
/** Properties that are displayed in the logs */
|
|
2166
2226
|
properties: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
2167
2227
|
label: z.ZodString;
|
|
2168
2228
|
text: z.ZodString;
|
|
@@ -2176,7 +2236,32 @@ declare const CompleteTaskBodyInputSchema: z.ZodObject<z.extendShape<Pick<z.exte
|
|
|
2176
2236
|
label: string;
|
|
2177
2237
|
text: string;
|
|
2178
2238
|
}>, "many">>;
|
|
2239
|
+
/** The input params to the Task, will be displayed in the logs */
|
|
2179
2240
|
params: z.ZodAny;
|
|
2241
|
+
/** The style of the log entry. */
|
|
2242
|
+
style: z.ZodOptional<z.ZodObject<{
|
|
2243
|
+
style: z.ZodEnum<["normal", "minimal"]>;
|
|
2244
|
+
variant: z.ZodOptional<z.ZodString>;
|
|
2245
|
+
}, "strip", z.ZodTypeAny, {
|
|
2246
|
+
variant?: string | undefined;
|
|
2247
|
+
style: "normal" | "minimal";
|
|
2248
|
+
}, {
|
|
2249
|
+
variant?: string | undefined;
|
|
2250
|
+
style: "normal" | "minimal";
|
|
2251
|
+
}>>;
|
|
2252
|
+
/** Allows you to link the Integration connection in the logs. This is handled automatically in integrations. */
|
|
2253
|
+
connectionKey: z.ZodOptional<z.ZodString>;
|
|
2254
|
+
/** 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. */
|
|
2255
|
+
operation: z.ZodOptional<z.ZodEnum<["fetch"]>>;
|
|
2256
|
+
/** 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). */
|
|
2257
|
+
noop: z.ZodDefault<z.ZodBoolean>;
|
|
2258
|
+
redact: z.ZodOptional<z.ZodObject<{
|
|
2259
|
+
paths: z.ZodArray<z.ZodString, "many">;
|
|
2260
|
+
}, "strip", z.ZodTypeAny, {
|
|
2261
|
+
paths: string[];
|
|
2262
|
+
}, {
|
|
2263
|
+
paths: string[];
|
|
2264
|
+
}>>;
|
|
2180
2265
|
trigger: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
2181
2266
|
type: z.ZodLiteral<"dynamic">;
|
|
2182
2267
|
id: z.ZodString;
|
|
@@ -2324,48 +2409,6 @@ declare const CompleteTaskBodyInputSchema: z.ZodObject<z.extendShape<Pick<z.exte
|
|
|
2324
2409
|
type: "interval";
|
|
2325
2410
|
};
|
|
2326
2411
|
}>]>>;
|
|
2327
|
-
redact: z.ZodOptional<z.ZodObject<{
|
|
2328
|
-
paths: z.ZodArray<z.ZodString, "many">;
|
|
2329
|
-
}, "strip", z.ZodTypeAny, {
|
|
2330
|
-
paths: string[];
|
|
2331
|
-
}, {
|
|
2332
|
-
paths: string[];
|
|
2333
|
-
}>>;
|
|
2334
|
-
connectionKey: z.ZodOptional<z.ZodString>;
|
|
2335
|
-
style: z.ZodOptional<z.ZodObject<{
|
|
2336
|
-
style: z.ZodEnum<["normal", "minimal"]>;
|
|
2337
|
-
variant: z.ZodOptional<z.ZodString>;
|
|
2338
|
-
}, "strip", z.ZodTypeAny, {
|
|
2339
|
-
variant?: string | undefined;
|
|
2340
|
-
style: "normal" | "minimal";
|
|
2341
|
-
}, {
|
|
2342
|
-
variant?: string | undefined;
|
|
2343
|
-
style: "normal" | "minimal";
|
|
2344
|
-
}>>;
|
|
2345
|
-
retry: z.ZodOptional<z.ZodObject<{
|
|
2346
|
-
/** The maximum number of times to retry the request. */
|
|
2347
|
-
limit: z.ZodOptional<z.ZodNumber>;
|
|
2348
|
-
/** The exponential factor to use when calculating the next retry time. */
|
|
2349
|
-
factor: z.ZodOptional<z.ZodNumber>;
|
|
2350
|
-
/** The minimum amount of time to wait before retrying the request. */
|
|
2351
|
-
minTimeoutInMs: z.ZodOptional<z.ZodNumber>;
|
|
2352
|
-
/** The maximum amount of time to wait before retrying the request. */
|
|
2353
|
-
maxTimeoutInMs: z.ZodOptional<z.ZodNumber>;
|
|
2354
|
-
/** Whether to randomize the retry time. */
|
|
2355
|
-
randomize: z.ZodOptional<z.ZodBoolean>;
|
|
2356
|
-
}, "strip", z.ZodTypeAny, {
|
|
2357
|
-
limit?: number | undefined;
|
|
2358
|
-
factor?: number | undefined;
|
|
2359
|
-
minTimeoutInMs?: number | undefined;
|
|
2360
|
-
maxTimeoutInMs?: number | undefined;
|
|
2361
|
-
randomize?: boolean | undefined;
|
|
2362
|
-
}, {
|
|
2363
|
-
limit?: number | undefined;
|
|
2364
|
-
factor?: number | undefined;
|
|
2365
|
-
minTimeoutInMs?: number | undefined;
|
|
2366
|
-
maxTimeoutInMs?: number | undefined;
|
|
2367
|
-
randomize?: boolean | undefined;
|
|
2368
|
-
}>>;
|
|
2369
2412
|
}, {
|
|
2370
2413
|
idempotencyKey: z.ZodString;
|
|
2371
2414
|
parentId: z.ZodOptional<z.ZodString>;
|
|
@@ -2752,9 +2795,13 @@ declare const ErrorWithStackSchema: z.ZodObject<{
|
|
|
2752
2795
|
}>;
|
|
2753
2796
|
type ErrorWithStack = z.infer<typeof ErrorWithStackSchema>;
|
|
2754
2797
|
|
|
2798
|
+
/** A property that is displayed in the logs */
|
|
2755
2799
|
declare const DisplayPropertySchema: z.ZodObject<{
|
|
2800
|
+
/** The label for the property */
|
|
2756
2801
|
label: z.ZodString;
|
|
2802
|
+
/** The value of the property */
|
|
2757
2803
|
text: z.ZodString;
|
|
2804
|
+
/** The URL to link to when the property is clicked */
|
|
2758
2805
|
url: z.ZodOptional<z.ZodString>;
|
|
2759
2806
|
}, "strip", z.ZodTypeAny, {
|
|
2760
2807
|
url?: string | undefined;
|
|
@@ -2845,14 +2892,19 @@ declare const ScheduledPayloadSchema: z.ZodObject<{
|
|
|
2845
2892
|
}>;
|
|
2846
2893
|
type ScheduledPayload = z.infer<typeof ScheduledPayloadSchema>;
|
|
2847
2894
|
declare const IntervalOptionsSchema: z.ZodObject<{
|
|
2895
|
+
/** The number of seconds for the interval. Min = 60, Max = 86400 (1 day) */
|
|
2848
2896
|
seconds: z.ZodNumber;
|
|
2849
2897
|
}, "strip", z.ZodTypeAny, {
|
|
2850
2898
|
seconds: number;
|
|
2851
2899
|
}, {
|
|
2852
2900
|
seconds: number;
|
|
2853
2901
|
}>;
|
|
2902
|
+
/** Interval options */
|
|
2854
2903
|
type IntervalOptions = z.infer<typeof IntervalOptionsSchema>;
|
|
2855
2904
|
declare const CronOptionsSchema: z.ZodObject<{
|
|
2905
|
+
/** A CRON expression that defines the schedule. A useful tool when writing CRON
|
|
2906
|
+
expressions is [crontab guru](https://crontab.guru). Note that the timezone
|
|
2907
|
+
used is UTC. */
|
|
2856
2908
|
cron: z.ZodString;
|
|
2857
2909
|
}, "strip", z.ZodTypeAny, {
|
|
2858
2910
|
cron: string;
|
|
@@ -2861,14 +2913,18 @@ declare const CronOptionsSchema: z.ZodObject<{
|
|
|
2861
2913
|
}>;
|
|
2862
2914
|
type CronOptions = z.infer<typeof CronOptionsSchema>;
|
|
2863
2915
|
declare const ScheduleMetadataSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
2916
|
+
/** An interval reoccurs at the specified number of seconds */
|
|
2864
2917
|
type: z.ZodLiteral<"interval">;
|
|
2918
|
+
/** An object containing options about the interval. */
|
|
2865
2919
|
options: z.ZodObject<{
|
|
2920
|
+
/** The number of seconds for the interval. Min = 60, Max = 86400 (1 day) */
|
|
2866
2921
|
seconds: z.ZodNumber;
|
|
2867
2922
|
}, "strip", z.ZodTypeAny, {
|
|
2868
2923
|
seconds: number;
|
|
2869
2924
|
}, {
|
|
2870
2925
|
seconds: number;
|
|
2871
2926
|
}>;
|
|
2927
|
+
/** Any additional metadata about the schedule. */
|
|
2872
2928
|
metadata: z.ZodAny;
|
|
2873
2929
|
}, "strip", z.ZodTypeAny, {
|
|
2874
2930
|
metadata?: any;
|
|
@@ -2885,6 +2941,9 @@ declare const ScheduleMetadataSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
2885
2941
|
}>, z.ZodObject<{
|
|
2886
2942
|
type: z.ZodLiteral<"cron">;
|
|
2887
2943
|
options: z.ZodObject<{
|
|
2944
|
+
/** A CRON expression that defines the schedule. A useful tool when writing CRON
|
|
2945
|
+
expressions is [crontab guru](https://crontab.guru). Note that the timezone
|
|
2946
|
+
used is UTC. */
|
|
2888
2947
|
cron: z.ZodString;
|
|
2889
2948
|
}, "strip", z.ZodTypeAny, {
|
|
2890
2949
|
cron: string;
|
|
@@ -3393,36 +3452,43 @@ declare class ApiClient {
|
|
|
3393
3452
|
}
|
|
3394
3453
|
|
|
3395
3454
|
interface TriggerContext {
|
|
3455
|
+
/** Job metadata */
|
|
3396
3456
|
job: {
|
|
3397
3457
|
id: string;
|
|
3398
3458
|
version: string;
|
|
3399
3459
|
};
|
|
3460
|
+
/** Environment metadata */
|
|
3400
3461
|
environment: {
|
|
3401
3462
|
slug: string;
|
|
3402
3463
|
id: string;
|
|
3403
3464
|
type: RuntimeEnvironmentType;
|
|
3404
3465
|
};
|
|
3466
|
+
/** Organization metadata */
|
|
3405
3467
|
organization: {
|
|
3406
3468
|
slug: string;
|
|
3407
3469
|
id: string;
|
|
3408
3470
|
title: string;
|
|
3409
3471
|
};
|
|
3472
|
+
/** Run metadata */
|
|
3410
3473
|
run: {
|
|
3411
3474
|
id: string;
|
|
3412
3475
|
isTest: boolean;
|
|
3413
3476
|
startedAt: Date;
|
|
3414
3477
|
};
|
|
3478
|
+
/** Event metadata */
|
|
3415
3479
|
event: {
|
|
3416
3480
|
id: string;
|
|
3417
3481
|
name: string;
|
|
3418
3482
|
context: any;
|
|
3419
3483
|
timestamp: Date;
|
|
3420
3484
|
};
|
|
3421
|
-
|
|
3485
|
+
/** Source metadata */
|
|
3486
|
+
source?: {
|
|
3422
3487
|
id: string;
|
|
3423
3488
|
metadata?: any;
|
|
3424
3489
|
};
|
|
3425
|
-
|
|
3490
|
+
/** Account metadata */
|
|
3491
|
+
account?: {
|
|
3426
3492
|
id: string;
|
|
3427
3493
|
metadata?: any;
|
|
3428
3494
|
};
|
|
@@ -3703,7 +3769,10 @@ declare class TriggerClient {
|
|
|
3703
3769
|
type: "oauth2";
|
|
3704
3770
|
accessToken: string;
|
|
3705
3771
|
} | undefined>;
|
|
3706
|
-
/** 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()` from inside a `run()` function.
|
|
3772
|
+
/** 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.
|
|
3773
|
+
* @param event The event to send.
|
|
3774
|
+
* @param options Options for sending the event.
|
|
3775
|
+
* @returns A promise that resolves to the event details
|
|
3707
3776
|
*/
|
|
3708
3777
|
sendEvent(event: SendEvent, options?: SendEventOptions): Promise<{
|
|
3709
3778
|
context?: DeserializedJson | undefined;
|
|
@@ -3918,6 +3987,13 @@ declare class IO {
|
|
|
3918
3987
|
id: string;
|
|
3919
3988
|
key: string;
|
|
3920
3989
|
}>;
|
|
3990
|
+
/** `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.
|
|
3991
|
+
* @param key Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
|
|
3992
|
+
* @param dynamicSchedule The [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) to register a new schedule on.
|
|
3993
|
+
* @param id A unique id for the interval. This is used to identify and unregister the interval later.
|
|
3994
|
+
* @param options The options for the interval.
|
|
3995
|
+
* @returns A promise that has information about the interval.
|
|
3996
|
+
*/
|
|
3921
3997
|
registerInterval(key: string | any[], dynamicSchedule: DynamicSchedule, id: string, options: IntervalOptions): Promise<{
|
|
3922
3998
|
metadata?: any;
|
|
3923
3999
|
id: string;
|
|
@@ -3936,9 +4012,20 @@ declare class IO {
|
|
|
3936
4012
|
};
|
|
3937
4013
|
active: boolean;
|
|
3938
4014
|
}>;
|
|
4015
|
+
/** `io.unregisterInterval()` allows you to unregister a [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) that was previously registered with `io.registerInterval()`.
|
|
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 unregister a schedule on.
|
|
4018
|
+
* @param id A unique id for the interval. This is used to identify and unregister the interval later.
|
|
4019
|
+
*/
|
|
3939
4020
|
unregisterInterval(key: string | any[], dynamicSchedule: DynamicSchedule, id: string): Promise<{
|
|
3940
4021
|
ok: boolean;
|
|
3941
4022
|
}>;
|
|
4023
|
+
/** `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.
|
|
4024
|
+
* @param key Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
|
|
4025
|
+
* @param dynamicSchedule The [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) to register a new schedule on.
|
|
4026
|
+
* @param id A unique id for the schedule. This is used to identify and unregister the schedule later.
|
|
4027
|
+
* @param options The options for the CRON schedule.
|
|
4028
|
+
*/
|
|
3942
4029
|
registerCron(key: string | any[], dynamicSchedule: DynamicSchedule, id: string, options: CronOptions): Promise<{
|
|
3943
4030
|
metadata?: any;
|
|
3944
4031
|
id: string;
|
|
@@ -3957,19 +4044,44 @@ declare class IO {
|
|
|
3957
4044
|
};
|
|
3958
4045
|
active: boolean;
|
|
3959
4046
|
}>;
|
|
4047
|
+
/** `io.unregisterCron()` allows you to unregister a [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) that was previously registered with `io.registerCron()`.
|
|
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 dynamicSchedule The [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) to unregister a schedule on.
|
|
4050
|
+
* @param id A unique id for the interval. This is used to identify and unregister the interval later.
|
|
4051
|
+
*/
|
|
3960
4052
|
unregisterCron(key: string | any[], dynamicSchedule: DynamicSchedule, id: string): Promise<{
|
|
3961
4053
|
ok: boolean;
|
|
3962
4054
|
}>;
|
|
4055
|
+
/** `io.registerTrigger()` allows you to register a [DynamicTrigger](https://trigger.dev/docs/sdk/dynamictrigger) with the specified trigger params.
|
|
4056
|
+
* @param key Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
|
|
4057
|
+
* @param trigger The [DynamicTrigger](https://trigger.dev/docs/sdk/dynamictrigger) to register.
|
|
4058
|
+
* @param id A unique id for the trigger. This is used to identify and unregister the trigger later.
|
|
4059
|
+
* @param params The params for the trigger.
|
|
4060
|
+
*/
|
|
3963
4061
|
registerTrigger<TTrigger extends DynamicTrigger<EventSpecification<any>, ExternalSource<any, any, any>>>(key: string | any[], trigger: TTrigger, id: string, params: ExternalSourceParams<TTrigger["source"]>): Promise<{
|
|
3964
4062
|
id: string;
|
|
3965
4063
|
key: string;
|
|
3966
4064
|
} | undefined>;
|
|
3967
4065
|
getAuth(key: string | any[], clientId?: string): Promise<ConnectionAuth | undefined>;
|
|
4066
|
+
/** `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.
|
|
4067
|
+
*
|
|
4068
|
+
* @param key Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
|
|
4069
|
+
* @param options The options of how you'd like to run and log the Task. Name is required.
|
|
4070
|
+
* @param callback The callback that will be called when the Task is run. The callback receives the Task and the IO as parameters.
|
|
4071
|
+
= * @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.
|
|
4072
|
+
* @returns A Promise that resolves with the returned value of the callback.
|
|
4073
|
+
*/
|
|
3968
4074
|
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) => {
|
|
3969
4075
|
retryAt: Date;
|
|
3970
4076
|
error?: Error;
|
|
3971
4077
|
jitter?: number;
|
|
3972
4078
|
} | undefined | void): Promise<TResult>;
|
|
4079
|
+
/** `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).
|
|
4080
|
+
* 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.
|
|
4081
|
+
* @param tryCallback The code you wish to run
|
|
4082
|
+
* @param catchCallback Thhis will be called if the Task fails. The callback receives the error
|
|
4083
|
+
* @returns A Promise that resolves with the returned value or the error
|
|
4084
|
+
*/
|
|
3973
4085
|
try<TResult, TCatchResult>(tryCallback: () => Promise<TResult>, catchCallback: (error: unknown) => Promise<TCatchResult>): Promise<TResult | TCatchResult>;
|
|
3974
4086
|
}
|
|
3975
4087
|
type CallbackFunction = (level: "DEBUG" | "INFO" | "WARN" | "ERROR" | "LOG", message: string, properties?: Record<string, any>) => Promise<void>;
|
|
@@ -4118,12 +4230,40 @@ declare class EventTrigger<TEventSpecification extends EventSpecification<any>>
|
|
|
4118
4230
|
attachToJob(triggerClient: TriggerClient, job: Job<Trigger<TEventSpecification>, any>): void;
|
|
4119
4231
|
get preprocessRuns(): boolean;
|
|
4120
4232
|
}
|
|
4233
|
+
/** Configuration options for an EventTrigger */
|
|
4121
4234
|
type TriggerOptions<TEvent> = {
|
|
4235
|
+
/** The name of the event you are subscribing to. Must be an exact match (case sensitive). */
|
|
4122
4236
|
name: string;
|
|
4237
|
+
/** A [Zod](https://trigger.dev/docs/documentation/guides/zod) schema that defines the shape of the event payload.
|
|
4238
|
+
* The default is `z.any()` which is `any`.
|
|
4239
|
+
* */
|
|
4123
4240
|
schema?: z.Schema<TEvent>;
|
|
4241
|
+
/** You can use this to filter events based on the source. */
|
|
4124
4242
|
source?: string;
|
|
4243
|
+
/** Used to filter which events trigger the Job
|
|
4244
|
+
* @example
|
|
4245
|
+
* filter:
|
|
4246
|
+
* ```ts
|
|
4247
|
+
* {
|
|
4248
|
+
* name: ["John", "Jane"],
|
|
4249
|
+
* age: [18, 21]
|
|
4250
|
+
* }
|
|
4251
|
+
* ```
|
|
4252
|
+
*
|
|
4253
|
+
* This filter would match against an event with the following data:
|
|
4254
|
+
* ```json
|
|
4255
|
+
* {
|
|
4256
|
+
* "name": "Jane",
|
|
4257
|
+
* "age": 18,
|
|
4258
|
+
* "location": "San Francisco"
|
|
4259
|
+
* }
|
|
4260
|
+
* ```
|
|
4261
|
+
*/
|
|
4125
4262
|
filter?: EventFilter;
|
|
4126
4263
|
};
|
|
4264
|
+
/** `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)
|
|
4265
|
+
* @param options options for the EventTrigger
|
|
4266
|
+
*/
|
|
4127
4267
|
declare function eventTrigger<TEvent extends any = any>(options: TriggerOptions<TEvent>): Trigger<EventSpecification<TEvent>>;
|
|
4128
4268
|
|
|
4129
4269
|
declare function missingConnectionNotification(integrations: Array<TriggerIntegration>): MissingConnectionNotification;
|
|
@@ -4236,6 +4376,12 @@ declare class RetryWithTaskError {
|
|
|
4236
4376
|
retryAt: Date;
|
|
4237
4377
|
constructor(cause: ErrorWithStack, task: ServerTask, retryAt: Date);
|
|
4238
4378
|
}
|
|
4379
|
+
/** Use this function if you're using a `try/catch` block to catch errors.
|
|
4380
|
+
* It checks if a thrown error is a special internal error that you should ignore.
|
|
4381
|
+
* If this returns `true` then you must rethrow the error: `throw err;`
|
|
4382
|
+
* @param err The error to check
|
|
4383
|
+
* @returns `true` if the error is a Trigger Error, `false` otherwise.
|
|
4384
|
+
*/
|
|
4239
4385
|
declare function isTriggerError(err: unknown): err is ResumeWithTaskError | RetryWithTaskError;
|
|
4240
4386
|
|
|
4241
4387
|
type Task = ServerTask;
|