@trigger.dev/react-hooks 0.0.0-v3-prerelease-20241028160720 → 0.0.0-v3-prerelease-20241101212227
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/hooks/useRealtimeBatch.d.ts +15 -1
- package/dist/commonjs/hooks/useRealtimeBatch.js +16 -2
- package/dist/commonjs/hooks/useRealtimeBatch.js.map +1 -1
- package/dist/esm/hooks/useRealtimeBatch.d.ts +15 -1
- package/dist/esm/hooks/useRealtimeBatch.js +15 -1
- package/dist/esm/hooks/useRealtimeBatch.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import { AnyTask, TaskRunShape } from "@trigger.dev/core/v3";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* hook to subscribe to realtime updates of a batch of task runs.
|
|
4
|
+
*
|
|
5
|
+
* @template TTask - The type of the task.
|
|
6
|
+
* @param {string} batchId - The unique identifier of the batch to subscribe to.
|
|
7
|
+
* @returns {{ runs: TaskRunShape<TTask>[], error: Error | null }} An object containing the current state of the runs and any error encountered.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* import type { myTask } from './path/to/task';
|
|
13
|
+
* const { runs, error } = useRealtimeBatch<typeof myTask>('batch-id-123');
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function useRealtimeBatch<TTask extends AnyTask>(batchId: string): {
|
|
3
17
|
runs: TaskRunShape<TTask>[];
|
|
4
18
|
error: Error | null;
|
|
5
19
|
};
|
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
4
|
+
exports.useRealtimeBatch = useRealtimeBatch;
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const useApiClient_js_1 = require("./useApiClient.js");
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* hook to subscribe to realtime updates of a batch of task runs.
|
|
9
|
+
*
|
|
10
|
+
* @template TTask - The type of the task.
|
|
11
|
+
* @param {string} batchId - The unique identifier of the batch to subscribe to.
|
|
12
|
+
* @returns {{ runs: TaskRunShape<TTask>[], error: Error | null }} An object containing the current state of the runs and any error encountered.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* import type { myTask } from './path/to/task';
|
|
18
|
+
* const { runs, error } = useRealtimeBatch<typeof myTask>('batch-id-123');
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
function useRealtimeBatch(batchId) {
|
|
8
22
|
const [runShapes, setRunShapes] = (0, react_1.useState)([]);
|
|
9
23
|
const [error, setError] = (0, react_1.useState)(null);
|
|
10
24
|
const apiClient = (0, useApiClient_js_1.useApiClient)();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRealtimeBatch.js","sourceRoot":"","sources":["../../../src/hooks/useRealtimeBatch.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;
|
|
1
|
+
{"version":3,"file":"useRealtimeBatch.js","sourceRoot":"","sources":["../../../src/hooks/useRealtimeBatch.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAoBb,4CA0BC;AA3CD,iCAA4C;AAC5C,uDAAiD;AAEjD;;;;;;;;;;;;;GAaG;AACH,SAAgB,gBAAgB,CAAwB,OAAe;IACrE,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,IAAA,gBAAQ,EAAwB,EAAE,CAAC,CAAC;IACtE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAe,IAAI,CAAC,CAAC;IACvD,MAAM,SAAS,GAAG,IAAA,8BAAY,GAAE,CAAC;IAEjC,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,YAAY,GA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AAE,CAAC;QACjB,OAAO,CAAC,GAAG,YAAY,EAAE,GAAG,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,GAAG,EAAE,GAAG,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import { AnyTask, TaskRunShape } from "@trigger.dev/core/v3";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* hook to subscribe to realtime updates of a batch of task runs.
|
|
4
|
+
*
|
|
5
|
+
* @template TTask - The type of the task.
|
|
6
|
+
* @param {string} batchId - The unique identifier of the batch to subscribe to.
|
|
7
|
+
* @returns {{ runs: TaskRunShape<TTask>[], error: Error | null }} An object containing the current state of the runs and any error encountered.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* import type { myTask } from './path/to/task';
|
|
13
|
+
* const { runs, error } = useRealtimeBatch<typeof myTask>('batch-id-123');
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function useRealtimeBatch<TTask extends AnyTask>(batchId: string): {
|
|
3
17
|
runs: TaskRunShape<TTask>[];
|
|
4
18
|
error: Error | null;
|
|
5
19
|
};
|
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
3
|
import { useApiClient } from "./useApiClient.js";
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* hook to subscribe to realtime updates of a batch of task runs.
|
|
6
|
+
*
|
|
7
|
+
* @template TTask - The type of the task.
|
|
8
|
+
* @param {string} batchId - The unique identifier of the batch to subscribe to.
|
|
9
|
+
* @returns {{ runs: TaskRunShape<TTask>[], error: Error | null }} An object containing the current state of the runs and any error encountered.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* import type { myTask } from './path/to/task';
|
|
15
|
+
* const { runs, error } = useRealtimeBatch<typeof myTask>('batch-id-123');
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export function useRealtimeBatch(batchId) {
|
|
5
19
|
const [runShapes, setRunShapes] = useState([]);
|
|
6
20
|
const [error, setError] = useState(null);
|
|
7
21
|
const apiClient = useApiClient();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRealtimeBatch.js","sourceRoot":"","sources":["../../../src/hooks/useRealtimeBatch.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"useRealtimeBatch.js","sourceRoot":"","sources":["../../../src/hooks/useRealtimeBatch.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,gBAAgB,CAAwB,OAAe;IACrE,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAwB,EAAE,CAAC,CAAC;IACtE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAe,IAAI,CAAC,CAAC;IACvD,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IAEjC,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,YAAY,GAAG,SAAS,CAAC,gBAAgB,CAAuB,OAAO,CAAC,CAAC;QAE/E,KAAK,UAAU,cAAc;YAC3B,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;gBACrC,YA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C,EAAE,GAAG,EAAE,GAAG,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9E,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trigger.dev/react-hooks",
|
|
3
|
-
"version": "0.0.0-v3-prerelease-
|
|
3
|
+
"version": "0.0.0-v3-prerelease-20241101212227",
|
|
4
4
|
"description": "trigger.dev react hooks",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
]
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@trigger.dev/core": "0.0.0-v3-prerelease-
|
|
32
|
+
"@trigger.dev/core": "0.0.0-v3-prerelease-20241101212227",
|
|
33
33
|
"swr": "^2.2.5"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|