export type ValueRange = {fromValue?: (number | null) | undefined, toValue?: (number | null) | undefined}; export type WhereConstrains = {startedAtLocal?: Record | undefined, kilojoules?: (ValueRange | null) | undefined, distance?: (ValueRange | null) | undefined, totalElevationGain?: (ValueRange | null) | undefined, averageHeartRate?: (ValueRange | null) | undefined, averageSpeed?: (ValueRange | null) | undefined, averageCadence?: (ValueRange | null) | undefined, rpe?: (ValueRange | null) | undefined, classification?: ('unclassified' | 'recovery' | 'endurance' | 'intensity' | null) | undefined, isIndoor?: (boolean | null) | undefined}; export type DynamicAction = {max?: (boolean | null) | undefined, min?: (boolean | null) | undefined, sum?: (boolean | null) | undefined, select?: (boolean | null) | undefined, average?: (boolean | null) | undefined, count?: (boolean | null) | undefined}; export type AggregateAttribute = {startedAtLocal?: (boolean | null) | undefined, id?: (boolean | null) | undefined, kilojoules?: (boolean | null) | undefined, distance?: (boolean | null) | undefined, totalElevationGain?: (boolean | null) | undefined, averageHeartRate?: (boolean | null) | undefined, averageWatts?: (boolean | null) | undefined, averageSpeed?: (boolean | null) | undefined, averageCadence?: (boolean | null) | undefined, rpe?: (boolean | null) | undefined, classification?: (boolean | null) | undefined, isIndoor?: (boolean | null) | undefined, movingDuration?: (boolean | null) | undefined}; export type DynamicRideData = {limit: number, orderBy: 'startedAtLocal' | 'kilojoules' | 'movingDuration' | 'distance' | 'totalElevationGain' | 'averageHeartRate' | 'averageWatts' | 'averageSpeed' | 'averageCadence' | 'rpe' | 'classification' | 'isIndoor', orderDirection: 'desc' | 'asc', where: WhereConstrains, action: DynamicAction, aggregateAttribute: AggregateAttribute}; export type CreateApiV1RidesDynamicArgs = {body: DynamicRideData}; export type CreateApiV1RidesDynamicOptions = {baseUrl: string, bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * POST /v1/rides/dynamic */ export const createApiV1RidesDynamic = async (args: CreateApiV1RidesDynamicArgs, options: CreateApiV1RidesDynamicOptions) => { const {baseUrl, fetch: fetchFn = fetch, bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (bearer !== undefined) headers.set('authorization', `Bearer ${bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/rides/dynamic${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 undefined };