Skip to content

Commit d908403

Browse files
authored
refactor: circular deps between app store and lib [1] (calcom#23653)
* move dailyApiFetcher.ts to app store package * update imports * bookingLocationService * revert * move findFieldValueByIdentifier * wip * fix * fix * fix * fix * fix * fix * fix * move to features package * update imports * update imports * move * fix typechecks * move getCalendarLinks * mv event test
1 parent 0fe7759 commit d908403

39 files changed

Lines changed: 63 additions & 55 deletions

apps/web/modules/bookings/views/bookings-single-view.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ import {
2626
SystemField,
2727
TITLE_FIELD,
2828
} from "@calcom/features/bookings/lib/SystemField";
29+
import { getCalendarLinks, CalendarLinkType } from "@calcom/features/bookings/lib/getCalendarLinks";
2930
import { RATING_OPTIONS, validateRating } from "@calcom/features/bookings/lib/rating";
30-
import { getCalendarLinks, CalendarLinkType } from "@calcom/lib/bookings/getCalendarLinks";
31+
import type { nameObjectSchema } from "@calcom/features/eventtypes/lib/eventNaming";
32+
import { getEventName } from "@calcom/features/eventtypes/lib/eventNaming";
3133
import { APP_NAME } from "@calcom/lib/constants";
3234
import { formatToLocalizedDate, formatToLocalizedTime, formatToLocalizedTimezone } from "@calcom/lib/dayjs";
33-
import type { nameObjectSchema } from "@calcom/lib/event";
34-
import { getEventName } from "@calcom/lib/event";
3535
import useGetBrandingColours from "@calcom/lib/getBrandColours";
3636
import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
3737
import { useLocale } from "@calcom/lib/hooks/useLocale";

apps/web/modules/test-setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ vi.mock("@calcom/app-store/utils", () => ({
3535
getEventTypeAppData: vi.fn(),
3636
}));
3737

38-
vi.mock("@calcom/lib/event", () => ({
38+
vi.mock("@calcom/features/eventtypes/lib/eventNaming", () => ({
3939
getEventName: vi.fn(),
4040
}));
4141

packages/app-store/dailyvideo/lib/VideoApiAdapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { z } from "zod";
22

33
import { getDailyAppKeys } from "@calcom/app-store/dailyvideo/lib/getDailyAppKeys";
4-
import { fetcher } from "@calcom/lib/dailyApiFetcher";
54
import { prisma } from "@calcom/prisma";
65
import type { GetRecordingsResponseSchema, GetAccessLinkResponseSchema } from "@calcom/prisma/zod-utils";
76
import {
@@ -16,6 +15,7 @@ import type { VideoApiAdapter, VideoCallData } from "@calcom/types/VideoApiAdapt
1615

1716
import { ZSubmitBatchProcessorJobRes, ZGetTranscriptAccessLink } from "../zod";
1817
import type { TSubmitBatchProcessorJobRes, TGetTranscriptAccessLink, batchProcessorBody } from "../zod";
18+
import { fetcher } from "./dailyApiFetcher";
1919
import {
2020
dailyReturnTypeSchema,
2121
getTranscripts,

packages/lib/dailyApiFetcher.ts renamed to packages/app-store/dailyvideo/lib/dailyApiFetcher.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { getDailyAppKeys } from "@calcom/app-store/dailyvideo/lib/getDailyAppKeys";
21
import { handleErrorsJson } from "@calcom/lib/errors";
32

3+
import { getDailyAppKeys } from "./getDailyAppKeys";
4+
45
export const fetcher = async (endpoint: string, init?: RequestInit | undefined) => {
56
const { api_key } = await getDailyAppKeys();
67
return fetch(`https://api.daily.co/v1${endpoint}`, {

packages/app-store/routing-forms/api/responses/[formId].ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import { getSession } from "next-auth/react";
44

55
import { sanitizeValue } from "@calcom/lib/csvUtils";
66
import { entityPrismaWhereClause, canEditEntity } from "@calcom/lib/entityPermissionUtils.server";
7-
import { getHumanReadableFieldResponseValue } from "@calcom/lib/server/service/routingForm/responseData/getHumanReadableFieldResponseValue";
87
import prisma from "@calcom/prisma";
98

109
import { getSerializableForm } from "../../lib/getSerializableForm";
10+
import { getHumanReadableFieldResponseValue } from "../../lib/responseData/getHumanReadableFieldResponseValue";
1111
import type { FormResponse, SerializableForm } from "../../types/types";
1212

1313
type Fields = NonNullable<SerializableForm<App_RoutingForms_Form>["fields"]>;

packages/app-store/routing-forms/cron/queuedFormResponseCleanup.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import type { NextRequest } from "next/server";
22
import { NextResponse } from "next/server";
33

44
import logger from "@calcom/lib/logger";
5-
import { PrismaQueuedFormResponseRepository } from "@calcom/lib/server/repository/routingForm/queuedFormResponse/PrismaQueuedFormResponseRepository";
6-
import { QueuedFormResponseService } from "@calcom/lib/server/service/routingForm/queuedFormResponse/QueuedFormResponseService";
75
import prisma from "@calcom/prisma";
86

7+
import { PrismaQueuedFormResponseRepository } from "../lib/queuedFormResponse/PrismaQueuedFormResponseRepository";
8+
import { QueuedFormResponseService } from "../lib/queuedFormResponse/QueuedFormResponseService";
9+
910
function validateRequest(request: NextRequest) {
1011
const apiKey = request.headers.get("authorization") || request.nextUrl.searchParams.get("apiKey");
1112

packages/lib/server/service/routingForm/RoutingFormResponseDataFactory.test.ts renamed to packages/app-store/routing-forms/lib/RoutingFormResponseDataFactory.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { describe, it, expect, beforeEach, vi } from "vitest";
22

3-
import type { RoutingFormResponseRepositoryInterface } from "../../repository/RoutingFormResponseRepository.interface";
3+
import type { RoutingFormResponseRepositoryInterface } from "@calcom/lib/server/repository/RoutingFormResponseRepository.interface";
4+
45
import { RoutingFormResponseDataFactory } from "./RoutingFormResponseDataFactory";
56
import { parseRoutingFormResponse } from "./responseData/parseRoutingFormResponse";
67

packages/lib/server/service/routingForm/RoutingFormResponseDataFactory.ts renamed to packages/app-store/routing-forms/lib/RoutingFormResponseDataFactory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type logger from "@calcom/lib/logger";
2+
import type { RoutingFormResponseRepositoryInterface } from "@calcom/lib/server/repository/RoutingFormResponseRepository.interface";
23

3-
import type { RoutingFormResponseRepositoryInterface } from "../../repository/RoutingFormResponseRepository.interface";
44
import { parseRoutingFormResponse } from "./responseData/parseRoutingFormResponse";
55

66
interface Dependencies {

packages/lib/server/service/routingForm/responseData/findFieldValueByIdentifier.test.ts renamed to packages/app-store/routing-forms/lib/findFieldValueByIdentifier.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { describe, it, expect } from "vitest";
22

33
import { findFieldValueByIdentifier } from "./findFieldValueByIdentifier";
4-
import type { RoutingFormResponseData } from "./types";
4+
import type { RoutingFormResponseData } from "./responseData/types";
55

66
describe("findFieldValueByIdentifier", () => {
77
const responseData: RoutingFormResponseData = {

packages/lib/server/service/routingForm/responseData/findFieldValueByIdentifier.ts renamed to packages/app-store/routing-forms/lib/findFieldValueByIdentifier.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import getFieldIdentifier from "@calcom/app-store/routing-forms/lib/getFieldIdentifier";
2-
3-
import type { RoutingFormResponseData } from "./types";
1+
import getFieldIdentifier from "./getFieldIdentifier";
2+
import type { RoutingFormResponseData } from "./responseData/types";
43

54
type FindFieldValueByIdentifierResult =
65
| { success: true; data: string | string[] | number | null }

0 commit comments

Comments
 (0)