@executor-js/plugin-openapi 0.0.1 → 0.0.2

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.
Files changed (41) hide show
  1. package/README.md +24 -23
  2. package/dist/api/group.d.ts +94 -38
  3. package/dist/api/handlers.d.ts +2 -2
  4. package/dist/chunk-ZZ7TQ4JC.js +2602 -0
  5. package/dist/chunk-ZZ7TQ4JC.js.map +1 -0
  6. package/dist/core.js +44 -50
  7. package/dist/core.js.map +1 -1
  8. package/dist/index.js +2 -5
  9. package/dist/index.js.map +1 -1
  10. package/dist/react/AddOpenApiSource.d.ts +13 -0
  11. package/dist/react/EditOpenApiSource.d.ts +2 -2
  12. package/dist/react/OpenApiSourceSummary.d.ts +3 -1
  13. package/dist/react/atoms.d.ts +129 -0
  14. package/dist/react/client.d.ts +421 -3
  15. package/dist/react/source-plugin.d.ts +1 -1
  16. package/dist/sdk/client-credentials-oauth.test.d.ts +1 -0
  17. package/dist/sdk/credential-status.d.ts +23 -0
  18. package/dist/sdk/credential-status.test.d.ts +1 -0
  19. package/dist/sdk/errors.d.ts +11 -10
  20. package/dist/sdk/form-urlencoded-body.test.d.ts +1 -0
  21. package/dist/sdk/index.d.ts +8 -10
  22. package/dist/sdk/invoke.d.ts +8 -17
  23. package/dist/sdk/multi-scope-bearer.test.d.ts +1 -0
  24. package/dist/sdk/multi-scope-oauth.test.d.ts +1 -0
  25. package/dist/sdk/non-json-body.test.d.ts +1 -0
  26. package/dist/sdk/oauth-refresh.test.d.ts +1 -0
  27. package/dist/sdk/openapi-utils.d.ts +35 -4
  28. package/dist/sdk/parse.d.ts +28 -4
  29. package/dist/sdk/plugin.d.ts +168 -22
  30. package/dist/sdk/preview-oauth2.test.d.ts +1 -0
  31. package/dist/sdk/preview.d.ts +86 -161
  32. package/dist/sdk/store.d.ts +201 -0
  33. package/dist/sdk/types.d.ts +234 -266
  34. package/package.json +11 -22
  35. package/dist/chunk-KPGROAQO.js +0 -1279
  36. package/dist/chunk-KPGROAQO.js.map +0 -1
  37. package/dist/promise.d.ts +0 -6
  38. package/dist/sdk/config-file-store.d.ts +0 -10
  39. package/dist/sdk/kv-operation-store.d.ts +0 -4
  40. package/dist/sdk/operation-store.d.ts +0 -36
  41. package/dist/sdk/stored-source.d.ts +0 -51
@@ -1,23 +1,14 @@
1
1
  import { Effect, Layer } from "effect";
2
- import { HttpClient } from "@effect/platform";
3
- import { type ToolInvoker, type ScopeId, type SecretId } from "@executor-js/sdk";
2
+ import { HttpClient } from "effect/unstable/http";
3
+ import type { SecretOwnedByConnectionError, StorageFailure } from "@executor-js/sdk/core";
4
4
  import { OpenApiInvocationError } from "./errors";
5
- import type { OpenApiOperationStore } from "./operation-store";
6
- import { type OperationBinding, InvocationConfig, InvocationResult } from "./types";
7
- /** Invoke an OpenAPI operation binding. Requires HttpClient in the context. */
8
- export declare const invoke: (operation: OperationBinding, args: Record<string, unknown>, config: InvocationConfig, resolvedHeaders?: Record<string, string> | undefined) => Effect.Effect<InvocationResult, OpenApiInvocationError | import("@effect/platform/HttpClientError").ResponseError, HttpClient.HttpClient>;
9
- /**
10
- * Derive tool annotations from the HTTP method and path.
11
- */
5
+ import { type HeaderValue, type OperationBinding, InvocationResult } from "./types";
6
+ export declare const resolveHeaders: (headers: Record<string, HeaderValue>, secrets: {
7
+ readonly get: (id: string) => Effect.Effect<string | null, SecretOwnedByConnectionError | StorageFailure>;
8
+ }) => Effect.Effect<Record<string, string>, OpenApiInvocationError | StorageFailure>;
9
+ export declare const invoke: (operation: OperationBinding, args: Record<string, unknown>, resolvedHeaders: Record<string, string>, sourceQueryParams?: Record<string, string> | undefined) => Effect.Effect<InvocationResult, OpenApiInvocationError, HttpClient.HttpClient>;
10
+ export declare const invokeWithLayer: (operation: OperationBinding, args: Record<string, unknown>, baseUrl: string, resolvedHeaders: Record<string, string>, sourceQueryParams: Record<string, string>, httpClientLayer: Layer.Layer<HttpClient.HttpClient, never, never>) => Effect.Effect<InvocationResult, OpenApiInvocationError, never>;
12
11
  export declare const annotationsForOperation: (method: string, pathTemplate: string) => {
13
12
  requiresApproval?: boolean;
14
13
  approvalDescription?: string;
15
14
  };
