Skip to content

Commit

Permalink
chore(4845): resolve typescript type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
junminahn committed Feb 5, 2025
1 parent 7b3d60c commit f30f16b
Show file tree
Hide file tree
Showing 39 changed files with 91 additions and 77 deletions.
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@ localmac:

.PHONY: dev
dev:
@DATABASE_URL=$$(grep -m 1 '^DATABASE_URL=' app/.env.local | cut -d '=' -f 2-) \
npm run prisma-push --prefix app && \
npm run dev --prefix app
pnpm --dir app run prisma-push
pnpm --dir app run dev

.PHONY: install
install:
pnpm install
npm install --prefix app
npm install --prefix data-migrations
pnpm --dir app install
pnpm --dir data-migrations install
pnpm --dir sandbox/_packages/keycloak-admin install
pnpm --dir sandbox/keycloak-provision install
pnpm --dir sandbox/m365mock install
pnpm --dir sandbox/nats-provision install

.PHONY: asdf-install
asdf-install:
Expand Down
2 changes: 1 addition & 1 deletion app/app/api/private-cloud/products/_operations/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export default async function updateOp({
return OkResponse(newRequest);
}

const proms = [];
const proms: any[] = [];

proms.push(
sendRequestNatsMessage(newRequest, {
Expand Down
2 changes: 1 addition & 1 deletion app/app/api/private-cloud/products/download/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ describe('Download Private Cloud Products - Validations', () => {
it('should successfully create products by admin', async () => {
await mockSessionByRole(GlobalRole.Admin);

const datasets = [];
const datasets: any[] = [];
datasets.push(
createSamplePrivateCloudProductData({ data: { ministry: Ministry.AEST, cluster: Cluster.CLAB } }),
createSamplePrivateCloudProductData({ data: { ministry: Ministry.AEST, cluster: Cluster.KLAB } }),
Expand Down
2 changes: 1 addition & 1 deletion app/app/api/private-cloud/products/search/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ describe('Search Private Cloud Products - Validations', () => {
it('should successfully create products by admin', async () => {
await mockSessionByRole(GlobalRole.Admin);

const datasets = [];
const datasets: any[] = [];
datasets.push(
createSamplePrivateCloudProductData({ data: { ministry: Ministry.AEST, cluster: Cluster.CLAB } }),
createSamplePrivateCloudProductData({ data: { ministry: Ministry.AEST, cluster: Cluster.KLAB } }),
Expand Down
2 changes: 1 addition & 1 deletion app/app/api/private-cloud/requests/[id]/decision/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export const POST = apiHandler(async ({ pathParams, body, session }) => {
return OkResponse(updatedRequestDecorated);
}

const proms = [];
const proms: any[] = [];

proms.push(
sendRequestNatsMessage(updatedRequestDecorated, {
Expand Down
2 changes: 1 addition & 1 deletion app/app/api/private-cloud/requests/search/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ describe('Search Private Cloud Requests - Validations', () => {
it('should successfully create products by admin', async () => {
await mockSessionByRole(GlobalRole.PrivateAdmin);

const datasets = [];
const datasets: any[] = [];
datasets.push(
createSamplePrivateCloudProductData({ data: { ministry: Ministry.AEST, cluster: Cluster.CLAB } }),
createSamplePrivateCloudProductData({ data: { ministry: Ministry.AEST, cluster: Cluster.KLAB } }),
Expand Down
3 changes: 2 additions & 1 deletion app/app/api/public-cloud/aws-roles/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import KcAdminClient from '@keycloak/keycloak-admin-client';
import GroupRepresentation from '@keycloak/keycloak-admin-client/lib/defs/groupRepresentation';
import { Credentials } from '@keycloak/keycloak-admin-client/lib/utils/auth';
import _compact from 'lodash-es/compact';
import _kebabCase from 'lodash-es/kebabCase';
Expand Down Expand Up @@ -173,7 +174,7 @@ async function findParentGroup(groupName = PROJECT_GROUP) {
}

async function listSubGroups({ parentId, search }: { parentId: string; search?: string }) {
const subGroups = [];
const subGroups: GroupRepresentation[] = [];

const max = 100;
let first = 0;
Expand Down
2 changes: 1 addition & 1 deletion app/app/api/public-cloud/products/_operations/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default async function createOp({ session, body }: { session: Session; bo
)
).data;

const proms = [];
const proms: any[] = [];

// Assign a task to the expense authority for new billing
if (newRequest.decisionData.expenseAuthorityId && !newRequest.decisionData.billing.signed) {
Expand Down
2 changes: 1 addition & 1 deletion app/app/api/public-cloud/products/download/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ describe('Download Public Cloud Products - Validations', () => {
it('should successfully create products by admin', async () => {
await mockSessionByRole(GlobalRole.Admin);

const datasets = [];
const datasets: any[] = [];
datasets.push(
createSamplePublicCloudProductData({ data: { ministry: Ministry.AEST, provider: Provider.AWS } }),
createSamplePublicCloudProductData({ data: { ministry: Ministry.AEST, provider: Provider.AZURE } }),
Expand Down
2 changes: 1 addition & 1 deletion app/app/api/public-cloud/products/search/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ describe('Search Public Cloud Products - Validations', () => {
it('should successfully create products by admin', async () => {
await mockSessionByRole(GlobalRole.Admin);

const datasets = [];
const datasets: any[] = [];
datasets.push(
createSamplePublicCloudProductData({ data: { ministry: Ministry.AEST, provider: Provider.AWS } }),
createSamplePublicCloudProductData({ data: { ministry: Ministry.AEST, provider: Provider.AZURE } }),
Expand Down
2 changes: 1 addition & 1 deletion app/app/api/public-cloud/requests/[id]/decision/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const POST = apiHandler(async ({ pathParams, body, session }) => {
return OkResponse(updatedRequest);
}

const proms = [];
const proms: any[] = [];

proms.push(sendPublicCloudNatsMessage(updatedRequestDecorated));
proms.push(sendRequestApprovalEmails(updatedRequestDecorated));
Expand Down
2 changes: 1 addition & 1 deletion app/app/api/public-cloud/requests/search/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ describe('Search Public Cloud Requests - Validations', () => {
it('should successfully create products by admin', async () => {
await mockSessionByRole(GlobalRole.Admin);

const datasets = [];
const datasets: any[] = [];
datasets.push(
createSamplePublicCloudProductData({ data: { ministry: Ministry.AEST, provider: Provider.AWS } }),
createSamplePublicCloudProductData({ data: { ministry: Ministry.AEST, provider: Provider.AZURE } }),
Expand Down
2 changes: 1 addition & 1 deletion app/app/api/v1/private-cloud/products/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ describe('API: List Private Cloud Products - Validations', () => {
it('should successfully create products by admin', async () => {
await mockSessionByRole(GlobalRole.Admin);

const datasets = [];
const datasets: any[] = [];
datasets.push(
createSamplePrivateCloudProductData({ data: { ministry: Ministry.AEST, cluster: Cluster.CLAB } }),
createSamplePrivateCloudProductData({ data: { ministry: Ministry.AEST, cluster: Cluster.KLAB } }),
Expand Down
2 changes: 1 addition & 1 deletion app/app/api/v1/public-cloud/products/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ describe('API: List Public Cloud Products - Validations', () => {
it('should successfully create products by admin', async () => {
await mockSessionByRole(GlobalRole.Admin);

const datasets = [];
const datasets: any[] = [];
datasets.push(
createSamplePublicCloudProductData({ data: { ministry: Ministry.AEST, provider: Provider.AWS } }),
createSamplePublicCloudProductData({ data: { ministry: Ministry.AEST, provider: Provider.AZURE } }),
Expand Down
3 changes: 2 additions & 1 deletion app/app/team-api-accounts/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Table, Badge, Button } from '@mantine/core';
import { useQuery } from '@tanstack/react-query';
import _compact from 'lodash-es/compact';
import _get from 'lodash-es/get';
import { JSX, ReactNode } from 'react';
import { GlobalRole } from '@/constants';
import createClientPage from '@/core/client-page';
import { listKeycloakTeamApiAccounts } from '@/services/backend/keycloak';
Expand All @@ -30,7 +31,7 @@ export default TeamApiAccountsPage(({ session }) => {
return null;
}

let rows = null;
let rows: ReactNode = null;
if (!apiAccounts || apiAccounts.length === 0) {
const message = session?.isAdmin ? 'No team API accounts found.' : 'You are not assigned to any team API accounts.';

Expand Down
3 changes: 2 additions & 1 deletion app/components/billing/PublicCloudBillingInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { Alert, Button } from '@mantine/core';
import { IconInfoCircle } from '@tabler/icons-react';
import { useSession } from 'next-auth/react';
import { ReactNode } from 'react';
import { openPublicCloudMouReviewModal } from '@/components/modal/publicCloudMouReview';
import { openPublicCloudMouSignModal } from '@/components/modal/publicCloudMouSign';
import { formatFullName } from '@/helpers/user';
Expand All @@ -26,7 +27,7 @@ export default function PublicCloudBillingInfo({
const { data: session } = useSession();
const { licencePlate, billing } = product;

let content = null;
let content: ReactNode = null;
if (billing.approved) {
content = (
<>
Expand Down
4 changes: 2 additions & 2 deletions app/components/form/AccountCoding.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Alert } from '@mantine/core';
import { IconInfoCircle } from '@tabler/icons-react';
import { useQuery, useMutation } from '@tanstack/react-query';
import { useCallback, useEffect, useState } from 'react';
import { ReactNode, useCallback, useEffect, useState } from 'react';
import { useFormContext } from 'react-hook-form';
import AccountCodingInput from '@/components/form/AccountCodingInput';
import FormCheckbox from '@/components/generic/checkbox/FormCheckbox';
Expand Down Expand Up @@ -72,7 +72,7 @@ export default function AccountCoding({
}
}, [disabled, billing]);

let billingAlert = null;
let billingAlert: ReactNode = null;
if (!disabled) {
if (billing) {
if (billing.approved) {
Expand Down
7 changes: 4 additions & 3 deletions app/components/form/Budget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Alert } from '@mantine/core';
import { Provider } from '@prisma/client';
import { IconInfoCircle } from '@tabler/icons-react';
import _sumBy from 'lodash-es/sumBy';
import { ReactNode } from 'react';
import { useFormContext } from 'react-hook-form';
import ExternalLink from '@/components/generic/button/ExternalLink';
import { cn } from '@/utils/js';
Expand All @@ -18,7 +19,7 @@ export default function Budget({ disabled }: { disabled?: boolean }) {
const budget = watch('budget', {});
const environmentsEnabled = watch('environmentsEnabled', {});

const values = [];
const values: number[] = [];
if (environmentsEnabled.development) values.push(budget.dev);
if (environmentsEnabled.test) values.push(budget.test);
if (environmentsEnabled.production) values.push(budget.prod);
Expand All @@ -31,8 +32,8 @@ export default function Budget({ disabled }: { disabled?: boolean }) {

const formattedTotalBudget = parseFloat(totalBudget.toFixed(2));

let calculatorLink = null;
let calculatorNote = null;
let calculatorLink: ReactNode = null;
let calculatorNote: ReactNode = null;

switch (provider) {
case Provider.AWS:
Expand Down
4 changes: 2 additions & 2 deletions app/components/form/ProjectDescriptionPrivate.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useSession } from 'next-auth/react';
import { useState, useEffect } from 'react';
import { useState, useEffect, ReactNode } from 'react';
import { useFormContext } from 'react-hook-form';
import AGMinistryCheckBox from '@/components/form/AGMinistryCheckBox';
import GolddrCheckbox from '@/components/form/GolddrCheckbox';
Expand Down Expand Up @@ -42,7 +42,7 @@ export default function ProjectDescriptionPrivate({
}
}, [session, setClustersList]);

let temporaryProduct = null;
let temporaryProduct: ReactNode = null;
if (mode === 'create') {
temporaryProduct = (
<>
Expand Down
3 changes: 2 additions & 1 deletion app/components/form/TemporaryProductAlert.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Alert, Badge } from '@mantine/core';
import { IconArrowBack, IconInfoCircle, IconFile, IconExclamationCircle } from '@tabler/icons-react';
import { differenceInDays } from 'date-fns/differenceInDays';
import { ReactNode } from 'react';

export default function TemporaryProductAlert({
data,
Expand All @@ -11,7 +12,7 @@ export default function TemporaryProductAlert({
};
className?: string;
}) {
let label = null;
let label: ReactNode = null;
if (data?.createdAt) {
const diffInDays = 30 - differenceInDays(new Date(), new Date(data.createdAt));
label = (
Expand Down
3 changes: 2 additions & 1 deletion app/components/form/TemporaryProductBadge.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Tooltip, Badge } from '@mantine/core';
import { differenceInDays } from 'date-fns/differenceInDays';
import { ReactNode } from 'react';
import { cn } from '@/utils/js';

export default function TemporaryProductBadge({
Expand All @@ -11,7 +12,7 @@ export default function TemporaryProductBadge({
};
className?: string;
}) {
let label = null;
let label: ReactNode = null;
let color = 'gray';
if (data?.createdAt) {
const diffInDays = 30 - differenceInDays(new Date(), new Date(data.createdAt));
Expand Down
4 changes: 2 additions & 2 deletions app/components/generic/button/CopyableButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useClipboard } from '@mantine/hooks';
import { IconClipboardCopy } from '@tabler/icons-react';
import _isString from 'lodash-es/isString';
import _truncate from 'lodash-es/truncate';
import React from 'react';
import React, { ReactNode } from 'react';
import { cn } from '@/utils/js';

export default function CopyableButton({
Expand All @@ -23,7 +23,7 @@ export default function CopyableButton({
}) {
const clipboard = useClipboard({ timeout: 500 });

let content = null;
let content: ReactNode = null;
if (children) {
content = (
<div
Expand Down
3 changes: 2 additions & 1 deletion app/components/modal/publicCloudProductCreateSubmit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { zodResolver } from '@hookform/resolvers/zod';
import { Button, Divider, Grid, LoadingOverlay, Box, Alert } from '@mantine/core';
import { IconInfoCircle } from '@tabler/icons-react';
import { useQuery, useMutation } from '@tanstack/react-query';
import { ReactNode } from 'react';
import { FormProvider, useForm, FieldValues } from 'react-hook-form';
import { z } from 'zod';
import MailLink from '@/components/generic/button/MailLink';
Expand Down Expand Up @@ -96,7 +97,7 @@ export const openPublicCloudProductCreateSubmitModal = createModal<ModalProps, M
);
};

let eMouCheckboxContent = null;
let eMouCheckboxContent: ReactNode = null;
if (billing) {
if (billing.approved) {
eMouCheckboxContent = (
Expand Down
3 changes: 2 additions & 1 deletion app/components/private-cloud/sections/Quotas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Loader } from '@mantine/core';
import { Cluster, ResourceRequestsEnv, ResourceRequests } from '@prisma/client';
import { useQueries } from '@tanstack/react-query';
import _startCase from 'lodash-es/startCase';
import { ReactNode } from 'react';
import { useFormContext } from 'react-hook-form';
import ExternalLink from '@/components/generic/button/ExternalLink';
import HookFormTextInput from '@/components/generic/input/HookFormTextInput';
Expand Down Expand Up @@ -72,7 +73,7 @@ export default function Quotas({
originalVal?.memory !== newVal?.memory ||
originalVal?.storage !== newVal?.storage);

let subnetInfo = null;
let subnetInfo: ReactNode = null;
if (cluster === Cluster.EMERALD) {
if (subnetInformation[index].isLoading) {
subnetInfo = <Loader color="blue" type="dots" />;
Expand Down
3 changes: 2 additions & 1 deletion app/emails/_components/ClusterDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Heading, Text, Link, Hr } from '@react-email/components';
import { ReactNode } from 'react';
import { defaultResourceRequests } from '@/constants';
import { PrivateCloudProductDetail } from '@/types/private-cloud';

Expand All @@ -11,7 +12,7 @@ interface Props {
export default function ClusterDetails({ product, showNamespaceInfo = false, showDefaultResource = false }: Props) {
const { cluster, licencePlate } = product;

let defaultProvisionedResource = null;
let defaultProvisionedResource: ReactNode = null;
if (showDefaultResource) {
defaultProvisionedResource = (
<>
Expand Down
9 changes: 5 additions & 4 deletions app/emails/_components/private-cloud/Changes.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Heading, Link, Text, Hr } from '@react-email/components';
import { ReactNode } from 'react';
import ContactChanges from '@/emails/_components/ContactChanges';
import DescriptionChanges from '@/emails/_components/DescriptionChanges';
import MemberChanges from '@/emails/_components/MemberChanges';
Expand All @@ -11,10 +12,10 @@ export default function Changes({ request }: { request: PrivateCloudRequestDetai

const diffData = comparePrivateProductData(request.originalData, request.decisionData);

let profileChange = null;
let contactChange = null;
let membersChange = null;
let quotaChange = null;
let profileChange: ReactNode = null;
let contactChange: ReactNode = null;
let membersChange: ReactNode = null;
let quotaChange: ReactNode = null;

if (diffData.profileChanged) {
profileChange = (
Expand Down
9 changes: 5 additions & 4 deletions app/emails/_components/public-cloud/Changes.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Heading, Link, Text, Hr } from '@react-email/components';
import { ReactNode } from 'react';
import BudgetChanges from '@/emails/_components/BudgetChanges';
import ContactChanges from '@/emails/_components/ContactChanges';
import DescriptionChanges from '@/emails/_components/DescriptionChanges';
Expand All @@ -11,10 +12,10 @@ export default function Changes({ request }: { request: PublicCloudRequestDetail

const diffData = comparePublicProductData(request.originalData, request.decisionData);

let profileChange = null;
let contactChange = null;
let membersChange = null;
let billingChange = null;
let profileChange: ReactNode = null;
let contactChange: ReactNode = null;
let membersChange: ReactNode = null;
let billingChange: ReactNode = null;

if (diffData.profileChanged) {
profileChange = (
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/pdfs/emou/BillingMou.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function formatCurrency(value: number, { suffix = 'CAD' }: { suffix: 'CAD' | 'US
}

export default function BillingMou({ product, billing }: { product: Product; billing: Billing }) {
const values = [];
const values: number[] = [];
if (product.environmentsEnabled.development) values.push(product.budget.dev);
if (product.environmentsEnabled.test) values.push(product.budget.test);
if (product.environmentsEnabled.production) values.push(product.budget.prod);
Expand Down
Loading

0 comments on commit f30f16b

Please sign in to comment.