@famgia/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/CHANGELOG.md +14 -0
- package/README.md +183 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +213 -0
- package/dist/cli.js.map +1 -0
- package/dist/generators/contextGenerator.d.ts +3 -0
- package/dist/generators/contextGenerator.d.ts.map +1 -0
- package/dist/generators/contextGenerator.js +134 -0
- package/dist/generators/contextGenerator.js.map +1 -0
- package/dist/generators/enumGenerator.d.ts +13 -0
- package/dist/generators/enumGenerator.d.ts.map +1 -0
- package/dist/generators/enumGenerator.js +80 -0
- package/dist/generators/enumGenerator.js.map +1 -0
- package/dist/generators/modelGenerator.d.ts +4 -0
- package/dist/generators/modelGenerator.d.ts.map +1 -0
- package/dist/generators/modelGenerator.js +138 -0
- package/dist/generators/modelGenerator.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +40 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/typeMapper.d.ts +6 -0
- package/dist/utils/typeMapper.d.ts.map +1 -0
- package/dist/utils/typeMapper.js +85 -0
- package/dist/utils/typeMapper.js.map +1 -0
- package/package.json +51 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.1.0] - 2025-11-09
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- Initial release
|
|
7
|
+
- TypeScript type generation from Omnify schema-lock.json
|
|
8
|
+
- Enum types and options generation
|
|
9
|
+
- Model interface generation
|
|
10
|
+
- React EnumsContext provider generation
|
|
11
|
+
- CLI tool for building types
|
|
12
|
+
- Support for all Omnify field types
|
|
13
|
+
- Automatic enum grouping by property name
|
|
14
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# @omnifyjp/omnify
|
|
2
|
+
|
|
3
|
+
Convert Omnify schema-lock.json to TypeScript models and enums.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@omnifyjp/omnify)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
A standalone code generator that reads Omnify schema files and generates TypeScript type definitions, enum constants, and React context providers.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
### From npm
|
|
13
|
+
```bash
|
|
14
|
+
npm install --save-dev @omnifyjp/omnify
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Local development (in monorepo)
|
|
18
|
+
```json
|
|
19
|
+
{
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@omnifyjp/omnify": "file:../packages/omnify"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Then run:
|
|
27
|
+
```bash
|
|
28
|
+
npm install
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
omnify-build [--schema <path>] --output <output-directory> [--watch]
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Options
|
|
38
|
+
|
|
39
|
+
- `--schema <path>` - Path to schema-lock.json file (optional, auto-detects from `.omnify/`)
|
|
40
|
+
- `--output <dir>` - Output directory for generated files (required)
|
|
41
|
+
- `--watch` - Watch for schema changes and rebuild automatically
|
|
42
|
+
- `--help` - Show help message
|
|
43
|
+
|
|
44
|
+
### Auto-detection
|
|
45
|
+
|
|
46
|
+
If `--schema` is not provided, the tool will automatically search for `schema-lock.json` in:
|
|
47
|
+
1. `../backend/.omnify/schema-lock.json` (from frontend directory)
|
|
48
|
+
2. `./backend/.omnify/schema-lock.json` (from project root)
|
|
49
|
+
3. `./.omnify/schema-lock.json` (current directory)
|
|
50
|
+
|
|
51
|
+
### Examples
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Auto-detect schema from .omnify/ directory
|
|
55
|
+
omnify-build --output src/omnify
|
|
56
|
+
|
|
57
|
+
# Explicit schema path
|
|
58
|
+
omnify-build --schema backend/.omnify/schema-lock.json --output src/omnify
|
|
59
|
+
|
|
60
|
+
# Watch mode with auto-detection
|
|
61
|
+
omnify-build --output src/omnify --watch
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Output Structure
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
output-dir/
|
|
68
|
+
├── types/
|
|
69
|
+
│ ├── enums.ts # TypeScript enum union types
|
|
70
|
+
│ ├── enumOptions.ts # Enum constant objects
|
|
71
|
+
│ ├── models.ts # TypeScript interfaces
|
|
72
|
+
│ └── index.ts
|
|
73
|
+
├── contexts/
|
|
74
|
+
│ ├── EnumsContext.tsx # React context provider
|
|
75
|
+
│ └── index.ts
|
|
76
|
+
└── index.ts
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Package.json Scripts
|
|
80
|
+
|
|
81
|
+
Add to your project's `package.json`:
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"scripts": {
|
|
86
|
+
"omnify:build": "omnify-build --output src/omnify",
|
|
87
|
+
"omnify:dev": "omnify-build --output src/omnify --watch"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Using Generated Types
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
// Import types
|
|
96
|
+
import { ApplicationForm } from '@/omnify/types';
|
|
97
|
+
import type { Company_EntityType } from '@/omnify/types';
|
|
98
|
+
|
|
99
|
+
// Import enum options
|
|
100
|
+
import { entity_typeOptions, account_typeOptions } from '@/omnify/types';
|
|
101
|
+
|
|
102
|
+
// Use in React
|
|
103
|
+
function MySelect() {
|
|
104
|
+
return (
|
|
105
|
+
<select>
|
|
106
|
+
{Object.entries(entity_typeOptions).map(([value, label]) => (
|
|
107
|
+
<option key={value} value={value}>{label}</option>
|
|
108
|
+
))}
|
|
109
|
+
</select>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Import context provider
|
|
114
|
+
import { EnumsProvider, useEnums } from '@/omnify/contexts';
|
|
115
|
+
|
|
116
|
+
function App() {
|
|
117
|
+
return (
|
|
118
|
+
<EnumsProvider>
|
|
119
|
+
<YourApp />
|
|
120
|
+
</EnumsProvider>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function Component() {
|
|
125
|
+
const { enums } = useEnums();
|
|
126
|
+
return <div>{enums.entity_type.CORPORATION}</div>;
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Features
|
|
131
|
+
|
|
132
|
+
- ✅ Generates TypeScript interfaces from Omnify models
|
|
133
|
+
- ✅ Creates enum union types
|
|
134
|
+
- ✅ Generates enum constant objects for easy use
|
|
135
|
+
- ✅ Creates React context provider with static enum data
|
|
136
|
+
- ✅ Watch mode for development
|
|
137
|
+
- ✅ Type-safe enum usage
|
|
138
|
+
- ✅ No runtime dependencies (enums are static)
|
|
139
|
+
- ✅ Standalone package - works with any project structure
|
|
140
|
+
- ✅ Supports composite types (JapanAddress, JapanPersonName)
|
|
141
|
+
- ✅ Includes prefectures enum (47 prefectures)
|
|
142
|
+
|
|
143
|
+
## Supported Omnify Types
|
|
144
|
+
|
|
145
|
+
### Numeric Types
|
|
146
|
+
- `Id`, `Int`, `TinyInt`, `BigInt`, `Float` → `number`
|
|
147
|
+
|
|
148
|
+
### String Types
|
|
149
|
+
- `String`, `Text`, `LongText`, `Email`, `Password`, `JapanPhone`, `Color`, `Time` → `string`
|
|
150
|
+
|
|
151
|
+
### Boolean Types
|
|
152
|
+
- `Boolean` → `boolean`
|
|
153
|
+
|
|
154
|
+
### Date/Time Types
|
|
155
|
+
- `Date`, `Timestamp` → `string` (ISO format)
|
|
156
|
+
|
|
157
|
+
### JSON Types
|
|
158
|
+
- `Json` → `Record<string, any>`
|
|
159
|
+
|
|
160
|
+
### Enum Types
|
|
161
|
+
- `Enum` → Generated union types
|
|
162
|
+
|
|
163
|
+
### Relation Types
|
|
164
|
+
- `Association`, `Polymorphic`, `Lookup` → `any` (skipped in models)
|
|
165
|
+
|
|
166
|
+
### Select Types
|
|
167
|
+
- `Select`, `SingleSelect`, `MultiSelect` → `string`
|
|
168
|
+
|
|
169
|
+
### File Types
|
|
170
|
+
- `File`, `MultiFile` → `string` (file path/URL)
|
|
171
|
+
|
|
172
|
+
### Composite Types
|
|
173
|
+
- `JapanAddress` → Expanded to flat fields (postal_code, prefecture_id, address1-3)
|
|
174
|
+
- `JapanPersonName` → Expanded to flat fields (lastname, firstname, kana_lastname, kana_firstname)
|
|
175
|
+
|
|
176
|
+
## Requirements
|
|
177
|
+
|
|
178
|
+
- Node.js >= 16
|
|
179
|
+
- TypeScript >= 5.0 (peer dependency)
|
|
180
|
+
|
|
181
|
+
## License
|
|
182
|
+
|
|
183
|
+
MIT
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const enumGenerator_1 = require("./generators/enumGenerator");
|
|
40
|
+
const modelGenerator_1 = require("./generators/modelGenerator");
|
|
41
|
+
const contextGenerator_1 = require("./generators/contextGenerator");
|
|
42
|
+
function build(options) {
|
|
43
|
+
const { schemaPath, outputDir } = options;
|
|
44
|
+
console.log('\n🔨 Building Omnify types...');
|
|
45
|
+
// Check if schema exists
|
|
46
|
+
if (!fs.existsSync(schemaPath)) {
|
|
47
|
+
console.error(`❌ Error: Schema file not found at ${schemaPath}`);
|
|
48
|
+
console.error('\nUsage:');
|
|
49
|
+
console.error(' omnify-build --schema <path> --output <dir>');
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
// Read schema
|
|
54
|
+
const schemaContent = fs.readFileSync(schemaPath, 'utf-8');
|
|
55
|
+
const schema = JSON.parse(schemaContent);
|
|
56
|
+
// Create output directories
|
|
57
|
+
const typesDir = path.join(outputDir, 'types');
|
|
58
|
+
const contextsDir = path.join(outputDir, 'contexts');
|
|
59
|
+
[typesDir, contextsDir].forEach(dir => {
|
|
60
|
+
if (!fs.existsSync(dir)) {
|
|
61
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
// Extract enums
|
|
65
|
+
const enums = (0, enumGenerator_1.extractEnums)(schema);
|
|
66
|
+
console.log(`📦 Found ${enums.length} enum properties`);
|
|
67
|
+
// Generate enum types
|
|
68
|
+
const enumTypesContent = (0, enumGenerator_1.generateEnumTypesFile)(enums);
|
|
69
|
+
fs.writeFileSync(path.join(typesDir, 'enums.ts'), enumTypesContent);
|
|
70
|
+
console.log('✅ Generated types/enums.ts');
|
|
71
|
+
// Generate enum options
|
|
72
|
+
const enumOptionsContent = (0, enumGenerator_1.generateEnumOptionsFile)(enums);
|
|
73
|
+
fs.writeFileSync(path.join(typesDir, 'enumOptions.ts'), enumOptionsContent);
|
|
74
|
+
console.log('✅ Generated types/enumOptions.ts');
|
|
75
|
+
// Generate models
|
|
76
|
+
const modelsContent = (0, modelGenerator_1.generateAllModels)(schema);
|
|
77
|
+
fs.writeFileSync(path.join(typesDir, 'models.ts'), modelsContent);
|
|
78
|
+
console.log('✅ Generated types/models.ts');
|
|
79
|
+
// Generate enum context
|
|
80
|
+
const contextContent = (0, contextGenerator_1.generateEnumContextFile)(enums);
|
|
81
|
+
fs.writeFileSync(path.join(contextsDir, 'EnumsContext.tsx'), contextContent);
|
|
82
|
+
console.log('✅ Generated contexts/EnumsContext.tsx');
|
|
83
|
+
// Generate index files
|
|
84
|
+
const typesIndexContent = `// Auto-generated by @omnifyjp/omnify
|
|
85
|
+
export * from './enums';
|
|
86
|
+
export * from './enumOptions';
|
|
87
|
+
export * from './models';
|
|
88
|
+
`;
|
|
89
|
+
fs.writeFileSync(path.join(typesDir, 'index.ts'), typesIndexContent);
|
|
90
|
+
console.log('✅ Generated types/index.ts');
|
|
91
|
+
const contextsIndexContent = `// Auto-generated by @omnifyjp/omnify
|
|
92
|
+
export * from './EnumsContext';
|
|
93
|
+
`;
|
|
94
|
+
fs.writeFileSync(path.join(contextsDir, 'index.ts'), contextsIndexContent);
|
|
95
|
+
console.log('✅ Generated contexts/index.ts');
|
|
96
|
+
const mainIndexContent = `// Auto-generated by @omnifyjp/omnify
|
|
97
|
+
export * from './types';
|
|
98
|
+
export * from './contexts';
|
|
99
|
+
`;
|
|
100
|
+
fs.writeFileSync(path.join(outputDir, 'index.ts'), mainIndexContent);
|
|
101
|
+
console.log('✅ Generated index.ts');
|
|
102
|
+
console.log(`\n✨ Generated files in: ${outputDir}\n`);
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
console.error('\n❌ Error:', error.message);
|
|
106
|
+
process.exit(1);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function watch(options) {
|
|
110
|
+
console.log(`\n👀 Watching ${options.schemaPath}...\n`);
|
|
111
|
+
// Initial build
|
|
112
|
+
build(options);
|
|
113
|
+
// Watch for changes
|
|
114
|
+
const chokidar = require('chokidar');
|
|
115
|
+
const watcher = chokidar.watch(options.schemaPath, {
|
|
116
|
+
persistent: true,
|
|
117
|
+
ignoreInitial: true,
|
|
118
|
+
});
|
|
119
|
+
watcher.on('change', () => {
|
|
120
|
+
console.log('\n🔄 Schema changed, rebuilding...');
|
|
121
|
+
build(options);
|
|
122
|
+
});
|
|
123
|
+
watcher.on('error', (error) => {
|
|
124
|
+
console.error('❌ Watcher error:', error);
|
|
125
|
+
});
|
|
126
|
+
// Handle graceful shutdown
|
|
127
|
+
process.on('SIGINT', () => {
|
|
128
|
+
console.log('\n\n👋 Stopping...');
|
|
129
|
+
watcher.close();
|
|
130
|
+
process.exit(0);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
// CLI
|
|
134
|
+
const args = process.argv.slice(2);
|
|
135
|
+
if (args.length === 0 || args.includes('--help') || args.includes('-h')) {
|
|
136
|
+
console.log('omnify-build - Convert Omnify .omnify/schema-lock.json to TypeScript types');
|
|
137
|
+
console.log('');
|
|
138
|
+
console.log('Usage:');
|
|
139
|
+
console.log(' omnify-build [--schema <path>] --output <dir> [--watch]');
|
|
140
|
+
console.log('');
|
|
141
|
+
console.log('Options:');
|
|
142
|
+
console.log(' --schema <path> Path to schema-lock.json (optional, auto-detect from .omnify/)');
|
|
143
|
+
console.log(' --output <dir> Output directory (required)');
|
|
144
|
+
console.log(' --watch Watch for schema changes');
|
|
145
|
+
console.log(' --help, -h Show this help');
|
|
146
|
+
console.log('');
|
|
147
|
+
console.log('Auto-detection paths (in order):');
|
|
148
|
+
console.log(' 1. ../backend/.omnify/schema-lock.json (from frontend)');
|
|
149
|
+
console.log(' 2. ./backend/.omnify/schema-lock.json (from root)');
|
|
150
|
+
console.log(' 3. ./.omnify/schema-lock.json (current dir)');
|
|
151
|
+
console.log('');
|
|
152
|
+
console.log('Examples:');
|
|
153
|
+
console.log(' omnify-build --output src/omnify # Auto-detect schema');
|
|
154
|
+
console.log(' omnify-build --schema backend/.omnify/schema-lock.json --output src/omnify');
|
|
155
|
+
console.log(' omnify-build --output src/omnify --watch # Auto-detect + watch');
|
|
156
|
+
process.exit(args.length === 0 ? 1 : 0);
|
|
157
|
+
}
|
|
158
|
+
// Parse arguments
|
|
159
|
+
let schemaPath = null;
|
|
160
|
+
let outputDir = null;
|
|
161
|
+
let watchMode = args.includes('--watch');
|
|
162
|
+
for (let i = 0; i < args.length; i++) {
|
|
163
|
+
if (args[i] === '--schema' && i + 1 < args.length) {
|
|
164
|
+
schemaPath = path.resolve(args[i + 1]);
|
|
165
|
+
i++;
|
|
166
|
+
}
|
|
167
|
+
else if (args[i] === '--output' && i + 1 < args.length) {
|
|
168
|
+
outputDir = path.resolve(args[i + 1]);
|
|
169
|
+
i++;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
// Auto-detect schema path if not provided
|
|
173
|
+
if (!schemaPath) {
|
|
174
|
+
const possiblePaths = [
|
|
175
|
+
path.resolve('../backend/.omnify/schema-lock.json'), // Priority: backend from frontend
|
|
176
|
+
path.resolve('backend/.omnify/schema-lock.json'), // Priority: backend from root
|
|
177
|
+
path.resolve('.omnify/schema-lock.json'), // Fallback: current directory
|
|
178
|
+
];
|
|
179
|
+
for (const possiblePath of possiblePaths) {
|
|
180
|
+
if (fs.existsSync(possiblePath)) {
|
|
181
|
+
schemaPath = possiblePath;
|
|
182
|
+
console.log(`📍 Auto-detected schema at: ${possiblePath}`);
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (!schemaPath) {
|
|
187
|
+
console.error('❌ Error: Could not find schema-lock.json');
|
|
188
|
+
console.error('\nSearched in:');
|
|
189
|
+
possiblePaths.forEach(p => console.error(` - ${p}`));
|
|
190
|
+
console.error('\nPlease specify with --schema <path>');
|
|
191
|
+
console.error('\nUsage:');
|
|
192
|
+
console.error(' omnify-build --schema <path> --output <dir>');
|
|
193
|
+
process.exit(1);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (!outputDir) {
|
|
197
|
+
console.error('❌ Error: --output is required');
|
|
198
|
+
console.error('\nUsage:');
|
|
199
|
+
console.error(' omnify-build --schema <path> --output <dir>');
|
|
200
|
+
process.exit(1);
|
|
201
|
+
}
|
|
202
|
+
const options = {
|
|
203
|
+
schemaPath,
|
|
204
|
+
outputDir,
|
|
205
|
+
watch: watchMode,
|
|
206
|
+
};
|
|
207
|
+
if (watchMode) {
|
|
208
|
+
watch(options);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
build(options);
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=cli.js.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O,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;IAC/D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,OAAO,GAAiB;IAC5B,UAAU;IACV,SAAS;IACT,KAAK,EAAE,SAAS;CACjB,CAAC;AAEF,IAAI,SAAS,EAAE,CAAC;IACd,KAAK,CAAC,OAAO,CAAC,CAAC;AACjB,CAAC;KAAM,CAAC;IACN,KAAK,CAAC,OAAO,CAAC,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contextGenerator.d.ts","sourceRoot":"","sources":["../../src/generators/contextGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,MAAM,CAyIjE"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateEnumContextFile = generateEnumContextFile;
|
|
4
|
+
function generateEnumContextFile(enums) {
|
|
5
|
+
const lines = [];
|
|
6
|
+
lines.push("'use client';");
|
|
7
|
+
lines.push('');
|
|
8
|
+
lines.push('// Auto-generated by @omnifyjp/omnify');
|
|
9
|
+
lines.push('// Do not edit this file manually');
|
|
10
|
+
lines.push('');
|
|
11
|
+
lines.push("import React, { createContext, useContext, useState, useEffect, ReactNode } from 'react';");
|
|
12
|
+
lines.push('');
|
|
13
|
+
// Group by property name
|
|
14
|
+
const enumsByProperty = new Map();
|
|
15
|
+
for (const enumInfo of enums) {
|
|
16
|
+
const key = enumInfo.propertyName;
|
|
17
|
+
if (!enumsByProperty.has(key)) {
|
|
18
|
+
enumsByProperty.set(key, []);
|
|
19
|
+
}
|
|
20
|
+
enumsByProperty.get(key).push(enumInfo);
|
|
21
|
+
}
|
|
22
|
+
// Generate EnumOptions interface
|
|
23
|
+
lines.push('export interface EnumOptions {');
|
|
24
|
+
for (const propertyName of enumsByProperty.keys()) {
|
|
25
|
+
lines.push(` ${propertyName}: Record<string, string>;`);
|
|
26
|
+
}
|
|
27
|
+
lines.push(' prefectures: Record<string, string>;');
|
|
28
|
+
lines.push('}');
|
|
29
|
+
lines.push('');
|
|
30
|
+
// Generate static enum data
|
|
31
|
+
lines.push('const STATIC_ENUMS: EnumOptions = {');
|
|
32
|
+
for (const [propertyName, enumInfos] of enumsByProperty.entries()) {
|
|
33
|
+
const values = enumInfos[0].values;
|
|
34
|
+
lines.push(` ${propertyName}: {`);
|
|
35
|
+
for (const { value, label } of values) {
|
|
36
|
+
lines.push(` ${value}: '${label}',`);
|
|
37
|
+
}
|
|
38
|
+
lines.push(' },');
|
|
39
|
+
}
|
|
40
|
+
// Add prefectures
|
|
41
|
+
lines.push(' prefectures: {');
|
|
42
|
+
const prefectures = [
|
|
43
|
+
{ code: 1, label: '北海道' },
|
|
44
|
+
{ code: 2, label: '青森県' },
|
|
45
|
+
{ code: 3, label: '岩手県' },
|
|
46
|
+
{ code: 4, label: '宮城県' },
|
|
47
|
+
{ code: 5, label: '秋田県' },
|
|
48
|
+
{ code: 6, label: '山形県' },
|
|
49
|
+
{ code: 7, label: '福島県' },
|
|
50
|
+
{ code: 8, label: '茨城県' },
|
|
51
|
+
{ code: 9, label: '栃木県' },
|
|
52
|
+
{ code: 10, label: '群馬県' },
|
|
53
|
+
{ code: 11, label: '埼玉県' },
|
|
54
|
+
{ code: 12, label: '千葉県' },
|
|
55
|
+
{ code: 13, label: '東京都' },
|
|
56
|
+
{ code: 14, label: '神奈川県' },
|
|
57
|
+
{ code: 15, label: '新潟県' },
|
|
58
|
+
{ code: 16, label: '富山県' },
|
|
59
|
+
{ code: 17, label: '石川県' },
|
|
60
|
+
{ code: 18, label: '福井県' },
|
|
61
|
+
{ code: 19, label: '山梨県' },
|
|
62
|
+
{ code: 20, label: '長野県' },
|
|
63
|
+
{ code: 21, label: '岐阜県' },
|
|
64
|
+
{ code: 22, label: '静岡県' },
|
|
65
|
+
{ code: 23, label: '愛知県' },
|
|
66
|
+
{ code: 24, label: '三重県' },
|
|
67
|
+
{ code: 25, label: '滋賀県' },
|
|
68
|
+
{ code: 26, label: '京都府' },
|
|
69
|
+
{ code: 27, label: '大阪府' },
|
|
70
|
+
{ code: 28, label: '兵庫県' },
|
|
71
|
+
{ code: 29, label: '奈良県' },
|
|
72
|
+
{ code: 30, label: '和歌山県' },
|
|
73
|
+
{ code: 31, label: '鳥取県' },
|
|
74
|
+
{ code: 32, label: '島根県' },
|
|
75
|
+
{ code: 33, label: '岡山県' },
|
|
76
|
+
{ code: 34, label: '広島県' },
|
|
77
|
+
{ code: 35, label: '山口県' },
|
|
78
|
+
{ code: 36, label: '徳島県' },
|
|
79
|
+
{ code: 37, label: '香川県' },
|
|
80
|
+
{ code: 38, label: '愛媛県' },
|
|
81
|
+
{ code: 39, label: '高知県' },
|
|
82
|
+
{ code: 40, label: '福岡県' },
|
|
83
|
+
{ code: 41, label: '佐賀県' },
|
|
84
|
+
{ code: 42, label: '長崎県' },
|
|
85
|
+
{ code: 43, label: '熊本県' },
|
|
86
|
+
{ code: 44, label: '大分県' },
|
|
87
|
+
{ code: 45, label: '宮崎県' },
|
|
88
|
+
{ code: 46, label: '鹿児島県' },
|
|
89
|
+
{ code: 47, label: '沖縄県' },
|
|
90
|
+
];
|
|
91
|
+
for (const { code, label } of prefectures) {
|
|
92
|
+
lines.push(` '${code}': '${label}',`);
|
|
93
|
+
}
|
|
94
|
+
lines.push(' },');
|
|
95
|
+
lines.push('};');
|
|
96
|
+
lines.push('');
|
|
97
|
+
// Generate context
|
|
98
|
+
lines.push('interface EnumsContextType {');
|
|
99
|
+
lines.push(' enums: EnumOptions | null;');
|
|
100
|
+
lines.push(' loading: boolean;');
|
|
101
|
+
lines.push(' error: Error | null;');
|
|
102
|
+
lines.push('}');
|
|
103
|
+
lines.push('');
|
|
104
|
+
lines.push('const EnumsContext = createContext<EnumsContextType | undefined>(undefined);');
|
|
105
|
+
lines.push('');
|
|
106
|
+
lines.push('export function EnumsProvider({ children }: { children: ReactNode }) {');
|
|
107
|
+
lines.push(' const [enums] = useState<EnumOptions>(STATIC_ENUMS);');
|
|
108
|
+
lines.push(' const [loading] = useState(false);');
|
|
109
|
+
lines.push(' const [error] = useState<Error | null>(null);');
|
|
110
|
+
lines.push('');
|
|
111
|
+
lines.push(' return (');
|
|
112
|
+
lines.push(' <EnumsContext.Provider');
|
|
113
|
+
lines.push(' value={{');
|
|
114
|
+
lines.push(' enums,');
|
|
115
|
+
lines.push(' loading,');
|
|
116
|
+
lines.push(' error,');
|
|
117
|
+
lines.push(' }}');
|
|
118
|
+
lines.push(' >');
|
|
119
|
+
lines.push(' {children}');
|
|
120
|
+
lines.push(' </EnumsContext.Provider>');
|
|
121
|
+
lines.push(' );');
|
|
122
|
+
lines.push('}');
|
|
123
|
+
lines.push('');
|
|
124
|
+
lines.push('export function useEnums(): EnumsContextType {');
|
|
125
|
+
lines.push(' const context = useContext(EnumsContext);');
|
|
126
|
+
lines.push(' if (context === undefined) {');
|
|
127
|
+
lines.push(" throw new Error('useEnums must be used within an EnumsProvider');");
|
|
128
|
+
lines.push(' }');
|
|
129
|
+
lines.push(' return context;');
|
|
130
|
+
lines.push('}');
|
|
131
|
+
lines.push('');
|
|
132
|
+
return lines.join('\n');
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=contextGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contextGenerator.js","sourceRoot":"","sources":["../../src/generators/contextGenerator.ts"],"names":[],"mappings":";;AAEA,0DAyIC;AAzID,SAAgB,uBAAuB,CAAC,KAAiB;IACvD,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAC5B,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAA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AC;IAC1D,KAAK,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;IAC7C,KAAK,CAAC,IAAI,CAAC,uEAAuE,CAAC,CAAC;IACpF,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClB,KAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IAChC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEf,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SchemaLock } from '../types';
|
|
2
|
+
export interface EnumInfo {
|
|
3
|
+
objectName: string;
|
|
4
|
+
propertyName: string;
|
|
5
|
+
values: Array<{
|
|
6
|
+
value: string;
|
|
7
|
+
label: string;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
10
|
+
export declare function extractEnums(schema: SchemaLock): EnumInfo[];
|
|
11
|
+
export declare function generateEnumTypesFile(enums: EnumInfo[]): string;
|
|
12
|
+
export declare function generateEnumOptionsFile(enums: EnumInfo[]): string;
|
|
13
|
+
//# sourceMappingURL=enumGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enumGenerator.d.ts","sourceRoot":"","sources":["../../src/generators/enumGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAY,MAAM,UAAU,CAAC;AAGhD,MAAM,WAAW,QAAQ;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACjD;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,QAAQ,EAAE,CAmB3D;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,MAAM,CA0B/D;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,MAAM,CAwCjE"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractEnums = extractEnums;
|
|
4
|
+
exports.generateEnumTypesFile = generateEnumTypesFile;
|
|
5
|
+
exports.generateEnumOptionsFile = generateEnumOptionsFile;
|
|
6
|
+
const typeMapper_1 = require("../utils/typeMapper");
|
|
7
|
+
function extractEnums(schema) {
|
|
8
|
+
const enums = [];
|
|
9
|
+
for (const [objectName, object] of Object.entries(schema)) {
|
|
10
|
+
for (const [propertyName, property] of Object.entries(object.properties)) {
|
|
11
|
+
if (property.type === 'Enum' && property.enum) {
|
|
12
|
+
const values = (0, typeMapper_1.normalizeEnumArray)(property.enum);
|
|
13
|
+
if (values.length > 0) {
|
|
14
|
+
enums.push({
|
|
15
|
+
objectName,
|
|
16
|
+
propertyName,
|
|
17
|
+
values,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return enums;
|
|
24
|
+
}
|
|
25
|
+
function generateEnumTypesFile(enums) {
|
|
26
|
+
const lines = [];
|
|
27
|
+
lines.push('// Auto-generated by @omnifyjp/omnify');
|
|
28
|
+
lines.push('// Do not edit this file manually');
|
|
29
|
+
lines.push('');
|
|
30
|
+
// Generate individual enum types
|
|
31
|
+
const enumTypeNames = new Set();
|
|
32
|
+
for (const enumInfo of enums) {
|
|
33
|
+
const enumTypeName = `${enumInfo.objectName}_${enumInfo.propertyName}`;
|
|
34
|
+
// Skip duplicates (same enum used in multiple models)
|
|
35
|
+
if (enumTypeNames.has(enumTypeName)) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
enumTypeNames.add(enumTypeName);
|
|
39
|
+
lines.push(`export type ${enumTypeName} =`);
|
|
40
|
+
const values = enumInfo.values.map(v => ` | '${v.value}'`);
|
|
41
|
+
lines.push(values.join('\n') + ';');
|
|
42
|
+
lines.push('');
|
|
43
|
+
}
|
|
44
|
+
return lines.join('\n');
|
|
45
|
+
}
|
|
46
|
+
function generateEnumOptionsFile(enums) {
|
|
47
|
+
const lines = [];
|
|
48
|
+
lines.push('// Auto-generated by @omnifyjp/omnify');
|
|
49
|
+
lines.push('// Do not edit this file manually');
|
|
50
|
+
lines.push('');
|
|
51
|
+
// Group enums by property name (e.g., all "entity_type", all "company_type")
|
|
52
|
+
const enumsByProperty = new Map();
|
|
53
|
+
for (const enumInfo of enums) {
|
|
54
|
+
const key = enumInfo.propertyName;
|
|
55
|
+
if (!enumsByProperty.has(key)) {
|
|
56
|
+
enumsByProperty.set(key, []);
|
|
57
|
+
}
|
|
58
|
+
enumsByProperty.get(key).push(enumInfo);
|
|
59
|
+
}
|
|
60
|
+
// Generate enum options objects
|
|
61
|
+
for (const [propertyName, enumInfos] of enumsByProperty.entries()) {
|
|
62
|
+
// Use the first one's values (they should be the same across models)
|
|
63
|
+
const values = enumInfos[0].values;
|
|
64
|
+
lines.push(`export const ${propertyName}Options = {`);
|
|
65
|
+
for (const { value, label } of values) {
|
|
66
|
+
lines.push(` ${value}: '${label}',`);
|
|
67
|
+
}
|
|
68
|
+
lines.push('} as const;');
|
|
69
|
+
lines.push('');
|
|
70
|
+
}
|
|
71
|
+
// Generate EnumOptions interface
|
|
72
|
+
lines.push('export interface EnumOptions {');
|
|
73
|
+
for (const propertyName of enumsByProperty.keys()) {
|
|
74
|
+
lines.push(` ${propertyName}: Record<string, string>;`);
|
|
75
|
+
}
|
|
76
|
+
lines.push('}');
|
|
77
|
+
lines.push('');
|
|
78
|
+
return lines.join('\n');
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=enumGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enumGenerator.js","sourceRoot":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;QAClE,qEAAqE;QACrE,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAEnC,KAAK,CAAC,IAAI,CAAC,gBAAgB,YAAY,aAAa,CAAC,CAAC;QACtD,KAAK,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,MAAM,EAAE,CAAC;YACtC,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC;QACxC,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC1B,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,iCAAiC;IACjC,KAAK,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;IAC7C,KAAK,MAAM,YAAY,IAAI,eAAe,CAAC,IAAI,EAAE,EAAE,CAAC;QAClD,KAAK,CAAC,IAAI,CAAC,KAAK,YAAY,2BAA2B,CAAC,CAAC;IAC3D,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEf,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelGenerator.d.ts","sourceRoot":"","sources":["../../src/generators/modelGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAY,UAAU,EAAE,MAAM,UAAU,CAAC;AAwB9D,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,MAAM,CA2ClF;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CA6F5D"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateModelFile = generateModelFile;
|
|
4
|
+
exports.generateAllModels = generateAllModels;
|
|
5
|
+
const typeMapper_1 = require("../utils/typeMapper");
|
|
6
|
+
function expandCompositeFields(prop) {
|
|
7
|
+
if (!prop.fields)
|
|
8
|
+
return [];
|
|
9
|
+
const fields = [];
|
|
10
|
+
for (const [fieldName, field] of Object.entries(prop.fields)) {
|
|
11
|
+
const tsType = (0, typeMapper_1.mapOmnifyTypeToTypeScript)(field.type, field.nullable);
|
|
12
|
+
const optional = field.nullable ? '?' : '';
|
|
13
|
+
const comment = field.displayName ? ` // ${field.displayName}` : '';
|
|
14
|
+
fields.push({
|
|
15
|
+
name: field.propertyName,
|
|
16
|
+
type: tsType,
|
|
17
|
+
optional,
|
|
18
|
+
comment,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return fields;
|
|
22
|
+
}
|
|
23
|
+
function generateModelFile(objectName, object) {
|
|
24
|
+
const lines = [];
|
|
25
|
+
lines.push('// Auto-generated by @omnifyjp/omnify');
|
|
26
|
+
lines.push('// Do not edit this file manually');
|
|
27
|
+
lines.push('');
|
|
28
|
+
// Generate interface
|
|
29
|
+
lines.push(`export interface ${objectName} {`);
|
|
30
|
+
for (const [propName, prop] of Object.entries(object.properties)) {
|
|
31
|
+
// Skip relations for now (they're complex)
|
|
32
|
+
if (prop.type === 'Association' || prop.type === 'Polymorphic') {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
// Handle composite types - expand fields
|
|
36
|
+
if (prop.fields) {
|
|
37
|
+
const expandedFields = expandCompositeFields(prop);
|
|
38
|
+
for (const field of expandedFields) {
|
|
39
|
+
lines.push(` ${field.name}${field.optional}: ${field.type};${field.comment}`);
|
|
40
|
+
}
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
let propType;
|
|
44
|
+
if (prop.type === 'Enum' && prop.enum) {
|
|
45
|
+
propType = `${objectName}_${propName}`;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
propType = (0, typeMapper_1.mapOmnifyTypeToTypeScript)(prop.type, prop.nullable);
|
|
49
|
+
}
|
|
50
|
+
const optional = prop.nullable ? '?' : '';
|
|
51
|
+
const comment = prop.displayName ? ` // ${prop.displayName}` : '';
|
|
52
|
+
lines.push(` ${propName}${optional}: ${propType};${comment}`);
|
|
53
|
+
}
|
|
54
|
+
lines.push('}');
|
|
55
|
+
lines.push('');
|
|
56
|
+
return lines.join('\n');
|
|
57
|
+
}
|
|
58
|
+
function generateAllModels(schema) {
|
|
59
|
+
const lines = [];
|
|
60
|
+
lines.push('// Auto-generated by @omnifyjp/omnify');
|
|
61
|
+
lines.push('// Do not edit this file manually');
|
|
62
|
+
lines.push('');
|
|
63
|
+
lines.push('import * as Enums from \'./enums\';');
|
|
64
|
+
lines.push('');
|
|
65
|
+
// Generate models
|
|
66
|
+
for (const [objectName, object] of Object.entries(schema)) {
|
|
67
|
+
lines.push(`// ${object.displayName}`);
|
|
68
|
+
lines.push(`export interface ${objectName} {`);
|
|
69
|
+
// Track processed properties to avoid duplicates from composite fields
|
|
70
|
+
const processedProps = new Set();
|
|
71
|
+
// PHASE 1: Add foreign keys for ManyToOne associations first
|
|
72
|
+
for (const [propName, prop] of Object.entries(object.properties)) {
|
|
73
|
+
if (prop.type === 'Association' && prop.relation === 'ManyToOne') {
|
|
74
|
+
const foreignKeyName = prop.foreignKey || `${propName}_id`;
|
|
75
|
+
if (!processedProps.has(foreignKeyName)) {
|
|
76
|
+
const comment = ` // Foreign key for ${prop.displayName || propName}`;
|
|
77
|
+
lines.push(` ${foreignKeyName}?: number | null;${comment}`);
|
|
78
|
+
processedProps.add(foreignKeyName);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// PHASE 2: Add all other properties
|
|
83
|
+
for (const [propName, prop] of Object.entries(object.properties)) {
|
|
84
|
+
// Skip if already processed
|
|
85
|
+
if (processedProps.has(propName)) {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
// Handle Association types
|
|
89
|
+
if (prop.type === 'Association') {
|
|
90
|
+
const comment = prop.displayName ? ` // ${prop.displayName}` : '';
|
|
91
|
+
switch (prop.relation) {
|
|
92
|
+
case 'ManyToOne':
|
|
93
|
+
lines.push(` ${propName}?: ${prop.target} | null;${comment}`);
|
|
94
|
+
break;
|
|
95
|
+
case 'OneToOne':
|
|
96
|
+
lines.push(` ${propName}?: ${prop.target} | null;${comment}`);
|
|
97
|
+
break;
|
|
98
|
+
case 'OneToMany':
|
|
99
|
+
case 'ManyToMany':
|
|
100
|
+
lines.push(` ${propName}?: ${prop.target}[];${comment}`);
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
processedProps.add(propName);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
// Skip Polymorphic for now (too complex)
|
|
107
|
+
if (prop.type === 'Polymorphic') {
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
// Handle composite types - expand fields and mark them as processed
|
|
111
|
+
if (prop.fields) {
|
|
112
|
+
const expandedFields = expandCompositeFields(prop);
|
|
113
|
+
for (const field of expandedFields) {
|
|
114
|
+
if (!processedProps.has(field.name)) {
|
|
115
|
+
lines.push(` ${field.name}${field.optional}: ${field.type};${field.comment}`);
|
|
116
|
+
processedProps.add(field.name);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
let propType;
|
|
122
|
+
if (prop.type === 'Enum' && prop.enum) {
|
|
123
|
+
propType = `Enums.${objectName}_${propName}`;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
propType = (0, typeMapper_1.mapOmnifyTypeToTypeScript)(prop.type, prop.nullable);
|
|
127
|
+
}
|
|
128
|
+
const optional = prop.nullable ? '?' : '';
|
|
129
|
+
const comment = prop.displayName ? ` // ${prop.displayName}` : '';
|
|
130
|
+
lines.push(` ${propName}${optional}: ${propType};${comment}`);
|
|
131
|
+
processedProps.add(propName);
|
|
132
|
+
}
|
|
133
|
+
lines.push('}');
|
|
134
|
+
lines.push('');
|
|
135
|
+
}
|
|
136
|
+
return lines.join('\n');
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=modelGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelGenerator.js","sourceRoot":"","sources":["../../src/generators/modelGenerator.ts"],"names":[],"mappings":";;AAwBA,8CA2CC;AAED,8CA6FC;AAjKD,oDAAgE;AAEhE,SAAS,qBAAqB,CAAC,IAAS;IACtC,IAAI,CAAC,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IAE5B,MAAM,MAAM,GAAU,EAAE,CAAC;IAEzB,KAAK,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAA6B,CAAC,EAAE,CAAC;QACpF,MAAM,MAAM,GAAG,IAAA,sCAAyB,EAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;QACrE,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3C,MAAM,OAAO,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAEpE,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,KAAK,CAAC,YAAY;YACxB,IAAI,EAAE,MAAM;YACZ,QAAQ;YACR,OAAO;SACR,CAAC,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,iBAAiB,CAAC,UAAkB,EAAE,MAAoB;IACxE,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,KAAK,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;IACpD,KAAK,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;IAChD,KAAK,CAAC,I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C,CAAC;QAC/B,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAChB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./generators/enumGenerator"), exports);
|
|
19
|
+
__exportStar(require("./generators/modelGenerator"), exports);
|
|
20
|
+
__exportStar(require("./generators/contextGenerator"), exports);
|
|
21
|
+
__exportStar(require("./utils/typeMapper"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,6DAA2C;AAC3C,8DAA4C;AAC5C,gEAA8C;AAC9C,qDAAmC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface EnumValue {
|
|
2
|
+
value: string;
|
|
3
|
+
label: string;
|
|
4
|
+
}
|
|
5
|
+
export interface Property {
|
|
6
|
+
objectName: string;
|
|
7
|
+
propertyName: string;
|
|
8
|
+
displayName: string;
|
|
9
|
+
description: string | null;
|
|
10
|
+
type: string;
|
|
11
|
+
enum?: EnumValue[] | Record<string, EnumValue>;
|
|
12
|
+
nullable?: boolean;
|
|
13
|
+
primary?: boolean;
|
|
14
|
+
unique?: boolean;
|
|
15
|
+
length?: number | null;
|
|
16
|
+
default?: string;
|
|
17
|
+
relation?: string;
|
|
18
|
+
target?: string;
|
|
19
|
+
foreignKey?: string | null;
|
|
20
|
+
inversedBy?: string | null;
|
|
21
|
+
mappedBy?: string | null;
|
|
22
|
+
fields?: Record<string, any>;
|
|
23
|
+
morphName?: string | null;
|
|
24
|
+
}
|
|
25
|
+
export interface OmnifyObject {
|
|
26
|
+
objectName: string;
|
|
27
|
+
kind: string;
|
|
28
|
+
titleIndex: string;
|
|
29
|
+
groupName: string;
|
|
30
|
+
displayName: string;
|
|
31
|
+
singularName: string;
|
|
32
|
+
pluralName: string;
|
|
33
|
+
tableName: string;
|
|
34
|
+
description: string | null;
|
|
35
|
+
properties: Record<string, Property>;
|
|
36
|
+
}
|
|
37
|
+
export interface SchemaLock {
|
|
38
|
+
[key: string]: OmnifyObject;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
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AC;IAClB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,UAAU;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAAC;CAC7B"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeMapper.d.ts","sourceRoot":"","sources":["../../src/utils/typeMapper.ts"],"names":[],"mappings":"AAAA,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,CAmFxF;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,GAAG,GAAG,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAUzF"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapOmnifyTypeToTypeScript = mapOmnifyTypeToTypeScript;
|
|
4
|
+
exports.normalizeEnumArray = normalizeEnumArray;
|
|
5
|
+
function mapOmnifyTypeToTypeScript(omnifyType, nullable) {
|
|
6
|
+
let tsType;
|
|
7
|
+
switch (omnifyType) {
|
|
8
|
+
// Numeric types
|
|
9
|
+
case 'Id':
|
|
10
|
+
case 'Int':
|
|
11
|
+
case 'TinyInt':
|
|
12
|
+
case 'BigInt':
|
|
13
|
+
case 'Float':
|
|
14
|
+
tsType = 'number';
|
|
15
|
+
break;
|
|
16
|
+
// String types
|
|
17
|
+
case 'String':
|
|
18
|
+
case 'Text':
|
|
19
|
+
case 'LongText':
|
|
20
|
+
case 'Email':
|
|
21
|
+
case 'Password':
|
|
22
|
+
case 'JapanPhone':
|
|
23
|
+
case 'Color':
|
|
24
|
+
case 'Time':
|
|
25
|
+
tsType = 'string';
|
|
26
|
+
break;
|
|
27
|
+
// Boolean types
|
|
28
|
+
case 'Boolean':
|
|
29
|
+
tsType = 'boolean';
|
|
30
|
+
break;
|
|
31
|
+
// Date/Time types
|
|
32
|
+
case 'Date':
|
|
33
|
+
case 'Timestamp':
|
|
34
|
+
tsType = 'string'; // ISO string format
|
|
35
|
+
break;
|
|
36
|
+
// JSON/Object types
|
|
37
|
+
case 'Json':
|
|
38
|
+
tsType = 'Record<string, any>';
|
|
39
|
+
break;
|
|
40
|
+
// Enum types
|
|
41
|
+
case 'Enum':
|
|
42
|
+
tsType = 'string'; // Will be replaced with specific enum type
|
|
43
|
+
break;
|
|
44
|
+
// Relation types
|
|
45
|
+
case 'Association':
|
|
46
|
+
case 'Polymorphic':
|
|
47
|
+
case 'Lookup':
|
|
48
|
+
tsType = 'any'; // Relations are complex
|
|
49
|
+
break;
|
|
50
|
+
// Select types
|
|
51
|
+
case 'Select':
|
|
52
|
+
case 'SingleSelect':
|
|
53
|
+
case 'MultiSelect':
|
|
54
|
+
tsType = 'string';
|
|
55
|
+
break;
|
|
56
|
+
// File types
|
|
57
|
+
case 'File':
|
|
58
|
+
case 'MultiFile':
|
|
59
|
+
tsType = 'string'; // Usually file path or URL
|
|
60
|
+
break;
|
|
61
|
+
// Address type
|
|
62
|
+
case 'Address':
|
|
63
|
+
tsType = 'string';
|
|
64
|
+
break;
|
|
65
|
+
// Composite types (will be expanded)
|
|
66
|
+
case 'JapanAddress':
|
|
67
|
+
case 'JapanPersonName':
|
|
68
|
+
tsType = 'object'; // Complex types - should be expanded
|
|
69
|
+
break;
|
|
70
|
+
default:
|
|
71
|
+
console.warn(`Unknown Omnify type: ${omnifyType}, mapping to 'any'`);
|
|
72
|
+
tsType = 'any';
|
|
73
|
+
}
|
|
74
|
+
return nullable ? `${tsType} | null` : tsType;
|
|
75
|
+
}
|
|
76
|
+
function normalizeEnumArray(enumData) {
|
|
77
|
+
if (Array.isArray(enumData)) {
|
|
78
|
+
return enumData;
|
|
79
|
+
}
|
|
80
|
+
if (typeof enumData === 'object' && enumData !== null) {
|
|
81
|
+
return Object.values(enumData);
|
|
82
|
+
}
|
|
83
|
+
return [];
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=typeMapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeMapper.js","sourceRoot":"","sources":["../../src/utils/typeMapper.ts"],"names":[],"mappings":";;AAAA,8DAmFC;AAED,gDAUC;AA/FD,SAAgB,yBAAyB,CAAC,UAAkB,EAAE,QAAkB;IAC9E,IAAI,MAAc,CAAC;IAEnB,QAAQ,UAAU,EAAE,CAAC;QACnB,gBAAgB;QAChB,KAAK,IAAI,CAAC;QACV,KAAK,KAAK,CAAC;QACX,KAAK,SAAS,CAAC;QACf,KAAK,QAAQ,CAAC;QACd,KAAK,OAAO;YACV,MAAM,GAAG,QAAQ,CAAC;YAClB,MAAM;QAER,eAAe;QACf,KAAK,QAAQ,CAAC;QACd,KAAK,MAAM,CAAC;QACZ,KAAK,UAAU,CAAC;QAChB,KAAK,OAAO,CAAC;QACb,KAAK,UAAU,CAAC;QAChB,KAAK,YAAY,CAAC;QAClB,KAAK,OAAO,CAAC;QACb,KAAK,MAAM;YACT,MAAM,GAAG,QAAQ,CAAC;YAClB,MAAM;QAER,gBAAgB;QAChB,KAAK,SAAS;YACZ,MAAM,GAAG,SAAS,CAAC;YACnB,MAAM;QAER,kBAAkB;QAClB,KAAK,MAAM,CAAC;QACZ,KAAK,WAAW;YACd,MAAM,GAAG,QAAQ,CAAC,CAAC,oBAAoB;YACvC,MAAM;QAER,oBAAoB;QACpB,KAAK,MAAM;YACT,MAAM,GAAG,qBAAqB,CAAC;YAC/B,MAAM;QAER,aAAa;QACb,KAAK,MAAM;YACT,MAAM,GAAG,QAAQ,CAAC,CAAC,2CAA2C;YAC9D,MAAM;QAER,iBAAiB;QACjB,KAAK,aAAa,CAAC;QACnB,KAAK,aAAa,CAAC;QACnB,KAAK,QAAQ;YACX,MAAM,GAAG,KAAK,CAAC,CAAC,wBAAwB;YACxC,MAAM;QAER,eAAe;QACf,KAAK,QAAQ,CAAC;QACd,KAAK,cAAc,CAAC;QACpB,KAAK,aAAa;YAChB,MAAM,GAAG,QAAQ,CAAC;YAClB,MAAM;QAER,aAAa;QACb,KAAK,MAAM,CAAC;QACZ,KAAK,WAAW;YACd,MAAM,GAAG,QAAQ,CAAC,CAAC,2BAA2B;YAC9C,MAAM;QAER,eAAe;QACf,KAAK,SAAS;YACZ,MAAM,GAAG,QAAQ,CAAC;YAClB,MAAM;QAER,qCAAqC;QACrC,KAAK,cAAc,CAAC;QACpB,KAAK,iBAAiB;YACpB,MAAM,GAAG,QAAQ,CAAC,CAAC,qCAAqC;YACxD,MAAM;QAER;YACE,OAAO,CAAC,IAAI,CAAC,wBAAwB,UAAU,oBAAoB,CAAC,CAAC;YACrE,MAAM,GAAG,KAAK,CAAC;IACnB,CAAC;IAED,OAAO,QAAQ,CAAC,CAAC,CAAC,GAAG,MAAM,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC;AAChD,CAAC;AAED,SAAgB,kBAAkB,CAAC,QAAa;IAC9C,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtD,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@famgia/omnify",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Convert Omnify schema-lock.json to TypeScript models and enums",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"omnify-build": "./dist/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"prepublishOnly": "npm run build"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"omnify",
|
|
16
|
+
"typescript",
|
|
17
|
+
"generator",
|
|
18
|
+
"schema",
|
|
19
|
+
"codegen",
|
|
20
|
+
"laravel",
|
|
21
|
+
"type-generation"
|
|
22
|
+
],
|
|
23
|
+
"author": "Omnify JP",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/omnifyjp/omnify.git"
|
|
28
|
+
},
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/omnifyjp/omnify/issues"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/omnifyjp/omnify#readme",
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=16.0.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/node": "^20.0.0",
|
|
38
|
+
"typescript": "^5.0.0"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"chokidar": "^3.6.0"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"typescript": ">=5.0.0"
|
|
45
|
+
},
|
|
46
|
+
"files": [
|
|
47
|
+
"dist",
|
|
48
|
+
"README.md",
|
|
49
|
+
"CHANGELOG.md"
|
|
50
|
+
]
|
|
51
|
+
}
|