generated from langchain-ai/new-langgraphjs-project
-
Notifications
You must be signed in to change notification settings - Fork 195
/
Copy pathdelete-cron.ts
40 lines (36 loc) · 1.05 KB
/
delete-cron.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import "dotenv/config";
import { Client } from "@langchain/langgraph-sdk";
/**
* Deletes a specified cron job from LangGraph.
*
* This function connects to the LangGraph API and deletes a cron job with the specified ID.
* After deletion, it retrieves and displays the updated list of cron jobs.
*
* To find available cron IDs that can be deleted, first run the list-crons script:
*
* ```bash
* yarn cron:list
* ```
*
* @async
* @returns {Promise<void>} A promise that resolves when the cron job is deleted
* and the updated list is displayed
* @throws {Error} If there's an issue deleting the cron job or retrieving the list
*
* @example
* ```bash
* yarn cron:delete
* ```
*/
async function deleteCron() {
const cronId = "ADD_CRON_ID_HERE";
const client = new Client({
apiUrl: process.env.LANGGRAPH_API_URL,
});
await client.crons.delete(cronId);
console.log("\n\nDeleted cron\n\n");
const crons = await client.crons.search();
console.log("\n\nAll Crons\n\n");
console.dir(crons, { depth: null });
}
deleteCron().catch(console.error);