* Base UI work * Bulk invite users * WIP workspace oauth implementation * Seperate components - add existing gcal check * Move callback session to getServerSession * Implementation of state redirect back to teams on login * Add callback to populate text field * Change error message * Redirect from callback and open modal * Fix bulk translations * Fix translations for google button * Delete Query * Feature flag this * Update packages/trpc/server/routers/viewer/teams/inviteMember.handler.ts * Check if Gcal in installed globally * Add new router * Add missing [trpc] route * Feedback * Update packages/trpc/server/routers/viewer/googleWorkspace/googleWorkspace.handler.ts * Typefixes * More typefixes --------- Co-authored-by: Hariom Balhara <hariombalhara@gmail.com> Co-authored-by: zomars <zomars@me.com>
62 lines
2.2 KiB
TypeScript
62 lines
2.2 KiB
TypeScript
import authedProcedure from "../../../procedures/authedProcedure";
|
|
import { router } from "../../../trpc";
|
|
|
|
type GoogleWorkspaceCache = {
|
|
checkForGWorkspace?: typeof import("./googleWorkspace.handler").checkForGWorkspace;
|
|
getUsersFromGWorkspace?: typeof import("./googleWorkspace.handler").getUsersFromGWorkspace;
|
|
removeCurrentGoogleWorkspaceConnection?: typeof import("./googleWorkspace.handler").removeCurrentGoogleWorkspaceConnection;
|
|
};
|
|
|
|
const UNSTABLE_HANDLER_CACHE: GoogleWorkspaceCache = {};
|
|
|
|
export const googleWorkspaceRouter = router({
|
|
checkForGWorkspace: authedProcedure.query(async ({ ctx }) => {
|
|
if (!UNSTABLE_HANDLER_CACHE.checkForGWorkspace) {
|
|
UNSTABLE_HANDLER_CACHE.checkForGWorkspace = await import("./googleWorkspace.handler").then(
|
|
(mod) => mod.checkForGWorkspace
|
|
);
|
|
}
|
|
|
|
// Unreachable code but required for type safety
|
|
if (!UNSTABLE_HANDLER_CACHE.checkForGWorkspace) {
|
|
throw new Error("Failed to load handler");
|
|
}
|
|
|
|
return UNSTABLE_HANDLER_CACHE.checkForGWorkspace({
|
|
ctx,
|
|
});
|
|
}),
|
|
getUsersFromGWorkspace: authedProcedure.mutation(async ({ ctx }) => {
|
|
if (!UNSTABLE_HANDLER_CACHE.getUsersFromGWorkspace) {
|
|
UNSTABLE_HANDLER_CACHE.getUsersFromGWorkspace = await import("./googleWorkspace.handler").then(
|
|
(mod) => mod.getUsersFromGWorkspace
|
|
);
|
|
}
|
|
|
|
// Unreachable code but required for type safety
|
|
if (!UNSTABLE_HANDLER_CACHE.getUsersFromGWorkspace) {
|
|
throw new Error("Failed to load handler");
|
|
}
|
|
|
|
return UNSTABLE_HANDLER_CACHE.getUsersFromGWorkspace({
|
|
ctx,
|
|
});
|
|
}),
|
|
removeCurrentGoogleWorkspaceConnection: authedProcedure.mutation(async ({ ctx }) => {
|
|
if (!UNSTABLE_HANDLER_CACHE.removeCurrentGoogleWorkspaceConnection) {
|
|
UNSTABLE_HANDLER_CACHE.removeCurrentGoogleWorkspaceConnection = await import(
|
|
"./googleWorkspace.handler"
|
|
).then((mod) => mod.removeCurrentGoogleWorkspaceConnection);
|
|
}
|
|
|
|
// Unreachable code but required for type safety
|
|
if (!UNSTABLE_HANDLER_CACHE.removeCurrentGoogleWorkspaceConnection) {
|
|
throw new Error("Failed to load handler");
|
|
}
|
|
|
|
return UNSTABLE_HANDLER_CACHE.removeCurrentGoogleWorkspaceConnection({
|
|
ctx,
|
|
});
|
|
}),
|
|
});
|