decompose structure
This commit is contained in:
16
src/entities/current/api.ts
Normal file
16
src/entities/current/api.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { getJson } from '../../shared/api/http';
|
||||
import { cloudApiUrl } from '../../shared/config/env';
|
||||
import type { CurrentResponse } from './types';
|
||||
|
||||
/** Загружает текущие значения показателей для выбранной буровой. */
|
||||
export function getCurrent(edge: string, tags?: string[]): Promise<CurrentResponse> {
|
||||
return getJson<CurrentResponse>(cloudApiUrl, '/current', { edge, tags });
|
||||
}
|
||||
|
||||
/** Формирует URL SSE-потока текущих значений. */
|
||||
export function getCurrentEventsUrl(edge: string, tags?: string[]): string {
|
||||
const url = new URL('/current/events', cloudApiUrl);
|
||||
url.searchParams.set('edge', edge);
|
||||
tags?.forEach((tag) => url.searchParams.append('tags', tag));
|
||||
return url.toString();
|
||||
}
|
||||
22
src/entities/current/types.ts
Normal file
22
src/entities/current/types.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
export type CurrentItem = {
|
||||
edge: string;
|
||||
tag: string;
|
||||
value: number;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
time: string;
|
||||
name: string | null;
|
||||
tagGroup: string | null;
|
||||
min: number | null;
|
||||
max: number | null;
|
||||
comment: string | null;
|
||||
unitOfMeasurement: string | null;
|
||||
precision: number | null;
|
||||
};
|
||||
|
||||
export type CurrentResponse = {
|
||||
edge: string;
|
||||
items: CurrentItem[];
|
||||
};
|
||||
|
||||
export type CurrentEvent = CurrentResponse;
|
||||
Reference in New Issue
Block a user