16
- export declare const makeOpenApiInvoker: (opts: {
17
- readonly operationStore: OpenApiOperationStore;
18
- readonly httpClientLayer: Layer.Layer<HttpClient.HttpClient>;
19
- readonly secrets: {
20
- readonly resolve: (secretId: SecretId, scopeId: ScopeId) => Effect.Effect<string, unknown>;
21
- };
22
- readonly scopeId: ScopeId;
23
- }) => ToolInvoker;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -13,12 +13,43 @@ export declare class DocResolver {
13
13
  resolve<T>(value: T | OpenAPIV3.ReferenceObject | OpenAPIV3_1.ReferenceObject): T | null;
14
14
  private resolvePointer;
15
15
  }
16
- export declare const resolveBaseUrl: (servers: readonly {
16
+ /** Substitute `{var}` placeholders in a templated URL using a plain map. */
17
+ export declare const substituteUrlVariables: (url: string, values: Record<string, string>) => string;
18
+ type ServerLike = {
17
19
  url: string;
18
- variables: import("effect/Option").Option<Record<string, string>>;
19
- }[]) => string;
20
- /** Pick the preferred media type entry (prefer application/json) */
20
+ variables: import("effect/Option").Option<Record<string, {
21
+ default: string;
22
+ } | string>>;
23
+ };
24
+ export declare const resolveBaseUrl: (servers: readonly ServerLike[]) => string;
25
+ /**
26
+ * Return all declared media entries in spec order. `Object.entries` on a
27
+ * plain object preserves insertion order in modern engines, which matches
28
+ * spec declaration order as the parser produced it.
29
+ */
30
+ export declare const declaredContents: (content: Record<string, MediaTypeObject> | undefined) => ReadonlyArray<{
31
+ mediaType: string;
32
+ media: MediaTypeObject;
33
+ }>;
34
+ /**
35
+ * Pick the default media type for a requestBody or response. Matches
36
+ * swagger-client behaviour: **first declared wins** (not JSON-first). Spec
37
+ * authors order content entries to signal intent (upload-heavy endpoints
38
+ * declare multipart first, JSON second); respecting that order avoids
39
+ * silently downgrading a multipart endpoint to JSON.
40
+ *
41
+ * For response bodies we still want a JSON preference because the server
42
+ * picks the response content type, not the client — the old `application/
43
+ * json` preference is preserved via `preferredResponseContent` below.
44
+ */
21
45
  export declare const preferredContent: (content: Record<string, MediaTypeObject> | undefined) => {
22
46
  mediaType: string;
23
47
  media: MediaTypeObject;
24
48
  } | undefined;
49
+ /** Response-side content picker — still JSON-first because the server
50
+ * picks the response media type, so we want to advertise a preference. */
51
+ export declare const preferredResponseContent: (content: Record<string, MediaTypeObject> | undefined) => {
52
+ mediaType: string;
53
+ media: MediaTypeObject;
54
+ } | undefined;
55
+ export {};
@@ -1,10 +1,34 @@
1
1
  import type { OpenAPIV3, OpenAPIV3_1 } from "openapi-types";
2
2
  import { Effect } from "effect";
3
- import { OpenApiParseError } from "./errors";
3
+ import { HttpClient } from "effect/unstable/http";
4
+ import { OpenApiExtractionError, OpenApiParseError } from "./errors";
4
5
  export type ParsedDocument = OpenAPIV3.Document | OpenAPIV3_1.Document;
5
- /** Parse, validate, and bundle an OpenAPI document from text or URL */
6
- export declare const parse: (input: string) => Effect.Effect<ParsedDocument, OpenApiParseError | OpenApiExtractionErrorFromParse, never>;
7
- import { OpenApiExtractionError } from "./errors";
6
+ export interface SpecFetchCredentials {
7
+ readonly headers?: Record<string, string>;
8
+ readonly queryParams?: Record<string, string>;
9
+ }
8
10
  declare class OpenApiExtractionErrorFromParse extends OpenApiExtractionError {
9
11
  }
