Skip to content

Commit

Permalink
undo linting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
SomayChauhan committed Oct 9, 2024
1 parent 4999a3a commit fbc623f
Show file tree
Hide file tree
Showing 23 changed files with 113 additions and 130 deletions.
6 changes: 3 additions & 3 deletions packages/app-store/routing-forms/components/SingleForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ function SingleForm({ form, appUrl, Page, enrichedWithUserProfileForm }: SingleF

function testRouting() {
const route = findMatchingRoute({ form, response });

if (route?.action?.type === "eventTypeRedirectUrl") {
setEventTypeUrl(
enrichedWithUserProfileForm
Expand All @@ -271,9 +271,9 @@ function SingleForm({ form, appUrl, Page, enrichedWithUserProfileForm }: SingleF
: ""
);
}

setChosenRoute(route || null);

if (!route) return;

findTeamMembersMatchingAttributeLogicMutation.mutate({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
// This is taken from "react-awesome-query-builder/lib/config/basic";
import type {
Operators as RAQBOperators,
Conjunction as RAQBConjunction,
Widget as RAQBWidget,
Type as RAQBType,
Settings as RAQBSettings,
Operator as RAQBOperator,
} from "react-awesome-query-builder";

export type Conjunction = Omit<
RAQBConjunction,
"formatConj" | "sqlFormatConj" | "spelFormatConj" | "mongoConj"
>;
export type Conjunction = Omit<RAQBConjunction, "formatConj" | "sqlFormatConj" | "spelFormatConj" | "mongoConj">;
export type Conjunctions = Record<string, Conjunction>;
export type Operator = RAQBOperator & {
_jsonLogicIsExclamationOp?: boolean;
};
}
export type Operators = Record<string, Operator>;
export type WidgetWithoutFactory = Omit<RAQBWidget, "factory"> & {
type: string;
Expand Down Expand Up @@ -452,4 +450,4 @@ export default {
widgets,
types,
settings,
};
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CAL_URL } from "@calcom/lib/constants";
import type { Ensure } from "@calcom/types/utils";
import { Ensure } from "@calcom/types/utils";

function getUserAndEventTypeSlug(eventTypeRedirectUrl: string) {
if (eventTypeRedirectUrl.startsWith("/")) {
Expand Down
5 changes: 1 addition & 4 deletions packages/app-store/routing-forms/lib/InitialConfig.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
FormFieldsBaseConfig,
AttributesBaseConfig,
} from "../components/react-awesome-query-builder/config/config";
import { FormFieldsBaseConfig, AttributesBaseConfig } from "../components/react-awesome-query-builder/config/config";

export const FormFieldsInitialConfig = FormFieldsBaseConfig;
export const AttributesInitialConfig = AttributesBaseConfig;
10 changes: 2 additions & 8 deletions packages/app-store/routing-forms/lib/evaluateRaqbLogic.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
"use client";

import { Utils as QbUtils, type JsonTree } from "react-awesome-query-builder";

import { safeStringify } from "@calcom/lib/safeStringify";

import jsonLogic from "./jsonLogic";

import { safeStringify } from "@calcom/lib/safeStringify";
export const enum RaqbLogicResult {
MATCH = "MATCH",
NO_MATCH = "NO_MATCH",
Expand Down Expand Up @@ -33,10 +30,7 @@ export const evaluateRaqbLogic = ({
if (beStrictWithEmptyLogic && queryValue.children1 && Object.keys(queryValue.children1).length > 0) {
throw new Error("Couldn't build the logic from the query value");
}
console.log(
"No logic found",
safeStringify({ queryValue, queryBuilderConfigFields: queryBuilderConfig.fields })
);
console.log("No logic found", safeStringify({ queryValue, queryBuilderConfigFields: queryBuilderConfig.fields }));
// If no logic is provided, then consider it a match
return RaqbLogicResult.LOGIC_NOT_FOUND_SO_MATCHED;
}
Expand Down
9 changes: 4 additions & 5 deletions packages/app-store/routing-forms/lib/getAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
import logger from "@calcom/lib/logger";
import { safeStringify } from "@calcom/lib/safeStringify";
import prisma from "@calcom/prisma";

import type { Attribute } from "../types/types";

async function getAttributeToUserWithMembershipAndAttributesForTeam({ teamId }: { teamId: number }) {
const log = logger.getSubLogger({ prefix: ["getAttributeToUserWithMembershipAndAttributes"] });
let log = logger.getSubLogger({ prefix: ["getAttributeToUserWithMembershipAndAttributes"] });

const whereClauseForAttributesAssignedToMembersOfTeam = {
member: {
Expand Down Expand Up @@ -53,9 +52,9 @@ async function getAttributeToUserWithMembershipAndAttributesForTeam({ teamId }:
}

async function getAttributesAssignedToMembersOfTeam({ teamId }: { teamId: number }) {
const log = logger.getSubLogger({ prefix: ["getAttributeToUserWithMembershipAndAttributes"] });
let log = logger.getSubLogger({ prefix: ["getAttributeToUserWithMembershipAndAttributes"] });

const whereClauseForAttributesAssignedToMembersOfTeam = {
const whereClauseForAttributesAssignedToMembersOfTeam = {
options: {
some: {
assignedUsers: {
Expand All @@ -73,7 +72,7 @@ async function getAttributesAssignedToMembersOfTeam({ teamId }: { teamId: number
},
},
},
};
}

log.debug(
safeStringify({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { AttributeType } from "@calcom/prisma/enums";

import type { RoutingForm, Attribute } from "../types/types";
import { FieldTypes, RoutingFormFieldType } from "./FieldTypes";
import { AttributesInitialConfig, FormFieldsInitialConfig } from "./InitialConfig";
Expand Down
5 changes: 2 additions & 3 deletions packages/app-store/routing-forms/lib/getSerializableForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import type { App_RoutingForms_Form } from "@prisma/client";
import type { z } from "zod";

import { entityPrismaWhereClause } from "@calcom/lib/entityPermissionUtils";
import logger from "@calcom/lib/logger";
import { safeStringify } from "@calcom/lib/safeStringify";
import { RoutingFormSettings } from "@calcom/prisma/zod-utils";

import type { SerializableForm, SerializableFormTeamMembers } from "../types/types";
Expand All @@ -13,7 +11,8 @@ import getConnectedForms from "./getConnectedForms";
import isRouter from "./isRouter";
import isRouterLinkedField from "./isRouterLinkedField";
import { getFieldWithOptions } from "./selectOptions";

import logger from "@calcom/lib/logger";
import { safeStringify } from "@calcom/lib/safeStringify";
const log = logger.getSubLogger({ prefix: ["getSerializableForm"] });
/**
* Doesn't have deleted fields by default
Expand Down
4 changes: 2 additions & 2 deletions packages/app-store/routing-forms/lib/processRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import type { z } from "zod";

import type { FormResponse, Route, SerializableForm } from "../types/types";
import type { zodNonRouterRoute } from "../zod";
import { evaluateRaqbLogic, RaqbLogicResult } from "./evaluateRaqbLogic";
import { getQueryBuilderConfigForFormFields } from "./getQueryBuilderConfig";
import { isFallbackRoute } from "./isFallbackRoute";
import isRouter from "./isRouter";
import { evaluateRaqbLogic, RaqbLogicResult } from "./evaluateRaqbLogic";

export function findMatchingRoute({
form,
Expand Down Expand Up @@ -54,7 +54,7 @@ export function findMatchingRoute({
queryBuilderConfig,
data: responseValues,
});

if (result === RaqbLogicResult.MATCH || result === RaqbLogicResult.LOGIC_NOT_FOUND_SO_MATCHED) {
chosenRoute = route;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ describe("getUrlSearchParamsToForward", () => {
fields,
searchParams,
teamMembersMatchingAttributeLogic: null,
formResponseId: 1,
formResponseId: 1
});
expect(fromEntriesWithDuplicateKeys(result.entries())).toEqual(expectedParams);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ export function getUrlSearchParamsToForward({
// In case of conflict b/w paramsFromResponse and paramsFromCurrentUrl, paramsFromResponse should win as the booker probably improved upon the prefilled value.
...paramsFromResponse,
...(teamMembersMatchingAttributeLogic
? { ["cal.routedTeamMemberIds"]: teamMembersMatchingAttributeLogic.join(",") }
? { ['cal.routedTeamMemberIds']: teamMembersMatchingAttributeLogic.join(",") }
: null),
["cal.routingFormResponseId"]: String(formResponseId),
['cal.routingFormResponseId']: String(formResponseId),
};

const allQueryURLSearchParams = new URLSearchParams();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ test.describe("Routing Forms", () => {
);
await expect(page.locator("text=Multiselect chosen")).toBeVisible({ timeout: 10000 });

// Negative test - Ensures that the "No logic" situation where a Route is considered to be always passing isn't hitting
// Negative test - Ensures that the "No logic" situation where a Route is considered to be always passing isn't hitting
await page.goto(`/router?form=${routingForm.id}&Test field=kuchbhi`);
await page.waitForURL((url) => {
return url.searchParams.get("Test field") === "kuchbhi";
Expand Down
4 changes: 2 additions & 2 deletions packages/app-store/routing-forms/trpc/_router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import publicProcedure from "@calcom/trpc/server/procedures/publicProcedure";
import { router } from "@calcom/trpc/server/trpc";

import { ZDeleteFormInputSchema } from "./deleteForm.schema";
import { ZFindTeamMembersMatchingAttributeLogicInputSchema } from "./findTeamMembersMatchingAttributeLogic.schema";
import { ZFormMutationInputSchema } from "./formMutation.schema";
import { ZFormQueryInputSchema } from "./formQuery.schema";
import { ZGetAttributesForTeamInputSchema } from "./getAttributesForTeam.schema";
import { forms } from "./procedures/forms";
import { ZReportInputSchema } from "./report.schema";
import { ZResponseInputSchema } from "./response.schema";
import { ZGetAttributesForTeamInputSchema } from "./getAttributesForTeam.schema";
import { ZFindTeamMembersMatchingAttributeLogicInputSchema } from "./findTeamMembersMatchingAttributeLogic.schema";

// eslint-disable-next-line @typescript-eslint/ban-types
const UNSTABLE_HANDLER_CACHE: Record<string, Function> = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { z } from "zod";
export const ZFindTeamMembersMatchingAttributeLogicInputSchema = z.object({
formId: z.string(),
response: z.record(z.string(), z.any()),
routeId: z.string(),
routeId: z.string()
});

export type TFindTeamMembersMatchingAttributeLogicInputSchema = z.infer<
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { MembershipRepository } from "@calcom/lib/server/repository/membership";
import type { TrpcSessionUser } from "@calcom/trpc/server/trpc";

import { TRPCError } from "@trpc/server";
import type { TrpcSessionUser } from "@calcom/trpc/server/trpc";

import { getAttributesForTeam } from "../lib/getAttributes";
import type { TGetAttributesForTeamInputSchema } from "./getAttributesForTeam.schema";
import { getAttributesForTeam } from "../lib/getAttributes";
import { MembershipRepository } from "@calcom/lib/server/repository/membership";

type GetAttributesForTeamHandlerOptions = {
ctx: {
Expand All @@ -29,4 +28,4 @@ export default async function getAttributesForTeamHandler({
}

return getAttributesForTeam({ teamId });
}
}
25 changes: 13 additions & 12 deletions packages/app-store/routing-forms/trpc/raqbUtils.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import type { App_RoutingForms_Form } from "@prisma/client";
import type { JsonGroup, JsonItem, JsonRule, JsonTree } from "react-awesome-query-builder";
import type { App_RoutingForms_Form, User } from "@prisma/client";
import { JsonGroup, JsonItem, JsonRule, JsonTree } from "react-awesome-query-builder";

import logger from "@calcom/lib/logger";
import { safeStringify } from "@calcom/lib/safeStringify";

import type { AttributesQueryBuilderConfigWithRaqbFields } from "../lib/getQueryBuilderConfig";
import { getQueryBuilderConfigForAttributes } from "../lib/getQueryBuilderConfig";
import type { Attribute } from "../types/types";
import {
AttributesQueryBuilderConfigWithRaqbFields,
getQueryBuilderConfigForAttributes,
} from "../lib/getQueryBuilderConfig";
import { Attribute } from "../types/types";
import type { LocalRoute } from "../types/types";
import type { FormResponse, SerializableForm } from "../types/types";
import type { SerializableField } from "../types/types";
Expand Down Expand Up @@ -173,11 +175,10 @@ const attributeChangeCompatibility = {
attributesQueryValue: NonNullable<LocalRoute["attributesQueryValue"]>;
attributeId: string;
}) {
const fieldTypeFromAttributesQueryValue =
raqbQueryValueUtils.getValueTypeFromAttributesQueryValueForRaqbField({
attributesQueryValue,
raqbFieldId: attributeId,
});
const fieldTypeFromAttributesQueryValue = raqbQueryValueUtils.getValueTypeFromAttributesQueryValueForRaqbField({
attributesQueryValue,
raqbFieldId: attributeId,
});

if (fieldTypeFromAttributesQueryValue === "multiselect") {
return ensureArray(attributeValue);
Expand All @@ -194,7 +195,7 @@ function getAttributesData({
attributesQueryValue: NonNullable<LocalRoute["attributesQueryValue"]>;
}) {
return Object.entries(attributesData).reduce((acc, [attributeId, value]) => {
const compatibleValueForAttributeAndFormFieldMatching = compatibleForAttributeAndFormFieldMatch(value);
let compatibleValueForAttributeAndFormFieldMatching = compatibleForAttributeAndFormFieldMatch(value);

// We do this to ensure that correct jsonLogic is generated for an existing route even if the attribute's type changes
acc[attributeId] = attributeChangeCompatibility.ensureAttributeValueToBeOfRaqbFieldValueType({
Expand Down Expand Up @@ -263,7 +264,7 @@ function getAttributesQueryBuilderConfig({

const attributesQueryBuilderConfigFieldsWithCompatibleListValues = Object.fromEntries(
Object.entries(attributesQueryBuilderConfig.fields).map(([raqbFieldId, raqbField]) => {
const raqbFieldType = attributeChangeCompatibility.getRaqbFieldTypeCompatibleWithQueryValue({
let raqbFieldType = attributeChangeCompatibility.getRaqbFieldTypeCompatibleWithQueryValue({
attributesQueryValue,
raqbField,
raqbFieldId,
Expand Down
5 changes: 1 addition & 4 deletions packages/app-store/routing-forms/trpc/response.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,7 @@ export const responseHandler = async ({ ctx, input }: ResponseHandlerOptions) =>
dbFormResponse.response as FormResponse
);

return {
formResponse: dbFormResponse,
teamMembersMatchingAttributeLogic: teamMemberIdsMatchingAttributeLogic,
};
return { formResponse: dbFormResponse, teamMembersMatchingAttributeLogic: teamMemberIdsMatchingAttributeLogic };
} catch (e) {
if (e instanceof Prisma.PrismaClientKnownRequestError) {
if (e.code === "P2002") {
Expand Down
13 changes: 6 additions & 7 deletions packages/app-store/routing-forms/trpc/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ import type { SerializableField, OrderedResponses } from "../types/types";
import type { FormResponse, SerializableForm } from "../types/types";
import { acrossQueryValueCompatiblity } from "./raqbUtils";

const {
getAttributesData: getAttributes,
getAttributesQueryBuilderConfig,
getAttributesQueryValue,
} = acrossQueryValueCompatiblity;
const { getAttributesData: getAttributes, getAttributesQueryBuilderConfig, getAttributesQueryValue } =
acrossQueryValueCompatiblity;

const moduleLogger = logger.getSubLogger({ prefix: ["routing-forms/trpc/utils"] });

Expand Down Expand Up @@ -107,7 +104,7 @@ export async function findTeamMembersMatchingAttributeLogicOfRoute({
if (!route) {
return null;
}
const teamMembersMatchingAttributeLogic: {
let teamMembersMatchingAttributeLogic: {
userId: number;
result: RaqbLogicResult;
}[] = [];
Expand Down Expand Up @@ -165,7 +162,9 @@ export async function findTeamMembersMatchingAttributeLogicOfRoute({
moduleLogger.debug(`Team member ${member.userId} matches attributes logic`);
teamMembersMatchingAttributeLogic.push({ userId: member.userId, result });
} else {
moduleLogger.debug(`Team member ${member.userId} does not match attributes logic`);
moduleLogger.debug(
`Team member ${member.userId} does not match attributes logic`
);
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions packages/app-store/routing-forms/types/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { App_RoutingForms_Form } from "@prisma/client";
import type z from "zod";
import { AttributeType } from "@calcom/prisma/client";

import type { AttributeType } from "@calcom/prisma/client";
import type { RoutingFormSettings } from "@calcom/prisma/zod-utils";

import type QueryBuilderInitialConfig from "../components/react-awesome-query-builder/config/config";
Expand Down Expand Up @@ -72,4 +72,4 @@ export type Attribute = {

export type AttributesQueryValue = NonNullable<LocalRoute["attributesQueryValue"]>;
export type FormFieldsQueryValue = LocalRoute["queryValue"];
export type SerializableField = NonNullable<SerializableForm<App_RoutingForms_Form>["fields"]>[number];
export type SerializableField = NonNullable<SerializableForm<App_RoutingForms_Form>["fields"]>[number];
4 changes: 3 additions & 1 deletion packages/embeds/embed-core/src/embed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ describe("Cal", () => {
CalClass = (await import("./embed")).Cal;
});



describe("createIframe", () => {
describe("params handling with forwardQueryParams feature enabled", () => {
beforeEach(() => {
Expand Down Expand Up @@ -124,7 +126,7 @@ describe("Cal", () => {
expect(iframe.src).toContain("duration=30");
expect(iframe.src).toContain("email=test%40example.com");
});

it("should respect forwardQueryParams setting to disable sending page query params but still send the ones in the config", () => {
mockSearchParams("?param1=value");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const mapBookingToMutationInput = ({
teamMemberEmail,
orgSlug,
routedTeamMemberIds,
routingFormResponseId,
routingFormResponseId
};
};

Expand Down
Loading

0 comments on commit fbc623f

Please sign in to comment.