@apifuse/provider-sdk 2.2.0-beta.4 → 2.2.0-beta.40
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 +501 -13
- package/CHANGELOG.md +165 -1
- package/README.md +72 -14
- package/SUBMISSION.md +1 -1
- package/bin/apifuse-check.ts +88 -4
- package/bin/apifuse-dev.ts +38 -5
- package/bin/apifuse-pack-check.ts +22 -2
- package/bin/apifuse-pack-smoke.ts +57 -2
- package/bin/apifuse-pack-types.ts +356 -38
- package/bin/apifuse-perf.ts +14 -13
- package/bin/apifuse-record.ts +691 -68
- package/bin/apifuse-submit-check.ts +518 -37
- package/bin/apifuse-sync-assets.ts +117 -0
- package/bin/submit-check-delimited-text.ts +50 -0
- package/dist/auth-turn/index.d.ts +3 -3
- package/dist/auth-turn/index.js +1 -1
- package/dist/auth.d.ts +14 -0
- package/dist/auth.js +67 -0
- package/dist/ceremonies/index.d.ts +16 -0
- package/dist/ceremonies/index.js +141 -36
- package/dist/cli/commands.d.ts +1 -1
- package/dist/cli/commands.js +8 -0
- package/dist/cli/create.d.ts +3 -0
- package/dist/cli/create.js +34 -35
- package/dist/cli/prompt-assets.d.ts +80 -0
- package/dist/cli/prompt-assets.js +743 -0
- package/dist/cli/templates/provider/AGENTS.md.tpl +17 -8
- package/dist/cli/templates/provider/Dockerfile.tpl +1 -1
- package/dist/cli/templates/provider/README.md.tpl +4 -4
- package/dist/cli/templates/provider/index.ts.tpl +6 -3
- package/dist/cli/templates/provider/operations/ping.ts.tpl +2 -1
- package/dist/config/loader.d.ts +177 -16
- package/dist/config/loader.js +424 -127
- package/dist/contract-serialization.js +4 -8
- package/dist/contract-types.d.ts +1 -0
- package/dist/contract.js +2 -0
- package/dist/declaration-validation.d.ts +32 -0
- package/dist/declaration-validation.js +207 -0
- package/dist/define.d.ts +51 -25
- package/dist/define.js +752 -38
- package/dist/error-resolution.d.ts +4 -0
- package/dist/error-resolution.js +122 -0
- package/dist/errors.d.ts +18 -0
- package/dist/errors.js +40 -0
- package/dist/fixture-sanitization.d.ts +28 -0
- package/dist/fixture-sanitization.js +217 -0
- package/dist/health-scenario.d.ts +1842 -0
- package/dist/health-scenario.js +624 -0
- package/dist/index.d.ts +19 -9
- package/dist/index.js +10 -6
- package/dist/lint.d.ts +6 -1
- package/dist/lint.js +362 -3
- package/dist/native-address.d.ts +43 -0
- package/dist/native-address.js +281 -0
- package/dist/native-egress-policy.d.ts +31 -0
- package/dist/native-egress-policy.js +288 -0
- package/dist/observability.d.ts +5 -2
- package/dist/observability.js +48 -1
- package/dist/provider.d.ts +8 -2
- package/dist/provider.js +3 -1
- package/dist/runtime/auth-flow.d.ts +5 -1
- package/dist/runtime/auth-flow.js +6 -0
- package/dist/runtime/browser.d.ts +1 -0
- package/dist/runtime/browser.js +492 -49
- package/dist/runtime/cache.d.ts +1 -0
- package/dist/runtime/cache.js +169 -15
- package/dist/runtime/choice-wordlist.d.ts +9 -0
- package/dist/runtime/choice-wordlist.js +138 -0
- package/dist/runtime/choice.d.ts +13 -1
- package/dist/runtime/choice.js +490 -102
- package/dist/runtime/executor.d.ts +2 -2
- package/dist/runtime/executor.js +26 -2
- package/dist/runtime/http.d.ts +1 -0
- package/dist/runtime/http.js +515 -53
- package/dist/runtime/instrumentation.d.ts +2 -2
- package/dist/runtime/instrumentation.js +366 -8
- 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 +96 -0
- package/dist/runtime/native-network.js +1232 -0
- package/dist/runtime/ocr.d.ts +29 -0
- package/dist/runtime/ocr.js +440 -0
- package/dist/runtime/proxy-errors.js +6 -2
- package/dist/runtime/proxy-nodemaven.d.ts +56 -0
- package/dist/runtime/proxy-nodemaven.js +146 -0
- package/dist/runtime/proxy-telemetry.d.ts +80 -1
- package/dist/runtime/proxy-telemetry.js +154 -47
- package/dist/runtime/redirects.d.ts +29 -0
- package/dist/runtime/redirects.js +36 -0
- package/dist/runtime/redis.d.ts +1 -1
- package/dist/runtime/redis.js +4 -2
- package/dist/runtime/request-options.d.ts +68 -1
- package/dist/runtime/request-options.js +548 -0
- package/dist/runtime/resolver-config.d.ts +6 -0
- package/dist/runtime/resolver-config.js +6 -0
- package/dist/runtime/resolver-public.d.ts +1 -0
- package/dist/runtime/resolver-public.js +1 -0
- package/dist/runtime/resolver-shared.d.ts +3 -0
- package/dist/runtime/resolver-shared.js +12 -0
- package/dist/runtime/resolver-vendors/bindings.d.ts +48 -0
- package/dist/runtime/resolver-vendors/bindings.js +40 -0
- package/dist/runtime/resolver-vendors/browser.d.ts +22 -0
- package/dist/runtime/resolver-vendors/browser.js +377 -0
- package/dist/runtime/resolver-vendors/capsolver.d.ts +22 -0
- package/dist/runtime/resolver-vendors/capsolver.js +526 -0
- package/dist/runtime/resolver-vendors/hosts.d.ts +2 -0
- package/dist/runtime/resolver-vendors/hosts.js +33 -0
- package/dist/runtime/resolver-vendors/twocaptcha.d.ts +24 -0
- package/dist/runtime/resolver-vendors/twocaptcha.js +407 -0
- package/dist/runtime/resolver-vendors/types.d.ts +94 -0
- package/dist/runtime/resolver-vendors/types.js +96 -0
- package/dist/runtime/resolver.d.ts +60 -0
- package/dist/runtime/resolver.js +737 -0
- package/dist/runtime/secrets.d.ts +27 -0
- package/dist/runtime/secrets.js +51 -0
- package/dist/runtime/state.d.ts +3 -0
- package/dist/runtime/state.js +277 -71
- package/dist/runtime/stealth-cookies.d.ts +20 -0
- package/dist/runtime/stealth-cookies.js +111 -0
- package/dist/runtime/stealth.d.ts +28 -3
- package/dist/runtime/stealth.js +519 -255
- package/dist/runtime/stt.js +1 -12
- package/dist/runtime/timeout.d.ts +5 -0
- package/dist/runtime/timeout.js +12 -0
- package/dist/runtime/trace-config.d.ts +12 -0
- package/dist/runtime/trace-config.js +61 -0
- package/dist/serve.d.ts +1 -1
- package/dist/serve.js +1 -1
- package/dist/server/index.d.ts +5 -3
- package/dist/server/index.js +3 -3
- package/dist/server/self-test-input-tokens.d.ts +2 -1
- package/dist/server/self-test-input-tokens.js +18 -14
- package/dist/server/self-test.d.ts +114 -0
- package/dist/server/self-test.js +784 -148
- package/dist/server/serve-implementation.d.ts +213 -0
- package/dist/server/serve-implementation.js +2173 -0
- package/dist/server/serve.d.ts +1 -70
- package/dist/server/serve.js +1 -1130
- package/dist/server/trace-output.d.ts +4 -0
- package/dist/server/trace-output.js +20 -0
- package/dist/server/types.d.ts +30 -5
- package/dist/server/types.js +13 -1
- package/dist/stateful/errors.d.ts +19 -0
- package/dist/stateful/errors.js +24 -0
- package/dist/stateful/http-provider-event-emitter.d.ts +40 -0
- package/dist/stateful/http-provider-event-emitter.js +237 -0
- package/dist/stateful/http-session-owner-registry.d.ts +44 -0
- package/dist/stateful/http-session-owner-registry.js +210 -0
- package/dist/stateful/index.d.ts +18 -0
- package/dist/stateful/index.js +18 -0
- package/dist/stateful/provider-event-delivery-failures.d.ts +32 -0
- package/dist/stateful/provider-event-delivery-failures.js +43 -0
- package/dist/stateful/provider-event-pipeline-metrics.d.ts +46 -0
- package/dist/stateful/provider-event-pipeline-metrics.js +48 -0
- package/dist/stateful/provider-event-pipeline.d.ts +50 -0
- package/dist/stateful/provider-event-pipeline.js +1 -0
- package/dist/stateful/provider-events.d.ts +101 -0
- package/dist/stateful/provider-events.js +289 -0
- package/dist/stateful/session-key.d.ts +15 -0
- package/dist/stateful/session-key.js +86 -0
- package/dist/stateful/stateful-provider-adapter-context.d.ts +5 -0
- package/dist/stateful/stateful-provider-adapter-context.js +42 -0
- package/dist/stateful/stateful-provider-adapter-metrics.d.ts +15 -0
- package/dist/stateful/stateful-provider-adapter-metrics.js +21 -0
- package/dist/stateful/stateful-provider-adapter.d.ts +98 -0
- package/dist/stateful/stateful-provider-adapter.js +287 -0
- package/dist/stateful/stateful-provider-observability.d.ts +62 -0
- package/dist/stateful/stateful-provider-observability.js +161 -0
- package/dist/stateful/stateful-provider-owner-forwarder.d.ts +41 -0
- package/dist/stateful/stateful-provider-owner-forwarder.js +215 -0
- package/dist/stateful/stateful-provider-runtime-context.d.ts +32 -0
- package/dist/stateful/stateful-provider-runtime-context.js +60 -0
- package/dist/stateful/stateful-provider-runtime-executor.d.ts +34 -0
- package/dist/stateful/stateful-provider-runtime-executor.js +52 -0
- package/dist/stateful/stateful-provider-session-routing.d.ts +67 -0
- package/dist/stateful/stateful-provider-session-routing.js +345 -0
- package/dist/stateful/stateful-provider-session-runtime.d.ts +98 -0
- package/dist/stateful/stateful-provider-session-runtime.js +245 -0
- package/dist/stateful-signing.d.ts +18 -0
- package/dist/stateful-signing.js +27 -0
- package/dist/stealth/profiles.js +16 -7
- package/dist/stream-evidence.d.ts +74 -0
- package/dist/stream-evidence.js +785 -0
- package/dist/stream.js +7 -1
- package/dist/testing/index.d.ts +2 -1
- package/dist/testing/index.js +2 -1
- package/dist/testing/run.d.ts +32 -2
- package/dist/testing/run.js +489 -21
- package/dist/trace-sanitization.d.ts +5 -0
- package/dist/trace-sanitization.js +45 -0
- package/dist/types.d.ts +545 -23
- package/dist/types.js +1 -0
- package/package.json +44 -5
- package/src/auth-turn/index.ts +1 -1
- package/src/auth.ts +118 -0
- package/src/ceremonies/index.ts +189 -46
- package/src/cli/commands.ts +10 -0
- package/src/cli/create.ts +42 -35
- package/src/cli/prompt-assets.ts +865 -0
- package/src/cli/templates/provider/AGENTS.md.tpl +17 -8
- package/src/cli/templates/provider/Dockerfile.tpl +1 -1
- package/src/cli/templates/provider/README.md.tpl +4 -4
- package/src/cli/templates/provider/index.ts.tpl +6 -3
- package/src/cli/templates/provider/operations/ping.ts.tpl +2 -1
- package/src/config/loader.ts +665 -163
- package/src/contract-serialization.ts +5 -7
- package/src/contract-types.ts +1 -0
- package/src/contract.ts +2 -0
- package/src/declaration-validation.ts +266 -0
- package/src/define.ts +970 -87
- package/src/error-resolution.ts +127 -0
- package/src/errors.ts +52 -0
- package/src/fixture-sanitization.ts +248 -0
- package/src/health-scenario.ts +875 -0
- package/src/index.ts +204 -8
- package/src/lint.ts +408 -4
- package/src/native-address.ts +340 -0
- package/src/native-egress-policy.ts +358 -0
- package/src/observability.ts +51 -1
- package/src/provider.ts +133 -0
- package/src/runtime/auth-flow.ts +12 -0
- package/src/runtime/browser.ts +661 -63
- package/src/runtime/cache.ts +189 -14
- package/src/runtime/choice-wordlist.ts +145 -0
- package/src/runtime/choice.ts +631 -120
- package/src/runtime/executor.ts +40 -7
- package/src/runtime/http.ts +641 -61
- package/src/runtime/instrumentation.ts +520 -15
- package/src/runtime/native-network-errors.ts +99 -0
- package/src/runtime/native-network.ts +1605 -0
- package/src/runtime/ocr.ts +523 -0
- package/src/runtime/proxy-errors.ts +12 -4
- package/src/runtime/proxy-nodemaven.ts +221 -0
- package/src/runtime/proxy-telemetry.ts +244 -75
- package/src/runtime/redirects.ts +66 -0
- package/src/runtime/redis.ts +7 -2
- package/src/runtime/request-options.ts +680 -1
- package/src/runtime/resolver-config.ts +6 -0
- package/src/runtime/resolver-public.ts +20 -0
- package/src/runtime/resolver-shared.ts +17 -0
- package/src/runtime/resolver-vendors/bindings.ts +56 -0
- package/src/runtime/resolver-vendors/browser.ts +533 -0
- package/src/runtime/resolver-vendors/capsolver.ts +700 -0
- package/src/runtime/resolver-vendors/hosts.ts +38 -0
- package/src/runtime/resolver-vendors/twocaptcha.ts +539 -0
- package/src/runtime/resolver-vendors/types.ts +212 -0
- package/src/runtime/resolver.ts +1103 -0
- package/src/runtime/secrets.ts +64 -0
- package/src/runtime/state.ts +394 -77
- package/src/runtime/stealth-cookies.ts +132 -0
- package/src/runtime/stealth.ts +675 -289
- package/src/runtime/stt.ts +1 -19
- package/src/runtime/timeout.ts +18 -0
- package/src/runtime/trace-config.ts +77 -0
- package/src/serve.ts +6 -1
- package/src/server/index.ts +37 -2
- package/src/server/self-test-input-tokens.ts +29 -14
- package/src/server/self-test.ts +1025 -175
- package/src/server/serve-implementation.ts +3250 -0
- package/src/server/serve.ts +1 -1626
- package/src/server/trace-output.ts +32 -0
- package/src/server/types.ts +13 -1
- package/src/stateful/README.md +146 -0
- package/src/stateful/errors.ts +35 -0
- package/src/stateful/http-provider-event-emitter.ts +314 -0
- package/src/stateful/http-session-owner-registry.ts +306 -0
- package/src/stateful/index.ts +18 -0
- package/src/stateful/provider-event-delivery-failures.ts +80 -0
- package/src/stateful/provider-event-pipeline-metrics.ts +95 -0
- package/src/stateful/provider-event-pipeline.ts +61 -0
- package/src/stateful/provider-events.ts +462 -0
- package/src/stateful/session-key.ts +111 -0
- package/src/stateful/stateful-provider-adapter-context.ts +59 -0
- package/src/stateful/stateful-provider-adapter-metrics.ts +48 -0
- package/src/stateful/stateful-provider-adapter.ts +562 -0
- package/src/stateful/stateful-provider-observability.ts +261 -0
- package/src/stateful/stateful-provider-owner-forwarder.ts +287 -0
- package/src/stateful/stateful-provider-runtime-context.ts +92 -0
- package/src/stateful/stateful-provider-runtime-executor.ts +96 -0
- package/src/stateful/stateful-provider-session-routing.ts +546 -0
- package/src/stateful/stateful-provider-session-runtime.ts +403 -0
- package/src/stateful-signing.ts +46 -0
- package/src/stealth/profiles.ts +17 -7
- package/src/stream-evidence.ts +988 -0
- package/src/stream.ts +8 -1
- package/src/testing/index.ts +10 -1
- package/src/testing/run.ts +658 -15
- package/src/trace-sanitization.ts +63 -0
- package/src/types.ts +660 -38
- package/dist/cli/templates/provider/CLAUDE.md.tpl +0 -1
- package/src/cli/templates/provider/CLAUDE.md.tpl +0 -1
- /package/dist/cli/templates/provider/{skills → .agents/skills}/fixtures-and-recording/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/health-checks-and-fail-closed/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/normalization-standards/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/pagination-and-counts/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/upstream-contract-verification/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/upstream-notes/README.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/fixtures-and-recording/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/health-checks-and-fail-closed/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/normalization-standards/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/pagination-and-counts/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/upstream-contract-verification/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/upstream-notes/README.md.tpl +0 -0
|
@@ -54,15 +54,11 @@ function isZodSchema(schema) {
|
|
|
54
54
|
return schema instanceof z.ZodType;
|
|
55
55
|
}
|
|
56
56
|
function zodJsonSchema(schema) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
if (error instanceof Error)
|
|
63
|
-
return undefined;
|
|
64
|
-
throw error;
|
|
57
|
+
const jsonSchema = toJsonValue(z.toJSONSchema(schema));
|
|
58
|
+
if (jsonSchema === undefined) {
|
|
59
|
+
throw new TypeError("z.toJSONSchema() returned a non-JSON value");
|
|
65
60
|
}
|
|
61
|
+
return jsonSchema;
|
|
66
62
|
}
|
|
67
63
|
function getSchemaTypeName(schema) {
|
|
68
64
|
if (!isRecord(schema))
|
package/dist/contract-types.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export interface ProviderContractSnapshot {
|
|
|
11
11
|
readonly allowedHosts?: readonly string[];
|
|
12
12
|
readonly stealth?: JsonValue;
|
|
13
13
|
readonly proxy?: JsonValue;
|
|
14
|
+
readonly ocr?: JsonValue;
|
|
14
15
|
readonly stt?: JsonValue;
|
|
15
16
|
readonly browser?: JsonValue;
|
|
16
17
|
readonly auth?: JsonValue;
|
package/dist/contract.js
CHANGED
|
@@ -7,6 +7,7 @@ export function extractProviderContract(provider) {
|
|
|
7
7
|
const auth = extractAuth(provider.auth);
|
|
8
8
|
const stealth = toJsonValue(provider.stealth);
|
|
9
9
|
const proxy = toJsonValue(provider.proxy);
|
|
10
|
+
const ocr = toJsonValue(provider.ocr);
|
|
10
11
|
const stt = toJsonValue(provider.stt);
|
|
11
12
|
const browser = toJsonValue(provider.browser);
|
|
12
13
|
const reviewed = toJsonValue(provider.reviewed);
|
|
@@ -30,6 +31,7 @@ export function extractProviderContract(provider) {
|
|
|
30
31
|
...(provider.allowedHosts ? { allowedHosts: [...provider.allowedHosts].sort() } : {}),
|
|
31
32
|
...(stealth === undefined ? {} : { stealth }),
|
|
32
33
|
...(proxy === undefined ? {} : { proxy }),
|
|
34
|
+
...(ocr === undefined ? {} : { ocr }),
|
|
33
35
|
...(stt === undefined ? {} : { stt }),
|
|
34
36
|
...(browser === undefined ? {} : { browser }),
|
|
35
37
|
...(auth === undefined ? {} : { auth }),
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ProviderError } from "./errors.js";
|
|
2
|
+
import type { ProviderDefinition } from "./types.js";
|
|
3
|
+
export declare const DECLARATION_INVALID_CODE = "DECLARATION_INVALID";
|
|
4
|
+
export declare const DECLARATION_RULE_IDS: {
|
|
5
|
+
readonly challengeShape: "credentials-challenge-shape";
|
|
6
|
+
readonly journeyExecutable: "health-journey-executable";
|
|
7
|
+
readonly journeyRunScenarioExclusive: "health-journey-run-scenario-exclusive";
|
|
8
|
+
readonly journeyScenarioValid: "health-journey-scenario-valid";
|
|
9
|
+
readonly schemaSerializable: "operation-schema-serializable";
|
|
10
|
+
readonly proxyExplicitPolicy: "proxy-explicit-policy";
|
|
11
|
+
readonly proxyVendorExclusive: "proxy-vendor-fields-exclusive";
|
|
12
|
+
readonly proxyNoMixedVendors: "proxy-no-mixed-vendors";
|
|
13
|
+
readonly proxySmartproxyGeo: "proxy-smartproxy-country-only";
|
|
14
|
+
readonly operationUpstreamProxy: "operation-upstream-proxy-unsupported";
|
|
15
|
+
};
|
|
16
|
+
export type DeclarationRuleId = (typeof DECLARATION_RULE_IDS)[keyof typeof DECLARATION_RULE_IDS];
|
|
17
|
+
export type DeclarationViolation = {
|
|
18
|
+
ruleId: DeclarationRuleId;
|
|
19
|
+
path: string;
|
|
20
|
+
message: string;
|
|
21
|
+
fix: string;
|
|
22
|
+
};
|
|
23
|
+
export declare function declarationInvalidError(violations: readonly DeclarationViolation[]): ProviderError;
|
|
24
|
+
/** Enforces declaration rules whose runtime behavior would otherwise fail open. */
|
|
25
|
+
export declare function validateFailClosedDeclaration(provider: ProviderDefinition): void;
|
|
26
|
+
type ProviderDeclarationRulesInput = Pick<ProviderDefinition, "healthJourneys" | "proxy">;
|
|
27
|
+
type OperationDeclarationRulesInput = Pick<ProviderDefinition, "operations">;
|
|
28
|
+
/** Enforces fail-closed rules that only depend on the provider declaration. */
|
|
29
|
+
export declare function validateFailClosedProviderDeclaration(provider: ProviderDeclarationRulesInput): void;
|
|
30
|
+
/** Enforces fail-closed rules that depend on the operation implementation. */
|
|
31
|
+
export declare function validateFailClosedOperationDeclaration(provider: OperationDeclarationRulesInput): void;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { describeSchema } from "./contract-serialization.js";
|
|
2
|
+
import { ProviderError } from "./errors.js";
|
|
3
|
+
import { HealthScenarioSchema } from "./health-scenario.js";
|
|
4
|
+
export const DECLARATION_INVALID_CODE = "DECLARATION_INVALID";
|
|
5
|
+
export const DECLARATION_RULE_IDS = {
|
|
6
|
+
challengeShape: "credentials-challenge-shape",
|
|
7
|
+
journeyExecutable: "health-journey-executable",
|
|
8
|
+
journeyRunScenarioExclusive: "health-journey-run-scenario-exclusive",
|
|
9
|
+
journeyScenarioValid: "health-journey-scenario-valid",
|
|
10
|
+
schemaSerializable: "operation-schema-serializable",
|
|
11
|
+
proxyExplicitPolicy: "proxy-explicit-policy",
|
|
12
|
+
proxyVendorExclusive: "proxy-vendor-fields-exclusive",
|
|
13
|
+
proxyNoMixedVendors: "proxy-no-mixed-vendors",
|
|
14
|
+
proxySmartproxyGeo: "proxy-smartproxy-country-only",
|
|
15
|
+
operationUpstreamProxy: "operation-upstream-proxy-unsupported",
|
|
16
|
+
};
|
|
17
|
+
export function declarationInvalidError(violations) {
|
|
18
|
+
const summary = violations
|
|
19
|
+
.map((violation) => `${violation.path} [${violation.ruleId}]: ${violation.message}`)
|
|
20
|
+
.join("\n");
|
|
21
|
+
return new ProviderError(`Provider declaration is invalid (${violations.length} violation${violations.length === 1 ? "" : "s"}).${summary ? `\n${summary}` : ""}`, {
|
|
22
|
+
code: DECLARATION_INVALID_CODE,
|
|
23
|
+
details: { violations: [...violations] },
|
|
24
|
+
fix: "Apply every violation's fix hint, then validate the declaration again.",
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/** Enforces declaration rules whose runtime behavior would otherwise fail open. */
|
|
28
|
+
export function validateFailClosedDeclaration(provider) {
|
|
29
|
+
const violations = [];
|
|
30
|
+
validateHealthDeclaration(provider, violations);
|
|
31
|
+
validateSchemaDeclaration(provider, violations);
|
|
32
|
+
validateProxyDeclaration(provider, violations);
|
|
33
|
+
validateOperationDeclaration(provider, violations);
|
|
34
|
+
if (violations.length > 0)
|
|
35
|
+
throw declarationInvalidError(violations);
|
|
36
|
+
}
|
|
37
|
+
/** Enforces fail-closed rules that only depend on the provider declaration. */
|
|
38
|
+
export function validateFailClosedProviderDeclaration(provider) {
|
|
39
|
+
const violations = [];
|
|
40
|
+
collectProviderDeclarationViolations(provider, violations);
|
|
41
|
+
if (violations.length > 0)
|
|
42
|
+
throw declarationInvalidError(violations);
|
|
43
|
+
}
|
|
44
|
+
/** Enforces fail-closed rules that depend on the operation implementation. */
|
|
45
|
+
export function validateFailClosedOperationDeclaration(provider) {
|
|
46
|
+
const violations = [];
|
|
47
|
+
collectOperationDeclarationViolations(provider, violations);
|
|
48
|
+
if (violations.length > 0)
|
|
49
|
+
throw declarationInvalidError(violations);
|
|
50
|
+
}
|
|
51
|
+
function collectProviderDeclarationViolations(provider, violations) {
|
|
52
|
+
validateHealthDeclaration(provider, violations);
|
|
53
|
+
validateProxyDeclaration(provider, violations);
|
|
54
|
+
}
|
|
55
|
+
function collectOperationDeclarationViolations(provider, violations) {
|
|
56
|
+
validateSchemaDeclaration(provider, violations);
|
|
57
|
+
validateOperationDeclaration(provider, violations);
|
|
58
|
+
}
|
|
59
|
+
function validateHealthDeclaration(provider, violations) {
|
|
60
|
+
for (const [index, journey] of (provider.healthJourneys ?? []).entries()) {
|
|
61
|
+
if (!journey || typeof journey !== "object")
|
|
62
|
+
continue;
|
|
63
|
+
const hasRun = journey.run !== undefined;
|
|
64
|
+
const hasScenario = journey.scenario !== undefined;
|
|
65
|
+
if (hasRun && hasScenario) {
|
|
66
|
+
const journeyPath = healthJourneyPath(journey, index);
|
|
67
|
+
violations.push({
|
|
68
|
+
ruleId: DECLARATION_RULE_IDS.journeyRunScenarioExclusive,
|
|
69
|
+
path: journeyPath,
|
|
70
|
+
message: "A health journey must declare exactly one of run or scenario, not both.",
|
|
71
|
+
fix: `Remove either ${journeyPath}.run or ${journeyPath}.scenario.`,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
if (!hasRun && !hasScenario) {
|
|
75
|
+
const journeyPath = healthJourneyPath(journey, index);
|
|
76
|
+
violations.push({
|
|
77
|
+
ruleId: DECLARATION_RULE_IDS.journeyExecutable,
|
|
78
|
+
path: `${journeyPath}.run`,
|
|
79
|
+
message: "coversOperations cannot provide health coverage without run or a declarative scenario.",
|
|
80
|
+
fix: `Add an async run(ctx) implementation or a valid scenario to ${journeyPath}.`,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
if (hasScenario) {
|
|
84
|
+
const parsed = HealthScenarioSchema.safeParse(journey.scenario);
|
|
85
|
+
if (!parsed.success) {
|
|
86
|
+
const journeyPath = healthJourneyPath(journey, index);
|
|
87
|
+
violations.push({
|
|
88
|
+
ruleId: DECLARATION_RULE_IDS.journeyScenarioValid,
|
|
89
|
+
path: `${journeyPath}.scenario`,
|
|
90
|
+
message: "scenario must conform to HealthScenario.",
|
|
91
|
+
fix: "Build the scenario with defineHealthScenario().",
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// NOTE: healthCheck.cases[].enabled is intentionally NOT validated here.
|
|
97
|
+
// self-test.ts reports a gated case as status "skipped" with skipReason
|
|
98
|
+
// "disabled", so the skip is visible in results rather than silent — it is a
|
|
99
|
+
// supported conditional-execution feature, not a class-1 silent no-op.
|
|
100
|
+
}
|
|
101
|
+
function healthJourneyPath(journey, index) {
|
|
102
|
+
return typeof journey.id === "string" && journey.id.length > 0
|
|
103
|
+
? `healthJourneys.${journey.id}`
|
|
104
|
+
: `healthJourneys[${index}]`;
|
|
105
|
+
}
|
|
106
|
+
function validateSchemaDeclaration(provider, violations) {
|
|
107
|
+
for (const [operationId, operation] of Object.entries(provider.operations ?? {})) {
|
|
108
|
+
const schemaEntries = [
|
|
109
|
+
[`operations.${operationId}.input`, operation.input],
|
|
110
|
+
[`operations.${operationId}.output`, operation.output],
|
|
111
|
+
];
|
|
112
|
+
// SSE event schemas reach contract extraction the same way input/output do,
|
|
113
|
+
// so a transform-bearing event schema would abort extraction at runtime while
|
|
114
|
+
// passing declaration checks. Validate them under the same rule.
|
|
115
|
+
const transport = operation.transport;
|
|
116
|
+
if (transport?.kind === "sse") {
|
|
117
|
+
for (const [eventName, eventSchema] of Object.entries(transport.events ?? {})) {
|
|
118
|
+
schemaEntries.push([
|
|
119
|
+
`operations.${operationId}.transport.events.${eventName}`,
|
|
120
|
+
eventSchema,
|
|
121
|
+
]);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
for (const [path, schema] of schemaEntries) {
|
|
125
|
+
try {
|
|
126
|
+
describeSchema(schema);
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
130
|
+
violations.push({
|
|
131
|
+
ruleId: DECLARATION_RULE_IDS.schemaSerializable,
|
|
132
|
+
path,
|
|
133
|
+
message: `schema conversion to JSON Schema failed: ${reason}`,
|
|
134
|
+
fix: `Replace unsupported constructs in ${path} so z.toJSONSchema() succeeds.`,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const MANAGED_PROXY_VENDORS = new Set(["smartproxy", "nodemaven"]);
|
|
141
|
+
const STATIC_PROXY_VENDORS = new Set(["custom", "decodo"]);
|
|
142
|
+
function validateProxyDeclaration(provider, violations) {
|
|
143
|
+
if (provider.proxy === true) {
|
|
144
|
+
violations.push({
|
|
145
|
+
ruleId: DECLARATION_RULE_IDS.proxyExplicitPolicy,
|
|
146
|
+
path: "proxy",
|
|
147
|
+
message: "proxy: true does not require resolvable proxy egress.",
|
|
148
|
+
fix: 'Replace proxy: true with an explicit policy such as proxy: { mode: "required", providers: ["smartproxy"] }.',
|
|
149
|
+
});
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (!provider.proxy || typeof provider.proxy !== "object")
|
|
153
|
+
return;
|
|
154
|
+
const policy = provider.proxy;
|
|
155
|
+
const hasProvider = policy.provider !== undefined;
|
|
156
|
+
const hasProviders = policy.providers !== undefined;
|
|
157
|
+
if (hasProvider && hasProviders) {
|
|
158
|
+
violations.push({
|
|
159
|
+
ruleId: DECLARATION_RULE_IDS.proxyVendorExclusive,
|
|
160
|
+
path: "proxy",
|
|
161
|
+
message: "provider and providers are ambiguous when declared together.",
|
|
162
|
+
fix: "Keep either proxy.provider or proxy.providers, and remove the other field.",
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
const vendors = declaredProxyVendors(policy);
|
|
166
|
+
if (vendors.some((vendor) => MANAGED_PROXY_VENDORS.has(vendor)) &&
|
|
167
|
+
vendors.some((vendor) => STATIC_PROXY_VENDORS.has(vendor))) {
|
|
168
|
+
violations.push({
|
|
169
|
+
ruleId: DECLARATION_RULE_IDS.proxyNoMixedVendors,
|
|
170
|
+
path: hasProviders ? "proxy.providers" : "proxy.provider",
|
|
171
|
+
message: "managed and deprecated static proxy vendors cannot share a chain.",
|
|
172
|
+
fix: "Use only smartproxy/nodemaven vendors, or only deprecated static markers, in one policy.",
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
if (vendors.includes("smartproxy")) {
|
|
176
|
+
for (const field of ["subdivision", "city"]) {
|
|
177
|
+
if (policy.geo?.[field] === undefined)
|
|
178
|
+
continue;
|
|
179
|
+
const path = `proxy.geo.${field}`;
|
|
180
|
+
violations.push({
|
|
181
|
+
ruleId: DECLARATION_RULE_IDS.proxySmartproxyGeo,
|
|
182
|
+
path,
|
|
183
|
+
message: `smartproxy cannot honor ${field}-level geo targeting.`,
|
|
184
|
+
fix: `Remove ${path} or use a vendor chain that can honor it.`,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
function declaredProxyVendors(policy) {
|
|
190
|
+
const vendors = [...(policy.providers ?? [])];
|
|
191
|
+
if (policy.provider !== undefined)
|
|
192
|
+
vendors.push(policy.provider);
|
|
193
|
+
return vendors;
|
|
194
|
+
}
|
|
195
|
+
function validateOperationDeclaration(provider, violations) {
|
|
196
|
+
for (const [operationId, operation] of Object.entries(provider.operations ?? {})) {
|
|
197
|
+
if (!operation.upstream?.proxy)
|
|
198
|
+
continue;
|
|
199
|
+
const path = `operations.${operationId}.upstream.proxy`;
|
|
200
|
+
violations.push({
|
|
201
|
+
ruleId: DECLARATION_RULE_IDS.operationUpstreamProxy,
|
|
202
|
+
path,
|
|
203
|
+
message: "operation-level proxy policy is not wired into operation execution.",
|
|
204
|
+
fix: `Remove ${path} and declare the effective policy at provider.proxy.`,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
package/dist/define.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AuthConfig, BrowserEngine, ContextDeclaration, CredentialDeclaration, HealthJourneyDefinition, HealthJourneySchedule, HealthScheduleRandomization, InferSchemaOutput, OperationDefinition, OperationHandlerResult, OperationHttpStreamTransport, OperationSseTransport, OperationWebSocketTransport, ProviderAccessConfig, ProviderDefinition, ProviderDeploymentOverrides, ProviderHealthMonitorConfig, ProviderProxyConfig, ProviderPublicProfile, ProviderReviewed, ProviderSecretDeclaration, ProviderStreamEvent, ProviderSttConfig, SchemaLike, SmsOtpMatcherDefinition, StealthPlatform } from "./types.js";
|
|
1
|
+
import type { AuthConfig, BrowserEngine, ContextDeclaration, CredentialDeclaration, HealthJourneyDefinition, HealthJourneySchedule, HealthScheduleRandomization, InferSchemaOutput, NativeProviderConfig, OperationDefinition, OperationHandlerResult, OperationHttpStreamTransport, OperationSseTransport, OperationWebSocketTransport, ProviderAccessConfig, ProviderContext, ProviderContextFor, ProviderDefinition, ProviderDeploymentOverrides, ProviderHealthMonitorConfig, ProviderOcrConfig, ProviderProxyConfig, ProviderPublicProfile, ProviderResolverConfig, ProviderReviewed, ProviderSecretDeclaration, ProviderStreamEvent, ProviderSttConfig, SchemaLike, SmsOtpMatcherDefinition, StealthPlatform } from "./types.js";
|
|
2
2
|
type ProviderImplementationSourceAccess = "official_api" | "private_api" | "browser_flow" | "hybrid";
|
|
3
3
|
type ProviderImplementationCredentialStrategy = "apifuse_managed" | "workspace_secret" | "user_oauth" | "user_session" | "none";
|
|
4
4
|
interface ProviderImplementationProfile {
|
|
@@ -8,36 +8,41 @@ interface ProviderImplementationProfile {
|
|
|
8
8
|
operatorNotes?: string;
|
|
9
9
|
visibility: "internal" | "operator";
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
export declare const VALID_PROVIDER_RESOLVER_VENDORS: readonly ["browser", "capsolver", "capmonster", "2captcha", "custom"];
|
|
12
|
+
export declare const VALID_PROVIDER_CHALLENGE_KINDS: readonly ["turnstile", "recaptcha_v2", "recaptcha_v3", "hcaptcha", "cloudflare_interstitial", "aws_waf", "akamai_sec_cpt", "akamai_sensor"];
|
|
13
|
+
type ProviderOperation = OperationDefinition<any, any, any>;
|
|
14
|
+
type OperationConfig<TInput extends SchemaLike, TOutput extends SchemaLike, TContext = ProviderContext> = Omit<OperationDefinition<TInput, TOutput, TContext>, "handler"> & {
|
|
15
|
+
handler(ctx: TContext, input: InferSchemaOutput<TInput>): OperationHandlerResult<InferSchemaOutput<TOutput>> | Promise<OperationHandlerResult<InferSchemaOutput<TOutput>>>;
|
|
14
16
|
};
|
|
15
|
-
type OperationMapConfig<TOperations extends Record<string, ProviderOperation
|
|
16
|
-
[K in keyof TOperations]: TOperations[K] extends OperationDefinition<infer TInput, infer TOutput> ? OperationConfig<TInput, TOutput> | OperationDefinition<TInput, TOutput> : never;
|
|
17
|
+
type OperationMapConfig<TOperations extends Record<string, ProviderOperation>, TContext = ProviderContext> = {
|
|
18
|
+
[K in keyof TOperations]: TOperations[K] extends OperationDefinition<infer TInput, infer TOutput> ? OperationConfig<TInput, TOutput, TContext> | OperationDefinition<TInput, TOutput, TContext> : never;
|
|
17
19
|
};
|
|
18
|
-
type StreamOperationConfig<TInput extends SchemaLike, TOutput extends SchemaLike> = SseOperationConfig<TInput, TOutput> | HttpStreamOperationConfig<TInput, TOutput> | WebSocketOperationConfig<TInput, TOutput>;
|
|
19
|
-
type SseOperationConfig<TInput extends SchemaLike, TOutput extends SchemaLike> = Omit<OperationConfig<TInput, TOutput>, "handler" | "transport"> & {
|
|
20
|
+
type StreamOperationConfig<TInput extends SchemaLike, TOutput extends SchemaLike, TContext = ProviderContext> = SseOperationConfig<TInput, TOutput, TContext> | HttpStreamOperationConfig<TInput, TOutput, TContext> | WebSocketOperationConfig<TInput, TOutput, TContext>;
|
|
21
|
+
type SseOperationConfig<TInput extends SchemaLike, TOutput extends SchemaLike, TContext = ProviderContext> = Omit<OperationConfig<TInput, TOutput, TContext>, "handler" | "transport"> & {
|
|
20
22
|
transport: OperationSseTransport;
|
|
21
|
-
handler(ctx:
|
|
23
|
+
handler(ctx: TContext, input: InferSchemaOutput<TInput>): AsyncIterable<ProviderStreamEvent> | Promise<AsyncIterable<ProviderStreamEvent>>;
|
|
22
24
|
};
|
|
23
|
-
type HttpStreamOperationConfig<TInput extends SchemaLike, TOutput extends SchemaLike> = Omit<OperationConfig<TInput, TOutput>, "handler" | "transport"> & {
|
|
25
|
+
type HttpStreamOperationConfig<TInput extends SchemaLike, TOutput extends SchemaLike, TContext = ProviderContext> = Omit<OperationConfig<TInput, TOutput, TContext>, "handler" | "transport"> & {
|
|
24
26
|
transport: OperationHttpStreamTransport;
|
|
25
|
-
handler(ctx:
|
|
27
|
+
handler(ctx: TContext, input: InferSchemaOutput<TInput>): Response | ReadableStream<Uint8Array> | Promise<Response | ReadableStream<Uint8Array>>;
|
|
26
28
|
};
|
|
27
|
-
type WebSocketOperationConfig<TInput extends SchemaLike, TOutput extends SchemaLike> = Omit<OperationConfig<TInput, TOutput>, "handler" | "transport"> & {
|
|
29
|
+
type WebSocketOperationConfig<TInput extends SchemaLike, TOutput extends SchemaLike, TContext = ProviderContext> = Omit<OperationConfig<TInput, TOutput, TContext>, "handler" | "transport"> & {
|
|
28
30
|
transport: OperationWebSocketTransport;
|
|
29
|
-
handler(ctx:
|
|
31
|
+
handler(ctx: TContext, input: InferSchemaOutput<TInput>): Response | ReadableStream<Uint8Array> | Promise<Response | ReadableStream<Uint8Array>>;
|
|
30
32
|
};
|
|
31
|
-
type
|
|
33
|
+
type AuthStartHandlerNoInputGuard<TStart> = TStart extends (...args: infer TArgs) => unknown ? TArgs["length"] extends 0 | 1 ? unknown : {
|
|
34
|
+
"auth start handlers must not declare input parameters; return a form turn from start and receive user input in continue": never;
|
|
35
|
+
} : unknown;
|
|
36
|
+
export type AuthStartNoInputGuard<TConfig> = TConfig extends {
|
|
32
37
|
auth?: {
|
|
33
38
|
flow?: {
|
|
34
39
|
start: infer TStart;
|
|
35
40
|
};
|
|
36
41
|
};
|
|
37
|
-
} ? TStart
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
export interface
|
|
42
|
+
} ? AuthStartHandlerNoInputGuard<TStart> : TConfig extends {
|
|
43
|
+
start: infer TStart;
|
|
44
|
+
} ? AuthStartHandlerNoInputGuard<TStart> : unknown;
|
|
45
|
+
export interface ProviderDeclaration {
|
|
41
46
|
id: string;
|
|
42
47
|
version: string;
|
|
43
48
|
runtime: "standard" | "shared" | "browser";
|
|
@@ -48,22 +53,37 @@ export interface ProviderConfig<TOperations extends Record<string, ProviderOpera
|
|
|
48
53
|
* resolves omitted fields against the runtime deployment profiles.
|
|
49
54
|
*/
|
|
50
55
|
deployment?: ProviderDeploymentOverrides;
|
|
56
|
+
/** Declares that provider operations use the SDK HTTP client. */
|
|
57
|
+
http?: true;
|
|
51
58
|
allowedHosts?: string[];
|
|
59
|
+
native?: NativeProviderConfig;
|
|
52
60
|
stealth?: {
|
|
53
61
|
profile: string;
|
|
54
62
|
platform: StealthPlatform;
|
|
55
63
|
};
|
|
56
64
|
proxy?: ProviderProxyConfig;
|
|
65
|
+
ocr?: ProviderOcrConfig;
|
|
57
66
|
stt?: ProviderSttConfig;
|
|
67
|
+
resolver?: ProviderResolverConfig;
|
|
58
68
|
browser?: {
|
|
59
69
|
engine: BrowserEngine;
|
|
60
70
|
};
|
|
61
71
|
auth?: AuthConfig;
|
|
72
|
+
/** Declares that provider operations issue and consume SDK choice tokens. */
|
|
73
|
+
choice?: true;
|
|
62
74
|
reviewed?: ProviderReviewed;
|
|
63
75
|
access?: ProviderAccessConfig;
|
|
64
76
|
secrets?: ProviderSecretDeclaration[];
|
|
77
|
+
/** Declares that provider operations read SDK-managed environment values. */
|
|
78
|
+
env?: true;
|
|
65
79
|
credential?: CredentialDeclaration;
|
|
66
80
|
context?: ContextDeclaration;
|
|
81
|
+
/** Declares that provider operations use SDK-managed persistent state. */
|
|
82
|
+
state?: true;
|
|
83
|
+
/** Declares that provider operations use the SDK provider cache. */
|
|
84
|
+
cache?: true;
|
|
85
|
+
/** Declares that provider operations access runtime-resolvable files. */
|
|
86
|
+
files?: true;
|
|
67
87
|
meta: {
|
|
68
88
|
displayName: string;
|
|
69
89
|
displayNameKey?: string;
|
|
@@ -85,16 +105,15 @@ export interface ProviderConfig<TOperations extends Record<string, ProviderOpera
|
|
|
85
105
|
publicSchemaFieldNames?: "normalized";
|
|
86
106
|
};
|
|
87
107
|
};
|
|
88
|
-
operations: OperationMapConfig<TOperations>;
|
|
89
108
|
healthMonitor?: ProviderHealthMonitorConfig;
|
|
90
109
|
/** New name for `healthMonitor` (transitional alias); declaring both is a ValidationError. */
|
|
91
110
|
healthProbe?: ProviderHealthMonitorConfig;
|
|
92
111
|
healthJourneys?: readonly HealthJourneyDefinition[];
|
|
93
112
|
}
|
|
94
|
-
/** Define one provider operation with schema-driven handler inference. */
|
|
95
|
-
export declare function defineOperation<TInput extends SchemaLike, TOutput extends SchemaLike>(
|
|
96
|
-
/** Define a non-JSON
|
|
97
|
-
export declare function defineStreamOperation<TInput extends SchemaLike, TOutput extends SchemaLike>(
|
|
113
|
+
/** Define one factored provider operation with schema-driven handler inference. */
|
|
114
|
+
export declare function defineOperation<TContext>(): <TInput extends SchemaLike, TOutput extends SchemaLike>(config: OperationConfig<TInput, TOutput, TContext>) => OperationDefinition<TInput, TOutput, TContext>;
|
|
115
|
+
/** Define a factored non-JSON operation with explicit transport metadata. */
|
|
116
|
+
export declare function defineStreamOperation<TContext>(): <TInput extends SchemaLike, TOutput extends SchemaLike>(config: StreamOperationConfig<TInput, TOutput, TContext>) => OperationDefinition<TInput, TOutput, TContext>;
|
|
98
117
|
export declare function every(interval: string, options?: {
|
|
99
118
|
jitter?: string;
|
|
100
119
|
randomize?: HealthScheduleRandomization;
|
|
@@ -103,7 +122,14 @@ export declare function centered(maxOffset: string): HealthScheduleRandomization
|
|
|
103
122
|
export declare function delayed(maxDelay: string): HealthScheduleRandomization;
|
|
104
123
|
export declare function defineSmsOtpMatcher(config: Omit<SmsOtpMatcherDefinition, "extractOtp">): SmsOtpMatcherDefinition;
|
|
105
124
|
export declare function defineHealthJourney(config: HealthJourneyDefinition): HealthJourneyDefinition;
|
|
106
|
-
|
|
107
|
-
|
|
125
|
+
/** The second authoring phase for a declaration established by defineProvider. */
|
|
126
|
+
export type ProviderBuilder<TDeclaration extends ProviderDeclaration> = <TOperations extends Record<string, ProviderOperation>>(implementation: {
|
|
127
|
+
operations: OperationMapConfig<TOperations, ProviderContextFor<TDeclaration>>;
|
|
128
|
+
}) => Omit<ProviderDefinition, "operations"> & {
|
|
129
|
+
operations: OperationMapConfig<TOperations, ProviderContextFor<TDeclaration>>;
|
|
108
130
|
};
|
|
131
|
+
/** Extract the declaration-derived operation context from a provider builder. */
|
|
132
|
+
export type ProviderContextOf<TBuilder> = TBuilder extends ProviderBuilder<infer TDeclaration> ? ProviderContextFor<TDeclaration> : never;
|
|
133
|
+
/** Establish a provider declaration before its operations are contextually typed. */
|
|
134
|
+
export declare function defineProvider<const TDeclaration extends ProviderDeclaration>(declaration: TDeclaration & Record<Exclude<keyof TDeclaration, keyof ProviderDeclaration>, never> & AuthStartNoInputGuard<TDeclaration>): ProviderBuilder<TDeclaration>;
|
|
109
135
|
export {};
|