2
0

first commit

This commit is contained in:
2024-08-09 00:39:27 +02:00
commit 79688abe2e
5698 changed files with 497838 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
## 0.0.20
In event-types create handler (packages/trpc/server/routers/viewer/eventTypes/create.handler.ts) enable passing scheduleId so that when an event type is created it can be connected
to a specific schedule.
## 0.0.19
Added - create event type handler was [updated](https://github.com/calcom/cal.com/pull/15774) for system admins not to be required
to be part of org team when creating event type for team. Update libraries to include these changes.

View File

@@ -0,0 +1,42 @@
# How to work with platform libraries in Dev
whenever you want to change anything in platform libraries, or if you modify the code of one of the functions imported in libraries you will need to build the code again.
first thing to know is that we version this package using NPM
https://www.npmjs.com/package/@calcom/platform-libraries?activeTab=code
In order to work using the locally built platform libraries you need to:
- in packages/platform/libraries/package.json set the version to for example 1.2.3
- in apps/api/v2/package.json add to dependencies:
"@calcom/platform-libraries-1.2.3": "npm:@calcom/platform-libraries@1.2.3"
- in api v2 code simply import using the new alias:
import {
getAllUserBookings as getAllUserBookings1.2.3,
} from "@calcom/platform-libraries-1.2.3";
since the versions are matching in both package.json yarn will try to use the locally built code
now go to packages/platform/libraries and do
- yarn build:dev
then go back to /apps/api/v2 and run
- yarn
- yarn dev
# Before Merging to main
- Publish Your Version of Libraries on NPM:
- To publish, ensure you are a contributor to the platform libraries' NPM package.
- Authenticate yourself via the CLI using npm auth.
- Increment the version number accordingly.
- Run yarn publish to publish your version.
- Once it's published, change back the version in packages/platform/libraries/package.json back to 0.0.0
- Run yarn
- You should now be using the npm package instead of the locally built version

View File

@@ -0,0 +1,111 @@
import { getCalendar } from "@calcom/app-store/_utils/getCalendar";
import { CalendarService } from "@calcom/app-store/applecalendar/lib";
import { getBookingForReschedule } from "@calcom/features/bookings/lib/get-booking";
import getBookingInfo from "@calcom/features/bookings/lib/getBookingInfo";
import handleCancelBooking from "@calcom/features/bookings/lib/handleCancelBooking";
import * as newBookingMethods from "@calcom/features/bookings/lib/handleNewBooking";
import { getPublicEvent } from "@calcom/features/eventtypes/lib/getPublicEvent";
import handleMarkNoShow from "@calcom/features/handleMarkNoShow";
import * as instantMeetingMethods from "@calcom/features/instant-meeting/handleInstantMeeting";
import getAllUserBookings from "@calcom/lib/bookings/getAllUserBookings";
import { symmetricEncrypt } from "@calcom/lib/crypto";
import { getTranslation } from "@calcom/lib/server/i18n";
import { updateHandler as updateScheduleHandler } from "@calcom/trpc/server/routers/viewer/availability/schedule/update.handler";
import { getAvailableSlots } from "@calcom/trpc/server/routers/viewer/slots/util";
import {
createNewUsersConnectToOrgIfExists,
sendSignupToOrganizationEmail,
} from "@calcom/trpc/server/routers/viewer/teams/inviteMember/utils";
export { slugify } from "@calcom/lib/slugify";
export { getBookingForReschedule };
export { updateScheduleHandler };
export type UpdateScheduleOutputType = Awaited<
ReturnType<
typeof import("@calcom/trpc/server/routers/viewer/availability/schedule/update.handler").updateHandler
>
>;
export { getEventTypeById } from "@calcom/lib/event-types/getEventTypeById";
export { getEventTypesByViewer } from "@calcom/lib/event-types/getEventTypesByViewer";
export { getEventTypesPublic } from "@calcom/lib/event-types/getEventTypesPublic";
export { createHandler as createEventType } from "@calcom/trpc/server/routers/viewer/eventTypes/create.handler";
export { updateHandler as updateEventType } from "@calcom/trpc/server/routers/viewer/eventTypes/update.handler";
export { SchedulingType, PeriodType } from "@calcom/prisma/enums";
export type { EventType } from "@calcom/lib/event-types/getEventTypeById";
export type { EventTypesByViewer } from "@calcom/lib/event-types/getEventTypesByViewer";
export type { EventTypesPublic } from "@calcom/lib/event-types/getEventTypesPublic";
export type { UpdateEventTypeReturn } from "@calcom/trpc/server/routers/viewer/eventTypes/update.handler";
export type PublicEventType = Awaited<ReturnType<typeof getPublicEvent>>;
export { getPublicEvent };
export { getUsernameList } from "@calcom/lib/defaultEvents";
const handleNewBooking = newBookingMethods.default;
export { handleNewBooking };
const handleInstantMeeting = instantMeetingMethods.default;
export { handleInstantMeeting };
export { handleMarkNoShow };
export { getAvailableSlots };
export type AvailableSlotsType = Awaited<ReturnType<typeof getAvailableSlots>>;
export { handleNewRecurringBooking } from "@calcom/features/bookings/lib/handleNewRecurringBooking";
export { getConnectedDestinationCalendars } from "@calcom/lib/getConnectedDestinationCalendars";
export type { ConnectedDestinationCalendars } from "@calcom/lib/getConnectedDestinationCalendars";
export { getBusyCalendarTimes } from "@calcom/core/CalendarManager";
export {
transformWorkingHoursForAtom,
transformAvailabilityForAtom,
transformDateOverridesForAtom,
transformApiScheduleAvailability,
transformApiScheduleOverrides,
} from "@calcom/lib/schedules/transformers";
export type {
BookingCreateBody,
BookingResponse,
RecurringBookingCreateBody,
} from "@calcom/features/bookings/types";
export { HttpError } from "@calcom/lib/http-error";
export type { AppsStatus } from "@calcom/types/Calendar";
export { MINUTES_TO_BOOK } from "@calcom/lib/constants";
export { cityTimezonesHandler } from "@calcom/lib/cityTimezonesHandler";
export type { CityTimezones } from "@calcom/lib/cityTimezonesHandler";
export { TRPCError } from "@trpc/server";
export type { TUpdateInputSchema } from "@calcom/trpc/server/routers/viewer/availability/schedule/update.schema";
export { createNewUsersConnectToOrgIfExists, sendSignupToOrganizationEmail };
export { getAllUserBookings };
export { getBookingInfo };
export { handleCancelBooking };
export { eventTypeBookingFields, eventTypeLocations } from "@calcom/prisma/zod-utils";
export { EventTypeMetaDataSchema, userMetadata } from "@calcom/prisma/zod-utils";
export {
transformApiEventTypeBookingFields,
transformApiEventTypeLocations,
getResponseEventTypeLocations,
getResponseEventTypeBookingFields,
TransformedLocationsSchema,
BookingFieldsSchema,
} from "@calcom/lib/event-types/transformers";
export { parseRecurringEvent } from "@calcom/lib/isRecurringEvent";
export { dynamicEvent } from "@calcom/lib/defaultEvents";
export { symmetricEncrypt };
export { CalendarService };
export { getCalendar };
export { getTranslation };

View File

@@ -0,0 +1,30 @@
{
"name": "@calcom/platform-libraries",
"version": "0.0.0",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"type": "module",
"files": [
"dist"
],
"scripts": {
"build": "yarn vite build",
"build:watch": "yarn vite build --watch",
"build:dev": "yarn vite build && sed -i'' -e 's/const CACHE = new lruCache\\.LRUCache({ max: 1e3 });/const CACHE = new lruCache({ max: 1e3 });/g' ./dist/index.cjs",
"publish": "rm -rf dist && yarn build && npm publish --access public"
},
"dependencies": {
"@calcom/core": "*",
"@calcom/features": "*",
"@calcom/lib": "*"
},
"devDependencies": {
"@types/node": "^20.3.1",
"@vitejs/plugin-react": "^4.2.1",
"typescript": "^4.9.4",
"vite": "^5.0.12",
"vite-plugin-dts": "^3.7.2",
"vite-plugin-environment": "^1.1.3"
}
}

View File

@@ -0,0 +1,24 @@
{
"extends": "@calcom/tsconfig/base.json",
"compilerOptions": {
"module": "CommonJS",
"target": "ES2021",
"jsx": "react-jsx",
"resolveJsonModule": true,
"types": ["jest"],
"outDir": "./dist",
"emitDecoratorMetadata": true,
"experimentalDecorators": true
},
"include": [".", "../../types/*.d.ts"],
"exclude": [
"dist",
"build",
"node_modules",
"**/*.test.*",
"**/__mocks__/*",
"**/__tests__/*",
"../../lib/hooks/useTheme.tsx",
"../../lib/getBrandColours.tsx"
]
}

View File

@@ -0,0 +1,185 @@
// vite.config.ts
import react from "@vitejs/plugin-react";
import { resolve } from "path";
import path from "path";
import { defineConfig } from "vite";
import dts from "vite-plugin-dts";
// https://vitejs.dev/guide/build.html#library-mode
export default defineConfig({
esbuild: {
target: "node18",
platform: "node",
},
build: {
target: "node18",
platform: "node",
ssr: true,
lib: {
entry: resolve(__dirname, "./index.ts"),
name: "calcom-lib",
fileName: "calcom-lib",
},
commonjsOptions: {
dynamicRequireRoot: "../../../apps/web",
dynamicRequireTargets: ["next-i18next.config.js"],
ignoreDynamicRequires: true,
},
rollupOptions: {
external: [
"react",
"fs",
"path",
"os",
"crypto",
"react-dom",
"http",
"fs/promises",
"perf_hooks",
"@prisma/client",
"async",
"libphonenumber-js",
"lodash",
"short-uuid",
"uuid",
"zod",
"dayjs",
"i18next",
"next-i18next",
"@sentry/nextjs",
"@trpc/server",
"raw-body",
"@getalby/lightning-tools",
"svix",
"ical.js",
"ics",
"tsdav",
"googleapis",
"rrule",
"@hubspot/api-client",
"querystring",
"handlebars",
"@sendgrid/client",
"@sendgrid/mail",
"twilio",
"@prisma/client/runtime/index-browser.js",
"lru-cache",
"next-auth/jwt",
"memory-cache",
"jsforce",
"axios",
"qs",
"qs-stringify",
"stripe",
"@tryvital/vital-node",
"queue",
"entities",
"nodemailer",
"react/jsx-runtime",
"sanitize-html",
"markdown-it",
"react-i18next",
"jsonwebtoken",
"ews-javascript-api",
"dayjs/plugin/customParseFormat.js",
"dayjs/plugin/duration.js",
"dayjs/plugin/isBetween.js",
"dayjs/plugin/isToday.js",
"dayjs/plugin/localizedFormat.js",
"dayjs/plugin/minMax.js",
"dayjs/plugin/relativeTime.js",
"dayjs/plugin/timezone.js",
"dayjs/plugin/toArray.js",
"dayjs/plugin/utc.js",
"tslog",
"@prisma/extension-accelerate",
"@ewsjs/xhr",
"next-i18next/serverSideTranslations",
],
output: {
globals: {
react: "React",
"react-dom": "ReactDOM",
fs: "fs",
path: "path",
os: "os",
crypto: "crypto",
http: "http",
"fs/promises": "fs/promises",
perf_hooks: "perf_hooks",
"@prisma/client": "@prisma/client",
async: "async",
"libphonenumber-js": "libphonenumber-js",
lodash: "lodash",
"short-uuid": "short-uuid",
uuid: "uuid",
zod: "zod",
dayjs: "dayjs",
i18next: "i18next",
"next-i18next": "next-i18next",
"@sentry/nextjs": "@sentry/nextjs",
"@trpc/server": "@trpc/server",
"raw-body": "raw-body",
"@getalby/lightning-tools": "@getalby/lightning-tools",
svix: "svix",
"ical.js": "ical.js",
ics: "ics",
tsdav: "tsdav",
googleapis: "googleapis",
rrule: "rrule",
"@hubspot/api-client": "@hubspot/api-client",
querystring: "querystring",
handlebars: "handlebars",
"@sendgrid/client": "@sendgrid/client",
"@sendgrid/mail": "@sendgrid/mail",
twilio: "twilio",
"@prisma/client/runtime/index-browser.js": "@prisma/client/runtime/index-browser.js",
"lru-cache": "lru-cache",
"next-auth/jwt": "next-auth/jwt",
"memory-cache": "memory-cache",
jsforce: "jsforce",
axios: "axios",
qs: "qs",
"qs-stringify": "qs-stringify",
stripe: "stripe",
"@tryvital/vital-node": "@tryvital/vital-node",
queue: "queue",
entities: "entities",
nodemailer: "nodemailer",
"react/jsx-runtime": "react/jsx-runtime",
"sanitize-html": "sanitize-html",
"markdown-it": "markdown-it",
"react-i18next": "react-i18next",
jsonwebtoken: "jsonwebtoken",
"ews-javascript-api": "ews-javascript-api",
"dayjs/plugin/customParseFormat.js": "dayjs/plugin/customParseFormat.js",
"dayjs/plugin/duration.js": "dayjs/plugin/duration.js",
"dayjs/plugin/isBetween.js": "dayjs/plugin/isBetween.js",
"dayjs/plugin/isToday.js": "dayjs/plugin/isToday.js",
"dayjs/plugin/localizedFormat.js": "dayjs/plugin/localizedFormat.js",
"dayjs/plugin/minMax.js": "dayjs/plugin/minMax.js",
"dayjs/plugin/relativeTime.js": "dayjs/plugin/relativeTime.js",
"dayjs/plugin/timezone.js": "dayjs/plugin/timezone.js",
"dayjs/plugin/toArray.js": "dayjs/plugin/toArray.js",
"dayjs/plugin/utc.js": "dayjs/plugin/utc.js",
tslog: "tslog",
"@prisma/extension-accelerate": "@prisma/extension-accelerate",
"@ewsjs/xhr": "@ewsjs/xhr",
"next-i18next/serverSideTranslations": "next-i18next/serverSideTranslations",
"@calcom/prisma/client": "@calcom/prisma/client",
},
},
},
},
plugins: [react(), dts()],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
"@calcom/lib": path.resolve(__dirname, "../../lib"),
"@calcom/trpc": resolve("../../trpc"),
"lru-cache": resolve("../../../node_modules/lru-cache/dist/cjs/index.js"),
"@prisma/client": resolve("../../../node_modules/@prisma/client"),
"@calcom/prisma/client": resolve("../../../node_modules/.prisma/client"),
},
},
});