* feat(mq): implement Apache Pulsar message queue admin - Add complete MQ admin adapter layer with version detection * Pulsar adapter with multi-version API support * OAuth2 token caching and authentication * JWT token signing for Pulsar clients * Transport layer (SSH/Proxy) integration - Implement comprehensive admin operations * Tenant, namespace, topic management * Subscription and consumer/producer monitoring * Rate limits, backlog quotas, retention policies * Permissions and role-based access control * Raw admin API for advanced operations - Add desktop UI components * MQ admin console with tabbed interface * Tenant, namespace, topic panels * Subscription management and cursor operations * Monitoring panel with stats visualization * Policy configuration UI - Add web routes for MQ admin operations - Add secret store support for MQ auth credentials - Add comprehensive test coverage * fix: del local test files * fix(mq): mark message queue as unsupported mcpMode in driver manifest MQ admin connections do not use the MCP query bridge - they use a separate REST admin API. Mark mcpMode as 'unsupported' to align with the test expectations and reflect the actual architecture. Fixes CI test: driver-manifest.test.ts * fix(mq): fix TypeScript errors in MQ components - Fix typo in SubscriptionsPanel.vue: messagformatError(e)Id -> message.messageId - Use formatError() helper in RawApiPanel.vue instead of accessing e?.message - Fix undefined 'tab' reference in ConnectionTree.vue: use config.db_type instead Fixes frontend CI TypeScript check errors. * fix(mcp): add 'mq' to MCP server connection type description The MCP server's connection type description must include all database types from the driver manifest. Add 'mq' to the list to fix the test: 'add connection database type description includes every manifest database type' Fixes: packages/mcp-server/tests/driver-manifest.test.ts * fix(mq): add missing ConnectionConfig fields for Rust compilation - Add gbase_server and keepalive_interval_secs fields to all ConnectionConfig test constructors in mq/config.rs, mq/service.rs, and storage.rs - Import uses_bare_mysql_pool in connection.rs tests module Fixes compilation errors from upstream ConnectionConfig changes. * chore(ui): simplify Pulsar icon to logo-only version Remove text from Pulsar icon (127x30 -> 35x30), keeping only the wave logo symbol for a cleaner, more consistent appearance with other database icons. * fix(mq): return removed pools from drain_connection_pools --------- Co-authored-by: t8y2 <1156263951@qq.com>
207 lines
8.4 KiB
TypeScript
207 lines
8.4 KiB
TypeScript
// HTTP fetch API for message queue admin (web mode)
|
|
import type {
|
|
MqClusterInfo,
|
|
TenantInfo,
|
|
TenantConfig,
|
|
NamespaceRef,
|
|
NamespaceInfo,
|
|
NamespaceConfig,
|
|
TopicRef,
|
|
TopicInfo,
|
|
ListTopicsOpts,
|
|
TopicStats,
|
|
SubscriptionInfo,
|
|
ResetPosition,
|
|
SkipCount,
|
|
ConsumerInfo,
|
|
ProducerInfo,
|
|
PolicyScope,
|
|
PublishRate,
|
|
DispatchRate,
|
|
SubscribeRate,
|
|
BacklogQuota,
|
|
RetentionPolicy,
|
|
AuthAction,
|
|
PermissionMap,
|
|
MqTokenIssueRequest,
|
|
MqTokenRecord,
|
|
MqIssuedToken,
|
|
BacklogStats,
|
|
PeekedMessage,
|
|
MqRawRequest,
|
|
MqRawResponse,
|
|
} from "@/types/mq";
|
|
|
|
async function post<T>(path: string, body: unknown): Promise<T> {
|
|
const resp = await fetch(path, {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify(body),
|
|
});
|
|
if (!resp.ok) {
|
|
const detail = (await resp.text().catch(() => "")).trim();
|
|
throw new Error(detail ? `${path} returned ${resp.status}: ${detail}` : `${path} returned ${resp.status}`);
|
|
}
|
|
return resp.json();
|
|
}
|
|
|
|
export async function mqTestConnection(connectionId: string): Promise<MqClusterInfo> {
|
|
return post("/api/mq/test-connection", { connectionId });
|
|
}
|
|
|
|
export async function mqListTenants(connectionId: string): Promise<TenantInfo[]> {
|
|
return post("/api/mq/tenants/list", { connectionId });
|
|
}
|
|
|
|
export async function mqGetTenant(connectionId: string, name: string): Promise<TenantInfo> {
|
|
return post("/api/mq/tenants/get", { connectionId, name });
|
|
}
|
|
|
|
export async function mqCreateTenant(connectionId: string, name: string, config: TenantConfig): Promise<void> {
|
|
return post("/api/mq/tenants/create", { connectionId, name, config });
|
|
}
|
|
|
|
export async function mqUpdateTenant(connectionId: string, name: string, config: TenantConfig): Promise<void> {
|
|
return post("/api/mq/tenants/update", { connectionId, name, config });
|
|
}
|
|
|
|
export async function mqDeleteTenant(connectionId: string, name: string, force: boolean): Promise<void> {
|
|
return post("/api/mq/tenants/delete", { connectionId, name, force });
|
|
}
|
|
|
|
export async function mqListNamespaces(connectionId: string, tenant: string): Promise<NamespaceInfo[]> {
|
|
return post("/api/mq/namespaces/list", { connectionId, tenant });
|
|
}
|
|
|
|
export async function mqCreateNamespace(connectionId: string, ns: NamespaceRef, config: NamespaceConfig): Promise<void> {
|
|
return post("/api/mq/namespaces/create", { connectionId, ns, config });
|
|
}
|
|
|
|
export async function mqDeleteNamespace(connectionId: string, ns: NamespaceRef, force: boolean): Promise<void> {
|
|
return post("/api/mq/namespaces/delete", { connectionId, ns, force });
|
|
}
|
|
|
|
export async function mqGetNamespacePolicies(connectionId: string, ns: NamespaceRef): Promise<unknown> {
|
|
return post("/api/mq/namespaces/policies", { connectionId, ns });
|
|
}
|
|
|
|
export async function mqListTopics(connectionId: string, ns: NamespaceRef, opts: ListTopicsOpts): Promise<TopicInfo[]> {
|
|
return post("/api/mq/topics/list", { connectionId, ns, opts });
|
|
}
|
|
|
|
export async function mqCreateTopic(connectionId: string, topic: TopicRef, partitions?: number): Promise<void> {
|
|
return post("/api/mq/topics/create", { connectionId, topic, partitions });
|
|
}
|
|
|
|
export async function mqDeleteTopic(connectionId: string, topic: TopicRef, force: boolean): Promise<void> {
|
|
return post("/api/mq/topics/delete", { connectionId, topic, force });
|
|
}
|
|
|
|
export async function mqUpdatePartitions(connectionId: string, topic: TopicRef, partitions: number): Promise<void> {
|
|
return post("/api/mq/topics/update-partitions", { connectionId, topic, partitions });
|
|
}
|
|
|
|
export async function mqGetTopicStats(connectionId: string, topic: TopicRef): Promise<TopicStats> {
|
|
return post("/api/mq/topics/stats", { connectionId, topic });
|
|
}
|
|
|
|
export async function mqGetTopicInternalStats(connectionId: string, topic: TopicRef): Promise<unknown> {
|
|
return post("/api/mq/topics/internal-stats", { connectionId, topic });
|
|
}
|
|
|
|
export async function mqListSubscriptions(connectionId: string, topic: TopicRef): Promise<SubscriptionInfo[]> {
|
|
return post("/api/mq/subscriptions/list", { connectionId, topic });
|
|
}
|
|
|
|
export async function mqCreateSubscription(connectionId: string, topic: TopicRef, sub: string, pos: ResetPosition): Promise<void> {
|
|
return post("/api/mq/subscriptions/create", { connectionId, topic, sub, pos });
|
|
}
|
|
|
|
export async function mqDeleteSubscription(connectionId: string, topic: TopicRef, sub: string, force: boolean): Promise<void> {
|
|
return post("/api/mq/subscriptions/delete", { connectionId, topic, sub, force });
|
|
}
|
|
|
|
export async function mqSkipMessages(connectionId: string, topic: TopicRef, sub: string, count: SkipCount): Promise<void> {
|
|
return post("/api/mq/subscriptions/skip-messages", { connectionId, topic, sub, count });
|
|
}
|
|
|
|
export async function mqResetCursor(connectionId: string, topic: TopicRef, sub: string, pos: ResetPosition): Promise<void> {
|
|
return post("/api/mq/subscriptions/reset-cursor", { connectionId, topic, sub, pos });
|
|
}
|
|
|
|
export async function mqClearBacklog(connectionId: string, topic: TopicRef, sub: string): Promise<void> {
|
|
return post("/api/mq/subscriptions/clear-backlog", { connectionId, topic, sub });
|
|
}
|
|
|
|
export async function mqPeekMessages(connectionId: string, topic: TopicRef, sub: string, count: number): Promise<PeekedMessage[]> {
|
|
return post("/api/mq/subscriptions/peek-messages", { connectionId, topic, sub, count });
|
|
}
|
|
|
|
export async function mqExpireMessages(connectionId: string, topic: TopicRef, sub: string, expireSeconds: number): Promise<void> {
|
|
return post("/api/mq/subscriptions/expire-messages", { connectionId, topic, sub, expireSeconds });
|
|
}
|
|
|
|
export async function mqListProducers(connectionId: string, topic: TopicRef): Promise<ProducerInfo[]> {
|
|
return post("/api/mq/producers/list", { connectionId, topic });
|
|
}
|
|
|
|
export async function mqListConsumers(connectionId: string, topic: TopicRef, sub: string): Promise<ConsumerInfo[]> {
|
|
return post("/api/mq/consumers/list", { connectionId, topic, sub });
|
|
}
|
|
|
|
export async function mqUnloadTopic(connectionId: string, topic: TopicRef): Promise<void> {
|
|
return post("/api/mq/topics/unload", { connectionId, topic });
|
|
}
|
|
|
|
export async function mqSetPublishRate(connectionId: string, scope: PolicyScope, rate: PublishRate): Promise<void> {
|
|
return post("/api/mq/policies/publish-rate", { connectionId, scope, rate });
|
|
}
|
|
|
|
export async function mqSetDispatchRate(connectionId: string, scope: PolicyScope, rate: DispatchRate): Promise<void> {
|
|
return post("/api/mq/policies/dispatch-rate", { connectionId, scope, rate });
|
|
}
|
|
|
|
export async function mqSetSubscribeRate(connectionId: string, scope: PolicyScope, rate: SubscribeRate): Promise<void> {
|
|
return post("/api/mq/policies/subscribe-rate", { connectionId, scope, rate });
|
|
}
|
|
|
|
export async function mqSetBacklogQuota(connectionId: string, scope: PolicyScope, quota: BacklogQuota): Promise<void> {
|
|
return post("/api/mq/policies/backlog-quota", { connectionId, scope, quota });
|
|
}
|
|
|
|
export async function mqSetRetention(connectionId: string, scope: PolicyScope, retention: RetentionPolicy): Promise<void> {
|
|
return post("/api/mq/policies/retention", { connectionId, scope, retention });
|
|
}
|
|
|
|
export async function mqGetEffectivePolicies(connectionId: string, scope: PolicyScope): Promise<unknown> {
|
|
return post("/api/mq/policies/effective", { connectionId, scope });
|
|
}
|
|
|
|
export async function mqGrantPermission(connectionId: string, scope: PolicyScope, role: string, actions: AuthAction[]): Promise<void> {
|
|
return post("/api/mq/permissions/grant", { connectionId, scope, role, actions });
|
|
}
|
|
|
|
export async function mqRevokePermission(connectionId: string, scope: PolicyScope, role: string): Promise<void> {
|
|
return post("/api/mq/permissions/revoke", { connectionId, scope, role });
|
|
}
|
|
|
|
export async function mqListPermissions(connectionId: string, scope: PolicyScope): Promise<PermissionMap> {
|
|
return post("/api/mq/permissions/list", { connectionId, scope });
|
|
}
|
|
|
|
export async function mqIssueToken(connectionId: string, req: MqTokenIssueRequest): Promise<MqIssuedToken> {
|
|
return post("/api/mq/tokens/issue", { connectionId, req });
|
|
}
|
|
|
|
export async function mqListTokenRecords(connectionId: string, subject?: string): Promise<MqTokenRecord[]> {
|
|
return post("/api/mq/tokens/list", { connectionId, subject });
|
|
}
|
|
|
|
export async function mqGetBacklog(connectionId: string, topic: TopicRef, sub?: string): Promise<BacklogStats> {
|
|
return post("/api/mq/monitoring/backlog", { connectionId, topic, sub });
|
|
}
|
|
|
|
export async function mqRawRequest(connectionId: string, req: MqRawRequest): Promise<MqRawResponse> {
|
|
return post("/api/mq/raw", { connectionId, req });
|
|
}
|