feat: add weather widget (#286)
* feat: add nestjs replacement, remove nestjs * feat: add weather widget * fix: lock issue * fix: format issue * fix: deepsource issues * fix: change timezone to auto
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
import { appSchemas } from "./app";
|
||||
import { boardSchemas } from "./board";
|
||||
import { integrationSchemas } from "./integration";
|
||||
import { locationSchemas } from "./location";
|
||||
import { userSchemas } from "./user";
|
||||
import { widgetSchemas } from "./widgets";
|
||||
|
||||
export const validation = {
|
||||
user: userSchemas,
|
||||
integration: integrationSchemas,
|
||||
board: boardSchemas,
|
||||
app: appSchemas,
|
||||
widget: widgetSchemas,
|
||||
location: locationSchemas,
|
||||
};
|
||||
|
||||
export { createSectionSchema, sharedItemSchema } from "./shared";
|
||||
|
||||
26
packages/validation/src/location.ts
Normal file
26
packages/validation/src/location.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { z } from "zod";
|
||||
|
||||
const citySchema = z.object({
|
||||
id: z.number(),
|
||||
name: z.string(),
|
||||
country: z.string().optional(),
|
||||
country_code: z.string().optional(),
|
||||
latitude: z.number(),
|
||||
longitude: z.number(),
|
||||
population: z.number().optional(),
|
||||
});
|
||||
|
||||
const searchCityInput = z.object({
|
||||
query: z.string(),
|
||||
});
|
||||
|
||||
const searchCityOutput = z.object({
|
||||
results: z.array(citySchema),
|
||||
});
|
||||
|
||||
export const locationSchemas = {
|
||||
searchCity: {
|
||||
input: searchCityInput,
|
||||
output: searchCityOutput,
|
||||
},
|
||||
};
|
||||
5
packages/validation/src/widgets/index.ts
Normal file
5
packages/validation/src/widgets/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { weatherWidgetSchemas } from "./weather";
|
||||
|
||||
export const widgetSchemas = {
|
||||
weather: weatherWidgetSchemas,
|
||||
};
|
||||
24
packages/validation/src/widgets/weather.ts
Normal file
24
packages/validation/src/widgets/weather.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const atLocationInput = z.object({
|
||||
longitude: z.number(),
|
||||
latitude: z.number(),
|
||||
});
|
||||
|
||||
export const atLocationOutput = z.object({
|
||||
current_weather: z.object({
|
||||
weathercode: z.number(),
|
||||
temperature: z.number(),
|
||||
}),
|
||||
daily: z.object({
|
||||
time: z.array(z.string()),
|
||||
weathercode: z.array(z.number()),
|
||||
temperature_2m_max: z.array(z.number()),
|
||||
temperature_2m_min: z.array(z.number()),
|
||||
}),
|
||||
});
|
||||
|
||||
export const weatherWidgetSchemas = {
|
||||
atLocationInput,
|
||||
atLocationOutput,
|
||||
};
|
||||
Reference in New Issue
Block a user