@omnifyjp/omnify 5.9.1 → 5.9.2
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omnifyjp/omnify",
|
|
3
|
-
"version": "5.9.
|
|
3
|
+
"version": "5.9.2",
|
|
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": "5.9.
|
|
40
|
-
"@omnifyjp/omnify-darwin-x64": "5.9.
|
|
41
|
-
"@omnifyjp/omnify-linux-x64": "5.9.
|
|
42
|
-
"@omnifyjp/omnify-linux-arm64": "5.9.
|
|
43
|
-
"@omnifyjp/omnify-win32-x64": "5.9.
|
|
39
|
+
"@omnifyjp/omnify-darwin-arm64": "5.9.2",
|
|
40
|
+
"@omnifyjp/omnify-darwin-x64": "5.9.2",
|
|
41
|
+
"@omnifyjp/omnify-linux-x64": "5.9.2",
|
|
42
|
+
"@omnifyjp/omnify-linux-arm64": "5.9.2",
|
|
43
|
+
"@omnifyjp/omnify-win32-x64": "5.9.2"
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -115,7 +115,7 @@ function generateBaseModel(name, schema, reader, config) {
|
|
|
115
115
|
// the generated base model.
|
|
116
116
|
const hasAuditLog = reader.isAuditLogEnabled(name);
|
|
117
117
|
const imports = buildImports(baseNamespace, modelName, hasSoftDelete, isAuthenticatable, hasTranslatable, properties, needsUuidTrait, needsUlidTrait, hasNestedSet, config.nestedset.namespace, hasFiles, modelNamespace, localesNamespace, traitsNamespace, sharedModelsNamespace, config, hasAuditLog);
|
|
118
|
-
const docProperties = buildDocProperties(properties, expandedProperties, propertyOrder);
|
|
118
|
+
const docProperties = buildDocProperties(properties, expandedProperties, propertyOrder, reader, config);
|
|
119
119
|
const baseClass = isAuthenticatable ? 'Authenticatable' : 'BaseModel';
|
|
120
120
|
const implementsClause = hasTranslatable ? ' implements TranslatableContract' : '';
|
|
121
121
|
const traits = buildTraits(hasSoftDelete, isAuthenticatable, hasTranslatable, needsUuidTrait, needsUlidTrait, hasNestedSet, hasFiles, hasAuditLog);
|
|
@@ -409,8 +409,14 @@ function buildImports(baseNamespace, modelName, hasSoftDelete, isAuthenticatable
|
|
|
409
409
|
}
|
|
410
410
|
return lines.join('\n') + '\n';
|
|
411
411
|
}
|
|
412
|
-
function buildDocProperties(properties, expandedProperties, propertyOrder) {
|
|
412
|
+
function buildDocProperties(properties, expandedProperties, propertyOrder, reader, config) {
|
|
413
413
|
const lines = [];
|
|
414
|
+
// Mirror buildCasts: EnumRef columns are cast to their generated enum class,
|
|
415
|
+
// so document them with that class (not `string`) — otherwise static analysis
|
|
416
|
+
// sees a string and rejects `$model->col->value` / enum comparisons.
|
|
417
|
+
const globalEnumNs = config
|
|
418
|
+
? resolveGlobalEnumNamespace(config, config.models.namespace)
|
|
419
|
+
: '';
|
|
414
420
|
for (const propName of propertyOrder) {
|
|
415
421
|
const prop = properties[propName];
|
|
416
422
|
if (!prop)
|
|
@@ -445,6 +451,16 @@ function buildDocProperties(properties, expandedProperties, propertyOrder) {
|
|
|
445
451
|
}
|
|
446
452
|
const nullable = prop['nullable'] ?? false;
|
|
447
453
|
const snakeName = toSnakeCase(propName);
|
|
454
|
+
// EnumRef → document the generated enum class (fully-qualified, matching the
|
|
455
|
+
// cast) only when the referenced enum schema exists; else fall through.
|
|
456
|
+
if (type === 'EnumRef') {
|
|
457
|
+
const enumName = prop['enum'];
|
|
458
|
+
if (typeof enumName === 'string' && reader.getSchema(enumName)?.kind === 'enum' && globalEnumNs) {
|
|
459
|
+
const enumType = `\\${globalEnumNs}\\${enumClassName(enumName)}`;
|
|
460
|
+
lines.push(` * @property ${nullable ? `${enumType}|null` : enumType} $${snakeName}`);
|
|
461
|
+
continue;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
448
464
|
const phpDocType = toPhpDocType(type, nullable);
|
|
449
465
|
lines.push(` * @property ${phpDocType} $${snakeName}`);
|
|
450
466
|
}
|