@famgia/omnify-laravel 2.0.19 → 2.0.21

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": "@famgia/omnify-laravel",
3
- "version": "2.0.19",
3
+ "version": "2.0.21",
4
4
  "description": "Laravel migration and TypeScript type generator for omnify-schema",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -33,9 +33,9 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "pluralize": "^8.0.0",
36
- "@famgia/omnify-atlas": "2.0.19",
37
- "@famgia/omnify-core": "2.0.19",
38
- "@famgia/omnify-types": "2.0.19"
36
+ "@famgia/omnify-atlas": "2.0.21",
37
+ "@famgia/omnify-core": "2.0.21",
38
+ "@famgia/omnify-types": "2.0.21"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/pluralize": "^0.0.33"
@@ -99,47 +99,50 @@ Use cases:
99
99
 
100
100
  ```yaml
101
101
  # schemas/PostStatus.yaml
102
- name: PostStatus
103
102
  kind: enum
104
103
  displayName:
105
104
  ja: 投稿ステータス
106
105
  en: Post Status
107
106
  values:
108
- draft:
109
- ja: 下書き
110
- en: Draft
111
- published:
112
- ja: 公開済み
113
- en: Published
114
- archived:
115
- ja: アーカイブ
116
- en: Archived
107
+ - value: draft
108
+ label:
109
+ ja: 下書き
110
+ en: Draft
111
+ - value: published
112
+ label:
113
+ ja: 公開済み
114
+ en: Published
115
+ - value: archived
116
+ label:
117
+ ja: アーカイブ
118
+ en: Archived
117
119
  ```
118
120
 
119
121
  Generated:
120
122
  ```typescript
121
- export const PostStatus = {
122
- draft: 'draft',
123
- published: 'published',
124
- archived: 'archived',
125
- } as const;
126
-
127
- export type PostStatus = typeof PostStatus[keyof typeof PostStatus];
128
-
129
- // Multi-locale labels
130
- export const PostStatusLabels: Record<PostStatus, Record<string, string>> = {
131
- draft: { ja: '下書き', en: 'Draft' },
132
- published: { ja: '公開済み', en: 'Published' },
133
- archived: { ja: 'アーカイブ', en: 'Archived' },
123
+ export enum PostStatus {
124
+ Draft = 'draft',
125
+ Published = 'published',
126
+ Archived = 'archived',
127
+ }
128
+
129
+ // Multi-locale labels (when locale config has multiple locales)
130
+ const postStatusLabels: Partial<Record<PostStatus, Record<string, string>>> = {
131
+ [PostStatus.Draft]: { 'ja': '下書き', 'en': 'Draft' },
132
+ [PostStatus.Published]: { 'ja': '公開済み', 'en': 'Published' },
133
+ [PostStatus.Archived]: { 'ja': 'アーカイブ', 'en': 'Archived' },
134
134
  };
135
135
 
136
- // Get label for specific locale
137
- export function getPostStatusLabel(value: PostStatus, locale: string = 'en'): string {
138
- return PostStatusLabels[value]?.[locale] ?? PostStatusLabels[value]?.['en'] ?? value;
136
+ // Get label for specific locale (fallback: ja → en → value)
137
+ export function getPostStatusLabel(value: PostStatus, locale?: string): string {
138
+ const labels = postStatusLabels[value];
139
+ if (!labels) return value;
140
+ if (locale && labels[locale]) return labels[locale];
141
+ return labels['ja'] ?? labels['en'] ?? Object.values(labels)[0] ?? value;
139
142
  }
140
143
 
141
144
  // Helper functions
142
- export const PostStatusValues = Object.values(PostStatus);
145
+ export const PostStatusValues = Object.values(PostStatus) as PostStatus[];
143
146
  export function isPostStatus(value: unknown): value is PostStatus {
144
147
  return PostStatusValues.includes(value as PostStatus);
145
148
  }