Merge pull request #6132 from halo-dev/refactor/api-client

pull/6136/head
John Niang 2024-06-25 12:48:12 +08:00 committed by GitHub
commit 9b02bc3405
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
545 changed files with 45116 additions and 23270 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -135,7 +135,11 @@ tasks.register('downloadPluginPresets', Download) {
openApi {
outputDir = file("$rootDir/api-docs/openapi/v3_0")
groupedApiMappings = [
'http://localhost:8091/v3/api-docs/all-api': 'aggregated.json',
'http://localhost:8091/v3/api-docs/apis_aggregated.api_v1alpha1': 'aggregated.json',
'http://localhost:8091/v3/api-docs/apis_public.api_v1alpha1' : 'apis_public.api_v1alpha1.json',
'http://localhost:8091/v3/api-docs/apis_console.api_v1alpha1' : 'apis_console.api_v1alpha1.json',
'http://localhost:8091/v3/api-docs/apis_uc.api_v1alpha1' : 'apis_uc.api_v1alpha1.json',
'http://localhost:8091/v3/api-docs/apis_extension.api_v1alpha1' : 'apis_extension.api_v1alpha1.json',
]
customBootRun {
args = ['--server.port=8091',

View File

@ -25,9 +25,10 @@ public class CacheEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
var tag = "CacheV1alpha1Console";
return route()
.DELETE("/caches/{name}", this::evictCache, builder -> builder
.tag("v1alpha1/Cache")
.tag(tag)
.operationId("EvictCache")
.description("Evict a cache.")
.parameter(parameterBuilder()

View File

@ -7,16 +7,18 @@ import io.swagger.v3.core.jackson.ModelResolver;
import io.swagger.v3.core.jackson.TypeNameResolver;
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.SpecVersion;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import java.util.Set;
import org.springdoc.core.customizers.OpenApiCustomizer;
import org.springdoc.core.customizers.GlobalOpenApiCustomizer;
import org.springdoc.core.models.GroupedOpenApi;
import org.springdoc.core.properties.SpringDocConfigProperties;
import org.springdoc.core.providers.ObjectMapperProvider;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.info.BuildProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
@ -29,92 +31,105 @@ import run.halo.app.extension.router.JsonPatch;
public class SwaggerConfig {
@Bean
OpenAPI haloOpenApi() {
return new OpenAPI(SpecVersion.V30)
OpenAPI haloOpenApi(ObjectProvider<BuildProperties> buildPropertiesProvider,
SpringDocConfigProperties docConfigProperties) {
var buildProperties = buildPropertiesProvider.getIfAvailable();
var version = "unknown";
if (buildProperties != null) {
version = buildProperties.getVersion();
}
return new OpenAPI()
.specVersion(docConfigProperties.getSpecVersion())
// See https://swagger.io/docs/specification/authentication/ for more.
.components(new Components()
.addSecuritySchemes("BasicAuth", new SecurityScheme()
.type(SecurityScheme.Type.HTTP).scheme("basic"))
.addSecuritySchemes("BearerAuth", new SecurityScheme()
.type(SecurityScheme.Type.HTTP).scheme("bearer").bearerFormat("JWT"))
.addSecuritySchemes("basicAuth", new SecurityScheme()
.type(SecurityScheme.Type.HTTP)
.scheme("basic"))
.addSecuritySchemes("bearerAuth", new SecurityScheme()
.type(SecurityScheme.Type.HTTP)
.scheme("bearer")
.bearerFormat("JWT"))
)
.addSecurityItem(new SecurityRequirement().addList("BasicAuth").addList("BearerAuth"))
.info(new Info().title("Halo Next API").version("2.0.0"));
.addSecurityItem(new SecurityRequirement()
.addList("basicAuth")
.addList("bearerAuth"))
.info(new Info()
.title("Halo")
.version(version)
);
}
OpenApiCustomizer openApiCustomizer() {
@Bean
GlobalOpenApiCustomizer openApiCustomizer() {
return openApi -> JsonPatch.addSchema(openApi.getComponents());
}
@Bean
GroupedOpenApi extensionCoreApi() {
GroupedOpenApi aggregatedV1alpha1Api() {
return GroupedOpenApi.builder()
.group("core-api")
.displayName("Core APIs")
.pathsToMatch("/api/**")
.addOpenApiCustomizer(openApiCustomizer())
.group("apis_aggregated.api_v1alpha1")
.displayName("Aggregated API V1alpha1")
.pathsToMatch(
"/apis/*/v1alpha1/**",
"/api/v1alpha1/**",
"/login/**"
)
.build();
}
@Bean
GroupedOpenApi publicV1alpha1Api() {
return GroupedOpenApi.builder()
.group("apis_public.api_v1alpha1")
.displayName("Public API V1alpha1")
.pathsToMatch(
"/apis/api.halo.run/**"
)
.build();
}
@Bean
GroupedOpenApi extensionApi() {
GroupedOpenApi consoleV1alpha1Api() {
return GroupedOpenApi.builder()
.group("extension-api")
.displayName("Extension APIs")
.pathsToMatch("/apis/**")
.pathsToExclude("/apis/api.console.halo.run/**", "/apis/api.halo.run/**",
"/apis/api.plugin.halo.run/**")
.addOpenApiCustomizer(openApiCustomizer())
.group("apis_console.api_v1alpha1")
.displayName("Console API V1alpha1")
.pathsToMatch(
"/apis/console.api.*/v1alpha1/**",
"/apis/api.console.halo.run/v1alpha1/**"
)
.build();
}
@Bean
GroupedOpenApi systemCustomApi() {
GroupedOpenApi ucV1alpha1Api() {
return GroupedOpenApi.builder()
.group("core-custom-api")
.displayName("Custom APIs in Core")
.pathsToMatch("/apis/api.console.halo.run/**")
.addOpenApiCustomizer(openApiCustomizer())
.group("apis_uc.api_v1alpha1")
.displayName("User-center API V1alpha1")
.pathsToMatch(
"/apis/uc.api.*/v1alpha1/**"
)
.build();
}
@Bean
GroupedOpenApi customApi() {
return GroupedOpenApi.builder()
.group("api.halo.run")
.displayName("api.halo.run")
.pathsToMatch("/apis/api.halo.run/**")
.addOpenApiCustomizer(openApiCustomizer())
.build();
}
@Bean
GroupedOpenApi pluginCustomApi() {
GroupedOpenApi extensionV1alpha1Api() {
return GroupedOpenApi.builder()
.group("plugin-custom-api")
.displayName("Custom APIs in Plugin")
.pathsToMatch("/apis/api.plugin.halo.run/**")
.addOpenApiCustomizer(openApiCustomizer())
.build();
}
@Bean
GroupedOpenApi userCenterApi() {
return GroupedOpenApi.builder()
.group("uc.api")
.displayName("User center APIs.")
.pathsToMatch("/apis/uc.api.*/**")
.addOpenApiCustomizer(openApiCustomizer())
.build();
}
@Bean
GroupedOpenApi allApi() {
return GroupedOpenApi.builder()
.group("all-api")
.displayName("All APIs")
.pathsToMatch("/api/**", "/apis/**", "/login/**")
.addOpenApiCustomizer(openApiCustomizer())
.group("apis_extension.api_v1alpha1")
.displayName("Extension API V1alpha1")
.pathsToMatch(
"/api/v1alpha1/**",
"/apis/content.halo.run/v1alpha1/**",
"/apis/theme.halo.run/v1alpha1/**",
"/apis/security.halo.run/v1alpha1/**",
"/apis/migration.halo.run/v1alpha1/**",
"/apis/auth.halo.run/v1alpha1/**",
"/apis/metrics.halo.run/v1alpha1/**",
"/apis/storage.halo.run/v1alpha1/**",
"/apis/plugin.halo.run/v1alpha1/**"
)
.build();
}

View File

@ -75,7 +75,7 @@ public class AttachmentEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
var tag = "api.console.halo.run/v1alpha1/Attachment";
var tag = "AttachmentV1alpha1Console";
return SpringdocRouteBuilder.route()
.POST("/attachments/upload", contentType(MediaType.MULTIPART_FORM_DATA),
request -> request.body(BodyExtractors.toMultipartData())

View File

@ -29,7 +29,7 @@ public class AuthProviderEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
final var tag = "api.console.halo.run/v1alpha1/AuthProvider";
final var tag = "AuthProviderV1alpha1Console";
return SpringdocRouteBuilder.route()
.GET("auth-providers", this::listAuthProviders,
builder -> builder.operationId("listAuthProviders")

View File

@ -47,7 +47,7 @@ public class CommentEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
final var tag = "api.console.halo.run/v1alpha1/Comment";
final var tag = "CommentV1alpha1Console";
return SpringdocRouteBuilder.route()
.GET("comments", this::listComments, builder -> {
builder.operationId("ListComments")

View File

@ -105,7 +105,7 @@ public class PluginEndpoint implements CustomEndpoint, InitializingBean {
@Override
public RouterFunction<ServerResponse> endpoint() {
final var tag = "api.console.halo.run/v1alpha1/Plugin";
var tag = "PluginV1alpha1Console";
return SpringdocRouteBuilder.route()
.POST("plugins/install", contentType(MediaType.MULTIPART_FORM_DATA),
this::install, builder -> builder.operationId("InstallPlugin")

View File

@ -58,7 +58,7 @@ public class PostEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
final var tag = "api.console.halo.run/v1alpha1/Post";
final var tag = "PostV1alpha1Console";
return SpringdocRouteBuilder.route()
.GET("posts", this::listPost, builder -> {
builder.operationId("ListPosts")

View File

@ -31,7 +31,7 @@ public class ReplyEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
final var tag = "api.console.halo.run/v1alpha1/Reply";
var tag = "ReplyV1alpha1Console";
return SpringdocRouteBuilder.route()
.GET("replies", this::listReplies, builder -> {
builder.operationId("ListReplies")

View File

@ -53,7 +53,7 @@ public class SinglePageEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
final var tag = "api.console.halo.run/v1alpha1/SinglePage";
var tag = "SinglePageV1alpha1Console";
return SpringdocRouteBuilder.route()
.GET("singlepages", this::listSinglePage, builder -> {
builder.operationId("ListSinglePages")

View File

@ -38,7 +38,7 @@ public class StatsEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
final var tag = "api.console.halo.run/v1alpha1/Stats";
var tag = "SystemV1alpha1Console";
return SpringdocRouteBuilder.route()
.GET("stats", this::getStats, builder -> builder.operationId("getStats")
.description("Get stats.")

View File

@ -50,7 +50,7 @@ public class SystemInitializationEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
var tag = "api.console.halo.run/v1alpha1/System";
var tag = "SystemV1alpha1Console";
// define a non-resource api
return SpringdocRouteBuilder.route()
.POST("/system/initialize", this::initialize,

View File

@ -44,7 +44,7 @@ public class TagEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
final var tag = "api.console.halo.run/v1alpha1/Tag";
var tag = "TagV1alpha1Console";
return SpringdocRouteBuilder.route()
.GET("tags", this::listTag, builder -> {
builder.operationId("ListPostTags")

View File

@ -35,7 +35,7 @@ public class TrackerEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
final var tag = "api.halo.run/v1alpha1/Tracker";
var tag = "MetricsV1alpha1Public";
return SpringdocRouteBuilder.route()
.POST("trackers/counter", this::increaseVisit,
builder -> builder.operationId("count")

View File

@ -111,7 +111,7 @@ public class UserEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
var tag = "api.console.halo.run/v1alpha1/User";
var tag = "UserV1alpha1Console";
return SpringdocRouteBuilder.route()
.GET("/users/-", this::me, builder -> builder.operationId("GetCurrentUserDetail")
.description("Get current user detail")

View File

@ -75,7 +75,7 @@ public class ThemeEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
final var tag = "api.console.halo.run/v1alpha1/Theme";
var tag = "ThemeV1alpha1Console";
return SpringdocRouteBuilder.route()
.POST("themes/install", contentType(MediaType.MULTIPART_FORM_DATA),
this::install, builder -> builder.operationId("InstallTheme")

View File

@ -60,7 +60,7 @@ public class UcPostAttachmentEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
var tag = groupVersion() + "/Attachment";
var tag = "AttachmentV1alpha1Uc";
return route()
.POST("/attachments",
this::createAttachmentForPost,

View File

@ -51,7 +51,7 @@ public class UcPostEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
var tag = groupVersion() + "/Post";
var tag = "PostV1alpha1Uc";
var namePathParam = parameterBuilder().name("name")
.description("Post name")
.in(ParameterIn.PATH)

View File

@ -38,8 +38,7 @@ public class UcSnapshotEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
var tag = groupVersion() + "/Snapshot";
var tag = "SnapshotV1alpha1Uc";
return route().nest(path("/snapshots"),
() -> route()
.GET("/{name}",

View File

@ -10,6 +10,7 @@ import io.swagger.v3.core.util.RefUtils;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import org.springdoc.webflux.core.fn.SpringdocRouteBuilder;
import org.springframework.lang.NonNull;
import org.springframework.util.StringUtils;
import org.springframework.web.reactive.function.server.HandlerFunction;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.ServerResponse;
@ -38,11 +39,12 @@ public class ExtensionRouterFunctionFactory {
var patchHandler = new ExtensionPatchHandler(scheme, client);
// TODO More handlers here
var gvk = scheme.groupVersionKind();
var tagName = gvk.toString();
var kind = gvk.kind();
var tagName = gvk.kind() + StringUtils.capitalize(gvk.version());
return SpringdocRouteBuilder.route()
.GET(getHandler.pathPattern(), getHandler,
builder -> builder.operationId("Get/" + gvk)
.description("Get " + gvk)
builder -> builder.operationId("get" + kind)
.description("Get " + kind)
.tag(tagName)
.parameter(parameterBuilder().in(ParameterIn.PATH)
.name("name")
@ -52,8 +54,8 @@ public class ExtensionRouterFunctionFactory {
.implementation(scheme.type())))
.GET(listHandler.pathPattern(), listHandler,
builder -> {
builder.operationId("List/" + gvk)
.description("List " + gvk)
builder.operationId("list" + kind)
.description("List " + kind)
.tag(tagName)
.response(responseBuilder().responseCode("200")
.description("Response " + scheme.plural())
@ -61,8 +63,8 @@ public class ExtensionRouterFunctionFactory {
SortableRequest.buildParameters(builder);
})
.POST(createHandler.pathPattern(), createHandler,
builder -> builder.operationId("Create/" + gvk)
.description("Create " + gvk)
builder -> builder.operationId("create" + kind)
.description("Create " + kind)
.tag(tagName)
.requestBody(requestBodyBuilder()
.description("Fresh " + scheme.singular())
@ -71,8 +73,8 @@ public class ExtensionRouterFunctionFactory {
.description("Response " + scheme.plural() + " created just now")
.implementation(scheme.type())))
.PUT(updateHandler.pathPattern(), updateHandler,
builder -> builder.operationId("Update/" + gvk)
.description("Update " + gvk)
builder -> builder.operationId("update" + kind)
.description("Update " + kind)
.tag(tagName)
.parameter(parameterBuilder().in(ParameterIn.PATH)
.name("name")
@ -84,8 +86,8 @@ public class ExtensionRouterFunctionFactory {
.description("Response " + scheme.plural() + " updated just now")
.implementation(scheme.type())))
.PATCH(patchHandler.pathPattern(), patchHandler,
builder -> builder.operationId("Patch/" + gvk)
.description("Patch " + gvk)
builder -> builder.operationId("patch" + kind)
.description("Patch " + kind)
.tag(tagName)
.parameter(parameterBuilder().in(ParameterIn.PATH)
.name("name")
@ -104,8 +106,8 @@ public class ExtensionRouterFunctionFactory {
)
)
.DELETE(deleteHandler.pathPattern(), deleteHandler,
builder -> builder.operationId("Delete/" + gvk)
.description("Delete " + gvk)
builder -> builder.operationId("delete" + kind)
.description("Delete " + kind)
.tag(tagName)
.parameter(parameterBuilder().in(ParameterIn.PATH)
.name("name")

View File

@ -53,7 +53,7 @@ public class MigrationEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
var tag = groupVersion().toString() + "/Migration";
var tag = "MigrationV1alpha1Console";
return SpringdocRouteBuilder.route()
.GET("/backups/{name}/files/{filename}",
request -> {

View File

@ -34,7 +34,7 @@ public class ConsoleNotifierEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
var tag = "api.console.halo.run/v1alpha1/Notifier";
var tag = "NotifierV1alpha1Console";
return SpringdocRouteBuilder.route()
.GET("/notifiers/{name}/sender-config", this::fetchSenderConfig,
builder -> builder.operationId("FetchSenderConfig")

View File

@ -49,7 +49,7 @@ public class EmailConfigValidationEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
var tag = "console.api.notification.halo.run/v1alpha1/Notifier";
var tag = "NotifierV1alpha1Console";
return SpringdocRouteBuilder.route()
.POST("/notifiers/default-email-notifier/verify-connection",
this::verifyEmailSenderConfig,

View File

@ -47,7 +47,7 @@ public class UserNotificationEndpoint implements CustomEndpoint {
}
Supplier<RouterFunction<ServerResponse>> userspaceScopedApis() {
var tag = "api.notification.halo.run/v1alpha1/Notification";
var tag = "NotificationV1alpha1Uc";
return () -> SpringdocRouteBuilder.route()
.GET("/notifications", this::listNotification,
builder -> {

View File

@ -63,7 +63,7 @@ public class UserNotificationPreferencesEndpoint implements CustomEndpoint {
}
Supplier<RouterFunction<ServerResponse>> userspaceScopedApis() {
var tag = "api.notification.halo.run/v1alpha1/Notification";
var tag = "NotificationV1alpha1Uc";
return () -> SpringdocRouteBuilder.route()
.GET("/notification-preferences", this::listNotificationPreferences,
builder -> builder.operationId("ListUserNotificationPreferences")

View File

@ -35,7 +35,7 @@ public class UserNotifierEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
var tag = "api.notification.halo.run/v1alpha1/Notifier";
var tag = "NotifierV1alpha1Uc";
return SpringdocRouteBuilder.route()
.GET("/notifiers/{name}/receiver-config", this::fetchReceiverConfig,
builder -> builder.operationId("FetchReceiverConfig")

View File

@ -24,7 +24,7 @@ public class IndicesEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
final var tag = API_VERSION + "/Indices";
final var tag = "IndicesV1alpha1Console";
return SpringdocRouteBuilder.route()
.POST("indices/post", this::rebuildPostIndices,
builder -> builder.operationId("BuildPostIndices")

View File

@ -29,7 +29,7 @@ public class PostSearchEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
final var tag = API_VERSION + "/Post";
var tag = "PostV1alpha1Public";
return SpringdocRouteBuilder.route()
.GET("indices/post", this::search,
builder -> {

View File

@ -25,7 +25,7 @@ public class PatEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
var tag = groupVersion().toString() + "/" + PersonalAccessToken.KIND;
var tag = PersonalAccessToken.KIND + "V1alpha1Uc";
return route().nest(path("/personalaccesstokens"),
() -> route()
.POST(patHandler::create,
@ -94,7 +94,7 @@ public class PatEndpoint implements CustomEndpoint {
@Override
public GroupVersion groupVersion() {
return GroupVersion.parseAPIVersion("api.security.halo.run/v1alpha1");
return GroupVersion.parseAPIVersion("uc.api.security.halo.run/v1alpha1");
}
}

View File

@ -64,7 +64,7 @@ public class TwoFactorAuthEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
var tag = groupVersion() + "/Authentication/TwoFactor";
var tag = "TwoFactorAuthV1alpha1Uc";
return route().nest(path("/authentications/two-factor"),
() -> route()
.GET("/settings", this::getTwoFactorSettings,
@ -278,6 +278,6 @@ public class TwoFactorAuthEndpoint implements CustomEndpoint {
@Override
public GroupVersion groupVersion() {
return GroupVersion.parseAPIVersion("api.security.halo.run/v1alpha1");
return GroupVersion.parseAPIVersion("uc.api.security.halo.run/v1alpha1");
}
}

View File

@ -41,7 +41,7 @@ public class CategoryQueryEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
final var tag = groupVersion().toString() + "/Category";
final var tag = "CategoryV1alpha1Public";
return SpringdocRouteBuilder.route()
.GET("categories", this::listCategories,
builder -> {

View File

@ -73,7 +73,7 @@ public class CommentFinderEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
final var tag = "api.halo.run/v1alpha1/Comment";
final var tag = "CommentV1alpha1Public";
return SpringdocRouteBuilder.route()
.POST("comments", this::createComment,
builder -> builder.operationId("CreateComment")

View File

@ -36,7 +36,7 @@ public class MenuQueryEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
final var tag = groupVersion().toString() + "/Menu";
final var tag = "MenuV1alpha1Public";
return SpringdocRouteBuilder.route()
.GET("menus/-", this::getByName,
builder -> builder.operationId("queryPrimaryMenu")

View File

@ -30,7 +30,7 @@ public class PluginQueryEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
final var tag = groupVersion().toString() + "/Plugin";
final var tag = "PluginV1alpha1Public";
return SpringdocRouteBuilder.route()
.GET("plugins/{name}/available", this::availableByName,
builder -> builder.operationId("queryPluginAvailableByName")

View File

@ -38,7 +38,7 @@ public class PostQueryEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
final var tag = groupVersion().toString() + "/Post";
var tag = "PostV1alpha1Public";
return SpringdocRouteBuilder.route()
.GET("posts", this::listPosts,
builder -> {

View File

@ -61,7 +61,7 @@ public class PublicUserEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
var tag = "api.halo.run/v1alpha1/User";
var tag = "UserV1alpha1Public";
return SpringdocRouteBuilder.route()
.POST("/users/-/signup", this::signUp,
builder -> builder.operationId("SignUp")

View File

@ -37,7 +37,7 @@ public class SinglePageQueryEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
final var tag = groupVersion().toString() + "/SinglePage";
var tag = "SinglePageV1alpha1Public";
return SpringdocRouteBuilder.route()
.GET("singlepages", this::listSinglePages,
builder -> {

View File

@ -29,7 +29,7 @@ public class SiteStatsQueryEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
final var tag = groupVersion().toString() + "/Stats";
var tag = "SystemV1alpha1Public";
return SpringdocRouteBuilder.route()
.GET("stats/-", this::getStats,
builder -> builder.operationId("queryStats")

View File

@ -42,7 +42,7 @@ public class TagQueryEndpoint implements CustomEndpoint {
@Override
public RouterFunction<ServerResponse> endpoint() {
final var tag = groupVersion().toString() + "/Tag";
var tag = "TagV1alpha1Public";
return SpringdocRouteBuilder.route()
.GET("tags", this::listTags,
builder -> {

View File

@ -26,7 +26,7 @@ class PatTest {
spec.setRoles(List.of("super-role"));
spec.setName("Fake PAT");
webClient.post()
.uri("/apis/api.security.halo.run/v1alpha1/personalaccesstokens")
.uri("/apis/uc.api.security.halo.run/v1alpha1/personalaccesstokens")
.bodyValue(requestPat)
.exchange()
.expectStatus().isOk()

View File

@ -1,6 +1,7 @@
plugins {
id 'idea'
id 'com.github.node-gradle.node'
id 'org.openapi.generator' version '7.6.0'
}
idea {

View File

@ -1,4 +1,4 @@
import { apiClient } from "@/utils/api-client";
import { coreApiClient } from "@halo-dev/api-client";
import { watch, type Ref, ref, nextTick } from "vue";
interface SnapshotContent {
@ -20,10 +20,9 @@ export function useContentSnapshot(
if (!snapshotName.value) {
return;
}
const { data } =
await apiClient.extension.snapshot.getContentHaloRunV1alpha1Snapshot({
name: snapshotName.value,
});
const { data } = await coreApiClient.content.snapshot.getSnapshot({
name: snapshotName.value,
});
version.value = data.metadata.version || 0;
};

View File

@ -1,11 +1,11 @@
import { apiClient } from "@/utils/api-client";
import { consoleApiClient } from "@halo-dev/api-client";
import { useQuery } from "@tanstack/vue-query";
export function useDashboardStats() {
const { data } = useQuery({
queryKey: ["dashboard-stats"],
queryFn: async () => {
const { data } = await apiClient.stats.getStats();
const { data } = await consoleApiClient.system.getStats();
return data;
},
});

View File

@ -3,7 +3,7 @@ import type { DirectiveBinding } from "vue";
import { createPinia } from "pinia";
import App from "./App.vue";
import router from "./router";
import { apiClient } from "@/utils/api-client";
import { consoleApiClient } from "@halo-dev/api-client";
// setup
import "@/setup/setupStyles";
import { setupComponents } from "@/setup/setupComponents";
@ -20,19 +20,22 @@ import {
setupCoreModules,
setupPluginModules,
} from "@console/setup/setupModules";
import { setupApiClient } from "@/setup/setupApiClient";
const app = createApp(App);
setupComponents(app);
setupI18n(app);
setupVueQuery(app);
setupApiClient();
app.use(createPinia());
async function loadUserPermissions() {
const { data: currentPermissions } = await apiClient.user.getPermissions({
name: "-",
});
const { data: currentPermissions } =
await consoleApiClient.user.getPermissions({
name: "-",
});
const roleStore = useRoleStore();
roleStore.$patch({
permissions: currentPermissions,

View File

@ -1,7 +1,7 @@
<script lang="ts" setup>
import UserFilterDropdown from "@/components/filter/UserFilterDropdown.vue";
import LazyImage from "@/components/image/LazyImage.vue";
import { apiClient } from "@/utils/api-client";
import { coreApiClient } from "@halo-dev/api-client";
import { isImage } from "@/utils/image";
import type { Attachment, Group } from "@halo-dev/api-client";
import {
@ -129,18 +129,16 @@ provide<Ref<Set<Attachment>>>("selectedAttachments", selectedAttachments);
const handleMove = async (group: Group) => {
try {
const promises = Array.from(selectedAttachments.value).map((attachment) => {
return apiClient.extension.storage.attachment.patchStorageHaloRunV1alpha1Attachment(
{
name: attachment.metadata.name,
jsonPatchInner: [
{
op: "add",
path: "/spec/groupName",
value: group.metadata.name,
},
],
}
);
return coreApiClient.storage.attachment.patchAttachment({
name: attachment.metadata.name,
jsonPatchInner: [
{
op: "add",
path: "/spec/groupName",
value: group.metadata.name,
},
],
});
});
await Promise.all(promises);
@ -232,8 +230,8 @@ onMounted(() => {
if (!nameQuery.value) {
return;
}
apiClient.extension.storage.attachment
.getStorageHaloRunV1alpha1Attachment({
coreApiClient.storage.attachment
.getAttachment({
name: nameQuery.value,
})
.then((response) => {

View File

@ -10,7 +10,7 @@ import LazyImage from "@/components/image/LazyImage.vue";
import type { Attachment } from "@halo-dev/api-client";
import prettyBytes from "pretty-bytes";
import { computed, ref } from "vue";
import { apiClient } from "@/utils/api-client";
import { coreApiClient } from "@halo-dev/api-client";
import { isImage } from "@/utils/image";
import { formatDatetime } from "@/utils/date";
import { useFetchAttachmentGroup } from "../composables/use-attachment-group";
@ -47,10 +47,9 @@ const { data: policy } = useQuery({
return;
}
const { data } =
await apiClient.extension.storage.policy.getStorageHaloRunV1alpha1Policy({
name: policyName.value,
});
const { data } = await coreApiClient.storage.policy.getPolicy({
name: policyName.value,
});
return data;
},

View File

@ -1,5 +1,5 @@
<script lang="ts" setup>
import { apiClient } from "@/utils/api-client";
import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import type { Group } from "@halo-dev/api-client";
import {
Dialog,
@ -49,29 +49,28 @@ const handleDelete = () => {
}
// TODO:
const { data } = await apiClient.attachment.searchAttachments({
fieldSelector: [`spec.groupName=${props.group.metadata.name}`],
page: 0,
size: 0,
});
const { data } =
await consoleApiClient.storage.attachment.searchAttachments({
fieldSelector: [`spec.groupName=${props.group.metadata.name}`],
page: 0,
size: 0,
});
await apiClient.extension.storage.group.deleteStorageHaloRunV1alpha1Group(
{ name: props.group.metadata.name }
);
await coreApiClient.storage.group.deleteGroup({
name: props.group.metadata.name,
});
// move attachments to none group
const moveToUnGroupRequests = data.items.map((attachment) => {
return apiClient.extension.storage.attachment.patchStorageHaloRunV1alpha1Attachment(
{
name: attachment.metadata.name,
jsonPatchInner: [
{
op: "remove",
path: "/spec/groupName",
},
],
}
);
return coreApiClient.storage.attachment.patchAttachment({
name: attachment.metadata.name,
jsonPatchInner: [
{
op: "remove",
path: "/spec/groupName",
},
],
});
});
await Promise.all(moveToUnGroupRequests);
@ -105,20 +104,21 @@ const handleDeleteWithAttachments = () => {
}
// TODO:
const { data } = await apiClient.attachment.searchAttachments({
fieldSelector: [`spec.groupName=${props.group.metadata.name}`],
page: 0,
size: 0,
const { data } =
await consoleApiClient.storage.attachment.searchAttachments({
fieldSelector: [`spec.groupName=${props.group.metadata.name}`],
page: 0,
size: 0,
});
await coreApiClient.storage.group.deleteGroup({
name: props.group.metadata.name,
});
await apiClient.extension.storage.group.deleteStorageHaloRunV1alpha1Group(
{ name: props.group.metadata.name }
);
const deleteAttachmentRequests = data.items.map((attachment) => {
return apiClient.extension.storage.attachment.deleteStorageHaloRunV1alpha1Attachment(
{ name: attachment.metadata.name }
);
return coreApiClient.storage.attachment.deleteAttachment({
name: attachment.metadata.name,
});
});
await Promise.all(deleteAttachmentRequests);

View File

@ -1,7 +1,7 @@
<script lang="ts" setup>
import SubmitButton from "@/components/button/SubmitButton.vue";
import { setFocus } from "@/formkit/utils/focus";
import { apiClient } from "@/utils/api-client";
import { coreApiClient } from "@halo-dev/api-client";
import type { Group } from "@halo-dev/api-client";
import { Toast, VButton, VModal, VSpace } from "@halo-dev/components";
import { cloneDeep } from "lodash-es";
@ -45,18 +45,14 @@ const handleSave = async () => {
try {
isSubmitting.value = true;
if (props.group) {
await apiClient.extension.storage.group.updateStorageHaloRunV1alpha1Group(
{
name: formState.value.metadata.name,
group: formState.value,
}
);
await coreApiClient.storage.group.updateGroup({
name: formState.value.metadata.name,
group: formState.value,
});
} else {
await apiClient.extension.storage.group.createStorageHaloRunV1alpha1Group(
{
group: formState.value,
}
);
await coreApiClient.storage.group.createGroup({
group: formState.value,
});
}
Toast.success(t("core.common.toast.save_success"));

View File

@ -15,7 +15,7 @@ import type { Attachment } from "@halo-dev/api-client";
import { formatDatetime } from "@/utils/date";
import prettyBytes from "pretty-bytes";
import { useFetchAttachmentPolicy } from "../composables/use-attachment-policy";
import { apiClient } from "@/utils/api-client";
import { coreApiClient } from "@halo-dev/api-client";
import { usePermission } from "@/utils/permission";
import { useI18n } from "vue-i18n";
import { useQueryClient } from "@tanstack/vue-query";
@ -65,11 +65,9 @@ const handleDelete = () => {
cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => {
try {
await apiClient.extension.storage.attachment.deleteStorageHaloRunV1alpha1Attachment(
{
name: props.attachment.metadata.name,
}
);
await coreApiClient.storage.attachment.deleteAttachment({
name: props.attachment.metadata.name,
});
selectedAttachments.value.delete(props.attachment);

View File

@ -1,5 +1,5 @@
<script lang="ts" setup>
import { apiClient } from "@/utils/api-client";
import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import { formatDatetime } from "@/utils/date";
import type { Policy, PolicyTemplate } from "@halo-dev/api-client";
import {
@ -50,7 +50,7 @@ const handleOpenCreateNewPolicyModal = (policyTemplate: PolicyTemplate) => {
};
const handleDelete = async (policy: Policy) => {
const { data } = await apiClient.attachment.searchAttachments({
const { data } = await consoleApiClient.storage.attachment.searchAttachments({
fieldSelector: [`spec.policyName=${policy.metadata.name}`],
});
@ -76,9 +76,9 @@ const handleDelete = async (policy: Policy) => {
confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => {
await apiClient.extension.storage.policy.deleteStorageHaloRunV1alpha1Policy(
{ name: policy.metadata.name }
);
await coreApiClient.storage.policy.deletePolicy({
name: policy.metadata.name,
});
Toast.success(t("core.common.toast.delete_success"));
handleFetchPolicies();

View File

@ -1,7 +1,7 @@
<script lang="ts" setup>
import SubmitButton from "@/components/button/SubmitButton.vue";
import { setFocus } from "@/formkit/utils/focus";
import { apiClient } from "@/utils/api-client";
import { coreApiClient } from "@halo-dev/api-client";
import { useSettingFormConvert } from "@console/composables/use-setting-form";
import type { Policy } from "@halo-dev/api-client";
import { Toast, VButton, VLoading, VModal, VSpace } from "@halo-dev/components";
@ -66,11 +66,9 @@ const { data: policyTemplate } = useQuery({
cacheTime: 0,
queryFn: async () => {
const { data } =
await apiClient.extension.storage.policyTemplate.getStorageHaloRunV1alpha1PolicyTemplate(
{
name: formState.value.spec.templateName,
}
);
await coreApiClient.storage.policyTemplate.getPolicyTemplate({
name: formState.value.spec.templateName,
});
return data;
},
retry: 0,
@ -88,7 +86,7 @@ const { data: setting, isLoading } = useQuery({
throw new Error("No setting found");
}
const { data } = await apiClient.extension.setting.getV1alpha1Setting({
const { data } = await coreApiClient.setting.getSetting({
name: policyTemplate.value.spec.settingName,
});
@ -118,7 +116,7 @@ const { data: configMap } = useQuery({
if (!policy.value?.spec.configMapName) {
throw new Error("No configMap found");
}
const { data } = await apiClient.extension.configMap.getV1alpha1ConfigMap({
const { data } = await coreApiClient.configMap.getConfigMap({
name: policy.value?.spec.configMapName,
});
return data;
@ -141,29 +139,26 @@ const handleSave = async () => {
const configMapToUpdate = convertToSave();
if (isUpdateMode) {
await apiClient.extension.configMap.updateV1alpha1ConfigMap({
await coreApiClient.configMap.updateConfigMap({
name: configMap.value.metadata.name,
configMap: configMapToUpdate,
});
await apiClient.extension.storage.policy.updateStorageHaloRunV1alpha1Policy(
{
name: formState.value.metadata.name,
policy: formState.value,
}
);
await coreApiClient.storage.policy.updatePolicy({
name: formState.value.metadata.name,
policy: formState.value,
});
} else {
const { data: newConfigMap } =
await apiClient.extension.configMap.createV1alpha1ConfigMap({
await coreApiClient.configMap.createConfigMap({
configMap: configMapToUpdate,
});
formState.value.spec.configMapName = newConfigMap.metadata.name;
await apiClient.extension.storage.policy.createStorageHaloRunV1alpha1Policy(
{
policy: formState.value,
}
);
await coreApiClient.storage.policy.createPolicy({
policy: formState.value,
});
}
Toast.success(t("core.common.toast.save_success"));

View File

@ -1,6 +1,6 @@
import type { Ref } from "vue";
import type { Group } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client";
import { coreApiClient } from "@halo-dev/api-client";
import { useQuery } from "@tanstack/vue-query";
interface useFetchAttachmentGroupReturn {
@ -13,13 +13,10 @@ export function useFetchAttachmentGroup(): useFetchAttachmentGroupReturn {
const { data, isLoading, refetch } = useQuery<Group[]>({
queryKey: ["attachment-groups"],
queryFn: async () => {
const { data } =
await apiClient.extension.storage.group.listStorageHaloRunV1alpha1Group(
{
labelSelector: ["!halo.run/hidden"],
sort: ["metadata.creationTimestamp,asc"],
}
);
const { data } = await coreApiClient.storage.group.listGroup({
labelSelector: ["!halo.run/hidden"],
sort: ["metadata.creationTimestamp,asc"],
});
return data.items;
},

View File

@ -1,6 +1,6 @@
import type { Ref } from "vue";
import type { Policy, PolicyTemplate } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client";
import { coreApiClient } from "@halo-dev/api-client";
import { useQuery } from "@tanstack/vue-query";
interface useFetchAttachmentPolicyReturn {
@ -19,8 +19,7 @@ export function useFetchAttachmentPolicy(): useFetchAttachmentPolicyReturn {
const { data, isLoading, refetch } = useQuery<Policy[]>({
queryKey: ["attachment-policies"],
queryFn: async () => {
const { data } =
await apiClient.extension.storage.policy.listStorageHaloRunV1alpha1Policy();
const { data } = await coreApiClient.storage.policy.listPolicy();
return data.items;
},
refetchInterval(data) {
@ -43,7 +42,7 @@ export function useFetchAttachmentPolicyTemplate(): useFetchAttachmentPolicyTemp
queryKey: ["attachment-policy-templates"],
queryFn: async () => {
const { data } =
await apiClient.extension.storage.policyTemplate.listStorageHaloRunV1alpha1PolicyTemplate();
await coreApiClient.storage.policyTemplate.listPolicyTemplate();
return data.items;
},
});

View File

@ -1,6 +1,6 @@
import type { Attachment } from "@halo-dev/api-client";
import { computed, nextTick, type Ref, ref, watch } from "vue";
import { apiClient } from "@/utils/api-client";
import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import { Dialog, Toast } from "@halo-dev/components";
import { useQuery } from "@tanstack/vue-query";
import { useI18n } from "vue-i18n";
@ -77,15 +77,16 @@ export function useAttachmentControl(filterOptions: {
})
.filter(Boolean) as string[];
const { data } = await apiClient.attachment.searchAttachments({
fieldSelector,
page: page.value,
size: size.value,
ungrouped: isUnGrouped,
accepts: accepts?.value,
keyword: keyword?.value,
sort: [sort?.value as string].filter(Boolean),
});
const { data } =
await consoleApiClient.storage.attachment.searchAttachments({
fieldSelector,
page: page.value,
size: size.value,
ungrouped: isUnGrouped,
accepts: accepts?.value,
keyword: keyword?.value,
sort: [sort?.value as string].filter(Boolean),
});
total.value = data.total;
hasPrevious.value = data.hasPrevious;
@ -158,11 +159,9 @@ export function useAttachmentControl(filterOptions: {
try {
const promises = Array.from(selectedAttachments.value).map(
(attachment) => {
return apiClient.extension.storage.attachment.deleteStorageHaloRunV1alpha1Attachment(
{
name: attachment.metadata.name,
}
);
return coreApiClient.storage.attachment.deleteAttachment({
name: attachment.metadata.name,
});
}
);
await Promise.all(promises);

View File

@ -15,7 +15,7 @@ import {
import CommentListItem from "./components/CommentListItem.vue";
import type { ListedComment } from "@halo-dev/api-client";
import { computed, ref, watch } from "vue";
import { apiClient } from "@/utils/api-client";
import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import { useQuery } from "@tanstack/vue-query";
import { useI18n } from "vue-i18n";
import UserFilterDropdown from "@/components/filter/UserFilterDropdown.vue";
@ -101,7 +101,7 @@ const {
})
.filter(Boolean) as string[];
const { data } = await apiClient.comment.listComments({
const { data } = await consoleApiClient.content.comment.listComments({
fieldSelector,
page: page.value,
size: size.value,
@ -165,11 +165,9 @@ const handleDeleteInBatch = async () => {
onConfirm: async () => {
try {
const promises = selectedCommentNames.value.map((name) => {
return apiClient.extension.comment.deleteContentHaloRunV1alpha1Comment(
{
name,
}
);
return coreApiClient.content.comment.deleteComment({
name,
});
});
await Promise.all(promises);
selectedCommentNames.value = [];
@ -200,24 +198,22 @@ const handleApproveInBatch = async () => {
});
const promises = commentsToUpdate?.map((comment) => {
return apiClient.extension.comment.patchContentHaloRunV1alpha1Comment(
{
name: comment.comment.metadata.name,
jsonPatchInner: [
{
op: "add",
path: "/spec/approved",
value: true,
},
{
op: "add",
path: "/spec/approvedTime",
// TODO: see https://github.com/halo-dev/halo/pull/2746
value: new Date().toISOString(),
},
],
}
);
return coreApiClient.content.comment.patchComment({
name: comment.comment.metadata.name,
jsonPatchInner: [
{
op: "add",
path: "/spec/approved",
value: true,
},
{
op: "add",
path: "/spec/approvedTime",
// TODO: see https://github.com/halo-dev/halo/pull/2746
value: new Date().toISOString(),
},
],
});
});
await Promise.all(promises || []);
selectedCommentNames.value = [];

View File

@ -1,6 +1,6 @@
<script lang="ts" setup>
import { usePluginModuleStore } from "@/stores/plugin";
import { apiClient } from "@/utils/api-client";
import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import { formatDatetime } from "@/utils/date";
import { usePermission } from "@/utils/permission";
import type {
@ -65,7 +65,7 @@ const handleDelete = async () => {
cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => {
try {
await apiClient.extension.comment.deleteContentHaloRunV1alpha1Comment({
await coreApiClient.content.comment.deleteComment({
name: props.comment?.comment?.metadata.name as string,
});
@ -90,7 +90,7 @@ const handleApproveReplyInBatch = async () => {
return !reply.reply.spec.approved;
});
const promises = repliesToUpdate?.map((reply) => {
return apiClient.extension.reply.patchContentHaloRunV1alpha1Reply({
return coreApiClient.content.reply.patchReply({
name: reply.reply.metadata.name,
jsonPatchInner: [
{
@ -121,7 +121,7 @@ const handleApproveReplyInBatch = async () => {
const handleApprove = async () => {
try {
await apiClient.extension.comment.patchContentHaloRunV1alpha1Comment({
await coreApiClient.content.comment.patchComment({
name: props.comment.comment.metadata.name,
jsonPatchInner: [
{
@ -157,7 +157,7 @@ const {
showReplies,
],
queryFn: async () => {
const { data } = await apiClient.reply.listReplies({
const { data } = await consoleApiClient.content.reply.listReplies({
commentName: props.comment.comment.metadata.name,
page: 0,
size: 0,
@ -176,7 +176,7 @@ const {
const { mutateAsync: updateCommentLastReadTimeMutate } = useMutation({
mutationKey: ["update-comment-last-read-time"],
mutationFn: async () => {
return apiClient.extension.comment.patchContentHaloRunV1alpha1Comment(
return coreApiClient.content.comment.patchComment(
{
name: props.comment.comment.metadata.name,
jsonPatchInner: [

View File

@ -18,7 +18,7 @@ import { Picker } from "emoji-mart";
import i18n from "@emoji-mart/data/i18n/zh.json";
import { onMounted, ref } from "vue";
import { setFocus } from "@/formkit/utils/focus";
import { apiClient } from "@/utils/api-client";
import { consoleApiClient } from "@halo-dev/api-client";
import { useI18n } from "vue-i18n";
const { t } = useI18n();
@ -62,7 +62,7 @@ const handleCreateReply = async () => {
formState.value.content = formState.value.raw;
await apiClient.comment.createReply({
await consoleApiClient.content.comment.createReply({
name: props.comment?.comment.metadata.name as string,
replyRequest: formState.value,
});

View File

@ -12,7 +12,7 @@ import {
} from "@halo-dev/components";
import type { ListedComment, ListedReply } from "@halo-dev/api-client";
import { formatDatetime } from "@/utils/date";
import { apiClient } from "@/utils/api-client";
import { coreApiClient } from "@halo-dev/api-client";
import { computed, inject, ref, type Ref } from "vue";
import { useI18n } from "vue-i18n";
import { useQueryClient } from "@tanstack/vue-query";
@ -54,7 +54,7 @@ const handleDelete = async () => {
cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => {
try {
await apiClient.extension.reply.deleteContentHaloRunV1alpha1Reply({
await coreApiClient.content.reply.deleteReply({
name: props.reply?.reply.metadata.name as string,
});
@ -70,7 +70,7 @@ const handleDelete = async () => {
const handleApprove = async () => {
try {
await apiClient.extension.reply.patchContentHaloRunV1alpha1Reply({
await coreApiClient.content.reply.patchReply({
name: props.reply.reply.metadata.name,
jsonPatchInner: [
{

View File

@ -19,7 +19,7 @@ import {
} from "@halo-dev/components";
import { ref, watch } from "vue";
import type { ListedSinglePage, SinglePage } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client";
import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import { formatDatetime } from "@/utils/date";
import { cloneDeep } from "lodash-es";
import { usePermission } from "@/utils/permission";
@ -46,7 +46,7 @@ const {
} = useQuery<ListedSinglePage[]>({
queryKey: ["deleted-singlePages", page, size, keyword],
queryFn: async () => {
const { data } = await apiClient.singlePage.listSinglePages({
const { data } = await consoleApiClient.content.singlePage.listSinglePages({
labelSelector: [`content.halo.run/deleted=true`],
page: page.value,
size: size.value,
@ -92,11 +92,9 @@ const handleDeletePermanently = async (singlePage: SinglePage) => {
confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => {
await apiClient.extension.singlePage.deleteContentHaloRunV1alpha1SinglePage(
{
name: singlePage.metadata.name,
}
);
await coreApiClient.content.singlePage.deleteSinglePage({
name: singlePage.metadata.name,
});
await refetch();
Toast.success(t("core.common.toast.delete_success"));
@ -114,11 +112,9 @@ const handleDeletePermanentlyInBatch = async () => {
onConfirm: async () => {
await Promise.all(
selectedPageNames.value.map((name) => {
return apiClient.extension.singlePage.deleteContentHaloRunV1alpha1SinglePage(
{
name,
}
);
return coreApiClient.content.singlePage.deleteSinglePage({
name,
});
})
);
await refetch();
@ -138,12 +134,10 @@ const handleRecovery = async (singlePage: SinglePage) => {
onConfirm: async () => {
const singlePageToUpdate = cloneDeep(singlePage);
singlePageToUpdate.spec.deleted = false;
await apiClient.extension.singlePage.updateContentHaloRunV1alpha1SinglePage(
{
name: singlePageToUpdate.metadata.name,
singlePage: singlePageToUpdate,
}
);
await coreApiClient.content.singlePage.updateSinglePage({
name: singlePageToUpdate.metadata.name,
singlePage: singlePageToUpdate,
});
await refetch();
Toast.success(t("core.common.toast.recovery_success"));
@ -170,18 +164,16 @@ const handleRecoveryInBatch = async () => {
return Promise.resolve();
}
return apiClient.extension.singlePage.updateContentHaloRunV1alpha1SinglePage(
{
name: singlePage.metadata.name,
singlePage: {
...singlePage,
spec: {
...singlePage.spec,
deleted: false,
},
return coreApiClient.content.singlePage.updateSinglePage({
name: singlePage.metadata.name,
singlePage: {
...singlePage,
spec: {
...singlePage.spec,
deleted: false,
},
}
);
},
});
})
);
await refetch();

View File

@ -24,7 +24,11 @@ import {
toRef,
watch,
} from "vue";
import { apiClient } from "@/utils/api-client";
import {
consoleApiClient,
coreApiClient,
ucApiClient,
} from "@halo-dev/api-client";
import { useRouteQuery } from "@vueuse/router";
import { useRouter } from "vue-router";
import { randomUUID } from "@/utils/id";
@ -156,10 +160,11 @@ const handleSave = async (options?: { mute?: boolean }) => {
).data;
}
const { data } = await apiClient.singlePage.updateSinglePageContent({
name: formState.value.page.metadata.name,
content: formState.value.content,
});
const { data } =
await consoleApiClient.content.singlePage.updateSinglePageContent({
name: formState.value.page.metadata.name,
content: formState.value.content,
});
formState.value.page = data;
isTitleChanged.value = false;
@ -167,9 +172,10 @@ const handleSave = async (options?: { mute?: boolean }) => {
// Clear new page content cache
handleClearCache();
const { data } = await apiClient.singlePage.draftSinglePage({
singlePageRequest: formState.value,
});
const { data } =
await consoleApiClient.content.singlePage.draftSinglePage({
singlePageRequest: formState.value,
});
formState.value.page = data;
routeQueryName.value = data.metadata.name;
}
@ -205,12 +211,12 @@ const handlePublish = async () => {
).data;
}
await apiClient.singlePage.updateSinglePageContent({
await consoleApiClient.content.singlePage.updateSinglePageContent({
name: singlePageName,
content: formState.value.content,
});
await apiClient.singlePage.publishSinglePage({
await consoleApiClient.content.singlePage.publishSinglePage({
name: singlePageName,
});
@ -221,7 +227,7 @@ const handlePublish = async () => {
}
} else {
formState.value.page.spec.publish = true;
await apiClient.singlePage.draftSinglePage({
await consoleApiClient.content.singlePage.draftSinglePage({
singlePageRequest: formState.value,
});
@ -254,9 +260,10 @@ const handleFetchContent = async () => {
if (!formState.value.page.spec.headSnapshot) {
return;
}
const { data } = await apiClient.singlePage.fetchSinglePageHeadContent({
name: formState.value.page.metadata.name,
});
const { data } =
await consoleApiClient.content.singlePage.fetchSinglePageHeadContent({
name: formState.value.page.metadata.name,
});
formState.value.content = Object.assign(formState.value.content, data);
@ -305,7 +312,7 @@ const handleFetchContent = async () => {
// SinglePage settings
const handleOpenSettingModal = async () => {
const { data: latestSinglePage } =
await apiClient.extension.singlePage.getContentHaloRunV1alpha1SinglePage({
await coreApiClient.content.singlePage.getSinglePage({
name: formState.value.page.metadata.name,
});
formState.value.page = latestSinglePage;
@ -335,7 +342,7 @@ onMounted(async () => {
if (routeQueryName.value) {
const { data: singlePage } =
await apiClient.extension.singlePage.getContentHaloRunV1alpha1SinglePage({
await coreApiClient.content.singlePage.getSinglePage({
name: routeQueryName.value,
});
formState.value.page = singlePage;
@ -412,7 +419,7 @@ async function handleUploadImage(file: File, options?: AxiosRequestConfig) {
await handleSave();
}
const { data } = await apiClient.uc.attachment.createAttachmentForPost(
const { data } = await ucApiClient.storage.attachment.createAttachmentForPost(
{
file,
singlePageName: formState.value.page.metadata.name,

View File

@ -19,7 +19,7 @@ import SinglePageSettingModal from "./components/SinglePageSettingModal.vue";
import type { Ref } from "vue";
import { computed, provide, ref, watch } from "vue";
import type { ListedSinglePage, SinglePage } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client";
import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import { singlePageLabels } from "@/constants/labels";
import { useQuery } from "@tanstack/vue-query";
import { useI18n } from "vue-i18n";
@ -114,7 +114,7 @@ const {
);
}
const { data } = await apiClient.singlePage.listSinglePages({
const { data } = await consoleApiClient.content.singlePage.listSinglePages({
labelSelector,
page: page.value,
size: size.value,
@ -143,10 +143,9 @@ const {
});
const handleOpenSettingModal = async (singlePage: SinglePage) => {
const { data } =
await apiClient.extension.singlePage.getContentHaloRunV1alpha1SinglePage({
name: singlePage.metadata.name,
});
const { data } = await coreApiClient.content.singlePage.getSinglePage({
name: singlePage.metadata.name,
});
selectedSinglePage.value = data;
settingModal.value = true;
};
@ -165,10 +164,9 @@ const handleSelectPrevious = async () => {
singlePage.page.metadata.name === selectedSinglePage.value?.metadata.name
);
if (index > 0) {
const { data } =
await apiClient.extension.singlePage.getContentHaloRunV1alpha1SinglePage({
name: singlePages.value[index - 1].page.metadata.name,
});
const { data } = await coreApiClient.content.singlePage.getSinglePage({
name: singlePages.value[index - 1].page.metadata.name,
});
selectedSinglePage.value = data;
return;
}
@ -188,10 +186,9 @@ const handleSelectNext = async () => {
singlePage.page.metadata.name === selectedSinglePage.value?.metadata.name
);
if (index < singlePages.value.length - 1) {
const { data } =
await apiClient.extension.singlePage.getContentHaloRunV1alpha1SinglePage({
name: singlePages.value[index + 1].page.metadata.name,
});
const { data } = await coreApiClient.content.singlePage.getSinglePage({
name: singlePages.value[index + 1].page.metadata.name,
});
selectedSinglePage.value = data;
return;
}
@ -240,18 +237,16 @@ const handleDeleteInBatch = async () => {
return Promise.resolve();
}
return apiClient.extension.singlePage.updateContentHaloRunV1alpha1SinglePage(
{
name: page.metadata.name,
singlePage: {
...page,
spec: {
...page.spec,
deleted: true,
},
return coreApiClient.content.singlePage.updateSinglePage({
name: page.metadata.name,
singlePage: {
...page,
spec: {
...page.spec,
deleted: true,
},
}
);
},
});
})
);
await refetch();

View File

@ -11,7 +11,7 @@ import {
} from "@halo-dev/components";
import { useQuery, useQueryClient } from "@tanstack/vue-query";
import { useRoute } from "vue-router";
import { apiClient } from "@/utils/api-client";
import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import { computed, watch } from "vue";
import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
import { useRouteQuery } from "@vueuse/router";
@ -28,10 +28,9 @@ const singlePageName = computed(() => route.query.name as string);
const { data: singlePage } = useQuery({
queryKey: ["singlePage-by-name", singlePageName],
queryFn: async () => {
const { data } =
await apiClient.extension.singlePage.getContentHaloRunV1alpha1SinglePage({
name: singlePageName.value,
});
const { data } = await coreApiClient.content.singlePage.getSinglePage({
name: singlePageName.value,
});
return data;
},
enabled: computed(() => !!singlePageName.value),
@ -40,9 +39,10 @@ const { data: singlePage } = useQuery({
const { data: snapshots, isLoading } = useQuery({
queryKey: ["singlePage-snapshots-by-singlePage-name", singlePageName],
queryFn: async () => {
const { data } = await apiClient.singlePage.listSinglePageSnapshots({
name: singlePageName.value,
});
const { data } =
await consoleApiClient.content.singlePage.listSinglePageSnapshots({
name: singlePageName.value,
});
return data;
},
refetchInterval(data) {
@ -99,7 +99,7 @@ function handleCleanup() {
}
for (let i = 0; i < snapshotsToDelete?.length; i++) {
await apiClient.singlePage.deleteSinglePageContent({
await consoleApiClient.content.singlePage.deleteSinglePageContent({
name: singlePageName.value,
snapshotName: snapshotsToDelete[i].metadata.name,
});

View File

@ -14,7 +14,7 @@ import {
} from "@halo-dev/components";
import { computed, ref } from "vue";
import type { ListedSinglePage, SinglePage } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client";
import { coreApiClient } from "@halo-dev/api-client";
import { formatDatetime } from "@/utils/date";
import { RouterLink } from "vue-router";
import { cloneDeep } from "lodash-es";
@ -72,12 +72,11 @@ const isPublishing = computed(() => {
const { mutate: changeVisibleMutation } = useMutation({
mutationFn: async (singlePage: SinglePage) => {
const { data } =
await apiClient.extension.singlePage.getContentHaloRunV1alpha1SinglePage({
name: singlePage.metadata.name,
});
const { data } = await coreApiClient.content.singlePage.getSinglePage({
name: singlePage.metadata.name,
});
data.spec.visible = data.spec.visible === "PRIVATE" ? "PUBLIC" : "PRIVATE";
await apiClient.extension.singlePage.updateContentHaloRunV1alpha1SinglePage(
await coreApiClient.content.singlePage.updateSinglePage(
{
name: singlePage.metadata.name,
singlePage: data,
@ -107,12 +106,10 @@ const handleDelete = async () => {
onConfirm: async () => {
const singlePageToUpdate = cloneDeep(props.singlePage.page);
singlePageToUpdate.spec.deleted = true;
await apiClient.extension.singlePage.updateContentHaloRunV1alpha1SinglePage(
{
name: props.singlePage.page.metadata.name,
singlePage: singlePageToUpdate,
}
);
await coreApiClient.content.singlePage.updateSinglePage({
name: props.singlePage.page.metadata.name,
singlePage: singlePageToUpdate,
});
await queryClient.invalidateQueries({ queryKey: ["singlePages"] });
Toast.success(t("core.common.toast.delete_success"));

View File

@ -2,7 +2,7 @@
import AnnotationsForm from "@/components/form/AnnotationsForm.vue";
import { singlePageLabels } from "@/constants/labels";
import { FormType } from "@/types/slug";
import { apiClient } from "@/utils/api-client";
import { coreApiClient } from "@halo-dev/api-client";
import { toDatetimeLocal, toISOString } from "@/utils/date";
import { randomUUID } from "@/utils/id";
import useSlugify from "@console/composables/use-slugify";
@ -134,11 +134,9 @@ const handleSave = async () => {
const { data } = isUpdateMode
? await singlePageUpdateMutate(formState.value)
: await apiClient.extension.singlePage.createContentHaloRunV1alpha1SinglePage(
{
singlePage: formState.value,
}
);
: await coreApiClient.content.singlePage.createSinglePage({
singlePage: formState.value,
});
formState.value = data;
emit("saved", data);
@ -183,13 +181,10 @@ const handlePublish = async () => {
singlePageToUpdate.spec.headSnapshot;
singlePageToUpdate.spec.publish = true;
const { data } =
await apiClient.extension.singlePage.updateContentHaloRunV1alpha1SinglePage(
{
name: formState.value.metadata.name,
singlePage: singlePageToUpdate,
}
);
const { data } = await coreApiClient.content.singlePage.updateSinglePage({
name: formState.value.metadata.name,
singlePage: singlePageToUpdate,
});
formState.value = data;
@ -210,20 +205,17 @@ const handleUnpublish = async () => {
publishCanceling.value = true;
const { data: singlePage } =
await apiClient.extension.singlePage.getContentHaloRunV1alpha1SinglePage({
await coreApiClient.content.singlePage.getSinglePage({
name: formState.value.metadata.name,
});
const singlePageToUpdate = cloneDeep(singlePage);
singlePageToUpdate.spec.publish = false;
const { data } =
await apiClient.extension.singlePage.updateContentHaloRunV1alpha1SinglePage(
{
name: formState.value.metadata.name,
singlePage: singlePageToUpdate,
}
);
const { data } = await coreApiClient.content.singlePage.updateSinglePage({
name: formState.value.metadata.name,
singlePage: singlePageToUpdate,
});
formState.value = data;

View File

@ -1,6 +1,6 @@
<script setup lang="ts">
import { useQuery } from "@tanstack/vue-query";
import { apiClient } from "@/utils/api-client";
import { consoleApiClient } from "@halo-dev/api-client";
import { computed, toRefs } from "vue";
import { Toast, VLoading } from "@halo-dev/components";
import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
@ -25,10 +25,11 @@ const { data: snapshot, isLoading } = useQuery({
throw new Error("singlePageName and snapshotName are required");
}
const { data } = await apiClient.singlePage.fetchSinglePageContent({
name: singlePageName.value,
snapshotName: snapshotName.value,
});
const { data } =
await consoleApiClient.content.singlePage.fetchSinglePageContent({
name: singlePageName.value,
snapshotName: snapshotName.value,
});
return data;
},
onError(err) {

View File

@ -1,6 +1,6 @@
<script setup lang="ts">
import type { ListedSnapshotDto, SinglePage } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client";
import { consoleApiClient } from "@halo-dev/api-client";
import { Dialog, Toast, VButton, VStatusDot, VTag } from "@halo-dev/components";
import { useQueryClient } from "@tanstack/vue-query";
import { computed } from "vue";
@ -29,12 +29,14 @@ async function handleRestore() {
confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"),
async onConfirm() {
await apiClient.singlePage.revertToSpecifiedSnapshotForSinglePage({
name: props.singlePage?.metadata.name as string,
revertSnapshotForSingleParam: {
snapshotName: props.snapshot.metadata.name,
},
});
await consoleApiClient.content.singlePage.revertToSpecifiedSnapshotForSinglePage(
{
name: props.singlePage?.metadata.name as string,
revertSnapshotForSingleParam: {
snapshotName: props.snapshot.metadata.name,
},
}
);
await queryClient.invalidateQueries({
queryKey: ["singlePage-snapshots-by-singlePage-name"],
});
@ -50,7 +52,7 @@ function handleDelete() {
confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"),
async onConfirm() {
await apiClient.singlePage.deleteSinglePageContent({
await consoleApiClient.content.singlePage.deleteSinglePageContent({
name: props.singlePage?.metadata.name as string,
snapshotName: props.snapshot.metadata.name,
});

View File

@ -1,4 +1,4 @@
import { apiClient } from "@/utils/api-client";
import { coreApiClient } from "@halo-dev/api-client";
import { useMutation } from "@tanstack/vue-query";
import type { SinglePage } from "@halo-dev/api-client";
import { Toast } from "@halo-dev/components";
@ -10,13 +10,11 @@ export function usePageUpdateMutate() {
mutationKey: ["singlePage-update"],
mutationFn: async (page: SinglePage) => {
const { data: latestSinglePage } =
await apiClient.extension.singlePage.getContentHaloRunV1alpha1SinglePage(
{
name: page.metadata.name,
}
);
await coreApiClient.content.singlePage.getSinglePage({
name: page.metadata.name,
});
return apiClient.extension.singlePage.updateContentHaloRunV1alpha1SinglePage(
return coreApiClient.content.singlePage.updateSinglePage(
{
name: page.metadata.name,
singlePage: {

View File

@ -1,13 +1,13 @@
<script lang="ts" setup>
import { VCard, IconPages } from "@halo-dev/components";
import { apiClient } from "@/utils/api-client";
import { consoleApiClient } from "@halo-dev/api-client";
import { singlePageLabels } from "@/constants/labels";
import { useQuery } from "@tanstack/vue-query";
const { data: total } = useQuery({
queryKey: ["widget-singlePage-count"],
queryFn: async () => {
const { data } = await apiClient.singlePage.listSinglePages({
const { data } = await consoleApiClient.content.singlePage.listSinglePages({
labelSelector: [
`${singlePageLabels.DELETED}=false`,
`${singlePageLabels.PUBLISHED}=true`,

View File

@ -20,7 +20,7 @@ import {
import PostTag from "./tags/components/PostTag.vue";
import { ref, watch } from "vue";
import type { ListedPost, Post } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client";
import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import { formatDatetime } from "@/utils/date";
import { usePermission } from "@/utils/permission";
import { cloneDeep } from "lodash-es";
@ -47,7 +47,7 @@ const {
} = useQuery<ListedPost[]>({
queryKey: ["deleted-posts", page, size, keyword],
queryFn: async () => {
const { data } = await apiClient.post.listPosts({
const { data } = await consoleApiClient.content.post.listPosts({
labelSelector: [`content.halo.run/deleted=true`],
page: page.value,
size: size.value,
@ -92,7 +92,7 @@ const handleDeletePermanently = async (post: Post) => {
confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => {
await apiClient.extension.post.deleteContentHaloRunV1alpha1Post({
await coreApiClient.content.post.deletePost({
name: post.metadata.name,
});
await refetch();
@ -112,7 +112,7 @@ const handleDeletePermanentlyInBatch = async () => {
onConfirm: async () => {
await Promise.all(
selectedPostNames.value.map((name) => {
return apiClient.extension.post.deleteContentHaloRunV1alpha1Post({
return coreApiClient.content.post.deletePost({
name,
});
})
@ -134,7 +134,7 @@ const handleRecovery = async (post: Post) => {
onConfirm: async () => {
const postToUpdate = cloneDeep(post);
postToUpdate.spec.deleted = false;
await apiClient.extension.post.updateContentHaloRunV1alpha1Post({
await coreApiClient.content.post.updatePost({
name: postToUpdate.metadata.name,
post: postToUpdate,
});
@ -165,7 +165,7 @@ const handleRecoveryInBatch = async () => {
return Promise.resolve();
}
return apiClient.extension.post.updateContentHaloRunV1alpha1Post({
return coreApiClient.content.post.updatePost({
name: post.metadata.name,
post: {
...post,

View File

@ -24,7 +24,11 @@ import {
toRef,
watch,
} from "vue";
import { apiClient } from "@/utils/api-client";
import {
consoleApiClient,
coreApiClient,
ucApiClient,
} from "@halo-dev/api-client";
import { useRouteQuery } from "@vueuse/router";
import { useRouter } from "vue-router";
import { randomUUID } from "@/utils/id";
@ -169,7 +173,7 @@ const handleSave = async (options?: { mute?: boolean }) => {
).data;
}
const { data } = await apiClient.post.updatePostContent({
const { data } = await consoleApiClient.content.post.updatePostContent({
name: formState.value.post.metadata.name,
content: formState.value.content,
});
@ -181,7 +185,7 @@ const handleSave = async (options?: { mute?: boolean }) => {
// Clear new post content cache
handleClearCache();
const { data } = await apiClient.post.draftPost({
const { data } = await consoleApiClient.content.post.draftPost({
postRequest: formState.value,
});
formState.value.post = data;
@ -218,12 +222,12 @@ const handlePublish = async () => {
).data;
}
await apiClient.post.updatePostContent({
await consoleApiClient.content.post.updatePostContent({
name: postName,
content: formState.value.content,
});
await apiClient.post.publishPost({
await consoleApiClient.content.post.publishPost({
name: postName,
});
@ -233,11 +237,11 @@ const handlePublish = async () => {
router.back();
}
} else {
const { data } = await apiClient.post.draftPost({
const { data } = await consoleApiClient.content.post.draftPost({
postRequest: formState.value,
});
await apiClient.post.publishPost({
await consoleApiClient.content.post.publishPost({
name: data.metadata.name,
});
@ -273,7 +277,7 @@ const handleFetchContent = async () => {
return;
}
const { data } = await apiClient.post.fetchPostHeadContent({
const { data } = await consoleApiClient.content.post.fetchPostHeadContent({
name: formState.value.post.metadata.name,
});
@ -326,10 +330,9 @@ const handleFetchContent = async () => {
};
const handleOpenSettingModal = async () => {
const { data: latestPost } =
await apiClient.extension.post.getContentHaloRunV1alpha1Post({
name: formState.value.post.metadata.name,
});
const { data: latestPost } = await coreApiClient.content.post.getPost({
name: formState.value.post.metadata.name,
});
formState.value.post = latestPost;
settingModal.value = true;
};
@ -360,10 +363,9 @@ onMounted(async () => {
if (name.value) {
// fetch post
const { data: post } =
await apiClient.extension.post.getContentHaloRunV1alpha1Post({
name: name.value as string,
});
const { data: post } = await coreApiClient.content.post.getPost({
name: name.value as string,
});
formState.value.post = post;
// fetch post content
@ -440,7 +442,7 @@ async function handleUploadImage(file: File, options?: AxiosRequestConfig) {
await handleSave();
}
const { data } = await apiClient.uc.attachment.createAttachmentForPost(
const { data } = await ucApiClient.storage.attachment.createAttachmentForPost(
{
file,
postName: formState.value.post.metadata.name,

View File

@ -19,7 +19,7 @@ import PostSettingModal from "./components/PostSettingModal.vue";
import type { Ref } from "vue";
import { computed, provide, ref, watch } from "vue";
import type { ListedPost, Post } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client";
import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import { postLabels } from "@/constants/labels";
import { useQuery } from "@tanstack/vue-query";
import { useI18n } from "vue-i18n";
@ -135,7 +135,7 @@ const {
labelSelector.push(selectedPublishStatus.value);
}
const { data } = await apiClient.post.listPosts({
const { data } = await consoleApiClient.content.post.listPosts({
labelSelector,
fieldSelector,
page: page.value,
@ -183,11 +183,9 @@ const {
});
const handleOpenSettingModal = async (post: Post) => {
const { data } = await apiClient.extension.post.getContentHaloRunV1alpha1Post(
{
name: post.metadata.name,
}
);
const { data } = await coreApiClient.content.post.getPost({
name: post.metadata.name,
});
selectedPost.value = data;
settingModal.value = true;
};
@ -206,10 +204,9 @@ const handleSelectPrevious = async () => {
);
if (index > 0) {
const { data: previousPost } =
await apiClient.extension.post.getContentHaloRunV1alpha1Post({
name: posts.value[index - 1].post.metadata.name,
});
const { data: previousPost } = await coreApiClient.content.post.getPost({
name: posts.value[index - 1].post.metadata.name,
});
selectedPost.value = previousPost;
return;
}
@ -227,10 +224,9 @@ const handleSelectNext = async () => {
(post) => post.post.metadata.name === selectedPost.value?.metadata.name
);
if (index < posts.value.length - 1) {
const { data: nextPost } =
await apiClient.extension.post.getContentHaloRunV1alpha1Post({
name: posts.value[index + 1].post.metadata.name,
});
const { data: nextPost } = await coreApiClient.content.post.getPost({
name: posts.value[index + 1].post.metadata.name,
});
selectedPost.value = nextPost;
return;
}
@ -271,7 +267,7 @@ const handleDeleteInBatch = async () => {
onConfirm: async () => {
await Promise.all(
selectedPostNames.value.map((name) => {
return apiClient.post.recyclePost({
return consoleApiClient.content.post.recyclePost({
name,
});
})

View File

@ -11,7 +11,7 @@ import {
} from "@halo-dev/components";
import { useQuery, useQueryClient } from "@tanstack/vue-query";
import { useRoute } from "vue-router";
import { apiClient } from "@/utils/api-client";
import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import { computed, watch } from "vue";
import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
import { useRouteQuery } from "@vueuse/router";
@ -28,10 +28,9 @@ const postName = computed(() => route.query.name as string);
const { data: post } = useQuery({
queryKey: ["post-by-name", postName],
queryFn: async () => {
const { data } =
await apiClient.extension.post.getContentHaloRunV1alpha1Post({
name: postName.value,
});
const { data } = await coreApiClient.content.post.getPost({
name: postName.value,
});
return data;
},
enabled: computed(() => !!postName.value),
@ -40,7 +39,7 @@ const { data: post } = useQuery({
const { data: snapshots, isLoading } = useQuery({
queryKey: ["post-snapshots-by-post-name", postName],
queryFn: async () => {
const { data } = await apiClient.post.listPostSnapshots({
const { data } = await consoleApiClient.content.post.listPostSnapshots({
name: postName.value,
});
return data;
@ -99,7 +98,7 @@ function handleCleanup() {
}
for (let i = 0; i < snapshotsToDelete?.length; i++) {
await apiClient.post.deletePostContent({
await consoleApiClient.content.post.deletePostContent({
name: postName.value,
snapshotName: snapshotsToDelete[i].metadata.name,
});

View File

@ -1,7 +1,7 @@
<script lang="ts" setup>
// core libs
import { ref } from "vue";
import { apiClient } from "@/utils/api-client";
import { coreApiClient } from "@halo-dev/api-client";
// components
import {
@ -40,7 +40,7 @@ const handleUpdateInBatch = useDebounceFn(async () => {
try {
batchUpdating.value = true;
const promises = categoriesToUpdate.map((category) =>
apiClient.extension.category.updateContentHaloRunV1alpha1Category({
coreApiClient.content.category.updateCategory({
name: category.metadata.name,
category: category,
})

View File

@ -1,9 +1,13 @@
<script lang="ts" setup>
// core libs
import { computed, nextTick, onMounted, ref } from "vue";
import { coreApiClient } from "@halo-dev/api-client";
// components
import SubmitButton from "@/components/button/SubmitButton.vue";
import AnnotationsForm from "@/components/form/AnnotationsForm.vue";
import { setFocus } from "@/formkit/utils/focus";
import { FormType } from "@/types/slug";
import { apiClient } from "@/utils/api-client";
import useSlugify from "@console/composables/use-slugify";
import { useThemeCustomTemplates } from "@console/modules/interface/themes/composables/use-theme";
import type { Category } from "@halo-dev/api-client";
@ -16,7 +20,6 @@ import {
} from "@halo-dev/components";
import { useQueryClient } from "@tanstack/vue-query";
import { cloneDeep } from "lodash-es";
import { computed, nextTick, onMounted, ref } from "vue";
import { useI18n } from "vue-i18n";
const props = withDefaults(
@ -87,7 +90,7 @@ const handleSaveCategory = async () => {
try {
saving.value = true;
if (isUpdateMode) {
await apiClient.extension.category.updateContentHaloRunV1alpha1Category({
await coreApiClient.content.category.updateCategory({
name: formState.value.metadata.name,
category: formState.value,
});
@ -96,10 +99,9 @@ const handleSaveCategory = async () => {
let parentCategory: Category | undefined = undefined;
if (selectedParentCategory.value) {
const { data } =
await apiClient.extension.category.getContentHaloRunV1alpha1Category({
name: selectedParentCategory.value,
});
const { data } = await coreApiClient.content.category.getCategory({
name: selectedParentCategory.value,
});
parentCategory = data;
}
@ -110,11 +112,9 @@ const handleSaveCategory = async () => {
formState.value.spec.priority = priority;
const { data: createdCategory } =
await apiClient.extension.category.createContentHaloRunV1alpha1Category(
{
category: formState.value,
}
);
await coreApiClient.content.category.createCategory({
category: formState.value,
});
if (parentCategory) {
parentCategory.spec.children = Array.from(
@ -124,12 +124,10 @@ const handleSaveCategory = async () => {
])
);
await apiClient.extension.category.updateContentHaloRunV1alpha1Category(
{
name: selectedParentCategory.value,
category: parentCategory,
}
);
await coreApiClient.content.category.updateCategory({
name: selectedParentCategory.value,
category: parentCategory,
});
}
}

View File

@ -1,5 +1,4 @@
<script lang="ts" setup>
import { apiClient } from "@/utils/api-client";
import { formatDatetime } from "@/utils/date";
import { usePermission } from "@/utils/permission";
import type { Category } from "@halo-dev/api-client";
@ -17,6 +16,7 @@ import type { PropType } from "vue";
import { ref } from "vue";
import { VueDraggable } from "vue-draggable-plus";
import { useI18n } from "vue-i18n";
import { coreApiClient } from "@halo-dev/api-client";
import GridiconsLinkBreak from "~icons/gridicons/link-break";
import { convertCategoryTreeToCategory, type CategoryTree } from "../utils";
import CategoryEditingModal from "./CategoryEditingModal.vue";
@ -69,11 +69,9 @@ const handleDelete = async (category: CategoryTree) => {
cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => {
try {
await apiClient.extension.category.deleteContentHaloRunV1alpha1Category(
{
name: category.metadata.name,
}
);
await coreApiClient.content.category.deleteCategory({
name: category.metadata.name,
});
Toast.success(t("core.common.toast.delete_success"));

View File

@ -1,4 +1,4 @@
import { apiClient } from "@/utils/api-client";
import { coreApiClient } from "@halo-dev/api-client";
import type { Category } from "@halo-dev/api-client";
import type { Ref } from "vue";
import { ref } from "vue";
@ -23,12 +23,11 @@ export function usePostCategory(): usePostCategoryReturn {
} = useQuery({
queryKey: ["post-categories"],
queryFn: async () => {
const { data } =
await apiClient.extension.category.listContentHaloRunV1alpha1Category({
page: 0,
size: 0,
sort: ["metadata.creationTimestamp,desc"],
});
const { data } = await coreApiClient.content.category.listCategory({
page: 0,
size: 0,
sort: ["metadata.creationTimestamp,desc"],
});
return data.items;
},

View File

@ -9,7 +9,7 @@ import {
import type { ListedPost, Post } from "@halo-dev/api-client";
import { useI18n } from "vue-i18n";
import { usePermission } from "@/utils/permission";
import { apiClient } from "@/utils/api-client";
import { consoleApiClient } from "@halo-dev/api-client";
import { useQueryClient } from "@tanstack/vue-query";
import type { Ref } from "vue";
import { computed, inject, markRaw, ref, toRefs } from "vue";
@ -58,7 +58,7 @@ const handleDelete = async () => {
confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => {
await apiClient.post.recyclePost({
await consoleApiClient.content.post.recyclePost({
name: props.post.post.metadata.name,
});
await queryClient.invalidateQueries({ queryKey: ["posts"] });
@ -77,7 +77,7 @@ const { operationItems } = useOperationItemExtensionPoint<ListedPost>(
component: markRaw(VDropdownItem),
label: t("core.common.buttons.publish"),
action: async () => {
await apiClient.post.publishPost({
await consoleApiClient.content.post.publishPost({
name: props.post.post.metadata.name,
});
@ -125,7 +125,7 @@ const { operationItems } = useOperationItemExtensionPoint<ListedPost>(
},
label: t("core.common.buttons.cancel_publish"),
action: async () => {
await apiClient.post.unpublishPost({
await consoleApiClient.content.post.unpublishPost({
name: props.post.post.metadata.name,
});

View File

@ -8,7 +8,7 @@ import {
} from "@halo-dev/components";
import { computed, nextTick, ref, watch } from "vue";
import type { Post } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client";
import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import { useThemeCustomTemplates } from "@console/modules/interface/themes/composables/use-theme";
import { postLabels } from "@/constants/labels";
import { randomUUID } from "@/utils/id";
@ -137,7 +137,7 @@ const handleSave = async () => {
const { data } = isUpdateMode.value
? await postUpdateMutate(formState.value)
: await apiClient.extension.post.createContentHaloRunV1alpha1Post({
: await coreApiClient.content.post.createPost({
post: formState.value,
});
@ -166,7 +166,7 @@ const handlePublish = async () => {
await postUpdateMutate(formState.value);
const { data } = await apiClient.post.publishPost({
const { data } = await consoleApiClient.content.post.publishPost({
name: formState.value.metadata.name,
});
@ -188,7 +188,7 @@ const handleUnpublish = async () => {
try {
publishCanceling.value = true;
await apiClient.post.unpublishPost({
await consoleApiClient.content.post.unpublishPost({
name: formState.value.metadata.name,
});

View File

@ -1,6 +1,6 @@
<script setup lang="ts">
import { useQuery } from "@tanstack/vue-query";
import { apiClient } from "@/utils/api-client";
import { consoleApiClient } from "@halo-dev/api-client";
import { computed, toRefs } from "vue";
import { Toast, VLoading } from "@halo-dev/components";
import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
@ -25,7 +25,7 @@ const { data: snapshot, isLoading } = useQuery({
throw new Error("postName and snapshotName are required");
}
const { data } = await apiClient.post.fetchPostContent({
const { data } = await consoleApiClient.content.post.fetchPostContent({
name: postName.value,
snapshotName: snapshotName.value,
});

View File

@ -1,6 +1,6 @@
<script setup lang="ts">
import type { ListedSnapshotDto, Post } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client";
import { consoleApiClient } from "@halo-dev/api-client";
import { Dialog, Toast, VButton, VStatusDot, VTag } from "@halo-dev/components";
import { useQueryClient } from "@tanstack/vue-query";
import { computed } from "vue";
@ -29,7 +29,7 @@ async function handleRestore() {
confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"),
async onConfirm() {
await apiClient.post.revertToSpecifiedSnapshotForPost({
await consoleApiClient.content.post.revertToSpecifiedSnapshotForPost({
name: props.post?.metadata.name as string,
revertSnapshotForPostParam: {
snapshotName: props.snapshot.metadata.name,
@ -50,7 +50,7 @@ function handleDelete() {
confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"),
async onConfirm() {
await apiClient.post.deletePostContent({
await consoleApiClient.content.post.deletePostContent({
name: props.post?.metadata.name as string,
snapshotName: props.snapshot.metadata.name,
});

View File

@ -2,7 +2,7 @@
import { postLabels } from "@/constants/labels";
import { formatDatetime } from "@/utils/date";
import { IconTimerLine, VEntityField } from "@halo-dev/components";
import type { ListedPost } from "packages/api-client/dist";
import type { ListedPost } from "@halo-dev/api-client";
withDefaults(
defineProps<{

View File

@ -1,5 +1,5 @@
<script lang="ts" setup>
import { apiClient } from "@/utils/api-client";
import { coreApiClient } from "@halo-dev/api-client";
import type { ListedPost, Post } from "@halo-dev/api-client";
import { IconEye, IconEyeOff, Toast, VEntityField } from "@halo-dev/components";
import { useMutation, useQueryClient } from "@tanstack/vue-query";
@ -17,12 +17,11 @@ withDefaults(
const { mutate: changeVisibleMutation } = useMutation({
mutationFn: async (post: Post) => {
const { data } =
await apiClient.extension.post.getContentHaloRunV1alpha1Post({
name: post.metadata.name,
});
const { data } = await coreApiClient.content.post.getPost({
name: post.metadata.name,
});
data.spec.visible = data.spec.visible === "PRIVATE" ? "PUBLIC" : "PRIVATE";
await apiClient.extension.post.updateContentHaloRunV1alpha1Post(
await coreApiClient.content.post.updatePost(
{
name: post.metadata.name,
post: data,

View File

@ -1,6 +1,6 @@
import { useMutation } from "@tanstack/vue-query";
import type { Post } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client";
import { coreApiClient } from "@halo-dev/api-client";
import { Toast } from "@halo-dev/components";
import { useI18n } from "vue-i18n";
@ -10,12 +10,11 @@ export function usePostUpdateMutate() {
return useMutation({
mutationKey: ["post-update"],
mutationFn: async (post: Post) => {
const { data: latestPost } =
await apiClient.extension.post.getContentHaloRunV1alpha1Post({
name: post.metadata.name,
});
const { data: latestPost } = await coreApiClient.content.post.getPost({
name: post.metadata.name,
});
return await apiClient.extension.post.updateContentHaloRunV1alpha1Post(
return await coreApiClient.content.post.updatePost(
{
name: post.metadata.name,
post: {

View File

@ -16,7 +16,7 @@ import {
import HasPermission from "@/components/permission/HasPermission.vue";
import TagEditingModal from "./components/TagEditingModal.vue";
import { useRouteQuery } from "@vueuse/router";
import { apiClient } from "@/utils/api-client";
import { coreApiClient } from "@halo-dev/api-client";
import { usePostTag } from "./composables/use-post-tag";
import TagListItem from "./components/TagListItem.vue";
import SearchInput from "@/components/input/SearchInput.vue";
@ -142,11 +142,9 @@ const queryName = useRouteQuery("name");
onMounted(async () => {
if (queryName.value) {
const { data } = await apiClient.extension.tag.getContentHaloRunV1alpha1Tag(
{
name: queryName.value as string,
}
);
const { data } = await coreApiClient.content.tag.getTag({
name: queryName.value as string,
});
selectedTag.value = data;
editingModal.value = true;
}

View File

@ -1,7 +1,7 @@
<script lang="ts" setup>
// core libs
import { computed, nextTick, ref, watch } from "vue";
import { apiClient } from "@/utils/api-client";
import { coreApiClient } from "@halo-dev/api-client";
// components
import {
@ -91,12 +91,12 @@ const handleSaveTag = async () => {
try {
saving.value = true;
if (isUpdateMode.value) {
await apiClient.extension.tag.updateContentHaloRunV1alpha1Tag({
await coreApiClient.content.tag.updateTag({
name: formState.value.metadata.name,
tag: formState.value,
});
} else {
await apiClient.extension.tag.createContentHaloRunV1alpha1Tag({
await coreApiClient.content.tag.createTag({
tag: formState.value,
});
}

View File

@ -1,4 +1,4 @@
import { apiClient } from "@/utils/api-client";
import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import type { Tag } from "@halo-dev/api-client";
import { ref, watch, type Ref } from "vue";
import { Dialog, Toast } from "@halo-dev/components";
@ -39,7 +39,7 @@ export function usePostTag(filterOptions?: {
} = useQuery({
queryKey: ["post-tags", sort, page, size, keyword],
queryFn: async () => {
const { data } = await apiClient.tag.listPostTags({
const { data } = await consoleApiClient.content.tag.listPostTags({
page: page?.value || 0,
size: size?.value || 0,
sort: [sort?.value as string].filter(Boolean) || [
@ -71,7 +71,7 @@ export function usePostTag(filterOptions?: {
cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => {
try {
await apiClient.extension.tag.deleteContentHaloRunV1alpha1Tag({
await coreApiClient.content.tag.deleteTag({
name: tag.metadata.name,
});
@ -97,7 +97,7 @@ export function usePostTag(filterOptions?: {
try {
await Promise.all(
tagNames.map((tagName) => {
apiClient.extension.tag.deleteContentHaloRunV1alpha1Tag({
coreApiClient.content.tag.deleteTag({
name: tagName,
});
})

View File

@ -7,7 +7,7 @@ import {
IconExternalLinkLine,
} from "@halo-dev/components";
import type { ListedPost } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client";
import { consoleApiClient } from "@halo-dev/api-client";
import { formatDatetime } from "@/utils/date";
import { postLabels } from "@/constants/labels";
import { useQuery } from "@tanstack/vue-query";
@ -16,7 +16,7 @@ import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
const { data } = useQuery<ListedPost[]>({
queryKey: ["widget-recent-posts"],
queryFn: async () => {
const { data } = await apiClient.post.listPosts({
const { data } = await consoleApiClient.content.post.listPosts({
labelSelector: [
`${postLabels.DELETED}=false`,
`${postLabels.PUBLISHED}=true`,

View File

@ -18,7 +18,7 @@ import {
import { markRaw, ref, type Component } from "vue";
import { useRouter } from "vue-router";
import ThemePreviewModal from "@console/modules/interface/themes/components/preview/ThemePreviewModal.vue";
import { apiClient } from "@/utils/api-client";
import { consoleApiClient } from "@halo-dev/api-client";
import { useI18n } from "vue-i18n";
import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
@ -143,7 +143,7 @@ const actions: Action[] = [
confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => {
await apiClient.indices.buildPostIndices();
await consoleApiClient.content.indices.buildPostIndices();
Toast.success(
t(
"core.dashboard.widgets.presets.quicklink.actions.refresh_search_engine.success_message"
@ -170,7 +170,7 @@ const actions: Action[] = [
confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => {
await apiClient.cache.evictCache({ name: "page" });
await consoleApiClient.cache.evictCache({ name: "page" });
Toast.success(
t(
"core.dashboard.widgets.presets.quicklink.actions.evict_page_cache.success_message"

View File

@ -15,7 +15,7 @@ import MenuItemEditingModal from "./components/MenuItemEditingModal.vue";
import MenuItemListItem from "./components/MenuItemListItem.vue";
import MenuList from "./components/MenuList.vue";
import { computed, ref } from "vue";
import { apiClient } from "@/utils/api-client";
import { coreApiClient } from "@halo-dev/api-client";
import type { Menu, MenuItem } from "@halo-dev/api-client";
import { cloneDeep } from "lodash-es";
import type { MenuTreeItem } from "./utils";
@ -51,7 +51,7 @@ const {
}
const menuItemNames = selectedMenu.value.spec.menuItems.filter(Boolean);
const { data } = await apiClient.extension.menuItem.listV1alpha1MenuItem({
const { data } = await coreApiClient.menuItem.listMenuItem({
page: 0,
size: 0,
fieldSelector: [`name=(${menuItemNames.join(",")})`],
@ -72,8 +72,8 @@ const {
});
const handleOpenEditingModal = (menuItem: MenuTreeItem) => {
apiClient.extension.menuItem
.getV1alpha1MenuItem({
coreApiClient.menuItem
.getMenuItem({
name: menuItem.metadata.name,
})
.then((response) => {
@ -106,7 +106,7 @@ const onMenuItemSaved = async (menuItem: MenuItem) => {
menuItem.metadata.name,
];
await apiClient.extension.menu.updateV1alpha1Menu({
await coreApiClient.menu.updateMenu({
name: menuToUpdate.metadata.name,
menu: menuToUpdate,
});
@ -124,7 +124,7 @@ const handleUpdateInBatch = useDebounceFn(async () => {
try {
batchUpdating.value = true;
const promises = menuItemsToUpdate.map((menuItem) =>
apiClient.extension.menuItem.updateV1alpha1MenuItem({
coreApiClient.menuItem.updateMenuItem({
name: menuItem.metadata.name,
menuItem,
})
@ -147,7 +147,7 @@ const handleDelete = async (menuItem: MenuTreeItem) => {
confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => {
await apiClient.extension.menuItem.deleteV1alpha1MenuItem({
await coreApiClient.menuItem.deleteMenuItem({
name: menuItem.metadata.name,
});
@ -155,7 +155,7 @@ const handleDelete = async (menuItem: MenuTreeItem) => {
if (childrenNames.length) {
const deleteChildrenRequests = childrenNames.map((name) =>
apiClient.extension.menuItem.deleteV1alpha1MenuItem({
coreApiClient.menuItem.deleteMenuItem({
name,
})
);
@ -170,7 +170,7 @@ const handleDelete = async (menuItem: MenuTreeItem) => {
menuToUpdate.spec.menuItems = menuToUpdate.spec.menuItems?.filter(
(name) => ![menuItem.metadata.name, ...childrenNames].includes(name)
);
await apiClient.extension.menu.updateV1alpha1Menu({
await coreApiClient.menu.updateMenu({
name: menuToUpdate.metadata.name,
menu: menuToUpdate,
});

View File

@ -3,7 +3,7 @@ import { Toast, VButton, VModal, VSpace } from "@halo-dev/components";
import SubmitButton from "@/components/button/SubmitButton.vue";
import type { Menu } from "@halo-dev/api-client";
import { onMounted, ref } from "vue";
import { apiClient } from "@/utils/api-client";
import { coreApiClient } from "@halo-dev/api-client";
import { setFocus } from "@/formkit/utils/focus";
import { useI18n } from "vue-i18n";
import { useQueryClient } from "@tanstack/vue-query";
@ -51,12 +51,12 @@ const handleSaveMenu = async () => {
try {
saving.value = true;
if (props.menu) {
await apiClient.extension.menu.updateV1alpha1Menu({
await coreApiClient.menu.updateMenu({
name: formState.value.metadata.name,
menu: formState.value,
});
} else {
const { data } = await apiClient.extension.menu.createV1alpha1Menu({
const { data } = await coreApiClient.menu.createMenu({
menu: formState.value,
});
emit("created", data);

View File

@ -3,7 +3,7 @@ import { Toast, VButton, VModal, VSpace } from "@halo-dev/components";
import SubmitButton from "@/components/button/SubmitButton.vue";
import { computed, nextTick, onMounted, ref } from "vue";
import type { Menu, MenuItem, Ref } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client";
import { coreApiClient } from "@halo-dev/api-client";
import { setFocus } from "@/formkit/utils/focus";
import AnnotationsForm from "@/components/form/AnnotationsForm.vue";
import { useI18n } from "vue-i18n";
@ -87,23 +87,21 @@ const handleSaveMenuItem = async () => {
}
if (isUpdateMode) {
const { data } =
await apiClient.extension.menuItem.updateV1alpha1MenuItem({
name: formState.value.metadata.name,
menuItem: formState.value,
});
const { data } = await coreApiClient.menuItem.updateMenuItem({
name: formState.value.metadata.name,
menuItem: formState.value,
});
emit("saved", data);
} else {
const { data } =
await apiClient.extension.menuItem.createV1alpha1MenuItem({
menuItem: formState.value,
});
const { data } = await coreApiClient.menuItem.createMenuItem({
menuItem: formState.value,
});
// if parent menu item is selected, add the new menu item to the parent menu item
if (selectedParentMenuItem.value) {
const { data: menuItemToUpdate } =
await apiClient.extension.menuItem.getV1alpha1MenuItem({
await coreApiClient.menuItem.getMenuItem({
name: selectedParentMenuItem.value,
});
@ -112,7 +110,7 @@ const handleSaveMenuItem = async () => {
data.metadata.name,
];
await apiClient.extension.menuItem.updateV1alpha1MenuItem({
await coreApiClient.menuItem.updateMenuItem({
name: menuItemToUpdate.metadata.name,
menuItem: menuItemToUpdate,
});

View File

@ -16,7 +16,7 @@ import {
import MenuEditingModal from "./MenuEditingModal.vue";
import { onMounted, ref } from "vue";
import type { Menu } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client";
import { coreApiClient } from "@halo-dev/api-client";
import { useRouteQuery } from "@vueuse/router";
import { usePermission } from "@/utils/permission";
import { useI18n } from "vue-i18n";
@ -48,7 +48,7 @@ const {
} = useQuery<Menu[]>({
queryKey: ["menus"],
queryFn: async () => {
const { data } = await apiClient.extension.menu.listV1alpha1Menu({
const { data } = await coreApiClient.menu.listMenu({
page: 0,
size: 0,
});
@ -87,12 +87,12 @@ const handleDeleteMenu = async (menu: Menu) => {
cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => {
try {
await apiClient.extension.menu.deleteV1alpha1Menu({
await coreApiClient.menu.deleteMenu({
name: menu.metadata.name,
});
const deleteItemsPromises = menu.spec.menuItems?.map((item) =>
apiClient.extension.menuItem.deleteV1alpha1MenuItem({
coreApiClient.menuItem.deleteMenuItem({
name: item,
})
);
@ -138,7 +138,7 @@ onMounted(async () => {
const { data: primaryMenuName, refetch: refetchPrimaryMenuName } = useQuery({
queryKey: ["primary-menu-name"],
queryFn: async () => {
const { data } = await apiClient.extension.configMap.getV1alpha1ConfigMap({
const { data } = await coreApiClient.configMap.getConfigMap({
name: "system",
});
@ -153,17 +153,16 @@ const { data: primaryMenuName, refetch: refetchPrimaryMenuName } = useQuery({
});
const handleSetPrimaryMenu = async (menu: Menu) => {
const { data: systemConfigMap } =
await apiClient.extension.configMap.getV1alpha1ConfigMap({
name: "system",
});
const { data: systemConfigMap } = await coreApiClient.configMap.getConfigMap({
name: "system",
});
if (systemConfigMap.data) {
const menuConfigToUpdate = JSON.parse(systemConfigMap.data?.menu || "{}");
menuConfigToUpdate.primary = menu.metadata.name;
systemConfigMap.data["menu"] = JSON.stringify(menuConfigToUpdate);
await apiClient.extension.configMap.updateV1alpha1ConfigMap({
await coreApiClient.configMap.updateConfigMap({
name: "system",
configMap: systemConfigMap,
});

View File

@ -1,6 +1,4 @@
<script lang="ts" setup>
import { apiClient } from "@/utils/api-client";
import type { Theme } from "@halo-dev/api-client";
import {
Dialog,
IconMore,
@ -14,6 +12,9 @@ import {
VStatusDot,
VTag,
} from "@halo-dev/components";
import type { Theme } from "@halo-dev/api-client";
import { consoleApiClient } from "@halo-dev/api-client";
import type { Ref } from "vue";
import { inject, ref } from "vue";
import { useI18n } from "vue-i18n";
@ -39,7 +40,7 @@ async function handleClearCache() {
return;
}
await apiClient.theme.invalidateCache({
await consoleApiClient.theme.theme.invalidateCache({
name: selectedTheme.value?.metadata.name,
});
@ -60,7 +61,7 @@ const handleReloadTheme = async () => {
return;
}
await apiClient.theme.reload({
await consoleApiClient.theme.theme.reload({
name: selectedTheme.value.metadata.name as string,
});

View File

@ -10,7 +10,7 @@ import type { Ref } from "vue";
import type { ConfigMap, Setting, Theme } from "@halo-dev/api-client";
// hooks
import { apiClient } from "@/utils/api-client";
import { consoleApiClient } from "@halo-dev/api-client";
import { useSettingFormConvert } from "@console/composables/use-setting-form";
import { useI18n } from "vue-i18n";
import { useQuery, useQueryClient } from "@tanstack/vue-query";
@ -29,7 +29,7 @@ const saving = ref(false);
const { data: configMap, suspense } = useQuery<ConfigMap>({
queryKey: ["theme-configMap", selectedTheme],
queryFn: async () => {
const { data } = await apiClient.theme.fetchThemeConfig({
const { data } = await consoleApiClient.theme.theme.fetchThemeConfig({
name: selectedTheme?.value?.metadata.name as string,
});
return data;
@ -55,7 +55,7 @@ const handleSaveConfigMap = async () => {
return;
}
await apiClient.theme.updateThemeConfig({
await consoleApiClient.theme.theme.updateThemeConfig({
name: selectedTheme?.value?.metadata.name,
configMap: configMapToUpdate,
});

View File

@ -10,7 +10,7 @@ import {
VSpace,
} from "@halo-dev/components";
import type { Theme } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client";
import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import { toRefs, ref, inject, type Ref } from "vue";
import { useThemeLifeCycle } from "../composables/use-theme";
import { usePermission } from "@/utils/permission";
@ -63,13 +63,12 @@ const handleCreateTheme = async () => {
try {
creating.value = true;
const { data } =
await apiClient.extension.theme.createThemeHaloRunV1alpha1Theme({
theme: props.theme,
});
const { data } = await coreApiClient.theme.theme.createTheme({
theme: props.theme,
});
// create theme settings
apiClient.theme.reload({ name: data.metadata.name });
consoleApiClient.theme.theme.reload({ name: data.metadata.name });
activeTabId.value = "installed";

Some files were not shown because too many files have changed in this diff Show More