Skip to content

Commit

Permalink
made the schema even more forgiving so that the app does not break..
Browse files Browse the repository at this point in the history
  • Loading branch information
aerotow committed Sep 16, 2024
1 parent a090b47 commit 9e18c04
Showing 1 changed file with 30 additions and 41 deletions.
71 changes: 30 additions & 41 deletions src/server/eight/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,47 +25,36 @@ export const DeviceListSchema = z.object({

export const UserProfileSchema = z.object({
user: z.object({
userId: z.string(),
email: z.string().email(),
firstName: z.string(),
lastName: z.string(),
gender: z.enum(["male", "female", "other"]).optional(),
tempPreference: z.enum(["cool", "warm", "neutral"]).optional(),
tempPreferenceUpdatedAt: z.string().optional(),
dob: z.string().optional(),
zip: z.number().optional(),
devices: z.array(z.string()),
emailVerified: z.boolean().optional(),
sharingMetricsTo: z.array(z.unknown()).optional(),
sharingMetricsFrom: z.array(z.unknown()).optional(),
notifications: z.object({
weeklyReportEmail: z.boolean(),
sessionProcessed: z.boolean(),
temperatureRecommendation: z.boolean(),
healthInsight: z.boolean(),
sleepInsight: z.boolean(),
marketingUpdates: z.boolean(),
bedtimeReminder: z.boolean(),
alarmWakeupPush: z.boolean(),
}).optional(),
createdAt: z.string().optional(),
experimentalFeatures: z.boolean().optional(),
autopilotEnabled: z.boolean().optional(),
lastReset: z.string().optional(),
nextReset: z.string().optional(),
sleepTracking: z.object({
enabledSince: z.string(),
}).optional(),
features: z.array(
z.enum(["warming", "cooling", "vibration", "tapControls"]),
).optional(),
currentDevice: z.object({
id: z.string(),
side: z.enum(["left", "right"]),
timeZone: z.string(),
}),
hotelGuest: z.boolean().optional(),
}),
userId: z.string().optional(),
email: z.string().optional(),
firstName: z.string().optional(),
lastName: z.string().optional(),
gender: z.string().optional(),
tempPreference: z.string().optional(),
tempPreferenceUpdatedAt: z.string().optional(),
dob: z.string().optional(),
zip: z.number().optional(),
devices: z.array(z.string()),
emailVerified: z.boolean().optional(),
sharingMetricsTo: z.array(z.unknown()).optional(),
sharingMetricsFrom: z.array(z.unknown()).optional(),
notifications: z.record(z.boolean()).optional(),
createdAt: z.string().optional(),
experimentalFeatures: z.boolean().optional(),
autopilotEnabled: z.boolean().optional(),
lastReset: z.string().optional(),
nextReset: z.string().optional(),
sleepTracking: z.object({
enabledSince: z.string().optional(),
}).optional(),
features: z.array(z.string()).optional(),
currentDevice: z.object({
id: z.string(),
side: z.string(),
timeZone: z.string(),
}),
hotelGuest: z.boolean().optional(),
}).catchall(z.unknown()),
});

export const DeviceDataSchema = z.object({
Expand Down

0 comments on commit 9e18c04

Please sign in to comment.