Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
lasryaric committed Nov 15, 2023
1 parent a95d384 commit f499573
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 25 deletions.
19 changes: 0 additions & 19 deletions front/lib/api/assistant/types.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ export type PostContentFragmentsResponseBody = {
contentFragment: ContentFragmentType;
};



export const PostContentFragmentRequestBodySchema = t.type({
title: t.string,
content: t.string,
Expand All @@ -39,7 +37,6 @@ export type PostContentFragmentRequestBody = t.TypeOf<
typeof PostContentFragmentRequestBodySchema
>;


async function handler(
req: NextApiRequest,
res: NextApiResponse<PostContentFragmentsResponseBody | ReturnedAPIErrorType>
Expand Down Expand Up @@ -93,7 +90,8 @@ async function handler(
});
}

const { content, title, url, contentType, context } = bodyValidation.right;
const { content, title, url, contentType, context } =
bodyValidation.right;

if (content.length === 0 || content.length > 64 * 1024) {
return apiError(req, res, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,29 @@ import {
getConversation,
postNewContentFragment,
} from "@app/lib/api/assistant/conversation";
import { PostContentFragmentRequestBodySchema } from "@app/lib/api/assistant/types";
import { Authenticator, getSession } from "@app/lib/auth";
import { ReturnedAPIErrorType } from "@app/lib/error";
import { apiError, withLogging } from "@app/logger/withlogging";
import { ContentFragmentType } from "@app/types/assistant/conversation";

export const PostContentFragmentRequestBodySchema = t.type({
title: t.string,
content: t.string,
url: t.union([t.string, t.null]),
contentType: t.union([
t.literal("slack_thread_content"),
t.literal("file_attachment"),
]),
context: t.type({
timezone: t.string,
profilePictureUrl: t.union([t.string, t.null]),
}),
});

export type PostContentFragmentRequestBody = t.TypeOf<
typeof PostContentFragmentRequestBodySchema
>;

export const PostMessagesRequestBodySchema = t.type({
content: t.string,
mentions: t.array(
Expand Down
3 changes: 2 additions & 1 deletion front/pages/api/w/[wId]/assistant/conversations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
postNewContentFragment,
} from "@app/lib/api/assistant/conversation";
import { postUserMessageWithPubSub } from "@app/lib/api/assistant/pubsub";
import { PostContentFragmentRequestBodySchema } from "@app/lib/api/assistant/types";
import { Authenticator, getSession } from "@app/lib/auth";
import { ReturnedAPIErrorType } from "@app/lib/error";
import { apiError, withLogging } from "@app/logger/withlogging";
Expand All @@ -22,6 +21,8 @@ import {
UserMessageType,
} from "@app/types/assistant/conversation";

import { PostContentFragmentRequestBodySchema } from "./[cId]/content_fragment";

export const PostConversationsRequestBodySchema = t.type({
title: t.union([t.string, t.null]),
visibility: t.union([
Expand Down

0 comments on commit f499573

Please sign in to comment.