@apifuse/provider-sdk 2.0.0-beta.1 → 2.1.0-beta.0
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 +102 -0
- package/CHANGELOG.md +14 -0
- package/README.md +100 -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 +47 -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 +28 -9
- package/src/ceremonies/index.ts +747 -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 +28 -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 +54 -0
- package/src/cli/templates/provider/start.ts.tpl +5 -0
- package/src/composite.ts +43 -0
- package/src/define.ts +527 -41
- package/src/dev.ts +2 -6
- package/src/errors.ts +42 -0
- package/src/index.ts +50 -38
- package/src/lint.ts +574 -0
- package/src/provider.ts +14 -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 +10 -2
- 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 +20 -5
- 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 +610 -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 +364 -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/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,13 @@
|
|
|
1
1
|
// @apifuse/provider-sdk
|
|
2
2
|
|
|
3
3
|
export { z } from "zod";
|
|
4
|
+
export * from "./ceremonies";
|
|
5
|
+
export {
|
|
6
|
+
type ClarifyResponse,
|
|
7
|
+
type CompositeContext,
|
|
8
|
+
type CompositeOperationDefinition,
|
|
9
|
+
defineCompositeOperation,
|
|
10
|
+
} from "./composite";
|
|
4
11
|
export type {
|
|
5
12
|
ApiFuseConfig,
|
|
6
13
|
BrowserConfig,
|
|
@@ -8,32 +15,25 @@ export type {
|
|
|
8
15
|
SessionConfig,
|
|
9
16
|
} from "./config/loader";
|
|
10
17
|
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";
|
|
18
|
+
export { defineOperation, defineProvider, type ProviderConfig } from "./define";
|
|
27
19
|
export type { DevServerOptions } from "./dev";
|
|
28
20
|
export { createDevServer, startDevServer } from "./dev";
|
|
29
21
|
export * from "./errors";
|
|
30
|
-
export
|
|
22
|
+
export {
|
|
23
|
+
type LintDiagnostic,
|
|
24
|
+
lintOperation,
|
|
25
|
+
lintProvider,
|
|
26
|
+
} from "./lint";
|
|
31
27
|
export * from "./recipes/gov-api";
|
|
32
28
|
export * from "./recipes/rest-api";
|
|
33
|
-
export
|
|
34
|
-
export { createAuthManager } from "./runtime/auth";
|
|
29
|
+
export { createFlowContext, createScratchpad } from "./runtime/auth-flow";
|
|
35
30
|
export type { BrowserClientOptions } from "./runtime/browser";
|
|
36
31
|
export { BrowserClient, createBrowserClient } from "./runtime/browser";
|
|
32
|
+
export {
|
|
33
|
+
type CreateCredentialContextOptions,
|
|
34
|
+
createCredentialContext,
|
|
35
|
+
} from "./runtime/credential";
|
|
36
|
+
export { createEnvContext } from "./runtime/env";
|
|
37
37
|
export { executeOperation } from "./runtime/executor";
|
|
38
38
|
export { createHttpClient } from "./runtime/http";
|
|
39
39
|
export type { Insight, InsightSeverity } from "./runtime/insights";
|
|
@@ -43,17 +43,8 @@ export {
|
|
|
43
43
|
type InstrumentedProviderContext,
|
|
44
44
|
wrapWithInstrumentation,
|
|
45
45
|
} from "./runtime/instrumentation";
|
|
46
|
+
export { type PrevalidateResult, prevalidate } from "./runtime/prevalidate";
|
|
46
47
|
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
48
|
export { createTlsClient } from "./runtime/tls";
|
|
58
49
|
export {
|
|
59
50
|
type CreateTraceContextOptions,
|
|
@@ -61,30 +52,50 @@ export {
|
|
|
61
52
|
type Span,
|
|
62
53
|
type TraceContext,
|
|
63
54
|
} from "./runtime/trace";
|
|
64
|
-
export {
|
|
55
|
+
export { createServerApp, type ServeOptions, serve } from "./server";
|
|
65
56
|
export { getStealthProfile, listStealthProfiles } from "./stealth/profiles";
|
|
66
|
-
export {
|
|
67
|
-
runStandardTests,
|
|
68
|
-
snapshotTransform,
|
|
69
|
-
toMatchShape,
|
|
70
|
-
} from "./testing";
|
|
71
57
|
export type {
|
|
72
58
|
ApiFuseResponse,
|
|
73
59
|
AuthConfig,
|
|
74
60
|
AuthContext,
|
|
75
|
-
|
|
61
|
+
AuthFlowDefinition,
|
|
62
|
+
AuthFlowHandler,
|
|
76
63
|
AuthMode,
|
|
64
|
+
AuthTurn,
|
|
77
65
|
BrowserEngine,
|
|
78
66
|
BrowserOptions,
|
|
67
|
+
ConnectionMode,
|
|
68
|
+
ContextDeclaration,
|
|
69
|
+
ContextScratchpad,
|
|
70
|
+
CredentialContext,
|
|
71
|
+
CredentialDeclaration,
|
|
72
|
+
EnvContext,
|
|
73
|
+
FlowContext,
|
|
74
|
+
FlowContextStore,
|
|
75
|
+
HealthCheckAssertionContext,
|
|
76
|
+
HealthCheckCase,
|
|
77
|
+
HealthCheckCaseResult,
|
|
78
|
+
HealthCheckSuite,
|
|
79
|
+
HealthCheckUnsupported,
|
|
79
80
|
HttpClient,
|
|
80
81
|
HttpResponse,
|
|
82
|
+
InferSchemaOutput,
|
|
83
|
+
OperationAnnotations,
|
|
81
84
|
OperationDefinition,
|
|
85
|
+
OperationDocMeta,
|
|
86
|
+
OperationErrorCode,
|
|
87
|
+
OperationInputExample,
|
|
88
|
+
OperationRelationships,
|
|
89
|
+
ProbeInterval,
|
|
82
90
|
ProviderContext,
|
|
83
91
|
ProviderDefinition,
|
|
92
|
+
ProviderHealthMonitorConfig,
|
|
84
93
|
ProviderMeta,
|
|
94
|
+
ProviderReviewed,
|
|
95
|
+
ProviderSecretDeclaration,
|
|
85
96
|
RequestOptions,
|
|
86
|
-
|
|
87
|
-
|
|
97
|
+
SchemaLike,
|
|
98
|
+
StandardSchemaV1,
|
|
88
99
|
StealthPlatform,
|
|
89
100
|
StealthProfile,
|
|
90
101
|
TlsClient,
|
|
@@ -94,6 +105,7 @@ export type {
|
|
|
94
105
|
TraceConfig,
|
|
95
106
|
TraceSpan,
|
|
96
107
|
} from "./types";
|
|
108
|
+
export { PROBE_INTERVALS } from "./types";
|
|
97
109
|
export * from "./utils/date";
|
|
98
110
|
export * from "./utils/parse";
|
|
99
111
|
export * from "./utils/text";
|