@commandkit/workflow 0.0.0-dev.20251108082950 → 0.0.0-dev.20251108124628

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.
Files changed (2) hide show
  1. package/README.md +54 -1
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -5,13 +5,66 @@ CommandKit plugin for [useworkflow.dev](https://useworkflow.dev).
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install @commandkit/workflow
8
+ npm install @commandkit/workflow workflow
9
9
  ```
10
10
 
11
11
  ## Usage
12
12
 
13
13
  ```typescript
14
+ import { defineConfig } from 'commandkit/config';
14
15
  import { workflow } from '@commandkit/workflow';
16
+
17
+ export default defineConfig({
18
+ plugins: [workflow()],
19
+ });
20
+ ```
21
+
22
+ Then, add workflow functions inside `src/workflows` directory.
23
+
24
+ ```typescript
25
+ import { sleep } from 'workflow';
26
+ import { useClient } from 'commandkit/hooks';
27
+
28
+ export async function greetUserWorkflow(userId: string) {
29
+ 'use workflow';
30
+
31
+ await greetUser(userId);
32
+
33
+ await sleep('5 seconds');
34
+
35
+ await greetUser(userId, true);
36
+
37
+ return { success: true };
38
+ }
39
+
40
+ async function greetUser(userId: string, again = false) {
41
+ 'use step';
42
+
43
+ const client = useClient<true>();
44
+
45
+ const user = await client.users.fetch(userId);
46
+
47
+ const message = again ? 'Hello again!' : 'Hello!';
48
+
49
+ await user.send(message);
50
+ }
51
+ ```
52
+
53
+ Now, you can run the workflow using the `start` function in your commands (or other places).
54
+
55
+ ```typescript
56
+ import { start } from 'workflow/api';
57
+ import {greetUserWorkflow} from '@/workflows/greet';
58
+
59
+ export const command: CommandData = {
60
+ name: 'greet',
61
+ description: 'Greet command',
62
+ };
63
+
64
+ export const chatInput: ChatInputCommand = async (ctx) => {
65
+ await ctx.interaction.reply("I'm gonna greet you :wink:");
66
+ await start(greetUserWorkflow, [ctx.interaction.user.id]);
67
+ }
15
68
  ```
16
69
 
17
70
  ## Documentation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commandkit/workflow",
3
- "version": "0.0.0-dev.20251108082950",
3
+ "version": "0.0.0-dev.20251108124628",
4
4
  "description": "CommandKit plugin for useworkflow.dev",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -39,8 +39,8 @@
39
39
  "devDependencies": {
40
40
  "typescript": "^5.8.3",
41
41
  "workflow": "^4.0.1-beta.12",
42
- "commandkit": "1.2.0-dev.20251108082950",
43
- "tsconfig": "0.0.0-dev.20251108082950"
42
+ "commandkit": "1.2.0-dev.20251108124628",
43
+ "tsconfig": "0.0.0-dev.20251108124628"
44
44
  },
45
45
  "dependencies": {
46
46
  "@hono/node-server": "^1.19.6",