12
+ /**
13
+ * Fetch an OpenAPI spec URL and return its body text. Uses the Effect
14
+ * HttpClient so the caller chooses the transport via layer — in Cloudflare
15
+ * Workers, `FetchHttpClient.layer` binds to the Workers-native `fetch` and
16
+ * avoids json-schema-ref-parser's Node-polyfill http resolver, which hangs
17
+ * in production. Bounded by a 20s timeout.
18
+ */
19
+ export declare const fetchSpecText: (url: string, credentials?: SpecFetchCredentials | undefined) => Effect.Effect<string, OpenApiParseError, HttpClient.HttpClient>;
20
+ /**
21
+ * Resolve an input string to spec text — if it's a URL, fetch it via
22
+ * HttpClient; otherwise return it as-is.
23
+ */
24
+ export declare const resolveSpecText: (input: string, credentials?: SpecFetchCredentials) => Effect.Effect<string, OpenApiParseError, HttpClient.HttpClient>;
25
+ /**
26
+ * Parse an OpenAPI document from spec text and validate it's OpenAPI 3.x.
27
+ *
28
+ * NOTE: does NOT resolve `$ref`s. `DocResolver` + `normalizeOpenApiRefs`
29
+ * downstream work on refs lazily, so inlining them here would just waste
30
+ * memory — and for big specs (e.g. Cloudflare's API) that blows through
31
+ * the 128MB Cloudflare Workers memory cap.
32
+ */
33
+ export declare const parse: (text: string) => Effect.Effect<ParsedDocument, OpenApiParseError | OpenApiExtractionErrorFromParse, never>;
10
34
  export {};
@@ -1,40 +1,186 @@
1
1
  import { Effect } from "effect";
2
- import { HttpClient } from "@effect/platform";
2
+ import { HttpClient } from "effect/unstable/http";
3
3
  import type { Layer } from "effect";
4
- import { type ExecutorPlugin } from "@executor-js/sdk";
5
- import type { OpenApiOperationStore, StoredSource } from "./operation-store";
4
+ import { type StorageFailure } from "@executor-js/sdk/core";
5
+ import { type ConfigFileSink } from "@executor-js/config";
6
+ import { OpenApiExtractionError, OpenApiOAuthError, OpenApiParseError } from "./errors";
6
7
  import { SpecPreview } from "./preview";
7
- import { type HeaderValue as HeaderValueValue } from "./types";
8
- /** A header value either a static string or a reference to a secret */
8
+ import { type OpenapiStore, type StoredSource } from "./store";
9
+ import { OAuth2Auth, OAuth2SourceConfig, OpenApiSourceBindingInput, type OpenApiSourceBindingRef, type ConfiguredHeaderValue as ConfiguredHeaderValueValue, type HeaderValue as HeaderValueValue } from "./types";
9
10
  export type HeaderValue = HeaderValueValue;
11
+ export type ConfiguredHeaderValue = ConfiguredHeaderValueValue;
12
+ export type OpenApiHeaderInput = HeaderValue | ConfiguredHeaderValue;
13
+ export type OpenApiOAuthInput = OAuth2Auth | OAuth2SourceConfig;
14
+ export interface OpenApiSpecFetchCredentials {
15
+ readonly headers?: Record<string, HeaderValue>;
16
+ readonly queryParams?: Record<string, HeaderValue>;
17
+ }
18
+ export interface OpenApiPreviewInput {
19
+ readonly spec: string;
20
+ readonly specFetchCredentials?: OpenApiSpecFetchCredentials;
21
+ }
10
22
  export interface OpenApiSpecConfig {
11
23
  readonly spec: string;
24
+ readonly specFetchCredentials?: OpenApiSpecFetchCredentials;
25
+ /**
26
+ * Executor scope id that owns this source row. Must be one of the
27
+ * executor's configured scopes. Typical shape: an admin adds the
28
+ * source at the outermost (organization) scope so it's visible to
29
+ * every inner (per-user) scope via fall-through reads.
30
+ */
31
+ readonly scope: string;
12
32
  readonly name?: string;
13
33
  readonly baseUrl?: string;
14
34
  readonly namespace?: string;
15
- /** Headers applied to every request. Values can reference secrets. */
16
- readonly headers?: Record<string, HeaderValue>;
35
+ readonly headers?: Record<string, OpenApiHeaderInput>;
36
+ readonly queryParams?: Record<string, HeaderValue>;
37
+ readonly oauth2?: OpenApiOAuthInput;
17
38
  }
