@@ -88,6 +88,11 @@ type GuardedProviderRequestParams = {
|
88 | 88 | ssrfPolicy?: SsrFPolicy; |
89 | 89 | dispatcherPolicy?: PinnedDispatcherPolicy; |
90 | 90 | auditContext?: string; |
| 91 | +/** |
| 92 | + * Override the guarded-fetch mode. Defaults to an auto-upgrade to |
| 93 | + * `TRUSTED_ENV_PROXY` when `HTTP_PROXY`/`HTTPS_PROXY` is configured in the |
| 94 | + * environment; pass `"strict"` to force pinned-DNS even inside a proxy. |
| 95 | + */ |
91 | 96 | mode?: GuardedFetchMode; |
92 | 97 | }; |
93 | 98 | |
@@ -521,26 +526,16 @@ type GuardedPostRequestRetryOptions = {
|
521 | 526 | retry?: TransientProviderRetryConfig; |
522 | 527 | }; |
523 | 528 | |
524 | | -export async function postTranscriptionRequest( |
525 | | -params: { |
| 529 | +type GuardedPostRequestParams<TBody> = GuardedProviderRequestParams & |
| 530 | +GuardedPostRequestRetryOptions & { |
526 | 531 | url: string; |
527 | 532 | headers: Headers; |
528 | | -body: BodyInit; |
| 533 | +body: TBody; |
529 | 534 | timeoutMs?: number; |
530 | 535 | fetchFn: typeof fetch; |
531 | | -pinDns?: boolean; |
532 | | -allowPrivateNetwork?: boolean; |
533 | | -ssrfPolicy?: SsrFPolicy; |
534 | | -dispatcherPolicy?: PinnedDispatcherPolicy; |
535 | | -auditContext?: string; |
536 | | -/** |
537 | | - * Override the guarded-fetch mode. Defaults to an auto-upgrade to |
538 | | - * `TRUSTED_ENV_PROXY` when `HTTP_PROXY`/`HTTPS_PROXY` is configured in the |
539 | | - * environment; pass `"strict"` to force pinned-DNS even inside a proxy. |
540 | | - */ |
541 | | -mode?: GuardedFetchMode; |
542 | | -} & GuardedPostRequestRetryOptions, |
543 | | -) { |
| 536 | +}; |
| 537 | + |
| 538 | +export async function postTranscriptionRequest(params: GuardedPostRequestParams<BodyInit>) { |
544 | 539 | return await postGuardedRequest({ |
545 | 540 | url: params.url, |
546 | 541 | init: { |
@@ -599,26 +594,7 @@ function isTransientProviderHttpStatus(status: number): boolean {
|
599 | 594 | return status === 500 || status === 502 || status === 503 || status === 504; |
600 | 595 | } |
601 | 596 | |
602 | | -export async function postJsonRequest( |
603 | | -params: { |
604 | | -url: string; |
605 | | -headers: Headers; |
606 | | -body: unknown; |
607 | | -timeoutMs?: number; |
608 | | -fetchFn: typeof fetch; |
609 | | -pinDns?: boolean; |
610 | | -allowPrivateNetwork?: boolean; |
611 | | -ssrfPolicy?: SsrFPolicy; |
612 | | -dispatcherPolicy?: PinnedDispatcherPolicy; |
613 | | -auditContext?: string; |
614 | | -/** |
615 | | - * Override the guarded-fetch mode. Defaults to an auto-upgrade to |
616 | | - * `TRUSTED_ENV_PROXY` when `HTTP_PROXY`/`HTTPS_PROXY` is configured in the |
617 | | - * environment; pass `"strict"` to force pinned-DNS even inside a proxy. |
618 | | - */ |
619 | | -mode?: GuardedFetchMode; |
620 | | -} & GuardedPostRequestRetryOptions, |
621 | | -) { |
| 597 | +export async function postJsonRequest(params: GuardedPostRequestParams<unknown>) { |
622 | 598 | return await postGuardedRequest({ |
623 | 599 | url: params.url, |
624 | 600 | init: { |
@@ -634,26 +610,7 @@ export async function postJsonRequest(
|
634 | 610 | }); |
635 | 611 | } |
636 | 612 | |
637 | | -export async function postMultipartRequest( |
638 | | -params: { |
639 | | -url: string; |
640 | | -headers: Headers; |
641 | | -body: BodyInit; |
642 | | -timeoutMs?: number; |
643 | | -fetchFn: typeof fetch; |
644 | | -pinDns?: boolean; |
645 | | -allowPrivateNetwork?: boolean; |
646 | | -ssrfPolicy?: SsrFPolicy; |
647 | | -dispatcherPolicy?: PinnedDispatcherPolicy; |
648 | | -auditContext?: string; |
649 | | -/** |
650 | | - * Override the guarded-fetch mode. Defaults to an auto-upgrade to |
651 | | - * `TRUSTED_ENV_PROXY` when `HTTP_PROXY`/`HTTPS_PROXY` is configured in the |
652 | | - * environment; pass `"strict"` to force pinned-DNS even inside a proxy. |
653 | | - */ |
654 | | -mode?: GuardedFetchMode; |
655 | | -} & GuardedPostRequestRetryOptions, |
656 | | -) { |
| 613 | +export async function postMultipartRequest(params: GuardedPostRequestParams<BodyInit>) { |
657 | 614 | return await postGuardedRequest({ |
658 | 615 | url: params.url, |
659 | 616 | init: { |
|