mirror of
https://github.com/stefanpejcic/openpanel
synced 2025-06-26 18:28:26 +00:00
39 lines
843 B
TypeScript
39 lines
843 B
TypeScript
import type { RefineHook, TraceType } from "@refinedev/devtools-shared";
|
|
import { getTrace } from "./get-trace";
|
|
import { getResourcePath } from "./get-resource-path";
|
|
|
|
export type XRayResponse = {
|
|
hookName: string;
|
|
trace: TraceType[];
|
|
resourcePath: string | null;
|
|
legacyKey: boolean;
|
|
resourceName?: string;
|
|
};
|
|
|
|
export function getXRay(
|
|
hookName: string,
|
|
legacyKey: boolean,
|
|
resourceName?: string,
|
|
excludeFromTrace?: string[],
|
|
): XRayResponse {
|
|
if (__DEV_CONDITION__ !== "development") {
|
|
return {
|
|
hookName: "",
|
|
trace: [],
|
|
resourcePath: null,
|
|
legacyKey: false,
|
|
};
|
|
}
|
|
const trace = getTrace(excludeFromTrace).slice(1);
|
|
|
|
const resourcePath = getResourcePath(hookName as RefineHook, legacyKey);
|
|
|
|
return {
|
|
hookName,
|
|
trace,
|
|
resourcePath,
|
|
legacyKey,
|
|
resourceName,
|
|
};
|
|
}
|