18
39
  export interface OpenApiUpdateSourceInput {
19
40
  readonly name?: string;
20
41
  readonly baseUrl?: string;
21
- readonly headers?: Record<string, HeaderValue>;
42
+ readonly headers?: Record<string, OpenApiHeaderInput>;
43
+ readonly queryParams?: Record<string, HeaderValue>;
44
+ /** Refresh the source's stored OAuth2 metadata after a successful
45
+ * re-authenticate. */
46
+ readonly oauth2?: OpenApiOAuthInput;
22
47
  }
48
+ /**
49
+ * Errors any OpenAPI extension method may surface. The first three are
50
+ * plugin-domain tagged errors that flow directly to clients (4xx, each
51
+ * carrying its own `HttpApiSchema` status). `StorageFailure` covers
52
+ * raw backend failures (`StorageError`) plus `UniqueViolationError`;
53
+ * the HTTP edge (`@executor-js/api`'s `withCapture`) translates
54
+ * `StorageError` to the opaque `InternalError({ traceId })` at Layer
55
+ * composition. `UniqueViolationError` passes through — plugins can
56
+ * `Effect.catchTag` it if they want a friendlier user-facing error.
57
+ */
58
+ export type OpenApiExtensionFailure = OpenApiParseError | OpenApiExtractionError | OpenApiOAuthError | StorageFailure;
23
59
  export interface OpenApiPluginExtension {
24
- /** Preview a spec without registering returns metadata, auth strategies, header presets */
25
- readonly previewSpec: (specText: string) => Effect.Effect<SpecPreview, Error>;
26
- /** Add an OpenAPI spec and register its operations as tools */
60
+ readonly previewSpec: (input: string | OpenApiPreviewInput) => Effect.Effect<SpecPreview, OpenApiParseError | OpenApiExtractionError | OpenApiOAuthError | StorageFailure>;
27
61
  readonly addSpec: (config: OpenApiSpecConfig) => Effect.Effect<{
62
+ readonly sourceId: string;
28
63
  readonly toolCount: number;
29
- }, Error>;
30
- /** Remove all tools from a previously added spec by namespace */
31
- readonly removeSpec: (namespace: string) => Effect.Effect<void>;
32
- /** Fetch the full stored source by namespace (or null if missing) */
33
- readonly getSource: (namespace: string) => Effect.Effect<StoredSource | null>;
34
- /** Update config (baseUrl, headers) for an existing OpenAPI source */
35
- readonly updateSource: (namespace: string, input: OpenApiUpdateSourceInput) => Effect.Effect<void>;
64
+ }, OpenApiParseError | OpenApiExtractionError | OpenApiOAuthError | StorageFailure>;
65
+ readonly removeSpec: (namespace: string, scope: string) => Effect.Effect<void, StorageFailure>;
66
+ readonly getSource: (namespace: string, scope: string) => Effect.Effect<StoredSource | null, StorageFailure>;
67
+ readonly updateSource: (namespace: string, scope: string, input: OpenApiUpdateSourceInput) => Effect.Effect<void, StorageFailure>;
68
+ readonly listSourceBindings: (sourceId: string, sourceScope: string) => Effect.Effect<readonly OpenApiSourceBindingRef[], StorageFailure>;
69
+ readonly setSourceBinding: (input: OpenApiSourceBindingInput) => Effect.Effect<OpenApiSourceBindingRef, StorageFailure>;
70
+ readonly removeSourceBinding: (sourceId: string, sourceScope: string, slot: string, scope: string) => Effect.Effect<void, StorageFailure>;
71
+ }
72
+ export interface OpenApiPluginOptions {
73
+ readonly httpClientLayer?: Layer.Layer<HttpClient.HttpClient, never, never>;
74
+ /** If provided, source add/remove is mirrored to executor.jsonc
75
+ * (best-effort — file errors are logged, not raised). */
76
+ readonly configFile?: ConfigFileSink;
36
77
  }
