@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
|
@@ -103,12 +103,219 @@ var parseTextToObject = (text) => Effect.gen(function* () {
|
|
|
103
103
|
});
|
|
104
104
|
var parseJsonText = Schema2.decodeUnknownEffect(Schema2.fromJsonString(Schema2.Unknown));
|
|
105
105
|
var parseJsonLike = (text) => {
|
|
106
|
-
const
|
|
106
|
+
const parseYaml2 = Effect.try({
|
|
107
107
|
try: () => parseYamlDocument(text, { json: true, schema: JSON_SCHEMA }),
|
|
108
108
|
catch: () => "YamlParseFailed"
|
|
109
109
|
});
|
|
110
|
-
if (!text.startsWith("{") && !text.startsWith("[")) return
|
|
111
|
-
return parseJsonText(text).pipe(Effect.catch(() =>
|
|
110
|
+
if (!text.startsWith("{") && !text.startsWith("[")) return parseYaml2;
|
|
111
|
+
return parseJsonText(text).pipe(Effect.catch(() => parseYaml2));
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
// src/sdk/split.ts
|
|
115
|
+
import { JSON_SCHEMA as JSON_SCHEMA2, load as parseYamlDocument2 } from "js-yaml";
|
|
116
|
+
var SPACE = 32;
|
|
117
|
+
var HASH = 35;
|
|
118
|
+
var DASH = 45;
|
|
119
|
+
var SMALL_COMPONENT_SECTIONS = /* @__PURE__ */ new Set([
|
|
120
|
+
"parameters",
|
|
121
|
+
"requestBodies",
|
|
122
|
+
"responses",
|
|
123
|
+
"headers",
|
|
124
|
+
"links",
|
|
125
|
+
"securitySchemes"
|
|
126
|
+
]);
|
|
127
|
+
var indentOf = (text, lineStart, lineEnd) => {
|
|
128
|
+
let i = lineStart;
|
|
129
|
+
while (i < lineEnd && text.charCodeAt(i) === SPACE) i++;
|
|
130
|
+
return i - lineStart;
|
|
131
|
+
};
|
|
132
|
+
var isBlankOrComment = (text, contentStart, lineEnd) => contentStart >= lineEnd || text.charCodeAt(contentStart) === HASH;
|
|
133
|
+
var opensBlockScalar = (line) => /:\s*[|>][+-]?\d*\s*(#.*)?$/.test(line) || /^\s*[|>][+-]?\d*\s*(#.*)?$/.test(line);
|
|
134
|
+
var lineAt = (text, from, limit) => {
|
|
135
|
+
if (from >= limit) return null;
|
|
136
|
+
let lineEnd = text.indexOf("\n", from);
|
|
137
|
+
if (lineEnd === -1 || lineEnd > limit) lineEnd = limit;
|
|
138
|
+
const indent = indentOf(text, from, lineEnd);
|
|
139
|
+
const contentStart = from + indent;
|
|
140
|
+
return {
|
|
141
|
+
lineStart: from,
|
|
142
|
+
lineEnd,
|
|
143
|
+
nextStart: lineEnd + 1,
|
|
144
|
+
indent,
|
|
145
|
+
contentStart
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
var keyLineStartsAtIndent = (text, start, end, indent) => {
|
|
149
|
+
const starts = [];
|
|
150
|
+
let blockScalarIndent = -1;
|
|
151
|
+
let pos = start;
|
|
152
|
+
while (pos < end) {
|
|
153
|
+
const line = lineAt(text, pos, end);
|
|
154
|
+
if (!line) break;
|
|
155
|
+
pos = line.nextStart;
|
|
156
|
+
if (isBlankOrComment(text, line.contentStart, line.lineEnd)) continue;
|
|
157
|
+
if (blockScalarIndent >= 0) {
|
|
158
|
+
if (line.indent > blockScalarIndent) continue;
|
|
159
|
+
blockScalarIndent = -1;
|
|
160
|
+
}
|
|
161
|
+
if (line.indent === indent && text.charCodeAt(line.contentStart) !== DASH) {
|
|
162
|
+
starts.push(line.lineStart);
|
|
163
|
+
}
|
|
164
|
+
if (line.indent <= indent && opensBlockScalar(text.slice(line.contentStart, line.lineEnd))) {
|
|
165
|
+
blockScalarIndent = line.indent;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return starts;
|
|
169
|
+
};
|
|
170
|
+
var rangesFromStarts = (starts, blockEnd) => starts.map((s, i) => ({ start: s, end: i + 1 < starts.length ? starts[i + 1] : blockEnd }));
|
|
171
|
+
var keyNameAt = (text, lineStart, lineEnd) => {
|
|
172
|
+
const indent = indentOf(text, lineStart, lineEnd);
|
|
173
|
+
const colon = text.indexOf(":", lineStart + indent);
|
|
174
|
+
const keyEnd = colon === -1 || colon > lineEnd ? lineEnd : colon;
|
|
175
|
+
return text.slice(lineStart + indent, keyEnd).trim();
|
|
176
|
+
};
|
|
177
|
+
var structuralSplit = (text) => {
|
|
178
|
+
const len = text.length;
|
|
179
|
+
const topStarts = [];
|
|
180
|
+
const topNames = [];
|
|
181
|
+
{
|
|
182
|
+
let blockScalarIndent = -1;
|
|
183
|
+
let pos = 0;
|
|
184
|
+
while (pos < len) {
|
|
185
|
+
const line = lineAt(text, pos, len);
|
|
186
|
+
if (!line) break;
|
|
187
|
+
pos = line.nextStart;
|
|
188
|
+
if (isBlankOrComment(text, line.contentStart, line.lineEnd)) continue;
|
|
189
|
+
if (blockScalarIndent >= 0) {
|
|
190
|
+
if (line.indent > blockScalarIndent) continue;
|
|
191
|
+
blockScalarIndent = -1;
|
|
192
|
+
}
|
|
193
|
+
if (line.indent === 0) {
|
|
194
|
+
topStarts.push(line.lineStart);
|
|
195
|
+
topNames.push(keyNameAt(text, line.lineStart, line.lineEnd));
|
|
196
|
+
}
|
|
197
|
+
if (opensBlockScalar(text.slice(line.contentStart, line.lineEnd))) {
|
|
198
|
+
blockScalarIndent = line.indent;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
const topRanges = rangesFromStarts(topStarts, len);
|
|
203
|
+
const pathsIdx = topNames.indexOf("paths");
|
|
204
|
+
if (pathsIdx === -1) return null;
|
|
205
|
+
const componentsIdx = topNames.indexOf("components");
|
|
206
|
+
const headRanges = [];
|
|
207
|
+
for (let i = 0; i < topRanges.length; i++) {
|
|
208
|
+
if (i === pathsIdx || i === componentsIdx) continue;
|
|
209
|
+
headRanges.push(topRanges[i]);
|
|
210
|
+
}
|
|
211
|
+
const pathsRange = topRanges[pathsIdx];
|
|
212
|
+
const pathsBodyStart = lineAt(text, pathsRange.start, pathsRange.end)?.nextStart ?? pathsRange.end;
|
|
213
|
+
const pathItems = rangesFromStarts(
|
|
214
|
+
keyLineStartsAtIndent(text, pathsBodyStart, pathsRange.end, 2),
|
|
215
|
+
pathsRange.end
|
|
216
|
+
);
|
|
217
|
+
const schemas = [];
|
|
218
|
+
const smallComponentRanges = [];
|
|
219
|
+
if (componentsIdx !== -1) {
|
|
220
|
+
const componentsRange = topRanges[componentsIdx];
|
|
221
|
+
const componentsBodyStart = lineAt(text, componentsRange.start, componentsRange.end)?.nextStart ?? componentsRange.end;
|
|
222
|
+
const subStarts = keyLineStartsAtIndent(text, componentsBodyStart, componentsRange.end, 2);
|
|
223
|
+
const subRanges = rangesFromStarts(subStarts, componentsRange.end);
|
|
224
|
+
for (const range of subRanges) {
|
|
225
|
+
const name = keyNameAt(text, range.start, lineAt(text, range.start, range.end).lineEnd);
|
|
226
|
+
if (name === "schemas") {
|
|
227
|
+
const bodyStart = lineAt(text, range.start, range.end)?.nextStart ?? range.end;
|
|
228
|
+
for (const s of rangesFromStarts(
|
|
229
|
+
keyLineStartsAtIndent(text, bodyStart, range.end, 4),
|
|
230
|
+
range.end
|
|
231
|
+
)) {
|
|
232
|
+
schemas.push(s);
|
|
233
|
+
}
|
|
234
|
+
} else if (SMALL_COMPONENT_SECTIONS.has(name)) {
|
|
235
|
+
smallComponentRanges.push(range);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return { text, headRanges, pathItems, schemas, smallComponentRanges };
|
|
240
|
+
};
|
|
241
|
+
var dedent = (fragment, indent) => indent === 0 ? fragment : fragment.replace(new RegExp(`^ {1,${indent}}`, "gm"), "");
|
|
242
|
+
var parseYaml = (text) => parseYamlDocument2(text, { json: true, schema: JSON_SCHEMA2 });
|
|
243
|
+
var parseEntry = (text, range, indent) => {
|
|
244
|
+
const parsed = parseYaml(dedent(text.slice(range.start, range.end), indent));
|
|
245
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
246
|
+
const entries = Object.entries(parsed);
|
|
247
|
+
if (entries.length !== 1) return null;
|
|
248
|
+
return entries[0];
|
|
249
|
+
};
|
|
250
|
+
var parseHead = (structure) => {
|
|
251
|
+
const text = structure.headRanges.map((r) => structure.text.slice(r.start, r.end)).join("");
|
|
252
|
+
const parsed = parseYaml(text);
|
|
253
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
|
|
254
|
+
};
|
|
255
|
+
var parseSmallComponents = (structure) => {
|
|
256
|
+
if (structure.smallComponentRanges.length === 0) return {};
|
|
257
|
+
const body = structure.smallComponentRanges.map((r) => structure.text.slice(r.start, r.end)).join("");
|
|
258
|
+
const parsed = parseYaml(`components:
|
|
259
|
+
${body}`);
|
|
260
|
+
const components = parsed && typeof parsed === "object" ? parsed.components : null;
|
|
261
|
+
return components && typeof components === "object" ? components : {};
|
|
262
|
+
};
|
|
263
|
+
var isStreamableSpec = (text) => {
|
|
264
|
+
if (text.indexOf(" ") !== -1) return false;
|
|
265
|
+
if (/(^|\s)[&*][A-Za-z0-9_]/m.test(text)) return false;
|
|
266
|
+
if (/<<\s*:/.test(text)) return false;
|
|
267
|
+
return /^paths:/m.test(text);
|
|
268
|
+
};
|
|
269
|
+
var SCHEMA_REF_PREFIX = "#/components/schemas/";
|
|
270
|
+
var indexSchemas = (structure) => {
|
|
271
|
+
const index = /* @__PURE__ */ new Map();
|
|
272
|
+
for (const range of structure.schemas) {
|
|
273
|
+
const line = lineAt(structure.text, range.start, range.end);
|
|
274
|
+
if (!line) continue;
|
|
275
|
+
const name = keyNameAt(structure.text, range.start, line.lineEnd);
|
|
276
|
+
if (name) index.set(name, range);
|
|
277
|
+
}
|
|
278
|
+
return index;
|
|
279
|
+
};
|
|
280
|
+
var decodeSchemaRefName = (segment) => segment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
281
|
+
var collectSchemaRefNames = (value, into) => {
|
|
282
|
+
if (typeof value === "string") {
|
|
283
|
+
if (value.startsWith(SCHEMA_REF_PREFIX)) {
|
|
284
|
+
const name = decodeSchemaRefName(value.slice(SCHEMA_REF_PREFIX.length));
|
|
285
|
+
if (name.length > 0) into.add(name);
|
|
286
|
+
}
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
if (Array.isArray(value)) {
|
|
290
|
+
for (const item of value) collectSchemaRefNames(item, into);
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
if (value !== null && typeof value === "object") {
|
|
294
|
+
for (const item of Object.values(value)) {
|
|
295
|
+
collectSchemaRefNames(item, into);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
var collectReferencedSchemas = (structure, index, roots) => {
|
|
300
|
+
const result = {};
|
|
301
|
+
const wanted = /* @__PURE__ */ new Set();
|
|
302
|
+
for (const root of roots) collectSchemaRefNames(root, wanted);
|
|
303
|
+
const queue = [...wanted];
|
|
304
|
+
for (let i = 0; i < queue.length; i += 1) {
|
|
305
|
+
const name = queue[i];
|
|
306
|
+
if (Object.prototype.hasOwnProperty.call(result, name)) continue;
|
|
307
|
+
const range = index.get(name);
|
|
308
|
+
if (!range) continue;
|
|
309
|
+
const entry = parseEntry(structure.text, range, 4);
|
|
310
|
+
if (!entry) continue;
|
|
311
|
+
result[name] = entry[1];
|
|
312
|
+
const next = /* @__PURE__ */ new Set();
|
|
313
|
+
collectSchemaRefNames(entry[1], next);
|
|
314
|
+
for (const ref of next) {
|
|
315
|
+
if (!Object.prototype.hasOwnProperty.call(result, ref)) queue.push(ref);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return result;
|
|
112
319
|
};
|
|
113
320
|
|
|
114
321
|
// src/sdk/openapi-utils.ts
|
|
@@ -290,7 +497,162 @@ var InvocationResult = Schema3.Struct({
|
|
|
290
497
|
});
|
|
291
498
|
|
|
292
499
|
// src/sdk/extract.ts
|
|
293
|
-
import { Effect as Effect2, Option } from "effect";
|
|
500
|
+
import { Effect as Effect2, Option as Option2 } from "effect";
|
|
501
|
+
|
|
502
|
+
// src/sdk/definitions.ts
|
|
503
|
+
import { Option } from "effect";
|
|
504
|
+
var splitWords = (value) => value.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z0-9]+)/g, "$1 $2").replace(/[^a-zA-Z0-9]+/g, " ").trim().split(/\s+/).filter((part) => part.length > 0);
|
|
505
|
+
var normalizeWord = (value) => value.toLowerCase();
|
|
506
|
+
var toCamelCase = (value) => {
|
|
507
|
+
const words = splitWords(value).map(normalizeWord);
|
|
508
|
+
if (words.length === 0) return "tool";
|
|
509
|
+
const [first, ...rest] = words;
|
|
510
|
+
return `${first}${rest.map((p) => `${p[0]?.toUpperCase() ?? ""}${p.slice(1)}`).join("")}`;
|
|
511
|
+
};
|
|
512
|
+
var toPascalCase = (value) => {
|
|
513
|
+
const camel = toCamelCase(value);
|
|
514
|
+
return `${camel[0]?.toUpperCase() ?? ""}${camel.slice(1)}`;
|
|
515
|
+
};
|
|
516
|
+
var VERSION_SEGMENT_REGEX = /^v\d+(?:[._-]\d+)?$/i;
|
|
517
|
+
var IGNORED_PATH_SEGMENTS = /* @__PURE__ */ new Set(["api"]);
|
|
518
|
+
var pathSegmentsFromTemplate = (pathTemplate) => pathTemplate.split("/").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
519
|
+
var isPathParameterSegment = (segment) => segment.startsWith("{") && segment.endsWith("}");
|
|
520
|
+
var normalizeGroupSegment = (value) => {
|
|
521
|
+
const candidate = value?.trim();
|
|
522
|
+
if (!candidate) return null;
|
|
523
|
+
return toCamelCase(candidate);
|
|
524
|
+
};
|
|
525
|
+
var deriveVersionSegment = (pathTemplate) => pathSegmentsFromTemplate(pathTemplate).map((s) => s.toLowerCase()).find((s) => VERSION_SEGMENT_REGEX.test(s));
|
|
526
|
+
var derivePathGroup = (pathTemplate) => {
|
|
527
|
+
for (const segment of pathSegmentsFromTemplate(pathTemplate)) {
|
|
528
|
+
const lower = segment.toLowerCase();
|
|
529
|
+
if (VERSION_SEGMENT_REGEX.test(lower)) continue;
|
|
530
|
+
if (IGNORED_PATH_SEGMENTS.has(lower)) continue;
|
|
531
|
+
if (isPathParameterSegment(segment)) continue;
|
|
532
|
+
return normalizeGroupSegment(segment) ?? "root";
|
|
533
|
+
}
|
|
534
|
+
return "root";
|
|
535
|
+
};
|
|
536
|
+
var splitOperationIdSegments = (value) => value.split(/[/.]+/).map((s) => s.trim()).filter((s) => s.length > 0);
|
|
537
|
+
var deriveLeafSeed = (operationId, group) => {
|
|
538
|
+
const segments = splitOperationIdSegments(operationId);
|
|
539
|
+
if (segments.length > 1) {
|
|
540
|
+
const [first, ...rest] = segments;
|
|
541
|
+
if ((normalizeGroupSegment(first) ?? first) === group && rest.length > 0) {
|
|
542
|
+
return rest.join(" ");
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
return operationId;
|
|
546
|
+
};
|
|
547
|
+
var fallbackLeafSeed = (method, pathTemplate, group) => {
|
|
548
|
+
const relevantSegments = pathSegmentsFromTemplate(pathTemplate).filter((s) => !VERSION_SEGMENT_REGEX.test(s.toLowerCase())).filter((s) => !IGNORED_PATH_SEGMENTS.has(s.toLowerCase())).filter((s) => !isPathParameterSegment(s)).map((s) => normalizeGroupSegment(s) ?? s).filter((s) => s !== group);
|
|
549
|
+
const segmentSuffix = relevantSegments.map((s) => toPascalCase(s)).join("");
|
|
550
|
+
return `${method}${segmentSuffix || "Operation"}`;
|
|
551
|
+
};
|
|
552
|
+
var deriveLeaf = (operationId, method, pathTemplate, group) => {
|
|
553
|
+
const preferred = toCamelCase(deriveLeafSeed(operationId, group));
|
|
554
|
+
if (preferred.length > 0 && preferred !== group) return preferred;
|
|
555
|
+
return toCamelCase(fallbackLeafSeed(method, pathTemplate, group));
|
|
556
|
+
};
|
|
557
|
+
var resolveCollisions = (definitions) => {
|
|
558
|
+
const staged = definitions.map((d) => ({ ...d }));
|
|
559
|
+
const applyFactory = (items, factory) => {
|
|
560
|
+
const byPath = /* @__PURE__ */ new Map();
|
|
561
|
+
for (const item of items) {
|
|
562
|
+
const bucket = byPath.get(item.toolPath) ?? [];
|
|
563
|
+
bucket.push(item);
|
|
564
|
+
byPath.set(item.toolPath, bucket);
|
|
565
|
+
}
|
|
566
|
+
for (const bucket of byPath.values()) {
|
|
567
|
+
if (bucket.length < 2) continue;
|
|
568
|
+
for (const d of bucket) {
|
|
569
|
+
d.toolPath = factory(d);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
};
|
|
573
|
+
applyFactory(
|
|
574
|
+
staged,
|
|
575
|
+
(d) => d.versionSegment ? `${d.group}.${d.versionSegment}.${d.leaf}` : d.toolPath
|
|
576
|
+
);
|
|
577
|
+
applyFactory(staged, (d) => {
|
|
578
|
+
const prefix = d.versionSegment ? `${d.group}.${d.versionSegment}` : d.group;
|
|
579
|
+
return `${prefix}.${d.leaf}${toPascalCase(d.method)}`;
|
|
580
|
+
});
|
|
581
|
+
applyFactory(staged, (d) => {
|
|
582
|
+
const prefix = d.versionSegment ? `${d.group}.${d.versionSegment}` : d.group;
|
|
583
|
+
return `${prefix}.${d.leaf}${toPascalCase(d.method)}${d.operationHash.slice(0, 8)}`;
|
|
584
|
+
});
|
|
585
|
+
return staged.map((d) => ({
|
|
586
|
+
toolPath: d.toolPath,
|
|
587
|
+
group: d.group,
|
|
588
|
+
leaf: d.leaf,
|
|
589
|
+
operationIndex: d.operationIndex
|
|
590
|
+
}));
|
|
591
|
+
};
|
|
592
|
+
var stableHash = (value) => {
|
|
593
|
+
const str = JSON.stringify(value, Object.keys(value).sort());
|
|
594
|
+
let hash = 0;
|
|
595
|
+
for (let i = 0; i < str.length; i++) {
|
|
596
|
+
hash = (hash << 5) - hash + str.charCodeAt(i) | 0;
|
|
597
|
+
}
|
|
598
|
+
return Math.abs(hash).toString(36).padStart(8, "0");
|
|
599
|
+
};
|
|
600
|
+
var planToolPaths = (inputs) => {
|
|
601
|
+
const raw = inputs.map((op, index) => {
|
|
602
|
+
const operationId = op.operationId;
|
|
603
|
+
const operationHash = stableHash({
|
|
604
|
+
method: op.method,
|
|
605
|
+
path: op.pathTemplate,
|
|
606
|
+
operationId
|
|
607
|
+
});
|
|
608
|
+
const versionSegment = deriveVersionSegment(op.pathTemplate);
|
|
609
|
+
if (op.explicitToolPath) {
|
|
610
|
+
const [group2 = "root", ...leafParts] = op.explicitToolPath.split(".").filter(Boolean);
|
|
611
|
+
const leaf2 = leafParts.join(".") || group2;
|
|
612
|
+
return {
|
|
613
|
+
toolPath: op.explicitToolPath,
|
|
614
|
+
group: group2,
|
|
615
|
+
leaf: leaf2,
|
|
616
|
+
versionSegment,
|
|
617
|
+
method: op.method,
|
|
618
|
+
operationHash,
|
|
619
|
+
operationIndex: index
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
const group = normalizeGroupSegment(op.tag0) ?? derivePathGroup(op.pathTemplate);
|
|
623
|
+
const leaf = deriveLeaf(operationId, op.method, op.pathTemplate, group);
|
|
624
|
+
return {
|
|
625
|
+
toolPath: `${group}.${leaf}`,
|
|
626
|
+
group,
|
|
627
|
+
leaf,
|
|
628
|
+
versionSegment,
|
|
629
|
+
method: op.method,
|
|
630
|
+
operationHash,
|
|
631
|
+
operationIndex: index
|
|
632
|
+
};
|
|
633
|
+
});
|
|
634
|
+
return resolveCollisions(raw).sort((a, b) => a.toolPath.localeCompare(b.toolPath));
|
|
635
|
+
};
|
|
636
|
+
var compileToolDefinitions = (operations) => {
|
|
637
|
+
const plans = planToolPaths(
|
|
638
|
+
operations.map((op) => ({
|
|
639
|
+
operationId: op.operationId,
|
|
640
|
+
explicitToolPath: Option.getOrUndefined(op.toolPath),
|
|
641
|
+
method: op.method,
|
|
642
|
+
pathTemplate: op.pathTemplate,
|
|
643
|
+
tag0: op.tags[0]
|
|
644
|
+
}))
|
|
645
|
+
);
|
|
646
|
+
return plans.map((plan) => ({
|
|
647
|
+
toolPath: plan.toolPath,
|
|
648
|
+
group: plan.group,
|
|
649
|
+
leaf: plan.leaf,
|
|
650
|
+
operationIndex: plan.operationIndex,
|
|
651
|
+
operation: operations[plan.operationIndex]
|
|
652
|
+
}));
|
|
653
|
+
};
|
|
654
|
+
|
|
655
|
+
// src/sdk/extract.ts
|
|
294
656
|
var HTTP_METHODS = [
|
|
295
657
|
"get",
|
|
296
658
|
"put",
|
|
@@ -319,11 +681,11 @@ var extractParameters = (pathItem, operation, r) => {
|
|
|
319
681
|
name: p.name,
|
|
320
682
|
location: p.in,
|
|
321
683
|
required: p.in === "path" ? true : p.required === true,
|
|
322
|
-
schema:
|
|
323
|
-
style:
|
|
324
|
-
explode:
|
|
325
|
-
allowReserved:
|
|
326
|
-
description:
|
|
684
|
+
schema: Option2.fromNullishOr(p.schema),
|
|
685
|
+
style: Option2.fromNullishOr(p.style),
|
|
686
|
+
explode: Option2.fromNullishOr(p.explode),
|
|
687
|
+
allowReserved: Option2.fromNullishOr("allowReserved" in p ? p.allowReserved : void 0),
|
|
688
|
+
description: Option2.fromNullishOr(p.description)
|
|
327
689
|
})
|
|
328
690
|
);
|
|
329
691
|
};
|
|
@@ -334,10 +696,10 @@ var buildEncodingRecord = (encoding) => {
|
|
|
334
696
|
if (typeof raw !== "object" || raw === null) continue;
|
|
335
697
|
const e = raw;
|
|
336
698
|
out[prop] = EncodingObject.make({
|
|
337
|
-
contentType:
|
|
338
|
-
style:
|
|
339
|
-
explode:
|
|
340
|
-
allowReserved:
|
|
699
|
+
contentType: Option2.fromNullishOr(e.contentType),
|
|
700
|
+
style: Option2.fromNullishOr(e.style),
|
|
701
|
+
explode: Option2.fromNullishOr(e.explode),
|
|
702
|
+
allowReserved: Option2.fromNullishOr(e.allowReserved)
|
|
341
703
|
});
|
|
342
704
|
}
|
|
343
705
|
return Object.keys(out).length > 0 ? out : void 0;
|
|
@@ -349,8 +711,8 @@ var extractRequestBody = (operation, r) => {
|
|
|
349
711
|
const contents = declaredContents(body.content).map(
|
|
350
712
|
({ mediaType, media }) => MediaBinding.make({
|
|
351
713
|
contentType: mediaType,
|
|
352
|
-
schema:
|
|
353
|
-
encoding:
|
|
714
|
+
schema: Option2.fromNullishOr(media.schema),
|
|
715
|
+
encoding: Option2.fromNullishOr(
|
|
354
716
|
buildEncodingRecord(media.encoding)
|
|
355
717
|
)
|
|
356
718
|
})
|
|
@@ -361,7 +723,7 @@ var extractRequestBody = (operation, r) => {
|
|
|
361
723
|
required: body.required === true,
|
|
362
724
|
contentType: defaultContent.contentType,
|
|
363
725
|
schema: defaultContent.schema,
|
|
364
|
-
contents:
|
|
726
|
+
contents: Option2.some(contents)
|
|
365
727
|
});
|
|
366
728
|
};
|
|
367
729
|
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -380,10 +742,10 @@ var detectFileHint = (schema, mediaType, r) => {
|
|
|
380
742
|
if (!isJsonMediaType(mediaType) && binaryStringSchema(resolved)) {
|
|
381
743
|
return OperationFileHint.make({
|
|
382
744
|
kind: "binaryResponse",
|
|
383
|
-
mimeType:
|
|
384
|
-
dataField:
|
|
385
|
-
sizeField:
|
|
386
|
-
encoding:
|
|
745
|
+
mimeType: Option2.some(mediaType),
|
|
746
|
+
dataField: Option2.none(),
|
|
747
|
+
sizeField: Option2.none(),
|
|
748
|
+
encoding: Option2.none()
|
|
387
749
|
});
|
|
388
750
|
}
|
|
389
751
|
if (!isJsonMediaType(mediaType)) return void 0;
|
|
@@ -397,10 +759,10 @@ var detectFileHint = (schema, mediaType, r) => {
|
|
|
397
759
|
const sizeField = sizeSchema && numericType(sizeSchema) ? "size" : void 0;
|
|
398
760
|
return OperationFileHint.make({
|
|
399
761
|
kind: "byteField",
|
|
400
|
-
mimeType:
|
|
401
|
-
dataField:
|
|
402
|
-
sizeField: sizeField ?
|
|
403
|
-
encoding:
|
|
762
|
+
mimeType: Option2.some("application/octet-stream"),
|
|
763
|
+
dataField: Option2.some("data"),
|
|
764
|
+
sizeField: sizeField ? Option2.some(sizeField) : Option2.none(),
|
|
765
|
+
encoding: Option2.some(base64EncodingFromDescription(dataSchema))
|
|
404
766
|
});
|
|
405
767
|
};
|
|
406
768
|
var extractResponseBody = (operation, r) => {
|
|
@@ -417,8 +779,8 @@ var extractResponseBody = (operation, r) => {
|
|
|
417
779
|
if (content?.media.schema) {
|
|
418
780
|
return OperationResponseBody.make({
|
|
419
781
|
contentType: content.mediaType,
|
|
420
|
-
schema:
|
|
421
|
-
fileHint:
|
|
782
|
+
schema: Option2.some(content.media.schema),
|
|
783
|
+
fileHint: Option2.fromNullishOr(detectFileHint(content.media.schema, content.mediaType, r))
|
|
422
784
|
});
|
|
423
785
|
}
|
|
424
786
|
}
|
|
@@ -427,7 +789,7 @@ var extractResponseBody = (operation, r) => {
|
|
|
427
789
|
var buildServerInputProperty = (servers) => {
|
|
428
790
|
const variableDefs = {};
|
|
429
791
|
for (const server of servers) {
|
|
430
|
-
for (const [name, v] of Object.entries(
|
|
792
|
+
for (const [name, v] of Object.entries(Option2.getOrUndefined(server.variables) ?? {})) {
|
|
431
793
|
if (!(name in variableDefs)) variableDefs[name] = v;
|
|
432
794
|
}
|
|
433
795
|
}
|
|
@@ -453,8 +815,8 @@ var buildServerInputProperty = (servers) => {
|
|
|
453
815
|
{
|
|
454
816
|
type: "string",
|
|
455
817
|
default: v.default,
|
|
456
|
-
...
|
|
457
|
-
...
|
|
818
|
+
...Option2.isSome(v.enum) ? { enum: v.enum.value } : {},
|
|
819
|
+
...Option2.isSome(v.description) ? { description: v.description.value } : {}
|
|
458
820
|
}
|
|
459
821
|
])
|
|
460
822
|
),
|
|
@@ -472,15 +834,15 @@ var buildInputSchema = (parameters, requestBody, servers) => {
|
|
|
472
834
|
const properties = {};
|
|
473
835
|
const required = [];
|
|
474
836
|
for (const param of parameters) {
|
|
475
|
-
properties[param.name] =
|
|
837
|
+
properties[param.name] = Option2.getOrElse(param.schema, () => ({ type: "string" }));
|
|
476
838
|
if (param.required) required.push(param.name);
|
|
477
839
|
}
|
|
478
840
|
const serverProperty = buildServerInputProperty(servers);
|
|
479
841
|
if (serverProperty && !("server" in properties)) properties.server = serverProperty;
|
|
480
842
|
if (requestBody) {
|
|
481
|
-
properties.body =
|
|
843
|
+
properties.body = Option2.getOrElse(requestBody.schema, () => ({ type: "object" }));
|
|
482
844
|
if (requestBody.required) required.push("body");
|
|
483
|
-
const contents =
|
|
845
|
+
const contents = Option2.getOrUndefined(requestBody.contents);
|
|
484
846
|
if (contents && contents.length > 1) {
|
|
485
847
|
properties.contentType = {
|
|
486
848
|
type: "string",
|
|
@@ -519,8 +881,8 @@ var extractServerList = (servers) => (servers ?? []).flatMap((server) => {
|
|
|
519
881
|
name,
|
|
520
882
|
ServerVariable.make({
|
|
521
883
|
default: String(v.default),
|
|
522
|
-
enum: enumValues && enumValues.length > 0 ?
|
|
523
|
-
description:
|
|
884
|
+
enum: enumValues && enumValues.length > 0 ? Option2.some(enumValues) : Option2.none(),
|
|
885
|
+
description: Option2.fromNullishOr(v.description)
|
|
524
886
|
})
|
|
525
887
|
]
|
|
526
888
|
];
|
|
@@ -529,8 +891,8 @@ var extractServerList = (servers) => (servers ?? []).flatMap((server) => {
|
|
|
529
891
|
return [
|
|
530
892
|
ServerInfo.make({
|
|
531
893
|
url: server.url,
|
|
532
|
-
description:
|
|
533
|
-
variables: vars && Object.keys(vars).length > 0 ?
|
|
894
|
+
description: Option2.fromNullishOr(server.description),
|
|
895
|
+
variables: vars && Object.keys(vars).length > 0 ? Option2.some(vars) : Option2.none()
|
|
534
896
|
})
|
|
535
897
|
];
|
|
536
898
|
});
|
|
@@ -564,40 +926,177 @@ var extract = Effect2.fn("OpenApi.extract")(function* (doc) {
|
|
|
564
926
|
const responseBody = extractResponseBody(operation, r);
|
|
565
927
|
const servers = operationServers(pathItem, operation, docServers);
|
|
566
928
|
const inputSchema = buildInputSchema(parameters, requestBody, servers);
|
|
567
|
-
const outputSchema = responseBody ?
|
|
929
|
+
const outputSchema = responseBody ? Option2.getOrUndefined(responseBody.schema) : void 0;
|
|
568
930
|
const tags = (operation.tags ?? []).filter((t) => t.trim().length > 0);
|
|
569
931
|
const operationPathTemplate = explicitPathTemplate(operation) ?? pathTemplate;
|
|
570
932
|
operations.push(
|
|
571
933
|
ExtractedOperation.make({
|
|
572
934
|
operationId: OperationId.make(deriveOperationId(method, pathTemplate, operation)),
|
|
573
|
-
toolPath:
|
|
935
|
+
toolPath: Option2.fromNullishOr(explicitToolPath(operation)),
|
|
574
936
|
method,
|
|
575
937
|
servers,
|
|
576
938
|
pathTemplate: operationPathTemplate,
|
|
577
|
-
summary:
|
|
578
|
-
description:
|
|
939
|
+
summary: Option2.fromNullishOr(operation.summary),
|
|
940
|
+
description: Option2.fromNullishOr(operation.description),
|
|
579
941
|
tags,
|
|
580
942
|
parameters,
|
|
581
|
-
requestBody:
|
|
582
|
-
responseBody:
|
|
583
|
-
inputSchema:
|
|
584
|
-
outputSchema:
|
|
943
|
+
requestBody: Option2.fromNullishOr(requestBody),
|
|
944
|
+
responseBody: Option2.fromNullishOr(responseBody),
|
|
945
|
+
inputSchema: Option2.fromNullishOr(inputSchema),
|
|
946
|
+
outputSchema: Option2.fromNullishOr(outputSchema),
|
|
585
947
|
deprecated: operation.deprecated === true
|
|
586
948
|
})
|
|
587
949
|
);
|
|
588
950
|
}
|
|
589
951
|
}
|
|
590
952
|
return ExtractionResult.make({
|
|
591
|
-
title:
|
|
592
|
-
description:
|
|
593
|
-
version:
|
|
953
|
+
title: Option2.fromNullishOr(doc.info?.title),
|
|
954
|
+
description: Option2.fromNullishOr(doc.info?.description),
|
|
955
|
+
version: Option2.fromNullishOr(doc.info?.version),
|
|
594
956
|
servers: docServers,
|
|
595
957
|
operations
|
|
596
958
|
});
|
|
597
959
|
});
|
|
960
|
+
var streamOperationBindings = (doc, chunkSize, onChunk) => Effect2.gen(function* () {
|
|
961
|
+
const paths = doc.paths;
|
|
962
|
+
if (!paths) {
|
|
963
|
+
return yield* new OpenApiExtractionError({
|
|
964
|
+
message: "OpenAPI document has no paths defined"
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
const r = new DocResolver(doc);
|
|
968
|
+
const docServers = extractServers(doc);
|
|
969
|
+
const inputs = [];
|
|
970
|
+
const opRefs = [];
|
|
971
|
+
for (const [pathTemplate, pathItem] of Object.entries(paths).sort(
|
|
972
|
+
([a], [b]) => a.localeCompare(b)
|
|
973
|
+
)) {
|
|
974
|
+
if (!pathItem) continue;
|
|
975
|
+
for (const method of HTTP_METHODS) {
|
|
976
|
+
const operation = pathItem[method];
|
|
977
|
+
if (!operation) continue;
|
|
978
|
+
const resolvedPathTemplate = explicitPathTemplate(operation) ?? pathTemplate;
|
|
979
|
+
const tags = (operation.tags ?? []).filter((t) => t.trim().length > 0);
|
|
980
|
+
inputs.push({
|
|
981
|
+
operationId: deriveOperationId(method, pathTemplate, operation),
|
|
982
|
+
explicitToolPath: explicitToolPath(operation),
|
|
983
|
+
method,
|
|
984
|
+
pathTemplate: resolvedPathTemplate,
|
|
985
|
+
tag0: tags[0]
|
|
986
|
+
});
|
|
987
|
+
opRefs.push({ pathItem, operation, method, pathTemplate: resolvedPathTemplate });
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
const plans = planToolPaths(inputs);
|
|
991
|
+
let chunk = [];
|
|
992
|
+
for (const plan of plans) {
|
|
993
|
+
const ref = opRefs[plan.operationIndex];
|
|
994
|
+
const parameters = extractParameters(ref.pathItem, ref.operation, r);
|
|
995
|
+
const requestBody = extractRequestBody(ref.operation, r);
|
|
996
|
+
const responseBody = extractResponseBody(ref.operation, r);
|
|
997
|
+
const servers = operationServers(ref.pathItem, ref.operation, docServers);
|
|
998
|
+
chunk.push({
|
|
999
|
+
toolName: plan.toolPath,
|
|
1000
|
+
description: ref.operation.description ?? ref.operation.summary ?? `${ref.method.toUpperCase()} ${ref.pathTemplate}`,
|
|
1001
|
+
binding: OperationBinding.make({
|
|
1002
|
+
method: ref.method,
|
|
1003
|
+
servers,
|
|
1004
|
+
pathTemplate: ref.pathTemplate,
|
|
1005
|
+
parameters,
|
|
1006
|
+
requestBody: Option2.fromNullishOr(requestBody),
|
|
1007
|
+
responseBody: Option2.fromNullishOr(responseBody)
|
|
1008
|
+
})
|
|
1009
|
+
});
|
|
1010
|
+
if (chunk.length >= chunkSize) {
|
|
1011
|
+
yield* onChunk(chunk);
|
|
1012
|
+
chunk = [];
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
if (chunk.length > 0) yield* onChunk(chunk);
|
|
1016
|
+
return { toolCount: plans.length, toolNames: plans.map((plan) => plan.toolPath) };
|
|
1017
|
+
}).pipe(Effect2.withSpan("OpenApi.streamOperationBindings"));
|
|
1018
|
+
var isPathItemValue = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
1019
|
+
var streamOperationBindingsFromStructure = (structure, options, onChunk) => Effect2.gen(function* () {
|
|
1020
|
+
const { chunkSize, keepPathItem } = options;
|
|
1021
|
+
const keptPathItem = (range) => {
|
|
1022
|
+
const entry = parseEntry(structure.text, range, 2);
|
|
1023
|
+
if (!entry) return null;
|
|
1024
|
+
const [path, rawValue] = entry;
|
|
1025
|
+
if (!isPathItemValue(rawValue)) return null;
|
|
1026
|
+
if (!keepPathItem) return [path, rawValue];
|
|
1027
|
+
const kept = keepPathItem(path, rawValue);
|
|
1028
|
+
return kept ? [path, kept] : null;
|
|
1029
|
+
};
|
|
1030
|
+
const inputs = [];
|
|
1031
|
+
for (const range of structure.pathItems) {
|
|
1032
|
+
const kept = keptPathItem(range);
|
|
1033
|
+
if (!kept) continue;
|
|
1034
|
+
const [path, pathItem] = kept;
|
|
1035
|
+
for (const method of HTTP_METHODS) {
|
|
1036
|
+
const operation = pathItem[method];
|
|
1037
|
+
if (!operation) continue;
|
|
1038
|
+
const resolvedPathTemplate = explicitPathTemplate(operation) ?? path;
|
|
1039
|
+
const tags = (operation.tags ?? []).filter((t) => t.trim().length > 0);
|
|
1040
|
+
inputs.push({
|
|
1041
|
+
operationId: deriveOperationId(method, path, operation),
|
|
1042
|
+
explicitToolPath: explicitToolPath(operation),
|
|
1043
|
+
method,
|
|
1044
|
+
pathTemplate: resolvedPathTemplate,
|
|
1045
|
+
tag0: tags[0]
|
|
1046
|
+
});
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
const plans = planToolPaths(inputs);
|
|
1050
|
+
const planByOpIndex = new Array(inputs.length);
|
|
1051
|
+
for (const plan of plans) planByOpIndex[plan.operationIndex] = plan;
|
|
1052
|
+
const resolverDoc = {
|
|
1053
|
+
...parseHead(structure),
|
|
1054
|
+
paths: {},
|
|
1055
|
+
components: parseSmallComponents(structure)
|
|
1056
|
+
};
|
|
1057
|
+
const r = new DocResolver(resolverDoc);
|
|
1058
|
+
const docServers = extractServers(resolverDoc);
|
|
1059
|
+
let opIndex = 0;
|
|
1060
|
+
let chunk = [];
|
|
1061
|
+
for (const range of structure.pathItems) {
|
|
1062
|
+
const kept = keptPathItem(range);
|
|
1063
|
+
if (!kept) continue;
|
|
1064
|
+
const [path, pathItem] = kept;
|
|
1065
|
+
for (const method of HTTP_METHODS) {
|
|
1066
|
+
const operation = pathItem[method];
|
|
1067
|
+
if (!operation) continue;
|
|
1068
|
+
const plan = planByOpIndex[opIndex];
|
|
1069
|
+
opIndex += 1;
|
|
1070
|
+
if (!plan) continue;
|
|
1071
|
+
const resolvedPathTemplate = explicitPathTemplate(operation) ?? path;
|
|
1072
|
+
const parameters = extractParameters(pathItem, operation, r);
|
|
1073
|
+
const requestBody = extractRequestBody(operation, r);
|
|
1074
|
+
const responseBody = extractResponseBody(operation, r);
|
|
1075
|
+
const servers = operationServers(pathItem, operation, docServers);
|
|
1076
|
+
chunk.push({
|
|
1077
|
+
toolName: plan.toolPath,
|
|
1078
|
+
description: operation.description ?? operation.summary ?? `${method.toUpperCase()} ${resolvedPathTemplate}`,
|
|
1079
|
+
binding: OperationBinding.make({
|
|
1080
|
+
method,
|
|
1081
|
+
servers,
|
|
1082
|
+
pathTemplate: resolvedPathTemplate,
|
|
1083
|
+
parameters,
|
|
1084
|
+
requestBody: Option2.fromNullishOr(requestBody),
|
|
1085
|
+
responseBody: Option2.fromNullishOr(responseBody)
|
|
1086
|
+
})
|
|
1087
|
+
});
|
|
1088
|
+
if (chunk.length >= chunkSize) {
|
|
1089
|
+
yield* onChunk(chunk);
|
|
1090
|
+
chunk = [];
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
if (chunk.length > 0) yield* onChunk(chunk);
|
|
1095
|
+
return { toolCount: plans.length, toolNames: plans.map((plan) => plan.toolPath) };
|
|
1096
|
+
}).pipe(Effect2.withSpan("OpenApi.streamOperationBindingsFromStructure"));
|
|
598
1097
|
|
|
599
1098
|
// src/sdk/preview.ts
|
|
600
|
-
import { Effect as Effect3, Option as
|
|
1099
|
+
import { Effect as Effect3, Option as Option3, Predicate } from "effect";
|
|
601
1100
|
import { Schema as Schema4 } from "effect";
|
|
602
1101
|
var OAuth2Scopes = Schema4.Record(Schema4.String, Schema4.String);
|
|
603
1102
|
var SecuritySchemeType = Schema4.Literals(["http", "apiKey", "oauth2", "openIdConnect"]);
|
|
@@ -718,21 +1217,21 @@ var stringRecord = (value) => {
|
|
|
718
1217
|
return out;
|
|
719
1218
|
};
|
|
720
1219
|
var extractFlows = (rawFlows) => {
|
|
721
|
-
if (!rawFlows || typeof rawFlows !== "object") return
|
|
1220
|
+
if (!rawFlows || typeof rawFlows !== "object") return Option3.none();
|
|
722
1221
|
const flows = rawFlows;
|
|
723
1222
|
const parseFlow = (key) => flows[key];
|
|
724
|
-
let authorizationCode =
|
|
1223
|
+
let authorizationCode = Option3.none();
|
|
725
1224
|
const authCodeRaw = parseFlow("authorizationCode");
|
|
726
1225
|
if (authCodeRaw && typeof authCodeRaw === "object") {
|
|
727
1226
|
const f = authCodeRaw;
|
|
728
1227
|
const authUrl = typeof f.authorizationUrl === "string" ? f.authorizationUrl : null;
|
|
729
1228
|
const tokenUrl = typeof f.tokenUrl === "string" ? f.tokenUrl : null;
|
|
730
1229
|
if (authUrl && tokenUrl) {
|
|
731
|
-
authorizationCode =
|
|
1230
|
+
authorizationCode = Option3.some(
|
|
732
1231
|
OAuth2AuthorizationCodeFlow.make({
|
|
733
1232
|
authorizationUrl: authUrl,
|
|
734
1233
|
tokenUrl,
|
|
735
|
-
refreshUrl:
|
|
1234
|
+
refreshUrl: Option3.fromNullishOr(
|
|
736
1235
|
typeof f.refreshUrl === "string" ? f.refreshUrl : void 0
|
|
737
1236
|
),
|
|
738
1237
|
scopes: stringRecord(f.scopes)
|
|
@@ -740,16 +1239,16 @@ var extractFlows = (rawFlows) => {
|
|
|
740
1239
|
);
|
|
741
1240
|
}
|
|
742
1241
|
}
|
|
743
|
-
let clientCredentials =
|
|
1242
|
+
let clientCredentials = Option3.none();
|
|
744
1243
|
const ccRaw = parseFlow("clientCredentials");
|
|
745
1244
|
if (ccRaw && typeof ccRaw === "object") {
|
|
746
1245
|
const f = ccRaw;
|
|
747
1246
|
const tokenUrl = typeof f.tokenUrl === "string" ? f.tokenUrl : null;
|
|
748
1247
|
if (tokenUrl) {
|
|
749
|
-
clientCredentials =
|
|
1248
|
+
clientCredentials = Option3.some(
|
|
750
1249
|
OAuth2ClientCredentialsFlow.make({
|
|
751
1250
|
tokenUrl,
|
|
752
|
-
refreshUrl:
|
|
1251
|
+
refreshUrl: Option3.fromNullishOr(
|
|
753
1252
|
typeof f.refreshUrl === "string" ? f.refreshUrl : void 0
|
|
754
1253
|
),
|
|
755
1254
|
scopes: stringRecord(f.scopes)
|
|
@@ -757,10 +1256,10 @@ var extractFlows = (rawFlows) => {
|
|
|
757
1256
|
);
|
|
758
1257
|
}
|
|
759
1258
|
}
|
|
760
|
-
if (
|
|
761
|
-
return
|
|
1259
|
+
if (Option3.isNone(authorizationCode) && Option3.isNone(clientCredentials)) {
|
|
1260
|
+
return Option3.none();
|
|
762
1261
|
}
|
|
763
|
-
return
|
|
1262
|
+
return Option3.some(OAuth2Flows.make({ authorizationCode, clientCredentials }));
|
|
764
1263
|
};
|
|
765
1264
|
var extractSecuritySchemes = (rawSchemes, resolver) => Object.entries(rawSchemes).flatMap(([name, schemeOrRef]) => {
|
|
766
1265
|
if (!schemeOrRef || typeof schemeOrRef !== "object") return [];
|
|
@@ -770,19 +1269,19 @@ var extractSecuritySchemes = (rawSchemes, resolver) => Object.entries(rawSchemes
|
|
|
770
1269
|
if (!resolved || typeof resolved !== "object") return [];
|
|
771
1270
|
const scheme = resolved;
|
|
772
1271
|
const type = decodeSecuritySchemeType(scheme.type);
|
|
773
|
-
if (
|
|
1272
|
+
if (Option3.isNone(type)) return [];
|
|
774
1273
|
const schemeType = type.value;
|
|
775
1274
|
return [
|
|
776
1275
|
SecurityScheme.make({
|
|
777
1276
|
name,
|
|
778
1277
|
type: schemeType,
|
|
779
|
-
scheme:
|
|
780
|
-
bearerFormat:
|
|
781
|
-
in:
|
|
782
|
-
headerName:
|
|
783
|
-
description:
|
|
784
|
-
flows: schemeType === "oauth2" ? extractFlows(scheme.flows) :
|
|
785
|
-
openIdConnectUrl:
|
|
1278
|
+
scheme: Option3.fromNullishOr(scheme.scheme),
|
|
1279
|
+
bearerFormat: Option3.fromNullishOr(scheme.bearerFormat),
|
|
1280
|
+
in: Option3.fromNullishOr(scheme.in),
|
|
1281
|
+
headerName: Option3.fromNullishOr(scheme.name),
|
|
1282
|
+
description: Option3.fromNullishOr(scheme.description),
|
|
1283
|
+
flows: schemeType === "oauth2" ? extractFlows(scheme.flows) : Option3.none(),
|
|
1284
|
+
openIdConnectUrl: Option3.fromNullishOr(scheme.openIdConnectUrl)
|
|
786
1285
|
})
|
|
787
1286
|
];
|
|
788
1287
|
});
|
|
@@ -795,21 +1294,21 @@ var buildHeaderPresets = (schemes, strategies) => {
|
|
|
795
1294
|
const secretHeaders = [];
|
|
796
1295
|
const labelParts = [];
|
|
797
1296
|
for (const scheme of resolved) {
|
|
798
|
-
if (scheme.type === "http" &&
|
|
1297
|
+
if (scheme.type === "http" && Option3.getOrElse(scheme.scheme, () => "") === "bearer") {
|
|
799
1298
|
headers["Authorization"] = null;
|
|
800
1299
|
secretHeaders.push("Authorization");
|
|
801
1300
|
labelParts.push("Bearer Token");
|
|
802
|
-
} else if (scheme.type === "http" &&
|
|
1301
|
+
} else if (scheme.type === "http" && Option3.getOrElse(scheme.scheme, () => "") === "basic") {
|
|
803
1302
|
headers["Authorization"] = null;
|
|
804
1303
|
secretHeaders.push("Authorization");
|
|
805
1304
|
labelParts.push("Basic Auth");
|
|
806
|
-
} else if (scheme.type === "apiKey" &&
|
|
807
|
-
const headerName =
|
|
1305
|
+
} else if (scheme.type === "apiKey" && Option3.getOrElse(scheme.in, () => "") === "header") {
|
|
1306
|
+
const headerName = Option3.getOrElse(scheme.headerName, () => scheme.name);
|
|
808
1307
|
headers[headerName] = null;
|
|
809
1308
|
secretHeaders.push(headerName);
|
|
810
1309
|
labelParts.push(scheme.name);
|
|
811
1310
|
} else if (scheme.type === "apiKey") {
|
|
812
|
-
labelParts.push(`${scheme.name} (${
|
|
1311
|
+
labelParts.push(`${scheme.name} (${Option3.getOrElse(scheme.in, () => "unknown")})`);
|
|
813
1312
|
} else if (scheme.type === "oauth2" || scheme.type === "openIdConnect") {
|
|
814
1313
|
return [];
|
|
815
1314
|
} else {
|
|
@@ -838,16 +1337,16 @@ var buildOAuth2Presets = (schemes) => {
|
|
|
838
1337
|
const presets = [];
|
|
839
1338
|
for (const scheme of schemes) {
|
|
840
1339
|
if (scheme.type !== "oauth2") continue;
|
|
841
|
-
if (
|
|
1340
|
+
if (Option3.isNone(scheme.flows)) continue;
|
|
842
1341
|
const flows = scheme.flows.value;
|
|
843
|
-
if (
|
|
1342
|
+
if (Option3.isSome(flows.authorizationCode)) {
|
|
844
1343
|
const flow = flows.authorizationCode.value;
|
|
845
1344
|
presets.push(
|
|
846
1345
|
OAuth2Preset.make({
|
|
847
1346
|
label: `OAuth2 Authorization Code \xB7 ${scheme.name}`,
|
|
848
1347
|
securitySchemeName: scheme.name,
|
|
849
1348
|
flow: "authorizationCode",
|
|
850
|
-
authorizationUrl:
|
|
1349
|
+
authorizationUrl: Option3.some(flow.authorizationUrl),
|
|
851
1350
|
tokenUrl: flow.tokenUrl,
|
|
852
1351
|
refreshUrl: flow.refreshUrl,
|
|
853
1352
|
scopes: flow.scopes,
|
|
@@ -855,14 +1354,14 @@ var buildOAuth2Presets = (schemes) => {
|
|
|
855
1354
|
})
|
|
856
1355
|
);
|
|
857
1356
|
}
|
|
858
|
-
if (
|
|
1357
|
+
if (Option3.isSome(flows.clientCredentials)) {
|
|
859
1358
|
const flow = flows.clientCredentials.value;
|
|
860
1359
|
presets.push(
|
|
861
1360
|
OAuth2Preset.make({
|
|
862
1361
|
label: `OAuth2 Client Credentials \xB7 ${scheme.name}`,
|
|
863
1362
|
securitySchemeName: scheme.name,
|
|
864
1363
|
flow: "clientCredentials",
|
|
865
|
-
authorizationUrl:
|
|
1364
|
+
authorizationUrl: Option3.none(),
|
|
866
1365
|
tokenUrl: flow.tokenUrl,
|
|
867
1366
|
refreshUrl: flow.refreshUrl,
|
|
868
1367
|
scopes: flow.scopes,
|
|
@@ -927,6 +1426,14 @@ export {
|
|
|
927
1426
|
fetchSpecText,
|
|
928
1427
|
resolveSpecText,
|
|
929
1428
|
parse,
|
|
1429
|
+
compileToolDefinitions,
|
|
1430
|
+
structuralSplit,
|
|
1431
|
+
parseEntry,
|
|
1432
|
+
parseHead,
|
|
1433
|
+
parseSmallComponents,
|
|
1434
|
+
isStreamableSpec,
|
|
1435
|
+
indexSchemas,
|
|
1436
|
+
collectReferencedSchemas,
|
|
930
1437
|
DocResolver,
|
|
931
1438
|
substituteUrlVariables,
|
|
932
1439
|
resolveServerUrl,
|
|
@@ -946,7 +1453,10 @@ export {
|
|
|
946
1453
|
OperationBinding,
|
|
947
1454
|
InvocationResult,
|
|
948
1455
|
TOKEN_VARIABLE,
|
|
1456
|
+
buildInputSchema,
|
|
949
1457
|
extract,
|
|
1458
|
+
streamOperationBindings,
|
|
1459
|
+
streamOperationBindingsFromStructure,
|
|
950
1460
|
OAuth2AuthorizationCodeFlow,
|
|
951
1461
|
OAuth2ClientCredentialsFlow,
|
|
952
1462
|
OAuth2Flows,
|
|
@@ -960,4 +1470,4 @@ export {
|
|
|
960
1470
|
previewSpecText,
|
|
961
1471
|
previewSpec
|
|
962
1472
|
};
|
|
963
|
-
//# sourceMappingURL=chunk-
|
|
1473
|
+
//# sourceMappingURL=chunk-R3X27XS6.js.map
|