/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { QueryClient, QueryFunctionContext, QueryKey, } from "@tanstack/react-query"; import { GustoEmbeddedCore } from "../core.js"; import { employeesList } from "../funcs/employeesList.js"; import { combineSignals } from "../lib/primitives.js"; import { RequestOptions } from "../lib/sdks.js"; import { GetV1CompaniesCompanyIdEmployeesHeaderXGustoAPIVersion, GetV1CompaniesCompanyIdEmployeesRequest, GetV1CompaniesCompanyIdEmployeesResponse, Include, } from "../models/operations/getv1companiescompanyidemployees.js"; import { unwrapAsync } from "../types/fp.js"; export type EmployeesListQueryData = GetV1CompaniesCompanyIdEmployeesResponse; export function prefetchEmployeesList( queryClient: QueryClient, client$: GustoEmbeddedCore, request: GetV1CompaniesCompanyIdEmployeesRequest, options?: RequestOptions, ): Promise { return queryClient.prefetchQuery({ ...buildEmployeesListQuery( client$, request, options, ), }); } export function buildEmployeesListQuery( client$: GustoEmbeddedCore, request: GetV1CompaniesCompanyIdEmployeesRequest, options?: RequestOptions, ): { queryKey: QueryKey; queryFn: (context: QueryFunctionContext) => Promise; } { return { queryKey: queryKeyEmployeesList(request.companyId, { xGustoAPIVersion: request.xGustoAPIVersion, locationUuid: request.locationUuid, payrollUuid: request.payrollUuid, searchTerm: request.searchTerm, sortBy: request.sortBy, include: request.include, onboarded: request.onboarded, onboardedActive: request.onboardedActive, terminated: request.terminated, terminatedToday: request.terminatedToday, uuids: request.uuids, page: request.page, per: request.per, }), queryFn: async function employeesListQueryFn( ctx, ): Promise { const sig = combineSignals( ctx.signal, options?.signal, options?.fetchOptions?.signal, ); const mergedOptions = { ...options?.fetchOptions, ...options, signal: sig, }; return unwrapAsync(employeesList( client$, request, mergedOptions, )); }, }; } export function queryKeyEmployeesList( companyId: string, parameters: { xGustoAPIVersion?: | GetV1CompaniesCompanyIdEmployeesHeaderXGustoAPIVersion | undefined; locationUuid?: string | undefined; payrollUuid?: string | undefined; searchTerm?: string | undefined; sortBy?: string | undefined; include?: Array | undefined; onboarded?: boolean | undefined; onboardedActive?: boolean | undefined; terminated?: boolean | undefined; terminatedToday?: boolean | undefined; uuids?: Array | undefined; page?: number | undefined; per?: number | undefined; }, ): QueryKey { return ["@gusto/embedded-api", "Employees", "list", companyId, parameters]; }