37
- export declare const openApiPlugin: (options?: {
38
- readonly httpClientLayer?: Layer.Layer<HttpClient.HttpClient>;
39
- readonly operationStore?: OpenApiOperationStore;
40
- }) => ExecutorPlugin<"openapi", OpenApiPluginExtension>;
78
+ export declare const openApiPlugin: import("@executor-js/sdk/core").ConfiguredPlugin<"openapi", OpenApiPluginExtension, OpenapiStore, OpenApiPluginOptions, {
79
+ readonly openapi_source: {
80
+ readonly fields: {
81
+ readonly id: {
82
+ readonly type: "string";
83
+ readonly required: true;
84
+ };
85
+ readonly scope_id: {
86
+ readonly type: "string";
87
+ readonly required: true;
88
+ readonly index: true;
89
+ };
90
+ readonly name: {
91
+ readonly type: "string";
92
+ readonly required: true;
93
+ };
94
+ readonly spec: {
95
+ readonly type: "string";
96
+ readonly required: true;
97
+ };
98
+ readonly source_url: {
99
+ readonly type: "string";
100
+ readonly required: false;
101
+ };
102
+ readonly base_url: {
103
+ readonly type: "string";
104
+ readonly required: false;
105
+ };
106
+ readonly headers: {
107
+ readonly type: "json";
108
+ readonly required: false;
109
+ };
110
+ readonly query_params: {
111
+ readonly type: "json";
112
+ readonly required: false;
113
+ };
114
+ readonly oauth2: {
115
+ readonly type: "json";
116
+ readonly required: false;
117
+ };
118
+ readonly invocation_config: {
119
+ readonly type: "json";
120
+ readonly required: true;
121
+ };
122
+ };
123
+ };
124
+ readonly openapi_operation: {
125
+ readonly fields: {
126
+ readonly id: {
127
+ readonly type: "string";
128
+ readonly required: true;
129
+ };
130
+ readonly scope_id: {
131
+ readonly type: "string";
132
+ readonly required: true;
133
+ readonly index: true;
134
+ };
135
+ readonly source_id: {
136
+ readonly type: "string";
137
+ readonly required: true;
138
+ readonly index: true;
139
+ };
140
+ readonly binding: {
141
+ readonly type: "json";
142
+ readonly required: true;
143
+ };
144
+ };
145
+ };
146
+ readonly openapi_source_binding: {
147
+ readonly fields: {
148
+ readonly id: {
149
+ readonly type: "string";
150
+ readonly required: true;
151
+ };
152
+ readonly source_id: {
153
+ readonly type: "string";
154
+ readonly required: true;
155
+ readonly index: true;
156
+ };
157
+ readonly source_scope_id: {
158
+ readonly type: "string";
159
+ readonly required: true;
160
+ readonly index: true;
161
+ };
162
+ readonly target_scope_id: {
163
+ readonly type: "string";
164
+ readonly required: true;
165
+ readonly index: true;
166
+ };
167
+ readonly slot: {
168
+ readonly type: "string";
169
+ readonly required: true;
170
+ readonly index: true;
171
+ };
172
+ readonly value: {
173
+ readonly type: "json";
174
+ readonly required: true;
175
+ };
176
+ readonly created_at: {
177
+ readonly type: "date";
178
+ readonly required: true;
179
+ };
180
+ readonly updated_at: {
181
+ readonly type: "date";
182
+ readonly required: true;
183
+ };
184
+ };
185
+ };
186
+ }>;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,187 +1,112 @@
1
- import { Effect, Option } from "effect";
1
+ import { Effect } from "effect";
2
2
  import { Schema } from "effect";
