mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-04 09:46:40 +00:00
✨ world map
This commit is contained in:
1002
src/lib/countryCodeList.ts
Normal file
1002
src/lib/countryCodeList.ts
Normal file
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,10 @@ import { durationToMs } from "./durationToMs";
|
||||
import { build } from "@server/build";
|
||||
import { remote } from "./api";
|
||||
import type ResponseT from "@server/types/Response";
|
||||
import z from "zod";
|
||||
import type { AxiosInstance, AxiosResponse } from "axios";
|
||||
import type { QueryRequestAnalyticsResponse } from "@server/routers/auditLogs";
|
||||
import type { ListResourceNamesResponse } from "@server/routers/resource";
|
||||
|
||||
export type ProductUpdate = {
|
||||
link: string | null;
|
||||
@@ -65,3 +69,65 @@ export const productUpdatesQueries = {
|
||||
// because we don't need to listen for new versions there
|
||||
})
|
||||
};
|
||||
|
||||
export const logAnalyticsFiltersSchema = z.object({
|
||||
timeStart: z
|
||||
.string()
|
||||
.refine((val) => !isNaN(Date.parse(val)), {
|
||||
error: "timeStart must be a valid ISO date string"
|
||||
})
|
||||
.optional(),
|
||||
timeEnd: z
|
||||
.string()
|
||||
.refine((val) => !isNaN(Date.parse(val)), {
|
||||
error: "timeEnd must be a valid ISO date string"
|
||||
})
|
||||
.optional(),
|
||||
resourceId: z
|
||||
.string()
|
||||
.optional()
|
||||
.transform(Number)
|
||||
.pipe(z.int().positive())
|
||||
.optional()
|
||||
});
|
||||
|
||||
export type LogAnalyticsFilters = z.TypeOf<typeof logAnalyticsFiltersSchema>;
|
||||
|
||||
export const logQueries = {
|
||||
requestAnalytics: ({
|
||||
orgId,
|
||||
filters,
|
||||
api
|
||||
}: {
|
||||
orgId: string;
|
||||
filters: LogAnalyticsFilters;
|
||||
api: AxiosInstance;
|
||||
}) =>
|
||||
queryOptions({
|
||||
queryKey: ["REQUEST_LOG_ANALYTICS", orgId, filters] as const,
|
||||
queryFn: async ({ signal }) => {
|
||||
const res = await api.get<
|
||||
AxiosResponse<QueryRequestAnalyticsResponse>
|
||||
>(`/org/${orgId}/logs/analytics`, {
|
||||
params: filters,
|
||||
signal
|
||||
});
|
||||
return res.data.data;
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
export const resourceQueries = {
|
||||
listNamesPerOrg: (orgId: string, api: AxiosInstance) =>
|
||||
queryOptions({
|
||||
queryKey: ["RESOURCES_NAMES", orgId] as const,
|
||||
queryFn: async ({ signal }) => {
|
||||
const res = await api.get<
|
||||
AxiosResponse<ListResourceNamesResponse>
|
||||
>(`/org/${orgId}/resource-names`, {
|
||||
signal
|
||||
});
|
||||
return res.data.data;
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user