fix: build issues, extend event-type in types, use @calcom/types
parent
7d8ed47268
commit
fdc46fac7d
|
@ -1,16 +1,8 @@
|
||||||
import type { IncomingMessage } from "http";
|
|
||||||
import { NextMiddleware } from "next-api-middleware";
|
import { NextMiddleware } from "next-api-middleware";
|
||||||
|
|
||||||
import { hashAPIKey } from "@calcom/ee/lib/api/apiKeys";
|
import { hashAPIKey } from "@calcom/ee/lib/api/apiKeys";
|
||||||
import prisma from "@calcom/prisma";
|
import prisma from "@calcom/prisma";
|
||||||
|
|
||||||
/** @todo figure how to use the one from `@calcom/types`fi */
|
|
||||||
declare module "next" {
|
|
||||||
export interface NextApiRequest extends IncomingMessage {
|
|
||||||
userId: number;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Used to check if the apiKey is not expired, could be extracted if reused. but not for now.
|
// Used to check if the apiKey is not expired, could be extracted if reused. but not for now.
|
||||||
export const dateNotInPast = function (date: Date) {
|
export const dateNotInPast = function (date: Date) {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
|
|
35
lib/types.ts
35
lib/types.ts
|
@ -1,3 +1,4 @@
|
||||||
|
import { AppStoreLocationType, DefaultLocationType } from "@calcom/app-store/locations";
|
||||||
import {
|
import {
|
||||||
User,
|
User,
|
||||||
Team,
|
Team,
|
||||||
|
@ -15,10 +16,9 @@ import {
|
||||||
Payment,
|
Payment,
|
||||||
Schedule,
|
Schedule,
|
||||||
ReminderMail,
|
ReminderMail,
|
||||||
|
EventType,
|
||||||
} from "@calcom/prisma/client";
|
} from "@calcom/prisma/client";
|
||||||
|
|
||||||
import { schemaEventTypeReadPublic } from "@lib/validations/event-type";
|
|
||||||
|
|
||||||
// Base response, used for all responses
|
// Base response, used for all responses
|
||||||
export type BaseResponse = {
|
export type BaseResponse = {
|
||||||
message?: string;
|
message?: string;
|
||||||
|
@ -124,13 +124,38 @@ export type EventTypeCustomInputResponse = BaseResponse & {
|
||||||
export type EventTypeCustomInputsResponse = BaseResponse & {
|
export type EventTypeCustomInputsResponse = BaseResponse & {
|
||||||
event_type_custom_inputs?: Partial<EventTypeCustomInput>[];
|
event_type_custom_inputs?: Partial<EventTypeCustomInput>[];
|
||||||
};
|
};
|
||||||
|
// From rrule https://jakubroztocil.github.io/rrule freq
|
||||||
|
enum Frequency {
|
||||||
|
"YEARLY",
|
||||||
|
"MONTHLY",
|
||||||
|
"WEEKLY",
|
||||||
|
"DAILY",
|
||||||
|
"HOURLY",
|
||||||
|
"MINUTELY",
|
||||||
|
"SECONDLY",
|
||||||
|
}
|
||||||
|
interface EventTypeExtended extends Omit<EventType, "recurringEvent" | "locations"> {
|
||||||
|
recurringEvent: {
|
||||||
|
dtstart?: Date | undefined;
|
||||||
|
interval?: number | undefined;
|
||||||
|
count?: number | undefined;
|
||||||
|
freq?: Frequency | undefined;
|
||||||
|
until?: Date | undefined;
|
||||||
|
tzid?: string | undefined;
|
||||||
|
};
|
||||||
|
locations: {
|
||||||
|
link?: string | undefined;
|
||||||
|
address?: string | undefined;
|
||||||
|
hostPhoneNumber?: string | undefined;
|
||||||
|
type: DefaultLocationType | AppStoreLocationType;
|
||||||
|
}[];
|
||||||
|
}
|
||||||
// EventType
|
// EventType
|
||||||
export type EventTypeResponse = BaseResponse & {
|
export type EventTypeResponse = BaseResponse & {
|
||||||
event_type?: Partial<typeof schemaEventTypeReadPublic>;
|
event_type?: Partial<EventTypeExtended>;
|
||||||
};
|
};
|
||||||
export type EventTypesResponse = BaseResponse & {
|
export type EventTypesResponse = BaseResponse & {
|
||||||
event_types?: Partial<typeof schemaEventTypeReadPublic>[];
|
event_types?: Partial<EventTypeExtended>[];
|
||||||
};
|
};
|
||||||
|
|
||||||
// Payment
|
// Payment
|
||||||
|
|
|
@ -38,9 +38,9 @@ const schemaEventTypeCreateParams = z
|
||||||
slug: z.string(),
|
slug: z.string(),
|
||||||
description: z.string().optional().nullable(),
|
description: z.string().optional().nullable(),
|
||||||
length: z.number().int(),
|
length: z.number().int(),
|
||||||
locations: jsonSchema.optional().nullable().or(z.null()),
|
locations: jsonSchema.optional(),
|
||||||
metadata: z.any().optional().nullable().or(z.null()),
|
metadata: z.any().optional(),
|
||||||
recurringEvent: jsonSchema.optional().nullable().or(z.null()),
|
recurringEvent: jsonSchema.optional(),
|
||||||
})
|
})
|
||||||
.strict();
|
.strict();
|
||||||
|
|
||||||
|
|
|
@ -5,5 +5,5 @@ type Literal = boolean | number | string;
|
||||||
type Json = Literal | { [key: string]: Json } | Json[];
|
type Json = Literal | { [key: string]: Json } | Json[];
|
||||||
const literalSchema = z.union([z.string(), z.number(), z.boolean()]);
|
const literalSchema = z.union([z.string(), z.number(), z.boolean()]);
|
||||||
export const jsonSchema: z.ZodSchema<Json> = z.lazy(() =>
|
export const jsonSchema: z.ZodSchema<Json> = z.lazy(() =>
|
||||||
z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)]).or(z.null())
|
z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)])
|
||||||
);
|
);
|
||||||
|
|
|
@ -19,11 +19,12 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@calcom/tsconfig": "*",
|
"@calcom/tsconfig": "*",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.22.0",
|
"@calcom/types": "*",
|
||||||
"babel-jest": "^28.0.3",
|
"@typescript-eslint/eslint-plugin": "^5.25.0",
|
||||||
|
"babel-jest": "^28.1.0",
|
||||||
"jest": "^28.0.3",
|
"jest": "^28.0.3",
|
||||||
"node-mocks-http": "^1.11.0"
|
"node-mocks-http": "^1.11.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@calcom/prisma": "*",
|
"@calcom/prisma": "*",
|
||||||
"@sentry/nextjs": "^6.19.7",
|
"@sentry/nextjs": "^6.19.7",
|
||||||
|
|
Loading…
Reference in New Issue