import {z} from 'zod' export type Atom = {atomic_number: number, position: Array, mass?: (number | null) | undefined}; export type PeriodicCellInput = {lattice_vectors: Array, is_periodic?: Array | undefined}; export type VibrationalMode = {frequency: number, reduced_mass: number, force_constant: number, displacements: Array>, ir_intensity?: (number | null) | undefined, symmetry_label?: (string | null) | undefined}; export type Solvent = 'water' | 'nitromethane' | 'nitrobenzene' | 'toluene' | 'benzene' | 'chlorobenzene' | 'carbontetrachloride' | 'dichloroethane' | 'dichloromethane' | 'chloroform' | 'diethylether' | 'diisopropylether' | 'dimethylsulfoxide' | 'tetrahydrofuran' | 'cyclohexane' | 'aceticacid' | 'hexane' | 'octane' | 'decane' | 'ethylacetate' | 'acetone' | 'acetonitrile' | 'methanol' | 'ethanol' | 'isopropanol' | 'octanol' | 'dimethylacetamide' | 'dimethylformamide' | 'n_methylpyrrolidone' | 'ethylene_glycol'; export type COSMORSParameterization = 'opencosmo_rs_24a' | 'rowan_cosmors_2026'; export type COSMORSDataInput = {solvent: Solvent, temperature: number, parameterization: COSMORSParameterization, e_diel: number, mu_res: number, mu_comb: number, g_disp: number, ring_correction: number, standard_state: number, eta: number, n_rings: number, gas_phase_energy?: (number | null) | undefined}; export type BandStructure = {kpoint_distances: Array, eigenvalues: Array>, high_symmetry_points: Array>, total_density_of_states: Array>, band_gap: number, valence_band_maximum: number, conduction_band_minimum: number}; export type MoleculeInput = {charge: number, multiplicity: number, atoms: Array, cell?: (PeriodicCellInput | null) | undefined, energy?: (number | null) | undefined, scf_iterations?: (number | null) | undefined, scf_completed?: (boolean | null) | undefined, elapsed?: (number | null) | undefined, homo_lumo_gap?: (number | null) | undefined, gradient?: (Array> | null) | undefined, stress?: (Array | null) | undefined, velocities?: (Array> | null) | undefined, mulliken_charges?: (Array | null) | undefined, mulliken_spin_densities?: (Array | null) | undefined, dipole?: (Array | null) | undefined, vibrational_modes?: (Array | null) | undefined, zero_point_energy?: (number | null) | undefined, thermal_energy_corr?: (number | null) | undefined, thermal_enthalpy_corr?: (number | null) | undefined, thermal_free_energy_corr?: (number | null) | undefined, excited_state_energies?: (Array | null) | undefined, oscillator_strengths?: (Array | null) | undefined, rotatory_strengths?: (Array | null) | undefined, cosmo_rs_data?: (COSMORSDataInput | null) | undefined, symmetry?: (string | number | null) | undefined, x_ray_diffraction_peaks?: (Array> | null) | undefined, band_structure?: (BandStructure | null) | undefined, elastic_tensor?: (Array | null) | undefined, smiles?: (string | null) | undefined, calculation_index?: (number | null) | undefined, name?: (string | null) | undefined, metadata?: ({[key: string]: boolean | number | number | string} | null) | undefined}; export type WorkflowCreate = {folder_uuid?: (string | null) | undefined, name?: (string | null) | undefined, workflow_type: string, initial_molecule?: (MoleculeInput | null) | undefined, initial_smiles?: (string | null) | undefined, workflow_data: Record, resubmitted_from_uuid?: (string | null) | undefined, max_credits?: (number | null) | undefined, is_draft?: boolean | undefined, webhook_url?: (string | null) | undefined}; export type CreateApiWorkflowDispatchInformationArgs = {access_token?: (string | null) | undefined, body: WorkflowCreate}; export type CreateApiWorkflowDispatchInformationOptions = {baseUrl: string, APIKeyHeader?: string | undefined, fetch?: typeof fetch | undefined}; export const createApiWorkflowDispatchInformationResponse = z.unknown(); 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 }; /** * Dispatch Information * * POST /workflow/dispatch_information */ export const createApiWorkflowDispatchInformation = async (args: CreateApiWorkflowDispatchInformationArgs, options: CreateApiWorkflowDispatchInformationOptions) => { const {baseUrl, fetch: fetchFn = fetch, APIKeyHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() const cookies: string[] = [] headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args.access_token != null) cookies.push("access_token=" + encodeURIComponent(String(args.access_token))) if (APIKeyHeader !== undefined) headers.set("X-API-Key", APIKeyHeader) if (cookies.length > 0) headers.set('cookie', cookies.join('; ')) const url = `${baseUrl.replace(/\/+$/, '')}/workflow/dispatch_information${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(createApiWorkflowDispatchInformationResponse, await res.json()) };