Skip to content

Commit

Permalink
Merge pull request #135 from terijaki/master
Browse files Browse the repository at this point in the history
add support for X-WR-CALNAME
  • Loading branch information
timheerwagen authored Jan 6, 2025
2 parents eb5cfc0 + 58ba9da commit 7d5d3c5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
21 changes: 12 additions & 9 deletions packages/ts-ics/src/constants/keys/calendar.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
export const VCALENDAR_KEYS = ["VERSION", "METHOD", "PRODID"] as const;
export const VCALENDAR_KEYS = ["VERSION", "METHOD", "PRODID", "X-WR-CALNAME"] as const;
export type VCalendarKeys = typeof VCALENDAR_KEYS;
export type VCalendarKey = VCalendarKeys[number];

export const VCALENDAR_OBJECT_KEYS = ["version", "method", "prodId"] as const;
export const VCALENDAR_OBJECT_KEYS = ["version", "method", "prodId", "name"] as const;

export type VCalendarObjectKeys = typeof VCALENDAR_OBJECT_KEYS;
export type VCalendarObjectKey = VCalendarObjectKeys[number];

export const VCALENDAR_TO_OBJECT_KEYS: Record<
VCalendarKey,
VCalendarObjectKey
> = { METHOD: "method", PRODID: "prodId", VERSION: "version" };
export const VCALENDAR_TO_OBJECT_KEYS: Record<VCalendarKey, VCalendarObjectKey> = {
METHOD: "method",
PRODID: "prodId",
VERSION: "version",
"X-WR-CALNAME": "name",
};

export const VCALENDAR_TO_KEYS: Record<VCalendarObjectKey, VCalendarKey> = {
method: "METHOD",
prodId: "PRODID",
version: "VERSION",
method: "METHOD",
prodId: "PRODID",
version: "VERSION",
name: "X-WR-CALNAME",
};
22 changes: 12 additions & 10 deletions packages/ts-ics/src/types/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@ export type VCalendarMethods = typeof zVCalendarMethods;
export type VCalenderMethod = VCalendarMethods[number];

export type VCalendar = {
version: "2.0";
prodId: string;
method?: VCalenderMethod | string;
timezones?: VTimezone[];
events?: VEvent[];
version: "2.0";
prodId: string;
method?: VCalenderMethod | string;
timezones?: VTimezone[];
events?: VEvent[];
name?: string;
};

export const zVCalendar: z.ZodType<VCalendar> = z.object({
version: z.literal("2.0"),
prodId: z.string(),
method: z.union([z.enum(zVCalendarMethods), z.string()]).optional(),
timezones: z.array(zVTimezone).optional(),
events: z.array(zVEvent).optional(),
version: z.literal("2.0"),
prodId: z.string(),
method: z.union([z.enum(zVCalendarMethods), z.string()]).optional(),
timezones: z.array(zVTimezone).optional(),
events: z.array(zVEvent).optional(),
name: z.string().optional(),
});

0 comments on commit 7d5d3c5

Please sign in to comment.