@trigger.dev/sdk 4.0.2 → 4.0.4
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/commonjs/v3/heartbeats.d.ts +37 -0
- package/dist/commonjs/v3/heartbeats.js +45 -0
- package/dist/commonjs/v3/heartbeats.js.map +1 -0
- package/dist/commonjs/v3/index.d.ts +1 -0
- package/dist/commonjs/v3/index.js +1 -0
- package/dist/commonjs/v3/index.js.map +1 -1
- package/dist/commonjs/version.js +1 -1
- package/dist/esm/v3/heartbeats.d.ts +37 -0
- package/dist/esm/v3/heartbeats.js +42 -0
- package/dist/esm/v3/heartbeats.js.map +1 -0
- package/dist/esm/v3/index.d.ts +1 -0
- package/dist/esm/v3/index.js +1 -0
- package/dist/esm/v3/index.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Yields to the Trigger.dev runtime to keep the task alive.
|
|
4
|
+
*
|
|
5
|
+
* This is a cooperative "heartbeat" that you can call as often as you like
|
|
6
|
+
* inside long-running or CPU-heavy loops (e.g. parsing large files, processing
|
|
7
|
+
* many records, or handling big Textract results).
|
|
8
|
+
*
|
|
9
|
+
* You don’t need to worry about over-calling it: the underlying implementation
|
|
10
|
+
* automatically decides when to actually yield to the event loop and send a
|
|
11
|
+
* heartbeat to the Trigger.dev runtime. Extra calls are effectively free.
|
|
12
|
+
*
|
|
13
|
+
* ### Example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { heartbeats } from "@trigger.dev/sdk/v3";
|
|
16
|
+
*
|
|
17
|
+
* for (const row of bigDataset) {
|
|
18
|
+
* process(row);
|
|
19
|
+
* await heartbeats.yield(); // safe to call every iteration
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Using this regularly prevents `TASK_RUN_STALLED_EXECUTING` errors by ensuring
|
|
24
|
+
* the run never appears idle, even during heavy synchronous work.
|
|
25
|
+
*
|
|
26
|
+
* This function is also safe to call from outside of a Trigger.dev task run, it will effectively be a no-op.
|
|
27
|
+
*/
|
|
28
|
+
declare function heartbeatsYield(): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the last heartbeat timestamp, for debugging purposes only. You probably don't need this.
|
|
31
|
+
*/
|
|
32
|
+
declare function heartbeatsGetLastHeartbeat(): Date | undefined;
|
|
33
|
+
export declare const heartbeats: {
|
|
34
|
+
yield: typeof heartbeatsYield;
|
|
35
|
+
getLastHeartbeat: typeof heartbeatsGetLastHeartbeat;
|
|
36
|
+
};
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.heartbeats = void 0;
|
|
4
|
+
const v3_1 = require("@trigger.dev/core/v3");
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* Yields to the Trigger.dev runtime to keep the task alive.
|
|
8
|
+
*
|
|
9
|
+
* This is a cooperative "heartbeat" that you can call as often as you like
|
|
10
|
+
* inside long-running or CPU-heavy loops (e.g. parsing large files, processing
|
|
11
|
+
* many records, or handling big Textract results).
|
|
12
|
+
*
|
|
13
|
+
* You don’t need to worry about over-calling it: the underlying implementation
|
|
14
|
+
* automatically decides when to actually yield to the event loop and send a
|
|
15
|
+
* heartbeat to the Trigger.dev runtime. Extra calls are effectively free.
|
|
16
|
+
*
|
|
17
|
+
* ### Example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { heartbeats } from "@trigger.dev/sdk/v3";
|
|
20
|
+
*
|
|
21
|
+
* for (const row of bigDataset) {
|
|
22
|
+
* process(row);
|
|
23
|
+
* await heartbeats.yield(); // safe to call every iteration
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* Using this regularly prevents `TASK_RUN_STALLED_EXECUTING` errors by ensuring
|
|
28
|
+
* the run never appears idle, even during heavy synchronous work.
|
|
29
|
+
*
|
|
30
|
+
* This function is also safe to call from outside of a Trigger.dev task run, it will effectively be a no-op.
|
|
31
|
+
*/
|
|
32
|
+
async function heartbeatsYield() {
|
|
33
|
+
await v3_1.heartbeats.yield();
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Returns the last heartbeat timestamp, for debugging purposes only. You probably don't need this.
|
|
37
|
+
*/
|
|
38
|
+
function heartbeatsGetLastHeartbeat() {
|
|
39
|
+
return v3_1.heartbeats.lastHeartbeat;
|
|
40
|
+
}
|
|
41
|
+
exports.heartbeats = {
|
|
42
|
+
yield: heartbeatsYield,
|
|
43
|
+
getLastHeartbeat: heartbeatsGetLastHeartbeat,
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=heartbeats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heartbeats.js","sourceRoot":"","sources":["../../../src/v3/heartbeats.ts"],"names":[],"mappings":";;;AAAA,6CAAoE;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,KAAK,UAAU,eAAe;IAC5B,MAAM,eAAc,CAAC,KAAK,EAAE,CAAC;AAC/B,CAAC;AAED;;GAEG;AACH,SAAS,0BAA0B;IACjC,OAAO,eAAc,CAAC,aAAa,CAAC;AACtC,CAAC;AAEY,QAAA,UAAU,GAAG;IACxB,KAAK,EAAE,eAAe;IACtB,gBAAgB,EAAE,0BAA0B;CAC7C,CAAC"}
|
|
@@ -15,6 +15,7 @@ export * from "./webhooks.js";
|
|
|
15
15
|
export * from "./locals.js";
|
|
16
16
|
export * from "./otel.js";
|
|
17
17
|
export * from "./schemas.js";
|
|
18
|
+
export * from "./heartbeats.js";
|
|
18
19
|
export type { Context };
|
|
19
20
|
import type { Context } from "./shared.js";
|
|
20
21
|
import type { ApiClientConfiguration } from "@trigger.dev/core/v3";
|
|
@@ -46,6 +46,7 @@ __exportStar(require("./webhooks.js"), exports);
|
|
|
46
46
|
__exportStar(require("./locals.js"), exports);
|
|
47
47
|
__exportStar(require("./otel.js"), exports);
|
|
48
48
|
__exportStar(require("./schemas.js"), exports);
|
|
49
|
+
__exportStar(require("./heartbeats.js"), exports);
|
|
49
50
|
var v3_1 = require("@trigger.dev/core/v3");
|
|
50
51
|
Object.defineProperty(exports, "ApiError", { enumerable: true, get: function () { return v3_1.ApiError; } });
|
|
51
52
|
Object.defineProperty(exports, "AuthenticationError", { enumerable: true, get: function () { return v3_1.AuthenticationError; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v3/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,8CAA4B;AAC5B,uCAAsD;AAA7C,iGAAA,KAAK,OAAA;AACd,yCAAoC;AAA3B,kGAAA,KAAK,OAAA;AACd,6CAA2B;AAC3B,6CAA2B;AAC3B,4CAA0B;AAC1B,iDAA+B;AAC/B,6CAA2B;AAC3B,uDAAqC;AACrC,4CAA0B;AAC1B,gDAA8B;AAC9B,+CAA6B;AAC7B,gDAA8B;AAC9B,8CAA4B;AAC5B,4CAA0B;AAC1B,+CAA6B;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v3/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,8CAA4B;AAC5B,uCAAsD;AAA7C,iGAAA,KAAK,OAAA;AACd,yCAAoC;AAA3B,kGAAA,KAAK,OAAA;AACd,6CAA2B;AAC3B,6CAA2B;AAC3B,4CAA0B;AAC1B,iDAA+B;AAC/B,6CAA2B;AAC3B,uDAAqC;AACrC,4CAA0B;AAC1B,gDAA8B;AAC9B,+CAA6B;AAC7B,gDAA8B;AAC9B,8CAA4B;AAC5B,4CAA0B;AAC1B,+CAA6B;AAC7B,kDAAgC;AAShC,2CAe8B;AAd5B,8FAAA,QAAQ,OAAA;AACR,yGAAA,mBAAmB,OAAA;AACnB,qGAAA,eAAe,OAAA;AACf,mGAAA,aAAa,OAAA;AACb,yGAAA,mBAAmB,OAAA;AACnB,mGAAA,aAAa,OAAA;AACb,2GAAA,qBAAqB,OAAA;AACrB,oGAAA,cAAc,OAAA;AACd,8GAAA,wBAAwB,OAAA;AACxB,uGAAA,iBAAiB,OAAA;AACjB,sGAAA,gBAAgB,OAAA;AAChB,4GAAA,sBAAsB,OAAA;AACtB,4FAAA,MAAM,OAAA;AAIR,qCASmB;AARjB,+FAAA,IAAI,OAAA;AASN,kEAAkD;AAClD,wDAAwC;AACxC,sDAAsC;AAGtC,qCAA4C;AAAnC,oGAAA,SAAS,OAAA;AAAE,+FAAA,IAAI,OAAA"}
|
package/dist/commonjs/version.js
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Yields to the Trigger.dev runtime to keep the task alive.
|
|
4
|
+
*
|
|
5
|
+
* This is a cooperative "heartbeat" that you can call as often as you like
|
|
6
|
+
* inside long-running or CPU-heavy loops (e.g. parsing large files, processing
|
|
7
|
+
* many records, or handling big Textract results).
|
|
8
|
+
*
|
|
9
|
+
* You don’t need to worry about over-calling it: the underlying implementation
|
|
10
|
+
* automatically decides when to actually yield to the event loop and send a
|
|
11
|
+
* heartbeat to the Trigger.dev runtime. Extra calls are effectively free.
|
|
12
|
+
*
|
|
13
|
+
* ### Example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { heartbeats } from "@trigger.dev/sdk/v3";
|
|
16
|
+
*
|
|
17
|
+
* for (const row of bigDataset) {
|
|
18
|
+
* process(row);
|
|
19
|
+
* await heartbeats.yield(); // safe to call every iteration
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Using this regularly prevents `TASK_RUN_STALLED_EXECUTING` errors by ensuring
|
|
24
|
+
* the run never appears idle, even during heavy synchronous work.
|
|
25
|
+
*
|
|
26
|
+
* This function is also safe to call from outside of a Trigger.dev task run, it will effectively be a no-op.
|
|
27
|
+
*/
|
|
28
|
+
declare function heartbeatsYield(): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the last heartbeat timestamp, for debugging purposes only. You probably don't need this.
|
|
31
|
+
*/
|
|
32
|
+
declare function heartbeatsGetLastHeartbeat(): Date | undefined;
|
|
33
|
+
export declare const heartbeats: {
|
|
34
|
+
yield: typeof heartbeatsYield;
|
|
35
|
+
getLastHeartbeat: typeof heartbeatsGetLastHeartbeat;
|
|
36
|
+
};
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { heartbeats as coreHeartbeats } from "@trigger.dev/core/v3";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Yields to the Trigger.dev runtime to keep the task alive.
|
|
5
|
+
*
|
|
6
|
+
* This is a cooperative "heartbeat" that you can call as often as you like
|
|
7
|
+
* inside long-running or CPU-heavy loops (e.g. parsing large files, processing
|
|
8
|
+
* many records, or handling big Textract results).
|
|
9
|
+
*
|
|
10
|
+
* You don’t need to worry about over-calling it: the underlying implementation
|
|
11
|
+
* automatically decides when to actually yield to the event loop and send a
|
|
12
|
+
* heartbeat to the Trigger.dev runtime. Extra calls are effectively free.
|
|
13
|
+
*
|
|
14
|
+
* ### Example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { heartbeats } from "@trigger.dev/sdk/v3";
|
|
17
|
+
*
|
|
18
|
+
* for (const row of bigDataset) {
|
|
19
|
+
* process(row);
|
|
20
|
+
* await heartbeats.yield(); // safe to call every iteration
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* Using this regularly prevents `TASK_RUN_STALLED_EXECUTING` errors by ensuring
|
|
25
|
+
* the run never appears idle, even during heavy synchronous work.
|
|
26
|
+
*
|
|
27
|
+
* This function is also safe to call from outside of a Trigger.dev task run, it will effectively be a no-op.
|
|
28
|
+
*/
|
|
29
|
+
async function heartbeatsYield() {
|
|
30
|
+
await coreHeartbeats.yield();
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Returns the last heartbeat timestamp, for debugging purposes only. You probably don't need this.
|
|
34
|
+
*/
|
|
35
|
+
function heartbeatsGetLastHeartbeat() {
|
|
36
|
+
return coreHeartbeats.lastHeartbeat;
|
|
37
|
+
}
|
|
38
|
+
export const heartbeats = {
|
|
39
|
+
yield: heartbeatsYield,
|
|
40
|
+
getLastHeartbeat: heartbeatsGetLastHeartbeat,
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=heartbeats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heartbeats.js","sourceRoot":"","sources":["../../../src/v3/heartbeats.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,KAAK,UAAU,eAAe;IAC5B,MAAM,cAAc,CAAC,KAAK,EAAE,CAAC;AAC/B,CAAC;AAED;;GAEG;AACH,SAAS,0BAA0B;IACjC,OAAO,cAAc,CAAC,aAAa,CAAC;AACtC,CAAC;AAED,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,KAAK,EAAE,eAAe;IACtB,gBAAgB,EAAE,0BAA0B;CAC7C,CAAC"}
|
package/dist/esm/v3/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export * from "./webhooks.js";
|
|
|
15
15
|
export * from "./locals.js";
|
|
16
16
|
export * from "./otel.js";
|
|
17
17
|
export * from "./schemas.js";
|
|
18
|
+
export * from "./heartbeats.js";
|
|
18
19
|
export type { Context };
|
|
19
20
|
import type { Context } from "./shared.js";
|
|
20
21
|
import type { ApiClientConfiguration } from "@trigger.dev/core/v3";
|
package/dist/esm/v3/index.js
CHANGED
|
@@ -15,6 +15,7 @@ export * from "./webhooks.js";
|
|
|
15
15
|
export * from "./locals.js";
|
|
16
16
|
export * from "./otel.js";
|
|
17
17
|
export * from "./schemas.js";
|
|
18
|
+
export * from "./heartbeats.js";
|
|
18
19
|
export { ApiError, AuthenticationError, BadRequestError, ConflictError, InternalServerError, NotFoundError, PermissionDeniedError, RateLimitError, UnprocessableEntityError, AbortTaskRunError, OutOfMemoryError, CompleteTaskWithOutput, logger, } from "@trigger.dev/core/v3";
|
|
19
20
|
export { runs, } from "./runs.js";
|
|
20
21
|
export * as schedules from "./schedules/index.js";
|
package/dist/esm/v3/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v3/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAqB,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v3/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAqB,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAShC,OAAO,EACL,QAAQ,EACR,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,qBAAqB,EACrB,cAAc,EACd,wBAAwB,EACxB,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,EACtB,MAAM,GAEP,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,IAAI,GAQL,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAGtC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/esm/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = "4.0.
|
|
1
|
+
export const VERSION = "4.0.4";
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trigger.dev/sdk",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"description": "trigger.dev Node.JS SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@opentelemetry/api": "1.9.0",
|
|
45
45
|
"@opentelemetry/semantic-conventions": "1.36.0",
|
|
46
|
-
"@trigger.dev/core": "4.0.
|
|
46
|
+
"@trigger.dev/core": "4.0.4",
|
|
47
47
|
"chalk": "^5.2.0",
|
|
48
48
|
"cronstrue": "^2.21.0",
|
|
49
49
|
"debug": "^4.3.4",
|