export type Subscriber = {successUri?: string | undefined, inProgressUri?: string | undefined, failedUri?: string | undefined}; export type Execute = {inputs: unknown, outputs: unknown, response?: ('raw' | 'document') | undefined, subscriber?: Subscriber | undefined}; export type CreateApiProcessesProcessIDExecutionArgs = {processID: string, body: Execute}; export type CreateApiProcessesProcessIDExecutionOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * execute a process. * * POST /processes/{processID}/execution */ export const createApiProcessesProcessIDExecution = async (args: CreateApiProcessesProcessIDExecutionArgs, options?: CreateApiProcessesProcessIDExecutionOptions) => { const {baseUrl = "http://example.org/ogcapi", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "/*") const url = `${baseUrl.replace(/\/+$/, '')}/processes/${encodeURIComponent(String(args.processID))}/execution${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 res.blob() };