@omnifyjp/omnify 0.1.0

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 ADDED
@@ -0,0 +1,130 @@
1
+ # @famgia/omnify-bin
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.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ # Global install
9
+ npm install -g @famgia/omnify-bin
10
+
11
+ # Or use npx
12
+ npx @famgia/omnify-bin generate
13
+ ```
14
+
15
+ ## Quick Start
16
+
17
+ ```bash
18
+ # Initialize a new project
19
+ omnify init
20
+
21
+ # Define schemas in schemas/ directory, then generate
22
+ omnify generate
23
+
24
+ # Validate your schemas
25
+ omnify validate
26
+
27
+ # Show what changed since last generation
28
+ omnify diff
29
+
30
+ # Start MCP server for AI assistant integration
31
+ omnify mcp
32
+ ```
33
+
34
+ ## Schema Example
35
+
36
+ ```yaml
37
+ # schemas/User.yaml
38
+ name: User
39
+ kind: object
40
+ displayName:
41
+ en: User
42
+ ja: ユーザー
43
+ options:
44
+ timestamps: true
45
+ softDelete: true
46
+ properties:
47
+ name:
48
+ type: String
49
+ length: 100
50
+ required: true
51
+ displayName:
52
+ en: Name
53
+ ja: 名前
54
+ email:
55
+ type: String
56
+ length: 255
57
+ required: true
58
+ unique: true
59
+ displayName:
60
+ en: Email
61
+ ja: メールアドレス
62
+ role:
63
+ type: Enum
64
+ enum: [admin, editor, viewer]
65
+ default: viewer
66
+ displayName:
67
+ en: Role
68
+ ja: 役割
69
+ ```
70
+
71
+ ## Configuration
72
+
73
+ Create `omnify.yaml` in your project root:
74
+
75
+ ```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
86
+ ```
87
+
88
+ ## MCP Integration
89
+
90
+ omnify includes a built-in MCP (Model Context Protocol) server for AI assistants:
91
+
92
+ ```json
93
+ {
94
+ "mcpServers": {
95
+ "omnify": {
96
+ "command": "omnify",
97
+ "args": ["mcp"]
98
+ }
99
+ }
100
+ }
101
+ ```
102
+
103
+ If installed via npm:
104
+
105
+ ```json
106
+ {
107
+ "mcpServers": {
108
+ "omnify": {
109
+ "command": "npx",
110
+ "args": ["@famgia/omnify-bin", "mcp"]
111
+ }
112
+ }
113
+ }
114
+ ```
115
+
116
+ ## Supported Platforms
117
+
118
+ | Platform | Architecture | Package |
119
+ |----------|-------------|---------|
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` |
125
+
126
+ The correct platform package is installed automatically via `optionalDependencies`.
127
+
128
+ ## License
129
+
130
+ MIT
package/bin/omnify ADDED
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawnSync } = require("child_process");
4
+ const path = require("path");
5
+
6
+ const PLATFORM_MAP = {
7
+ "darwin-arm64": "@famgia/omnify-bin-darwin-arm64",
8
+ "darwin-x64": "@famgia/omnify-bin-darwin-x64",
9
+ "linux-x64": "@famgia/omnify-bin-linux-x64",
10
+ "linux-arm64": "@famgia/omnify-bin-linux-arm64",
11
+ "win32-x64": "@famgia/omnify-bin-win32-x64",
12
+ };
13
+
14
+ const platformKey = `${process.platform}-${process.arch}`;
15
+ const pkg = PLATFORM_MAP[platformKey];
16
+
17
+ if (!pkg) {
18
+ console.error(
19
+ `Unsupported platform: ${process.platform}-${process.arch}\n` +
20
+ `Supported: ${Object.keys(PLATFORM_MAP).join(", ")}`
21
+ );
22
+ process.exit(1);
23
+ }
24
+
25
+ const binName = process.platform === "win32" ? "omnify.exe" : "omnify";
26
+
27
+ let binPath;
28
+ try {
29
+ binPath = require.resolve(path.join(pkg, "bin", binName));
30
+ } catch {
31
+ console.error(
32
+ `Could not find omnify binary for ${platformKey}.\n` +
33
+ `Expected package: ${pkg}\n` +
34
+ `Try reinstalling: npm install -g @famgia/omnify-bin`
35
+ );
36
+ process.exit(1);
37
+ }
38
+
39
+ const result = spawnSync(binPath, process.argv.slice(2), {
40
+ stdio: "inherit",
41
+ env: process.env,
42
+ });
43
+
44
+ if (result.error) {
45
+ if (result.error.code === "EACCES") {
46
+ console.error(
47
+ `Permission denied. Try: chmod +x "${binPath}"`
48
+ );
49
+ } else {
50
+ console.error(`Failed to run omnify: ${result.error.message}`);
51
+ }
52
+ process.exit(1);
53
+ }
54
+
55
+ process.exit(result.status ?? 1);
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@omnifyjp/omnify",
3
+ "version": "0.1.0",
4
+ "description": "Schema-driven code generation for Laravel, TypeScript, and SQL",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/omnifyjp/omnify-go"
9
+ },
10
+ "bin": {
11
+ "omnify": "bin/omnify"
12
+ },
13
+ "types": "types/index.d.ts",
14
+ "exports": {
15
+ "./types": {
16
+ "types": "./types/index.d.ts"
17
+ },
18
+ "./types/*": {
19
+ "types": "./types/*.d.ts"
20
+ },
21
+ "./omnify-schema.json": "./omnify-schema.json",
22
+ "./omnify-config-schema.json": "./omnify-config-schema.json"
23
+ },
24
+ "files": ["bin/", "types/", "omnify-schema.json", "omnify-config-schema.json", "README.md"],
25
+ "optionalDependencies": {
26
+ "@omnifyjp/omnify-darwin-arm64": "0.1.0",
27
+ "@omnifyjp/omnify-darwin-x64": "0.1.0",
28
+ "@omnifyjp/omnify-linux-x64": "0.1.0",
29
+ "@omnifyjp/omnify-linux-arm64": "0.1.0",
30
+ "@omnifyjp/omnify-win32-x64": "0.1.0"
31
+ }
32
+ }
@@ -0,0 +1,70 @@
1
+ import type { LocaleConfig } from "./i18n";
2
+
3
+ /** Supported database driver identifiers. */
4
+ export type DatabaseDriver = "mysql" | "pgsql" | "postgres" | "sqlite";
5
+
6
+ /** SQL dialect for generated migrations. */
7
+ export type SQLDialect = "mysql" | "postgresql" | "sqlite";
8
+
9
+ /** Laravel output configuration. */
10
+ export interface LaravelOutputConfig {
11
+ /** Directory for Laravel migration files. */
12
+ migrationsPath: string;
13
+ /** Path for exported schemas JSON (used by omnify-php-laravel). */
14
+ schemasPath?: string;
15
+ }
16
+
17
+ /** Raw SQL output configuration. */
18
+ export interface SQLOutputConfig {
19
+ /** Directory for SQL migration files. */
20
+ path: string;
21
+ /** SQL dialect for generated migrations. */
22
+ dialect?: SQLDialect;
23
+ }
24
+
25
+ /** TypeScript output configuration. */
26
+ export interface TypeScriptOutputConfig {
27
+ /** Directory for generated TypeScript model files. */
28
+ path: string;
29
+ }
30
+
31
+ /** All output configurations for a connection. */
32
+ export interface OutputConfig {
33
+ laravel?: LaravelOutputConfig;
34
+ sql?: SQLOutputConfig;
35
+ typescript?: TypeScriptOutputConfig;
36
+ }
37
+
38
+ /** Per-connection database and output configuration. */
39
+ export interface ConnectionConfig {
40
+ driver: DatabaseDriver;
41
+ output: OutputConfig;
42
+ }
43
+
44
+ /** Additional schema directory to load. */
45
+ export interface AdditionalSchemaPath {
46
+ /** Path to the additional schema directory. */
47
+ path: string;
48
+ /** Namespace prefix for schemas in this directory. */
49
+ namespace?: string;
50
+ }
51
+
52
+ /** Main Omnify configuration (omnify.yaml). */
53
+ export interface OmnifyConfig {
54
+ /** Directory containing schema YAML files. */
55
+ schemasDir?: string;
56
+ /** Additional schema directories to load. */
57
+ additionalSchemaPaths?: AdditionalSchemaPath[];
58
+ /** Path to the lock file for tracking migration state. */
59
+ lockFilePath?: string;
60
+ /** Database connection configurations. */
61
+ connections?: Record<string, ConnectionConfig>;
62
+ /** Default connection name. */
63
+ default?: string;
64
+ /** Locale settings for multi-language support. */
65
+ locale?: LocaleConfig;
66
+ /** Built-in compound type packs to enable (e.g. "japan"). */
67
+ compoundTypes?: string[];
68
+ /** Enable verbose output during generation. */
69
+ verbose?: boolean;
70
+ }
@@ -0,0 +1,18 @@
1
+ /** BCP-47 locale code (e.g. "ja", "en", "vi"). */
2
+ export type LocaleCode = string;
3
+
4
+ /** Map of locale codes to translated strings. */
5
+ export type LocaleMap = Record<LocaleCode, string>;
6
+
7
+ /** A plain string or a locale map for multi-language support. */
8
+ export type LocalizedString = string | LocaleMap;
9
+
10
+ /** Locale settings for multi-language support. */
11
+ export interface LocaleConfig {
12
+ /** Supported locale codes (e.g. ["ja", "en", "vi"]). */
13
+ locales?: LocaleCode[];
14
+ /** Default locale code. */
15
+ defaultLocale?: string;
16
+ /** Fallback locale when translation is missing. */
17
+ fallbackLocale?: string;
18
+ }
@@ -0,0 +1,36 @@
1
+ export type {
2
+ LocaleCode,
3
+ LocaleMap,
4
+ LocalizedString,
5
+ LocaleConfig,
6
+ } from "./i18n";
7
+
8
+ export type {
9
+ BuiltInPropertyType,
10
+ AssociationRelation,
11
+ ReferentialAction,
12
+ SchemaKind,
13
+ IdType,
14
+ IndexType,
15
+ InlineEnumValue,
16
+ CompoundFieldOverride,
17
+ PivotFieldDefinition,
18
+ ValidationRules,
19
+ PropertyDefinition,
20
+ IndexDefinition,
21
+ SchemaOptions,
22
+ SchemaDefinition,
23
+ LoadedSchema,
24
+ SchemaCollection,
25
+ } from "./schema";
26
+
27
+ export type {
28
+ DatabaseDriver,
29
+ SQLDialect,
30
+ LaravelOutputConfig,
31
+ SQLOutputConfig,
32
+ OutputConfig,
33
+ ConnectionConfig,
34
+ AdditionalSchemaPath,
35
+ OmnifyConfig,
36
+ } from "./config";
@@ -0,0 +1,240 @@
1
+ import type { LocalizedString } from "./i18n";
2
+
3
+ // ---------------------------------------------------------------------------
4
+ // Type unions
5
+ // ---------------------------------------------------------------------------
6
+
7
+ /** Built-in property types supported by Omnify. */
8
+ export type BuiltInPropertyType =
9
+ | "String"
10
+ | "TinyInt"
11
+ | "Int"
12
+ | "BigInt"
13
+ | "Float"
14
+ | "Decimal"
15
+ | "Boolean"
16
+ | "Text"
17
+ | "MediumText"
18
+ | "LongText"
19
+ | "Date"
20
+ | "Time"
21
+ | "Timestamp"
22
+ | "DateTime"
23
+ | "Json"
24
+ | "Email"
25
+ | "Password"
26
+ | "File"
27
+ | "Point"
28
+ | "Coordinates"
29
+ | "Enum"
30
+ | "EnumRef"
31
+ | "Association"
32
+ | "Uuid";
33
+
34
+ /** Relationship cardinality types. */
35
+ export type AssociationRelation =
36
+ | "OneToOne"
37
+ | "OneToMany"
38
+ | "ManyToOne"
39
+ | "ManyToMany"
40
+ | "MorphTo"
41
+ | "MorphOne"
42
+ | "MorphMany"
43
+ | "MorphToMany"
44
+ | "MorphedByMany";
45
+
46
+ /** Referential action for foreign key constraints. */
47
+ export type ReferentialAction =
48
+ | "CASCADE"
49
+ | "SET NULL"
50
+ | "SET DEFAULT"
51
+ | "RESTRICT"
52
+ | "NO ACTION";
53
+
54
+ /** Schema kind determines how a schema is processed. */
55
+ export type SchemaKind = "object" | "enum" | "partial" | "extend" | "pivot";
56
+
57
+ /** Primary key column type. */
58
+ export type IdType = "BigInt" | "Int" | "Uuid" | "String";
59
+
60
+ /** Database index type. */
61
+ export type IndexType = "btree" | "hash" | "fulltext" | "spatial" | "gin" | "gist";
62
+
63
+ // ---------------------------------------------------------------------------
64
+ // Interfaces
65
+ // ---------------------------------------------------------------------------
66
+
67
+ /** An enum value with optional label and extra properties. */
68
+ export interface InlineEnumValue {
69
+ /** Enum value stored in database. */
70
+ value: string;
71
+ /** Human-readable label (supports multi-language). */
72
+ label?: LocalizedString;
73
+ /** Additional metadata. */
74
+ extra?: Record<string, unknown>;
75
+ }
76
+
77
+ /** Per-field overrides for compound types (e.g. JapaneseName sub-fields). */
78
+ export interface CompoundFieldOverride {
79
+ nullable?: boolean;
80
+ hidden?: boolean;
81
+ fillable?: boolean;
82
+ /** Override length for string fields. */
83
+ length?: number;
84
+ displayName?: LocalizedString;
85
+ placeholder?: LocalizedString;
86
+ }
87
+
88
+ /** Field definition on a pivot table. */
89
+ export interface PivotFieldDefinition {
90
+ type: BuiltInPropertyType;
91
+ nullable?: boolean;
92
+ default?: unknown;
93
+ length?: number;
94
+ unsigned?: boolean;
95
+ /** Inline enum values or reference. */
96
+ enum?: (string | InlineEnumValue)[] | string;
97
+ displayName?: LocalizedString;
98
+ }
99
+
100
+ /** Application-level validation rules. */
101
+ export interface ValidationRules {
102
+ required?: boolean;
103
+ // String rules
104
+ minLength?: number;
105
+ maxLength?: number;
106
+ url?: boolean;
107
+ uuid?: boolean;
108
+ ip?: boolean;
109
+ ipv4?: boolean;
110
+ ipv6?: boolean;
111
+ alpha?: boolean;
112
+ alphaNum?: boolean;
113
+ alphaDash?: boolean;
114
+ numeric?: boolean;
115
+ digits?: number;
116
+ digitsBetween?: [number, number];
117
+ startsWith?: string | string[];
118
+ endsWith?: string | string[];
119
+ lowercase?: boolean;
120
+ uppercase?: boolean;
121
+ // Numeric rules
122
+ min?: number;
123
+ max?: number;
124
+ between?: [number, number];
125
+ gt?: number;
126
+ lt?: number;
127
+ multipleOf?: number;
128
+ // Array rules
129
+ arrayMin?: number;
130
+ arrayMax?: number;
131
+ }
132
+
133
+ /** Flat property definition covering all property types. */
134
+ export interface PropertyDefinition {
135
+ type: BuiltInPropertyType;
136
+ displayName?: LocalizedString;
137
+ nullable?: boolean;
138
+ default?: unknown;
139
+ unique?: boolean;
140
+ description?: LocalizedString;
141
+ renamedFrom?: string;
142
+ rules?: ValidationRules;
143
+ primary?: boolean;
144
+ hidden?: boolean;
145
+ fillable?: boolean;
146
+ placeholder?: LocalizedString;
147
+ /** Per-field overrides for compound types. */
148
+ fields?: Record<string, CompoundFieldOverride>;
149
+
150
+ // String-specific
151
+ length?: number;
152
+
153
+ // Numeric-specific
154
+ unsigned?: boolean;
155
+ precision?: number;
156
+ scale?: number;
157
+
158
+ // Timestamp-specific
159
+ useCurrent?: boolean;
160
+ useCurrentOnUpdate?: boolean;
161
+
162
+ // Enum-specific (array for inline Enum, string for EnumRef)
163
+ enum?: (string | InlineEnumValue)[] | string;
164
+
165
+ // File-specific
166
+ multiple?: boolean;
167
+ maxFiles?: number;
168
+ accept?: string[];
169
+ maxSize?: number;
170
+
171
+ // Association-specific
172
+ relation?: AssociationRelation;
173
+ target?: string;
174
+ targets?: string[];
175
+ morphName?: string;
176
+ inversedBy?: string;
177
+ mappedBy?: string;
178
+ onDelete?: ReferentialAction;
179
+ onUpdate?: ReferentialAction;
180
+ owning?: boolean;
181
+ joinTable?: string;
182
+ pivotFields?: Record<string, PivotFieldDefinition>;
183
+ targetNamespace?: string;
184
+ idType?: IdType;
185
+ }
186
+
187
+ /** Database index definition. */
188
+ export interface IndexDefinition {
189
+ columns: string[];
190
+ unique?: boolean;
191
+ name?: string;
192
+ type?: IndexType;
193
+ }
194
+
195
+ /** Schema-level configuration options. */
196
+ export interface SchemaOptions {
197
+ /** Whether to auto-generate an 'id' primary key column. */
198
+ id?: boolean;
199
+ idType?: IdType;
200
+ /** Custom primary key — single column or composite. */
201
+ primaryKey?: string | string[];
202
+ timestamps?: boolean;
203
+ softDelete?: boolean;
204
+ /** Unique constraints — column list or array of column lists. */
205
+ unique?: string[] | string[][];
206
+ indexes?: IndexDefinition[];
207
+ translations?: boolean;
208
+ tableName?: string;
209
+ authenticatable?: boolean;
210
+ hidden?: boolean;
211
+ }
212
+
213
+ /** Complete schema definition (corresponds to a single YAML file). */
214
+ export interface SchemaDefinition {
215
+ connection?: string;
216
+ kind?: SchemaKind;
217
+ /** Target schema name for partial/extend schemas. */
218
+ target?: string;
219
+ /** Priority for partial merging (default 50). */
220
+ priority?: number;
221
+ /** Schema names this pivot is for. */
222
+ pivotFor?: string[];
223
+ displayName?: LocalizedString;
224
+ titleIndex?: string;
225
+ group?: string;
226
+ options?: SchemaOptions;
227
+ properties?: Record<string, PropertyDefinition>;
228
+ /** Enum values (only when kind is "enum"). */
229
+ values?: (string | InlineEnumValue)[];
230
+ }
231
+
232
+ /** A schema with metadata from loading. */
233
+ export interface LoadedSchema extends SchemaDefinition {
234
+ name: string;
235
+ filePath: string;
236
+ relativePath: string;
237
+ }
238
+
239
+ /** Map of schema name to loaded schema. */
240
+ export type SchemaCollection = Record<string, LoadedSchema>;