Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes generated API client from repo, replacing with package import #1618

Draft
wants to merge 3 commits into
base: nextjs
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions frontends/api/.openapi-generator-ignore

This file was deleted.

5 changes: 3 additions & 2 deletions frontends/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"exports": {
".": "./src/generated/v1/api.ts",
"./clients": "./src/clients.ts",
"./v0": "./src/generated/v0/api.ts",
"./v1": "./src/generated/v1/api.ts",
"./v0": "./src/v0.ts",
"./v1": "./src/v1.ts",
"./hooks/*": "./src/hooks/*/index.ts",
"./constants": "./src/common/constants.ts",
"./test-utils/factories": "./src/test-utils/factories/index.ts",
Expand All @@ -27,6 +27,7 @@
},
"dependencies": {
"@lukemorales/query-key-factory": "^1.3.2",
"@mitodl/open-api-axios": "^2024.9.26",
"@tanstack/react-query": "^4.36.1",
"axios": "^1.6.3"
}
Expand Down
4 changes: 2 additions & 2 deletions frontends/api/src/clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
LearningResourcesUserSubscriptionApi,
SchoolsApi,
FeaturedApi,
} from "./generated/v1/api"
} from "@mitodl/open-api-axios/v1"

import {
ChannelsApi,
Expand All @@ -20,7 +20,7 @@ import {
NewsEventsApi,
ProfilesApi,
TestimonialsApi,
} from "./generated/v0/api"
} from "@mitodl/open-api-axios/v0"

import axiosInstance from "./axios"

Expand Down
2 changes: 1 addition & 1 deletion frontends/api/src/hooks/articles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { articlesApi } from "../../clients"
import type {
ArticlesApiArticlesListRequest as ArticleListRequest,
Article,
} from "../../generated/v1"
} from "@mitodl/open-api-axios/v1"
import articles from "./keyFactory"

