Merge pull request #17 from calcom/fix/update-validations-new-format

This commit is contained in:
Agusti Fernandez
2022-04-02 03:48:25 +02:00
committed by GitHub
16 changed files with 90 additions and 42 deletions
+1 -2
View File
@@ -1,4 +1,3 @@
name: Check types
on:
pull_request:
@@ -24,4 +23,4 @@ jobs:
with:
node-version: ${{ matrix.node }}
- run: yarn
- run: yarn type-check
- run: yarn type-check
+2 -1
View File
@@ -1,3 +1,4 @@
.next/
coverage/
node_modules/
node_modules/
tests/
+23
View File
@@ -0,0 +1,23 @@
import { withValidation } from "next-validations";
import { z } from "zod";
import { _ApiKeyModel as ApiKey } from "@calcom/prisma/zod";
export const schemaApiKeyBaseBodyParams = ApiKey.omit({ id: true, userId: true, createdAt: true }).partial();
const schemaApiKeyRequiredParams = z.object({
email: z.string().email(),
});
export const schemaApiKeyBodyParams = schemaApiKeyBaseBodyParams.merge(schemaApiKeyRequiredParams);
export const schemaApiKeyPublic = ApiKey.omit({
id: true,
userId: true,
});
export const withValidApiKey = withValidation({
schema: schemaApiKeyBodyParams,
type: "Zod",
mode: "body",
});
-16
View File
@@ -1,16 +0,0 @@
import { withValidation } from "next-validations";
import { _ApiKeyModel as ApiKey } from "@calcom/prisma/zod";
export const schemaApiKeyBodyParams = ApiKey.omit({ id: true, userId: true, createdAt: true }).partial();
export const schemaApiKeyPublic = ApiKey.omit({
id: true,
userId: true,
});
export const withValidApiKey = withValidation({
schema: schemaApiKeyBodyParams,
type: "Zod",
mode: "body",
});
+10 -1
View File
@@ -1,8 +1,17 @@
import { withValidation } from "next-validations";
import { z } from "zod";
import { _DailyEventReferenceModel as DailyEventReference } from "@calcom/prisma/zod";
export const schemaDailyEventReferenceBodyParams = DailyEventReference.omit({ id: true });
export const schemaDailyEventReferenceBaseBodyParams = DailyEventReference.omit({ id: true });
const schemaDailyEventReferenceRequiredParams = z.object({
email: z.string().email(),
});
export const schemaDailyEventReferenceBodyParams = schemaDailyEventReferenceBaseBodyParams.merge(
schemaDailyEventReferenceRequiredParams
);
export const schemaDailyEventReferencePublic = DailyEventReference.omit({});
+11 -1
View File
@@ -1,8 +1,18 @@
import { withValidation } from "next-validations";
import { z } from "zod";
import { _DestinationCalendarModel as DestinationCalendar } from "@calcom/prisma/zod";
export const schemaDestinationCalendarBodyParams = DestinationCalendar.omit({ id: true });
export const schemaDestinationCalendarBaseBodyParams = DestinationCalendar.omit({ id: true }).partial();
const schemaDestinationCalendarRequiredParams = z.object({
integration: z.string(),
externalId: z.string(),
});
export const schemaDestinationCalendarBodyParams = schemaDestinationCalendarBaseBodyParams.merge(
schemaDestinationCalendarRequiredParams
);
export const schemaDestinationCalendarPublic = DestinationCalendar.omit({});
+22
View File
@@ -0,0 +1,22 @@
import { withValidation } from "next-validations";
import { z } from "zod";
import { _EventTypeModel as EventType } from "@calcom/prisma/zod";
export const schemaEventTypeBaseBodyParams = EventType.omit({ id: true }).partial();
const schemaEventTypeRequiredParams = z.object({
title: z.string(),
slug: z.string(),
length: z.number(),
});
export const schemaEventTypeBodyParams = schemaEventTypeBaseBodyParams.merge(schemaEventTypeRequiredParams);
export const schemaEventTypePublic = EventType.omit({});
export const withValidEventType = withValidation({
schema: schemaEventTypeBodyParams,
type: "Zod",
mode: "body",
});
-13
View File
@@ -1,13 +0,0 @@
import { withValidation } from "next-validations";
import { _EventTypeModel as EventType } from "@calcom/prisma/zod";
export const schemaEventTypeBodyParams = EventType.omit({ id: true });
export const schemaEventTypePublic = EventType.omit({});
export const withValidEventType = withValidation({
schema: schemaEventTypeBodyParams,
type: "Zod",
mode: "body",
});
+9 -1
View File
@@ -1,8 +1,16 @@
import { withValidation } from "next-validations";
import { z } from "zod";
import { _MembershipModel as Membership } from "@calcom/prisma/zod";
export const schemaMembershipBodyParams = Membership.omit({});
export const schemaMembershipBaseBodyParams = Membership.omit({});
const schemaMembershipRequiredParams = z.object({
teamId: z.number(),
});
export const schemaMembershipBodyParams = schemaMembershipBaseBodyParams.merge(
schemaMembershipRequiredParams
);
export const schemaMembershipPublic = Membership.omit({});
+6 -1
View File
@@ -1,8 +1,13 @@
import { withValidation } from "next-validations";
import { z } from "zod";
import { _TeamModel as Team } from "@calcom/prisma/zod";
export const schemaTeamBodyParams = Team.omit({ id: true }).partial();
export const schemaTeamBaseBodyParams = Team.omit({ id: true }).partial();
const schemaTeamRequiredParams = z.object({});
export const schemaTeamBodyParams = schemaTeamBaseBodyParams.merge(schemaTeamRequiredParams);
export const schemaTeamPublic = Team.omit({});
+1 -1
View File
@@ -4,7 +4,7 @@ import prisma from "@calcom/prisma";
import { ApiKey } from "@calcom/prisma/client";
import { withMiddleware } from "@lib/helpers/withMiddleware";
import { schemaApiKeyBodyParams, withValidApiKey } from "@lib/validations/apiKey";
import { schemaApiKeyBodyParams, withValidApiKey } from "@lib/validations/api-key";
import { schemaQueryIdAsString, withValidQueryIdString } from "@lib/validations/shared/queryIdString";
type ResponseData = {
+1 -1
View File
@@ -4,7 +4,7 @@ import prisma from "@calcom/prisma";
import { ApiKey } from "@calcom/prisma/client";
import { withMiddleware } from "@lib/helpers/withMiddleware";
import { schemaApiKeyBodyParams, withValidApiKey } from "@lib/validations/apiKey";
import { schemaApiKeyBodyParams, withValidApiKey } from "@lib/validations/api-key";
type ResponseData = {
data?: ApiKey;
+1 -1
View File
@@ -8,7 +8,7 @@ import {
schemaEventTypeBodyParams,
schemaEventTypePublic,
withValidEventType,
} from "@lib/validations/eventType";
} from "@lib/validations/event-type";
import {
schemaQueryIdParseInt,
withValidQueryIdTransformParseInt,
+1 -1
View File
@@ -4,7 +4,7 @@ import prisma from "@calcom/prisma";
import { withMiddleware } from "@lib/helpers/withMiddleware";
import type { EventTypeResponse } from "@lib/types";
import { schemaEventTypePublic } from "@lib/validations/eventType";
import { schemaEventTypePublic } from "@lib/validations/event-type";
import {
schemaQueryIdParseInt,
withValidQueryIdTransformParseInt,
+1 -1
View File
@@ -4,7 +4,7 @@ import prisma from "@calcom/prisma";
import { withMiddleware } from "@lib/helpers/withMiddleware";
import { EventTypesResponse } from "@lib/types";
import { schemaEventTypePublic } from "@lib/validations/eventType";
import { schemaEventTypePublic } from "@lib/validations/event-type";
/**
* @swagger
+1 -1
View File
@@ -8,7 +8,7 @@ import {
schemaEventTypeBodyParams,
schemaEventTypePublic,
withValidEventType,
} from "@lib/validations/eventType";
} from "@lib/validations/event-type";
/**
* @swagger