@mintlify/msft-sdk 1.1.18 → 1.1.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/api-playground/ApiPlayground/ApiPlaygroundContext.js +11 -0
  2. package/dist/api-playground/ApiPlayground/ApiPlaygroundContext.js.map +1 -0
  3. package/dist/api-playground-2/ApiExamples.js +3 -3
  4. package/dist/api-playground-2/components/Example/GeneratedRequestExample.js +3 -3
  5. package/dist/api-playground-2/components/Example/GeneratedResponseExample.js +2 -2
  6. package/dist/api-playground-2/components/Example/RequestExample.js +2 -2
  7. package/dist/api-playground-2/constants/index.js +20 -0
  8. package/dist/api-playground-2/constants/index.js.map +1 -0
  9. package/dist/api-playground-2/generators/createBodyData.js +67 -0
  10. package/dist/api-playground-2/generators/createBodyData.js.map +1 -0
  11. package/dist/api-playground-2/generators/createHeaders.js +45 -0
  12. package/dist/api-playground-2/generators/createHeaders.js.map +1 -0
  13. package/dist/api-playground-2/generators/generateInteractiveCodeSample.js +50 -0
  14. package/dist/api-playground-2/generators/generateInteractiveCodeSample.js.map +1 -0
  15. package/dist/api-playground-2/generators/generateRequest.js +65 -0
  16. package/dist/api-playground-2/generators/generateRequest.js.map +1 -0
  17. package/dist/api-playground-2/generators/generateResponseExampleMap.js +36 -0
  18. package/dist/api-playground-2/generators/generateResponseExampleMap.js.map +1 -0
  19. package/dist/api-playground-2/generators/generateSnippet.js +42 -0
  20. package/dist/api-playground-2/generators/generateSnippet.js.map +1 -0
  21. package/dist/api-playground-2/generators/generateSnippetMap.js +68 -0
  22. package/dist/api-playground-2/generators/generateSnippetMap.js.map +1 -0
  23. package/dist/api-playground-2/generators/getFileProperties.js +24 -0
  24. package/dist/api-playground-2/generators/getFileProperties.js.map +1 -0
  25. package/dist/api-playground-2/hooks/usePlaygroundInputsStore.js +22 -0
  26. package/dist/api-playground-2/hooks/usePlaygroundInputsStore.js.map +1 -0
  27. package/dist/api-playground-2/schemaGraph/getAllRequiredProperties.js +10 -0
  28. package/dist/api-playground-2/schemaGraph/getAllRequiredProperties.js.map +1 -0
  29. package/dist/api-playground-2/schemaGraph/processExamples.js +13 -0
  30. package/dist/api-playground-2/schemaGraph/processExamples.js.map +1 -0
  31. package/dist/api-playground-2/schemaGraph/utils.js +76 -0
  32. package/dist/api-playground-2/schemaGraph/utils.js.map +1 -0
  33. package/dist/components/Api/dropdown-menu.js +4 -3
  34. package/dist/components/Api/dropdown-menu.js.map +1 -1
  35. package/dist/components/content-components/CodeGroupSelect/index.js +3 -3
  36. package/dist/constants/initialRequest.js +14 -0
  37. package/dist/constants/initialRequest.js.map +1 -0
  38. package/dist/constants/snippetPresets.js +47 -13
  39. package/dist/constants/snippetPresets.js.map +1 -1
  40. package/dist/contexts/CodeExampleLabelContext.js +14 -0
  41. package/dist/contexts/CodeExampleLabelContext.js.map +1 -0
  42. package/dist/contexts/ConfigContext.js +1 -2
  43. package/dist/contexts/ConfigContext.js.map +1 -1
  44. package/dist/env.js +3 -0
  45. package/dist/env.js.map +1 -0
  46. package/dist/hooks/useSendPlaygroundRequest.js +18 -0
  47. package/dist/hooks/useSendPlaygroundRequest.js.map +1 -0
  48. package/dist/utils/locales/en.js +111 -0
  49. package/dist/utils/locales/en.js.map +1 -0
  50. package/dist/utils/locales/index.js +6 -0
  51. package/dist/utils/locales/index.js.map +1 -0
  52. package/dist/utils/uuid.js +7 -0
  53. package/dist/utils/uuid.js.map +1 -0
  54. package/package.json +1 -1
@@ -0,0 +1,11 @@
1
+ import { createContext as e } from "react";
2
+ const t = e({
3
+ isSending: !1,
4
+ selectedBaseUrlIndex: 0,
5
+ isPlaygroundExpanded: !1,
6
+ selectedExampleIndex: 0
7
+ });
8
+ export {
9
+ t as ApiPlaygroundContext
10
+ };
11
+ //# sourceMappingURL=ApiPlaygroundContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiPlaygroundContext.js","sources":["../../../src/api-playground/ApiPlayground/ApiPlaygroundContext.tsx"],"sourcesContent":["'use client';\n\nimport { ApiPlaygroundResultType } from '@mintlify/models';\nimport { createContext } from 'react';\n\nexport type ApiPlaygroundContextType = {\n isSending?: boolean;\n sendRequest?: () => void;\n isPlaygroundExpanded: boolean;\n result?: ApiPlaygroundResultType;\n selectedBaseUrlIndex: number;\n setSelectedBaseUrlIndex?: (index: number) => void;\n setIsPlaygroundExpanded?: (expanded: boolean) => void;\n baseUrlOptions?: string[];\n selectedExampleIndex?: number;\n setSelectedExampleIndex?: (index: number) => void;\n};\n\nexport const ApiPlaygroundContext = createContext<ApiPlaygroundContextType>({\n isSending: false,\n selectedBaseUrlIndex: 0,\n isPlaygroundExpanded: false,\n selectedExampleIndex: 0,\n});\n"],"names":["ApiPlaygroundContext","createContext"],"mappings":";AAkBO,MAAMA,IAAuBC,EAAwC;AAAA,EAC1E,WAAW;AAAA,EACX,sBAAsB;AAAA,EACtB,sBAAsB;AAAA,EACtB,sBAAsB;AACxB,CAAC;"}
@@ -1,8 +1,8 @@
1
1
  import { jsx as e, jsxs as c } from "react/jsx-runtime";
2
2
  import { useContext as x, useState as f, useMemo as u } from "react";
3
- import { usePlaygroundInputsStore as d } from "@/api-playground-2/hooks/usePlaygroundInputsStore";
4
- import { CodeExampleLabelContext as h } from "@/contexts/CodeExampleLabelContext";
5
- import { ApiReferenceContext2 as g } from "@/contexts/ConfigContext";
3
+ import { usePlaygroundInputsStore as d } from "./hooks/usePlaygroundInputsStore.js";
4
+ import { CodeExampleLabelContext as h } from "../contexts/CodeExampleLabelContext.js";
5
+ import { ApiReferenceContext2 as g } from "../contexts/ConfigContext.js";
6
6
  import R from "../components/Api/ErrorBoundary.js";
7
7
  import { clsx as v } from "clsx";
8
8
  import { RequestExample as C } from "./components/Example/RequestExample.js";
@@ -1,8 +1,8 @@
1
1
  import { jsx as y } from "react/jsx-runtime";
2
2
  import { useState as M, useEffect as B } from "react";
3
- import { generateRequest as E } from "@/api-playground-2/generators/generateRequest";
4
- import { generateSnippet as I } from "@/api-playground-2/generators/generateSnippet";
5
- import { getFirstExampleValue as a } from "@/api-playground-2/schemaGraph/processExamples";
3
+ import { generateRequest as E } from "../../generators/generateRequest.js";
4
+ import { generateSnippet as I } from "../../generators/generateSnippet.js";
5
+ import { getFirstExampleValue as a } from "../../schemaGraph/processExamples.js";
6
6
  import { CodeGroupSelect as w } from "../../../components/content-components/CodeGroupSelect/index.js";
7
7
  import { CodeSnippets as A } from "../../../components/content-components/code-snippets.js";
8
8
  import { langToPresetMap as G } from "../../../constants/snippetPresets.js";
@@ -1,6 +1,6 @@
1
1
  import { jsx as r } from "react/jsx-runtime";
2
- import { generateResponseExampleMap as m } from "@/api-playground-2/generators/generateResponseExampleMap";
3
- import { mapResponseExamples as i } from "@/api-playground-2/schemaGraph/utils";
2
+ import { generateResponseExampleMap as m } from "../../generators/generateResponseExampleMap.js";
3
+ import { mapResponseExamples as i } from "../../schemaGraph/utils.js";
4
4
  import { CodeGroupSelect as u } from "../../../components/content-components/CodeGroupSelect/index.js";
5
5
  import { CodeSnippets as d } from "../../../components/content-components/code-snippets.js";
