@omnifyjp/omnify 3.23.2 → 3.23.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 +6 -6
- package/ts-dist/zod-generator.js +15 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omnifyjp/omnify",
|
|
3
|
-
"version": "3.23.
|
|
3
|
+
"version": "3.23.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": "3.23.
|
|
40
|
-
"@omnifyjp/omnify-darwin-x64": "3.23.
|
|
41
|
-
"@omnifyjp/omnify-linux-x64": "3.23.
|
|
42
|
-
"@omnifyjp/omnify-linux-arm64": "3.23.
|
|
43
|
-
"@omnifyjp/omnify-win32-x64": "3.23.
|
|
39
|
+
"@omnifyjp/omnify-darwin-arm64": "3.23.4",
|
|
40
|
+
"@omnifyjp/omnify-darwin-x64": "3.23.4",
|
|
41
|
+
"@omnifyjp/omnify-linux-x64": "3.23.4",
|
|
42
|
+
"@omnifyjp/omnify-linux-arm64": "3.23.4",
|
|
43
|
+
"@omnifyjp/omnify-win32-x64": "3.23.4"
|
|
44
44
|
}
|
|
45
45
|
}
|
package/ts-dist/zod-generator.js
CHANGED
|
@@ -566,18 +566,27 @@ export function formatZodSchemasSection(schemaName, zodSchemas, displayNames, ex
|
|
|
566
566
|
parts.push(`export function get${schemaName}Label(locale: string): string {\n`);
|
|
567
567
|
parts.push(` return ${lowerName}I18n.label[locale as keyof typeof ${lowerName}I18n.label] ?? ${lowerName}I18n.label['en'] ?? '${schemaName}';\n`);
|
|
568
568
|
parts.push(`}\n\n`);
|
|
569
|
+
// #83 (v3.23.4): cast the fields lookup through a structural index type
|
|
570
|
+
// so the helpers type-check even when the schema has zero properties.
|
|
571
|
+
// Without the cast, `keyof typeof i18n.fields` is `never` for an empty
|
|
572
|
+
// fields object and every downstream `.label` / `.placeholder` access
|
|
573
|
+
// produces `error TS2339: Property 'label' does not exist on type 'never'`.
|
|
574
|
+
// Hits every kind:extend schema with no project-owned properties (Branch,
|
|
575
|
+
// Organization, Role, User in the godx-tempo SSO set).
|
|
576
|
+
const fieldRecordType = `Record<string, { label: Record<string, string>; placeholder?: Record<string, string> }>`;
|
|
569
577
|
parts.push(`/** Get field label for a specific locale */\n`);
|
|
570
578
|
parts.push(`export function get${schemaName}FieldLabel(field: string, locale: string): string {\n`);
|
|
571
|
-
parts.push(` const
|
|
579
|
+
parts.push(` const fields = ${lowerName}I18n.fields as ${fieldRecordType};\n`);
|
|
580
|
+
parts.push(` const fieldI18n = fields[field];\n`);
|
|
572
581
|
parts.push(` if (!fieldI18n) return field;\n`);
|
|
573
|
-
parts.push(` return fieldI18n.label[locale
|
|
582
|
+
parts.push(` return fieldI18n.label[locale] ?? fieldI18n.label['en'] ?? field;\n`);
|
|
574
583
|
parts.push(`}\n\n`);
|
|
575
584
|
parts.push(`/** Get field placeholder for a specific locale */\n`);
|
|
576
585
|
parts.push(`export function get${schemaName}FieldPlaceholder(field: string, locale: string): string {\n`);
|
|
577
|
-
parts.push(` const
|
|
578
|
-
parts.push(`
|
|
579
|
-
parts.push(`
|
|
580
|
-
parts.push(` return placeholder[locale] ?? placeholder['en'] ?? '';\n`);
|
|
586
|
+
parts.push(` const fields = ${lowerName}I18n.fields as ${fieldRecordType};\n`);
|
|
587
|
+
parts.push(` const fieldI18n = fields[field];\n`);
|
|
588
|
+
parts.push(` if (!fieldI18n?.placeholder) return '';\n`);
|
|
589
|
+
parts.push(` return fieldI18n.placeholder[locale] ?? fieldI18n.placeholder['en'] ?? '';\n`);
|
|
581
590
|
parts.push(`}\n`);
|
|
582
591
|
return parts.join('');
|
|
583
592
|
}
|