swallowkit 1.0.0-beta.4 → 1.0.0-beta.40

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 (204) hide show
  1. package/LICENSE +21 -21
  2. package/README.ja.md +153 -215
  3. package/README.md +153 -216
  4. package/dist/__tests__/fixtures.d.ts +22 -0
  5. package/dist/__tests__/fixtures.d.ts.map +1 -0
  6. package/dist/__tests__/fixtures.js +146 -0
  7. package/dist/__tests__/fixtures.js.map +1 -0
  8. package/dist/cli/commands/add-auth.d.ts +10 -0
  9. package/dist/cli/commands/add-auth.d.ts.map +1 -0
  10. package/dist/cli/commands/add-auth.js +426 -0
  11. package/dist/cli/commands/add-auth.js.map +1 -0
  12. package/dist/cli/commands/add-connector.d.ts +20 -0
  13. package/dist/cli/commands/add-connector.d.ts.map +1 -0
  14. package/dist/cli/commands/add-connector.js +163 -0
  15. package/dist/cli/commands/add-connector.js.map +1 -0
  16. package/dist/cli/commands/create-model.d.ts +1 -4
  17. package/dist/cli/commands/create-model.d.ts.map +1 -1
  18. package/dist/cli/commands/create-model.js +21 -82
  19. package/dist/cli/commands/create-model.js.map +1 -1
  20. package/dist/cli/commands/dev-seeds.d.ts +57 -0
  21. package/dist/cli/commands/dev-seeds.d.ts.map +1 -0
  22. package/dist/cli/commands/dev-seeds.js +470 -0
  23. package/dist/cli/commands/dev-seeds.js.map +1 -0
  24. package/dist/cli/commands/dev.d.ts +33 -0
  25. package/dist/cli/commands/dev.d.ts.map +1 -1
  26. package/dist/cli/commands/dev.js +628 -146
  27. package/dist/cli/commands/dev.js.map +1 -1
  28. package/dist/cli/commands/index.d.ts +1 -0
  29. package/dist/cli/commands/index.d.ts.map +1 -1
  30. package/dist/cli/commands/index.js +3 -1
  31. package/dist/cli/commands/index.js.map +1 -1
  32. package/dist/cli/commands/init.d.ts +45 -0
  33. package/dist/cli/commands/init.d.ts.map +1 -1
  34. package/dist/cli/commands/init.js +2851 -1754
  35. package/dist/cli/commands/init.js.map +1 -1
  36. package/dist/cli/commands/scaffold.d.ts +4 -0
  37. package/dist/cli/commands/scaffold.d.ts.map +1 -1
  38. package/dist/cli/commands/scaffold.js +439 -130
  39. package/dist/cli/commands/scaffold.js.map +1 -1
  40. package/dist/cli/index.d.ts +5 -1
  41. package/dist/cli/index.d.ts.map +1 -1
  42. package/dist/cli/index.js +200 -42
  43. package/dist/cli/index.js.map +1 -1
  44. package/dist/core/config.d.ts +8 -2
  45. package/dist/core/config.d.ts.map +1 -1
  46. package/dist/core/config.js +94 -5
  47. package/dist/core/config.js.map +1 -1
  48. package/dist/core/mock/connector-mock-server.d.ts +101 -0
  49. package/dist/core/mock/connector-mock-server.d.ts.map +1 -0
  50. package/dist/core/mock/connector-mock-server.js +480 -0
  51. package/dist/core/mock/connector-mock-server.js.map +1 -0
  52. package/dist/core/mock/zod-mock-generator.d.ts +14 -0
  53. package/dist/core/mock/zod-mock-generator.d.ts.map +1 -0
  54. package/dist/core/mock/zod-mock-generator.js +163 -0
  55. package/dist/core/mock/zod-mock-generator.js.map +1 -0
  56. package/dist/core/operations/create-model.d.ts +15 -0
  57. package/dist/core/operations/create-model.d.ts.map +1 -0
  58. package/dist/core/operations/create-model.js +171 -0
  59. package/dist/core/operations/create-model.js.map +1 -0
  60. package/dist/core/operations/runtime.d.ts +32 -0
  61. package/dist/core/operations/runtime.d.ts.map +1 -0
  62. package/dist/core/operations/runtime.js +225 -0
  63. package/dist/core/operations/runtime.js.map +1 -0
  64. package/dist/core/operations/scaffold-machine.d.ts +16 -0
  65. package/dist/core/operations/scaffold-machine.d.ts.map +1 -0
  66. package/dist/core/operations/scaffold-machine.js +63 -0
  67. package/dist/core/operations/scaffold-machine.js.map +1 -0
  68. package/dist/core/project/manifest.d.ts +92 -0
  69. package/dist/core/project/manifest.d.ts.map +1 -0
  70. package/dist/core/project/manifest.js +321 -0
  71. package/dist/core/project/manifest.js.map +1 -0
  72. package/dist/core/project/validation.d.ts +20 -0
  73. package/dist/core/project/validation.d.ts.map +1 -0
  74. package/dist/core/project/validation.js +209 -0
  75. package/dist/core/project/validation.js.map +1 -0
  76. package/dist/core/scaffold/auth-generator.d.ts +38 -0
  77. package/dist/core/scaffold/auth-generator.d.ts.map +1 -0
  78. package/dist/core/scaffold/auth-generator.js +1244 -0
  79. package/dist/core/scaffold/auth-generator.js.map +1 -0
  80. package/dist/core/scaffold/connector-functions-generator.d.ts +41 -0
  81. package/dist/core/scaffold/connector-functions-generator.d.ts.map +1 -0
  82. package/dist/core/scaffold/connector-functions-generator.js +1027 -0
  83. package/dist/core/scaffold/connector-functions-generator.js.map +1 -0
  84. package/dist/core/scaffold/functions-generator.d.ts +7 -1
  85. package/dist/core/scaffold/functions-generator.d.ts.map +1 -1
  86. package/dist/core/scaffold/functions-generator.js +920 -220
  87. package/dist/core/scaffold/functions-generator.js.map +1 -1
  88. package/dist/core/scaffold/model-parser.d.ts +20 -1
  89. package/dist/core/scaffold/model-parser.d.ts.map +1 -1
  90. package/dist/core/scaffold/model-parser.js +328 -135
  91. package/dist/core/scaffold/model-parser.js.map +1 -1
  92. package/dist/core/scaffold/native-schema-generator.d.ts +13 -0
  93. package/dist/core/scaffold/native-schema-generator.d.ts.map +1 -0
  94. package/dist/core/scaffold/native-schema-generator.js +696 -0
  95. package/dist/core/scaffold/native-schema-generator.js.map +1 -0
  96. package/dist/core/scaffold/nextjs-generator.d.ts +8 -0
  97. package/dist/core/scaffold/nextjs-generator.d.ts.map +1 -1
  98. package/dist/core/scaffold/nextjs-generator.js +314 -182
  99. package/dist/core/scaffold/nextjs-generator.js.map +1 -1
  100. package/dist/core/scaffold/openapi-generator.d.ts +3 -0
  101. package/dist/core/scaffold/openapi-generator.d.ts.map +1 -0
  102. package/dist/core/scaffold/openapi-generator.js +190 -0
  103. package/dist/core/scaffold/openapi-generator.js.map +1 -0
  104. package/dist/core/scaffold/ui-generator.d.ts +10 -4
  105. package/dist/core/scaffold/ui-generator.d.ts.map +1 -1
  106. package/dist/core/scaffold/ui-generator.js +768 -663
  107. package/dist/core/scaffold/ui-generator.js.map +1 -1
  108. package/dist/database/base-model.d.ts +3 -3
  109. package/dist/database/base-model.js +3 -3
  110. package/dist/index.d.ts +2 -2
  111. package/dist/index.d.ts.map +1 -1
  112. package/dist/index.js +2 -1
  113. package/dist/index.js.map +1 -1
  114. package/dist/machine/contracts.d.ts +16 -0
  115. package/dist/machine/contracts.d.ts.map +1 -0
  116. package/dist/machine/contracts.js +3 -0
  117. package/dist/machine/contracts.js.map +1 -0
  118. package/dist/machine/errors.d.ts +11 -0
  119. package/dist/machine/errors.d.ts.map +1 -0
  120. package/dist/machine/errors.js +34 -0
  121. package/dist/machine/errors.js.map +1 -0
  122. package/dist/machine/index.d.ts +3 -0
  123. package/dist/machine/index.d.ts.map +1 -0
  124. package/dist/machine/index.js +156 -0
  125. package/dist/machine/index.js.map +1 -0
  126. package/dist/mcp/index.d.ts +25 -0
  127. package/dist/mcp/index.d.ts.map +1 -0
  128. package/dist/mcp/index.js +186 -0
  129. package/dist/mcp/index.js.map +1 -0
  130. package/dist/types/index.d.ts +65 -0
  131. package/dist/types/index.d.ts.map +1 -1
  132. package/dist/utils/package-manager.d.ts +110 -0
  133. package/dist/utils/package-manager.d.ts.map +1 -0
  134. package/dist/utils/package-manager.js +224 -0
  135. package/dist/utils/package-manager.js.map +1 -0
  136. package/dist/utils/python-uv.d.ts +21 -0
  137. package/dist/utils/python-uv.d.ts.map +1 -0
  138. package/dist/utils/python-uv.js +111 -0
  139. package/dist/utils/python-uv.js.map +1 -0
  140. package/package.json +84 -73
  141. package/src/__tests__/__snapshots__/functions-generator.test.ts.snap +1139 -0
  142. package/src/__tests__/__snapshots__/nextjs-generator.test.ts.snap +194 -0
  143. package/src/__tests__/__snapshots__/ui-generator.test.ts.snap +532 -0
  144. package/src/__tests__/auth.test.ts +654 -0
  145. package/src/__tests__/config.test.ts +274 -0
  146. package/src/__tests__/connector-functions-generator.test.ts +288 -0
  147. package/src/__tests__/connector-mock-server.test.ts +439 -0
  148. package/src/__tests__/connector-model-bff.test.ts +162 -0
  149. package/src/__tests__/dev-seeds.test.ts +173 -0
  150. package/src/__tests__/dev.test.ts +252 -0
  151. package/src/__tests__/fixtures.ts +144 -0
  152. package/src/__tests__/functions-generator.test.ts +237 -0
  153. package/src/__tests__/init.test.ts +197 -0
  154. package/src/__tests__/jest-globals.d.ts +8 -0
  155. package/src/__tests__/machine.test.ts +356 -0
  156. package/src/__tests__/mcp.test.ts +124 -0
  157. package/src/__tests__/model-parser.test.ts +52 -0
  158. package/src/__tests__/nextjs-generator.test.ts +97 -0
  159. package/src/__tests__/openapi-generator.test.ts +43 -0
  160. package/src/__tests__/package-manager.test.ts +201 -0
  161. package/src/__tests__/python-uv.test.ts +48 -0
  162. package/src/__tests__/scaffold.test.ts +191 -0
  163. package/src/__tests__/string-utils.test.ts +75 -0
  164. package/src/__tests__/tsconfig.json +15 -0
  165. package/src/__tests__/ui-generator.test.ts +144 -0
  166. package/src/__tests__/zod-mock-generator.test.ts +132 -0
  167. package/src/cli/commands/add-auth.ts +482 -0
  168. package/src/cli/commands/add-connector.ts +158 -0
  169. package/src/cli/commands/create-model.ts +62 -0
  170. package/src/cli/commands/dev-seeds.ts +614 -0
  171. package/src/cli/commands/dev.ts +1134 -0
  172. package/src/cli/commands/index.ts +9 -0
  173. package/src/cli/commands/init.ts +3600 -0
  174. package/src/cli/commands/provision.ts +193 -0
  175. package/src/cli/commands/scaffold.ts +991 -0
  176. package/src/cli/index.ts +196 -0
  177. package/src/core/config.ts +312 -0
  178. package/src/core/mock/connector-mock-server.ts +555 -0
  179. package/src/core/mock/zod-mock-generator.ts +205 -0
  180. package/src/core/operations/create-model.ts +174 -0
  181. package/src/core/operations/runtime.ts +235 -0
  182. package/src/core/operations/scaffold-machine.ts +91 -0
  183. package/src/core/project/manifest.ts +402 -0
  184. package/src/core/project/validation.ts +229 -0
  185. package/src/core/scaffold/auth-generator.ts +1284 -0
  186. package/src/core/scaffold/connector-functions-generator.ts +1128 -0
  187. package/src/core/scaffold/functions-generator.ts +970 -0
  188. package/src/core/scaffold/model-parser.ts +841 -0
  189. package/src/core/scaffold/native-schema-generator.ts +822 -0
  190. package/src/core/scaffold/nextjs-generator.ts +370 -0
  191. package/src/core/scaffold/openapi-generator.ts +212 -0
  192. package/src/core/scaffold/ui-generator.ts +1061 -0
  193. package/src/database/base-model.ts +184 -0
  194. package/src/database/client.ts +140 -0
  195. package/src/database/repository.ts +104 -0
  196. package/src/database/runtime-check.ts +25 -0
  197. package/src/index.ts +27 -0
  198. package/src/machine/contracts.ts +17 -0
  199. package/src/machine/errors.ts +34 -0
  200. package/src/machine/index.ts +173 -0
  201. package/src/mcp/index.ts +191 -0
  202. package/src/types/index.ts +134 -0
  203. package/src/utils/package-manager.ts +238 -0
  204. package/src/utils/python-uv.ts +96 -0
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Takumasa Hirabayashi
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.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Takumasa Hirabayashi
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.ja.md CHANGED
@@ -1,215 +1,153 @@
1
- # SwallowKit
2
-
3
- [![npm version](https://img.shields.io/npm/v/swallowkit.svg)](https://www.npmjs.com/package/swallowkit)
4
- [![npm downloads](https://img.shields.io/npm/dm/swallowkit.svg)](https://www.npmjs.com/package/swallowkit)
5
- [![license](https://img.shields.io/npm/l/swallowkit.svg)](./LICENSE)
6
-
7
- [English](./README.md) | 日本語
8
-
9
- **Azure 上の Next.js アプリケーション向けの型安全なスキーマ駆動開発ツールキット**
10
-
11
- SwallowKit は、Zod スキーマを通じてエンドツーエンドの型安全性を維持しながら、外部の Azure Functions バックエンドを持つフルスタック Next.js アプリケーションを Static Web Apps で構築するための統合キットです。
12
-
13
- Next.js の API ルートを BFF(Backend For Frontend)としての使用のみに制限し、ビジネスロジックは独立した Azure Functions にオフロードすることでクライアント・サーバー間の明確な分離を提供します。
14
-
15
- Zod スキーマから自動的に CRUD 操作を生成する Scaffold 機能を備え、一貫した型定義で Next.js (Azure Static Web Apps)、Azure Functions、Cosmos DB を組み合わせた構成で、CRUD コードの自動生成から本番デプロイ・CI/CD までをサポートします。
16
-
17
- > **注意**: このプロジェクトは活発に開発中です。将来のバージョンでAPIが変更される可能性があります。
18
-
19
- ## ✨ 主な特徴
20
-
21
- - **🔄 Zod スキーマ共有** - フロントエンド、BFF、Azure Functions、Cosmos DB で同じスキーマを使用
22
- - **⚡ CRUD コード生成** - `swallowkit scaffold` で Azure Functions + Next.js コードを自動生成
23
- - **🛡️ 完全な型安全性** - クライアントからデータベースまでエンドツーエンド TypeScript
24
- - **🎯 BFF パターン** - Next.js API Routes が BFF レイヤーとして機能、自動検証・リソース名推論
25
- - **☁️ Azure 最適化** - Static Web Apps + Functions + Cosmos DB で最小コスト構成
26
- - **🚀 簡単デプロイ** - Bicep IaC + CI/CD ワークフローを自動生成
27
-
28
-
29
- ## 📚 ドキュメント
30
-
31
- - **[CLI リファレンス](./docs/cli-reference.ja.md)** - 全コマンドの詳細
32
- - **[Scaffold ガイド](./docs/scaffold-guide.ja.md)** - CRUD コード生成
33
- - **[Zod スキーマ共有ガイド](./docs/zod-schema-sharing-guide.ja.md)** - スキーマ設計
34
- - **[デプロイガイド](./docs/deployment-guide.ja.md)** - Azure へのデプロイ
35
-
36
- ## 🚀 クイックスタート
37
-
38
- ### 1. プロジェクト作成
39
-
40
- ```bash
41
- npx swallowkit init my-app
42
- cd my-app
43
- ```
44
-
45
- ### 2. モデルの作成
46
-
47
- 複数のモデルをまとめて作成できます:
48
-
49
- ```bash
50
- npx swallowkit create-model category todo
51
- ```
52
-
53
- これにより `shared/models/category.ts` と `shared/models/todo.ts` が生成されます。必要なフィールドを追加してカスタマイズ:
54
-
55
- ```typescript
56
- // shared/models/category.ts
57
- import { z } from 'zod';
58
-
59
- export const category = z.object({
60
- id: z.string(),
61
- name: z.string().min(1).max(50),
62
- createdAt: z.string().optional(),
63
- updatedAt: z.string().optional(),
64
- });
65
-
66
- export type Category = z.infer<typeof category>;
67
- ```
68
-
69
- 親子関係を表現するには、ID 参照ではなく**ネスト型**で記述します:
70
-
71
- ```typescript
72
- // shared/models/todo.ts
73
- import { z } from 'zod';
74
- import { category } from './category';
75
-
76
- export const todo = z.object({
77
- id: z.string(),
78
- text: z.string().min(1).max(200),
79
- completed: z.boolean().default(false),
80
- category: category.optional(), // ネストオブジェクト(categoryId ではない)
81
- createdAt: z.string().optional(),
82
- updatedAt: z.string().optional(),
83
- });
84
-
85
- export type Todo = z.infer<typeof todo>;
86
- ```
87
-
88
- > **Tip**: ネスト型を使うことで型安全性が保たれ、関連データがドキュメント内にまとまって保存されます。これは Cosmos DB のドキュメントモデルに自然な形です。
89
-
90
- ### 3. CRUD コード生成
91
-
92
- ```bash
93
- npx swallowkit scaffold shared/models/todo.ts
94
- ```
95
-
96
- これで以下が自動生成されます:
97
- - ✅ Azure Functions (CRUD エンドポイント + Cosmos DB バインディング)
98
- - ✅ Next.js BFF API Routes (自動検証・リソース名推論)
99
- - React コンポーネント (型安全なフォーム)
100
-
101
- ### 4. 開発サーバー起動
102
-
103
- ```bash
104
- npx swallowkit dev
105
- ```
106
-
107
- - Next.js: http://localhost:3000
108
- - Azure Functions: http://localhost:7071
109
-
110
- ### 5. フロントエンドから使用
111
-
112
- ```typescript
113
- import { api } from '@/lib/api/backend';
114
- import type { Todo } from '@/shared/models/todo';
115
-
116
- // 全件取得 - BFFエンドポイントを呼び出し
117
- const todos = await api.get<Todo[]>('/api/todos');
118
-
119
- // 作成 - バックエンドで検証
120
- const created = await api.post<Todo>('/api/todos', {
121
- text: '牛乳を買う',
122
- completed: false
123
- });
124
-
125
- // 更新 - バックエンドで検証
126
- const updated = await api.put<Todo>('/api/todos/123', { completed: true });
127
-
128
- // 削除
129
- await api.delete('/api/todos/123');
130
- ```
131
-
132
- ## 🏗️ アーキテクチャ
133
-
134
- ```
135
- ┌─────────────────────────────────────────────────────────────┐
136
- │ Frontend (React) │
137
- │ - Client Components │
138
- - Server Components (SSR) │
139
- └──────────────────────────┬───────────────────────────────────┘
140
- api.post('/api/todos', data)
141
-
142
- ┌─────────────────────────────────────────────────────────────┐
143
- │ BFF Layer (Next.js API Routes) │
144
- │ - Auto Schema Validation (Zod) │
145
- │ - Error Handling │
146
- └──────────────────────────┬───────────────────────────────────┘
147
- HTTP Request
148
-
149
- ┌─────────────────────────────────────────────────────────────┐
150
- │ Azure Functions (Backend) │
151
- │ - HTTP Triggers (CRUD) │
152
- │ - Zod Validation (Re-check) │
153
- │ - Business Logic │
154
- │ - Cosmos DB Bindings │
155
- └──────────────────────────┬───────────────────────────────────┘
156
-
157
-
158
- ┌─────────────────────────────────────────────────────────────┐
159
- │ Azure Cosmos DB │
160
- │ - NoSQL Database │
161
- │ - Zod Schema Validation │
162
- └─────────────────────────────────────────────────────────────┘
163
- ```
164
-
165
- **重要なパターン:**
166
- - **BFF (Backend For Frontend)**: Next.js API Routes が Azure Functions へのプロキシ
167
- - **共有スキーマ**: Zod スキーマをフロントエンド・BFF・Functions・DB で共有
168
- - **型安全性**: Zod から TypeScript 型を自動推論
169
- - **マネージド ID**: サービス間の安全な接続(接続文字列不要)
170
-
171
- ## 📦 前提条件
172
-
173
- - Node.js 22.x
174
- - Azure Cosmos DB Emulator (ローカル開発用)
175
- - [公式ドキュメント (vNext 推奨)](https://learn.microsoft.com/ja-jp/azure/cosmos-db/emulator-linux)
176
- - Windows: [ダウンロード](https://aka.ms/cosmosdb-emulator)
177
- - Docker: `docker run -p 8081:8081 mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator`
178
-
179
- ## 🚀 Azure へのデプロイ
180
-
181
- Next.js アプリを standalone モードで Azure Static Web Apps にデプロイし、バックエンド操作のために独立した Azure Functions に接続します。
182
-
183
- **1. リソースをプロビジョニング (Bicep IaC)**
184
-
185
- ```bash
186
- npx swallowkit provision --resource-group my-app-rg --location japaneast
187
- ```
188
-
189
- プロビジョニング完了後、CI/CD に必要なシークレット値がターミナルに表示されます。コピーしておいてください。
190
-
191
- **2. コードをプッシュ**
192
-
193
- ```bash
194
- git push origin main
195
- ```
196
-
197
- **3. 自動実行された CI/CD をキャンセル** — シークレット未登録のため失敗します。
198
-
199
- **4. 表示された値をシークレットに登録** — GitHub (Settings → Secrets) または Azure DevOps (Pipelines → Library) に登録します。
200
-
201
- **5. CI/CD ワークフローを手動で再実行します。**
202
-
203
- 詳細は **[デプロイガイド](./docs/deployment-guide.ja.md)** を参照してください。
204
-
205
- ## ライセンス
206
-
207
- MIT
208
-
209
- ## 🔗 関連リンク
210
-
211
- - [Azure Static Web Apps](https://learn.microsoft.com/ja-jp/azure/static-web-apps/)
212
- - [Azure Functions](https://learn.microsoft.com/ja-jp/azure/azure-functions/)
213
- - [Azure Cosmos DB](https://learn.microsoft.com/ja-jp/azure/cosmos-db/)
214
- - [Next.js](https://nextjs.org/)
215
- - [Zod](https://zod.dev/)
1
+ # SwallowKit
2
+
3
+ [![npm version](https://img.shields.io/npm/v/swallowkit.svg)](https://www.npmjs.com/package/swallowkit)
4
+ [![npm downloads](https://img.shields.io/npm/dm/swallowkit.svg)](https://www.npmjs.com/package/swallowkit)
5
+ [![VS Code Marketplace](https://img.shields.io/visual-studio-marketplace/v/himanago.swallowkit-vscode?label=VS%20Code%20Extension)](https://marketplace.visualstudio.com/items?itemName=himanago.swallowkit-vscode)
6
+ [![license](https://img.shields.io/npm/l/swallowkit.svg)](./LICENSE)
7
+
8
+ [English](./README.md) | 日本語
9
+
10
+ Next.js と Azure のための、スキーマ駆動アプリケーション開発ツールキットです。
11
+
12
+ SwallowKit は、共有された Zod スキーマを中心にして、保守しやすいフルスタックアプリケーションを Azure 上に構築するための scaffolding ツールです。1 つのスキーマ定義から、フロントエンドフォーム、BFF ルート、Azure Functions バックエンド、OpenAPI、インフラ定義、AI エージェント向けのプロジェクトメタデータなどを生成できます。
13
+
14
+ フロントエンド、バックエンド、データベース、バリデーション、API 契約、デプロイ構成がばらばらになりがちな Next.js + Azure アプリケーション開発を、明示的な構成で整理することを目的としています。
15
+
16
+ ## 🎯 なぜ SwallowKit か
17
+
18
+ AI はアプリケーションコードをすばやく生成できます。フレームワークは複雑さをうまく隠してくれます。しかし、本番で運用するアプリケーションには、依然として明示的なアーキテクチャが必要です。
19
+
20
+ 一般的なフルスタックアプリケーションでは、同じドメインモデルが多くの場所に重複して現れます。
21
+
22
+ - フロントエンドのフォーム型
23
+ - クライアント側バリデーション
24
+ - BFF のリクエスト・レスポンス型
25
+ - バックエンド DTO
26
+ - API 契約
27
+ - データベースエンティティ
28
+ - シードデータ
29
+ - インフラ・デプロイ構成
30
+
31
+ アプリケーションが大きくなるほど、これらの定義は少しずつずれていきます。SwallowKit は、スキーマを明示的な中心に置き、その周辺に必要なアプリケーション構造を生成することで、このずれを減らします。
32
+
33
+ **SwallowKit は、すべてを隠蔽するフルスタックフレームワークではありません。生成されたコードを読み、編集し、必要なら置き換えられることを重視した scaffolding ツールです。**
34
+
35
+ ## ✨ 主な機能
36
+
37
+ - **Zod スキーマを中心にした型定義** とバリデーション共有
38
+ - **Next.js、BFF ルート、Azure Functions、UI コンポーネントの CRUD scaffolding**
39
+ - **Bicep による Azure 向けインフラ定義**
40
+ - **複数言語の Azure Functions バックエンド対応**(TypeScript、C#、Python)
41
+ - **ローカル開発支援** とシードデータ
42
+ - **AI / MCP 向けのプロジェクトメタデータ** とコマンド
43
+ - **VS Code 拡張機能**
44
+
45
+ ## 🏗️ 想定アーキテクチャ
46
+
47
+ SwallowKit は、次のような構成のアプリケーションを主な対象にしています。
48
+
49
+ - Next.js
50
+ - Azure Static Web Apps
51
+ - Azure Functions
52
+ - Azure Cosmos DB
53
+ - Azure Bicep
54
+ - GitHub Actions または Azure Pipelines
55
+
56
+ 標準構成では、BFF パターンを採用します。
57
+
58
+ ```
59
+ ブラウザー
60
+ |
61
+ Next.js フロントエンド
62
+ |
63
+ Next.js BFF ルート
64
+ |
65
+ Azure Functions API
66
+ |
67
+ Azure Cosmos DB
68
+ ```
69
+
70
+ BFF レイヤーを置くことで、フロントエンドをシンプルに保ちながら、バックエンドサービス、認証・認可、クラウドリソースとの接続を整理しやすくします。
71
+
72
+ > **注意**: このプロジェクトは活発に開発中です。将来のバージョンでAPIが変更される可能性があります。
73
+
74
+ ## 📚 ドキュメント
75
+
76
+ 詳しい使い方はドキュメントサイトを参照してください([English](https://himanago.github.io/swallowkit/en/) もあります)。
77
+
78
+ - **[はじめる](https://himanago.github.io/swallowkit/ja/getting-started)** - 最初のプロジェクトセットアップ
79
+ - **[基本概念](https://himanago.github.io/swallowkit/ja/concepts)** - スキーマ中心のアーキテクチャ
80
+ - **[Scaffold ガイド](https://himanago.github.io/swallowkit/ja/scaffold-guide)** - CRUD コード生成
81
+ - **[ローカル開発](https://himanago.github.io/swallowkit/ja/dev-guide)** - Dev サーバー、seeds、モックコネクタ
82
+ - **[デプロイガイド](https://himanago.github.io/swallowkit/ja/deployment-guide)** - Azure へのデプロイ
83
+ - **[AI / MCP ガイド](https://himanago.github.io/swallowkit/ja/ai-mcp-guide)** - AI エージェント統合
84
+ - **[認証](https://himanago.github.io/swallowkit/ja/auth-guide)** - 認証と認可
85
+ - **[コネクタ](https://himanago.github.io/swallowkit/ja/connector-guide)** - 外部データソース統合
86
+
87
+ ## 🚀 クイックスタート
88
+
89
+ 新しいプロジェクトを作成します。
90
+
91
+ ```bash
92
+ npx swallowkit init my-app
93
+ cd my-app
94
+ ```
95
+
96
+ モデルを作成し、スキーマを編集します。
97
+
98
+ ```bash
99
+ npx swallowkit create-model todo
100
+ ```
101
+
102
+ ```typescript
103
+ // shared/models/todo.ts
104
+ import { z } from 'zod';
105
+
106
+ export const todo = z.object({
107
+ id: z.string(),
108
+ text: z.string().min(1).max(200),
109
+ completed: z.boolean().default(false),
110
+ createdAt: z.string().optional(),
111
+ updatedAt: z.string().optional(),
112
+ });
113
+
114
+ export type Todo = z.infer<typeof todo>;
115
+ ```
116
+
117
+ CRUD コードを生成し、開発サーバーを起動します。
118
+
119
+ ```bash
120
+ npx swallowkit scaffold todo
121
+ npx swallowkit dev
122
+ ```
123
+
124
+ Azure Functions、Next.js BFF ルート、React UI コンポーネントが、共有スキーマから型付きで生成されます。
125
+
126
+ ## 🤖 AI エージェントとの協調
127
+
128
+ SwallowKit は、AI コーディングエージェントがプロジェクト構造を理解し、公式の生成コマンドを通じて変更を行い、生成物を検証できるように、機械可読なプロジェクトメタデータとコマンドインターフェースを提供します。
129
+
130
+ 目的は、AI に自由にファイルを書き換えさせることではなく、明示的なアーキテクチャ境界の中で安全に開発を支援させることです。
131
+
132
+ ## 📦 生成されるプロジェクト構成
133
+
134
+ ```
135
+ .
136
+ ├── app/ # Next.js ページと BFF API ルート
137
+ ├── shared/
138
+ └── models/ # 共有 Zod スキーマ(単一のソース)
139
+ ├── functions/ # Azure Functions バックエンド
140
+ ├── infra/ # Bicep テンプレート
141
+ ├── lib/ # BFF ヘルパーと scaffold 設定
142
+ └── .swallowkit/ # SwallowKit プロジェクトメタデータ
143
+ ```
144
+
145
+ ## 🔗 ステータス
146
+
147
+ SwallowKit は現在開発中です。API、プロジェクト構成、生成されるコードは変更される可能性があります。
148
+
149
+ フィードバック、Issue、小さなサンプルユースケースの共有を歓迎します。
150
+
151
+ ## 📄 ライセンス
152
+
153
+ MIT