@executor-js/plugin-openapi 1.5.16 → 1.5.18
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/dist/{AddOpenApiSource-U7AYB224.js → AddOpenApiSource-IBZQRCTW.js} +4 -4
- package/dist/{OpenApiAccountsPanel-GHFHHE6P.js → OpenApiAccountsPanel-U47OVLYG.js} +3 -3
- package/dist/{UpdateSpecSection-PLCBUU4I.js → UpdateSpecSection-FFYVB3VH.js} +3 -3
- package/dist/{chunk-CPPTKUOW.js → chunk-2RNIMASA.js} +2 -2
- package/dist/{chunk-CKBX4SXK.js → chunk-5IDND4UF.js} +2 -2
- package/dist/{chunk-3FM2SWM4.js → chunk-ELCKZJE4.js} +236 -210
- package/dist/chunk-ELCKZJE4.js.map +1 -0
- package/dist/{chunk-KVPUDOJZ.js → chunk-R3X27XS6.js} +587 -77
- package/dist/chunk-R3X27XS6.js.map +1 -0
- package/dist/client.js +3 -3
- package/dist/core.js +27 -3
- package/dist/core.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/sdk/backing.d.ts +91 -1
- package/dist/sdk/definitions.d.ts +33 -1
- package/dist/sdk/extract.d.ts +66 -0
- package/dist/sdk/index.d.ts +3 -2
- package/dist/sdk/request-user-agent.test.d.ts +1 -0
- package/dist/sdk/split.d.ts +84 -0
- package/dist/sdk/store.d.ts +19 -0
- package/package.json +3 -3
- package/dist/chunk-3FM2SWM4.js.map +0 -1
- package/dist/chunk-KVPUDOJZ.js.map +0 -1
- /package/dist/{AddOpenApiSource-U7AYB224.js.map → AddOpenApiSource-IBZQRCTW.js.map} +0 -0
- /package/dist/{OpenApiAccountsPanel-GHFHHE6P.js.map → OpenApiAccountsPanel-U47OVLYG.js.map} +0 -0
- /package/dist/{UpdateSpecSection-PLCBUU4I.js.map → UpdateSpecSection-FFYVB3VH.js.map} +0 -0
- /package/dist/{chunk-CPPTKUOW.js.map → chunk-2RNIMASA.js.map} +0 -0
- /package/dist/{chunk-CKBX4SXK.js.map → chunk-5IDND4UF.js.map} +0 -0
package/dist/sdk/backing.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { type OpenApiIntegrationConfig } from "./config";
|
|
|
6
6
|
import { OpenApiExtractionError, OpenApiParseError } from "./errors";
|
|
7
7
|
import { type ToolDefinition } from "./definitions";
|
|
8
8
|
import { type ParsedDocument } from "./parse";
|
|
9
|
+
import { type KeepPathItem, type SpecStructure } from "./split";
|
|
9
10
|
import { type OpenapiStore, type StoredOperation } from "./store";
|
|
10
11
|
export declare const extractOpenApiUpstreamMessage: (body: unknown, status: number) => string;
|
|
11
12
|
/** Rewrite OpenAPI `#/components/schemas/X` refs to standard `#/$defs/X`. */
|
|
@@ -20,8 +21,97 @@ export declare const compileOpenApiDocument: (doc: ParsedDocument) => Effect.Eff
|
|
|
20
21
|
export declare const compileOpenApiSpec: (specText: string) => Effect.Effect<CompiledOpenApiSpec, OpenApiParseError | OpenApiExtractionError>;
|
|
21
22
|
export declare const openApiToolDefsFromCompiled: (compiled: CompiledOpenApiSpec) => readonly ToolDef[];
|
|
22
23
|
export declare const openApiStoredOperationsFromCompiled: (integration: string, compiled: CompiledOpenApiSpec) => readonly StoredOperation[];
|
|
24
|
+
/**
|
|
25
|
+
* Serialize a document's `components.schemas` into the content-addressed defs
|
|
26
|
+
* blob JSON (`{ "<Name>": <normalized schema>, ... }`), one schema at a time.
|
|
27
|
+
* Normalizing + stringifying per entry keeps the whole normalized definition
|
|
28
|
+
* tree from ever being co-resident with the parsed document, so the streaming
|
|
29
|
+
* add path's peak stays near parse level. The serve path JSON-parses this blob
|
|
30
|
+
* to rebuild the shared `definitions` instead of re-parsing the spec.
|
|
31
|
+
*/
|
|
32
|
+
export declare const buildDefsJson: (doc: ParsedDocument) => string;
|
|
33
|
+
/**
|
|
34
|
+
* Streaming twin of `buildDefsJson`: serialize the content-addressed defs blob
|
|
35
|
+
* from a `SpecStructure` by parsing each `components.schemas` entry in isolation
|
|
36
|
+
* (indent-4 range) rather than from a whole-document parse. Used by the fully
|
|
37
|
+
* streaming add path so the 37MB Microsoft Graph spec never builds its
|
|
38
|
+
* ~300MB tree. The blob carries *all* source schemas (it is shared across every
|
|
39
|
+
* tenant/selection on the same spec hash); extra unreferenced `$defs` are
|
|
40
|
+
* harmless. Like `buildDefsJson`, normalizing + stringifying per entry keeps the
|
|
41
|
+
* whole normalized tree from being co-resident with any parsed schema, and the
|
|
42
|
+
* ConsString accumulation avoids the join-doubling of an array build.
|
|
43
|
+
*/
|
|
44
|
+
export declare const buildDefsJsonStreaming: (structure: SpecStructure) => string;
|
|
45
|
+
export interface OpenApiPersistResult {
|
|
46
|
+
readonly toolCount: number;
|
|
47
|
+
readonly toolNames: readonly string[];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Compile a parsed document straight to persisted operation bindings, streaming
|
|
51
|
+
* in bounded chunks so a huge spec's bindings are never all co-resident with
|
|
52
|
+
* the parsed tree. This is the memory-safe replacement for
|
|
53
|
+
* `compileOpenApiDocument` + `openApiStoredOperationsFromCompiled` + `putOperations`
|
|
54
|
+
* on the add/update path: it skips per-op input/output schema assembly (the
|
|
55
|
+
* serve path rebuilds those on demand from the bindings). Clears existing
|
|
56
|
+
* operations first, then appends each chunk. When `specHash` is given, also
|
|
57
|
+
* stream-serializes the document's `#/$defs/*` into the content-addressed defs
|
|
58
|
+
* blob so the serve path can resolve the shared `definitions` without
|
|
59
|
+
* re-parsing the spec.
|
|
60
|
+
*/
|
|
61
|
+
export declare const compileAndPersistOpenApiOperations: ({ doc, integration, storage, specHash, chunkSize, }: {
|
|
62
|
+
readonly doc: ParsedDocument;
|
|
63
|
+
readonly integration: string;
|
|
64
|
+
readonly storage: OpenapiStore;
|
|
65
|
+
readonly specHash?: string;
|
|
66
|
+
readonly chunkSize?: number;
|
|
67
|
+
}) => Effect.Effect<OpenApiPersistResult, OpenApiExtractionError | StorageFailure>;
|
|
68
|
+
/** Parse spec text, then stream-compile + persist its bindings (and, when
|
|
69
|
+
* `specHash` is given, the content-addressed defs blob). */
|
|
70
|
+
export declare const compileAndPersistOpenApiSpec: ({ specText, integration, storage, specHash, chunkSize, }: {
|
|
71
|
+
readonly specText: string;
|
|
72
|
+
readonly integration: string;
|
|
73
|
+
readonly storage: OpenapiStore;
|
|
74
|
+
readonly specHash?: string;
|
|
75
|
+
readonly chunkSize?: number;
|
|
76
|
+
}) => Effect.Effect<OpenApiPersistResult, OpenApiParseError | OpenApiExtractionError | StorageFailure>;
|
|
77
|
+
/**
|
|
78
|
+
* Fully streaming add/update path: compile + persist operation bindings (and the
|
|
79
|
+
* content-addressed defs blob) straight from spec *text*, without ever parsing
|
|
80
|
+
* the whole document. The text is structurally split, then each path-item and
|
|
81
|
+
* each schema is parsed in isolation and discarded, so peak memory stays near
|
|
82
|
+
* one item rather than the ~300MB whole-tree parse that OOMs a 128MB Workers
|
|
83
|
+
* isolate on the 37MB Microsoft Graph spec.
|
|
84
|
+
*
|
|
85
|
+
* There is deliberately no whole-parse fallback: a spec that does not present
|
|
86
|
+
* the streamable block-YAML profile (no top-level `paths:` block) is a hard
|
|
87
|
+
* `OpenApiExtractionError`, because the fallback is exactly the OOM this path
|
|
88
|
+
* exists to avoid. `keepPathItem` optionally filters/trims path-items (the
|
|
89
|
+
* Microsoft Graph scope selection), so the same primitive serves a full-spec
|
|
90
|
+
* compile and a selection identically.
|
|
91
|
+
*/
|
|
92
|
+
export declare const compileAndPersistOpenApiSpecStreaming: ({ specText, integration, storage, specHash, chunkSize, keepPathItem, }: {
|
|
93
|
+
readonly specText: string;
|
|
94
|
+
readonly integration: string;
|
|
95
|
+
readonly storage: OpenapiStore;
|
|
96
|
+
readonly specHash?: string;
|
|
97
|
+
readonly chunkSize?: number;
|
|
98
|
+
readonly keepPathItem?: KeepPathItem;
|
|
99
|
+
}) => Effect.Effect<OpenApiPersistResult, OpenApiExtractionError | StorageFailure>;
|
|
23
100
|
export declare const loadOpenApiSpecText: (storage: OpenapiStore, config: OpenApiIntegrationConfig) => Effect.Effect<string | null, StorageFailure>;
|
|
24
|
-
|
|
101
|
+
/**
|
|
102
|
+
* Resolve the tool defs + shared definitions for a connection refresh
|
|
103
|
+
* (`tools/list`). Fast path: serve from the persisted operation bindings plus
|
|
104
|
+
* the content-addressed defs blob, rebuilding each tool's input/output schema
|
|
105
|
+
* on demand, so a 37MB spec is never re-parsed (the 2nd OOM site). The defs
|
|
106
|
+
* blob is global per `specHash`, so the heavy normalize work is done once at
|
|
107
|
+
* add time and shared across every tenant on the same spec. Falls back to the
|
|
108
|
+
* spec re-parse for legacy rows persisted before the defs blob existed (or if
|
|
109
|
+
* the blob is missing/corrupt).
|
|
110
|
+
*/
|
|
111
|
+
export declare const resolveOpenApiBackedTools: ({ integration, config, storage, }: {
|
|
112
|
+
readonly integration: {
|
|
113
|
+
readonly slug: string;
|
|
114
|
+
};
|
|
25
115
|
readonly config: unknown;
|
|
26
116
|
readonly storage: OpenapiStore;
|
|
27
117
|
}) => Effect.Effect<ResolveToolsResult, StorageFailure>;
|
|
@@ -18,8 +18,40 @@ export interface ToolDefinition {
|
|
|
18
18
|
/** The original operation */
|
|
19
19
|
readonly operation: ExtractedOperation;
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* The minimal per-operation metadata the tool-path planner needs. Kept
|
|
23
|
+
* deliberately light (no schemas) so the streaming compile path can plan paths
|
|
24
|
+
* for tens of thousands of operations without holding the full extracted
|
|
25
|
+
* operations in memory.
|
|
26
|
+
*/
|
|
27
|
+
export interface OperationPathInput {
|
|
28
|
+
readonly operationId: string;
|
|
29
|
+
readonly explicitToolPath: string | undefined;
|
|
30
|
+
readonly method: string;
|
|
31
|
+
readonly pathTemplate: string;
|
|
32
|
+
/** The first non-empty tag, used to seed the group segment. */
|
|
33
|
+
readonly tag0: string | undefined;
|
|
34
|
+
}
|
|
35
|
+
/** A resolved tool path plus its index back into the input operations array. */
|
|
36
|
+
export interface PlannedToolPath {
|
|
37
|
+
readonly toolPath: string;
|
|
38
|
+
readonly group: string;
|
|
39
|
+
readonly leaf: string;
|
|
40
|
+
readonly operationIndex: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Plan structured `group.leaf` tool paths from lightweight per-operation
|
|
44
|
+
* metadata. Path derivation + collision resolution need a global view of every
|
|
45
|
+
* operation, but only its name/method/path/tag, never its schemas. Keeping this
|
|
46
|
+
* pass schema-free lets the streaming compile path plan paths for a 16k-op spec
|
|
47
|
+
* without materializing the full extracted operations.
|
|
48
|
+
*
|
|
49
|
+
* The returned `operationIndex` points back into the `inputs` array.
|
|
50
|
+
*/
|
|
51
|
+
export declare const planToolPaths: (inputs: readonly OperationPathInput[]) => PlannedToolPath[];
|
|
21
52
|
/**
|
|
22
53
|
* Compile extracted operations into tool definitions with structured
|
|
23
|
-
* `group.leaf` paths suitable for tree rendering.
|
|
54
|
+
* `group.leaf` paths suitable for tree rendering. Thin wrapper over
|
|
55
|
+
* `planToolPaths` that re-attaches each operation by index.
|
|
24
56
|
*/
|
|
25
57
|
export declare const compileToolDefinitions: (operations: readonly ExtractedOperation[]) => ToolDefinition[];
|
package/dist/sdk/extract.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Effect, Option } from "effect";
|
|
2
2
|
import { OpenApiExtractionError } from "./errors";
|
|
3
3
|
import type { ParsedDocument } from "./parse";
|
|
4
|
+
import { type KeepPathItem, type SpecStructure } from "./split";
|
|
5
|
+
import { OperationBinding, OperationParameter, OperationRequestBody, ServerInfo } from "./types";
|
|
6
|
+
export declare const buildInputSchema: (parameters: readonly OperationParameter[], requestBody: OperationRequestBody | undefined, servers: readonly ServerInfo[]) => Record<string, unknown> | undefined;
|
|
4
7
|
/** Extract all operations from a bundled OpenAPI 3.x document */
|
|
5
8
|
export declare const extract: (doc: ParsedDocument) => Effect.Effect<{
|
|
6
9
|
readonly version: Option.Option<string>;
|
|
@@ -79,3 +82,66 @@ export declare const extract: (doc: ParsedDocument) => Effect.Effect<{
|
|
|
79
82
|
}>;
|
|
80
83
|
}[];
|
|
81
84
|
}, OpenApiExtractionError, never>;
|
|
85
|
+
/** One persisted invocation binding plus the tool name and description it
|
|
86
|
+
* backs. The description is the resolved operation description / summary /
|
|
87
|
+
* method+path fallback, persisted so the serve path needs no re-parse. */
|
|
88
|
+
export interface OperationBindingChunk {
|
|
89
|
+
readonly toolName: string;
|
|
90
|
+
readonly description: string;
|
|
91
|
+
readonly binding: OperationBinding;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Stream invocation bindings out of a parsed document in bounded chunks,
|
|
95
|
+
* persisting each chunk via `onChunk` before building the next.
|
|
96
|
+
*
|
|
97
|
+
* This is the memory-safe compile path for huge specs (e.g. Microsoft Graph,
|
|
98
|
+
* 16.5k operations / 37MB). It differs from `extract` + `compileToolDefinitions`
|
|
99
|
+
* in two ways that keep peak memory at parse level rather than ~doubling it:
|
|
100
|
+
*
|
|
101
|
+
* 1. It never builds `hoistedDefs` or per-operation `inputSchema`/`outputSchema`
|
|
102
|
+
* (the add path only needs invocation bindings, which carry `$ref`s, not
|
|
103
|
+
* inlined schemas).
|
|
104
|
+
* 2. It never holds all bindings at once. Tool-path planning needs a global
|
|
105
|
+
* view, but only of lightweight metadata (`planToolPaths`, schema-free);
|
|
106
|
+
* the heavy per-operation bindings are built, flushed, and dropped one
|
|
107
|
+
* chunk at a time.
|
|
108
|
+
*
|
|
109
|
+
* Bindings reference subtrees of the parsed document rather than copying them,
|
|
110
|
+
* so `onChunk` must sever those references (its storage layer JSON-serializes
|
|
111
|
+
* the binding) before the chunk is dropped. Returns the resolved tool names in
|
|
112
|
+
* sorted order, matching `compileToolDefinitions`.
|
|
113
|
+
*/
|
|
114
|
+
export declare const streamOperationBindings: <E, R>(doc: ParsedDocument, chunkSize: number, onChunk: (chunk: readonly OperationBindingChunk[]) => Effect.Effect<void, E, R>) => Effect.Effect<{
|
|
115
|
+
readonly toolCount: number;
|
|
116
|
+
readonly toolNames: readonly string[];
|
|
117
|
+
}, OpenApiExtractionError | E, R>;
|
|
118
|
+
/**
|
|
119
|
+
* Stream invocation bindings straight from a `SpecStructure` (the structural
|
|
120
|
+
* split of a large spec) without ever materializing the whole-document tree.
|
|
121
|
+
*
|
|
122
|
+
* This is the fully-streaming compile path: it never parses the spec whole.
|
|
123
|
+
* Each path-item is parsed in isolation twice (pass 1 for light tool-path
|
|
124
|
+
* planning metadata, pass 2 to build the heavy binding) and discarded, so peak
|
|
125
|
+
* memory stays near the size of a single path-item plus the raw text, even for
|
|
126
|
+
* the 37MB / 16.5k-operation Microsoft Graph spec that OOMs a whole-tree parse.
|
|
127
|
+
* Re-parsing in pass 2 (rather than holding pass-1 tree references) is the
|
|
128
|
+
* deliberate CPU-for-memory trade that keeps peak at one-path-item level.
|
|
129
|
+
*
|
|
130
|
+
* `keepPathItem`, when given, filters (and may trim) each path-item, so the same
|
|
131
|
+
* primitive serves both a full-spec compile (no filter) and a selection (e.g.
|
|
132
|
+
* the Microsoft Graph scope filter) with identical streaming guarantees. It is
|
|
133
|
+
* applied identically in both passes so the per-operation index stays aligned.
|
|
134
|
+
*
|
|
135
|
+
* Schemas are never resolved here: parameter / requestBody / response component
|
|
136
|
+
* `$ref`s resolve against the small (schema-free) components built from the
|
|
137
|
+
* structure; `#/components/schemas/X` refs stay as strings in the binding and
|
|
138
|
+
* are normalized + served from the content-addressed defs blob. Returns the
|
|
139
|
+
* resolved tool names in sorted order, matching `compileToolDefinitions`.
|
|
140
|
+
*/
|
|
141
|
+
export declare const streamOperationBindingsFromStructure: <E, R>(structure: SpecStructure, options: {
|
|
142
|
+
readonly chunkSize: number;
|
|
143
|
+
readonly keepPathItem?: KeepPathItem;
|
|
144
|
+
}, onChunk: (chunk: readonly OperationBindingChunk[]) => Effect.Effect<void, E, R>) => Effect.Effect<{
|
|
145
|
+
readonly toolCount: number;
|
|
146
|
+
readonly toolNames: readonly string[];
|
|
147
|
+
}, E, R>;
|
package/dist/sdk/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { parse, resolveSpecText, fetchSpecText } from "./parse";
|
|
2
|
-
export { extract } from "./extract";
|
|
2
|
+
export { extract, streamOperationBindingsFromStructure } from "./extract";
|
|
3
|
+
export { structuralSplit, isStreamableSpec, indexSchemas, collectReferencedSchemas, parseEntry, parseHead, parseSmallComponents, type SpecStructure, type ByteRange, type KeepPathItem, } from "./split";
|
|
3
4
|
export { invoke, invokeWithLayer, annotationsForOperation } from "./invoke";
|
|
4
|
-
export { compileOpenApiDocument, compileOpenApiSpec, extractOpenApiUpstreamMessage, invokeOpenApiBackedTool, loadOpenApiSpecText, normalizeOpenApiRefs, openApiStoredOperationsFromCompiled, openApiToolDefsFromCompiled, resolveOpenApiBackedAnnotations, resolveOpenApiBackedTools, type CompiledOpenApiSpec, } from "./backing";
|
|
5
|
+
export { buildDefsJsonStreaming, compileAndPersistOpenApiOperations, compileAndPersistOpenApiSpec, compileAndPersistOpenApiSpecStreaming, compileOpenApiDocument, compileOpenApiSpec, extractOpenApiUpstreamMessage, invokeOpenApiBackedTool, loadOpenApiSpecText, normalizeOpenApiRefs, openApiStoredOperationsFromCompiled, openApiToolDefsFromCompiled, resolveOpenApiBackedAnnotations, resolveOpenApiBackedTools, type CompiledOpenApiSpec, type OpenApiPersistResult, } from "./backing";
|
|
5
6
|
export type { ParsedDocument } from "./parse";
|
|
6
7
|
export { openApiPlugin, type OpenApiSpecConfig, type OpenApiConfigureInput, type OpenApiSpecInput, type OpenApiPreviewInput, type OpenApiPluginExtension, type OpenApiPluginOptions, } from "./plugin";
|
|
7
8
|
export { type OpenapiStore, type StoredOperation, makeDefaultOpenapiStore } from "./store";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural splitter for large OpenAPI documents written in clean block YAML.
|
|
3
|
+
*
|
|
4
|
+
* The whole-document parse of a 37MB spec (Microsoft Graph: 16.5k operations,
|
|
5
|
+
* 8.2k schemas) builds a ~300MB JS tree that OOMs the 128MB Cloudflare Workers
|
|
6
|
+
* isolate. This splitter avoids ever holding that tree: it scans the text once,
|
|
7
|
+
* recording the byte range of each top-level key, each path-item (the indent-2
|
|
8
|
+
* entries under `paths:`), and each schema (the indent-4 entries under
|
|
9
|
+
* `components.schemas:`). The streaming compile then slices one item at a time,
|
|
10
|
+
* de-indents it back to column 0, hands the isolated fragment to a real YAML
|
|
11
|
+
* parser, and discards the result before moving on. Peak memory stays near the
|
|
12
|
+
* size of the largest single item plus the raw text, not the parsed whole.
|
|
13
|
+
*
|
|
14
|
+
* This is not a YAML reimplementation: it extracts safe byte ranges from a
|
|
15
|
+
* constrained document shape, then defers every actual parse to `js-yaml`. It
|
|
16
|
+
* is only valid for the block-YAML profile `isStreamableSpec` accepts (2-space
|
|
17
|
+
* block maps, top-level keys at column 0, no anchors/aliases/merge keys). Block
|
|
18
|
+
* scalars (`|` / `>`) in descriptions are tracked so their indented content is
|
|
19
|
+
* never mistaken for structure.
|
|
20
|
+
*/
|
|
21
|
+
export interface ByteRange {
|
|
22
|
+
readonly start: number;
|
|
23
|
+
readonly end: number;
|
|
24
|
+
}
|
|
25
|
+
export interface SpecStructure {
|
|
26
|
+
/** Raw spec text. Every range below indexes into this string. */
|
|
27
|
+
readonly text: string;
|
|
28
|
+
/** Byte ranges of the top-level keys that are not `paths` / `components`
|
|
29
|
+
* (openapi, info, servers, tags, security, ...). Concatenated and parsed as
|
|
30
|
+
* one small document for the head (servers, info). */
|
|
31
|
+
readonly headRanges: readonly ByteRange[];
|
|
32
|
+
/** One range per path-item: the indent-2 entries under `paths:`. */
|
|
33
|
+
readonly pathItems: readonly ByteRange[];
|
|
34
|
+
/** One range per schema entry: the indent-4 entries under
|
|
35
|
+
* `components.schemas:`. */
|
|
36
|
+
readonly schemas: readonly ByteRange[];
|
|
37
|
+
/** Ranges of the indent-2 `components` subkeys we keep whole because they are
|
|
38
|
+
* small and may be `$ref`'d by a kept operation (parameters / requestBodies /
|
|
39
|
+
* responses / headers / links / securitySchemes). Excludes the huge `schemas`
|
|
40
|
+
* (streamed and pruned separately) and `examples` (never referenced by a
|
|
41
|
+
* binding). */
|
|
42
|
+
readonly smallComponentRanges: readonly ByteRange[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Scan a document into its structural ranges. Pure and synchronous; never
|
|
46
|
+
* parses. Returns null when the document does not present the expected shape
|
|
47
|
+
* (no `paths:` block), so the caller can fall back to a whole-document parse.
|
|
48
|
+
*/
|
|
49
|
+
export declare const structuralSplit: (text: string) => SpecStructure | null;
|
|
50
|
+
/**
|
|
51
|
+
* Parse a single indent-N entry range (a path-item or a schema) in isolation.
|
|
52
|
+
* Returns `[name, value]` where `name` is the entry's key and `value` its
|
|
53
|
+
* parsed body, or null when the fragment does not parse to a single-key map.
|
|
54
|
+
*/
|
|
55
|
+
export declare const parseEntry: (text: string, range: ByteRange, indent: number) => readonly [string, unknown] | null;
|
|
56
|
+
/** Parse the concatenation of the head ranges into the document head (openapi,
|
|
57
|
+
* info, servers, tags). Small; safe to materialize whole. */
|
|
58
|
+
export declare const parseHead: (structure: SpecStructure) => Record<string, unknown>;
|
|
59
|
+
/** Parse the small component subkeys (parameters / requestBodies / responses)
|
|
60
|
+
* into a `components`-shaped object for `$ref` resolution. */
|
|
61
|
+
export declare const parseSmallComponents: (structure: SpecStructure) => Record<string, unknown>;
|
|
62
|
+
/**
|
|
63
|
+
* Accept only the block-YAML profile the splitter can safely slice: no tabs, no
|
|
64
|
+
* anchors/aliases, no merge keys, and a `paths:` block present. Block scalars
|
|
65
|
+
* are allowed (tracked during the scan). Conservative by design: a false
|
|
66
|
+
* negative just routes a spec through the whole-document parse.
|
|
67
|
+
*/
|
|
68
|
+
export declare const isStreamableSpec: (text: string) => boolean;
|
|
69
|
+
/** Map each `components.schemas` entry name to its byte range, reading only the
|
|
70
|
+
* key line (never parsing the schema body). The schema name is the raw YAML
|
|
71
|
+
* key, which matches the trailing segment of a `#/components/schemas/<name>`
|
|
72
|
+
* reference. */
|
|
73
|
+
export declare const indexSchemas: (structure: SpecStructure) => ReadonlyMap<string, ByteRange>;
|
|
74
|
+
/**
|
|
75
|
+
* Resolve the transitive closure of schemas referenced by `roots`, parsing each
|
|
76
|
+
* referenced schema once from its byte range (BFS over `$ref`s). Schemas not
|
|
77
|
+
* reachable from `roots` are never parsed, so peak memory tracks the kept
|
|
78
|
+
* subset rather than the full `components.schemas` map.
|
|
79
|
+
*/
|
|
80
|
+
export declare const collectReferencedSchemas: (structure: SpecStructure, index: ReadonlyMap<string, ByteRange>, roots: readonly unknown[]) => Record<string, unknown>;
|
|
81
|
+
/** A path-item filter for the streaming compile: given a parsed path-item,
|
|
82
|
+
* return the (possibly trimmed) value to keep, or null to drop the path
|
|
83
|
+
* entirely. Applied per path-item by `streamOperationBindingsFromStructure`. */
|
|
84
|
+
export type KeepPathItem = (path: string, pathItem: Record<string, unknown>) => Record<string, unknown> | null;
|
package/dist/sdk/store.d.ts
CHANGED
|
@@ -7,13 +7,25 @@ export interface StoredOperation {
|
|
|
7
7
|
/** The tool name (the `<tool>` address segment) this operation backs. */
|
|
8
8
|
readonly toolName: string;
|
|
9
9
|
readonly binding: OperationBinding;
|
|
10
|
+
/** Resolved tool description, persisted alongside the binding so the serve
|
|
11
|
+
* path can rebuild the tool def without re-parsing the spec. */
|
|
12
|
+
readonly description?: string;
|
|
10
13
|
}
|
|
11
14
|
/** Blob key for a spec's content hash. Content-addressed so re-puts are
|
|
12
15
|
* idempotent and identical specs share one blob per partition. */
|
|
13
16
|
export declare const specBlobKey: (specHash: string) => string;
|
|
17
|
+
/** Blob key for a spec's compiled `#/$defs/*` schemas, keyed by the same
|
|
18
|
+
* content hash as the spec. The serve path reads this instead of re-parsing
|
|
19
|
+
* the (potentially multi-MB) spec to rebuild the shared `definitions`. */
|
|
20
|
+
export declare const defsBlobKey: (specHash: string) => string;
|
|
14
21
|
export interface OpenapiStore {
|
|
15
22
|
/** Replace all stored operations for an integration. */
|
|
16
23
|
readonly putOperations: (integration: string, operations: readonly StoredOperation[]) => Effect.Effect<void, StorageFailure>;
|
|
24
|
+
/** Append operations without clearing existing ones. The caller is
|
|
25
|
+
* responsible for `removeOperations` first when doing a full rebuild. Used
|
|
26
|
+
* by the streaming compile path, which persists operations chunk by chunk so
|
|
27
|
+
* a huge spec's bindings are never all materialized at once. */
|
|
28
|
+
readonly appendOperations: (integration: string, operations: readonly StoredOperation[]) => Effect.Effect<void, StorageFailure>;
|
|
17
29
|
/** Look up one operation by integration + tool name. */
|
|
18
30
|
readonly getOperation: (integration: string, toolName: string) => Effect.Effect<StoredOperation | null, StorageFailure>;
|
|
19
31
|
/** List every stored operation for an integration. */
|
|
@@ -26,5 +38,12 @@ export interface OpenapiStore {
|
|
|
26
38
|
readonly putSpec: (specHash: string, specText: string) => Effect.Effect<void, StorageFailure>;
|
|
27
39
|
/** Load spec text by content hash; null when no blob exists. */
|
|
28
40
|
readonly getSpec: (specHash: string) => Effect.Effect<string | null, StorageFailure>;
|
|
41
|
+
/** Persist the compiled `#/$defs/*` JSON for a spec under its content hash.
|
|
42
|
+
* Content-addressed like the spec blob; lets the serve path serve the shared
|
|
43
|
+
* `definitions` without re-parsing the spec. */
|
|
44
|
+
readonly putDefs: (specHash: string, defsJson: string) => Effect.Effect<void, StorageFailure>;
|
|
45
|
+
/** Load the compiled `#/$defs/*` JSON by content hash; null when no blob
|
|
46
|
+
* exists (legacy rows added before the defs blob). */
|
|
47
|
+
readonly getDefs: (specHash: string) => Effect.Effect<string | null, StorageFailure>;
|
|
29
48
|
}
|
|
30
49
|
export declare const makeDefaultOpenapiStore: ({ pluginStorage, blobs }: StorageDeps) => OpenapiStore;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@executor-js/plugin-openapi",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.18",
|
|
4
4
|
"homepage": "https://github.com/RhysSullivan/executor/tree/main/packages/plugins/openapi",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/RhysSullivan/executor/issues"
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@effect/platform-node": "4.0.0-beta.59",
|
|
56
|
-
"@executor-js/config": "1.5.
|
|
57
|
-
"@executor-js/sdk": "1.5.
|
|
56
|
+
"@executor-js/config": "1.5.18",
|
|
57
|
+
"@executor-js/sdk": "1.5.18",
|
|
58
58
|
"js-yaml": "4.1.1",
|
|
59
59
|
"lucide-react": "^1.7.0",
|
|
60
60
|
"openapi-types": "^12.1.3"
|