@apifuse/provider-sdk 2.2.0-beta.26 → 2.2.0-beta.28
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/CHANGELOG.md +8 -0
- package/bin/apifuse-dev.ts +2 -2
- package/bin/apifuse-pack-smoke.ts +1 -1
- package/bin/apifuse-pack-types.ts +2 -1
- package/bin/apifuse-perf.ts +2 -4
- package/bin/apifuse-record.ts +1 -1
- package/dist/auth-turn/index.d.ts +1 -1
- package/dist/auth-turn/index.js +1 -1
- package/dist/ceremonies/index.js +52 -11
- package/dist/config/loader.d.ts +1 -1
- package/dist/config/loader.js +4 -2
- package/dist/contract-serialization.d.ts +1 -20
- package/dist/contract-serialization.js +8 -587
- package/dist/contract.d.ts +0 -2
- package/dist/contract.js +5 -9
- package/dist/index.d.ts +9 -8
- package/dist/index.js +6 -8
- package/dist/provider.d.ts +3 -2
- package/dist/provider.js +2 -2
- package/dist/runtime/auth-flow.js +1 -1
- package/dist/runtime/http.d.ts +1 -0
- package/dist/runtime/http.js +135 -12
- package/dist/runtime/instrumentation.js +1 -1
- package/dist/runtime/native-network-errors.d.ts +33 -0
- package/dist/runtime/native-network-errors.js +69 -0
- package/dist/runtime/native-network.d.ts +2 -33
- package/dist/runtime/native-network.js +2 -68
- package/dist/runtime/redis.d.ts +1 -1
- package/dist/runtime/redis.js +4 -2
- package/dist/runtime/resolver-config.d.ts +6 -0
- package/dist/runtime/resolver-config.js +6 -0
- package/dist/runtime/resolver-shared.d.ts +3 -0
- package/dist/runtime/resolver-shared.js +12 -0
- package/dist/runtime/resolver-vendors/twocaptcha.d.ts +2 -1
- package/dist/runtime/resolver-vendors/twocaptcha.js +80 -43
- package/dist/runtime/resolver-vendors/types.d.ts +1 -1
- package/dist/runtime/resolver.d.ts +6 -10
- package/dist/runtime/resolver.js +19 -18
- package/dist/runtime/state.js +5 -115
- package/dist/runtime/stealth-cookies.d.ts +20 -0
- package/dist/runtime/stealth-cookies.js +111 -0
- package/dist/runtime/stealth.js +7 -130
- package/dist/schema.d.ts +0 -63
- package/dist/schema.js +8 -808
- package/dist/serve.d.ts +1 -1
- package/dist/serve.js +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/self-test.d.ts +13 -0
- package/dist/server/self-test.js +124 -46
- package/dist/server/serve-implementation.d.ts +199 -0
- package/dist/server/serve-implementation.js +2054 -0
- package/dist/server/serve.d.ts +1 -187
- package/dist/server/serve.js +1 -1827
- package/dist/stateful/errors.d.ts +5 -0
- package/dist/stateful/errors.js +10 -0
- package/dist/stateful/stateful-provider-session-routing.d.ts +1 -5
- package/dist/stateful/stateful-provider-session-routing.js +2 -10
- package/dist/stream.js +7 -1
- package/package.json +27 -2
- package/src/auth-turn/index.ts +1 -1
- package/src/ceremonies/index.ts +68 -18
- package/src/config/loader.ts +5 -2
- package/src/contract-serialization.ts +8 -859
- package/src/contract.ts +5 -16
- package/src/index.ts +18 -34
- package/src/provider.ts +12 -24
- package/src/runtime/auth-flow.ts +1 -1
- package/src/runtime/http.ts +155 -11
- package/src/runtime/instrumentation.ts +1 -1
- package/src/runtime/native-network-errors.ts +99 -0
- package/src/runtime/native-network.ts +16 -97
- package/src/runtime/redis.ts +7 -2
- package/src/runtime/resolver-config.ts +6 -0
- package/src/runtime/resolver-shared.ts +17 -0
- package/src/runtime/resolver-vendors/twocaptcha.ts +100 -49
- package/src/runtime/resolver-vendors/types.ts +1 -0
- package/src/runtime/resolver.ts +47 -22
- package/src/runtime/state.ts +5 -144
- package/src/runtime/stealth-cookies.ts +132 -0
- package/src/runtime/stealth.ts +14 -157
- package/src/schema.ts +9 -1060
- package/src/serve.ts +6 -1
- package/src/server/index.ts +1 -0
- package/src/server/self-test.ts +184 -59
- package/src/server/serve-implementation.ts +3024 -0
- package/src/server/serve.ts +1 -2661
- package/src/stateful/errors.ts +12 -0
- package/src/stateful/stateful-provider-session-routing.ts +2 -11
- package/src/stream.ts +8 -1
package/src/stateful/errors.ts
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
export type StatefulControlPlaneOperation = "resolve" | "acquire" | "renew" | "release";
|
|
2
2
|
|
|
3
|
+
export class StatefulRoutingDeadlineError extends Error {
|
|
4
|
+
readonly requestId: string;
|
|
5
|
+
readonly deadlineAt: string;
|
|
6
|
+
|
|
7
|
+
constructor(requestId: string, deadlineAt: string) {
|
|
8
|
+
super(`Stateful operation request ${requestId} deadline has expired.`);
|
|
9
|
+
this.name = "StatefulRoutingDeadlineError";
|
|
10
|
+
this.requestId = requestId;
|
|
11
|
+
this.deadlineAt = deadlineAt;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
3
15
|
export class StatefulControlPlaneError extends Error {
|
|
4
16
|
readonly code: string;
|
|
5
17
|
readonly operation: StatefulControlPlaneOperation;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SessionKey } from "./session-key.js";
|
|
2
|
+
import { StatefulRoutingDeadlineError } from "./errors.js";
|
|
2
3
|
import {
|
|
3
4
|
NOOP_STATEFUL_PROVIDER_METRIC_EMITTER,
|
|
4
5
|
type StatefulProviderMetricEmitter,
|
|
@@ -82,17 +83,7 @@ type DeadlineSignal = {
|
|
|
82
83
|
readonly cleanup: () => void;
|
|
83
84
|
};
|
|
84
85
|
|
|
85
|
-
export
|
|
86
|
-
readonly requestId: string;
|
|
87
|
-
readonly deadlineAt: string;
|
|
88
|
-
|
|
89
|
-
constructor(requestId: string, deadlineAt: string) {
|
|
90
|
-
super(`Stateful operation request ${requestId} deadline has expired.`);
|
|
91
|
-
this.name = "StatefulRoutingDeadlineError";
|
|
92
|
-
this.requestId = requestId;
|
|
93
|
-
this.deadlineAt = deadlineAt;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
86
|
+
export { StatefulRoutingDeadlineError } from "./errors.js";
|
|
96
87
|
|
|
97
88
|
export class StatefulRoutingOwnershipError extends Error {
|
|
98
89
|
readonly requestId: string;
|
package/src/stream.ts
CHANGED
|
@@ -85,13 +85,20 @@ function sseFieldValue(value: string, field: "event" | "id"): string {
|
|
|
85
85
|
|
|
86
86
|
export async function* readableBytes(body: ReadableStream<Uint8Array>): AsyncIterable<Uint8Array> {
|
|
87
87
|
const reader = body.getReader();
|
|
88
|
+
let completed = false;
|
|
88
89
|
try {
|
|
89
90
|
for (;;) {
|
|
90
91
|
const { value, done } = await reader.read();
|
|
91
|
-
if (done)
|
|
92
|
+
if (done) {
|
|
93
|
+
completed = true;
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
92
96
|
if (value) yield value;
|
|
93
97
|
}
|
|
94
98
|
} finally {
|
|
99
|
+
if (!completed) {
|
|
100
|
+
await reader.cancel().catch(() => undefined);
|
|
101
|
+
}
|
|
95
102
|
reader.releaseLock();
|
|
96
103
|
}
|
|
97
104
|
}
|