import {z} from 'zod' export type OverrideType = 'Active' | 'Inactive'; export type UserType = 'Employee' | 'User' | 'TenantAdministrator' | 'SystemAdministrator'; export type GetApiApiTenantsTenantIdPayrollsPayrollIdReportsArgs = {tenantId: number, payrollId: number, clusterSetName?: string | undefined, evaluationDate?: string | undefined, overrideType?: OverrideType | undefined, regulationDate?: string | undefined, reportNames?: Array | undefined, userType?: UserType | undefined}; export type GetApiApiTenantsTenantIdPayrollsPayrollIdReportsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const objectStatus = z.enum(["Active", "Inactive"]); export const reportAttributeMode = z.enum(["Json", "Table"]); export const userType = z.enum(["Employee", "User", "TenantAdministrator", "SystemAdministrator"]); export const reportIsolation = z.enum(["None", "Global", "Company", "Division", "Employee"]); export const dataRelation = z.object({name: z.string().nullable().optional(), parentTable: z.string().nullable().optional(), parentColumn: z.string().nullable().optional(), childTable: z.string().nullable().optional(), childColumn: z.string().nullable().optional()}); export const overrideType = 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 reportParameterType = z.enum(["Value", "Now", "Today", "TenantId", "UserId", "EmployeeId", "RegulationId", "PayrollId", "PayrunId", "ReportId", "WebhookId"]); export const reportParameter = z.object({id: z.number().int().optional(), status: objectStatus.optional(), created: z.string().optional(), updated: z.string().optional(), name: z.string().max(128), nameLocalizations: z.record(z.string(), z.string().nullable()).nullable().optional(), description: z.string().nullable().optional(), descriptionLocalizations: z.record(z.string(), z.string().nullable()).nullable().optional(), mandatory: z.boolean().optional(), hidden: z.boolean().optional(), value: z.string().nullable().optional(), valueType: valueType.optional(), parameterType: reportParameterType.optional(), overrideType: overrideType.optional(), attributes: z.record(z.string(), z.unknown()).nullable().optional()}); export const reportTemplate = z.object({id: z.number().int().optional(), status: objectStatus.optional(), created: z.string().optional(), updated: z.string().optional(), name: z.string().max(128), culture: z.string().min(1), content: z.string().min(1), contentType: z.string().max(128).nullable().optional(), schema: z.string().nullable().optional(), resource: z.string().max(256).nullable().optional(), overrideType: overrideType.optional(), attributes: z.record(z.string(), z.unknown()).nullable().optional()}); export const reportSet = z.object({id: z.number().int().optional(), status: objectStatus.optional(), created: z.string().optional(), updated: z.string().optional(), name: z.string().max(128), nameLocalizations: z.record(z.string(), z.string().nullable()).nullable().optional(), description: z.string().nullable().optional(), descriptionLocalizations: z.record(z.string(), z.string().nullable()).nullable().optional(), category: z.string().nullable().optional(), attributeMode: reportAttributeMode.optional(), userType: userType.optional(), reportIsolation: reportIsolation.optional(), queries: z.record(z.string(), z.string().nullable()).nullable().optional(), relations: z.array(dataRelation).nullable().optional(), buildExpression: z.string().nullable().optional(), startExpression: z.string().nullable().optional(), endExpression: z.string().nullable().optional(), overrideType: overrideType.optional(), attributes: z.record(z.string(), z.unknown()).nullable().optional(), clusters: z.array(z.string()).nullable().optional(), regulationId: z.number().int().optional(), parameters: z.array(reportParameter).nullable().optional(), templates: z.array(reportTemplate).nullable().optional()}); export const getApiApiTenantsTenantIdPayrollsPayrollIdReportsResponse = z.array(reportSet); 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}/reports */ export const getApiApiTenantsTenantIdPayrollsPayrollIdReports = async (args: GetApiApiTenantsTenantIdPayrollsPayrollIdReportsArgs, options: GetApiApiTenantsTenantIdPayrollsPayrollIdReportsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.clusterSetName != null) query.append("clusterSetName", String(args.clusterSetName)) if (args.evaluationDate != null) query.append("evaluationDate", String(args.evaluationDate)) if (args.overrideType != null) query.append("overrideType", String(args.overrideType)) if (args.regulationDate != null) query.append("regulationDate", String(args.regulationDate)) for (const item of args.reportNames ?? []) query.append("reportNames", String(item)) if (args.userType != null) query.append("userType", String(args.userType)) const url = `${baseUrl.replace(/\/+$/, '')}/api/tenants/${encodeURIComponent(String(args.tenantId))}/payrolls/${encodeURIComponent(String(args.payrollId))}/reports${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(getApiApiTenantsTenantIdPayrollsPayrollIdReportsResponse, await res.json()) };