@omnifyjp/omnify 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +344 -61
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -1,129 +1,412 @@
1
- # @famgia/omnify-bin
1
+ # @omnifyjp/omnify
2
2
 
3
- Schema-driven code generation for Laravel, TypeScript, and SQL. Define your database schemas in YAML once, then generate migrations, models, interfaces, and more.
3
+ **Schema-driven migration & type generation for Laravel and TypeScript.**
4
4
 
5
- ## Installation
5
+ Define your database schemas in YAML, generate Laravel PHP migrations, raw SQL, and TypeScript types — all with a single command.
6
6
 
7
- ```bash
8
- # Global install
9
- npm install -g @famgia/omnify-bin
7
+ **YAMLでデータベーススキーマを定義し、Laravelマイグレーション・SQL・TypeScript型を一括生成するCLIツールです。**
10
8
 
11
- # Or use npx
12
- npx @famgia/omnify-bin generate
13
- ```
9
+ ---
10
+
11
+ ## Features / 機能
12
+
13
+ - **YAML Schema Definition** — Human-readable schema format with localized display names
14
+ - **Laravel Migration Generation** — Complete PHP migration files with foreign keys, indexes, and comments
15
+ - **Raw SQL Generation** — MySQL, PostgreSQL, and SQLite
16
+ - **TypeScript Generation** — Interfaces, Zod schemas, and i18n types from `schemas.json`
17
+ - **Incremental Generation** — Lock file tracks changes; only regenerates what's needed
18
+ - **Compound Types** — Single property expands to multiple columns (e.g., `JapaneseName` → 4 columns)
19
+ - **Associations** — ManyToOne, OneToMany, ManyToMany (pivot tables), MorphMany/MorphTo
20
+ - **MCP Server** — AI tool integration for Cursor, Claude Code, and other MCP-compatible editors
21
+ - **Zero Runtime Dependencies** — Single Go binary + bundled TypeScript generator
14
22
 
15
- ## Quick Start
23
+ ---
24
+
25
+ ## Installation / インストール
16
26
 
17
27
  ```bash
18
- # Initialize a new project
19
- omnify init
28
+ npm install -D @omnifyjp/omnify
29
+ ```
30
+
31
+ This installs:
32
+ - `omnify` — Go CLI binary (platform-specific)
33
+ - `omnify-ts` — TypeScript type generator
20
34
 
21
- # Define schemas in schemas/ directory, then generate
22
- omnify generate
35
+ Both are available in `node_modules/.bin/` after installation.
23
36
 
24
- # Validate your schemas
25
- omnify validate
37
+ > **Note:** You can also install Go binary directly:
38
+ > ```bash
39
+ > go install github.com/famgia/omnify-go/cmd/omnify@latest
40
+ > ```
26
41
 
27
- # Show what changed since last generation
28
- omnify diff
42
+ ---
29
43
 
30
- # Start MCP server for AI assistant integration
31
- omnify mcp
44
+ ## Quick Start / クイックスタート
45
+
46
+ ### 1. Initialize / 初期化
47
+
48
+ ```bash
49
+ npx omnify init
32
50
  ```
33
51
 
34
- ## Schema Example
52
+ Creates `omnify.yaml` and `schemas/` directory.
53
+
54
+ ### 2. Define a Schema / スキーマ定義
55
+
56
+ Create `schemas/system/User.yaml`:
35
57
 
36
58
  ```yaml
37
- # schemas/User.yaml
38
- name: User
39
- kind: object
40
59
  displayName:
41
- en: User
42
60
  ja: ユーザー
61
+ en: User
62
+ group: system
63
+
43
64
  options:
44
65
  timestamps: true
45
66
  softDelete: true
67
+
46
68
  properties:
47
69
  name:
48
70
  type: String
49
71
  length: 100
50
- required: true
51
72
  displayName:
52
- en: Name
53
73
  ja: 名前
74
+ en: Name
75
+
54
76
  email:
55
- type: String
56
- length: 255
57
- required: true
77
+ type: Email
58
78
  unique: true
59
79
  displayName:
60
- en: Email
61
80
  ja: メールアドレス
62
- role:
63
- type: Enum
64
- enum: [admin, editor, viewer]
65
- default: viewer
81
+ en: Email
82
+
83
+ password:
84
+ type: Password
66
85
  displayName:
67
- en: Role
68
- ja: 役割
86
+ ja: パスワード
87
+ en: Password
88
+ ```
89
+
90
+ ### 3. Generate / 生成
91
+
92
+ ```bash
93
+ npx omnify generate
69
94
  ```
