@omnifyjp/omnify 3.12.3 → 3.12.5
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/package.json +6 -6
- package/ts-dist/enum-generator.js +20 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omnifyjp/omnify",
|
|
3
|
-
"version": "3.12.
|
|
3
|
+
"version": "3.12.5",
|
|
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": "3.12.
|
|
40
|
-
"@omnifyjp/omnify-darwin-x64": "3.12.
|
|
41
|
-
"@omnifyjp/omnify-linux-x64": "3.12.
|
|
42
|
-
"@omnifyjp/omnify-linux-arm64": "3.12.
|
|
43
|
-
"@omnifyjp/omnify-win32-x64": "3.12.
|
|
39
|
+
"@omnifyjp/omnify-darwin-arm64": "3.12.5",
|
|
40
|
+
"@omnifyjp/omnify-darwin-x64": "3.12.5",
|
|
41
|
+
"@omnifyjp/omnify-linux-x64": "3.12.5",
|
|
42
|
+
"@omnifyjp/omnify-linux-arm64": "3.12.5",
|
|
43
|
+
"@omnifyjp/omnify-win32-x64": "3.12.5"
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -208,12 +208,32 @@ export function formatTypeAlias(alias) {
|
|
|
208
208
|
/** Extract inline enums from Enum/Select properties. */
|
|
209
209
|
export function extractInlineEnums(schemas, options) {
|
|
210
210
|
const results = [];
|
|
211
|
+
// Pre-compute the set of real `kind: enum` schema names so we can skip
|
|
212
|
+
// inline enums whose generated name (`{Schema}{Property}`) would collide.
|
|
213
|
+
// This happens when a project has e.g. both `kind: enum MenuStatus` and
|
|
214
|
+
// a `Menu.status: { type: Enum, enum: [...] }` inline declaration — the
|
|
215
|
+
// generator used to emit BOTH into index.ts, producing duplicate
|
|
216
|
+
// exports. The real enum schema is canonical; the inline duplicate is
|
|
217
|
+
// skipped so the user can clean it up by switching the property to
|
|
218
|
+
// `type: EnumRef, enum: MenuStatus`.
|
|
219
|
+
const realEnumNames = new Set();
|
|
220
|
+
for (const s of Object.values(schemas)) {
|
|
221
|
+
if (s.kind === 'enum')
|
|
222
|
+
realEnumNames.add(s.name);
|
|
223
|
+
}
|
|
211
224
|
for (const schema of Object.values(schemas)) {
|
|
212
225
|
if (schema.kind === 'enum' || !schema.properties)
|
|
213
226
|
continue;
|
|
214
227
|
for (const [propName, property] of Object.entries(schema.properties)) {
|
|
215
228
|
if (property.type === 'Enum' && Array.isArray(property.enum) && property.enum.length > 0) {
|
|
216
229
|
const typeName = `${schema.name}${toPascalCase(propName)}`;
|
|
230
|
+
if (realEnumNames.has(typeName)) {
|
|
231
|
+
// eslint-disable-next-line no-console
|
|
232
|
+
console.warn(`[omnify-ts] Skipping inline enum ${schema.name}.${propName} — ` +
|
|
233
|
+
`its generated name "${typeName}" collides with the real enum schema "${typeName}". ` +
|
|
234
|
+
`Consider switching the property to \`type: EnumRef, enum: ${typeName}\` to remove the duplication.`);
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
217
237
|
const displayName = resolveString(schema.displayName, options);
|
|
218
238
|
// Check if values have labels (i.e., are objects not strings)
|
|
219
239
|
const enumValues = property.enum;
|