@apifuse/provider-sdk 2.2.0-beta.3 → 2.2.0-beta.5
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 +53 -0
- package/CHANGELOG.md +8 -0
- package/bin/apifuse-check.ts +18 -58
- package/bin/apifuse-create.ts +1 -1
- package/bin/apifuse-dev.ts +27 -52
- package/bin/apifuse-pack-smoke.ts +22 -81
- package/bin/apifuse-pack-types.ts +266 -0
- package/bin/apifuse-perf.ts +45 -127
- package/bin/apifuse-record.ts +23 -61
- package/bin/apifuse-submit-check.ts +266 -34
- package/bin/apifuse.ts +1 -1
- package/bin/submit-check-xml.ts +1 -1
- package/dist/auth-turn/index.d.ts +1 -1
- package/dist/auth.d.ts +2 -2
- package/dist/auth.js +9 -18
- package/dist/ceremonies/index.d.ts +1 -1
- package/dist/ceremonies/index.js +8 -18
- package/dist/config/loader.d.ts +2 -2
- package/dist/config/loader.js +19 -42
- package/dist/contract-serialization.d.ts +2 -2
- package/dist/contract-serialization.js +3 -6
- package/dist/contract-types.d.ts +2 -2
- package/dist/contract.d.ts +3 -3
- package/dist/contract.js +4 -6
- package/dist/define.d.ts +8 -1
- package/dist/define.js +57 -115
- package/dist/dev.d.ts +1 -1
- package/dist/dev.js +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +1 -3
- package/dist/i18n/catalog.d.ts +2 -2
- package/dist/i18n/catalog.js +4 -10
- package/dist/i18n/index.d.ts +2 -2
- package/dist/i18n/index.js +2 -2
- package/dist/i18n/keys.d.ts +2 -2
- package/dist/index.d.ts +43 -42
- package/dist/index.js +38 -37
- package/dist/lint.js +8 -15
- package/dist/provider.d.ts +11 -11
- package/dist/provider.js +9 -9
- package/dist/public-schema-field-lint.d.ts +1 -1
- package/dist/recipes/gov-api.js +1 -1
- package/dist/runtime/auth-flow.d.ts +1 -1
- package/dist/runtime/auth-flow.js +3 -3
- package/dist/runtime/browser.d.ts +1 -1
- package/dist/runtime/browser.js +15 -29
- package/dist/runtime/cache.d.ts +1 -1
- package/dist/runtime/cache.js +4 -8
- package/dist/runtime/choice.d.ts +1 -1
- package/dist/runtime/choice.js +12 -34
- package/dist/runtime/credential.d.ts +1 -1
- package/dist/runtime/credential.js +1 -1
- package/dist/runtime/env.d.ts +1 -1
- package/dist/runtime/executor.d.ts +1 -1
- package/dist/runtime/executor.js +2 -2
- package/dist/runtime/http.d.ts +2 -2
- package/dist/runtime/http.js +5 -5
- package/dist/runtime/insights.d.ts +1 -1
- package/dist/runtime/insights.js +6 -13
- package/dist/runtime/instrumentation.d.ts +2 -2
- package/dist/runtime/instrumentation.js +5 -15
- package/dist/runtime/keyring.js +1 -1
- package/dist/runtime/namespace.js +1 -1
- package/dist/runtime/otlp.d.ts +1 -1
- package/dist/runtime/perf.d.ts +1 -1
- package/dist/runtime/provider.d.ts +1 -1
- package/dist/runtime/provider.js +1 -2
- package/dist/runtime/proxy-errors.d.ts +1 -1
- package/dist/runtime/proxy-errors.js +3 -5
- package/dist/runtime/proxy-retry-policy.d.ts +2 -2
- package/dist/runtime/proxy-retry-policy.js +2 -2
- package/dist/runtime/proxy-telemetry.d.ts +1 -1
- package/dist/runtime/proxy-telemetry.js +16 -48
- package/dist/runtime/redis.d.ts +1 -1
- package/dist/runtime/redis.js +2 -4
- package/dist/runtime/request-options.d.ts +1 -1
- package/dist/runtime/state.d.ts +2 -2
- package/dist/runtime/state.js +3 -3
- package/dist/runtime/stealth.d.ts +2 -2
- package/dist/runtime/stealth.js +6 -6
- package/dist/runtime/stt.d.ts +1 -1
- package/dist/runtime/stt.js +11 -15
- package/dist/runtime/trace.d.ts +2 -2
- package/dist/runtime/trace.js +2 -4
- package/dist/runtime/waterfall.d.ts +1 -1
- package/dist/schema.d.ts +1 -1
- package/dist/schema.js +7 -15
- package/dist/serve.d.ts +1 -1
- package/dist/serve.js +1 -1
- package/dist/server/index.d.ts +7 -7
- package/dist/server/index.js +6 -6
- package/dist/server/self-test-redaction.d.ts +1 -1
- package/dist/server/self-test-redaction.js +1 -1
- package/dist/server/self-test.d.ts +104 -3
- package/dist/server/self-test.js +673 -115
- package/dist/server/serve.d.ts +3 -3
- package/dist/server/serve.js +37 -49
- package/dist/server/types.js +2 -7
- package/dist/stealth/profiles.d.ts +1 -1
- package/dist/stealth/profiles.js +5 -14
- package/dist/stream.d.ts +1 -1
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/index.js +2 -2
- package/dist/testing/run.d.ts +1 -1
- package/dist/testing/run.js +7 -14
- package/dist/types.d.ts +57 -0
- package/dist/user-input.d.ts +30 -0
- package/dist/user-input.js +66 -0
- package/package.json +6 -4
- package/src/auth-turn/index.ts +1 -1
- package/src/auth.ts +28 -86
- package/src/ceremonies/index.ts +24 -78
- package/src/config/loader.ts +58 -176
- package/src/contract-serialization.ts +5 -11
- package/src/contract-types.ts +2 -2
- package/src/contract.ts +12 -28
- package/src/define.ts +174 -495
- package/src/dev.ts +4 -9
- package/src/errors.ts +4 -11
- package/src/i18n/catalog.ts +10 -32
- package/src/i18n/index.ts +2 -2
- package/src/i18n/keys.ts +5 -11
- package/src/index.ts +44 -42
- package/src/lint.ts +89 -159
- package/src/provider.ts +12 -11
- package/src/public-schema-field-lint.ts +7 -33
- package/src/recipes/gov-api.ts +2 -5
- package/src/runtime/auth-flow.ts +5 -7
- package/src/runtime/browser.ts +64 -187
- package/src/runtime/cache.ts +20 -67
- package/src/runtime/choice.ts +55 -129
- package/src/runtime/credential.ts +2 -2
- package/src/runtime/env.ts +1 -1
- package/src/runtime/executor.ts +9 -19
- package/src/runtime/http.ts +7 -7
- package/src/runtime/insights.ts +15 -53
- package/src/runtime/instrumentation.ts +19 -58
- package/src/runtime/keyring.ts +7 -19
- package/src/runtime/namespace.ts +2 -7
- package/src/runtime/otlp.ts +12 -23
- package/src/runtime/perf.ts +1 -1
- package/src/runtime/provider.ts +4 -9
- package/src/runtime/proxy-errors.ts +17 -38
- package/src/runtime/proxy-retry-policy.ts +3 -3
- package/src/runtime/proxy-telemetry.ts +23 -72
- package/src/runtime/redis.ts +4 -12
- package/src/runtime/request-options.ts +4 -13
- package/src/runtime/state.ts +30 -109
- package/src/runtime/stealth.ts +8 -8
- package/src/runtime/stt.ts +38 -94
- package/src/runtime/trace.ts +14 -44
- package/src/runtime/waterfall.ts +5 -18
- package/src/schema.ts +23 -84
- package/src/serve.ts +1 -1
- package/src/server/index.ts +12 -7
- package/src/server/self-test-redaction.ts +2 -2
- package/src/server/self-test.ts +857 -132
- package/src/server/serve.ts +89 -238
- package/src/server/types.ts +6 -19
- package/src/stealth/profiles.ts +10 -26
- package/src/stream.ts +8 -19
- package/src/testing/index.ts +2 -2
- package/src/testing/run.ts +19 -67
- package/src/types.ts +58 -0
- package/src/user-input.ts +118 -0
package/dist/define.js
CHANGED
|
@@ -1,27 +1,14 @@
|
|
|
1
1
|
import ms from "ms";
|
|
2
|
-
import { ProviderError, ValidationError } from "./errors";
|
|
3
|
-
import { safeParseSchemaSync } from "./schema";
|
|
4
|
-
import { HEALTH_CHECK_DEGRADED_THRESHOLD_MS_MAX, HEALTH_CHECK_DEGRADED_THRESHOLD_MS_MIN, HEALTH_CHECK_TIMEOUT_MS_MAX, HEALTH_CHECK_TIMEOUT_MS_MIN, OPERATION_TIMEOUT_MS_MAX, OPERATION_TIMEOUT_MS_MIN, STREAM_CHUNK_BYTES_MAX, STREAM_CHUNK_BYTES_MIN, STREAM_HEARTBEAT_MS_MAX, STREAM_HEARTBEAT_MS_MIN, STREAM_IDLE_TIMEOUT_MS_MAX, STREAM_IDLE_TIMEOUT_MS_MIN, STREAM_MAX_DURATION_MS_MAX, STREAM_MAX_DURATION_MS_MIN, } from "./types";
|
|
2
|
+
import { ProviderError, ValidationError } from "./errors.js";
|
|
3
|
+
import { safeParseSchemaSync } from "./schema.js";
|
|
4
|
+
import { HEALTH_CHECK_DEGRADED_THRESHOLD_MS_MAX, HEALTH_CHECK_DEGRADED_THRESHOLD_MS_MIN, HEALTH_CHECK_TIMEOUT_MS_MAX, HEALTH_CHECK_TIMEOUT_MS_MIN, OPERATION_TIMEOUT_MS_MAX, OPERATION_TIMEOUT_MS_MIN, STREAM_CHUNK_BYTES_MAX, STREAM_CHUNK_BYTES_MIN, STREAM_HEARTBEAT_MS_MAX, STREAM_HEARTBEAT_MS_MIN, STREAM_IDLE_TIMEOUT_MS_MAX, STREAM_IDLE_TIMEOUT_MS_MIN, STREAM_MAX_DURATION_MS_MAX, STREAM_MAX_DURATION_MS_MIN, } from "./types.js";
|
|
5
5
|
const CONNECTOR_ID_REGEX = /^[a-z][a-z0-9]*(-[a-z][a-z0-9]*)*$/;
|
|
6
6
|
const OPERATION_ID_REGEX = /^[a-z][a-z0-9]*(?:[-_][a-z0-9]+)*$/;
|
|
7
7
|
const VALID_RUNTIMES = ["standard", "shared", "browser"];
|
|
8
|
-
const VALID_AUTH_MODES = [
|
|
9
|
-
"none",
|
|
10
|
-
"platform-managed",
|
|
11
|
-
"credentials",
|
|
12
|
-
"oauth2",
|
|
13
|
-
];
|
|
8
|
+
const VALID_AUTH_MODES = ["none", "platform-managed", "credentials", "oauth2"];
|
|
14
9
|
const VALID_PROVIDER_ACCESS_VISIBILITIES = ["public", "early_access"];
|
|
15
|
-
const VALID_PROVIDER_PROXY_MODES = [
|
|
16
|
-
|
|
17
|
-
"optional",
|
|
18
|
-
"required",
|
|
19
|
-
];
|
|
20
|
-
const VALID_PROVIDER_PROXY_PROVIDERS = [
|
|
21
|
-
"smartproxy",
|
|
22
|
-
"decodo",
|
|
23
|
-
"custom",
|
|
24
|
-
];
|
|
10
|
+
const VALID_PROVIDER_PROXY_MODES = ["disabled", "optional", "required"];
|
|
11
|
+
const VALID_PROVIDER_PROXY_PROVIDERS = ["smartproxy", "decodo", "custom"];
|
|
25
12
|
const VALID_PROVIDER_PROXY_AFFINITIES = [
|
|
26
13
|
"request",
|
|
27
14
|
"operation",
|
|
@@ -32,23 +19,9 @@ const VALID_PROVIDER_STT_MODES = ["optional", "required"];
|
|
|
32
19
|
const SMARTPROXY_APP_KEY_SECRET = "APIFUSE__PROXY__SMARTPROXY_APP_KEY";
|
|
33
20
|
const RESERVED_OPERATION_IDS = new Set(["auth", "health"]);
|
|
34
21
|
const MCP_TOOL_NAME_REGEX = /^[A-Za-z][A-Za-z0-9_]{0,127}$/;
|
|
35
|
-
const VALID_OPERATION_RISK_CLASSES = [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"destructive",
|
|
39
|
-
"external-send",
|
|
40
|
-
];
|
|
41
|
-
const VALID_OPERATION_APPROVAL_POLICIES = [
|
|
42
|
-
"never",
|
|
43
|
-
"risk-based",
|
|
44
|
-
"always",
|
|
45
|
-
];
|
|
46
|
-
const VALID_OPERATION_TRANSPORT_KINDS = [
|
|
47
|
-
"json",
|
|
48
|
-
"sse",
|
|
49
|
-
"http-stream",
|
|
50
|
-
"websocket",
|
|
51
|
-
];
|
|
22
|
+
const VALID_OPERATION_RISK_CLASSES = ["read", "write", "destructive", "external-send"];
|
|
23
|
+
const VALID_OPERATION_APPROVAL_POLICIES = ["never", "risk-based", "always"];
|
|
24
|
+
const VALID_OPERATION_TRANSPORT_KINDS = ["json", "sse", "http-stream", "websocket"];
|
|
52
25
|
const SSE_EVENT_NAME_REGEX = /^[A-Za-z][A-Za-z0-9_.-]{0,127}$/;
|
|
53
26
|
const WEBSOCKET_SUBPROTOCOL_REGEX = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
54
27
|
const MS_DURATION_PATTERN = /^([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*([a-zA-Z]+)?$/;
|
|
@@ -109,10 +82,7 @@ function validateProviderShape(config) {
|
|
|
109
82
|
if (typeof config.runtime === "string")
|
|
110
83
|
assertLiteralField(config.runtime, "runtime", VALID_RUNTIMES, String(config.id));
|
|
111
84
|
const auth = config.auth;
|
|
112
|
-
if (auth &&
|
|
113
|
-
typeof auth === "object" &&
|
|
114
|
-
"mode" in auth &&
|
|
115
|
-
typeof auth.mode === "string")
|
|
85
|
+
if (auth && typeof auth === "object" && "mode" in auth && typeof auth.mode === "string")
|
|
116
86
|
assertLiteralField(auth.mode, "auth.mode", VALID_AUTH_MODES, String(config.id));
|
|
117
87
|
if (auth && typeof auth === "object" && "exchange" in auth) {
|
|
118
88
|
throw new ProviderError(`Provider "${String(config.id)}" auth.exchange is not part of the Provider SDK auth contract`, {
|
|
@@ -173,9 +143,7 @@ function validateProviderProxy(config) {
|
|
|
173
143
|
assertLiteralField(proxy.provider, "proxy.provider", VALID_PROVIDER_PROXY_PROVIDERS, config.id);
|
|
174
144
|
}
|
|
175
145
|
if (proxy.geo !== undefined) {
|
|
176
|
-
if (!proxy.geo ||
|
|
177
|
-
typeof proxy.geo !== "object" ||
|
|
178
|
-
Array.isArray(proxy.geo)) {
|
|
146
|
+
if (!proxy.geo || typeof proxy.geo !== "object" || Array.isArray(proxy.geo)) {
|
|
179
147
|
throw new ValidationError(`Provider "${config.id}" has invalid proxy.geo: must be an object.`, {
|
|
180
148
|
fix: `Use proxy.geo: { country: "KR" } with ISO alpha-2 country codes.`,
|
|
181
149
|
});
|
|
@@ -192,9 +160,7 @@ function validateProviderProxy(config) {
|
|
|
192
160
|
}
|
|
193
161
|
}
|
|
194
162
|
if (proxy.session !== undefined) {
|
|
195
|
-
if (!proxy.session ||
|
|
196
|
-
typeof proxy.session !== "object" ||
|
|
197
|
-
Array.isArray(proxy.session)) {
|
|
163
|
+
if (!proxy.session || typeof proxy.session !== "object" || Array.isArray(proxy.session)) {
|
|
198
164
|
throw new ValidationError(`Provider "${config.id}" has invalid proxy.session: must be an object.`, {
|
|
199
165
|
fix: `Use proxy.session: { affinity: "connection", lifetimeMinutes: 30 }.`,
|
|
200
166
|
});
|
|
@@ -204,13 +170,11 @@ function validateProviderProxy(config) {
|
|
|
204
170
|
assertLiteralField(proxy.session.affinity, "proxy.session.affinity", VALID_PROVIDER_PROXY_AFFINITIES, config.id);
|
|
205
171
|
}
|
|
206
172
|
const lifetime = proxy.session.lifetimeMinutes;
|
|
207
|
-
if (lifetime !== undefined &&
|
|
208
|
-
(!Number.isFinite(lifetime) || lifetime <= 0)) {
|
|
173
|
+
if (lifetime !== undefined && (!Number.isFinite(lifetime) || lifetime <= 0)) {
|
|
209
174
|
throw new ValidationError(`Provider "${config.id}" has invalid proxy.session.lifetimeMinutes: must be a positive number of minutes.`);
|
|
210
175
|
}
|
|
211
176
|
const poolSize = proxy.session.poolSize;
|
|
212
|
-
if (poolSize !== undefined &&
|
|
213
|
-
(!Number.isInteger(poolSize) || poolSize <= 0)) {
|
|
177
|
+
if (poolSize !== undefined && (!Number.isInteger(poolSize) || poolSize <= 0)) {
|
|
214
178
|
throw new ValidationError(`Provider "${config.id}" has invalid proxy.session.poolSize: must be a positive integer.`);
|
|
215
179
|
}
|
|
216
180
|
}
|
|
@@ -228,7 +192,9 @@ function validateProviderStt(config) {
|
|
|
228
192
|
if (stt === undefined)
|
|
229
193
|
return;
|
|
230
194
|
if (!stt || typeof stt !== "object" || Array.isArray(stt)) {
|
|
231
|
-
throw new ValidationError(`Provider "${config.id}" has invalid stt: must be an object.`, {
|
|
195
|
+
throw new ValidationError(`Provider "${config.id}" has invalid stt: must be an object.`, {
|
|
196
|
+
fix: `Use stt: { mode: "required" } or stt: { mode: "optional" }.`,
|
|
197
|
+
});
|
|
232
198
|
}
|
|
233
199
|
rejectUnknownFields(stt, new Set(["mode"]), "stt");
|
|
234
200
|
assertLiteralField(stt.mode, "stt.mode", VALID_PROVIDER_STT_MODES, config.id);
|
|
@@ -247,12 +213,7 @@ function validateOperationIds(providerId, operations) {
|
|
|
247
213
|
}
|
|
248
214
|
const OPERATION_CONTRACT_VERSION_REGEX = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
|
|
249
215
|
const OPERATION_SENSITIVE_PATH_REGEX = /^(?:[A-Za-z0-9_$-]+|\*)(?:\.(?:[A-Za-z0-9_$-]+|\*))*$/;
|
|
250
|
-
const VALID_OPERATION_LIFECYCLES = [
|
|
251
|
-
"stable",
|
|
252
|
-
"beta",
|
|
253
|
-
"deprecated",
|
|
254
|
-
"removed",
|
|
255
|
-
];
|
|
216
|
+
const VALID_OPERATION_LIFECYCLES = ["stable", "beta", "deprecated", "removed"];
|
|
256
217
|
function assertNonEmptyString(value, field, providerId, operationName) {
|
|
257
218
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
258
219
|
throw new ValidationError(`Provider "${providerId}" operation "${operationName}" has invalid ${field}: must be a non-empty string.`, { fix: `Set ${field} to a non-empty customer-facing value.` });
|
|
@@ -268,8 +229,7 @@ function validateToolRouterMetadata(providerId, operations) {
|
|
|
268
229
|
fix: `Remove operations.${operationName}.toolRouter or provide MCP-safe metadata.`,
|
|
269
230
|
});
|
|
270
231
|
}
|
|
271
|
-
if (toolRouter.name !== undefined &&
|
|
272
|
-
!MCP_TOOL_NAME_REGEX.test(toolRouter.name)) {
|
|
232
|
+
if (toolRouter.name !== undefined && !MCP_TOOL_NAME_REGEX.test(toolRouter.name)) {
|
|
273
233
|
throw new ValidationError(`Provider "${providerId}" operation "${operationName}" has invalid operations.${operationName}.toolRouter.name: expected an MCP-safe name.`, {
|
|
274
234
|
fix: `Use letters, numbers, and underscores only, starting with a letter, for example "${providerId.replace(/[^A-Za-z0-9]+/g, "_")}__${operationName.replace(/[^A-Za-z0-9]+/g, "_")}".`,
|
|
275
235
|
});
|
|
@@ -307,8 +267,7 @@ function validateOperationContracts(providerId, operations) {
|
|
|
307
267
|
if (contract.lifecycle !== undefined) {
|
|
308
268
|
assertLiteralField(contract.lifecycle, `operations.${operationName}.contract.lifecycle`, VALID_OPERATION_LIFECYCLES, providerId);
|
|
309
269
|
}
|
|
310
|
-
if (contract.lifecycle === "deprecated" ||
|
|
311
|
-
contract.lifecycle === "removed") {
|
|
270
|
+
if (contract.lifecycle === "deprecated" || contract.lifecycle === "removed") {
|
|
312
271
|
if (!contract.deprecation || typeof contract.deprecation !== "object") {
|
|
313
272
|
throw new ValidationError(`Provider "${providerId}" operation "${operationName}" is ${contract.lifecycle} but lacks operations.${operationName}.contract.deprecation metadata.`, {
|
|
314
273
|
fix: `Add announcedAt, removalAfter, and migrationGuide to operations.${operationName}.contract.deprecation.`,
|
|
@@ -333,8 +292,7 @@ function validateOperationAnnotations(providerId, operations) {
|
|
|
333
292
|
throw new ValidationError(`Provider "${providerId}" has invalid ${field}: must be an integer number of milliseconds.`, {
|
|
334
293
|
fix: `Set ${field} to an integer in [${OPERATION_TIMEOUT_MS_MIN}, ${OPERATION_TIMEOUT_MS_MAX}] (milliseconds).`,
|
|
335
294
|
});
|
|
336
|
-
if (timeoutMs < OPERATION_TIMEOUT_MS_MIN ||
|
|
337
|
-
timeoutMs > OPERATION_TIMEOUT_MS_MAX)
|
|
295
|
+
if (timeoutMs < OPERATION_TIMEOUT_MS_MIN || timeoutMs > OPERATION_TIMEOUT_MS_MAX)
|
|
338
296
|
throw new ValidationError(`Provider "${providerId}" has invalid ${field}: ${timeoutMs} is outside [${OPERATION_TIMEOUT_MS_MIN}, ${OPERATION_TIMEOUT_MS_MAX}] ms.`, {
|
|
339
297
|
fix: `Set ${field} to an integer in [${OPERATION_TIMEOUT_MS_MIN}, ${OPERATION_TIMEOUT_MS_MAX}] ms (the upper bound stays below the gateway/ALB ceiling).`,
|
|
340
298
|
});
|
|
@@ -478,9 +436,7 @@ function validateOperationTransports(providerId, operations) {
|
|
|
478
436
|
assertStreamMs(maxDurationMs, `${fieldPath}.maxDurationMs`, STREAM_MAX_DURATION_MS_MIN, STREAM_MAX_DURATION_MS_MAX, "max duration");
|
|
479
437
|
assertPositiveBytes(Reflect.get(transport, "maxEventBytes"), `${fieldPath}.maxEventBytes`);
|
|
480
438
|
const resumable = Reflect.get(transport, "resumable");
|
|
481
|
-
if (resumable !== undefined &&
|
|
482
|
-
resumable !== false &&
|
|
483
|
-
resumable !== "last-event-id") {
|
|
439
|
+
if (resumable !== undefined && resumable !== false && resumable !== "last-event-id") {
|
|
484
440
|
throw new ValidationError(`Provider "${providerId}" operation "${operationName}" has invalid ${fieldPath}.resumable: expected false or "last-event-id".`, {
|
|
485
441
|
fix: `Use ${fieldPath}.resumable: "last-event-id" for SSE Last-Event-ID resume support, or false to disable resume.`,
|
|
486
442
|
});
|
|
@@ -515,8 +471,7 @@ function validateOperationTransports(providerId, operations) {
|
|
|
515
471
|
});
|
|
516
472
|
}
|
|
517
473
|
for (const subprotocol of subprotocols) {
|
|
518
|
-
if (typeof subprotocol !== "string" ||
|
|
519
|
-
!WEBSOCKET_SUBPROTOCOL_REGEX.test(subprotocol)) {
|
|
474
|
+
if (typeof subprotocol !== "string" || !WEBSOCKET_SUBPROTOCOL_REGEX.test(subprotocol)) {
|
|
520
475
|
throw new ValidationError(`Provider "${providerId}" operation "${operationName}" has invalid ${fieldPath}.subprotocols: each subprotocol must be an RFC token string.`, {
|
|
521
476
|
fix: `Use values such as "apifuse.v1" without spaces or separators that are invalid for Sec-WebSocket-Protocol.`,
|
|
522
477
|
});
|
|
@@ -624,9 +579,7 @@ function assertBoundedIntegerMs(value, fieldPath, options) {
|
|
|
624
579
|
function validateProviderHealthMonitor(providerId, healthMonitor, field = "healthMonitor") {
|
|
625
580
|
if (healthMonitor === undefined)
|
|
626
581
|
return;
|
|
627
|
-
if (!healthMonitor ||
|
|
628
|
-
typeof healthMonitor !== "object" ||
|
|
629
|
-
Array.isArray(healthMonitor))
|
|
582
|
+
if (!healthMonitor || typeof healthMonitor !== "object" || Array.isArray(healthMonitor))
|
|
630
583
|
throw new ValidationError(`Provider "${providerId}" has invalid ${field}: must be an object.`, {
|
|
631
584
|
fix: `Set ${field} to { requiredSecrets?: string[]; serviceAccount?: string }`,
|
|
632
585
|
});
|
|
@@ -676,9 +629,7 @@ function validateProviderHealthMonitor(providerId, healthMonitor, field = "healt
|
|
|
676
629
|
}
|
|
677
630
|
const probeOverrides = healthMonitorRecord.probeOverrides;
|
|
678
631
|
if (probeOverrides !== undefined) {
|
|
679
|
-
if (!probeOverrides ||
|
|
680
|
-
typeof probeOverrides !== "object" ||
|
|
681
|
-
Array.isArray(probeOverrides))
|
|
632
|
+
if (!probeOverrides || typeof probeOverrides !== "object" || Array.isArray(probeOverrides))
|
|
682
633
|
throw new ValidationError(`Provider "${providerId}" has invalid ${field}.probeOverrides: must be an object keyed by probe id.`);
|
|
683
634
|
for (const [probeId, override] of Object.entries(probeOverrides)) {
|
|
684
635
|
if (probeId.length === 0)
|
|
@@ -756,9 +707,7 @@ function validateHealthCheckSuite(providerId, operationName, suite) {
|
|
|
756
707
|
fix: `Set ${fieldPath}.interval to a positive ms-style duration string.`,
|
|
757
708
|
});
|
|
758
709
|
if (s.schedule !== undefined) {
|
|
759
|
-
if (!s.schedule ||
|
|
760
|
-
typeof s.schedule !== "object" ||
|
|
761
|
-
Array.isArray(s.schedule)) {
|
|
710
|
+
if (!s.schedule || typeof s.schedule !== "object" || Array.isArray(s.schedule)) {
|
|
762
711
|
throw new ValidationError(`Provider "${providerId}" ${fieldPath}.schedule must be an object.`);
|
|
763
712
|
}
|
|
764
713
|
if (Reflect.get(s.schedule, "jitter") !== undefined) {
|
|
@@ -784,8 +733,7 @@ function validateHealthCheckSuite(providerId, operationName, suite) {
|
|
|
784
733
|
label: "degraded threshold",
|
|
785
734
|
});
|
|
786
735
|
}
|
|
787
|
-
if (s.requiresConnection !== undefined &&
|
|
788
|
-
typeof s.requiresConnection !== "boolean")
|
|
736
|
+
if (s.requiresConnection !== undefined && typeof s.requiresConnection !== "boolean")
|
|
789
737
|
throw new ValidationError(`Provider "${providerId}" ${fieldPath}.requiresConnection must be a boolean.`);
|
|
790
738
|
if (!Array.isArray(s.cases) || s.cases.length === 0)
|
|
791
739
|
throw new ValidationError(`Provider "${providerId}" ${fieldPath}.cases must be a non-empty array.`, {
|
|
@@ -804,9 +752,7 @@ function validateHealthCheckSuite(providerId, operationName, suite) {
|
|
|
804
752
|
}
|
|
805
753
|
function validateHealthCheckUnsupported(providerId, operationName, unsupported) {
|
|
806
754
|
const fieldPath = `operations.${operationName}.healthCheckUnsupported`;
|
|
807
|
-
if (!unsupported ||
|
|
808
|
-
typeof unsupported !== "object" ||
|
|
809
|
-
Array.isArray(unsupported))
|
|
755
|
+
if (!unsupported || typeof unsupported !== "object" || Array.isArray(unsupported))
|
|
810
756
|
throw new ValidationError(`Provider "${providerId}" ${fieldPath} must be an object.`);
|
|
811
757
|
rejectUnknownFields(unsupported, HEALTH_CHECK_UNSUPPORTED_FIELDS, fieldPath);
|
|
812
758
|
const u = unsupported;
|
|
@@ -831,12 +777,7 @@ const HEALTH_JOURNEY_FIELDS = new Set([
|
|
|
831
777
|
"steps",
|
|
832
778
|
"run",
|
|
833
779
|
]);
|
|
834
|
-
const HEALTH_JOURNEY_SCHEDULE_FIELDS = new Set([
|
|
835
|
-
"kind",
|
|
836
|
-
"interval",
|
|
837
|
-
"jitter",
|
|
838
|
-
"randomize",
|
|
839
|
-
]);
|
|
780
|
+
const HEALTH_JOURNEY_SCHEDULE_FIELDS = new Set(["kind", "interval", "jitter", "randomize"]);
|
|
840
781
|
const HEALTH_JOURNEY_STEP_FIELDS = new Set([
|
|
841
782
|
"id",
|
|
842
783
|
"description",
|
|
@@ -854,10 +795,7 @@ const HEALTH_JOURNEY_MANUAL_TRIGGER_FIELDS = new Set([
|
|
|
854
795
|
"minManualInterval",
|
|
855
796
|
"publicRationale",
|
|
856
797
|
]);
|
|
857
|
-
const HEALTH_JOURNEY_MANUAL_TRIGGER_DISABLED_FIELDS = new Set([
|
|
858
|
-
"enabled",
|
|
859
|
-
"reason",
|
|
860
|
-
]);
|
|
798
|
+
const HEALTH_JOURNEY_MANUAL_TRIGGER_DISABLED_FIELDS = new Set(["enabled", "reason"]);
|
|
861
799
|
const HEALTH_JOURNEY_MANUAL_TRIGGER_ENABLED_FIELDS = new Set([
|
|
862
800
|
"enabled",
|
|
863
801
|
"requiresAcknowledgement",
|
|
@@ -872,9 +810,7 @@ const HEALTH_JOURNEY_MANUAL_TRIGGER_RISKS = new Set([
|
|
|
872
810
|
]);
|
|
873
811
|
function validateHealthJourneyManualTrigger(providerId, journeyId, manualTrigger) {
|
|
874
812
|
const fieldPath = `healthJourneys.${journeyId}.manualTrigger`;
|
|
875
|
-
if (!manualTrigger ||
|
|
876
|
-
typeof manualTrigger !== "object" ||
|
|
877
|
-
Array.isArray(manualTrigger)) {
|
|
813
|
+
if (!manualTrigger || typeof manualTrigger !== "object" || Array.isArray(manualTrigger)) {
|
|
878
814
|
throw new ValidationError(`Provider "${providerId}" ${fieldPath} must be an object when present.`);
|
|
879
815
|
}
|
|
880
816
|
rejectUnknownFields(manualTrigger, HEALTH_JOURNEY_MANUAL_TRIGGER_FIELDS, fieldPath);
|
|
@@ -897,8 +833,7 @@ function validateHealthJourneyManualTrigger(providerId, journeyId, manualTrigger
|
|
|
897
833
|
throw new ValidationError(`Provider "${providerId}" ${fieldPath}.requiresAcknowledgement must be a boolean.`);
|
|
898
834
|
}
|
|
899
835
|
const risk = Reflect.get(manualTrigger, "risk");
|
|
900
|
-
if (typeof risk !== "string" ||
|
|
901
|
-
!HEALTH_JOURNEY_MANUAL_TRIGGER_RISKS.has(risk)) {
|
|
836
|
+
if (typeof risk !== "string" || !HEALTH_JOURNEY_MANUAL_TRIGGER_RISKS.has(risk)) {
|
|
902
837
|
throw new ValidationError(`Provider "${providerId}" ${fieldPath}.risk must be one of read_only, writes_external_state, or sms_or_payment.`);
|
|
903
838
|
}
|
|
904
839
|
if (risk !== "read_only" && requiresAcknowledgement !== true) {
|
|
@@ -950,7 +885,7 @@ function isoDurationMs(value) {
|
|
|
950
885
|
const hours = Number(/(\d+)H/.exec(value)?.[1] ?? 0);
|
|
951
886
|
const minutes = Number(/(\d+)M/.exec(value)?.[1] ?? 0);
|
|
952
887
|
const seconds = Number(/(\d+(?:\.\d+)?)S/.exec(value)?.[1] ?? 0);
|
|
953
|
-
return
|
|
888
|
+
return days * 86_400_000 + hours * 3_600_000 + minutes * 60_000 + seconds * 1_000;
|
|
954
889
|
}
|
|
955
890
|
function scheduleRandomizationMs(randomize, fieldPath) {
|
|
956
891
|
const mode = Reflect.get(randomize, "mode");
|
|
@@ -974,9 +909,7 @@ function validateScheduleRandomization(randomize, fieldPath, intervalMs) {
|
|
|
974
909
|
throw new ValidationError(`${fieldPath} must be an object.`);
|
|
975
910
|
}
|
|
976
911
|
const mode = Reflect.get(randomize, "mode");
|
|
977
|
-
const allowedFields = mode === "centered"
|
|
978
|
-
? new Set(["mode", "maxOffset"])
|
|
979
|
-
: new Set(["mode", "maxDelay"]);
|
|
912
|
+
const allowedFields = mode === "centered" ? new Set(["mode", "maxOffset"]) : new Set(["mode", "maxDelay"]);
|
|
980
913
|
rejectUnknownFields(randomize, allowedFields, fieldPath);
|
|
981
914
|
const offsetMs = scheduleRandomizationMs(randomize, fieldPath);
|
|
982
915
|
if (offsetMs <= 0) {
|
|
@@ -1062,9 +995,7 @@ function countCapturingGroups(pattern) {
|
|
|
1062
995
|
const next = source[i + 1];
|
|
1063
996
|
if (next === "?" && source[i + 2] !== "<")
|
|
1064
997
|
continue;
|
|
1065
|
-
if (next === "?" &&
|
|
1066
|
-
source[i + 2] === "<" &&
|
|
1067
|
-
(source[i + 3] === "=" || source[i + 3] === "!"))
|
|
998
|
+
if (next === "?" && source[i + 2] === "<" && (source[i + 3] === "=" || source[i + 3] === "!"))
|
|
1068
999
|
continue;
|
|
1069
1000
|
count += 1;
|
|
1070
1001
|
}
|
|
@@ -1142,8 +1073,7 @@ function validateSmsOtpMatcher(matcher, fieldPath) {
|
|
|
1142
1073
|
throw new ValidationError(`${fieldPath}.code.pattern must be a RegExp or pattern source string.`);
|
|
1143
1074
|
}
|
|
1144
1075
|
const regex = pattern instanceof RegExp ? pattern : new RegExp(pattern);
|
|
1145
|
-
if (countCapturingGroups(regex) !== 1 &&
|
|
1146
|
-
Reflect.get(code, "capture") === undefined) {
|
|
1076
|
+
if (countCapturingGroups(regex) !== 1 && Reflect.get(code, "capture") === undefined) {
|
|
1147
1077
|
throw new ValidationError(`${fieldPath}.code.pattern must contain exactly one OTP capture or declare code.capture.`);
|
|
1148
1078
|
}
|
|
1149
1079
|
if (Reflect.get(code, "capture") !== undefined &&
|
|
@@ -1195,8 +1125,7 @@ function validateHealthJourneySchedule(providerId, journeyId, schedule) {
|
|
|
1195
1125
|
const interval = Reflect.get(schedule, "interval");
|
|
1196
1126
|
assertIsoDuration(interval, `Provider "${providerId}" ${fieldPath}.interval`);
|
|
1197
1127
|
const randomize = Reflect.get(schedule, "randomize");
|
|
1198
|
-
if (Reflect.get(schedule, "jitter") !== undefined &&
|
|
1199
|
-
randomize !== undefined) {
|
|
1128
|
+
if (Reflect.get(schedule, "jitter") !== undefined && randomize !== undefined) {
|
|
1200
1129
|
throw new ValidationError(`Provider "${providerId}" ${fieldPath} cannot define both jitter and randomize.`);
|
|
1201
1130
|
}
|
|
1202
1131
|
if (Reflect.get(schedule, "jitter") !== undefined)
|
|
@@ -1226,8 +1155,7 @@ function validateHealthJourneys(providerId, operations, healthJourneys) {
|
|
|
1226
1155
|
throw new ValidationError(`Provider "${providerId}" has duplicate health journey id "${journey.id}".`);
|
|
1227
1156
|
journeyIds.add(journey.id);
|
|
1228
1157
|
validateHealthJourneySchedule(providerId, journey.id, journey.schedule);
|
|
1229
|
-
if (!Array.isArray(journey.coversOperations) ||
|
|
1230
|
-
journey.coversOperations.length === 0) {
|
|
1158
|
+
if (!Array.isArray(journey.coversOperations) || journey.coversOperations.length === 0) {
|
|
1231
1159
|
throw new ValidationError(`Provider "${providerId}" healthJourneys.${journey.id}.coversOperations must be a non-empty array.`);
|
|
1232
1160
|
}
|
|
1233
1161
|
for (const operationId of journey.coversOperations) {
|
|
@@ -1265,8 +1193,7 @@ function validateHealthJourneys(providerId, operations, healthJourneys) {
|
|
|
1265
1193
|
throw new ValidationError(`Provider "${providerId}" ${stepPath}.id must be a kebab-case identifier.`);
|
|
1266
1194
|
if (step.operationId !== undefined && !operations[step.operationId])
|
|
1267
1195
|
throw new ValidationError(`Provider "${providerId}" ${stepPath}.operationId references unknown operation "${step.operationId}".`);
|
|
1268
|
-
if (step.usesSmsMatcher !== undefined &&
|
|
1269
|
-
!matcherIds.has(step.usesSmsMatcher))
|
|
1196
|
+
if (step.usesSmsMatcher !== undefined && !matcherIds.has(step.usesSmsMatcher))
|
|
1270
1197
|
throw new ValidationError(`Provider "${providerId}" ${stepPath}.usesSmsMatcher references unknown matcher "${step.usesSmsMatcher}".`);
|
|
1271
1198
|
}
|
|
1272
1199
|
if (journey.manualTrigger !== undefined)
|
|
@@ -1300,9 +1227,7 @@ function validateOperationHealthChecks(providerId, operations, journeyCoveredOpe
|
|
|
1300
1227
|
validateHealthCheckSuite(providerId, operationName, operation.healthCheck);
|
|
1301
1228
|
if (hasUnsupported)
|
|
1302
1229
|
validateHealthCheckUnsupported(providerId, operationName, operation.healthCheckUnsupported);
|
|
1303
|
-
if (!hasCheck &&
|
|
1304
|
-
!hasUnsupported &&
|
|
1305
|
-
!journeyCoveredOperations.has(operationName))
|
|
1230
|
+
if (!hasCheck && !hasUnsupported && !journeyCoveredOperations.has(operationName))
|
|
1306
1231
|
throw new ValidationError(`Provider "${providerId}" operation "${operationName}" declares neither healthCheck nor healthCheckUnsupported.`, {
|
|
1307
1232
|
fix: `Add \`healthCheck: { interval, cases: [...] }\` or \`healthCheckUnsupported: { reason: "..." }\` to operations.${operationName}.`,
|
|
1308
1233
|
});
|
|
@@ -1332,6 +1257,19 @@ function validateOperationFixtures(providerId, operations) {
|
|
|
1332
1257
|
}
|
|
1333
1258
|
}
|
|
1334
1259
|
}
|
|
1260
|
+
/**
|
|
1261
|
+
* Shallow shape guard only: the `deployment` object is passed through
|
|
1262
|
+
* verbatim and deliberately not deep-validated by the SDK — the APIFuse
|
|
1263
|
+
* registry builder owns deployment validation and profile resolution.
|
|
1264
|
+
*/
|
|
1265
|
+
function validateProviderDeployment(providerId, deployment) {
|
|
1266
|
+
if (deployment === undefined)
|
|
1267
|
+
return;
|
|
1268
|
+
if (!deployment || typeof deployment !== "object" || Array.isArray(deployment))
|
|
1269
|
+
throw new ProviderError(`Provider "${providerId}" deployment must be an object when present`, {
|
|
1270
|
+
fix: 'Pass deployment: { runtime: "shared" | "dedicated" | "browser", ... } or remove the field',
|
|
1271
|
+
});
|
|
1272
|
+
}
|
|
1335
1273
|
export function defineProvider(config) {
|
|
1336
1274
|
validateProviderShape(config);
|
|
1337
1275
|
if (!CONNECTOR_ID_REGEX.test(config.id))
|
|
@@ -1356,6 +1294,7 @@ export function defineProvider(config) {
|
|
|
1356
1294
|
});
|
|
1357
1295
|
validateProviderHealthMonitor(config.id, config.healthProbe ?? config.healthMonitor, config.healthProbe !== undefined ? "healthProbe" : "healthMonitor");
|
|
1358
1296
|
validateOperationFixtures(config.id, config.operations);
|
|
1297
|
+
validateProviderDeployment(config.id, config.deployment);
|
|
1359
1298
|
validateProviderProxy(config);
|
|
1360
1299
|
validateProviderStt(config);
|
|
1361
1300
|
if (config.runtime === "browser" && !config.browser)
|
|
@@ -1368,6 +1307,9 @@ export function defineProvider(config) {
|
|
|
1368
1307
|
id: config.id,
|
|
1369
1308
|
version: config.version,
|
|
1370
1309
|
runtime: config.runtime,
|
|
1310
|
+
// Verbatim passthrough: deployment validation and profile resolution
|
|
1311
|
+
// are owned by the APIFuse registry builder, not the SDK.
|
|
1312
|
+
deployment: config.deployment,
|
|
1371
1313
|
allowedHosts: config.allowedHosts,
|
|
1372
1314
|
stealth: config.stealth,
|
|
1373
1315
|
proxy: config.proxy,
|
package/dist/dev.d.ts
CHANGED
package/dist/dev.js
CHANGED
package/dist/errors.d.ts
CHANGED
package/dist/errors.js
CHANGED
|
@@ -28,9 +28,7 @@ function hasOwnBrand(value, brand, expected) {
|
|
|
28
28
|
return false;
|
|
29
29
|
}
|
|
30
30
|
const descriptor = Object.getOwnPropertyDescriptor(value, brand);
|
|
31
|
-
return (descriptor !== undefined &&
|
|
32
|
-
Object.hasOwn(descriptor, "value") &&
|
|
33
|
-
descriptor.value === expected);
|
|
31
|
+
return (descriptor !== undefined && Object.hasOwn(descriptor, "value") && descriptor.value === expected);
|
|
34
32
|
}
|
|
35
33
|
export class ProviderError extends Error {
|
|
36
34
|
options;
|
package/dist/i18n/catalog.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AuthTurn } from "../types";
|
|
2
|
-
import { type ProviderLocale, type ProviderLocaleCatalog, type ProviderLocaleKey, type ProviderLocaleValue } from "./keys";
|
|
1
|
+
import type { AuthTurn } from "../types.js";
|
|
2
|
+
import { type ProviderLocale, type ProviderLocaleCatalog, type ProviderLocaleKey, type ProviderLocaleValue } from "./keys.js";
|
|
3
3
|
export type ProviderLocaleCatalogMap = Record<ProviderLocale, ProviderLocaleCatalog>;
|
|
4
4
|
export interface LoadProviderLocaleCatalogsOptions {
|
|
5
5
|
providerDir: string;
|
package/dist/i18n/catalog.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import { getProviderLocalePath, isProviderLocaleValue, providerLocaleKey, } from "./keys";
|
|
3
|
+
import { getProviderLocalePath, isProviderLocaleValue, providerLocaleKey, } from "./keys.js";
|
|
4
4
|
export function loadProviderLocaleCatalogs(options) {
|
|
5
5
|
const catalogs = {};
|
|
6
6
|
for (const locale of options.locales) {
|
|
@@ -26,9 +26,7 @@ function isStringRecord(value) {
|
|
|
26
26
|
function localizeAuthInputSchema(expectedInput, options) {
|
|
27
27
|
if (!expectedInput)
|
|
28
28
|
return undefined;
|
|
29
|
-
const schema = isRecord(expectedInput.schema)
|
|
30
|
-
? expectedInput.schema
|
|
31
|
-
: expectedInput;
|
|
29
|
+
const schema = isRecord(expectedInput.schema) ? expectedInput.schema : expectedInput;
|
|
32
30
|
const localizedSchema = localizeAuthSchemaObject(schema, options);
|
|
33
31
|
if (localizedSchema === schema)
|
|
34
32
|
return undefined;
|
|
@@ -40,9 +38,7 @@ function isRecord(value) {
|
|
|
40
38
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
41
39
|
}
|
|
42
40
|
function localizeAuthSchemaObject(schema, options) {
|
|
43
|
-
const properties = isRecord(schema.properties)
|
|
44
|
-
? schema.properties
|
|
45
|
-
: undefined;
|
|
41
|
+
const properties = isRecord(schema.properties) ? schema.properties : undefined;
|
|
46
42
|
if (!properties)
|
|
47
43
|
return schema;
|
|
48
44
|
let changed = false;
|
|
@@ -50,9 +46,7 @@ function localizeAuthSchemaObject(schema, options) {
|
|
|
50
46
|
if (!isRecord(property))
|
|
51
47
|
return [fieldName, property];
|
|
52
48
|
const nameKey = typeof property.nameKey === "string" ? property.nameKey : undefined;
|
|
53
|
-
const descriptionKey = typeof property.descriptionKey === "string"
|
|
54
|
-
? property.descriptionKey
|
|
55
|
-
: undefined;
|
|
49
|
+
const descriptionKey = typeof property.descriptionKey === "string" ? property.descriptionKey : undefined;
|
|
56
50
|
const title = nameKey
|
|
57
51
|
? asStringValue(resolveProviderLocaleValue(options.catalogs, nameKey, options.locale, options.fallbackLocale))
|
|
58
52
|
: undefined;
|
package/dist/i18n/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./catalog";
|
|
2
|
-
export * from "./keys";
|
|
1
|
+
export * from "./catalog.js";
|
|
2
|
+
export * from "./keys.js";
|
package/dist/i18n/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./catalog";
|
|
2
|
-
export * from "./keys";
|
|
1
|
+
export * from "./catalog.js";
|
|
2
|
+
export * from "./keys.js";
|
package/dist/i18n/keys.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ProviderLocaleKey } from "../types";
|
|
2
|
-
export type { ProviderLocale, ProviderLocaleKey } from "../types";
|
|
1
|
+
import type { ProviderLocaleKey } from "../types.js";
|
|
2
|
+
export type { ProviderLocale, ProviderLocaleKey } from "../types.js";
|
|
3
3
|
export declare function providerLocaleKey(key: string): ProviderLocaleKey;
|
|
4
4
|
export declare function isProviderLocaleKey(value: unknown): value is ProviderLocaleKey;
|
|
5
5
|
export declare function assertProviderLocaleKey(value: unknown): asserts value is ProviderLocaleKey;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,42 +1,43 @@
|
|
|
1
|
-
export * from "./auth";
|
|
2
|
-
export * from "./ceremonies";
|
|
3
|
-
export * from "./choice-token";
|
|
4
|
-
export type { ApiFuseConfig, BrowserConfig, ProxyConfig, SessionConfig, } from "./config/loader";
|
|
5
|
-
export { defineConfig, loadApiFuseConfig } from "./config/loader";
|
|
6
|
-
export { canonicalJson, digestProviderContract, extractProviderContract, type JsonPrimitive, type JsonValue, PROVIDER_CONTRACT_SCHEMA_VERSION, type ProviderContractOperation, type ProviderContractSnapshot, } from "./contract";
|
|
7
|
-
export { centered, delayed, defineHealthJourney, defineOperation, defineProvider, defineSmsOtpMatcher, defineStreamOperation, every, type ProviderConfig, } from "./define";
|
|
8
|
-
export type { DevServerOptions } from "./dev";
|
|
9
|
-
export { createDevServer, startDevServer } from "./dev";
|
|
10
|
-
export * from "./errors";
|
|
11
|
-
export * from "./
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export * from "./recipes/
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
19
|
-
export {
|
|
20
|
-
export { type
|
|
21
|
-
export {
|
|
22
|
-
export {
|
|
23
|
-
export {
|
|
24
|
-
export
|
|
25
|
-
export {
|
|
26
|
-
export {
|
|
27
|
-
export { type
|
|
28
|
-
export {
|
|
29
|
-
export {
|
|
30
|
-
export {
|
|
31
|
-
export {
|
|
32
|
-
export {
|
|
33
|
-
export {
|
|
34
|
-
export {
|
|
35
|
-
export {
|
|
36
|
-
export
|
|
37
|
-
export
|
|
38
|
-
export {
|
|
39
|
-
export
|
|
40
|
-
export * from "./utils/
|
|
41
|
-
export * from "./utils/
|
|
42
|
-
export * from "./utils/
|
|
1
|
+
export * from "./auth.js";
|
|
2
|
+
export * from "./ceremonies/index.js";
|
|
3
|
+
export * from "./choice-token.js";
|
|
4
|
+
export type { ApiFuseConfig, BrowserConfig, ProxyConfig, SessionConfig, } from "./config/loader.js";
|
|
5
|
+
export { defineConfig, loadApiFuseConfig } from "./config/loader.js";
|
|
6
|
+
export { canonicalJson, digestProviderContract, extractProviderContract, type JsonPrimitive, type JsonValue, PROVIDER_CONTRACT_SCHEMA_VERSION, type ProviderContractOperation, type ProviderContractSnapshot, } from "./contract.js";
|
|
7
|
+
export { centered, delayed, defineHealthJourney, defineOperation, defineProvider, defineSmsOtpMatcher, defineStreamOperation, every, type ProviderConfig, } from "./define.js";
|
|
8
|
+
export type { DevServerOptions } from "./dev.js";
|
|
9
|
+
export { createDevServer, startDevServer } from "./dev.js";
|
|
10
|
+
export * from "./errors.js";
|
|
11
|
+
export * from "./user-input.js";
|
|
12
|
+
export * from "./i18n/index.js";
|
|
13
|
+
export { type LintDiagnostic, lintOperation, lintProvider, } from "./lint.js";
|
|
14
|
+
export * from "./recipes/gov-api.js";
|
|
15
|
+
export * from "./recipes/rest-api.js";
|
|
16
|
+
export { createFlowContext, createScratchpad } from "./runtime/auth-flow.js";
|
|
17
|
+
export type { BrowserClientOptions } from "./runtime/browser.js";
|
|
18
|
+
export { BrowserClient, createBrowserClient } from "./runtime/browser.js";
|
|
19
|
+
export { createBypassProviderCache, createProviderCache, type ProviderCacheOptions, resetProviderCacheForTests, } from "./runtime/cache.js";
|
|
20
|
+
export { type CreateProviderChoiceContextOptions, createProviderChoiceContext, createTestProviderChoiceContext, PROVIDER_RUNTIME_CHOICE_TOKEN_MASTER_SECRET_ENV, } from "./runtime/choice.js";
|
|
21
|
+
export { type CreateCredentialContextOptions, createCredentialContext, } from "./runtime/credential.js";
|
|
22
|
+
export { createEnvContext } from "./runtime/env.js";
|
|
23
|
+
export { executeOperation } from "./runtime/executor.js";
|
|
24
|
+
export { createHttpClient } from "./runtime/http.js";
|
|
25
|
+
export type { Insight, InsightSeverity } from "./runtime/insights.js";
|
|
26
|
+
export { generateInsights } from "./runtime/insights.js";
|
|
27
|
+
export { type InstrumentationOptions, type InstrumentedProviderContext, wrapWithInstrumentation, } from "./runtime/instrumentation.js";
|
|
28
|
+
export { type PrevalidateResult, prevalidate } from "./runtime/prevalidate.js";
|
|
29
|
+
export { getProviderBaseUrl } from "./runtime/provider.js";
|
|
30
|
+
export { createUnsupportedProviderRuntimeState, UnsupportedProviderStateError, } from "./runtime/state.js";
|
|
31
|
+
export { createStealthClient } from "./runtime/stealth.js";
|
|
32
|
+
export { APIFUSE__STT__BACKEND_ENV, APIFUSE__STT__CLOUDFLARE_API_TOKEN_ENV, APIFUSE__STT__MODEL_ENV, createSttClientFromEnv, createUnsupportedSttClient, extractVerificationCode, resolveSttPrompt, } from "./runtime/stt.js";
|
|
33
|
+
export { type CreateTraceContextOptions, createTraceContext, type Span, type TraceContext, } from "./runtime/trace.js";
|
|
34
|
+
export { APIFUSE_DESCRIPTION_KEY_META_KEY, APIFUSE_REDACTION_MARKER, APIFUSE_SENSITIVE_KIND_META_KEY, APIFUSE_SENSITIVE_META_KEY, collectSensitivePaths, describeKey, field, fields, isSensitiveSchema, redactPayload, type SensitiveFieldKind, type SensitiveFieldOptions, type SensitivePath, sensitive, z, } from "./schema.js";
|
|
35
|
+
export { createServerApp, type ServeOptions, serve } from "./server/index.js";
|
|
36
|
+
export { getStealthProfile, listStealthProfiles } from "./stealth/profiles.js";
|
|
37
|
+
export * from "./stream.js";
|
|
38
|
+
export type { ApiFuseResponse, AuthConfig, AuthContext, AuthFlowDefinition, AuthFlowInputHandler, AuthFlowStartHandler, AuthMode, AuthTurn, Bcp47Locale, BrowserEngine, BrowserOptions, BrowserResourceBody, BrowserResourceDecision, BrowserResourceMethod, BrowserResourcePolicy, BrowserResourceRequest, BrowserResourceRoute, ConnectionMode, ContextDeclaration, CookieJar, ContextScratchpad, CredentialContext, CredentialDeclaration, E164PhoneNumber, EnvContext, FlowContext, FlowContextStore, HealthCheckAssertionContext, HealthCheckCase, HealthCheckCaseResult, HealthCheckSuite, HealthCheckUnsupported, HealthJourneyDefinition, HealthJourneyEventContext, HealthJourneyGatewayContext, HealthJourneyJournalContext, HealthJourneyManualTriggerPolicy, HealthJourneyRunContext, HealthJourneyRunResult, HealthJourneySchedule, HealthScheduleRandomization, HealthJourneySmsContext, HealthJourneyStep, HttpClient, HttpMethod, HttpResponse, HttpRetryOptions, HttpRetrySummary, HttpStreamResponse, IanaTimeZone, InferSchemaOutput, Iso3166Alpha2CountryCode, Iso4217CurrencyCode, Iso8601Duration, OperationAnnotations, OperationApprovalPolicy, OperationContractMetadata, OperationDefinition, OperationDeprecationMetadata, OperationDocMeta, OperationErrorCode, OperationHandlerResult, OperationInputExample, OperationLifecycle, OperationObservabilityConfig, OperationObservabilitySensitiveConfig, OperationRelationships, OperationRiskClass, OperationSensitivePath, OperationToolRouterMetadata, OperationTransport, OperationTransportKind, ProbeInterval, ProviderAccessConfig, ProviderAccessVisibility, ProviderCache, ProviderCacheGetOrSetOptions, ProviderCacheKeyOptions, ProviderCacheLookupMeta, ProviderCacheResponseMeta, ProviderCacheResult, ProviderChoiceBindingOptions, ProviderChoiceContext, ProviderChoiceIssueOptions, ProviderChoiceParseOptions, ProviderContext, ProviderDefinition, ProviderDeploymentOverrides, ProviderHealthMonitorConfig, ProviderHealthProbeConfig, ProviderLocale, ProviderLocaleKey, ProviderLocaleKeyInput, ProviderLogoProfile, ProviderLogoSource, ProviderMeta, ProviderProxyConfig, ProviderProxyMode, ProviderProxyPolicy, ProviderProxyProvider, ProviderProxySessionAffinity, ProviderPublicConnectionMode, ProviderPublicProfile, ProviderReviewed, ProviderRuntimeState, ProviderSecretDeclaration, ProviderStateDurationString, ProviderStateNamespace, ProviderStreamEvent, ProviderSttConfig, ProviderSttMode, ProviderSupportLevel, RequestOptions, Rfc3339Instant, SchemaLike, SmsOrigin, SmsOtpExtractionPattern, SmsOtpMatcherDefinition, SseMessage, StandardSchemaV1, StateCasResult, StateNamespaceOptions, StateValue, StateWriteOptions, StealthClient, StealthFetchOptions, StealthPlatform, StealthProfile, StealthRedirectHop, StealthRedirectRunOptions, StealthRedirectRunResult, StealthResponse, StealthSession, StealthSessionCookies, SttAudioInput, SttContext, SttPromptPolicy, SttSegment, SttTranscribeMode, SttTranscribeRequest, SttTranscript, SttUnsupportedOptionPolicy, SttUsage, SttVerificationCodeOptions, SttWarning, TraceConfig, TraceSpan, VerificationCodeCandidate, VerificationCodeCandidateSource, VerificationCodeExtractionResult, } from "./types.js";
|
|
39
|
+
export { DEFAULT_OPERATION_TRANSPORT, HttpRetryAfterPolicy, HttpRetryDelayStrategy, HttpRetryJitter, HttpRetryPreset, HttpRetryUnsafeMethodPolicy, PROBE_INTERVALS, STREAM_CHUNK_BYTES_MAX, STREAM_CHUNK_BYTES_MIN, STREAM_HEARTBEAT_MS_MAX, STREAM_HEARTBEAT_MS_MIN, STREAM_IDLE_TIMEOUT_MS_MAX, STREAM_IDLE_TIMEOUT_MS_MIN, STREAM_MAX_DURATION_MS_MAX, STREAM_MAX_DURATION_MS_MIN, } from "./types.js";
|
|
40
|
+
export * from "./utils/date.js";
|
|
41
|
+
export * from "./utils/parse.js";
|
|
42
|
+
export * from "./utils/text.js";
|
|
43
|
+
export * from "./utils/transform.js";
|