mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-12 18:26:36 +08:00
prettier
This commit is contained in:
@@ -16,12 +16,12 @@ import type {
|
||||
|
||||
function buildSearchParams(filters: object): Record<string, unknown> {
|
||||
const params: Record<string, unknown> = {};
|
||||
Object.entries(filters as Record<string, string | number | undefined>).forEach(
|
||||
([key, value]) => {
|
||||
if (value === undefined || value === null || value === '') return;
|
||||
params[key] = value;
|
||||
},
|
||||
);
|
||||
Object.entries(
|
||||
filters as Record<string, string | number | undefined>,
|
||||
).forEach(([key, value]) => {
|
||||
if (value === undefined || value === null || value === '') return;
|
||||
params[key] = value;
|
||||
});
|
||||
return params;
|
||||
}
|
||||
|
||||
@@ -35,10 +35,7 @@ export class AccessLogService extends OpenFlareBaseService {
|
||||
static listFolds(
|
||||
filters: FoldedAccessLogFilters,
|
||||
): Promise<FoldedAccessLogList> {
|
||||
return this.get<FoldedAccessLogList>(
|
||||
'/folds',
|
||||
buildSearchParams(filters),
|
||||
);
|
||||
return this.get<FoldedAccessLogList>('/folds', buildSearchParams(filters));
|
||||
}
|
||||
|
||||
static listFoldIPs(
|
||||
@@ -73,4 +70,4 @@ export class AccessLogService extends OpenFlareBaseService {
|
||||
): Promise<AccessLogCleanupResult> {
|
||||
return this.post<AccessLogCleanupResult>('/cleanup', payload);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
import {OpenFlareBaseService} from './base.service';
|
||||
import type {
|
||||
ApplyLogCleanupPayload,
|
||||
ApplyLogCleanupResult,
|
||||
ApplyLogList,
|
||||
ApplyLogListQuery,
|
||||
} from './types';
|
||||
import type {ApplyLogCleanupPayload, ApplyLogCleanupResult, ApplyLogList, ApplyLogListQuery,} from './types';
|
||||
|
||||
export class ApplyLogService extends OpenFlareBaseService {
|
||||
protected static override readonly basePath: string = '/api/v1/d/apply-logs';
|
||||
@@ -26,7 +21,9 @@ export class ApplyLogService extends OpenFlareBaseService {
|
||||
return this.get<ApplyLogList>('/', params);
|
||||
}
|
||||
|
||||
static cleanup(payload: ApplyLogCleanupPayload): Promise<ApplyLogCleanupResult> {
|
||||
static cleanup(
|
||||
payload: ApplyLogCleanupPayload,
|
||||
): Promise<ApplyLogCleanupResult> {
|
||||
return this.post<ApplyLogCleanupResult>('/cleanup', payload);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,4 +2,4 @@ import {BaseService} from '@/lib/services/core';
|
||||
|
||||
export class OpenFlareBaseService extends BaseService {
|
||||
protected static override readonly basePath: string = '/api/v1/d';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ import type {
|
||||
} from './types';
|
||||
|
||||
export class ConfigVersionService extends OpenFlareBaseService {
|
||||
protected static override readonly basePath: string = '/api/v1/d/config-versions';
|
||||
protected static override readonly basePath: string =
|
||||
'/api/v1/d/config-versions';
|
||||
|
||||
static list(): Promise<ConfigVersionSummary[]> {
|
||||
return this.get<ConfigVersionSummary[]>('/');
|
||||
@@ -52,4 +53,4 @@ export class ConfigVersionService extends OpenFlareBaseService {
|
||||
): Promise<ConfigVersionCleanupResult> {
|
||||
return this.post<ConfigVersionCleanupResult>('/cleanup', payload);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,9 +161,7 @@ function normalizeDiskIOTrendPoints(
|
||||
|
||||
function normalizeDashboardNodes(
|
||||
items:
|
||||
| Array<DashboardNodeHealth | CompactDashboardNodeHealth>
|
||||
| null
|
||||
| undefined,
|
||||
Array<DashboardNodeHealth | CompactDashboardNodeHealth> | null | undefined,
|
||||
): DashboardNodeHealth[] {
|
||||
return arrayOrEmpty(items).map((item) =>
|
||||
isCompactDashboardNode(item)
|
||||
|
||||
@@ -2,7 +2,8 @@ import {OpenFlareBaseService} from './base.service';
|
||||
import type {DnsAccountItem, DnsAccountMutationPayload} from './types';
|
||||
|
||||
export class DnsAccountService extends OpenFlareBaseService {
|
||||
protected static override readonly basePath: string = '/api/v1/d/dns-accounts';
|
||||
protected static override readonly basePath: string =
|
||||
'/api/v1/d/dns-accounts';
|
||||
|
||||
static async list(): Promise<DnsAccountItem[]> {
|
||||
return this.get<DnsAccountItem[]>('/');
|
||||
@@ -24,4 +25,4 @@ export class DnsAccountService extends OpenFlareBaseService {
|
||||
static async deleteById(id: number): Promise<void> {
|
||||
return this.post<void>(`/${id}/delete`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,21 +126,21 @@ export type {
|
||||
TlsCertificateMutationPayload,
|
||||
} from './types';
|
||||
|
||||
import {AccessLogService} from './access-log.service';
|
||||
import {ApplyLogService} from './apply-log.service';
|
||||
import {ConfigVersionService} from './config-version.service';
|
||||
import {DashboardService} from './dashboard.service';
|
||||
import {DnsAccountService} from './dns-account.service';
|
||||
import {NodeService} from './node.service';
|
||||
import {OptionService} from './option.service';
|
||||
import {StatusService} from './status.service';
|
||||
import {UptimeKumaService} from './uptimekuma.service';
|
||||
import {OriginService} from './origin.service';
|
||||
import {PagesService} from './pages.service';
|
||||
import {ProxyRouteService} from './proxy-route.service';
|
||||
import {TlsCertificateService} from './tls-certificate.service';
|
||||
import {WafService} from './waf.service';
|
||||
import {ZoneDomainService, ZoneService} from './zone.service';
|
||||
import { AccessLogService } from './access-log.service';
|
||||
import { ApplyLogService } from './apply-log.service';
|
||||
import { ConfigVersionService } from './config-version.service';
|
||||
import { DashboardService } from './dashboard.service';
|
||||
import { DnsAccountService } from './dns-account.service';
|
||||
import { NodeService } from './node.service';
|
||||
import { OptionService } from './option.service';
|
||||
import { StatusService } from './status.service';
|
||||
import { UptimeKumaService } from './uptimekuma.service';
|
||||
import { OriginService } from './origin.service';
|
||||
import { PagesService } from './pages.service';
|
||||
import { ProxyRouteService } from './proxy-route.service';
|
||||
import { TlsCertificateService } from './tls-certificate.service';
|
||||
import { WafService } from './waf.service';
|
||||
import { ZoneDomainService, ZoneService } from './zone.service';
|
||||
|
||||
export const openflareServices = {
|
||||
node: NodeService,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {OpenFlareBaseService} from './base.service';
|
||||
import { OpenFlareBaseService } from './base.service';
|
||||
import type {
|
||||
NodeAgentReleaseInfo,
|
||||
NodeAgentUpdatePayload,
|
||||
@@ -20,7 +20,10 @@ export class NodeService extends OpenFlareBaseService {
|
||||
return this.post<NodeItem>('/', payload);
|
||||
}
|
||||
|
||||
static async updateNode(id: number, payload: NodeMutationPayload): Promise<NodeItem> {
|
||||
static async updateNode(
|
||||
id: number,
|
||||
payload: NodeMutationPayload,
|
||||
): Promise<NodeItem> {
|
||||
return this.post<NodeItem>(`/${id}/update`, payload);
|
||||
}
|
||||
|
||||
@@ -75,4 +78,4 @@ export class NodeService extends OpenFlareBaseService {
|
||||
`/${id}/observability/cleanup`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {OpenFlareBaseService} from './base.service';
|
||||
import { OpenFlareBaseService } from './base.service';
|
||||
import type {
|
||||
DatabaseCleanupPayload,
|
||||
DatabaseCleanupResult,
|
||||
@@ -32,4 +32,4 @@ export class OptionService extends OpenFlareBaseService {
|
||||
): Promise<DatabaseCleanupResult> {
|
||||
return this.post<DatabaseCleanupResult>('/database/cleanup', payload);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {OpenFlareBaseService} from './base.service';
|
||||
import type {OriginDetail, OriginItem, OriginMutationPayload} from './types';
|
||||
import { OpenFlareBaseService } from './base.service';
|
||||
import type { OriginDetail, OriginItem, OriginMutationPayload } from './types';
|
||||
|
||||
export class OriginService extends OpenFlareBaseService {
|
||||
protected static override readonly basePath: string = '/api/v1/d/origins';
|
||||
@@ -26,4 +26,4 @@ export class OriginService extends OpenFlareBaseService {
|
||||
static deleteById(id: number): Promise<void> {
|
||||
return this.post<void>(`/${id}/delete`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type {AxiosProgressEvent, InternalAxiosRequestConfig} from 'axios';
|
||||
import type { AxiosProgressEvent, InternalAxiosRequestConfig } from 'axios';
|
||||
|
||||
import apiClient from '@/lib/services/core/api-client';
|
||||
import {apiConfig} from '@/lib/services/core/config';
|
||||
import type {ApiResponse} from '@/lib/services/core';
|
||||
import { apiConfig } from '@/lib/services/core/config';
|
||||
import type { ApiResponse } from '@/lib/services/core';
|
||||
|
||||
import {OpenFlareBaseService} from './base.service';
|
||||
import { OpenFlareBaseService } from './base.service';
|
||||
import type {
|
||||
PagesDeployment,
|
||||
PagesDeploymentFile,
|
||||
@@ -80,9 +80,7 @@ export class PagesService extends OpenFlareBaseService {
|
||||
projectId: number,
|
||||
deploymentId: number,
|
||||
): Promise<void> {
|
||||
return this.post<void>(
|
||||
`/${projectId}/deployments/${deploymentId}/delete`,
|
||||
);
|
||||
return this.post<void>(`/${projectId}/deployments/${deploymentId}/delete`);
|
||||
}
|
||||
|
||||
private static async postFormData<T>(
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import {OpenFlareBaseService} from './base.service';
|
||||
import type {ProxyRouteItem, ProxyRouteMutationPayload} from './types';
|
||||
import { OpenFlareBaseService } from './base.service';
|
||||
import type { ProxyRouteItem, ProxyRouteMutationPayload } from './types';
|
||||
|
||||
export class ProxyRouteService extends OpenFlareBaseService {
|
||||
protected static override readonly basePath: string = '/api/v1/d/proxy-routes';
|
||||
protected static override readonly basePath: string =
|
||||
'/api/v1/d/proxy-routes';
|
||||
|
||||
static async list(): Promise<ProxyRouteItem[]> {
|
||||
return this.get<ProxyRouteItem[]>('/');
|
||||
@@ -12,7 +13,9 @@ export class ProxyRouteService extends OpenFlareBaseService {
|
||||
return this.get<ProxyRouteItem>(`/${id}`);
|
||||
}
|
||||
|
||||
static async create(payload: ProxyRouteMutationPayload): Promise<ProxyRouteItem> {
|
||||
static async create(
|
||||
payload: ProxyRouteMutationPayload,
|
||||
): Promise<ProxyRouteItem> {
|
||||
return this.post<ProxyRouteItem>('/', payload);
|
||||
}
|
||||
|
||||
@@ -26,4 +29,4 @@ export class ProxyRouteService extends OpenFlareBaseService {
|
||||
static async deleteById(id: number): Promise<void> {
|
||||
return this.post<void>(`/${id}/delete`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import {OpenFlareBaseService} from './base.service';
|
||||
import type {OpenFlarePublicStatus} from './types';
|
||||
import { OpenFlareBaseService } from './base.service';
|
||||
import type { OpenFlarePublicStatus } from './types';
|
||||
|
||||
export class StatusService extends OpenFlareBaseService {
|
||||
static getPublicStatus(): Promise<OpenFlarePublicStatus> {
|
||||
return this.get<OpenFlarePublicStatus>('/status');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {OpenFlareBaseService} from './base.service';
|
||||
import { OpenFlareBaseService } from './base.service';
|
||||
import type {
|
||||
AcmeAccountItem,
|
||||
TlsCertificateApplyPayload,
|
||||
@@ -10,7 +10,8 @@ import type {
|
||||
} from './types';
|
||||
|
||||
class AcmeAccountApi extends OpenFlareBaseService {
|
||||
protected static override readonly basePath: string = '/api/v1/d/acme-accounts';
|
||||
protected static override readonly basePath: string =
|
||||
'/api/v1/d/acme-accounts';
|
||||
|
||||
static getDefault(): Promise<AcmeAccountItem> {
|
||||
return this.get<AcmeAccountItem>('/default');
|
||||
@@ -18,7 +19,8 @@ class AcmeAccountApi extends OpenFlareBaseService {
|
||||
}
|
||||
|
||||
export class TlsCertificateService extends OpenFlareBaseService {
|
||||
protected static override readonly basePath: string = '/api/v1/d/tls-certificates';
|
||||
protected static override readonly basePath: string =
|
||||
'/api/v1/d/tls-certificates';
|
||||
|
||||
static async list(): Promise<TlsCertificateItem[]> {
|
||||
return this.get<TlsCertificateItem[]>('/');
|
||||
@@ -88,4 +90,4 @@ export class TlsCertificateService extends OpenFlareBaseService {
|
||||
static getDefaultAcmeAccount(): Promise<AcmeAccountItem> {
|
||||
return AcmeAccountApi.getDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type {XYPosition} from '@xyflow/react';
|
||||
import type { XYPosition } from '@xyflow/react';
|
||||
|
||||
export type ReleaseChannel = 'stable' | 'preview';
|
||||
|
||||
@@ -201,12 +201,7 @@ export interface NodeObservability {
|
||||
}
|
||||
|
||||
export type ProxyRouteConfigSection =
|
||||
| 'domains'
|
||||
| 'limits'
|
||||
| 'proxy'
|
||||
| 'cache'
|
||||
| 'waf'
|
||||
| 'auth';
|
||||
'domains' | 'limits' | 'proxy' | 'cache' | 'waf' | 'auth';
|
||||
|
||||
export interface ProxyRouteCustomHeader {
|
||||
key: string;
|
||||
@@ -666,9 +661,7 @@ export interface GeoIPLookupResult {
|
||||
}
|
||||
|
||||
export type DatabaseCleanupTarget =
|
||||
| 'node_access_logs'
|
||||
| 'node_metric_snapshots'
|
||||
| 'node_request_reports';
|
||||
'node_access_logs' | 'node_metric_snapshots' | 'node_request_reports';
|
||||
|
||||
export interface DatabaseCleanupPayload {
|
||||
target: DatabaseCleanupTarget;
|
||||
@@ -715,12 +708,37 @@ export interface BlockNodeConfig {
|
||||
}
|
||||
|
||||
export type WAFRuleNode =
|
||||
| {id: string; type: 'start'; position: XYPosition; config: Record<string, never>}
|
||||
| {id: string; type: 'ip_match'; position: XYPosition; config: IPMatchConfig}
|
||||
| {id: string; type: 'geo_match'; position: XYPosition; config: GeoMatchConfig}
|
||||
| {id: string; type: 'pow'; position: XYPosition; config: PoWNodeConfig}
|
||||
| {id: string; type: 'allow'; position: XYPosition; config: Record<string, never>}
|
||||
| {id: string; type: 'block'; position: XYPosition; config: BlockNodeConfig};
|
||||
| {
|
||||
id: string;
|
||||
type: 'start';
|
||||
position: XYPosition;
|
||||
config: Record<string, never>;
|
||||
}
|
||||
| {
|
||||
id: string;
|
||||
type: 'ip_match';
|
||||
position: XYPosition;
|
||||
config: IPMatchConfig;
|
||||
}
|
||||
| {
|
||||
id: string;
|
||||
type: 'geo_match';
|
||||
position: XYPosition;
|
||||
config: GeoMatchConfig;
|
||||
}
|
||||
| { id: string; type: 'pow'; position: XYPosition; config: PoWNodeConfig }
|
||||
| {
|
||||
id: string;
|
||||
type: 'allow';
|
||||
position: XYPosition;
|
||||
config: Record<string, never>;
|
||||
}
|
||||
| {
|
||||
id: string;
|
||||
type: 'block';
|
||||
position: XYPosition;
|
||||
config: BlockNodeConfig;
|
||||
};
|
||||
|
||||
export interface WAFRuleEdge {
|
||||
id: string;
|
||||
@@ -1077,10 +1095,6 @@ export interface ZoneStats {
|
||||
series: ZoneStatsPoint[];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export interface TlsCertificateItem {
|
||||
id: number;
|
||||
name: string;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {OpenFlareBaseService} from './base.service';
|
||||
import { OpenFlareBaseService } from './base.service';
|
||||
|
||||
export class UptimeKumaService extends OpenFlareBaseService {
|
||||
protected static override readonly basePath: string = '/api/v1/d/uptimekuma';
|
||||
@@ -6,4 +6,4 @@ export class UptimeKumaService extends OpenFlareBaseService {
|
||||
static sync(): Promise<void> {
|
||||
return this.post<void>('/sync');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {OpenFlareBaseService} from './base.service';
|
||||
import { OpenFlareBaseService } from './base.service';
|
||||
import type {
|
||||
WAFIPGroup,
|
||||
WAFIPGroupAutoTestPayload,
|
||||
@@ -70,7 +70,10 @@ export class WafService extends OpenFlareBaseService {
|
||||
return this.post<WAFIPGroup>('/ip-groups', payload);
|
||||
}
|
||||
|
||||
static async updateIPGroup(id: number, payload: WAFIPGroupPayload): Promise<WAFIPGroup> {
|
||||
static async updateIPGroup(
|
||||
id: number,
|
||||
payload: WAFIPGroupPayload,
|
||||
): Promise<WAFIPGroup> {
|
||||
return this.post<WAFIPGroup>(`/ip-groups/${id}/update`, payload);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {OpenFlareBaseService} from './base.service'
|
||||
import { OpenFlareBaseService } from './base.service';
|
||||
import type {
|
||||
ZoneDomainItem,
|
||||
ZoneDomainMutationPayload,
|
||||
@@ -7,27 +7,56 @@ import type {
|
||||
ZoneOverview,
|
||||
ZoneStats,
|
||||
ZoneStatsRange,
|
||||
} from './types'
|
||||
} from './types';
|
||||
|
||||
export const zoneQueryKey = ['openflare', 'zones'] as const
|
||||
export const zoneQueryKey = ['openflare', 'zones'] as const;
|
||||
|
||||
export class ZoneService extends OpenFlareBaseService {
|
||||
protected static override readonly basePath = '/api/v1/d/zones'
|
||||
protected static override readonly basePath = '/api/v1/d/zones';
|
||||
|
||||
static list(): Promise<ZoneItem[]> { return this.get<ZoneItem[]>('/') }
|
||||
static getOverview(id: number): Promise<ZoneOverview> { return this.get<ZoneOverview>(`/${id}/overview`) }
|
||||
static getStats(id: number, range: ZoneStatsRange = '24h'): Promise<ZoneStats> {
|
||||
return this.get<ZoneStats>(`/${id}/stats`, {range})
|
||||
static list(): Promise<ZoneItem[]> {
|
||||
return this.get<ZoneItem[]>('/');
|
||||
}
|
||||
static getOverview(id: number): Promise<ZoneOverview> {
|
||||
return this.get<ZoneOverview>(`/${id}/overview`);
|
||||
}
|
||||
static getStats(
|
||||
id: number,
|
||||
range: ZoneStatsRange = '24h',
|
||||
): Promise<ZoneStats> {
|
||||
return this.get<ZoneStats>(`/${id}/stats`, { range });
|
||||
}
|
||||
static create(payload: ZoneMutationPayload): Promise<ZoneItem> {
|
||||
return this.post<ZoneItem>('/', payload);
|
||||
}
|
||||
static update(id: number, payload: ZoneMutationPayload): Promise<ZoneItem> {
|
||||
return this.post<ZoneItem>(`/${id}/update`, payload);
|
||||
}
|
||||
static deleteById(id: number): Promise<void> {
|
||||
return this.post<void>(`/${id}/delete`);
|
||||
}
|
||||
static create(payload: ZoneMutationPayload): Promise<ZoneItem> { return this.post<ZoneItem>('/', payload) }
|
||||
static update(id: number, payload: ZoneMutationPayload): Promise<ZoneItem> { return this.post<ZoneItem>(`/${id}/update`, payload) }
|
||||
static deleteById(id: number): Promise<void> { return this.post<void>(`/${id}/delete`) }
|
||||
}
|
||||
|
||||
export class ZoneDomainService extends OpenFlareBaseService {
|
||||
protected static override readonly basePath = '/api/v1/d/zones'
|
||||
protected static override readonly basePath = '/api/v1/d/zones';
|
||||
|
||||
static create(zoneId: number, payload: ZoneDomainMutationPayload): Promise<ZoneDomainItem> { return this.post<ZoneDomainItem>(`/${zoneId}/domains`, payload) }
|
||||
static update(zoneId: number, id: number, payload: ZoneDomainMutationPayload): Promise<ZoneDomainItem> { return this.post<ZoneDomainItem>(`/${zoneId}/domains/${id}/update`, payload) }
|
||||
static deleteById(zoneId: number, id: number): Promise<void> { return this.post<void>(`/${zoneId}/domains/${id}/delete`) }
|
||||
static create(
|
||||
zoneId: number,
|
||||
payload: ZoneDomainMutationPayload,
|
||||
): Promise<ZoneDomainItem> {
|
||||
return this.post<ZoneDomainItem>(`/${zoneId}/domains`, payload);
|
||||
}
|
||||
static update(
|
||||
zoneId: number,
|
||||
id: number,
|
||||
payload: ZoneDomainMutationPayload,
|
||||
): Promise<ZoneDomainItem> {
|
||||
return this.post<ZoneDomainItem>(
|
||||
`/${zoneId}/domains/${id}/update`,
|
||||
payload,
|
||||
);
|
||||
}
|
||||
static deleteById(zoneId: number, id: number): Promise<void> {
|
||||
return this.post<void>(`/${zoneId}/domains/${id}/delete`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user