Files
calendar/packages/trpc/server/routers/viewer/calVideo/getMeetingInformation.handler.ts
Keith WilliamsGitHubDevin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
191db5104a perf: optimize video adapter imports to avoid loading entire app store (#23435)
* perf: optimize video adapter imports to avoid loading entire app store

- Creates VideoApiAdapterMap with lazy imports for 12 video services
- Updates getVideoAdapters function to use VideoApiAdapterMap instead of dynamic app store imports
- Preserves zoom app name parsing logic (zoom_video → zoomvideo)
- Follows same optimization pattern as calendar, analytics, and payment services
- Reduces bundle size by avoiding import of 100+ apps when only video functionality needed

Affected files:
- packages/app-store-cli/src/build.ts: Added video service generation logic
- packages/lib/videoClient.ts: Updated to use VideoApiAdapterMap
- packages/features/bookings/lib/handleCancelBooking.ts: Updated FAKE_DAILY_CREDENTIAL import
- packages/lib/EventManager.ts: Updated FAKE_DAILY_CREDENTIAL import
- packages/trpc/server/routers/viewer/calVideo/getMeetingInformation.handler.ts: Updated to use VideoApiAdapterMap
- apps/web/lib/video/[uid]/getServerSideProps.ts: Updated daily video function imports
- packages/app-store/video.services.generated.ts: Generated video adapter map with re-exports

Co-Authored-By: [email protected] <[email protected]>

* fix: add missing re-exports to video.services.generated.ts

- Updates build.ts to include FAKE_DAILY_CREDENTIAL and other daily video function re-exports
- Fixes type errors in EventManager.ts and other files importing from video.services.generated
- Ensures video adapter refactoring maintains all existing functionality

Co-Authored-By: [email protected] <[email protected]>

* fix: update video adapter test mocks to work with VideoApiAdapterMap

- Creates global mockVideoAdapterRegistry for dynamic video adapter mocks
- Uses Proxy in vi.mock for VideoApiAdapterMap to return registered mocks
- Updates mockVideoApp and mockErrorOnVideoMeetingCreation to register mocks
- Fixes unit test failures in booking scenario tests
- Ensures video meeting operations (createMeeting, updateMeeting, deleteMeeting) work correctly

Co-Authored-By: [email protected] <[email protected]>

* fix: remove re-exports from video.services.generated.ts and revert imports

- Remove re-export block from video.services.generated.ts as requested
- Revert imports back to pull directly from dailyvideo/lib/VideoApiAdapter
- Update build.ts to not generate the re-exports
- Maintains all existing functionality while addressing GitHub feedback

Co-Authored-By: [email protected] <[email protected]>

* fix: rename video.services.generated.ts to video.adapters.generated.ts

- Updates build.ts to generate video.adapters.generated.ts instead of video.services.generated.ts
- Updates all import statements to use new filename
- Removes unnecessary mock exports from bookingScenario.ts (FAKE_DAILY_CREDENTIAL, etc.)
- Addresses GitHub comments from @keithwillcode on PR #23435

The terminology change from 'services map' to 'adapters map' better reflects
the actual content (video adapters, not services) and maintains consistency
with the established refactoring pattern.

Co-Authored-By: [email protected] <[email protected]>

* refactor: rename videoServices to videoAdapters and simplify return statement

- Rename variable from videoServices to videoAdapters for consistency
- Remove unnecessary const variable and return directly in same line
- Addresses GitHub comments from @keithwillcode on PR #23435

Co-Authored-By: [email protected] <[email protected]>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2025-08-29 14:21:05 +09:00

44 lines
1.3 KiB
TypeScript

import { VideoApiAdapterMap } from "@calcom/app-store/video.adapters.generated";
import type { TrpcSessionUser } from "@calcom/trpc/server/types";
import { TRPCError } from "@trpc/server";
import type { TGetMeetingInformationInputSchema } from "./getMeetingInformation.schema";
type GetMeetingInformationOptions = {
ctx: {
user: NonNullable<TrpcSessionUser>;
};
input: TGetMeetingInformationInputSchema;
};
export const getMeetingInformationHandler = async ({ ctx: _ctx, input }: GetMeetingInformationOptions) => {
const { roomName } = input;
try {
const dailyVideoAdapterImport = VideoApiAdapterMap["dailyvideo"];
if (!dailyVideoAdapterImport) {
throw new TRPCError({
code: "BAD_REQUEST",
message: "Daily video adapter not available",
});
}
const dailyVideoAdapterModule = await dailyVideoAdapterImport;
const videoApiAdapter = dailyVideoAdapterModule.default();
if (!videoApiAdapter || !videoApiAdapter.getMeetingInformation) {
throw new TRPCError({
code: "BAD_REQUEST",
message: "Meeting information feature not available",
});
}
const res = await videoApiAdapter.getMeetingInformation(roomName);
return res;
} catch (err) {
throw new TRPCError({
code: "BAD_REQUEST",
});
}
};