Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into 122-add-filtering-by-restriction-code-to-web…
Browse files Browse the repository at this point in the history
…soc-endpoint
  • Loading branch information
ecxyzzy authored Feb 13, 2024
2 parents 4ec18b0 + f8539de commit 8d2d018
Show file tree
Hide file tree
Showing 61 changed files with 559 additions and 492 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const config = {
],
rules: {
"no-unused-vars": "off",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/no-unused-vars": [
"error",
{
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ jobs:
uses: ./.github/actions/setup-node-and-pnpm

- name: Install dependencies
# Ensure NODE_ENV != production so pnpm will install devDependencies!!!
run: NODE_ENV=development pnpm install --frozen-lockfile
run: pnpm install --frozen-lockfile

- name: Build API
run: pnpm build --filter="@apps/api"
Expand All @@ -72,8 +71,7 @@ jobs:
uses: ./.github/actions/setup-node-and-pnpm

- name: Install dependencies
# Ensure NODE_ENV != production so pnpm will install devDependencies!!!
run: NODE_ENV=development pnpm install --frozen-lockfile
run: pnpm install --frozen-lockfile

- name: Build documentation
run: pnpm build --filter="@apps/docs"
Expand All @@ -96,8 +94,7 @@ jobs:
uses: ./.github/actions/setup-node-and-pnpm

- name: Install dependencies
# Ensure NODE_ENV != production so pnpm will install devDependencies!!!
run: NODE_ENV=development pnpm install --frozen-lockfile
run: pnpm install --frozen-lockfile

- name: Build services
run: pnpm build --filter="@services/*"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/validate-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ jobs:
- name: Setup Node.js and pnpm
uses: ./.github/actions/setup-node-and-pnpm

- name: Install devDependencies
run: pnpm install --dev --frozen-lockfile --ignore-scripts --workspace-root
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts --workspace-root

- name: Lint pull request title
run: echo ${{ toJSON(github.event.pull_request.title) }} | npx --no -- commitlint
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
engine-strict = true
public-hoist-pattern[]=*prisma*
3 changes: 2 additions & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"@graphql-tools/utils": "10.0.13",
"@libs/db": "workspace:^",
"@libs/lambda": "workspace:^",
"@libs/uc-irvine-api": "workspace:^",
"@libs/uc-irvine-lib": "workspace:^",
"@libs/utils": "workspace:^",
"@libs/websoc-utils": "workspace:^",
"@peterportal-api/types": "workspace:^",
"@services/websoc-proxy": "workspace:^",
Expand Down
2 changes: 2 additions & 0 deletions apps/api/src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
* Virtual module for caching course information during build time.
*/
declare module "virtual:courses" {
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
declare const courses: Record<string, import("@peterportal-api/types").Course>;
}
/**
* Virtual module for caching instructor information during build time.
*/
declare module "virtual:instructors" {
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
declare const instructors: Record<string, import("@peterportal-api/types").Instructor>;
}
4 changes: 2 additions & 2 deletions apps/api/src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Course as PrismaCourse } from "@libs/db";
import {
import type { Course as PrismaCourse } from "@libs/db";
import type {
Course,
CourseLevel,
CoursePreview,
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/routes/v1/graphql/+config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { cpSync, mkdirSync } from "node:fs";
import { join, resolve } from "node:path";

import { ApiPropsOverride } from "@bronya.js/api-construct";
import type { ApiPropsOverride } from "@bronya.js/api-construct";

import { esbuildOptions, constructs } from "../../../../bronya.config";

Expand Down
3 changes: 2 additions & 1 deletion apps/api/src/routes/v1/graphql/+endpoint.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { join } from "node:path";
import { parse } from "node:url";

import { ApolloServer, HeaderMap, HTTPGraphQLRequest } from "@apollo/server";
import type { HTTPGraphQLRequest } from "@apollo/server";
import { ApolloServer, HeaderMap } from "@apollo/server";
import {
ApolloServerPluginLandingPageLocalDefault,
ApolloServerPluginLandingPageProductionDefault,
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/routes/v1/rest/calendar/+endpoint.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PrismaClient } from "@libs/db";
import { createHandler } from "@libs/lambda";
import { getTermDateData } from "@libs/uc-irvine-api/registrar";
import { getTermDateData } from "@libs/uc-irvine-lib/registrar";
import type { Quarter, QuarterDates } from "@peterportal-api/types";
import { ZodError } from "zod";

Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/routes/v1/rest/courses/lib.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Prisma } from "@libs/db";
import type { Prisma } from "@libs/db";

import { Query } from "./schema";
import type { Query } from "./schema";

/**
* Constructs a Prisma query for the given filter parameters.
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/routes/v1/rest/courses/{id}/+config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ApiPropsOverride } from "@bronya.js/api-construct";
import type { ApiPropsOverride } from "@bronya.js/api-construct";

import { esbuildOptions, constructs } from "../../../../../../bronya.config";

Expand Down
10 changes: 3 additions & 7 deletions apps/api/src/routes/v1/rest/grades/{id}/lib.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { GradesSection, Prisma } from "@libs/db";
import type { GradesSection, Prisma } from "@libs/db";
import { notNull } from "@libs/utils";
import type {
AggregateGrades,
AggregateGradesByOffering,
Expand All @@ -13,12 +14,7 @@ import type {
} from "@peterportal-api/types";
import { geCodes } from "@peterportal-api/types";

import { Query } from "./schema";

/**
* type guard that asserts input is defined
*/
export const notNull = <T>(x: T): x is NonNullable<T> => x != null;
import type { Query } from "./schema";

/**
* Returns the lexicographical ordering of two elements.
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/routes/v1/rest/instructors/lib.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Prisma } from "@libs/db";
import type { Prisma } from "@libs/db";

import { Query } from "./schema";
import type { Query } from "./schema";

/**
* Constructs a Prisma query for the given filter parameters.
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/routes/v1/rest/instructors/{id}/+config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ApiPropsOverride } from "@bronya.js/api-construct";
import type { ApiPropsOverride } from "@bronya.js/api-construct";

import { esbuildOptions, constructs } from "../../../../../../bronya.config";

Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/routes/v1/rest/larc/lib.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Quarter } from "@peterportal-api/types";
import type { Quarter } from "@peterportal-api/types";

export const quarterToLarcSuffix = (quarter: Exclude<Quarter, "Summer10wk">): string => {
switch (quarter) {
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/routes/v1/rest/websoc/+config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ApiPropsOverride } from "@bronya.js/api-construct";
import type { ApiPropsOverride } from "@bronya.js/api-construct";
import {
Effect,
ManagedPolicy,
Expand Down
5 changes: 3 additions & 2 deletions apps/api/src/routes/v1/rest/websoc/+endpoint.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { PrismaClient } from "@libs/db";
import { createHandler } from "@libs/lambda";
import type { WebsocAPIResponse } from "@libs/uc-irvine-api/websoc";
import { combineAndNormalizeResponses, notNull, sortResponse } from "@libs/websoc-utils";
import type { WebsocAPIResponse } from "@libs/uc-irvine-lib/websoc";
import { notNull } from "@libs/utils";
import { combineAndNormalizeResponses, sortResponse } from "@libs/websoc-utils";
import { ZodError } from "zod";

import { APILambdaClient } from "./APILambdaClient";
Expand Down
5 changes: 3 additions & 2 deletions apps/api/src/routes/v1/rest/websoc/APILambdaClient.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { InvokeCommand, LambdaClient, LambdaClientConfig } from "@aws-sdk/client-lambda";
import type { LambdaClientConfig } from "@aws-sdk/client-lambda";
import { InvokeCommand, LambdaClient } from "@aws-sdk/client-lambda";
import { zeroUUID } from "@libs/lambda";
import type { WebsocAPIResponse } from "@libs/uc-irvine-api/websoc";
import type { WebsocAPIResponse } from "@libs/uc-irvine-lib/websoc";
import type { Department, TermData } from "@peterportal-api/types";
import type { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from "aws-lambda";

Expand Down
11 changes: 4 additions & 7 deletions apps/api/src/routes/v1/rest/websoc/lib.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Prisma, $Enums } from "@libs/db";
import { WebsocAPIOptions } from "@libs/uc-irvine-api/websoc";
import { $Enums } from "@libs/db";
import type { Prisma } from "@libs/db";
import type { WebsocAPIOptions } from "@libs/uc-irvine-lib/websoc";
import { notNull } from "@libs/utils";

import type { Query } from "./schema";

Expand All @@ -9,11 +11,6 @@ import type { Query } from "./schema";
export const fulfilled = <T>(value: PromiseSettledResult<T>): value is PromiseFulfilledResult<T> =>
value.status === "fulfilled";

/**
* type guard that asserts input is defined
*/
export const notNull = <T>(x: T): x is NonNullable<T> => x != null;

/**
* Converts a 12-hour time string into number of minutes since midnight.
* @param time The time string to parse.
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/routes/v1/rest/websoc/{id}/+config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ApiPropsOverride } from "@bronya.js/api-construct";
import type { ApiPropsOverride } from "@bronya.js/api-construct";
import {
Effect,
ManagedPolicy,
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/routes/v1/rest/week/lib.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CalendarTerm } from "@libs/db";
import { Quarter } from "@peterportal-api/types";
import type { CalendarTerm } from "@libs/db";
import type { Quarter } from "@peterportal-api/types";

const DAY_MS = 24 * 60 * 60 * 1000;
const WEEK_MS = 7 * DAY_MS;
Expand Down
1 change: 1 addition & 0 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@apps/docs",
"version": "0.0.0",
"private": true,
"description": "The documentation site for API",
"scripts": {
"build": "docusaurus build",
"dev": "docusaurus start"
Expand Down
1 change: 1 addition & 0 deletions libs/db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@libs/db",
"version": "0.0.0",
"private": true,
"description": "Wrapper package for shared Prisma Client",
"license": "MIT",
"type": "module",
"main": "index.ts",
Expand Down
1 change: 1 addition & 0 deletions libs/lambda/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@libs/lambda",
"version": "0.0.0",
"private": true,
"description": "Helpers for handling Lambda requests",
"license": "MIT",
"type": "module",
"main": "src/index.ts",
Expand Down
3 changes: 0 additions & 3 deletions libs/uc-irvine-api/tsconfig.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@libs/uc-irvine-api",
"name": "@libs/uc-irvine-lib",
"version": "0.10.8",
"private": true,
"description": "SDK for various UC Irvine services",
"description": "Libraries to interface with various UC Irvine data sources",
"keywords": [],
"homepage": "https://docs.api-next.peterportal.org",
"bugs": {
Expand All @@ -11,7 +11,7 @@
"repository": {
"type": "git",
"url": "https://github.com/icssc/peterportal-api-next",
"directory": "libs/uc-irvine-api"
"directory": "libs/uc-irvine-lib"
},
"license": "MIT",
"type": "module",
Expand Down Expand Up @@ -55,8 +55,5 @@
"engines": {
"node": "20",
"pnpm": "8"
},
"publishConfig": {
"access": "public"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { QuarterDates, quarters } from "@peterportal-api/types";
import type { QuarterDates } from "@peterportal-api/types";
import { quarters } from "@peterportal-api/types";
import { load } from "cheerio";
import fetch from "cross-fetch";

Expand Down
3 changes: 3 additions & 0 deletions libs/uc-irvine-lib/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["../../tsconfig.json"],
}
8 changes: 8 additions & 0 deletions libs/utils/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@libs/utils",
"version": "0.0.0",
"private": true,
"description": "Miscellaneous utilities used by the API's components",
"license": "MIT",
"main": "src/index.ts"
}
12 changes: 12 additions & 0 deletions libs/utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Sleep for the given number of milliseconds.
* @param duration Duration in ms.
*/
export const sleep = async (duration: number) =>
new Promise((resolve) => setTimeout(resolve, duration));

/**
* Type guard that asserts the input is defined.
* @param x The input to check.
*/
export const notNull = <T>(x: T): x is NonNullable<T> => x != null;
3 changes: 2 additions & 1 deletion libs/websoc-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
"name": "@libs/websoc-utils",
"version": "0.0.0",
"private": true,
"description": "Helper functions for transforming WebSoc JSON responses",
"type": "module",
"main": "src/index.ts",
"types": "src/index.ts",
"dependencies": {
"@libs/uc-irvine-api": "workspace:^",
"@libs/uc-irvine-lib": "workspace:^",
"@peterportal-api/types": "workspace:^"
}
}
14 changes: 1 addition & 13 deletions libs/websoc-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
WebsocSchool,
WebsocSection,
WebsocSectionMeeting,
} from "@libs/uc-irvine-api/websoc";
} from "@libs/uc-irvine-lib/websoc";
import type {
DayOfWeek,
WebsocAPIResponse as NormalizedResponse,
Expand Down Expand Up @@ -40,18 +40,6 @@ export type EnhancedNormalizedSection = {
export const fulfilled = <T>(value: PromiseSettledResult<T>): value is PromiseFulfilledResult<T> =>
value.status === "fulfilled";

/**
* type guard that asserts input is defined
*/
export const notNull = <T>(x: T): x is NonNullable<T> => x != null;

/**
* Sleep for the given number of milliseconds.
* @param duration Duration in ms.
*/
export const sleep = async (duration: number) =>
new Promise((resolve) => setTimeout(resolve, duration));

const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];

/**
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
"destroy": "turbo run destroy",
"dev": "dotenv -c development -- turbo run dev",
"format": "prettier --write .",
"postinstall": "husky install",
"lint": "eslint --fix .",
"prepare": "husky",
"test": "turbo run test"
},
"devDependencies": {
"dependencies": {
"@commitlint/cli": "18.6.0",
"@commitlint/config-conventional": "18.6.0",
"@commitlint/types": "18.6.0",
Expand Down
1 change: 1 addition & 0 deletions packages/types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@peterportal-api/types",
"version": "1.0.0-rc.3",
"description": "",
"license": "MIT",
"type": "module",
"main": "index.ts",
Expand Down
4 changes: 2 additions & 2 deletions packages/types/types/courses.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CourseLevel, GECategory } from "./constants";
import { InstructorPreview } from "./instructor";
import type { CourseLevel, GECategory } from "./constants";
import type { InstructorPreview } from "./instructor";

/**
* An object representing a prerequisite.
Expand Down
2 changes: 1 addition & 1 deletion packages/types/types/enrollmentHistory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Quarter, SectionType } from "./constants";
import type { Quarter, SectionType } from "./constants";

export type Meeting = {
bldg: string[];
Expand Down
Loading

0 comments on commit 8d2d018

Please sign in to comment.