refactor: decouple @calcom/features from @calcom/trpc/server (#27751)
* make GetPublicEventInput * space * mv feature flags router to trpc * remove trpc imports * wip * mv OrgMembershipLookup to features * fix * fix * update * fix * revert formatting-only changes to improve PR reviewability Co-Authored-By: [email protected] <[email protected]> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
c0504993a6
commit
431fbe44fc
26 files changed
+196
-210
No files matched your search
@@ -4,6 +4,7 @@ import {
|
||||
ConditionIdentifierEnum,
|
||||
ConditionOperatorEnum,
|
||||
type IAttributeSyncRule,
|
||||
type ICreateAttributeSyncInput,
|
||||
type IFieldMapping,
|
||||
type IFieldMappingFormState,
|
||||
type IFieldMappingWithOptionalId,
|
||||
@@ -80,3 +81,13 @@ export const syncFormDataSchema: z.ZodType<ISyncFormData> = z.object({
|
||||
rule: attributeSyncRuleSchema,
|
||||
syncFieldMappings: z.array(z.union([fieldMappingSchema, newFieldMappingSchema])),
|
||||
});
|
||||
|
||||
export const createAttributeSyncSchema: z.ZodType<ICreateAttributeSyncInput> = z.object({
|
||||
name: z.string().min(1, "Name is required"),
|
||||
credentialId: z.number(),
|
||||
rule: attributeSyncRuleSchema,
|
||||
syncFieldMappings: z.array(newFieldMappingSchema),
|
||||
enabled: z.boolean(),
|
||||
});
|
||||
|
||||
export type ZCreateAttributeSyncSchema = ICreateAttributeSyncInput;
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
import type { CredentialRepository } from "@calcom/features/credentials/repositories/CredentialRepository";
|
||||
import type { TeamRepository } from "@calcom/features/ee/teams/repositories/TeamRepository";
|
||||
import type { ZCreateAttributeSyncSchema } from "@calcom/trpc/server/routers/viewer/attribute-sync/createAttributeSync.schema";
|
||||
|
||||
import { enabledAppSlugs } from "../constants";
|
||||
import {
|
||||
@@ -11,7 +10,7 @@ import {
|
||||
AttributeSyncIntegrations,
|
||||
ConditionIdentifierEnum,
|
||||
} from "../repositories/IIntegrationAttributeSyncRepository";
|
||||
import { attributeSyncRuleSchema } from "../schemas/zod";
|
||||
import { attributeSyncRuleSchema, type ZCreateAttributeSyncSchema } from "../schemas/zod";
|
||||
|
||||
export class DuplicateAttributeWithinSyncError extends Error {
|
||||
constructor(public attributeId: string) {
|
||||
|
||||
@@ -5,8 +5,17 @@ import { renameDomain } from "@calcom/lib/domainManager/organization";
|
||||
import { getMetadataHelpers } from "@calcom/lib/getMetadataHelpers";
|
||||
import { HttpError } from "@calcom/lib/http-error";
|
||||
import type { Prisma, PrismaClient } from "@calcom/prisma/client";
|
||||
import { teamMetadataStrictSchema } from "@calcom/prisma/zod-utils";
|
||||
import type { TAdminUpdate } from "@calcom/trpc/server/routers/viewer/organizations/adminUpdate.schema";
|
||||
import { orgSettingsSchema, teamMetadataStrictSchema } from "@calcom/prisma/zod-utils";
|
||||
import { z } from "zod";
|
||||
|
||||
export const ZAdminUpdate = z.object({
|
||||
id: z.number(),
|
||||
name: z.string().optional(),
|
||||
slug: z.string().nullish(),
|
||||
organizationSettings: orgSettingsSchema.unwrap().optional(),
|
||||
});
|
||||
|
||||
export type TAdminUpdate = z.infer<typeof ZAdminUpdate>;
|
||||
|
||||
type AdminOrganizationUpdateServiceDeps = {
|
||||
prismaClient: PrismaClient;
|
||||
|
||||
@@ -13,6 +13,8 @@ import type { TimeUnit, WorkflowTemplates, WorkflowTriggerEvents } from "@calcom
|
||||
import { WorkflowActions } from "@calcom/prisma/enums";
|
||||
import type { CalEventResponses, RecurringEvent } from "@calcom/types/Calendar";
|
||||
import type { MultiSelectCheckboxesOptionType as Option } from "@calcom/ui/components/form";
|
||||
import { z } from "zod";
|
||||
import { TIME_UNIT, WORKFLOW_ACTIONS, WORKFLOW_TEMPLATES, WORKFLOW_TRIGGER_EVENTS } from "./constants";
|
||||
|
||||
export type Workflow = {
|
||||
id: number;
|
||||
@@ -39,6 +41,31 @@ export type WorkflowStep = {
|
||||
verifiedAt?: Date | null;
|
||||
};
|
||||
|
||||
export const ZWorkflow: z.ZodType<Workflow> = z.object({
|
||||
id: z.number(),
|
||||
name: z.string(),
|
||||
trigger: z.enum(WORKFLOW_TRIGGER_EVENTS),
|
||||
time: z.number().nullable(),
|
||||
timeUnit: z.enum(TIME_UNIT).nullable(),
|
||||
userId: z.number().nullable(),
|
||||
teamId: z.number().nullable(),
|
||||
steps: z
|
||||
.object({
|
||||
id: z.number(),
|
||||
action: z.enum(WORKFLOW_ACTIONS),
|
||||
sendTo: z.string().nullable(),
|
||||
template: z.enum(WORKFLOW_TEMPLATES),
|
||||
reminderBody: z.string().nullable(),
|
||||
emailSubject: z.string().nullable(),
|
||||
numberRequired: z.boolean().nullable(),
|
||||
sender: z.string().nullable(),
|
||||
includeCalendarEvent: z.boolean(),
|
||||
numberVerificationPending: z.boolean(),
|
||||
verifiedAt: z.coerce.date().nullable().optional(),
|
||||
})
|
||||
.array(),
|
||||
});
|
||||
|
||||
export type FormSubmissionData = {
|
||||
responses: FORM_SUBMITTED_WEBHOOK_RESPONSES;
|
||||
routedEventTypeId: number | null;
|
||||
|
||||
@@ -3,6 +3,7 @@ import { deleteScheduledAIPhoneCall } from "@calcom/ee/workflows/lib/reminders/a
|
||||
import { deleteScheduledEmailReminder } from "@calcom/ee/workflows/lib/reminders/emailReminderManager";
|
||||
import { deleteScheduledSMSReminder } from "@calcom/ee/workflows/lib/reminders/smsReminderManager";
|
||||
import type { WorkflowStep, WorkflowListType as WorkflowType } from "@calcom/ee/workflows/lib/types";
|
||||
import type { filterQuerySchemaStrict } from "@calcom/features/filters/lib/getTeamsFiltersFromQuery";
|
||||
import { hasFilter } from "@calcom/features/filters/lib/hasFilter";
|
||||
import { PermissionCheckService } from "@calcom/features/pbac/services/permission-check.service";
|
||||
import { HttpError } from "@calcom/lib/http-error";
|
||||
@@ -16,15 +17,29 @@ import {
|
||||
WorkflowMethods,
|
||||
type WorkflowTriggerEvents,
|
||||
} from "@calcom/prisma/enums";
|
||||
import type { TFilteredListInputSchema } from "@calcom/trpc/server/routers/viewer/workflows/filteredList.schema";
|
||||
import type { TGetVerifiedEmailsInputSchema } from "@calcom/trpc/server/routers/viewer/workflows/getVerifiedEmails.schema";
|
||||
import type { TGetVerifiedNumbersInputSchema } from "@calcom/trpc/server/routers/viewer/workflows/getVerifiedNumbers.schema";
|
||||
import { z } from "zod";
|
||||
|
||||
export const ZGetInputSchema = z.object({
|
||||
id: z.number(),
|
||||
});
|
||||
|
||||
export type TGetInputSchema = z.infer<typeof ZGetInputSchema>;
|
||||
|
||||
export type TFilteredListInputSchema =
|
||||
| {
|
||||
filters?: z.infer<typeof filterQuerySchemaStrict>;
|
||||
}
|
||||
| null
|
||||
| undefined;
|
||||
|
||||
export type TGetVerifiedEmailsInputSchema = {
|
||||
teamId?: number;
|
||||
};
|
||||
|
||||
export type TGetVerifiedNumbersInputSchema = {
|
||||
teamId?: number;
|
||||
};
|
||||
|
||||
const excludeFormTriggersWhereClause = {
|
||||
trigger: {
|
||||
not: {
|
||||
@@ -40,8 +55,6 @@ const getWorkflowType = (trigger: WorkflowTriggerEvents): PrismaWorkflowType =>
|
||||
return PrismaWorkflowType.EVENT_TYPE;
|
||||
};
|
||||
|
||||
export type TGetInputSchema = z.infer<typeof ZGetInputSchema>;
|
||||
|
||||
const deleteScheduledWhatsappReminder = deleteScheduledSMSReminder;
|
||||
|
||||
const includedFields = {
|
||||
|
||||
Reference in new issue
Block a user