@rafads/plugin-openapi 1.5.38
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/README.md +83 -0
- package/dist/AddOpenApiIntegration-JPAEXE56.js +512 -0
- package/dist/AddOpenApiIntegration-JPAEXE56.js.map +1 -0
- package/dist/OpenApiAccountsPanel-GZFDSTAU.js +106 -0
- package/dist/OpenApiAccountsPanel-GZFDSTAU.js.map +1 -0
- package/dist/UpdateSpecSection-KUSNI44Q.js +106 -0
- package/dist/UpdateSpecSection-KUSNI44Q.js.map +1 -0
- package/dist/api/group.d.ts +239 -0
- package/dist/api/handlers.d.ts +7 -0
- package/dist/api/index.d.ts +237 -0
- package/dist/chunk-6V45G2XQ.js +199 -0
- package/dist/chunk-6V45G2XQ.js.map +1 -0
- package/dist/chunk-CURJJXB3.js +132 -0
- package/dist/chunk-CURJJXB3.js.map +1 -0
- package/dist/chunk-CXFO6TLJ.js +39 -0
- package/dist/chunk-CXFO6TLJ.js.map +1 -0
- package/dist/chunk-HTHEUUJA.js +2873 -0
- package/dist/chunk-HTHEUUJA.js.map +1 -0
- package/dist/chunk-IG6QTTZB.js +79 -0
- package/dist/chunk-IG6QTTZB.js.map +1 -0
- package/dist/chunk-O2LMSZ2Z.js +120 -0
- package/dist/chunk-O2LMSZ2Z.js.map +1 -0
- package/dist/chunk-OR27BCXQ.js +956 -0
- package/dist/chunk-OR27BCXQ.js.map +1 -0
- package/dist/chunk-R7TVM3XD.js +275 -0
- package/dist/chunk-R7TVM3XD.js.map +1 -0
- package/dist/client.js +38 -0
- package/dist/client.js.map +1 -0
- package/dist/core.js +331 -0
- package/dist/core.js.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/google/config.d.ts +34 -0
- package/dist/providers/google/discovery.d.ts +49 -0
- package/dist/providers/google/discovery.test.d.ts +1 -0
- package/dist/providers/google/index.d.ts +5 -0
- package/dist/providers/google/oauth-scopes.d.ts +3 -0
- package/dist/providers/google/oauth-scopes.test.d.ts +1 -0
- package/dist/providers/google/openapi-ownership-migration.d.ts +7 -0
- package/dist/providers/google/openapi-ownership-migration.test.d.ts +1 -0
- package/dist/providers/google/presets.d.ts +31 -0
- package/dist/providers/google/presets.test.d.ts +1 -0
- package/dist/providers/google/spec-format-adapter.d.ts +3 -0
- package/dist/providers/google/spec-format-adapter.test.d.ts +1 -0
- package/dist/providers/google.js +1446 -0
- package/dist/providers/google.js.map +1 -0
- package/dist/providers/microsoft/graph.d.ts +76 -0
- package/dist/providers/microsoft/graph.test.d.ts +1 -0
- package/dist/providers/microsoft/index.d.ts +3 -0
- package/dist/providers/microsoft/presets.d.ts +46 -0
- package/dist/providers/microsoft/presets.test.d.ts +1 -0
- package/dist/providers/microsoft/spec-format-adapter.d.ts +2 -0
- package/dist/providers/microsoft/spec-format-adapter.test.d.ts +1 -0
- package/dist/providers/microsoft.js +1056 -0
- package/dist/providers/microsoft.js.map +1 -0
- package/dist/react/AddOpenApiIntegration.d.ts +22 -0
- package/dist/react/AddOpenApiIntegration.test.d.ts +1 -0
- package/dist/react/OpenApiAccountsPanel.d.ts +6 -0
- package/dist/react/OpenApiIntegrationDetailsFields.d.ts +25 -0
- package/dist/react/UpdateSpecSection.d.ts +2 -0
- package/dist/react/atoms.d.ts +317 -0
- package/dist/react/auth-method-config.d.ts +18 -0
- package/dist/react/auth-method-config.test.d.ts +1 -0
- package/dist/react/client.d.ts +233 -0
- package/dist/react/index.d.ts +5 -0
- package/dist/react/integration-plugin.d.ts +6 -0
- package/dist/react/plugin-client.d.ts +2 -0
- package/dist/sdk/backing.d.ts +188 -0
- package/dist/sdk/client-credentials-oauth.test.d.ts +1 -0
- package/dist/sdk/compiled-spec-cache.test.d.ts +1 -0
- package/dist/sdk/config.d.ts +81 -0
- package/dist/sdk/configure.test.d.ts +1 -0
- package/dist/sdk/definitions.d.ts +57 -0
- package/dist/sdk/derive-auth.d.ts +11 -0
- package/dist/sdk/describe-auth-methods.test.d.ts +1 -0
- package/dist/sdk/errors.d.ts +45 -0
- package/dist/sdk/extract.d.ts +157 -0
- package/dist/sdk/extract.test.d.ts +1 -0
- package/dist/sdk/form-urlencoded-body.test.d.ts +1 -0
- package/dist/sdk/index.d.ts +19 -0
- package/dist/sdk/index.test.d.ts +1 -0
- package/dist/sdk/invoke.d.ts +150 -0
- package/dist/sdk/migrate-config.d.ts +4 -0
- package/dist/sdk/migrate-config.test.d.ts +1 -0
- package/dist/sdk/multi-scope-bearer.test.d.ts +1 -0
- package/dist/sdk/multi-scope-oauth.test.d.ts +1 -0
- package/dist/sdk/ndjson-output-migration.d.ts +13 -0
- package/dist/sdk/ndjson-output-migration.test.d.ts +1 -0
- package/dist/sdk/non-json-body.test.d.ts +1 -0
- package/dist/sdk/oauth-refresh.test.d.ts +1 -0
- package/dist/sdk/openapi-utils.d.ts +65 -0
- package/dist/sdk/output-schema-migration.d.ts +21 -0
- package/dist/sdk/output-schema-migration.test.d.ts +1 -0
- package/dist/sdk/parse.d.ts +33 -0
- package/dist/sdk/parse.test.d.ts +1 -0
- package/dist/sdk/plugin.d.ts +109 -0
- package/dist/sdk/plugin.test.d.ts +1 -0
- package/dist/sdk/presets.d.ts +15 -0
- package/dist/sdk/preview-oauth2.test.d.ts +1 -0
- package/dist/sdk/preview.d.ts +514 -0
- package/dist/sdk/query-serialization.test.d.ts +1 -0
- package/dist/sdk/real-specs.test.d.ts +1 -0
- package/dist/sdk/request-user-agent.test.d.ts +1 -0
- package/dist/sdk/response-headers-timeout.test.d.ts +1 -0
- package/dist/sdk/server-url-resolution.test.d.ts +1 -0
- package/dist/sdk/spec-blob-migration.d.ts +7 -0
- package/dist/sdk/spec-blob.test.d.ts +1 -0
- package/dist/sdk/spec-format.d.ts +36 -0
- package/dist/sdk/spec-format.test.d.ts +1 -0
- package/dist/sdk/split.d.ts +84 -0
- package/dist/sdk/store.d.ts +49 -0
- package/dist/sdk/store.test.d.ts +1 -0
- package/dist/sdk/streaming-response.test.d.ts +1 -0
- package/dist/sdk/tool-row-projection.test.d.ts +1 -0
- package/dist/sdk/types.d.ts +352 -0
- package/dist/sdk/upstream-failures.test.d.ts +1 -0
- package/dist/sdk/usage-scope-isolation.test.d.ts +1 -0
- package/dist/testing/index.d.ts +177 -0
- package/dist/testing.js +454 -0
- package/dist/testing.js.map +1 -0
- package/dist/testing.test.d.ts +1 -0
- package/package.json +103 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import type { Option } from "effect";
|
|
3
|
+
import type { AuthToolFailureCode } from "@rafads/sdk/core";
|
|
4
|
+
declare const OpenApiParseError_base: Schema.Class<OpenApiParseError, Schema.TaggedStruct<"OpenApiParseError", {
|
|
5
|
+
readonly message: Schema.String;
|
|
6
|
+
}>, import("effect/Cause").YieldableError>;
|
|
7
|
+
export declare class OpenApiParseError extends OpenApiParseError_base {
|
|
8
|
+
}
|
|
9
|
+
declare const OpenApiExtractionError_base: Schema.Class<OpenApiExtractionError, Schema.TaggedStruct<"OpenApiExtractionError", {
|
|
10
|
+
readonly message: Schema.String;
|
|
11
|
+
}>, import("effect/Cause").YieldableError>;
|
|
12
|
+
export declare class OpenApiExtractionError extends OpenApiExtractionError_base {
|
|
13
|
+
}
|
|
14
|
+
declare const OpenApiInvocationError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
15
|
+
readonly _tag: "OpenApiInvocationError";
|
|
16
|
+
} & Readonly<A>;
|
|
17
|
+
export declare class OpenApiInvocationError extends OpenApiInvocationError_base<{
|
|
18
|
+
readonly message: string;
|
|
19
|
+
readonly statusCode: Option.Option<number>;
|
|
20
|
+
readonly reason?: "response_headers_timeout" | "unknown_arguments";
|
|
21
|
+
readonly cause?: unknown;
|
|
22
|
+
}> {
|
|
23
|
+
}
|
|
24
|
+
declare const OpenApiOAuthError_base: Schema.Class<OpenApiOAuthError, Schema.TaggedStruct<"OpenApiOAuthError", {
|
|
25
|
+
readonly message: Schema.String;
|
|
26
|
+
}>, import("effect/Cause").YieldableError>;
|
|
27
|
+
export declare class OpenApiOAuthError extends OpenApiOAuthError_base {
|
|
28
|
+
}
|
|
29
|
+
declare const OpenApiAuthRequiredError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
30
|
+
readonly _tag: "OpenApiAuthRequiredError";
|
|
31
|
+
} & Readonly<A>;
|
|
32
|
+
export declare class OpenApiAuthRequiredError extends OpenApiAuthRequiredError_base<{
|
|
33
|
+
readonly code: AuthToolFailureCode;
|
|
34
|
+
readonly message: string;
|
|
35
|
+
readonly owner: "org" | "user";
|
|
36
|
+
readonly integration: string;
|
|
37
|
+
readonly connection: string;
|
|
38
|
+
readonly credentialKind: "secret" | "oauth" | "upstream";
|
|
39
|
+
readonly credentialLabel?: string;
|
|
40
|
+
readonly status?: number;
|
|
41
|
+
readonly details?: unknown;
|
|
42
|
+
readonly cause?: unknown;
|
|
43
|
+
}> {
|
|
44
|
+
}
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { Effect, Option } from "effect";
|
|
2
|
+
import { OpenApiExtractionError } from "./errors";
|
|
3
|
+
import type { ParsedDocument } from "./parse";
|
|
4
|
+
import { type KeepPathItem, type SpecStructure } from "./split";
|
|
5
|
+
import { OperationBinding, OperationParameter, OperationRequestBody, OperationResponseBody, ServerInfo } from "./types";
|
|
6
|
+
/**
|
|
7
|
+
* Derive an operation's output schema from its response body. NDJSON bodies
|
|
8
|
+
* (`application/stream+json` and friends) are spec'd per LINE but returned by
|
|
9
|
+
* the invoke path as an array of parsed lines, so the advertised schema wraps
|
|
10
|
+
* the line schema in an array; otherwise describe previews promise a single
|
|
11
|
+
* object that invocations never return. Used by both the whole-tree extract
|
|
12
|
+
* and the serve path's stored-binding rebuild so the two stay in lockstep.
|
|
13
|
+
*/
|
|
14
|
+
export declare const outputSchemaFromResponseBody: (responseBody: OperationResponseBody) => unknown | undefined;
|
|
15
|
+
export declare const buildInputSchema: (parameters: readonly OperationParameter[], requestBody: OperationRequestBody | undefined, servers: readonly ServerInfo[]) => Record<string, unknown> | undefined;
|
|
16
|
+
/** Extract all operations from a bundled OpenAPI 3.x document */
|
|
17
|
+
export declare const extract: (doc: ParsedDocument) => Effect.Effect<{
|
|
18
|
+
readonly version: Option.Option<string>;
|
|
19
|
+
readonly operations: readonly {
|
|
20
|
+
readonly description: Option.Option<string>;
|
|
21
|
+
readonly summary: Option.Option<string>;
|
|
22
|
+
readonly parameters: readonly {
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly required: boolean;
|
|
25
|
+
readonly description: Option.Option<string>;
|
|
26
|
+
readonly location: "path" | "header" | "query" | "cookie";
|
|
27
|
+
readonly schema: Option.Option<unknown>;
|
|
28
|
+
readonly style: Option.Option<string>;
|
|
29
|
+
readonly explode: Option.Option<boolean>;
|
|
30
|
+
readonly allowReserved: Option.Option<boolean>;
|
|
31
|
+
}[];
|
|
32
|
+
readonly method: "post" | "options" | "get" | "delete" | "put" | "patch" | "head" | "trace";
|
|
33
|
+
readonly inputSchema: Option.Option<unknown>;
|
|
34
|
+
readonly outputSchema: Option.Option<unknown>;
|
|
35
|
+
readonly deprecated: boolean;
|
|
36
|
+
readonly toolPath: Option.Option<string>;
|
|
37
|
+
readonly servers: readonly {
|
|
38
|
+
readonly description: Option.Option<string>;
|
|
39
|
+
readonly url: string;
|
|
40
|
+
readonly variables: Option.Option<{
|
|
41
|
+
readonly [x: string]: {
|
|
42
|
+
readonly default: string;
|
|
43
|
+
readonly description: Option.Option<string>;
|
|
44
|
+
readonly enum: Option.Option<readonly string[]>;
|
|
45
|
+
};
|
|
46
|
+
}>;
|
|
47
|
+
}[];
|
|
48
|
+
readonly tags: readonly string[];
|
|
49
|
+
readonly requestBody: Option.Option<{
|
|
50
|
+
readonly required: boolean;
|
|
51
|
+
readonly schema: Option.Option<unknown>;
|
|
52
|
+
readonly contentType: string;
|
|
53
|
+
readonly contents: Option.Option<readonly {
|
|
54
|
+
readonly schema: Option.Option<unknown>;
|
|
55
|
+
readonly encoding: Option.Option<{
|
|
56
|
+
readonly [x: string]: {
|
|
57
|
+
readonly style: Option.Option<string>;
|
|
58
|
+
readonly contentType: Option.Option<string>;
|
|
59
|
+
readonly explode: Option.Option<boolean>;
|
|
60
|
+
readonly allowReserved: Option.Option<boolean>;
|
|
61
|
+
};
|
|
62
|
+
}>;
|
|
63
|
+
readonly contentType: string;
|
|
64
|
+
}[]>;
|
|
65
|
+
}>;
|
|
66
|
+
readonly responseBody: Option.Option<{
|
|
67
|
+
readonly schema: Option.Option<unknown>;
|
|
68
|
+
readonly contentType: string;
|
|
69
|
+
readonly fileHint: Option.Option<{
|
|
70
|
+
readonly kind: "binaryResponse" | "byteField";
|
|
71
|
+
readonly encoding: Option.Option<"base64" | "base64url">;
|
|
72
|
+
readonly mimeType: Option.Option<string>;
|
|
73
|
+
readonly dataField: Option.Option<string>;
|
|
74
|
+
readonly sizeField: Option.Option<string>;
|
|
75
|
+
}>;
|
|
76
|
+
}>;
|
|
77
|
+
readonly operationId: string & import("effect/Brand").Brand<"OperationId">;
|
|
78
|
+
readonly pathTemplate: string;
|
|
79
|
+
readonly requiredScopeAlternatives?: readonly (readonly string[])[] | undefined;
|
|
80
|
+
}[];
|
|
81
|
+
readonly description: Option.Option<string>;
|
|
82
|
+
readonly title: Option.Option<string>;
|
|
83
|
+
readonly servers: readonly {
|
|
84
|
+
readonly description: Option.Option<string>;
|
|
85
|
+
readonly url: string;
|
|
86
|
+
readonly variables: Option.Option<{
|
|
87
|
+
readonly [x: string]: {
|
|
88
|
+
readonly default: string;
|
|
89
|
+
readonly description: Option.Option<string>;
|
|
90
|
+
readonly enum: Option.Option<readonly string[]>;
|
|
91
|
+
};
|
|
92
|
+
}>;
|
|
93
|
+
}[];
|
|
94
|
+
}, OpenApiExtractionError, never>;
|
|
95
|
+
/** One persisted invocation binding plus the tool name and description it
|
|
96
|
+
* backs. The description is the resolved operation description / summary /
|
|
97
|
+
* method+path fallback, persisted so the serve path needs no re-parse. */
|
|
98
|
+
export interface OperationBindingChunk {
|
|
99
|
+
readonly toolName: string;
|
|
100
|
+
readonly description: string;
|
|
101
|
+
readonly binding: OperationBinding;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Stream invocation bindings out of a parsed document in bounded chunks,
|
|
105
|
+
* persisting each chunk via `onChunk` before building the next.
|
|
106
|
+
*
|
|
107
|
+
* This is the memory-safe compile path for huge specs (e.g. Microsoft Graph,
|
|
108
|
+
* 16.5k operations / 37MB). It differs from `extract` + `compileToolDefinitions`
|
|
109
|
+
* in two ways that keep peak memory at parse level rather than ~doubling it:
|
|
110
|
+
*
|
|
111
|
+
* 1. It never builds `hoistedDefs` or per-operation `inputSchema`/`outputSchema`
|
|
112
|
+
* (the add path only needs invocation bindings, which carry `$ref`s, not
|
|
113
|
+
* inlined schemas).
|
|
114
|
+
* 2. It never holds all bindings at once. Tool-path planning needs a global
|
|
115
|
+
* view, but only of lightweight metadata (`planToolPaths`, schema-free);
|
|
116
|
+
* the heavy per-operation bindings are built, flushed, and dropped one
|
|
117
|
+
* chunk at a time.
|
|
118
|
+
*
|
|
119
|
+
* Bindings reference subtrees of the parsed document rather than copying them,
|
|
120
|
+
* so `onChunk` must sever those references (its storage layer JSON-serializes
|
|
121
|
+
* the binding) before the chunk is dropped. Returns the resolved tool names in
|
|
122
|
+
* sorted order, matching `compileToolDefinitions`.
|
|
123
|
+
*/
|
|
124
|
+
export declare const streamOperationBindings: <E, R>(doc: ParsedDocument, chunkSize: number, onChunk: (chunk: readonly OperationBindingChunk[]) => Effect.Effect<void, E, R>) => Effect.Effect<{
|
|
125
|
+
readonly toolCount: number;
|
|
126
|
+
readonly toolNames: readonly string[];
|
|
127
|
+
}, OpenApiExtractionError | E, R>;
|
|
128
|
+
/**
|
|
129
|
+
* Stream invocation bindings straight from a `SpecStructure` (the structural
|
|
130
|
+
* split of a large spec) without ever materializing the whole-document tree.
|
|
131
|
+
*
|
|
132
|
+
* This is the fully-streaming compile path: it never parses the spec whole.
|
|
133
|
+
* Each path-item is parsed in isolation twice (pass 1 for light tool-path
|
|
134
|
+
* planning metadata, pass 2 to build the heavy binding) and discarded, so peak
|
|
135
|
+
* memory stays near the size of a single path-item plus the raw text, even for
|
|
136
|
+
* the 37MB / 16.5k-operation Microsoft Graph spec that OOMs a whole-tree parse.
|
|
137
|
+
* Re-parsing in pass 2 (rather than holding pass-1 tree references) is the
|
|
138
|
+
* deliberate CPU-for-memory trade that keeps peak at one-path-item level.
|
|
139
|
+
*
|
|
140
|
+
* `keepPathItem`, when given, filters (and may trim) each path-item, so the same
|
|
141
|
+
* primitive serves both a full-spec compile (no filter) and a selection (e.g.
|
|
142
|
+
* the Microsoft Graph scope filter) with identical streaming guarantees. It is
|
|
143
|
+
* applied identically in both passes so the per-operation index stays aligned.
|
|
144
|
+
*
|
|
145
|
+
* Schemas are never resolved here: parameter / requestBody / response component
|
|
146
|
+
* `$ref`s resolve against the small (schema-free) components built from the
|
|
147
|
+
* structure; `#/components/schemas/X` refs stay as strings in the binding and
|
|
148
|
+
* are normalized + served from the content-addressed defs blob. Returns the
|
|
149
|
+
* resolved tool names in sorted order, matching `compileToolDefinitions`.
|
|
150
|
+
*/
|
|
151
|
+
export declare const streamOperationBindingsFromStructure: <E, R>(structure: SpecStructure, options: {
|
|
152
|
+
readonly chunkSize: number;
|
|
153
|
+
readonly keepPathItem?: KeepPathItem;
|
|
154
|
+
}, onChunk: (chunk: readonly OperationBindingChunk[]) => Effect.Effect<void, E, R>) => Effect.Effect<{
|
|
155
|
+
readonly toolCount: number;
|
|
156
|
+
readonly toolNames: readonly string[];
|
|
157
|
+
}, E, R>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { parse, resolveSpecText, fetchSpecText } from "./parse";
|
|
2
|
+
export { extract, streamOperationBindingsFromStructure } from "./extract";
|
|
3
|
+
export { structuralSplit, isStreamableSpec, indexSchemas, collectReferencedSchemas, parseEntry, parseHead, parseSmallComponents, type SpecStructure, type ByteRange, type KeepPathItem, } from "./split";
|
|
4
|
+
export { invoke, invokeWithLayer, buildRequest, annotationsForOperation, RESPONSE_HEADERS_TIMEOUT_MS, type InvokeOptions, } from "./invoke";
|
|
5
|
+
export { buildDefsJsonStreaming, checkHealthOpenApi, compileAndPersistOpenApiOperations, compileAndPersistOpenApiSpec, compileAndPersistOpenApiSpecStreaming, compileOpenApiDocument, compileOpenApiSpec, extractOpenApiUpstreamMessage, invokeOpenApiBackedTool, listHealthCheckCandidatesOpenApi, loadOpenApiSpecText, normalizeOpenApiRefs, openApiStoredOperationsFromCompiled, openApiToolDefsFromCompiled, resolveOpenApiBackedAnnotations, resolveOpenApiBackedTools, validateOpenApiBackedToolArgs, type CompiledOpenApiSpec, type OpenApiPersistResult, } from "./backing";
|
|
6
|
+
export type { ParsedDocument } from "./parse";
|
|
7
|
+
export { openApiPlugin, type OpenApiSpecConfig, type OpenApiConfigureInput, type OpenApiSpecInput, type OpenApiPreviewInput, type OpenApiPluginExtension, type OpenApiPluginOptions, } from "./plugin";
|
|
8
|
+
export { resolveSpecFormatAdapter, type ConvertedSpec, type DerivedIdentity, type SpecFetchCredentials, type SpecFetchInput, type SpecFormatAdapter, } from "./spec-format";
|
|
9
|
+
export { type OpenapiStore, type StoredOperation, makeDefaultOpenapiStore } from "./store";
|
|
10
|
+
export { decodeOpenApiIntegrationConfig, renderAuthTemplate, AuthenticationSchema, OpenApiIntegrationConfigSchema, type OpenApiIntegrationConfig, type RenderedAuth, } from "./config";
|
|
11
|
+
export { previewSpec, SecurityScheme, AuthStrategy, HeaderPreset, OAuth2Preset, OAuth2Flows, OAuth2AuthorizationCodeFlow, OAuth2ClientCredentialsFlow, PreviewOperation, SpecPreview, } from "./preview";
|
|
12
|
+
export { DocResolver, resolveServerUrl, substituteUrlVariables, preferredContent, } from "./openapi-utils";
|
|
13
|
+
export { OpenApiParseError, OpenApiExtractionError, OpenApiInvocationError, OpenApiOAuthError, OpenApiAuthRequiredError, } from "./errors";
|
|
14
|
+
export { EncodingObject, ExtractedOperation, ExtractionResult, InvocationResult, MediaBinding, OperationBinding, OperationParameter, OperationRequestBody, ServerInfo, ServerVariable, OperationId, HttpMethod, ParameterLocation, TOKEN_VARIABLE, normalizeOpenApiAuthInputs, type Authentication, type AuthenticationInput, type APIKeyAuthentication, } from "./types";
|
|
15
|
+
export { variable, type ApiKeyAuthTemplate } from "@rafads/sdk/http-auth";
|
|
16
|
+
export { migrateOpenApiAuthConfig } from "./migrate-config";
|
|
17
|
+
export { openApiOutputSchemaDataMigration, runSqliteOpenApiOutputSchemaMigration, unwrapOpenApiTransportEnvelope, } from "./output-schema-migration";
|
|
18
|
+
export { openApiNdjsonOutputDataMigration, runSqliteNdjsonOutputMigration, } from "./ndjson-output-migration";
|
|
19
|
+
export { openApiSpecBlobDataMigration } from "./spec-blob-migration";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { Effect, Layer, Option, Stream } from "effect";
|
|
2
|
+
import { HttpClient, HttpClientRequest } from "effect/unstable/http";
|
|
3
|
+
import { OpenApiInvocationError } from "./errors";
|
|
4
|
+
import { type OperationBinding } from "./types";
|
|
5
|
+
export declare const STREAM_MAX_BYTES = 1000000;
|
|
6
|
+
export declare const STREAM_MAX_MS = 10000;
|
|
7
|
+
export declare const RESPONSE_HEADERS_TIMEOUT_MS = 110000;
|
|
8
|
+
export interface StreamingResponseCaps {
|
|
9
|
+
readonly maxBytes?: number;
|
|
10
|
+
readonly maxMs?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface InvokeOptions {
|
|
13
|
+
readonly responseHeadersTimeoutMs?: number;
|
|
14
|
+
}
|
|
15
|
+
export declare const collectStreamingBody: (stream: Stream.Stream<Uint8Array, unknown, never>, contentType: string | null, caps?: StreamingResponseCaps) => Effect.Effect<{
|
|
16
|
+
data: unknown;
|
|
17
|
+
headers: {
|
|
18
|
+
"x-executor-stream": string;
|
|
19
|
+
"x-executor-stream-bytes": string;
|
|
20
|
+
"x-executor-stream-duration-ms": string;
|
|
21
|
+
};
|
|
22
|
+
}, unknown, never>;
|
|
23
|
+
export declare const buildRequest: (operation: {
|
|
24
|
+
readonly parameters: readonly {
|
|
25
|
+
readonly name: string;
|
|
26
|
+
readonly required: boolean;
|
|
27
|
+
readonly description: Option.Option<string>;
|
|
28
|
+
readonly location: "path" | "header" | "query" | "cookie";
|
|
29
|
+
readonly schema: Option.Option<unknown>;
|
|
30
|
+
readonly style: Option.Option<string>;
|
|
31
|
+
readonly explode: Option.Option<boolean>;
|
|
32
|
+
readonly allowReserved: Option.Option<boolean>;
|
|
33
|
+
}[];
|
|
34
|
+
readonly method: "post" | "options" | "get" | "delete" | "put" | "patch" | "head" | "trace";
|
|
35
|
+
readonly requestBody: Option.Option<{
|
|
36
|
+
readonly required: boolean;
|
|
37
|
+
readonly schema: Option.Option<unknown>;
|
|
38
|
+
readonly contentType: string;
|
|
39
|
+
readonly contents: Option.Option<readonly {
|
|
40
|
+
readonly schema: Option.Option<unknown>;
|
|
41
|
+
readonly encoding: Option.Option<{
|
|
42
|
+
readonly [x: string]: {
|
|
43
|
+
readonly style: Option.Option<string>;
|
|
44
|
+
readonly contentType: Option.Option<string>;
|
|
45
|
+
readonly explode: Option.Option<boolean>;
|
|
46
|
+
readonly allowReserved: Option.Option<boolean>;
|
|
47
|
+
};
|
|
48
|
+
}>;
|
|
49
|
+
readonly contentType: string;
|
|
50
|
+
}[]>;
|
|
51
|
+
}>;
|
|
52
|
+
readonly responseBody: Option.Option<{
|
|
53
|
+
readonly schema: Option.Option<unknown>;
|
|
54
|
+
readonly contentType: string;
|
|
55
|
+
readonly fileHint: Option.Option<{
|
|
56
|
+
readonly kind: "binaryResponse" | "byteField";
|
|
57
|
+
readonly encoding: Option.Option<"base64" | "base64url">;
|
|
58
|
+
readonly mimeType: Option.Option<string>;
|
|
59
|
+
readonly dataField: Option.Option<string>;
|
|
60
|
+
readonly sizeField: Option.Option<string>;
|
|
61
|
+
}>;
|
|
62
|
+
}>;
|
|
63
|
+
readonly pathTemplate: string;
|
|
64
|
+
readonly servers?: readonly {
|
|
65
|
+
readonly description: Option.Option<string>;
|
|
66
|
+
readonly url: string;
|
|
67
|
+
readonly variables: Option.Option<{
|
|
68
|
+
readonly [x: string]: {
|
|
69
|
+
readonly default: string;
|
|
70
|
+
readonly description: Option.Option<string>;
|
|
71
|
+
readonly enum: Option.Option<readonly string[]>;
|
|
72
|
+
};
|
|
73
|
+
}>;
|
|
74
|
+
}[] | undefined;
|
|
75
|
+
readonly requiredScopeAlternatives?: readonly (readonly string[])[] | undefined;
|
|
76
|
+
}, args: Record<string, unknown>, resolvedHeaders: Record<string, string>, integrationQueryParams?: Record<string, string> | undefined) => Effect.Effect<HttpClientRequest.HttpClientRequest, OpenApiInvocationError, never>;
|
|
77
|
+
export declare const invoke: (operation: {
|
|
78
|
+
readonly parameters: readonly {
|
|
79
|
+
readonly name: string;
|
|
80
|
+
readonly required: boolean;
|
|
81
|
+
readonly description: Option.Option<string>;
|
|
82
|
+
readonly location: "path" | "header" | "query" | "cookie";
|
|
83
|
+
readonly schema: Option.Option<unknown>;
|
|
84
|
+
readonly style: Option.Option<string>;
|
|
85
|
+
readonly explode: Option.Option<boolean>;
|
|
86
|
+
readonly allowReserved: Option.Option<boolean>;
|
|
87
|
+
}[];
|
|
88
|
+
readonly method: "post" | "options" | "get" | "delete" | "put" | "patch" | "head" | "trace";
|
|
89
|
+
readonly requestBody: Option.Option<{
|
|
90
|
+
readonly required: boolean;
|
|
91
|
+
readonly schema: Option.Option<unknown>;
|
|
92
|
+
readonly contentType: string;
|
|
93
|
+
readonly contents: Option.Option<readonly {
|
|
94
|
+
readonly schema: Option.Option<unknown>;
|
|
95
|
+
readonly encoding: Option.Option<{
|
|
96
|
+
readonly [x: string]: {
|
|
97
|
+
readonly style: Option.Option<string>;
|
|
98
|
+
readonly contentType: Option.Option<string>;
|
|
99
|
+
readonly explode: Option.Option<boolean>;
|
|
100
|
+
readonly allowReserved: Option.Option<boolean>;
|
|
101
|
+
};
|
|
102
|
+
}>;
|
|
103
|
+
readonly contentType: string;
|
|
104
|
+
}[]>;
|
|
105
|
+
}>;
|
|
106
|
+
readonly responseBody: Option.Option<{
|
|
107
|
+
readonly schema: Option.Option<unknown>;
|
|
108
|
+
readonly contentType: string;
|
|
109
|
+
readonly fileHint: Option.Option<{
|
|
110
|
+
readonly kind: "binaryResponse" | "byteField";
|
|
111
|
+
readonly encoding: Option.Option<"base64" | "base64url">;
|
|
112
|
+
readonly mimeType: Option.Option<string>;
|
|
113
|
+
readonly dataField: Option.Option<string>;
|
|
114
|
+
readonly sizeField: Option.Option<string>;
|
|
115
|
+
}>;
|
|
116
|
+
}>;
|
|
117
|
+
readonly pathTemplate: string;
|
|
118
|
+
readonly servers?: readonly {
|
|
119
|
+
readonly description: Option.Option<string>;
|
|
120
|
+
readonly url: string;
|
|
121
|
+
readonly variables: Option.Option<{
|
|
122
|
+
readonly [x: string]: {
|
|
123
|
+
readonly default: string;
|
|
124
|
+
readonly description: Option.Option<string>;
|
|
125
|
+
readonly enum: Option.Option<readonly string[]>;
|
|
126
|
+
};
|
|
127
|
+
}>;
|
|
128
|
+
}[] | undefined;
|
|
129
|
+
readonly requiredScopeAlternatives?: readonly (readonly string[])[] | undefined;
|
|
130
|
+
}, args: Record<string, unknown>, resolvedHeaders: Record<string, string>, integrationQueryParams?: Record<string, string> | undefined, options?: InvokeOptions | undefined) => Effect.Effect<{
|
|
131
|
+
readonly error: unknown;
|
|
132
|
+
readonly status: number;
|
|
133
|
+
readonly data: unknown;
|
|
134
|
+
readonly headers: {
|
|
135
|
+
readonly [x: string]: string;
|
|
136
|
+
};
|
|
137
|
+
}, OpenApiInvocationError, HttpClient.HttpClient>;
|
|
138
|
+
export declare const invokeWithLayer: (operation: OperationBinding, args: Record<string, unknown>, baseUrl: string, resolvedHeaders: Record<string, string>, integrationQueryParams: Record<string, string>, httpClientLayer: Layer.Layer<HttpClient.HttpClient, never, never>, options?: InvokeOptions) => Effect.Effect<{
|
|
139
|
+
readonly error: unknown;
|
|
140
|
+
readonly status: number;
|
|
141
|
+
readonly data: unknown;
|
|
142
|
+
readonly headers: {
|
|
143
|
+
readonly [x: string]: string;
|
|
144
|
+
};
|
|
145
|
+
}, OpenApiInvocationError, never>;
|
|
146
|
+
export declare const REQUIRE_APPROVAL: Set<string>;
|
|
147
|
+
export declare const annotationsForOperation: (method: string, pathTemplate: string) => {
|
|
148
|
+
requiresApproval?: boolean;
|
|
149
|
+
approvalDescription?: string;
|
|
150
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Rewrite a stored OpenAPI integration config blob into the canonical shape.
|
|
2
|
+
* Returns the rewritten config, or `null` when no rewrite is needed (already
|
|
3
|
+
* canonical, no auth templates, or not this plugin's shape). Idempotent. */
|
|
4
|
+
export declare const migrateOpenApiAuthConfig: (config: unknown) => unknown | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { DataMigrationError, type SqliteDataMigrationClient } from "@rafads/sdk/core";
|
|
3
|
+
/** Stale-mark every connection whose integration has at least one stored
|
|
4
|
+
* operation binding with an NDJSON response, so the next read rebuilds its
|
|
5
|
+
* tool rows (with array-wrapped output schemas). Returns the number of
|
|
6
|
+
* connections marked. Fresh databases may lack either table; nothing to
|
|
7
|
+
* migrate. */
|
|
8
|
+
export declare const runSqliteNdjsonOutputMigration: (client: SqliteDataMigrationClient) => Effect.Effect<number, DataMigrationError>;
|
|
9
|
+
/** Registry entry for the boot-time data-migration ledger. */
|
|
10
|
+
export declare const openApiNdjsonOutputDataMigration: {
|
|
11
|
+
name: string;
|
|
12
|
+
run: (client: SqliteDataMigrationClient) => Effect.Effect<void, DataMigrationError, never>;
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { OpenAPIV3, OpenAPIV3_1 } from "openapi-types";
|
|
2
|
+
import type { ParsedDocument } from "./parse";
|
|
3
|
+
import type { ServerVariable } from "./types";
|
|
4
|
+
export type ParameterObject = OpenAPIV3.ParameterObject | OpenAPIV3_1.ParameterObject;
|
|
5
|
+
export type OperationObject = OpenAPIV3.OperationObject | OpenAPIV3_1.OperationObject;
|
|
6
|
+
export type PathItemObject = OpenAPIV3.PathItemObject | OpenAPIV3_1.PathItemObject;
|
|
7
|
+
export type RequestBodyObject = OpenAPIV3.RequestBodyObject | OpenAPIV3_1.RequestBodyObject;
|
|
8
|
+
export type ResponseObject = OpenAPIV3.ResponseObject | OpenAPIV3_1.ResponseObject;
|
|
9
|
+
export type MediaTypeObject = OpenAPIV3.MediaTypeObject | OpenAPIV3_1.MediaTypeObject;
|
|
10
|
+
export type ServerObject = OpenAPIV3.ServerObject | OpenAPIV3_1.ServerObject;
|
|
11
|
+
export declare class DocResolver {
|
|
12
|
+
readonly doc: ParsedDocument;
|
|
13
|
+
constructor(doc: ParsedDocument);
|
|
14
|
+
/** Resolve a value that might be a $ref, returning the resolved object */
|
|
15
|
+
resolve<T>(value: T | OpenAPIV3.ReferenceObject | OpenAPIV3_1.ReferenceObject): T | null;
|
|
16
|
+
private resolvePointer;
|
|
17
|
+
}
|
|
18
|
+
/** Substitute `{var}` placeholders in a templated URL using a plain map. */
|
|
19
|
+
export declare const substituteUrlVariables: (url: string, values: Record<string, string>) => string;
|
|
20
|
+
/** Resolve a templated server URL, filling each `{var}` from `overrides` when
|
|
21
|
+
* non-empty, otherwise the variable's spec default. URLs without placeholders
|
|
22
|
+
* pass through unchanged. */
|
|
23
|
+
export declare const resolveServerUrl: (templateUrl: string, variables: Record<string, ServerVariable> | undefined, overrides: Record<string, string>) => string;
|
|
24
|
+
/**
|
|
25
|
+
* Return all declared media entries in spec order. `Object.entries` on a
|
|
26
|
+
* plain object preserves insertion order in modern engines, which matches
|
|
27
|
+
* spec declaration order as the parser produced it.
|
|
28
|
+
*/
|
|
29
|
+
export declare const declaredContents: (content: Record<string, MediaTypeObject> | undefined) => ReadonlyArray<{
|
|
30
|
+
mediaType: string;
|
|
31
|
+
media: MediaTypeObject;
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* Pick the default media type for a requestBody or response. Matches
|
|
35
|
+
* swagger-client behaviour: **first declared wins** (not JSON-first). Spec
|
|
36
|
+
* authors order content entries to signal intent (upload-heavy endpoints
|
|
37
|
+
* declare multipart first, JSON second); respecting that order avoids
|
|
38
|
+
* silently downgrading a multipart endpoint to JSON.
|
|
39
|
+
*
|
|
40
|
+
* For response bodies we still want a JSON preference because the server
|
|
41
|
+
* picks the response content type, not the client — the old `application/
|
|
42
|
+
* json` preference is preserved via `preferredResponseContent` below.
|
|
43
|
+
*/
|
|
44
|
+
export declare const preferredContent: (content: Record<string, MediaTypeObject> | undefined) => {
|
|
45
|
+
mediaType: string;
|
|
46
|
+
media: MediaTypeObject;
|
|
47
|
+
} | undefined;
|
|
48
|
+
/** Response-side content picker — still JSON-first because the server
|
|
49
|
+
* picks the response media type, so we want to advertise a preference. */
|
|
50
|
+
export declare const preferredResponseContent: (content: Record<string, MediaTypeObject> | undefined) => {
|
|
51
|
+
mediaType: string;
|
|
52
|
+
media: MediaTypeObject;
|
|
53
|
+
} | undefined;
|
|
54
|
+
export declare const normalizeMediaType: (mediaType: string | null | undefined) => string;
|
|
55
|
+
/** Media types whose bodies are newline-delimited JSON documents. The invoke
|
|
56
|
+
* path collects these streams and returns an ARRAY of parsed lines, so every
|
|
57
|
+
* schema surface must describe that array: the spec convention is to declare
|
|
58
|
+
* the schema of ONE line (e.g. Vercel's runtime-logs endpoint). */
|
|
59
|
+
export declare const NDJSON_MEDIA_TYPES: ReadonlySet<string>;
|
|
60
|
+
export declare const isNdjsonMediaType: (mediaType: string | null | undefined) => boolean;
|
|
61
|
+
/** Wrap a per-line NDJSON response schema into the array the runtime actually
|
|
62
|
+
* returns. The description rides into the compiled TypeScript preview as a
|
|
63
|
+
* JSDoc comment, so agents learn the truncation and raw-text caveats where
|
|
64
|
+
* they read the type. */
|
|
65
|
+
export declare const ndjsonArrayOutputSchema: (lineSchema: unknown) => Record<string, unknown>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { DataMigrationError, type SqliteDataMigrationClient } from "@rafads/sdk/core";
|
|
3
|
+
/**
|
|
4
|
+
* If `schema` is the retired transport envelope, return the payload schema
|
|
5
|
+
* to persist instead (`null` when the envelope carried an empty `{}` data
|
|
6
|
+
* schema — the new producer persists no output schema for those). Returns
|
|
7
|
+
* undefined when the schema is not an envelope and the row must be left
|
|
8
|
+
* untouched.
|
|
9
|
+
*/
|
|
10
|
+
export declare const unwrapOpenApiTransportEnvelope: (schema: unknown) => {
|
|
11
|
+
readonly outputSchema: unknown | null;
|
|
12
|
+
} | undefined;
|
|
13
|
+
/** Unwrap envelope-shaped openapi tool output schemas in a SQLite database.
|
|
14
|
+
* Returns the number of rows rewritten. The `tool` table may not exist yet
|
|
15
|
+
* on a fresh database — that counts as nothing to migrate. */
|
|
16
|
+
export declare const runSqliteOpenApiOutputSchemaMigration: (client: SqliteDataMigrationClient) => Effect.Effect<number, DataMigrationError>;
|
|
17
|
+
/** Registry entry for the boot-time data-migration ledger. */
|
|
18
|
+
export declare const openApiOutputSchemaDataMigration: {
|
|
19
|
+
name: string;
|
|
20
|
+
run: (client: SqliteDataMigrationClient) => Effect.Effect<void, DataMigrationError, never>;
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { OpenAPIV3, OpenAPIV3_1 } from "openapi-types";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import { HttpClient } from "effect/unstable/http";
|
|
4
|
+
import { OpenApiExtractionError, OpenApiParseError } from "./errors";
|
|
5
|
+
export type ParsedDocument = OpenAPIV3.Document | OpenAPIV3_1.Document;
|
|
6
|
+
export interface SpecFetchCredentials {
|
|
7
|
+
readonly headers?: Record<string, string>;
|
|
8
|
+
readonly queryParams?: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
declare class OpenApiExtractionErrorFromParse extends OpenApiExtractionError {
|
|
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`.
|
|
16
|
+
* Bounded by a 60s timeout.
|
|
17
|
+
*/
|
|
18
|
+
export declare const fetchSpecText: (url: string, credentials?: SpecFetchCredentials | undefined) => Effect.Effect<string, OpenApiParseError, HttpClient.HttpClient>;
|
|
19
|
+
/**
|
|
20
|
+
* Resolve an input string to spec text — if it's a URL, fetch it via
|
|
21
|
+
* HttpClient; otherwise return it as-is.
|
|
22
|
+
*/
|
|
23
|
+
export declare const resolveSpecText: (input: string, credentials?: SpecFetchCredentials) => Effect.Effect<string, OpenApiParseError, HttpClient.HttpClient>;
|
|
24
|
+
/**
|
|
25
|
+
* Parse an OpenAPI document from spec text and validate it's OpenAPI 3.x.
|
|
26
|
+
*
|
|
27
|
+
* NOTE: does NOT resolve `$ref`s. `DocResolver` + `normalizeOpenApiRefs`
|
|
28
|
+
* downstream work on refs lazily, so inlining them here would just waste
|
|
29
|
+
* memory — and for big specs (e.g. Cloudflare's API) that blows through
|
|
30
|
+
* the 128MB Cloudflare Workers memory cap.
|
|
31
|
+
*/
|
|
32
|
+
export declare const parse: (text: string) => Effect.Effect<ParsedDocument, OpenApiParseError | OpenApiExtractionErrorFromParse, never>;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|