diff --git a/web/src/apis/v1/api-auto.d.ts b/web/src/apis/v1/api-auto.d.ts index aa7fe912a3..6ce34d8cd7 100644 --- a/web/src/apis/v1/api-auto.d.ts +++ b/web/src/apis/v1/api-auto.d.ts @@ -5,6 +5,7 @@ declare namespace Definitions { websocket?: boolean; methods?: string[]; code?: string /* The source code of the function */; + tags?: string[]; }; export type UpdateFunctionDto = { @@ -12,6 +13,7 @@ declare namespace Definitions { websocket?: boolean; methods?: string[]; code?: string /* The source code of the function */; + tags?: string[]; }; export type CompileFunctionDto = { @@ -31,10 +33,24 @@ declare namespace Definitions { state?: string; }; + export type CreateEnvironmentDto = { + name?: string; + value?: string; + }; + export type CreateWebsiteDto = {}; export type UpdateWebsiteDto = {}; + export type Pat2TokenDto = { + pat?: string /* PAT */; + }; + + export type CreatePATDto = { + name?: string; + expiresIn?: number; + }; + export type CreateCollectionDto = { name?: string; }; @@ -46,11 +62,19 @@ declare namespace Definitions { export type CreatePolicyDto = { name?: string; - rules?: string; }; export type UpdatePolicyDto = { - rules?: string; + injector?: string; + }; + + export type CreatePolicyRuleDto = { + collectionName?: string; + value?: string; + }; + + export type UpdatePolicyRuleDto = { + value?: string; }; export type CreateBucketDto = { @@ -184,6 +208,30 @@ declare namespace Paths { export type Responses = any; } + namespace EnvironmentVariableControllerAdd { + export type QueryParameters = any; + + export type BodyParameters = Definitions.CreateEnvironmentDto; + + export type Responses = any; + } + + namespace EnvironmentVariableControllerGet { + export type QueryParameters = any; + + export type BodyParameters = any; + + export type Responses = any; + } + + namespace EnvironmentVariableControllerDelete { + export type QueryParameters = any; + + export type BodyParameters = any; + + export type Responses = any; + } + namespace WebsitesControllerCreate { export type QueryParameters = any; @@ -248,6 +296,14 @@ declare namespace Paths { export type Responses = any; } + namespace AuthControllerPat2token { + export type QueryParameters = any; + + export type BodyParameters = Definitions.Pat2TokenDto; + + export type Responses = any; + } + namespace AuthControllerGetProfile { export type QueryParameters = any; @@ -256,6 +312,30 @@ declare namespace Paths { export type Responses = any; } + namespace PatControllerCreate { + export type QueryParameters = any; + + export type BodyParameters = Definitions.CreatePATDto; + + export type Responses = any; + } + + namespace PatControllerFindAll { + export type QueryParameters = any; + + export type BodyParameters = any; + + export type Responses = any; + } + + namespace PatControllerRemove { + export type QueryParameters = any; + + export type BodyParameters = any; + + export type Responses = any; + } + namespace CollectionControllerCreate { export type QueryParameters = any; @@ -336,6 +416,38 @@ declare namespace Paths { export type Responses = any; } + namespace PolicyRuleControllerCreate { + export type QueryParameters = any; + + export type BodyParameters = Definitions.CreatePolicyRuleDto; + + export type Responses = any; + } + + namespace PolicyRuleControllerFindAll { + export type QueryParameters = any; + + export type BodyParameters = any; + + export type Responses = any; + } + + namespace PolicyRuleControllerUpdate { + export type QueryParameters = any; + + export type BodyParameters = Definitions.UpdatePolicyRuleDto; + + export type Responses = any; + } + + namespace PolicyRuleControllerRemove { + export type QueryParameters = any; + + export type BodyParameters = any; + + export type Responses = any; + } + namespace BucketControllerCreate { export type QueryParameters = any; @@ -392,6 +504,14 @@ declare namespace Paths { export type Responses = any; } + namespace DependencyControllerUpdate { + export type QueryParameters = any; + + export type BodyParameters = any; + + export type Responses = any; + } + namespace DependencyControllerGetDependencies { export type QueryParameters = any; diff --git a/web/src/apis/v1/apps.ts b/web/src/apis/v1/apps.ts index 7b55f82240..242165f29c 100644 --- a/web/src/apis/v1/apps.ts +++ b/web/src/apis/v1/apps.ts @@ -111,6 +111,57 @@ export async function FunctionControllerCompile( }); } +/** + * Set a environment variable (create/update) + */ +export async function EnvironmentVariableControllerAdd( + params: Definitions.CreateEnvironmentDto | any, +): Promise { + // /v1/apps/{appid}/environments + let _params: { [key: string]: any } = { + appid: localStorage.getItem("app"), + ...params, + }; + return request(`/v1/apps/${_params.appid}/environments`, { + method: "POST", + data: params, + }); +} + +/** + * Get environment variables + */ +export async function EnvironmentVariableControllerGet( + params: Paths.EnvironmentVariableControllerGet.BodyParameters | any, +): Promise { + // /v1/apps/{appid}/environments + let _params: { [key: string]: any } = { + appid: localStorage.getItem("app"), + ...params, + }; + return request(`/v1/apps/${_params.appid}/environments`, { + method: "GET", + params: params, + }); +} + +/** + * Delete an environment variable by name + */ +export async function EnvironmentVariableControllerDelete( + params: Paths.EnvironmentVariableControllerDelete.BodyParameters | any, +): Promise { + // /v1/apps/{appid}/environments/{name} + let _params: { [key: string]: any } = { + appid: localStorage.getItem("app"), + ...params, + }; + return request(`/v1/apps/${_params.appid}/environments/${_params.name}`, { + method: "DELETE", + data: params, + }); +} + /** * TODO - ⌛️ */ @@ -316,7 +367,7 @@ export async function PolicyControllerFindAll( } /** - * Update policy rules + * Update database policy */ export async function PolicyControllerUpdate( params: Definitions.UpdatePolicyDto | any, @@ -366,6 +417,74 @@ export async function DatabaseControllerProxy( }); } +/** + * Create database policy rule + */ +export async function PolicyRuleControllerCreate( + params: Definitions.CreatePolicyRuleDto | any, +): Promise { + // /v1/apps/{appid}/policies/{name}/rules + let _params: { [key: string]: any } = { + appid: localStorage.getItem("app"), + ...params, + }; + return request(`/v1/apps/${_params.appid}/policies/${_params.name}/rules`, { + method: "POST", + data: params, + }); +} + +/** + * Get database policy rules + */ +export async function PolicyRuleControllerFindAll( + params: Paths.PolicyRuleControllerFindAll.BodyParameters | any, +): Promise { + // /v1/apps/{appid}/policies/{name}/rules + let _params: { [key: string]: any } = { + appid: localStorage.getItem("app"), + ...params, + }; + return request(`/v1/apps/${_params.appid}/policies/${_params.name}/rules`, { + method: "GET", + params: params, + }); +} + +/** + * Update database policy rule by collection name + */ +export async function PolicyRuleControllerUpdate( + params: Definitions.UpdatePolicyRuleDto | any, +): Promise { + // /v1/apps/{appid}/policies/{name}/rules/{collection} + let _params: { [key: string]: any } = { + appid: localStorage.getItem("app"), + ...params, + }; + return request(`/v1/apps/${_params.appid}/policies/${_params.name}/rules/${_params.collection}`, { + method: "PATCH", + data: params, + }); +} + +/** + * Remove a database policy rule by collection name + */ +export async function PolicyRuleControllerRemove( + params: Paths.PolicyRuleControllerRemove.BodyParameters | any, +): Promise { + // /v1/apps/{appid}/policies/{name}/rules/{collection} + let _params: { [key: string]: any } = { + appid: localStorage.getItem("app"), + ...params, + }; + return request(`/v1/apps/${_params.appid}/policies/${_params.name}/rules/${_params.collection}`, { + method: "DELETE", + data: params, + }); +} + /** * Create a new bucket */ @@ -469,7 +588,7 @@ export async function LogControllerGetLogs( } /** - * Add a dependency + * Add application dependencies */ export async function DependencyControllerAdd( params: Paths.DependencyControllerAdd.BodyParameters | any, @@ -485,6 +604,23 @@ export async function DependencyControllerAdd( }); } +/** + * Update application dependencies + */ +export async function DependencyControllerUpdate( + params: Paths.DependencyControllerUpdate.BodyParameters | any, +): Promise { + // /v1/apps/{appid}/dependencies + let _params: { [key: string]: any } = { + appid: localStorage.getItem("app"), + ...params, + }; + return request(`/v1/apps/${_params.appid}/dependencies`, { + method: "PATCH", + data: params, + }); +} + /** * Get application dependencies */ @@ -569,45 +705,3 @@ export async function TriggerControllerRemove( data: params, }); } - -export async function EnvironmentsControllerAdd( - params: any, -): Promise { - // /v1/apps/{appid}/dependencies - let _params: { [key: string]: any } = { - appid: localStorage.getItem("app"), - ...params, - }; - return request(`/v1/apps/${_params.appid}/environments`, { - method: "POST", - data: params, - }); -} - -export async function EnvironmentsControllerGetEnvironments( - params: any, -): Promise { - // /v1/apps/{appid}/dependencies - let _params: { [key: string]: any } = { - appid: localStorage.getItem("app"), - ...params, - }; - return request(`/v1/apps/${_params.appid}/environments`, { - method: "GET", - params: params, - }); -} - -export async function EnvironmentsControllerRemove( - params: any, -): Promise { - // /v1/apps/{appid}/dependencies/{name} - let _params: { [key: string]: any } = { - appid: localStorage.getItem("app"), - ...params, - }; - return request(`/v1/apps/${_params.appid}/environments/${_params.name}`, { - method: "DELETE", - data: params, - }); -} diff --git a/web/src/apis/v1/pat2token.ts b/web/src/apis/v1/pat2token.ts new file mode 100644 index 0000000000..a72abb2ee5 --- /dev/null +++ b/web/src/apis/v1/pat2token.ts @@ -0,0 +1,27 @@ +// @ts-ignore +/* eslint-disable */ +/////////////////////////////////////////////////////////////////////// +// // +// this file is autogenerated by service-generate // +// do not edit this file manually // +// // +/////////////////////////////////////////////////////////////////////// +/// +import request from "@/utils/request"; + +/** + * Get user token by PAT + */ +export async function AuthControllerPat2token( + params: Definitions.Pat2TokenDto | any, +): Promise { + // /v1/pat2token + let _params: { [key: string]: any } = { + appid: localStorage.getItem("app"), + ...params, + }; + return request(`/v1/pat2token`, { + method: "POST", + data: params, + }); +} diff --git a/web/src/apis/v1/pats.ts b/web/src/apis/v1/pats.ts index b38f0f5c26..5b932b35c9 100644 --- a/web/src/apis/v1/pats.ts +++ b/web/src/apis/v1/pats.ts @@ -10,22 +10,46 @@ import request from "@/utils/request"; /** - * Get current user profile + * Create a PAT */ -export async function AuthControllerGetPATs( - params: any, -): Promise { - // /v1/profile +export async function PatControllerCreate( + params: Definitions.CreatePATDto | any, +): Promise { + // /v1/pats + let _params: { [key: string]: any } = { + appid: localStorage.getItem("app"), + ...params, + }; + return request(`/v1/pats`, { + method: "POST", + data: params, + }); +} + +/** + * List PATs + */ +export async function PatControllerFindAll( + params: Paths.PatControllerFindAll.BodyParameters | any, +): Promise { + // /v1/pats + let _params: { [key: string]: any } = { + appid: localStorage.getItem("app"), + ...params, + }; return request(`/v1/pats`, { method: "GET", params: params, }); } -export async function AuthControllerPATsRemove( - params: any, -): Promise { - // /v1/profile +/** + * Delete a PAT + */ +export async function PatControllerRemove( + params: Paths.PatControllerRemove.BodyParameters | any, +): Promise { + // /v1/pats/{id} let _params: { [key: string]: any } = { appid: localStorage.getItem("app"), ...params, @@ -35,13 +59,3 @@ export async function AuthControllerPATsRemove( data: params, }); } - -export async function AuthControllerPATsCreate( - params: any, -): Promise { - // /v1/profile - return request(`/v1/pats`, { - method: "POST", - data: params, - }); -} diff --git a/web/src/chakraTheme.ts b/web/src/chakraTheme.ts index 9f2018be66..64a035bea8 100644 --- a/web/src/chakraTheme.ts +++ b/web/src/chakraTheme.ts @@ -56,8 +56,8 @@ const Modal = { const theme = extendTheme({ fontSizes: { sm: "12px", + base: "12px", md: "14px", - base: "14px", lg: "16px", xl: "16px", "2xl": "18px", diff --git a/web/src/components/EditableTable/index.module.scss b/web/src/components/EditableTable/index.module.scss index c94e4a1736..be99f7b997 100644 --- a/web/src/components/EditableTable/index.module.scss +++ b/web/src/components/EditableTable/index.module.scss @@ -3,4 +3,4 @@ white-space: nowrap; overflow: hidden; text-overflow: ellipsis; -} \ No newline at end of file +} diff --git a/web/src/pages/app/mods/SiderBar/index.module.scss b/web/src/pages/app/mods/SiderBar/index.module.scss index 430eb013a2..82082fc4f0 100644 --- a/web/src/pages/app/mods/SiderBar/index.module.scss +++ b/web/src/pages/app/mods/SiderBar/index.module.scss @@ -20,4 +20,4 @@ width: 100%; position: absolute; bottom: 10px; -} \ No newline at end of file +} diff --git a/web/src/pages/app/setting/AppEnvList/service.ts b/web/src/pages/app/setting/AppEnvList/service.ts index 4516593225..64bebf204d 100644 --- a/web/src/pages/app/setting/AppEnvList/service.ts +++ b/web/src/pages/app/setting/AppEnvList/service.ts @@ -1,9 +1,9 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { - EnvironmentsControllerAdd, - EnvironmentsControllerGetEnvironments, - EnvironmentsControllerRemove, + EnvironmentVariableControllerAdd, + EnvironmentVariableControllerDelete, + EnvironmentVariableControllerGet, } from "@/apis/v1/apps"; import useGlobalStore from "@/pages/globalStore"; @@ -20,7 +20,7 @@ export const useEnvironmentQuery = (callback?: (data: any) => void) => { return useQuery( queryKeys.useEnvironmentQuery, () => { - return EnvironmentsControllerGetEnvironments({}); + return EnvironmentVariableControllerGet({}); }, { onSuccess: (data) => { @@ -32,7 +32,7 @@ export const useEnvironmentQuery = (callback?: (data: any) => void) => { export const useAddEnvironmentMutation = (callback?: () => void) => { const queryClient = useQueryClient(); - return useMutation((params: TEnvironment[]) => EnvironmentsControllerAdd(params), { + return useMutation((params: TEnvironment[]) => EnvironmentVariableControllerAdd(params), { onSuccess: async () => { useGlobalStore.getState().showSuccess("update environment success"); await queryClient.invalidateQueries(queryKeys.useEnvironmentQuery); @@ -44,7 +44,7 @@ export const useAddEnvironmentMutation = (callback?: () => void) => { export const useDelEnvironmentMutation = (callback?: () => void) => { const queryClient = useQueryClient(); return useMutation( - (params: { name: string | undefined }) => EnvironmentsControllerRemove(params), + (params: { name: string | undefined }) => EnvironmentVariableControllerDelete(params), { onSuccess: async () => { useGlobalStore.getState().showSuccess("delete environment success"); diff --git a/web/src/pages/app/setting/PATList/service.ts b/web/src/pages/app/setting/PATList/service.ts index 46ae064999..653b59c23c 100644 --- a/web/src/pages/app/setting/PATList/service.ts +++ b/web/src/pages/app/setting/PATList/service.ts @@ -1,10 +1,6 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; -import { - AuthControllerGetPATs, - AuthControllerPATsCreate, - AuthControllerPATsRemove, -} from "@/apis/v1/pats"; +import { PatControllerCreate, PatControllerFindAll, PatControllerRemove } from "@/apis/v1/pats"; import useGlobalStore from "@/pages/globalStore"; export type TPAT = { @@ -21,7 +17,7 @@ export const usePATQuery = (callback?: (data: any) => void) => { return useQuery( queryKeys.usePATQuery, () => { - return AuthControllerGetPATs({}); + return PatControllerFindAll({}); }, { onSuccess: (data) => { @@ -33,7 +29,7 @@ export const usePATQuery = (callback?: (data: any) => void) => { export const useAddPATMutation = (callback?: (data: any) => void) => { const queryClient = useQueryClient(); - return useMutation((params: TPAT) => AuthControllerPATsCreate(params), { + return useMutation((params: TPAT) => PatControllerCreate(params), { onSuccess: async (data) => { useGlobalStore.getState().showSuccess("update PAT success"); await queryClient.invalidateQueries(queryKeys.usePATQuery); @@ -44,7 +40,7 @@ export const useAddPATMutation = (callback?: (data: any) => void) => { export const useDelPATMutation = (callback?: () => void) => { const queryClient = useQueryClient(); - return useMutation((params: { id: string | undefined }) => AuthControllerPATsRemove(params), { + return useMutation((params: { id: string | undefined }) => PatControllerRemove(params), { onSuccess: async () => { useGlobalStore.getState().showSuccess("delete PAT success"); await queryClient.invalidateQueries(queryKeys.usePATQuery); diff --git a/web/src/pages/home/mods/CreateAppModal/index.tsx b/web/src/pages/home/mods/CreateAppModal/index.tsx index 7297bac928..8ced9309aa 100644 --- a/web/src/pages/home/mods/CreateAppModal/index.tsx +++ b/web/src/pages/home/mods/CreateAppModal/index.tsx @@ -128,7 +128,7 @@ const CreateAppModal = (props: { application?: any; children: React.ReactElement
{regions.map((region: any) => { return ( -
+