6
6
  const C = ({
@@ -1,7 +1,7 @@
1
1
  import { jsx as l } from "react/jsx-runtime";
2
2
  import { useState as q, useEffect as y } from "react";
3
- import { initialApiPlaygroundInputs as E } from "@/api-playground-2/constants";
4
- import { generateSnippetMap as x } from "@/api-playground-2/generators/generateSnippetMap";
3
+ import { initialApiPlaygroundInputs as E } from "../../constants/index.js";
4
+ import { generateSnippetMap as x } from "../../generators/generateSnippetMap.js";
5
5
  import { CodeGroupSelect as M } from "../../../components/content-components/CodeGroupSelect/index.js";
6
6
  import { CodeSnippets as O } from "../../../components/content-components/code-snippets.js";
7
7
  import { CodeBlock as T } from "../../../components/content-components/code-block.js";
@@ -0,0 +1,20 @@
1
+ const e = {
2
+ server: {},
3
+ path: {},
4
+ query: {},
5
+ header: {},
6
+ cookie: {},
7
+ body: void 0
8
+ }, o = {
9
+ server: "server",
10
+ path: "path",
11
+ query: "query",
12
+ header: "header",
13
+ cookie: "cookie",
14
+ body: "body"
15
+ };
16
+ export {
17
+ o as apiPlaygroundInputKeys,
18
+ e as initialApiPlaygroundInputs
19
+ };
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/api-playground-2/constants/index.ts"],"sourcesContent":["import { ApiPlaygroundInputs } from '@mintlify/validation';\n\nexport const MAX_RECURSION_DEPTH = 10;\nexport const MAX_SCHEMA_COMBINATION_SIZE = 1000;\nexport const CIRCULAR_REF_KEY = '$circularRef';\nexport const stringFileFormats = ['binary', 'base64'];\n\nexport const combinationKeys = [\n 'properties',\n 'additionalProperties',\n 'items',\n 'oneOf',\n 'anyOf',\n 'allOf',\n];\n\n// duplicated from ApiPlaygroundInputsContext.tsx\nexport const initialApiPlaygroundInputs: ApiPlaygroundInputs = {\n server: {},\n path: {},\n query: {},\n header: {},\n cookie: {},\n body: undefined,\n};\n\nexport const apiPlaygroundInputKeys = {\n server: 'server',\n path: 'path',\n query: 'query',\n header: 'header',\n cookie: 'cookie',\n body: 'body',\n};\n"],"names":["initialApiPlaygroundInputs","apiPlaygroundInputKeys"],"mappings":"AAiBO,MAAMA,IAAkD;AAAA,EAC7D,QAAQ,CAAA;AAAA,EACR,MAAM,CAAA;AAAA,EACN,OAAO,CAAA;AAAA,EACP,QAAQ,CAAA;AAAA,EACR,QAAQ,CAAA;AAAA,EACR,MAAM;AACR,GAEaC,IAAyB;AAAA,EACpC,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AACR;"}
@@ -0,0 +1,67 @@
1
+ import { isObject as x, isFile as s } from "@mintlify/common";
2
+ const j = (n, r, c, m) => {
3
+ if (n !== void 0) {
4
+ if (typeof n == "object" && n !== null && c && c.length > 0 && (n = Object.fromEntries(
5
+ Object.entries(n).filter(([e]) => c.includes(e))
6
+ )), r === "multipart/form-data" || r === "application/x-www-form-urlencoded") {
7
+ if (!n || typeof n != "object")
8
+ return;
9
+ typeof n == "object" && m && m.length > 0 && x(n) && m.forEach((i) => {
10
+ i in n || (n[i] = {
11
+ fileName: "example-file"
12
+ });
13
+ });
14
+ const e = (i) => s(i) ? i.name || "file" : typeof i == "object" ? JSON.stringify(i, void 0, 2) : i == null ? void 0 : i.toString();
15
+ return {
16
+ mimeType: r,
17
+ params: Object.entries(n).flatMap(([i, f]) => Array.isArray(f) ? f.filter((t) => t != null).map((t, u) => {
18
+ const l = f.length > 1 ? `${i}[${u}]` : i;
19
+ return s(t) && "name" in t ? {
20
+ name: l,
21
+ value: e(t),
22
+ fileName: t.name
23
+ } : m && m.includes(i) ? {
24
+ name: l,
25
+ value: e(t),
26
+ fileName: "example-file"
27
+ } : {
28
+ name: l,
29
+ value: e(t)
30
+ };
31
+ }) : s(f) && "name" in f ? [
32
+ {
33
+ name: i,
34
+ value: e(f),
35
+ fileName: f.name
36
+ }
37
+ ] : m && m.includes(i) ? [
38
+ {
39
+ name: i,
40
+ value: e(f),
41
+ fileName: "example-file"
42
+ }
43
+ ] : [
44
+ {
45
+ name: i,
46
+ value: e(f)
47
+ }
48
+ ])
49
+ };
50
+ }
51
+ return typeof n == "string" && r && p(r) ? {
52
+ mimeType: r,
53
+ text: n
54
+ } : {
55
+ mimeType: "application/json",
56
+ text: JSON.stringify(n, null, 2)
57
+ };
58
+ }
59
+ };
60
+ function p(n) {
61
+ const r = n.toLowerCase();
62
+ return r.startsWith("text/") || r.endsWith("+xml") || r.endsWith("/xml");
63
+ }
64
+ export {
65
+ j as getPostData
66
+ };
67
+ //# sourceMappingURL=createBodyData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createBodyData.js","sources":["../../../src/api-playground-2/generators/createBodyData.ts"],"sourcesContent":["import { isFile, isObject } from '@mintlify/common';\nimport type { PostData } from 'har-format';\n\nexport const getPostData = (\n bodyData: unknown,\n selectedBodyContentType?: string,\n requiredProperties?: string[],\n fileProperties?: string[]\n): PostData | undefined => {\n if (bodyData === undefined) {\n return undefined;\n }\n\n if (\n typeof bodyData === 'object' &&\n bodyData !== null &&\n requiredProperties &&\n requiredProperties.length > 0\n ) {\n bodyData = Object.fromEntries(\n Object.entries(bodyData).filter(([key]) => requiredProperties.includes(key))\n );\n }\n\n // if body type is form data, convert to a list of form params\n if (\n selectedBodyContentType === 'multipart/form-data' ||\n selectedBodyContentType === 'application/x-www-form-urlencoded'\n ) {\n if (!bodyData || typeof bodyData !== 'object') {\n return undefined;\n }\n\n if (typeof bodyData === 'object' && fileProperties && fileProperties.length > 0) {\n if (isObject(bodyData)) {\n fileProperties.forEach((fieldName: string) => {\n if (!(fieldName in bodyData)) {\n bodyData[fieldName] = {\n fileName: 'example-file',\n };\n }\n });\n }\n }\n\n const getParamValue = (value: unknown) => {\n if (isFile(value)) {\n return value.name || 'file';\n }\n if (typeof value === 'object') {\n return JSON.stringify(value, undefined, 2);\n }\n return value?.toString();\n };\n\n return {\n mimeType: selectedBodyContentType,\n params: Object.entries(bodyData).flatMap(([name, value]) => {\n if (Array.isArray(value)) {\n return value\n .filter((item) => item !== undefined && item !== null)\n .map((item, index) => {\n const paramName = value.length > 1 ? `${name}[${index}]` : name;\n if (isFile(item) && 'name' in item) {\n return {\n name: paramName,\n value: getParamValue(item),\n fileName: item.name,\n };\n } else if (fileProperties && fileProperties.includes(name)) {\n return {\n name: paramName,\n value: getParamValue(item),\n fileName: 'example-file',\n };\n }\n return {\n name: paramName,\n value: getParamValue(item),\n };\n });\n }\n\n if (isFile(value) && 'name' in value) {\n return [\n {\n name,\n value: getParamValue(value),\n fileName: value.name,\n },\n ];\n } else if (fileProperties && fileProperties.includes(name)) {\n return [\n {\n name,\n value: getParamValue(value),\n fileName: 'example-file',\n },\n ];\n }\n return [\n {\n name,\n value: getParamValue(value),\n },\n ];\n }),\n };\n }\n\n if (\n typeof bodyData === 'string' &&\n selectedBodyContentType &&\n isPlainText(selectedBodyContentType)\n ) {\n return {\n mimeType: selectedBodyContentType,\n text: bodyData,\n };\n }\n\n return {\n mimeType: 'application/json',\n text: JSON.stringify(bodyData, null, 2),\n };\n};\n\nfunction isPlainText(rawContentType: string) {\n const contentType = rawContentType.toLowerCase();\n return (\n contentType.startsWith('text/') || contentType.endsWith('+xml') || contentType.endsWith('/xml')\n );\n}\n"],"names":["getPostData","bodyData","selectedBodyContentType","requiredProperties","fileProperties","key","isObject","fieldName","getParamValue","value","isFile","name","item","index","paramName","isPlainText","rawContentType","contentType"],"mappings":";AAGO,MAAMA,IAAc,CACzBC,GACAC,GACAC,GACAC,MACyB;AACzB,MAAIH,MAAa,QAgBjB;AAAA,QAXE,OAAOA,KAAa,YACpBA,MAAa,QACbE,KACAA,EAAmB,SAAS,MAE5BF,IAAW,OAAO;AAAA,MAChB,OAAO,QAAQA,CAAQ,EAAE,OAAO,CAAC,CAACI,CAAG,MAAMF,EAAmB,SAASE,CAAG,CAAC;AAAA,IAAA,IAM7EH,MAA4B,yBAC5BA,MAA4B,qCAC5B;AACA,UAAI,CAACD,KAAY,OAAOA,KAAa;AACnC;AAGF,MAAI,OAAOA,KAAa,YAAYG,KAAkBA,EAAe,SAAS,KACxEE,EAASL,CAAQ,KACnBG,EAAe,QAAQ,CAACG,MAAsB;AAC5C,QAAMA,KAAaN,MACjBA,EAASM,CAAS,IAAI;AAAA,UACpB,UAAU;AAAA,QAAA;AAAA,MAGhB,CAAC;AAIL,YAAMC,IAAgB,CAACC,MACjBC,EAAOD,CAAK,IACPA,EAAM,QAAQ,SAEnB,OAAOA,KAAU,WACZ,KAAK,UAAUA,GAAO,QAAW,CAAC,IAEpCA,KAAA,gBAAAA,EAAO;AAGhB,aAAO;AAAA,QACL,UAAUP;AAAA,QACV,QAAQ,OAAO,QAAQD,CAAQ,EAAE,QAAQ,CAAC,CAACU,GAAMF,CAAK,MAChD,MAAM,QAAQA,CAAK,IACdA,EACJ,OAAO,CAACG,MAA+BA,KAAS,IAAI,EACpD,IAAI,CAACA,GAAMC,M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
3
+ const a = [], i = /* @__PURE__ */ new Set(), h = Object.values(
4
+ ((c = (o = t.dependencies) == null ? void 0 : o.parameters) == null ? void 0 : c.header) ?? {}
5
+ ).filter((e) => !e.in || e.in === "header").filter((e) => e.schema.isRequired), l = Object.values(
6
+ ((u = t.dependencies) == null ? void 0 : u.processedSecurityOptions) ?? {}
7
+ ).filter(({ scheme: e }) => !("in" in e) || e.in === "header");
8
+ return Object.entries(s).filter((e) => e[1] != null).forEach(([e, r]) => {
9
+ i.add(e), a.push({
10
+ name: e,
11
+ value: r.toString()
12
+ });
13
+ }), h.forEach((e) => {
14
+ const r = e.name;
15
+ i.has(r) || a.push({
16
+ name: r,
17
+ value: `<${r.toLowerCase()}>`
18
+ });
19
+ }), l.forEach(({ scheme: e, schema: r }) => {
20
+ const d = r.title ?? "Authorization";
21
+ i.has(d) || a.push({
22
+ name: d,
23
+ value: p(e)
24
+ });
25
+ }), n && f(a, n), a;
26
+ }, p = (t) => {
27
+ switch (t.type) {
28
+ case "http":
29
+ return t.scheme === "basic" ? "Basic <encoded-value>" : "Bearer <token>";
30
+ case "oauth2":
31
+ return "Bearer <token>";
32
+ case "apiKey":
33
+ default:
34
+ return "<api-key>";
35
+ }
36
+ }, f = (t, s) => {
37
+ t.some(({ name: n }) => n.toLowerCase() === "content-type") || t.push({
38
+ name: "Content-Type",
39
+ value: s
40
+ });
41
+ };
42
+ export {
43
+ v as createHeaders
44
+ };
45
+ //# sourceMappingURL=createHeaders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createHeaders.js","sources":["../../../src/api-playground-2/generators/createHeaders.ts"],"sourcesContent":["import type { Header } from 'har-format';\n\nimport type { ApiReferenceDataV2, SecuritySchemeAndScope } from '@/api-playground-2/types';\n\nexport const createHeaders = (\n apiReferenceData: ApiReferenceDataV2,\n headerInputs: Record<string, unknown>,\n selectedBodyContentType?: string\n): Header[] => {\n const headers: Header[] = [];\n const addedHeaders = new Set<string>();\n const requiredHeaderParameters = Object.values(\n apiReferenceData.dependencies?.parameters?.header ?? {}\n )\n .filter((param) => !param.in || param.in === 'header')\n .filter((param) => param.schema.isRequired);\n const securityHeaderParameters = Object.values(\n apiReferenceData.dependencies?.processedSecurityOptions ?? {}\n ).filter(({ scheme }) => !('in' in scheme) || scheme.in === 'header');\n\n Object.entries(headerInputs)\n .filter((entry): entry is [string, NonNullable<unknown>] => entry[1] != null)\n .forEach(([name, value]) => {\n addedHeaders.add(name);\n headers.push({\n name,\n value: value.toString(),\n });\n });\n\n requiredHeaderParameters.forEach((param) => {\n const name = param.name;\n if (!addedHeaders.has(name)) {\n headers.push({\n name,\n value: `<${name.toLowerCase()}>`,\n });\n }\n });\n\n securityHeaderParameters.forEach(({ scheme, schema }) => {\n const name = schema.title ?? 'Authorization';\n if (!addedHeaders.has(name)) {\n headers.push({\n name,\n value: generateAuthPlaceholder(scheme),\n });\n }\n });\n\n if (selectedBodyContentType) {\n addContentTypeHeader(headers, selectedBodyContentType);\n }\n\n return headers;\n};\n\nconst generateAuthPlaceholder = (scheme: SecuritySchemeAndScope): string => {\n switch (scheme.type) {\n case 'http':\n return scheme.scheme === 'basic' ? 'Basic <encoded-value>' : 'Bearer <token>';\n case 'oauth2':\n return 'Bearer <token>';\n case 'apiKey':\n default:\n return '<api-key>';\n }\n};\n\nconst addContentTypeHeader = (headers: Header[], contentType: string) => {\n if (headers.some(({ name }) => name.toLowerCase() === 'content-type')) {\n return;\n }\n\n headers.push({\n name: 'Content-Type',\n value: contentType,\n });\n};\n"],"names":["createHeaders","apiReferenceData","headerInputs","selectedBodyContentType","_a","_b","_c","headers","addedHeaders","requiredHeaderParameters","param","securityHeaderParameters","scheme","entry","name","value","schema","generateAuthPlaceholder","addContentTypeHeader","contentType"],"mappings":"AAIO,MAAMA,IAAgB,CAC3BC,GACAC,GACAC,MACa;AAJR,MAAAC,GAAAC,GAAAC;AAKL,QAAMC,IAAoB,CAAA,GACpBC,wBAAmB,IAAA,GACnBC,IAA2B,OAAO;AAAA,MACtC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UAAU,0BAA0B;AAAA,IAC/D,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL;AACE,aAAO;AAAA,EAAA;AAEb,GAEMM,IAAuB,CAACX,GAAmBY,MAAwB;AACvE,EAAIZ,EAAQ,KAAK,CAAC,EAAE,MAAAO,EAAA,MAAWA,EAAK,kBAAkB,cAAc,KAIpEP,EAAQ,KAAK;AAAA,IACX,MAAM;AAAA,IACN,OAAOY;AAAA,EAAA,CACR;AACH;"}
@@ -0,0 +1,50 @@
1
+ import { getFirstExampleValue as g } from "../schemaGraph/processExamples.js";
2
+ import { langToPresetMap as f } from "../../constants/snippetPresets.js";
3
+ import { generateRequest as q } from "./generateRequest.js";
4
+ import { generateSnippet as x } from "./generateSnippet.js";
5
+ const E = async ({
6
+ apiReferenceData: e,
7
+ baseUrl: n,
8
+ inputs: o,
9
+ apiPlaygroundMode: m,
10
+ lang: d,
11
+ requiredOnly: l
12
+ }) => {
13
+ var r, s, p, c;
14
+ if (n && m !== "none") {
15
+ const u = Object.keys(
16
+ ((s = (r = e.dependencies) == null ? void 0 : r.requestBody) == null ? void 0 : s.content) ?? {}
17
+ )[0], y = g(
18
+ ((c = (p = e.dependencies) == null ? void 0 : p.requestBody) == null ? void 0 : c.content) ?? {}
19
+ );
20
+ try {
21
+ const a = q({
22
+ baseUrl: n,
23
+ apiReferenceData: e,
24
+ inputs: o,
25
+ exampleData: y,
26
+ selectedBodyContentType: u,
27
+ requiredOnly: l
28
+ }), i = f[d];
29
+ if (i == null)
30
+ return;
31
+ const [t] = await x({
32
+ request: a,
33
+ pathInputs: o.path,
34
+ snippetPresets: [i],
35
+ apiReferenceData: e
36
+ });
37
+ if (t)
38
+ return {
39
+ label: "Interactive Example",
40
+ lang: t.language,
41
+ source: t.code
42
+ };
43
+ } catch {
44
+ }
45
+ }
46
+ };
47
+ export {
48
+ E as generateInteractiveCodeSample
49
+ };
50
+ //# sourceMappingURL=generateInteractiveCodeSample.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateInteractiveCodeSample.js","sources":["../../../src/api-playground-2/generators/generateInteractiveCodeSample.ts"],"sourcesContent":["import { ApiPlaygroundDisplayType } from '@mintlify/models';\nimport { ApiPlaygroundInputs, CodeSample } from '@mintlify/validation';\n\nimport { getFirstExampleValue } from '@/api-playground-2/schemaGraph/processExamples';\nimport type { ApiReferenceDataV2 } from '@/api-playground-2/types';\nimport { langToPresetMap } from '@/constants/snippetPresets';\n\nimport { generateRequest } from './generateRequest';\nimport { generateSnippet } from './generateSnippet';\n\nexport const generateInteractiveCodeSample = async ({\n apiReferenceData,\n baseUrl,\n inputs,\n apiPlaygroundMode,\n lang,\n requiredOnly,\n}: {\n lang: string;\n baseUrl?: string;\n apiReferenceData: ApiReferenceDataV2;\n inputs: ApiPlaygroundInputs;\n apiPlaygroundMode: ApiPlaygroundDisplayType;\n requiredOnly?: boolean;\n}): Promise<CodeSample | undefined> => {\n if (baseUrl && apiPlaygroundMode !== 'none') {\n const firstRequestBodyContentType = Object.keys(\n apiReferenceData.dependencies?.requestBody?.content ?? {}\n )[0];\n const firstExample = getFirstExampleValue(\n apiReferenceData.dependencies?.requestBody?.content ?? {}\n );\n try {\n const request = generateRequest({\n baseUrl,\n apiReferenceData,\n inputs,\n exampleData: firstExample,\n selectedBodyContentType: firstRequestBodyContentType,\n requiredOnly,\n });\n const preset = langToPresetMap[lang];\n if (preset == undefined) {\n return;\n }\n const [snippet] = await generateSnippet({\n request,\n pathInputs: inputs.path,\n snippetPresets: [preset],\n apiReferenceData,\n });\n if (snippet)\n return {\n label: 'Interactive Example',\n lang: snippet.language,\n source: snippet.code,\n };\n } catch (err) {}\n }\n};\n"],"names":["generateInteractiveCodeSample","apiReferenceData","baseUrl","inputs","apiPlaygroundMode","lang","requiredOnly","firstRequestBodyContentType","_b","_a","firstExample","getFirstExampleValue","_d","_c","request","generateRequest","preset","langToPresetMap","snippet","generateSnippet"],"mappings":";;;;AAUO,MAAMA,IAAgC,OAAO;AAAA,EAClD,kBAAAC;AAAA,EACA,SAAAC;AAAA,EACA,QAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,MAAAC;AAAA,EACA,cAAAC;AACF,MAOuC;;AACrC,MAAIJ,KAAWE,MAAsB,QAAQ;AAC3C,UAAMG,IAA8B,OAAO;AAAA,QACzCC,KAAAC,IAAAR,EAAiB,iBAAjB,gBAAAQ,EAA+B,gBAA/B,gBAAAD,EAA4C,YAAW,CAAA;AAAA,IAAC,EACxD,CAAC,GACGE,IAAeC;AAAA,QACnBC,KAAAC,IAAAZ,EAAiB,iBAAjB,gBAAAY,EAA+B,gBAA/B,gBAAAD,EAA4C,YAAW,CAAA;AAAA,IAAC;AAE1D,QAAI;AACF,YAAME,IAAUC,EAAgB;AAAA,QAC9B,SAAAb;AAAA,QACA,kBAAAD;AAAA,QACA,QAAAE;AAAA,QACA,aAAaO;AAAA,QACb,yBAAyBH;AAAA,QACzB,cAAAD;AAAA,MAAA,CACD,GACKU,IAASC,EAAgBZ,CAAI;AACnC,UAAIW,KAAU;AACZ;AAEF,YAAM,CAACE,CAAO,IAAI,MAAMC,EAAgB;AAAA,QACtC,SAAAL;AAAA,QACA,YAAYX,EAAO;AAAA,QACnB,gBAAgB,CAACa,CAAM;AAAA,QACvB,kBAAAf;AAAA,MAAA,CACD;AACD,UAAIiB;AACF,eAAO;AAAA,UACL,OAAO;AAAA,UACP,MAAMA,EAAQ;AAAA,UACd,QAAQA,EAAQ;AAAA,QAAA;AAAA,IAEtB,QAAc;AAAA,IAAC;AAAA,EACjB;AACF;"}
@@ -0,0 +1,65 @@
1
+ import { isObject as c } from "@mintlify/common";
2
+ import y from "lodash/cloneDeep";
3
+ import U from "lodash/merge";
4
+ import { getAllRequiredProperties as $ } from "../schemaGraph/getAllRequiredProperties.js";
5
+ import { isSchemaObject as k } from "../schemaGraph/utils.js";
6
+ import { initialRequest as F } from "../../constants/initialRequest.js";
7
+ import { addPathParams as H, joinWithSingleSlash as J, addServerVariables as K } from "../../hooks/useSendPlaygroundRequest.js";
8
+ import { getPostData as M } from "./createBodyData.js";
9
+ import { createHeaders as N } from "./createHeaders.js";
10
+ import { getFileProperties as Q } from "./getFileProperties.js";
11
+ const W = ({
12
+ exampleData: o,
13
+ apiReferenceData: r,
14
+ baseUrl: t,
15
+ inputs: e,
16
+ selectedBodyContentType: i,
17
+ requiredOnly: n
18
+ }) => {
19
+ var f, l, p, u, b, g;
20
+ const S = Object.values(((f = r.dependencies) == null ? void 0 : f.parameters) ?? {}).filter((d) => d.style === "deepObject").map((d) => d.name), j = V(e, S), v = H(((l = r.operation) == null ? void 0 : l.path) ?? "", e.path), a = N(r, e.header, i), m = _(e.body), q = c(o), O = c(e.body) ? h(e.body) : {}, A = !m && q ? U(y(o), O) : null, P = m ? o : A;
21
+ let s;
22
+ i && k(
23
+ (b = (u = (p = r.dependencies) == null ? void 0 : p.requestBody) == null ? void 0 : u.content[i]) == null ? void 0 : b.schema
24
+ ) && (s = r.dependencies.requestBody.content[i].schema);
25
+ const E = n && !e.body && s ? $(s) : void 0, B = s ? Q(s) : void 0, I = M(
26
+ P,
27
+ i,
28
+ E,
29
+ B
30
+ );
31
+ return {
32
+ ...F,
33
+ method: (((g = r.operation) == null ? void 0 : g.method) ?? "").toUpperCase(),
34
+ url: J(K(t, e.server), v),
35
+ queryString: j,
36
+ headers: a,
37
+ postData: I
38
+ };
39
+ }, V = (o, r) => Object.entries(o.query).flatMap(([t, e]) => e ? Array.isArray(e) ? e.filter(Boolean).map((i) => ({
40
+ name: t,
41
+ value: i.toString()
42
+ })) : typeof e == "object" ? r != null && r.includes(t) ? Object.entries(e).filter(([i, n]) => n).map(([i, n]) => ({
43
+ name: `${t}[${i}]`,
44
+ value: n.toString()
45
+ })) : [{ name: t, value: JSON.stringify(e) }] : [
46
+ {
47
+ name: t,
48
+ value: e.toString()
49
+ }
50
+ ] : []), _ = (o) => {
51
+ if (o == null)
52
+ return !0;
53
+ if (typeof o == "object")
54
+ return Object.values(o).every((r) => r === void 0);
55
+ };
56
+ function h(o) {
57
+ const r = y(o);
58
+ for (const t in r)
59
+ r[t] === void 0 ? delete r[t] : c(r[t]) && h(r[t]);
60
+ return r;
61
+ }
62
+ export {
63
+ W as generateRequest
64
+ };
65
+ //# sourceMappingURL=generateRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateRequest.js","sources":["../../../src/api-playground-2/generators/generateRequest.ts"],"sourcesContent":["import { isObject } from '@mintlify/common';\nimport { ApiPlaygroundInputs, SchemaObject } from '@mintlify/validation';\nimport type { Request } from 'har-format';\nimport cloneDeep from 'lodash/cloneDeep';\nimport merge from 'lodash/merge';\n\nimport { getAllRequiredProperties } from '@/api-playground-2/schemaGraph/getAllRequiredProperties';\nimport { isSchemaObject } from '@/api-playground-2/schemaGraph/utils';\nimport type { ApiReferenceDataV2 } from '@/api-playground-2/types';\nimport { initialRequest } from '@/constants/initialRequest';\nimport {\n addPathParams,\n addServerVariables,\n joinWithSingleSlash,\n} from '@/hooks/useSendPlaygroundRequest';\n\nimport { getPostData } from './createBodyData';\nimport { createHeaders } from './createHeaders';\nimport { getFileProperties } from './getFileProperties';\n\ntype QueryParam = { name: string; value: string };\n\n/**\n * Constructs the request from the URL, schema, and inputs\n */\nexport const generateRequest = ({\n exampleData,\n apiReferenceData,\n baseUrl,\n inputs,\n selectedBodyContentType,\n requiredOnly,\n}: {\n exampleData?: unknown;\n apiReferenceData: ApiReferenceDataV2;\n baseUrl: string;\n inputs: ApiPlaygroundInputs;\n selectedBodyContentType?: string;\n requiredOnly?: boolean;\n}): Request => {\n const queryParamsWithDeepObjects = Object.values(apiReferenceData.dependencies?.parameters ?? {})\n .filter((param) => param.style === 'deepObject')\n .map((param) => param.name);\n\n const queryString = createQueryString(inputs, queryParamsWithDeepObjects);\n const path = addPathParams(apiReferenceData.operation?.path ?? '', inputs.path);\n const headers = createHeaders(apiReferenceData, inputs.header, selectedBodyContentType);\n\n const bodyIsEmpty = isBodyEmpty(inputs.body);\n const bodyIsObject = isObject(exampleData);\n const input = isObject(inputs.body) ? deleteUndefinedKeys(inputs.body) : {};\n\n const mergedExampleAndBody =\n !bodyIsEmpty && bodyIsObject ? merge(cloneDeep(exampleData), input) : null;\n\n const bodyData = bodyIsEmpty ? exampleData : mergedExampleAndBody;\n let requestBodySchema: SchemaObject | undefined = undefined;\n\n if (selectedBodyContentType) {\n if (\n isSchemaObject(\n apiReferenceData.dependencies?.requestBody?.content[selectedBodyContentType]?.schema\n )\n ) {\n requestBodySchema =\n apiReferenceData.dependencies.requestBody.content[selectedBodyContentType].schema;\n }\n }\n\n const requiredProperties =\n requiredOnly && !inputs.body && requestBodySchema\n ? \n getAllRequiredProperties(requestBodySchema as SchemaObject)\n : undefined;\n\n const fileProperties = requestBodySchema ? getFileProperties(requestBodySchema) : undefined;\n\n const postData = getPostData(\n bodyData,\n selectedBodyContentType,\n requiredProperties,\n fileProperties\n );\n\n return {\n ...initialRequest,\n method: (apiReferenceData.operation?.method ?? '').toUpperCase(),\n url: joinWithSingleSlash(addServerVariables(baseUrl, inputs.server), path),\n queryString,\n headers,\n postData,\n };\n};\n\nconst createQueryString = (\n inputs: ApiPlaygroundInputs,\n queryParamsWithDeepObjects?: string[]\n): QueryParam[] => {\n return Object.entries(inputs.query).flatMap(([name, value]) => {\n if (!value) return [];\n\n if (Array.isArray(value)) {\n return value.filter(Boolean).map((element) => ({\n name,\n value: element.toString(),\n }));\n }\n\n if (typeof value === 'object') {\n if (queryParamsWithDeepObjects?.includes(name)) {\n return Object.entries(value)\n .filter(([_, value]) => value)\n .map(([key, value]) => ({\n name: `${name}[${key}]`,\n value: value.toString(),\n }));\n }\n\n return [{ name, value: JSON.stringify(value) }];\n }\n\n return [\n {\n name,\n value: value.toString(),\n },\n ];\n });\n};\n\nconst isBodyEmpty = (bodyData: unknown) => {\n if (bodyData === null || bodyData === undefined) {\n return true;\n }\n\n if (typeof bodyData === 'object') {\n return Object.values(bodyData).every((value) => value === undefined);\n }\n};\n\nfunction deleteUndefinedKeys(obj: Record<string, unknown>): Record<string, unknown> {\n const objClone = cloneDeep(obj);\n for (const key in objClone) {\n if (objClone[key] === undefined) delete objClone[key];\n else if (isObject(objClone[key])) deleteUndefinedKeys(objClone[key]);\n }\n return objClone;\n}\n"],"names":["generateRequest","exampleData","apiReferenceData","baseUrl","inputs","selectedBodyContentType","requiredOnly","queryParamsWithDeepObjects","_a","param","queryString","createQueryString","path","addPathParams","_b","headers","createHeaders","bodyIsEmpty","isBodyEmpty","bodyIsObject","isObject","input","deleteUndefinedKeys","mergedExampleAndBody","merge","cloneDeep","bodyData","requestBodySchema","isSchemaObject","_e","_d","_c","requiredProperties","getAllRequiredProperties","fileProperties","getFileProperties","postData","getPostData","initialRequest","_f","joinWithSingleSlash","addServerVariables","name","value","element","_","key","obj","objClone"],"mappings":";;;;;;;;;;AAyBO,MAAMA,IAAkB,CAAC;AAAA,EAC9B,aAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,SAAAC;AAAA,EACA,QAAAC;AAAA,EACA,yBAAAC;AAAA,EACA,cAAAC;AACF,MAOe;;AACb,QAAMC,IAA6B,OAAO,SAAOC,IAAAN,EAAiB,iBAAjB,gBAAAM,EAA+B,eAAc,CAAA,CAAE,EAC7F,OAAO,CAACC,MAAUA,EAAM,UAAU,YAAY,EAC9C,IAAI,CAACA,MAAUA,EAAM,IAAI,GAEtBC,IAAcC,EAAkBP,GAAQG,CAA0B,GAClEK,IAAOC,IAAcC,IAAAZ,EAAiB,cAAjB,gBAAAY,EAA4B,SAAQ,IAAIV,EAAO,IAAI,GACxEW,IAAUC,EAAcd,GAAkBE,EAAO,QAAQC,CAAuB,GAEhFY,IAAcC,EAAYd,EAAO,IAAI,GACrCe,IAAeC,EAASnB,CAAW,GACnCoB,IAAQD,EAAShB,EAAO,IAAI,IAAIkB,EAAoBlB,EAAO,IAAI,IAAI,CAAA,GAEnEmB,IACJ,CAACN,KAAeE,IAAeK,EAAMC,EAAUxB,CAAW,GAAGoB,CAAK,IAAI,MAElEK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AD,GAAM,OAAO,KAAK,UAAUC,CAAK,GAAG,IAGzC;AAAA,EACL;AAAA,IACE,MAAAD;AAAA,IACA,OAAOC,EAAM,SAAA;AAAA,EAAS;AACxB,IA1BiB,CAAA,CA4BpB,GAGGzB,IAAc,CAACQ,MAAsB;AACzC,MAAIA,KAAa;AACf,WAAO;AAGT,MAAI,OAAOA,KAAa;AACtB,WAAO,OAAO,OAAOA,CAAQ,EAAE,MAAM,CAACiB,MAAUA,MAAU,MAAS;AAEvE;AAEA,SAASrB,EAAoByB,GAAuD;AAClF,QAAMC,IAAWvB,EAAUsB,CAAG;AAC9B,aAAWD,KAAOE;AAChB,IAAIA,EAASF,CAAG,MAAM,SAAW,OAAOE,EAASF,CAAG,IAC3C1B,EAAS4B,EAASF,CAAG,CAAC,KAAGxB,EAAoB0B,EAASF,CAAG,CAAC;AAErE,SAAOE;AACT;"}
@@ -0,0 +1,36 @@
1
+ const y = (a, l) => Object.entries(a).sort().reduce((e, [n, r]) => {
2
+ const t = Object.keys(r), c = t[l] ? r[t[l]] : r[t[0]];
3
+ if (c === void 0)
4
+ return e[n] = {
5
+ "": {
6
+ filename: n,
7
+ code: "This response has no body data.",
8
+ language: ""
9
+ }
10
+ }, e;
11
+ const i = c.examples, s = i == null ? void 0 : i[0];
12
+ if (s && "value" in s && s.value === void 0)
13
+ return e[n] = {
14
+ "": {
15
+ filename: n,
16
+ code: "This response does not have an example.",
17
+ language: ""
18
+ }
19
+ }, e;
20
+ const g = Object.entries(i ?? {}).reduce(
21
+ (u, [h, o]) => {
22
+ const f = "value" in o ? o.value : o, d = "title" in o && typeof o.title == "string" ? o.title : "", v = JSON.stringify(f, null, 2);
23
+ return u[d] = {
24
+ filename: n,
25
+ language: "json",
26
+ code: v
27
+ }, u;
28
+ },
29
+ {}
30
+ );
31
+ return e[n] = g, e;
32
+ }, {});
33
+ export {
34
+ y as generateResponseExampleMap
35
+ };
36
+ //# sourceMappingURL=generateResponseExampleMap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateResponseExampleMap.js","sources":["../../../src/api-playground-2/generators/generateResponseExampleMap.ts"],"sourcesContent":["import type { MediaObject } from '@mintlify/validation';\n\nimport type { ExampleCodeSnippet } from '@/types/exampleCodeSnippet';\n\ntype ExampleMap = { [title: string]: ExampleCodeSnippet };\ntype ResponseExampleMap = { [status: string]: ExampleMap };\n\nexport const generateResponseExampleMap = (\n responses: Record<string, MediaObject>,\n selectedContentTypeIndex?: number\n): ResponseExampleMap => {\n return Object.entries(responses)\n .sort()\n .reduce<ResponseExampleMap>((map, [status, mediaObject]) => {\n const contentTypes = Object.keys(mediaObject);\n const content: MediaObject | undefined =\n selectedContentTypeIndex !== undefined && contentTypes[selectedContentTypeIndex]\n ? \n mediaObject[contentTypes[selectedContentTypeIndex] as keyof MediaObject]\n : \n mediaObject[contentTypes[0] as keyof MediaObject];\n if (content === undefined) {\n map[status] = {\n '': {\n filename: status,\n code: 'This response has no body data.',\n language: '',\n },\n };\n return map;\n }\n const contentExamples = content.examples;\n const firstExample = contentExamples?.[0];\n if (firstExample && 'value' in firstExample && firstExample.value === undefined) {\n map[status] = {\n '': {\n filename: status,\n code: 'This response does not have an example.',\n language: '',\n },\n };\n return map;\n }\n const exampleMap = Object.entries(contentExamples ?? {}).reduce<ExampleMap>(\n (exampleMap, [_, example]) => {\n const exampleValue = 'value' in example ? example.value : example;\n const exampleTitle =\n 'title' in example && typeof example.title === 'string' ? example.title : '';\n const stringifiedExample = JSON.stringify(exampleValue, null, 2);\n exampleMap[exampleTitle] = {\n filename: status,\n language: 'json',\n code: stringifiedExample,\n };\n return exampleMap;\n },\n {}\n );\n map[status] = exampleMap;\n return map;\n }, {});\n};\n"],"names":["generateResponseExampleMap","responses","selectedContentTypeIndex","map","status","mediaObject","contentTypes","content","contentExamples","firstExample","exampleMap","_","example","exampleValue","exampleTitle","stringifiedExample"],"mappings":"AAOO,MAAMA,IAA6B,CACxCC,GACAC,MAEO,OAAO,QAAQD,CAAS,EAC5B,KAAA,EACA,OAA2B,CAACE,GAAK,CAACC,GAAQC,CAAW,MAAM;AAC1D,QAAMC,IAAe,OAAO,KAAKD,CAAW,GACtCE,IACsCD,EAAaJ,CAAwB,IAE3EG,EAAYC,EAAaJ,CAAwB,CAAsB,IAEvEG,EAAYC,EAAa,CAAC,CAAsB;AACtD,MAAIC,MAAY;AACd,WAAAJ,EAAIC,CAAM,IAAI;AAAA,MACZ,IAAI;AAAA,QACF,UAAUA;AAAA,QACV,MAAM;AAAA,QACN,UAAU;AAAA,MAAA;AAAA,IACZ,GAEKD;AAET,QAAMK,IAAkBD,EAAQ,UAC1BE,IAAeD,KAAA,gBAAAA,EAAkB;AACvC,MAAIC,KAAgB,WAAWA,KAAgBA,EAAa,UAAU;AACpE,WAAAN,EAAIC,CAAM,IAAI;AAAA,MACZ,IAAI;AAAA,QACF,UAAUA;AAAA,QACV,MAAM;AAAA,QACN,UAAU;AAAA,MAAA;AAAA,IACZ,GAEKD;AAET,QAAMO,IAAa,OAAO,QAAQF,KAAmB,CAAA,CAAE,EAAE;AAAA,IACvD,CAACE,GAAY,CAACC,GAAGC,CAAO,MAAM;AAC5B,YAAMC,IAAe,WAAWD,IAAUA,EAAQ,QAAQA,GACpDE,IACJ,WAAWF,KAAW,OAAOA,EAAQ,SAAU,WAAWA,EAAQ,QAAQ,IACtEG,IAAqB,KAAK,UAAUF,GAAc,MAAM,CAAC;AAC/DH,aAAAA,EAAWI,CAAY,IAAI;AAAA,QACzB,UAAUV;AAAA,QACV,UAAU;AAAA,QACV,MAAMW;AAAA,MAAA,GAEDL;AAAAA,IACT;AAAA,IACA,CAAA;AAAA,EAAC;AAEH,SAAAP,EAAIC,CAAM,IAAIM,GACPP;AACT,GAAG,CAAA,CAAE;"}
@@ -0,0 +1,42 @@
1
+ import { HTTPSnippet as T } from "@readme/httpsnippet";
2
+ import { generateUniqueString as U } from "../../utils/uuid.js";
3
+ import { snippetPresets as x } from "../../constants/snippetPresets.js";
4
+ const N = async ({
5
+ request: r,
6
+ pathInputs: p,
7
+ apiReferenceData: s,
8
+ snippetPresets: a = x,
9
+ isMultipleRequest: c = !1
10
+ }) => {
11
+ const i = {}, g = /:{[^{}]+}/g, m = r.url.replace(g, (t) => {
12
+ const e = ":62437";
13
+ return i[e] = t, e;
14
+ }), f = /{[^{}]+}/g, d = m.replace(f, (t) => {
15
+ const e = t.slice(1, t.length - 1), n = p[e];
16
+ if (t === "{endpoint}")
17
+ return "https://{endpoint}";
18
+ if (n && (typeof n != "string" || n.length > 0))
19
+ return `${encodeURIComponent(n.toString())}`;
20
+ const o = U();
21
+ return i[o] = t, o;
22
+ }), h = new T({
23
+ ...r,
24
+ url: d,
25
+ postData: r.postData || { mimeType: "application/json" }
26
+ });
27
+ return Promise.all(
28
+ a.map(async (t) => {
29
+ var u;
30
+ const { filename: e, snippet: n, language: o } = t, { target: P, client: S } = n, l = h.convert(P, S), y = R(i, (l == null ? void 0 : l.toString()) || "");
31
+ return {
32
+ filename: c ? e : ((u = s.operation) == null ? void 0 : u.title) || e,
33
+ code: y,
34
+ language: o
35
+ };
36
+ })
37
+ );
38
+ }, R = (r, p) => Object.entries(r).reduce((s, [a, c]) => s.replace(a, c), p);
39
+ export {
40
+ N as generateSnippet
41
+ };
42
+ //# sourceMappingURL=generateSnippet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateSnippet.js","sources":["../../../src/api-playground-2/generators/generateSnippet.ts"],"sourcesContent":["import { ApiPlaygroundInputs } from '@mintlify/validation';\nimport type { Request } from 'har-format';\nimport { HTTPSnippet } from '@readme/httpsnippet';\nimport { generateUniqueString } from '@/utils/uuid';\n\nimport type { ApiReferenceDataV2 } from '@/api-playground-2/types';\nimport { snippetPresets as defaultSnippetPresets, SnippetPreset } from '@/constants/snippetPresets';\nimport { ExampleCodeSnippet } from '@/types/exampleCodeSnippet';\n\ntype TargetId = 'c' | 'clojure' | 'csharp' | 'go' | 'http' | 'java' | 'javascript' | 'json' | 'kotlin' | 'node' | 'objc' | 'ocaml' | 'php' | 'powershell' | 'python' | 'r' | 'ruby' | 'shell' | 'swift';\n\nexport interface GenerateSnippetParams {\n request: Request;\n pathInputs: ApiPlaygroundInputs['path'];\n apiReferenceData: ApiReferenceDataV2;\n snippetPresets?: SnippetPreset[];\n isMultipleRequest?: boolean;\n}\n\nexport const generateSnippet = async ({\n request,\n pathInputs,\n apiReferenceData,\n snippetPresets = defaultSnippetPresets,\n isMultipleRequest = false,\n}: GenerateSnippetParams): Promise<ExampleCodeSnippet[]> => {\n const uuidToName: Record<string, string> = {};\n\n // https://regex101.com/r/3PPRco/1\n const portRegex = /:{[^{}]+}/g;\n\n // for the port number found in the url that is not populated, replace it with a rare integer\n const safePortUrl = request.url.replace(portRegex, (nameWithColon) => {\n const replacementWithColon = ':62437'; // arbitrary port value which is unlikely to appear in url\n uuidToName[replacementWithColon] = nameWithColon;\n return replacementWithColon;\n });\n\n // https://regex101.com/r/pwKjrJ/1\n const pathParamRegex = /{[^{}]+}/g;\n\n // for each path param found in the url, replace it with the value if the input is populated, otherwise replace it with a uuid\n const safeUrl = safePortUrl.replace(pathParamRegex, (name) => {\n const nameNoBrackets = name.slice(1, name.length - 1);\n const paramValue = pathInputs[nameNoBrackets];\n\n if (name === '{endpoint}') {\n return 'https://{endpoint}';\n }\n\n if (paramValue && (typeof paramValue !== 'string' || paramValue.length > 0)) {\n return `${encodeURIComponent(paramValue.toString())}`;\n }\n\n const uuid = generateUniqueString();\n uuidToName[uuid] = name;\n return uuid;\n });\n\n const httpSnippet = new HTTPSnippet({\n ...request,\n url: safeUrl,\n postData: request.postData || { mimeType: 'application/json' },\n });\n\n return Promise.all(\n snippetPresets.map(async (snippetPreset) => {\n const { filename, snippet, language } = snippetPreset;\n const { target, client } = snippet;\n const response = httpSnippet.convert(target as TargetId, client);\n\n const code = restorePlaceholders(uuidToName, response?.toString() || '');\n\n return {\n filename: isMultipleRequest ? filename : apiReferenceData.operation?.title || filename,\n code,\n language,\n };\n })\n );\n};\n\n/**\n * For each uuid that was substituted into the url, replaces the first (and only) instance of the uuid with the original name.\n *\n * @param uuidNameMap - Mapping of UUIDs to their original names.\n * @param snippet - String where UUIDs need to be replaced with their original names.\n */\nconst restorePlaceholders = (uuidNameMap: Record<string, string>, snippet: string): string => {\n return Object.entries(uuidNameMap).reduce((acc, [uuid, name]) => {\n return acc.replace(uuid, name);\n }, snippet);\n};\n"],"names":["generateSnippet","request","pathInputs","apiReferenceData","snippetPresets","defaultSnippetPresets","isMultipleRequest","uuidToName","portRegex","safePortUrl","nameWithColon","replacementWithColon","pathParamRegex","safeUrl","name","nameNoBrackets","paramValue","uuid","generateUniqueString","httpSnippet","HTTPSnippet","snippetPreset","filename","snippet","language","target","client","response","code","restorePlaceholders","_a","uuidNameMap","acc"],"mappings":";;;AAmBO,MAAMA,IAAkB,OAAO;AAAA,EACpC,SAAAC;AAAA,EACA,YAAAC;AAAA,EACA,kBAAAC;AAAA,EAAA,gBACAC,IAAiBC;AAAAA,EACjB,mBAAAC,IAAoB;AACtB,MAA4D;AAC1D,QAAMC,IAAqC,CAAA,GAGrCC,IAAY,cAGZC,IAAcR,EAAQ,IAAI,QAAQO,GAAW,CAACE,MAAkB;AACpE,UAAMC,IAAuB;AAC7B,WAAAJ,EAAWI,CAAoB,IAAID,GAC5BC;AAAA,EACT,CAAC,GAGKC,IAAiB,aAGjBC,IAAUJ,EAAY,QAAQG,GAAgB,CAACE,MAAS;AAC5D,UAAMC,IAAiBD,EAAK,MAAM,GAAGA,EAAK,SAAS,CAAC,GAC9CE,IAAad,EAAWa,CAAc;AAE5C,QAAID,MAAS;AACX,aAAO;AAGT,QAAIE,MAAe,OAAOA,KAAe,YAAYA,EAAW,SAAS;AACvE,aAAO,GAAG,mBAAmBA,EAAW,SAAA,CAAU,CAAC;AAGrD,UAAMC,IAAOC,EAAA;AACb,WAAAX,EAAWU,CAAI,IAAIH,GACZG;AAAA,EACT,CAAC,GAEKE,IAAc,IAAIC,EAAY;AAAA,IAClC,GAAGnB;AAAA,IACH,KAAKY;AAAA,IACL,UAAUZ,EAAQ,YAAY,EAAE,UAAU,mBAAA;AAAA,EAAmB,CAC9D;AAED,SAAO,QAAQ;AAAA,IACbG,EAAe,IAAI,OAAOiB,MAAkB;;AAC1C,YAAM,EAAE,UAAAC,GAAU,SAAAC,GAAS,UAAAC,EAAA,IAAaH,GAClC,EAAE,QAAAI,GAAQ,QAAAC,EAAA,IAAWH,GACrBI,IAAWR,EAAY,QAAQM,GAAoBC,CAAM,GAEzDE,IAAOC,EAAoBtB,IAAYoB,KAAA,gBAAAA,EAAU,eAAc,EAAE;AAEvE,aAAO;AAAA,QACL,UAAUrB,IAAoBgB,MAAWQ,IAAA3B,EAAiB,cAAjB,gBAAA2B,EAA4B,UAASR;AAAA,QAC9E,MAAAM;AAAA,QACA,UAAAJ;AAAA,MAAA;AAAA,IAEJ,CAAC;AAAA,EAAA;AAEL,GAQMK,IAAsB,CAACE,GAAqCR,MACzD,OAAO,QAAQQ,CAAW,EAAE,OAAO,CAACC,GAAK,CAACf,GAAMH,CAAI,MAClDkB,EAAI,QAAQf,GAAMH,CAAI,GAC5BS,CAAO;"}
@@ -0,0 +1,68 @@
1
+ import { requestExampleLanguages as d } from "@mintlify/models";
2
+ import { toShikiLang as k, shikiLangToDisplayLang as m } from "../../constants/snippetPresets.js";
3
+ import { generateInteractiveCodeSample as x } from "./generateInteractiveCodeSample.js";
4
+ const O = async ({
5
+ codeSamples: t,
6
+ apiReferenceData: c,
7
+ baseUrl: i,
8
+ inputs: e,
9
+ apiPlaygroundMode: f,
10
+ requestExampleLanguages: r,
11
+ requiredOnly: g
12
+ }) => {
13
+ const L = i && f !== "none" || i && r, s = r ?? [];
14
+ t = t.map((n) => ({
15
+ ...n,
16
+ lang: k(n.lang)
17
+ })), r === void 0 && (t.forEach((n) => {
18
+ s.includes(n.lang) || s.push(n.lang);
19
+ }), L && d.forEach((n) => {
20
+ s.includes(n) || s.push(n);
21
+ }));
22
+ const h = {};
23
+ for (const n of s) {
24
+ let o = m[n] ?? n;
25
+ const u = t.filter((a) => a.lang === n), l = h[o] ?? {};
26
+ if (u.length === 0) {
27
+ const a = await x({
28
+ baseUrl: i,
29
+ apiReferenceData: c,
30
+ inputs: e,
31
+ apiPlaygroundMode: f,
32
+ lang: n,
33
+ requiredOnly: g
34
+ });
35
+ a && E(
36
+ a,
37
+ n,
38
+ o,
39
+ l,
40
+ !0
41
+ );
42
+ } else
43
+ u.forEach((a) => {
44
+ o = m[n] ?? a.label ?? n, E(
45
+ a,
46
+ n,
47
+ o,
48
+ l,
49
+ !1
50
+ );
51
+ });
52
+ Object.keys(l).length > 0 && (h[o] = l);
53
+ }
54
+ return h;
55
+ }, E = (t, c, i, e, f) => {
56
+ "" in e && (e["Example 1"] = e[""], delete e[""]);
57
+ const r = Object.keys(e).length, g = t.label ?? (r > 0 ? `Example ${r + 1}` : "");
58
+ e[g] = {
59
+ filename: f ? i : g || i,
60
+ // (used in CodeSnippets)
61
+ language: c,
62
+ code: t.source
63
+ };
64
+ };
65
+ export {
66
+ O as generateSnippetMap
67
+ };
68
+ //# sourceMappingURL=generateSnippetMap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateSnippetMap.js","sources":["../../../src/api-playground-2/generators/generateSnippetMap.ts"],"sourcesContent":["import {\n ApiPlaygroundDisplayType,\n requestExampleLanguages as defaultRequestExampleLanguages,\n} from '@mintlify/models';\nimport { ApiPlaygroundInputs, CodeSample } from '@mintlify/validation';\n\nimport type { ApiReferenceDataV2 } from '@/api-playground-2/types';\nimport { shikiLangToDisplayLang, toShikiLang } from '@/constants/snippetPresets';\nimport { ExampleCodeSnippet } from '@/types/exampleCodeSnippet';\n\nimport { generateInteractiveCodeSample } from './generateInteractiveCodeSample';\n\n// more or less identical but in all places where we use Endpoint, we use ApiReferenceDataV2 instead\nexport const generateSnippetMap = async ({\n codeSamples,\n apiReferenceData,\n baseUrl,\n inputs,\n apiPlaygroundMode,\n requestExampleLanguages,\n requiredOnly,\n}: {\n codeSamples: CodeSample[];\n apiReferenceData: ApiReferenceDataV2;\n baseUrl?: string;\n inputs: ApiPlaygroundInputs;\n apiPlaygroundMode: ApiPlaygroundDisplayType;\n requestExampleLanguages?: string[];\n requiredOnly?: boolean;\n}): Promise<Record<string, Record<string, ExampleCodeSnippet>>> => {\n const shouldHaveGeneratedExamples =\n (baseUrl && apiPlaygroundMode !== 'none') || (baseUrl && requestExampleLanguages);\n const langOrder = requestExampleLanguages ?? [];\n codeSamples = codeSamples.map((codeSample) => ({\n ...codeSample,\n lang: toShikiLang(codeSample.lang),\n }));\n if (requestExampleLanguages === undefined) {\n codeSamples.forEach((codeSample) => {\n if (langOrder.includes(codeSample.lang)) return;\n langOrder.push(codeSample.lang);\n });\n if (shouldHaveGeneratedExamples) {\n defaultRequestExampleLanguages.forEach((lang) => {\n if (langOrder.includes(lang)) return;\n langOrder.push(lang);\n });\n }\n }\n\n const map: Record<string, Record<string, ExampleCodeSnippet>> = {};\n\n for (const shikiLang of langOrder) {\n let displayLang = shikiLangToDisplayLang[shikiLang] ?? shikiLang;\n\n const codeSamplesInLang = codeSamples.filter((codeSample) => codeSample.lang === shikiLang);\n\n const labelToSnippetMap = map[displayLang] ?? {};\n if (codeSamplesInLang.length === 0) {\n const generatedCodeSample = await generateInteractiveCodeSample({\n baseUrl,\n apiReferenceData,\n inputs,\n apiPlaygroundMode,\n lang: shikiLang,\n requiredOnly,\n });\n if (generatedCodeSample) {\n addCodeSampleToLabelToSnippetMap(\n generatedCodeSample,\n shikiLang,\n displayLang,\n labelToSnippetMap,\n true\n );\n }\n } else {\n codeSamplesInLang.forEach((codeSample) => {\n displayLang = shikiLangToDisplayLang[shikiLang] ?? codeSample.label ?? shikiLang;\n addCodeSampleToLabelToSnippetMap(\n codeSample,\n shikiLang,\n displayLang,\n labelToSnippetMap,\n false\n );\n });\n }\n if (Object.keys(labelToSnippetMap).length > 0) {\n map[displayLang] = labelToSnippetMap;\n }\n }\n\n return map;\n};\n\nconst addCodeSampleToLabelToSnippetMap = (\n codeSample: CodeSample,\n shikiLang: string,\n displayLang: string,\n labelToSnippetMap: Record<string, ExampleCodeSnippet>,\n isGenerated: boolean\n) => {\n // if we have entered an empty label, retroactively update it to 'Example 1'\n if ('' in labelToSnippetMap) {\n labelToSnippetMap['Example 1'] = labelToSnippetMap[''];\n delete labelToSnippetMap[''];\n }\n\n const numExistingLabels = Object.keys(labelToSnippetMap).length;\n const label =\n codeSample.label ?? (numExistingLabels > 0 ? `Example ${numExistingLabels + 1}` : '');\n\n labelToSnippetMap[label] = {\n filename: isGenerated ? displayLang : label || displayLang, // (used in CodeSnippets)\n language: shikiLang,\n code: codeSample.source,\n };\n};\n"],"names":["generateSnippetMap","codeSamples","apiReferenceData","baseUrl","inputs","apiPlaygroundMode","requestExampleLanguages","requiredOnly","shouldHaveGeneratedExamples","langOrder","codeSample","toShikiLang","defaultRequestExampleLanguages","lang","map","shikiLang","displayLang","shikiLangToDisplayLang","codeSamplesInLang","labelToSnippetMap","generatedCodeSample","generateInteractiveCodeSample","addCodeSampleToLabelToSnippetMap","isGenerated","numExistingLabels","label"],"mappings":";;;AAaO,MAAMA,IAAqB,OAAO;AAAA,EACvC,aAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,SAAAC;AAAA,EACA,QAAAC;AAAA,EACA,mBAAAC;AAAA,EAAA,yBACAC;AAAAA,EACA,cAAAC;AACF,MAQmE;AACjE,QAAMC,IACHL,KAAWE,MAAsB,UAAYF,KAAWG,GACrDG,IAAYH,KAA2B,CAAA;AAC7C,EAAAL,IAAcA,EAAY,IAAI,CAACS,OAAgB;AAAA,IAC7C,GAAGA;AAAA,IACH,MAAMC,EAAYD,EAAW,IAAI;AAAA,EAAA,EACjC,GACEJ,MAA4B,WAC9BL,EAAY,QAAQ,CAACS,MAAe;AAClC,IAAID,EAAU,SAASC,EAAW,IAAI,KACtCD,EAAU,KAAKC,EAAW,IAAI;AAAA,EAChC,CAAC,GACGF,KACFI,EAA+B,QAAQ,CA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IAC/C,UAAUD;AAAA,IACV,MAAML,EAAW;AAAA,EAAA;AAErB;"}
@@ -0,0 +1,24 @@
1
+ import { isSchemaObject as d } from "../schemaGraph/utils.js";
2
+ const f = (i, o = "", t = []) => {
3
+ if ("format" in i && (i.format === "binary" || i.format === "base64") && o && !t.includes(o) && t.push(o), "items" in i && i.items) {
4
+ const r = o ? `${o}.items` : "items";
5
+ d(i.items) && f(i.items, r, t);
6
+ }
7
+ if ("properties" in i && i.properties && Object.entries(i.properties).forEach(([r, n]) => {
8
+ const e = o ? `${o}.${r}` : r;
9
+ f(n, e, t);
10
+ }), "additionalProperties" in i && d(i.additionalProperties)) {
11
+ const r = o ? `${o}.additionalProperties` : "additionalProperties";
12
+ f(i.additionalProperties, r, t);
13
+ }
14
+ return "oneOf" in i && Array.isArray(i.oneOf) && i.oneOf.forEach((r, n) => {
15
+ if (d(r)) {
16
+ const e = o ? `${o}.${n}` : `${n}`;
17
+ f(r, e, t);
18
+ }
19
+ }), t;
20
+ };
21
+ export {
22
+ f as getFileProperties
23
+ };
24
+ //# sourceMappingURL=getFileProperties.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getFileProperties.js","sources":["../../../src/api-playground-2/generators/getFileProperties.ts"],"sourcesContent":["import { SchemaObject } from '@mintlify/validation';\n\nimport { isSchemaObject } from '@/api-playground-2/schemaGraph/utils';\n\nexport const getFileProperties = (\n schema: SchemaObject,\n path: string = '',\n result: string[] = []\n): string[] => {\n if ('format' in schema && (schema.format === 'binary' || schema.format === 'base64')) {\n if (path && !result.includes(path)) {\n result.push(path);\n }\n }\n\n if ('items' in schema && schema.items) {\n const itemPath = path ? `${path}.items` : 'items';\n if (isSchemaObject(schema.items)) {\n getFileProperties(schema.items, itemPath, result);\n }\n }\n\n if ('properties' in schema && schema.properties) {\n Object.entries(schema.properties).forEach(([propName, propSchema]) => {\n const propPath = path ? `${path}.${propName}` : propName;\n getFileProperties(propSchema, propPath, result);\n });\n }\n\n if ('additionalProperties' in schema && isSchemaObject(schema.additionalProperties)) {\n const additionalPropsPath = path ? `${path}.additionalProperties` : 'additionalProperties';\n getFileProperties(schema.additionalProperties, additionalPropsPath, result);\n }\n\n if ('oneOf' in schema && Array.isArray(schema.oneOf)) {\n schema.oneOf.forEach((subSchema, index) => {\n if (isSchemaObject(subSchema)) {\n const oneOfPath = path ? `${path}.${index}` : `${index}`;\n getFileProperties(subSchema, oneOfPath, result);\n }\n });\n }\n\n return result;\n};\n"],"names":["getFileProperties","schema","path","result","itemPath","isSchemaObject","propName","propSchema","propPath","additionalPropsPath","subSchema","index","oneOfPath"],"mappings":";AAIO,MAAMA,IAAoB,CAC/BC,GACAC,IAAe,IACfC,IAAmB,CAAA,MACN;AAOb,MANI,YAAYF,MAAWA,EAAO,WAAW,YAAYA,EAAO,WAAW,aACrEC,KAAQ,CAACC,EAAO,SAASD,CAAI,KAC/BC,EAAO,KAAKD,CAAI,GAIhB,WAAWD,KAAUA,EAAO,OAAO;AACrC,UAAMG,IAAWF,IAAO,GAAGA,CAAI,WAAW;AAC1C,IAAIG,EAAeJ,EAAO,KAAK,KAC7BD,EAAkBC,EAAO,OAAOG,GAAUD,CAAM;AAAA,EAEpD;AASA,MAPI,gBAAgBF,KAAUA,EAAO,cACnC,OAAO,QAAQA,EAAO,UAAU,EAAE,QAAQ,CAAC,CAACK,GAAUC,CAAU,MAAM;AACpE,UAAMC,IAAWN,IAAO,GAAGA,CAAI,IAAII,CAAQ,KAAKA;AAChD,IAAAN,EAAkBO,GAAYC,GAAUL,CAAM;AAAA,EAChD,CAAC,GAGC,0BAA0BF,KAAUI,EAAeJ,EAAO,oBAAoB,GAAG;AACnF,UAAMQ,IAAsBP,IAAO,GAAGA,CAAI,0BAA0B;AACpE,IAAAF,EAAkBC,EAAO,sBAAsBQ,GAAqBN,CAAM;AAAA,EAC5E;AAEA,SAAI,WAAWF,KAAU,MAAM,QAAQA,EAAO,KAAK,KACjDA,EAAO,MAAM,QAAQ,CAACS,GAAWC,MAAU;AACzC,QAAIN,EAAeK,CAAS,GAAG;AAC7B,YAAME,IAAYV,IAAO,GAAGA,CAAI,IAAIS,CAAK,KAAK,GAAGA,CAAK;AACtD,MAAAX,EAAkBU,GAAWE,GAAWT,CAAM;AAAA,IAChD;AAAA,EACF,CAAC,GAGIA;AACT;"}
@@ -0,0 +1,22 @@
1
+ import { create as s } from "zustand";
2
+ import { unflattenInputs as r } from "../schemaGraph/utils.js";
3
+ const a = s((n, u) => ({
4
+ inputs: {},
5
+ initialize: (t) => n({
6
+ inputs: { ...t }
7
+ }),
8
+ setInput: (t, p) => n((i) => ({
9
+ inputs: { ...i.inputs, [t]: p }
10
+ })),
11
+ setInputs: (t) => n((p) => ({
12
+ inputs: { ...p.inputs, ...t }
13
+ })),
14
+ getInput: (t) => u().inputs[t],
15
+ getApiPlaygroundInputs: () => r(u().inputs),
16
+ clear: () => n({ inputs: {} }),
17
+ reset: () => n({ inputs: {} })
18
+ }));
19
+ export {
20
+ a as usePlaygroundInputsStore
21
+ };
22
+ //# sourceMappingURL=usePlaygroundInputsStore.js.map