diff --git a/apps/api/package.json b/apps/api/package.json index e55caa84..3699a6b3 100644 --- a/apps/api/package.json +++ b/apps/api/package.json @@ -22,6 +22,7 @@ "unit": "pnpm db:generate-types && jest --config=jest.config.ts" }, "dependencies": { + "@keyshade/schema": "workspace:*", "@nestjs/common": "^10.0.0", "@nestjs/config": "^3.2.0", "@nestjs/core": "^10.0.0", @@ -34,18 +35,22 @@ "@nestjs/swagger": "^7.3.0", "@nestjs/throttler": "^6.2.1", "@nestjs/websockets": "^10.3.7", - "@slack/bolt": "^3.22.0", "@react-email/components": "^0.0.25", "@react-email/preview": "0.0.11", + "@slack/bolt": "^3.22.0", "@react-email/render": "^1.0.1", "@socket.io/redis-adapter": "^8.3.0", + "@sentry/node": "^7.102.0", + "@sentry/profiling-node": "^7.102.0", "@supabase/supabase-js": "^2.39.6", + "chalk": "^4.1.2", "class-transformer": "^0.5.1", "class-validator": "^0.14.1", "cookie-parser": "^1.4.6", "dayjs": "^1.11.11", "eccrypto": "^1.1.6", "minio": "^8.0.0", + "moment": "^2.30.1", "nodemailer": "^6.9.9", "passport-github2": "^0.1.12", "passport-gitlab2": "^5.0.0", @@ -54,9 +59,11 @@ "redis": "^4.6.13", "rxjs": "^7.8.1", "socket.io": "^4.7.5", - "uuid": "^9.0.1" + "uuid": "^9.0.1", + "zod": "^3.23.6" }, "devDependencies": { + "@types/jest": "^29.5.2", "@nestjs/cli": "^10.0.0", "@nestjs/schematics": "^10.0.0", "@nestjs/testing": "^10.0.0", @@ -69,8 +76,10 @@ "@types/supertest": "^6.0.0", "@types/uuid": "^9.0.8", "ajv": "^7", + "cross-env": "^7.0.3", "dotenv-cli": "^7.4.2", "file-loader": "^6.2.0", + "husky": "^9.0.11", "jest": "^29.5.0", "jest-mock-extended": "^3.0.5", "prettier": "^3.0.0", diff --git a/apps/api/tsconfig.app.json b/apps/api/tsconfig.app.json index ea9978a1..c5a9ae49 100644 --- a/apps/api/tsconfig.app.json +++ b/apps/api/tsconfig.app.json @@ -1,5 +1,5 @@ { - "extends": "./tsconfig.json", + "extends": "tsconfig.json", "compilerOptions": { "outDir": "dist/out-tsc", "module": "ES2022", diff --git a/apps/cli/package.json b/apps/cli/package.json index dedcaf43..25775537 100644 --- a/apps/cli/package.json +++ b/apps/cli/package.json @@ -14,7 +14,7 @@ }, "type": "module", "scripts": { - "build": "esbuild src/index.ts --bundle --platform=node --outfile=dist/index.esm.js --format=esm --banner:js='#!/usr/bin/env node' && esbuild src/index.ts --bundle --platform=node --outfile=dist/index.cjs --format=cjs --banner:js='#!/usr/bin/env node'", + "build": "esbuild src/index.ts --bundle --platform=node --outfile=dist/index.cjs --format=cjs --banner:js=\"#!/usr/bin/env node\" && esbuild src/index.ts --bundle --platform=node --outfile=dist/index.esm.js --format=esm --banner:js=\"#!/usr/bin/env node\"", "start": "node dist/index.cjs", "dev": "pnpm build && node dist/index.cjs", "lint": "eslint \"src/**/*.ts\" --fix", @@ -26,6 +26,8 @@ "dependencies": { "@clack/core": "^0.3.4", "@clack/prompts": "^0.7.0", + "@keyshade/api-client": "workspace:*", + "@keyshade/secret-scan": "workspace:*", "chalk": "^4.1.2", "cli-table": "^0.3.11", "colors": "^1.4.0", diff --git a/apps/platform/package.json b/apps/platform/package.json index afbc6356..6c66367f 100644 --- a/apps/platform/package.json +++ b/apps/platform/package.json @@ -9,6 +9,7 @@ "lint": "eslint \"src/**/*.ts\" --fix --config .eslintrc.cjs" }, "dependencies": { + "@keyshade/schema": "workspace:*", "@radix-ui/react-accordion": "^1.2.0", "@radix-ui/react-alert-dialog": "^1.1.4", "@radix-ui/react-avatar": "^1.0.4", diff --git a/apps/platform/src/app/(main)/page.tsx b/apps/platform/src/app/(main)/page.tsx index d475f405..b20c6fad 100644 --- a/apps/platform/src/app/(main)/page.tsx +++ b/apps/platform/src/app/(main)/page.tsx @@ -1,80 +1,30 @@ 'use client' -import { useCallback, useEffect, useMemo, useState } from 'react' -import type { - CreateProjectRequest, - GetAllProjectsResponse, - ProjectWithCount, - Workspace -} from '@keyshade/schema' -import { AddSVG } from '@public/svg/shared' +import { useEffect, useMemo, useState } from 'react' +import type { GetAllProjectsResponse } from '@keyshade/schema' import { FolderSVG } from '@public/svg/dashboard' -import ProjectCard from '@/components/dashboard/projectCard' -import { - Sheet, - SheetClose, - SheetContent, - SheetDescription, - SheetFooter, - SheetHeader, - SheetTitle -} from '@/components/ui/sheet' -import { Button } from '@/components/ui/button' -import { Label } from '@/components/ui/label' -import { Input } from '@/components/ui/input' -import { - Select, - SelectContent, - SelectGroup, - SelectItem, - SelectTrigger, - SelectValue -} from '@/components/ui/select' -import { Switch } from '@/components/ui/switch' -import { - Dialog, - DialogContent, - DialogDescription, - DialogHeader, - DialogTrigger -} from '@/components/ui/dialog' +import { toast } from 'sonner' +import { useAtom, useAtomValue, useSetAtom } from 'jotai' +import ProjectCard from '@/components/dashboard/project/projectCard' import ControllerInstance from '@/lib/controller-instance' -import { Textarea } from '@/components/ui/textarea' import ProjectScreenLoader from '@/components/ui/project-screen-loader' +import CreateProjectDialogue from '@/components/dashboard/project/createProjectDialogue' +import { + createProjectDialogOpenAtom, + currentWorkspaceAtom, + projectsOfWorkspaceAtom +} from '@/store' +import EditProjectSheet from '@/components/dashboard/project/editProjectSheet' +import { Button } from '@/components/ui/button' export default function Index(): JSX.Element { - const [isSheetOpen, setIsSheetOpen] = useState(false) - const [isProjectEmpty, setIsProjectEmpty] = useState(true) - const [isDialogOpen, setIsDialogOpen] = useState(false) const [loading, setLoading] = useState(false) - // Projects to be displayed in the dashboard - const [projects, setProjects] = useState([]) + const setIsCreateProjectDialogOpen = useSetAtom(createProjectDialogOpenAtom) + const currentWorkspace = useAtomValue(currentWorkspaceAtom) - // Contains the data for the new project - const [newProjectData, setNewProjectData] = useState({ - name: '', - workspaceSlug: '', - description: '', - storePrivateKey: false, - environments: [ - { - name: '', - description: '' - } - ], - accessLevel: 'GLOBAL' - }) - - // Fetches the currently selected workspace from context - const currentWorkspace: Workspace | null = useMemo( - () => - typeof localStorage !== 'undefined' - ? (JSON.parse( - localStorage.getItem('currentWorkspace') ?? '{}' - ) as Workspace) - : null, - [] - ) + // Projects to be displayed in the dashboard + const [projects, setProjects] = useAtom(projectsOfWorkspaceAtom) + const isProjectsEmpty = useMemo(() => projects.length === 0, [projects]) // If a workspace is selected, we want to fetch all the projects // under that workspace and display it in the dashboard. @@ -92,6 +42,9 @@ export default function Index(): JSX.Element { if (success && data) { setProjects(data.items) } else { + toast.error( + 'Something went wrong while fetching projects. Check console for more info.' + ) // eslint-disable-next-line no-console -- we need to log the error console.error(error) } @@ -101,248 +54,23 @@ export default function Index(): JSX.Element { } getAllProjects() - }, [currentWorkspace]) - - // Check if the projects array is empty - useEffect(() => setIsProjectEmpty(projects.length === 0), [projects]) - - // Function to create a new project - const createNewProject = useCallback(async () => { - if (currentWorkspace) { - newProjectData.workspaceSlug = currentWorkspace.slug - - const { data, error, success } = - await ControllerInstance.getInstance().projectController.createProject( - newProjectData, - {} - ) - - if (success && data) { - setProjects([ - ...projects, - { - ...data, - environmentCount: newProjectData.environments - ? newProjectData.environments.length - : 0, - secretCount: 0, - variableCount: 0 - } - ]) - } else { - // eslint-disable-next-line no-console -- we need to log the error - console.error(error) - } - - setIsDialogOpen(false) - } else { - throw new Error('No workspace selected') - } - }, [currentWorkspace, newProjectData, projects]) - - const toggleDialog = useCallback(() => setIsDialogOpen((prev) => !prev), []) + }, [currentWorkspace, setProjects]) return (
- {!isProjectEmpty && ( + {!isProjectsEmpty && (

My Projects

)} - - - - {isProjectEmpty ? null : ( - - )} - - -
- - Create Projects - - - - Create your new project - -
-
-
- {/* NAME */} -
- - { - setNewProjectData((prev) => ({ - ...prev, - name: e.target.value - })) - }} - placeholder="Enter the name" - /> -
- - {/* DESCRIPTION */} -
- -