70
95
 
71
- ## Configuration
96
+ This generates:
97
+ - **Laravel migrations** → `database/migrations/omnify/`
98
+ - **SQL files** → configured output path
99
+ - **TypeScript types** → configured `typescript.path` (interfaces, Zod schemas, i18n)
100
+ - **schemas.json** → serialized schema data
101
+ - **Lock file** → `.omnify.lock` (tracks schema state)
102
+
103
+ ---
104
+
105
+ ## Configuration / 設定
72
106
 
73
107
  Create `omnify.yaml` in your project root:
74
108
 
75
109
  ```yaml
76
- schemasDir: schemas
77
- generators:
78
- laravel:
79
- enabled: true
80
- migrationsDir: database/migrations
81
- modelsDir: app/Models
82
- sql:
83
- enabled: true
84
- outputDir: migrations
85
- dialect: mysql
110
+ schemasDir: ./schemas
111
+ lockFilePath: .omnify.lock
112
+
113
+ connections:
114
+ default:
115
+ driver: mysql
116
+ output:
117
+ laravel:
118
+ migrationsPath: database/migrations/omnify
119
+ schemasPath: database/omnify/schemas.json
120
+ sql:
121
+ path: migrations/sql
122
+ dialect: mysql
123
+ typescript:
124
+ path: resources/js/types/models # TypeScript types output directory
125
+
126
+ default: default
127
+
128
+ locale:
129
+ locales: [ja, en, vi]
130
+ defaultLocale: ja
131
+ fallbackLocale: en
132
+
133
+ compoundTypes:
134
+ - japan # Enables JapaneseName, JapaneseAddress, JapaneseBankAccount
135
+ ```
136
+
137
+ ### TypeScript Auto-Generation / TypeScript自動生成
138
+
139
+ When `typescript.path` is configured, `omnify generate` automatically generates TypeScript types after writing `schemas.json`. No separate step needed.
140
+
141
+ `typescript.path`を設定すると、`omnify generate`実行時にTypeScript型が自動生成されます。別途コマンドを実行する必要はありません。
142
+
143
+ Generated files:
144
+ - `base/` — Auto-generated interfaces and Zod schemas (overwritten on each generation)
145
+ - `enum/` — Enum type definitions
146
+ - Model files — User-editable model files (created once, never overwritten)
147
+
148
+ ### Multiple Connections / 複数接続
149
+
150
+ ```yaml
151
+ connections:
152
+ default:
153
+ driver: mysql
154
+ output:
155
+ laravel:
156
+ migrationsPath: database/migrations/omnify
157
+
158
+ product-db:
159
+ driver: pgsql
160
+ output:
161
+ laravel:
162
+ migrationsPath: database/migrations/product
163
+ sql:
164
+ path: output/sql/product
165
+ dialect: postgresql
166
+ ```
167
+
168
+ ---
169
+
170
+ ## CLI Commands / コマンド一覧
171
+
172
+ ```bash
173
+ omnify init # Initialize project / プロジェクト初期化
174
+ omnify validate # Validate all schemas / スキーマ検証
175
+ omnify diff # Show pending changes / 変更差分表示
176
+ omnify generate # Generate migrations + types / マイグレーション+型生成
177
+ omnify generate --force # Regenerate all / 全再生成
178
+ omnify generate --migrations-only # Migrations only (skip SQL, TypeScript) / マイグレーションのみ
179
+ omnify generate --connection=name # Generate for specific connection / 特定接続のみ
180
+ omnify list # List schemas and types / スキーマ一覧
181
+ omnify add # Add a new schema / スキーマ追加
182
+ omnify mcp # Start MCP server / MCPサーバー起動
183
+ omnify version # Show version / バージョン表示
184
+ ```
185
+
186
+ ### Global Flags
187
+
188
+ | Flag | Short | Description |
189
+ |------|-------|-------------|
190
+ | `--config` | `-c` | Config file path (default: `omnify.yaml`) |
191
+ | `--verbose` | `-v` | Enable verbose output |
192
+
193
+ ---
194
+
195
+ ## Schema Format / スキーマフォーマット
196
+
197
+ ### Associations / アソシエーション
198
+
199
+ ```yaml
200
+ properties:
201
+ # ManyToOne — creates foreign key column
202
+ author:
203
+ type: Association
204
+ relation: ManyToOne
205
+ target: User
206
+ onDelete: CASCADE
207
+
208
+ # ManyToMany — generates pivot table
209
+ tags:
210
+ type: Association
211
+ relation: ManyToMany
212
+ target: Tag
213
+ joinTable: post_tags
214
+
215
+ # Polymorphic
216
+ comments:
217
+ type: Association
218
+ relation: MorphMany
219
+ target: Comment
220
+ morphName: commentable
221
+ ```
222
+
223
+ ### Enum Schema / Enumスキーマ
224
+
225
+ ```yaml
226
+ # schemas/blog/PostStatus.yaml
227
+ kind: enum
228
+ displayName:
229
+ ja: 投稿ステータス
230
+ en: Post Status
231
+ group: blog
232
+
233
+ values:
234
+ - draft
235
+ - published
236
+ - archived
237
+ ```
238
+
239
+ ### Schema Options
240
+
241
+ | Option | Type | Default | Description |
242
+ |--------|------|---------|-------------|
243
+ | `id` | bool | `true` | Auto-incrementing primary key / 自動採番主キー |
244
+ | `idType` | string | `BigInt` | Primary key type / 主キー型 |
245
+ | `timestamps` | bool | `true` | `created_at` / `updated_at` columns |
246
+ | `softDelete` | bool | `false` | `deleted_at` column / 論理削除 |
247
+ | `indexes` | array | `[]` | Composite indexes / 複合インデックス |
248
+
249
+ ### Property Options
250
+
251
+ | Option | Type | Description |
252
+ |--------|------|-------------|
253
+ | `type` | string | Property type (see Type System below) |
254
+ | `nullable` | bool | Allow NULL values |
255
+ | `unique` | bool | Unique constraint |
256
+ | `default` | any | Default value |
257
+ | `length` | int | String/VARCHAR length |
258
+ | `unsigned` | bool | Unsigned integer |
259
+ | `precision` | int | Decimal precision |
260
+ | `scale` | int | Decimal scale |
261
+ | `displayName` | object | Localized display names / 多言語表示名 |
262
+
263
+ ---
264
+
265
+ ## Type System / 型システム
266
+
267
+ ### Built-in Types / 組み込み型
268
+
269
+ | Type | Laravel | MySQL | PostgreSQL | SQLite |
270
+ |------|---------|-------|------------|--------|
271
+ | `String` | `string` | VARCHAR(255) | VARCHAR(255) | TEXT |
272
+ | `TinyInt` | `tinyInteger` | TINYINT | SMALLINT | INTEGER |
273
+ | `Int` | `integer` | INT | INTEGER | INTEGER |
274
+ | `BigInt` | `bigInteger` | BIGINT UNSIGNED | BIGINT | INTEGER |
275
+ | `Float` | `double` | DOUBLE | DOUBLE PRECISION | REAL |
276
+ | `Decimal` | `decimal` | DECIMAL(p,s) | DECIMAL(p,s) | REAL |
277
+ | `Boolean` | `boolean` | TINYINT(1) | BOOLEAN | INTEGER |
278
+ | `Text` | `text` | TEXT | TEXT | TEXT |
279
+ | `MediumText` | `mediumText` | MEDIUMTEXT | TEXT | TEXT |
280
+ | `LongText` | `longText` | LONGTEXT | TEXT | TEXT |
281
+ | `Date` | `date` | DATE | DATE | TEXT |
282
+ | `Time` | `time` | TIME | TIME | TEXT |
283
+ | `Timestamp` | `timestamp` | TIMESTAMP | TIMESTAMP | TEXT |
284
+ | `DateTime` | `dateTime` | DATETIME | TIMESTAMP | TEXT |
285
+ | `Json` | `json` | JSON | JSONB | TEXT |
286
+ | `Email` | `string` | VARCHAR(255) | VARCHAR(255) | TEXT |
287
+ | `Password` | `string` | VARCHAR(255) | VARCHAR(255) | TEXT |
288
+ | `Uuid` | `uuid` | CHAR(36) | UUID | TEXT |
289
+ | `Enum` | `enum` | ENUM(...) | VARCHAR(50) | TEXT |
290
+ | `EnumRef` | `string(50)` | VARCHAR(50) | VARCHAR(50) | TEXT |
291
+ | `Point` | `point` | POINT | POINT | - |
292
+ | `Coordinates` | `decimal` x2 | DECIMAL | DECIMAL | REAL |
293
+
294
+ ### Compound Types (Japan Plugin) / 複合型(日本プラグイン)
295
+
296
+ Enable with `compoundTypes: [japan]` in `omnify.yaml`.
297
+
298
+ | Type | Columns | Description |
299
+ |------|---------|-------------|
300
+ | `JapaneseName` | 4 | `lastname`, `firstname`, `kana_lastname`, `kana_firstname` |
301
+ | `JapaneseAddress` | 5 | `postal_code`, `prefecture` (ENUM 47都道府県), `address1`, `address2`, `address3` |
302
+ | `JapaneseBankAccount` | 7 | `bank_code`, `bank_name`, `branch_code`, `branch_name`, `account_type`, `account_number`, `account_holder` |
303
+ | `JapanesePhone` | 1 | Maps to String (VARCHAR 15) |
304
+ | `JapanesePostalCode` | 1 | Maps to String (VARCHAR 8) |
305
+
306
+ #### Example / 使用例
307
+
308
+ ```yaml
309
+ properties:
310
+ name:
311
+ type: JapaneseName
312
+ displayName:
313
+ ja: 氏名
314
+ en: Full Name
315
+ ```
316
+
317
+ Generates:
318
+
319
+ ```php
320
+ $table->string('name_lastname', 100)->comment('Full Name (Lastname)');
321
+ $table->string('name_firstname', 100)->comment('Full Name (Firstname)');
322
+ $table->string('name_kana_lastname', 200)->nullable()->comment('Full Name (KanaLastname)');
323
+ $table->string('name_kana_firstname', 200)->nullable()->comment('Full Name (KanaFirstname)');
86
324
  ```
