@mintlify/msft-sdk 1.1.24 → 1.1.25
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/api-playground/ApiPlayground/Request/PlaygroundModal.js +46 -45
- package/dist/api-playground/ApiPlayground/Request/PlaygroundModal.js.map +1 -1
- package/dist/api-playground/ApiPlayground/Request/index.js +18 -18
- package/dist/api-playground/ApiPlayground/Request/index.js.map +1 -1
- package/dist/api-playground/ApiPlayground/components/EndpointsMenu.js +20 -21
- package/dist/api-playground/ApiPlayground/components/EndpointsMenu.js.map +1 -1
- package/dist/api-playground/ApiPlayground/components/EndpointsMenuLink.js +10 -11
- package/dist/api-playground/ApiPlayground/components/EndpointsMenuLink.js.map +1 -1
- package/dist/api-playground/ApiPlayground/index.js +30 -30
- package/dist/api-playground/ApiPlayground/index.js.map +1 -1
- package/dist/api-playground-2/constants/index.js +12 -3
- package/dist/api-playground-2/constants/index.js.map +1 -1
- package/dist/api-playground-2/schemaGraph/addUniqueKeysToSchema.js +41 -0
- package/dist/api-playground-2/schemaGraph/addUniqueKeysToSchema.js.map +1 -0
- package/dist/api-playground-2/schemaGraph/errors.js +19 -0
- package/dist/api-playground-2/schemaGraph/errors.js.map +1 -0
- package/dist/api-playground-2/schemaGraph/getApiReferenceDataFromGraph.js +26 -0
- package/dist/api-playground-2/schemaGraph/getApiReferenceDataFromGraph.js.map +1 -0
- package/dist/api-playground-2/schemaGraph/getDocumentProperties.js +58 -0
- package/dist/api-playground-2/schemaGraph/getDocumentProperties.js.map +1 -0
- package/dist/api-playground-2/schemaGraph/getSchemaGraphOperationData.js +77 -0
- package/dist/api-playground-2/schemaGraph/getSchemaGraphOperationData.js.map +1 -0
- package/dist/api-playground-2/schemaGraph/getSchemaGraphSchemaData.js +16 -0
- package/dist/api-playground-2/schemaGraph/getSchemaGraphSchemaData.js.map +1 -0
- package/dist/api-playground-2/schemaGraph/processExamples.js +111 -34
- package/dist/api-playground-2/schemaGraph/processExamples.js.map +1 -1
- package/dist/api-playground-2/schemaGraph/reduceCompositions.js +283 -0
- package/dist/api-playground-2/schemaGraph/reduceCompositions.js.map +1 -0
- package/dist/api-playground-2/schemaGraph/resolveGraphNode.js +61 -0
- package/dist/api-playground-2/schemaGraph/resolveGraphNode.js.map +1 -0
- package/dist/api-playground-2/schemaGraph/resolveOperationWithDependencies.js +149 -0
- package/dist/api-playground-2/schemaGraph/resolveOperationWithDependencies.js.map +1 -0
- package/dist/api-playground-2/schemaGraph/resolveSchemaWithDependencies.js +33 -0
- package/dist/api-playground-2/schemaGraph/resolveSchemaWithDependencies.js.map +1 -0
- package/dist/api-playground-2/schemaGraph/sortSchemaByRequired.js +35 -0
- package/dist/api-playground-2/schemaGraph/sortSchemaByRequired.js.map +1 -0
- package/dist/api-playground-2/schemaGraph/utils.js +144 -98
- package/dist/api-playground-2/schemaGraph/utils.js.map +1 -1
- package/dist/common/parseApiTargetFromMetadata.js +24 -0
- package/dist/common/parseApiTargetFromMetadata.js.map +1 -0
- package/dist/common/parseOpenApiString.js +42 -0
- package/dist/common/parseOpenApiString.js.map +1 -0
- package/dist/components/Api/ApiReferenceProvider.js +6 -15
- package/dist/components/Api/ApiReferenceProvider.js.map +1 -1
- package/dist/components/nav-tree/index.js +135 -109
- package/dist/components/nav-tree/index.js.map +1 -1
- package/dist/contexts/ConfigContext.js +61 -12
- package/dist/contexts/ConfigContext.js.map +1 -1
- package/dist/contexts/MDXContentContext.js +0 -1
- package/dist/contexts/MDXContentContext.js.map +1 -1
- package/dist/index.d.ts +125 -9
- package/dist/index.js +156 -144
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/dist/hooks/useCurrentPath.js +0 -17
- package/dist/hooks/useCurrentPath.js.map +0 -1
- package/dist/utils/decodeSlug.js +0 -8
- package/dist/utils/decodeSlug.js.map +0 -1
- package/dist/utils/optionallyAddLeadingSlash.js +0 -7
- package/dist/utils/optionallyAddLeadingSlash.js.map +0 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { addUniqueKeysToSchema as i } from "./addUniqueKeysToSchema.js";
|
|
2
|
+
import { reduceExpandedSchema as n } from "./reduceCompositions.js";
|
|
3
|
+
import { deeplyResolveGraphNode as t } from "./resolveGraphNode.js";
|
|
4
|
+
import { sortSchemaByRequired as c } from "./sortSchemaByRequired.js";
|
|
5
|
+
function p(o, r) {
|
|
6
|
+
const d = r.spec.refUuidMap[o];
|
|
7
|
+
if (d)
|
|
8
|
+
return d;
|
|
9
|
+
}
|
|
10
|
+
function a({
|
|
11
|
+
schemaPath: o,
|
|
12
|
+
schemaGraphData: r
|
|
13
|
+
}) {
|
|
14
|
+
const d = p(o, r);
|
|
15
|
+
if (!d)
|
|
16
|
+
throw new Error(`no matching OpenAPI schema found with path "${o}"`);
|
|
17
|
+
let e = t({
|
|
18
|
+
uuidObjectHashMap: r.spec.uuidObjectHashMap,
|
|
19
|
+
hashedNodeMap: r.spec.hashedNodeMap,
|
|
20
|
+
id: d
|
|
21
|
+
});
|
|
22
|
+
if (!e)
|
|
23
|
+
throw new Error(`no matching OpenAPI schema found with id "${o}"`);
|
|
24
|
+
return e = n({
|
|
25
|
+
schema: e,
|
|
26
|
+
depth: 0,
|
|
27
|
+
location: "request"
|
|
28
|
+
}), e = c(e), e = i(e, ""), e;
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
a as resolveSchemaWithDependencies
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=resolveSchemaWithDependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveSchemaWithDependencies.js","sources":["../../../src/api-playground-2/schemaGraph/resolveSchemaWithDependencies.ts"],"sourcesContent":["import { SchemaGraphData } from '@mintlify/validation';\n\nimport { addUniqueKeysToSchema } from '@/api-playground-2/schemaGraph/addUniqueKeysToSchema';\nimport { reduceExpandedSchema } from '@/api-playground-2/schemaGraph/reduceCompositions';\nimport { deeplyResolveGraphNode } from '@/api-playground-2/schemaGraph/resolveGraphNode';\nimport { sortSchemaByRequired } from '@/api-playground-2/schemaGraph/sortSchemaByRequired';\nimport { SchemaV2 } from '@/api-playground-2/types';\n\nfunction getSchemaId(schemaString: string, graph: SchemaGraphData) {\n const schemaUuid = graph.spec.refUuidMap[schemaString];\n if (!schemaUuid) return undefined;\n return schemaUuid;\n}\n\nexport function resolveSchemaWithDependencies({\n schemaPath,\n schemaGraphData,\n}: {\n schemaPath: string;\n schemaGraphData: SchemaGraphData;\n}): SchemaV2 {\n const schemaId = getSchemaId(schemaPath, schemaGraphData);\n if (!schemaId) {\n throw new Error(`no matching OpenAPI schema found with path \"${schemaPath}\"`);\n }\n let schema = deeplyResolveGraphNode<SchemaV2>({\n uuidObjectHashMap: schemaGraphData.spec.uuidObjectHashMap,\n hashedNodeMap: schemaGraphData.spec.hashedNodeMap,\n id: schemaId,\n });\n if (!schema) {\n throw new Error(`no matching OpenAPI schema found with id \"${schemaPath}\"`);\n }\n schema = reduceExpandedSchema({\n schema,\n depth: 0,\n location: 'request',\n });\n schema = sortSchemaByRequired(schema);\n schema = addUniqueKeysToSchema(schema, '');\n\n return schema;\n}\n"],"names":["getSchemaId","schemaString","graph","schemaUuid","resolveSchemaWithDependencies","schemaPath","schemaGraphData","schemaId","schema","deeplyResolveGraphNode","reduceExpandedSchema","sortSchemaByRequired","addUniqueKeysToSchema"],"mappings":";;;;AAQA,SAASA,EAAYC,GAAsBC,GAAwB;AACjE,QAAMC,IAAaD,EAAM,KAAK,WAAWD,CAAY;AACrD,MAAKE;AACL,WAAOA;AACT;AAEO,SAASC,EAA8B;AAAA,EAC5C,YAAAC;AAAA,EACA,iBAAAC;AACF,GAGa;AACX,QAAMC,IAAWP,EAAYK,GAAYC,CAAe;AACxD,MAAI,CAACC;AACH,UAAM,IAAI,MAAM,+CAA+CF,CAAU,GAAG;AAE9E,MAAIG,IAASC,EAAiC;AAAA,IAC5C,mBAAmBH,EAAgB,KAAK;AAAA,IACxC,eAAeA,EAAgB,KAAK;AAAA,IACpC,IAAIC;AAAA,EAAA,CACL;AACD,MAAI,CAACC;AACH,UAAM,IAAI,MAAM,6CAA6CH,CAAU,GAAG;AAE5E,SAAAG,IAASE,EAAqB;AAAA,IAC5B,QAAAF;AAAA,IACA,OAAO;AAAA,IACP,UAAU;AAAA,EAAA,CACX,GACDA,IAASG,EAAqBH,CAAM,GACpCA,IAASI,EAAsBJ,GAAQ,EAAE,GAElCA;AACT;"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { isSchemaObject as o } from "./utils.js";
|
|
2
|
+
const u = (r) => {
|
|
3
|
+
if (!o(r))
|
|
4
|
+
return r;
|
|
5
|
+
if (r.oneOf && Array.isArray(r.oneOf))
|
|
6
|
+
return {
|
|
7
|
+
...r,
|
|
8
|
+
oneOf: r.oneOf.map(
|
|
9
|
+
(t) => o(t) ? u(t) : t
|
|
10
|
+
)
|
|
11
|
+
};
|
|
12
|
+
if (r.type === "object" && r.properties) {
|
|
13
|
+
const t = new Set(r.required || []), d = Object.entries(r.properties).filter(
|
|
14
|
+
(e) => o(e[1])
|
|
15
|
+
).sort(([e], [i]) => {
|
|
16
|
+
const n = t.has(e), s = t.has(i);
|
|
17
|
+
return n === s ? 0 : n ? -1 : 1;
|
|
18
|
+
}), f = {};
|
|
19
|
+
return d.forEach(([e, i]) => {
|
|
20
|
+
const n = t.has(e), s = o(i) ? u(i) : i;
|
|
21
|
+
f[e] = n ? { ...s, isRequired: !0 } : s;
|
|
22
|
+
}), {
|
|
23
|
+
...r,
|
|
24
|
+
properties: f
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return r.type === "array" && o(r.items) ? {
|
|
28
|
+
...r,
|
|
29
|
+
items: u(r.items)
|
|
30
|
+
} : r;
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
u as sortSchemaByRequired
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=sortSchemaByRequired.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sortSchemaByRequired.js","sources":["../../../src/api-playground-2/schemaGraph/sortSchemaByRequired.ts"],"sourcesContent":["import { SchemaObject } from '@mintlify/validation';\n\nimport { isSchemaObject } from '@/api-playground-2/schemaGraph/utils';\nimport type { ResolvedSchemaObject } from '@/api-playground-2/types';\n\n/**\n * Mutate a SchemaObject to sort its properties by whether or not they are required. Transforms\n * a schema's `required: string[]` field into individual `isRequired: true` fields on the respective\n * properties.\n */\nexport const sortSchemaByRequired = (schema: SchemaObject): ResolvedSchemaObject => {\n if (!isSchemaObject(schema)) {\n return schema;\n }\n\n if (schema.oneOf && Array.isArray(schema.oneOf)) {\n return {\n ...schema,\n oneOf: schema.oneOf.map((subSchema) =>\n isSchemaObject(subSchema) ? sortSchemaByRequired(subSchema) : subSchema\n ),\n };\n }\n\n if (schema.type === 'object' && schema.properties) {\n const requiredSet = new Set(schema.required || []);\n const entries = Object.entries(schema.properties).filter(\n (entry): entry is [string, SchemaObject] => isSchemaObject(entry[1])\n );\n\n const sortedEntries = entries.sort(([nameA], [nameB]) => {\n const isRequiredA = requiredSet.has(nameA);\n const isRequiredB = requiredSet.has(nameB);\n if (isRequiredA === isRequiredB) return 0;\n return isRequiredA ? -1 : 1;\n });\n\n const sortedProperties: Record<string, SchemaObject> = {};\n sortedEntries.forEach(([name, propSchema]) => {\n const isRequired = requiredSet.has(name);\n const processedSchema = isSchemaObject(propSchema)\n ? sortSchemaByRequired(propSchema)\n : propSchema;\n\n sortedProperties[name] = isRequired\n ? { ...processedSchema, isRequired: true }\n : processedSchema;\n });\n\n return {\n ...schema,\n properties: sortedProperties,\n };\n }\n\n if (schema.type === 'array' && isSchemaObject(schema.items)) {\n return {\n ...schema,\n items: sortSchemaByRequired(schema.items),\n };\n }\n\n return schema;\n};\n"],"names":["sortSchemaByRequired","schema","isSchemaObject","subSchema","requiredSet","sortedEntries","entry","nameA","nameB","isRequiredA","isRequiredB","sortedProperties","name","propSchema","isRequ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import "@mintlify/validation";
|
|
2
|
-
import { apiPlaygroundInputKeys as
|
|
3
|
-
function
|
|
4
|
-
return typeof e == "object" && e !== null &&
|
|
2
|
+
import { apiPlaygroundInputKeys as c, initialApiPlaygroundInputs as O, CIRCULAR_REF_KEY as A, stringFileFormats as S, combinationKeys as g, MAX_SCHEMA_COMBINATION_SIZE as k } from "../constants/index.js";
|
|
3
|
+
function j(e) {
|
|
4
|
+
return typeof e == "object" && e !== null && A in e && typeof e[A] == "string";
|
|
5
5
|
}
|
|
6
|
-
const
|
|
6
|
+
const B = () => ({ oneOf: [] }), T = () => ({ oneOf: [{}] }), m = (e) => typeof e == "object" && e !== null && !Array.isArray(e), x = (e) => a(e) && Array.isArray(e.oneOf), a = (e) => m(e) ? "type" in e || "properties" in e || "oneOf" in e || "anyOf" in e || "allOf" in e || "items" in e || "additionalProperties" in e || "enum" in e || "const" in e || "format" in e || "pattern" in e || "minimum" in e || "maximum" in e || "minLength" in e || "maxLength" in e || "minItems" in e || "maxItems" in e || "minProperties" in e || "maxProperties" in e || "required" in e || "nullable" in e || "description" in e : !1, K = (e) => a(e) && e.type === "array";
|
|
7
|
+
function R(e) {
|
|
8
|
+
const t = Array.isArray(e.oneOf) ? e.oneOf.length : 1, n = Array.isArray(e.anyOf) ? e.anyOf.length : 1, r = Array.isArray(e.allOf) ? e.allOf.length : 1, i = [t, n, r];
|
|
9
|
+
return g.forEach((o) => {
|
|
10
|
+
if (e[o]) {
|
|
11
|
+
const u = e[o];
|
|
12
|
+
i.push(Object.keys(u).length), g.forEach((f) => {
|
|
13
|
+
if (u[f]) {
|
|
14
|
+
const p = u[f];
|
|
15
|
+
i.push(Object.keys(p).length), g.forEach((b) => {
|
|
16
|
+
if (p[b]) {
|
|
17
|
+
const P = p[b];
|
|
18
|
+
i.push(Object.keys(P).length);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}), i.reduce((o, u) => o * u, 1) > k;
|
|
25
|
+
}
|
|
26
|
+
const D = (e, t, n) => t[n] ?? e[n], v = (e, t, n, r) => e[n] !== void 0 && t[n] !== void 0 ? r(e[n], t[n]) : e[n] ?? t[n], L = (e) => e.oneOf && e.oneOf.length === 1 ? e.oneOf[0] : e, y = (e) => {
|
|
27
|
+
let t = { ...e };
|
|
28
|
+
if (t.properties && typeof t.properties == "object") {
|
|
29
|
+
const n = {};
|
|
30
|
+
for (const [r, i] of Object.entries(t.properties))
|
|
31
|
+
a(i) ? n[r] = y(i) : n[r] = i;
|
|
32
|
+
t.properties = n;
|
|
33
|
+
}
|
|
34
|
+
if ("items" in t && t.items && typeof t.items == "object" && a(t.items) && (t.items = y(t.items)), t.additionalProperties && typeof t.additionalProperties == "object" && a(t.additionalProperties) && (t.additionalProperties = y(t.additionalProperties)), t.oneOf && Array.isArray(t.oneOf) && t.oneOf.length > 1) {
|
|
35
|
+
const r = t.oneOf.map((i) => a(i) ? y(i) : i);
|
|
36
|
+
t.oneOf = r;
|
|
37
|
+
}
|
|
38
|
+
if ("oneOf" in t && t.oneOf && Array.isArray(t.oneOf) && t.oneOf.length === 1) {
|
|
39
|
+
const n = t.oneOf[0];
|
|
40
|
+
if (a(n))
|
|
41
|
+
return t = { ...t, ...n }, delete t.oneOf, y(t);
|
|
42
|
+
}
|
|
43
|
+
return t;
|
|
44
|
+
}, N = (e) => {
|
|
7
45
|
if (e.oneOf)
|
|
8
46
|
return "oneOf";
|
|
9
47
|
if (e.enum)
|
|
@@ -17,56 +55,56 @@ const l = (e) => typeof e == "object" && e !== null && !Array.isArray(e), p = (e
|
|
|
17
55
|
default:
|
|
18
56
|
return e.type;
|
|
19
57
|
}
|
|
20
|
-
return e.format &&
|
|
21
|
-
},
|
|
58
|
+
return e.format && S.includes(e.format) ? "file" : e.type;
|
|
59
|
+
}, $ = (e) => "enum" in e && e.enum !== void 0, F = (e) => "placeholder" in e && typeof e.placeholder == "string" ? e.placeholder : void 0, M = (e) => e.type === "string", _ = (e) => e.type === "number" || e.type === "integer", z = (e) => {
|
|
22
60
|
var n;
|
|
23
61
|
const t = {};
|
|
24
|
-
return Object.entries(((n = e.operation) == null ? void 0 : n.responses) ?? {}).forEach(([r,
|
|
25
|
-
var o,
|
|
26
|
-
const
|
|
27
|
-
|
|
62
|
+
return Object.entries(((n = e.operation) == null ? void 0 : n.responses) ?? {}).forEach(([r, i]) => {
|
|
63
|
+
var o, u;
|
|
64
|
+
const s = (u = (o = e.dependencies) == null ? void 0 : o.responses) == null ? void 0 : u[i];
|
|
65
|
+
s && s.content && (t[r] = s.content);
|
|
28
66
|
}), t;
|
|
29
|
-
},
|
|
30
|
-
var o,
|
|
31
|
-
const t = (
|
|
67
|
+
}, w = (e) => {
|
|
68
|
+
var o, u, f;
|
|
69
|
+
const t = (u = (o = e.dependencies) == null ? void 0 : o.requestBody) == null ? void 0 : u.content;
|
|
32
70
|
if (t === void 0)
|
|
33
|
-
return [
|
|
71
|
+
return [O];
|
|
34
72
|
const r = Object.keys(t)[0];
|
|
35
73
|
if (!r)
|
|
36
|
-
return [
|
|
37
|
-
const
|
|
38
|
-
for (const
|
|
39
|
-
"value" in
|
|
40
|
-
...
|
|
41
|
-
body:
|
|
74
|
+
return [O];
|
|
75
|
+
const i = Object.values(((f = t[r]) == null ? void 0 : f.examples) ?? {}), s = [];
|
|
76
|
+
for (const p of i)
|
|
77
|
+
"value" in p && s.push({
|
|
78
|
+
...O,
|
|
79
|
+
body: p.value
|
|
42
80
|
});
|
|
43
|
-
return
|
|
44
|
-
},
|
|
81
|
+
return s;
|
|
82
|
+
}, U = (e) => {
|
|
45
83
|
var n;
|
|
46
84
|
const t = (n = e.dependencies) == null ? void 0 : n.parameters;
|
|
47
85
|
if (t) {
|
|
48
|
-
const r = Object.values(t),
|
|
49
|
-
(
|
|
50
|
-
),
|
|
86
|
+
const r = Object.values(t), i = r.filter(
|
|
87
|
+
(f) => !("in" in f) || f.in === "header"
|
|
88
|
+
), s = r.filter((f) => f.in === "cookie"), o = r.filter((f) => f.in === "path"), u = r.filter((f) => f.in === "query");
|
|
51
89
|
return {
|
|
52
|
-
header:
|
|
90
|
+
header: i,
|
|
53
91
|
path: o,
|
|
54
|
-
query:
|
|
55
|
-
cookie:
|
|
92
|
+
query: u,
|
|
93
|
+
cookie: s
|
|
56
94
|
};
|
|
57
95
|
}
|
|
58
96
|
return { header: [], path: [], query: [], cookie: [] };
|
|
59
|
-
},
|
|
97
|
+
}, C = (e) => {
|
|
60
98
|
let t;
|
|
61
99
|
if (e)
|
|
62
100
|
return typeof e == "object" && "default" in e && (t = e.default), typeof e == "object" && "x-default" in e && (t = e["x-default"]), t;
|
|
63
|
-
},
|
|
101
|
+
}, V = (e, t, n, r) => {
|
|
64
102
|
if (t.uniqueKey) {
|
|
65
|
-
const
|
|
66
|
-
return `${e ? e + "." : ""}${t.uniqueKey}${
|
|
103
|
+
const i = n || r;
|
|
104
|
+
return `${e ? e + "." : ""}${t.uniqueKey}${i ? "." + i : ""}`;
|
|
67
105
|
} else
|
|
68
106
|
return e;
|
|
69
|
-
},
|
|
107
|
+
}, H = () => ({
|
|
70
108
|
oneOf: [
|
|
71
109
|
{
|
|
72
110
|
type: "string"
|
|
@@ -98,24 +136,24 @@ const l = (e) => typeof e == "object" && e !== null && !Array.isArray(e), p = (e
|
|
|
98
136
|
type: "null"
|
|
99
137
|
}
|
|
100
138
|
]
|
|
101
|
-
}),
|
|
102
|
-
var
|
|
103
|
-
const n = (
|
|
139
|
+
}), W = (e, t) => {
|
|
140
|
+
var i, s;
|
|
141
|
+
const n = (s = (i = e.dependencies) == null ? void 0 : i.requestBody) == null ? void 0 : s.content;
|
|
104
142
|
return n === void 0 ? void 0 : Object.keys(n)[t];
|
|
105
|
-
},
|
|
143
|
+
}, X = (e) => e.replace(/\./g, "\\."), Y = (e) => {
|
|
106
144
|
switch (e) {
|
|
107
145
|
case "header":
|
|
108
|
-
return
|
|
146
|
+
return c.header;
|
|
109
147
|
case "path":
|
|
110
|
-
return
|
|
148
|
+
return c.path;
|
|
111
149
|
case "query":
|
|
112
|
-
return
|
|
150
|
+
return c.query;
|
|
113
151
|
case "cookie":
|
|
114
|
-
return
|
|
152
|
+
return c.cookie;
|
|
115
153
|
default:
|
|
116
|
-
return
|
|
154
|
+
return c.header;
|
|
117
155
|
}
|
|
118
|
-
},
|
|
156
|
+
}, Z = (e) => {
|
|
119
157
|
const t = {
|
|
120
158
|
server: {},
|
|
121
159
|
header: {},
|
|
@@ -127,102 +165,110 @@ const l = (e) => typeof e == "object" && e !== null && !Array.isArray(e), p = (e
|
|
|
127
165
|
return Object.entries(e).forEach(([n, r]) => {
|
|
128
166
|
if (r == null)
|
|
129
167
|
return;
|
|
130
|
-
const
|
|
131
|
-
if (
|
|
168
|
+
const i = n.split(new RegExp("(?<!\\\\)\\.")).map((f) => f.replace(/\\\./g, "."));
|
|
169
|
+
if (i.length < 2) {
|
|
132
170
|
n === "body" && (t.body = r);
|
|
133
171
|
return;
|
|
134
172
|
}
|
|
135
|
-
const [
|
|
136
|
-
!
|
|
137
|
-
t[
|
|
173
|
+
const [s, ...o] = i, u = Object.values(c);
|
|
174
|
+
!s || !u.includes(s) || (s !== c.body ? q(
|
|
175
|
+
t[s],
|
|
138
176
|
[...o],
|
|
139
177
|
r
|
|
140
|
-
) : [...o].length === 0 ? t.body = r : ((t.body === void 0 || typeof t.body != "object") && (t.body = {}),
|
|
141
|
-
}),
|
|
142
|
-
},
|
|
143
|
-
if (!
|
|
178
|
+
) : [...o].length === 0 ? t.body = r : ((t.body === void 0 || typeof t.body != "object") && (t.body = {}), q(t.body, o, r)));
|
|
179
|
+
}), d(t);
|
|
180
|
+
}, h = (e) => {
|
|
181
|
+
if (!m(e))
|
|
144
182
|
return !1;
|
|
145
183
|
const t = Object.keys(e);
|
|
146
184
|
return t.length === 0 ? !1 : t.every((n) => /^\d+$/.test(n));
|
|
147
|
-
},
|
|
185
|
+
}, d = (e) => {
|
|
148
186
|
if (e == null)
|
|
149
187
|
return e;
|
|
150
188
|
if (Array.isArray(e))
|
|
151
|
-
return e.map(
|
|
152
|
-
if (
|
|
153
|
-
if (
|
|
154
|
-
return Object.keys(e).sort((
|
|
189
|
+
return e.map(d);
|
|
190
|
+
if (m(e)) {
|
|
191
|
+
if (h(e))
|
|
192
|
+
return Object.keys(e).sort((i, s) => Number(i) - Number(s)).map((i) => e[i]).map(d);
|
|
155
193
|
const t = {};
|
|
156
194
|
for (const [n, r] of Object.entries(e))
|
|
157
|
-
t[n] =
|
|
195
|
+
t[n] = d(r);
|
|
158
196
|
return t;
|
|
159
197
|
}
|
|
160
198
|
return e;
|
|
161
|
-
},
|
|
199
|
+
}, q = (e, t, n) => {
|
|
162
200
|
const r = [];
|
|
163
|
-
for (let
|
|
164
|
-
const o = t[
|
|
201
|
+
for (let s = 0; s < t.length; s++) {
|
|
202
|
+
const o = t[s];
|
|
165
203
|
if (o === "oneOf") {
|
|
166
|
-
|
|
204
|
+
s++;
|
|
167
205
|
continue;
|
|
168
206
|
}
|
|
169
207
|
o === "additionalProperties" || o === "items" || o && r.push(o);
|
|
170
208
|
}
|
|
171
|
-
let
|
|
172
|
-
for (let
|
|
173
|
-
const o = r[
|
|
174
|
-
|
|
209
|
+
let i = e;
|
|
210
|
+
for (let s = 0; s < r.length; s++) {
|
|
211
|
+
const o = r[s];
|
|
212
|
+
s === r.length - 1 ? o && (i[o] = n) : (o && (!i[o] || typeof i[o] != "object") && (i[o] = {}), o && (i = i[o]));
|
|
175
213
|
}
|
|
176
|
-
},
|
|
214
|
+
}, G = (e) => e.filter((n) => "enum" in n && n.enum && "const" in n ? n.enum.includes(n.const) : !0), l = (e) => {
|
|
177
215
|
const t = {};
|
|
178
216
|
if ("uniqueKey" in e && e.uniqueKey !== void 0) {
|
|
179
|
-
const n =
|
|
217
|
+
const n = C(e);
|
|
180
218
|
if (n !== void 0) {
|
|
181
|
-
const r = `${
|
|
219
|
+
const r = `${c.body}.${e.uniqueKey}`;
|
|
182
220
|
t[r] = n;
|
|
183
221
|
}
|
|
184
222
|
}
|
|
185
223
|
if ("oneOf" in e && Array.isArray(e.oneOf) && e.oneOf.forEach((n) => {
|
|
186
|
-
if (
|
|
187
|
-
const r =
|
|
224
|
+
if (a(n)) {
|
|
225
|
+
const r = l(n);
|
|
188
226
|
Object.assign(t, r);
|
|
189
227
|
}
|
|
190
228
|
}), e.type === "object" && e.properties && Object.values(e.properties).forEach((n) => {
|
|
191
|
-
if (
|
|
192
|
-
const r =
|
|
229
|
+
if (a(n)) {
|
|
230
|
+
const r = l(n);
|
|
193
231
|
Object.assign(t, r);
|
|
194
232
|
}
|
|
195
|
-
}), e.additionalProperties && typeof e.additionalProperties == "object" &&
|
|
196
|
-
const n =
|
|
233
|
+
}), e.additionalProperties && typeof e.additionalProperties == "object" && a(e.additionalProperties)) {
|
|
234
|
+
const n = l(e.additionalProperties);
|
|
197
235
|
Object.assign(t, n);
|
|
198
236
|
}
|
|
199
|
-
if (e.type === "array" && "items" in e &&
|
|
200
|
-
const n =
|
|
237
|
+
if (e.type === "array" && "items" in e && a(e.items)) {
|
|
238
|
+
const n = l(e.items);
|
|
201
239
|
Object.assign(t, n);
|
|
202
240
|
}
|
|
203
241
|
return t;
|
|
204
242
|
};
|
|
205
243
|
export {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
244
|
+
v as combine,
|
|
245
|
+
H as convertAnySchemaToOneOfs,
|
|
246
|
+
B as createEmptyReducedSchema,
|
|
247
|
+
T as createUnknownReducedSchema,
|
|
248
|
+
X as escapeDots,
|
|
249
|
+
G as filterSchemasWithConsts,
|
|
250
|
+
y as flattenSchemaOneOfs,
|
|
251
|
+
L as flattenSingleOneOf,
|
|
252
|
+
w as generatePrefillRequestData,
|
|
253
|
+
l as getBodyDefaultsFromSchema,
|
|
254
|
+
N as getDifferentiatedType,
|
|
255
|
+
U as getParametersPerSection,
|
|
256
|
+
W as getRequestBodyContentType,
|
|
257
|
+
C as getSchemaDefault,
|
|
258
|
+
F as getSchemaPlaceholder,
|
|
259
|
+
V as getUniqueInputKey,
|
|
260
|
+
K as isArrayObject,
|
|
261
|
+
j as isCircularRef,
|
|
262
|
+
$ as isEnum,
|
|
263
|
+
_ as isNumberSchema,
|
|
264
|
+
m as isPlainRecord,
|
|
265
|
+
x as isReducedSchema,
|
|
266
|
+
a as isSchemaObject,
|
|
267
|
+
M as isStringSchema,
|
|
268
|
+
Y as mapParamInToPlaygroundInputKey,
|
|
269
|
+
z as mapResponseExamples,
|
|
270
|
+
R as shouldTruncateForSize,
|
|
271
|
+
D as takeLast,
|
|
272
|
+
Z as unflattenInputs
|
|
227
273
|
};
|
|
228
274
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../src/api-playground-2/schemaGraph/utils.ts"],"sourcesContent":["import { openApiToSchemaGraph } from '@mintlify/validation';\nimport type {\n ApiPlaygroundInputs,\n ArraySchemaObject,\n MediaObject,\n ParameterObject,\n GraphNode,\n SchemaObject,\n DataSchema,\n} from '@mintlify/validation';\nimport type { OpenAPIV3_1 } from 'openapi-types';\n\nimport {\n CIRCULAR_REF_KEY,\n combinationKeys,\n initialApiPlaygroundInputs,\n MAX_SCHEMA_COMBINATION_SIZE,\n stringFileFormats,\n apiPlaygroundInputKeys,\n} from '@/api-playground-2/constants';\nimport type {\n ApiReferenceDataV2,\n CircularRefObject,\n DifferentiatedType,\n ResolvedSchemaObject,\n ReducedSchema,\n} from '@/api-playground-2/types';\n\nimport { PlaygroundInputValue } from '../hooks/usePlaygroundInputsStore';\nimport { cn } from '@/utils/cn';\n\nexport { cn };\n\nexport function isCircularRef(value: unknown): value is CircularRefObject {\n return (\n typeof value === 'object' &&\n value !== null &&\n CIRCULAR_REF_KEY in value &&\n typeof value[CIRCULAR_REF_KEY] === 'string'\n );\n}\n\nexport const isResolvedSchemaObject = (obj: unknown): obj is ResolvedSchemaObject => {\n return isSchemaObject(obj) && ('isCircular' in obj || 'isRequired' in obj);\n};\n\nexport const createEmptyReducedSchema = (): ReducedSchema => ({ oneOf: [] });\nexport const createUnknownReducedSchema = (): ReducedSchema => ({ oneOf: [{}] });\n\nexport const isPlainRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nexport const isReducedSchema = (schema: unknown): schema is ReducedSchema =>\n isSchemaObject(schema) && Array.isArray(schema.oneOf);\n\n/**\n * Given an OpenAPI 3.1 schema, this function will attempt to determine the schema type\n * based on the properties present in the schema. This is useful for assigning types to\n * schemas that are missing a type.\n *\n * For example, if a schema has no type but has `schema.properties`, we can infer the\n * intended type is `object`.\n *\n * Used in the Conversion step.\n *\n * @param schema\n * @returns if exactly one type can be inferred, the string corresponding to that type; otherwise `undefined`\n */\nexport const inferType = (\n schema: Omit<SchemaObject, 'type'>\n): OpenAPIV3_1.ArraySchemaObjectType | OpenAPIV3_1.NonArraySchemaObjectType | undefined => {\n let type: OpenAPIV3_1.ArraySchemaObjectType | OpenAPIV3_1.NonArraySchemaObjectType | undefined;\n if (\n schema.format !== undefined ||\n schema.pattern !== undefined ||\n schema.minLength !== undefined ||\n schema.maxLength !== undefined ||\n schema.enum?.every((option) => typeof option === 'string')\n ) {\n type = 'string';\n }\n if (\n schema.multipleOf !== undefined ||\n schema.minimum !== undefined ||\n schema.maximum !== undefined ||\n schema.exclusiveMinimum !== undefined ||\n schema.exclusiveMaximum !== undefined ||\n schema.enum?.every((option) => typeof option === 'number')\n ) {\n if (type !== undefined) {\n return undefined;\n }\n type = 'number';\n }\n if (\n ('items' in schema && schema.items !== undefined) ||\n schema.minItems !== undefined ||\n schema.maxItems !== undefined ||\n schema.uniqueItems !== undefined\n ) {\n if (type !== undefined) {\n return undefined;\n }\n type = 'array';\n }\n if (\n schema.additionalProperties !== undefined ||\n schema.properties !== undefined ||\n schema.minProperties !== undefined ||\n schema.maxProperties !== undefined\n ) {\n if (type !== undefined) {\n return undefined;\n }\n type = 'object';\n }\n\n return type;\n};\n\nexport const isSchemaObject = (obj: unknown): obj is SchemaObject => {\n if (!isPlainRecord(obj)) {\n return false;\n }\n\n return (\n 'type' in obj ||\n 'properties' in obj ||\n 'oneOf' in obj ||\n 'anyOf' in obj ||\n 'allOf' in obj ||\n 'items' in obj ||\n 'additionalProperties' in obj ||\n 'enum' in obj ||\n 'const' in obj ||\n 'format' in obj ||\n 'pattern' in obj ||\n 'minimum' in obj ||\n 'maximum' in obj ||\n 'minLength' in obj ||\n 'maxLength' in obj ||\n 'minItems' in obj ||\n 'maxItems' in obj ||\n 'minProperties' in obj ||\n 'maxProperties' in obj ||\n 'required' in obj ||\n 'nullable' in obj ||\n 'description' in obj\n );\n};\n\nexport const isArrayObject = (obj: unknown): obj is ArraySchemaObject => {\n return isSchemaObject(obj) && obj.type === 'array';\n};\n\nexport function hasCombinationKey(obj: Record<string, unknown>): boolean {\n return combinationKeys.some((key) => key in obj);\n}\n\nexport function shouldTruncateForSize(schema: OpenAPIV3_1.SchemaObject): boolean {\n const oneOfSize = Array.isArray(schema.oneOf) ? schema.oneOf.length : 1;\n const anyOfSize = Array.isArray(schema.anyOf) ? schema.anyOf.length : 1;\n const allOfSize = Array.isArray(schema.allOf) ? schema.allOf.length : 1;\n\n const combinations: number[] = [oneOfSize, anyOfSize, allOfSize];\n\n // go three levels deep to estimate if combinations may explode\n combinationKeys.forEach((key) => {\n if (schema[key as keyof OpenAPIV3_1.SchemaObject]) {\n const subSchema = schema[key as keyof OpenAPIV3_1.SchemaObject];\n combinations.push(Object.keys(subSchema).length);\n combinationKeys.forEach((subSchemaKey) => {\n if (subSchema[subSchemaKey as keyof OpenAPIV3_1.SchemaObject]) {\n const subSubSchema = subSchema[subSchemaKey as keyof OpenAPIV3_1.SchemaObject];\n combinations.push(Object.keys(subSubSchema).length);\n combinationKeys.forEach((subSubSchemaKey) => {\n if (subSubSchema[subSubSchemaKey as keyof OpenAPIV3_1.SchemaObject]) {\n const subSubSubSchema =\n subSubSchema[subSubSchemaKey as keyof OpenAPIV3_1.SchemaObject];\n combinations.push(Object.keys(subSubSubSchema).length);\n }\n });\n }\n });\n }\n });\n\n const totalCombinations = combinations.reduce((acc, curr) => acc * curr, 1);\n\n return totalCombinations > MAX_SCHEMA_COMBINATION_SIZE;\n}\n\n// similar to RecursiveParamField/renderTruncatedNextProperties\nexport function createTruncatedNextProperties(\n schema: OpenAPIV3_1.SchemaObject\n): OpenAPIV3_1.SchemaObject {\n const truncatedSchema = { ...schema };\n\n // Remove all composition properties to prevent further recursion\n delete truncatedSchema.oneOf;\n delete truncatedSchema.anyOf;\n delete truncatedSchema.allOf;\n\n if (truncatedSchema.type === 'array') {\n truncatedSchema.items = {};\n } else if (truncatedSchema.type === 'object') {\n truncatedSchema.properties = {};\n if (\n truncatedSchema.additionalProperties &&\n typeof truncatedSchema.additionalProperties === 'object'\n ) {\n truncatedSchema.additionalProperties = {};\n }\n }\n\n return truncatedSchema;\n}\n\nexport function createTruncatedReducedSchema(schema: OpenAPIV3_1.SchemaObject): ReducedSchema {\n const truncatedSchema = createTruncatedNextProperties(schema);\n // For reduction, we need to wrap in oneOf\n return { oneOf: [truncatedSchema] };\n}\n\nexport function collectCombinationSizes(\n value: unknown,\n remainingDepth: number,\n combinations: number[]\n): void {\n if (remainingDepth === 0 || value === undefined || value === null) {\n return;\n }\n\n if (Array.isArray(value)) {\n combinations.push(value.length);\n if (remainingDepth > 1) {\n value.forEach((item) => collectCombinationSizes(item, remainingDepth - 1, combinations));\n }\n return;\n }\n\n if (isPlainRecord(value)) {\n combinations.push(Object.keys(value).length);\n if (remainingDepth > 1) {\n Object.values(value).forEach((item) =>\n collectCombinationSizes(item, remainingDepth - 1, combinations)\n );\n }\n }\n}\n\nexport const addKeyIfDefined = <D, K extends keyof D>(\n key: K,\n value: D[K] | undefined,\n destination: D\n) => {\n if (value !== undefined) {\n destination[key] = value;\n }\n};\n\nexport const copyKeyIfDefined = <D, K extends keyof D>(\n key: K,\n source: Pick<D, K>,\n destination: D\n) => {\n if (source[key] !== undefined) {\n destination[key] = source[key];\n }\n};\n\nexport const takeLast = <T extends keyof OpenAPIV3_1.SchemaObject>(\n schema1: OpenAPIV3_1.SchemaObject,\n schema2: OpenAPIV3_1.SchemaObject,\n key: T\n): OpenAPIV3_1.SchemaObject[T] => {\n return schema2[key] ?? schema1[key];\n};\n\nexport const combine = <T extends keyof OpenAPIV3_1.SchemaObject>(\n schema1: OpenAPIV3_1.SchemaObject,\n schema2: OpenAPIV3_1.SchemaObject,\n key: T,\n transform: (\n a: NonNullable<OpenAPIV3_1.SchemaObject[T]>,\n b: NonNullable<OpenAPIV3_1.SchemaObject[T]>\n ) => OpenAPIV3_1.SchemaObject[T]\n): OpenAPIV3_1.SchemaObject[T] => {\n return schema1[key] !== undefined && schema2[key] !== undefined\n ? transform(schema1[key], schema2[key])\n : schema1[key] ?? schema2[key];\n};\n\nexport const copyExampleIfDefined = (\n source: Pick<OpenAPIV3_1.SchemaObject, 'example' | 'examples'>,\n destination: Pick<DataSchema, 'example'>\n) => {\n const example = source.example !== undefined ? source.example : source.examples?.[0];\n if (example !== undefined) {\n destination.example = example;\n }\n};\n\n// Testing utility for quick and dirty schema graph conversion\nexport const convertSchemaToGraph = (\n schema: OpenAPIV3_1.SchemaObject,\n skipClone: boolean = false\n) => {\n let spec: OpenAPIV3_1.Document;\n if ('openapi' in schema) {\n spec = schema as OpenAPIV3_1.Document;\n } else {\n spec = {\n openapi: '3.1.0',\n info: { title: 'Test', version: '1.0.0' },\n paths: {},\n components: {\n schemas: {\n TestSchema: schema,\n },\n },\n };\n }\n if (!skipClone) {\n const clonedSpec = JSON.parse(JSON.stringify(spec));\n return openApiToSchemaGraph({\n spec: clonedSpec,\n filename: 'test.json',\n originalFileLocation: 'test.json',\n });\n }\n return openApiToSchemaGraph({\n spec,\n filename: 'test.json',\n originalFileLocation: 'test.json',\n });\n};\n\nexport const flattenSingleOneOf = <T extends GraphNode & { oneOf?: SchemaObject[] }>(\n node: T\n): T => {\n if (node.oneOf && node.oneOf.length === 1) {\n return node.oneOf[0] as T;\n }\n return node;\n};\n\nexport const flattenSchemaOneOfs = (schema: SchemaObject): SchemaObject => {\n let result = { ...schema } as SchemaObject;\n\n // recursively flatten into each combinator\n if (result.properties && typeof result.properties === 'object') {\n const flattened: Record<string, SchemaObject> = {};\n for (const [key, value] of Object.entries(result.properties)) {\n if (isSchemaObject(value)) {\n flattened[key] = flattenSchemaOneOfs(value);\n } else {\n flattened[key] = value as SchemaObject;\n }\n }\n result.properties = flattened;\n }\n\n if ('items' in result && result.items && typeof result.items === 'object') {\n if (isSchemaObject(result.items)) {\n result.items = flattenSchemaOneOfs(result.items);\n }\n }\n\n if (\n result.additionalProperties &&\n typeof result.additionalProperties === 'object' &&\n isSchemaObject(result.additionalProperties)\n ) {\n result.additionalProperties = flattenSchemaOneOfs(result.additionalProperties);\n }\n if (result.oneOf && Array.isArray(result.oneOf) && result.oneOf.length > 1) {\n const oneOfArray = result.oneOf;\n const mappedOneOf = (oneOfArray as unknown[]).map((item: unknown) => {\n if (isSchemaObject(item)) {\n return flattenSchemaOneOfs(item);\n }\n return item as SchemaObject;\n });\n result.oneOf = mappedOneOf as SchemaObject[];\n }\n\n if (\n 'oneOf' in result &&\n result.oneOf &&\n Array.isArray(result.oneOf) &&\n result.oneOf.length === 1\n ) {\n const singleItem = result.oneOf[0];\n if (isSchemaObject(singleItem)) {\n result = { ...result, ...singleItem } as SchemaObject;\n delete (result as { oneOf?: unknown[] }).oneOf;\n return flattenSchemaOneOfs(result);\n }\n }\n\n return result;\n};\n\nexport const calculateMaxDepth = (obj: unknown, currentDepth = 0): number => {\n if (obj === null || typeof obj !== 'object') {\n return currentDepth;\n }\n\n if (Array.isArray(obj)) {\n if (obj.length === 0) return currentDepth;\n return Math.max(...obj.map((item) => calculateMaxDepth(item, currentDepth)));\n }\n\n const depths = Object.entries(obj).map(([key, value]) => {\n if (key === 'type' || key === 'title') {\n return currentDepth;\n }\n return calculateMaxDepth(value, currentDepth + 1);\n });\n\n return depths.length > 0 ? Math.max(...depths) : currentDepth;\n};\n\n// converts standard schema types to differentiated types that were used in v1 and oneOf type\nexport const getDifferentiatedType = (schema: ResolvedSchemaObject): DifferentiatedType => {\n if (schema.oneOf) {\n return 'oneOf';\n }\n if (schema.enum) {\n switch (schema.type) {\n case 'string':\n return 'enum<string>';\n case 'number':\n return 'enum<number>';\n case 'integer':\n return 'enum<integer>';\n default:\n return schema.type;\n }\n }\n if (schema.format && stringFileFormats.includes(schema.format)) {\n return 'file';\n }\n return schema.type;\n};\n\nexport const isEnum = (schema: SchemaObject): boolean => {\n return 'enum' in schema && schema.enum !== undefined;\n};\n\nexport const getSchemaPlaceholder = (schema: SchemaObject): string | undefined => {\n return 'placeholder' in schema && typeof schema.placeholder === 'string'\n ? schema.placeholder\n : undefined;\n};\n\nexport const isStringSchema = (schema: SchemaObject): boolean => {\n return schema.type === 'string';\n};\n\nexport const isNumberSchema = (schema: SchemaObject): boolean => {\n return schema.type === 'number' || schema.type === 'integer';\n};\n\nexport const mapResponseExamples = (apiReferenceData: ApiReferenceDataV2) => {\n const responseCodeMediaObjectMap: Record<string, MediaObject> = {};\n Object.entries(apiReferenceData.operation?.responses ?? {}).forEach(([responseCode, UUID]) => {\n const response = apiReferenceData.dependencies?.responses?.[UUID];\n if (response && response.content) {\n responseCodeMediaObjectMap[responseCode] = response.content;\n }\n });\n return responseCodeMediaObjectMap;\n};\n\nexport const generatePrefillRequestData = (\n apiReferenceData: ApiReferenceDataV2\n): ApiPlaygroundInputs[] => {\n const requestBodyContent = apiReferenceData.dependencies?.requestBody?.content;\n if (requestBodyContent === undefined) {\n return [initialApiPlaygroundInputs];\n }\n const requestBodyContentTypes = Object.keys(requestBodyContent);\n const contentType = requestBodyContentTypes[0];\n if (!contentType) {\n return [initialApiPlaygroundInputs];\n }\n const requestBodyContentExamples = Object.values(requestBodyContent[contentType]?.examples ?? {});\n const examples: ApiPlaygroundInputs[] = [];\n for (const example of requestBodyContentExamples) {\n if ('value' in example) {\n examples.push({\n ...initialApiPlaygroundInputs,\n body: example.value,\n });\n }\n }\n\n return examples;\n};\n\nexport const getParametersPerSection = (\n apiReferenceData: ApiReferenceDataV2\n): {\n header: ParameterObject[];\n path: ParameterObject[];\n query: ParameterObject[];\n cookie: ParameterObject[];\n} => {\n const parameters = apiReferenceData.dependencies?.parameters;\n if (parameters) {\n const parameterObjects = Object.values(parameters);\n const headerParameters = parameterObjects.filter(\n (parameter) => !('in' in parameter) || parameter.in === 'header'\n );\n const cookieParameters = parameterObjects.filter((parameter) => parameter.in === 'cookie');\n const pathParameters = parameterObjects.filter((parameter) => parameter.in === 'path');\n const queryParameters = parameterObjects.filter((parameter) => parameter.in === 'query');\n return {\n header: headerParameters,\n path: pathParameters,\n query: queryParameters,\n cookie: cookieParameters,\n };\n }\n return { header: [], path: [], query: [], cookie: [] };\n};\n\nexport const getSchemaDefault = (schema: object | undefined): unknown | undefined => {\n let defaultValue = undefined;\n if (!schema) {\n return undefined;\n }\n if (typeof schema === 'object' && 'default' in schema) {\n defaultValue = schema.default;\n }\n if (typeof schema === 'object' && 'x-default' in schema) {\n defaultValue = schema['x-default'];\n }\n return defaultValue;\n};\n\nexport const getUniqueInputKey = (\n inputKeyPrefix: string,\n schema: ResolvedSchemaObject,\n arrayIndex?: number,\n key?: string\n) => {\n if (!schema.uniqueKey) {\n return inputKeyPrefix;\n } else {\n const arrayIndexOrKey = arrayIndex || key;\n return `${inputKeyPrefix ? inputKeyPrefix + '.' : ''}${schema.uniqueKey}${arrayIndexOrKey ? '.' + arrayIndexOrKey : ''}`;\n }\n};\n\nexport const convertAnySchemaToOneOfs = (): SchemaObject => {\n return {\n oneOf: [\n {\n type: 'string',\n },\n {\n type: 'number',\n },\n {\n type: 'boolean',\n },\n {\n type: 'object',\n properties: {},\n },\n {\n type: 'array',\n items: {\n oneOf: [\n { type: 'string' },\n { type: 'number' },\n { type: 'boolean' },\n { type: 'object', properties: {} },\n { type: 'array', items: {} },\n { type: 'null' },\n ],\n },\n },\n {\n type: 'null',\n },\n ],\n };\n};\n\nexport const getRequestBodyContentType = (\n apiReferenceData: ApiReferenceDataV2,\n contentTypeIndex: number\n): string | undefined => {\n const requestBodyContent = apiReferenceData.dependencies?.requestBody?.content;\n if (requestBodyContent === undefined) {\n return undefined;\n }\n const requestBodyContentTypes = Object.keys(requestBodyContent);\n return requestBodyContentTypes[contentTypeIndex];\n};\n\nexport const escapeDots = (key: string): string => {\n return key.replace(/\\./g, '\\\\.');\n};\n\nexport const mapParamInToPlaygroundInputKey = (parameterIn: string): string => {\n switch (parameterIn) {\n case 'header':\n return apiPlaygroundInputKeys.header;\n case 'path':\n return apiPlaygroundInputKeys.path;\n case 'query':\n return apiPlaygroundInputKeys.query;\n case 'cookie':\n return apiPlaygroundInputKeys.cookie;\n default:\n return apiPlaygroundInputKeys.header;\n }\n};\n\n// CLANKED AS HELL. TODO: Refactor.\nexport const unflattenInputs = (\n inputs: Record<string, PlaygroundInputValue>\n): ApiPlaygroundInputs => {\n const result: ApiPlaygroundInputs = {\n server: {},\n header: {},\n path: {},\n query: {},\n cookie: {},\n body: undefined,\n };\n\n Object.entries(inputs).forEach(([key, value]) => {\n // skip undefined/null values\n if (value === undefined || value === null) {\n return;\n }\n // split on . but not on \\. (escaped dots), then unescape the parts\n const parts = key.split(/(?<!\\\\)\\./).map((part) => part.replace(/\\\\\\./g, '.'));\n if (parts.length < 2) {\n if (key === 'body') {\n result.body = value;\n }\n return;\n }\n\n const [section, ...keyPath] = parts;\n\n const validKeys = Object.values(apiPlaygroundInputKeys);\n if (!section || !validKeys.includes(section)) {\n return;\n }\n\n if (section !== apiPlaygroundInputKeys.body) {\n setNestedValue(\n result[section as keyof ApiPlaygroundInputs] as Record<string, unknown>,\n [...keyPath],\n value\n );\n } else {\n if ([...keyPath].length === 0) {\n result.body = value;\n } else {\n // Initialize body as object if it's undefined\n if (result.body === undefined || typeof result.body !== 'object') {\n result.body = {};\n }\n setNestedValue(result.body as Record<string, unknown>, keyPath, value);\n }\n }\n });\n\n // Convert array-like objects (objects with only numeric keys) to actual arrays\n return convertArrayLikeToArray(result) as ApiPlaygroundInputs;\n};\n\n// Check if an object should be converted to an array (all keys are numeric strings)\nconst isArrayLike = (obj: unknown): obj is Record<string, unknown> => {\n if (!isPlainRecord(obj)) {\n return false;\n }\n const keys = Object.keys(obj);\n if (keys.length === 0) {\n return false;\n }\n // Check if all keys are numeric strings\n return keys.every((k) => /^\\d+$/.test(k));\n};\n\n// Recursively convert array-like objects to arrays\nconst convertArrayLikeToArray = (value: unknown): unknown => {\n if (value === null || value === undefined) {\n return value;\n }\n\n if (Array.isArray(value)) {\n return value.map(convertArrayLikeToArray);\n }\n\n if (isPlainRecord(value)) {\n if (isArrayLike(value)) {\n // Convert object with numeric keys to array\n // Sort keys numerically and map to values\n const keys = Object.keys(value).sort((a, b) => Number(a) - Number(b));\n const arr = keys.map((k) => value[k]);\n // Recursively convert nested values\n return arr.map(convertArrayLikeToArray);\n }\n\n // Recursively process regular objects\n const result: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(value)) {\n result[key] = convertArrayLikeToArray(val);\n }\n return result;\n }\n\n return value;\n};\n\n// recursively set a value in a nested object\nconst setNestedValue = (obj: Record<string, unknown>, keyPath: string[], value: unknown) => {\n // First pass: filter out keys we want to skip\n const filteredKeys: string[] = [];\n for (let i = 0; i < keyPath.length; i++) {\n const key = keyPath[i];\n if (key === 'oneOf') {\n // Skip this key and the next one (the oneOf index)\n i++;\n continue;\n }\n if (key === 'additionalProperties' || key === 'items') {\n // Skip these keys\n continue;\n }\n if (key) {\n filteredKeys.push(key);\n }\n }\n\n // Second pass: navigate through/create nested structure and set value\n let current = obj;\n for (let i = 0; i < filteredKeys.length; i++) {\n const key = filteredKeys[i];\n if (i === filteredKeys.length - 1) {\n // Last key - set the value\n if (key) {\n current[key] = value;\n }\n } else {\n // Not the last key - ensure nested object exists\n if (key && (!current[key] || typeof current[key] !== 'object')) {\n current[key] = {};\n }\n if (key) {\n current = current[key] as Record<string, unknown>;\n }\n }\n }\n};\n// CLANK ENDS HERE\n\nexport const filterSchemasWithConsts = (\n schemas: ResolvedSchemaObject[]\n): ResolvedSchemaObject[] => {\n const filteredSchemas = schemas.filter((schema) => {\n if ('enum' in schema && schema.enum && 'const' in schema) {\n return schema.enum.includes(schema.const);\n }\n return true;\n });\n return filteredSchemas;\n};\n\nexport const getBodyDefaultsFromSchema = (schema: SchemaObject): Record<string, unknown> => {\n const bodyDefaults: Record<string, unknown> = {};\n\n if ('uniqueKey' in schema && schema.uniqueKey !== undefined) {\n const defaultValue = getSchemaDefault(schema);\n if (defaultValue !== undefined) {\n const inputKey = `${apiPlaygroundInputKeys.body}.${schema.uniqueKey}`;\n bodyDefaults[inputKey] = defaultValue;\n }\n }\n\n if ('oneOf' in schema && Array.isArray(schema.oneOf)) {\n schema.oneOf.forEach((subSchema) => {\n if (isSchemaObject(subSchema)) {\n const subDefaults = getBodyDefaultsFromSchema(subSchema);\n Object.assign(bodyDefaults, subDefaults);\n }\n });\n }\n\n if (schema.type === 'object' && schema.properties) {\n Object.values(schema.properties).forEach((propSchema) => {\n if (isSchemaObject(propSchema)) {\n const propDefaults = getBodyDefaultsFromSchema(propSchema);\n Object.assign(bodyDefaults, propDefaults);\n }\n });\n }\n\n if (\n schema.additionalProperties &&\n typeof schema.additionalProperties === 'object' &&\n isSchemaObject(schema.additionalProperties)\n ) {\n const addPropsDefaults = getBodyDefaultsFromSchema(schema.additionalProperties);\n Object.assign(bodyDefaults, addPropsDefaults);\n }\n\n if (schema.type === 'array' && 'items' in schema && isSchemaObject(schema.items)) {\n const itemsDefaults = getBodyDefaultsFromSchema(schema.items);\n Object.assign(bodyDefaults, itemsDefaults);\n }\n\n return bodyDefaults;\n};"],"names":["isCircularRef","value","CIRCULAR_REF_KEY","isPlainRecord","isSchemaObject","obj","isArrayObject","getDifferentiatedType","schema","stringFileFormats","isEnum","getSchemaPlaceholder","isStringSchema","isNumberSchema","mapResponseExamples","apiReferenceData","responseCodeMediaObjectMap","_a","responseCode","UUID","response","_b","generatePrefillRequestData","requestBodyContent","initialApiPlaygroundInputs","contentType","requestBodyContentExamples","_c","examples","example","getParametersPerSection","parameters","parameterObjects","headerParameters","parameter","cookieParameters","pathParameters","queryParameters","getSchemaDefault","defaultValue","getUniqueInputKey","inputKeyPrefix","arrayIndex","key","arrayIndexOrKey","convertAnySchemaToOneOfs","getRequestBodyContentType","contentTypeIndex","escapeDots","mapParamInToPlaygroundInputKey","parameterIn","apiPlaygroundInputKeys","unflattenInputs","inputs","result","parts","part","section","keyPath","validKeys","setNestedValue","convertArrayLikeToArray","isArrayLike","keys","k","a","b","val","filteredKeys","current","filterSchemasWithConsts","schemas","getBodyDefaultsFromSchema","bodyDefaults","inputKey","subSchema","subDefaults","propSchema","propDefaults","addPropsDefaults","itemsDefaults"],"mappings":";;AAiCO,SAASA,EAAcC,GAA4C;AACxE,SACE,OAAOA,KAAU,YACjBA,MAAU,QACVC,KAAoBD,KACpB,OAAOA,EAAMC,CAAgB,KAAM;AAEvC;AASO,MAAMC,IAAgB,CAACF,MAC5B,OAAOA,KAAU,YAAYA,MAAU,QAAQ,CAAC,MAAM,QAAQA,CAAK,GAsExDG,IAAiB,CAACC,MACxBF,EAAcE,CAAG,IAKpB,UAAUA,KACV,gBAAgBA,KAChB,WAAWA,KACX,WAAWA,KACX,WAAWA,KACX,WAAWA,KACX,0BAA0BA,KAC1B,UAAUA,KACV,WAAWA,KACX,YAAYA,KACZ,aAAaA,KACb,aAAaA,KACb,aAAaA,KACb,eAAeA,KACf,eAAeA,KACf,cAAcA,KACd,cAAcA,KACd,mBAAmBA,KACnB,mBAAmBA,KAC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K,IAEnC,EACR,GAIUgE,IAA4B,CAAChE,MAAkD;AAC1F,QAAMiE,IAAwC,CAAA;AAE9C,MAAI,eAAejE,KAAUA,EAAO,cAAc,QAAW;AAC3D,UAAM+B,IAAeD,EAAiB9B,CAAM;AAC5C,QAAI+B,MAAiB,QAAW;AAC9B,YAAMmC,IAAW,GAAGvB,EAAuB,IAAI,IAAI3C,EAAO,SAAS;AACnE,MAAAiE,EAAaC,CAAQ,IAAInC;AAAA,IAC3B;AAAA,EACF;AAoBA,MAlBI,WAAW/B,KAAU,MAAM,QAAQA,EAAO,KAAK,KACjDA,EAAO,MAAM,QAAQ,CAACmE,MAAc;AAClC,QAAIvE,EAAeuE,CAAS,GAAG;AAC7B,YAAMC,IAAcJ,EAA0BG,CAAS;AACvD,aAAO,OAAOF,GAAcG,CAAW;AAAA,IACzC;AAAA,EACF,CAAC,GAGCpE,EAAO,SAAS,YAAYA,EAAO,cACrC,OAAO,OAAOA,EAAO,UAAU,EAAE,QAAQ,CAACqE,MAAe;AACvD,QAAIzE,EAAeyE,CAAU,GAAG;AAC9B,YAAMC,IAAeN,EAA0BK,CAAU;AACzD,aAAO,OAAOJ,GAAcK,CAAY;AAAA,IAC1C;AAAA,EACF,CAAC,GAIDtE,EAAO,wBACP,OAAOA,EAAO,wBAAyB,YACvCJ,EAAeI,EAAO,oBAAoB,GAC1C;AACA,UAAMuE,IAAmBP,EAA0BhE,EAAO,oBAAoB;AAC9E,WAAO,OAAOiE,GAAcM,CAAgB;AAAA,EAC9C;AAEA,MAAIvE,EAAO,SAAS,WAAW,WAAWA,KAAUJ,EAAeI,EAAO,KAAK,GAAG;AAChF,UAAMwE,IAAgBR,EAA0BhE,EAAO,KAAK;AAC5D,WAAO,OAAOiE,GAAcO,CAAa;AAAA,EAC3C;AAEA,SAAOP;AACT;"}
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../src/api-playground-2/schemaGraph/utils.ts"],"sourcesContent":["import { openApiToSchemaGraph } from '@mintlify/validation';\nimport type {\n ApiPlaygroundInputs,\n ArraySchemaObject,\n MediaObject,\n ParameterObject,\n GraphNode,\n SchemaObject,\n DataSchema,\n} from '@mintlify/validation';\nimport type { OpenAPIV3_1 } from 'openapi-types';\n\nimport {\n CIRCULAR_REF_KEY,\n combinationKeys,\n initialApiPlaygroundInputs,\n MAX_SCHEMA_COMBINATION_SIZE,\n stringFileFormats,\n apiPlaygroundInputKeys,\n} from '@/api-playground-2/constants';\nimport type {\n ApiReferenceDataV2,\n CircularRefObject,\n DifferentiatedType,\n ResolvedSchemaObject,\n ReducedSchema,\n} from '@/api-playground-2/types';\n\nimport { PlaygroundInputValue } from '../hooks/usePlaygroundInputsStore';\nimport { cn } from '@/utils/cn';\n\nexport { cn };\n\nexport function isCircularRef(value: unknown): value is CircularRefObject {\n return (\n typeof value === 'object' &&\n value !== null &&\n CIRCULAR_REF_KEY in value &&\n typeof value[CIRCULAR_REF_KEY] === 'string'\n );\n}\n\nexport const isResolvedSchemaObject = (obj: unknown): obj is ResolvedSchemaObject => {\n return isSchemaObject(obj) && ('isCircular' in obj || 'isRequired' in obj);\n};\n\nexport const createEmptyReducedSchema = (): ReducedSchema => ({ oneOf: [] });\nexport const createUnknownReducedSchema = (): ReducedSchema => ({ oneOf: [{}] });\n\nexport const isPlainRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nexport const isReducedSchema = (schema: unknown): schema is ReducedSchema =>\n isSchemaObject(schema) && Array.isArray(schema.oneOf);\n\n/**\n * Given an OpenAPI 3.1 schema, this function will attempt to determine the schema type\n * based on the properties present in the schema. This is useful for assigning types to\n * schemas that are missing a type.\n *\n * For example, if a schema has no type but has `schema.properties`, we can infer the\n * intended type is `object`.\n *\n * Used in the Conversion step.\n *\n * @param schema\n * @returns if exactly one type can be inferred, the string corresponding to that type; otherwise `undefined`\n */\nexport const inferType = (\n schema: Omit<SchemaObject, 'type'>\n): OpenAPIV3_1.ArraySchemaObjectType | OpenAPIV3_1.NonArraySchemaObjectType | undefined => {\n let type: OpenAPIV3_1.ArraySchemaObjectType | OpenAPIV3_1.NonArraySchemaObjectType | undefined;\n if (\n schema.format !== undefined ||\n schema.pattern !== undefined ||\n schema.minLength !== undefined ||\n schema.maxLength !== undefined ||\n schema.enum?.every((option) => typeof option === 'string')\n ) {\n type = 'string';\n }\n if (\n schema.multipleOf !== undefined ||\n schema.minimum !== undefined ||\n schema.maximum !== undefined ||\n schema.exclusiveMinimum !== undefined ||\n schema.exclusiveMaximum !== undefined ||\n schema.enum?.every((option) => typeof option === 'number')\n ) {\n if (type !== undefined) {\n return undefined;\n }\n type = 'number';\n }\n if (\n ('items' in schema && schema.items !== undefined) ||\n schema.minItems !== undefined ||\n schema.maxItems !== undefined ||\n schema.uniqueItems !== undefined\n ) {\n if (type !== undefined) {\n return undefined;\n }\n type = 'array';\n }\n if (\n schema.additionalProperties !== undefined ||\n schema.properties !== undefined ||\n schema.minProperties !== undefined ||\n schema.maxProperties !== undefined\n ) {\n if (type !== undefined) {\n return undefined;\n }\n type = 'object';\n }\n\n return type;\n};\n\nexport const isSchemaObject = (obj: unknown): obj is SchemaObject => {\n if (!isPlainRecord(obj)) {\n return false;\n }\n\n return (\n 'type' in obj ||\n 'properties' in obj ||\n 'oneOf' in obj ||\n 'anyOf' in obj ||\n 'allOf' in obj ||\n 'items' in obj ||\n 'additionalProperties' in obj ||\n 'enum' in obj ||\n 'const' in obj ||\n 'format' in obj ||\n 'pattern' in obj ||\n 'minimum' in obj ||\n 'maximum' in obj ||\n 'minLength' in obj ||\n 'maxLength' in obj ||\n 'minItems' in obj ||\n 'maxItems' in obj ||\n 'minProperties' in obj ||\n 'maxProperties' in obj ||\n 'required' in obj ||\n 'nullable' in obj ||\n 'description' in obj\n );\n};\n\nexport const isArrayObject = (obj: unknown): obj is ArraySchemaObject => {\n return isSchemaObject(obj) && obj.type === 'array';\n};\n\nexport function hasCombinationKey(obj: Record<string, unknown>): boolean {\n return combinationKeys.some((key) => key in obj);\n}\n\nexport function shouldTruncateForSize(schema: OpenAPIV3_1.SchemaObject): boolean {\n const oneOfSize = Array.isArray(schema.oneOf) ? schema.oneOf.length : 1;\n const anyOfSize = Array.isArray(schema.anyOf) ? schema.anyOf.length : 1;\n const allOfSize = Array.isArray(schema.allOf) ? schema.allOf.length : 1;\n\n const combinations: number[] = [oneOfSize, anyOfSize, allOfSize];\n\n // go three levels deep to estimate if combinations may explode\n combinationKeys.forEach((key) => {\n if (schema[key as keyof OpenAPIV3_1.SchemaObject]) {\n const subSchema = schema[key as keyof OpenAPIV3_1.SchemaObject];\n combinations.push(Object.keys(subSchema).length);\n combinationKeys.forEach((subSchemaKey) => {\n if (subSchema[subSchemaKey as keyof OpenAPIV3_1.SchemaObject]) {\n const subSubSchema = subSchema[subSchemaKey as keyof OpenAPIV3_1.SchemaObject];\n combinations.push(Object.keys(subSubSchema).length);\n combinationKeys.forEach((subSubSchemaKey) => {\n if (subSubSchema[subSubSchemaKey as keyof OpenAPIV3_1.SchemaObject]) {\n const subSubSubSchema =\n subSubSchema[subSubSchemaKey as keyof OpenAPIV3_1.SchemaObject];\n combinations.push(Object.keys(subSubSubSchema).length);\n }\n });\n }\n });\n }\n });\n\n const totalCombinations = combinations.reduce((acc, curr) => acc * curr, 1);\n\n return totalCombinations > MAX_SCHEMA_COMBINATION_SIZE;\n}\n\n// similar to RecursiveParamField/renderTruncatedNextProperties\nexport function createTruncatedNextProperties(\n schema: OpenAPIV3_1.SchemaObject\n): OpenAPIV3_1.SchemaObject {\n const truncatedSchema = { ...schema };\n\n // Remove all composition properties to prevent further recursion\n delete truncatedSchema.oneOf;\n delete truncatedSchema.anyOf;\n delete truncatedSchema.allOf;\n\n if (truncatedSchema.type === 'array') {\n truncatedSchema.items = {};\n } else if (truncatedSchema.type === 'object') {\n truncatedSchema.properties = {};\n if (\n truncatedSchema.additionalProperties &&\n typeof truncatedSchema.additionalProperties === 'object'\n ) {\n truncatedSchema.additionalProperties = {};\n }\n }\n\n return truncatedSchema;\n}\n\nexport function createTruncatedReducedSchema(schema: OpenAPIV3_1.SchemaObject): ReducedSchema {\n const truncatedSchema = createTruncatedNextProperties(schema);\n // For reduction, we need to wrap in oneOf\n return { oneOf: [truncatedSchema] };\n}\n\nexport function collectCombinationSizes(\n value: unknown,\n remainingDepth: number,\n combinations: number[]\n): void {\n if (remainingDepth === 0 || value === undefined || value === null) {\n return;\n }\n\n if (Array.isArray(value)) {\n combinations.push(value.length);\n if (remainingDepth > 1) {\n value.forEach((item) => collectCombinationSizes(item, remainingDepth - 1, combinations));\n }\n return;\n }\n\n if (isPlainRecord(value)) {\n combinations.push(Object.keys(value).length);\n if (remainingDepth > 1) {\n Object.values(value).forEach((item) =>\n collectCombinationSizes(item, remainingDepth - 1, combinations)\n );\n }\n }\n}\n\nexport const addKeyIfDefined = <D, K extends keyof D>(\n key: K,\n value: D[K] | undefined,\n destination: D\n) => {\n if (value !== undefined) {\n destination[key] = value;\n }\n};\n\nexport const copyKeyIfDefined = <D, K extends keyof D>(\n key: K,\n source: Pick<D, K>,\n destination: D\n) => {\n if (source[key] !== undefined) {\n destination[key] = source[key];\n }\n};\n\nexport const takeLast = <T extends keyof OpenAPIV3_1.SchemaObject>(\n schema1: OpenAPIV3_1.SchemaObject,\n schema2: OpenAPIV3_1.SchemaObject,\n key: T\n): OpenAPIV3_1.SchemaObject[T] => {\n return schema2[key] ?? schema1[key];\n};\n\nexport const combine = <T extends keyof OpenAPIV3_1.SchemaObject>(\n schema1: OpenAPIV3_1.SchemaObject,\n schema2: OpenAPIV3_1.SchemaObject,\n key: T,\n transform: (\n a: NonNullable<OpenAPIV3_1.SchemaObject[T]>,\n b: NonNullable<OpenAPIV3_1.SchemaObject[T]>\n ) => OpenAPIV3_1.SchemaObject[T]\n): OpenAPIV3_1.SchemaObject[T] => {\n return schema1[key] !== undefined && schema2[key] !== undefined\n ? transform(schema1[key], schema2[key])\n : schema1[key] ?? schema2[key];\n};\n\nexport const copyExampleIfDefined = (\n source: Pick<OpenAPIV3_1.SchemaObject, 'example' | 'examples'>,\n destination: Pick<DataSchema, 'example'>\n) => {\n const example = source.example !== undefined ? source.example : source.examples?.[0];\n if (example !== undefined) {\n destination.example = example;\n }\n};\n\n// Testing utility for quick and dirty schema graph conversion\nexport const convertSchemaToGraph = (\n schema: OpenAPIV3_1.SchemaObject,\n skipClone: boolean = false\n) => {\n let spec: OpenAPIV3_1.Document;\n if ('openapi' in schema) {\n spec = schema as OpenAPIV3_1.Document;\n } else {\n spec = {\n openapi: '3.1.0',\n info: { title: 'Test', version: '1.0.0' },\n paths: {},\n components: {\n schemas: {\n TestSchema: schema,\n },\n },\n };\n }\n if (!skipClone) {\n const clonedSpec = JSON.parse(JSON.stringify(spec));\n return openApiToSchemaGraph({\n spec: clonedSpec,\n filename: 'test.json',\n originalFileLocation: 'test.json',\n });\n }\n return openApiToSchemaGraph({\n spec,\n filename: 'test.json',\n originalFileLocation: 'test.json',\n });\n};\n\nexport const flattenSingleOneOf = <T extends GraphNode & { oneOf?: SchemaObject[] }>(\n node: T\n): T => {\n if (node.oneOf && node.oneOf.length === 1) {\n return node.oneOf[0] as T;\n }\n return node;\n};\n\nexport const flattenSchemaOneOfs = (schema: SchemaObject): SchemaObject => {\n let result = { ...schema } as SchemaObject;\n\n // recursively flatten into each combinator\n if (result.properties && typeof result.properties === 'object') {\n const flattened: Record<string, SchemaObject> = {};\n for (const [key, value] of Object.entries(result.properties)) {\n if (isSchemaObject(value)) {\n flattened[key] = flattenSchemaOneOfs(value);\n } else {\n flattened[key] = value as SchemaObject;\n }\n }\n result.properties = flattened;\n }\n\n if ('items' in result && result.items && typeof result.items === 'object') {\n if (isSchemaObject(result.items)) {\n result.items = flattenSchemaOneOfs(result.items);\n }\n }\n\n if (\n result.additionalProperties &&\n typeof result.additionalProperties === 'object' &&\n isSchemaObject(result.additionalProperties)\n ) {\n result.additionalProperties = flattenSchemaOneOfs(result.additionalProperties);\n }\n if (result.oneOf && Array.isArray(result.oneOf) && result.oneOf.length > 1) {\n const oneOfArray = result.oneOf;\n const mappedOneOf = (oneOfArray as unknown[]).map((item: unknown) => {\n if (isSchemaObject(item)) {\n return flattenSchemaOneOfs(item);\n }\n return item as SchemaObject;\n });\n result.oneOf = mappedOneOf as SchemaObject[];\n }\n\n if (\n 'oneOf' in result &&\n result.oneOf &&\n Array.isArray(result.oneOf) &&\n result.oneOf.length === 1\n ) {\n const singleItem = result.oneOf[0];\n if (isSchemaObject(singleItem)) {\n result = { ...result, ...singleItem } as SchemaObject;\n delete (result as { oneOf?: unknown[] }).oneOf;\n return flattenSchemaOneOfs(result);\n }\n }\n\n return result;\n};\n\nexport const calculateMaxDepth = (obj: unknown, currentDepth = 0): number => {\n if (obj === null || typeof obj !== 'object') {\n return currentDepth;\n }\n\n if (Array.isArray(obj)) {\n if (obj.length === 0) return currentDepth;\n return Math.max(...obj.map((item) => calculateMaxDepth(item, currentDepth)));\n }\n\n const depths = Object.entries(obj).map(([key, value]) => {\n if (key === 'type' || key === 'title') {\n return currentDepth;\n }\n return calculateMaxDepth(value, currentDepth + 1);\n });\n\n return depths.length > 0 ? Math.max(...depths) : currentDepth;\n};\n\n// converts standard schema types to differentiated types that were used in v1 and oneOf type\nexport const getDifferentiatedType = (schema: ResolvedSchemaObject): DifferentiatedType => {\n if (schema.oneOf) {\n return 'oneOf';\n }\n if (schema.enum) {\n switch (schema.type) {\n case 'string':\n return 'enum<string>';\n case 'number':\n return 'enum<number>';\n case 'integer':\n return 'enum<integer>';\n default:\n return schema.type;\n }\n }\n if (schema.format && stringFileFormats.includes(schema.format)) {\n return 'file';\n }\n return schema.type;\n};\n\nexport const isEnum = (schema: SchemaObject): boolean => {\n return 'enum' in schema && schema.enum !== undefined;\n};\n\nexport const getSchemaPlaceholder = (schema: SchemaObject): string | undefined => {\n return 'placeholder' in schema && typeof schema.placeholder === 'string'\n ? schema.placeholder\n : undefined;\n};\n\nexport const isStringSchema = (schema: SchemaObject): boolean => {\n return schema.type === 'string';\n};\n\nexport const isNumberSchema = (schema: SchemaObject): boolean => {\n return schema.type === 'number' || schema.type === 'integer';\n};\n\nexport const mapResponseExamples = (apiReferenceData: ApiReferenceDataV2) => {\n const responseCodeMediaObjectMap: Record<string, MediaObject> = {};\n Object.entries(apiReferenceData.operation?.responses ?? {}).forEach(([responseCode, UUID]) => {\n const response = apiReferenceData.dependencies?.responses?.[UUID];\n if (response && response.content) {\n responseCodeMediaObjectMap[responseCode] = response.content;\n }\n });\n return responseCodeMediaObjectMap;\n};\n\nexport const generatePrefillRequestData = (\n apiReferenceData: ApiReferenceDataV2\n): ApiPlaygroundInputs[] => {\n const requestBodyContent = apiReferenceData.dependencies?.requestBody?.content;\n if (requestBodyContent === undefined) {\n return [initialApiPlaygroundInputs];\n }\n const requestBodyContentTypes = Object.keys(requestBodyContent);\n const contentType = requestBodyContentTypes[0];\n if (!contentType) {\n return [initialApiPlaygroundInputs];\n }\n const requestBodyContentExamples = Object.values(requestBodyContent[contentType]?.examples ?? {});\n const examples: ApiPlaygroundInputs[] = [];\n for (const example of requestBodyContentExamples) {\n if ('value' in example) {\n examples.push({\n ...initialApiPlaygroundInputs,\n body: example.value,\n });\n }\n }\n\n return examples;\n};\n\nexport const getParametersPerSection = (\n apiReferenceData: ApiReferenceDataV2\n): {\n header: ParameterObject[];\n path: ParameterObject[];\n query: ParameterObject[];\n cookie: ParameterObject[];\n} => {\n const parameters = apiReferenceData.dependencies?.parameters;\n if (parameters) {\n const parameterObjects = Object.values(parameters);\n const headerParameters = parameterObjects.filter(\n (parameter) => !('in' in parameter) || parameter.in === 'header'\n );\n const cookieParameters = parameterObjects.filter((parameter) => parameter.in === 'cookie');\n const pathParameters = parameterObjects.filter((parameter) => parameter.in === 'path');\n const queryParameters = parameterObjects.filter((parameter) => parameter.in === 'query');\n return {\n header: headerParameters,\n path: pathParameters,\n query: queryParameters,\n cookie: cookieParameters,\n };\n }\n return { header: [], path: [], query: [], cookie: [] };\n};\n\nexport const getSchemaDefault = (schema: object | undefined): unknown | undefined => {\n let defaultValue = undefined;\n if (!schema) {\n return undefined;\n }\n if (typeof schema === 'object' && 'default' in schema) {\n defaultValue = schema.default;\n }\n if (typeof schema === 'object' && 'x-default' in schema) {\n defaultValue = schema['x-default'];\n }\n return defaultValue;\n};\n\nexport const getUniqueInputKey = (\n inputKeyPrefix: string,\n schema: ResolvedSchemaObject,\n arrayIndex?: number,\n key?: string\n) => {\n if (!schema.uniqueKey) {\n return inputKeyPrefix;\n } else {\n const arrayIndexOrKey = arrayIndex || key;\n return `${inputKeyPrefix ? inputKeyPrefix + '.' : ''}${schema.uniqueKey}${arrayIndexOrKey ? '.' + arrayIndexOrKey : ''}`;\n }\n};\n\nexport const convertAnySchemaToOneOfs = (): SchemaObject => {\n return {\n oneOf: [\n {\n type: 'string',\n },\n {\n type: 'number',\n },\n {\n type: 'boolean',\n },\n {\n type: 'object',\n properties: {},\n },\n {\n type: 'array',\n items: {\n oneOf: [\n { type: 'string' },\n { type: 'number' },\n { type: 'boolean' },\n { type: 'object', properties: {} },\n { type: 'array', items: {} },\n { type: 'null' },\n ],\n },\n },\n {\n type: 'null',\n },\n ],\n };\n};\n\nexport const getRequestBodyContentType = (\n apiReferenceData: ApiReferenceDataV2,\n contentTypeIndex: number\n): string | undefined => {\n const requestBodyContent = apiReferenceData.dependencies?.requestBody?.content;\n if (requestBodyContent === undefined) {\n return undefined;\n }\n const requestBodyContentTypes = Object.keys(requestBodyContent);\n return requestBodyContentTypes[contentTypeIndex];\n};\n\nexport const escapeDots = (key: string): string => {\n return key.replace(/\\./g, '\\\\.');\n};\n\nexport const mapParamInToPlaygroundInputKey = (parameterIn: string): string => {\n switch (parameterIn) {\n case 'header':\n return apiPlaygroundInputKeys.header;\n case 'path':\n return apiPlaygroundInputKeys.path;\n case 'query':\n return apiPlaygroundInputKeys.query;\n case 'cookie':\n return apiPlaygroundInputKeys.cookie;\n default:\n return apiPlaygroundInputKeys.header;\n }\n};\n\n// CLANKED AS HELL. TODO: Refactor.\nexport const unflattenInputs = (\n inputs: Record<string, PlaygroundInputValue>\n): ApiPlaygroundInputs => {\n const result: ApiPlaygroundInputs = {\n server: {},\n header: {},\n path: {},\n query: {},\n cookie: {},\n body: undefined,\n };\n\n Object.entries(inputs).forEach(([key, value]) => {\n // skip undefined/null values\n if (value === undefined || value === null) {\n return;\n }\n // split on . but not on \\. (escaped dots), then unescape the parts\n const parts = key.split(/(?<!\\\\)\\./).map((part) => part.replace(/\\\\\\./g, '.'));\n if (parts.length < 2) {\n if (key === 'body') {\n result.body = value;\n }\n return;\n }\n\n const [section, ...keyPath] = parts;\n\n const validKeys = Object.values(apiPlaygroundInputKeys);\n if (!section || !validKeys.includes(section)) {\n return;\n }\n\n if (section !== apiPlaygroundInputKeys.body) {\n setNestedValue(\n result[section as keyof ApiPlaygroundInputs] as Record<string, unknown>,\n [...keyPath],\n value\n );\n } else {\n if ([...keyPath].length === 0) {\n result.body = value;\n } else {\n // Initialize body as object if it's undefined\n if (result.body === undefined || typeof result.body !== 'object') {\n result.body = {};\n }\n setNestedValue(result.body as Record<string, unknown>, keyPath, value);\n }\n }\n });\n\n // Convert array-like objects (objects with only numeric keys) to actual arrays\n return convertArrayLikeToArray(result) as ApiPlaygroundInputs;\n};\n\n// Check if an object should be converted to an array (all keys are numeric strings)\nconst isArrayLike = (obj: unknown): obj is Record<string, unknown> => {\n if (!isPlainRecord(obj)) {\n return false;\n }\n const keys = Object.keys(obj);\n if (keys.length === 0) {\n return false;\n }\n // Check if all keys are numeric strings\n return keys.every((k) => /^\\d+$/.test(k));\n};\n\n// Recursively convert array-like objects to arrays\nconst convertArrayLikeToArray = (value: unknown): unknown => {\n if (value === null || value === undefined) {\n return value;\n }\n\n if (Array.isArray(value)) {\n return value.map(convertArrayLikeToArray);\n }\n\n if (isPlainRecord(value)) {\n if (isArrayLike(value)) {\n // Convert object with numeric keys to array\n // Sort keys numerically and map to values\n const keys = Object.keys(value).sort((a, b) => Number(a) - Number(b));\n const arr = keys.map((k) => value[k]);\n // Recursively convert nested values\n return arr.map(convertArrayLikeToArray);\n }\n\n // Recursively process regular objects\n const result: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(value)) {\n result[key] = convertArrayLikeToArray(val);\n }\n return result;\n }\n\n return value;\n};\n\n// recursively set a value in a nested object\nconst setNestedValue = (obj: Record<string, unknown>, keyPath: string[], value: unknown) => {\n // First pass: filter out keys we want to skip\n const filteredKeys: string[] = [];\n for (let i = 0; i < keyPath.length; i++) {\n const key = keyPath[i];\n if (key === 'oneOf') {\n // Skip this key and the next one (the oneOf index)\n i++;\n continue;\n }\n if (key === 'additionalProperties' || key === 'items') {\n // Skip these keys\n continue;\n }\n if (key) {\n filteredKeys.push(key);\n }\n }\n\n // Second pass: navigate through/create nested structure and set value\n let current = obj;\n for (let i = 0; i < filteredKeys.length; i++) {\n const key = filteredKeys[i];\n if (i === filteredKeys.length - 1) {\n // Last key - set the value\n if (key) {\n current[key] = value;\n }\n } else {\n // Not the last key - ensure nested object exists\n if (key && (!current[key] || typeof current[key] !== 'object')) {\n current[key] = {};\n }\n if (key) {\n current = current[key] as Record<string, unknown>;\n }\n }\n }\n};\n// CLANK ENDS HERE\n\nexport const filterSchemasWithConsts = (\n schemas: ResolvedSchemaObject[]\n): ResolvedSchemaObject[] => {\n const filteredSchemas = schemas.filter((schema) => {\n if ('enum' in schema && schema.enum && 'const' in schema) {\n return schema.enum.includes(schema.const);\n }\n return true;\n });\n return filteredSchemas;\n};\n\nexport const getBodyDefaultsFromSchema = (schema: SchemaObject): Record<string, unknown> => {\n const bodyDefaults: Record<string, unknown> = {};\n\n if ('uniqueKey' in schema && schema.uniqueKey !== undefined) {\n const defaultValue = getSchemaDefault(schema);\n if (defaultValue !== undefined) {\n const inputKey = `${apiPlaygroundInputKeys.body}.${schema.uniqueKey}`;\n bodyDefaults[inputKey] = defaultValue;\n }\n }\n\n if ('oneOf' in schema && Array.isArray(schema.oneOf)) {\n schema.oneOf.forEach((subSchema) => {\n if (isSchemaObject(subSchema)) {\n const subDefaults = getBodyDefaultsFromSchema(subSchema);\n Object.assign(bodyDefaults, subDefaults);\n }\n });\n }\n\n if (schema.type === 'object' && schema.properties) {\n Object.values(schema.properties).forEach((propSchema) => {\n if (isSchemaObject(propSchema)) {\n const propDefaults = getBodyDefaultsFromSchema(propSchema);\n Object.assign(bodyDefaults, propDefaults);\n }\n });\n }\n\n if (\n schema.additionalProperties &&\n typeof schema.additionalProperties === 'object' &&\n isSchemaObject(schema.additionalProperties)\n ) {\n const addPropsDefaults = getBodyDefaultsFromSchema(schema.additionalProperties);\n Object.assign(bodyDefaults, addPropsDefaults);\n }\n\n if (schema.type === 'array' && 'items' in schema && isSchemaObject(schema.items)) {\n const itemsDefaults = getBodyDefaultsFromSchema(schema.items);\n Object.assign(bodyDefaults, itemsDefaults);\n }\n\n return bodyDefaults;\n};"],"names":["isCircularRef","value","CIRCULAR_REF_KEY","createEmptyReducedSchema","createUnknownReducedSchema","isPlainRecord","isReducedSchema","schema","isSchemaObject","obj","isArrayObject","shouldTruncateForSize","oneOfSize","anyOfSize","allOfSize","combinations","combinationKeys","key","subSchema","subSchemaKey","subSubSchema","subSubSchemaKey","subSubSubSchema","acc","curr","MAX_SCHEMA_COMBINATION_SIZE","takeLast","schema1","schema2","combine","transform","flattenSingleOneOf","node","flattenSchemaOneOfs","result","flattened","mappedOneOf","item","singleItem","getDifferentiatedType","stringFileFormats","isEnum","getSchemaPlaceholder","isStringSchema","isNumberSchema","mapResponseExamples","apiReferenceData","responseCodeMediaObjectMap","_a","responseCode","UUID","response","_b","generatePrefillRequestData","requestBodyContent","initialApiPlaygroundInputs","contentType","requestBodyContentExamples","_c","examples","example","getParametersPerSection","parameters","parameterObjects","headerParameters","parameter","cookieParameters","pathParameters","queryParameters","getSchemaDefault","defaultValue","getUniqueInputKey","inputKeyPrefix","arrayIndex","arrayIndexOrKey","convertAnySchemaToOneOfs","getRequestBodyContentType","contentTypeIndex","escapeDots","mapParamInToPlaygroundInputKey","parameterIn","apiPlaygroundInputKeys","unflattenInputs","inputs","parts","part","section","keyPath","validKeys","setNestedValue","convertArrayLikeToArray","isArrayLike","keys","k","a","b","val","filteredKeys","i","current","filterSchemasWithConsts","schemas","getBodyDefaultsFromSchema","bodyDefaults","inputKey","subDefaults","propSchema","propDefaults","addPropsDefaults","itemsDefaults"],"mappings":";;AAiCO,SAASA,EAAcC,GAA4C;AACxE,SACE,OAAOA,KAAU,YACjBA,MAAU,QACVC,KAAoBD,KACpB,OAAOA,EAAMC,CAAgB,KAAM;AAEvC;AAMO,MAAMC,IAA2B,OAAsB,EAAE,OAAO,GAAC,IAC3DC,IAA6B,OAAsB,EAAE,OAAO,CAAC,CAAA,CAAE,EAAA,IAE/DC,IAAgB,CAACJ,MAC5B,OAAOA,KAAU,YAAYA,MAAU,QAAQ,CAAC,MAAM,QAAQA,CAAK,GAExDK,IAAkB,CAACC,MAC9BC,EAAeD,CAAM,KAAK,MAAM,QAAQA,EAAO,KAAK,GAmEzCC,IAAiB,CAACC,MACxBJ,EAAcI,CAAG,IAKpB,UAAUA,KACV,gBAAgBA,KAChB,WAAWA,KACX,WAAWA,KACX,WAAWA,KACX,WAAWA,KACX,0BAA0BA,KAC1B,UAAUA,KACV,WAAWA,KACX,YAAYA,KACZ,aAAaA,KACb,aAAaA,KACb,aAAaA,KACb,eAAeA,KACf,eAAeA,KACf,cAAcA,KACd,cAAcA,KACd,mBAAmBA,KACnB,mBAAmBA,KACnB,cAAcA,KACd,cAAcA,KACd,iBAAiBA,IAzBV,IA6BEC,IAAgB,CAACD,MACrBD,EAAeC,CAAG,KAAKA,EAAI,SAAS;AAOtC,SAASE,EAAsBJ,GAA2C;AAC/E,QAAMK,IAAY,MAAM,QAAQL,EAAO,KAAK,IAAIA,EAAO,MAAM,SAAS,GAChEM,IAAY,MAAM,QAAQN,EAAO,KAAK,IAAIA,EAAO,MAAM,SAAS,GAChEO,IAAY,MAAM,QAAQP,EAAO,KAAK,IAAIA,EAAO,MAAM,SAAS,GAEh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QAAQA,EAAO,KAAK,KACjDA,EAAO,MAAM,QAAQ,CAACW,MAAc;AAClC,QAAIV,EAAeU,CAAS,GAAG;AAC7B,YAAMuF,IAAcH,EAA0BpF,CAAS;AACvD,aAAO,OAAOqF,GAAcE,CAAW;AAAA,IACzC;AAAA,EACF,CAAC,GAGClG,EAAO,SAAS,YAAYA,EAAO,cACrC,OAAO,OAAOA,EAAO,UAAU,EAAE,QAAQ,CAACmG,MAAe;AACvD,QAAIlG,EAAekG,CAAU,GAAG;AAC9B,YAAMC,IAAeL,EAA0BI,CAAU;AACzD,aAAO,OAAOH,GAAcI,CAAY;AAAA,IAC1C;AAAA,EACF,CAAC,GAIDpG,EAAO,wBACP,OAAOA,EAAO,wBAAyB,YACvCC,EAAeD,EAAO,oBAAoB,GAC1C;AACA,UAAMqG,IAAmBN,EAA0B/F,EAAO,oBAAoB;AAC9E,WAAO,OAAOgG,GAAcK,CAAgB;AAAA,EAC9C;AAEA,MAAIrG,EAAO,SAAS,WAAW,WAAWA,KAAUC,EAAeD,EAAO,KAAK,GAAG;AAChF,UAAMsG,IAAgBP,EAA0B/F,EAAO,KAAK;AAC5D,WAAO,OAAOgG,GAAcM,CAAa;AAAA,EAC3C;AAEA,SAAON;AACT;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { parseOpenApiSchemaString as t, parseOpenApiString as n } from "./parseOpenApiString.js";
|
|
2
|
+
const a = (p) => {
|
|
3
|
+
const r = p["openapi-schema"];
|
|
4
|
+
if (typeof r == "string" && r.length > 0)
|
|
5
|
+
return {
|
|
6
|
+
type: "schema",
|
|
7
|
+
...t(r)
|
|
8
|
+
};
|
|
9
|
+
const e = p.openapi;
|
|
10
|
+
if (typeof e == "string" && e.length > 0)
|
|
11
|
+
try {
|
|
12
|
+
return {
|
|
13
|
+
type: "operation",
|
|
14
|
+
...n(e)
|
|
15
|
+
};
|
|
16
|
+
} catch (o) {
|
|
17
|
+
console.error(`unable to parse value "${e}" for field "openapi":`, o);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
a as parseApiTargetFromMetadata
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=parseApiTargetFromMetadata.js.map
|