wavelet init

This commit is contained in:
ryan
2026-06-18 15:24:48 +08:00
parent d6a7011885
commit 99738bbc17
714 changed files with 139987 additions and 0 deletions
@@ -0,0 +1,5 @@
// Copyright 2026 Arctel.net
// SPDX-License-Identifier: Apache-2.0
export * from './types';
export * from './push.service';
@@ -0,0 +1,123 @@
// Copyright 2026 Arctel.net
// SPDX-License-Identifier: Apache-2.0
import {BaseService} from '@/lib/services/core';
import type {
ChannelDefinition,
CreateChannelRequest,
CreatePushEventRequest,
EventMetadata,
ListPushHistoriesRequest,
ListPushHistoriesResponse,
PushChannel,
PushEvent,
TestChannelRequest,
TestPushRequest,
UpdateChannelRequest,
UpdatePushEventRequest
} from './types';
/**
* 通知推送服务类
*/
export class PushService extends BaseService {
protected static readonly basePath = '/api/v1/admin/push';
/**
* 获取通知事件列表
*/
static async listEvents(): Promise<PushEvent[]> {
return this.get<PushEvent[]>('/events');
}
/**
* 获取系统内置通知事件元数据列表
*/
static async listBuiltInEvents(): Promise<EventMetadata[]> {
return this.get<EventMetadata[]>('/events/builtin');
}
/**
* 创建通知事件配置
*/
static async createEvent(data: CreatePushEventRequest): Promise<PushEvent> {
return this.post<PushEvent>('/events', data as unknown as Record<string, unknown>);
}
/**
* 更新指定通知事件配置
*/
static async updateEvent(id: number, data: UpdatePushEventRequest): Promise<void> {
return this.put<void>(`/events/${id}`, data as unknown as Record<string, unknown>);
}
/**
* 删除指定通知事件配置
*/
static async deleteEvent(id: number): Promise<void> {
return this.delete<void>(`/events/${id}`);
}
/**
* 快捷切换事件启用状态
*/
static async toggleEvent(id: number): Promise<boolean> {
return this.post<boolean>(`/events/${id}/toggle`);
}
/**
* 分页查询通知推送历史
*/
static async listHistories(params: ListPushHistoriesRequest): Promise<ListPushHistoriesResponse> {
return this.get<ListPushHistoriesResponse>('/histories', params as unknown as Record<string, unknown>);
}
/**
* 发送测试推送进行联通性校验
*/
static async testPush(data: TestPushRequest): Promise<void> {
return this.post<void>('/test', data as unknown as Record<string, unknown>);
}
/**
* 获取所有消息通道
*/
static async listChannels(): Promise<PushChannel[]> {
return this.get<PushChannel[]>('/channels');
}
/**
* 创建新的消息通道
*/
static async createChannel(data: CreateChannelRequest): Promise<PushChannel> {
return this.post<PushChannel>('/channels', data as unknown as Record<string, unknown>);
}
/**
* 更新指定消息通道
*/
static async updateChannel(id: number, data: UpdateChannelRequest): Promise<PushChannel> {
return this.put<PushChannel>(`/channels/${id}`, data as unknown as Record<string, unknown>);
}
/**
* 删除指定消息通道
*/
static async deleteChannel(id: number): Promise<void> {
return this.delete<void>(`/channels/${id}`);
}
/**
* 测试消息通道连通性
*/
static async testChannel(data: TestChannelRequest): Promise<void> {
return this.post<void>('/channels/test', data as unknown as Record<string, unknown>);
}
/**
* 获取各消息通道的动态表单定义
*/
static async listChannelDefinitions(): Promise<ChannelDefinition[]> {
return this.get<ChannelDefinition[]>('/channels/definitions');
}
}
+138
View File
@@ -0,0 +1,138 @@
// Copyright 2026 Arctel.net
// SPDX-License-Identifier: Apache-2.0
export interface PushEvent {
id: number;
event_key: string;
name: string;
task_type?: string;
channels: string[];
targets: string[];
template: string;
enabled: boolean;
created_at: string;
updated_at: string;
}
export interface PushHistory {
id: number;
event_key: string;
channel: string;
target: string;
title: string;
content: string;
level: 'INFO' | 'IMPORTANT' | 'CRITICAL';
status: 'success' | 'failed';
error_msg?: string;
created_at: string;
}
export interface PushChannelConfig {
channel: string;
url?: string;
secret?: string;
key?: string;
ext?: Record<string, unknown>;
}
export interface ListPushHistoriesRequest {
page?: number;
page_size?: number;
event_key?: string;
status?: string;
}
export interface ListPushHistoriesResponse {
total: number;
results: PushHistory[];
}
export interface UpdatePushEventRequest {
channels: string[];
targets: string[];
template: string;
enabled: boolean;
}
export interface TestPushRequest {
config: PushChannelConfig;
target?: string;
}
export interface EventMetadata {
key: string;
name: string;
default_template: {
title: string;
content: string;
level: string;
ext?: Record<string, unknown>;
};
description: string;
}
export interface CreatePushEventRequest {
event_key?: string;
task_type?: string;
channels: string[];
targets?: string[];
template?: string;
enabled: boolean;
}
export interface PushChannel {
id: number;
name: string;
description?: string;
type: string;
token?: string;
url: string;
other: string;
enabled: boolean;
created_at?: string;
updated_at?: string;
}
export interface CreateChannelRequest {
name: string;
description?: string;
type: string;
token?: string;
url: string;
other: string;
enabled?: boolean;
}
export interface UpdateChannelRequest {
description?: string;
type: string;
token?: string;
url: string;
other: string;
enabled?: boolean;
}
export interface TestChannelRequest {
name?: string;
type?: string;
url?: string;
other?: string;
target?: string;
}
export interface ChannelFieldDef {
key: string;
label: string;
type: 'text' | 'password' | 'textarea';
required: boolean;
placeholder?: string;
description?: string;
}
export interface ChannelDefinition {
type: string;
name: string;
description: string;
fields: ChannelFieldDef[];
}