feat: upgrade all validations, rename to use snake_case
parent
837247f81b
commit
d144c0f9e1
|
@ -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
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
.next/
|
||||
coverage/
|
||||
node_modules/
|
||||
node_modules/
|
||||
tests/
|
|
@ -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",
|
||||
});
|
|
@ -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",
|
||||
});
|
|
@ -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({});
|
||||
|
||||
|
|
|
@ -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({});
|
||||
|
||||
|
|
|
@ -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",
|
||||
});
|
|
@ -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",
|
||||
});
|
|
@ -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({});
|
||||
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
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({
|
||||
// email: z.string().email(),
|
||||
});
|
||||
|
||||
export const schemaTeamBodyParams = schemaTeamBaseBodyParams.merge(schemaTeamRequiredParams);
|
||||
|
||||
export const schemaTeamPublic = Team.omit({});
|
||||
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -8,7 +8,7 @@ import {
|
|||
schemaEventTypeBodyParams,
|
||||
schemaEventTypePublic,
|
||||
withValidEventType,
|
||||
} from "@lib/validations/eventType";
|
||||
} from "@lib/validations/event-type";
|
||||
import {
|
||||
schemaQueryIdParseInt,
|
||||
withValidQueryIdTransformParseInt,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -8,7 +8,7 @@ import {
|
|||
schemaEventTypeBodyParams,
|
||||
schemaEventTypePublic,
|
||||
withValidEventType,
|
||||
} from "@lib/validations/eventType";
|
||||
} from "@lib/validations/event-type";
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
|
|
Loading…
Reference in New Issue