@apifuse/provider-sdk 2.2.0-beta.14 → 2.2.0-beta.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/types.ts CHANGED
@@ -719,9 +719,13 @@ export interface HealthMonitorProbeOverride {
719
719
  degradedThresholdMs?: number;
720
720
  }
721
721
 
722
+ export const VALID_OPERATION_ERROR_STATUSES = [400, 401, 404, 429, 500, 502, 503, 504] as const;
723
+
724
+ export type ProviderErrorStatus = (typeof VALID_OPERATION_ERROR_STATUSES)[number];
725
+
722
726
  export interface OperationErrorCode {
723
727
  code: string;
724
- status?: number;
728
+ status?: ProviderErrorStatus;
725
729
  description: string;
726
730
  retryable?: boolean;
727
731
  }
@@ -1019,8 +1023,32 @@ export interface RequestOptions {
1019
1023
  */
1020
1024
  throwOnHttpError?: boolean;
1021
1025
  retry?: boolean | HttpRetryPreset | HttpRetryOptions;
1026
+ /**
1027
+ * Opt-in redirect-hop enforcement for ctx.http. When present, redirects are
1028
+ * evaluated before the next request is issued. Existing callers that omit
1029
+ * this policy retain the native fetch redirect behavior.
1030
+ */
1031
+ redirectPolicy?: HttpRedirectPolicy;
1032
+ }
1033
+
1034
+ export type RedirectRunReason =
1035
+ | "completed"
1036
+ | "stopped"
1037
+ | "max_hops"
1038
+ | "missing_location"
1039
+ | "loop";
1040
+
1041
+ export type HttpRedirectPolicyMode = "same-origin";
1042
+
1043
+ export interface HttpRedirectPolicy {
1044
+ /** Only follow redirects whose canonical scheme, host, and port match the initial URL. */
1045
+ mode: HttpRedirectPolicyMode;
1046
+ /** Maximum number of redirect hops that may be followed. Must be an integer from 0 to 20. */
1047
+ maxHops: number;
1022
1048
  }
1023
1049
 
1050
+ export type HttpRedirectFailureReason = Exclude<RedirectRunReason, "completed">;
1051
+
1024
1052
  export type HttpMethod =
1025
1053
  | "HEAD"
1026
1054
  | "head"
@@ -1039,7 +1067,7 @@ export type HttpMethod =
1039
1067
  | "PATCH"
1040
1068
  | "patch";
1041
1069
 
1042
- export interface StealthFetchOptions extends RequestOptions {
1070
+ export interface StealthFetchOptions extends Omit<RequestOptions, "redirectPolicy"> {
1043
1071
  method?: HttpMethod;
1044
1072
  body?: string | Buffer;
1045
1073
  redirect?: "follow" | "manual" | "error";
@@ -1152,7 +1180,7 @@ export interface StealthRedirectRunOptions
1152
1180
  export interface StealthRedirectRunResult {
1153
1181
  final: StealthResponse;
1154
1182
  hops: StealthRedirectHop[];
1155
- reason: "completed" | "stopped" | "max_hops" | "missing_location" | "loop";
1183
+ reason: RedirectRunReason;
1156
1184
  /**
1157
1185
  * Complete flat view across all redirect hosts. Attributes and duplicate names are lost.
1158
1186
  * @deprecated Use cookieStore for lossless persistence.
@@ -1290,6 +1318,12 @@ export interface NativeTcpEgressRule {
1290
1318
  /**
1291
1319
  * Bounded native TCP egress discovered through a declared bootstrap endpoint.
1292
1320
  * Host suffixes are exact DNS suffixes, not wildcard patterns.
1321
+ *
1322
+ * Dynamic rules are ordered. The first rule whose source, target, port, and TLS
1323
+ * selectors match exclusively owns the grant; its ttlMs and maxGrants bounds
1324
+ * apply, and an exhausted/shorter rule never falls through to a later overlap.
1325
+ * Every rule must declare a source host selector, source port list/range, and
1326
+ * target port list/range; omitted ttlMs/maxGrants remain unbounded.
1293
1327
  */
1294
1328
  export interface NativeTcpDynamicEgressRule {
1295
1329
  readonly sourceHost?: string;