Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions packages/manager/apps/pci-ai-tools/.eslintrc.cjs

This file was deleted.

8 changes: 8 additions & 0 deletions packages/manager/apps/pci-ai-tools/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { typescriptEslintConfig } from '@ovh-ux/manager-static-analysis-kit/eslint/typescript';

export default [
{
...typescriptEslintConfig,
rules: {},
},
];
8 changes: 5 additions & 3 deletions packages/manager/apps/pci-ai-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@
"type": "module",
"scripts": {
"build": "tsc --project tsconfig.build.json && vite build",
"build:strict": "tsc --project tsconfig.json && vite build",
"coverage": "vitest run --coverage",
"lint": "manager-legacy-lint --kinds tsx,js,css,html,md --continue",
"lint:fix": "manager-legacy-lint --kinds tsx,js,css,html,md --fix --continue",
"lint": "manager-lint --config eslint.config.mjs ./src",
"lint:fix": "manager-lint --fix --config eslint.config.mjs ./src",
"start": "vite",
"test": "vitest run --pool=threads",
"test-ui": "vitest --ui --coverage.enabled=true --pool=threads"
},
"dependencies": {
"@datatr-ux/ods-tailwind-config": "^1.0.3",
"@datatr-ux/ovhcloud-types": "^1.0.83",
"@datatr-ux/ovhcloud-types": "^2.0.79",
"@datatr-ux/uxlib": "^0.0.11-beta-8",
"@hookform/resolvers": "5.0.1",
"@ovh-ux/manager-config": "^8.9.0",
Expand Down Expand Up @@ -52,6 +53,7 @@
},
"devDependencies": {
"@jest/globals": "29.7.0",
"@ovh-ux/manager-static-analysis-kit": "^0.15.0",
"@ovh-ux/manager-static-analysis-legacy-kit": "^0.1.0",
"@ovh-ux/manager-tests-setup": "^0.6.2",
"@ovh-ux/manager-vite-config": "^0.15.6",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import ai from '@/types/AI';
import { mockedDataSync } from '../volume/datasync';
import { mockedAutoScaling, mockedFixedScaling } from './appHelper';
import {
mockedAutoScaling,
mockedAutoScalingInput,
mockedFixedScaling,
mockedFixedScalingInput,
} from './appHelper';
import { mockedCPUResources, mockedGPUResources } from '../shared/resource';
import {
mockedGitVolume,
Expand Down Expand Up @@ -81,7 +86,7 @@ export const mockedAppSpecInput: ai.app.AppSpecInput = {
},
command: ['command', 'docker'],
volumes: [mockedS3Volume, mockedGitVolume],
scalingStrategy: mockedAutoScaling,
scalingStrategy: mockedAutoScalingInput,
probe: {
path: '/health',
port: 8080,
Expand All @@ -104,5 +109,5 @@ export const mockedAppSpecInputGPU: ai.app.AppSpecInput = {
partnerId: 'lettria',
resources: { flavor: 'ai1-1-gpu', gpu: 2 },
volumes: [mockedPublicGitVolume],
scalingStrategy: mockedFixedScaling,
scalingStrategy: mockedFixedScalingInput,
};
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ export const mockedFixedScaling: ai.app.ScalingStrategy = {
},
};

export const mockedFixedScalingInput: ai.app.ScalingStrategyInput = {
fixed: {
replicas: 2,
},
};

export const mockedAutoScaling: ai.app.ScalingStrategy = {
automatic: {
replicasMin: 2,
Expand All @@ -29,3 +35,12 @@ export const mockedAutoScaling: ai.app.ScalingStrategy = {
resourceType: ai.app.ScalingAutomaticStrategyResourceTypeEnum.CPU,
},
};

export const mockedAutoScalingInput: ai.app.ScalingStrategyInput = {
automatic: {
replicasMin: 2,
replicasMax: 100,
averageUsageTarget: 75,
resourceType: ai.app.ScalingAutomaticStrategyResourceTypeEnum.CPU,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const mockedCapabilitiesFlavorCPU: ai.capabilities.Flavor = {
max: 4,
resourcesPerUnit: {
cpu: 1,
gpu: 0,
ephemeralStorage: 15,
memory: 5,
privateNetwork: 5,
Expand All @@ -29,6 +30,7 @@ export const mockedCapabilitiesFlavorGPU: ai.capabilities.Flavor = {
max: 2,
resourcesPerUnit: {
cpu: 11,
gpu: 1,
ephemeralStorage: 15,
memory: 5,
privateNetwork: 5,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as order from '@datatr-ux/ovhcloud-types/order/index';
import * as nichandle from '@datatr-ux/ovhcloud-types/nichandle/index';
import * as order from '@datatr-ux/ovhcloud-types/order';
import * as nichandle from '@datatr-ux/ovhcloud-types/nichandle';
import catalog from '@/types/Catalog';

export const mockedPricing: catalog.Pricing = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { AccessTypeEnum } from '@datatr-ux/ovhcloud-types/cloud/AccessTypeEnum';
import { Project } from '@datatr-ux/ovhcloud-types/cloud/Project';
import { ProjectStatusEnum } from '@datatr-ux/ovhcloud-types/cloud/project/ProjectStatusEnum';
import { AccessTypeEnum, Project } from '@datatr-ux/ovhcloud-types/cloud';
import { ProjectStatusEnum } from '@datatr-ux/ovhcloud-types/cloud/project';

export const mockedPciProject: Project = {
access: AccessTypeEnum.full,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import * as billingView from '@datatr-ux/ovhcloud-types/cloud/billingView/index';
import * as usage from '@datatr-ux/ovhcloud-types/cloud/usage/index';
import * as billingView from '@datatr-ux/ovhcloud-types/cloud/billingView';
import * as usage from '@datatr-ux/ovhcloud-types/cloud/usage';
import * as order from '@datatr-ux/ovhcloud-types/order';

const mockedRegionalizedResource: billingView.RegionalizedResource = {
components: [
{
id: 'component-id-1',
name: 'regResourceName',
quantity: { unit: billingView.UnitQuantityEnum.Minute, value: 5 },
resourceId: 'resource-id-1',
totalPrice: 10,
},
],
Expand Down Expand Up @@ -40,4 +43,9 @@ export const mockedCurrentUsage: usage.UsageCurrent = {
type: 'ai-app',
},
],
totalPrice: {
currencyCode: order.CurrencyCodeEnum.EUR,
text: '100 EUR',
value: 100,
},
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as sshkey from '@datatr-ux/ovhcloud-types/cloud/sshkey/index';
import * as sshkey from '@datatr-ux/ovhcloud-types/cloud/sshkey';
import { OrderSshKey } from '@/types/orderFunnel';

export const mockedSshKey: sshkey.SshKey = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { zodResolver } from '@hookform/resolvers/zod';
import { z } from 'zod';
import { useForm, SubmitHandler } from 'react-hook-form';
import { Plus, Trash2 } from 'lucide-react';
import * as sshkey from '@datatr-ux/ovhcloud-types/cloud/sshkey/index';
import * as sshkey from '@datatr-ux/ovhcloud-types/cloud/sshkey';
import { useTranslation } from 'react-i18next';
import {
Button,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
updateApp,
} from './app.api';
import {
mockedAppSpec,
mockedAppSpecInput,
mockedAppUpdate,
} from '@/__tests__/helpers/mocks/app/app';

Expand Down Expand Up @@ -52,22 +52,11 @@ describe('app functions', () => {
expect(apiClient.v6.post).not.toHaveBeenCalled();
await addApp({
projectId: 'projectId',
appInfo: mockedAppSpec,
appInfo: mockedAppSpecInput,
});
expect(apiClient.v6.post).toHaveBeenCalledWith(
'/cloud/project/projectId/ai/app',
{
image: mockedAppSpec.image,
name: mockedAppSpec.name,
grpcPort: mockedAppSpec.grpcPort,
command: mockedAppSpec.command,
defaultHttpPort: mockedAppSpec.defaultHttpPort,
deploymentStrategy: mockedAppSpec.deploymentStrategy,
region: mockedAppSpec.region,
resources: mockedAppSpec.resources,
scalingStrategy: mockedAppSpec.scalingStrategy,
unsecureHttp: false,
},
mockedAppSpecInput,
);
});

Expand Down Expand Up @@ -129,22 +118,11 @@ describe('app functions', () => {
expect(apiClient.v6.post).not.toHaveBeenCalled();
await getCommand({
projectId: 'projectId',
appInfo: mockedAppSpec,
appInfo: mockedAppSpecInput,
});
expect(apiClient.v6.post).toHaveBeenCalledWith(
'/cloud/project/projectId/ai/app/command',
{
image: mockedAppSpec.image,
name: mockedAppSpec.name,
grpcPort: mockedAppSpec.grpcPort,
command: mockedAppSpec.command,
defaultHttpPort: mockedAppSpec.defaultHttpPort,
deploymentStrategy: mockedAppSpec.deploymentStrategy,
region: mockedAppSpec.region,
resources: mockedAppSpec.resources,
scalingStrategy: mockedAppSpec.scalingStrategy,
unsecureHttp: false,
},
mockedAppSpecInput,
);
});
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { apiClient } from '@ovh-ux/manager-core-api';
import { describe, expect, vi } from 'vitest';
import { scalingStrategy } from './scaling-strategy.api';
import { mockedFixedScaling } from '@/__tests__/helpers/mocks/app/appHelper';
import { mockedFixedScalingInput } from '@/__tests__/helpers/mocks/app/appHelper';

describe('scaling stategy functions', () => {
afterEach(() => {
Expand All @@ -13,7 +13,7 @@ describe('scaling stategy functions', () => {
await scalingStrategy({
projectId: 'projectId',
appId: 'appId',
scalingStrat: mockedFixedScaling,
scalingStrat: mockedFixedScalingInput,
});
expect(apiClient.v6.put).toHaveBeenCalledWith(
'/cloud/project/projectId/ai/app/appId/scalingstrategy',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { apiClient } from '@ovh-ux/manager-core-api';
import { Project } from '@datatr-ux/ovhcloud-types/cloud/Project';
import { Project } from '@datatr-ux/ovhcloud-types/cloud';

export const getProject = async (projectId: string): Promise<Project> => {
const response = await apiClient.v6.get(`/cloud/project/${projectId}`);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { apiClient } from '@ovh-ux/manager-core-api';
import * as sshkey from '@datatr-ux/ovhcloud-types/cloud/index';
import * as sshkey from '@datatr-ux/ovhcloud-types/cloud';
import { PCIAi } from '..';

export const getSshkey = async ({ projectId }: PCIAi) =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as usage from '@datatr-ux/ovhcloud-types/cloud/usage/index';
import * as usage from '@datatr-ux/ovhcloud-types/cloud/usage';
import { apiClient } from '@ovh-ux/manager-core-api';
import { PCIAi } from '..';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { renderHook, waitFor } from '@testing-library/react';
import { vi } from 'vitest';
import { QueryClientWrapper } from '@/__tests__/helpers/wrappers/QueryClientWrapper';
import * as appApi from '@/data/api/ai/app/app.api';
import { mockedApp, mockedAppSpec } from '@/__tests__/helpers/mocks/app/app';
import {
mockedApp,
mockedAppSpecInput,
} from '@/__tests__/helpers/mocks/app/app';
import { useAddApp } from './useAddApp.hook';

vi.mock('@/data/api/ai/app/app.api', () => ({
Expand All @@ -20,12 +23,12 @@ describe('useAddApp', () => {
wrapper: QueryClientWrapper,
});

result.current.addApp(mockedAppSpec);
result.current.addApp(mockedAppSpecInput);

await waitFor(() => {
expect(appApi.addApp).toHaveBeenCalledWith({
projectId: undefined,
appInfo: mockedAppSpec,
appInfo: mockedAppSpecInput,
});
expect(onSuccess).toHaveBeenCalledWith(mockedApp);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { QueryClientWrapper } from '@/__tests__/helpers/wrappers/QueryClientWrap
import * as appApi from '@/data/api/ai/app/app.api';
import { useGetCommand } from './useGetCommand.hook';
import { mockedCommand } from '@/__tests__/helpers/mocks/shared/command';
import { mockedAppSpec } from '@/__tests__/helpers/mocks/app/app';
import { mockedAppSpecInput } from '@/__tests__/helpers/mocks/app/app';
import { AddApp } from '@/data/api/ai/app/app.api';

vi.mock('@/data/api/ai/app/app.api', () => ({
Expand All @@ -25,7 +25,7 @@ describe('useGetCommand', () => {

const addAppProps: AddApp = {
projectId,
appInfo: mockedAppSpec,
appInfo: mockedAppSpecInput,
};
result.current.getCommand(addAppProps);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import * as sshkey from '@datatr-ux/ovhcloud-types/cloud/sshkey/index';
import * as sshkey from '@datatr-ux/ovhcloud-types/cloud/sshkey';
import { useParams } from 'react-router-dom';
import { AIError } from '@/data/api';
import { AddSSHKey, addSSHKey } from '@/data/api/sshkey/sshkey.api';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { QueryObserverOptions, UseQueryResult } from '@tanstack/react-query';
import * as sshkey from '@datatr-ux/ovhcloud-types/cloud/sshkey/index';
import * as sshkey from '@datatr-ux/ovhcloud-types/cloud/sshkey';

import { getSshkey } from '@/data/api/sshkey/sshkey.api';
import { useQueryImmediateRefetch } from '@/hooks/useImmediateRefetch';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { QueryObserverOptions, UseQueryResult } from '@tanstack/react-query';
import * as usage from '@datatr-ux/ovhcloud-types/cloud/usage/index';
import * as usage from '@datatr-ux/ovhcloud-types/cloud/usage';
import { getCurrentUsage } from '@/data/api/usage/usage.api';
import { useQueryImmediateRefetch } from '@/hooks/useImmediateRefetch';

Expand Down
2 changes: 1 addition & 1 deletion packages/manager/apps/pci-ai-tools/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import initI18n from './i18n';
import './index.css';
import App from './App';

import '@/vite-hmr.ts';
import '@/vite-hmr';
import { LoadingIndicatorProvider } from './contexts/LoadingIndicator.context';

const init = async (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
Input,
useToast,
} from '@datatr-ux/uxlib';
import * as sshkey from '@datatr-ux/ovhcloud-types/cloud/index';
import * as sshkey from '@datatr-ux/ovhcloud-types/cloud';

import { getAIApiErrorMessage } from '@/lib/apiHelper';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useParams } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import * as role from '@datatr-ux/ovhcloud-types/cloud/role/index';
import * as role from '@datatr-ux/ovhcloud-types/cloud/role';
import ai from '@/types/AI';
import user from '@/types/User';
import { useGetTokens } from '@/data/hooks/ai/token/useGetTokens.hook';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ArrowRight } from 'lucide-react';
import { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router-dom';
import * as billingView from '@datatr-ux/ovhcloud-types/cloud/billingView/index';
import * as billingView from '@datatr-ux/ovhcloud-types/cloud/billingView';
import OvhLink from '@/components/links/OvhLink.component';
import FormattedDate from '@/components/formatted-date/FormattedDate.component';
import { useGetCurrentUsage } from '@/data/hooks/usage/useGetUsage.hook';
Expand Down
Loading
Loading