feat: projects create, update, delete
This commit is contained in:
@ -7,7 +7,7 @@
|
|||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"lint": "next lint",
|
"lint": "next lint",
|
||||||
"generate-client": "openapi-ts && prettier --write ./src/client/**/*.ts && git add ./src/client"
|
"generate-client": "openapi-ts && prettier --write ./src/lib/client/**/*.ts && git add ./src/lib/client"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@dnd-kit/core": "^6.3.1",
|
"@dnd-kit/core": "^6.3.1",
|
||||||
|
|||||||
@ -11,8 +11,12 @@ import { ColorSchemeToggle } from "@/components/ui/ColorSchemeToggle/ColorScheme
|
|||||||
import useIsMobile from "@/hooks/useIsMobile";
|
import useIsMobile from "@/hooks/useIsMobile";
|
||||||
|
|
||||||
const Header = () => {
|
const Header = () => {
|
||||||
const { projects, setSelectedProject, selectedProject } =
|
const {
|
||||||
useProjectsContext();
|
projects,
|
||||||
|
setSelectedProject,
|
||||||
|
selectedProject,
|
||||||
|
setIsEditorDrawerOpened: setIsProjectsDrawerOpened,
|
||||||
|
} = useProjectsContext();
|
||||||
const { setIsEditorDrawerOpened } = useBoardsContext();
|
const { setIsEditorDrawerOpened } = useBoardsContext();
|
||||||
const isMobile = useIsMobile();
|
const isMobile = useIsMobile();
|
||||||
|
|
||||||
@ -38,7 +42,9 @@ const Header = () => {
|
|||||||
return (
|
return (
|
||||||
<Stack gap={0}>
|
<Stack gap={0}>
|
||||||
<Group justify={"space-between"}>
|
<Group justify={"space-between"}>
|
||||||
<Box p={"md"}>
|
<Box
|
||||||
|
p={"md"}
|
||||||
|
onClick={() => setIsProjectsDrawerOpened(true)}>
|
||||||
<IconChevronLeft />
|
<IconChevronLeft />
|
||||||
</Box>
|
</Box>
|
||||||
<Text>{selectedProject?.name}</Text>
|
<Text>{selectedProject?.name}</Text>
|
||||||
|
|||||||
@ -7,8 +7,9 @@ import React, {
|
|||||||
useEffect,
|
useEffect,
|
||||||
useState,
|
useState,
|
||||||
} from "react";
|
} from "react";
|
||||||
import { ProjectSchema } from "@/lib/client";
|
|
||||||
import useProjectsList from "@/hooks/useProjectsList";
|
import useProjectsList from "@/hooks/useProjectsList";
|
||||||
|
import { useProjectsOperations } from "@/hooks/useProjectsOperations";
|
||||||
|
import { ProjectSchema, UpdateProjectSchema } from "@/lib/client";
|
||||||
|
|
||||||
type ProjectsContextState = {
|
type ProjectsContextState = {
|
||||||
selectedProject: ProjectSchema | null;
|
selectedProject: ProjectSchema | null;
|
||||||
@ -16,6 +17,11 @@ type ProjectsContextState = {
|
|||||||
React.SetStateAction<ProjectSchema | null>
|
React.SetStateAction<ProjectSchema | null>
|
||||||
>;
|
>;
|
||||||
projects: ProjectSchema[];
|
projects: ProjectSchema[];
|
||||||
|
onCreateProject: (name: string) => void;
|
||||||
|
onUpdateProject: (projectId: number, project: UpdateProjectSchema) => void;
|
||||||
|
onDeleteProject: (project: ProjectSchema) => void;
|
||||||
|
isEditorDrawerOpened: boolean;
|
||||||
|
setIsEditorDrawerOpened: React.Dispatch<React.SetStateAction<boolean>>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const ProjectsContext = createContext<ProjectsContextState | undefined>(
|
const ProjectsContext = createContext<ProjectsContextState | undefined>(
|
||||||
@ -23,7 +29,13 @@ const ProjectsContext = createContext<ProjectsContextState | undefined>(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const useProjectsContextState = () => {
|
const useProjectsContextState = () => {
|
||||||
const { projects } = useProjectsList();
|
const [isEditorDrawerOpened, setIsEditorDrawerOpened] =
|
||||||
|
useState<boolean>(false);
|
||||||
|
const {
|
||||||
|
projects,
|
||||||
|
setProjects,
|
||||||
|
refetch: refetchProjects,
|
||||||
|
} = useProjectsList();
|
||||||
const [selectedProject, setSelectedProject] =
|
const [selectedProject, setSelectedProject] =
|
||||||
useState<ProjectSchema | null>(null);
|
useState<ProjectSchema | null>(null);
|
||||||
|
|
||||||
@ -43,10 +55,22 @@ const useProjectsContextState = () => {
|
|||||||
setSelectedProject(null);
|
setSelectedProject(null);
|
||||||
}, [projects]);
|
}, [projects]);
|
||||||
|
|
||||||
|
const { onCreateProject, onUpdateProject, onDeleteProject } =
|
||||||
|
useProjectsOperations({
|
||||||
|
projects,
|
||||||
|
setProjects,
|
||||||
|
refetchProjects,
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
projects,
|
projects,
|
||||||
selectedProject,
|
selectedProject,
|
||||||
setSelectedProject,
|
setSelectedProject,
|
||||||
|
onCreateProject,
|
||||||
|
onUpdateProject,
|
||||||
|
onDeleteProject,
|
||||||
|
isEditorDrawerOpened,
|
||||||
|
setIsEditorDrawerOpened,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,15 @@
|
|||||||
|
.project:hover {
|
||||||
|
background-color: whitesmoke;
|
||||||
|
|
||||||
|
@mixin dark {
|
||||||
|
background-color: var(--mantine-color-dark-6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-button {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.project:hover:has(.menu-button:hover) {
|
||||||
|
background: none; /* or revert to normal */
|
||||||
|
}
|
||||||
@ -0,0 +1,66 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import React, { FC } from "react";
|
||||||
|
import { IconChevronLeft } from "@tabler/icons-react";
|
||||||
|
import {
|
||||||
|
Box,
|
||||||
|
Center,
|
||||||
|
Divider,
|
||||||
|
Drawer,
|
||||||
|
Group,
|
||||||
|
rem,
|
||||||
|
Stack,
|
||||||
|
Text,
|
||||||
|
} from "@mantine/core";
|
||||||
|
import { useProjectsContext } from "@/app/deals/contexts/ProjectsContext";
|
||||||
|
import CreateProjectButton from "@/app/deals/drawers/ProjectsEditorDrawer/components/CreateProjectButton";
|
||||||
|
import ProjectMobile from "@/app/deals/drawers/ProjectsEditorDrawer/components/ProjectMobile";
|
||||||
|
|
||||||
|
const ProjectsEditorDrawer: FC = () => {
|
||||||
|
const { projects, isEditorDrawerOpened, setIsEditorDrawerOpened } =
|
||||||
|
useProjectsContext();
|
||||||
|
const onClose = () => setIsEditorDrawerOpened(false);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Drawer
|
||||||
|
size={"100%"}
|
||||||
|
position={"left"}
|
||||||
|
onClose={onClose}
|
||||||
|
removeScrollProps={{ allowPinchZoom: true }}
|
||||||
|
withCloseButton={false}
|
||||||
|
opened={isEditorDrawerOpened}
|
||||||
|
trapFocus={false}
|
||||||
|
styles={{
|
||||||
|
body: {
|
||||||
|
height: "100%",
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
gap: rem(10),
|
||||||
|
},
|
||||||
|
}}>
|
||||||
|
<Group justify={"space-between"}>
|
||||||
|
<Box
|
||||||
|
onClick={onClose}
|
||||||
|
p={"xs"}>
|
||||||
|
<IconChevronLeft />
|
||||||
|
</Box>
|
||||||
|
<Center>
|
||||||
|
<Text>Проекты</Text>
|
||||||
|
</Center>
|
||||||
|
<Box p={"lg"} />
|
||||||
|
</Group>
|
||||||
|
<Divider />
|
||||||
|
<Stack gap={0}>
|
||||||
|
{projects.map((project, index) => (
|
||||||
|
<ProjectMobile
|
||||||
|
key={index}
|
||||||
|
project={project}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Stack>
|
||||||
|
<CreateProjectButton />
|
||||||
|
</Drawer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ProjectsEditorDrawer;
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
import { IconPlus } from "@tabler/icons-react";
|
||||||
|
import { Box, Group, Text } from "@mantine/core";
|
||||||
|
import { modals } from "@mantine/modals";
|
||||||
|
import { useProjectsContext } from "@/app/deals/contexts/ProjectsContext";
|
||||||
|
|
||||||
|
const CreateProjectButton = () => {
|
||||||
|
const { onCreateProject } = useProjectsContext();
|
||||||
|
|
||||||
|
const onStartCreating = () => {
|
||||||
|
modals.openContextModal({
|
||||||
|
modal: "enterNameModal",
|
||||||
|
title: "Создание проекта",
|
||||||
|
withCloseButton: true,
|
||||||
|
innerProps: {
|
||||||
|
onComplete: onCreateProject,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Group
|
||||||
|
ml={"xs"}
|
||||||
|
onClick={onStartCreating}>
|
||||||
|
<IconPlus />
|
||||||
|
<Box mt={5}>
|
||||||
|
<Text>Создать проект</Text>
|
||||||
|
</Box>
|
||||||
|
</Group>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default CreateProjectButton;
|
||||||
@ -0,0 +1,56 @@
|
|||||||
|
import React, { FC } from "react";
|
||||||
|
import { IconDotsVertical, IconEdit, IconTrash } from "@tabler/icons-react";
|
||||||
|
import { Box, Group, Menu, Text } from "@mantine/core";
|
||||||
|
import { useProjectsContext } from "@/app/deals/contexts/ProjectsContext";
|
||||||
|
import { ProjectSchema } from "@/lib/client";
|
||||||
|
import styles from "./../ProjectsEditorDrawer.module.css";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
project: ProjectSchema;
|
||||||
|
startEditing: () => void;
|
||||||
|
menuIconSize: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
const ProjectMenu: FC<Props> = ({
|
||||||
|
project,
|
||||||
|
startEditing,
|
||||||
|
menuIconSize = 16,
|
||||||
|
}) => {
|
||||||
|
const { onDeleteProject } = useProjectsContext();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Menu>
|
||||||
|
<Menu.Target>
|
||||||
|
<Box
|
||||||
|
className={styles["menu-button"]}
|
||||||
|
onClick={e => e.stopPropagation()}>
|
||||||
|
<IconDotsVertical size={menuIconSize} />
|
||||||
|
</Box>
|
||||||
|
</Menu.Target>
|
||||||
|
<Menu.Dropdown>
|
||||||
|
<Menu.Item
|
||||||
|
onClick={e => {
|
||||||
|
e.stopPropagation();
|
||||||
|
startEditing();
|
||||||
|
}}>
|
||||||
|
<Group wrap={"nowrap"}>
|
||||||
|
<IconEdit />
|
||||||
|
<Text>Переименовать</Text>
|
||||||
|
</Group>
|
||||||
|
</Menu.Item>
|
||||||
|
<Menu.Item
|
||||||
|
onClick={e => {
|
||||||
|
e.stopPropagation();
|
||||||
|
onDeleteProject(project);
|
||||||
|
}}>
|
||||||
|
<Group wrap={"nowrap"}>
|
||||||
|
<IconTrash />
|
||||||
|
<Text>Удалить</Text>
|
||||||
|
</Group>
|
||||||
|
</Menu.Item>
|
||||||
|
</Menu.Dropdown>
|
||||||
|
</Menu>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ProjectMenu;
|
||||||
@ -0,0 +1,55 @@
|
|||||||
|
import React, { FC } from "react";
|
||||||
|
import { Box, Group, Text } from "@mantine/core";
|
||||||
|
import { modals } from "@mantine/modals";
|
||||||
|
import { useProjectsContext } from "@/app/deals/contexts/ProjectsContext";
|
||||||
|
import ProjectMenu from "@/app/deals/drawers/ProjectsEditorDrawer/components/ProjectMenu";
|
||||||
|
import { ProjectSchema } from "@/lib/client";
|
||||||
|
import styles from "./../ProjectsEditorDrawer.module.css";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
project: ProjectSchema;
|
||||||
|
};
|
||||||
|
|
||||||
|
const ProjectMobile: FC<Props> = ({ project }) => {
|
||||||
|
const { onUpdateProject, setSelectedProject, setIsEditorDrawerOpened } =
|
||||||
|
useProjectsContext();
|
||||||
|
|
||||||
|
const startEditing = () => {
|
||||||
|
modals.openContextModal({
|
||||||
|
modal: "enterNameModal",
|
||||||
|
title: "Редактирование проекта",
|
||||||
|
withCloseButton: true,
|
||||||
|
innerProps: {
|
||||||
|
onComplete: name => onUpdateProject(project.id, { name }),
|
||||||
|
defaultValue: project.name,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const onClick = () => {
|
||||||
|
setSelectedProject(project);
|
||||||
|
setIsEditorDrawerOpened(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Group
|
||||||
|
w={"100%"}
|
||||||
|
pl={"xs"}
|
||||||
|
py={"xs"}
|
||||||
|
justify={"space-between"}
|
||||||
|
wrap={"nowrap"}
|
||||||
|
className={styles.project}
|
||||||
|
onClick={onClick}>
|
||||||
|
<Box>
|
||||||
|
<Text>{project.name}</Text>
|
||||||
|
</Box>
|
||||||
|
<ProjectMenu
|
||||||
|
project={project}
|
||||||
|
startEditing={startEditing}
|
||||||
|
menuIconSize={22}
|
||||||
|
/>
|
||||||
|
</Group>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ProjectMobile;
|
||||||
3
src/app/deals/drawers/ProjectsEditorDrawer/index.ts
Normal file
3
src/app/deals/drawers/ProjectsEditorDrawer/index.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import ProjectsEditorDrawer from "@/app/deals/drawers/ProjectsEditorDrawer/ProjectsEditorDrawer";
|
||||||
|
|
||||||
|
export default ProjectsEditorDrawer;
|
||||||
@ -5,6 +5,7 @@ import { ProjectsContextProvider } from "@/app/deals/contexts/ProjectsContext";
|
|||||||
import { StatusesContextProvider } from "@/app/deals/contexts/StatusesContext";
|
import { StatusesContextProvider } from "@/app/deals/contexts/StatusesContext";
|
||||||
import BoardStatusesEditorDrawer from "@/app/deals/drawers/BoardStatusesEditorDrawer";
|
import BoardStatusesEditorDrawer from "@/app/deals/drawers/BoardStatusesEditorDrawer";
|
||||||
import ProjectBoardsEditorDrawer from "@/app/deals/drawers/ProjectBoardsEditorDrawer";
|
import ProjectBoardsEditorDrawer from "@/app/deals/drawers/ProjectBoardsEditorDrawer";
|
||||||
|
import ProjectsEditorDrawer from "@/app/deals/drawers/ProjectsEditorDrawer";
|
||||||
import PageBlock from "@/components/layout/PageBlock/PageBlock";
|
import PageBlock from "@/components/layout/PageBlock/PageBlock";
|
||||||
import PageContainer from "@/components/layout/PageContainer/PageContainer";
|
import PageContainer from "@/components/layout/PageContainer/PageContainer";
|
||||||
import { DealsContextProvider } from "./contexts/DealsContext";
|
import { DealsContextProvider } from "./contexts/DealsContext";
|
||||||
@ -27,6 +28,7 @@ export default function DealsPage() {
|
|||||||
<BoardStatusesEditorDrawer />
|
<BoardStatusesEditorDrawer />
|
||||||
</StatusesContextProvider>
|
</StatusesContextProvider>
|
||||||
<ProjectBoardsEditorDrawer />
|
<ProjectBoardsEditorDrawer />
|
||||||
|
<ProjectsEditorDrawer />
|
||||||
</PageBlock>
|
</PageBlock>
|
||||||
</PageContainer>
|
</PageContainer>
|
||||||
</BoardsContextProvider>
|
</BoardsContextProvider>
|
||||||
|
|||||||
@ -1,12 +1,22 @@
|
|||||||
|
import { useEffect, useState } from "react";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { ProjectSchema } from "@/lib/client";
|
||||||
import { getProjectsOptions } from "@/lib/client/@tanstack/react-query.gen";
|
import { getProjectsOptions } from "@/lib/client/@tanstack/react-query.gen";
|
||||||
|
|
||||||
const useProjectsList = () => {
|
const useProjectsList = () => {
|
||||||
|
const [projects, setProjects] = useState<ProjectSchema[]>([]);
|
||||||
|
|
||||||
const { data, refetch, isLoading } = useQuery({
|
const { data, refetch, isLoading } = useQuery({
|
||||||
...getProjectsOptions(),
|
...getProjectsOptions(),
|
||||||
});
|
});
|
||||||
const projects = !data ? [] : data.projects;
|
|
||||||
return { projects, refetch, isLoading };
|
useEffect(() => {
|
||||||
|
if (data?.projects) {
|
||||||
|
setProjects(data.projects);
|
||||||
|
}
|
||||||
|
}, [data?.projects]);
|
||||||
|
|
||||||
|
return { projects, setProjects, refetch, isLoading };
|
||||||
};
|
};
|
||||||
|
|
||||||
export default useProjectsList;
|
export default useProjectsList;
|
||||||
|
|||||||
112
src/hooks/useProjectsOperations.tsx
Normal file
112
src/hooks/useProjectsOperations.tsx
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { useMutation } from "@tanstack/react-query";
|
||||||
|
import { AxiosError } from "axios";
|
||||||
|
import { Text } from "@mantine/core";
|
||||||
|
import { modals } from "@mantine/modals";
|
||||||
|
import {
|
||||||
|
HttpValidationError,
|
||||||
|
ProjectSchema,
|
||||||
|
UpdateProjectSchema,
|
||||||
|
} from "@/lib/client";
|
||||||
|
import {
|
||||||
|
createProjectMutation,
|
||||||
|
deleteProjectMutation,
|
||||||
|
updateProjectMutation,
|
||||||
|
} from "@/lib/client/@tanstack/react-query.gen";
|
||||||
|
import { notifications } from "@/lib/notifications";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
projects: ProjectSchema[];
|
||||||
|
setProjects: React.Dispatch<React.SetStateAction<ProjectSchema[]>>;
|
||||||
|
refetchProjects: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useProjectsOperations = ({
|
||||||
|
projects,
|
||||||
|
setProjects,
|
||||||
|
refetchProjects,
|
||||||
|
}: Props) => {
|
||||||
|
const onError = (error: AxiosError<HttpValidationError>) => {
|
||||||
|
console.error(error);
|
||||||
|
notifications.error({
|
||||||
|
message: error.response?.data?.detail as string | undefined,
|
||||||
|
});
|
||||||
|
refetchProjects();
|
||||||
|
};
|
||||||
|
|
||||||
|
const createProject = useMutation({
|
||||||
|
...createProjectMutation(),
|
||||||
|
onError,
|
||||||
|
onSuccess: res => {
|
||||||
|
setProjects([...projects, res.project]);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const updateProject = useMutation({
|
||||||
|
...updateProjectMutation(),
|
||||||
|
onError,
|
||||||
|
});
|
||||||
|
|
||||||
|
const deleteProject = useMutation({
|
||||||
|
...deleteProjectMutation(),
|
||||||
|
onError,
|
||||||
|
});
|
||||||
|
|
||||||
|
const onCreateProject = (name: string) => {
|
||||||
|
createProject.mutate({
|
||||||
|
body: {
|
||||||
|
project: {
|
||||||
|
name,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const onUpdateProject = (
|
||||||
|
projectId: number,
|
||||||
|
project: UpdateProjectSchema
|
||||||
|
) => {
|
||||||
|
updateProject.mutate({
|
||||||
|
query: { projectId },
|
||||||
|
body: { project },
|
||||||
|
});
|
||||||
|
|
||||||
|
setProjects(boards =>
|
||||||
|
boards.map(oldProject =>
|
||||||
|
oldProject.id !== projectId
|
||||||
|
? oldProject
|
||||||
|
: {
|
||||||
|
id: oldProject.id,
|
||||||
|
name: project.name ? project.name : oldProject.name,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onDeleteProject = (project: ProjectSchema) => {
|
||||||
|
modals.openConfirmModal({
|
||||||
|
title: "Удаление проекта",
|
||||||
|
children: (
|
||||||
|
<Text>
|
||||||
|
Вы уверены, что хотите удалить проект "{project.name}"?
|
||||||
|
</Text>
|
||||||
|
),
|
||||||
|
labels: { confirm: "Да", cancel: "Нет" },
|
||||||
|
confirmProps: { color: "red" },
|
||||||
|
onConfirm: () => {
|
||||||
|
deleteProject.mutate({
|
||||||
|
query: { projectId: project.id },
|
||||||
|
});
|
||||||
|
setProjects(projects =>
|
||||||
|
projects.filter(p => p.id !== project.id)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
onCreateProject,
|
||||||
|
onUpdateProject,
|
||||||
|
onDeleteProject,
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -1,22 +1,80 @@
|
|||||||
// This file is auto-generated by @hey-api/openapi-ts
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
|
|
||||||
import { type Options, getBoards, createBoard, deleteBoard, updateBoard, getDeals, updateDeal, getProjects, getStatuses, createStatus, deleteStatus, updateStatus } from '../sdk.gen';
|
import { queryOptions, type UseMutationOptions } from "@tanstack/react-query";
|
||||||
import { queryOptions, type UseMutationOptions } from '@tanstack/react-query';
|
import type { AxiosError } from "axios";
|
||||||
import type { GetBoardsData, CreateBoardData, CreateBoardError, CreateBoardResponse2, DeleteBoardData, DeleteBoardError, DeleteBoardResponse2, UpdateBoardData, UpdateBoardError, UpdateBoardResponse2, GetDealsData, UpdateDealData, UpdateDealError, UpdateDealResponse2, GetProjectsData, GetStatusesData, CreateStatusData, CreateStatusError, CreateStatusResponse2, DeleteStatusData, DeleteStatusError, DeleteStatusResponse2, UpdateStatusData, UpdateStatusError, UpdateStatusResponse2 } from '../types.gen';
|
import { client as _heyApiClient } from "../client.gen";
|
||||||
import type { AxiosError } from 'axios';
|
import {
|
||||||
import { client as _heyApiClient } from '../client.gen';
|
createBoard,
|
||||||
|
createProject,
|
||||||
|
createStatus,
|
||||||
|
deleteBoard,
|
||||||
|
deleteProject,
|
||||||
|
deleteStatus,
|
||||||
|
getBoards,
|
||||||
|
getDeals,
|
||||||
|
getProjects,
|
||||||
|
getStatuses,
|
||||||
|
updateBoard,
|
||||||
|
updateDeal,
|
||||||
|
updateProject,
|
||||||
|
updateStatus,
|
||||||
|
type Options,
|
||||||
|
} from "../sdk.gen";
|
||||||
|
import type {
|
||||||
|
CreateBoardData,
|
||||||
|
CreateBoardError,
|
||||||
|
CreateBoardResponse2,
|
||||||
|
CreateProjectData,
|
||||||
|
CreateProjectError,
|
||||||
|
CreateProjectResponse2,
|
||||||
|
CreateStatusData,
|
||||||
|
CreateStatusError,
|
||||||
|
CreateStatusResponse2,
|
||||||
|
DeleteBoardData,
|
||||||
|
DeleteBoardError,
|
||||||
|
DeleteBoardResponse2,
|
||||||
|
DeleteProjectData,
|
||||||
|
DeleteProjectError,
|
||||||
|
DeleteProjectResponse2,
|
||||||
|
DeleteStatusData,
|
||||||
|
DeleteStatusError,
|
||||||
|
DeleteStatusResponse2,
|
||||||
|
GetBoardsData,
|
||||||
|
GetDealsData,
|
||||||
|
GetProjectsData,
|
||||||
|
GetStatusesData,
|
||||||
|
UpdateBoardData,
|
||||||
|
UpdateBoardError,
|
||||||
|
UpdateBoardResponse2,
|
||||||
|
UpdateDealData,
|
||||||
|
UpdateDealError,
|
||||||
|
UpdateDealResponse2,
|
||||||
|
UpdateProjectData,
|
||||||
|
UpdateProjectError,
|
||||||
|
UpdateProjectResponse2,
|
||||||
|
UpdateStatusData,
|
||||||
|
UpdateStatusError,
|
||||||
|
UpdateStatusResponse2,
|
||||||
|
} from "../types.gen";
|
||||||
|
|
||||||
export type QueryKey<TOptions extends Options> = [
|
export type QueryKey<TOptions extends Options> = [
|
||||||
Pick<TOptions, 'baseURL' | 'body' | 'headers' | 'path' | 'query'> & {
|
Pick<TOptions, "baseURL" | "body" | "headers" | "path" | "query"> & {
|
||||||
_id: string;
|
_id: string;
|
||||||
_infinite?: boolean;
|
_infinite?: boolean;
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean): [
|
const createQueryKey = <TOptions extends Options>(
|
||||||
QueryKey<TOptions>[0]
|
id: string,
|
||||||
] => {
|
options?: TOptions,
|
||||||
const params: QueryKey<TOptions>[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? _heyApiClient).getConfig().baseURL } as QueryKey<TOptions>[0];
|
infinite?: boolean
|
||||||
|
): [QueryKey<TOptions>[0]] => {
|
||||||
|
const params: QueryKey<TOptions>[0] = {
|
||||||
|
_id: id,
|
||||||
|
baseURL:
|
||||||
|
options?.baseURL ||
|
||||||
|
(options?.client ?? _heyApiClient).getConfig().baseURL,
|
||||||
|
} as QueryKey<TOptions>[0];
|
||||||
if (infinite) {
|
if (infinite) {
|
||||||
params._infinite = infinite;
|
params._infinite = infinite;
|
||||||
}
|
}
|
||||||
@ -32,12 +90,11 @@ const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions
|
|||||||
if (options?.query) {
|
if (options?.query) {
|
||||||
params.query = options.query;
|
params.query = options.query;
|
||||||
}
|
}
|
||||||
return [
|
return [params];
|
||||||
params
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getBoardsQueryKey = (options: Options<GetBoardsData>) => createQueryKey('getBoards', options);
|
export const getBoardsQueryKey = (options: Options<GetBoardsData>) =>
|
||||||
|
createQueryKey("getBoards", options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Boards
|
* Get Boards
|
||||||
@ -49,15 +106,16 @@ export const getBoardsOptions = (options: Options<GetBoardsData>) => {
|
|||||||
...options,
|
...options,
|
||||||
...queryKey[0],
|
...queryKey[0],
|
||||||
signal,
|
signal,
|
||||||
throwOnError: true
|
throwOnError: true,
|
||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
queryKey: getBoardsQueryKey(options)
|
queryKey: getBoardsQueryKey(options),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createBoardQueryKey = (options: Options<CreateBoardData>) => createQueryKey('createBoard', options);
|
export const createBoardQueryKey = (options: Options<CreateBoardData>) =>
|
||||||
|
createQueryKey("createBoard", options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create Board
|
* Create Board
|
||||||
@ -69,27 +127,37 @@ export const createBoardOptions = (options: Options<CreateBoardData>) => {
|
|||||||
...options,
|
...options,
|
||||||
...queryKey[0],
|
...queryKey[0],
|
||||||
signal,
|
signal,
|
||||||
throwOnError: true
|
throwOnError: true,
|
||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
queryKey: createBoardQueryKey(options)
|
queryKey: createBoardQueryKey(options),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create Board
|
* Create Board
|
||||||
*/
|
*/
|
||||||
export const createBoardMutation = (options?: Partial<Options<CreateBoardData>>): UseMutationOptions<CreateBoardResponse2, AxiosError<CreateBoardError>, Options<CreateBoardData>> => {
|
export const createBoardMutation = (
|
||||||
const mutationOptions: UseMutationOptions<CreateBoardResponse2, AxiosError<CreateBoardError>, Options<CreateBoardData>> = {
|
options?: Partial<Options<CreateBoardData>>
|
||||||
mutationFn: async (localOptions) => {
|
): UseMutationOptions<
|
||||||
|
CreateBoardResponse2,
|
||||||
|
AxiosError<CreateBoardError>,
|
||||||
|
Options<CreateBoardData>
|
||||||
|
> => {
|
||||||
|
const mutationOptions: UseMutationOptions<
|
||||||
|
CreateBoardResponse2,
|
||||||
|
AxiosError<CreateBoardError>,
|
||||||
|
Options<CreateBoardData>
|
||||||
|
> = {
|
||||||
|
mutationFn: async localOptions => {
|
||||||
const { data } = await createBoard({
|
const { data } = await createBoard({
|
||||||
...options,
|
...options,
|
||||||
...localOptions,
|
...localOptions,
|
||||||
throwOnError: true
|
throwOnError: true,
|
||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
return mutationOptions;
|
return mutationOptions;
|
||||||
};
|
};
|
||||||
@ -97,16 +165,26 @@ export const createBoardMutation = (options?: Partial<Options<CreateBoardData>>)
|
|||||||
/**
|
/**
|
||||||
* Delete Board
|
* Delete Board
|
||||||
*/
|
*/
|
||||||
export const deleteBoardMutation = (options?: Partial<Options<DeleteBoardData>>): UseMutationOptions<DeleteBoardResponse2, AxiosError<DeleteBoardError>, Options<DeleteBoardData>> => {
|
export const deleteBoardMutation = (
|
||||||
const mutationOptions: UseMutationOptions<DeleteBoardResponse2, AxiosError<DeleteBoardError>, Options<DeleteBoardData>> = {
|
options?: Partial<Options<DeleteBoardData>>
|
||||||
mutationFn: async (localOptions) => {
|
): UseMutationOptions<
|
||||||
|
DeleteBoardResponse2,
|
||||||
|
AxiosError<DeleteBoardError>,
|
||||||
|
Options<DeleteBoardData>
|
||||||
|
> => {
|
||||||
|
const mutationOptions: UseMutationOptions<
|
||||||
|
DeleteBoardResponse2,
|
||||||
|
AxiosError<DeleteBoardError>,
|
||||||
|
Options<DeleteBoardData>
|
||||||
|
> = {
|
||||||
|
mutationFn: async localOptions => {
|
||||||
const { data } = await deleteBoard({
|
const { data } = await deleteBoard({
|
||||||
...options,
|
...options,
|
||||||
...localOptions,
|
...localOptions,
|
||||||
throwOnError: true
|
throwOnError: true,
|
||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
return mutationOptions;
|
return mutationOptions;
|
||||||
};
|
};
|
||||||
@ -114,21 +192,32 @@ export const deleteBoardMutation = (options?: Partial<Options<DeleteBoardData>>)
|
|||||||
/**
|
/**
|
||||||
* Update Board
|
* Update Board
|
||||||
*/
|
*/
|
||||||
export const updateBoardMutation = (options?: Partial<Options<UpdateBoardData>>): UseMutationOptions<UpdateBoardResponse2, AxiosError<UpdateBoardError>, Options<UpdateBoardData>> => {
|
export const updateBoardMutation = (
|
||||||
const mutationOptions: UseMutationOptions<UpdateBoardResponse2, AxiosError<UpdateBoardError>, Options<UpdateBoardData>> = {
|
options?: Partial<Options<UpdateBoardData>>
|
||||||
mutationFn: async (localOptions) => {
|
): UseMutationOptions<
|
||||||
|
UpdateBoardResponse2,
|
||||||
|
AxiosError<UpdateBoardError>,
|
||||||
|
Options<UpdateBoardData>
|
||||||
|
> => {
|
||||||
|
const mutationOptions: UseMutationOptions<
|
||||||
|
UpdateBoardResponse2,
|
||||||
|
AxiosError<UpdateBoardError>,
|
||||||
|
Options<UpdateBoardData>
|
||||||
|
> = {
|
||||||
|
mutationFn: async localOptions => {
|
||||||
const { data } = await updateBoard({
|
const { data } = await updateBoard({
|
||||||
...options,
|
...options,
|
||||||
...localOptions,
|
...localOptions,
|
||||||
throwOnError: true
|
throwOnError: true,
|
||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
return mutationOptions;
|
return mutationOptions;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getDealsQueryKey = (options: Options<GetDealsData>) => createQueryKey('getDeals', options);
|
export const getDealsQueryKey = (options: Options<GetDealsData>) =>
|
||||||
|
createQueryKey("getDeals", options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Deals
|
* Get Deals
|
||||||
@ -140,32 +229,43 @@ export const getDealsOptions = (options: Options<GetDealsData>) => {
|
|||||||
...options,
|
...options,
|
||||||
...queryKey[0],
|
...queryKey[0],
|
||||||
signal,
|
signal,
|
||||||
throwOnError: true
|
throwOnError: true,
|
||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
queryKey: getDealsQueryKey(options)
|
queryKey: getDealsQueryKey(options),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update Deal
|
* Update Deal
|
||||||
*/
|
*/
|
||||||
export const updateDealMutation = (options?: Partial<Options<UpdateDealData>>): UseMutationOptions<UpdateDealResponse2, AxiosError<UpdateDealError>, Options<UpdateDealData>> => {
|
export const updateDealMutation = (
|
||||||
const mutationOptions: UseMutationOptions<UpdateDealResponse2, AxiosError<UpdateDealError>, Options<UpdateDealData>> = {
|
options?: Partial<Options<UpdateDealData>>
|
||||||
mutationFn: async (localOptions) => {
|
): UseMutationOptions<
|
||||||
|
UpdateDealResponse2,
|
||||||
|
AxiosError<UpdateDealError>,
|
||||||
|
Options<UpdateDealData>
|
||||||
|
> => {
|
||||||
|
const mutationOptions: UseMutationOptions<
|
||||||
|
UpdateDealResponse2,
|
||||||
|
AxiosError<UpdateDealError>,
|
||||||
|
Options<UpdateDealData>
|
||||||
|
> = {
|
||||||
|
mutationFn: async localOptions => {
|
||||||
const { data } = await updateDeal({
|
const { data } = await updateDeal({
|
||||||
...options,
|
...options,
|
||||||
...localOptions,
|
...localOptions,
|
||||||
throwOnError: true
|
throwOnError: true,
|
||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
return mutationOptions;
|
return mutationOptions;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getProjectsQueryKey = (options?: Options<GetProjectsData>) => createQueryKey('getProjects', options);
|
export const getProjectsQueryKey = (options?: Options<GetProjectsData>) =>
|
||||||
|
createQueryKey("getProjects", options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Projects
|
* Get Projects
|
||||||
@ -177,15 +277,118 @@ export const getProjectsOptions = (options?: Options<GetProjectsData>) => {
|
|||||||
...options,
|
...options,
|
||||||
...queryKey[0],
|
...queryKey[0],
|
||||||
signal,
|
signal,
|
||||||
throwOnError: true
|
throwOnError: true,
|
||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
queryKey: getProjectsQueryKey(options)
|
queryKey: getProjectsQueryKey(options),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getStatusesQueryKey = (options: Options<GetStatusesData>) => createQueryKey('getStatuses', options);
|
export const createProjectQueryKey = (options: Options<CreateProjectData>) =>
|
||||||
|
createQueryKey("createProject", options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Project
|
||||||
|
*/
|
||||||
|
export const createProjectOptions = (options: Options<CreateProjectData>) => {
|
||||||
|
return queryOptions({
|
||||||
|
queryFn: async ({ queryKey, signal }) => {
|
||||||
|
const { data } = await createProject({
|
||||||
|
...options,
|
||||||
|
...queryKey[0],
|
||||||
|
signal,
|
||||||
|
throwOnError: true,
|
||||||
|
});
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
queryKey: createProjectQueryKey(options),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Project
|
||||||
|
*/
|
||||||
|
export const createProjectMutation = (
|
||||||
|
options?: Partial<Options<CreateProjectData>>
|
||||||
|
): UseMutationOptions<
|
||||||
|
CreateProjectResponse2,
|
||||||
|
AxiosError<CreateProjectError>,
|
||||||
|
Options<CreateProjectData>
|
||||||
|
> => {
|
||||||
|
const mutationOptions: UseMutationOptions<
|
||||||
|
CreateProjectResponse2,
|
||||||
|
AxiosError<CreateProjectError>,
|
||||||
|
Options<CreateProjectData>
|
||||||
|
> = {
|
||||||
|
mutationFn: async localOptions => {
|
||||||
|
const { data } = await createProject({
|
||||||
|
...options,
|
||||||
|
...localOptions,
|
||||||
|
throwOnError: true,
|
||||||
|
});
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
return mutationOptions;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete Project
|
||||||
|
*/
|
||||||
|
export const deleteProjectMutation = (
|
||||||
|
options?: Partial<Options<DeleteProjectData>>
|
||||||
|
): UseMutationOptions<
|
||||||
|
DeleteProjectResponse2,
|
||||||
|
AxiosError<DeleteProjectError>,
|
||||||
|
Options<DeleteProjectData>
|
||||||
|
> => {
|
||||||
|
const mutationOptions: UseMutationOptions<
|
||||||
|
DeleteProjectResponse2,
|
||||||
|
AxiosError<DeleteProjectError>,
|
||||||
|
Options<DeleteProjectData>
|
||||||
|
> = {
|
||||||
|
mutationFn: async localOptions => {
|
||||||
|
const { data } = await deleteProject({
|
||||||
|
...options,
|
||||||
|
...localOptions,
|
||||||
|
throwOnError: true,
|
||||||
|
});
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
return mutationOptions;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update Project
|
||||||
|
*/
|
||||||
|
export const updateProjectMutation = (
|
||||||
|
options?: Partial<Options<UpdateProjectData>>
|
||||||
|
): UseMutationOptions<
|
||||||
|
UpdateProjectResponse2,
|
||||||
|
AxiosError<UpdateProjectError>,
|
||||||
|
Options<UpdateProjectData>
|
||||||
|
> => {
|
||||||
|
const mutationOptions: UseMutationOptions<
|
||||||
|
UpdateProjectResponse2,
|
||||||
|
AxiosError<UpdateProjectError>,
|
||||||
|
Options<UpdateProjectData>
|
||||||
|
> = {
|
||||||
|
mutationFn: async localOptions => {
|
||||||
|
const { data } = await updateProject({
|
||||||
|
...options,
|
||||||
|
...localOptions,
|
||||||
|
throwOnError: true,
|
||||||
|
});
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
return mutationOptions;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getStatusesQueryKey = (options: Options<GetStatusesData>) =>
|
||||||
|
createQueryKey("getStatuses", options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Statuses
|
* Get Statuses
|
||||||
@ -197,15 +400,16 @@ export const getStatusesOptions = (options: Options<GetStatusesData>) => {
|
|||||||
...options,
|
...options,
|
||||||
...queryKey[0],
|
...queryKey[0],
|
||||||
signal,
|
signal,
|
||||||
throwOnError: true
|
throwOnError: true,
|
||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
queryKey: getStatusesQueryKey(options)
|
queryKey: getStatusesQueryKey(options),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createStatusQueryKey = (options: Options<CreateStatusData>) => createQueryKey('createStatus', options);
|
export const createStatusQueryKey = (options: Options<CreateStatusData>) =>
|
||||||
|
createQueryKey("createStatus", options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create Status
|
* Create Status
|
||||||
@ -217,27 +421,37 @@ export const createStatusOptions = (options: Options<CreateStatusData>) => {
|
|||||||
...options,
|
...options,
|
||||||
...queryKey[0],
|
...queryKey[0],
|
||||||
signal,
|
signal,
|
||||||
throwOnError: true
|
throwOnError: true,
|
||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
queryKey: createStatusQueryKey(options)
|
queryKey: createStatusQueryKey(options),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create Status
|
* Create Status
|
||||||
*/
|
*/
|
||||||
export const createStatusMutation = (options?: Partial<Options<CreateStatusData>>): UseMutationOptions<CreateStatusResponse2, AxiosError<CreateStatusError>, Options<CreateStatusData>> => {
|
export const createStatusMutation = (
|
||||||
const mutationOptions: UseMutationOptions<CreateStatusResponse2, AxiosError<CreateStatusError>, Options<CreateStatusData>> = {
|
options?: Partial<Options<CreateStatusData>>
|
||||||
mutationFn: async (localOptions) => {
|
): UseMutationOptions<
|
||||||
|
CreateStatusResponse2,
|
||||||
|
AxiosError<CreateStatusError>,
|
||||||
|
Options<CreateStatusData>
|
||||||
|
> => {
|
||||||
|
const mutationOptions: UseMutationOptions<
|
||||||
|
CreateStatusResponse2,
|
||||||
|
AxiosError<CreateStatusError>,
|
||||||
|
Options<CreateStatusData>
|
||||||
|
> = {
|
||||||
|
mutationFn: async localOptions => {
|
||||||
const { data } = await createStatus({
|
const { data } = await createStatus({
|
||||||
...options,
|
...options,
|
||||||
...localOptions,
|
...localOptions,
|
||||||
throwOnError: true
|
throwOnError: true,
|
||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
return mutationOptions;
|
return mutationOptions;
|
||||||
};
|
};
|
||||||
@ -245,16 +459,26 @@ export const createStatusMutation = (options?: Partial<Options<CreateStatusData>
|
|||||||
/**
|
/**
|
||||||
* Delete Status
|
* Delete Status
|
||||||
*/
|
*/
|
||||||
export const deleteStatusMutation = (options?: Partial<Options<DeleteStatusData>>): UseMutationOptions<DeleteStatusResponse2, AxiosError<DeleteStatusError>, Options<DeleteStatusData>> => {
|
export const deleteStatusMutation = (
|
||||||
const mutationOptions: UseMutationOptions<DeleteStatusResponse2, AxiosError<DeleteStatusError>, Options<DeleteStatusData>> = {
|
options?: Partial<Options<DeleteStatusData>>
|
||||||
mutationFn: async (localOptions) => {
|
): UseMutationOptions<
|
||||||
|
DeleteStatusResponse2,
|
||||||
|
AxiosError<DeleteStatusError>,
|
||||||
|
Options<DeleteStatusData>
|
||||||
|
> => {
|
||||||
|
const mutationOptions: UseMutationOptions<
|
||||||
|
DeleteStatusResponse2,
|
||||||
|
AxiosError<DeleteStatusError>,
|
||||||
|
Options<DeleteStatusData>
|
||||||
|
> = {
|
||||||
|
mutationFn: async localOptions => {
|
||||||
const { data } = await deleteStatus({
|
const { data } = await deleteStatus({
|
||||||
...options,
|
...options,
|
||||||
...localOptions,
|
...localOptions,
|
||||||
throwOnError: true
|
throwOnError: true,
|
||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
return mutationOptions;
|
return mutationOptions;
|
||||||
};
|
};
|
||||||
@ -262,16 +486,26 @@ export const deleteStatusMutation = (options?: Partial<Options<DeleteStatusData>
|
|||||||
/**
|
/**
|
||||||
* Update Status
|
* Update Status
|
||||||
*/
|
*/
|
||||||
export const updateStatusMutation = (options?: Partial<Options<UpdateStatusData>>): UseMutationOptions<UpdateStatusResponse2, AxiosError<UpdateStatusError>, Options<UpdateStatusData>> => {
|
export const updateStatusMutation = (
|
||||||
const mutationOptions: UseMutationOptions<UpdateStatusResponse2, AxiosError<UpdateStatusError>, Options<UpdateStatusData>> = {
|
options?: Partial<Options<UpdateStatusData>>
|
||||||
mutationFn: async (localOptions) => {
|
): UseMutationOptions<
|
||||||
|
UpdateStatusResponse2,
|
||||||
|
AxiosError<UpdateStatusError>,
|
||||||
|
Options<UpdateStatusData>
|
||||||
|
> => {
|
||||||
|
const mutationOptions: UseMutationOptions<
|
||||||
|
UpdateStatusResponse2,
|
||||||
|
AxiosError<UpdateStatusError>,
|
||||||
|
Options<UpdateStatusData>
|
||||||
|
> = {
|
||||||
|
mutationFn: async localOptions => {
|
||||||
const { data } = await updateStatus({
|
const { data } = await updateStatus({
|
||||||
...options,
|
...options,
|
||||||
...localOptions,
|
...localOptions,
|
||||||
throwOnError: true
|
throwOnError: true,
|
||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
return mutationOptions;
|
return mutationOptions;
|
||||||
};
|
};
|
||||||
@ -1,8 +1,13 @@
|
|||||||
// This file is auto-generated by @hey-api/openapi-ts
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
|
|
||||||
import type { ClientOptions } from './types.gen';
|
import { createClientConfig } from "../../hey-api-config";
|
||||||
import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client';
|
import {
|
||||||
import { createClientConfig } from '../../hey-api-config';
|
createClient,
|
||||||
|
createConfig,
|
||||||
|
type Config,
|
||||||
|
type ClientOptions as DefaultClientOptions,
|
||||||
|
} from "./client";
|
||||||
|
import type { ClientOptions } from "./types.gen";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The `createClientConfig()` function will be called on client initialization
|
* The `createClientConfig()` function will be called on client initialization
|
||||||
@ -12,8 +17,15 @@ import { createClientConfig } from '../../hey-api-config';
|
|||||||
* `setConfig()`. This is useful for example if you're using Next.js
|
* `setConfig()`. This is useful for example if you're using Next.js
|
||||||
* to ensure your client always has the correct values.
|
* to ensure your client always has the correct values.
|
||||||
*/
|
*/
|
||||||
export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>;
|
export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> =
|
||||||
|
(
|
||||||
|
override?: Config<DefaultClientOptions & T>
|
||||||
|
) => Config<Required<DefaultClientOptions> & T>;
|
||||||
|
|
||||||
export const client = createClient(createClientConfig(createConfig<ClientOptions>({
|
export const client = createClient(
|
||||||
baseURL: '/api'
|
createClientConfig(
|
||||||
})));
|
createConfig<ClientOptions>({
|
||||||
|
baseURL: "/api",
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|||||||
@ -1,14 +1,13 @@
|
|||||||
import type { AxiosError, RawAxiosRequestHeaders } from 'axios';
|
import type { AxiosError, RawAxiosRequestHeaders } from "axios";
|
||||||
import axios from 'axios';
|
import axios from "axios";
|
||||||
|
import type { Client, Config } from "./types";
|
||||||
import type { Client, Config } from './types';
|
|
||||||
import {
|
import {
|
||||||
buildUrl,
|
buildUrl,
|
||||||
createConfig,
|
createConfig,
|
||||||
mergeConfigs,
|
mergeConfigs,
|
||||||
mergeHeaders,
|
mergeHeaders,
|
||||||
setAuthParams,
|
setAuthParams,
|
||||||
} from './utils';
|
} from "./utils";
|
||||||
|
|
||||||
export const createClient = (config: Config = {}): Client => {
|
export const createClient = (config: Config = {}): Client => {
|
||||||
let _config = mergeConfigs(createConfig(), config);
|
let _config = mergeConfigs(createConfig(), config);
|
||||||
@ -31,7 +30,7 @@ export const createClient = (config: Config = {}): Client => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
const request: Client['request'] = async (options) => {
|
const request: Client["request"] = async options => {
|
||||||
const opts = {
|
const opts = {
|
||||||
..._config,
|
..._config,
|
||||||
...options,
|
...options,
|
||||||
@ -73,7 +72,7 @@ export const createClient = (config: Config = {}): Client => {
|
|||||||
|
|
||||||
let { data } = response;
|
let { data } = response;
|
||||||
|
|
||||||
if (opts.responseType === 'json') {
|
if (opts.responseType === "json") {
|
||||||
if (opts.responseValidator) {
|
if (opts.responseValidator) {
|
||||||
await opts.responseValidator(data);
|
await opts.responseValidator(data);
|
||||||
}
|
}
|
||||||
@ -100,15 +99,15 @@ export const createClient = (config: Config = {}): Client => {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
buildUrl,
|
buildUrl,
|
||||||
delete: (options) => request({ ...options, method: 'DELETE' }),
|
delete: options => request({ ...options, method: "DELETE" }),
|
||||||
get: (options) => request({ ...options, method: 'GET' }),
|
get: options => request({ ...options, method: "GET" }),
|
||||||
getConfig,
|
getConfig,
|
||||||
head: (options) => request({ ...options, method: 'HEAD' }),
|
head: options => request({ ...options, method: "HEAD" }),
|
||||||
instance,
|
instance,
|
||||||
options: (options) => request({ ...options, method: 'OPTIONS' }),
|
options: options => request({ ...options, method: "OPTIONS" }),
|
||||||
patch: (options) => request({ ...options, method: 'PATCH' }),
|
patch: options => request({ ...options, method: "PATCH" }),
|
||||||
post: (options) => request({ ...options, method: 'POST' }),
|
post: options => request({ ...options, method: "POST" }),
|
||||||
put: (options) => request({ ...options, method: 'PUT' }),
|
put: options => request({ ...options, method: "PUT" }),
|
||||||
request,
|
request,
|
||||||
setConfig,
|
setConfig,
|
||||||
} as Client;
|
} as Client;
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
export type { Auth } from '../core/auth';
|
export type { Auth } from "../core/auth";
|
||||||
export type { QuerySerializerOptions } from '../core/bodySerializer';
|
export type { QuerySerializerOptions } from "../core/bodySerializer";
|
||||||
export {
|
export {
|
||||||
formDataBodySerializer,
|
formDataBodySerializer,
|
||||||
jsonBodySerializer,
|
jsonBodySerializer,
|
||||||
urlSearchParamsBodySerializer,
|
urlSearchParamsBodySerializer,
|
||||||
} from '../core/bodySerializer';
|
} from "../core/bodySerializer";
|
||||||
export { buildClientParams } from '../core/params';
|
export { buildClientParams } from "../core/params";
|
||||||
export { createClient } from './client';
|
export { createClient } from "./client";
|
||||||
export type {
|
export type {
|
||||||
Client,
|
Client,
|
||||||
ClientOptions,
|
ClientOptions,
|
||||||
@ -17,5 +17,5 @@ export type {
|
|||||||
RequestOptions,
|
RequestOptions,
|
||||||
RequestResult,
|
RequestResult,
|
||||||
TDataShape,
|
TDataShape,
|
||||||
} from './types';
|
} from "./types";
|
||||||
export { createConfig } from './utils';
|
export { createConfig } from "./utils";
|
||||||
|
|||||||
@ -5,16 +5,15 @@ import type {
|
|||||||
AxiosResponse,
|
AxiosResponse,
|
||||||
AxiosStatic,
|
AxiosStatic,
|
||||||
CreateAxiosDefaults,
|
CreateAxiosDefaults,
|
||||||
} from 'axios';
|
} from "axios";
|
||||||
|
import type { Auth } from "../core/auth";
|
||||||
import type { Auth } from '../core/auth';
|
import type { Client as CoreClient, Config as CoreConfig } from "../core/types";
|
||||||
import type {
|
|
||||||
Client as CoreClient,
|
|
||||||
Config as CoreConfig,
|
|
||||||
} from '../core/types';
|
|
||||||
|
|
||||||
export interface Config<T extends ClientOptions = ClientOptions>
|
export interface Config<T extends ClientOptions = ClientOptions>
|
||||||
extends Omit<CreateAxiosDefaults, 'auth' | 'baseURL' | 'headers' | 'method'>,
|
extends Omit<
|
||||||
|
CreateAxiosDefaults,
|
||||||
|
"auth" | "baseURL" | "headers" | "method"
|
||||||
|
>,
|
||||||
CoreConfig {
|
CoreConfig {
|
||||||
/**
|
/**
|
||||||
* Axios implementation. You can use this option to provide a custom
|
* Axios implementation. You can use this option to provide a custom
|
||||||
@ -26,7 +25,7 @@ export interface Config<T extends ClientOptions = ClientOptions>
|
|||||||
/**
|
/**
|
||||||
* Base URL for all requests made by this client.
|
* Base URL for all requests made by this client.
|
||||||
*/
|
*/
|
||||||
baseURL?: T['baseURL'];
|
baseURL?: T["baseURL"];
|
||||||
/**
|
/**
|
||||||
* An object containing any HTTP headers that you want to pre-populate your
|
* An object containing any HTTP headers that you want to pre-populate your
|
||||||
* `Headers` object with.
|
* `Headers` object with.
|
||||||
@ -50,7 +49,7 @@ export interface Config<T extends ClientOptions = ClientOptions>
|
|||||||
*
|
*
|
||||||
* @default false
|
* @default false
|
||||||
*/
|
*/
|
||||||
throwOnError?: T['throwOnError'];
|
throwOnError?: T["throwOnError"];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RequestOptions<
|
export interface RequestOptions<
|
||||||
@ -86,10 +85,14 @@ export type RequestResult<
|
|||||||
>
|
>
|
||||||
: Promise<
|
: Promise<
|
||||||
| (AxiosResponse<
|
| (AxiosResponse<
|
||||||
TData extends Record<string, unknown> ? TData[keyof TData] : TData
|
TData extends Record<string, unknown>
|
||||||
|
? TData[keyof TData]
|
||||||
|
: TData
|
||||||
> & { error: undefined })
|
> & { error: undefined })
|
||||||
| (AxiosError<
|
| (AxiosError<
|
||||||
TError extends Record<string, unknown> ? TError[keyof TError] : TError
|
TError extends Record<string, unknown>
|
||||||
|
? TError[keyof TError]
|
||||||
|
: TError
|
||||||
> & {
|
> & {
|
||||||
data: undefined;
|
data: undefined;
|
||||||
error: TError extends Record<string, unknown>
|
error: TError extends Record<string, unknown>
|
||||||
@ -108,7 +111,7 @@ type MethodFn = <
|
|||||||
TError = unknown,
|
TError = unknown,
|
||||||
ThrowOnError extends boolean = false,
|
ThrowOnError extends boolean = false,
|
||||||
>(
|
>(
|
||||||
options: Omit<RequestOptions<ThrowOnError>, 'method'>,
|
options: Omit<RequestOptions<ThrowOnError>, "method">
|
||||||
) => RequestResult<TData, TError, ThrowOnError>;
|
) => RequestResult<TData, TError, ThrowOnError>;
|
||||||
|
|
||||||
type RequestFn = <
|
type RequestFn = <
|
||||||
@ -116,8 +119,8 @@ type RequestFn = <
|
|||||||
TError = unknown,
|
TError = unknown,
|
||||||
ThrowOnError extends boolean = false,
|
ThrowOnError extends boolean = false,
|
||||||
>(
|
>(
|
||||||
options: Omit<RequestOptions<ThrowOnError>, 'method'> &
|
options: Omit<RequestOptions<ThrowOnError>, "method"> &
|
||||||
Pick<Required<RequestOptions<ThrowOnError>>, 'method'>,
|
Pick<Required<RequestOptions<ThrowOnError>>, "method">
|
||||||
) => RequestResult<TData, TError, ThrowOnError>;
|
) => RequestResult<TData, TError, ThrowOnError>;
|
||||||
|
|
||||||
type BuildUrlFn = <
|
type BuildUrlFn = <
|
||||||
@ -128,7 +131,7 @@ type BuildUrlFn = <
|
|||||||
url: string;
|
url: string;
|
||||||
},
|
},
|
||||||
>(
|
>(
|
||||||
options: Pick<TData, 'url'> & Omit<Options<TData>, 'axios'>,
|
options: Pick<TData, "url"> & Omit<Options<TData>, "axios">
|
||||||
) => string;
|
) => string;
|
||||||
|
|
||||||
export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn> & {
|
export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn> & {
|
||||||
@ -144,7 +147,7 @@ export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn> & {
|
|||||||
* to ensure your client always has the correct values.
|
* to ensure your client always has the correct values.
|
||||||
*/
|
*/
|
||||||
export type CreateClientConfig<T extends ClientOptions = ClientOptions> = (
|
export type CreateClientConfig<T extends ClientOptions = ClientOptions> = (
|
||||||
override?: Config<ClientOptions & T>,
|
override?: Config<ClientOptions & T>
|
||||||
) => Config<Required<ClientOptions> & T>;
|
) => Config<Required<ClientOptions> & T>;
|
||||||
|
|
||||||
export interface TDataShape {
|
export interface TDataShape {
|
||||||
@ -160,20 +163,21 @@ type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|||||||
export type Options<
|
export type Options<
|
||||||
TData extends TDataShape = TDataShape,
|
TData extends TDataShape = TDataShape,
|
||||||
ThrowOnError extends boolean = boolean,
|
ThrowOnError extends boolean = boolean,
|
||||||
> = OmitKeys<RequestOptions<ThrowOnError>, 'body' | 'path' | 'query' | 'url'> &
|
> = OmitKeys<RequestOptions<ThrowOnError>, "body" | "path" | "query" | "url"> &
|
||||||
Omit<TData, 'url'>;
|
Omit<TData, "url">;
|
||||||
|
|
||||||
export type OptionsLegacyParser<
|
export type OptionsLegacyParser<
|
||||||
TData = unknown,
|
TData = unknown,
|
||||||
ThrowOnError extends boolean = boolean,
|
ThrowOnError extends boolean = boolean,
|
||||||
> = TData extends { body?: any }
|
> = TData extends { body?: any }
|
||||||
? TData extends { headers?: any }
|
? TData extends { headers?: any }
|
||||||
? OmitKeys<RequestOptions<ThrowOnError>, 'body' | 'headers' | 'url'> & TData
|
? OmitKeys<RequestOptions<ThrowOnError>, "body" | "headers" | "url"> &
|
||||||
: OmitKeys<RequestOptions<ThrowOnError>, 'body' | 'url'> &
|
TData
|
||||||
|
: OmitKeys<RequestOptions<ThrowOnError>, "body" | "url"> &
|
||||||
TData &
|
TData &
|
||||||
Pick<RequestOptions<ThrowOnError>, 'headers'>
|
Pick<RequestOptions<ThrowOnError>, "headers">
|
||||||
: TData extends { headers?: any }
|
: TData extends { headers?: any }
|
||||||
? OmitKeys<RequestOptions<ThrowOnError>, 'headers' | 'url'> &
|
? OmitKeys<RequestOptions<ThrowOnError>, "headers" | "url"> &
|
||||||
TData &
|
TData &
|
||||||
Pick<RequestOptions<ThrowOnError>, 'body'>
|
Pick<RequestOptions<ThrowOnError>, "body">
|
||||||
: OmitKeys<RequestOptions<ThrowOnError>, 'url'> & TData;
|
: OmitKeys<RequestOptions<ThrowOnError>, "url"> & TData;
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
import { getAuthToken } from '../core/auth';
|
import { getAuthToken } from "../core/auth";
|
||||||
import type {
|
import type {
|
||||||
QuerySerializer,
|
QuerySerializer,
|
||||||
QuerySerializerOptions,
|
QuerySerializerOptions,
|
||||||
} from '../core/bodySerializer';
|
} from "../core/bodySerializer";
|
||||||
import type { ArraySeparatorStyle } from '../core/pathSerializer';
|
import type { ArraySeparatorStyle } from "../core/pathSerializer";
|
||||||
import {
|
import {
|
||||||
serializeArrayParam,
|
serializeArrayParam,
|
||||||
serializeObjectParam,
|
serializeObjectParam,
|
||||||
serializePrimitiveParam,
|
serializePrimitiveParam,
|
||||||
} from '../core/pathSerializer';
|
} from "../core/pathSerializer";
|
||||||
import type { Client, ClientOptions, Config, RequestOptions } from './types';
|
import type { Client, ClientOptions, Config, RequestOptions } from "./types";
|
||||||
|
|
||||||
interface PathSerializer {
|
interface PathSerializer {
|
||||||
path: Record<string, unknown>;
|
path: Record<string, unknown>;
|
||||||
@ -25,19 +25,19 @@ const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
|
|||||||
for (const match of matches) {
|
for (const match of matches) {
|
||||||
let explode = false;
|
let explode = false;
|
||||||
let name = match.substring(1, match.length - 1);
|
let name = match.substring(1, match.length - 1);
|
||||||
let style: ArraySeparatorStyle = 'simple';
|
let style: ArraySeparatorStyle = "simple";
|
||||||
|
|
||||||
if (name.endsWith('*')) {
|
if (name.endsWith("*")) {
|
||||||
explode = true;
|
explode = true;
|
||||||
name = name.substring(0, name.length - 1);
|
name = name.substring(0, name.length - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name.startsWith('.')) {
|
if (name.startsWith(".")) {
|
||||||
name = name.substring(1);
|
name = name.substring(1);
|
||||||
style = 'label';
|
style = "label";
|
||||||
} else if (name.startsWith(';')) {
|
} else if (name.startsWith(";")) {
|
||||||
name = name.substring(1);
|
name = name.substring(1);
|
||||||
style = 'matrix';
|
style = "matrix";
|
||||||
}
|
}
|
||||||
|
|
||||||
const value = path[name];
|
const value = path[name];
|
||||||
@ -49,12 +49,12 @@ const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
|
|||||||
if (Array.isArray(value)) {
|
if (Array.isArray(value)) {
|
||||||
url = url.replace(
|
url = url.replace(
|
||||||
match,
|
match,
|
||||||
serializeArrayParam({ explode, name, style, value }),
|
serializeArrayParam({ explode, name, style, value })
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof value === 'object') {
|
if (typeof value === "object") {
|
||||||
url = url.replace(
|
url = url.replace(
|
||||||
match,
|
match,
|
||||||
serializeObjectParam({
|
serializeObjectParam({
|
||||||
@ -63,24 +63,24 @@ const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
|
|||||||
style,
|
style,
|
||||||
value: value as Record<string, unknown>,
|
value: value as Record<string, unknown>,
|
||||||
valueOnly: true,
|
valueOnly: true,
|
||||||
}),
|
})
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (style === 'matrix') {
|
if (style === "matrix") {
|
||||||
url = url.replace(
|
url = url.replace(
|
||||||
match,
|
match,
|
||||||
`;${serializePrimitiveParam({
|
`;${serializePrimitiveParam({
|
||||||
name,
|
name,
|
||||||
value: value as string,
|
value: value as string,
|
||||||
})}`,
|
})}`
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const replaceValue = encodeURIComponent(
|
const replaceValue = encodeURIComponent(
|
||||||
style === 'label' ? `.${value as string}` : (value as string),
|
style === "label" ? `.${value as string}` : (value as string)
|
||||||
);
|
);
|
||||||
url = url.replace(match, replaceValue);
|
url = url.replace(match, replaceValue);
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ export const createQuerySerializer = <T = unknown>({
|
|||||||
}: QuerySerializerOptions = {}) => {
|
}: QuerySerializerOptions = {}) => {
|
||||||
const querySerializer = (queryParams: T) => {
|
const querySerializer = (queryParams: T) => {
|
||||||
const search: string[] = [];
|
const search: string[] = [];
|
||||||
if (queryParams && typeof queryParams === 'object') {
|
if (queryParams && typeof queryParams === "object") {
|
||||||
for (const name in queryParams) {
|
for (const name in queryParams) {
|
||||||
const value = queryParams[name];
|
const value = queryParams[name];
|
||||||
|
|
||||||
@ -108,17 +108,17 @@ export const createQuerySerializer = <T = unknown>({
|
|||||||
allowReserved,
|
allowReserved,
|
||||||
explode: true,
|
explode: true,
|
||||||
name,
|
name,
|
||||||
style: 'form',
|
style: "form",
|
||||||
value,
|
value,
|
||||||
...array,
|
...array,
|
||||||
});
|
});
|
||||||
if (serializedArray) search.push(serializedArray);
|
if (serializedArray) search.push(serializedArray);
|
||||||
} else if (typeof value === 'object') {
|
} else if (typeof value === "object") {
|
||||||
const serializedObject = serializeObjectParam({
|
const serializedObject = serializeObjectParam({
|
||||||
allowReserved,
|
allowReserved,
|
||||||
explode: true,
|
explode: true,
|
||||||
name,
|
name,
|
||||||
style: 'deepObject',
|
style: "deepObject",
|
||||||
value: value as Record<string, unknown>,
|
value: value as Record<string, unknown>,
|
||||||
...object,
|
...object,
|
||||||
});
|
});
|
||||||
@ -133,7 +133,7 @@ export const createQuerySerializer = <T = unknown>({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return search.join('&');
|
return search.join("&");
|
||||||
};
|
};
|
||||||
return querySerializer;
|
return querySerializer;
|
||||||
};
|
};
|
||||||
@ -141,8 +141,8 @@ export const createQuerySerializer = <T = unknown>({
|
|||||||
export const setAuthParams = async ({
|
export const setAuthParams = async ({
|
||||||
security,
|
security,
|
||||||
...options
|
...options
|
||||||
}: Pick<Required<RequestOptions>, 'security'> &
|
}: Pick<Required<RequestOptions>, "security"> &
|
||||||
Pick<RequestOptions, 'auth' | 'query'> & {
|
Pick<RequestOptions, "auth" | "query"> & {
|
||||||
headers: Record<any, unknown>;
|
headers: Record<any, unknown>;
|
||||||
}) => {
|
}) => {
|
||||||
for (const auth of security) {
|
for (const auth of security) {
|
||||||
@ -152,25 +152,26 @@ export const setAuthParams = async ({
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const name = auth.name ?? 'Authorization';
|
const name = auth.name ?? "Authorization";
|
||||||
|
|
||||||
switch (auth.in) {
|
switch (auth.in) {
|
||||||
case 'query':
|
case "query":
|
||||||
if (!options.query) {
|
if (!options.query) {
|
||||||
options.query = {};
|
options.query = {};
|
||||||
}
|
}
|
||||||
options.query[name] = token;
|
options.query[name] = token;
|
||||||
break;
|
break;
|
||||||
case 'cookie': {
|
case "cookie": {
|
||||||
const value = `${name}=${token}`;
|
const value = `${name}=${token}`;
|
||||||
if ('Cookie' in options.headers && options.headers['Cookie']) {
|
if ("Cookie" in options.headers && options.headers["Cookie"]) {
|
||||||
options.headers['Cookie'] = `${options.headers['Cookie']}; ${value}`;
|
options.headers["Cookie"] =
|
||||||
|
`${options.headers["Cookie"]}; ${value}`;
|
||||||
} else {
|
} else {
|
||||||
options.headers['Cookie'] = value;
|
options.headers["Cookie"] = value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'header':
|
case "header":
|
||||||
default:
|
default:
|
||||||
options.headers[name] = token;
|
options.headers[name] = token;
|
||||||
break;
|
break;
|
||||||
@ -180,13 +181,13 @@ export const setAuthParams = async ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const buildUrl: Client['buildUrl'] = (options) => {
|
export const buildUrl: Client["buildUrl"] = options => {
|
||||||
const url = getUrl({
|
const url = getUrl({
|
||||||
path: options.path,
|
path: options.path,
|
||||||
// let `paramsSerializer()` handle query params if it exists
|
// let `paramsSerializer()` handle query params if it exists
|
||||||
query: !options.paramsSerializer ? options.query : undefined,
|
query: !options.paramsSerializer ? options.query : undefined,
|
||||||
querySerializer:
|
querySerializer:
|
||||||
typeof options.querySerializer === 'function'
|
typeof options.querySerializer === "function"
|
||||||
? options.querySerializer
|
? options.querySerializer
|
||||||
: createQuerySerializer(options.querySerializer),
|
: createQuerySerializer(options.querySerializer),
|
||||||
url: options.url,
|
url: options.url,
|
||||||
@ -205,13 +206,13 @@ export const getUrl = ({
|
|||||||
querySerializer: QuerySerializer;
|
querySerializer: QuerySerializer;
|
||||||
url: string;
|
url: string;
|
||||||
}) => {
|
}) => {
|
||||||
const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
|
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
||||||
let url = pathUrl;
|
let url = pathUrl;
|
||||||
if (path) {
|
if (path) {
|
||||||
url = defaultPathSerializer({ path, url });
|
url = defaultPathSerializer({ path, url });
|
||||||
}
|
}
|
||||||
let search = query ? querySerializer(query) : '';
|
let search = query ? querySerializer(query) : "";
|
||||||
if (search.startsWith('?')) {
|
if (search.startsWith("?")) {
|
||||||
search = search.substring(1);
|
search = search.substring(1);
|
||||||
}
|
}
|
||||||
if (search) {
|
if (search) {
|
||||||
@ -230,21 +231,21 @@ export const mergeConfigs = (a: Config, b: Config): Config => {
|
|||||||
* Special Axios headers keywords allowing to set headers by request method.
|
* Special Axios headers keywords allowing to set headers by request method.
|
||||||
*/
|
*/
|
||||||
export const axiosHeadersKeywords = [
|
export const axiosHeadersKeywords = [
|
||||||
'common',
|
"common",
|
||||||
'delete',
|
"delete",
|
||||||
'get',
|
"get",
|
||||||
'head',
|
"head",
|
||||||
'patch',
|
"patch",
|
||||||
'post',
|
"post",
|
||||||
'put',
|
"put",
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
export const mergeHeaders = (
|
export const mergeHeaders = (
|
||||||
...headers: Array<Required<Config>['headers'] | undefined>
|
...headers: Array<Required<Config>["headers"] | undefined>
|
||||||
): Record<any, unknown> => {
|
): Record<any, unknown> => {
|
||||||
const mergedHeaders: Record<any, unknown> = {};
|
const mergedHeaders: Record<any, unknown> = {};
|
||||||
for (const header of headers) {
|
for (const header of headers) {
|
||||||
if (!header || typeof header !== 'object') {
|
if (!header || typeof header !== "object") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,9 +254,9 @@ export const mergeHeaders = (
|
|||||||
for (const [key, value] of iterator) {
|
for (const [key, value] of iterator) {
|
||||||
if (
|
if (
|
||||||
axiosHeadersKeywords.includes(
|
axiosHeadersKeywords.includes(
|
||||||
key as (typeof axiosHeadersKeywords)[number],
|
key as (typeof axiosHeadersKeywords)[number]
|
||||||
) &&
|
) &&
|
||||||
typeof value === 'object'
|
typeof value === "object"
|
||||||
) {
|
) {
|
||||||
mergedHeaders[key] = {
|
mergedHeaders[key] = {
|
||||||
...(mergedHeaders[key] as Record<any, unknown>),
|
...(mergedHeaders[key] as Record<any, unknown>),
|
||||||
@ -266,13 +267,18 @@ export const mergeHeaders = (
|
|||||||
} else if (Array.isArray(value)) {
|
} else if (Array.isArray(value)) {
|
||||||
for (const v of value) {
|
for (const v of value) {
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
mergedHeaders[key] = [...(mergedHeaders[key] ?? []), v as string];
|
mergedHeaders[key] = [
|
||||||
|
...(mergedHeaders[key] ?? []),
|
||||||
|
v as string,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
} else if (value !== undefined) {
|
} else if (value !== undefined) {
|
||||||
// assume object headers are meant to be JSON stringified, i.e. their
|
// assume object headers are meant to be JSON stringified, i.e. their
|
||||||
// content value in OpenAPI specification is 'application/json'
|
// content value in OpenAPI specification is 'application/json'
|
||||||
mergedHeaders[key] =
|
mergedHeaders[key] =
|
||||||
typeof value === 'object' ? JSON.stringify(value) : (value as string);
|
typeof value === "object"
|
||||||
|
? JSON.stringify(value)
|
||||||
|
: (value as string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -280,7 +286,7 @@ export const mergeHeaders = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const createConfig = <T extends ClientOptions = ClientOptions>(
|
export const createConfig = <T extends ClientOptions = ClientOptions>(
|
||||||
override: Config<Omit<ClientOptions, keyof T> & T> = {},
|
override: Config<Omit<ClientOptions, keyof T> & T> = {}
|
||||||
): Config<Omit<ClientOptions, keyof T> & T> => ({
|
): Config<Omit<ClientOptions, keyof T> & T> => ({
|
||||||
...override,
|
...override,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -6,33 +6,33 @@ export interface Auth {
|
|||||||
*
|
*
|
||||||
* @default 'header'
|
* @default 'header'
|
||||||
*/
|
*/
|
||||||
in?: 'header' | 'query' | 'cookie';
|
in?: "header" | "query" | "cookie";
|
||||||
/**
|
/**
|
||||||
* Header or query parameter name.
|
* Header or query parameter name.
|
||||||
*
|
*
|
||||||
* @default 'Authorization'
|
* @default 'Authorization'
|
||||||
*/
|
*/
|
||||||
name?: string;
|
name?: string;
|
||||||
scheme?: 'basic' | 'bearer';
|
scheme?: "basic" | "bearer";
|
||||||
type: 'apiKey' | 'http';
|
type: "apiKey" | "http";
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getAuthToken = async (
|
export const getAuthToken = async (
|
||||||
auth: Auth,
|
auth: Auth,
|
||||||
callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken,
|
callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken
|
||||||
): Promise<string | undefined> => {
|
): Promise<string | undefined> => {
|
||||||
const token =
|
const token =
|
||||||
typeof callback === 'function' ? await callback(auth) : callback;
|
typeof callback === "function" ? await callback(auth) : callback;
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auth.scheme === 'bearer') {
|
if (auth.scheme === "bearer") {
|
||||||
return `Bearer ${token}`;
|
return `Bearer ${token}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auth.scheme === 'basic') {
|
if (auth.scheme === "basic") {
|
||||||
return `Basic ${btoa(token)}`;
|
return `Basic ${btoa(token)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import type {
|
|||||||
ArrayStyle,
|
ArrayStyle,
|
||||||
ObjectStyle,
|
ObjectStyle,
|
||||||
SerializerOptions,
|
SerializerOptions,
|
||||||
} from './pathSerializer';
|
} from "./pathSerializer";
|
||||||
|
|
||||||
export type QuerySerializer = (query: Record<string, unknown>) => string;
|
export type QuerySerializer = (query: Record<string, unknown>) => string;
|
||||||
|
|
||||||
@ -17,9 +17,9 @@ export interface QuerySerializerOptions {
|
|||||||
const serializeFormDataPair = (
|
const serializeFormDataPair = (
|
||||||
data: FormData,
|
data: FormData,
|
||||||
key: string,
|
key: string,
|
||||||
value: unknown,
|
value: unknown
|
||||||
): void => {
|
): void => {
|
||||||
if (typeof value === 'string' || value instanceof Blob) {
|
if (typeof value === "string" || value instanceof Blob) {
|
||||||
data.append(key, value);
|
data.append(key, value);
|
||||||
} else {
|
} else {
|
||||||
data.append(key, JSON.stringify(value));
|
data.append(key, JSON.stringify(value));
|
||||||
@ -29,9 +29,9 @@ const serializeFormDataPair = (
|
|||||||
const serializeUrlSearchParamsPair = (
|
const serializeUrlSearchParamsPair = (
|
||||||
data: URLSearchParams,
|
data: URLSearchParams,
|
||||||
key: string,
|
key: string,
|
||||||
value: unknown,
|
value: unknown
|
||||||
): void => {
|
): void => {
|
||||||
if (typeof value === 'string') {
|
if (typeof value === "string") {
|
||||||
data.append(key, value);
|
data.append(key, value);
|
||||||
} else {
|
} else {
|
||||||
data.append(key, JSON.stringify(value));
|
data.append(key, JSON.stringify(value));
|
||||||
@ -39,8 +39,10 @@ const serializeUrlSearchParamsPair = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const formDataBodySerializer = {
|
export const formDataBodySerializer = {
|
||||||
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(
|
bodySerializer: <
|
||||||
body: T,
|
T extends Record<string, any> | Array<Record<string, any>>,
|
||||||
|
>(
|
||||||
|
body: T
|
||||||
): FormData => {
|
): FormData => {
|
||||||
const data = new FormData();
|
const data = new FormData();
|
||||||
|
|
||||||
@ -49,7 +51,7 @@ export const formDataBodySerializer = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Array.isArray(value)) {
|
if (Array.isArray(value)) {
|
||||||
value.forEach((v) => serializeFormDataPair(data, key, v));
|
value.forEach(v => serializeFormDataPair(data, key, v));
|
||||||
} else {
|
} else {
|
||||||
serializeFormDataPair(data, key, value);
|
serializeFormDataPair(data, key, value);
|
||||||
}
|
}
|
||||||
@ -62,13 +64,15 @@ export const formDataBodySerializer = {
|
|||||||
export const jsonBodySerializer = {
|
export const jsonBodySerializer = {
|
||||||
bodySerializer: <T>(body: T): string =>
|
bodySerializer: <T>(body: T): string =>
|
||||||
JSON.stringify(body, (_key, value) =>
|
JSON.stringify(body, (_key, value) =>
|
||||||
typeof value === 'bigint' ? value.toString() : value,
|
typeof value === "bigint" ? value.toString() : value
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
export const urlSearchParamsBodySerializer = {
|
export const urlSearchParamsBodySerializer = {
|
||||||
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(
|
bodySerializer: <
|
||||||
body: T,
|
T extends Record<string, any> | Array<Record<string, any>>,
|
||||||
|
>(
|
||||||
|
body: T
|
||||||
): string => {
|
): string => {
|
||||||
const data = new URLSearchParams();
|
const data = new URLSearchParams();
|
||||||
|
|
||||||
@ -77,7 +81,7 @@ export const urlSearchParamsBodySerializer = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Array.isArray(value)) {
|
if (Array.isArray(value)) {
|
||||||
value.forEach((v) => serializeUrlSearchParamsPair(data, key, v));
|
value.forEach(v => serializeUrlSearchParamsPair(data, key, v));
|
||||||
} else {
|
} else {
|
||||||
serializeUrlSearchParamsPair(data, key, value);
|
serializeUrlSearchParamsPair(data, key, value);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
type Slot = 'body' | 'headers' | 'path' | 'query';
|
type Slot = "body" | "headers" | "path" | "query";
|
||||||
|
|
||||||
export type Field =
|
export type Field =
|
||||||
| {
|
| {
|
||||||
in: Exclude<Slot, 'body'>;
|
in: Exclude<Slot, "body">;
|
||||||
/**
|
/**
|
||||||
* Field name. This is the name we want the user to see and use.
|
* Field name. This is the name we want the user to see and use.
|
||||||
*/
|
*/
|
||||||
@ -14,7 +14,7 @@ export type Field =
|
|||||||
map?: string;
|
map?: string;
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
in: Extract<Slot, 'body'>;
|
in: Extract<Slot, "body">;
|
||||||
/**
|
/**
|
||||||
* Key isn't required for bodies.
|
* Key isn't required for bodies.
|
||||||
*/
|
*/
|
||||||
@ -30,10 +30,10 @@ export interface Fields {
|
|||||||
export type FieldsConfig = ReadonlyArray<Field | Fields>;
|
export type FieldsConfig = ReadonlyArray<Field | Fields>;
|
||||||
|
|
||||||
const extraPrefixesMap: Record<string, Slot> = {
|
const extraPrefixesMap: Record<string, Slot> = {
|
||||||
$body_: 'body',
|
$body_: "body",
|
||||||
$headers_: 'headers',
|
$headers_: "headers",
|
||||||
$path_: 'path',
|
$path_: "path",
|
||||||
$query_: 'query',
|
$query_: "query",
|
||||||
};
|
};
|
||||||
const extraPrefixes = Object.entries(extraPrefixesMap);
|
const extraPrefixes = Object.entries(extraPrefixesMap);
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const config of fields) {
|
for (const config of fields) {
|
||||||
if ('in' in config) {
|
if ("in" in config) {
|
||||||
if (config.key) {
|
if (config.key) {
|
||||||
map.set(config.key, {
|
map.set(config.key, {
|
||||||
in: config.in,
|
in: config.in,
|
||||||
@ -75,7 +75,7 @@ interface Params {
|
|||||||
|
|
||||||
const stripEmptySlots = (params: Params) => {
|
const stripEmptySlots = (params: Params) => {
|
||||||
for (const [slot, value] of Object.entries(params)) {
|
for (const [slot, value] of Object.entries(params)) {
|
||||||
if (value && typeof value === 'object' && !Object.keys(value).length) {
|
if (value && typeof value === "object" && !Object.keys(value).length) {
|
||||||
delete params[slot as Slot];
|
delete params[slot as Slot];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ const stripEmptySlots = (params: Params) => {
|
|||||||
|
|
||||||
export const buildClientParams = (
|
export const buildClientParams = (
|
||||||
args: ReadonlyArray<unknown>,
|
args: ReadonlyArray<unknown>,
|
||||||
fields: FieldsConfig,
|
fields: FieldsConfig
|
||||||
) => {
|
) => {
|
||||||
const params: Params = {
|
const params: Params = {
|
||||||
body: {},
|
body: {},
|
||||||
@ -105,7 +105,7 @@ export const buildClientParams = (
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('in' in config) {
|
if ("in" in config) {
|
||||||
if (config.key) {
|
if (config.key) {
|
||||||
const field = map.get(config.key)!;
|
const field = map.get(config.key)!;
|
||||||
const name = field.map || config.key;
|
const name = field.map || config.key;
|
||||||
@ -122,7 +122,7 @@ export const buildClientParams = (
|
|||||||
(params[field.in] as Record<string, unknown>)[name] = value;
|
(params[field.in] as Record<string, unknown>)[name] = value;
|
||||||
} else {
|
} else {
|
||||||
const extra = extraPrefixes.find(([prefix]) =>
|
const extra = extraPrefixes.find(([prefix]) =>
|
||||||
key.startsWith(prefix),
|
key.startsWith(prefix)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (extra) {
|
if (extra) {
|
||||||
@ -132,10 +132,15 @@ export const buildClientParams = (
|
|||||||
] = value;
|
] = value;
|
||||||
} else {
|
} else {
|
||||||
for (const [slot, allowed] of Object.entries(
|
for (const [slot, allowed] of Object.entries(
|
||||||
config.allowExtra ?? {},
|
config.allowExtra ?? {}
|
||||||
)) {
|
)) {
|
||||||
if (allowed) {
|
if (allowed) {
|
||||||
(params[slot as Slot] as Record<string, unknown>)[key] = value;
|
(
|
||||||
|
params[slot as Slot] as Record<
|
||||||
|
string,
|
||||||
|
unknown
|
||||||
|
>
|
||||||
|
)[key] = value;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,10 +15,10 @@ export interface SerializerOptions<T> {
|
|||||||
style: T;
|
style: T;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
|
export type ArrayStyle = "form" | "spaceDelimited" | "pipeDelimited";
|
||||||
export type ArraySeparatorStyle = ArrayStyle | MatrixStyle;
|
export type ArraySeparatorStyle = ArrayStyle | MatrixStyle;
|
||||||
type MatrixStyle = 'label' | 'matrix' | 'simple';
|
type MatrixStyle = "label" | "matrix" | "simple";
|
||||||
export type ObjectStyle = 'form' | 'deepObject';
|
export type ObjectStyle = "form" | "deepObject";
|
||||||
type ObjectSeparatorStyle = ObjectStyle | MatrixStyle;
|
type ObjectSeparatorStyle = ObjectStyle | MatrixStyle;
|
||||||
|
|
||||||
interface SerializePrimitiveParam extends SerializePrimitiveOptions {
|
interface SerializePrimitiveParam extends SerializePrimitiveOptions {
|
||||||
@ -27,40 +27,40 @@ interface SerializePrimitiveParam extends SerializePrimitiveOptions {
|
|||||||
|
|
||||||
export const separatorArrayExplode = (style: ArraySeparatorStyle) => {
|
export const separatorArrayExplode = (style: ArraySeparatorStyle) => {
|
||||||
switch (style) {
|
switch (style) {
|
||||||
case 'label':
|
case "label":
|
||||||
return '.';
|
return ".";
|
||||||
case 'matrix':
|
case "matrix":
|
||||||
return ';';
|
return ";";
|
||||||
case 'simple':
|
case "simple":
|
||||||
return ',';
|
return ",";
|
||||||
default:
|
default:
|
||||||
return '&';
|
return "&";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => {
|
export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => {
|
||||||
switch (style) {
|
switch (style) {
|
||||||
case 'form':
|
case "form":
|
||||||
return ',';
|
return ",";
|
||||||
case 'pipeDelimited':
|
case "pipeDelimited":
|
||||||
return '|';
|
return "|";
|
||||||
case 'spaceDelimited':
|
case "spaceDelimited":
|
||||||
return '%20';
|
return "%20";
|
||||||
default:
|
default:
|
||||||
return ',';
|
return ",";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const separatorObjectExplode = (style: ObjectSeparatorStyle) => {
|
export const separatorObjectExplode = (style: ObjectSeparatorStyle) => {
|
||||||
switch (style) {
|
switch (style) {
|
||||||
case 'label':
|
case "label":
|
||||||
return '.';
|
return ".";
|
||||||
case 'matrix':
|
case "matrix":
|
||||||
return ';';
|
return ";";
|
||||||
case 'simple':
|
case "simple":
|
||||||
return ',';
|
return ",";
|
||||||
default:
|
default:
|
||||||
return '&';
|
return "&";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -75,14 +75,16 @@ export const serializeArrayParam = ({
|
|||||||
}) => {
|
}) => {
|
||||||
if (!explode) {
|
if (!explode) {
|
||||||
const joinedValues = (
|
const joinedValues = (
|
||||||
allowReserved ? value : value.map((v) => encodeURIComponent(v as string))
|
allowReserved
|
||||||
|
? value
|
||||||
|
: value.map(v => encodeURIComponent(v as string))
|
||||||
).join(separatorArrayNoExplode(style));
|
).join(separatorArrayNoExplode(style));
|
||||||
switch (style) {
|
switch (style) {
|
||||||
case 'label':
|
case "label":
|
||||||
return `.${joinedValues}`;
|
return `.${joinedValues}`;
|
||||||
case 'matrix':
|
case "matrix":
|
||||||
return `;${name}=${joinedValues}`;
|
return `;${name}=${joinedValues}`;
|
||||||
case 'simple':
|
case "simple":
|
||||||
return joinedValues;
|
return joinedValues;
|
||||||
default:
|
default:
|
||||||
return `${name}=${joinedValues}`;
|
return `${name}=${joinedValues}`;
|
||||||
@ -91,8 +93,8 @@ export const serializeArrayParam = ({
|
|||||||
|
|
||||||
const separator = separatorArrayExplode(style);
|
const separator = separatorArrayExplode(style);
|
||||||
const joinedValues = value
|
const joinedValues = value
|
||||||
.map((v) => {
|
.map(v => {
|
||||||
if (style === 'label' || style === 'simple') {
|
if (style === "label" || style === "simple") {
|
||||||
return allowReserved ? v : encodeURIComponent(v as string);
|
return allowReserved ? v : encodeURIComponent(v as string);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +105,7 @@ export const serializeArrayParam = ({
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
.join(separator);
|
.join(separator);
|
||||||
return style === 'label' || style === 'matrix'
|
return style === "label" || style === "matrix"
|
||||||
? separator + joinedValues
|
? separator + joinedValues
|
||||||
: joinedValues;
|
: joinedValues;
|
||||||
};
|
};
|
||||||
@ -114,12 +116,12 @@ export const serializePrimitiveParam = ({
|
|||||||
value,
|
value,
|
||||||
}: SerializePrimitiveParam) => {
|
}: SerializePrimitiveParam) => {
|
||||||
if (value === undefined || value === null) {
|
if (value === undefined || value === null) {
|
||||||
return '';
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof value === 'object') {
|
if (typeof value === "object") {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.',
|
"Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,10 +140,12 @@ export const serializeObjectParam = ({
|
|||||||
valueOnly?: boolean;
|
valueOnly?: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
if (value instanceof Date) {
|
if (value instanceof Date) {
|
||||||
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
return valueOnly
|
||||||
|
? value.toISOString()
|
||||||
|
: `${name}=${value.toISOString()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (style !== 'deepObject' && !explode) {
|
if (style !== "deepObject" && !explode) {
|
||||||
let values: string[] = [];
|
let values: string[] = [];
|
||||||
Object.entries(value).forEach(([key, v]) => {
|
Object.entries(value).forEach(([key, v]) => {
|
||||||
values = [
|
values = [
|
||||||
@ -150,13 +154,13 @@ export const serializeObjectParam = ({
|
|||||||
allowReserved ? (v as string) : encodeURIComponent(v as string),
|
allowReserved ? (v as string) : encodeURIComponent(v as string),
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
const joinedValues = values.join(',');
|
const joinedValues = values.join(",");
|
||||||
switch (style) {
|
switch (style) {
|
||||||
case 'form':
|
case "form":
|
||||||
return `${name}=${joinedValues}`;
|
return `${name}=${joinedValues}`;
|
||||||
case 'label':
|
case "label":
|
||||||
return `.${joinedValues}`;
|
return `.${joinedValues}`;
|
||||||
case 'matrix':
|
case "matrix":
|
||||||
return `;${name}=${joinedValues}`;
|
return `;${name}=${joinedValues}`;
|
||||||
default:
|
default:
|
||||||
return joinedValues;
|
return joinedValues;
|
||||||
@ -168,12 +172,12 @@ export const serializeObjectParam = ({
|
|||||||
.map(([key, v]) =>
|
.map(([key, v]) =>
|
||||||
serializePrimitiveParam({
|
serializePrimitiveParam({
|
||||||
allowReserved,
|
allowReserved,
|
||||||
name: style === 'deepObject' ? `${name}[${key}]` : key,
|
name: style === "deepObject" ? `${name}[${key}]` : key,
|
||||||
value: v as string,
|
value: v as string,
|
||||||
}),
|
})
|
||||||
)
|
)
|
||||||
.join(separator);
|
.join(separator);
|
||||||
return style === 'label' || style === 'matrix'
|
return style === "label" || style === "matrix"
|
||||||
? separator + joinedValues
|
? separator + joinedValues
|
||||||
: joinedValues;
|
: joinedValues;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
import type { Auth, AuthToken } from './auth';
|
import type { Auth, AuthToken } from "./auth";
|
||||||
import type {
|
import type {
|
||||||
BodySerializer,
|
BodySerializer,
|
||||||
QuerySerializer,
|
QuerySerializer,
|
||||||
QuerySerializerOptions,
|
QuerySerializerOptions,
|
||||||
} from './bodySerializer';
|
} from "./bodySerializer";
|
||||||
|
|
||||||
export interface Client<
|
export interface Client<
|
||||||
RequestFn = never,
|
RequestFn = never,
|
||||||
@ -47,7 +47,7 @@ export interface Config {
|
|||||||
* {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
|
* {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
|
||||||
*/
|
*/
|
||||||
headers?:
|
headers?:
|
||||||
| RequestInit['headers']
|
| RequestInit["headers"]
|
||||||
| Record<
|
| Record<
|
||||||
string,
|
string,
|
||||||
| string
|
| string
|
||||||
@ -64,15 +64,15 @@ export interface Config {
|
|||||||
* {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
|
* {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
|
||||||
*/
|
*/
|
||||||
method?:
|
method?:
|
||||||
| 'CONNECT'
|
| "CONNECT"
|
||||||
| 'DELETE'
|
| "DELETE"
|
||||||
| 'GET'
|
| "GET"
|
||||||
| 'HEAD'
|
| "HEAD"
|
||||||
| 'OPTIONS'
|
| "OPTIONS"
|
||||||
| 'PATCH'
|
| "PATCH"
|
||||||
| 'POST'
|
| "POST"
|
||||||
| 'PUT'
|
| "PUT"
|
||||||
| 'TRACE';
|
| "TRACE";
|
||||||
/**
|
/**
|
||||||
* A function for serializing request query parameters. By default, arrays
|
* A function for serializing request query parameters. By default, arrays
|
||||||
* will be exploded in form style, objects will be exploded in deepObject
|
* will be exploded in form style, objects will be exploded in deepObject
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
// This file is auto-generated by @hey-api/openapi-ts
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
export * from './types.gen';
|
export * from "./types.gen";
|
||||||
export * from './sdk.gen';
|
export * from "./sdk.gen";
|
||||||
|
|||||||
@ -1,11 +1,85 @@
|
|||||||
// This file is auto-generated by @hey-api/openapi-ts
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
|
|
||||||
import type { Options as ClientOptions, TDataShape, Client } from './client';
|
import type { Client, Options as ClientOptions, TDataShape } from "./client";
|
||||||
import type { GetBoardsData, GetBoardsResponses, GetBoardsErrors, CreateBoardData, CreateBoardResponses, CreateBoardErrors, DeleteBoardData, DeleteBoardResponses, DeleteBoardErrors, UpdateBoardData, UpdateBoardResponses, UpdateBoardErrors, GetDealsData, GetDealsResponses, GetDealsErrors, UpdateDealData, UpdateDealResponses, UpdateDealErrors, GetProjectsData, GetProjectsResponses, GetStatusesData, GetStatusesResponses, GetStatusesErrors, CreateStatusData, CreateStatusResponses, CreateStatusErrors, DeleteStatusData, DeleteStatusResponses, DeleteStatusErrors, UpdateStatusData, UpdateStatusResponses, UpdateStatusErrors } from './types.gen';
|
import { client as _heyApiClient } from "./client.gen";
|
||||||
import { zGetBoardsData, zGetBoardsResponse2, zCreateBoardData, zCreateBoardResponse2, zDeleteBoardData, zDeleteBoardResponse2, zUpdateBoardData, zUpdateBoardResponse2, zGetDealsData, zGetDealsResponse2, zUpdateDealData, zUpdateDealResponse2, zGetProjectsData, zGetProjectsResponse2, zGetStatusesData, zGetStatusesResponse2, zCreateStatusData, zCreateStatusResponse2, zDeleteStatusData, zDeleteStatusResponse2, zUpdateStatusData, zUpdateStatusResponse2 } from './zod.gen';
|
import type {
|
||||||
import { client as _heyApiClient } from './client.gen';
|
CreateBoardData,
|
||||||
|
CreateBoardErrors,
|
||||||
|
CreateBoardResponses,
|
||||||
|
CreateProjectData,
|
||||||
|
CreateProjectErrors,
|
||||||
|
CreateProjectResponses,
|
||||||
|
CreateStatusData,
|
||||||
|
CreateStatusErrors,
|
||||||
|
CreateStatusResponses,
|
||||||
|
DeleteBoardData,
|
||||||
|
DeleteBoardErrors,
|
||||||
|
DeleteBoardResponses,
|
||||||
|
DeleteProjectData,
|
||||||
|
DeleteProjectErrors,
|
||||||
|
DeleteProjectResponses,
|
||||||
|
DeleteStatusData,
|
||||||
|
DeleteStatusErrors,
|
||||||
|
DeleteStatusResponses,
|
||||||
|
GetBoardsData,
|
||||||
|
GetBoardsErrors,
|
||||||
|
GetBoardsResponses,
|
||||||
|
GetDealsData,
|
||||||
|
GetDealsErrors,
|
||||||
|
GetDealsResponses,
|
||||||
|
GetProjectsData,
|
||||||
|
GetProjectsResponses,
|
||||||
|
GetStatusesData,
|
||||||
|
GetStatusesErrors,
|
||||||
|
GetStatusesResponses,
|
||||||
|
UpdateBoardData,
|
||||||
|
UpdateBoardErrors,
|
||||||
|
UpdateBoardResponses,
|
||||||
|
UpdateDealData,
|
||||||
|
UpdateDealErrors,
|
||||||
|
UpdateDealResponses,
|
||||||
|
UpdateProjectData,
|
||||||
|
UpdateProjectErrors,
|
||||||
|
UpdateProjectResponses,
|
||||||
|
UpdateStatusData,
|
||||||
|
UpdateStatusErrors,
|
||||||
|
UpdateStatusResponses,
|
||||||
|
} from "./types.gen";
|
||||||
|
import {
|
||||||
|
zCreateBoardData,
|
||||||
|
zCreateBoardResponse2,
|
||||||
|
zCreateProjectData,
|
||||||
|
zCreateProjectResponse2,
|
||||||
|
zCreateStatusData,
|
||||||
|
zCreateStatusResponse2,
|
||||||
|
zDeleteBoardData,
|
||||||
|
zDeleteBoardResponse2,
|
||||||
|
zDeleteProjectData,
|
||||||
|
zDeleteProjectResponse2,
|
||||||
|
zDeleteStatusData,
|
||||||
|
zDeleteStatusResponse2,
|
||||||
|
zGetBoardsData,
|
||||||
|
zGetBoardsResponse2,
|
||||||
|
zGetDealsData,
|
||||||
|
zGetDealsResponse2,
|
||||||
|
zGetProjectsData,
|
||||||
|
zGetProjectsResponse2,
|
||||||
|
zGetStatusesData,
|
||||||
|
zGetStatusesResponse2,
|
||||||
|
zUpdateBoardData,
|
||||||
|
zUpdateBoardResponse2,
|
||||||
|
zUpdateDealData,
|
||||||
|
zUpdateDealResponse2,
|
||||||
|
zUpdateProjectData,
|
||||||
|
zUpdateProjectResponse2,
|
||||||
|
zUpdateStatusData,
|
||||||
|
zUpdateStatusResponse2,
|
||||||
|
} from "./zod.gen";
|
||||||
|
|
||||||
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {
|
export type Options<
|
||||||
|
TData extends TDataShape = TDataShape,
|
||||||
|
ThrowOnError extends boolean = boolean,
|
||||||
|
> = ClientOptions<TData, ThrowOnError> & {
|
||||||
/**
|
/**
|
||||||
* You can provide a client instance returned by `createClient()` instead of
|
* You can provide a client instance returned by `createClient()` instead of
|
||||||
* individual options. This might be also useful if you want to implement a
|
* individual options. This might be also useful if you want to implement a
|
||||||
@ -22,206 +96,349 @@ export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends
|
|||||||
/**
|
/**
|
||||||
* Get Boards
|
* Get Boards
|
||||||
*/
|
*/
|
||||||
export const getBoards = <ThrowOnError extends boolean = false>(options: Options<GetBoardsData, ThrowOnError>) => {
|
export const getBoards = <ThrowOnError extends boolean = false>(
|
||||||
return (options.client ?? _heyApiClient).get<GetBoardsResponses, GetBoardsErrors, ThrowOnError>({
|
options: Options<GetBoardsData, ThrowOnError>
|
||||||
requestValidator: async (data) => {
|
) => {
|
||||||
|
return (options.client ?? _heyApiClient).get<
|
||||||
|
GetBoardsResponses,
|
||||||
|
GetBoardsErrors,
|
||||||
|
ThrowOnError
|
||||||
|
>({
|
||||||
|
requestValidator: async data => {
|
||||||
return await zGetBoardsData.parseAsync(data);
|
return await zGetBoardsData.parseAsync(data);
|
||||||
},
|
},
|
||||||
responseType: 'json',
|
responseType: "json",
|
||||||
responseValidator: async (data) => {
|
responseValidator: async data => {
|
||||||
return await zGetBoardsResponse2.parseAsync(data);
|
return await zGetBoardsResponse2.parseAsync(data);
|
||||||
},
|
},
|
||||||
url: '/board/{projectId}',
|
url: "/board/{projectId}",
|
||||||
...options
|
...options,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create Board
|
* Create Board
|
||||||
*/
|
*/
|
||||||
export const createBoard = <ThrowOnError extends boolean = false>(options: Options<CreateBoardData, ThrowOnError>) => {
|
export const createBoard = <ThrowOnError extends boolean = false>(
|
||||||
return (options.client ?? _heyApiClient).post<CreateBoardResponses, CreateBoardErrors, ThrowOnError>({
|
options: Options<CreateBoardData, ThrowOnError>
|
||||||
requestValidator: async (data) => {
|
) => {
|
||||||
|
return (options.client ?? _heyApiClient).post<
|
||||||
|
CreateBoardResponses,
|
||||||
|
CreateBoardErrors,
|
||||||
|
ThrowOnError
|
||||||
|
>({
|
||||||
|
requestValidator: async data => {
|
||||||
return await zCreateBoardData.parseAsync(data);
|
return await zCreateBoardData.parseAsync(data);
|
||||||
},
|
},
|
||||||
responseType: 'json',
|
responseType: "json",
|
||||||
responseValidator: async (data) => {
|
responseValidator: async data => {
|
||||||
return await zCreateBoardResponse2.parseAsync(data);
|
return await zCreateBoardResponse2.parseAsync(data);
|
||||||
},
|
},
|
||||||
url: '/board/',
|
url: "/board/",
|
||||||
...options,
|
...options,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
"Content-Type": "application/json",
|
||||||
...options.headers
|
...options.headers,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete Board
|
* Delete Board
|
||||||
*/
|
*/
|
||||||
export const deleteBoard = <ThrowOnError extends boolean = false>(options: Options<DeleteBoardData, ThrowOnError>) => {
|
export const deleteBoard = <ThrowOnError extends boolean = false>(
|
||||||
return (options.client ?? _heyApiClient).delete<DeleteBoardResponses, DeleteBoardErrors, ThrowOnError>({
|
options: Options<DeleteBoardData, ThrowOnError>
|
||||||
requestValidator: async (data) => {
|
) => {
|
||||||
|
return (options.client ?? _heyApiClient).delete<
|
||||||
|
DeleteBoardResponses,
|
||||||
|
DeleteBoardErrors,
|
||||||
|
ThrowOnError
|
||||||
|
>({
|
||||||
|
requestValidator: async data => {
|
||||||
return await zDeleteBoardData.parseAsync(data);
|
return await zDeleteBoardData.parseAsync(data);
|
||||||
},
|
},
|
||||||
responseType: 'json',
|
responseType: "json",
|
||||||
responseValidator: async (data) => {
|
responseValidator: async data => {
|
||||||
return await zDeleteBoardResponse2.parseAsync(data);
|
return await zDeleteBoardResponse2.parseAsync(data);
|
||||||
},
|
},
|
||||||
url: '/board/{boardId}',
|
url: "/board/{boardId}",
|
||||||
...options
|
...options,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update Board
|
* Update Board
|
||||||
*/
|
*/
|
||||||
export const updateBoard = <ThrowOnError extends boolean = false>(options: Options<UpdateBoardData, ThrowOnError>) => {
|
export const updateBoard = <ThrowOnError extends boolean = false>(
|
||||||
return (options.client ?? _heyApiClient).patch<UpdateBoardResponses, UpdateBoardErrors, ThrowOnError>({
|
options: Options<UpdateBoardData, ThrowOnError>
|
||||||
requestValidator: async (data) => {
|
) => {
|
||||||
|
return (options.client ?? _heyApiClient).patch<
|
||||||
|
UpdateBoardResponses,
|
||||||
|
UpdateBoardErrors,
|
||||||
|
ThrowOnError
|
||||||
|
>({
|
||||||
|
requestValidator: async data => {
|
||||||
return await zUpdateBoardData.parseAsync(data);
|
return await zUpdateBoardData.parseAsync(data);
|
||||||
},
|
},
|
||||||
responseType: 'json',
|
responseType: "json",
|
||||||
responseValidator: async (data) => {
|
responseValidator: async data => {
|
||||||
return await zUpdateBoardResponse2.parseAsync(data);
|
return await zUpdateBoardResponse2.parseAsync(data);
|
||||||
},
|
},
|
||||||
url: '/board/{boardId}',
|
url: "/board/{boardId}",
|
||||||
...options,
|
...options,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
"Content-Type": "application/json",
|
||||||
...options.headers
|
...options.headers,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Deals
|
* Get Deals
|
||||||
*/
|
*/
|
||||||
export const getDeals = <ThrowOnError extends boolean = false>(options: Options<GetDealsData, ThrowOnError>) => {
|
export const getDeals = <ThrowOnError extends boolean = false>(
|
||||||
return (options.client ?? _heyApiClient).get<GetDealsResponses, GetDealsErrors, ThrowOnError>({
|
options: Options<GetDealsData, ThrowOnError>
|
||||||
requestValidator: async (data) => {
|
) => {
|
||||||
|
return (options.client ?? _heyApiClient).get<
|
||||||
|
GetDealsResponses,
|
||||||
|
GetDealsErrors,
|
||||||
|
ThrowOnError
|
||||||
|
>({
|
||||||
|
requestValidator: async data => {
|
||||||
return await zGetDealsData.parseAsync(data);
|
return await zGetDealsData.parseAsync(data);
|
||||||
},
|
},
|
||||||
responseType: 'json',
|
responseType: "json",
|
||||||
responseValidator: async (data) => {
|
responseValidator: async data => {
|
||||||
return await zGetDealsResponse2.parseAsync(data);
|
return await zGetDealsResponse2.parseAsync(data);
|
||||||
},
|
},
|
||||||
url: '/deal/{boardId}',
|
url: "/deal/{boardId}",
|
||||||
...options
|
...options,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update Deal
|
* Update Deal
|
||||||
*/
|
*/
|
||||||
export const updateDeal = <ThrowOnError extends boolean = false>(options: Options<UpdateDealData, ThrowOnError>) => {
|
export const updateDeal = <ThrowOnError extends boolean = false>(
|
||||||
return (options.client ?? _heyApiClient).patch<UpdateDealResponses, UpdateDealErrors, ThrowOnError>({
|
options: Options<UpdateDealData, ThrowOnError>
|
||||||
requestValidator: async (data) => {
|
) => {
|
||||||
|
return (options.client ?? _heyApiClient).patch<
|
||||||
|
UpdateDealResponses,
|
||||||
|
UpdateDealErrors,
|
||||||
|
ThrowOnError
|
||||||
|
>({
|
||||||
|
requestValidator: async data => {
|
||||||
return await zUpdateDealData.parseAsync(data);
|
return await zUpdateDealData.parseAsync(data);
|
||||||
},
|
},
|
||||||
responseType: 'json',
|
responseType: "json",
|
||||||
responseValidator: async (data) => {
|
responseValidator: async data => {
|
||||||
return await zUpdateDealResponse2.parseAsync(data);
|
return await zUpdateDealResponse2.parseAsync(data);
|
||||||
},
|
},
|
||||||
url: '/deal/{dealId}',
|
url: "/deal/{dealId}",
|
||||||
...options,
|
...options,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
"Content-Type": "application/json",
|
||||||
...options.headers
|
...options.headers,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Projects
|
* Get Projects
|
||||||
*/
|
*/
|
||||||
export const getProjects = <ThrowOnError extends boolean = false>(options?: Options<GetProjectsData, ThrowOnError>) => {
|
export const getProjects = <ThrowOnError extends boolean = false>(
|
||||||
return (options?.client ?? _heyApiClient).get<GetProjectsResponses, unknown, ThrowOnError>({
|
options?: Options<GetProjectsData, ThrowOnError>
|
||||||
requestValidator: async (data) => {
|
) => {
|
||||||
|
return (options?.client ?? _heyApiClient).get<
|
||||||
|
GetProjectsResponses,
|
||||||
|
unknown,
|
||||||
|
ThrowOnError
|
||||||
|
>({
|
||||||
|
requestValidator: async data => {
|
||||||
return await zGetProjectsData.parseAsync(data);
|
return await zGetProjectsData.parseAsync(data);
|
||||||
},
|
},
|
||||||
responseType: 'json',
|
responseType: "json",
|
||||||
responseValidator: async (data) => {
|
responseValidator: async data => {
|
||||||
return await zGetProjectsResponse2.parseAsync(data);
|
return await zGetProjectsResponse2.parseAsync(data);
|
||||||
},
|
},
|
||||||
url: '/project/',
|
url: "/project/",
|
||||||
...options
|
...options,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Project
|
||||||
|
*/
|
||||||
|
export const createProject = <ThrowOnError extends boolean = false>(
|
||||||
|
options: Options<CreateProjectData, ThrowOnError>
|
||||||
|
) => {
|
||||||
|
return (options.client ?? _heyApiClient).post<
|
||||||
|
CreateProjectResponses,
|
||||||
|
CreateProjectErrors,
|
||||||
|
ThrowOnError
|
||||||
|
>({
|
||||||
|
requestValidator: async data => {
|
||||||
|
return await zCreateProjectData.parseAsync(data);
|
||||||
|
},
|
||||||
|
responseType: "json",
|
||||||
|
responseValidator: async data => {
|
||||||
|
return await zCreateProjectResponse2.parseAsync(data);
|
||||||
|
},
|
||||||
|
url: "/project/",
|
||||||
|
...options,
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
...options.headers,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete Project
|
||||||
|
*/
|
||||||
|
export const deleteProject = <ThrowOnError extends boolean = false>(
|
||||||
|
options: Options<DeleteProjectData, ThrowOnError>
|
||||||
|
) => {
|
||||||
|
return (options.client ?? _heyApiClient).delete<
|
||||||
|
DeleteProjectResponses,
|
||||||
|
DeleteProjectErrors,
|
||||||
|
ThrowOnError
|
||||||
|
>({
|
||||||
|
requestValidator: async data => {
|
||||||
|
return await zDeleteProjectData.parseAsync(data);
|
||||||
|
},
|
||||||
|
responseType: "json",
|
||||||
|
responseValidator: async data => {
|
||||||
|
return await zDeleteProjectResponse2.parseAsync(data);
|
||||||
|
},
|
||||||
|
url: "/project/{projectId}",
|
||||||
|
...options,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update Project
|
||||||
|
*/
|
||||||
|
export const updateProject = <ThrowOnError extends boolean = false>(
|
||||||
|
options: Options<UpdateProjectData, ThrowOnError>
|
||||||
|
) => {
|
||||||
|
return (options.client ?? _heyApiClient).patch<
|
||||||
|
UpdateProjectResponses,
|
||||||
|
UpdateProjectErrors,
|
||||||
|
ThrowOnError
|
||||||
|
>({
|
||||||
|
requestValidator: async data => {
|
||||||
|
return await zUpdateProjectData.parseAsync(data);
|
||||||
|
},
|
||||||
|
responseType: "json",
|
||||||
|
responseValidator: async data => {
|
||||||
|
return await zUpdateProjectResponse2.parseAsync(data);
|
||||||
|
},
|
||||||
|
url: "/project/{projectId}",
|
||||||
|
...options,
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
...options.headers,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Statuses
|
* Get Statuses
|
||||||
*/
|
*/
|
||||||
export const getStatuses = <ThrowOnError extends boolean = false>(options: Options<GetStatusesData, ThrowOnError>) => {
|
export const getStatuses = <ThrowOnError extends boolean = false>(
|
||||||
return (options.client ?? _heyApiClient).get<GetStatusesResponses, GetStatusesErrors, ThrowOnError>({
|
options: Options<GetStatusesData, ThrowOnError>
|
||||||
requestValidator: async (data) => {
|
) => {
|
||||||
|
return (options.client ?? _heyApiClient).get<
|
||||||
|
GetStatusesResponses,
|
||||||
|
GetStatusesErrors,
|
||||||
|
ThrowOnError
|
||||||
|
>({
|
||||||
|
requestValidator: async data => {
|
||||||
return await zGetStatusesData.parseAsync(data);
|
return await zGetStatusesData.parseAsync(data);
|
||||||
},
|
},
|
||||||
responseType: 'json',
|
responseType: "json",
|
||||||
responseValidator: async (data) => {
|
responseValidator: async data => {
|
||||||
return await zGetStatusesResponse2.parseAsync(data);
|
return await zGetStatusesResponse2.parseAsync(data);
|
||||||
},
|
},
|
||||||
url: '/status/{boardId}',
|
url: "/status/{boardId}",
|
||||||
...options
|
...options,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create Status
|
* Create Status
|
||||||
*/
|
*/
|
||||||
export const createStatus = <ThrowOnError extends boolean = false>(options: Options<CreateStatusData, ThrowOnError>) => {
|
export const createStatus = <ThrowOnError extends boolean = false>(
|
||||||
return (options.client ?? _heyApiClient).post<CreateStatusResponses, CreateStatusErrors, ThrowOnError>({
|
options: Options<CreateStatusData, ThrowOnError>
|
||||||
requestValidator: async (data) => {
|
) => {
|
||||||
|
return (options.client ?? _heyApiClient).post<
|
||||||
|
CreateStatusResponses,
|
||||||
|
CreateStatusErrors,
|
||||||
|
ThrowOnError
|
||||||
|
>({
|
||||||
|
requestValidator: async data => {
|
||||||
return await zCreateStatusData.parseAsync(data);
|
return await zCreateStatusData.parseAsync(data);
|
||||||
},
|
},
|
||||||
responseType: 'json',
|
responseType: "json",
|
||||||
responseValidator: async (data) => {
|
responseValidator: async data => {
|
||||||
return await zCreateStatusResponse2.parseAsync(data);
|
return await zCreateStatusResponse2.parseAsync(data);
|
||||||
},
|
},
|
||||||
url: '/status/',
|
url: "/status/",
|
||||||
...options,
|
...options,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
"Content-Type": "application/json",
|
||||||
...options.headers
|
...options.headers,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete Status
|
* Delete Status
|
||||||
*/
|
*/
|
||||||
export const deleteStatus = <ThrowOnError extends boolean = false>(options: Options<DeleteStatusData, ThrowOnError>) => {
|
export const deleteStatus = <ThrowOnError extends boolean = false>(
|
||||||
return (options.client ?? _heyApiClient).delete<DeleteStatusResponses, DeleteStatusErrors, ThrowOnError>({
|
options: Options<DeleteStatusData, ThrowOnError>
|
||||||
requestValidator: async (data) => {
|
) => {
|
||||||
|
return (options.client ?? _heyApiClient).delete<
|
||||||
|
DeleteStatusResponses,
|
||||||
|
DeleteStatusErrors,
|
||||||
|
ThrowOnError
|
||||||
|
>({
|
||||||
|
requestValidator: async data => {
|
||||||
return await zDeleteStatusData.parseAsync(data);
|
return await zDeleteStatusData.parseAsync(data);
|
||||||
},
|
},
|
||||||
responseType: 'json',
|
responseType: "json",
|
||||||
responseValidator: async (data) => {
|
responseValidator: async data => {
|
||||||
return await zDeleteStatusResponse2.parseAsync(data);
|
return await zDeleteStatusResponse2.parseAsync(data);
|
||||||
},
|
},
|
||||||
url: '/status/{statusId}',
|
url: "/status/{statusId}",
|
||||||
...options
|
...options,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update Status
|
* Update Status
|
||||||
*/
|
*/
|
||||||
export const updateStatus = <ThrowOnError extends boolean = false>(options: Options<UpdateStatusData, ThrowOnError>) => {
|
export const updateStatus = <ThrowOnError extends boolean = false>(
|
||||||
return (options.client ?? _heyApiClient).patch<UpdateStatusResponses, UpdateStatusErrors, ThrowOnError>({
|
options: Options<UpdateStatusData, ThrowOnError>
|
||||||
requestValidator: async (data) => {
|
) => {
|
||||||
|
return (options.client ?? _heyApiClient).patch<
|
||||||
|
UpdateStatusResponses,
|
||||||
|
UpdateStatusErrors,
|
||||||
|
ThrowOnError
|
||||||
|
>({
|
||||||
|
requestValidator: async data => {
|
||||||
return await zUpdateStatusData.parseAsync(data);
|
return await zUpdateStatusData.parseAsync(data);
|
||||||
},
|
},
|
||||||
responseType: 'json',
|
responseType: "json",
|
||||||
responseValidator: async (data) => {
|
responseValidator: async data => {
|
||||||
return await zUpdateStatusResponse2.parseAsync(data);
|
return await zUpdateStatusResponse2.parseAsync(data);
|
||||||
},
|
},
|
||||||
url: '/status/{statusId}',
|
url: "/status/{statusId}",
|
||||||
...options,
|
...options,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
"Content-Type": "application/json",
|
||||||
...options.headers
|
...options.headers,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -54,6 +54,34 @@ export type CreateBoardSchema = {
|
|||||||
lexorank: string;
|
lexorank: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CreateProjectRequest
|
||||||
|
*/
|
||||||
|
export type CreateProjectRequest = {
|
||||||
|
project: CreateProjectSchema;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CreateProjectResponse
|
||||||
|
*/
|
||||||
|
export type CreateProjectResponse = {
|
||||||
|
/**
|
||||||
|
* Message
|
||||||
|
*/
|
||||||
|
message: string;
|
||||||
|
project: ProjectSchema;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CreateProjectSchema
|
||||||
|
*/
|
||||||
|
export type CreateProjectSchema = {
|
||||||
|
/**
|
||||||
|
* Name
|
||||||
|
*/
|
||||||
|
name: string;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CreateStatusRequest
|
* CreateStatusRequest
|
||||||
*/
|
*/
|
||||||
@ -122,6 +150,16 @@ export type DeleteBoardResponse = {
|
|||||||
message: string;
|
message: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DeleteProjectResponse
|
||||||
|
*/
|
||||||
|
export type DeleteProjectResponse = {
|
||||||
|
/**
|
||||||
|
* Message
|
||||||
|
*/
|
||||||
|
message: string;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DeleteStatusResponse
|
* DeleteStatusResponse
|
||||||
*/
|
*/
|
||||||
@ -186,14 +224,14 @@ export type HttpValidationError = {
|
|||||||
* ProjectSchema
|
* ProjectSchema
|
||||||
*/
|
*/
|
||||||
export type ProjectSchema = {
|
export type ProjectSchema = {
|
||||||
/**
|
|
||||||
* Name
|
|
||||||
*/
|
|
||||||
name: string;
|
|
||||||
/**
|
/**
|
||||||
* Id
|
* Id
|
||||||
*/
|
*/
|
||||||
id: number;
|
id: number;
|
||||||
|
/**
|
||||||
|
* Name
|
||||||
|
*/
|
||||||
|
name: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -280,6 +318,33 @@ export type UpdateDealSchema = {
|
|||||||
statusId?: number | null;
|
statusId?: number | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UpdateProjectRequest
|
||||||
|
*/
|
||||||
|
export type UpdateProjectRequest = {
|
||||||
|
project: UpdateProjectSchema;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UpdateProjectResponse
|
||||||
|
*/
|
||||||
|
export type UpdateProjectResponse = {
|
||||||
|
/**
|
||||||
|
* Message
|
||||||
|
*/
|
||||||
|
message: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UpdateProjectSchema
|
||||||
|
*/
|
||||||
|
export type UpdateProjectSchema = {
|
||||||
|
/**
|
||||||
|
* Name
|
||||||
|
*/
|
||||||
|
name?: string | null;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UpdateStatusRequest
|
* UpdateStatusRequest
|
||||||
*/
|
*/
|
||||||
@ -338,7 +403,7 @@ export type GetBoardsData = {
|
|||||||
projectId: number;
|
projectId: number;
|
||||||
};
|
};
|
||||||
query?: never;
|
query?: never;
|
||||||
url: '/board/{projectId}';
|
url: "/board/{projectId}";
|
||||||
};
|
};
|
||||||
|
|
||||||
export type GetBoardsErrors = {
|
export type GetBoardsErrors = {
|
||||||
@ -363,7 +428,7 @@ export type CreateBoardData = {
|
|||||||
body: CreateBoardRequest;
|
body: CreateBoardRequest;
|
||||||
path?: never;
|
path?: never;
|
||||||
query?: never;
|
query?: never;
|
||||||
url: '/board/';
|
url: "/board/";
|
||||||
};
|
};
|
||||||
|
|
||||||
export type CreateBoardErrors = {
|
export type CreateBoardErrors = {
|
||||||
@ -382,7 +447,8 @@ export type CreateBoardResponses = {
|
|||||||
200: CreateBoardResponse;
|
200: CreateBoardResponse;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type CreateBoardResponse2 = CreateBoardResponses[keyof CreateBoardResponses];
|
export type CreateBoardResponse2 =
|
||||||
|
CreateBoardResponses[keyof CreateBoardResponses];
|
||||||
|
|
||||||
export type DeleteBoardData = {
|
export type DeleteBoardData = {
|
||||||
body?: never;
|
body?: never;
|
||||||
@ -393,7 +459,7 @@ export type DeleteBoardData = {
|
|||||||
boardId: number;
|
boardId: number;
|
||||||
};
|
};
|
||||||
query?: never;
|
query?: never;
|
||||||
url: '/board/{boardId}';
|
url: "/board/{boardId}";
|
||||||
};
|
};
|
||||||
|
|
||||||
export type DeleteBoardErrors = {
|
export type DeleteBoardErrors = {
|
||||||
@ -412,7 +478,8 @@ export type DeleteBoardResponses = {
|
|||||||
200: DeleteBoardResponse;
|
200: DeleteBoardResponse;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type DeleteBoardResponse2 = DeleteBoardResponses[keyof DeleteBoardResponses];
|
export type DeleteBoardResponse2 =
|
||||||
|
DeleteBoardResponses[keyof DeleteBoardResponses];
|
||||||
|
|
||||||
export type UpdateBoardData = {
|
export type UpdateBoardData = {
|
||||||
body: UpdateBoardRequest;
|
body: UpdateBoardRequest;
|
||||||
@ -423,7 +490,7 @@ export type UpdateBoardData = {
|
|||||||
boardId: number;
|
boardId: number;
|
||||||
};
|
};
|
||||||
query?: never;
|
query?: never;
|
||||||
url: '/board/{boardId}';
|
url: "/board/{boardId}";
|
||||||
};
|
};
|
||||||
|
|
||||||
export type UpdateBoardErrors = {
|
export type UpdateBoardErrors = {
|
||||||
@ -442,7 +509,8 @@ export type UpdateBoardResponses = {
|
|||||||
200: UpdateBoardResponse;
|
200: UpdateBoardResponse;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type UpdateBoardResponse2 = UpdateBoardResponses[keyof UpdateBoardResponses];
|
export type UpdateBoardResponse2 =
|
||||||
|
UpdateBoardResponses[keyof UpdateBoardResponses];
|
||||||
|
|
||||||
export type GetDealsData = {
|
export type GetDealsData = {
|
||||||
body?: never;
|
body?: never;
|
||||||
@ -453,7 +521,7 @@ export type GetDealsData = {
|
|||||||
boardId: number;
|
boardId: number;
|
||||||
};
|
};
|
||||||
query?: never;
|
query?: never;
|
||||||
url: '/deal/{boardId}';
|
url: "/deal/{boardId}";
|
||||||
};
|
};
|
||||||
|
|
||||||
export type GetDealsErrors = {
|
export type GetDealsErrors = {
|
||||||
@ -483,7 +551,7 @@ export type UpdateDealData = {
|
|||||||
dealId: number;
|
dealId: number;
|
||||||
};
|
};
|
||||||
query?: never;
|
query?: never;
|
||||||
url: '/deal/{dealId}';
|
url: "/deal/{dealId}";
|
||||||
};
|
};
|
||||||
|
|
||||||
export type UpdateDealErrors = {
|
export type UpdateDealErrors = {
|
||||||
@ -502,13 +570,14 @@ export type UpdateDealResponses = {
|
|||||||
200: UpdateDealResponse;
|
200: UpdateDealResponse;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type UpdateDealResponse2 = UpdateDealResponses[keyof UpdateDealResponses];
|
export type UpdateDealResponse2 =
|
||||||
|
UpdateDealResponses[keyof UpdateDealResponses];
|
||||||
|
|
||||||
export type GetProjectsData = {
|
export type GetProjectsData = {
|
||||||
body?: never;
|
body?: never;
|
||||||
path?: never;
|
path?: never;
|
||||||
query?: never;
|
query?: never;
|
||||||
url: '/project/';
|
url: "/project/";
|
||||||
};
|
};
|
||||||
|
|
||||||
export type GetProjectsResponses = {
|
export type GetProjectsResponses = {
|
||||||
@ -518,7 +587,96 @@ export type GetProjectsResponses = {
|
|||||||
200: GetProjectsResponse;
|
200: GetProjectsResponse;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type GetProjectsResponse2 = GetProjectsResponses[keyof GetProjectsResponses];
|
export type GetProjectsResponse2 =
|
||||||
|
GetProjectsResponses[keyof GetProjectsResponses];
|
||||||
|
|
||||||
|
export type CreateProjectData = {
|
||||||
|
body: CreateProjectRequest;
|
||||||
|
path?: never;
|
||||||
|
query?: never;
|
||||||
|
url: "/project/";
|
||||||
|
};
|
||||||
|
|
||||||
|
export type CreateProjectErrors = {
|
||||||
|
/**
|
||||||
|
* Validation Error
|
||||||
|
*/
|
||||||
|
422: HttpValidationError;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type CreateProjectError = CreateProjectErrors[keyof CreateProjectErrors];
|
||||||
|
|
||||||
|
export type CreateProjectResponses = {
|
||||||
|
/**
|
||||||
|
* Successful Response
|
||||||
|
*/
|
||||||
|
200: CreateProjectResponse;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type CreateProjectResponse2 =
|
||||||
|
CreateProjectResponses[keyof CreateProjectResponses];
|
||||||
|
|
||||||
|
export type DeleteProjectData = {
|
||||||
|
body?: never;
|
||||||
|
path?: never;
|
||||||
|
query: {
|
||||||
|
/**
|
||||||
|
* Projectid
|
||||||
|
*/
|
||||||
|
projectId: number;
|
||||||
|
};
|
||||||
|
url: "/project/{projectId}";
|
||||||
|
};
|
||||||
|
|
||||||
|
export type DeleteProjectErrors = {
|
||||||
|
/**
|
||||||
|
* Validation Error
|
||||||
|
*/
|
||||||
|
422: HttpValidationError;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type DeleteProjectError = DeleteProjectErrors[keyof DeleteProjectErrors];
|
||||||
|
|
||||||
|
export type DeleteProjectResponses = {
|
||||||
|
/**
|
||||||
|
* Successful Response
|
||||||
|
*/
|
||||||
|
200: DeleteProjectResponse;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type DeleteProjectResponse2 =
|
||||||
|
DeleteProjectResponses[keyof DeleteProjectResponses];
|
||||||
|
|
||||||
|
export type UpdateProjectData = {
|
||||||
|
body: UpdateProjectRequest;
|
||||||
|
path?: never;
|
||||||
|
query: {
|
||||||
|
/**
|
||||||
|
* Projectid
|
||||||
|
*/
|
||||||
|
projectId: number;
|
||||||
|
};
|
||||||
|
url: "/project/{projectId}";
|
||||||
|
};
|
||||||
|
|
||||||
|
export type UpdateProjectErrors = {
|
||||||
|
/**
|
||||||
|
* Validation Error
|
||||||
|
*/
|
||||||
|
422: HttpValidationError;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type UpdateProjectError = UpdateProjectErrors[keyof UpdateProjectErrors];
|
||||||
|
|
||||||
|
export type UpdateProjectResponses = {
|
||||||
|
/**
|
||||||
|
* Successful Response
|
||||||
|
*/
|
||||||
|
200: UpdateProjectResponse;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type UpdateProjectResponse2 =
|
||||||
|
UpdateProjectResponses[keyof UpdateProjectResponses];
|
||||||
|
|
||||||
export type GetStatusesData = {
|
export type GetStatusesData = {
|
||||||
body?: never;
|
body?: never;
|
||||||
@ -529,7 +687,7 @@ export type GetStatusesData = {
|
|||||||
boardId: number;
|
boardId: number;
|
||||||
};
|
};
|
||||||
query?: never;
|
query?: never;
|
||||||
url: '/status/{boardId}';
|
url: "/status/{boardId}";
|
||||||
};
|
};
|
||||||
|
|
||||||
export type GetStatusesErrors = {
|
export type GetStatusesErrors = {
|
||||||
@ -548,13 +706,14 @@ export type GetStatusesResponses = {
|
|||||||
200: GetStatusesResponse;
|
200: GetStatusesResponse;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type GetStatusesResponse2 = GetStatusesResponses[keyof GetStatusesResponses];
|
export type GetStatusesResponse2 =
|
||||||
|
GetStatusesResponses[keyof GetStatusesResponses];
|
||||||
|
|
||||||
export type CreateStatusData = {
|
export type CreateStatusData = {
|
||||||
body: CreateStatusRequest;
|
body: CreateStatusRequest;
|
||||||
path?: never;
|
path?: never;
|
||||||
query?: never;
|
query?: never;
|
||||||
url: '/status/';
|
url: "/status/";
|
||||||
};
|
};
|
||||||
|
|
||||||
export type CreateStatusErrors = {
|
export type CreateStatusErrors = {
|
||||||
@ -573,7 +732,8 @@ export type CreateStatusResponses = {
|
|||||||
200: CreateStatusResponse;
|
200: CreateStatusResponse;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type CreateStatusResponse2 = CreateStatusResponses[keyof CreateStatusResponses];
|
export type CreateStatusResponse2 =
|
||||||
|
CreateStatusResponses[keyof CreateStatusResponses];
|
||||||
|
|
||||||
export type DeleteStatusData = {
|
export type DeleteStatusData = {
|
||||||
body?: never;
|
body?: never;
|
||||||
@ -584,7 +744,7 @@ export type DeleteStatusData = {
|
|||||||
statusId: number;
|
statusId: number;
|
||||||
};
|
};
|
||||||
query?: never;
|
query?: never;
|
||||||
url: '/status/{statusId}';
|
url: "/status/{statusId}";
|
||||||
};
|
};
|
||||||
|
|
||||||
export type DeleteStatusErrors = {
|
export type DeleteStatusErrors = {
|
||||||
@ -603,7 +763,8 @@ export type DeleteStatusResponses = {
|
|||||||
200: DeleteStatusResponse;
|
200: DeleteStatusResponse;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type DeleteStatusResponse2 = DeleteStatusResponses[keyof DeleteStatusResponses];
|
export type DeleteStatusResponse2 =
|
||||||
|
DeleteStatusResponses[keyof DeleteStatusResponses];
|
||||||
|
|
||||||
export type UpdateStatusData = {
|
export type UpdateStatusData = {
|
||||||
body: UpdateStatusRequest;
|
body: UpdateStatusRequest;
|
||||||
@ -614,7 +775,7 @@ export type UpdateStatusData = {
|
|||||||
statusId: number;
|
statusId: number;
|
||||||
};
|
};
|
||||||
query?: never;
|
query?: never;
|
||||||
url: '/status/{statusId}';
|
url: "/status/{statusId}";
|
||||||
};
|
};
|
||||||
|
|
||||||
export type UpdateStatusErrors = {
|
export type UpdateStatusErrors = {
|
||||||
@ -633,7 +794,8 @@ export type UpdateStatusResponses = {
|
|||||||
200: UpdateStatusResponse;
|
200: UpdateStatusResponse;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type UpdateStatusResponse2 = UpdateStatusResponses[keyof UpdateStatusResponses];
|
export type UpdateStatusResponse2 =
|
||||||
|
UpdateStatusResponses[keyof UpdateStatusResponses];
|
||||||
|
|
||||||
export type ClientOptions = {
|
export type ClientOptions = {
|
||||||
baseURL: `${string}://${string}/api` | (string & {});
|
baseURL: `${string}://${string}/api` | (string & {});
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// This file is auto-generated by @hey-api/openapi-ts
|
// This file is auto-generated by @hey-api/openapi-ts
|
||||||
|
|
||||||
import { z } from 'zod';
|
import { z } from "zod";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BoardSchema
|
* BoardSchema
|
||||||
@ -8,7 +8,7 @@ import { z } from 'zod';
|
|||||||
export const zBoardSchema = z.object({
|
export const zBoardSchema = z.object({
|
||||||
id: z.int(),
|
id: z.int(),
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
lexorank: z.string()
|
lexorank: z.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -17,14 +17,14 @@ export const zBoardSchema = z.object({
|
|||||||
export const zCreateBoardSchema = z.object({
|
export const zCreateBoardSchema = z.object({
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
projectId: z.int(),
|
projectId: z.int(),
|
||||||
lexorank: z.string()
|
lexorank: z.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CreateBoardRequest
|
* CreateBoardRequest
|
||||||
*/
|
*/
|
||||||
export const zCreateBoardRequest = z.object({
|
export const zCreateBoardRequest = z.object({
|
||||||
board: zCreateBoardSchema
|
board: zCreateBoardSchema,
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,7 +32,37 @@ export const zCreateBoardRequest = z.object({
|
|||||||
*/
|
*/
|
||||||
export const zCreateBoardResponse = z.object({
|
export const zCreateBoardResponse = z.object({
|
||||||
message: z.string(),
|
message: z.string(),
|
||||||
board: zBoardSchema
|
board: zBoardSchema,
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CreateProjectSchema
|
||||||
|
*/
|
||||||
|
export const zCreateProjectSchema = z.object({
|
||||||
|
name: z.string(),
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CreateProjectRequest
|
||||||
|
*/
|
||||||
|
export const zCreateProjectRequest = z.object({
|
||||||
|
project: zCreateProjectSchema,
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ProjectSchema
|
||||||
|
*/
|
||||||
|
export const zProjectSchema = z.object({
|
||||||
|
id: z.int(),
|
||||||
|
name: z.string(),
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CreateProjectResponse
|
||||||
|
*/
|
||||||
|
export const zCreateProjectResponse = z.object({
|
||||||
|
message: z.string(),
|
||||||
|
project: zProjectSchema,
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,14 +71,14 @@ export const zCreateBoardResponse = z.object({
|
|||||||
export const zCreateStatusSchema = z.object({
|
export const zCreateStatusSchema = z.object({
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
boardId: z.int(),
|
boardId: z.int(),
|
||||||
lexorank: z.string()
|
lexorank: z.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CreateStatusRequest
|
* CreateStatusRequest
|
||||||
*/
|
*/
|
||||||
export const zCreateStatusRequest = z.object({
|
export const zCreateStatusRequest = z.object({
|
||||||
status: zCreateStatusSchema
|
status: zCreateStatusSchema,
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,7 +87,7 @@ export const zCreateStatusRequest = z.object({
|
|||||||
export const zStatusSchema = z.object({
|
export const zStatusSchema = z.object({
|
||||||
id: z.int(),
|
id: z.int(),
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
lexorank: z.string()
|
lexorank: z.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,7 +95,7 @@ export const zStatusSchema = z.object({
|
|||||||
*/
|
*/
|
||||||
export const zCreateStatusResponse = z.object({
|
export const zCreateStatusResponse = z.object({
|
||||||
message: z.string(),
|
message: z.string(),
|
||||||
status: zStatusSchema
|
status: zStatusSchema,
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,172 +105,168 @@ export const zDealSchema = z.object({
|
|||||||
name: z.string(),
|
name: z.string(),
|
||||||
id: z.int(),
|
id: z.int(),
|
||||||
lexorank: z.string(),
|
lexorank: z.string(),
|
||||||
statusId: z.int()
|
statusId: z.int(),
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DeleteBoardResponse
|
* DeleteBoardResponse
|
||||||
*/
|
*/
|
||||||
export const zDeleteBoardResponse = z.object({
|
export const zDeleteBoardResponse = z.object({
|
||||||
message: z.string()
|
message: z.string(),
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DeleteProjectResponse
|
||||||
|
*/
|
||||||
|
export const zDeleteProjectResponse = z.object({
|
||||||
|
message: z.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DeleteStatusResponse
|
* DeleteStatusResponse
|
||||||
*/
|
*/
|
||||||
export const zDeleteStatusResponse = z.object({
|
export const zDeleteStatusResponse = z.object({
|
||||||
message: z.string()
|
message: z.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GetBoardsResponse
|
* GetBoardsResponse
|
||||||
*/
|
*/
|
||||||
export const zGetBoardsResponse = z.object({
|
export const zGetBoardsResponse = z.object({
|
||||||
boards: z.array(zBoardSchema)
|
boards: z.array(zBoardSchema),
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GetDealsResponse
|
* GetDealsResponse
|
||||||
*/
|
*/
|
||||||
export const zGetDealsResponse = z.object({
|
export const zGetDealsResponse = z.object({
|
||||||
deals: z.array(zDealSchema)
|
deals: z.array(zDealSchema),
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ProjectSchema
|
|
||||||
*/
|
|
||||||
export const zProjectSchema = z.object({
|
|
||||||
name: z.string(),
|
|
||||||
id: z.int()
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GetProjectsResponse
|
* GetProjectsResponse
|
||||||
*/
|
*/
|
||||||
export const zGetProjectsResponse = z.object({
|
export const zGetProjectsResponse = z.object({
|
||||||
projects: z.array(zProjectSchema)
|
projects: z.array(zProjectSchema),
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GetStatusesResponse
|
* GetStatusesResponse
|
||||||
*/
|
*/
|
||||||
export const zGetStatusesResponse = z.object({
|
export const zGetStatusesResponse = z.object({
|
||||||
statuses: z.array(zStatusSchema)
|
statuses: z.array(zStatusSchema),
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ValidationError
|
* ValidationError
|
||||||
*/
|
*/
|
||||||
export const zValidationError = z.object({
|
export const zValidationError = z.object({
|
||||||
loc: z.array(z.union([
|
loc: z.array(z.union([z.string(), z.int()])),
|
||||||
z.string(),
|
|
||||||
z.int()
|
|
||||||
])),
|
|
||||||
msg: z.string(),
|
msg: z.string(),
|
||||||
type: z.string()
|
type: z.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HTTPValidationError
|
* HTTPValidationError
|
||||||
*/
|
*/
|
||||||
export const zHttpValidationError = z.object({
|
export const zHttpValidationError = z.object({
|
||||||
detail: z.optional(z.array(zValidationError))
|
detail: z.optional(z.array(zValidationError)),
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UpdateBoardSchema
|
* UpdateBoardSchema
|
||||||
*/
|
*/
|
||||||
export const zUpdateBoardSchema = z.object({
|
export const zUpdateBoardSchema = z.object({
|
||||||
name: z.optional(z.union([
|
name: z.optional(z.union([z.string(), z.null()])),
|
||||||
z.string(),
|
lexorank: z.optional(z.union([z.string(), z.null()])),
|
||||||
z.null()
|
|
||||||
])),
|
|
||||||
lexorank: z.optional(z.union([
|
|
||||||
z.string(),
|
|
||||||
z.null()
|
|
||||||
]))
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UpdateBoardRequest
|
* UpdateBoardRequest
|
||||||
*/
|
*/
|
||||||
export const zUpdateBoardRequest = z.object({
|
export const zUpdateBoardRequest = z.object({
|
||||||
board: zUpdateBoardSchema
|
board: zUpdateBoardSchema,
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UpdateBoardResponse
|
* UpdateBoardResponse
|
||||||
*/
|
*/
|
||||||
export const zUpdateBoardResponse = z.object({
|
export const zUpdateBoardResponse = z.object({
|
||||||
message: z.string()
|
message: z.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UpdateDealSchema
|
* UpdateDealSchema
|
||||||
*/
|
*/
|
||||||
export const zUpdateDealSchema = z.object({
|
export const zUpdateDealSchema = z.object({
|
||||||
name: z.optional(z.union([
|
name: z.optional(z.union([z.string(), z.null()])),
|
||||||
z.string(),
|
lexorank: z.optional(z.union([z.string(), z.null()])),
|
||||||
z.null()
|
statusId: z.optional(z.union([z.int(), z.null()])),
|
||||||
])),
|
|
||||||
lexorank: z.optional(z.union([
|
|
||||||
z.string(),
|
|
||||||
z.null()
|
|
||||||
])),
|
|
||||||
statusId: z.optional(z.union([
|
|
||||||
z.int(),
|
|
||||||
z.null()
|
|
||||||
]))
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UpdateDealRequest
|
* UpdateDealRequest
|
||||||
*/
|
*/
|
||||||
export const zUpdateDealRequest = z.object({
|
export const zUpdateDealRequest = z.object({
|
||||||
deal: zUpdateDealSchema
|
deal: zUpdateDealSchema,
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UpdateDealResponse
|
* UpdateDealResponse
|
||||||
*/
|
*/
|
||||||
export const zUpdateDealResponse = z.object({
|
export const zUpdateDealResponse = z.object({
|
||||||
message: z.string()
|
message: z.string(),
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UpdateProjectSchema
|
||||||
|
*/
|
||||||
|
export const zUpdateProjectSchema = z.object({
|
||||||
|
name: z.optional(z.union([z.string(), z.null()])),
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UpdateProjectRequest
|
||||||
|
*/
|
||||||
|
export const zUpdateProjectRequest = z.object({
|
||||||
|
project: zUpdateProjectSchema,
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UpdateProjectResponse
|
||||||
|
*/
|
||||||
|
export const zUpdateProjectResponse = z.object({
|
||||||
|
message: z.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UpdateStatusSchema
|
* UpdateStatusSchema
|
||||||
*/
|
*/
|
||||||
export const zUpdateStatusSchema = z.object({
|
export const zUpdateStatusSchema = z.object({
|
||||||
name: z.optional(z.union([
|
name: z.optional(z.union([z.string(), z.null()])),
|
||||||
z.string(),
|
lexorank: z.optional(z.union([z.string(), z.null()])),
|
||||||
z.null()
|
|
||||||
])),
|
|
||||||
lexorank: z.optional(z.union([
|
|
||||||
z.string(),
|
|
||||||
z.null()
|
|
||||||
]))
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UpdateStatusRequest
|
* UpdateStatusRequest
|
||||||
*/
|
*/
|
||||||
export const zUpdateStatusRequest = z.object({
|
export const zUpdateStatusRequest = z.object({
|
||||||
status: zUpdateStatusSchema
|
status: zUpdateStatusSchema,
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UpdateStatusResponse
|
* UpdateStatusResponse
|
||||||
*/
|
*/
|
||||||
export const zUpdateStatusResponse = z.object({
|
export const zUpdateStatusResponse = z.object({
|
||||||
message: z.string()
|
message: z.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const zGetBoardsData = z.object({
|
export const zGetBoardsData = z.object({
|
||||||
body: z.optional(z.never()),
|
body: z.optional(z.never()),
|
||||||
path: z.object({
|
path: z.object({
|
||||||
projectId: z.int()
|
projectId: z.int(),
|
||||||
}),
|
}),
|
||||||
query: z.optional(z.never())
|
query: z.optional(z.never()),
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -251,7 +277,7 @@ export const zGetBoardsResponse2 = zGetBoardsResponse;
|
|||||||
export const zCreateBoardData = z.object({
|
export const zCreateBoardData = z.object({
|
||||||
body: zCreateBoardRequest,
|
body: zCreateBoardRequest,
|
||||||
path: z.optional(z.never()),
|
path: z.optional(z.never()),
|
||||||
query: z.optional(z.never())
|
query: z.optional(z.never()),
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -262,9 +288,9 @@ export const zCreateBoardResponse2 = zCreateBoardResponse;
|
|||||||
export const zDeleteBoardData = z.object({
|
export const zDeleteBoardData = z.object({
|
||||||
body: z.optional(z.never()),
|
body: z.optional(z.never()),
|
||||||
path: z.object({
|
path: z.object({
|
||||||
boardId: z.int()
|
boardId: z.int(),
|
||||||
}),
|
}),
|
||||||
query: z.optional(z.never())
|
query: z.optional(z.never()),
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -275,9 +301,9 @@ export const zDeleteBoardResponse2 = zDeleteBoardResponse;
|
|||||||
export const zUpdateBoardData = z.object({
|
export const zUpdateBoardData = z.object({
|
||||||
body: zUpdateBoardRequest,
|
body: zUpdateBoardRequest,
|
||||||
path: z.object({
|
path: z.object({
|
||||||
boardId: z.int()
|
boardId: z.int(),
|
||||||
}),
|
}),
|
||||||
query: z.optional(z.never())
|
query: z.optional(z.never()),
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -288,9 +314,9 @@ export const zUpdateBoardResponse2 = zUpdateBoardResponse;
|
|||||||
export const zGetDealsData = z.object({
|
export const zGetDealsData = z.object({
|
||||||
body: z.optional(z.never()),
|
body: z.optional(z.never()),
|
||||||
path: z.object({
|
path: z.object({
|
||||||
boardId: z.int()
|
boardId: z.int(),
|
||||||
}),
|
}),
|
||||||
query: z.optional(z.never())
|
query: z.optional(z.never()),
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -301,9 +327,9 @@ export const zGetDealsResponse2 = zGetDealsResponse;
|
|||||||
export const zUpdateDealData = z.object({
|
export const zUpdateDealData = z.object({
|
||||||
body: zUpdateDealRequest,
|
body: zUpdateDealRequest,
|
||||||
path: z.object({
|
path: z.object({
|
||||||
dealId: z.int()
|
dealId: z.int(),
|
||||||
}),
|
}),
|
||||||
query: z.optional(z.never())
|
query: z.optional(z.never()),
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -314,7 +340,7 @@ export const zUpdateDealResponse2 = zUpdateDealResponse;
|
|||||||
export const zGetProjectsData = z.object({
|
export const zGetProjectsData = z.object({
|
||||||
body: z.optional(z.never()),
|
body: z.optional(z.never()),
|
||||||
path: z.optional(z.never()),
|
path: z.optional(z.never()),
|
||||||
query: z.optional(z.never())
|
query: z.optional(z.never()),
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -322,12 +348,49 @@ export const zGetProjectsData = z.object({
|
|||||||
*/
|
*/
|
||||||
export const zGetProjectsResponse2 = zGetProjectsResponse;
|
export const zGetProjectsResponse2 = zGetProjectsResponse;
|
||||||
|
|
||||||
|
export const zCreateProjectData = z.object({
|
||||||
|
body: zCreateProjectRequest,
|
||||||
|
path: z.optional(z.never()),
|
||||||
|
query: z.optional(z.never()),
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Successful Response
|
||||||
|
*/
|
||||||
|
export const zCreateProjectResponse2 = zCreateProjectResponse;
|
||||||
|
|
||||||
|
export const zDeleteProjectData = z.object({
|
||||||
|
body: z.optional(z.never()),
|
||||||
|
path: z.optional(z.never()),
|
||||||
|
query: z.object({
|
||||||
|
projectId: z.int(),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Successful Response
|
||||||
|
*/
|
||||||
|
export const zDeleteProjectResponse2 = zDeleteProjectResponse;
|
||||||
|
|
||||||
|
export const zUpdateProjectData = z.object({
|
||||||
|
body: zUpdateProjectRequest,
|
||||||
|
path: z.optional(z.never()),
|
||||||
|
query: z.object({
|
||||||
|
projectId: z.int(),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Successful Response
|
||||||
|
*/
|
||||||
|
export const zUpdateProjectResponse2 = zUpdateProjectResponse;
|
||||||
|
|
||||||
export const zGetStatusesData = z.object({
|
export const zGetStatusesData = z.object({
|
||||||
body: z.optional(z.never()),
|
body: z.optional(z.never()),
|
||||||
path: z.object({
|
path: z.object({
|
||||||
boardId: z.int()
|
boardId: z.int(),
|
||||||
}),
|
}),
|
||||||
query: z.optional(z.never())
|
query: z.optional(z.never()),
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -338,7 +401,7 @@ export const zGetStatusesResponse2 = zGetStatusesResponse;
|
|||||||
export const zCreateStatusData = z.object({
|
export const zCreateStatusData = z.object({
|
||||||
body: zCreateStatusRequest,
|
body: zCreateStatusRequest,
|
||||||
path: z.optional(z.never()),
|
path: z.optional(z.never()),
|
||||||
query: z.optional(z.never())
|
query: z.optional(z.never()),
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -349,9 +412,9 @@ export const zCreateStatusResponse2 = zCreateStatusResponse;
|
|||||||
export const zDeleteStatusData = z.object({
|
export const zDeleteStatusData = z.object({
|
||||||
body: z.optional(z.never()),
|
body: z.optional(z.never()),
|
||||||
path: z.object({
|
path: z.object({
|
||||||
statusId: z.int()
|
statusId: z.int(),
|
||||||
}),
|
}),
|
||||||
query: z.optional(z.never())
|
query: z.optional(z.never()),
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -362,9 +425,9 @@ export const zDeleteStatusResponse2 = zDeleteStatusResponse;
|
|||||||
export const zUpdateStatusData = z.object({
|
export const zUpdateStatusData = z.object({
|
||||||
body: zUpdateStatusRequest,
|
body: zUpdateStatusRequest,
|
||||||
path: z.object({
|
path: z.object({
|
||||||
statusId: z.int()
|
statusId: z.int(),
|
||||||
}),
|
}),
|
||||||
query: z.optional(z.never())
|
query: z.optional(z.never()),
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user