mirror of
https://github.com/pterodactyl/panel.git
synced 2026-11-30 03:17:56 -05:00
Co-authored-by: Anthony <anthony@infraly.co> Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
22 lines
759 B
TypeScript
22 lines
759 B
TypeScript
import type { QueryKey } from '@tanstack/react-query';
|
|
import { isObject, isString } from '@/lib/objects';
|
|
|
|
interface GeneratedQueryKeyRoot {
|
|
_id?: string;
|
|
}
|
|
|
|
const isGeneratedQueryKeyRoot = (value: QueryKey[number]): value is GeneratedQueryKeyRoot =>
|
|
isObject(value) && (!('_id' in value) || value._id === undefined || isString(value._id));
|
|
|
|
export const hasGeneratedOperationId = (queryKey: QueryKey, id: string): boolean => {
|
|
const [key] = queryKey;
|
|
|
|
return isGeneratedQueryKeyRoot(key) && key._id === id;
|
|
};
|
|
|
|
export const hasPathParam = (queryKey: QueryKey, name: string, value: string): boolean => {
|
|
const [key] = queryKey;
|
|
|
|
return isObject(key) && 'path' in key && isObject(key.path) && Reflect.get(key.path, name) === value;
|
|
};
|