@famgia/omnify-react-sso 2.2.0 → 2.2.1
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/dist/@omnify-base/package.json +16 -0
- package/dist/@omnify-base/schemas/Branch.ts +131 -0
- package/dist/@omnify-base/schemas/Permission.ts +114 -0
- package/dist/@omnify-base/schemas/Role.ts +121 -0
- package/dist/@omnify-base/schemas/RolePermission.ts +97 -0
- package/dist/@omnify-base/schemas/Team.ts +110 -0
- package/dist/@omnify-base/schemas/TeamPermission.ts +109 -0
- package/dist/@omnify-base/schemas/User.ts +135 -0
- package/dist/@omnify-base/schemas/common.ts +47 -0
- package/dist/@omnify-base/schemas/i18n.ts +118 -0
- package/package.json +8 -3
- package/scripts/postinstall.cjs +43 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@omnify-base",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
"./enum/*": {
|
|
8
|
+
"types": "./enum/*.ts",
|
|
9
|
+
"default": "./enum/*.ts"
|
|
10
|
+
},
|
|
11
|
+
"./schemas/*": {
|
|
12
|
+
"types": "./schemas/*.ts",
|
|
13
|
+
"default": "./schemas/*.ts"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ⚠️ DO NOT EDIT THIS FILE! ⚠️
|
|
3
|
+
* このファイルを編集しないでください!
|
|
4
|
+
* KHÔNG ĐƯỢC SỬA FILE NÀY!
|
|
5
|
+
*
|
|
6
|
+
* Auto-generated TypeScript types from Omnify schemas.
|
|
7
|
+
* Any manual changes will be OVERWRITTEN on next generation.
|
|
8
|
+
*
|
|
9
|
+
* To modify: Edit the schema YAML file and run: npx omnify generate
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
import type { DateTimeString } from './common';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Branch
|
|
17
|
+
*/
|
|
18
|
+
export interface Branch {
|
|
19
|
+
/** Primary key */
|
|
20
|
+
id: string;
|
|
21
|
+
/** Console Branch ID */
|
|
22
|
+
console_branch_id: unknown;
|
|
23
|
+
/** Console Organization ID */
|
|
24
|
+
console_org_id: unknown;
|
|
25
|
+
/** Branch Code */
|
|
26
|
+
code: string;
|
|
27
|
+
/** Branch Name */
|
|
28
|
+
name: string;
|
|
29
|
+
/** Is Headquarters */
|
|
30
|
+
is_headquarters: boolean;
|
|
31
|
+
/** Active */
|
|
32
|
+
is_active: boolean;
|
|
33
|
+
/** Creation timestamp */
|
|
34
|
+
created_at?: DateTimeString;
|
|
35
|
+
/** Last update timestamp */
|
|
36
|
+
updated_at?: DateTimeString;
|
|
37
|
+
/** Soft delete timestamp */
|
|
38
|
+
deleted_at?: DateTimeString;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// ============================================================================
|
|
42
|
+
// I18n (Internationalization)
|
|
43
|
+
// ============================================================================
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Unified i18n object for Branch
|
|
47
|
+
* Contains model label and all field labels/placeholders
|
|
48
|
+
*/
|
|
49
|
+
export const branchI18n = {
|
|
50
|
+
/** Model display name */
|
|
51
|
+
label: {"en":"Branch"},
|
|
52
|
+
/** Field labels and placeholders */
|
|
53
|
+
fields: {
|
|
54
|
+
console_branch_id: {
|
|
55
|
+
label: {"en":"Console Branch ID"},
|
|
56
|
+
},
|
|
57
|
+
console_org_id: {
|
|
58
|
+
label: {"en":"Console Organization ID"},
|
|
59
|
+
},
|
|
60
|
+
code: {
|
|
61
|
+
label: {"en":"Branch Code"},
|
|
62
|
+
},
|
|
63
|
+
name: {
|
|
64
|
+
label: {"en":"Branch Name"},
|
|
65
|
+
},
|
|
66
|
+
is_headquarters: {
|
|
67
|
+
label: {"en":"Is Headquarters"},
|
|
68
|
+
},
|
|
69
|
+
is_active: {
|
|
70
|
+
label: {"en":"Active"},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
} as const;
|
|
74
|
+
|
|
75
|
+
// ============================================================================
|
|
76
|
+
// Zod Schemas
|
|
77
|
+
// ============================================================================
|
|
78
|
+
|
|
79
|
+
/** Field schemas for Branch */
|
|
80
|
+
export const baseBranchSchemas = {
|
|
81
|
+
console_branch_id: z.string(),
|
|
82
|
+
console_org_id: z.string(),
|
|
83
|
+
code: z.string().min(1).max(20),
|
|
84
|
+
name: z.string().min(1).max(100),
|
|
85
|
+
is_headquarters: z.boolean(),
|
|
86
|
+
is_active: z.boolean(),
|
|
87
|
+
} as const;
|
|
88
|
+
|
|
89
|
+
/** Create schema for Branch (POST requests) */
|
|
90
|
+
export const baseBranchCreateSchema = z.object({
|
|
91
|
+
console_branch_id: baseBranchSchemas.console_branch_id,
|
|
92
|
+
console_org_id: baseBranchSchemas.console_org_id,
|
|
93
|
+
code: baseBranchSchemas.code,
|
|
94
|
+
name: baseBranchSchemas.name,
|
|
95
|
+
is_headquarters: baseBranchSchemas.is_headquarters,
|
|
96
|
+
is_active: baseBranchSchemas.is_active,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
/** Update schema for Branch (PUT/PATCH requests) */
|
|
100
|
+
export const baseBranchUpdateSchema = baseBranchCreateSchema.partial();
|
|
101
|
+
|
|
102
|
+
// ============================================================================
|
|
103
|
+
// Inferred Types
|
|
104
|
+
// ============================================================================
|
|
105
|
+
|
|
106
|
+
export type BaseBranchCreate = z.infer<typeof baseBranchCreateSchema>;
|
|
107
|
+
export type BaseBranchUpdate = z.infer<typeof baseBranchUpdateSchema>;
|
|
108
|
+
|
|
109
|
+
// ============================================================================
|
|
110
|
+
// I18n Helper Functions
|
|
111
|
+
// ============================================================================
|
|
112
|
+
|
|
113
|
+
/** Get model label for a specific locale */
|
|
114
|
+
export function getBranchLabel(locale: string): string {
|
|
115
|
+
return branchI18n.label[locale as keyof typeof branchI18n.label] ?? branchI18n.label['en'] ?? 'Branch';
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Get field label for a specific locale */
|
|
119
|
+
export function getBranchFieldLabel(field: string, locale: string): string {
|
|
120
|
+
const fieldI18n = branchI18n.fields[field as keyof typeof branchI18n.fields];
|
|
121
|
+
if (!fieldI18n) return field;
|
|
122
|
+
return fieldI18n.label[locale as keyof typeof fieldI18n.label] ?? fieldI18n.label['en'] ?? field;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Get field placeholder for a specific locale */
|
|
126
|
+
export function getBranchFieldPlaceholder(field: string, locale: string): string {
|
|
127
|
+
const fieldI18n = branchI18n.fields[field as keyof typeof branchI18n.fields];
|
|
128
|
+
if (!fieldI18n || !('placeholder' in fieldI18n)) return '';
|
|
129
|
+
const placeholder = fieldI18n.placeholder as Record<string, string>;
|
|
130
|
+
return placeholder[locale] ?? placeholder['en'] ?? '';
|
|
131
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ⚠️ DO NOT EDIT THIS FILE! ⚠️
|
|
3
|
+
* このファイルを編集しないでください!
|
|
4
|
+
* KHÔNG ĐƯỢC SỬA FILE NÀY!
|
|
5
|
+
*
|
|
6
|
+
* Auto-generated TypeScript types from Omnify schemas.
|
|
7
|
+
* Any manual changes will be OVERWRITTEN on next generation.
|
|
8
|
+
*
|
|
9
|
+
* To modify: Edit the schema YAML file and run: npx omnify generate
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
import type { DateTimeString } from './common';
|
|
14
|
+
import type { Role } from './Role';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Permission
|
|
18
|
+
*/
|
|
19
|
+
export interface Permission {
|
|
20
|
+
/** Primary key */
|
|
21
|
+
id: string;
|
|
22
|
+
/** Permission Name */
|
|
23
|
+
name: string;
|
|
24
|
+
/** Slug */
|
|
25
|
+
slug: string;
|
|
26
|
+
/** Group */
|
|
27
|
+
group?: string;
|
|
28
|
+
/** Roles */
|
|
29
|
+
roles: Role[];
|
|
30
|
+
/** Creation timestamp */
|
|
31
|
+
created_at?: DateTimeString;
|
|
32
|
+
/** Last update timestamp */
|
|
33
|
+
updated_at?: DateTimeString;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// ============================================================================
|
|
37
|
+
// I18n (Internationalization)
|
|
38
|
+
// ============================================================================
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Unified i18n object for Permission
|
|
42
|
+
* Contains model label and all field labels/placeholders
|
|
43
|
+
*/
|
|
44
|
+
export const permissionI18n = {
|
|
45
|
+
/** Model display name */
|
|
46
|
+
label: {"en":"Permission"},
|
|
47
|
+
/** Field labels and placeholders */
|
|
48
|
+
fields: {
|
|
49
|
+
name: {
|
|
50
|
+
label: {"en":"Permission Name"},
|
|
51
|
+
},
|
|
52
|
+
slug: {
|
|
53
|
+
label: {"en":"Slug"},
|
|
54
|
+
},
|
|
55
|
+
group: {
|
|
56
|
+
label: {"en":"Group"},
|
|
57
|
+
},
|
|
58
|
+
roles: {
|
|
59
|
+
label: {"en":"Roles"},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
} as const;
|
|
63
|
+
|
|
64
|
+
// ============================================================================
|
|
65
|
+
// Zod Schemas
|
|
66
|
+
// ============================================================================
|
|
67
|
+
|
|
68
|
+
/** Field schemas for Permission */
|
|
69
|
+
export const basePermissionSchemas = {
|
|
70
|
+
name: z.string().min(1).max(100),
|
|
71
|
+
slug: z.string().min(1).max(100),
|
|
72
|
+
group: z.string().max(50).optional().nullable(),
|
|
73
|
+
} as const;
|
|
74
|
+
|
|
75
|
+
/** Create schema for Permission (POST requests) */
|
|
76
|
+
export const basePermissionCreateSchema = z.object({
|
|
77
|
+
name: basePermissionSchemas.name,
|
|
78
|
+
slug: basePermissionSchemas.slug,
|
|
79
|
+
group: basePermissionSchemas.group,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
/** Update schema for Permission (PUT/PATCH requests) */
|
|
83
|
+
export const basePermissionUpdateSchema = basePermissionCreateSchema.partial();
|
|
84
|
+
|
|
85
|
+
// ============================================================================
|
|
86
|
+
// Inferred Types
|
|
87
|
+
// ============================================================================
|
|
88
|
+
|
|
89
|
+
export type BasePermissionCreate = z.infer<typeof basePermissionCreateSchema>;
|
|
90
|
+
export type BasePermissionUpdate = z.infer<typeof basePermissionUpdateSchema>;
|
|
91
|
+
|
|
92
|
+
// ============================================================================
|
|
93
|
+
// I18n Helper Functions
|
|
94
|
+
// ============================================================================
|
|
95
|
+
|
|
96
|
+
/** Get model label for a specific locale */
|
|
97
|
+
export function getPermissionLabel(locale: string): string {
|
|
98
|
+
return permissionI18n.label[locale as keyof typeof permissionI18n.label] ?? permissionI18n.label['en'] ?? 'Permission';
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Get field label for a specific locale */
|
|
102
|
+
export function getPermissionFieldLabel(field: string, locale: string): string {
|
|
103
|
+
const fieldI18n = permissionI18n.fields[field as keyof typeof permissionI18n.fields];
|
|
104
|
+
if (!fieldI18n) return field;
|
|
105
|
+
return fieldI18n.label[locale as keyof typeof fieldI18n.label] ?? fieldI18n.label['en'] ?? field;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** Get field placeholder for a specific locale */
|
|
109
|
+
export function getPermissionFieldPlaceholder(field: string, locale: string): string {
|
|
110
|
+
const fieldI18n = permissionI18n.fields[field as keyof typeof permissionI18n.fields];
|
|
111
|
+
if (!fieldI18n || !('placeholder' in fieldI18n)) return '';
|
|
112
|
+
const placeholder = fieldI18n.placeholder as Record<string, string>;
|
|
113
|
+
return placeholder[locale] ?? placeholder['en'] ?? '';
|
|
114
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ⚠️ DO NOT EDIT THIS FILE! ⚠️
|
|
3
|
+
* このファイルを編集しないでください!
|
|
4
|
+
* KHÔNG ĐƯỢC SỬA FILE NÀY!
|
|
5
|
+
*
|
|
6
|
+
* Auto-generated TypeScript types from Omnify schemas.
|
|
7
|
+
* Any manual changes will be OVERWRITTEN on next generation.
|
|
8
|
+
*
|
|
9
|
+
* To modify: Edit the schema YAML file and run: npx omnify generate
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
import type { DateTimeString } from './common';
|
|
14
|
+
import type { Permission } from './Permission';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Role
|
|
18
|
+
*/
|
|
19
|
+
export interface Role {
|
|
20
|
+
/** Primary key */
|
|
21
|
+
id: string;
|
|
22
|
+
/** Role Name */
|
|
23
|
+
name: string;
|
|
24
|
+
/** Slug */
|
|
25
|
+
slug: string;
|
|
26
|
+
/** Description */
|
|
27
|
+
description?: string;
|
|
28
|
+
/** Level */
|
|
29
|
+
level: number;
|
|
30
|
+
/** Permissions */
|
|
31
|
+
permissions: Permission[];
|
|
32
|
+
/** Creation timestamp */
|
|
33
|
+
created_at?: DateTimeString;
|
|
34
|
+
/** Last update timestamp */
|
|
35
|
+
updated_at?: DateTimeString;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// ============================================================================
|
|
39
|
+
// I18n (Internationalization)
|
|
40
|
+
// ============================================================================
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Unified i18n object for Role
|
|
44
|
+
* Contains model label and all field labels/placeholders
|
|
45
|
+
*/
|
|
46
|
+
export const roleI18n = {
|
|
47
|
+
/** Model display name */
|
|
48
|
+
label: {"en":"Role"},
|
|
49
|
+
/** Field labels and placeholders */
|
|
50
|
+
fields: {
|
|
51
|
+
name: {
|
|
52
|
+
label: {"en":"Role Name"},
|
|
53
|
+
},
|
|
54
|
+
slug: {
|
|
55
|
+
label: {"en":"Slug"},
|
|
56
|
+
},
|
|
57
|
+
description: {
|
|
58
|
+
label: {"en":"Description"},
|
|
59
|
+
},
|
|
60
|
+
level: {
|
|
61
|
+
label: {"en":"Level"},
|
|
62
|
+
},
|
|
63
|
+
permissions: {
|
|
64
|
+
label: {"en":"Permissions"},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
} as const;
|
|
68
|
+
|
|
69
|
+
// ============================================================================
|
|
70
|
+
// Zod Schemas
|
|
71
|
+
// ============================================================================
|
|
72
|
+
|
|
73
|
+
/** Field schemas for Role */
|
|
74
|
+
export const baseRoleSchemas = {
|
|
75
|
+
name: z.string().min(1).max(100),
|
|
76
|
+
slug: z.string().min(1).max(100),
|
|
77
|
+
description: z.string().optional().nullable(),
|
|
78
|
+
level: z.number().int(),
|
|
79
|
+
} as const;
|
|
80
|
+
|
|
81
|
+
/** Create schema for Role (POST requests) */
|
|
82
|
+
export const baseRoleCreateSchema = z.object({
|
|
83
|
+
name: baseRoleSchemas.name,
|
|
84
|
+
slug: baseRoleSchemas.slug,
|
|
85
|
+
description: baseRoleSchemas.description,
|
|
86
|
+
level: baseRoleSchemas.level,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
/** Update schema for Role (PUT/PATCH requests) */
|
|
90
|
+
export const baseRoleUpdateSchema = baseRoleCreateSchema.partial();
|
|
91
|
+
|
|
92
|
+
// ============================================================================
|
|
93
|
+
// Inferred Types
|
|
94
|
+
// ============================================================================
|
|
95
|
+
|
|
96
|
+
export type BaseRoleCreate = z.infer<typeof baseRoleCreateSchema>;
|
|
97
|
+
export type BaseRoleUpdate = z.infer<typeof baseRoleUpdateSchema>;
|
|
98
|
+
|
|
99
|
+
// ============================================================================
|
|
100
|
+
// I18n Helper Functions
|
|
101
|
+
// ============================================================================
|
|
102
|
+
|
|
103
|
+
/** Get model label for a specific locale */
|
|
104
|
+
export function getRoleLabel(locale: string): string {
|
|
105
|
+
return roleI18n.label[locale as keyof typeof roleI18n.label] ?? roleI18n.label['en'] ?? 'Role';
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** Get field label for a specific locale */
|
|
109
|
+
export function getRoleFieldLabel(field: string, locale: string): string {
|
|
110
|
+
const fieldI18n = roleI18n.fields[field as keyof typeof roleI18n.fields];
|
|
111
|
+
if (!fieldI18n) return field;
|
|
112
|
+
return fieldI18n.label[locale as keyof typeof fieldI18n.label] ?? fieldI18n.label['en'] ?? field;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Get field placeholder for a specific locale */
|
|
116
|
+
export function getRoleFieldPlaceholder(field: string, locale: string): string {
|
|
117
|
+
const fieldI18n = roleI18n.fields[field as keyof typeof roleI18n.fields];
|
|
118
|
+
if (!fieldI18n || !('placeholder' in fieldI18n)) return '';
|
|
119
|
+
const placeholder = fieldI18n.placeholder as Record<string, string>;
|
|
120
|
+
return placeholder[locale] ?? placeholder['en'] ?? '';
|
|
121
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ⚠️ DO NOT EDIT THIS FILE! ⚠️
|
|
3
|
+
* このファイルを編集しないでください!
|
|
4
|
+
* KHÔNG ĐƯỢC SỬA FILE NÀY!
|
|
5
|
+
*
|
|
6
|
+
* Auto-generated TypeScript types from Omnify schemas.
|
|
7
|
+
* Any manual changes will be OVERWRITTEN on next generation.
|
|
8
|
+
*
|
|
9
|
+
* To modify: Edit the schema YAML file and run: npx omnify generate
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
import type { DateTimeString } from './common';
|
|
14
|
+
import type { Permission } from './Permission';
|
|
15
|
+
import type { Role } from './Role';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Role Permission
|
|
19
|
+
*/
|
|
20
|
+
export interface RolePermission {
|
|
21
|
+
/** Role */
|
|
22
|
+
role: Role;
|
|
23
|
+
/** Permission */
|
|
24
|
+
permission: Permission;
|
|
25
|
+
/** Creation timestamp */
|
|
26
|
+
created_at?: DateTimeString;
|
|
27
|
+
/** Last update timestamp */
|
|
28
|
+
updated_at?: DateTimeString;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// ============================================================================
|
|
32
|
+
// I18n (Internationalization)
|
|
33
|
+
// ============================================================================
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Unified i18n object for RolePermission
|
|
37
|
+
* Contains model label and all field labels/placeholders
|
|
38
|
+
*/
|
|
39
|
+
export const rolePermissionI18n = {
|
|
40
|
+
/** Model display name */
|
|
41
|
+
label: {"en":"Role Permission"},
|
|
42
|
+
/** Field labels and placeholders */
|
|
43
|
+
fields: {
|
|
44
|
+
role: {
|
|
45
|
+
label: {"en":"Role"},
|
|
46
|
+
},
|
|
47
|
+
permission: {
|
|
48
|
+
label: {"en":"Permission"},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
} as const;
|
|
52
|
+
|
|
53
|
+
// ============================================================================
|
|
54
|
+
// Zod Schemas
|
|
55
|
+
// ============================================================================
|
|
56
|
+
|
|
57
|
+
/** Field schemas for RolePermission */
|
|
58
|
+
export const baseRolePermissionSchemas = {
|
|
59
|
+
} as const;
|
|
60
|
+
|
|
61
|
+
/** Create schema for RolePermission (POST requests) */
|
|
62
|
+
export const baseRolePermissionCreateSchema = z.object({
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
/** Update schema for RolePermission (PUT/PATCH requests) */
|
|
66
|
+
export const baseRolePermissionUpdateSchema = baseRolePermissionCreateSchema.partial();
|
|
67
|
+
|
|
68
|
+
// ============================================================================
|
|
69
|
+
// Inferred Types
|
|
70
|
+
// ============================================================================
|
|
71
|
+
|
|
72
|
+
export type BaseRolePermissionCreate = z.infer<typeof baseRolePermissionCreateSchema>;
|
|
73
|
+
export type BaseRolePermissionUpdate = z.infer<typeof baseRolePermissionUpdateSchema>;
|
|
74
|
+
|
|
75
|
+
// ============================================================================
|
|
76
|
+
// I18n Helper Functions
|
|
77
|
+
// ============================================================================
|
|
78
|
+
|
|
79
|
+
/** Get model label for a specific locale */
|
|
80
|
+
export function getRolePermissionLabel(locale: string): string {
|
|
81
|
+
return rolePermissionI18n.label[locale as keyof typeof rolePermissionI18n.label] ?? rolePermissionI18n.label['en'] ?? 'RolePermission';
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Get field label for a specific locale */
|
|
85
|
+
export function getRolePermissionFieldLabel(field: string, locale: string): string {
|
|
86
|
+
const fieldI18n = rolePermissionI18n.fields[field as keyof typeof rolePermissionI18n.fields];
|
|
87
|
+
if (!fieldI18n) return field;
|
|
88
|
+
return fieldI18n.label[locale as keyof typeof fieldI18n.label] ?? fieldI18n.label['en'] ?? field;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Get field placeholder for a specific locale */
|
|
92
|
+
export function getRolePermissionFieldPlaceholder(field: string, locale: string): string {
|
|
93
|
+
const fieldI18n = rolePermissionI18n.fields[field as keyof typeof rolePermissionI18n.fields];
|
|
94
|
+
if (!fieldI18n || !('placeholder' in fieldI18n)) return '';
|
|
95
|
+
const placeholder = fieldI18n.placeholder as Record<string, string>;
|
|
96
|
+
return placeholder[locale] ?? placeholder['en'] ?? '';
|
|
97
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ⚠️ DO NOT EDIT THIS FILE! ⚠️
|
|
3
|
+
* このファイルを編集しないでください!
|
|
4
|
+
* KHÔNG ĐƯỢC SỬA FILE NÀY!
|
|
5
|
+
*
|
|
6
|
+
* Auto-generated TypeScript types from Omnify schemas.
|
|
7
|
+
* Any manual changes will be OVERWRITTEN on next generation.
|
|
8
|
+
*
|
|
9
|
+
* To modify: Edit the schema YAML file and run: npx omnify generate
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
import type { DateTimeString } from './common';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Team
|
|
17
|
+
*/
|
|
18
|
+
export interface Team {
|
|
19
|
+
/** Primary key */
|
|
20
|
+
id: string;
|
|
21
|
+
/** Console Team ID */
|
|
22
|
+
console_team_id: unknown;
|
|
23
|
+
/** Console Organization ID */
|
|
24
|
+
console_org_id: unknown;
|
|
25
|
+
/** Team Name */
|
|
26
|
+
name: string;
|
|
27
|
+
/** Creation timestamp */
|
|
28
|
+
created_at?: DateTimeString;
|
|
29
|
+
/** Last update timestamp */
|
|
30
|
+
updated_at?: DateTimeString;
|
|
31
|
+
/** Soft delete timestamp */
|
|
32
|
+
deleted_at?: DateTimeString;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// ============================================================================
|
|
36
|
+
// I18n (Internationalization)
|
|
37
|
+
// ============================================================================
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Unified i18n object for Team
|
|
41
|
+
* Contains model label and all field labels/placeholders
|
|
42
|
+
*/
|
|
43
|
+
export const teamI18n = {
|
|
44
|
+
/** Model display name */
|
|
45
|
+
label: {"en":"Team"},
|
|
46
|
+
/** Field labels and placeholders */
|
|
47
|
+
fields: {
|
|
48
|
+
console_team_id: {
|
|
49
|
+
label: {"en":"Console Team ID"},
|
|
50
|
+
},
|
|
51
|
+
console_org_id: {
|
|
52
|
+
label: {"en":"Console Organization ID"},
|
|
53
|
+
},
|
|
54
|
+
name: {
|
|
55
|
+
label: {"en":"Team Name"},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
} as const;
|
|
59
|
+
|
|
60
|
+
// ============================================================================
|
|
61
|
+
// Zod Schemas
|
|
62
|
+
// ============================================================================
|
|
63
|
+
|
|
64
|
+
/** Field schemas for Team */
|
|
65
|
+
export const baseTeamSchemas = {
|
|
66
|
+
console_team_id: z.string(),
|
|
67
|
+
console_org_id: z.string(),
|
|
68
|
+
name: z.string().min(1).max(100),
|
|
69
|
+
} as const;
|
|
70
|
+
|
|
71
|
+
/** Create schema for Team (POST requests) */
|
|
72
|
+
export const baseTeamCreateSchema = z.object({
|
|
73
|
+
console_team_id: baseTeamSchemas.console_team_id,
|
|
74
|
+
console_org_id: baseTeamSchemas.console_org_id,
|
|
75
|
+
name: baseTeamSchemas.name,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
/** Update schema for Team (PUT/PATCH requests) */
|
|
79
|
+
export const baseTeamUpdateSchema = baseTeamCreateSchema.partial();
|
|
80
|
+
|
|
81
|
+
// ============================================================================
|
|
82
|
+
// Inferred Types
|
|
83
|
+
// ============================================================================
|
|
84
|
+
|
|
85
|
+
export type BaseTeamCreate = z.infer<typeof baseTeamCreateSchema>;
|
|
86
|
+
export type BaseTeamUpdate = z.infer<typeof baseTeamUpdateSchema>;
|
|
87
|
+
|
|
88
|
+
// ============================================================================
|
|
89
|
+
// I18n Helper Functions
|
|
90
|
+
// ============================================================================
|
|
91
|
+
|
|
92
|
+
/** Get model label for a specific locale */
|
|
93
|
+
export function getTeamLabel(locale: string): string {
|
|
94
|
+
return teamI18n.label[locale as keyof typeof teamI18n.label] ?? teamI18n.label['en'] ?? 'Team';
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Get field label for a specific locale */
|
|
98
|
+
export function getTeamFieldLabel(field: string, locale: string): string {
|
|
99
|
+
const fieldI18n = teamI18n.fields[field as keyof typeof teamI18n.fields];
|
|
100
|
+
if (!fieldI18n) return field;
|
|
101
|
+
return fieldI18n.label[locale as keyof typeof fieldI18n.label] ?? fieldI18n.label['en'] ?? field;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Get field placeholder for a specific locale */
|
|
105
|
+
export function getTeamFieldPlaceholder(field: string, locale: string): string {
|
|
106
|
+
const fieldI18n = teamI18n.fields[field as keyof typeof teamI18n.fields];
|
|
107
|
+
if (!fieldI18n || !('placeholder' in fieldI18n)) return '';
|
|
108
|
+
const placeholder = fieldI18n.placeholder as Record<string, string>;
|
|
109
|
+
return placeholder[locale] ?? placeholder['en'] ?? '';
|
|
110
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ⚠️ DO NOT EDIT THIS FILE! ⚠️
|
|
3
|
+
* このファイルを編集しないでください!
|
|
4
|
+
* KHÔNG ĐƯỢC SỬA FILE NÀY!
|
|
5
|
+
*
|
|
6
|
+
* Auto-generated TypeScript types from Omnify schemas.
|
|
7
|
+
* Any manual changes will be OVERWRITTEN on next generation.
|
|
8
|
+
*
|
|
9
|
+
* To modify: Edit the schema YAML file and run: npx omnify generate
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
import type { DateTimeString } from './common';
|
|
14
|
+
import type { Permission } from './Permission';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Team Permission
|
|
18
|
+
*/
|
|
19
|
+
export interface TeamPermission {
|
|
20
|
+
/** Primary key */
|
|
21
|
+
id: string;
|
|
22
|
+
/** Console Organization ID */
|
|
23
|
+
console_org_id: unknown;
|
|
24
|
+
/** Console Team ID */
|
|
25
|
+
console_team_id: unknown;
|
|
26
|
+
/** Permission */
|
|
27
|
+
permission: Permission;
|
|
28
|
+
/** Creation timestamp */
|
|
29
|
+
created_at?: DateTimeString;
|
|
30
|
+
/** Last update timestamp */
|
|
31
|
+
updated_at?: DateTimeString;
|
|
32
|
+
/** Soft delete timestamp */
|
|
33
|
+
deleted_at?: DateTimeString;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// ============================================================================
|
|
37
|
+
// I18n (Internationalization)
|
|
38
|
+
// ============================================================================
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Unified i18n object for TeamPermission
|
|
42
|
+
* Contains model label and all field labels/placeholders
|
|
43
|
+
*/
|
|
44
|
+
export const teamPermissionI18n = {
|
|
45
|
+
/** Model display name */
|
|
46
|
+
label: {"en":"Team Permission"},
|
|
47
|
+
/** Field labels and placeholders */
|
|
48
|
+
fields: {
|
|
49
|
+
console_org_id: {
|
|
50
|
+
label: {"en":"Console Organization ID"},
|
|
51
|
+
},
|
|
52
|
+
console_team_id: {
|
|
53
|
+
label: {"en":"Console Team ID"},
|
|
54
|
+
},
|
|
55
|
+
permission: {
|
|
56
|
+
label: {"en":"Permission"},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
} as const;
|
|
60
|
+
|
|
61
|
+
// ============================================================================
|
|
62
|
+
// Zod Schemas
|
|
63
|
+
// ============================================================================
|
|
64
|
+
|
|
65
|
+
/** Field schemas for TeamPermission */
|
|
66
|
+
export const baseTeamPermissionSchemas = {
|
|
67
|
+
console_org_id: z.string(),
|
|
68
|
+
console_team_id: z.string(),
|
|
69
|
+
} as const;
|
|
70
|
+
|
|
71
|
+
/** Create schema for TeamPermission (POST requests) */
|
|
72
|
+
export const baseTeamPermissionCreateSchema = z.object({
|
|
73
|
+
console_org_id: baseTeamPermissionSchemas.console_org_id,
|
|
74
|
+
console_team_id: baseTeamPermissionSchemas.console_team_id,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
/** Update schema for TeamPermission (PUT/PATCH requests) */
|
|
78
|
+
export const baseTeamPermissionUpdateSchema = baseTeamPermissionCreateSchema.partial();
|
|
79
|
+
|
|
80
|
+
// ============================================================================
|
|
81
|
+
// Inferred Types
|
|
82
|
+
// ============================================================================
|
|
83
|
+
|
|
84
|
+
export type BaseTeamPermissionCreate = z.infer<typeof baseTeamPermissionCreateSchema>;
|
|
85
|
+
export type BaseTeamPermissionUpdate = z.infer<typeof baseTeamPermissionUpdateSchema>;
|
|
86
|
+
|
|
87
|
+
// ============================================================================
|
|
88
|
+
// I18n Helper Functions
|
|
89
|
+
// ============================================================================
|
|
90
|
+
|
|
91
|
+
/** Get model label for a specific locale */
|
|
92
|
+
export function getTeamPermissionLabel(locale: string): string {
|
|
93
|
+
return teamPermissionI18n.label[locale as keyof typeof teamPermissionI18n.label] ?? teamPermissionI18n.label['en'] ?? 'TeamPermission';
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Get field label for a specific locale */
|
|
97
|
+
export function getTeamPermissionFieldLabel(field: string, locale: string): string {
|
|
98
|
+
const fieldI18n = teamPermissionI18n.fields[field as keyof typeof teamPermissionI18n.fields];
|
|
99
|
+
if (!fieldI18n) return field;
|
|
100
|
+
return fieldI18n.label[locale as keyof typeof fieldI18n.label] ?? fieldI18n.label['en'] ?? field;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Get field placeholder for a specific locale */
|
|
104
|
+
export function getTeamPermissionFieldPlaceholder(field: string, locale: string): string {
|
|
105
|
+
const fieldI18n = teamPermissionI18n.fields[field as keyof typeof teamPermissionI18n.fields];
|
|
106
|
+
if (!fieldI18n || !('placeholder' in fieldI18n)) return '';
|
|
107
|
+
const placeholder = fieldI18n.placeholder as Record<string, string>;
|
|
108
|
+
return placeholder[locale] ?? placeholder['en'] ?? '';
|
|
109
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ⚠️ DO NOT EDIT THIS FILE! ⚠️
|
|
3
|
+
* このファイルを編集しないでください!
|
|
4
|
+
* KHÔNG ĐƯỢC SỬA FILE NÀY!
|
|
5
|
+
*
|
|
6
|
+
* Auto-generated TypeScript types from Omnify schemas.
|
|
7
|
+
* Any manual changes will be OVERWRITTEN on next generation.
|
|
8
|
+
*
|
|
9
|
+
* To modify: Edit the schema YAML file and run: npx omnify generate
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
import type { DateTimeString } from './common';
|
|
14
|
+
import type { Role } from './Role';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* User
|
|
18
|
+
*/
|
|
19
|
+
export interface User {
|
|
20
|
+
/** Primary key */
|
|
21
|
+
id: string;
|
|
22
|
+
/** Name */
|
|
23
|
+
name: string;
|
|
24
|
+
/** Email */
|
|
25
|
+
email: string;
|
|
26
|
+
/** Console User ID */
|
|
27
|
+
console_user_id?: unknown;
|
|
28
|
+
/** Console Access Token */
|
|
29
|
+
console_access_token?: string;
|
|
30
|
+
/** Console Refresh Token */
|
|
31
|
+
console_refresh_token?: string;
|
|
32
|
+
/** Console Token Expiry */
|
|
33
|
+
console_token_expires_at?: DateTimeString;
|
|
34
|
+
/** Roles */
|
|
35
|
+
roles: Role[];
|
|
36
|
+
/** Creation timestamp */
|
|
37
|
+
created_at?: DateTimeString;
|
|
38
|
+
/** Last update timestamp */
|
|
39
|
+
updated_at?: DateTimeString;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// ============================================================================
|
|
43
|
+
// I18n (Internationalization)
|
|
44
|
+
// ============================================================================
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Unified i18n object for User
|
|
48
|
+
* Contains model label and all field labels/placeholders
|
|
49
|
+
*/
|
|
50
|
+
export const userI18n = {
|
|
51
|
+
/** Model display name */
|
|
52
|
+
label: {"en":"User"},
|
|
53
|
+
/** Field labels and placeholders */
|
|
54
|
+
fields: {
|
|
55
|
+
name: {
|
|
56
|
+
label: {"en":"Name"},
|
|
57
|
+
},
|
|
58
|
+
email: {
|
|
59
|
+
label: {"en":"Email"},
|
|
60
|
+
},
|
|
61
|
+
console_user_id: {
|
|
62
|
+
label: {"en":"Console User ID"},
|
|
63
|
+
},
|
|
64
|
+
console_access_token: {
|
|
65
|
+
label: {"en":"Console Access Token"},
|
|
66
|
+
},
|
|
67
|
+
console_refresh_token: {
|
|
68
|
+
label: {"en":"Console Refresh Token"},
|
|
69
|
+
},
|
|
70
|
+
console_token_expires_at: {
|
|
71
|
+
label: {"en":"Console Token Expiry"},
|
|
72
|
+
},
|
|
73
|
+
roles: {
|
|
74
|
+
label: {"en":"Roles"},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
} as const;
|
|
78
|
+
|
|
79
|
+
// ============================================================================
|
|
80
|
+
// Zod Schemas
|
|
81
|
+
// ============================================================================
|
|
82
|
+
|
|
83
|
+
/** Field schemas for User */
|
|
84
|
+
export const baseUserSchemas = {
|
|
85
|
+
name: z.string().min(1),
|
|
86
|
+
email: z.string().min(1),
|
|
87
|
+
console_user_id: z.string().optional().nullable(),
|
|
88
|
+
console_access_token: z.string().optional().nullable(),
|
|
89
|
+
console_refresh_token: z.string().optional().nullable(),
|
|
90
|
+
console_token_expires_at: z.string().datetime({ offset: true }).optional().nullable(),
|
|
91
|
+
} as const;
|
|
92
|
+
|
|
93
|
+
/** Create schema for User (POST requests) */
|
|
94
|
+
export const baseUserCreateSchema = z.object({
|
|
95
|
+
name: baseUserSchemas.name,
|
|
96
|
+
email: baseUserSchemas.email,
|
|
97
|
+
console_user_id: baseUserSchemas.console_user_id,
|
|
98
|
+
console_access_token: baseUserSchemas.console_access_token,
|
|
99
|
+
console_refresh_token: baseUserSchemas.console_refresh_token,
|
|
100
|
+
console_token_expires_at: baseUserSchemas.console_token_expires_at,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
/** Update schema for User (PUT/PATCH requests) */
|
|
104
|
+
export const baseUserUpdateSchema = baseUserCreateSchema.partial();
|
|
105
|
+
|
|
106
|
+
// ============================================================================
|
|
107
|
+
// Inferred Types
|
|
108
|
+
// ============================================================================
|
|
109
|
+
|
|
110
|
+
export type BaseUserCreate = z.infer<typeof baseUserCreateSchema>;
|
|
111
|
+
export type BaseUserUpdate = z.infer<typeof baseUserUpdateSchema>;
|
|
112
|
+
|
|
113
|
+
// ============================================================================
|
|
114
|
+
// I18n Helper Functions
|
|
115
|
+
// ============================================================================
|
|
116
|
+
|
|
117
|
+
/** Get model label for a specific locale */
|
|
118
|
+
export function getUserLabel(locale: string): string {
|
|
119
|
+
return userI18n.label[locale as keyof typeof userI18n.label] ?? userI18n.label['en'] ?? 'User';
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Get field label for a specific locale */
|
|
123
|
+
export function getUserFieldLabel(field: string, locale: string): string {
|
|
124
|
+
const fieldI18n = userI18n.fields[field as keyof typeof userI18n.fields];
|
|
125
|
+
if (!fieldI18n) return field;
|
|
126
|
+
return fieldI18n.label[locale as keyof typeof fieldI18n.label] ?? fieldI18n.label['en'] ?? field;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Get field placeholder for a specific locale */
|
|
130
|
+
export function getUserFieldPlaceholder(field: string, locale: string): string {
|
|
131
|
+
const fieldI18n = userI18n.fields[field as keyof typeof userI18n.fields];
|
|
132
|
+
if (!fieldI18n || !('placeholder' in fieldI18n)) return '';
|
|
133
|
+
const placeholder = fieldI18n.placeholder as Record<string, string>;
|
|
134
|
+
return placeholder[locale] ?? placeholder['en'] ?? '';
|
|
135
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ⚠️ DO NOT EDIT THIS FILE! ⚠️
|
|
3
|
+
* このファイルを編集しないでください!
|
|
4
|
+
* KHÔNG ĐƯỢC SỬA FILE NÀY!
|
|
5
|
+
*
|
|
6
|
+
* Auto-generated TypeScript types from Omnify schemas.
|
|
7
|
+
* Any manual changes will be OVERWRITTEN on next generation.
|
|
8
|
+
*
|
|
9
|
+
* To modify: Edit the schema YAML file and run: npx omnify generate
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Locale map for multi-language support.
|
|
15
|
+
*/
|
|
16
|
+
export interface LocaleMap {
|
|
17
|
+
[locale: string]: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Supported locales in this project.
|
|
22
|
+
*/
|
|
23
|
+
export type Locale = 'ja' | 'en';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Validation rule with multi-locale messages.
|
|
27
|
+
* Use get{Model}Rules(locale) to get Ant Design compatible rules with string messages.
|
|
28
|
+
*/
|
|
29
|
+
export interface ValidationRule {
|
|
30
|
+
required?: boolean;
|
|
31
|
+
type?: 'string' | 'number' | 'email' | 'url' | 'integer' | 'array' | 'object';
|
|
32
|
+
min?: number;
|
|
33
|
+
max?: number;
|
|
34
|
+
len?: number;
|
|
35
|
+
pattern?: RegExp;
|
|
36
|
+
message: LocaleMap;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* ISO 8601 date-time string.
|
|
41
|
+
*/
|
|
42
|
+
export type DateTimeString = string;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* ISO 8601 date string (YYYY-MM-DD).
|
|
46
|
+
*/
|
|
47
|
+
export type DateString = string;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ⚠️ DO NOT EDIT THIS FILE! ⚠️
|
|
3
|
+
* このファイルを編集しないでください!
|
|
4
|
+
* KHÔNG ĐƯỢC SỬA FILE NÀY!
|
|
5
|
+
*
|
|
6
|
+
* Auto-generated TypeScript types from Omnify schemas.
|
|
7
|
+
* Any manual changes will be OVERWRITTEN on next generation.
|
|
8
|
+
*
|
|
9
|
+
* To modify: Edit the schema YAML file and run: npx omnify generate
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
import type { LocaleMap } from '@omnify-base/schemas/common';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Default locale for this project.
|
|
17
|
+
*/
|
|
18
|
+
export const defaultLocale = 'ja' as const;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Fallback locale when requested locale is not found.
|
|
22
|
+
*/
|
|
23
|
+
export const fallbackLocale = 'en' as const;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Supported locales in this project.
|
|
27
|
+
*/
|
|
28
|
+
export const supportedLocales = ["ja","en"] as const;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Validation messages for all supported locales.
|
|
32
|
+
* Use getMessage(key, locale, params) to get formatted message.
|
|
33
|
+
*/
|
|
34
|
+
export const validationMessages = {
|
|
35
|
+
"required": {
|
|
36
|
+
"ja": "${displayName}は必須です",
|
|
37
|
+
"en": "${displayName} is required"
|
|
38
|
+
},
|
|
39
|
+
"minLength": {
|
|
40
|
+
"ja": "${displayName}は${min}文字以上で入力してください",
|
|
41
|
+
"en": "${displayName} must be at least ${min} characters"
|
|
42
|
+
},
|
|
43
|
+
"maxLength": {
|
|
44
|
+
"ja": "${displayName}は${max}文字以内で入力してください",
|
|
45
|
+
"en": "${displayName} must be at most ${max} characters"
|
|
46
|
+
},
|
|
47
|
+
"min": {
|
|
48
|
+
"ja": "${displayName}は${min}以上で入力してください",
|
|
49
|
+
"en": "${displayName} must be at least ${min}"
|
|
50
|
+
},
|
|
51
|
+
"max": {
|
|
52
|
+
"ja": "${displayName}は${max}以下で入力してください",
|
|
53
|
+
"en": "${displayName} must be at most ${max}"
|
|
54
|
+
},
|
|
55
|
+
"email": {
|
|
56
|
+
"ja": "有効なメールアドレスを入力してください",
|
|
57
|
+
"en": "Please enter a valid email address"
|
|
58
|
+
},
|
|
59
|
+
"url": {
|
|
60
|
+
"ja": "有効なURLを入力してください",
|
|
61
|
+
"en": "Please enter a valid URL"
|
|
62
|
+
},
|
|
63
|
+
"pattern": {
|
|
64
|
+
"ja": "${displayName}の形式が正しくありません",
|
|
65
|
+
"en": "${displayName} format is invalid"
|
|
66
|
+
}
|
|
67
|
+
} as const;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Get validation message for a specific key and locale.
|
|
71
|
+
* Supports template placeholders: ${displayName}, ${min}, ${max}, etc.
|
|
72
|
+
*
|
|
73
|
+
* @param key - Message key (e.g., 'required', 'minLength')
|
|
74
|
+
* @param locale - Locale code (e.g., 'ja', 'en')
|
|
75
|
+
* @param params - Template parameters to replace
|
|
76
|
+
* @returns Formatted message string
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* getMessage('required', 'ja', { displayName: '氏名' })
|
|
80
|
+
* // => '氏名は必須です'
|
|
81
|
+
*/
|
|
82
|
+
export function getMessage(
|
|
83
|
+
key: string,
|
|
84
|
+
locale: string,
|
|
85
|
+
params: Record<string, string | number> = {}
|
|
86
|
+
): string {
|
|
87
|
+
const messages = validationMessages[key as keyof typeof validationMessages];
|
|
88
|
+
if (!messages) return key;
|
|
89
|
+
|
|
90
|
+
let message = (messages as LocaleMap)[locale]
|
|
91
|
+
?? (messages as LocaleMap)[fallbackLocale]
|
|
92
|
+
?? (messages as LocaleMap)[defaultLocale]
|
|
93
|
+
?? key;
|
|
94
|
+
|
|
95
|
+
// Replace template placeholders
|
|
96
|
+
for (const [param, value] of Object.entries(params)) {
|
|
97
|
+
message = message.replace(new RegExp(`\\$\{${param}\}`, 'g'), String(value));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return message;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Get all validation messages for a specific locale.
|
|
105
|
+
*
|
|
106
|
+
* @param locale - Locale code
|
|
107
|
+
* @returns Object with all messages for the locale
|
|
108
|
+
*/
|
|
109
|
+
export function getMessages(locale: string): Record<string, string> {
|
|
110
|
+
const result: Record<string, string> = {};
|
|
111
|
+
for (const [key, messages] of Object.entries(validationMessages)) {
|
|
112
|
+
result[key] = (messages as LocaleMap)[locale]
|
|
113
|
+
?? (messages as LocaleMap)[fallbackLocale]
|
|
114
|
+
?? (messages as LocaleMap)[defaultLocale]
|
|
115
|
+
?? key;
|
|
116
|
+
}
|
|
117
|
+
return result;
|
|
118
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@famgia/omnify-react-sso",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "SSO (Single Sign-On) schemas, types, and utilities for Omnify",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -46,6 +46,9 @@
|
|
|
46
46
|
"types": "./dist/testing/index.d.cts",
|
|
47
47
|
"default": "./dist/testing/index.cjs"
|
|
48
48
|
}
|
|
49
|
+
},
|
|
50
|
+
"./@omnify-base/*": {
|
|
51
|
+
"types": "./dist/@omnify-base/*"
|
|
49
52
|
}
|
|
50
53
|
},
|
|
51
54
|
"files": [
|
|
@@ -56,11 +59,13 @@
|
|
|
56
59
|
"scripts": {
|
|
57
60
|
"build:schemas": "tsx scripts/build-schemas.ts",
|
|
58
61
|
"build:lib": "tsup",
|
|
59
|
-
"build": "
|
|
62
|
+
"build:copy-base": "cp -r node_modules/@omnify-base dist/",
|
|
63
|
+
"build": "pnpm build:schemas && pnpm build:lib && pnpm build:copy-base",
|
|
60
64
|
"clean": "rm -rf dist src/schemas schemas",
|
|
61
65
|
"typecheck": "tsc --noEmit",
|
|
62
66
|
"test": "vitest run",
|
|
63
|
-
"test:watch": "vitest"
|
|
67
|
+
"test:watch": "vitest",
|
|
68
|
+
"postinstall": "node scripts/postinstall.cjs"
|
|
64
69
|
},
|
|
65
70
|
"keywords": [
|
|
66
71
|
"omnify",
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Postinstall script for @famgia/omnify-react-sso
|
|
4
|
+
*
|
|
5
|
+
* Creates @omnify-base in the consumer's node_modules so TypeScript can resolve types.
|
|
6
|
+
* The actual @omnify-base types are bundled in this package's dist/@omnify-base.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const fs = require('fs');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
|
|
12
|
+
// Find the consumer's node_modules (go up from this package)
|
|
13
|
+
const packageDir = path.resolve(__dirname, '..');
|
|
14
|
+
const nodeModulesDir = path.resolve(packageDir, '..', '..'); // node_modules/@famgia/omnify-react-sso -> node_modules
|
|
15
|
+
const targetDir = path.join(nodeModulesDir, '@omnify-base');
|
|
16
|
+
const sourceDir = path.join(packageDir, 'dist', '@omnify-base');
|
|
17
|
+
|
|
18
|
+
// Only run if we're in a consumer's node_modules (not during development)
|
|
19
|
+
if (!nodeModulesDir.includes('node_modules')) {
|
|
20
|
+
console.log('@famgia/omnify-react-sso: Skipping postinstall (not in node_modules)');
|
|
21
|
+
process.exit(0);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Check if source exists
|
|
25
|
+
if (!fs.existsSync(sourceDir)) {
|
|
26
|
+
console.log('@famgia/omnify-react-sso: dist/@omnify-base not found, skipping');
|
|
27
|
+
process.exit(0);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Skip if @omnify-base already exists (from another package or manual setup)
|
|
31
|
+
if (fs.existsSync(targetDir)) {
|
|
32
|
+
console.log('@famgia/omnify-react-sso: @omnify-base already exists, skipping');
|
|
33
|
+
process.exit(0);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
// Copy @omnify-base to node_modules
|
|
38
|
+
fs.cpSync(sourceDir, targetDir, { recursive: true });
|
|
39
|
+
console.log('@famgia/omnify-react-sso: Created @omnify-base for TypeScript');
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.warn('@famgia/omnify-react-sso: Could not create @omnify-base:', error.message);
|
|
42
|
+
// Don't fail - the package still works at runtime
|
|
43
|
+
}
|