Consolidates dayjs in a single package
This commit is contained in:
1 parent
5be669a479
commit
7122a4a91d
80 files changed
+120
-299
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { WebClient } from "@slack/web-api";
|
||||
import dayjs from "dayjs";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
import { z } from "zod";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { BookingStatus } from "@prisma/client";
|
||||
import dayjs from "dayjs";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
|
||||
import prisma from "@calcom/prisma";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createHmac } from "crypto";
|
||||
import dayjs from "dayjs";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
import { stringify } from "querystring";
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import dayjs from "dayjs";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { Blocks, Elements, Message } from "slack-block-builder";
|
||||
|
||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Booking } from "@prisma/client";
|
||||
import dayjs from "dayjs";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { Blocks, Elements, Message } from "slack-block-builder";
|
||||
|
||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { BookingStatus, Prisma } from "@prisma/client";
|
||||
import dayjs from "dayjs";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
import queue from "queue";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Booking, BookingReference, BookingStatus, User } from "@prisma/client";
|
||||
import dayjs from "dayjs";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import type { TFunction } from "next-i18next";
|
||||
|
||||
import EventManager from "@calcom/core/EventManager";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ClockIcon, XIcon } from "@heroicons/react/outline";
|
||||
import dayjs from "dayjs";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { Dispatch, SetStateAction } from "react";
|
||||
import { useState } from "react";
|
||||
import { useMutation } from "react-query";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Booking, BookingReference, BookingStatus, User } from "@prisma/client";
|
||||
import dayjs from "dayjs";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import type { TFunction } from "next-i18next";
|
||||
|
||||
import EventManager from "@calcom/core/EventManager";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Prisma, Booking } from "@prisma/client";
|
||||
import dayjs from "dayjs";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import short from "short-uuid";
|
||||
import { v5 as uuidv5 } from "uuid";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Prisma } from "@prisma/client";
|
||||
import dayjs, { Dayjs } from "dayjs";
|
||||
import dayjs, { Dayjs } from "@calcom/dayjs";
|
||||
import { z } from "zod";
|
||||
|
||||
import { getWorkingHours } from "@calcom/lib/availability";
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@calcom/app-store": "*",
|
||||
"@calcom/dayjs": "*",
|
||||
"@calcom/lib": "*",
|
||||
"dayjs": "^1.11.2",
|
||||
"ical.js": "^1.4.0",
|
||||
"ics": "^2.31.0",
|
||||
"uuid": "^8.3.2"
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import dayjs from "dayjs";
|
||||
import dayjsBusinessTime from "dayjs-business-days2";
|
||||
import customParseFormat from "dayjs/plugin/customParseFormat";
|
||||
import isBetween from "dayjs/plugin/isBetween";
|
||||
import isToday from "dayjs/plugin/isToday";
|
||||
import localizedFormat from "dayjs/plugin/localizedFormat";
|
||||
import relativeTime from "dayjs/plugin/relativeTime";
|
||||
import timeZone from "dayjs/plugin/timezone";
|
||||
import toArray from "dayjs/plugin/toArray";
|
||||
import utc from "dayjs/plugin/utc";
|
||||
|
||||
dayjs.extend(customParseFormat);
|
||||
dayjs.extend(dayjsBusinessTime);
|
||||
dayjs.extend(isBetween);
|
||||
dayjs.extend(isToday);
|
||||
dayjs.extend(localizedFormat);
|
||||
dayjs.extend(relativeTime);
|
||||
dayjs.extend(timeZone);
|
||||
dayjs.extend(toArray);
|
||||
dayjs.extend(utc);
|
||||
|
||||
export type Dayjs = dayjs.Dayjs;
|
||||
|
||||
export type { ConfigType } from "dayjs";
|
||||
|
||||
export default dayjs;
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "@calcom/dayjs",
|
||||
"description": "Cal.com's Day.js shared library",
|
||||
"version": "1.0.0",
|
||||
"main": "./index.ts",
|
||||
"dependencies": {
|
||||
"dayjs": "^1.11.2",
|
||||
"dayjs-business-days2": "^1.1.0"
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,8 @@
|
||||
"private": true,
|
||||
"scripts": {},
|
||||
"dependencies": {
|
||||
"@calcom/dayjs": "*",
|
||||
"@calcom/lib": "*",
|
||||
"dayjs": "^1.11.2",
|
||||
"next-i18next": "^11.0.0",
|
||||
"rrule": "^2.6.9"
|
||||
},
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
import dayjs from "dayjs";
|
||||
import timezone from "dayjs/plugin/timezone";
|
||||
import { TFunction } from "next-i18next";
|
||||
import rrule from "rrule";
|
||||
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { getEveryFreqFor } from "@calcom/lib/recurringStrings";
|
||||
import type { CalendarEvent } from "@calcom/types/Calendar";
|
||||
import { RecurringEvent } from "@calcom/types/Calendar";
|
||||
|
||||
import { Info } from "./Info";
|
||||
|
||||
dayjs.extend(timezone);
|
||||
|
||||
function getRecurringWhen({ calEvent }: { calEvent: CalendarEvent }) {
|
||||
if (calEvent.recurringEvent) {
|
||||
const t = calEvent.attendees[0].language.translate;
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import dayjs from "dayjs";
|
||||
import localizedFormat from "dayjs/plugin/localizedFormat";
|
||||
import timezone from "dayjs/plugin/timezone";
|
||||
import toArray from "dayjs/plugin/toArray";
|
||||
import utc from "dayjs/plugin/utc";
|
||||
import type { TFunction } from "next-i18next";
|
||||
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import type { CalendarEvent, Person } from "@calcom/types/Calendar";
|
||||
|
||||
import {
|
||||
@@ -17,11 +13,6 @@ import {
|
||||
WhoInfo,
|
||||
} from "../components";
|
||||
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(timezone);
|
||||
dayjs.extend(localizedFormat);
|
||||
dayjs.extend(toArray);
|
||||
|
||||
export const BaseScheduledEmail = (
|
||||
props: {
|
||||
calEvent: CalendarEvent;
|
||||
|
||||
@@ -1,18 +1,9 @@
|
||||
import dayjs, { Dayjs } from "dayjs";
|
||||
import localizedFormat from "dayjs/plugin/localizedFormat";
|
||||
import timezone from "dayjs/plugin/timezone";
|
||||
import toArray from "dayjs/plugin/toArray";
|
||||
import utc from "dayjs/plugin/utc";
|
||||
import nodemailer from "nodemailer";
|
||||
|
||||
import dayjs, { Dayjs } from "@calcom/dayjs";
|
||||
import { getErrorFromUnknown } from "@calcom/lib/errors";
|
||||
import { serverConfig } from "@calcom/lib/serverConfig";
|
||||
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(timezone);
|
||||
dayjs.extend(localizedFormat);
|
||||
dayjs.extend(toArray);
|
||||
|
||||
export default class BaseEmail {
|
||||
name = "";
|
||||
|
||||
|
||||
@@ -1,21 +1,12 @@
|
||||
import dayjs from "dayjs";
|
||||
import localizedFormat from "dayjs/plugin/localizedFormat";
|
||||
import timezone from "dayjs/plugin/timezone";
|
||||
import toArray from "dayjs/plugin/toArray";
|
||||
import utc from "dayjs/plugin/utc";
|
||||
import { createEvent, DateArray, Person } from "ics";
|
||||
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { getCancelLink } from "@calcom/lib/CalEventParser";
|
||||
import { CalendarEvent } from "@calcom/types/Calendar";
|
||||
|
||||
import { renderEmail } from "../";
|
||||
import OrganizerScheduledEmail from "./organizer-scheduled-email";
|
||||
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(timezone);
|
||||
dayjs.extend(localizedFormat);
|
||||
dayjs.extend(toArray);
|
||||
|
||||
export default class AttendeeRequestRescheduledEmail extends OrganizerScheduledEmail {
|
||||
private metadata: { rescheduleLink: string };
|
||||
constructor(calEvent: CalendarEvent, metadata: { rescheduleLink: string }) {
|
||||
|
||||
@@ -1,23 +1,14 @@
|
||||
import dayjs from "dayjs";
|
||||
import localizedFormat from "dayjs/plugin/localizedFormat";
|
||||
import timezone from "dayjs/plugin/timezone";
|
||||
import toArray from "dayjs/plugin/toArray";
|
||||
import utc from "dayjs/plugin/utc";
|
||||
import { createEvent, DateArray } from "ics";
|
||||
import { TFunction } from "next-i18next";
|
||||
import rrule from "rrule";
|
||||
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { getRichDescription } from "@calcom/lib/CalEventParser";
|
||||
import type { CalendarEvent, Person } from "@calcom/types/Calendar";
|
||||
|
||||
import { renderEmail } from "../";
|
||||
import BaseEmail from "./_base-email";
|
||||
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(timezone);
|
||||
dayjs.extend(localizedFormat);
|
||||
dayjs.extend(toArray);
|
||||
|
||||
export default class AttendeeScheduledEmail extends BaseEmail {
|
||||
calEvent: CalendarEvent;
|
||||
attendee: Person;
|
||||
|
||||
@@ -1,11 +1,4 @@
|
||||
import dayjs from "dayjs";
|
||||
import localizedFormat from "dayjs/plugin/localizedFormat";
|
||||
import timezone from "dayjs/plugin/timezone";
|
||||
import toArray from "dayjs/plugin/toArray";
|
||||
import utc from "dayjs/plugin/utc";
|
||||
import { createEvent, DateArray, Person } from "ics";
|
||||
import { TFunction } from "next-i18next";
|
||||
import rrule from "rrule";
|
||||
|
||||
import { getRichDescription } from "@calcom/lib/CalEventParser";
|
||||
import type { CalendarEvent } from "@calcom/types/Calendar";
|
||||
@@ -13,11 +6,6 @@ import type { CalendarEvent } from "@calcom/types/Calendar";
|
||||
import { renderEmail } from "..";
|
||||
import BaseEmail from "./_base-email";
|
||||
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(timezone);
|
||||
dayjs.extend(localizedFormat);
|
||||
dayjs.extend(toArray);
|
||||
|
||||
export default class BrokenIntegrationEmail extends BaseEmail {
|
||||
type: "calendar" | "video";
|
||||
calEvent: CalendarEvent;
|
||||
|
||||
@@ -1,20 +1,11 @@
|
||||
import dayjs from "dayjs";
|
||||
import localizedFormat from "dayjs/plugin/localizedFormat";
|
||||
import timezone from "dayjs/plugin/timezone";
|
||||
import toArray from "dayjs/plugin/toArray";
|
||||
import utc from "dayjs/plugin/utc";
|
||||
import { createEvent, DateArray, Person } from "ics";
|
||||
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { CalendarEvent } from "@calcom/types/Calendar";
|
||||
|
||||
import { renderEmail } from "../";
|
||||
import OrganizerScheduledEmail from "./organizer-scheduled-email";
|
||||
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(timezone);
|
||||
dayjs.extend(localizedFormat);
|
||||
dayjs.extend(toArray);
|
||||
|
||||
export default class OrganizerRequestRescheduledEmail extends OrganizerScheduledEmail {
|
||||
private metadata: { rescheduleLink: string };
|
||||
constructor(calEvent: CalendarEvent, metadata: { rescheduleLink: string }) {
|
||||
|
||||
@@ -1,23 +1,14 @@
|
||||
import dayjs from "dayjs";
|
||||
import localizedFormat from "dayjs/plugin/localizedFormat";
|
||||
import timezone from "dayjs/plugin/timezone";
|
||||
import toArray from "dayjs/plugin/toArray";
|
||||
import utc from "dayjs/plugin/utc";
|
||||
import { createEvent, DateArray, Person } from "ics";
|
||||
import { TFunction } from "next-i18next";
|
||||
import rrule from "rrule";
|
||||
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { getRichDescription } from "@calcom/lib/CalEventParser";
|
||||
import type { CalendarEvent } from "@calcom/types/Calendar";
|
||||
|
||||
import { renderEmail } from "../";
|
||||
import BaseEmail from "./_base-email";
|
||||
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(timezone);
|
||||
dayjs.extend(localizedFormat);
|
||||
dayjs.extend(toArray);
|
||||
|
||||
export default class OrganizerScheduledEmail extends BaseEmail {
|
||||
calEvent: CalendarEvent;
|
||||
t: TFunction;
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
/// <reference path="../types/ical.d.ts"/>
|
||||
import { Credential, Prisma } from "@prisma/client";
|
||||
import dayjs from "dayjs";
|
||||
import isBetween from "dayjs/plugin/isBetween";
|
||||
import timezone from "dayjs/plugin/timezone";
|
||||
import utc from "dayjs/plugin/utc";
|
||||
import ICAL from "ical.js";
|
||||
import { Attendee, createEvent, DateArray, DurationObject, Person } from "ics";
|
||||
import {
|
||||
@@ -18,6 +14,7 @@ import {
|
||||
} from "tsdav";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import type {
|
||||
Calendar,
|
||||
CalendarEvent,
|
||||
@@ -35,10 +32,6 @@ import logger from "./logger";
|
||||
const TIMEZONE_FORMAT = "YYYY-MM-DDTHH:mm:ss[Z]";
|
||||
const DEFAULT_CALENDAR_TYPE = "caldav";
|
||||
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(timezone);
|
||||
dayjs.extend(isBetween);
|
||||
|
||||
const CALENDSO_ENCRYPTION_KEY = process.env.CALENDSO_ENCRYPTION_KEY || "";
|
||||
|
||||
const convertDate = (date: string): DateArray =>
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
import type { Availability } from "@prisma/client";
|
||||
import dayjs, { ConfigType } from "dayjs";
|
||||
import customParseFormat from "dayjs/plugin/customParseFormat";
|
||||
import timezone from "dayjs/plugin/timezone";
|
||||
import utc from "dayjs/plugin/utc";
|
||||
|
||||
import dayjs, { ConfigType } from "@calcom/dayjs";
|
||||
import type { Schedule, TimeRange, WorkingHours } from "@calcom/types/schedule";
|
||||
|
||||
import { nameOfDay } from "./weekday";
|
||||
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(timezone);
|
||||
dayjs.extend(customParseFormat);
|
||||
// sets the desired time in current date, needs to be current date for proper DST translation
|
||||
export const defaultDayRange: TimeRange = {
|
||||
start: new Date(new Date().setUTCHours(9, 0, 0, 0)),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import dayjs, { Dayjs } from "dayjs";
|
||||
import dayjs, { Dayjs } from "@calcom/dayjs";
|
||||
|
||||
// converts a date to 2022-04-25 for example.
|
||||
export const yyyymmdd = (date: Date | Dayjs) =>
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
"types": "./index.ts",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@calcom/dayjs": "*",
|
||||
"@prisma/client": "^3.15.2",
|
||||
"bcryptjs": "^2.4.3",
|
||||
"dayjs": "^1.11.2",
|
||||
"ical.js": "^1.4.0",
|
||||
"ics": "^2.31.0",
|
||||
"next-i18next": "^11.0.0",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { BookingStatus, MembershipRole, Prisma, UserPlan } from "@prisma/client";
|
||||
import dayjs from "dayjs";
|
||||
import { uuid } from "short-uuid";
|
||||
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { hashPassword } from "@calcom/lib/auth";
|
||||
import { DEFAULT_SCHEDULE, getAvailabilityFromSchedule } from "@calcom/lib/availability";
|
||||
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
import dayjs from "dayjs";
|
||||
import timezone from "dayjs/plugin/timezone";
|
||||
import utc from "dayjs/plugin/utc";
|
||||
import { z } from "zod";
|
||||
|
||||
import { LocationType } from "@calcom/core/location";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { slugify } from "@calcom/lib/slugify";
|
||||
|
||||
//
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(timezone);
|
||||
|
||||
// Let's not import 118kb just to get an enum
|
||||
export enum Frequency {
|
||||
YEARLY = 0,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env ts-node
|
||||
// To run this script: `yarn downgrade 2>&1 | tee result.log`
|
||||
import { Prisma, UserPlan } from "@prisma/client";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { TRIAL_LIMIT_DAYS } from "@calcom/lib/constants";
|
||||
import prisma from "@calcom/prisma";
|
||||
import stripe from "@calcom/stripe/server";
|
||||
|
||||
@@ -11,11 +11,11 @@
|
||||
"ts-node": "^10.6.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@calcom/dayjs": "*",
|
||||
"@calcom/ee": "*",
|
||||
"@calcom/lib": "*",
|
||||
"@stripe/react-stripe-js": "^1.8.0",
|
||||
"@stripe/stripe-js": "^1.29.0",
|
||||
"dayjs": "^1.11.2",
|
||||
"stripe": "^9.1.0"
|
||||
},
|
||||
"main": "index.ts",
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import { ChevronLeftIcon, ChevronRightIcon } from "@heroicons/react/solid";
|
||||
import dayjs, { Dayjs } from "dayjs";
|
||||
import isToday from "dayjs/plugin/isToday";
|
||||
|
||||
import dayjs, { Dayjs } from "@calcom/dayjs";
|
||||
import classNames from "@calcom/lib/classNames";
|
||||
import { daysInMonth, yyyymmdd } from "@calcom/lib/date-fns";
|
||||
import { weekdayNames } from "@calcom/lib/weekday";
|
||||
import { SkeletonText } from "@calcom/ui/skeleton";
|
||||
|
||||
dayjs.extend(isToday);
|
||||
|
||||
export type DatePickerProps = {
|
||||
/** which day of the week to render the calendar. Usually Sunday (=0) or Monday (=1) - default: Sunday */
|
||||
weekStart?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
||||
|
||||
Reference in new issue
Block a user