3
- declare const SecurityScheme_base: Schema.Class<SecurityScheme, {
4
- /** Key name in components.securitySchemes (e.g. "api_token") */
5
- name: typeof Schema.String;
6
- /** OpenAPI security scheme type */
7
- type: Schema.Literal<["http", "apiKey", "oauth2", "openIdConnect"]>;
8
- /** For type: "http" — e.g. "bearer", "basic" */
9
- scheme: Schema.optionalWith<typeof Schema.String, {
10
- as: "Option";
11
- }>;
12
- /** For type: "apiKey" — where the key goes */
13
- in: Schema.optionalWith<Schema.Literal<["header", "query", "cookie"]>, {
14
- as: "Option";
15
- }>;
16
- /** For type: "apiKey" — the header/query/cookie name */
17
- headerName: Schema.optionalWith<typeof Schema.String, {
18
- as: "Option";
19
- }>;
20
- description: Schema.optionalWith<typeof Schema.String, {
21
- as: "Option";
22
- }>;
23
- }, Schema.Struct.Encoded<{
3
+ import { ServerInfo } from "./types";
4
+ declare const OAuth2AuthorizationCodeFlow_base: Schema.Class<OAuth2AuthorizationCodeFlow, Schema.Struct<{
5
+ readonly authorizationUrl: Schema.String;
6
+ readonly tokenUrl: Schema.String;
7
+ readonly refreshUrl: Schema.OptionFromOptional<Schema.String>;
8
+ readonly scopes: Schema.$Record<Schema.String, Schema.String>;
9
+ }>, {}>;
10
+ export declare class OAuth2AuthorizationCodeFlow extends OAuth2AuthorizationCodeFlow_base {
11
+ }
12
+ declare const OAuth2ClientCredentialsFlow_base: Schema.Class<OAuth2ClientCredentialsFlow, Schema.Struct<{
13
+ readonly tokenUrl: Schema.String;
14
+ readonly refreshUrl: Schema.OptionFromOptional<Schema.String>;
15
+ readonly scopes: Schema.$Record<Schema.String, Schema.String>;
16
+ }>, {}>;
17
+ export declare class OAuth2ClientCredentialsFlow extends OAuth2ClientCredentialsFlow_base {
18
+ }
19
+ declare const OAuth2Flows_base: Schema.Class<OAuth2Flows, Schema.Struct<{
20
+ readonly authorizationCode: Schema.OptionFromOptional<typeof OAuth2AuthorizationCodeFlow>;
21
+ readonly clientCredentials: Schema.OptionFromOptional<typeof OAuth2ClientCredentialsFlow>;
22
+ }>, {}>;
23
+ export declare class OAuth2Flows extends OAuth2Flows_base {
24
+ }
25
+ declare const SecurityScheme_base: Schema.Class<SecurityScheme, Schema.Struct<{
24
26
  /** Key name in components.securitySchemes (e.g. "api_token") */
25
- name: typeof Schema.String;
27
+ readonly name: Schema.String;
26
28
  /** OpenAPI security scheme type */
27
- type: Schema.Literal<["http", "apiKey", "oauth2", "openIdConnect"]>;
29
+ readonly type: Schema.Literals<readonly ["http", "apiKey", "oauth2", "openIdConnect"]>;
28
30
  /** For type: "http" — e.g. "bearer", "basic" */
29
- scheme: Schema.optionalWith<typeof Schema.String, {
30
- as: "Option";
31
- }>;
31
+ readonly scheme: Schema.OptionFromOptional<Schema.String>;
32
+ /** For type: "http" with scheme "bearer" — e.g. "JWT" */
33
+ readonly bearerFormat: Schema.OptionFromOptional<Schema.String>;
32
34
  /** For type: "apiKey" — where the key goes */
33
- in: Schema.optionalWith<Schema.Literal<["header", "query", "cookie"]>, {
34
- as: "Option";
35
- }>;
35
+ readonly in: Schema.OptionFromOptional<Schema.Literals<readonly ["header", "query", "cookie"]>>;
36
36
  /** For type: "apiKey" — the header/query/cookie name */
37
- headerName: Schema.optionalWith<typeof Schema.String, {
38
- as: "Option";
39
- }>;
40
- description: Schema.optionalWith<typeof Schema.String, {
41
- as: "Option";
42
- }>;
43
- }>, never, {
44
- readonly name: string;
45
- } & {
46
- readonly description: Option.Option<string>;
47
- } & {
48
- readonly type: "http" | "apiKey" | "oauth2" | "openIdConnect";
49
- } & {
50
- readonly scheme: Option.Option<string>;
51
- } & {
52
- readonly in: Option.Option<"query" | "header" | "cookie">;
53
- } & {
54
- readonly headerName: Option.Option<string>;
55
- }, {}, {}>;
37
+ readonly headerName: Schema.OptionFromOptional<Schema.String>;
38
+ readonly description: Schema.OptionFromOptional<Schema.String>;
39
+ /** For type: "oauth2" — declared flows (authorizationCode / clientCredentials only; implicit and password are deprecated). */
40
+ readonly flows: Schema.OptionFromOptional<typeof OAuth2Flows>;
41
+ /** For type: "openIdConnect" — the discovery URL. */
42
+ readonly openIdConnectUrl: Schema.OptionFromOptional<Schema.String>;
43
+ }>, {}>;
56
44
  export declare class SecurityScheme extends SecurityScheme_base {
57
45
  }
58
- declare const AuthStrategy_base: Schema.Class<AuthStrategy, {
59
- /** The security schemes required together for this strategy */
60
- schemes: Schema.Array$<typeof Schema.String>;
61
- }, Schema.Struct.Encoded<{
46
+ declare const AuthStrategy_base: Schema.Class<AuthStrategy, Schema.Struct<{
62
47
  /** The security schemes required together for this strategy */
63
- schemes: Schema.Array$<typeof Schema.String>;
64
- }>, never, {
65
- readonly schemes: readonly string[];
66
- }, {}, {}>;
48
+ readonly schemes: Schema.$Array<Schema.String>;
49
+ }>, {}>;
67
50
  export declare class AuthStrategy extends AuthStrategy_base {
68
51
  }
