@apifuse/provider-sdk 2.0.0-beta.1 → 2.1.0-beta.1
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 +93 -0
- package/CHANGELOG.md +21 -0
- package/README.md +133 -28
- package/bin/apifuse-check.ts +78 -71
- package/bin/apifuse-create.ts +12 -0
- package/bin/apifuse-dev.ts +24 -61
- package/bin/apifuse-pack-check.ts +87 -0
- package/bin/apifuse-pack-smoke.ts +122 -0
- package/bin/apifuse-perf.ts +33 -32
- package/bin/apifuse-record.ts +17 -7
- package/bin/apifuse-test.ts +6 -4
- package/bin/apifuse.ts +36 -35
- package/package.json +29 -9
- package/src/ceremonies/index.ts +768 -0
- package/src/cli/commands.ts +87 -0
- package/src/cli/create.ts +845 -0
- package/src/cli/templates/provider/Dockerfile.tpl +7 -0
- package/src/cli/templates/provider/README.md.tpl +41 -0
- package/src/cli/templates/provider/dev.ts.tpl +5 -0
- package/src/cli/templates/provider/index.test.ts.tpl +13 -0
- package/src/cli/templates/provider/index.ts.tpl +58 -0
- package/src/cli/templates/provider/start.ts.tpl +5 -0
- package/src/config/loader.ts +61 -1
- package/src/define.ts +565 -41
- package/src/dev.ts +2 -6
- package/src/errors.ts +42 -0
- package/src/index.ts +44 -38
- package/src/lint.ts +574 -0
- package/src/provider.ts +13 -0
- package/src/runtime/auth-flow.ts +67 -0
- package/src/runtime/credential.ts +95 -0
- package/src/runtime/env.ts +13 -0
- package/src/runtime/executor.ts +13 -14
- package/src/runtime/http.ts +36 -12
- package/src/runtime/insights.ts +3 -3
- package/src/runtime/key-derivation.ts +122 -0
- package/src/runtime/keyring.ts +148 -0
- package/src/runtime/namespace.ts +33 -0
- package/src/runtime/prevalidate.ts +252 -0
- package/src/runtime/tls.ts +41 -17
- package/src/runtime/waterfall.ts +0 -1
- package/src/schema.ts +77 -0
- package/src/serve.ts +1 -664
- package/src/server/index.ts +22 -0
- package/src/server/serve.ts +624 -0
- package/src/server/types.ts +78 -0
- package/src/stealth/profiles.ts +10 -93
- package/src/testing/run.ts +391 -32
- package/src/types.ts +390 -41
- package/bin/apifuse-init.ts +0 -387
- package/src/__tests__/auth.test.ts +0 -396
- package/src/__tests__/browser-auth.test.ts +0 -180
- package/src/__tests__/browser.test.ts +0 -632
- package/src/__tests__/define.test.ts +0 -225
- package/src/__tests__/errors.test.ts +0 -69
- package/src/__tests__/executor.test.ts +0 -214
- package/src/__tests__/http.test.ts +0 -238
- package/src/__tests__/insights.test.ts +0 -210
- package/src/__tests__/instrumentation.test.ts +0 -290
- package/src/__tests__/otlp.test.ts +0 -141
- package/src/__tests__/perf.test.ts +0 -60
- package/src/__tests__/providers-yaml.test.ts +0 -135
- package/src/__tests__/proxy.test.ts +0 -359
- package/src/__tests__/recipes.test.ts +0 -36
- package/src/__tests__/serve.test.ts +0 -233
- package/src/__tests__/session.test.ts +0 -231
- package/src/__tests__/state.test.ts +0 -100
- package/src/__tests__/stealth.test.ts +0 -57
- package/src/__tests__/testing.test.ts +0 -97
- package/src/__tests__/tls.test.ts +0 -345
- package/src/__tests__/types.test.ts +0 -142
- package/src/__tests__/utils.test.ts +0 -62
- package/src/__tests__/waterfall.test.ts +0 -270
- package/src/config/providers-yaml.ts +0 -370
- package/src/index.test.ts +0 -1
- package/src/protocol.ts +0 -183
- package/src/runtime/auth.ts +0 -245
- package/src/runtime/session.ts +0 -573
- package/src/runtime/state.ts +0 -124
package/src/dev.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { serve } from "./server/serve";
|
|
2
2
|
import type { ProviderDefinition } from "./types";
|
|
3
3
|
|
|
4
4
|
export interface DevServerOptions {
|
|
@@ -11,14 +11,10 @@ export function createDevServer(
|
|
|
11
11
|
options?: DevServerOptions,
|
|
12
12
|
): { start: () => void } {
|
|
13
13
|
const port = options?.port ?? 3900;
|
|
14
|
-
const server = createProviderServer(provider, {
|
|
15
|
-
port,
|
|
16
|
-
sessionDbPath: options?.sessionDbPath,
|
|
17
|
-
});
|
|
18
14
|
|
|
19
15
|
return {
|
|
20
16
|
start: () => {
|
|
21
|
-
|
|
17
|
+
void serve(provider, { port });
|
|
22
18
|
console.log(
|
|
23
19
|
`[apifuse dev] ${provider.id}@${provider.version} running at http://localhost:${port}`,
|
|
24
20
|
);
|
package/src/errors.ts
CHANGED
|
@@ -66,3 +66,45 @@ export class TransportError extends ProviderError {
|
|
|
66
66
|
this.status = options?.status;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
+
|
|
70
|
+
export class ProviderSecretError extends ProviderError {
|
|
71
|
+
constructor(message: string, options?: ProviderErrorOptions) {
|
|
72
|
+
super(message, { code: "provider_secret_error", ...options });
|
|
73
|
+
this.name = "ProviderSecretError";
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export class CredentialKeyError extends ProviderError {
|
|
78
|
+
constructor(message: string, options?: ProviderErrorOptions) {
|
|
79
|
+
super(message, { code: "credential_key_error", ...options });
|
|
80
|
+
this.name = "CredentialKeyError";
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export class CredentialModeError extends ProviderError {
|
|
85
|
+
constructor(message: string, options?: ProviderErrorOptions) {
|
|
86
|
+
super(message, { code: "credential_mode_error", ...options });
|
|
87
|
+
this.name = "CredentialModeError";
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export class FlowExpiredError extends ProviderError {
|
|
92
|
+
constructor(message: string, options?: ProviderErrorOptions) {
|
|
93
|
+
super(message, { code: "flow_expired", ...options });
|
|
94
|
+
this.name = "FlowExpiredError";
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export class TurnValidationError extends ProviderError {
|
|
99
|
+
constructor(message: string, options?: ProviderErrorOptions) {
|
|
100
|
+
super(message, { code: "turn_validation_error", ...options });
|
|
101
|
+
this.name = "TurnValidationError";
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export class ContextAccessError extends ProviderError {
|
|
106
|
+
constructor(message: string, options?: ProviderErrorOptions) {
|
|
107
|
+
super(message, { code: "context_access_error", ...options });
|
|
108
|
+
this.name = "ContextAccessError";
|
|
109
|
+
}
|
|
110
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// @apifuse/provider-sdk
|
|
2
2
|
|
|
3
3
|
export { z } from "zod";
|
|
4
|
+
export * from "./ceremonies";
|
|
4
5
|
export type {
|
|
5
6
|
ApiFuseConfig,
|
|
6
7
|
BrowserConfig,
|
|
@@ -8,32 +9,25 @@ export type {
|
|
|
8
9
|
SessionConfig,
|
|
9
10
|
} from "./config/loader";
|
|
10
11
|
export { defineConfig, loadApiFuseConfig } from "./config/loader";
|
|
11
|
-
export type
|
|
12
|
-
PoolSizeRange,
|
|
13
|
-
ProviderConfig,
|
|
14
|
-
ProvidersYaml,
|
|
15
|
-
} from "./config/providers-yaml";
|
|
16
|
-
export {
|
|
17
|
-
CdpSchema,
|
|
18
|
-
ContainerSchema,
|
|
19
|
-
loadProvidersYaml,
|
|
20
|
-
ProviderConfigSchema,
|
|
21
|
-
ProvidersYamlSchema,
|
|
22
|
-
parseProvidersYaml,
|
|
23
|
-
resolveProviderConfig,
|
|
24
|
-
SecuritySchema,
|
|
25
|
-
} from "./config/providers-yaml";
|
|
26
|
-
export { defineProvider } from "./define";
|
|
12
|
+
export { defineOperation, defineProvider, type ProviderConfig } from "./define";
|
|
27
13
|
export type { DevServerOptions } from "./dev";
|
|
28
14
|
export { createDevServer, startDevServer } from "./dev";
|
|
29
15
|
export * from "./errors";
|
|
30
|
-
export
|
|
16
|
+
export {
|
|
17
|
+
type LintDiagnostic,
|
|
18
|
+
lintOperation,
|
|
19
|
+
lintProvider,
|
|
20
|
+
} from "./lint";
|
|
31
21
|
export * from "./recipes/gov-api";
|
|
32
22
|
export * from "./recipes/rest-api";
|
|
33
|
-
export
|
|
34
|
-
export { createAuthManager } from "./runtime/auth";
|
|
23
|
+
export { createFlowContext, createScratchpad } from "./runtime/auth-flow";
|
|
35
24
|
export type { BrowserClientOptions } from "./runtime/browser";
|
|
36
25
|
export { BrowserClient, createBrowserClient } from "./runtime/browser";
|
|
26
|
+
export {
|
|
27
|
+
type CreateCredentialContextOptions,
|
|
28
|
+
createCredentialContext,
|
|
29
|
+
} from "./runtime/credential";
|
|
30
|
+
export { createEnvContext } from "./runtime/env";
|
|
37
31
|
export { executeOperation } from "./runtime/executor";
|
|
38
32
|
export { createHttpClient } from "./runtime/http";
|
|
39
33
|
export type { Insight, InsightSeverity } from "./runtime/insights";
|
|
@@ -43,17 +37,8 @@ export {
|
|
|
43
37
|
type InstrumentedProviderContext,
|
|
44
38
|
wrapWithInstrumentation,
|
|
45
39
|
} from "./runtime/instrumentation";
|
|
40
|
+
export { type PrevalidateResult, prevalidate } from "./runtime/prevalidate";
|
|
46
41
|
export { getProviderBaseUrl } from "./runtime/provider";
|
|
47
|
-
export type {
|
|
48
|
-
SessionFetch,
|
|
49
|
-
SupabaseSessionStoreConfig,
|
|
50
|
-
} from "./runtime/session";
|
|
51
|
-
export {
|
|
52
|
-
createSessionStore,
|
|
53
|
-
createSqliteSessionStore,
|
|
54
|
-
SupabaseSessionStore,
|
|
55
|
-
} from "./runtime/session";
|
|
56
|
-
export { createStateContext } from "./runtime/state";
|
|
57
42
|
export { createTlsClient } from "./runtime/tls";
|
|
58
43
|
export {
|
|
59
44
|
type CreateTraceContextOptions,
|
|
@@ -61,30 +46,50 @@ export {
|
|
|
61
46
|
type Span,
|
|
62
47
|
type TraceContext,
|
|
63
48
|
} from "./runtime/trace";
|
|
64
|
-
export {
|
|
49
|
+
export { createServerApp, type ServeOptions, serve } from "./server";
|
|
65
50
|
export { getStealthProfile, listStealthProfiles } from "./stealth/profiles";
|
|
66
|
-
export {
|
|
67
|
-
runStandardTests,
|
|
68
|
-
snapshotTransform,
|
|
69
|
-
toMatchShape,
|
|
70
|
-
} from "./testing";
|
|
71
51
|
export type {
|
|
72
52
|
ApiFuseResponse,
|
|
73
53
|
AuthConfig,
|
|
74
54
|
AuthContext,
|
|
75
|
-
|
|
55
|
+
AuthFlowDefinition,
|
|
56
|
+
AuthFlowHandler,
|
|
76
57
|
AuthMode,
|
|
58
|
+
AuthTurn,
|
|
77
59
|
BrowserEngine,
|
|
78
60
|
BrowserOptions,
|
|
61
|
+
ConnectionMode,
|
|
62
|
+
ContextDeclaration,
|
|
63
|
+
ContextScratchpad,
|
|
64
|
+
CredentialContext,
|
|
65
|
+
CredentialDeclaration,
|
|
66
|
+
EnvContext,
|
|
67
|
+
FlowContext,
|
|
68
|
+
FlowContextStore,
|
|
69
|
+
HealthCheckAssertionContext,
|
|
70
|
+
HealthCheckCase,
|
|
71
|
+
HealthCheckCaseResult,
|
|
72
|
+
HealthCheckSuite,
|
|
73
|
+
HealthCheckUnsupported,
|
|
79
74
|
HttpClient,
|
|
80
75
|
HttpResponse,
|
|
76
|
+
InferSchemaOutput,
|
|
77
|
+
OperationAnnotations,
|
|
81
78
|
OperationDefinition,
|
|
79
|
+
OperationDocMeta,
|
|
80
|
+
OperationErrorCode,
|
|
81
|
+
OperationInputExample,
|
|
82
|
+
OperationRelationships,
|
|
83
|
+
ProbeInterval,
|
|
82
84
|
ProviderContext,
|
|
83
85
|
ProviderDefinition,
|
|
86
|
+
ProviderHealthMonitorConfig,
|
|
84
87
|
ProviderMeta,
|
|
88
|
+
ProviderReviewed,
|
|
89
|
+
ProviderSecretDeclaration,
|
|
85
90
|
RequestOptions,
|
|
86
|
-
|
|
87
|
-
|
|
91
|
+
SchemaLike,
|
|
92
|
+
StandardSchemaV1,
|
|
88
93
|
StealthPlatform,
|
|
89
94
|
StealthProfile,
|
|
90
95
|
TlsClient,
|
|
@@ -94,6 +99,7 @@ export type {
|
|
|
94
99
|
TraceConfig,
|
|
95
100
|
TraceSpan,
|
|
96
101
|
} from "./types";
|
|
102
|
+
export { PROBE_INTERVALS } from "./types";
|
|
97
103
|
export * from "./utils/date";
|
|
98
104
|
export * from "./utils/parse";
|
|
99
105
|
export * from "./utils/text";
|