11import { z } from 'zod' ;
22
3- /**
3+ /**
44 * Zod schema for ChatWork Room object
55 * @see https://developer.chatwork.com/reference/get-rooms
66 */
77export const roomSchema = z . object ( {
8- room_id : z
9- . number ( )
10- . int ( )
11- . positive ( )
12- . describe ( 'ルームID' ) ,
13-
14- name : z
15- . string ( )
16- . min ( 1 )
17- . describe ( 'ルーム名' ) ,
18-
8+ room_id : z . number ( ) . int ( ) . positive ( ) . describe ( 'ルームID' ) ,
9+
10+ name : z . string ( ) . min ( 1 ) . describe ( 'ルーム名' ) ,
11+
1912 type : z
2013 . enum ( [ 'my' , 'direct' , 'group' ] )
21- . describe ( 'ルームタイプ (my: マイチャット, direct: ダイレクトチャット, group: グループチャット)' ) ,
22-
14+ . describe (
15+ 'ルームタイプ (my: マイチャット, direct: ダイレクトチャット, group: グループチャット)' ,
16+ ) ,
17+
2318 role : z
2419 . enum ( [ 'admin' , 'member' , 'readonly' ] )
25- . describe ( 'ルールでの自分の権限 (admin: 管理者, member: メンバー, readonly: 閲覧のみ)' ) ,
26-
27- sticky : z
28- . boolean ( )
29- . describe ( 'スティッキー (お気に入り) 設定' ) ,
30-
31- unread_num : z
32- . number ( )
33- . int ( )
34- . min ( 0 )
35- . describe ( '未読メッセージ数' ) ,
36-
37- mention_num : z
38- . number ( )
39- . int ( )
40- . min ( 0 )
41- . describe ( '自分宛てのメンション数' ) ,
42-
43- mytask_num : z
44- . number ( )
45- . int ( )
46- . min ( 0 )
47- . describe ( '自分が担当者のタスク数' ) ,
48-
49- message_num : z
50- . number ( )
51- . int ( )
52- . min ( 0 )
53- . describe ( '総メッセージ数' ) ,
54-
55- file_num : z
56- . number ( )
57- . int ( )
58- . min ( 0 )
59- . describe ( 'ファイル数' ) ,
60-
61- task_num : z
62- . number ( )
63- . int ( )
64- . min ( 0 )
65- . describe ( 'タスク数' ) ,
66-
67- icon_path : z
68- . string ( )
69- . url ( )
70- . describe ( 'ルームアイコンのURL' ) ,
71-
20+ . describe (
21+ 'ルールでの自分の権限 (admin: 管理者, member: メンバー, readonly: 閲覧のみ)' ,
22+ ) ,
23+
24+ sticky : z . boolean ( ) . describe ( 'スティッキー (お気に入り) 設定' ) ,
25+
26+ unread_num : z . number ( ) . int ( ) . min ( 0 ) . describe ( '未読メッセージ数' ) ,
27+
28+ mention_num : z . number ( ) . int ( ) . min ( 0 ) . describe ( '自分宛てのメンション数' ) ,
29+
30+ mytask_num : z . number ( ) . int ( ) . min ( 0 ) . describe ( '自分が担当者のタスク数' ) ,
31+
32+ message_num : z . number ( ) . int ( ) . min ( 0 ) . describe ( '総メッセージ数' ) ,
33+
34+ file_num : z . number ( ) . int ( ) . min ( 0 ) . describe ( 'ファイル数' ) ,
35+
36+ task_num : z . number ( ) . int ( ) . min ( 0 ) . describe ( 'タスク数' ) ,
37+
38+ icon_path : z . string ( ) . url ( ) . describe ( 'ルームアイコンのURL' ) ,
39+
7240 last_update_time : z
7341 . number ( )
7442 . int ( )
@@ -108,4 +76,4 @@ export const safeValidateRoom = (data: unknown): Room | null => {
10876export const safeValidateRoomsArray = ( data : unknown ) : Room [ ] | null => {
10977 const result = roomsArraySchema . safeParse ( data ) ;
11078 return result . success ? result . data : null ;
111- } ;
79+ } ;
0 commit comments