swallowkit 1.0.0-beta.3 โ†’ 1.0.0-beta.30

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 (201) hide show
  1. package/LICENSE +21 -21
  2. package/README.ja.md +321 -215
  3. package/README.md +388 -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 +444 -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 +15 -0
  33. package/dist/cli/commands/init.d.ts.map +1 -1
  34. package/dist/cli/commands/init.js +2693 -1706
  35. package/dist/cli/commands/init.js.map +1 -1
  36. package/dist/cli/commands/scaffold.d.ts.map +1 -1
  37. package/dist/cli/commands/scaffold.js +448 -129
  38. package/dist/cli/commands/scaffold.js.map +1 -1
  39. package/dist/cli/index.d.ts +5 -1
  40. package/dist/cli/index.d.ts.map +1 -1
  41. package/dist/cli/index.js +200 -42
  42. package/dist/cli/index.js.map +1 -1
  43. package/dist/core/config.d.ts +8 -2
  44. package/dist/core/config.d.ts.map +1 -1
  45. package/dist/core/config.js +94 -5
  46. package/dist/core/config.js.map +1 -1
  47. package/dist/core/mock/connector-mock-server.d.ts +101 -0
  48. package/dist/core/mock/connector-mock-server.d.ts.map +1 -0
  49. package/dist/core/mock/connector-mock-server.js +480 -0
  50. package/dist/core/mock/connector-mock-server.js.map +1 -0
  51. package/dist/core/mock/zod-mock-generator.d.ts +14 -0
  52. package/dist/core/mock/zod-mock-generator.d.ts.map +1 -0
  53. package/dist/core/mock/zod-mock-generator.js +163 -0
  54. package/dist/core/mock/zod-mock-generator.js.map +1 -0
  55. package/dist/core/operations/create-model.d.ts +15 -0
  56. package/dist/core/operations/create-model.d.ts.map +1 -0
  57. package/dist/core/operations/create-model.js +171 -0
  58. package/dist/core/operations/create-model.js.map +1 -0
  59. package/dist/core/operations/runtime.d.ts +32 -0
  60. package/dist/core/operations/runtime.d.ts.map +1 -0
  61. package/dist/core/operations/runtime.js +225 -0
  62. package/dist/core/operations/runtime.js.map +1 -0
  63. package/dist/core/operations/scaffold-machine.d.ts +16 -0
  64. package/dist/core/operations/scaffold-machine.d.ts.map +1 -0
  65. package/dist/core/operations/scaffold-machine.js +63 -0
  66. package/dist/core/operations/scaffold-machine.js.map +1 -0
  67. package/dist/core/project/manifest.d.ts +92 -0
  68. package/dist/core/project/manifest.d.ts.map +1 -0
  69. package/dist/core/project/manifest.js +321 -0
  70. package/dist/core/project/manifest.js.map +1 -0
  71. package/dist/core/project/validation.d.ts +20 -0
  72. package/dist/core/project/validation.d.ts.map +1 -0
  73. package/dist/core/project/validation.js +209 -0
  74. package/dist/core/project/validation.js.map +1 -0
  75. package/dist/core/scaffold/auth-generator.d.ts +38 -0
  76. package/dist/core/scaffold/auth-generator.d.ts.map +1 -0
  77. package/dist/core/scaffold/auth-generator.js +1244 -0
  78. package/dist/core/scaffold/auth-generator.js.map +1 -0
  79. package/dist/core/scaffold/connector-functions-generator.d.ts +41 -0
  80. package/dist/core/scaffold/connector-functions-generator.d.ts.map +1 -0
  81. package/dist/core/scaffold/connector-functions-generator.js +1027 -0
  82. package/dist/core/scaffold/connector-functions-generator.js.map +1 -0
  83. package/dist/core/scaffold/functions-generator.d.ts +7 -1
  84. package/dist/core/scaffold/functions-generator.d.ts.map +1 -1
  85. package/dist/core/scaffold/functions-generator.js +920 -213
  86. package/dist/core/scaffold/functions-generator.js.map +1 -1
  87. package/dist/core/scaffold/model-parser.d.ts +20 -1
  88. package/dist/core/scaffold/model-parser.d.ts.map +1 -1
  89. package/dist/core/scaffold/model-parser.js +328 -135
  90. package/dist/core/scaffold/model-parser.js.map +1 -1
  91. package/dist/core/scaffold/native-schema-generator.d.ts +13 -0
  92. package/dist/core/scaffold/native-schema-generator.d.ts.map +1 -0
  93. package/dist/core/scaffold/native-schema-generator.js +677 -0
  94. package/dist/core/scaffold/native-schema-generator.js.map +1 -0
  95. package/dist/core/scaffold/nextjs-generator.d.ts +8 -0
  96. package/dist/core/scaffold/nextjs-generator.d.ts.map +1 -1
  97. package/dist/core/scaffold/nextjs-generator.js +314 -182
  98. package/dist/core/scaffold/nextjs-generator.js.map +1 -1
  99. package/dist/core/scaffold/openapi-generator.d.ts +3 -0
  100. package/dist/core/scaffold/openapi-generator.d.ts.map +1 -0
  101. package/dist/core/scaffold/openapi-generator.js +190 -0
  102. package/dist/core/scaffold/openapi-generator.js.map +1 -0
  103. package/dist/core/scaffold/ui-generator.d.ts +10 -4
  104. package/dist/core/scaffold/ui-generator.d.ts.map +1 -1
  105. package/dist/core/scaffold/ui-generator.js +768 -663
  106. package/dist/core/scaffold/ui-generator.js.map +1 -1
  107. package/dist/database/base-model.d.ts +3 -3
  108. package/dist/database/base-model.js +3 -3
  109. package/dist/index.d.ts +2 -2
  110. package/dist/index.d.ts.map +1 -1
  111. package/dist/index.js +2 -1
  112. package/dist/index.js.map +1 -1
  113. package/dist/machine/contracts.d.ts +16 -0
  114. package/dist/machine/contracts.d.ts.map +1 -0
  115. package/dist/machine/contracts.js +3 -0
  116. package/dist/machine/contracts.js.map +1 -0
  117. package/dist/machine/errors.d.ts +11 -0
  118. package/dist/machine/errors.d.ts.map +1 -0
  119. package/dist/machine/errors.js +34 -0
  120. package/dist/machine/errors.js.map +1 -0
  121. package/dist/machine/index.d.ts +3 -0
  122. package/dist/machine/index.d.ts.map +1 -0
  123. package/dist/machine/index.js +156 -0
  124. package/dist/machine/index.js.map +1 -0
  125. package/dist/mcp/index.d.ts +25 -0
  126. package/dist/mcp/index.d.ts.map +1 -0
  127. package/dist/mcp/index.js +184 -0
  128. package/dist/mcp/index.js.map +1 -0
  129. package/dist/types/index.d.ts +65 -0
  130. package/dist/types/index.d.ts.map +1 -1
  131. package/dist/utils/package-manager.d.ts +109 -0
  132. package/dist/utils/package-manager.d.ts.map +1 -0
  133. package/dist/utils/package-manager.js +215 -0
  134. package/dist/utils/package-manager.js.map +1 -0
  135. package/dist/utils/python-uv.d.ts +21 -0
  136. package/dist/utils/python-uv.d.ts.map +1 -0
  137. package/dist/utils/python-uv.js +111 -0
  138. package/dist/utils/python-uv.js.map +1 -0
  139. package/package.json +85 -73
  140. package/src/__tests__/__snapshots__/functions-generator.test.ts.snap +1139 -0
  141. package/src/__tests__/__snapshots__/nextjs-generator.test.ts.snap +194 -0
  142. package/src/__tests__/__snapshots__/ui-generator.test.ts.snap +532 -0
  143. package/src/__tests__/auth.test.ts +654 -0
  144. package/src/__tests__/config.test.ts +274 -0
  145. package/src/__tests__/connector-functions-generator.test.ts +288 -0
  146. package/src/__tests__/connector-mock-server.test.ts +439 -0
  147. package/src/__tests__/connector-model-bff.test.ts +162 -0
  148. package/src/__tests__/dev-seeds.test.ts +173 -0
  149. package/src/__tests__/dev.test.ts +252 -0
  150. package/src/__tests__/fixtures.ts +144 -0
  151. package/src/__tests__/functions-generator.test.ts +237 -0
  152. package/src/__tests__/init.test.ts +109 -0
  153. package/src/__tests__/machine.test.ts +251 -0
  154. package/src/__tests__/mcp.test.ts +117 -0
  155. package/src/__tests__/model-parser.test.ts +52 -0
  156. package/src/__tests__/nextjs-generator.test.ts +97 -0
  157. package/src/__tests__/openapi-generator.test.ts +43 -0
  158. package/src/__tests__/package-manager.test.ts +189 -0
  159. package/src/__tests__/python-uv.test.ts +48 -0
  160. package/src/__tests__/scaffold.test.ts +67 -0
  161. package/src/__tests__/string-utils.test.ts +75 -0
  162. package/src/__tests__/ui-generator.test.ts +144 -0
  163. package/src/__tests__/zod-mock-generator.test.ts +132 -0
  164. package/src/cli/commands/add-auth.ts +500 -0
  165. package/src/cli/commands/add-connector.ts +158 -0
  166. package/src/cli/commands/create-model.ts +62 -0
  167. package/src/cli/commands/dev-seeds.ts +614 -0
  168. package/src/cli/commands/dev.ts +1134 -0
  169. package/src/cli/commands/index.ts +9 -0
  170. package/src/cli/commands/init.ts +3477 -0
  171. package/src/cli/commands/provision.ts +193 -0
  172. package/src/cli/commands/scaffold.ts +1001 -0
  173. package/src/cli/index.ts +196 -0
  174. package/src/core/config.ts +312 -0
  175. package/src/core/mock/connector-mock-server.ts +555 -0
  176. package/src/core/mock/zod-mock-generator.ts +205 -0
  177. package/src/core/operations/create-model.ts +174 -0
  178. package/src/core/operations/runtime.ts +235 -0
  179. package/src/core/operations/scaffold-machine.ts +91 -0
  180. package/src/core/project/manifest.ts +402 -0
  181. package/src/core/project/validation.ts +229 -0
  182. package/src/core/scaffold/auth-generator.ts +1284 -0
  183. package/src/core/scaffold/connector-functions-generator.ts +1128 -0
  184. package/src/core/scaffold/functions-generator.ts +970 -0
  185. package/src/core/scaffold/model-parser.ts +841 -0
  186. package/src/core/scaffold/native-schema-generator.ts +798 -0
  187. package/src/core/scaffold/nextjs-generator.ts +370 -0
  188. package/src/core/scaffold/openapi-generator.ts +212 -0
  189. package/src/core/scaffold/ui-generator.ts +1061 -0
  190. package/src/database/base-model.ts +184 -0
  191. package/src/database/client.ts +140 -0
  192. package/src/database/repository.ts +104 -0
  193. package/src/database/runtime-check.ts +25 -0
  194. package/src/index.ts +27 -0
  195. package/src/machine/contracts.ts +17 -0
  196. package/src/machine/errors.ts +34 -0
  197. package/src/machine/index.ts +173 -0
  198. package/src/mcp/index.ts +185 -0
  199. package/src/types/index.ts +134 -0
  200. package/src/utils/package-manager.ts +229 -0
  201. package/src/utils/python-uv.ts +96 -0
