fix: v2 event type locations (#17288)
* refactor: split internal locations in separate file * refactor: rename TransformedLocationsSchema to InternalLocationsSchema * feat: add missing locations in internal schema * refactor: explicit input locations only for input * refactor: explicit output locations only for output * fix: v2 * fix: atoms * test: internal to api locations transformation * e2e tests * upgrade platform libraries
This commit is contained in:
1 parent
50a41109d0
commit
c629d08a9c
20 files changed
+1087
-280
No files matched your search
@@ -9,7 +9,7 @@ import {
|
||||
} from "@calcom/platform-enums/monorepo";
|
||||
import type {
|
||||
InputBookingField_2024_06_14,
|
||||
Location_2024_06_14,
|
||||
InputLocation_2024_06_14,
|
||||
BookingLimitsCount_2024_06_14,
|
||||
BookingWindow_2024_06_14,
|
||||
BookerLayouts_2024_06_14,
|
||||
@@ -19,9 +19,9 @@ import type {
|
||||
CreateEventTypeInput_2024_06_14,
|
||||
SeatOptionsTransformedSchema,
|
||||
SeatOptionsDisabledSchema,
|
||||
AttendeeAddressLocation_2024_06_14,
|
||||
AttendeePhoneLocation_2024_06_14,
|
||||
AttendeeDefinedLocation_2024_06_14,
|
||||
InputAttendeeAddressLocation_2024_06_14,
|
||||
InputAttendeePhoneLocation_2024_06_14,
|
||||
InputAttendeeDefinedLocation_2024_06_14,
|
||||
} from "@calcom/platform-types";
|
||||
|
||||
import {
|
||||
@@ -45,7 +45,7 @@ import {
|
||||
|
||||
describe("transformLocationsApiToInternal", () => {
|
||||
it("should transform address", () => {
|
||||
const input: Location_2024_06_14[] = [
|
||||
const input: InputLocation_2024_06_14[] = [
|
||||
{
|
||||
type: "address",
|
||||
address: "London road 10-1",
|
||||
@@ -61,7 +61,7 @@ describe("transformLocationsApiToInternal", () => {
|
||||
});
|
||||
|
||||
it("should transform link", () => {
|
||||
const input: Location_2024_06_14[] = [
|
||||
const input: InputLocation_2024_06_14[] = [
|
||||
{
|
||||
type: "link",
|
||||
link: "https://customvideo.com/join/123456",
|
||||
@@ -79,7 +79,7 @@ describe("transformLocationsApiToInternal", () => {
|
||||
});
|
||||
|
||||
it("should transform integration", () => {
|
||||
const input: Location_2024_06_14[] = [
|
||||
const input: InputLocation_2024_06_14[] = [
|
||||
{
|
||||
type: "integration",
|
||||
integration: "cal-video",
|
||||
@@ -94,7 +94,7 @@ describe("transformLocationsApiToInternal", () => {
|
||||
});
|
||||
|
||||
it("should transform phone", () => {
|
||||
const input: Location_2024_06_14[] = [
|
||||
const input: InputLocation_2024_06_14[] = [
|
||||
{
|
||||
type: "phone",
|
||||
phone: "+37120993151",
|
||||
@@ -112,7 +112,7 @@ describe("transformLocationsApiToInternal", () => {
|
||||
});
|
||||
|
||||
it("should transform attendee address", () => {
|
||||
const input: AttendeeAddressLocation_2024_06_14[] = [
|
||||
const input: InputAttendeeAddressLocation_2024_06_14[] = [
|
||||
{
|
||||
type: "attendeeAddress",
|
||||
},
|
||||
@@ -125,7 +125,7 @@ describe("transformLocationsApiToInternal", () => {
|
||||
});
|
||||
|
||||
it("should transform attendee phone", () => {
|
||||
const input: AttendeePhoneLocation_2024_06_14[] = [
|
||||
const input: InputAttendeePhoneLocation_2024_06_14[] = [
|
||||
{
|
||||
type: "attendeePhone",
|
||||
},
|
||||
@@ -138,7 +138,7 @@ describe("transformLocationsApiToInternal", () => {
|
||||
});
|
||||
|
||||
it("should transform attendee defined", () => {
|
||||
const input: AttendeeDefinedLocation_2024_06_14[] = [
|
||||
const input: InputAttendeeDefinedLocation_2024_06_14[] = [
|
||||
{
|
||||
type: "attendeeDefined",
|
||||
},
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
import { z } from "zod";
|
||||
import type { InputLocation_2024_06_14 } from "@calcom/platform-types";
|
||||
import { type Integration_2024_06_14 } from "@calcom/platform-types";
|
||||
|
||||
import { type CreateEventTypeInput_2024_06_14, type Integration_2024_06_14 } from "@calcom/platform-types";
|
||||
import type {
|
||||
AttendeeAddressLocation,
|
||||
AttendeeDefinedLocation,
|
||||
AttendeePhoneLocation,
|
||||
OrganizerAddressLocation,
|
||||
OrganizerIntegrationLocation,
|
||||
OrganizerLinkLocation,
|
||||
OrganizerPhoneLocation,
|
||||
} from "../internal/locations";
|
||||
|
||||
const integrationsMapping: Record<Integration_2024_06_14, "integrations:daily"> = {
|
||||
const apiToInternalintegrationsMapping: Record<Integration_2024_06_14, "integrations:daily"> = {
|
||||
"cal-video": "integrations:daily",
|
||||
};
|
||||
|
||||
export function transformLocationsApiToInternal(
|
||||
inputLocations: CreateEventTypeInput_2024_06_14["locations"]
|
||||
) {
|
||||
export function transformLocationsApiToInternal(inputLocations: InputLocation_2024_06_14[] | undefined) {
|
||||
if (!inputLocations) {
|
||||
return [];
|
||||
}
|
||||
@@ -31,7 +38,7 @@ export function transformLocationsApiToInternal(
|
||||
displayLocationPublicly: location.public,
|
||||
} satisfies OrganizerLinkLocation;
|
||||
case "integration":
|
||||
const integrationLabel = integrationsMapping[location.integration];
|
||||
const integrationLabel = apiToInternalintegrationsMapping[location.integration];
|
||||
return { type: integrationLabel } satisfies OrganizerIntegrationLocation;
|
||||
case "phone":
|
||||
return {
|
||||
@@ -44,69 +51,7 @@ export function transformLocationsApiToInternal(
|
||||
case "attendeeDefined":
|
||||
return { type: "somewhereElse" } satisfies AttendeeDefinedLocation;
|
||||
default:
|
||||
throw new Error(`Unsupported location type '${type}'`);
|
||||
throw new Error(`Unsupported input location type '${type}'`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const integrationsMappingSchema = {
|
||||
"cal-video": z.literal("integrations:daily"),
|
||||
};
|
||||
|
||||
const OrganizerAddressSchema = z.object({
|
||||
type: z.literal("inPerson"),
|
||||
address: z.string(),
|
||||
displayLocationPublicly: z.boolean().default(false),
|
||||
});
|
||||
|
||||
const OrganizerLinkSchema = z.object({
|
||||
type: z.literal("link"),
|
||||
link: z.string().url(),
|
||||
displayLocationPublicly: z.boolean().default(false),
|
||||
});
|
||||
|
||||
const OrganizerIntegrationSchema = z.object({
|
||||
type: z.union([integrationsMappingSchema["cal-video"], integrationsMappingSchema["cal-video"]]),
|
||||
});
|
||||
|
||||
const OrganizerPhoneSchema = z.object({
|
||||
type: z.literal("userPhone"),
|
||||
hostPhoneNumber: z.string(),
|
||||
displayLocationPublicly: z.boolean().default(false),
|
||||
});
|
||||
|
||||
const OrganizerConferencingSchema = z.object({
|
||||
type: z.literal("conferencing"),
|
||||
});
|
||||
|
||||
const AttendeeAddressSchema = z.object({
|
||||
type: z.literal("attendeeInPerson"),
|
||||
});
|
||||
|
||||
const AttendeePhoneSchema = z.object({
|
||||
type: z.literal("phone"),
|
||||
});
|
||||
|
||||
const AttendeeDefinedSchema = z.object({
|
||||
type: z.literal("somewhereElse"),
|
||||
});
|
||||
|
||||
type OrganizerAddressLocation = z.infer<typeof OrganizerAddressSchema>;
|
||||
type OrganizerLinkLocation = z.infer<typeof OrganizerLinkSchema>;
|
||||
export type OrganizerIntegrationLocation = z.infer<typeof OrganizerIntegrationSchema>;
|
||||
type OrganizerPhoneLocation = z.infer<typeof OrganizerPhoneSchema>;
|
||||
type AttendeeAddressLocation = z.infer<typeof AttendeeAddressSchema>;
|
||||
type AttendeePhoneLocation = z.infer<typeof AttendeePhoneSchema>;
|
||||
type AttendeeDefinedLocation = z.infer<typeof AttendeeDefinedSchema>;
|
||||
|
||||
const TransformedLocationSchema = z.union([
|
||||
OrganizerAddressSchema,
|
||||
OrganizerLinkSchema,
|
||||
OrganizerIntegrationSchema,
|
||||
OrganizerPhoneSchema,
|
||||
OrganizerConferencingSchema,
|
||||
AttendeeAddressSchema,
|
||||
AttendeePhoneSchema,
|
||||
AttendeeDefinedSchema,
|
||||
]);
|
||||
export const TransformedLocationsSchema = z.array(TransformedLocationSchema);
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from "./api-to-internal";
|
||||
export * from "./internal-to-api";
|
||||
export * from "./internal/locations";
|
||||
@@ -7,10 +7,6 @@ import {
|
||||
NoticeThresholdUnitEnum,
|
||||
} from "@calcom/platform-enums/monorepo";
|
||||
import type {
|
||||
AddressLocation_2024_06_14,
|
||||
LinkLocation_2024_06_14,
|
||||
PhoneLocation_2024_06_14,
|
||||
IntegrationLocation_2024_06_14,
|
||||
TransformBookingLimitsSchema_2024_06_14,
|
||||
TransformFutureBookingsLimitSchema_2024_06_14,
|
||||
BookerLayoutsTransformedSchema,
|
||||
@@ -18,9 +14,14 @@ import type {
|
||||
TransformRecurringEventSchema_2024_06_14,
|
||||
SeatOptionsTransformedSchema,
|
||||
SeatOptionsDisabledSchema,
|
||||
AttendeeAddressLocation_2024_06_14,
|
||||
AttendeePhoneLocation_2024_06_14,
|
||||
AttendeeDefinedLocation_2024_06_14,
|
||||
OutputAddressLocation_2024_06_14,
|
||||
OutputAttendeeAddressLocation_2024_06_14,
|
||||
OutputAttendeeDefinedLocation_2024_06_14,
|
||||
OutputAttendeePhoneLocation_2024_06_14,
|
||||
OutputIntegrationLocation_2024_06_14,
|
||||
OutputLinkLocation_2024_06_14,
|
||||
OutputPhoneLocation_2024_06_14,
|
||||
OutputUnknownLocation_2024_06_14,
|
||||
} from "@calcom/platform-types";
|
||||
|
||||
import {
|
||||
@@ -51,7 +52,7 @@ describe("transformLocationsInternalToApi", () => {
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput: AddressLocation_2024_06_14[] = [
|
||||
const expectedOutput: OutputAddressLocation_2024_06_14[] = [
|
||||
{
|
||||
type: "address",
|
||||
address: "1234 Main St",
|
||||
@@ -73,7 +74,7 @@ describe("transformLocationsInternalToApi", () => {
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput: LinkLocation_2024_06_14[] = [
|
||||
const expectedOutput: OutputLinkLocation_2024_06_14[] = [
|
||||
{
|
||||
type: "link",
|
||||
link: "https://example.com",
|
||||
@@ -95,7 +96,7 @@ describe("transformLocationsInternalToApi", () => {
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput: PhoneLocation_2024_06_14[] = [
|
||||
const expectedOutput: OutputPhoneLocation_2024_06_14[] = [
|
||||
{
|
||||
type: "phone",
|
||||
phone: "123456789",
|
||||
@@ -115,7 +116,7 @@ describe("transformLocationsInternalToApi", () => {
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput: IntegrationLocation_2024_06_14[] = [
|
||||
const expectedOutput: OutputIntegrationLocation_2024_06_14[] = [
|
||||
{
|
||||
type: "integration",
|
||||
integration: "cal-video",
|
||||
@@ -127,6 +128,91 @@ describe("transformLocationsInternalToApi", () => {
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should transform integration location", () => {
|
||||
const transformedLocation = [
|
||||
{
|
||||
type: "integrations:discord_video" as const,
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput: OutputIntegrationLocation_2024_06_14[] = [
|
||||
{
|
||||
type: "integration",
|
||||
integration: "discord-video",
|
||||
},
|
||||
];
|
||||
|
||||
const result = transformLocationsInternalToApi(transformedLocation);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should transform integration location with link and credentialId", () => {
|
||||
const transformedLocation = [
|
||||
{
|
||||
type: "integrations:discord_video" as const,
|
||||
link: "https://discord.com/users/100",
|
||||
credentialId: 100,
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput: OutputIntegrationLocation_2024_06_14[] = [
|
||||
{
|
||||
type: "integration",
|
||||
integration: "discord-video",
|
||||
link: "https://discord.com/users/100",
|
||||
credentialId: 100,
|
||||
},
|
||||
];
|
||||
|
||||
const result = transformLocationsInternalToApi(transformedLocation);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should transform unknown location", () => {
|
||||
const transformedLocation = [
|
||||
{
|
||||
type: "unknown" as const,
|
||||
location: "unknown location",
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput: OutputUnknownLocation_2024_06_14[] = [
|
||||
{
|
||||
type: "unknown",
|
||||
location: JSON.stringify(transformedLocation[0]),
|
||||
},
|
||||
];
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
const result = transformLocationsInternalToApi(transformedLocation);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should transform unknown integration location", () => {
|
||||
const transformedLocation = [
|
||||
{
|
||||
type: "integrations:unknown_video" as const,
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput: OutputUnknownLocation_2024_06_14[] = [
|
||||
{
|
||||
type: "unknown",
|
||||
location: JSON.stringify(transformedLocation[0]),
|
||||
},
|
||||
];
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
const result = transformLocationsInternalToApi(transformedLocation);
|
||||
|
||||
expect(result).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it("should reverse transform attendee address location", () => {
|
||||
const transformedLocation = [
|
||||
{
|
||||
@@ -134,7 +220,7 @@ describe("transformLocationsInternalToApi", () => {
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput: AttendeeAddressLocation_2024_06_14[] = [
|
||||
const expectedOutput: OutputAttendeeAddressLocation_2024_06_14[] = [
|
||||
{
|
||||
type: "attendeeAddress",
|
||||
},
|
||||
@@ -151,7 +237,7 @@ describe("transformLocationsInternalToApi", () => {
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput: AttendeePhoneLocation_2024_06_14[] = [
|
||||
const expectedOutput: OutputAttendeePhoneLocation_2024_06_14[] = [
|
||||
{
|
||||
type: "attendeePhone",
|
||||
},
|
||||
@@ -168,7 +254,7 @@ describe("transformLocationsInternalToApi", () => {
|
||||
},
|
||||
];
|
||||
|
||||
const expectedOutput: AttendeeDefinedLocation_2024_06_14[] = [
|
||||
const expectedOutput: OutputAttendeeDefinedLocation_2024_06_14[] = [
|
||||
{
|
||||
type: "attendeeDefined",
|
||||
},
|
||||
@@ -208,11 +294,11 @@ describe("transformBookingFieldsInternalToApi", () => {
|
||||
fullName: {
|
||||
fields: [
|
||||
{
|
||||
name: "fullName",
|
||||
name: "fullName" as const,
|
||||
label: "custom label",
|
||||
placeholder: "custom placeholder",
|
||||
type: "text",
|
||||
required: true,
|
||||
type: "text" as const,
|
||||
required: true as const,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -1,34 +1,64 @@
|
||||
import type {
|
||||
AddressLocation_2024_06_14,
|
||||
IntegrationLocation_2024_06_14,
|
||||
LinkLocation_2024_06_14,
|
||||
PhoneLocation_2024_06_14,
|
||||
Integration_2024_06_14,
|
||||
AttendeePhoneLocation_2024_06_14,
|
||||
AttendeeAddressLocation_2024_06_14,
|
||||
AttendeeDefinedLocation_2024_06_14,
|
||||
OutputConferencingLocation_2024_06_14,
|
||||
OutputIntegration_2024_06_14,
|
||||
OutputIntegrationLocation_2024_06_14,
|
||||
OutputAddressLocation_2024_06_14,
|
||||
OutputAttendeeAddressLocation_2024_06_14,
|
||||
OutputAttendeeDefinedLocation_2024_06_14,
|
||||
OutputAttendeePhoneLocation_2024_06_14,
|
||||
OutputLinkLocation_2024_06_14,
|
||||
OutputPhoneLocation_2024_06_14,
|
||||
OutputUnknownLocation_2024_06_14,
|
||||
} from "@calcom/platform-types";
|
||||
|
||||
import type { transformLocationsApiToInternal } from "../api-to-internal";
|
||||
import type { InternalLocation } from "../internal/locations";
|
||||
|
||||
const reverseIntegrationsMapping: Record<string, Integration_2024_06_14> = {
|
||||
const internalToApiIntegrationsMapping: Record<string, OutputIntegration_2024_06_14> = {
|
||||
"integrations:daily": "cal-video",
|
||||
"integrations:google:meet": "google-meet",
|
||||
"integrations:zoom": "zoom",
|
||||
"integrations:whereby_video": "whereby-video",
|
||||
"integrations:whatsapp_video": "whatsapp-video",
|
||||
"integrations:webex_video": "webex-video",
|
||||
"integrations:telegram_video": "telegram-video",
|
||||
"integrations:tandem": "tandem",
|
||||
"integrations:sylaps_video": "sylaps-video",
|
||||
"integrations:skype_video": "skype-video",
|
||||
"integrations:sirius_video_video": "sirius-video",
|
||||
"integrations:signal_video": "signal-video",
|
||||
"integrations:shimmer_video": "shimmer-video",
|
||||
"integrations:salesroom_video": "salesroom-video",
|
||||
"integrations:roam_video": "roam-video",
|
||||
"integrations:riverside_video": "riverside-video",
|
||||
"integrations:ping_video": "ping-video",
|
||||
"integrations:office365_video": "office365-video",
|
||||
"integrations:mirotalk_video": "mirotalk-video",
|
||||
"integrations:jitsi": "jitsi",
|
||||
"integrations:jelly_video": "jelly-video",
|
||||
"integrations:jelly_conferencing": "jelly-conferencing",
|
||||
"integrations:huddle01": "huddle",
|
||||
"integrations:facetime_video": "facetime-video",
|
||||
"integrations:element-call_video": "element-call-video",
|
||||
"integrations:eightxeight_video": "eightxeight-video",
|
||||
"integrations:discord_video": "discord-video",
|
||||
"integrations:demodesk_video": "demodesk-video",
|
||||
"integrations:campsite_conferencing": "campsite-conferencing",
|
||||
"integrations:campfire_video": "campfire-video",
|
||||
"integrations:around_video": "around-video",
|
||||
};
|
||||
|
||||
export function transformLocationsInternalToApi(
|
||||
transformedLocations: ReturnType<typeof transformLocationsApiToInternal>
|
||||
) {
|
||||
if (!transformedLocations) {
|
||||
export function transformLocationsInternalToApi(internalLocations: InternalLocation[] | undefined) {
|
||||
if (!internalLocations) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return transformedLocations.map((location) => {
|
||||
return internalLocations.map((location) => {
|
||||
switch (location.type) {
|
||||
case "inPerson": {
|
||||
if (!location.address) {
|
||||
throw new Error("Address location must have an address");
|
||||
}
|
||||
const addressLocation: AddressLocation_2024_06_14 = {
|
||||
const addressLocation: OutputAddressLocation_2024_06_14 = {
|
||||
type: "address",
|
||||
address: location.address,
|
||||
public: location.displayLocationPublicly,
|
||||
@@ -36,7 +66,7 @@ export function transformLocationsInternalToApi(
|
||||
return addressLocation;
|
||||
}
|
||||
case "attendeeInPerson": {
|
||||
const attendeeAddressLocation: AttendeeAddressLocation_2024_06_14 = {
|
||||
const attendeeAddressLocation: OutputAttendeeAddressLocation_2024_06_14 = {
|
||||
type: "attendeeAddress",
|
||||
};
|
||||
return attendeeAddressLocation;
|
||||
@@ -45,7 +75,7 @@ export function transformLocationsInternalToApi(
|
||||
if (!location.link) {
|
||||
throw new Error("Link location must have a link");
|
||||
}
|
||||
const linkLocation: LinkLocation_2024_06_14 = {
|
||||
const linkLocation: OutputLinkLocation_2024_06_14 = {
|
||||
type: "link",
|
||||
link: location.link,
|
||||
public: location.displayLocationPublicly,
|
||||
@@ -56,7 +86,7 @@ export function transformLocationsInternalToApi(
|
||||
if (!location.hostPhoneNumber) {
|
||||
throw new Error("Phone location must have a phone number");
|
||||
}
|
||||
const phoneLocation: PhoneLocation_2024_06_14 = {
|
||||
const phoneLocation: OutputPhoneLocation_2024_06_14 = {
|
||||
type: "phone",
|
||||
phone: location.hostPhoneNumber,
|
||||
public: location.displayLocationPublicly,
|
||||
@@ -64,25 +94,37 @@ export function transformLocationsInternalToApi(
|
||||
return phoneLocation;
|
||||
}
|
||||
case "phone": {
|
||||
const attendeePhoneLocation: AttendeePhoneLocation_2024_06_14 = {
|
||||
const attendeePhoneLocation: OutputAttendeePhoneLocation_2024_06_14 = {
|
||||
type: "attendeePhone",
|
||||
};
|
||||
return attendeePhoneLocation;
|
||||
}
|
||||
case "somewhereElse": {
|
||||
const attendeeDefinedLocation: AttendeeDefinedLocation_2024_06_14 = {
|
||||
const attendeeDefinedLocation: OutputAttendeeDefinedLocation_2024_06_14 = {
|
||||
type: "attendeeDefined",
|
||||
};
|
||||
return attendeeDefinedLocation;
|
||||
}
|
||||
case "conferencing": {
|
||||
const conferencingLocation: OutputConferencingLocation_2024_06_14 = {
|
||||
type: "conferencing",
|
||||
};
|
||||
return conferencingLocation;
|
||||
}
|
||||
default: {
|
||||
const integrationType = reverseIntegrationsMapping[location.type];
|
||||
const integrationType = internalToApiIntegrationsMapping[location.type];
|
||||
if (!integrationType) {
|
||||
throw new Error(`Unsupported integration type '${location.type}'.`);
|
||||
const unknown: OutputUnknownLocation_2024_06_14 = {
|
||||
type: "unknown",
|
||||
location: JSON.stringify(location),
|
||||
};
|
||||
return unknown;
|
||||
}
|
||||
const integration: IntegrationLocation_2024_06_14 = {
|
||||
const integration: OutputIntegrationLocation_2024_06_14 = {
|
||||
type: "integration",
|
||||
integration: integrationType,
|
||||
link: location.link,
|
||||
credentialId: location.credentialId,
|
||||
};
|
||||
return integration;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
import { z } from "zod";
|
||||
|
||||
const integrationsApiAvailable = {
|
||||
"cal-video": z.literal("integrations:daily"),
|
||||
};
|
||||
|
||||
// note(Lauris): these are read only aka they exist in database and are to be returned by a READ operation
|
||||
const integrationsApiUnavailable = {
|
||||
"google-meet": z.literal("integrations:google:meet"),
|
||||
zoom: z.literal("integrations:zoom"),
|
||||
"whereby-video": z.literal("integrations:whereby_video"),
|
||||
"whatsapp-video": z.literal("integrations:whatsapp_video"),
|
||||
"webex-video": z.literal("integrations:webex_video"),
|
||||
"telegram-video": z.literal("integrations:telegram_video"),
|
||||
tandem: z.literal("integrations:tandem"),
|
||||
"sylaps-video": z.literal("integrations:sylaps_video"),
|
||||
"skype-video": z.literal("integrations:skype_video"),
|
||||
"sirius-video": z.literal("integrations:sirius_video_video"),
|
||||
"signal-video": z.literal("integrations:signal_video"),
|
||||
"shimmer-video": z.literal("integrations:shimmer_video"),
|
||||
"salesroom-video": z.literal("integrations:salesroom_video"),
|
||||
"roam-video": z.literal("integrations:roam_video"),
|
||||
"riverside-video": z.literal("integrations:riverside_video"),
|
||||
"ping-video": z.literal("integrations:ping_video"),
|
||||
"office365-video": z.literal("integrations:office365_video"),
|
||||
"mirotalk-video": z.literal("integrations:mirotalk_video"),
|
||||
jitsi: z.literal("integrations:jitsi"),
|
||||
"jelly-video": z.literal("integrations:jelly_video"),
|
||||
"jelly-conferencing": z.literal("integrations:jelly_conferencing"),
|
||||
huddle: z.literal("integrations:huddle01"),
|
||||
"facetime-video": z.literal("integrations:facetime_video"),
|
||||
"element-call-video": z.literal("integrations:element-call_video"),
|
||||
"eightxeight-video": z.literal("integrations:eightxeight_video"),
|
||||
"discord-video": z.literal("integrations:discord_video"),
|
||||
"demodesk-video": z.literal("integrations:demodesk_video"),
|
||||
"campsite-conferencing": z.literal("integrations:campsite_conferencing"),
|
||||
"campfire-video": z.literal("integrations:campfire_video"),
|
||||
"around-video": z.literal("integrations:around_video"),
|
||||
};
|
||||
|
||||
export const integrationsApiToInternalMappingSchema = {
|
||||
...integrationsApiAvailable,
|
||||
...integrationsApiUnavailable,
|
||||
};
|
||||
|
||||
const OrganizerIntegrationSchema = z.object({
|
||||
type: z.union([
|
||||
integrationsApiToInternalMappingSchema["cal-video"],
|
||||
integrationsApiToInternalMappingSchema["google-meet"],
|
||||
integrationsApiToInternalMappingSchema["zoom"],
|
||||
integrationsApiToInternalMappingSchema["whereby-video"],
|
||||
integrationsApiToInternalMappingSchema["whatsapp-video"],
|
||||
integrationsApiToInternalMappingSchema["webex-video"],
|
||||
integrationsApiToInternalMappingSchema["telegram-video"],
|
||||
integrationsApiToInternalMappingSchema["tandem"],
|
||||
integrationsApiToInternalMappingSchema["sylaps-video"],
|
||||
integrationsApiToInternalMappingSchema["skype-video"],
|
||||
integrationsApiToInternalMappingSchema["sirius-video"],
|
||||
integrationsApiToInternalMappingSchema["signal-video"],
|
||||
integrationsApiToInternalMappingSchema["shimmer-video"],
|
||||
integrationsApiToInternalMappingSchema["salesroom-video"],
|
||||
integrationsApiToInternalMappingSchema["roam-video"],
|
||||
integrationsApiToInternalMappingSchema["riverside-video"],
|
||||
integrationsApiToInternalMappingSchema["ping-video"],
|
||||
integrationsApiToInternalMappingSchema["office365-video"],
|
||||
integrationsApiToInternalMappingSchema["mirotalk-video"],
|
||||
integrationsApiToInternalMappingSchema["jitsi"],
|
||||
integrationsApiToInternalMappingSchema["jelly-video"],
|
||||
integrationsApiToInternalMappingSchema["jelly-conferencing"],
|
||||
integrationsApiToInternalMappingSchema["huddle"],
|
||||
integrationsApiToInternalMappingSchema["facetime-video"],
|
||||
integrationsApiToInternalMappingSchema["element-call-video"],
|
||||
integrationsApiToInternalMappingSchema["eightxeight-video"],
|
||||
integrationsApiToInternalMappingSchema["discord-video"],
|
||||
integrationsApiToInternalMappingSchema["demodesk-video"],
|
||||
integrationsApiToInternalMappingSchema["campsite-conferencing"],
|
||||
integrationsApiToInternalMappingSchema["campfire-video"],
|
||||
integrationsApiToInternalMappingSchema["around-video"],
|
||||
]),
|
||||
link: z.string().url().optional(),
|
||||
credentialId: z.number().optional(),
|
||||
});
|
||||
|
||||
const OrganizerAddressSchema = z.object({
|
||||
type: z.literal("inPerson"),
|
||||
address: z.string(),
|
||||
displayLocationPublicly: z.boolean().default(false),
|
||||
});
|
||||
|
||||
const OrganizerLinkSchema = z.object({
|
||||
type: z.literal("link"),
|
||||
link: z.string().url(),
|
||||
displayLocationPublicly: z.boolean().default(false),
|
||||
});
|
||||
|
||||
const OrganizerPhoneSchema = z.object({
|
||||
type: z.literal("userPhone"),
|
||||
hostPhoneNumber: z.string(),
|
||||
displayLocationPublicly: z.boolean().default(false),
|
||||
});
|
||||
|
||||
const OrganizerConferencingSchema = z.object({
|
||||
type: z.literal("conferencing"),
|
||||
});
|
||||
|
||||
const AttendeeAddressSchema = z.object({
|
||||
type: z.literal("attendeeInPerson"),
|
||||
});
|
||||
|
||||
const AttendeePhoneSchema = z.object({
|
||||
type: z.literal("phone"),
|
||||
});
|
||||
|
||||
const AttendeeDefinedSchema = z.object({
|
||||
type: z.literal("somewhereElse"),
|
||||
});
|
||||
|
||||
export type OrganizerAddressLocation = z.infer<typeof OrganizerAddressSchema>;
|
||||
export type OrganizerLinkLocation = z.infer<typeof OrganizerLinkSchema>;
|
||||
export type OrganizerIntegrationLocation = z.infer<typeof OrganizerIntegrationSchema>;
|
||||
export type OrganizerPhoneLocation = z.infer<typeof OrganizerPhoneSchema>;
|
||||
export type OrganizerConferencingSchema = z.infer<typeof OrganizerConferencingSchema>;
|
||||
export type AttendeeAddressLocation = z.infer<typeof AttendeeAddressSchema>;
|
||||
export type AttendeePhoneLocation = z.infer<typeof AttendeePhoneSchema>;
|
||||
export type AttendeeDefinedLocation = z.infer<typeof AttendeeDefinedSchema>;
|
||||
|
||||
export const InternalLocationSchema = z.union([
|
||||
OrganizerAddressSchema,
|
||||
OrganizerLinkSchema,
|
||||
OrganizerIntegrationSchema,
|
||||
OrganizerPhoneSchema,
|
||||
OrganizerConferencingSchema,
|
||||
AttendeeAddressSchema,
|
||||
AttendeePhoneSchema,
|
||||
AttendeeDefinedSchema,
|
||||
]);
|
||||
export type InternalLocation = z.infer<typeof InternalLocationSchema>;
|
||||
|
||||
export const InternalLocationsSchema = z.array(InternalLocationSchema);
|
||||
Reference in new issue
Block a user