import * as v from "valibot" export const notionDateReminderSchema = v.object({ unit: v.picklist(["year", "month", "week", "day"]), value: v.number(), time: v.string(), defaultTimeZone: v.optional(v.string()), }) export type NotionDateReminder = v.InferOutput export const notionTimeReminderSchema = v.object({ unit: v.picklist(["hour", "minute"]), value: v.number(), }) export type NotionTimeReminder = v.InferOutput export const notionNoReminderSchema = v.object({ unit: v.literal("none"), }) export type NotionNoReminder = v.InferOutput /** * Possible types for a Notion `datetime` reminder. */ export const notionDateTimeReminderSchema = v.union([ notionDateReminderSchema, notionTimeReminderSchema, ]) export type NotionDateTimeReminder = v.InferOutput< typeof notionDateTimeReminderSchema > const dateOrNoReminder = v.optional( v.union([notionDateReminderSchema, notionNoReminderSchema]), ) const dateTimeOrNoReminder = v.optional( v.union([notionDateTimeReminderSchema, notionNoReminderSchema]), ) export const notionDateSchema = v.object({ type: v.literal("date"), start_date: v.string(), reminder: dateOrNoReminder, }) export type NotionDate = v.InferOutput export const notionDateRangeSchema = v.object({ type: v.literal("daterange"), start_date: v.string(), end_date: v.string(), reminder: dateOrNoReminder, }) export type NotionDateRange = v.InferOutput export const notionDateTimeSchema = v.object({ type: v.literal("datetime"), start_date: v.string(), start_time: v.string(), time_zone: v.optional(v.string()), reminder: dateTimeOrNoReminder, }) export type NotionDateTime = v.InferOutput export const notionDateTimeRangeSchema = v.object({ type: v.literal("datetimerange"), start_date: v.string(), start_time: v.string(), end_date: v.string(), end_time: v.string(), time_zone: v.optional(v.string()), reminder: dateTimeOrNoReminder, }) export type NotionDateTimeRange = v.InferOutput< typeof notionDateTimeRangeSchema > /** * Possible types for a Notion `date` value. */ export const notionDateValueSchema = v.variant("type", [ notionDateSchema, notionDateRangeSchema, notionDateTimeSchema, notionDateTimeRangeSchema, ]) export type NotionDateValue = Readonly< v.InferOutput >