The road to zero TypeScript errors (#1756)

* Type fixes

* Type fixes

* Type fixes

* Type fixes

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Omar Lópezandkodiakhq[bot] authored and GitHub committed 2022-02-10 10:44:46 +00:00
1 parent 798930bf23
commit 5d0ba3dafc
14 files changed
+54 -53

No files matched your search

+1 -1
View File
@@ -33,7 +33,7 @@ export const symmetricDecrypt = function (text: string, key: string) {
const _key = Buffer.from(key, "latin1");
const components = text.split(":");
const iv_from_ciphertext = Buffer.from(components.shift(), OUTPUT_ENCODING);
const iv_from_ciphertext = Buffer.from(components.shift() || "", OUTPUT_ENCODING);
const decipher = crypto.createDecipheriv(ALGORITHM, _key, iv_from_ciphertext);
let deciphered = decipher.update(components.join(":"), OUTPUT_ENCODING, INPUT_ENCODING);
deciphered += decipher.final(INPUT_ENCODING);
+5 -4
View File
@@ -18,7 +18,7 @@ export interface EventResult {
success: boolean;
uid: string;
createdEvent?: Event;
updatedEvent?: Event;
updatedEvent?: Event | Event[];
originalEvent: CalendarEvent;
}
@@ -207,9 +207,10 @@ export default class EventManager {
// If and only if event type is a dedicated meeting, update the dedicated video meeting.
if (isDedicated) {
const result = await this.updateVideoEvent(evt, booking);
if (result.updatedEvent) {
evt.videoCallData = result.updatedEvent;
evt.location = result.updatedEvent.url;
const [updatedEvent] = Array.isArray(result.updatedEvent) ? result.updatedEvent : [result.updatedEvent];
if (updatedEvent) {
evt.videoCallData = updatedEvent;
evt.location = updatedEvent.url;
}
results.push(result);
}
@@ -8,6 +8,7 @@ import { VideoCallData } from "@lib/videoClient";
import { NewCalendarEventType } from "../constants/types";
import { ConferenceData } from "./GoogleCalendar";
import type { Event } from "@lib/events/EventManager";
export type Person = {
name: string;
@@ -66,7 +67,7 @@ type EventBusyDate = Record<"start" | "end", Date | string>;
export interface Calendar {
createEvent(event: CalendarEvent): Promise<NewCalendarEventType>;
updateEvent(uid: string, event: CalendarEvent): Promise<unknown>;
updateEvent(uid: string, event: CalendarEvent): Promise<Event | Event[]>;
deleteEvent(uid: string, event: CalendarEvent): Promise<unknown>;
@@ -25,6 +25,7 @@ import { CALDAV_CALENDAR_TYPE } from "../constants/generals";
import { CalendarEventType, EventBusyDate, NewCalendarEventType } from "../constants/types";
import { Calendar, CalendarEvent, IntegrationCalendar } from "../interfaces/Calendar";
import { convertDate, getAttendees, getDuration } from "../utils/CalendarUtils";
import type { Event } from "@lib/events/EventManager";
dayjs.extend(utc);
dayjs.extend(timezone);
@@ -121,7 +122,7 @@ export default abstract class BaseCalendarService implements Calendar {
}
}
async updateEvent(uid: string, event: CalendarEvent): Promise<unknown> {
async updateEvent(uid: string, event: CalendarEvent) {
try {
const events = await this.getEventsByUID(uid);
@@ -141,7 +142,12 @@ export default abstract class BaseCalendarService implements Calendar {
if (error) {
this.log.debug("Error creating iCalString");
return {};
return {
type: event.type,
id: typeof event.uid === "string" ? event.uid : "-1",
password: "",
url: typeof event.location === "string" ? event.location : "-1",
};
}
const eventsToUpdate = events.filter((e) => e.uid === uid);
@@ -157,7 +163,7 @@ export default abstract class BaseCalendarService implements Calendar {
headers: this.headers,
});
})
);
).then((p) => p.map((r) => r.json() as unknown as Event));
} catch (reason) {
this.log.error(reason);
+4 -4
View File
@@ -23,22 +23,22 @@ export function parseZone(
date,
{
utc: true,
...format,
...(typeof format === "string" ? { format } : { ...format }),
},
locale,
strict
);
}
const [, dateTime, sign, tzHour, tzMinute] = match;
const uOffset: number = tzHour * 60 + parseInt(tzMinute, 10);
const uOffset: number = parseInt(tzHour) * 60 + parseInt(tzMinute, 10);
const offset = sign === "+" ? uOffset : -uOffset;
return dayjs(
dateTime,
{
$offset: offset,
...format,
} as dayjs.OptionType,
...(typeof format === "string" ? { format } : { ...format }),
} as dayjs.OptionType & { $offset: number },
locale,
strict
);
+5 -2
View File
@@ -1,10 +1,13 @@
function detectTransport(): string | any {
import SendmailTransport from "nodemailer/lib/sendmail-transport";
import SMTPConnection from "nodemailer/lib/smtp-connection";
function detectTransport(): SendmailTransport.Options | SMTPConnection.Options | string {
if (process.env.EMAIL_SERVER) {
return process.env.EMAIL_SERVER;
}
if (process.env.EMAIL_SERVER_HOST) {
const port = parseInt(process.env.EMAIL_SERVER_PORT);
const port = parseInt(process.env.EMAIL_SERVER_PORT!);
const transport = {
host: process.env.EMAIL_SERVER_HOST,
port,