export type ExposureAnalysisType = 'Collection' | 'Target' | 'TargetList' | 'Country' | 'Alert' | 'Scenario'; export type CommodityFilterId = {treeId: number, commodityId: number, path: Array}; export type CommodityFilter = {commodities: Array, suspectedSuppliers: boolean, logisticsProvider: boolean}; export type BaseExposurePayload = {maxTiers: number, type: ExposureAnalysisType, scopePrivate: boolean, scopeShared: boolean, scopePublic: boolean, sourceCustoms: boolean, sourcePrewavePrediction: boolean, sourceMedia: boolean, sourceCustomer: boolean, minShipments?: (number | null) | undefined, minProbability?: (number | null) | undefined, shipmentsPeriodFrom?: (string | null) | undefined, shipmentsPeriodTo?: (string | null) | undefined, commodityFilter: CommodityFilter, collectionCommodityFilters: {[key: string]: CommodityFilter}, exposedCollectionIds: Array, exposedTargetIds: Array, exposedTargetId?: (number | null) | undefined, exposedCountryIds: Array, exposedAlertId?: (number | null) | undefined, scenarioId?: (number | null) | undefined}; export type UpdateApiPublicV1AlphaExposureTargetTargetIdGraphArgs = {targetId: number, body: BaseExposurePayload}; export type UpdateApiPublicV1AlphaExposureTargetTargetIdGraphOptions = {baseUrl?: string | undefined, TokenAuthentication?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get exposure graph by target id * * PUT /public/v1/alpha/exposure/target/{targetId}/graph */ export const updateApiPublicV1AlphaExposureTargetTargetIdGraph = async (args: UpdateApiPublicV1AlphaExposureTargetTargetIdGraphArgs, options?: UpdateApiPublicV1AlphaExposureTargetTargetIdGraphOptions) => { const {baseUrl = "https://api.prewave.com", fetch: fetchFn = fetch, TokenAuthentication} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") if (TokenAuthentication !== undefined) headers.set("X-Auth-Token", TokenAuthentication) const url = `${baseUrl.replace(/\/+$/, '')}/public/v1/alpha/exposure/target/${encodeURIComponent(String(args.targetId))}/graph${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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() };