@famgia/omnify-react-sso 2.2.1 → 2.2.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/README.md +404 -113
- package/dist/@omnify-base/schemas/BranchCache.ts +131 -0
- package/dist/@omnify-base/schemas/OrganizationCache.ts +117 -0
- package/dist/@omnify-base/schemas/TeamCache.ts +110 -0
- package/dist/@omnify-base/schemas/UserCache.ts +135 -0
- package/dist/index.cjs +1200 -381
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +245 -7
- package/dist/index.d.ts +245 -7
- package/dist/index.js +1158 -355
- package/dist/index.js.map +1 -1
- package/dist/schemas/index.cjs +201 -133
- package/dist/schemas/index.cjs.map +1 -1
- package/dist/schemas/index.d.cts +61 -28
- package/dist/schemas/index.d.ts +61 -28
- package/dist/schemas/index.js +173 -112
- package/dist/schemas/index.js.map +1 -1
- package/dist/testing/index.d.cts +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/{types-BCBSfJJr.d.cts → types-CJmA2a9r.d.cts} +102 -1
- package/dist/{types-BCBSfJJr.d.ts → types-CJmA2a9r.d.ts} +102 -1
- package/package.json +3 -1
|
@@ -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 Cache
|
|
17
|
+
*/
|
|
18
|
+
export interface BranchCache {
|
|
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 BranchCache
|
|
47
|
+
* Contains model label and all field labels/placeholders
|
|
48
|
+
*/
|
|
49
|
+
export const branchCacheI18n = {
|
|
50
|
+
/** Model display name */
|
|
51
|
+
label: {"en":"Branch Cache"},
|
|
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 BranchCache */
|
|
80
|
+
export const baseBranchCacheSchemas = {
|
|
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 BranchCache (POST requests) */
|
|
90
|
+
export const baseBranchCacheCreateSchema = z.object({
|
|
91
|
+
console_branch_id: baseBranchCacheSchemas.console_branch_id,
|
|
92
|
+
console_org_id: baseBranchCacheSchemas.console_org_id,
|
|
93
|
+
code: baseBranchCacheSchemas.code,
|
|
94
|
+
name: baseBranchCacheSchemas.name,
|
|
95
|
+
is_headquarters: baseBranchCacheSchemas.is_headquarters,
|
|
96
|
+
is_active: baseBranchCacheSchemas.is_active,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
/** Update schema for BranchCache (PUT/PATCH requests) */
|
|
100
|
+
export const baseBranchCacheUpdateSchema = baseBranchCacheCreateSchema.partial();
|
|
101
|
+
|
|
102
|
+
// ============================================================================
|
|
103
|
+
// Inferred Types
|
|
104
|
+
// ============================================================================
|
|
105
|
+
|
|
106
|
+
export type BaseBranchCacheCreate = z.infer<typeof baseBranchCacheCreateSchema>;
|
|
107
|
+
export type BaseBranchCacheUpdate = z.infer<typeof baseBranchCacheUpdateSchema>;
|
|
108
|
+
|
|
109
|
+
// ============================================================================
|
|
110
|
+
// I18n Helper Functions
|
|
111
|
+
// ============================================================================
|
|
112
|
+
|
|
113
|
+
/** Get model label for a specific locale */
|
|
114
|
+
export function getBranchCacheLabel(locale: string): string {
|
|
115
|
+
return branchCacheI18n.label[locale as keyof typeof branchCacheI18n.label] ?? branchCacheI18n.label['en'] ?? 'BranchCache';
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Get field label for a specific locale */
|
|
119
|
+
export function getBranchCacheFieldLabel(field: string, locale: string): string {
|
|
120
|
+
const fieldI18n = branchCacheI18n.fields[field as keyof typeof branchCacheI18n.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 getBranchCacheFieldPlaceholder(field: string, locale: string): string {
|
|
127
|
+
const fieldI18n = branchCacheI18n.fields[field as keyof typeof branchCacheI18n.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,117 @@
|
|
|
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
|
+
* Organization Cache
|
|
17
|
+
*/
|
|
18
|
+
export interface OrganizationCache {
|
|
19
|
+
/** Primary key */
|
|
20
|
+
id: string;
|
|
21
|
+
/** Console Organization ID */
|
|
22
|
+
console_org_id: unknown;
|
|
23
|
+
/** Organization Name */
|
|
24
|
+
name: string;
|
|
25
|
+
/** Organization Code */
|
|
26
|
+
code: string;
|
|
27
|
+
/** Active */
|
|
28
|
+
is_active: boolean;
|
|
29
|
+
/** Creation timestamp */
|
|
30
|
+
created_at?: DateTimeString;
|
|
31
|
+
/** Last update timestamp */
|
|
32
|
+
updated_at?: DateTimeString;
|
|
33
|
+
/** Soft delete timestamp */
|
|
34
|
+
deleted_at?: DateTimeString;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// ============================================================================
|
|
38
|
+
// I18n (Internationalization)
|
|
39
|
+
// ============================================================================
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Unified i18n object for OrganizationCache
|
|
43
|
+
* Contains model label and all field labels/placeholders
|
|
44
|
+
*/
|
|
45
|
+
export const organizationCacheI18n = {
|
|
46
|
+
/** Model display name */
|
|
47
|
+
label: {"en":"Organization Cache"},
|
|
48
|
+
/** Field labels and placeholders */
|
|
49
|
+
fields: {
|
|
50
|
+
console_org_id: {
|
|
51
|
+
label: {"en":"Console Organization ID"},
|
|
52
|
+
},
|
|
53
|
+
name: {
|
|
54
|
+
label: {"en":"Organization Name"},
|
|
55
|
+
},
|
|
56
|
+
code: {
|
|
57
|
+
label: {"en":"Organization Code"},
|
|
58
|
+
},
|
|
59
|
+
is_active: {
|
|
60
|
+
label: {"en":"Active"},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
} as const;
|
|
64
|
+
|
|
65
|
+
// ============================================================================
|
|
66
|
+
// Zod Schemas
|
|
67
|
+
// ============================================================================
|
|
68
|
+
|
|
69
|
+
/** Field schemas for OrganizationCache */
|
|
70
|
+
export const baseOrganizationCacheSchemas = {
|
|
71
|
+
console_org_id: z.string(),
|
|
72
|
+
name: z.string().min(1).max(100),
|
|
73
|
+
code: z.string().min(1).max(20),
|
|
74
|
+
is_active: z.boolean(),
|
|
75
|
+
} as const;
|
|
76
|
+
|
|
77
|
+
/** Create schema for OrganizationCache (POST requests) */
|
|
78
|
+
export const baseOrganizationCacheCreateSchema = z.object({
|
|
79
|
+
console_org_id: baseOrganizationCacheSchemas.console_org_id,
|
|
80
|
+
name: baseOrganizationCacheSchemas.name,
|
|
81
|
+
code: baseOrganizationCacheSchemas.code,
|
|
82
|
+
is_active: baseOrganizationCacheSchemas.is_active,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
/** Update schema for OrganizationCache (PUT/PATCH requests) */
|
|
86
|
+
export const baseOrganizationCacheUpdateSchema = baseOrganizationCacheCreateSchema.partial();
|
|
87
|
+
|
|
88
|
+
// ============================================================================
|
|
89
|
+
// Inferred Types
|
|
90
|
+
// ============================================================================
|
|
91
|
+
|
|
92
|
+
export type BaseOrganizationCacheCreate = z.infer<typeof baseOrganizationCacheCreateSchema>;
|
|
93
|
+
export type BaseOrganizationCacheUpdate = z.infer<typeof baseOrganizationCacheUpdateSchema>;
|
|
94
|
+
|
|
95
|
+
// ============================================================================
|
|
96
|
+
// I18n Helper Functions
|
|
97
|
+
// ============================================================================
|
|
98
|
+
|
|
99
|
+
/** Get model label for a specific locale */
|
|
100
|
+
export function getOrganizationCacheLabel(locale: string): string {
|
|
101
|
+
return organizationCacheI18n.label[locale as keyof typeof organizationCacheI18n.label] ?? organizationCacheI18n.label['en'] ?? 'OrganizationCache';
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Get field label for a specific locale */
|
|
105
|
+
export function getOrganizationCacheFieldLabel(field: string, locale: string): string {
|
|
106
|
+
const fieldI18n = organizationCacheI18n.fields[field as keyof typeof organizationCacheI18n.fields];
|
|
107
|
+
if (!fieldI18n) return field;
|
|
108
|
+
return fieldI18n.label[locale as keyof typeof fieldI18n.label] ?? fieldI18n.label['en'] ?? field;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Get field placeholder for a specific locale */
|
|
112
|
+
export function getOrganizationCacheFieldPlaceholder(field: string, locale: string): string {
|
|
113
|
+
const fieldI18n = organizationCacheI18n.fields[field as keyof typeof organizationCacheI18n.fields];
|
|
114
|
+
if (!fieldI18n || !('placeholder' in fieldI18n)) return '';
|
|
115
|
+
const placeholder = fieldI18n.placeholder as Record<string, string>;
|
|
116
|
+
return placeholder[locale] ?? placeholder['en'] ?? '';
|
|
117
|
+
}
|
|
@@ -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 Cache
|
|
17
|
+
*/
|
|
18
|
+
export interface TeamCache {
|
|
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 TeamCache
|
|
41
|
+
* Contains model label and all field labels/placeholders
|
|
42
|
+
*/
|
|
43
|
+
export const teamCacheI18n = {
|
|
44
|
+
/** Model display name */
|
|
45
|
+
label: {"en":"Team Cache"},
|
|
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 TeamCache */
|
|
65
|
+
export const baseTeamCacheSchemas = {
|
|
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 TeamCache (POST requests) */
|
|
72
|
+
export const baseTeamCacheCreateSchema = z.object({
|
|
73
|
+
console_team_id: baseTeamCacheSchemas.console_team_id,
|
|
74
|
+
console_org_id: baseTeamCacheSchemas.console_org_id,
|
|
75
|
+
name: baseTeamCacheSchemas.name,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
/** Update schema for TeamCache (PUT/PATCH requests) */
|
|
79
|
+
export const baseTeamCacheUpdateSchema = baseTeamCacheCreateSchema.partial();
|
|
80
|
+
|
|
81
|
+
// ============================================================================
|
|
82
|
+
// Inferred Types
|
|
83
|
+
// ============================================================================
|
|
84
|
+
|
|
85
|
+
export type BaseTeamCacheCreate = z.infer<typeof baseTeamCacheCreateSchema>;
|
|
86
|
+
export type BaseTeamCacheUpdate = z.infer<typeof baseTeamCacheUpdateSchema>;
|
|
87
|
+
|
|
88
|
+
// ============================================================================
|
|
89
|
+
// I18n Helper Functions
|
|
90
|
+
// ============================================================================
|
|
91
|
+
|
|
92
|
+
/** Get model label for a specific locale */
|
|
93
|
+
export function getTeamCacheLabel(locale: string): string {
|
|
94
|
+
return teamCacheI18n.label[locale as keyof typeof teamCacheI18n.label] ?? teamCacheI18n.label['en'] ?? 'TeamCache';
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Get field label for a specific locale */
|
|
98
|
+
export function getTeamCacheFieldLabel(field: string, locale: string): string {
|
|
99
|
+
const fieldI18n = teamCacheI18n.fields[field as keyof typeof teamCacheI18n.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 getTeamCacheFieldPlaceholder(field: string, locale: string): string {
|
|
106
|
+
const fieldI18n = teamCacheI18n.fields[field as keyof typeof teamCacheI18n.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,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 Cache
|
|
18
|
+
*/
|
|
19
|
+
export interface UserCache {
|
|
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 UserCache
|
|
48
|
+
* Contains model label and all field labels/placeholders
|
|
49
|
+
*/
|
|
50
|
+
export const userCacheI18n = {
|
|
51
|
+
/** Model display name */
|
|
52
|
+
label: {"en":"User Cache"},
|
|
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 UserCache */
|
|
84
|
+
export const baseUserCacheSchemas = {
|
|
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 UserCache (POST requests) */
|
|
94
|
+
export const baseUserCacheCreateSchema = z.object({
|
|
95
|
+
name: baseUserCacheSchemas.name,
|
|
96
|
+
email: baseUserCacheSchemas.email,
|
|
97
|
+
console_user_id: baseUserCacheSchemas.console_user_id,
|
|
98
|
+
console_access_token: baseUserCacheSchemas.console_access_token,
|
|
99
|
+
console_refresh_token: baseUserCacheSchemas.console_refresh_token,
|
|
100
|
+
console_token_expires_at: baseUserCacheSchemas.console_token_expires_at,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
/** Update schema for UserCache (PUT/PATCH requests) */
|
|
104
|
+
export const baseUserCacheUpdateSchema = baseUserCacheCreateSchema.partial();
|
|
105
|
+
|
|
106
|
+
// ============================================================================
|
|
107
|
+
// Inferred Types
|
|
108
|
+
// ============================================================================
|
|
109
|
+
|
|
110
|
+
export type BaseUserCacheCreate = z.infer<typeof baseUserCacheCreateSchema>;
|
|
111
|
+
export type BaseUserCacheUpdate = z.infer<typeof baseUserCacheUpdateSchema>;
|
|
112
|
+
|
|
113
|
+
// ============================================================================
|
|
114
|
+
// I18n Helper Functions
|
|
115
|
+
// ============================================================================
|
|
116
|
+
|
|
117
|
+
/** Get model label for a specific locale */
|
|
118
|
+
export function getUserCacheLabel(locale: string): string {
|
|
119
|
+
return userCacheI18n.label[locale as keyof typeof userCacheI18n.label] ?? userCacheI18n.label['en'] ?? 'UserCache';
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Get field label for a specific locale */
|
|
123
|
+
export function getUserCacheFieldLabel(field: string, locale: string): string {
|
|
124
|
+
const fieldI18n = userCacheI18n.fields[field as keyof typeof userCacheI18n.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 getUserCacheFieldPlaceholder(field: string, locale: string): string {
|
|
131
|
+
const fieldI18n = userCacheI18n.fields[field as keyof typeof userCacheI18n.fields];
|
|
132
|
+
if (!fieldI18n || !('placeholder' in fieldI18n)) return '';
|
|
133
|
+
const placeholder = fieldI18n.placeholder as Record<string, string>;
|
|
134
|
+
return placeholder[locale] ?? placeholder['en'] ?? '';
|
|
135
|
+
}
|