Future proof schemas by making them nonstrict
This commit is contained in:
parent
75476bce86
commit
b92996f1d5
@ -24,7 +24,7 @@ const EventSchema = object({
|
||||
origin_server_ts: string(),
|
||||
unsigned: object({}).nonstrict().optional(),
|
||||
room_id: string(),
|
||||
});
|
||||
}).nonstrict();
|
||||
|
||||
export type Event = TypeOf<typeof EventSchema>;
|
||||
export default EventSchema;
|
||||
|
@ -26,18 +26,16 @@ export const RoomSchema = object({
|
||||
world_readable: boolean(),
|
||||
guest_can_join: boolean(),
|
||||
avatar_url: string().optional(),
|
||||
});
|
||||
|
||||
}).nonstrict();
|
||||
|
||||
const PublicRoomsSchema = object({
|
||||
chunk: array(RoomSchema),
|
||||
next_batch: string().optional(),
|
||||
prev_batch: string().optional(),
|
||||
total_room_count_estimate: number().optional(),
|
||||
});
|
||||
}).nonstrict();
|
||||
|
||||
export type Room = TypeOf<typeof RoomSchema>;
|
||||
export type PublicRooms = TypeOf<typeof PublicRoomsSchema>;
|
||||
|
||||
export default PublicRoomsSchema;
|
||||
|
||||
|
@ -19,8 +19,7 @@ import { object, array, string, TypeOf } from 'zod';
|
||||
const RoomAliasSchema = object({
|
||||
room_id: string(),
|
||||
servers: array(string()),
|
||||
});
|
||||
}).nonstrict();
|
||||
|
||||
export type RoomAlias = TypeOf<typeof RoomAliasSchema>;
|
||||
export default RoomAliasSchema;
|
||||
|
||||
|
@ -19,8 +19,7 @@ import { object, string, TypeOf } from 'zod';
|
||||
const UserSchema = object({
|
||||
avatar_url: string().optional(),
|
||||
displayname: string().optional(),
|
||||
})
|
||||
}).nonstrict();
|
||||
|
||||
export type User = TypeOf<typeof UserSchema>;
|
||||
export default UserSchema;
|
||||
|
||||
|
@ -18,12 +18,12 @@ import { object, string, TypeOf } from 'zod';
|
||||
|
||||
const WellKnownSchema = object({
|
||||
'm.homeserver': object({
|
||||
'base_url': string().url(),
|
||||
base_url: string().url(),
|
||||
}),
|
||||
'm.identity_server': object({
|
||||
'base_url': string().url(),
|
||||
}),
|
||||
});
|
||||
base_url: string().url(),
|
||||
}).optional(),
|
||||
}).nonstrict();
|
||||
|
||||
export type WellKnown = TypeOf<typeof WellKnownSchema>;
|
||||
export default WellKnownSchema;
|
||||
|
Loading…
Reference in New Issue
Block a user