diff --git a/packages/manager/apps/pci-ai-notebooks/src/__tests__/helpers/mocks/datasync.ts b/packages/manager/apps/pci-ai-notebooks/src/__tests__/helpers/mocks/datasync.ts index 171fa12f928e..edb4f2b944f5 100644 --- a/packages/manager/apps/pci-ai-notebooks/src/__tests__/helpers/mocks/datasync.ts +++ b/packages/manager/apps/pci-ai-notebooks/src/__tests__/helpers/mocks/datasync.ts @@ -2,6 +2,7 @@ import * as ai from '@/types/cloud/project/ai'; export const mockedDataSyncSpec: ai.volume.DataSyncSpec = { direction: ai.volume.DataSyncEnum.pull, + manual: true, volume: '1934e1d3-2ba0-4000-8fd3-6f11081e4401', }; @@ -10,7 +11,35 @@ export const mockedDataSync: ai.volume.DataSync = { id: 'idDuDataSync', spec: { direction: ai.volume.DataSyncEnum.pull, + manual: true, volume: '1934e1d3-2ba0-4000-8fd3-6f11081e4401', }, + status: { + endedAt: 'endedAT', + info: { + code: ai.InfoCodeEnum.APP_ERROR, + message: 'error_message', + }, + progress: [ + { + completed: 1, + createdAt: 'createdAt', + deleted: 1, + direction: ai.volume.DataSyncEnum.pull, + failed: 3, + id: 'id', + info: 'info', + processed: 1, + skipped: 1, + state: ai.volume.DataSyncProgressStateEnum.DONE, + total: 1, + transferredBytes: 1, + updatedAt: 'updatedAt', + }, + ], + queuedAt: 'queudAt', + startedAt: 'startedAt', + state: ai.volume.DataSyncStateEnum.DONE, + }, updatedAt: 'updatedAt', }; diff --git a/packages/manager/apps/pci-ai-notebooks/src/__tests__/helpers/mocks/job.ts b/packages/manager/apps/pci-ai-notebooks/src/__tests__/helpers/mocks/job.ts index eb786859b1b1..7ac6225512e2 100644 --- a/packages/manager/apps/pci-ai-notebooks/src/__tests__/helpers/mocks/job.ts +++ b/packages/manager/apps/pci-ai-notebooks/src/__tests__/helpers/mocks/job.ts @@ -18,30 +18,37 @@ export const mockedJobStatus: ai.job.JobStatus = { dataSync: [ { createdAt: 'createdAt', - id: 'datasyncId', + id: 'idDuDataSync', + spec: { + direction: ai.volume.DataSyncEnum.pull, + manual: true, + volume: '1934e1d3-2ba0-4000-8fd3-6f11081e4401', + }, status: { + endedAt: 'endedAT', info: { - code: ai.InfoCodeEnum.APP_RUNNING, - message: 'message', + code: ai.InfoCodeEnum.APP_ERROR, + message: 'error_message', }, progress: [ { completed: 1, createdAt: 'createdAt', - deleted: 0, - direction: ai.volume.DataSyncEnum.push, - failed: 0, - id: 'progressId', + deleted: 1, + direction: ai.volume.DataSyncEnum.pull, + failed: 3, + id: 'id', info: 'info', - processed: 3, + processed: 1, skipped: 1, state: ai.volume.DataSyncProgressStateEnum.DONE, - total: 2, - transferredBytes: 30, + total: 1, + transferredBytes: 1, updatedAt: 'updatedAt', }, ], - queuedAt: 'queuedAt', + queuedAt: 'queudAt', + startedAt: 'startedAt', state: ai.volume.DataSyncStateEnum.DONE, }, updatedAt: 'updatedAt', diff --git a/packages/manager/apps/pci-ai-notebooks/src/__tests__/helpers/mocks/notebook.ts b/packages/manager/apps/pci-ai-notebooks/src/__tests__/helpers/mocks/notebook.ts index d3c1c78f9f02..e010f2b80340 100644 --- a/packages/manager/apps/pci-ai-notebooks/src/__tests__/helpers/mocks/notebook.ts +++ b/packages/manager/apps/pci-ai-notebooks/src/__tests__/helpers/mocks/notebook.ts @@ -30,30 +30,37 @@ export const mockedNotebookStatus: ai.notebook.NotebookStatus = { dataSync: [ { createdAt: 'createdAt', - id: 'datasyncId', + id: 'idDuDataSync', + spec: { + direction: ai.volume.DataSyncEnum.pull, + manual: true, + volume: '1934e1d3-2ba0-4000-8fd3-6f11081e4401', + }, status: { + endedAt: 'endedAT', info: { - code: ai.InfoCodeEnum.APP_RUNNING, - message: 'message', + code: ai.InfoCodeEnum.APP_ERROR, + message: 'error_message', }, progress: [ { completed: 1, createdAt: 'createdAt', - deleted: 0, - direction: ai.volume.DataSyncEnum.push, - failed: 0, - id: 'progressId', + deleted: 1, + direction: ai.volume.DataSyncEnum.pull, + failed: 3, + id: 'id', info: 'info', - processed: 3, + processed: 1, skipped: 1, state: ai.volume.DataSyncProgressStateEnum.DONE, - total: 2, - transferredBytes: 30, + total: 1, + transferredBytes: 1, updatedAt: 'updatedAt', }, ], - queuedAt: 'queuedAt', + queuedAt: 'queudAt', + startedAt: 'startedAt', state: ai.volume.DataSyncStateEnum.DONE, }, updatedAt: 'updatedAt', diff --git a/packages/manager/apps/pci-ai-notebooks/src/__tests__/helpers/mocks/notebook/editor.ts b/packages/manager/apps/pci-ai-notebooks/src/__tests__/helpers/mocks/notebook/editor.ts index e839836720ed..576d76b76bd3 100644 --- a/packages/manager/apps/pci-ai-notebooks/src/__tests__/helpers/mocks/notebook/editor.ts +++ b/packages/manager/apps/pci-ai-notebooks/src/__tests__/helpers/mocks/notebook/editor.ts @@ -1,10 +1,10 @@ import * as ai from '@/types/cloud/project/ai'; -export const mockedEditor: ai.notebook.Editor = { +export const mockedEditor: ai.capabilities.notebook.Editor = { description: 'description', docUrl: 'docURl', id: 'editorId', logoUrl: 'logo', name: 'EditorName', - version: 'version', + versions: ['version'], }; diff --git a/packages/manager/apps/pci-ai-notebooks/src/__tests__/helpers/mocks/sshkey.ts b/packages/manager/apps/pci-ai-notebooks/src/__tests__/helpers/mocks/sshkey.ts index bf64920e5d25..30d656e9833e 100644 --- a/packages/manager/apps/pci-ai-notebooks/src/__tests__/helpers/mocks/sshkey.ts +++ b/packages/manager/apps/pci-ai-notebooks/src/__tests__/helpers/mocks/sshkey.ts @@ -6,3 +6,11 @@ export const mockedSshKey: sshkey.SshKey = { publicKey: 'publicKey', regions: ['GRA'], }; + +export const mockedSshKeyDetail: sshkey.SshKeyDetail = { + fingerPrint: 'fingerPrint', + id: 'id', + name: 'name', + publicKey: 'publicKey', + regions: ['GRA', 'BHS'], +}; diff --git a/packages/manager/apps/pci-ai-notebooks/src/data/api/ai/notebook/capabilities/editor.api.ts b/packages/manager/apps/pci-ai-notebooks/src/data/api/ai/notebook/capabilities/editor.api.ts index eaf67bb9f26b..4a8df5e9d24d 100644 --- a/packages/manager/apps/pci-ai-notebooks/src/data/api/ai/notebook/capabilities/editor.api.ts +++ b/packages/manager/apps/pci-ai-notebooks/src/data/api/ai/notebook/capabilities/editor.api.ts @@ -10,4 +10,4 @@ export const getEditor = async ({ projectId }: PCIAi) => 'X-Pagination-Size': '50000', }, }) - .then((res) => res.data as ai.notebook.Editor[]); + .then((res) => res.data as ai.capabilities.notebook.Editor[]); diff --git a/packages/manager/apps/pci-ai-notebooks/src/data/api/ai/notebook/capabilities/framework.api.ts b/packages/manager/apps/pci-ai-notebooks/src/data/api/ai/notebook/capabilities/framework.api.ts index 618ee7513919..21e6aa3a8958 100644 --- a/packages/manager/apps/pci-ai-notebooks/src/data/api/ai/notebook/capabilities/framework.api.ts +++ b/packages/manager/apps/pci-ai-notebooks/src/data/api/ai/notebook/capabilities/framework.api.ts @@ -10,4 +10,4 @@ export const getFramework = async ({ projectId }: PCIAi) => 'X-Pagination-Size': '50000', }, }) - .then((res) => res.data as ai.notebook.Framework[]); + .then((res) => res.data as ai.capabilities.notebook.Framework[]); diff --git a/packages/manager/apps/pci-ai-notebooks/src/data/api/ai/notebook/notebook.api.ts b/packages/manager/apps/pci-ai-notebooks/src/data/api/ai/notebook/notebook.api.ts index 937faaa55121..4ad646be69a6 100644 --- a/packages/manager/apps/pci-ai-notebooks/src/data/api/ai/notebook/notebook.api.ts +++ b/packages/manager/apps/pci-ai-notebooks/src/data/api/ai/notebook/notebook.api.ts @@ -20,7 +20,7 @@ export const getNotebook = async ({ projectId, notebookId }: NotebookData) => .then((res) => res.data as ai.notebook.Notebook); export interface AddNotebook extends PCIAi { - notebookInfo: ai.notebook.NotebookSpec; + notebookInfo: ai.notebook.NotebookSpecInput; } export const addNotebook = async ({ projectId, notebookInfo }: AddNotebook) => apiClient.v6 diff --git a/packages/manager/apps/pci-ai-notebooks/src/hooks/api/ai/notebook/capabilities/useGetEditor.hook.tsx b/packages/manager/apps/pci-ai-notebooks/src/hooks/api/ai/notebook/capabilities/useGetEditor.hook.tsx index d2bf5ca43343..2fb2f5c901eb 100644 --- a/packages/manager/apps/pci-ai-notebooks/src/hooks/api/ai/notebook/capabilities/useGetEditor.hook.tsx +++ b/packages/manager/apps/pci-ai-notebooks/src/hooks/api/ai/notebook/capabilities/useGetEditor.hook.tsx @@ -13,5 +13,5 @@ export function useGetEditor( queryKey, queryFn: () => getEditor({ projectId }), ...options, - }) as UseQueryResult; + }) as UseQueryResult; } diff --git a/packages/manager/apps/pci-ai-notebooks/src/hooks/api/ai/notebook/capabilities/useGetFramework.hook.tsx b/packages/manager/apps/pci-ai-notebooks/src/hooks/api/ai/notebook/capabilities/useGetFramework.hook.tsx index 9dc505e22f1a..d141074e63af 100644 --- a/packages/manager/apps/pci-ai-notebooks/src/hooks/api/ai/notebook/capabilities/useGetFramework.hook.tsx +++ b/packages/manager/apps/pci-ai-notebooks/src/hooks/api/ai/notebook/capabilities/useGetFramework.hook.tsx @@ -13,5 +13,5 @@ export function useGetFramework( queryKey, queryFn: () => getFramework({ projectId }), ...options, - }) as UseQueryResult; + }) as UseQueryResult; } diff --git a/packages/manager/apps/pci-ai-notebooks/src/hooks/api/ai/notebook/useAddNotebook.hook.tsx b/packages/manager/apps/pci-ai-notebooks/src/hooks/api/ai/notebook/useAddNotebook.hook.tsx index c80866a6aed7..05449699ca7d 100644 --- a/packages/manager/apps/pci-ai-notebooks/src/hooks/api/ai/notebook/useAddNotebook.hook.tsx +++ b/packages/manager/apps/pci-ai-notebooks/src/hooks/api/ai/notebook/useAddNotebook.hook.tsx @@ -14,7 +14,7 @@ export function useAddNotebook({ onError, onSuccess }: AddNotebookProps) { const queryClient = useQueryClient(); const { projectId } = useParams(); const mutation = useMutation({ - mutationFn: (notebookInfo: ai.notebook.NotebookSpec) => { + mutationFn: (notebookInfo: ai.notebook.NotebookSpecInput) => { return addNotebook({ projectId, notebookInfo }); }, onError, @@ -30,7 +30,7 @@ export function useAddNotebook({ onError, onSuccess }: AddNotebookProps) { }); return { - addNotebook: (notebookInfo: ai.notebook.NotebookSpec) => { + addNotebook: (notebookInfo: ai.notebook.NotebookSpecInput) => { return mutation.mutate(notebookInfo); }, ...mutation, diff --git a/packages/manager/apps/pci-ai-notebooks/src/hooks/api/ai/notebook/useGetCommand.hook.tsx b/packages/manager/apps/pci-ai-notebooks/src/hooks/api/ai/notebook/useGetCommand.hook.tsx index 0b5dfa8bb614..151a97d9c074 100644 --- a/packages/manager/apps/pci-ai-notebooks/src/hooks/api/ai/notebook/useGetCommand.hook.tsx +++ b/packages/manager/apps/pci-ai-notebooks/src/hooks/api/ai/notebook/useGetCommand.hook.tsx @@ -14,7 +14,7 @@ export function useGetCommand({ onError, onSuccess }: GetCommandProps) { const queryClient = useQueryClient(); const { projectId } = useParams(); const mutation = useMutation({ - mutationFn: (notebookInfo: ai.notebook.NotebookSpec) => { + mutationFn: (notebookInfo: ai.notebook.NotebookSpecInput) => { return getCommand({ projectId, notebookInfo }); }, onError, @@ -30,7 +30,7 @@ export function useGetCommand({ onError, onSuccess }: GetCommandProps) { }); return { - getCommand: (notebookInfo: ai.notebook.NotebookSpec) => { + getCommand: (notebookInfo: ai.notebook.NotebookSpecInput) => { return mutation.mutate(notebookInfo); }, ...mutation, diff --git a/packages/manager/apps/pci-ai-notebooks/src/hooks/api/sshkey/useAddSshKey.hook.tsx b/packages/manager/apps/pci-ai-notebooks/src/hooks/api/sshkey/useAddSshKey.hook.tsx index 05163d25da4a..800a3beb9e5e 100644 --- a/packages/manager/apps/pci-ai-notebooks/src/hooks/api/sshkey/useAddSshKey.hook.tsx +++ b/packages/manager/apps/pci-ai-notebooks/src/hooks/api/sshkey/useAddSshKey.hook.tsx @@ -14,7 +14,7 @@ export function useAddSshKey({ onError, onAddKeySuccess }: UseAddSshKey) { const mutation = useMutation({ mutationFn: (sshKey: AddSSHKey) => addSSHKey(sshKey), onError, - onSuccess: (data: sshkey.SshKey) => { + onSuccess: (data: sshkey.SshKeyDetail) => { onAddKeySuccess(data); // Invalidate service list query to get the latest data queryClient.invalidateQueries({ diff --git a/packages/manager/apps/pci-ai-notebooks/src/hooks/api/sshkey/useAddSshKey.spec.tsx b/packages/manager/apps/pci-ai-notebooks/src/hooks/api/sshkey/useAddSshKey.spec.tsx index f0db6f8763b5..b64afd535381 100644 --- a/packages/manager/apps/pci-ai-notebooks/src/hooks/api/sshkey/useAddSshKey.spec.tsx +++ b/packages/manager/apps/pci-ai-notebooks/src/hooks/api/sshkey/useAddSshKey.spec.tsx @@ -2,7 +2,10 @@ import { renderHook, waitFor } from '@testing-library/react'; import { vi } from 'vitest'; import { QueryClientWrapper } from '@/__tests__/helpers/wrappers/QueryClientWrapper'; import * as sshkeyApi from '@/data/api/sshkey/sshkey.api'; -import { mockedSshKey } from '@/__tests__/helpers/mocks/sshkey'; +import { + mockedSshKey, + mockedSshKeyDetail, +} from '@/__tests__/helpers/mocks/sshkey'; import { useAddSshKey } from './useAddSshKey.hook'; vi.mock('@/data/api/sshkey/sshkey.api', () => ({ @@ -14,7 +17,7 @@ describe('useAddSshKey', () => { const onAddKeySuccess = vi.fn(); const onError = vi.fn(); - vi.mocked(sshkeyApi.addSSHKey).mockResolvedValue(mockedSshKey); + vi.mocked(sshkeyApi.addSSHKey).mockResolvedValue(mockedSshKeyDetail); const { result } = renderHook( () => useAddSshKey({ onError, onAddKeySuccess }), diff --git a/packages/manager/apps/pci-ai-notebooks/src/lib/orderFunnelHelper.tsx b/packages/manager/apps/pci-ai-notebooks/src/lib/orderFunnelHelper.tsx index 88f29d5c412d..379e20b51e38 100644 --- a/packages/manager/apps/pci-ai-notebooks/src/lib/orderFunnelHelper.tsx +++ b/packages/manager/apps/pci-ai-notebooks/src/lib/orderFunnelHelper.tsx @@ -27,30 +27,32 @@ export function humanizeFramework( } export function getNotebookSpec(formResult: NotebookOrderResult) { - const notebookInfos: ai.notebook.NotebookSpec = { - env: { - frameworkId: formResult.framework.id, - frameworkVersion: formResult.version, - editorId: formResult.editor.id, - }, + const notebookEnv: ai.notebook.NotebookEnv = { + frameworkId: formResult.framework.id, + frameworkVersion: formResult.version, + editorId: formResult.editor.id, + }; + const notebookResource: ai.ResourcesInput = + formResult.flavor.type === ai.capabilities.FlavorTypeEnum.cpu + ? { + flavor: formResult.flavor.id, + cpu: Number(formResult.resourcesQuantity), + } + : { + flavor: formResult.flavor.id, + gpu: Number(formResult.resourcesQuantity), + }; + + const notebookInfos: ai.notebook.NotebookSpecInput = { + env: notebookEnv, + resources: notebookResource, + name: formResult.notebookName, region: formResult.region.id, unsecureHttp: formResult.unsecureHttp, sshPublicKeys: formResult.sshKey, labels: formResult.labels, }; - if (formResult.flavor.type === ai.capabilities.FlavorTypeEnum.cpu) { - notebookInfos.resources = { - flavor: formResult.flavor.id, - cpu: Number(formResult.resourcesQuantity), - }; - } else { - notebookInfos.resources = { - flavor: formResult.flavor.id, - gpu: Number(formResult.resourcesQuantity), - }; - } - if (formResult.volumes.length > 0) { notebookInfos.volumes = formResult.volumes.map((volume: OrderVolumes) => ({ cache: volume.cache, diff --git a/packages/manager/apps/pci-ai-notebooks/src/pages/notebooks/[notebookId]/attached-data/_components/DataSync.component.tsx b/packages/manager/apps/pci-ai-notebooks/src/pages/notebooks/[notebookId]/attached-data/_components/DataSync.component.tsx index e26c660fafab..964d9e4ab123 100644 --- a/packages/manager/apps/pci-ai-notebooks/src/pages/notebooks/[notebookId]/attached-data/_components/DataSync.component.tsx +++ b/packages/manager/apps/pci-ai-notebooks/src/pages/notebooks/[notebookId]/attached-data/_components/DataSync.component.tsx @@ -89,6 +89,7 @@ const DataSync = ({ const onSubmit = form.handleSubmit((formValues) => { const dataSyncFormValues: ai.volume.DataSyncSpec = { direction: formValues.type, + manual: true, }; if (volume) dataSyncFormValues.volume = notebook.status.volumes.find( diff --git a/packages/manager/apps/pci-ai-notebooks/src/pages/notebooks/[notebookId]/dashboard/Dashboard.page.tsx b/packages/manager/apps/pci-ai-notebooks/src/pages/notebooks/[notebookId]/dashboard/Dashboard.page.tsx index 916fecf0587f..6de51acee7a8 100644 --- a/packages/manager/apps/pci-ai-notebooks/src/pages/notebooks/[notebookId]/dashboard/Dashboard.page.tsx +++ b/packages/manager/apps/pci-ai-notebooks/src/pages/notebooks/[notebookId]/dashboard/Dashboard.page.tsx @@ -28,7 +28,7 @@ const Dashboard = () => { const { notebook, projectId } = useNotebookData(); const { t } = useTranslation('pci-ai-notebooks/notebooks/notebook/dashboard'); const { toast } = useToast(); - const [command, setCommand] = useState({}); + const [command, setCommand] = useState(); const { getCommand } = useGetCommand({ onError: (err) => { diff --git a/packages/manager/apps/pci-ai-notebooks/src/pages/notebooks/create/_components/OrderFunnel.component.tsx b/packages/manager/apps/pci-ai-notebooks/src/pages/notebooks/create/_components/OrderFunnel.component.tsx index c59debd94010..9d2445e3582e 100644 --- a/packages/manager/apps/pci-ai-notebooks/src/pages/notebooks/create/_components/OrderFunnel.component.tsx +++ b/packages/manager/apps/pci-ai-notebooks/src/pages/notebooks/create/_components/OrderFunnel.component.tsx @@ -89,7 +89,7 @@ const OrderFunnel = ({ const navigate = useNavigate(); const { toast } = useToast(); - const [command, setCommand] = useState({}); + const [command, setCommand] = useState({ command: '' }); const addSshKeyModale = useModale('addSshKey'); const { addNotebook, isPending: isPendingAddNotebook } = useAddNotebook({ @@ -122,7 +122,7 @@ const OrderFunnel = ({ }); const getCliCommand = () => { - const notebookInfos: ai.notebook.NotebookSpec = getNotebookSpec( + const notebookInfos: ai.notebook.NotebookSpecInput = getNotebookSpec( model.result, ); getCommand(notebookInfos); @@ -130,7 +130,7 @@ const OrderFunnel = ({ const onSubmit = model.form.handleSubmit( () => { - const notebookInfos: ai.notebook.NotebookSpec = getNotebookSpec( + const notebookInfos: ai.notebook.NotebookSpecInput = getNotebookSpec( model.result, ); addNotebook(notebookInfos); diff --git a/packages/manager/apps/pci-ai-notebooks/src/types/cloud/project/ai/Guide.ts b/packages/manager/apps/pci-ai-notebooks/src/types/cloud/project/ai/Guide.ts new file mode 100644 index 000000000000..bc5487c01339 --- /dev/null +++ b/packages/manager/apps/pci-ai-notebooks/src/types/cloud/project/ai/Guide.ts @@ -0,0 +1,8 @@ +export interface Guide { + section: string; + lang: string; + slug: string; + title: string; + excerpt: string; + url: string; +} diff --git a/packages/manager/apps/pci-ai-notebooks/src/types/cloud/project/ai/index.ts b/packages/manager/apps/pci-ai-notebooks/src/types/cloud/project/ai/index.ts index 5d11daa09497..68b4941282e1 100644 --- a/packages/manager/apps/pci-ai-notebooks/src/types/cloud/project/ai/index.ts +++ b/packages/manager/apps/pci-ai-notebooks/src/types/cloud/project/ai/index.ts @@ -1,3 +1,4 @@ +import exp from 'constants'; import * as app from './app/index'; import * as capabilities from './capabilities/index'; import * as job from './job/index'; @@ -19,6 +20,7 @@ export * from './DataStoreTypeEnum'; export * from './Env'; export * from './GenericResponse'; export * from './GitCredentialsInput'; +export * from './Guide'; export * from './Info'; export * from './InfoCodeEnum'; export * from './Label'; diff --git a/packages/manager/apps/pci-ai-notebooks/src/types/cloud/sshkey/SshKey.ts b/packages/manager/apps/pci-ai-notebooks/src/types/cloud/sshkey/SshKey.ts index 0dd944f36d60..7e6514a676ad 100644 --- a/packages/manager/apps/pci-ai-notebooks/src/types/cloud/sshkey/SshKey.ts +++ b/packages/manager/apps/pci-ai-notebooks/src/types/cloud/sshkey/SshKey.ts @@ -1,11 +1,11 @@ /** SshKey */ export interface SshKey { /** SSH key id */ - id: string; + id?: string; /** SSH key name */ name: string; /** SSH public key */ publicKey: string; /** SSH key regions */ - regions: string[]; + regions?: string[]; }