69
- declare const HeaderPreset_base: Schema.Class<HeaderPreset, {
52
+ declare const HeaderPreset_base: Schema.Class<HeaderPreset, Schema.Struct<{
70
53
  /** Human-readable label for the UI (e.g. "Bearer Token", "API Key + Email") */
71
- label: typeof Schema.String;
54
+ readonly label: Schema.String;
72
55
  /** Headers this strategy needs. Value is null when the user must provide it. */
73
- headers: Schema.Record$<typeof Schema.String, Schema.NullOr<typeof Schema.String>>;
56
+ readonly headers: Schema.$Record<Schema.String, Schema.NullOr<Schema.String>>;
74
57
  /** Which headers should be stored as secrets */
75
- secretHeaders: Schema.Array$<typeof Schema.String>;
76
- }, Schema.Struct.Encoded<{
77
- /** Human-readable label for the UI (e.g. "Bearer Token", "API Key + Email") */
78
- label: typeof Schema.String;
79
- /** Headers this strategy needs. Value is null when the user must provide it. */
80
- headers: Schema.Record$<typeof Schema.String, Schema.NullOr<typeof Schema.String>>;
81
- /** Which headers should be stored as secrets */
82
- secretHeaders: Schema.Array$<typeof Schema.String>;
83
- }>, never, {
84
- readonly headers: {
85
- readonly [x: string]: string | null;
86
- };
87
- } & {
88
- readonly label: string;
89
- } & {
90
- readonly secretHeaders: readonly string[];
91
- }, {}, {}>;
58
+ readonly secretHeaders: Schema.$Array<Schema.String>;
59
+ }>, {}>;
92
60
  export declare class HeaderPreset extends HeaderPreset_base {
93
61
  }
94
- declare const PreviewOperation_base: Schema.Class<PreviewOperation, {
95
- operationId: typeof Schema.String;
96
- method: Schema.Literal<["get", "put", "post", "delete", "patch", "head", "options", "trace"]>;
97
- path: typeof Schema.String;
98
- summary: Schema.optionalWith<typeof Schema.String, {
99
- as: "Option";
100
- }>;
101
- tags: Schema.Array$<typeof Schema.String>;
102
- deprecated: typeof Schema.Boolean;
103
- }, Schema.Struct.Encoded<{
104
- operationId: typeof Schema.String;
105
- method: Schema.Literal<["get", "put", "post", "delete", "patch", "head", "options", "trace"]>;
106
- path: typeof Schema.String;
107
- summary: Schema.optionalWith<typeof Schema.String, {
108
- as: "Option";
109
- }>;
110
- tags: Schema.Array$<typeof Schema.String>;
111
- deprecated: typeof Schema.Boolean;
112
- }>, never, {
113
- readonly tags: readonly string[];
114
- } & {
115
- readonly summary: Option.Option<string>;
116
- } & {
117
- readonly operationId: string;
118
- } & {
119
- readonly deprecated: boolean;
120
- } & {
121
- readonly path: string;
122
- } & {
123
- readonly method: "delete" | "get" | "put" | "post" | "options" | "head" | "patch" | "trace";
124
- }, {}, {}>;
62
+ declare const OAuth2Preset_base: Schema.Class<OAuth2Preset, Schema.Struct<{
63
+ /** Human-readable label for the UI (e.g. "OAuth2 (Authorization Code) — oauth_app") */
64
+ readonly label: Schema.String;
65
+ /** The source security scheme this preset came from (components.securitySchemes key). */
66
+ readonly securitySchemeName: Schema.String;
67
+ /** Which OAuth2 flow this preset uses. */
68
+ readonly flow: Schema.Literals<readonly ["authorizationCode", "clientCredentials"]>;
69
+ /** For authorizationCode: user-agent redirect URL (from the spec). */
70
+ readonly authorizationUrl: Schema.OptionFromOptional<Schema.String>;
71
+ /** Token endpoint to exchange the code / refresh. */
72
+ readonly tokenUrl: Schema.String;
73
+ /** Optional refresh endpoint if the spec declares one separately. */
74
+ readonly refreshUrl: Schema.OptionFromOptional<Schema.String>;
75
+ /** Declared scopes for this flow: `{ scope: description }`. */
76
+ readonly scopes: Schema.$Record<Schema.String, Schema.String>;
77
+ }>, {}>;
78
+ export declare class OAuth2Preset extends OAuth2Preset_base {
79
+ }
80
+ declare const PreviewOperation_base: Schema.Class<PreviewOperation, Schema.Struct<{
81
+ readonly operationId: Schema.String;
82
+ readonly method: Schema.Literals<readonly ["get", "put", "post", "delete", "patch", "head", "options", "trace"]>;
83
+ readonly path: Schema.String;
84
+ readonly summary: Schema.OptionFromOptional<Schema.String>;
85
+ readonly tags: Schema.$Array<Schema.String>;
86
+ readonly deprecated: Schema.Boolean;
87
+ }>, {}>;
125
88
  export declare class PreviewOperation extends PreviewOperation_base {
126
89
  }