const useArticleList = (
Expand Down
2 changes: 1 addition & 1 deletion frontends/api/src/hooks/articles/keyFactory.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { articlesApi } from "../../clients"
import type { ArticlesApiArticlesListRequest as ArticleListRequest } from "../../generated/v1"
import type { ArticlesApiArticlesListRequest as ArticleListRequest } from "@mitodl/open-api-axios/v1"
import { createQueryKeys } from "@lukemorales/query-key-factory"

const articles = createQueryKeys("articles", {
Expand Down
2 changes: 1 addition & 1 deletion frontends/api/src/hooks/channels/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { channelsApi } from "../../clients"
import type {
ChannelsApiChannelsListRequest,
PatchedChannelWriteRequest,
} from "../../generated/v0"
} from "@mitodl/open-api-axios/v0"
import channels from "./keyFactory"

const useChannelsList = (
Expand Down
2 changes: 1 addition & 1 deletion frontends/api/src/hooks/channels/keyFactory.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { channelsApi } from "../../clients"
import type { ChannelsApiChannelsListRequest as FieldsApiListRequest } from "../../generated/v0"
import type { ChannelsApiChannelsListRequest as FieldsApiListRequest } from "@mitodl/open-api-axios/v0"
import { createQueryKeys } from "@lukemorales/query-key-factory"

const channels = createQueryKeys("channel", {
Expand Down
2 changes: 1 addition & 1 deletion frontends/api/src/hooks/learningResources/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
import { setMockResponse, urls, makeRequest } from "../../test-utils"
import * as factories from "../../test-utils/factories"
import { UseQueryResult } from "@tanstack/react-query"
import { LearningResource } from "../../generated/v1"
import { LearningResource } from "@mitodl/open-api-axios/v1"

const factory = factories.learningResources

Expand Down
2 changes: 1 addition & 1 deletion frontends/api/src/hooks/learningResources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import type {
PaginatedLearningResourceList,
LearningResourcesApiLearningResourcesUserlistsPartialUpdateRequest,
LearningResourcesApiLearningResourcesLearningPathsPartialUpdateRequest,
} from "../../generated/v1"
} from "@mitodl/open-api-axios/v1"
import learningResources, {
invalidateResourceQueries,
invalidateUserListQueries,
Expand Down
2 changes: 1 addition & 1 deletion frontends/api/src/hooks/learningResources/keyFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import type {
FeaturedApiFeaturedListRequest as FeaturedListParams,
UserListRelationship,
MicroUserListRelationship,
} from "../../generated/v1"
} from "@mitodl/open-api-axios/v1"
import { createQueryKeys } from "@lukemorales/query-key-factory"

const learningResources = createQueryKeys("learningResources", {
Expand Down
2 changes: 1 addition & 1 deletion frontends/api/src/hooks/newsEvents/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import newsEvents from "./keyFactory"
import {
NewsEventsApiNewsEventsListRequest,
NewsEventsListFeedTypeEnum,
} from "../../generated/v0/api"
} from "@mitodl/open-api-axios/v0"

const useNewsEventsList = (params: NewsEventsApiNewsEventsListRequest) => {
return useQuery({
Expand Down
2 changes: 1 addition & 1 deletion frontends/api/src/hooks/newsEvents/keyFactory.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { newsEventsApi } from "../../clients"
import type { NewsEventsApiNewsEventsListRequest } from "../../generated/v0"
import type { NewsEventsApiNewsEventsListRequest } from "@mitodl/open-api-axios/v0"
import { createQueryKeys } from "@lukemorales/query-key-factory"

const newsEvents = createQueryKeys("newsEvents", {
Expand Down
2 changes: 1 addition & 1 deletion frontends/api/src/hooks/profile/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"
import { profilesApi } from "../../clients"
import type { Profile, PatchedProfileRequest } from "../../generated/v0/api"
import type { Profile, PatchedProfileRequest } from "@mitodl/open-api-axios/v0"

const useProfileQuery = (username: string) =>
useQuery<Profile>({
Expand Down
2 changes: 1 addition & 1 deletion frontends/api/src/hooks/searchSubscription/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
useQuery,
} from "@tanstack/react-query"
import searchSubscriptions from "./keyFactory"
import type { LearningResourcesUserSubscriptionApiLearningResourcesUserSubscriptionSubscribeCreateRequest as subscriptionCreateRequest } from "../../generated/v1"
import type { LearningResourcesUserSubscriptionApiLearningResourcesUserSubscriptionSubscribeCreateRequest as subscriptionCreateRequest } from "@mitodl/open-api-axios/v1"
import { searchSubscriptionApi } from "../../clients"

const useSearchSubscriptionCreate = () => {
Expand Down
2 changes: 1 addition & 1 deletion frontends/api/src/hooks/searchSubscription/keyFactory.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { searchSubscriptionApi } from "../../clients"
import { createQueryKeys } from "@lukemorales/query-key-factory"
import type { LearningResourcesUserSubscriptionApiLearningResourcesUserSubscriptionCheckListRequest as subscriptionCheckListRequest } from "../../generated/v1"
import type { LearningResourcesUserSubscriptionApiLearningResourcesUserSubscriptionCheckListRequest as subscriptionCheckListRequest } from "@mitodl/open-api-axios/v1"
const searchSubscriptions = createQueryKeys("searchSubscriptions", {
list: (params: subscriptionCheckListRequest) => ({
queryKey: [params],
Expand Down
2 changes: 1 addition & 1 deletion frontends/api/src/hooks/testimonials/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { UseQueryOptions, useQuery } from "@tanstack/react-query"

import type { TestimonialsApiTestimonialsListRequest } from "../../generated/v0"
import type { TestimonialsApiTestimonialsListRequest } from "@mitodl/open-api-axios/v0"
import testimonials from "./keyFactory"

const useTestimonialList = (
Expand Down
2 changes: 1 addition & 1 deletion frontends/api/src/hooks/testimonials/keyFactory.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { testimonialsApi } from "../../clients"
import type { TestimonialsApiTestimonialsListRequest as TestimonialsListRequest } from "../../generated/v0"
import type { TestimonialsApiTestimonialsListRequest as TestimonialsListRequest } from "@mitodl/open-api-axios/v0"
import { createQueryKeys } from "@lukemorales/query-key-factory"

const testimonials = createQueryKeys("testimonials", {
Expand Down
2 changes: 1 addition & 1 deletion frontends/api/src/hooks/user/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useQuery } from "@tanstack/react-query"
import { usersApi } from "../../clients"
import type { User as UserApi } from "../../generated/v0/api"
import type { User as UserApi } from "@mitodl/open-api-axios/v0"

interface User extends Partial<UserApi> {
is_authenticated: boolean
Expand Down
2 changes: 2 additions & 0 deletions frontends/api/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * as v0 from "@mitodl/open-api-axios/v0"
export * from "@mitodl/open-api-axios/v1"
9 changes: 0 additions & 9 deletions frontends/api/src/types/settings.d.ts

This file was deleted.

36 changes: 36 additions & 0 deletions frontends/api/src/v0.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// export { ChannelTypeEnum } from "@mitodl/open-api-axios/v1"

export * from "@mitodl/open-api-axios/v0"

// TODO below items are not in latest published api client yet

export const CertificateDesiredEnumDescriptions = {
yes: "Yes, I am looking for a certificate",
no: "No, I am not looking for a certificate",
"not-sure-yet": "Not Sure",
} as const

export const CurrentEducationEnumDescriptions = {
Doctorate: "Doctorate",
"Master's or professional degree": "Master's or professional degree",
"Bachelor's degree": "Bachelor's degree",
"Associate degree": "Associate degree",
"Secondary/high school": "Secondary/high school",
"Junior secondary/junior high/middle school":
"Junior secondary/junior high/middle school",
"No formal education": "No formal education",
"Other education": "Other education",
} as const

export const GoalsEnumDescriptions = {
"academic-excellence": "Academic Boost",
"career-growth": "Career Growth",
"lifelong-learning": "Lifelong Learning",
} as const

export const DeliveryEnumDescriptions = {
online: "Online",
hybrid: "Hybrid",
in_person: "In-Person",
offline: "Offline",
} as const
9 changes: 9 additions & 0 deletions frontends/api/src/v1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export * from "@mitodl/open-api-axios/v1"

// TODO below items are not in latest published api client yet

export const SearchModeEnumDescriptions = {
best_fields: "best_fields",
most_fields: "most_fields",
phrase: "phrase",
} as const
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { SearchSubscriptionToggle } from "@/page-components/SearchSubscriptionTo
import { useChannelDetail } from "api/hooks/channels"
import ChannelMenu from "@/components/ChannelMenu/ChannelMenu"
import ChannelAvatar from "@/components/ChannelAvatar/ChannelAvatar"
import { SourceTypeEnum } from "api"
import { SourceTypeEnum } from "api/v1"
import { HOME as HOME_URL } from "../../common/urls"
import {
CHANNEL_TYPE_BREADCRUMB_TARGETS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import ChannelMenu from "@/components/ChannelMenu/ChannelMenu"
import ResourceCarousel, {
ResourceCarouselProps,
} from "@/page-components/ResourceCarousel/ResourceCarousel"
import { SourceTypeEnum } from "api"
import { SourceTypeEnum } from "api/v1"
import { getSearchParamMap } from "@/common/utils"
import { HOME as HOME_URL, UNITS as UNITS_URL } from "../../common/urls"
import { ChannelTypeEnum } from "api/v0"
Expand Down
2 changes: 1 addition & 1 deletion frontends/main/src/app-pages/DashboardPage/carousels.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ResourceCarouselProps } from "@/page-components/ResourceCarousel/ResourceCarousel"
import { LearningResourcesSearchRetrieveDeliveryEnum } from "api"
import { LearningResourcesSearchRetrieveDeliveryEnum } from "api/v1"
import { Profile } from "api/v0"

type TopPicksCarouselConfigProps = (
Expand Down
3 changes: 2 additions & 1 deletion frontends/main/src/app-pages/UnitsListingPage/UnitCard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react"
import { LearningResourceOfferorDetail, OfferedByEnum } from "api"
import { LearningResourceOfferorDetail } from "api/v0"
import { OfferedByEnum } from "api/v1"
import { Card, Skeleton, Typography, styled, theme } from "ol-components"
import { useChannelDetail } from "api/hooks/channels"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
Button,
} from "ol-components"
import * as Yup from "yup"
import { PrivacyLevelEnum, type LearningPathResource, UserList } from "api"
import { PrivacyLevelEnum, type LearningPathResource, UserList } from "api/v1"

import {
useLearningpathCreate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
LearningResourcesSearchApiLearningResourcesSearchRetrieveRequest as LRSearchRequest,
ResourceCategoryEnum,
SearchModeEnumDescriptions,
} from "api"
} from "api/v1"
import { useLearningResourcesSearch } from "api/hooks/learningResources"
import { GridColumn, GridContainer } from "@/components/GridLayout/GridLayout"
import {
Expand Down
11 changes: 11 additions & 0 deletions yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading