@apifuse/provider-sdk 2.2.0-beta.2 → 2.2.0-beta.4
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 +14 -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 +73 -30
- package/bin/apifuse.ts +1 -1
- package/bin/submit-check-xml-semantics.ts +204 -0
- package/bin/submit-check-xml.ts +134 -0
- 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 +4 -1
- package/dist/errors.js +48 -0
- 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 +8 -3
- 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 +3 -3
- package/dist/server/self-test.js +3 -3
- package/dist/server/serve.d.ts +3 -3
- package/dist/server/serve.js +49 -57
- 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 +7 -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 +58 -5
- 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 +15 -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 +15 -20
- 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 +7 -7
- package/src/server/self-test-redaction.ts +2 -2
- package/src/server/self-test.ts +5 -5
- package/src/server/serve.ts +103 -252
- 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/src/dev.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { serve } from "./server/serve";
|
|
2
|
-
import type { ProviderDefinition } from "./types";
|
|
1
|
+
import { serve } from "./server/serve.js";
|
|
2
|
+
import type { ProviderDefinition } from "./types.js";
|
|
3
3
|
|
|
4
4
|
export interface DevServerOptions {
|
|
5
5
|
port?: number;
|
|
@@ -18,17 +18,12 @@ export function createDevServer(
|
|
|
18
18
|
console.log(
|
|
19
19
|
`[apifuse dev] ${provider.id}@${provider.version} running at http://localhost:${port}`,
|
|
20
20
|
);
|
|
21
|
-
console.log(
|
|
22
|
-
`[apifuse dev] Operations: ${Object.keys(provider.operations).join(", ")}`,
|
|
23
|
-
);
|
|
21
|
+
console.log(`[apifuse dev] Operations: ${Object.keys(provider.operations).join(", ")}`);
|
|
24
22
|
console.log(`[apifuse dev] Health: http://localhost:${port}/health`);
|
|
25
23
|
},
|
|
26
24
|
};
|
|
27
25
|
}
|
|
28
26
|
|
|
29
|
-
export function startDevServer(
|
|
30
|
-
provider: ProviderDefinition,
|
|
31
|
-
options?: DevServerOptions,
|
|
32
|
-
): void {
|
|
27
|
+
export function startDevServer(provider: ProviderDefinition, options?: DevServerOptions): void {
|
|
33
28
|
createDevServer(provider, options).start();
|
|
34
29
|
}
|
package/src/errors.ts
CHANGED
|
@@ -1,4 +1,41 @@
|
|
|
1
|
-
import type { ProviderErrorCategory } from "./observability";
|
|
1
|
+
import type { ProviderErrorCategory } from "./observability.js";
|
|
2
|
+
|
|
3
|
+
// Versioned, cross-realm brands. `Symbol.for` resolves to the same symbol in
|
|
4
|
+
// any copy/entrypoint of this SDK major version, so an error created by a
|
|
5
|
+
// duplicate module instance (e.g. the packaged CLI's src/* server vs a
|
|
6
|
+
// provider's dist/* import) still carries a brand the server can recognize even
|
|
7
|
+
// though `instanceof` splits across the two constructors. The `@1` suffix lets a
|
|
8
|
+
// future breaking change to this contract mint a distinct key.
|
|
9
|
+
const PROVIDER_ERROR_BRAND = Symbol.for("@apifuse/provider-sdk/error-brand@1");
|
|
10
|
+
const PROVIDER_ERROR_BRAND_VALUE = 1;
|
|
11
|
+
const SESSION_EXPIRED_BRAND = Symbol.for("@apifuse/provider-sdk/error-kind/session-expired@1");
|
|
12
|
+
const TRANSPORT_BRAND = Symbol.for("@apifuse/provider-sdk/error-kind/transport@1");
|
|
13
|
+
|
|
14
|
+
// Defines a non-enumerable, non-writable, non-configurable own data property.
|
|
15
|
+
// Immutable + own means a guard can trust it via a single descriptor read
|
|
16
|
+
// without invoking attacker-controlled getters or accepting inherited brands.
|
|
17
|
+
function defineErrorBrand(target: object, brand: symbol, value: number | true): void {
|
|
18
|
+
Object.defineProperty(target, brand, {
|
|
19
|
+
value,
|
|
20
|
+
enumerable: false,
|
|
21
|
+
writable: false,
|
|
22
|
+
configurable: false,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Recognizes an own data-property brand with the expected value. Rejects
|
|
27
|
+
// missing brands (unbranded lookalikes), accessor brands (no own `value`
|
|
28
|
+
// slot — the getter is never called), and inherited brands (own-descriptor
|
|
29
|
+
// lookup returns undefined on the child).
|
|
30
|
+
function hasOwnBrand(value: unknown, brand: symbol, expected: number | true): boolean {
|
|
31
|
+
if (value === null || (typeof value !== "object" && typeof value !== "function")) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, brand);
|
|
35
|
+
return (
|
|
36
|
+
descriptor !== undefined && Object.hasOwn(descriptor, "value") && descriptor.value === expected
|
|
37
|
+
);
|
|
38
|
+
}
|
|
2
39
|
|
|
3
40
|
export type ProviderErrorOptions = {
|
|
4
41
|
fix?: string;
|
|
@@ -19,6 +56,7 @@ export class ProviderError extends Error {
|
|
|
19
56
|
if (options?.cause) {
|
|
20
57
|
this.cause = options.cause;
|
|
21
58
|
}
|
|
59
|
+
defineErrorBrand(this, PROVIDER_ERROR_BRAND, PROVIDER_ERROR_BRAND_VALUE);
|
|
22
60
|
}
|
|
23
61
|
|
|
24
62
|
get fix(): string | undefined {
|
|
@@ -49,10 +87,7 @@ export class AuthError extends ProviderError {
|
|
|
49
87
|
}
|
|
50
88
|
|
|
51
89
|
export class SessionExpiredError extends AuthError {
|
|
52
|
-
constructor(
|
|
53
|
-
message = "Provider session expired",
|
|
54
|
-
options?: ProviderErrorOptions,
|
|
55
|
-
) {
|
|
90
|
+
constructor(message = "Provider session expired", options?: ProviderErrorOptions) {
|
|
56
91
|
super(message, {
|
|
57
92
|
code: "reauth_required",
|
|
58
93
|
category: "credential_expired",
|
|
@@ -60,6 +95,7 @@ export class SessionExpiredError extends AuthError {
|
|
|
60
95
|
...options,
|
|
61
96
|
});
|
|
62
97
|
this.name = "SessionExpiredError";
|
|
98
|
+
defineErrorBrand(this, SESSION_EXPIRED_BRAND, true);
|
|
63
99
|
}
|
|
64
100
|
}
|
|
65
101
|
|
|
@@ -91,9 +127,26 @@ export class TransportError extends ProviderError {
|
|
|
91
127
|
this.name = "TransportError";
|
|
92
128
|
this.status = options?.status;
|
|
93
129
|
this.upstreamStatus = options?.upstreamStatus ?? options?.status;
|
|
130
|
+
defineErrorBrand(this, TRANSPORT_BRAND, true);
|
|
94
131
|
}
|
|
95
132
|
}
|
|
96
133
|
|
|
134
|
+
// Cross-module type guards. Prefer these over `instanceof` at any boundary that
|
|
135
|
+
// may receive an error from a different copy/entrypoint of the SDK (see the HTTP
|
|
136
|
+
// server error boundary). They recognize branded errors regardless of which
|
|
137
|
+
// module instance constructed them, while rejecting unbranded lookalikes.
|
|
138
|
+
export function isProviderError(value: unknown): value is ProviderError {
|
|
139
|
+
return hasOwnBrand(value, PROVIDER_ERROR_BRAND, PROVIDER_ERROR_BRAND_VALUE);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function isSessionExpiredError(value: unknown): value is SessionExpiredError {
|
|
143
|
+
return isProviderError(value) && hasOwnBrand(value, SESSION_EXPIRED_BRAND, true);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export function isTransportError(value: unknown): value is TransportError {
|
|
147
|
+
return isProviderError(value) && hasOwnBrand(value, TRANSPORT_BRAND, true);
|
|
148
|
+
}
|
|
149
|
+
|
|
97
150
|
export class ProviderSecretError extends ProviderError {
|
|
98
151
|
constructor(message: string, options?: ProviderErrorOptions) {
|
|
99
152
|
super(message, { code: "provider_secret_error", ...options });
|
package/src/i18n/catalog.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
|
|
4
|
-
import type { AuthTurn } from "../types";
|
|
4
|
+
import type { AuthTurn } from "../types.js";
|
|
5
5
|
import {
|
|
6
6
|
getProviderLocalePath,
|
|
7
7
|
isProviderLocaleValue,
|
|
@@ -10,12 +10,9 @@ import {
|
|
|
10
10
|
type ProviderLocaleKey,
|
|
11
11
|
type ProviderLocaleValue,
|
|
12
12
|
providerLocaleKey,
|
|
13
|
-
} from "./keys";
|
|
13
|
+
} from "./keys.js";
|
|
14
14
|
|
|
15
|
-
export type ProviderLocaleCatalogMap = Record<
|
|
16
|
-
ProviderLocale,
|
|
17
|
-
ProviderLocaleCatalog
|
|
18
|
-
>;
|
|
15
|
+
export type ProviderLocaleCatalogMap = Record<ProviderLocale, ProviderLocaleCatalog>;
|
|
19
16
|
|
|
20
17
|
export interface LoadProviderLocaleCatalogsOptions {
|
|
21
18
|
providerDir: string;
|
|
@@ -58,9 +55,7 @@ export function resolveProviderLocaleValue(
|
|
|
58
55
|
);
|
|
59
56
|
}
|
|
60
57
|
|
|
61
|
-
function asStringValue(
|
|
62
|
-
value: ProviderLocaleValue | undefined,
|
|
63
|
-
): string | undefined {
|
|
58
|
+
function asStringValue(value: ProviderLocaleValue | undefined): string | undefined {
|
|
64
59
|
return typeof value === "string" ? value : undefined;
|
|
65
60
|
}
|
|
66
61
|
|
|
@@ -82,9 +77,7 @@ function localizeAuthInputSchema(
|
|
|
82
77
|
},
|
|
83
78
|
): Record<string, unknown> | undefined {
|
|
84
79
|
if (!expectedInput) return undefined;
|
|
85
|
-
const schema = isRecord(expectedInput.schema)
|
|
86
|
-
? expectedInput.schema
|
|
87
|
-
: expectedInput;
|
|
80
|
+
const schema = isRecord(expectedInput.schema) ? expectedInput.schema : expectedInput;
|
|
88
81
|
const localizedSchema = localizeAuthSchemaObject(schema, options);
|
|
89
82
|
if (localizedSchema === schema) return undefined;
|
|
90
83
|
return isRecord(expectedInput.schema)
|
|
@@ -104,21 +97,16 @@ function localizeAuthSchemaObject(
|
|
|
104
97
|
fallbackLocale: ProviderLocale;
|
|
105
98
|
},
|
|
106
99
|
): Record<string, unknown> {
|
|
107
|
-
const properties = isRecord(schema.properties)
|
|
108
|
-
? schema.properties
|
|
109
|
-
: undefined;
|
|
100
|
+
const properties = isRecord(schema.properties) ? schema.properties : undefined;
|
|
110
101
|
if (!properties) return schema;
|
|
111
102
|
|
|
112
103
|
let changed = false;
|
|
113
104
|
const localizedProperties = Object.fromEntries(
|
|
114
105
|
Object.entries(properties).map(([fieldName, property]) => {
|
|
115
106
|
if (!isRecord(property)) return [fieldName, property];
|
|
116
|
-
const nameKey =
|
|
117
|
-
typeof property.nameKey === "string" ? property.nameKey : undefined;
|
|
107
|
+
const nameKey = typeof property.nameKey === "string" ? property.nameKey : undefined;
|
|
118
108
|
const descriptionKey =
|
|
119
|
-
typeof property.descriptionKey === "string"
|
|
120
|
-
? property.descriptionKey
|
|
121
|
-
: undefined;
|
|
109
|
+
typeof property.descriptionKey === "string" ? property.descriptionKey : undefined;
|
|
122
110
|
const title = nameKey
|
|
123
111
|
? asStringValue(
|
|
124
112
|
resolveProviderLocaleValue(
|
|
@@ -166,12 +154,7 @@ export function localizeAuthTurn(
|
|
|
166
154
|
const fallbackLocale = options.fallbackLocale ?? "en";
|
|
167
155
|
const hint = turn.hintKey
|
|
168
156
|
? asStringValue(
|
|
169
|
-
resolveProviderLocaleValue(
|
|
170
|
-
options.catalogs,
|
|
171
|
-
turn.hintKey,
|
|
172
|
-
options.locale,
|
|
173
|
-
fallbackLocale,
|
|
174
|
-
),
|
|
157
|
+
resolveProviderLocaleValue(options.catalogs, turn.hintKey, options.locale, fallbackLocale),
|
|
175
158
|
)
|
|
176
159
|
: undefined;
|
|
177
160
|
const expectedInput = localizeAuthInputSchema(turn.expectedInput, {
|
|
@@ -184,12 +167,7 @@ export function localizeAuthTurn(
|
|
|
184
167
|
? Object.fromEntries(
|
|
185
168
|
Object.entries(fieldErrorKeys).flatMap(([fieldName, key]) => {
|
|
186
169
|
const message = asStringValue(
|
|
187
|
-
resolveProviderLocaleValue(
|
|
188
|
-
options.catalogs,
|
|
189
|
-
key,
|
|
190
|
-
options.locale,
|
|
191
|
-
fallbackLocale,
|
|
192
|
-
),
|
|
170
|
+
resolveProviderLocaleValue(options.catalogs, key, options.locale, fallbackLocale),
|
|
193
171
|
);
|
|
194
172
|
return message ? [[fieldName, message]] : [];
|
|
195
173
|
}),
|
package/src/i18n/index.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/src/i18n/keys.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ProviderLocaleKey } from "../types";
|
|
1
|
+
import type { ProviderLocaleKey } from "../types.js";
|
|
2
2
|
|
|
3
|
-
export type { ProviderLocale, ProviderLocaleKey } from "../types";
|
|
3
|
+
export type { ProviderLocale, ProviderLocaleKey } from "../types.js";
|
|
4
4
|
|
|
5
5
|
const PROVIDER_LOCALE_KEY_RE =
|
|
6
6
|
/^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]+)*(?:\.[a-z][a-z0-9]*(?:[A-Z][a-z0-9]+)*|\.[0-9]+)*$/;
|
|
@@ -10,15 +10,11 @@ export function providerLocaleKey(key: string): ProviderLocaleKey {
|
|
|
10
10
|
return key;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export function isProviderLocaleKey(
|
|
14
|
-
value: unknown,
|
|
15
|
-
): value is ProviderLocaleKey {
|
|
13
|
+
export function isProviderLocaleKey(value: unknown): value is ProviderLocaleKey {
|
|
16
14
|
return typeof value === "string" && PROVIDER_LOCALE_KEY_RE.test(value);
|
|
17
15
|
}
|
|
18
16
|
|
|
19
|
-
export function assertProviderLocaleKey(
|
|
20
|
-
value: unknown,
|
|
21
|
-
): asserts value is ProviderLocaleKey {
|
|
17
|
+
export function assertProviderLocaleKey(value: unknown): asserts value is ProviderLocaleKey {
|
|
22
18
|
if (!isProviderLocaleKey(value)) {
|
|
23
19
|
throw new Error(
|
|
24
20
|
`Provider locale key must be a dot path such as "meta.description" or "operations.search.description"; received ${JSON.stringify(value)}`,
|
|
@@ -50,9 +46,7 @@ export function getProviderLocalePath(
|
|
|
50
46
|
export type ProviderLocaleValue = string | readonly string[];
|
|
51
47
|
export type ProviderLocaleCatalog = Record<string, unknown>;
|
|
52
48
|
|
|
53
|
-
export function isProviderLocaleValue(
|
|
54
|
-
value: unknown,
|
|
55
|
-
): value is ProviderLocaleValue {
|
|
49
|
+
export function isProviderLocaleValue(value: unknown): value is ProviderLocaleValue {
|
|
56
50
|
return (
|
|
57
51
|
typeof value === "string" ||
|
|
58
52
|
(Array.isArray(value) && value.every((entry) => typeof entry === "string"))
|
package/src/index.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// @apifuse/provider-sdk
|
|
2
2
|
|
|
3
|
-
export * from "./auth";
|
|
4
|
-
export * from "./ceremonies";
|
|
5
|
-
export * from "./choice-token";
|
|
3
|
+
export * from "./auth.js";
|
|
4
|
+
export * from "./ceremonies/index.js";
|
|
5
|
+
export * from "./choice-token.js";
|
|
6
6
|
export type {
|
|
7
7
|
ApiFuseConfig,
|
|
8
8
|
BrowserConfig,
|
|
9
9
|
ProxyConfig,
|
|
10
10
|
SessionConfig,
|
|
11
|
-
} from "./config/loader";
|
|
12
|
-
export { defineConfig, loadApiFuseConfig } from "./config/loader";
|
|
11
|
+
} from "./config/loader.js";
|
|
12
|
+
export { defineConfig, loadApiFuseConfig } from "./config/loader.js";
|
|
13
13
|
export {
|
|
14
14
|
canonicalJson,
|
|
15
15
|
digestProviderContract,
|
|
@@ -19,7 +19,7 @@ export {
|
|
|
19
19
|
PROVIDER_CONTRACT_SCHEMA_VERSION,
|
|
20
20
|
type ProviderContractOperation,
|
|
21
21
|
type ProviderContractSnapshot,
|
|
22
|
-
} from "./contract";
|
|
22
|
+
} from "./contract.js";
|
|
23
23
|
export {
|
|
24
24
|
centered,
|
|
25
25
|
delayed,
|
|
@@ -30,54 +30,55 @@ export {
|
|
|
30
30
|
defineStreamOperation,
|
|
31
31
|
every,
|
|
32
32
|
type ProviderConfig,
|
|
33
|
-
} from "./define";
|
|
34
|
-
export type { DevServerOptions } from "./dev";
|
|
35
|
-
export { createDevServer, startDevServer } from "./dev";
|
|
36
|
-
export * from "./errors";
|
|
37
|
-
export * from "./
|
|
33
|
+
} from "./define.js";
|
|
34
|
+
export type { DevServerOptions } from "./dev.js";
|
|
35
|
+
export { createDevServer, startDevServer } from "./dev.js";
|
|
36
|
+
export * from "./errors.js";
|
|
37
|
+
export * from "./user-input.js";
|
|
38
|
+
export * from "./i18n/index.js";
|
|
38
39
|
export {
|
|
39
40
|
type LintDiagnostic,
|
|
40
41
|
lintOperation,
|
|
41
42
|
lintProvider,
|
|
42
|
-
} from "./lint";
|
|
43
|
-
export * from "./recipes/gov-api";
|
|
44
|
-
export * from "./recipes/rest-api";
|
|
45
|
-
export { createFlowContext, createScratchpad } from "./runtime/auth-flow";
|
|
46
|
-
export type { BrowserClientOptions } from "./runtime/browser";
|
|
47
|
-
export { BrowserClient, createBrowserClient } from "./runtime/browser";
|
|
43
|
+
} from "./lint.js";
|
|
44
|
+
export * from "./recipes/gov-api.js";
|
|
45
|
+
export * from "./recipes/rest-api.js";
|
|
46
|
+
export { createFlowContext, createScratchpad } from "./runtime/auth-flow.js";
|
|
47
|
+
export type { BrowserClientOptions } from "./runtime/browser.js";
|
|
48
|
+
export { BrowserClient, createBrowserClient } from "./runtime/browser.js";
|
|
48
49
|
export {
|
|
49
50
|
createBypassProviderCache,
|
|
50
51
|
createProviderCache,
|
|
51
52
|
type ProviderCacheOptions,
|
|
52
53
|
resetProviderCacheForTests,
|
|
53
|
-
} from "./runtime/cache";
|
|
54
|
+
} from "./runtime/cache.js";
|
|
54
55
|
export {
|
|
55
56
|
type CreateProviderChoiceContextOptions,
|
|
56
57
|
createProviderChoiceContext,
|
|
57
58
|
createTestProviderChoiceContext,
|
|
58
59
|
PROVIDER_RUNTIME_CHOICE_TOKEN_MASTER_SECRET_ENV,
|
|
59
|
-
} from "./runtime/choice";
|
|
60
|
+
} from "./runtime/choice.js";
|
|
60
61
|
export {
|
|
61
62
|
type CreateCredentialContextOptions,
|
|
62
63
|
createCredentialContext,
|
|
63
|
-
} from "./runtime/credential";
|
|
64
|
-
export { createEnvContext } from "./runtime/env";
|
|
65
|
-
export { executeOperation } from "./runtime/executor";
|
|
66
|
-
export { createHttpClient } from "./runtime/http";
|
|
67
|
-
export type { Insight, InsightSeverity } from "./runtime/insights";
|
|
68
|
-
export { generateInsights } from "./runtime/insights";
|
|
64
|
+
} from "./runtime/credential.js";
|
|
65
|
+
export { createEnvContext } from "./runtime/env.js";
|
|
66
|
+
export { executeOperation } from "./runtime/executor.js";
|
|
67
|
+
export { createHttpClient } from "./runtime/http.js";
|
|
68
|
+
export type { Insight, InsightSeverity } from "./runtime/insights.js";
|
|
69
|
+
export { generateInsights } from "./runtime/insights.js";
|
|
69
70
|
export {
|
|
70
71
|
type InstrumentationOptions,
|
|
71
72
|
type InstrumentedProviderContext,
|
|
72
73
|
wrapWithInstrumentation,
|
|
73
|
-
} from "./runtime/instrumentation";
|
|
74
|
-
export { type PrevalidateResult, prevalidate } from "./runtime/prevalidate";
|
|
75
|
-
export { getProviderBaseUrl } from "./runtime/provider";
|
|
74
|
+
} from "./runtime/instrumentation.js";
|
|
75
|
+
export { type PrevalidateResult, prevalidate } from "./runtime/prevalidate.js";
|
|
76
|
+
export { getProviderBaseUrl } from "./runtime/provider.js";
|
|
76
77
|
export {
|
|
77
78
|
createUnsupportedProviderRuntimeState,
|
|
78
79
|
UnsupportedProviderStateError,
|
|
79
|
-
} from "./runtime/state";
|
|
80
|
-
export { createStealthClient } from "./runtime/stealth";
|
|
80
|
+
} from "./runtime/state.js";
|
|
81
|
+
export { createStealthClient } from "./runtime/stealth.js";
|
|
81
82
|
export {
|
|
82
83
|
APIFUSE__STT__BACKEND_ENV,
|
|
83
84
|
APIFUSE__STT__CLOUDFLARE_API_TOKEN_ENV,
|
|
@@ -86,13 +87,13 @@ export {
|
|
|
86
87
|
createUnsupportedSttClient,
|
|
87
88
|
extractVerificationCode,
|
|
88
89
|
resolveSttPrompt,
|
|
89
|
-
} from "./runtime/stt";
|
|
90
|
+
} from "./runtime/stt.js";
|
|
90
91
|
export {
|
|
91
92
|
type CreateTraceContextOptions,
|
|
92
93
|
createTraceContext,
|
|
93
94
|
type Span,
|
|
94
95
|
type TraceContext,
|
|
95
|
-
} from "./runtime/trace";
|
|
96
|
+
} from "./runtime/trace.js";
|
|
96
97
|
export {
|
|
97
98
|
APIFUSE_DESCRIPTION_KEY_META_KEY,
|
|
98
99
|
APIFUSE_REDACTION_MARKER,
|
|
@@ -109,10 +110,10 @@ export {
|
|
|
109
110
|
type SensitivePath,
|
|
110
111
|
sensitive,
|
|
111
112
|
z,
|
|
112
|
-
} from "./schema";
|
|
113
|
-
export { createServerApp, type ServeOptions, serve } from "./server";
|
|
114
|
-
export { getStealthProfile, listStealthProfiles } from "./stealth/profiles";
|
|
115
|
-
export * from "./stream";
|
|
113
|
+
} from "./schema.js";
|
|
114
|
+
export { createServerApp, type ServeOptions, serve } from "./server/index.js";
|
|
115
|
+
export { getStealthProfile, listStealthProfiles } from "./stealth/profiles.js";
|
|
116
|
+
export * from "./stream.js";
|
|
116
117
|
export type {
|
|
117
118
|
ApiFuseResponse,
|
|
118
119
|
AuthConfig,
|
|
@@ -201,6 +202,7 @@ export type {
|
|
|
201
202
|
ProviderChoiceParseOptions,
|
|
202
203
|
ProviderContext,
|
|
203
204
|
ProviderDefinition,
|
|
205
|
+
ProviderDeploymentOverrides,
|
|
204
206
|
ProviderHealthMonitorConfig,
|
|
205
207
|
ProviderHealthProbeConfig,
|
|
206
208
|
ProviderLocale,
|
|
@@ -263,7 +265,7 @@ export type {
|
|
|
263
265
|
VerificationCodeCandidate,
|
|
264
266
|
VerificationCodeCandidateSource,
|
|
265
267
|
VerificationCodeExtractionResult,
|
|
266
|
-
} from "./types";
|
|
268
|
+
} from "./types.js";
|
|
267
269
|
export {
|
|
268
270
|
DEFAULT_OPERATION_TRANSPORT,
|
|
269
271
|
HttpRetryAfterPolicy,
|
|
@@ -280,8 +282,8 @@ export {
|
|
|
280
282
|
STREAM_IDLE_TIMEOUT_MS_MIN,
|
|
281
283
|
STREAM_MAX_DURATION_MS_MAX,
|
|
282
284
|
STREAM_MAX_DURATION_MS_MIN,
|
|
283
|
-
} from "./types";
|
|
284
|
-
export * from "./utils/date";
|
|
285
|
-
export * from "./utils/parse";
|
|
286
|
-
export * from "./utils/text";
|
|
287
|
-
export * from "./utils/transform";
|
|
285
|
+
} from "./types.js";
|
|
286
|
+
export * from "./utils/date.js";
|
|
287
|
+
export * from "./utils/parse.js";
|
|
288
|
+
export * from "./utils/text.js";
|
|
289
|
+
export * from "./utils/transform.js";
|