@gravito/flux 1.0.0-alpha.1 → 1.0.0-alpha.6
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/README.zh-TW.md +30 -0
- package/package.json +65 -65
package/README.zh-TW.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# @gravito/flux
|
|
2
|
+
|
|
3
|
+
> Gravito 的高效能工作流程引擎,跨平台、型別安全的狀態機。
|
|
4
|
+
|
|
5
|
+
## 安裝
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun add @gravito/flux
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 快速開始
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { FluxEngine, createWorkflow } from '@gravito/flux'
|
|
15
|
+
|
|
16
|
+
const orderFlow = createWorkflow('order-process')
|
|
17
|
+
.input<{ orderId: string }>()
|
|
18
|
+
.step('fetch', async (ctx) => {
|
|
19
|
+
ctx.data.order = await db.orders.find(ctx.input.orderId)
|
|
20
|
+
})
|
|
21
|
+
.step('validate', async (ctx) => {
|
|
22
|
+
if (!ctx.data.order.isPaid) throw new Error('Unpaid order')
|
|
23
|
+
})
|
|
24
|
+
.commit('fulfill', async (ctx) => {
|
|
25
|
+
await fulfillment.ship(ctx.data.order)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
const engine = new FluxEngine()
|
|
29
|
+
const result = await engine.execute(orderFlow, { orderId: '123' })
|
|
30
|
+
```
|
package/package.json
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
},
|
|
24
|
-
"./bun": {
|
|
25
|
-
"bun": {
|
|
26
|
-
"import": "./dist/bun.js",
|
|
27
|
-
"types": "./dist/bun.d.ts"
|
|
28
|
-
}
|
|
29
|
-
}
|
|
2
|
+
"name": "@gravito/flux",
|
|
3
|
+
"version": "1.0.0-alpha.6",
|
|
4
|
+
"description": "Platform-agnostic workflow engine for Gravito",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/node/index.cjs",
|
|
7
|
+
"module": "./dist/node/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"bun": {
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
},
|
|
15
|
+
"node": {
|
|
16
|
+
"import": "./dist/node/index.mjs",
|
|
17
|
+
"require": "./dist/node/index.cjs",
|
|
18
|
+
"types": "./dist/index.node.d.ts"
|
|
19
|
+
},
|
|
20
|
+
"import": "./dist/node/index.mjs",
|
|
21
|
+
"require": "./dist/node/index.cjs",
|
|
22
|
+
"types": "./dist/index.d.ts"
|
|
30
23
|
},
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"keywords": [
|
|
54
|
-
"gravito",
|
|
55
|
-
"workflow",
|
|
56
|
-
"state-machine",
|
|
57
|
-
"pipeline",
|
|
58
|
-
"bun",
|
|
59
|
-
"node"
|
|
60
|
-
],
|
|
61
|
-
"author": "Gravito Team",
|
|
62
|
-
"license": "MIT",
|
|
63
|
-
"repository": {
|
|
64
|
-
"type": "git",
|
|
65
|
-
"url": "https://github.com/gravito-framework/gravito.git",
|
|
66
|
-
"directory": "packages/flux"
|
|
24
|
+
"./bun": {
|
|
25
|
+
"bun": {
|
|
26
|
+
"import": "./dist/bun.js",
|
|
27
|
+
"types": "./dist/bun.d.ts"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"README.md"
|
|
34
|
+
],
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "bun run build.ts",
|
|
37
|
+
"typecheck": "tsc --noEmit",
|
|
38
|
+
"test": "bun test"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"gravito-core": "1.0.0-beta.5"
|
|
42
|
+
},
|
|
43
|
+
"peerDependenciesMeta": {
|
|
44
|
+
"gravito-core": {
|
|
45
|
+
"optional": true
|
|
67
46
|
}
|
|
68
|
-
}
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"bun-types": "latest",
|
|
50
|
+
"gravito-core": "1.0.0-beta.5",
|
|
51
|
+
"typescript": "^5.0.0"
|
|
52
|
+
},
|
|
53
|
+
"keywords": [
|
|
54
|
+
"gravito",
|
|
55
|
+
"workflow",
|
|
56
|
+
"state-machine",
|
|
57
|
+
"pipeline",
|
|
58
|
+
"bun",
|
|
59
|
+
"node"
|
|
60
|
+
],
|
|
61
|
+
"author": "Gravito Team",
|
|
62
|
+
"license": "MIT",
|
|
63
|
+
"repository": {
|
|
64
|
+
"type": "git",
|
|
65
|
+
"url": "https://github.com/gravito-framework/gravito.git",
|
|
66
|
+
"directory": "packages/flux"
|
|
67
|
+
}
|
|
68
|
+
}
|