fix: Booking atom phone booking field and booking fields order (#18678)
* chore: examples app make managed user admin * fix: phone field not appearing * fix: booking fields order * feat: local libraries setup script * chore: add log when parsing booking field fails * fix: backwards compatbile name booking field * chore: libraries publish support scripts * chore: bump libraries * docs * fix: phone default field return label and placeholder * fix: e2e tests
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
"@axiomhq/winston": "^1.2.0",
|
||||
"@calcom/platform-constants": "*",
|
||||
"@calcom/platform-enums": "*",
|
||||
"@calcom/platform-libraries": "npm:@calcom/platform-libraries@0.0.82",
|
||||
"@calcom/platform-libraries": "npm:@calcom/platform-libraries@0.0.85",
|
||||
"@calcom/platform-libraries-0.0.2": "npm:@calcom/platform-libraries@0.0.2",
|
||||
"@calcom/platform-types": "*",
|
||||
"@calcom/platform-utils": "*",
|
||||
|
||||
+22
-20
@@ -123,7 +123,6 @@ describe("Event types Endpoints", () => {
|
||||
slug: "location",
|
||||
required: false,
|
||||
hidden: false,
|
||||
disableOnPrefill: false,
|
||||
};
|
||||
|
||||
const defaultResponseBookingFieldTitle = {
|
||||
@@ -452,9 +451,6 @@ describe("Event types Endpoints", () => {
|
||||
{ ...defaultResponseBookingFieldName, ...nameBookingField },
|
||||
{ ...defaultResponseBookingFieldEmail },
|
||||
{ ...defaultResponseBookingFieldLocation },
|
||||
{ ...defaultResponseBookingFieldTitle },
|
||||
{ ...defaultResponseBookingFieldGuests },
|
||||
{ ...defaultResponseBookingFieldRescheduleReason },
|
||||
{
|
||||
type: "select",
|
||||
label: "select which language you want to learn",
|
||||
@@ -466,7 +462,10 @@ describe("Event types Endpoints", () => {
|
||||
hidden: false,
|
||||
isDefault: false,
|
||||
},
|
||||
{ ...defaultResponseBookingFieldTitle },
|
||||
{ ...defaultResponseBookingFieldNotes },
|
||||
{ ...defaultResponseBookingFieldGuests },
|
||||
{ ...defaultResponseBookingFieldRescheduleReason },
|
||||
];
|
||||
|
||||
expect(createdEventType.bookingFields).toEqual(expectedBookingFields);
|
||||
@@ -942,9 +941,6 @@ describe("Event types Endpoints", () => {
|
||||
{ ...defaultResponseBookingFieldName, ...nameBookingField },
|
||||
{ ...defaultResponseBookingFieldEmail },
|
||||
{ ...defaultResponseBookingFieldLocation },
|
||||
{ ...defaultResponseBookingFieldTitle },
|
||||
{ ...defaultResponseBookingFieldGuests },
|
||||
{ ...defaultResponseBookingFieldRescheduleReason },
|
||||
{
|
||||
type: "select",
|
||||
label: "select which language you want to learn",
|
||||
@@ -956,7 +952,10 @@ describe("Event types Endpoints", () => {
|
||||
hidden: false,
|
||||
isDefault: false,
|
||||
},
|
||||
{ ...defaultResponseBookingFieldTitle },
|
||||
{ ...defaultResponseBookingFieldNotes, ...notesBookingField },
|
||||
{ ...defaultResponseBookingFieldGuests },
|
||||
{ ...defaultResponseBookingFieldRescheduleReason },
|
||||
];
|
||||
|
||||
expect(updatedEventType.bookingFields).toEqual(expectedBookingFields);
|
||||
@@ -1163,10 +1162,7 @@ describe("Event types Endpoints", () => {
|
||||
type: "radioInput",
|
||||
slug: "location",
|
||||
required: false,
|
||||
disableOnPrefill: false,
|
||||
hidden: false,
|
||||
label: "",
|
||||
placeholder: "",
|
||||
},
|
||||
{ isDefault: true, required: true, slug: "title", type: "text", disableOnPrefill: false, hidden: true },
|
||||
{
|
||||
@@ -1185,7 +1181,14 @@ describe("Event types Endpoints", () => {
|
||||
disableOnPrefill: false,
|
||||
hidden: false,
|
||||
},
|
||||
{ isDefault: true, type: "phone", slug: "attendeePhoneNumber", required: false, hidden: true },
|
||||
{
|
||||
disableOnPrefill: false,
|
||||
isDefault: true,
|
||||
type: "phone",
|
||||
slug: "attendeePhoneNumber",
|
||||
required: false,
|
||||
hidden: true,
|
||||
},
|
||||
{
|
||||
isDefault: true,
|
||||
required: false,
|
||||
@@ -1610,7 +1613,6 @@ describe("Event types Endpoints", () => {
|
||||
type: "radioInput",
|
||||
slug: "location",
|
||||
required: false,
|
||||
disableOnPrefill: false,
|
||||
hidden: false,
|
||||
},
|
||||
{
|
||||
@@ -1621,6 +1623,14 @@ describe("Event types Endpoints", () => {
|
||||
disableOnPrefill: false,
|
||||
hidden: true,
|
||||
},
|
||||
{
|
||||
isDefault: true,
|
||||
type: "textarea",
|
||||
slug: "notes",
|
||||
required: false,
|
||||
disableOnPrefill: false,
|
||||
hidden: false,
|
||||
},
|
||||
{
|
||||
isDefault: true,
|
||||
type: "multiemail",
|
||||
@@ -1637,14 +1647,6 @@ describe("Event types Endpoints", () => {
|
||||
disableOnPrefill: false,
|
||||
hidden: false,
|
||||
},
|
||||
{
|
||||
isDefault: true,
|
||||
type: "textarea",
|
||||
slug: "notes",
|
||||
required: false,
|
||||
disableOnPrefill: false,
|
||||
hidden: false,
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
+1
-13
@@ -243,19 +243,7 @@ export class OutputEventTypesService_2024_06_14 {
|
||||
}
|
||||
}
|
||||
|
||||
const fields = [...transformBookingFieldsInternalToApi(knownBookingFields), ...unknownBookingFields];
|
||||
|
||||
// ensure additional notes are always at the end
|
||||
return fields.sort((a, b) => {
|
||||
if (!a?.slug || !b?.slug) return 0;
|
||||
if (a.slug === "notes" && b.slug !== "notes") {
|
||||
return 1;
|
||||
}
|
||||
if (b.slug === "notes" && a.slug !== "notes") {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
return [...transformBookingFieldsInternalToApi(knownBookingFields), ...unknownBookingFields];
|
||||
}
|
||||
|
||||
getDefaultBookingFields(isOrgTeamEvent: boolean) {
|
||||
|
||||
+27
-19
@@ -590,6 +590,7 @@ describe("Organizations Event Types Endpoints", () => {
|
||||
slug: "attendeePhoneNumber",
|
||||
required: true,
|
||||
label: "Phone number",
|
||||
hidden: true,
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -623,7 +624,6 @@ describe("Organizations Event Types Endpoints", () => {
|
||||
type: "radioInput",
|
||||
slug: "location",
|
||||
required: false,
|
||||
disableOnPrefill: false,
|
||||
hidden: false,
|
||||
},
|
||||
{
|
||||
@@ -632,6 +632,8 @@ describe("Organizations Event Types Endpoints", () => {
|
||||
slug: "attendeePhoneNumber",
|
||||
required: true,
|
||||
hidden: true,
|
||||
label: "Phone number",
|
||||
disableOnPrefill: false,
|
||||
},
|
||||
{
|
||||
isDefault: true,
|
||||
@@ -641,6 +643,14 @@ describe("Organizations Event Types Endpoints", () => {
|
||||
disableOnPrefill: false,
|
||||
hidden: true,
|
||||
},
|
||||
{
|
||||
isDefault: true,
|
||||
type: "textarea",
|
||||
slug: "notes",
|
||||
required: false,
|
||||
disableOnPrefill: false,
|
||||
hidden: false,
|
||||
},
|
||||
{
|
||||
isDefault: true,
|
||||
type: "multiemail",
|
||||
@@ -657,14 +667,6 @@ describe("Organizations Event Types Endpoints", () => {
|
||||
disableOnPrefill: false,
|
||||
hidden: false,
|
||||
},
|
||||
{
|
||||
isDefault: true,
|
||||
type: "textarea",
|
||||
slug: "notes",
|
||||
required: false,
|
||||
disableOnPrefill: false,
|
||||
hidden: false,
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -771,13 +773,19 @@ describe("Organizations Event Types Endpoints", () => {
|
||||
expect(fetchedEventType.bookingFields).toEqual([
|
||||
{ isDefault: true, required: true, slug: "name", type: "name", disableOnPrefill: false },
|
||||
{ isDefault: true, required: true, slug: "email", type: "email", disableOnPrefill: false },
|
||||
{ isDefault: true, type: "phone", slug: "attendeePhoneNumber", required: false, hidden: true },
|
||||
{
|
||||
disableOnPrefill: false,
|
||||
isDefault: true,
|
||||
type: "phone",
|
||||
slug: "attendeePhoneNumber",
|
||||
required: false,
|
||||
hidden: true,
|
||||
},
|
||||
{
|
||||
isDefault: true,
|
||||
type: "radioInput",
|
||||
slug: "location",
|
||||
required: false,
|
||||
disableOnPrefill: false,
|
||||
hidden: false,
|
||||
},
|
||||
{
|
||||
@@ -788,6 +796,14 @@ describe("Organizations Event Types Endpoints", () => {
|
||||
disableOnPrefill: false,
|
||||
hidden: true,
|
||||
},
|
||||
{
|
||||
isDefault: true,
|
||||
required: false,
|
||||
slug: "notes",
|
||||
type: "textarea",
|
||||
disableOnPrefill: false,
|
||||
hidden: false,
|
||||
},
|
||||
{
|
||||
isDefault: true,
|
||||
required: false,
|
||||
@@ -804,14 +820,6 @@ describe("Organizations Event Types Endpoints", () => {
|
||||
disableOnPrefill: false,
|
||||
hidden: false,
|
||||
},
|
||||
{
|
||||
isDefault: true,
|
||||
required: false,
|
||||
slug: "notes",
|
||||
type: "textarea",
|
||||
disableOnPrefill: false,
|
||||
hidden: false,
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -86,6 +86,10 @@ function getBaseProperties(field: InputBookingField): CustomField | SystemField
|
||||
return {
|
||||
...systemBeforeFieldPhone,
|
||||
required: field.required,
|
||||
hidden: field.hidden,
|
||||
label: field.label,
|
||||
placeholder: field.placeholder,
|
||||
disableOnPrefill: !!field.disableOnPrefill,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -2,24 +2,34 @@ import { z } from "zod";
|
||||
|
||||
import type {
|
||||
OutputBookingField_2024_06_14,
|
||||
DefaultFieldOutput_2024_06_14,
|
||||
CustomFieldOutput_2024_06_14,
|
||||
SplitNameDefaultFieldOutput_2024_06_14,
|
||||
NameDefaultFieldOutput_2024_06_14,
|
||||
EmailDefaultFieldOutput_2024_06_14,
|
||||
PhoneDefaultFieldOutput_2024_06_14,
|
||||
LocationDefaultFieldOutput_2024_06_14,
|
||||
RescheduleReasonDefaultFieldOutput_2024_06_14,
|
||||
TitleDefaultFieldOutput_2024_06_14,
|
||||
NotesDefaultFieldOutput_2024_06_14,
|
||||
GuestsDefaultFieldOutput_2024_06_14,
|
||||
OutputUnknownBookingField_2024_06_14,
|
||||
AddressFieldOutput_2024_06_14,
|
||||
BooleanFieldOutput_2024_06_14,
|
||||
CheckboxGroupFieldOutput_2024_06_14,
|
||||
MultiEmailFieldOutput_2024_06_14,
|
||||
MultiSelectFieldOutput_2024_06_14,
|
||||
NumberFieldOutput_2024_06_14,
|
||||
PhoneFieldOutput_2024_06_14,
|
||||
RadioGroupFieldOutput_2024_06_14,
|
||||
SelectFieldOutput_2024_06_14,
|
||||
TextAreaFieldOutput_2024_06_14,
|
||||
TextFieldOutput_2024_06_14,
|
||||
} from "@calcom/platform-types";
|
||||
import type { OutputUnknownBookingField_2024_06_14 } from "@calcom/platform-types/event-types/event-types_2024_06_14/outputs/booking-fields.output";
|
||||
|
||||
export function transformBookingFieldsInternalToApi(
|
||||
databaseBookingFields: (SystemField | CustomField)[]
|
||||
): OutputBookingField_2024_06_14[] {
|
||||
const defaultFields: SystemField[] = databaseBookingFields.filter(
|
||||
(field): field is SystemField => field.editable === "system" || field.editable === "system-but-optional"
|
||||
);
|
||||
|
||||
const customFields: CustomField[] = databaseBookingFields.filter(
|
||||
(field): field is CustomField => field.editable === "user"
|
||||
);
|
||||
|
||||
const responseDefaultFields: (DefaultFieldOutput_2024_06_14 | OutputUnknownBookingField_2024_06_14)[] =
|
||||
defaultFields.map((field) => {
|
||||
return databaseBookingFields.map((field) => {
|
||||
if (field.editable === "system" || field.editable === "system-but-optional") {
|
||||
switch (field.name) {
|
||||
case "name": {
|
||||
if (field.variant === "firstAndLastName") {
|
||||
@@ -40,7 +50,7 @@ export function transformBookingFieldsInternalToApi(
|
||||
lastNamePlaceholder: lastNameField?.placeholder,
|
||||
lastNameRequired: !!lastNameField?.required,
|
||||
disableOnPrefill: !!field.disableOnPrefill,
|
||||
};
|
||||
} satisfies SplitNameDefaultFieldOutput_2024_06_14;
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -51,7 +61,7 @@ export function transformBookingFieldsInternalToApi(
|
||||
label: field.variantsConfig?.variants?.fullName?.fields[0]?.label,
|
||||
placeholder: field.variantsConfig?.variants?.fullName?.fields[0]?.placeholder,
|
||||
disableOnPrefill: !!field.disableOnPrefill,
|
||||
};
|
||||
} satisfies NameDefaultFieldOutput_2024_06_14;
|
||||
}
|
||||
case "email":
|
||||
return {
|
||||
@@ -62,93 +72,90 @@ export function transformBookingFieldsInternalToApi(
|
||||
label: field.label,
|
||||
placeholder: field.placeholder,
|
||||
disableOnPrefill: !!field.disableOnPrefill,
|
||||
};
|
||||
} satisfies EmailDefaultFieldOutput_2024_06_14;
|
||||
case "location":
|
||||
return {
|
||||
isDefault: true,
|
||||
type: field.type,
|
||||
slug: field.name,
|
||||
type: "radioInput",
|
||||
slug: "location",
|
||||
required: !!field.required,
|
||||
hidden: !!field.hidden,
|
||||
label: field.label,
|
||||
placeholder: field.placeholder,
|
||||
disableOnPrefill: !!field.disableOnPrefill,
|
||||
};
|
||||
} satisfies LocationDefaultFieldOutput_2024_06_14;
|
||||
case "rescheduleReason":
|
||||
return {
|
||||
isDefault: true,
|
||||
type: field.type,
|
||||
slug: field.name,
|
||||
type: "textarea",
|
||||
slug: "rescheduleReason",
|
||||
required: !!field.required,
|
||||
hidden: !!field.hidden,
|
||||
label: field.label,
|
||||
placeholder: field.placeholder,
|
||||
disableOnPrefill: !!field.disableOnPrefill,
|
||||
};
|
||||
hidden: !!field.hidden,
|
||||
} satisfies RescheduleReasonDefaultFieldOutput_2024_06_14;
|
||||
case "title":
|
||||
return {
|
||||
isDefault: true,
|
||||
type: field.type,
|
||||
slug: field.name,
|
||||
type: "text",
|
||||
slug: "title",
|
||||
required: !!field.required,
|
||||
hidden: !!field.hidden,
|
||||
label: field.label,
|
||||
placeholder: field.placeholder,
|
||||
disableOnPrefill: !!field.disableOnPrefill,
|
||||
};
|
||||
hidden: !!field.hidden,
|
||||
} satisfies TitleDefaultFieldOutput_2024_06_14;
|
||||
case "notes":
|
||||
return {
|
||||
isDefault: true,
|
||||
type: field.type,
|
||||
slug: field.name,
|
||||
type: "textarea",
|
||||
slug: "notes",
|
||||
required: !!field.required,
|
||||
hidden: !!field.hidden,
|
||||
label: field.label,
|
||||
placeholder: field.placeholder,
|
||||
disableOnPrefill: !!field.disableOnPrefill,
|
||||
};
|
||||
hidden: !!field.hidden,
|
||||
} satisfies NotesDefaultFieldOutput_2024_06_14;
|
||||
case "guests":
|
||||
return {
|
||||
isDefault: true,
|
||||
type: field.type,
|
||||
slug: field.name,
|
||||
type: "multiemail",
|
||||
slug: "guests",
|
||||
required: !!field.required,
|
||||
hidden: !!field.hidden,
|
||||
label: field.label,
|
||||
placeholder: field.placeholder,
|
||||
disableOnPrefill: !!field.disableOnPrefill,
|
||||
};
|
||||
hidden: !!field.hidden,
|
||||
} satisfies GuestsDefaultFieldOutput_2024_06_14;
|
||||
case "attendeePhoneNumber":
|
||||
return {
|
||||
isDefault: true,
|
||||
type: field.type,
|
||||
slug: field.name,
|
||||
required: !!field.required,
|
||||
label: field.label,
|
||||
placeholder: field.placeholder,
|
||||
disableOnPrefill: !!field.disableOnPrefill,
|
||||
hidden: !!field.hidden,
|
||||
};
|
||||
} satisfies PhoneDefaultFieldOutput_2024_06_14;
|
||||
default:
|
||||
return {
|
||||
type: "unknown",
|
||||
slug: "unknown",
|
||||
bookingField: JSON.stringify(field),
|
||||
};
|
||||
} satisfies OutputUnknownBookingField_2024_06_14;
|
||||
}
|
||||
});
|
||||
|
||||
const responseCustomFields: (CustomFieldOutput_2024_06_14 | OutputUnknownBookingField_2024_06_14)[] =
|
||||
customFields.map((field) => {
|
||||
} else {
|
||||
switch (field.type) {
|
||||
case "phone":
|
||||
return {
|
||||
isDefault: false,
|
||||
type: field.type,
|
||||
slug: field.name,
|
||||
label: field.label,
|
||||
label: field.label || "",
|
||||
required: !!field.required,
|
||||
placeholder: field.placeholder,
|
||||
disableOnPrefill: !!field.disableOnPrefill,
|
||||
hidden: !!field.hidden,
|
||||
};
|
||||
} satisfies PhoneFieldOutput_2024_06_14;
|
||||
case "address":
|
||||
return {
|
||||
isDefault: false,
|
||||
@@ -159,18 +166,18 @@ export function transformBookingFieldsInternalToApi(
|
||||
placeholder: field.placeholder,
|
||||
disableOnPrefill: !!field.disableOnPrefill,
|
||||
hidden: !!field.hidden,
|
||||
};
|
||||
} satisfies AddressFieldOutput_2024_06_14;
|
||||
case "text":
|
||||
return {
|
||||
isDefault: false,
|
||||
type: field.type,
|
||||
slug: field.name,
|
||||
label: field.label,
|
||||
label: field.label || "",
|
||||
required: !!field.required,
|
||||
placeholder: field.placeholder,
|
||||
disableOnPrefill: !!field.disableOnPrefill,
|
||||
hidden: !!field.hidden,
|
||||
};
|
||||
} satisfies TextFieldOutput_2024_06_14;
|
||||
case "number":
|
||||
return {
|
||||
isDefault: false,
|
||||
@@ -181,29 +188,29 @@ export function transformBookingFieldsInternalToApi(
|
||||
placeholder: field.placeholder,
|
||||
disableOnPrefill: !!field.disableOnPrefill,
|
||||
hidden: !!field.hidden,
|
||||
};
|
||||
} satisfies NumberFieldOutput_2024_06_14;
|
||||
case "textarea":
|
||||
return {
|
||||
isDefault: false,
|
||||
type: field.type,
|
||||
slug: field.name,
|
||||
label: field.label,
|
||||
label: field.label || "",
|
||||
required: !!field.required,
|
||||
placeholder: field.placeholder,
|
||||
disableOnPrefill: !!field.disableOnPrefill,
|
||||
hidden: !!field.hidden,
|
||||
};
|
||||
} satisfies TextAreaFieldOutput_2024_06_14;
|
||||
case "multiemail":
|
||||
return {
|
||||
isDefault: false,
|
||||
type: field.type,
|
||||
slug: field.name,
|
||||
label: field.label,
|
||||
label: field.label || "",
|
||||
required: !!field.required,
|
||||
placeholder: field.placeholder,
|
||||
disableOnPrefill: !!field.disableOnPrefill,
|
||||
hidden: !!field.hidden,
|
||||
};
|
||||
} satisfies MultiEmailFieldOutput_2024_06_14;
|
||||
case "boolean":
|
||||
return {
|
||||
isDefault: false,
|
||||
@@ -213,7 +220,7 @@ export function transformBookingFieldsInternalToApi(
|
||||
required: !!field.required,
|
||||
disableOnPrefill: !!field.disableOnPrefill,
|
||||
hidden: !!field.hidden,
|
||||
};
|
||||
} satisfies BooleanFieldOutput_2024_06_14;
|
||||
case "select":
|
||||
return {
|
||||
isDefault: false,
|
||||
@@ -222,10 +229,10 @@ export function transformBookingFieldsInternalToApi(
|
||||
label: field.label,
|
||||
required: !!field.required,
|
||||
placeholder: field.placeholder,
|
||||
options: field.options ? field.options.map((option) => option.value) : [],
|
||||
disableOnPrefill: !!field.disableOnPrefill,
|
||||
options: field.options ? field.options.map((option) => option.value) : [],
|
||||
hidden: !!field.hidden,
|
||||
};
|
||||
} satisfies SelectFieldOutput_2024_06_14;
|
||||
case "multiselect":
|
||||
return {
|
||||
isDefault: false,
|
||||
@@ -233,10 +240,10 @@ export function transformBookingFieldsInternalToApi(
|
||||
slug: field.name,
|
||||
label: field.label,
|
||||
required: !!field.required,
|
||||
options: field.options ? field.options?.map((option) => option.value) : [],
|
||||
disableOnPrefill: !!field.disableOnPrefill,
|
||||
options: field.options ? field.options.map((option) => option.value) : [],
|
||||
hidden: !!field.hidden,
|
||||
};
|
||||
} satisfies MultiSelectFieldOutput_2024_06_14;
|
||||
case "checkbox":
|
||||
return {
|
||||
isDefault: false,
|
||||
@@ -244,10 +251,10 @@ export function transformBookingFieldsInternalToApi(
|
||||
slug: field.name,
|
||||
label: field.label,
|
||||
required: !!field.required,
|
||||
options: field.options ? field.options?.map((option) => option.value) : [],
|
||||
disableOnPrefill: !!field.disableOnPrefill,
|
||||
options: field.options ? field.options.map((option) => option.value) : [],
|
||||
hidden: !!field.hidden,
|
||||
};
|
||||
} satisfies CheckboxGroupFieldOutput_2024_06_14;
|
||||
case "radio":
|
||||
return {
|
||||
isDefault: false,
|
||||
@@ -255,20 +262,19 @@ export function transformBookingFieldsInternalToApi(
|
||||
slug: field.name,
|
||||
label: field.label,
|
||||
required: !!field.required,
|
||||
options: field.options ? field.options?.map((option) => option.value) : [],
|
||||
options: field.options ? field.options.map((option) => option.value) : [],
|
||||
disableOnPrefill: !!field.disableOnPrefill,
|
||||
hidden: !!field.hidden,
|
||||
};
|
||||
} satisfies RadioGroupFieldOutput_2024_06_14;
|
||||
default:
|
||||
return {
|
||||
type: "unknown",
|
||||
slug: "unknown",
|
||||
bookingField: JSON.stringify(field),
|
||||
};
|
||||
} satisfies OutputUnknownBookingField_2024_06_14;
|
||||
}
|
||||
});
|
||||
|
||||
return [...responseDefaultFields, ...responseCustomFields];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const CustomFieldTypeEnum = z.enum([
|
||||
@@ -382,17 +388,19 @@ const NameSystemFieldSchema = SystemFieldSchema.extend({
|
||||
})
|
||||
),
|
||||
}),
|
||||
firstAndLastName: z.object({
|
||||
fields: z.array(
|
||||
z.object({
|
||||
name: z.enum(["firstName", "lastName"]),
|
||||
type: z.literal("text"),
|
||||
label: z.string().optional(),
|
||||
required: z.boolean(),
|
||||
placeholder: z.string().optional(),
|
||||
})
|
||||
),
|
||||
}),
|
||||
firstAndLastName: z
|
||||
.object({
|
||||
fields: z.array(
|
||||
z.object({
|
||||
name: z.enum(["firstName", "lastName"]),
|
||||
type: z.literal("text"),
|
||||
label: z.string().optional(),
|
||||
required: z.boolean(),
|
||||
placeholder: z.string().optional(),
|
||||
})
|
||||
),
|
||||
})
|
||||
.optional(),
|
||||
}),
|
||||
})
|
||||
.optional(),
|
||||
|
||||
@@ -835,6 +835,9 @@ describe("transformBookingFieldsInternalToApi", () => {
|
||||
slug: "attendeePhoneNumber",
|
||||
required: false,
|
||||
hidden: true,
|
||||
disableOnPrefill: false,
|
||||
label: undefined,
|
||||
placeholder: undefined,
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
@@ -169,6 +169,7 @@ async function createMembership(orgId: number, teamId: number, userId: number) {
|
||||
body: JSON.stringify({
|
||||
userId,
|
||||
accepted: true,
|
||||
role: "ADMIN",
|
||||
}),
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,34 +1,16 @@
|
||||
# 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
|
||||
|
||||
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:
|
||||
Here is the workflow:
|
||||
1. If you change platform libraries for the first time, then run `yarn local` to build them locally for the first time. This will also make v2 api point to the local libraries.
|
||||
2. If you change them for the second time, then run `yarn build:dev` to re-build them.
|
||||
3. Once you are happy with platform libraries:
|
||||
- run `yarn publish` - it will check "@calcom/platform-libraries" version in npm and update it's package.json to the next version and then it will publish the package to np.
|
||||
- run `yarn postpublish` - it will update the version of "@calcom/platform-libraries" in the api v2 package.json, reset "@calcom/platform-libraries" to 0.0.0 and run yarn install.
|
||||
|
||||
- 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
|
||||
note(Lauris) - we could have 1 publish script but the problem is that `yarn publish` does not exit for some reason.
|
||||
|
||||
# Before Merging to main
|
||||
|
||||
|
||||
@@ -12,7 +12,9 @@
|
||||
"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"
|
||||
"local": "node scripts/local.js && rm -rf dist && yarn build:dev && cd ../../.. && yarn",
|
||||
"publish": "yarn && node scripts/prepublish.js && rm -rf dist && yarn build && npm publish --access public",
|
||||
"postpublish": "node scripts/postpublish.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@calcom/core": "*",
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const VERSION = "9.9.9";
|
||||
|
||||
// note(Lauris): update libraries package.json version
|
||||
const librariesPath = path.join(__dirname, "..");
|
||||
const librariesPackageJsonPath = path.join(librariesPath, "package.json");
|
||||
const librariesPackageJson = JSON.parse(fs.readFileSync(librariesPackageJsonPath, "utf8"));
|
||||
|
||||
librariesPackageJson.version = VERSION;
|
||||
|
||||
fs.writeFileSync(librariesPackageJsonPath, `${JSON.stringify(librariesPackageJson, null, 2)}\n`);
|
||||
|
||||
// note(Lauris): update API v2 package.json dependency
|
||||
const apiV2PackageJsonPath = path.join(librariesPath, "..", "..", "..", "apps", "api", "v2", "package.json");
|
||||
const apiV2PackageJson = JSON.parse(fs.readFileSync(apiV2PackageJsonPath, "utf8"));
|
||||
|
||||
apiV2PackageJson.dependencies["@calcom/platform-libraries"] = `npm:@calcom/platform-libraries@${VERSION}`;
|
||||
|
||||
fs.writeFileSync(apiV2PackageJsonPath, `${JSON.stringify(apiV2PackageJson, null, 2)}\n`);
|
||||
@@ -0,0 +1,58 @@
|
||||
import { spawn } from "child_process";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
// Get the published version before resetting
|
||||
const librariesPath = path.join(__dirname, "..");
|
||||
const librariesPackageJsonPath = path.join(librariesPath, "package.json");
|
||||
const librariesPackageJson = JSON.parse(fs.readFileSync(librariesPackageJsonPath, "utf8"));
|
||||
const publishedVersion = librariesPackageJson.version;
|
||||
|
||||
// Reset libraries package.json version to 0.0.0
|
||||
librariesPackageJson.version = "0.0.0";
|
||||
fs.writeFileSync(librariesPackageJsonPath, `${JSON.stringify(librariesPackageJson, null, 2)}\n`);
|
||||
|
||||
// Update API v2 package.json dependency
|
||||
const apiV2PackageJsonPath = path.join(
|
||||
librariesPath,
|
||||
"..",
|
||||
"..",
|
||||
"..",
|
||||
"apps",
|
||||
"api",
|
||||
"v2",
|
||||
"package.json"
|
||||
);
|
||||
const apiV2PackageJson = JSON.parse(fs.readFileSync(apiV2PackageJsonPath, "utf8"));
|
||||
|
||||
apiV2PackageJson.dependencies[
|
||||
"@calcom/platform-libraries"
|
||||
] = `npm:@calcom/platform-libraries@${publishedVersion}`;
|
||||
fs.writeFileSync(apiV2PackageJsonPath, `${JSON.stringify(apiV2PackageJson, null, 2)}\n`);
|
||||
|
||||
// Run yarn install
|
||||
const yarnInstall = spawn("yarn", ["install"], {
|
||||
stdio: "inherit",
|
||||
cwd: path.join(librariesPath, "..", "..", ".."),
|
||||
});
|
||||
|
||||
yarnInstall.on("close", (code) => {
|
||||
if (code !== 0) {
|
||||
console.error("yarn install failed");
|
||||
process.exit(1);
|
||||
}
|
||||
console.log("Successfully reset version and updated dependencies");
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Error:", error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
@@ -0,0 +1,65 @@
|
||||
import fs from "fs";
|
||||
import https from "https";
|
||||
import path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
// Fetch current version from npm registry
|
||||
function getCurrentVersion() {
|
||||
return new Promise((resolve, reject) => {
|
||||
https
|
||||
.get(
|
||||
"https://registry.npmjs.org/@calcom/platform-libraries",
|
||||
{
|
||||
headers: { Accept: "application/json" },
|
||||
},
|
||||
(res) => {
|
||||
let data = "";
|
||||
res.on("data", (chunk) => (data += chunk));
|
||||
res.on("end", () => {
|
||||
try {
|
||||
const packageInfo = JSON.parse(data);
|
||||
const currentVersion = packageInfo["dist-tags"].latest;
|
||||
resolve(currentVersion);
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
)
|
||||
.on("error", reject);
|
||||
});
|
||||
}
|
||||
|
||||
// Increment patch version (a.b.c -> a.b.c+1)
|
||||
function incrementPatchVersion(version) {
|
||||
const parts = version.split(".");
|
||||
parts[2] = String(Number(parts[2]) + 1);
|
||||
return parts.join(".");
|
||||
}
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
// Get and increment version
|
||||
const currentVersion = await getCurrentVersion();
|
||||
const newVersion = incrementPatchVersion(currentVersion);
|
||||
console.log(`Current version in npm: ${currentVersion}. Incremented locally to ${newVersion}`);
|
||||
|
||||
// Update libraries package.json version
|
||||
const librariesPath = path.join(__dirname, "..");
|
||||
const librariesPackageJsonPath = path.join(librariesPath, "package.json");
|
||||
const librariesPackageJson = JSON.parse(fs.readFileSync(librariesPackageJsonPath, "utf8"));
|
||||
|
||||
librariesPackageJson.version = newVersion;
|
||||
fs.writeFileSync(librariesPackageJsonPath, `${JSON.stringify(librariesPackageJson, null, 2)}\n`);
|
||||
|
||||
console.log("Successfully incremented @calcom/platform-libraries package.json version.");
|
||||
} catch (error) {
|
||||
console.error("Error:", error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
+27
@@ -371,6 +371,33 @@ export class PhoneDefaultFieldOutput_2024_06_14 {
|
||||
@IsBoolean()
|
||||
@DocsProperty()
|
||||
required!: boolean;
|
||||
|
||||
@IsBoolean()
|
||||
@DocsProperty({
|
||||
description:
|
||||
"If true show under event type settings but don't show this booking field in the Booker. If false show in both.",
|
||||
})
|
||||
hidden!: boolean;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
@DocsProperty()
|
||||
label?: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
@DocsProperty()
|
||||
placeholder?: string;
|
||||
|
||||
@IsBoolean()
|
||||
@ApiProperty({
|
||||
type: Boolean,
|
||||
description:
|
||||
"Disable this booking field if the URL contains query parameter with key equal to the slug and prefill it with the provided value.\
|
||||
For example, if URL contains query parameter `&attendeePhoneNumber=+37122222222`,\
|
||||
the guests field will be prefilled with this value and disabled.",
|
||||
})
|
||||
disableOnPrefill!: boolean;
|
||||
}
|
||||
|
||||
export class PhoneFieldOutput_2024_06_14 extends PhoneFieldInput_2024_06_14 {
|
||||
|
||||
@@ -3498,7 +3498,7 @@ __metadata:
|
||||
"@axiomhq/winston": ^1.2.0
|
||||
"@calcom/platform-constants": "*"
|
||||
"@calcom/platform-enums": "*"
|
||||
"@calcom/platform-libraries": "npm:@calcom/platform-libraries@0.0.82"
|
||||
"@calcom/platform-libraries": "npm:@calcom/platform-libraries@0.0.85"
|
||||
"@calcom/platform-libraries-0.0.2": "npm:@calcom/platform-libraries@0.0.2"
|
||||
"@calcom/platform-types": "*"
|
||||
"@calcom/platform-utils": "*"
|
||||
@@ -4514,14 +4514,14 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@calcom/platform-libraries@npm:@calcom/platform-libraries@0.0.82":
|
||||
version: 0.0.82
|
||||
resolution: "@calcom/platform-libraries@npm:0.0.82"
|
||||
"@calcom/platform-libraries@npm:@calcom/platform-libraries@0.0.85":
|
||||
version: 0.0.85
|
||||
resolution: "@calcom/platform-libraries@npm:0.0.85"
|
||||
dependencies:
|
||||
"@calcom/core": "*"
|
||||
"@calcom/features": "*"
|
||||
"@calcom/lib": "*"
|
||||
checksum: 46c8d73dcd0a21faa40cbf0605686dcff70d0f8b9e42410ce2e4252fba73d8c618a3b8f9729f503fc7200a2d36ac9b38d6b9570598c8efdafcfbac04722fa405
|
||||
checksum: 19e00a1de600805d800fc7027c246164f1c1ce58b837ca934313fe31c0c77e6338179e72b8045ceabcc9d754ddc3600028b8676dcf2b456696a443a3aed186ea
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
||||
Reference in New Issue
Block a user