@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/AUTHORING.md +52 -13
- package/CHANGELOG.md +11 -0
- package/dist/define.js +29 -1
- package/dist/error-resolution.d.ts +2 -0
- package/dist/error-resolution.js +90 -0
- package/dist/errors.d.ts +12 -0
- package/dist/errors.js +19 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/native-egress-policy.d.ts +27 -0
- package/dist/native-egress-policy.js +225 -0
- package/dist/provider.d.ts +3 -3
- package/dist/provider.js +2 -2
- package/dist/runtime/http.js +189 -9
- package/dist/runtime/native-network.d.ts +39 -4
- package/dist/runtime/native-network.js +365 -20
- package/dist/runtime/redirects.d.ts +29 -0
- package/dist/runtime/redirects.js +36 -0
- package/dist/runtime/stealth.js +16 -44
- package/dist/server/serve.js +105 -94
- package/dist/testing/run.js +32 -13
- package/dist/types.d.ts +26 -3
- package/dist/types.js +1 -0
- package/package.json +1 -1
- package/src/define.ts +44 -0
- package/src/error-resolution.ts +91 -0
- package/src/errors.ts +28 -0
- package/src/index.ts +7 -0
- package/src/native-egress-policy.ts +285 -0
- package/src/provider.ts +8 -0
- package/src/runtime/http.ts +217 -9
- package/src/runtime/native-network.ts +474 -22
- package/src/runtime/redirects.ts +66 -0
- package/src/runtime/stealth.ts +20 -47
- package/src/server/serve.ts +141 -92
- package/src/testing/run.ts +39 -14
- package/src/types.ts +37 -3
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?:
|
|
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:
|
|
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;
|