-
-
Notifications
You must be signed in to change notification settings - Fork 115
/
t updateSelf = useCallback(async () => {
664 lines (664 loc) · 27.7 KB
/
t updateSelf = useCallback(async () => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
[1mdiff --git a/apps/platform/.eslintrc.cjs b/apps/platform/.eslintrc.cjs[m
[1mindex 28a8b27..fa9233a 100644[m
[1m--- a/apps/platform/.eslintrc.cjs[m
[1m+++ b/apps/platform/.eslintrc.cjs[m
[36m@@ -7,24 +7,13 @@[m [mmodule.exports = {[m
},[m
rules: {[m
'import/no-extraneous-dependencies': 0,[m
[31m- '@typescript-eslint/interface-name-prefix': 'off',[m
'@typescript-eslint/explicit-function-return-type': 'off',[m
'@typescript-eslint/explicit-module-boundary-types': 'off',[m
[31m- '@typescript-eslint/no-explicit-any': 'off',[m
'@typescript-eslint/no-unused-vars': ['warn'],[m
[31m- '@typescript-eslint/no-unsafe-call': 'off',[m
[31m- '@typescript-eslint/no-unsafe-return': 'off',[m
'@typescript-eslint/space-before-function-paren': 'off',[m
'@typescript-eslint/strict-boolean-expressions': 'off',[m
[31m- '@typescript-eslint/prefer-nullish-coalescing': 'off',[m
[31m- 'space-before-function-paren': 'off',[m
[31m- '@typescript-eslint/member-delimiter-style': 'off',[m
'@typescript-eslint/no-confusing-void-expression': 'off',[m
'@typescript-eslint/no-floating-promises': 'off',[m
[31m- '@typescript-eslint/no-misused-promises': 'off',[m
[31m- '@typescript-eslint/no-unsafe-assignment': 'off',[m
[31m- '@typescript-eslint/no-unsafe-member-access': 'off',[m
[31m- '@typescript-eslint/no-unsafe-argument': 'off',[m
[31m- '@typescript-eslint/no-unnecessary-condition': 'off'[m
[32m+[m[32m '@typescript-eslint/no-misused-promises': 'off'[m
}[m
}[m
[1mdiff --git a/apps/platform/src/app/(main)/page.tsx b/apps/platform/src/app/(main)/page.tsx[m
[1mindex fe8fa2a..9a9cb2a 100644[m
[1m--- a/apps/platform/src/app/(main)/page.tsx[m
[1m+++ b/apps/platform/src/app/(main)/page.tsx[m
[36m@@ -6,7 +6,6 @@[m [mimport type {[m
ProjectWithCount,[m
Workspace[m
} from '@keyshade/schema'[m
[31m-import { ProjectController } from '@keyshade/api-client'[m
import { AddSVG } from '@public/svg/shared'[m
import { FolderSVG } from '@public/svg/dashboard'[m
import ProjectCard from '@/components/dashboard/projectCard'[m
[36m@@ -38,6 +37,7 @@[m [mimport {[m
DialogHeader,[m
DialogTrigger[m
} from '@/components/ui/dialog'[m
[32m+[m[32mimport ControllerInstance from '@/lib/controller-instance'[m
[m
export default function Index(): JSX.Element {[m
const [isSheetOpen, setIsSheetOpen] = useState<boolean>(false)[m
[36m@@ -76,16 +76,13 @@[m [mexport default function Index(): JSX.Element {[m
// If a workspace is selected, we want to fetch all the projects[m
// under that workspace and display it in the dashboard.[m
useEffect(() => {[m
[31m- const projectController = new ProjectController([m
[31m- process.env.NEXT_PUBLIC_BACKEND_URL[m
[31m- )[m
[31m-[m
async function getAllProjects() {[m
if (currentWorkspace) {[m
[31m- const { success, error, data } = await projectController.getAllProjects([m
[31m- { workspaceSlug: currentWorkspace.slug },[m
[31m- {}[m
[31m- )[m
[32m+[m[32m const { success, error, data } =[m
[32m+[m[32m await ControllerInstance.getInstance().projectController.getAllProjects([m
[32m+[m[32m { workspaceSlug: currentWorkspace.slug },[m
[32m+[m[32m {}[m
[32m+[m[32m )[m
[m
if (success && data) {[m
setProjects(data.items)[m
[36m@@ -105,16 +102,13 @@[m [mexport default function Index(): JSX.Element {[m
// Function to create a new project[m
const createNewProject = useCallback(async () => {[m
if (currentWorkspace) {[m
[31m- const projectController = new ProjectController([m
[31m- process.env.NEXT_PUBLIC_BACKEND_URL[m
[31m- )[m
[31m-[m
newProjectData.workspaceSlug = currentWorkspace.slug[m
[m
[31m- const { data, error, success } = await projectController.createProject([m
[31m- newProjectData,[m
[31m- {}[m
[31m- )[m
[32m+[m[32m const { data, error, success } =[m
[32m+[m[32m await ControllerInstance.getInstance().projectController.createProject([m
[32m+[m[32m newProjectData,[m
[32m+[m[32m {}[m
[32m+[m[32m )[m
[m
if (success && data) {[m
setProjects([[m
[1mdiff --git a/apps/platform/src/app/(main)/project/[project]/@secret/page.tsx b/apps/platform/src/app/(main)/project/[project]/@secret/page.tsx[m
[1mindex 18134ab..e1bd8e6 100644[m
[1m--- a/apps/platform/src/app/(main)/project/[project]/@secret/page.tsx[m
[1m+++ b/apps/platform/src/app/(main)/project/[project]/@secret/page.tsx[m
[36m@@ -5,6 +5,7 @@[m [mimport { usePathname } from 'next/navigation'[m
import dayjs, { extend } from 'dayjs'[m
import relativeTime from 'dayjs/plugin/relativeTime'[m
import { NoteIconSVG } from '@public/svg/secret'[m
[32m+[m[32mimport type { GetAllSecretsOfProjectResponse } from '@keyshade/schema'[m
import {[m
Accordion,[m
AccordionContent,[m
[36m@@ -19,8 +20,6 @@[m [mimport {[m
TableHeader,[m
TableRow[m
} from '@/components/ui/table'[m
[31m-import type { Secret } from '@keyshade/schema'[m
[31m-import { SecretController } from '@keyshade/api-client'[m
import { ScrollArea } from '@/components/ui/scroll-area'[m
import {[m
Tooltip,[m
[36m@@ -29,31 +28,28 @@[m [mimport {[m
TooltipTrigger[m
} from '@/components/ui/tooltip'[m
import { Skeleton } from '@/components/ui/skeleton'[m
[32m+[m[32mimport ControllerInstance from '@/lib/controller-instance'[m
[m
extend(relativeTime)[m
[m
function SecretPage(): React.JSX.Element {[m
[31m- const [allSecrets, setAllSecrets] = useState<Secret[]>()[m
[32m+[m[32m const [allSecrets, setAllSecrets] =[m
[32m+[m[32m useState<GetAllSecretsOfProjectResponse['items']>()[m
const [isLoading, setIsLoading] = useState<boolean>(true)[m
const pathname = usePathname()[m
[m
useEffect(() => {[m
setIsLoading(true)[m
[m
[31m- const secretController = new SecretController([m
[31m- process.env.NEXT_PUBLIC_BACKEND_URL[m
[31m- )[m
[31m-[m
async function getAllSecretsByProjectSlug() {[m
const { success, error, data } =[m
[31m- await secretController.getAllSecretsOfProject([m
[32m+[m[32m await ControllerInstance.getInstance().secretController.getAllSecretsOfProject([m
{ projectSlug: pathname.split('/')[2] },[m
{}[m
)[m
[m
if (success && data) {[m
[31m- //@ts-ignore[m
[31m- setAllSecrets(data)[m
[32m+[m[32m setAllSecrets(data.items)[m
} else {[m
// eslint-disable-next-line no-console -- we need to log the error[m
console.error(error)[m
[36m@@ -68,9 +64,9 @@[m [mfunction SecretPage(): React.JSX.Element {[m
if (isLoading) {[m
return ([m
<div className="space-y-4">[m
[31m- <SerectLoader />[m
[31m- <SerectLoader />[m
[31m- <SerectLoader />[m
[32m+[m[32m <SecretLoader />[m
[32m+[m[32m <SecretLoader />[m
[32m+[m[32m <SecretLoader />[m
</div>[m
)[m
}[m
[36m@@ -82,7 +78,7 @@[m [mfunction SecretPage(): React.JSX.Element {[m
collapsible[m
type="single"[m
>[m
[31m- {allSecrets?.map((secret) => {[m
[32m+[m[32m {allSecrets?.map(({ secret, values }) => {[m
return ([m
<AccordionItem[m
className="rounded-xl bg-white/5 px-5"[m
[36m@@ -126,7 +122,7 @@[m [mfunction SecretPage(): React.JSX.Element {[m
</TableRow>[m
</TableHeader>[m
<TableBody>[m
[31m- {secret.versions.map((value) => {[m
[32m+[m[32m {values.map((value) => {[m
return ([m
<TableRow key={value.environment.id}>[m
<TableCell>{value.environment.slug}</TableCell>[m
[36m@@ -147,7 +143,7 @@[m [mfunction SecretPage(): React.JSX.Element {[m
)[m
}[m
[m
[31m-function SerectLoader(): React.JSX.Element {[m
[32m+[m[32mfunction SecretLoader(): React.JSX.Element {[m
return ([m
<div className=" rounded-xl bg-white/5 p-4">[m
<div className="flex justify-between">[m
[1mdiff --git a/apps/platform/src/app/(main)/project/[project]/layout.tsx b/apps/platform/src/app/(main)/project/[project]/layout.tsx[m
[1mindex 1eb511b..9edfb0b 100644[m
[1m--- a/apps/platform/src/app/(main)/project/[project]/layout.tsx[m
[1m+++ b/apps/platform/src/app/(main)/project/[project]/layout.tsx[m
[36m@@ -2,6 +2,7 @@[m
import { useEffect, useState } from 'react'[m
import { useSearchParams } from 'next/navigation'[m
import { AddSVG } from '@public/svg/shared'[m
[32m+[m[32mimport type { Project } from '@keyshade/schema'[m
import { Button } from '@/components/ui/button'[m
import {[m
Dialog,[m
[36m@@ -13,8 +14,7 @@[m [mimport {[m
} from '@/components/ui/dialog'[m
import { Input } from '@/components/ui/input'[m
import { Label } from '@/components/ui/label'[m
[31m-import { ProjectController } from '@keyshade/api-client'[m
[31m-import type { Project } from '@keyshade/schema'[m
[32m+[m[32mimport ControllerInstance from '@/lib/controller-instance'[m
[m
interface DetailedProjectPageProps {[m
params: { project: string }[m
[36m@@ -38,29 +38,22 @@[m [mfunction DetailedProjectPage({[m
const tab = searchParams.get('tab') ?? 'rollup-details'[m
[m
useEffect(() => {[m
[32m+[m[32m async function getProjectBySlug() {[m
[32m+[m[32m const { success, error, data } =[m
[32m+[m[32m await ControllerInstance.getInstance().projectController.getProject([m
[32m+[m[32m { projectSlug: params.project },[m
[32m+[m[32m {}[m
[32m+[m[32m )[m
[m
[31m- const projectController = new ProjectController([m
[31m- process.env.NEXT_PUBLIC_BACKEND_URL[m
[31m- )[m
[31m-[m
[31m- async function getProjectBySlug(){[m
[31m- const {success, error, data} = await projectController.getProject([m
[31m- {projectSlug: params.project},[m
[31m- {}[m
[31m- )[m
[31m-[m
[31m- if( success && data ){[m
[31m- //@ts-ignore[m
[32m+[m[32m if (success && data) {[m
setCurrentProject(data)[m
[31m- }[m
[31m- else{[m
[32m+[m[32m } else {[m
// eslint-disable-next-line no-console -- we need to log the error[m
console.error(error)[m
}[m
}[m
[m
getProjectBySlug()[m
[31m-[m
}, [params.project])[m
[m
return ([m
[1mdiff --git a/apps/platform/src/app/(main)/settings/@profile/page.tsx b/apps/platform/src/app/(main)/settings/@profile/page.tsx[m
[1mindex 21de60b..4559ec6 100644[m
[1m--- a/apps/platform/src/app/(main)/settings/@profile/page.tsx[m
[1m+++ b/apps/platform/src/app/(main)/settings/@profile/page.tsx[m
[36m@@ -1,54 +1,52 @@[m
'use client'[m
[31m-import React, { useEffect, useState } from 'react'[m
[32m+[m[32mimport React, { useCallback, useEffect, useState } from 'react'[m
import { toast } from 'sonner'[m
[31m-import type { User } from '@keyshade/schema'[m
import InputLoading from './loading'[m
import { Input } from '@/components/ui/input'[m
import { Separator } from '@/components/ui/separator'[m
[32m+[m[32mimport ControllerInstance from '@/lib/controller-instance'[m
import { Button } from '@/components/ui/button'[m
[31m-import { apiClient } from '@/lib/api-client'[m
[31m-[m
[31m-type UserData = Omit<[m
[31m- User,[m
[31m- 'id' | 'isActive' | 'isOnboardingFinished' | 'isAdmin' | 'authProvider'[m
[31m->[m
[31m-async function getUserDetails(): Promise<User | undefined> {[m
[31m- try {[m
[31m- return await apiClient.get<User>('/user')[m
[31m- } catch (error) {[m
[31m- // eslint-disable-next-line no-console -- we need to log the error[m
[31m- console.error(error)[m
[31m- }[m
[31m-}[m
[31m-[m
[31m-async function updateUserDetails(userData: UserData): Promise<void> {[m
[31m- try {[m
[31m- await apiClient.put<User>('/user', userData)[m
[31m- } catch (error) {[m
[31m- // eslint-disable-next-line no-console -- we need to log the error[m
[31m- console.error(error)[m
[31m- }[m
[31m-}[m
[m
function ProfilePage(): React.JSX.Element {[m
const [isLoading, setIsLoading] = useState<boolean>(true)[m
[31m- const [userData, setUserData] = useState<UserData>({[m
[32m+[m[32m const [userData, setUserData] = useState({[m
email: '',[m
name: '',[m
profilePictureUrl: ''[m
})[m
const [isModified, setIsModified] = useState<boolean>(false)[m
[m
[32m+[m[32m const updateSelf = useCallback(async () => {[m
[32m+[m[32m try {[m
[32m+[m[32m await ControllerInstance.getInstance().userController.updateSelf([m
[32m+[m[32m {[m
[32m+[m[32m name: userData.name,[m
[32m+[m[32m email: userData.email[m
[32m+[m[32m },[m
[32m+[m[32m {}[m
[32m+[m[32m )[m
[32m+[m[32m toast.success('Profile updated successfully')[m
[32m+[m[32m } catch (error) {[m
[32m+[m[32m // eslint-disable-next-line no-console -- we need to log the error[m
[32m+[m[32m console.error(error)[m
[32m+[m[32m }[m
[32m+[m[32m setIsModified(false)[m
[32m+[m[32m }, [userData])[m
[32m+[m
useEffect(() => {[m
[31m- getUserDetails()[m
[31m- .then((data) => {[m
[31m- if (data) {[m
[32m+[m[32m ControllerInstance.getInstance()[m
[32m+[m[32m .userController.getSelf()[m
[32m+[m[32m .then(({ data, success, error }) => {[m
[32m+[m[32m if (success && data) {[m
setUserData({[m
email: data.email,[m
[31m- name: data.name ?? '',[m
[31m- profilePictureUrl: data.profilePictureUrl[m
[32m+[m[32m name: data.name,[m
[32m+[m[32m profilePictureUrl: data.profilePictureUrl || ''[m
})[m
setIsLoading(false)[m
[32m+[m[32m } else {[m
[32m+[m[32m // eslint-disable-next-line no-console -- we need to log the error[m
[32m+[m[32m console.error(error)[m
}[m
})[m
.catch((error) => {[m
[36m@@ -67,7 +65,7 @@[m [mfunction ProfilePage(): React.JSX.Element {[m
Upload a picture to change your avatar across Keyshade.[m
</span>[m
</div>[m
[31m- <div className="aspect-square w-[5rem] rounded-full bg-gray-600" />{' '}[m
[32m+[m[32m <div className="aspect-square w-[5rem] rounded-full bg-gray-600" />[m
{/* //! This is will be replaced by an image tag */}[m
</div>[m
{/* Name */}[m
[36m@@ -114,20 +112,7 @@[m [mfunction ProfilePage(): React.JSX.Element {[m
)}[m
</div>[m
<div>[m
[31m- <Button[m
[31m- disabled={!isModified}[m
[31m- onClick={() => {[m
[31m- updateUserDetails(userData)[m
[31m- .then(() => {[m
[31m- toast.success('User details updated successfully')[m
[31m- })[m
[31m- .catch(() => {[m
[31m- toast.error('Failed to update user details')[m
[31m- })[m
[31m- setIsModified(false)[m
[31m- }}[m
[31m- variant="secondary"[m
[31m- >[m
[32m+[m[32m <Button disabled={!isModified} onClick={updateSelf} variant="secondary">[m
Save Changes[m
</Button>[m
</div>[m
[1mdiff --git a/apps/platform/src/components/shared/sidebar/index.tsx b/apps/platform/src/components/shared/sidebar/index.tsx[m
[1mindex ee7cd9b..7da768b 100644[m
[1m--- a/apps/platform/src/components/shared/sidebar/index.tsx[m
[1m+++ b/apps/platform/src/components/shared/sidebar/index.tsx[m
[36m@@ -6,8 +6,8 @@[m [mimport {[m
SettingsSVG,[m
TeamSVG[m
} from '@public/svg/shared'[m
[31m-import { Combobox } from '@/components/ui/combobox'[m
import SidebarTab from './sidebarTab'[m
[32m+[m[32mimport { Combobox } from '@/components/ui/combobox'[m
[m
function Sidebar(): JSX.Element {[m
const sidebarTabData = [[m
[1mdiff --git a/apps/platform/src/components/ui/combobox.tsx b/apps/platform/src/components/ui/combobox.tsx[m
[1mindex b3107dc..8414098 100644[m
[1m--- a/apps/platform/src/components/ui/combobox.tsx[m
[1m+++ b/apps/platform/src/components/ui/combobox.tsx[m
[36m@@ -5,27 +5,6 @@[m [mimport { useEffect, useState } from 'react'[m
import { useRouter } from 'next/navigation'[m
import { toast } from 'sonner'[m
import { AddSVG } from '@public/svg/shared'[m
[31m-import { cn } from '@/lib/utils'[m
[31m-import {[m
[31m- Command,[m
[31m- CommandEmpty,[m
[31m- CommandInput,[m
[31m- CommandItem,[m
[31m- CommandList[m
[31m-} from '@/components/ui/command'[m
[31m-import {[m
[31m- Popover,[m
[31m- PopoverContent,[m
[31m- PopoverTrigger[m
[31m-} from '@/components/ui/popover'[m
[31m-import { apiClient } from '@/lib/api-client'[m
[31m-// import type { Workspace } from '@/types'[m
[31m-import { zWorkspace } from '@/types'[m
[31m-import {[m
[31m- getCurrentWorkspace,[m
[31m- setCurrentWorkspace,[m
[31m- setWorkspace[m
[31m-} from '@/lib/workspace-storage'[m
import type { Workspace } from '@keyshade/schema'[m
import { Input } from './input'[m
import { Label } from './label'[m
[36m@@ -38,39 +17,43 @@[m [mimport {[m
DialogTrigger[m
} from './dialog'[m
import { Button } from './button'[m
[31m-import { WorkspaceSchema } from '@keyshade/schema/schemas'[m
[31m-[m
[31m-interface WorkspaceResponse {[m
[31m- items: Workspace[][m
[31m- metadata: {[m
[31m- page: number[m
[31m- perPage: number[m
[31m- pageCount: number[m
[31m- totalCount: number[m
[31m- links: {[m
[31m- self: string[m
[31m- first: string[m
[31m- previous: string | null[m
[31m- next: string | null[m
[31m- last: string[m
[31m- }[m
[31m- }[m
[31m-}[m
[32m+[m[32mimport {[m
[32m+[m[32m getCurrentWorkspace,[m
[32m+[m[32m setCurrentWorkspace,[m
[32m+[m[32m setWorkspace[m
[32m+[m[32m} from '@/lib/workspace-storage'[m
[32m+[m[32mimport { cn } from '@/lib/utils'[m
[32m+[m[32mimport {[m
[32m+[m[32m Popover,[m
[32m+[m[32m PopoverContent,[m
[32m+[m[32m PopoverTrigger[m
[32m+[m[32m} from '@/components/ui/popover'[m
[32m+[m[32mimport {[m
[32m+[m[32m Command,[m
[32m+[m[32m CommandEmpty,[m
[32m+[m[32m CommandInput,[m
[32m+[m[32m CommandItem,[m
[32m+[m[32m CommandList[m
[32m+[m[32m} from '@/components/ui/command'[m
[32m+[m[32mimport ControllerInstance from '@/lib/controller-instance'[m
[m
async function getAllWorkspace(): Promise<Workspace[] | undefined> {[m
try {[m
[31m- const workspaceData: WorkspaceResponse =[m
[31m- await apiClient.get<WorkspaceResponse>('/workspace')[m
[32m+[m[32m const { data, success, error } =[m
[32m+[m[32m await ControllerInstance.getInstance().workspaceController.getWorkspacesOfUser([m
[32m+[m[32m {},[m
[32m+[m[32m {}[m
[32m+[m[32m )[m
[m
[31m- // TODO: We are getting error here from the success flag, need to see this again[m
[31m- // const { success, data } = WorkspaceSchema.array().safeParse(workspaceData.items)[m
[31m- // if (!success) {[m
[31m- // throw new Error('Invalid data')[m
[31m- // }[m
[32m+[m[32m if (error) {[m
[32m+[m[32m // eslint-disable-next-line no-console -- we need to log the error[m
[32m+[m[32m console.error(error)[m
[32m+[m[32m return undefined[m
[32m+[m[32m }[m
[m
[31m- return workspaceData.items[m
[31m- // return data[m
[31m- // return workspaceData;[m
[32m+[m[32m if (success && data) {[m
[32m+[m[32m return data.items[m
[32m+[m[32m }[m
} catch (error) {[m
// eslint-disable-next-line no-console -- we need to log the error[m
console.error(error)[m
[36m@@ -92,9 +75,13 @@[m [mexport function Combobox(): React.JSX.Element {[m
}[m
setIsNameEmpty(false)[m
try {[m
[31m- const response = await apiClient.post<Workspace>('/workspace', {[m
[31m- name[m
[31m- })[m
[32m+[m[32m const response =[m
[32m+[m[32m await ControllerInstance.getInstance().workspaceController.createWorkspace([m
[32m+[m[32m {[m
[32m+[m[32m name[m
[32m+[m[32m },[m
[32m+[m[32m {}[m
[32m+[m[32m )[m
setCurrentWorkspace(response)[m
setOpen(false)[m
} catch (error) {[m
[1mdiff --git a/apps/platform/src/lib/controller-instance.ts b/apps/platform/src/lib/controller-instance.ts[m
[1mindex fe432b7..a766038 100644[m
[1m--- a/apps/platform/src/lib/controller-instance.ts[m
[1m+++ b/apps/platform/src/lib/controller-instance.ts[m
[36m@@ -1,30 +1,90 @@[m
[31m-import { AuthController } from '@keyshade/api-client'[m
[32m+[m[32mimport {[m
[32m+[m[32m AuthController,[m
[32m+[m[32m EnvironmentController,[m
[32m+[m[32m ProjectController,[m
[32m+[m[32m SecretController,[m
[32m+[m[32m UserController,[m
[32m+[m[32m VariableController,[m
[32m+[m[32m WorkspaceController,[m
[32m+[m[32m WorkspaceMembershipController,[m
[32m+[m[32m WorkspaceRoleController[m
[32m+[m[32m} from '@keyshade/api-client'[m
[m
export default class ControllerInstance {[m
private static instance: ControllerInstance | null[m
[m
[31m- private _authController: AuthController | null = null[m
[32m+[m[32m private _authController: AuthController[m
[32m+[m[32m private _userController: UserController[m
[32m+[m[32m private _workspaceController: WorkspaceController[m
[32m+[m[32m private _workspaceMembershipController: WorkspaceMembershipController[m
[32m+[m[32m private _workspaceRoleController: WorkspaceRoleController[m
[32m+[m[32m private _projectController: ProjectController[m
[32m+[m[32m private _environmentController: EnvironmentController[m
[32m+[m[32m private _secretController: SecretController[m
[32m+[m[32m private _variableController: VariableController[m
[m
get authController(): AuthController {[m
[31m- if (!this._authController) {[m
[31m- throw new Error('ControllerInstance not initialized')[m
[31m- }[m
return this._authController[m
}[m
[m
[31m- static initialize(baseUrl: string): void {[m
[31m- if (!ControllerInstance.instance) {[m
[31m- const instance = new ControllerInstance()[m
[32m+[m[32m get workspaceController(): WorkspaceController {[m
[32m+[m[32m return this._workspaceController[m
[32m+[m[32m }[m
[32m+[m
[32m+[m[32m get workspaceMembershipController(): WorkspaceMembershipController {[m
[32m+[m[32m return this._workspaceMembershipController[m
[32m+[m[32m }[m
[m
[31m- instance._authController = new AuthController(baseUrl)[m
[32m+[m[32m get workspaceRoleController(): WorkspaceRoleController {[m
[32m+[m[32m return this._workspaceRoleController[m
[32m+[m[32m }[m
[m
[31m- ControllerInstance.instance = instance[m
[31m- }[m
[32m+[m[32m get projectController(): ProjectController {[m
[32m+[m[32m return this._projectController[m
[32m+[m[32m }[m
[32m+[m
[32m+[m[32m get environmentController(): EnvironmentController {[m
[32m+[m[32m return this._environmentController[m
[32m+[m[32m }[m
[32m+[m
[32m+[m[32m get secretController(): SecretController {[m
[32m+[m[32m return this._secretController[m
[32m+[m[32m }[m
[32m+[m
[32m+[m[32m get variableController(): VariableController {[m
[32m+[m[32m return this._variableController[m
[32m+[m[32m }[m
[32m+[m
[32m+[m[32m get userController(): UserController {[m
[32m+[m[32m return this._userController[m
}[m
[m
static getInstance(): ControllerInstance {[m
if (!ControllerInstance.instance) {[m
[31m- throw new Error('ControllerInstance not initialized')[m
[32m+[m[32m ControllerInstance.instance = new ControllerInstance()[m
[32m+[m[32m ControllerInstance.instance._authController = new AuthController([m
[32m+[m[32m process.env.NEXT_PUBLIC_BACKEND_URL[m
[32m+[m[32m )[m
[32m+[m[32m ControllerInstance.instance._userController = new UserController([m
[32m+[m[32m process.env.NEXT_PUBLIC_BACKEND_URL[m
[32m+[m[32m )[m
[32m+[m[32m ControllerInstance.instance._workspaceController =[m
[32m+[m[32m new WorkspaceController(process.env.NEXT_PUBLIC_BACKEND_URL)[m
[32m+[m[32m ControllerInstance.instance._workspaceMembershipController =[m
[32m+[m[32m new WorkspaceMembershipController(process.env.NEXT_PUBLIC_BACKEND_URL)[m
[32m+[m[32m ControllerInstance.instance._workspaceRoleController =[m
[32m+[m[32m new WorkspaceRoleController(process.env.NEXT_PUBLIC_BACKEND_URL)[m
[32m+[m[32m ControllerInstance.instance._projectController = new ProjectController([m
[32m+[m[32m process.env.NEXT_PUBLIC_BACKEND_URL[m
[32m+[m[32m )[m
[32m+[m[32m ControllerInstance.instance._environmentController =[m
[32m+[m[32m new EnvironmentController(process.env.NEXT_PUBLIC_BACKEND_URL)[m
[32m+[m[32m ControllerInstance.instance._secretController = new SecretController([m
[32m+[m[32m process.env.NEXT_PUBLIC_BACKEND_URL[m
[32m+[m[32m )[m
[32m+[m[32m ControllerInstance.instance._variableController = new VariableController([m
[32m+[m[32m process.env.NEXT_PUBLIC_BACKEND_URL[m
[32m+[m[32m )[m
}[m
return ControllerInstance.instance[m
}[m
[1mdiff --git a/packages/api-client/src/index.ts b/packages/api-client/src/index.ts[m
[1mindex 79ab5f6..edd344f 100644[m
[1m--- a/packages/api-client/src/index.ts[m
[1m+++ b/packages/api-client/src/index.ts[m
[36m@@ -8,6 +8,7 @@[m [mimport WorkspaceController from '@api-client/controllers/workspace'[m
import WorkspaceRoleController from '@api-client/controllers/workspace-role'[m
import WorkspaceMembershipController from '@api-client/controllers/workspace-membership'[m
import AuthController from '@api-client/controllers/auth'[m
[32m+[m[32mimport UserController from '@api-client/controllers/user'[m
export {[m
EnvironmentController,[m
SecretController,[m
[36m@@ -18,5 +19,6 @@[m [mexport {[m
WorkspaceController,[m
WorkspaceRoleController,[m
WorkspaceMembershipController,[m
[31m- AuthController[m
[32m+[m[32m AuthController,[m
[32m+[m[32m UserController[m
}[m
[1mdiff --git a/packages/schema/src/secret/index.ts b/packages/schema/src/secret/index.ts[m
[1mindex ff5b499..4277679 100644[m
[1m--- a/packages/schema/src/secret/index.ts[m
[1m+++ b/packages/schema/src/secret/index.ts[m
[36m@@ -100,15 +100,17 @@[m [mexport const GetAllSecretsOfProjectResponseSchema = PageResponseSchema([m
name: z.string()[m
})[m
}),[m
[31m- values: z.object({[m
[31m- environment: z.object({[m
[31m- id: z.string(),[m
[31m- name: z.string(),[m
[31m- slug: z.string()[m
[31m- }),[m
[31m- value: z.string(),[m
[31m- version: z.number()[m
[31m- })[m
[32m+[m[32m values: z.array([m
[32m+[m[32m z.object({[m
[32m+[m[32m environment: z.object({[m
[32m+[m[32m id: z.string(),[m
[32m+[m[32m name: z.string(),[m
[32m+[m[32m slug: z.string()[m
[32m+[m[32m }),[m
[32m+[m[32m value: z.string(),[m
[32m+[m[32m version: z.number()[m
[32m+[m[32m })[m
[32m+[m[32m )[m
})[m
)[m
[m