export type TransformationParamValue = string | number | boolean; export type TransformationParamsGroup = {[key: string]: TransformationParamValue}; export type TransformationParams = TransformationParamsGroup | Array; export type AccountId = string; export type TransformationArtifactPath = string; export type FilePath = string; export type TransformationUrlSlug = string; export type GetApiAccountIdTransformationFilePathArgs = {''?: TransformationParams | undefined, accountId: AccountId, artifact?: TransformationArtifactPath | undefined, cache?: boolean | undefined, 'cache-only'?: boolean | undefined, 'cache-perm'?: ('auto' | 'false' | 'true') | undefined, 'cache-ttl'?: number | undefined, 'cache-ttl-404'?: number | undefined, exp?: (number | 'inf') | undefined, filePath: FilePath, transformation: TransformationUrlSlug, version?: string | undefined}; export type GetApiAccountIdTransformationFilePathOptions = {baseUrl?: string | undefined, authorizationHeader?: string | undefined, fetch?: typeof fetch | undefined}; /** * Processes a file and returns the result. * * GET /{accountId}/{transformation}{filePath} */ export const getApiAccountIdTransformationFilePath = async (args: GetApiAccountIdTransformationFilePathArgs, options?: GetApiAccountIdTransformationFilePathOptions) => { const {baseUrl = "https://upcdn.io", fetch: fetchFn = fetch, authorizationHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*") if (args[''] != null) query.append("", String(args[''])) if (args.artifact != null) query.append("artifact", String(args.artifact)) if (args.cache != null) query.append("cache", String(args.cache)) if (args['cache-only'] != null) query.append("cache-only", String(args['cache-only'])) if (args['cache-perm'] != null) query.append("cache-perm", String(args['cache-perm'])) if (args['cache-ttl'] != null) query.append("cache-ttl", String(args['cache-ttl'])) if (args['cache-ttl-404'] != null) query.append("cache-ttl-404", String(args['cache-ttl-404'])) if (args.exp != null) query.append("exp", String(args.exp)) if (args.version != null) query.append("version", String(args.version)) if (authorizationHeader !== undefined) headers.set("Authorization", authorizationHeader) const url = `${baseUrl.replace(/\/+$/, '')}/${encodeURIComponent(String(args.accountId))}/${encodeURIComponent(String(args.transformation))}${encodeURIComponent(String(args.filePath))}${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 res.blob() };