@omnifyjp/omnify 1.3.2 → 1.3.4
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": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
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": "1.3.
|
|
40
|
-
"@omnifyjp/omnify-darwin-x64": "1.3.
|
|
41
|
-
"@omnifyjp/omnify-linux-x64": "1.3.
|
|
42
|
-
"@omnifyjp/omnify-linux-arm64": "1.3.
|
|
43
|
-
"@omnifyjp/omnify-win32-x64": "1.3.
|
|
39
|
+
"@omnifyjp/omnify-darwin-arm64": "1.3.4",
|
|
40
|
+
"@omnifyjp/omnify-darwin-x64": "1.3.4",
|
|
41
|
+
"@omnifyjp/omnify-linux-x64": "1.3.4",
|
|
42
|
+
"@omnifyjp/omnify-linux-arm64": "1.3.4",
|
|
43
|
+
"@omnifyjp/omnify-win32-x64": "1.3.4"
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -62,7 +62,7 @@ function generateBaseModel(name, schema, reader, config) {
|
|
|
62
62
|
const fillable = buildFillable(properties, expandedProperties, propertyOrder);
|
|
63
63
|
const hidden = buildHidden(properties, expandedProperties, propertyOrder);
|
|
64
64
|
const appends = buildAppends(expandedProperties);
|
|
65
|
-
const casts = buildCasts(properties, expandedProperties, propertyOrder);
|
|
65
|
+
const casts = buildCasts(properties, expandedProperties, propertyOrder, reader);
|
|
66
66
|
const relations = buildRelations(name, properties, propertyOrder, modelNamespace, reader);
|
|
67
67
|
const accessors = buildAccessors(expandedProperties);
|
|
68
68
|
const nestedSetMethod = buildNestedSetParentIdMethod(nestedSetParentColumn);
|
|
@@ -384,15 +384,28 @@ function buildAppends(expandedProperties) {
|
|
|
384
384
|
return '';
|
|
385
385
|
return appends.map(a => ` '${a}',`).join('\n') + '\n';
|
|
386
386
|
}
|
|
387
|
-
function buildCasts(properties, expandedProperties, propertyOrder) {
|
|
387
|
+
function buildCasts(properties, expandedProperties, propertyOrder, reader) {
|
|
388
388
|
const casts = [];
|
|
389
389
|
for (const propName of propertyOrder) {
|
|
390
390
|
const prop = properties[propName];
|
|
391
391
|
if (!prop)
|
|
392
392
|
continue;
|
|
393
393
|
const type = prop['type'] ?? 'String';
|
|
394
|
-
if (type === 'Association')
|
|
394
|
+
if (type === 'Association') {
|
|
395
|
+
const relation = prop['relation'] ?? '';
|
|
396
|
+
if (relation === 'ManyToOne') {
|
|
397
|
+
const target = prop['target'] ?? '';
|
|
398
|
+
const targetSchema = reader.getSchema(target);
|
|
399
|
+
const targetIdType = typeof targetSchema?.options?.id === 'string'
|
|
400
|
+
? targetSchema.options.id
|
|
401
|
+
: 'BigInt';
|
|
402
|
+
if (targetIdType !== 'Uuid' && targetIdType !== 'Ulid') {
|
|
403
|
+
const snakeName = toSnakeCase(propName);
|
|
404
|
+
casts.push(`'${snakeName}_id' => 'integer',`);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
395
407
|
continue;
|
|
408
|
+
}
|
|
396
409
|
if (expandedProperties[propName]) {
|
|
397
410
|
for (const col of expandedProperties[propName].columns ?? []) {
|
|
398
411
|
const colType = col.type ?? 'String';
|