import {z} from 'zod' export type CaseType = 'Global' | 'National' | 'Company' | 'Employee'; export type GetApiApiTenantsTenantIdPayrollsPayrollIdCasesValuesTimeArgs = {tenantId: number, payrollId: number, employeeId?: number | undefined, caseFieldNames?: Array | undefined, caseType?: CaseType | undefined, evaluationDate?: string | undefined, regulationDate?: string | undefined, valueDate?: string | undefined}; export type GetApiApiTenantsTenantIdPayrollsPayrollIdCasesValuesTimeOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const objectStatus = z.enum(["Active", "Inactive"]); export const valueType = z.enum(["String", "Boolean", "Integer", "NumericBoolean", "Decimal", "DateTime", "None", "Date", "Weekday", "Month", "Year", "Money", "Percent", "WebResource"]); export const caseRelationReference = z.object({sourceCaseName: z.string().nullable().optional(), sourceCaseSlot: z.string().nullable().optional(), targetCaseName: z.string().nullable().optional(), targetCaseSlot: z.string().nullable().optional()}); export const caseValue = z.object({id: z.number().int().optional(), status: objectStatus.optional(), created: z.string().optional(), updated: z.string().optional(), divisionId: z.number().int().nullable().optional(), employeeId: z.number().int().nullable().optional(), caseName: z.string().max(128).nullable().optional(), caseNameLocalizations: z.record(z.string(), z.string().nullable()).nullable().optional(), caseFieldName: z.string().max(128), caseFieldNameLocalizations: z.record(z.string(), z.string().nullable()).nullable().optional(), caseSlot: z.string().max(128).nullable().optional(), caseSlotLocalizations: z.record(z.string(), z.string().nullable()).nullable().optional(), valueType: valueType.optional(), value: z.string().nullable().optional(), numericValue: z.number().nullable().optional(), culture: z.string().nullable().optional(), caseRelation: caseRelationReference.optional(), cancellationDate: z.string().nullable().optional(), start: z.string().nullable().optional(), end: z.string().nullable().optional(), forecast: z.string().max(128).nullable().optional(), tags: z.array(z.string()).nullable().optional(), attributes: z.record(z.string(), z.unknown()).nullable().optional()}); export const getApiApiTenantsTenantIdPayrollsPayrollIdCasesValuesTimeResponse = z.array(caseValue); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * GET /api/tenants/{tenantId}/payrolls/{payrollId}/cases/values/time */ export const getApiApiTenantsTenantIdPayrollsPayrollIdCasesValuesTime = async (args: GetApiApiTenantsTenantIdPayrollsPayrollIdCasesValuesTimeArgs, options: GetApiApiTenantsTenantIdPayrollsPayrollIdCasesValuesTimeOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.employeeId != null) query.append("employeeId", String(args.employeeId)) for (const item of args.caseFieldNames ?? []) query.append("caseFieldNames", String(item)) if (args.caseType != null) query.append("caseType", String(args.caseType)) if (args.evaluationDate != null) query.append("evaluationDate", String(args.evaluationDate)) if (args.regulationDate != null) query.append("regulationDate", String(args.regulationDate)) if (args.valueDate != null) query.append("valueDate", String(args.valueDate)) const url = `${baseUrl.replace(/\/+$/, '')}/api/tenants/${encodeURIComponent(String(args.tenantId))}/payrolls/${encodeURIComponent(String(args.payrollId))}/cases/values/time${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(getApiApiTenantsTenantIdPayrollsPayrollIdCasesValuesTimeResponse, await res.json()) };