87
325
 
88
- ## MCP Integration
326
+ ---
89
327
 
90
- omnify includes a built-in MCP (Model Context Protocol) server for AI assistants:
328
+ ## MCP Server (AI Integration) / MCPサーバー(AI連携)
329
+
330
+ Omnify includes a built-in [Model Context Protocol](https://modelcontextprotocol.io/) server for AI-powered editors.
331
+
332
+ AI対応エディタ(Cursor、Claude Code等)でスキーマ情報をリアルタイムに参照できるMCPサーバーを内蔵しています。
333
+
334
+ ### Cursor
335
+
336
+ Add to `.cursor/mcp.json`:
91
337
 
92
338
  ```json
93
339
  {
94
340
  "mcpServers": {
95
341
  "omnify": {
96
- "command": "omnify",
97
- "args": ["mcp"]
342
+ "command": "npx",
343
+ "args": ["omnify", "mcp"]
98
344
  }
99
345
  }
100
346
  }
101
347
  ```
102
348
 
103
- If installed via npm:
349
+ ### Claude Code
350
+
351
+ Add to `.mcp.json`:
104
352
 
105
353
  ```json
106
354
  {
107
355
  "mcpServers": {
108
356
  "omnify": {
109
357
  "command": "npx",
110
- "args": ["@famgia/omnify-bin", "mcp"]
358
+ "args": ["omnify", "mcp"],
359
+ "type": "stdio"
111
360
  }
112
361
  }
113
362
  }
114
363
  ```
115
364
 
116
- ## Supported Platforms
365
+ ### Available MCP Tools / 利用可能なツール
366
+
367
+ | Tool | Description |
368
+ |------|-------------|
369
+ | `omnify_guide` | Interactive documentation (YAML format, types, associations, best practices) |
370
+ | `omnify_list_schemas` | List all schemas with metadata, filterable by kind/group |
371
+ | `omnify_get_schema` | Get raw YAML + computed metadata for a specific schema |
372
+ | `omnify_list_types` | List all property types (built-in, compound, simple, enum) |
373
+ | `omnify_validate` | Validate YAML against the schema system with target verification |
374
+
375
+ ---
376
+
377
+ ## TypeScript Editor DX / TypeScriptエディタ支援
378
+
379
+ This package includes `.d.ts` type definitions for `omnify.yaml` and YAML schema files, providing autocompletion in your editor.
380
+
381
+ このパッケージには`omnify.yaml`とYAMLスキーマファイル用の`.d.ts`型定義が含まれており、エディタで自動補完が利用できます。
382
+
383
+ ```typescript
384
+ import type { OmnifyConfig } from '@omnifyjp/omnify/types/config';
385
+ import type { SchemaDefinition } from '@omnifyjp/omnify/types/schema';
386
+ ```
387
+
388
+ ---
389
+
390
+ ## Supported Platforms / 対応プラットフォーム
117
391
 
118
392
  | Platform | Architecture | Package |
119
393
  |----------|-------------|---------|
120
- | macOS | Apple Silicon (arm64) | `@famgia/omnify-bin-darwin-arm64` |
121
- | macOS | Intel (x64) | `@famgia/omnify-bin-darwin-x64` |
122
- | Linux | x86_64 | `@famgia/omnify-bin-linux-x64` |
123
- | Linux | ARM64 | `@famgia/omnify-bin-linux-arm64` |
124
- | Windows | x86_64 | `@famgia/omnify-bin-win32-x64` |
394
+ | macOS | Apple Silicon (arm64) | `@omnifyjp/omnify-darwin-arm64` |
395
+ | macOS | Intel (x64) | `@omnifyjp/omnify-darwin-x64` |
396
+ | Linux | x86_64 | `@omnifyjp/omnify-linux-x64` |
397
+ | Linux | ARM64 | `@omnifyjp/omnify-linux-arm64` |
398
+ | Windows | x86_64 | `@omnifyjp/omnify-win32-x64` |
399
+
400
+ The correct platform binary is installed automatically via `optionalDependencies`.
401
+
402
+ プラットフォームに応じたバイナリが`optionalDependencies`経由で自動インストールされます。
403
+
404
+ ---
405
+
406
+ ## Links
125
407
 
126
- The correct platform package is installed automatically via `optionalDependencies`.
408
+ - [GitHub](https://github.com/omnifyjp/omnify-go) Source code, issues, and contributions
409
+ - [DEVELOPMENT.md](https://github.com/omnifyjp/omnify-go/blob/main/DEVELOPMENT.md) — Architecture docs, data flow, type system reference
127
410
 
128
411
  ## License
129
412
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnifyjp/omnify",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Schema-driven code generation for Laravel, TypeScript, and SQL",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -36,10 +36,10 @@
36
36
  "zod": "^3.24.0"
37
37
  },
38
38
  "optionalDependencies": {
39
- "@omnifyjp/omnify-darwin-arm64": "0.2.0",
40
- "@omnifyjp/omnify-darwin-x64": "0.2.0",
41
- "@omnifyjp/omnify-linux-x64": "0.2.0",
42
- "@omnifyjp/omnify-linux-arm64": "0.2.0",
43
- "@omnifyjp/omnify-win32-x64": "0.2.0"
39
+ "@omnifyjp/omnify-darwin-arm64": "0.2.1",
40
+ "@omnifyjp/omnify-darwin-x64": "0.2.1",
41
+ "@omnifyjp/omnify-linux-x64": "0.2.1",
42
+ "@omnifyjp/omnify-linux-arm64": "0.2.1",
43
+ "@omnifyjp/omnify-win32-x64": "0.2.1"
44
44
  }
45
45
  }