127
- declare const SpecPreview_base: Schema.Class<SpecPreview, {
128
- title: Schema.optionalWith<typeof Schema.String, {
129
- as: "Option";
130
- }>;
131
- version: Schema.optionalWith<typeof Schema.String, {
132
- as: "Option";
133
- }>;
134
- /** Reuses ServerInfo from extraction */
135
- servers: Schema.Array$<typeof Schema.Unknown>;
136
- operationCount: typeof Schema.Number;
137
- /** Lightweight operation list for the add-source UI */
138
- operations: Schema.Array$<typeof PreviewOperation>;
139
- tags: Schema.Array$<typeof Schema.String>;
140
- securitySchemes: Schema.Array$<typeof SecurityScheme>;
141
- /** Valid auth strategies (each is a set of schemes used together) */
142
- authStrategies: Schema.Array$<typeof AuthStrategy>;
143
- /** Pre-built header presets derived from auth strategies */
144
- headerPresets: Schema.Array$<typeof HeaderPreset>;
145
- }, Schema.Struct.Encoded<{
146
- title: Schema.optionalWith<typeof Schema.String, {
147
- as: "Option";
148
- }>;
149
- version: Schema.optionalWith<typeof Schema.String, {
150
- as: "Option";
151
- }>;
90
+ declare const SpecPreview_base: Schema.Class<SpecPreview, Schema.Struct<{
91
+ readonly title: Schema.OptionFromOptional<Schema.String>;
92
+ readonly version: Schema.OptionFromOptional<Schema.String>;
152
93
  /** Reuses ServerInfo from extraction */
153
- servers: Schema.Array$<typeof Schema.Unknown>;
154
- operationCount: typeof Schema.Number;
94
+ readonly servers: Schema.$Array<typeof ServerInfo>;
95
+ readonly operationCount: Schema.Number;
155
96
  /** Lightweight operation list for the add-source UI */
156
- operations: Schema.Array$<typeof PreviewOperation>;
157
- tags: Schema.Array$<typeof Schema.String>;
158
- securitySchemes: Schema.Array$<typeof SecurityScheme>;
97
+ readonly operations: Schema.$Array<typeof PreviewOperation>;
98
+ readonly tags: Schema.$Array<Schema.String>;
99
+ readonly securitySchemes: Schema.$Array<typeof SecurityScheme>;
159
100
  /** Valid auth strategies (each is a set of schemes used together) */
160
- authStrategies: Schema.Array$<typeof AuthStrategy>;
101
+ readonly authStrategies: Schema.$Array<typeof AuthStrategy>;
161
102
  /** Pre-built header presets derived from auth strategies */
162
- headerPresets: Schema.Array$<typeof HeaderPreset>;
163
- }>, never, {
164
- readonly title: Option.Option<string>;
165
- } & {
166
- readonly servers: readonly unknown[];
167
- } & {
168
- readonly tags: readonly string[];
169
- } & {
170
- readonly version: Option.Option<string>;
171
- } & {
172
- readonly securitySchemes: readonly SecurityScheme[];
173
- } & {
174
- readonly operations: readonly PreviewOperation[];
175
- } & {
176
- readonly operationCount: number;
177
- } & {
178
- readonly authStrategies: readonly AuthStrategy[];
179
- } & {
180
- readonly headerPresets: readonly HeaderPreset[];
181
- }, {}, {}>;
103
+ readonly headerPresets: Schema.$Array<typeof HeaderPreset>;
104
+ /** OAuth2 presets — one per (oauth2 scheme × supported flow) combination */
105
+ readonly oauth2Presets: Schema.$Array<typeof OAuth2Preset>;
106
+ }>, {}>;
182
107
  export declare class SpecPreview extends SpecPreview_base {
183
108
  }
184
109
  /** Preview an OpenAPI spec — extract metadata without registering anything.
185
- * Reuses parse() + extract() for the heavy lifting. */
186
- export declare const previewSpec: (specText: string) => Effect.Effect<SpecPreview, import("./errors").OpenApiParseError | import("./errors").OpenApiExtractionError, never>;
110
+ * Accepts either a URL or raw JSON/YAML text. */
111
+ export declare const previewSpec: (input: string) => Effect.Effect<SpecPreview, import("./errors").OpenApiParseError | import("./errors").OpenApiExtractionError, import("effect/unstable/http/HttpClient").HttpClient>;
187
112
  export {};