package/README.md CHANGED
@@ -1,216 +1,388 @@
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.ja.md)
8
-
9
- **Type-safe schema-driven development toolkit for Next.js applications on Azure**
10
-
11
- SwallowKit enables developers to build full-stack Next.js applications with external Azure Functions backends while maintaining end-to-end type safety through shared Zod schemas.
12
-
13
- Deploy your Next.js app to Azure Static Web Apps using standalone mode, and connect to independent Azure Functions for backend operations.
14
-
15
- Next.js API routes are restricted to use only as BFF (Backend For Frontend), offloading business logic to Azure Functions to provide clear separation between client and server.
16
-
17
- Featuring Scaffold functionality to automatically generate CRUD operations from Zod schemas, achieving type-safe integration with Cosmos DB and consistent type definitions and validation.
18
-
19
- > **Note**: This project is in active development. APIs may change in future versions.
20
-
21
- ## โœจ Key Features
22
-
23
- - **๐Ÿ”„ Zod Schema Sharing** - Same schema across frontend, BFF, Azure Functions, and Cosmos DB
24
- - **โšก CRUD Code Generation** - Auto-generate Azure Functions + Next.js code with `swallowkit scaffold`
25
- - **๐Ÿ›ก๏ธ Full Type Safety** - End-to-end TypeScript from client to database
26
- - **๐ŸŽฏ BFF Pattern** - Next.js API Routes as BFF layer with auto-validation and resource inference
27
- - **โ˜๏ธ Azure Optimized** - Minimal-cost architecture with Static Web Apps + Functions + Cosmos DB
28
- - **๐Ÿš€ Easy Deployment** - Auto-generated Bicep IaC + CI/CD workflows
29
-
30
- ## ๐Ÿ“š Documentation
31
-
32
- - **[CLI Reference](./docs/cli-reference.md)** - All commands in detail
33
- - **[Scaffold Guide](./docs/scaffold-guide.md)** - CRUD code generation
34
- - **[Zod Schema Sharing Guide](./docs/zod-schema-sharing-guide.md)** - Schema design
35
- - **[Deployment Guide](./docs/deployment-guide.md)** - Deploy to Azure
36
-
37
- ## ๐Ÿš€ Quick Start
38
-
39
- ### 1. Create Project
40
-
41
- ```bash
42
- npx swallowkit init my-app
43
- cd my-app
44
- ```
45
-
46
- ### 2. Create Models
47
-
48
- You can create multiple models at once:
49
-
50
- ```bash
51
- npx swallowkit create-model category todo
52
- ```
53
-
54
- This generates `shared/models/category.ts` and `shared/models/todo.ts`. Customize them by adding your required fields:
55
-
56
- ```typescript
57
- // shared/models/category.ts
58
- import { z } from 'zod';
59
-
60
- export const category = z.object({
61
- id: z.string(),
62
- name: z.string().min(1).max(50),
63
- createdAt: z.string().optional(),
64
- updatedAt: z.string().optional(),
65
- });
66
-
67
- export type Category = z.infer<typeof category>;
68
- ```
69
-
70
- For parent-child relationships, use **nested schemas** instead of ID references:
71
-
72
- ```typescript
73
- // shared/models/todo.ts
74
- import { z } from 'zod';
75
- import { category } from './category';
76
-
77
- export const todo = z.object({
78
- id: z.string(),
79
- text: z.string().min(1).max(200),
80
- completed: z.boolean().default(false),
81
- category: category.optional(), // Nested object (not categoryId)
82
- createdAt: z.string().optional(),
83
- updatedAt: z.string().optional(),
84
- });
85
-
86
- export type Todo = z.infer<typeof todo>;
87
- ```
88
-
89
- > **Tip**: Nesting preserves type safety and stores related data together in the document, which is natural for Cosmos DB's document model.
90
-
91
- ### 3. Generate CRUD Code
92
-
93
- ```bash
94
- npx swallowkit scaffold shared/models/todo.ts
95
- ```
96
-
97
- This auto-generates:
98
- - โœ… Azure Functions (CRUD endpoints + Cosmos DB bindings)
99
- - โœ… Next.js BFF API Routes (auto-validation + resource inference)
100
- - โœ… React Components (type-safe forms)
101
-
102
- ### 4. Start Development Server
103
-
104
- ```bash
105
- npx swallowkit dev
106
- ```
107
-
108
- - Next.js: http://localhost:3000
109
- - Azure Functions: http://localhost:7071
110
-
111
- ### 5. Use from Frontend
112
-
113
- ```typescript
114
- import { api } from '@/lib/api/backend';
115
- import type { Todo } from '@/shared/models/todo';
116
-
117
- // Get all - call BFF endpoint
118
- const todos = await api.get<Todo[]>('/api/todos');
119
-
120
- // Create - validated by backend
121
- const created = await api.post<Todo>('/api/todos', {
122
- text: 'Buy milk',
123
- completed: false
124
- });
125
-
126
- // Update - validated by backend
127
- const updated = await api.put<Todo>('/api/todos/123', { completed: true });
128
-
129
- // Delete
130
- await api.delete('/api/todos/123');
131
- ```
132
-
133
- ## ๐Ÿ—๏ธ Architecture
134
-
135
- ```
136
- โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
137
- โ”‚ Frontend (React) โ”‚
138
- โ”‚ - Client Components โ”‚
139
- โ”‚ - Server Components (SSR) โ”‚
140
- โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
141
- โ”‚ api.post('/api/todos', data)
142
- โ–ผ
143
- โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
144
- โ”‚ BFF Layer (Next.js API Routes) โ”‚
145
- โ”‚ - Auto Schema Validation (Zod) โ”‚
146
- โ”‚ - Error Handling โ”‚
147
- โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
148
- โ”‚ HTTP Request
149
- โ–ผ
150
- โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
151
- โ”‚ Azure Functions (Backend) โ”‚
152
- โ”‚ - HTTP Triggers (CRUD) โ”‚
153
- โ”‚ - Zod Validation (Re-check) โ”‚
154
- โ”‚ - Business Logic โ”‚
155
- โ”‚ - Cosmos DB Bindings โ”‚
156
- โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
157
- โ”‚
158
- โ–ผ
159
- โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
160
- โ”‚ Azure Cosmos DB โ”‚
161
- โ”‚ - NoSQL Database โ”‚
162
- โ”‚ - Zod Schema Validation โ”‚
163
- โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
164
- ```
165
-
166
- **Key Patterns:**
167
- - **BFF (Backend For Frontend)**: Next.js API Routes proxy to Azure Functions
168
- - **Shared Schemas**: Zod schemas used across frontend, BFF, Functions, and DB
169
- - **Type Safety**: TypeScript types auto-inferred from Zod
170
- - **Managed Identity**: Secure service connections (no connection strings)
171
-
172
- ## ๐Ÿ“ฆ Prerequisites
173
-
174
- - Node.js 22.x
175
- - Azure Cosmos DB Emulator (local development)
176
- - [Official documentation (vNext recommended)](https://learn.microsoft.com/en-us/azure/cosmos-db/emulator-linux)
177
- - Windows: [Download](https://aka.ms/cosmosdb-emulator)
178
- - Docker: `docker run -p 8081:8081 mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator`
179
-
180
- ## ๐Ÿš€ Deploy to Azure
181
-
182
- Deploy your Next.js app to Azure Static Web Apps using standalone mode, and connect to independent Azure Functions for backend operations.
183
-
184
- **1. Provision resources (Bicep IaC)**
185
-
186
- ```bash
187
- npx swallowkit provision --resource-group my-app-rg --location japaneast
188
- ```
189
-
190
- After provisioning, the required CI/CD secret values are displayed in the terminal. Copy them.
191
-
192
- **2. Push code**
193
-
194
- ```bash
195
- git push origin main
196
- ```
197
-
198
- **3. Cancel the auto-triggered CI/CD run** โ€” it will fail because secrets are not registered yet.
199
-
200
- **4. Register the displayed secret values** in GitHub (Settings โ†’ Secrets) or Azure DevOps (Pipelines โ†’ Library).
201
-
202
- **5. Manually re-run the CI/CD workflow.**
203
-
204
- See **[Deployment Guide](./docs/deployment-guide.md)** for details.
205
-
206
- ## License
207
-
208
- MIT
209
-
210
- ## ๐Ÿ”— Related Links
211
-
212
- - [Azure Static Web Apps](https://learn.microsoft.com/en-us/azure/static-web-apps/)
213
- - [Azure Functions](https://learn.microsoft.com/en-us/azure/azure-functions/)
214
- - [Azure Cosmos DB](https://learn.microsoft.com/en-us/azure/cosmos-db/)
215
- - [Next.js](https://nextjs.org/)
216
- - [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.ja.md)
9
+
10
+ **Type-safe schema-driven development toolkit for Next.js applications on Azure**
11
+
12
+ SwallowKit enables developers to build full-stack Next.js applications with external Azure Functions backends while maintaining end-to-end type safety through shared Zod schemas.
13
+
14
+ Deploy your Next.js app to Azure Static Web Apps using standalone mode, and connect to independent Azure Functions for backend operations.
15
+
16
+ Next.js API routes are restricted to use only as BFF (Backend For Frontend), offloading business logic to Azure Functions to provide clear separation between client and server.
17
+
18
+ Featuring Scaffold functionality to automatically generate CRUD operations from Zod schemas, achieving type-safe integration with Cosmos DB and consistent type definitions and validation.
19
+
20
+ > **Note**: This project is in active development. APIs may change in future versions.
21
+
22
+ ## โœจ Key Features
23
+
24
+ - **๐Ÿ”„ Zod Schema Sharing** - Keep Zod as the source of truth across frontend, BFF, Azure Functions, and Cosmos DB
25
+ - **โšก CRUD Code Generation** - Auto-generate Azure Functions + Next.js code with `swallowkit scaffold`
26
+ - **๐ŸŒ Multi-language Functions Backends** - Choose TypeScript, C#, or Python for Azure Functions during `init`
27
+ - **๐Ÿงฌ OpenAPI Export + Native Codegen** - For C#/Python backends, `scaffold` exports OpenAPI from Zod and generates backend schema assets with native language tooling
28
+ - **๐Ÿ›ก๏ธ Contract Safety** - Keep frontend/BFF contracts aligned with backend implementations through shared Zod or native-generated backend models
29
+ - **๐ŸŽฏ BFF Pattern** - Next.js API Routes as BFF layer with auto-validation and resource inference
30
+ - **โ˜๏ธ Azure Optimized** - Minimal-cost architecture with Static Web Apps + Functions + Cosmos DB
31
+ - **๐Ÿš€ Easy Deployment** - Auto-generated Bicep IaC + CI/CD workflows
32
+ - **๐Ÿค– AI-Friendly** - Auto-generated instruction files (`AGENTS.md`, `CLAUDE.md`, `.github/copilot-instructions.md`) and layer-specific rules help GitHub Copilot, Claude Code, and OpenAI Codex follow project conventions
33
+ - **๐Ÿง  MCP + Machine Interface** - `swallowkit machine ...` exposes deterministic JSON inspection / validation / generation commands, and `swallowkit-mcp` exposes the same capabilities over MCP stdio
34
+ - **๐Ÿ”Œ External Data Connectors** - Integrate MySQL, PostgreSQL, REST APIs, and other external data sources alongside Cosmos DB โ€” same Zod-driven scaffold workflow with full type safety
35
+ - **๐Ÿ” Authentication & Authorization** - Built-in support for custom JWT auth (with external RDB user stores) and role-based access control per model โ€” with planned Static Web Apps auth integration
36
+ - **๐Ÿงฉ [VS Code Extension](https://marketplace.visualstudio.com/items?itemName=himanago.swallowkit-vscode)** - GUI wizard for init/scaffold/dev, right-click model scaffolding, dev server status bar, and TypeScript snippets
37
+
38
+ ## ๐Ÿ“š Documentation
39
+
40
+ Visit the **[SwallowKit Documentation](https://himanago.github.io/swallowkit/)** for the full docs (also available in [ๆ—ฅๆœฌ่ชž](https://himanago.github.io/swallowkit/ja/)).
41
+
42
+ - **[CLI Reference](https://himanago.github.io/swallowkit/en/cli-reference)** - All commands in detail
43
+ - **[Scaffold Guide](https://himanago.github.io/swallowkit/en/scaffold-guide)** - CRUD code generation
44
+ - **[Connector Guide](https://himanago.github.io/swallowkit/en/connector-guide)** - External data source integration
45
+ - **[Authentication Guide](https://himanago.github.io/swallowkit/en/auth-guide)** - Authentication and role-based access control
46
+ - **[Zod Schema Sharing Guide](https://himanago.github.io/swallowkit/en/zod-schema-sharing-guide)** - Schema design
47
+ - **[Deployment Guide](https://himanago.github.io/swallowkit/en/deployment-guide)** - Deploy to Azure
48
+
49
+ ## ๐Ÿš€ Quick Start
50
+
51
+ ### 1. Create Project
52
+
53
+ ```bash
54
+ npx swallowkit init my-app
55
+ # or
56
+ pnpm dlx swallowkit init my-app
57
+ cd my-app
58
+ ```
59
+
60
+ The interactive prompts ask for CI/CD provider, Azure Functions backend language, Cosmos DB mode, and network settings. You can also specify them as flags to skip prompts entirely:
61
+
62
+ ```bash
63
+ # Non-interactive mode (useful for VS Code extensions or automation)
64
+ npx swallowkit init my-app --cicd github --backend-language python --cosmos-db-mode serverless --vnet outbound
65
+ ```
66
+
67
+ | Flag | Values | Description |
68
+ |------|--------|-------------|
69
+ | `--cicd <provider>` | `github`, `azure`, `skip` | CI/CD provider |
70
+ | `--backend-language <language>` | `typescript`, `csharp`, `python` | Azure Functions backend language |
71
+ | `--cosmos-db-mode <mode>` | `freetier`, `serverless` | Cosmos DB pricing mode |
72
+ | `--vnet <option>` | `outbound`, `none` | Network security |
73
+
74
+ Omit any flag to be prompted for that value interactively.
75
+
76
+ ### 2. Create Models
77
+
78
+ You can create multiple models at once:
79
+
80
+ ```bash
81
+ npx swallowkit create-model category todo
82
+ # or
83
+ pnpm dlx swallowkit create-model category todo
84
+ ```
85
+
86
+ This generates `shared/models/category.ts` and `shared/models/todo.ts`. Customize them by adding your required fields:
87
+
88
+ ```typescript
89
+ // shared/models/category.ts
90
+ import { z } from 'zod';
91
+
92
+ export const category = z.object({
93
+ id: z.string(),
94
+ name: z.string().min(1).max(50),
95
+ createdAt: z.string().optional(),
96
+ updatedAt: z.string().optional(),
97
+ });
98
+
99
+ export type Category = z.infer<typeof category>;
100
+ ```
101
+
102
+ For parent-child relationships, use **nested schemas** instead of ID references:
103
+
104
+ ```typescript
105
+ // shared/models/todo.ts
106
+ import { z } from 'zod';
107
+ import { category } from './category';
108
+
109
+ export const todo = z.object({
110
+ id: z.string(),
111
+ text: z.string().min(1).max(200),
112
+ completed: z.boolean().default(false),
113
+ category: category.optional(), // Nested object (not categoryId)
114
+ createdAt: z.string().optional(),
115
+ updatedAt: z.string().optional(),
116
+ });
117
+
118
+ export type Todo = z.infer<typeof todo>;
119
+ ```
120
+
121
+ > **Tip**: Nesting preserves type safety and stores related data together in the document, which is natural for Cosmos DB's document model.
122
+
123
+ ### 3. Generate CRUD Code
124
+
125
+ ```bash
126
+ npx swallowkit scaffold shared/models/todo.ts
127
+ # or
128
+ pnpm dlx swallowkit scaffold shared/models/todo.ts
129
+ ```
130
+
131
+ This auto-generates:
132
+ - โœ… Azure Functions (CRUD endpoints + Cosmos DB bindings)
133
+ - โœ… Next.js BFF API Routes (auto-validation + resource inference)
134
+ - โœ… React Components (type-safe forms)
135
+
136
+ If you selected `csharp` or `python` at `init` time, `swallowkit scaffold` also writes an OpenAPI document under `functions/openapi/` and generates native backend schema assets under `functions/generated/`.
137
+
138
+ ### 4. Start Development Server
139
+
140
+ ```bash
141
+ npx swallowkit dev
142
+ # or
143
+ pnpm dlx swallowkit dev
144
+ ```
145
+
146
+ - Next.js: http://localhost:3000
147
+ - Azure Functions: http://localhost:7071
148
+
149
+ Backend-specific notes:
150
+
151
+ - **Python backends**: `swallowkit dev` uses **uv** for local runtime management. It installs or reuses a project-local `uv` binary under `.uv/bin`, keeps uv-managed Python under `.uv/python`, creates `functions/.venv` for the Functions app, and creates `functions/.codegen-venv` for Python schema generation.
152
+ - **C# backends**: Azure Functions isolated worker can take longer to answer on cold start while the worker build completes. `swallowkit dev` waits for the Functions host to start responding before it prints the backend URL as ready.
153
+
154
+ If you want to replace Cosmos DB Emulator data before startup, you can either generate an environment template or export the data currently stored in the local emulator:
155
+
156
+ ```bash
157
+ npx swallowkit create-dev-seeds local
158
+ # edit dev-seeds/local/*.json
159
+ npx swallowkit dev --seed-env local
160
+
161
+ # or capture current emulator data as reusable seeds
162
+ npx swallowkit create-dev-seeds local --from-emulator --force
163
+ npx swallowkit dev --seed-env local
164
+ ```
165
+
166
+ This workflow is designed for local debugging against the Cosmos DB Emulator:
167
+
168
+ - `create-dev-seeds <environment>` generates one JSON template per schema under `dev-seeds/<environment>/`
169
+ - `create-dev-seeds <environment> --from-emulator` exports the current data from the matching local Cosmos DB Emulator containers into the same file layout
170
+ - each file name maps to a schema/container, for example `shared/models/todo.ts` -> `dev-seeds/local/todo.json` -> `Todos`
171
+ - when you start `dev --seed-env <environment>`, SwallowKit replaces the existing data for each matching container with the JSON documents from that environment
172
+ - containers without a matching JSON file are left untouched
173
+ - if `--seed-env` is omitted, or `dev-seeds/<environment>/` does not exist, current emulator data is preserved
174
+ - exported files strip Cosmos system properties such as `_etag` before saving so they can be replayed safely
175
+
176
+ Example file layout:
177
+
178
+ ```text
179
+ dev-seeds/
180
+ local/
181
+ todo.json
182
+ category.json
183
+ staging-debug/
184
+ todo.json
185
+ ```
186
+
187
+ Each `{schema}.json` file can contain either a single JSON object or an array of JSON objects. Every document must include an `id`:
188
+
189
+ ```json
190
+ [
191
+ {
192
+ "id": "seed-todo-001",
193
+ "name": "Seed todo one",
194
+ "createdAt": "2026-03-21T00:00:00.000Z",
195
+ "updatedAt": "2026-03-21T00:00:00.000Z"
196
+ },
197
+ {
198
+ "id": "seed-todo-002",
199
+ "name": "Seed todo two",
200
+ "createdAt": "2026-03-21T00:00:01.000Z",
201
+ "updatedAt": "2026-03-21T00:00:01.000Z"
202
+ }
203
+ ]
204
+ ```
205
+
206
+ Recommended workflow:
207
+
208
+ ```bash
209
+ npx swallowkit create-model todo
210
+ npx swallowkit scaffold shared/models/todo.ts
211
+ npx swallowkit create-dev-seeds local
212
+ # edit dev-seeds/local/todo.json
213
+ npx swallowkit dev --seed-env local
214
+
215
+ # or export your current local Cosmos Emulator data
216
+ npx swallowkit create-dev-seeds local --from-emulator --force
217
+ npx swallowkit dev --seed-env local
218
+ ```
219
+
220
+ ### 5. Use from Frontend
221
+
222
+ ```typescript
223
+ import { api } from '@/lib/api/backend';
224
+ import type { Todo } from '@/shared/models/todo';
225
+
226
+ // Get all - call BFF endpoint
227
+ const todos = await api.get<Todo[]>('/api/todos');
228
+
229
+ // Create - validated by backend
230
+ const created = await api.post<Todo>('/api/todos', {
231
+ text: 'Buy milk',
232
+ completed: false
233
+ });
234
+
235
+ // Update - validated by backend
236
+ const updated = await api.put<Todo>('/api/todos/123', { completed: true });
237
+
238
+ // Delete
239
+ await api.delete('/api/todos/123');
240
+ ```
241
+
242
+ ### 6. Connect External Data Sources (Optional)
243
+
244
+ SwallowKit supports **connectors** for integrating external RDB databases and REST APIs alongside Cosmos DB, using the same Zod-driven workflow:
245
+
246
+ ```bash
247
+ # Register a connector
248
+ npx swallowkit add-connector mysql --type rdb --provider mysql --connection-env MYSQL_CONNECTION_STRING
249
+
250
+ # Create a connector-aware model
251
+ npx swallowkit create-model user --connector mysql
252
+ # edit shared/models/user.ts (customize schema + connectorConfig)
253
+
254
+ # Scaffold generates connector-specific Functions code
255
+ npx swallowkit scaffold shared/models/user.ts
256
+
257
+ # Develop locally with mock data (no real MySQL needed)
258
+ npx swallowkit dev --mock-connectors
259
+ ```
260
+
261
+ The frontend and BFF layer are completely transparent to data source differences โ€” `callFunction()` works identically for Cosmos DB and connector models. See the **[Connector Guide](https://himanago.github.io/swallowkit/en/connector-guide)** for details.
262
+
263
+ ## ๐Ÿค– AI / MCP Integration
264
+
265
+ SwallowKit provides a machine-readable CLI surface for coding agents and MCP adapters. Instead of letting AI guess raw filesystem changes, it can go through SwallowKit's official generators, inspectors, and validators.
266
+
267
+ ```bash
268
+ # Inspect framework-owned project metadata
269
+ npx swallowkit machine inspect project
270
+
271
+ # Validate SwallowKit conventions and generated artifacts
272
+ npx swallowkit machine validate project
273
+
274
+ # Generate through the official machine interface
275
+ npx swallowkit machine generate model todo --overwrite never
276
+ npx swallowkit machine generate scaffold todo --api-only
277
+ ```
278
+
279
+ `swallowkit machine` is:
280
+
281
+ - non-interactive
282
+ - deterministic
283
+ - JSON-only on stdout
284
+ - structured on success and failure
285
+
286
+ For MCP clients, use the bundled stdio server:
287
+
288
+ ```bash
289
+ npx swallowkit-mcp
290
+ ```
291
+
292
+ Projects generated by `swallowkit init` include a project-scoped `.mcp.json` bootstrap that launches the locally installed SwallowKit MCP entrypoint. Agent runtimes that support repository MCP discovery can start using the same `swallowkit_*` tools automatically from the project root after project dependencies are installed.
293
+
294
+ When a runtime does not auto-load project MCP config, the generated instruction files still steer the agent toward `swallowkit machine ...`, and you can manually register the same launcher in the client.
295
+
296
+ The MCP server is intentionally a thin adapter with explicit tools only. It delegates real work to the machine CLI.
297
+
298
+ ## ๐Ÿ—๏ธ Architecture
299
+
300
+ ```
301
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
302
+ โ”‚ Frontend (React) โ”‚
303
+ โ”‚ - Client Components โ”‚
304
+ โ”‚ - Server Components (SSR) โ”‚
305
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
306
+ โ”‚ api.post('/api/todos', data)
307
+ โ–ผ
308
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
309
+ โ”‚ BFF Layer (Next.js API Routes) โ”‚
310
+ โ”‚ - Auto Schema Validation (Zod) โ”‚
311
+ โ”‚ - Error Handling โ”‚
312
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
313
+ โ”‚ HTTP Request
314
+ โ–ผ
315
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
316
+ โ”‚ Azure Functions (Backend) โ”‚
317
+ โ”‚ - HTTP Triggers (CRUD) โ”‚
318
+ โ”‚ - Zod Validation (Re-check) โ”‚
319
+ โ”‚ - Business Logic โ”‚
320
+ โ”‚ - Data Source Bindings โ”‚
321
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
322
+ โ”‚ โ”‚ โ”‚
323
+ โ–ผ โ–ผ โ–ผ
324
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
325
+ โ”‚ Azure Cosmos โ”‚ โ”‚ External โ”‚ โ”‚ External SaaS โ”‚
326
+ โ”‚ DB (Default) โ”‚ โ”‚ RDB (MySQL โ”‚ โ”‚ APIs (REST) โ”‚
327
+ โ”‚ โ”‚ โ”‚ PostgreSQL) โ”‚ โ”‚ โ”‚
328
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
329
+ ```
330
+
331
+ **Key Patterns:**
332
+ - **BFF (Backend For Frontend)**: Next.js API Routes proxy to Azure Functions
333
+ - **Shared Schemas**: Zod schemas stay in `shared/models/` as the source of truth
334
+ - **OpenAPI Export for C#/Python**: Non-TypeScript Functions consume native-generated assets under `functions/generated/`
335
+ - **External Connectors**: MySQL, PostgreSQL, REST APIs โ€” scaffold-generated Functions with the same BFF pattern
336
+ - **Contract Safety**: BFF and backend stay aligned through shared Zod or generated backend models
337
+ - **Managed Identity**: Secure service connections (no connection strings)
338
+
339
+ ## ๐Ÿ“ฆ Prerequisites
340
+
341
+ - Node.js 22.x
342
+ - **pnpm** (recommended): `corepack enable` or `npm install -g pnpm`
343
+ - npm also works โ€” SwallowKit auto-detects the package manager (if pnpm is installed, it is always preferred)
344
+ - Azure Cosmos DB Emulator (local development)
345
+ - [Official documentation (vNext recommended)](https://learn.microsoft.com/en-us/azure/cosmos-db/emulator-linux)
346
+ - Windows: [Download](https://aka.ms/cosmosdb-emulator)
347
+ - Docker: `docker run -p 8081:8081 mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator`
348
+
349
+ ## ๐Ÿš€ Deploy to Azure
350
+
351
+ Deploy your Next.js app to Azure Static Web Apps using standalone mode, and connect to independent Azure Functions for backend operations.
352
+
353
+ **1. Provision resources (Bicep IaC)**
354
+
355
+ ```bash
356
+ npx swallowkit provision --resource-group my-app-rg
357
+ # or
358
+ pnpm dlx swallowkit provision --resource-group my-app-rg
359
+ ```
360
+
361
+ The command prompts you to choose the primary region and the Static Web App region. After provisioning, the terminal displays the CI/CD values you need for setup. Copy them.
362
+
363
+ **2. Push code**
364
+
365
+ ```bash
366
+ git push origin main
367
+ ```
368
+
369
+ **3. Cancel the auto-triggered CI/CD run** โ€” it will fail because secrets are not registered yet.
370
+
371
+ **4. Register the displayed secrets / variables** in GitHub (Settings โ†’ Secrets) or Azure DevOps (Pipelines โ†’ Library).
372
+
373
+ **5. Manually re-run the CI/CD workflow.**
374
+
375
+ See **[Deployment Guide](https://himanago.github.io/swallowkit/en/deployment-guide)** for details.
376
+
377
+ ## License
378
+
379
+ MIT
380
+
381
+ ## ๐Ÿ”— Related Links
382
+
383
+ - [SwallowKit VS Code Extension](https://marketplace.visualstudio.com/items?itemName=himanago.swallowkit-vscode)
384
+ - [Azure Static Web Apps](https://learn.microsoft.com/en-us/azure/static-web-apps/)
385
+ - [Azure Functions](https://learn.microsoft.com/en-us/azure/azure-functions/)
386
+ - [Azure Cosmos DB](https://learn.microsoft.com/en-us/azure/cosmos-db/)
387
+ - [Next.js](https://nextjs.org/)
388
+ - [Zod](https://zod.dev/)
@@ -0,0 +1,22 @@
1
+ import { ModelInfo } from "../core/scaffold/model-parser";
2
+ /**
3
+ * ใƒ†ใ‚นใƒˆ็”จใฎๅŸบๆœฌ็š„ใช ModelInfo ใƒ•ใ‚ฃใ‚ฏใ‚นใƒใƒฃ
4
+ */
5
+ export declare function createBasicModelInfo(overrides?: Partial<ModelInfo>): ModelInfo;
6
+ /**
7
+ * RDB ใ‚ณใƒใ‚ฏใ‚ฟ (read-only) ไป˜ใใฎ ModelInfo ใƒ•ใ‚ฃใ‚ฏใ‚นใƒใƒฃ
8
+ */
9
+ export declare function createRdbConnectorModelInfo(overrides?: Partial<ModelInfo>): ModelInfo;
10
+ /**
11
+ * API ใ‚ณใƒใ‚ฏใ‚ฟ (read-write) ไป˜ใใฎ ModelInfo ใƒ•ใ‚ฃใ‚ฏใ‚นใƒใƒฃ
12
+ */
13
+ export declare function createApiConnectorModelInfo(overrides?: Partial<ModelInfo>): ModelInfo;
14
+ /**
15
+ * ๅค–้ƒจใ‚ญใƒผใ‚’ๅซใ‚€ ModelInfo ใƒ•ใ‚ฃใ‚ฏใ‚นใƒใƒฃ
16
+ */
17
+ export declare function createModelInfoWithForeignKey(): ModelInfo;
18
+ /**
19
+ * enum ใƒ•ใ‚ฃใƒผใƒซใƒ‰ใ‚’ๅซใ‚€ ModelInfo ใƒ•ใ‚ฃใ‚ฏใ‚นใƒใƒฃ
20
+ */
21
+ export declare function createModelInfoWithEnum(): ModelInfo;
22
+ //# sourceMappingURL=fixtures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../src/__tests__/fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,SAAS,CAqB9E;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,SAAS,CAuBrF;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,SAAS,CA2BrF;AAED;;GAEG;AACH,wBAAgB,6BAA6B,IAAI,SAAS,CAqBzD;AAED;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,SAAS,CA0BnD"}