swallowkit 1.0.0-beta.5 → 1.0.0-beta.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.md CHANGED
@@ -1,243 +1,246 @@
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
- # or
44
- pnpm dlx swallowkit init my-app
45
- cd my-app
46
- ```
47
-
48
- The interactive prompts ask for CI/CD provider, Cosmos DB mode, and network settings. You can also specify them as flags to skip prompts entirely:
49
-
50
- ```bash
51
- # Non-interactive mode (useful for VS Code extensions or automation)
52
- npx swallowkit init my-app --cicd github --cosmos-db-mode serverless --vnet outbound
53
- ```
54
-
55
- | Flag | Values | Description |
56
- |------|--------|-------------|
57
- | `--cicd <provider>` | `github`, `azure`, `skip` | CI/CD provider |
58
- | `--cosmos-db-mode <mode>` | `freetier`, `serverless` | Cosmos DB pricing mode |
59
- | `--vnet <option>` | `outbound`, `none` | Network security |
60
-
61
- Omit any flag to be prompted for that value interactively.
62
-
63
- ### 2. Create Models
64
-
65
- You can create multiple models at once:
66
-
67
- ```bash
68
- npx swallowkit create-model category todo
69
- # or
70
- pnpm dlx swallowkit create-model category todo
71
- ```
72
-
73
- This generates `shared/models/category.ts` and `shared/models/todo.ts`. Customize them by adding your required fields:
74
-
75
- ```typescript
76
- // shared/models/category.ts
77
- import { z } from 'zod';
78
-
79
- export const category = z.object({
80
- id: z.string(),
81
- name: z.string().min(1).max(50),
82
- createdAt: z.string().optional(),
83
- updatedAt: z.string().optional(),
84
- });
85
-
86
- export type Category = z.infer<typeof category>;
87
- ```
88
-
89
- For parent-child relationships, use **nested schemas** instead of ID references:
90
-
91
- ```typescript
92
- // shared/models/todo.ts
93
- import { z } from 'zod';
94
- import { category } from './category';
95
-
96
- export const todo = z.object({
97
- id: z.string(),
98
- text: z.string().min(1).max(200),
99
- completed: z.boolean().default(false),
100
- category: category.optional(), // Nested object (not categoryId)
101
- createdAt: z.string().optional(),
102
- updatedAt: z.string().optional(),
103
- });
104
-
105
- export type Todo = z.infer<typeof todo>;
106
- ```
107
-
108
- > **Tip**: Nesting preserves type safety and stores related data together in the document, which is natural for Cosmos DB's document model.
109
-
110
- ### 3. Generate CRUD Code
111
-
112
- ```bash
113
- npx swallowkit scaffold shared/models/todo.ts
114
- # or
115
- pnpm dlx swallowkit scaffold shared/models/todo.ts
116
- ```
117
-
118
- This auto-generates:
119
- - ✅ Azure Functions (CRUD endpoints + Cosmos DB bindings)
120
- - ✅ Next.js BFF API Routes (auto-validation + resource inference)
121
- - ✅ React Components (type-safe forms)
122
-
123
- ### 4. Start Development Server
124
-
125
- ```bash
126
- npx swallowkit dev
127
- # or
128
- pnpm dlx swallowkit dev
129
- ```
130
-
131
- - Next.js: http://localhost:3000
132
- - Azure Functions: http://localhost:7071
133
-
134
- ### 5. Use from Frontend
135
-
136
- ```typescript
137
- import { api } from '@/lib/api/backend';
138
- import type { Todo } from '@/shared/models/todo';
139
-
140
- // Get all - call BFF endpoint
141
- const todos = await api.get<Todo[]>('/api/todos');
142
-
143
- // Create - validated by backend
144
- const created = await api.post<Todo>('/api/todos', {
145
- text: 'Buy milk',
146
- completed: false
147
- });
148
-
149
- // Update - validated by backend
150
- const updated = await api.put<Todo>('/api/todos/123', { completed: true });
151
-
152
- // Delete
153
- await api.delete('/api/todos/123');
154
- ```
155
-
156
- ## 🏗️ Architecture
157
-
158
- ```
159
- ┌─────────────────────────────────────────────────────────────┐
160
- │ Frontend (React) │
161
- │ - Client Components │
162
- │ - Server Components (SSR) │
163
- └──────────────────────────┬───────────────────────────────────┘
164
- api.post('/api/todos', data)
165
-
166
- ┌─────────────────────────────────────────────────────────────┐
167
- BFF Layer (Next.js API Routes)
168
- │ - Auto Schema Validation (Zod) │
169
- │ - Error Handling │
170
- └──────────────────────────┬───────────────────────────────────┘
171
- HTTP Request
172
-
173
- ┌─────────────────────────────────────────────────────────────┐
174
- Azure Functions (Backend) │
175
- │ - HTTP Triggers (CRUD) │
176
- │ - Zod Validation (Re-check) │
177
- - Business Logic
178
- │ - Cosmos DB Bindings
179
- └──────────────────────────┬───────────────────────────────────┘
180
-
181
-
182
- ┌─────────────────────────────────────────────────────────────┐
183
- Azure Cosmos DB │
184
- │ - NoSQL Database │
185
- │ - Zod Schema Validation │
186
- └─────────────────────────────────────────────────────────────┘
187
- ```
188
-
189
- **Key Patterns:**
190
- - **BFF (Backend For Frontend)**: Next.js API Routes proxy to Azure Functions
191
- - **Shared Schemas**: Zod schemas used across frontend, BFF, Functions, and DB
192
- - **Type Safety**: TypeScript types auto-inferred from Zod
193
- - **Managed Identity**: Secure service connections (no connection strings)
194
-
195
- ## 📦 Prerequisites
196
-
197
- - Node.js 22.x
198
- - **pnpm** (recommended): `corepack enable` or `npm install -g pnpm`
199
- - npm also works — SwallowKit auto-detects the package manager (if pnpm is installed, it is always preferred)
200
- - Azure Cosmos DB Emulator (local development)
201
- - [Official documentation (vNext recommended)](https://learn.microsoft.com/en-us/azure/cosmos-db/emulator-linux)
202
- - Windows: [Download](https://aka.ms/cosmosdb-emulator)
203
- - Docker: `docker run -p 8081:8081 mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator`
204
-
205
- ## 🚀 Deploy to Azure
206
-
207
- Deploy your Next.js app to Azure Static Web Apps using standalone mode, and connect to independent Azure Functions for backend operations.
208
-
209
- **1. Provision resources (Bicep IaC)**
210
-
211
- ```bash
212
- npx swallowkit provision --resource-group my-app-rg --location japaneast
213
- # or
214
- pnpm dlx swallowkit provision --resource-group my-app-rg --location japaneast
215
- ```
216
-
217
- After provisioning, the required CI/CD secret values are displayed in the terminal. Copy them.
218
-
219
- **2. Push code**
220
-
221
- ```bash
222
- git push origin main
223
- ```
224
-
225
- **3. Cancel the auto-triggered CI/CD run** — it will fail because secrets are not registered yet.
226
-
227
- **4. Register the displayed secret values** in GitHub (Settings → Secrets) or Azure DevOps (Pipelines → Library).
228
-
229
- **5. Manually re-run the CI/CD workflow.**
230
-
231
- See **[Deployment Guide](./docs/deployment-guide.md)** for details.
232
-
233
- ## License
234
-
235
- MIT
236
-
237
- ## 🔗 Related Links
238
-
239
- - [Azure Static Web Apps](https://learn.microsoft.com/en-us/azure/static-web-apps/)
240
- - [Azure Functions](https://learn.microsoft.com/en-us/azure/azure-functions/)
241
- - [Azure Cosmos DB](https://learn.microsoft.com/en-us/azure/cosmos-db/)
242
- - [Next.js](https://nextjs.org/)
243
- - [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
+ [![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
+ - **🤖 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
30
+
31
+ ## 📚 Documentation
32
+
33
+ Visit the **[SwallowKit Documentation](https://himanago.github.io/swallowkit/)** for the full docs (also available in [日本語](https://himanago.github.io/swallowkit/ja/)).
34
+
35
+ - **[CLI Reference](https://himanago.github.io/swallowkit/en/cli-reference)** - All commands in detail
36
+ - **[Scaffold Guide](https://himanago.github.io/swallowkit/en/scaffold-guide)** - CRUD code generation
37
+ - **[Zod Schema Sharing Guide](https://himanago.github.io/swallowkit/en/zod-schema-sharing-guide)** - Schema design
38
+ - **[Deployment Guide](https://himanago.github.io/swallowkit/en/deployment-guide)** - Deploy to Azure
39
+
40
+ ## 🚀 Quick Start
41
+
42
+ ### 1. Create Project
43
+
44
+ ```bash
45
+ npx swallowkit init my-app
46
+ # or
47
+ pnpm dlx swallowkit init my-app
48
+ cd my-app
49
+ ```
50
+
51
+ The interactive prompts ask for CI/CD provider, Cosmos DB mode, and network settings. You can also specify them as flags to skip prompts entirely:
52
+
53
+ ```bash
54
+ # Non-interactive mode (useful for VS Code extensions or automation)
55
+ npx swallowkit init my-app --cicd github --cosmos-db-mode serverless --vnet outbound
56
+ ```
57
+
58
+ | Flag | Values | Description |
59
+ |------|--------|-------------|
60
+ | `--cicd <provider>` | `github`, `azure`, `skip` | CI/CD provider |
61
+ | `--cosmos-db-mode <mode>` | `freetier`, `serverless` | Cosmos DB pricing mode |
62
+ | `--vnet <option>` | `outbound`, `none` | Network security |
63
+
64
+ Omit any flag to be prompted for that value interactively.
65
+
66
+ ### 2. Create Models
67
+
68
+ You can create multiple models at once:
69
+
70
+ ```bash
71
+ npx swallowkit create-model category todo
72
+ # or
73
+ pnpm dlx swallowkit create-model category todo
74
+ ```
75
+
76
+ This generates `shared/models/category.ts` and `shared/models/todo.ts`. Customize them by adding your required fields:
77
+
78
+ ```typescript
79
+ // shared/models/category.ts
80
+ import { z } from 'zod';
81
+
82
+ export const category = z.object({
83
+ id: z.string(),
84
+ name: z.string().min(1).max(50),
85
+ createdAt: z.string().optional(),
86
+ updatedAt: z.string().optional(),
87
+ });
88
+
89
+ export type Category = z.infer<typeof category>;
90
+ ```
91
+
92
+ For parent-child relationships, use **nested schemas** instead of ID references:
93
+
94
+ ```typescript
95
+ // shared/models/todo.ts
96
+ import { z } from 'zod';
97
+ import { category } from './category';
98
+
99
+ export const todo = z.object({
100
+ id: z.string(),
101
+ text: z.string().min(1).max(200),
102
+ completed: z.boolean().default(false),
103
+ category: category.optional(), // Nested object (not categoryId)
104
+ createdAt: z.string().optional(),
105
+ updatedAt: z.string().optional(),
106
+ });
107
+
108
+ export type Todo = z.infer<typeof todo>;
109
+ ```
110
+
111
+ > **Tip**: Nesting preserves type safety and stores related data together in the document, which is natural for Cosmos DB's document model.
112
+
113
+ ### 3. Generate CRUD Code
114
+
115
+ ```bash
116
+ npx swallowkit scaffold shared/models/todo.ts
117
+ # or
118
+ pnpm dlx swallowkit scaffold shared/models/todo.ts
119
+ ```
120
+
121
+ This auto-generates:
122
+ - ✅ Azure Functions (CRUD endpoints + Cosmos DB bindings)
123
+ - ✅ Next.js BFF API Routes (auto-validation + resource inference)
124
+ - ✅ React Components (type-safe forms)
125
+
126
+ ### 4. Start Development Server
127
+
128
+ ```bash
129
+ npx swallowkit dev
130
+ # or
131
+ pnpm dlx swallowkit dev
132
+ ```
133
+
134
+ - Next.js: http://localhost:3000
135
+ - Azure Functions: http://localhost:7071
136
+
137
+ ### 5. Use from Frontend
138
+
139
+ ```typescript
140
+ import { api } from '@/lib/api/backend';
141
+ import type { Todo } from '@/shared/models/todo';
142
+
143
+ // Get all - call BFF endpoint
144
+ const todos = await api.get<Todo[]>('/api/todos');
145
+
146
+ // Create - validated by backend
147
+ const created = await api.post<Todo>('/api/todos', {
148
+ text: 'Buy milk',
149
+ completed: false
150
+ });
151
+
152
+ // Update - validated by backend
153
+ const updated = await api.put<Todo>('/api/todos/123', { completed: true });
154
+
155
+ // Delete
156
+ await api.delete('/api/todos/123');
157
+ ```
158
+
159
+ ## 🏗️ Architecture
160
+
161
+ ```
162
+ ┌─────────────────────────────────────────────────────────────┐
163
+ │ Frontend (React) │
164
+ - Client Components │
165
+ │ - Server Components (SSR) │
166
+ └──────────────────────────┬───────────────────────────────────┘
167
+ api.post('/api/todos', data)
168
+
169
+ ┌─────────────────────────────────────────────────────────────┐
170
+ │ BFF Layer (Next.js API Routes) │
171
+ - Auto Schema Validation (Zod) │
172
+ │ - Error Handling │
173
+ └──────────────────────────┬───────────────────────────────────┘
174
+ HTTP Request
175
+
176
+ ┌─────────────────────────────────────────────────────────────┐
177
+ Azure Functions (Backend)
178
+ │ - HTTP Triggers (CRUD)
179
+ │ - Zod Validation (Re-check) │
180
+ - Business Logic │
181
+ │ - Cosmos DB Bindings │
182
+ └──────────────────────────┬───────────────────────────────────┘
183
+
184
+
185
+ ┌─────────────────────────────────────────────────────────────┐
186
+ │ Azure Cosmos DB │
187
+ │ - NoSQL Database │
188
+ │ - Zod Schema Validation │
189
+ └─────────────────────────────────────────────────────────────┘
190
+ ```
191
+
192
+ **Key Patterns:**
193
+ - **BFF (Backend For Frontend)**: Next.js API Routes proxy to Azure Functions
194
+ - **Shared Schemas**: Zod schemas used across frontend, BFF, Functions, and DB
195
+ - **Type Safety**: TypeScript types auto-inferred from Zod
196
+ - **Managed Identity**: Secure service connections (no connection strings)
197
+
198
+ ## 📦 Prerequisites
199
+
200
+ - Node.js 22.x
201
+ - **pnpm** (recommended): `corepack enable` or `npm install -g pnpm`
202
+ - npm also works — SwallowKit auto-detects the package manager (if pnpm is installed, it is always preferred)
203
+ - Azure Cosmos DB Emulator (local development)
204
+ - [Official documentation (vNext recommended)](https://learn.microsoft.com/en-us/azure/cosmos-db/emulator-linux)
205
+ - Windows: [Download](https://aka.ms/cosmosdb-emulator)
206
+ - Docker: `docker run -p 8081:8081 mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator`
207
+
208
+ ## 🚀 Deploy to Azure
209
+
210
+ Deploy your Next.js app to Azure Static Web Apps using standalone mode, and connect to independent Azure Functions for backend operations.
211
+
212
+ **1. Provision resources (Bicep IaC)**
213
+
214
+ ```bash
215
+ npx swallowkit provision --resource-group my-app-rg --location japaneast
216
+ # or
217
+ pnpm dlx swallowkit provision --resource-group my-app-rg --location japaneast
218
+ ```
219
+
220
+ After provisioning, the required CI/CD secret values are displayed in the terminal. Copy them.
221
+
222
+ **2. Push code**
223
+
224
+ ```bash
225
+ git push origin main
226
+ ```
227
+
228
+ **3. Cancel the auto-triggered CI/CD run** — it will fail because secrets are not registered yet.
229
+
230
+ **4. Register the displayed secret values** in GitHub (Settings → Secrets) or Azure DevOps (Pipelines → Library).
231
+
232
+ **5. Manually re-run the CI/CD workflow.**
233
+
234
+ See **[Deployment Guide](https://himanago.github.io/swallowkit/en/deployment-guide)** for details.
235
+
236
+ ## License
237
+
238
+ MIT
239
+
240
+ ## 🔗 Related Links
241
+
242
+ - [Azure Static Web Apps](https://learn.microsoft.com/en-us/azure/static-web-apps/)
243
+ - [Azure Functions](https://learn.microsoft.com/en-us/azure/azure-functions/)
244
+ - [Azure Cosmos DB](https://learn.microsoft.com/en-us/azure/cosmos-db/)
245
+ - [Next.js](https://nextjs.org/)
246
+ - [Zod](https://zod.dev/)
@@ -0,0 +1,14 @@
1
+ import { ModelInfo } from "../core/scaffold/model-parser";
2
+ /**
3
+ * テスト用の基本的な ModelInfo フィクスチャ
4
+ */
5
+ export declare function createBasicModelInfo(overrides?: Partial<ModelInfo>): ModelInfo;
6
+ /**
7
+ * 外部キーを含む ModelInfo フィクスチャ
8
+ */
9
+ export declare function createModelInfoWithForeignKey(): ModelInfo;
10
+ /**
11
+ * enum フィールドを含む ModelInfo フィクスチャ
12
+ */
13
+ export declare function createModelInfoWithEnum(): ModelInfo;
14
+ //# 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,CAoB9E;AAED;;GAEG;AACH,wBAAgB,6BAA6B,IAAI,SAAS,CAqBzD;AAED;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,SAAS,CA0BnD"}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createBasicModelInfo = createBasicModelInfo;
4
+ exports.createModelInfoWithForeignKey = createModelInfoWithForeignKey;
5
+ exports.createModelInfoWithEnum = createModelInfoWithEnum;
6
+ /**
7
+ * テスト用の基本的な ModelInfo フィクスチャ
8
+ */
9
+ function createBasicModelInfo(overrides) {
10
+ return {
11
+ name: "Todo",
12
+ displayName: "Todo",
13
+ schemaName: "todoSchema",
14
+ filePath: "/models/todo.ts",
15
+ fields: [
16
+ { name: "id", type: "string", isOptional: false, isArray: false },
17
+ { name: "title", type: "string", isOptional: false, isArray: false },
18
+ { name: "description", type: "string", isOptional: true, isArray: false },
19
+ { name: "completed", type: "boolean", isOptional: false, isArray: false },
20
+ { name: "createdAt", type: "string", isOptional: false, isArray: false },
21
+ { name: "updatedAt", type: "string", isOptional: false, isArray: false },
22
+ ],
23
+ hasId: true,
24
+ hasCreatedAt: true,
25
+ hasUpdatedAt: true,
26
+ nestedSchemaRefs: [],
27
+ ...overrides,
28
+ };
29
+ }
30
+ /**
31
+ * 外部キーを含む ModelInfo フィクスチャ
32
+ */
33
+ function createModelInfoWithForeignKey() {
34
+ return createBasicModelInfo({
35
+ name: "Task",
36
+ displayName: "Task",
37
+ schemaName: "taskSchema",
38
+ filePath: "/models/task.ts",
39
+ fields: [
40
+ { name: "id", type: "string", isOptional: false, isArray: false },
41
+ { name: "title", type: "string", isOptional: false, isArray: false },
42
+ {
43
+ name: "categoryId",
44
+ type: "string",
45
+ isOptional: false,
46
+ isArray: false,
47
+ isForeignKey: true,
48
+ referencedModel: "Category",
49
+ },
50
+ { name: "createdAt", type: "string", isOptional: false, isArray: false },
51
+ { name: "updatedAt", type: "string", isOptional: false, isArray: false },
52
+ ],
53
+ });
54
+ }
55
+ /**
56
+ * enum フィールドを含む ModelInfo フィクスチャ
57
+ */
58
+ function createModelInfoWithEnum() {
59
+ return createBasicModelInfo({
60
+ name: "Issue",
61
+ displayName: "Issue",
62
+ schemaName: "issueSchema",
63
+ filePath: "/models/issue.ts",
64
+ fields: [
65
+ { name: "id", type: "string", isOptional: false, isArray: false },
66
+ { name: "title", type: "string", isOptional: false, isArray: false },
67
+ {
68
+ name: "status",
69
+ type: "string",
70
+ isOptional: false,
71
+ isArray: false,
72
+ enumValues: ["open", "in_progress", "closed"],
73
+ },
74
+ {
75
+ name: "priority",
76
+ type: "number",
77
+ isOptional: true,
78
+ isArray: false,
79
+ },
80
+ { name: "createdAt", type: "string", isOptional: false, isArray: false },
81
+ { name: "updatedAt", type: "string", isOptional: false, isArray: false },
82
+ ],
83
+ });
84
+ }
85
+ //# sourceMappingURL=fixtures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixtures.js","sourceRoot":"","sources":["../../src/__tests__/fixtures.ts"],"names":[],"mappings":";;AAKA,oDAoBC;AAKD,sEAqBC;AAKD,0DA0BC;AAhFD;;GAEG;AACH,SAAgB,oBAAoB,CAAC,SAA8B;IACjE,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,MAAM;QACnB,UAAU,EAAE,YAAY;QACxB,QAAQ,EAAE,iBAAiB;QAC3B,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE;YACjE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EA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elName) {
51
51
  const pascalName = (0, model_parser_1.toPascalCase)(modelName);
52
- return `import { z } from 'zod/v4';
53
-
54
- // ${pascalName} model (Zod official pattern: same name for value and type)
55
- export const ${pascalName} = z.object({
56
- id: z.string(),
57
- name: z.string().min(1),
58
- createdAt: z.string().optional(),
59
- updatedAt: z.string().optional(),
60
- });
61
-
62
- export type ${pascalName} = z.infer<typeof ${pascalName}>;
63
-
64
- // Display name for UI
65
- export const displayName = '${pascalName}';
52
+ return `import { z } from 'zod/v4';
53
+
54
+ // ${pascalName} model (Zod official pattern: same name for value and type)
55
+ export const ${pascalName} = z.object({
56
+ id: z.string(),
57
+ name: z.string().min(1),
58
+ createdAt: z.string().optional(),
59
+ updatedAt: z.string().optional(),
60
+ });
61
+
62
+ export type ${pascalName} = z.infer<typeof ${pascalName}>;
63
+
64
+ // Display name for UI
65
+ export const displayName = '${pascalName}';
66
66
  `;
67
67
  }
68
68
  /**