@apifuse/provider-sdk 2.2.0-beta.22 → 2.2.0-beta.23
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 +4 -0
- package/bin/apifuse-dev.ts +2 -0
- package/bin/apifuse-record.ts +2 -0
- package/dist/contract-types.d.ts +1 -0
- package/dist/contract.js +2 -0
- package/dist/define.d.ts +2 -1
- package/dist/define.js +15 -0
- package/dist/error-resolution.js +5 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/runtime/auth-flow.d.ts +2 -1
- package/dist/runtime/auth-flow.js +2 -0
- package/dist/runtime/browser.js +28 -9
- package/dist/runtime/ocr.d.ts +29 -0
- package/dist/runtime/ocr.js +440 -0
- package/dist/runtime/stt.js +1 -12
- package/dist/runtime/timeout.d.ts +5 -0
- package/dist/runtime/timeout.js +12 -0
- package/dist/server/serve.d.ts +3 -1
- package/dist/server/serve.js +4 -0
- package/dist/testing/run.js +3 -0
- package/dist/types.d.ts +51 -0
- package/package.json +1 -1
- package/src/contract-types.ts +1 -0
- package/src/contract.ts +2 -0
- package/src/define.ts +17 -0
- package/src/error-resolution.ts +5 -0
- package/src/index.ts +25 -0
- package/src/runtime/auth-flow.ts +4 -0
- package/src/runtime/browser.ts +70 -19
- package/src/runtime/ocr.ts +523 -0
- package/src/runtime/stt.ts +1 -19
- package/src/runtime/timeout.ts +18 -0
- package/src/server/serve.ts +7 -0
- package/src/testing/run.ts +7 -0
- package/src/types.ts +58 -0
package/src/types.ts
CHANGED
|
@@ -243,6 +243,61 @@ export interface SmsOtpMatcherDefinition {
|
|
|
243
243
|
extractOtp(body: string): string | null;
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
+
export interface ProviderOcrConfig {
|
|
247
|
+
readonly mode: "required" | "optional";
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export type OcrImageInput =
|
|
251
|
+
| { readonly kind: "base64"; readonly data: string; readonly mediaType?: string }
|
|
252
|
+
| { readonly kind: "url"; readonly url: string };
|
|
253
|
+
|
|
254
|
+
export interface OcrRecognizeRequest {
|
|
255
|
+
readonly image: OcrImageInput;
|
|
256
|
+
readonly hint?: "captcha" | "document" | "generic";
|
|
257
|
+
readonly prompt?: string;
|
|
258
|
+
readonly maxTokens?: number;
|
|
259
|
+
readonly timeoutMs?: number;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export interface OcrWarning {
|
|
263
|
+
readonly code: string;
|
|
264
|
+
readonly message: string;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export interface OcrResult {
|
|
268
|
+
readonly text: string;
|
|
269
|
+
readonly model: string;
|
|
270
|
+
readonly warnings?: readonly OcrWarning[];
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export interface OcrCaptchaOptions {
|
|
274
|
+
readonly length?: number;
|
|
275
|
+
/** Allowed characters. A RegExp is applied to each character, not to the whole text. */
|
|
276
|
+
readonly charset?: string | RegExp;
|
|
277
|
+
readonly caseSensitive?: boolean;
|
|
278
|
+
readonly maxCandidates?: number;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export interface OcrCaptchaCandidate {
|
|
282
|
+
readonly text: string;
|
|
283
|
+
readonly satisfiesConstraints: boolean;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export interface OcrCaptchaResult {
|
|
287
|
+
readonly text: string;
|
|
288
|
+
readonly candidates: readonly OcrCaptchaCandidate[];
|
|
289
|
+
readonly satisfiesConstraints: boolean;
|
|
290
|
+
readonly model: string;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export interface OcrContext {
|
|
294
|
+
recognize(request: OcrRecognizeRequest): Promise<OcrResult>;
|
|
295
|
+
extractCaptchaText(
|
|
296
|
+
image: OcrImageInput,
|
|
297
|
+
options?: OcrCaptchaOptions,
|
|
298
|
+
): Promise<OcrCaptchaResult>;
|
|
299
|
+
}
|
|
300
|
+
|
|
246
301
|
export type SttTranscribeMode = "general" | "otp";
|
|
247
302
|
export type SttPromptPolicy = "none" | "default-hint" | "custom-hint";
|
|
248
303
|
export type SttUnsupportedOptionPolicy = "warn" | "error";
|
|
@@ -1889,6 +1944,7 @@ export interface FlowContext {
|
|
|
1889
1944
|
env: EnvContext;
|
|
1890
1945
|
credential?: CredentialContext;
|
|
1891
1946
|
context: ContextScratchpad;
|
|
1947
|
+
ocr: OcrContext;
|
|
1892
1948
|
stt: SttContext;
|
|
1893
1949
|
auth: AuthFlowTerminalContext;
|
|
1894
1950
|
}
|
|
@@ -2014,6 +2070,7 @@ export interface ProviderContext {
|
|
|
2014
2070
|
browser: BrowserClient;
|
|
2015
2071
|
trace: TraceContext;
|
|
2016
2072
|
auth: AuthContext;
|
|
2073
|
+
ocr: OcrContext;
|
|
2017
2074
|
stt: SttContext;
|
|
2018
2075
|
choice: ProviderChoiceContext;
|
|
2019
2076
|
}
|
|
@@ -2187,6 +2244,7 @@ export interface ProviderDefinition {
|
|
|
2187
2244
|
platform: StealthPlatform;
|
|
2188
2245
|
};
|
|
2189
2246
|
proxy?: ProviderProxyConfig;
|
|
2247
|
+
ocr?: ProviderOcrConfig;
|
|
2190
2248
|
stt?: ProviderSttConfig;
|
|
2191
2249
|
browser?: {
|
|
2192
2250
|
engine: BrowserEngine;
|