koyuki 0.1.0-alpha.0 → 0.1.0-alpha.1

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 (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +76 -15
  3. package/README.txt +1 -1
  4. package/package.json +7 -2
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 yukiharada1228
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,18 +1,17 @@
1
1
  # Koyuki
2
2
 
3
- Declarative, functional business workflows for TypeScript.
4
-
5
- Koyuki separates pure business rules from loading, persistence, and execution.
6
- Declare validation, requirements, and state evolution; the runtime connects the
7
- steps and propagates failures. HTTP routing can stay with Hono or another server.
8
-
9
- This is an experimental alpha. APIs may change. The current runtime requires
10
- Node.js 22 or later; browser and edge-runtime compatibility is not guaranteed.
3
+ 業務の状態・検証・遷移を宣言し、接続と実行を任せるTypeScriptフレームワーク。
11
4
 
12
5
  ```sh
13
6
  npm install koyuki@alpha
14
7
  ```
15
8
 
9
+ **実験段階のアルファ版です。** APIは変更される可能性があります。ES Modulesと
10
+ Node.js 22以上が必要です。現在の実装は `node:crypto` を使うため、ブラウザや
11
+ エッジランタイムでの動作は保証していません。
12
+
13
+ ## 最初の状態遷移
14
+
16
15
  ```ts
17
16
  import { ok, err, step, transition, type Result } from 'koyuki';
18
17
 
@@ -28,12 +27,74 @@ approve.run(100); // { ok: true, value: { kind: 'approved', amount: 100 } }
28
27
  approve.run(-1); // { ok: false, error: 'InvalidAmount' }
29
28
  ```
30
29
 
31
- The public API also includes `defineTarget`, `defineApplication`, `operation`,
32
- `collect`, `workflow`, and lower-level command and program primitives.
33
- Repository adapters, domain models, authorization rules, and transaction boundaries
34
- remain application responsibilities.
30
+ `validate` が成功した値を `require`、`evolve` に渡します。
31
+ 失敗すると後続の処理を実行せず、型付きのエラーを返します。
32
+ この例は接続の最小例です。実際の業務では直和型で状態を表し、権限や不変条件を検証します。
33
+
34
+ ## 取得・保存・アプリケーションの実行
35
+
36
+ 経費承認の宣言は次の形です。下記の関数とrepositoryは利用者が実装します。
37
+ [実行できる経費精算サンプル](examples/expenses/README.md)に全コードがあります。
38
+
39
+ ```ts
40
+ import { defineTarget, step } from 'koyuki';
41
+
42
+ const approved = {
43
+ validate: step('authorize-approval', validateApproval),
44
+ require: [] as const,
45
+ evolve: step('approve', approve),
46
+ };
47
+
48
+ const approval = defineTarget({
49
+ operation: 'expense.approve.v1',
50
+ load: input => repository.load(input, authenticatedActor),
51
+ save: change => repository.save(change),
52
+ }).on(approved);
53
+
54
+ await approval.run({ id: 'expense-1', expectedVersion: 2 });
55
+ ```
56
+
57
+ | 利用者が書くもの | Koyukiが実行するもの |
58
+ | --- | --- |
59
+ | 状態の型・検証・純粋な遷移関数 | 型の合う処理を接続し、Resultの失敗を伝播 |
60
+ | データの取得・保存アダプター | load → validate → require → evolve → save |
61
+ | 操作と成功時の業務データ更新 | `defineApplication` による ready / running / failed の管理 |
62
+ | 内部状態から返したい情報 | `view` の再計算、購読通知 |
63
+
64
+ HTTPはHonoなどに任せられます。ReactやJSXは必須ではありません。
65
+ 認証済みの利用者の注入、権限ルール、DBトランザクション、更新競合の防止は利用者が設計します。
66
+ 自動トランザクション・永続的なリトライ・監査ログは現時点では提供しません。
67
+
68
+ ## 経費精算サンプルを試す
69
+
70
+ ```sh
71
+ git clone https://github.com/yukiharada1228/koyuki.git
72
+ cd koyuki/examples/expenses
73
+ npm ci
74
+ npm run check
75
+ npm test
76
+ npm start
77
+ ```
78
+
79
+ サンプルはソース内部の相対importではなく、npmの `koyuki` を使用します。
80
+ 申請 → 上長承認 → 経理承認と、別申請の却下を確認できます。
81
+
82
+ ## フレームワークを開発する
83
+
84
+ リポジトリのルートで実行します。全テストには `node:sqlite` が必要です。
85
+ Node.js 26.12.0で検証しています。
86
+
87
+ ```sh
88
+ npm ci
89
+ npm run check
90
+ npm test
91
+ npm run build
92
+ ```
93
+
94
+ 既存のタグ管理・SQLite/Honoデモは [README.txt](README.txt)、
95
+ APIの検討記録は [PUBLIC-API.txt](PUBLIC-API.txt) を参照してください。
96
+ 将来機能は [Issues](https://github.com/yukiharada1228/koyuki/issues) で管理しています。
35
97
 
36
- See [the repository](https://github.com/yukiharada1228/business-react-lab)
37
- for tag and expense workflow examples and prototype documentation.
98
+ ## License
38
99
 
39
- No open-source license has been granted in this release.
100
+ [MIT](LICENSE) © 2026 yukiharada1228
package/README.txt CHANGED
@@ -1,4 +1,4 @@
1
- Business React Lab
1
+ Koyuki
2
2
 
3
3
  業務の状態・検証・遷移を宣言し、Resultの合成と取得・保存・実行管理を任せる
4
4
  TypeScriptフレームワークの試作です。安定版APIではありません。
package/package.json CHANGED
@@ -42,7 +42,7 @@
42
42
  "react": "^19.3.1",
43
43
  "react-dom": "^19.3.1"
44
44
  },
45
- "version": "0.1.0-alpha.0",
45
+ "version": "0.1.0-alpha.1",
46
46
  "description": "Declarative, functional business workflows for TypeScript",
47
47
  "main": "./dist/index.js",
48
48
  "types": "./dist/index.d.ts",
@@ -60,10 +60,15 @@
60
60
  },
61
61
  "repository": {
62
62
  "type": "git",
63
- "url": "git+https://github.com/yukiharada1228/business-react-lab.git"
63
+ "url": "git+https://github.com/yukiharada1228/koyuki.git"
64
64
  },
65
65
  "publishConfig": {
66
66
  "access": "public",
67
67
  "tag": "alpha"
68
+ },
69
+ "license": "MIT",
70
+ "homepage": "https://github.com/yukiharada1228/koyuki#readme",
71
+ "bugs": {
72
+ "url": "https://github.com/yukiharada1228/koyuki/issues"
68
73
  }
69
74
  }