@mintlify/msft-sdk 1.1.61 → 1.1.63

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 (234) hide show
  1. package/dist/api-playground/ApiPlayground/Response/DownloadFileButton.js +6 -5
  2. package/dist/api-playground/ApiPlayground/Response/ResponseBody/CodeResponseContent.js +13 -12
  3. package/dist/api-playground/ApiPlayground/Response/ResponsePlaceholder.js +8 -7
  4. package/dist/api-playground/ApiPlayground/Response/ResponseTable.js +3 -2
  5. package/dist/api-playground/ApiPlayground/Response/ResponseTopbar.js +9 -8
  6. package/dist/api-playground/ApiPlayground/Response/index.js +4 -3
  7. package/dist/api-playground/ApiPlayground/components/AdditionalPropertyButton.js +42 -21
  8. package/dist/api-playground/ApiPlayground/components/ParamFieldWrapper.js +13 -9
  9. package/dist/api-playground/ApiPlayground/components/PlaygroundModalWrapper.js +6 -5
  10. package/dist/api-playground/ApiPlayground/components/SendPill.js +3 -2
  11. package/dist/api-playground/ApiPlayground/components/TypeDropdown.js +6 -5
  12. package/dist/api-playground/EndpointFields/ParamFields/ExampleDescription.js +3 -2
  13. package/dist/api-playground/EndpointFields/components/Description.js +6 -5
  14. package/dist/api-playground/EndpointFields/components/OptionDropdown.js +9 -8
  15. package/dist/api-playground/EndpointFields/components/SectionHeading.js +8 -7
  16. package/dist/api-playground-2/ApiExamples.js +19 -20
  17. package/dist/api-playground-2/ApiFields.js +20 -247
  18. package/dist/api-playground-2/EndpointHeader.js +59 -47
  19. package/dist/api-playground-2/OperationPage.js +70 -66
  20. package/dist/api-playground-2/Playground.js +67 -83
  21. package/dist/api-playground-2/SchemaPage.js +22 -9
  22. package/dist/api-playground-2/components/EndpointFields/Body.js +40 -0
  23. package/dist/api-playground-2/components/EndpointFields/Parameters.js +90 -0
  24. package/dist/api-playground-2/components/EndpointFields/Response.js +146 -0
  25. package/dist/api-playground-2/components/EndpointFields/Security.js +88 -0
  26. package/dist/api-playground-2/components/EndpointFields/fields/ArrayParamField.js +93 -0
  27. package/dist/api-playground-2/components/EndpointFields/fields/Enum.js +29 -11
  28. package/dist/api-playground-2/components/EndpointFields/fields/ObjectParamField.js +145 -0
  29. package/dist/api-playground-2/components/EndpointFields/fields/PrimitiveParamField.js +60 -48
  30. package/dist/api-playground-2/components/EndpointFields/fields/SchemaField.js +230 -0
  31. package/dist/api-playground-2/components/Example/GeneratedRequestExample.js +93 -89
  32. package/dist/api-playground-2/components/Example/GeneratedResponseExample.js +18 -17
  33. package/dist/api-playground-2/components/Example/RequestExample.js +92 -93
  34. package/dist/api-playground-2/components/Example/ResponseExample.js +19 -15
  35. package/dist/api-playground-2/components/Request/ParameterSection.js +20 -18
  36. package/dist/api-playground-2/components/Request/SecuritySection.js +53 -43
  37. package/dist/api-playground-2/components/Request/inputs/ArrayInput.js +89 -40
  38. package/dist/api-playground-2/components/Request/inputs/DifferentiatedInput.js +12 -12
  39. package/dist/api-playground-2/components/Request/inputs/FileInput.js +16 -15
  40. package/dist/api-playground-2/components/Request/inputs/InputContainer.js +76 -57
  41. package/dist/api-playground-2/components/Request/inputs/NumberInput.js +10 -9
  42. package/dist/api-playground-2/components/Request/inputs/ObjectInput.js +98 -80
  43. package/dist/api-playground-2/components/Request/inputs/OneOfInput.js +55 -47
  44. package/dist/api-playground-2/components/Request/inputs/SelectInput.js +18 -17
  45. package/dist/api-playground-2/components/Request/inputs/StringInput.js +19 -18
  46. package/dist/api-playground-2/components/Request/inputs/TextInput.js +12 -11
  47. package/dist/api-playground-2/components/SendPillWrapper.js +35 -0
  48. package/dist/api-playground-2/contexts/ApiPlaygroundContext.js +3 -5
  49. package/dist/api-playground-2/generators/createCookies.js +23 -0
  50. package/dist/api-playground-2/generators/createHeaders.js +53 -36
  51. package/dist/api-playground-2/generators/createQueryString.js +30 -0
  52. package/dist/api-playground-2/generators/generateAuthPlaceholder.js +14 -0
  53. package/dist/api-playground-2/generators/generateInteractiveCodeSample.js +27 -25
  54. package/dist/api-playground-2/generators/generateRequest.js +47 -51
  55. package/dist/api-playground-2/generators/generateResponseExampleMap.js +15 -11
  56. package/dist/api-playground-2/generators/generateSnippet.js +1 -1
  57. package/dist/api-playground-2/generators/generateSnippetMap.js +13 -11
  58. package/dist/api-playground-2/hooks/useCopyPathWithInputs.js +11 -11
  59. package/dist/api-playground-2/hooks/useInitializeInputs.js +185 -88
  60. package/dist/api-playground-2/hooks/usePlaygroundInputsStore.js +70 -25
  61. package/dist/api-playground-2/hooks/useSelectedBaseUrl.js +13 -0
  62. package/dist/api-playground-2/hooks/useSelectedExample.js +10 -0
  63. package/dist/api-playground-2/hooks/useSelectedRequestBodyContentType.js +12 -0
  64. package/dist/api-playground-2/hooks/useSelectedResponseContentType.js +12 -0
  65. package/dist/api-playground-2/hooks/useSelectedSecurityOption.js +31 -0
  66. package/dist/api-playground-2/hooks/useSendPlaygroundRequest.js +114 -101
  67. package/dist/api-playground-2/schemaGraph/addApiReferenceDataFromMdxAndDocsConfig.js +23 -32
  68. package/dist/api-playground-2/schemaGraph/addTypeLabelsToSchema.js +50 -0
  69. package/dist/api-playground-2/schemaGraph/addUniqueKeysToSchema.js +40 -24
  70. package/dist/api-playground-2/schemaGraph/getExampleBodyInputs.js +94 -0
  71. package/dist/api-playground-2/schemaGraph/getSchemaGraphOperationData.js +56 -50
  72. package/dist/api-playground-2/schemaGraph/processExamples.js +117 -52
  73. package/dist/api-playground-2/schemaGraph/processSchema.js +10 -0
  74. package/dist/api-playground-2/schemaGraph/processSecurityOptions.js +58 -28
  75. package/dist/api-playground-2/schemaGraph/reduceCompositions.js +220 -181
  76. package/dist/api-playground-2/schemaGraph/resolveOperationWithDependencies.js +128 -89
  77. package/dist/api-playground-2/schemaGraph/resolveSchemaWithDependencies.js +15 -16
  78. package/dist/api-playground-2/schemaGraph/sortSchemaByRequired.js +14 -12
  79. package/dist/api-playground-2/schemaGraph/utils.js +185 -147
  80. package/dist/common/guards.js +11 -19
  81. package/dist/components/Api/Expandable.js +10 -9
  82. package/dist/components/Api/Param.js +11 -13
  83. package/dist/components/Api/dropdown-menu.js +10 -9
  84. package/dist/components/content-components/code-group.js +4 -4
  85. package/dist/contexts/EndpointLocationContext.js +3 -3
  86. package/dist/hooks/useApiParamFieldOption.js +10 -0
  87. package/dist/hooks/useEndpoint.js +3 -3
  88. package/dist/hooks/useKeyboardShortcut.js +13 -13
  89. package/dist/hooks/useSendPlaygroundRequest.js +14 -146
  90. package/dist/httpsnippet/src/helpers/code-builder.js +27 -0
  91. package/dist/httpsnippet/src/helpers/escape.js +11 -0
  92. package/dist/httpsnippet/src/helpers/headers.js +13 -0
  93. package/dist/httpsnippet/src/helpers/reducer.js +7 -0
  94. package/dist/httpsnippet/src/helpers/shell.js +5 -0
  95. package/dist/httpsnippet/src/helpers/url-format.js +35 -0
  96. package/dist/httpsnippet/src/helpers/url-parse.js +76 -0
  97. package/dist/httpsnippet/src/index.js +157 -0
  98. package/dist/httpsnippet/src/targets/c/libcurl/client.js +22 -0
  99. package/dist/httpsnippet/src/targets/c/target.js +15 -0
  100. package/dist/httpsnippet/src/targets/clojure/clj_http/client.js +120 -0
  101. package/dist/httpsnippet/src/targets/clojure/target.js +14 -0
  102. package/dist/httpsnippet/src/targets/csharp/httpclient/client.js +76 -0
  103. package/dist/httpsnippet/src/targets/csharp/restsharp/client.js +63 -0
  104. package/dist/httpsnippet/src/targets/csharp/target.js +17 -0
  105. package/dist/httpsnippet/src/targets/go/native/client.js +24 -0
  106. package/dist/httpsnippet/src/targets/go/target.js +15 -0
  107. package/dist/httpsnippet/src/targets/http/http1.1/client.js +34 -0
  108. package/dist/httpsnippet/src/targets/http/target.js +14 -0
  109. package/dist/httpsnippet/src/targets/index.js +43 -0
  110. package/dist/httpsnippet/src/targets/java/asynchttp/client.js +23 -0
  111. package/dist/httpsnippet/src/targets/java/nethttp/client.js +28 -0
  112. package/dist/httpsnippet/src/targets/java/okhttp/client.js +23 -0
  113. package/dist/httpsnippet/src/targets/java/target.js +20 -0
  114. package/dist/httpsnippet/src/targets/java/unirest/client.js +23 -0
  115. package/dist/httpsnippet/src/targets/javascript/axios/client.js +50 -0
  116. package/dist/httpsnippet/src/targets/javascript/fetch/client.js +61 -0
  117. package/dist/httpsnippet/src/targets/javascript/jquery/client.js +51 -0
  118. package/dist/httpsnippet/src/targets/javascript/target.js +20 -0
  119. package/dist/httpsnippet/src/targets/javascript/xhr/client.js +49 -0
  120. package/dist/httpsnippet/src/targets/json/native/client.js +39 -0
  121. package/dist/httpsnippet/src/targets/json/target.js +14 -0
  122. package/dist/httpsnippet/src/targets/kotlin/okhttp/client.js +23 -0
  123. package/dist/httpsnippet/src/targets/kotlin/target.js +14 -0
  124. package/dist/httpsnippet/src/targets/node/axios/client.js +40 -0
  125. package/dist/httpsnippet/src/targets/node/fetch/client.js +68 -0
  126. package/dist/httpsnippet/src/targets/node/native/client.js +45 -0
  127. package/dist/httpsnippet/src/targets/node/target.js +19 -0
  128. package/dist/httpsnippet/src/targets/objc/helpers.js +27 -0
  129. package/dist/httpsnippet/src/targets/objc/nsurlsession/client.js +63 -0
  130. package/dist/httpsnippet/src/targets/objc/target.js +14 -0
  131. package/dist/httpsnippet/src/targets/ocaml/cohttp/client.js +32 -0
  132. package/dist/httpsnippet/src/targets/ocaml/target.js +14 -0
  133. package/dist/httpsnippet/src/targets/php/curl/client.js +85 -0
  134. package/dist/httpsnippet/src/targets/php/guzzle/client.js +57 -0
  135. package/dist/httpsnippet/src/targets/php/helpers.js +65 -0
  136. package/dist/httpsnippet/src/targets/php/http1/client.js +28 -0
  137. package/dist/httpsnippet/src/targets/php/http2/client.js +55 -0
  138. package/dist/httpsnippet/src/targets/php/target.js +21 -0
  139. package/dist/httpsnippet/src/targets/powershell/common.js +19 -0
  140. package/dist/httpsnippet/src/targets/powershell/restmethod/client.js +14 -0
  141. package/dist/httpsnippet/src/targets/powershell/target.js +16 -0
  142. package/dist/httpsnippet/src/targets/powershell/webrequest/client.js +14 -0
  143. package/dist/httpsnippet/src/targets/python/helpers.js +33 -0
  144. package/dist/httpsnippet/src/targets/python/requests/client.js +74 -0
  145. package/dist/httpsnippet/src/targets/python/target.js +15 -0
  146. package/dist/httpsnippet/src/targets/r/httr/client.js +46 -0
  147. package/dist/httpsnippet/src/targets/r/target.js +14 -0
  148. package/dist/httpsnippet/src/targets/ruby/native/client.js +37 -0
  149. package/dist/httpsnippet/src/targets/ruby/target.js +14 -0
  150. package/dist/httpsnippet/src/targets/shell/curl/client.js +92 -0
  151. package/dist/httpsnippet/src/targets/shell/httpie/client.js +56 -0
  152. package/dist/httpsnippet/src/targets/shell/target.js +19 -0
  153. package/dist/httpsnippet/src/targets/shell/wget/client.js +30 -0
  154. package/dist/httpsnippet/src/targets/swift/helpers.js +38 -0
  155. package/dist/httpsnippet/src/targets/swift/target.js +14 -0
  156. package/dist/httpsnippet/src/targets/swift/urlsession/client.js +59 -0
  157. package/dist/index.d.ts +65 -58
  158. package/dist/index.js +109 -111
  159. package/dist/openapi/generateTypeStringFromSchema.js +2 -31
  160. package/dist/styles.css +1 -1
  161. package/package.json +17 -4
  162. package/dist/api-playground/ApiPlayground/Request/BodySection.js +0 -64
  163. package/dist/api-playground/ApiPlayground/Request/ParameterSection.js +0 -32
  164. package/dist/api-playground/ApiPlayground/Request/PlaygroundModal.js +0 -201
  165. package/dist/api-playground/ApiPlayground/Request/SecuritySection.js +0 -146
  166. package/dist/api-playground/ApiPlayground/Request/ServerSection.js +0 -30
  167. package/dist/api-playground/ApiPlayground/Request/index.js +0 -43
  168. package/dist/api-playground/ApiPlayground/Request/inputs/ArrayInput.js +0 -93
  169. package/dist/api-playground/ApiPlayground/Request/inputs/DifferentiatedInput.js +0 -90
  170. package/dist/api-playground/ApiPlayground/Request/inputs/FileInput.js +0 -62
  171. package/dist/api-playground/ApiPlayground/Request/inputs/NullInput.js +0 -33
  172. package/dist/api-playground/ApiPlayground/Request/inputs/NumberInput.js +0 -61
  173. package/dist/api-playground/ApiPlayground/Request/inputs/ObjectChildren.js +0 -109
  174. package/dist/api-playground/ApiPlayground/Request/inputs/ObjectInput.js +0 -87
  175. package/dist/api-playground/ApiPlayground/Request/inputs/RecursiveInput.js +0 -61
  176. package/dist/api-playground/ApiPlayground/Request/inputs/SelectInput.js +0 -54
  177. package/dist/api-playground/ApiPlayground/Request/inputs/StringInput.js +0 -67
  178. package/dist/api-playground/ApiPlayground/Request/inputs/TextInput.js +0 -44
  179. package/dist/api-playground/ApiPlayground/components/EndpointsMenu.js +0 -42
  180. package/dist/api-playground/ApiPlayground/components/EndpointsMenuLink.js +0 -43
  181. package/dist/api-playground/ApiPlayground/components/EndpointsMenuSearch.js +0 -38
  182. package/dist/api-playground/ApiPlayground/components/InputContainer.js +0 -128
  183. package/dist/api-playground/ApiPlayground/components/InputSectionContainer.js +0 -59
  184. package/dist/api-playground/ApiPlayground/components/PathHeader.js +0 -162
  185. package/dist/api-playground/ApiPlayground/components/TrashButton.js +0 -26
  186. package/dist/api-playground/ApiPlayground/index.js +0 -67
  187. package/dist/api-playground/EndpointFields/ParamFields/PrimitiveParamField/Enum.js +0 -19
  188. package/dist/api-playground/EndpointFields/ParamFields/PrimitiveParamField/NumberMetadata.js +0 -18
  189. package/dist/api-playground/EndpointFields/ParamFields/PrimitiveParamField/StringMetadata.js +0 -28
  190. package/dist/api-playground/EndpointFields/ParamFields/PrimitiveParamField/index.js +0 -5
  191. package/dist/api-playground/EndpointFields/ParamFields/RecursiveParamField.js +0 -13
  192. package/dist/api-playground/EndpointFields/index.js +0 -7
  193. package/dist/api-playground-2/components/EndpointFields/EndpointSecurity.js +0 -87
  194. package/dist/api-playground-2/components/EndpointFields/fields/SimpleArrayParamField.js +0 -89
  195. package/dist/api-playground-2/components/EndpointFields/fields/SimpleObjectParamField.js +0 -121
  196. package/dist/api-playground-2/components/EndpointFields/fields/SimplePrimitiveParamField.js +0 -74
  197. package/dist/api-playground-2/components/EndpointFields/fields/SimpleSchemaField.js +0 -252
  198. package/dist/common/potentiallyParseOpenApiString.js +0 -24
  199. package/dist/common/replaceSlashIndex.js +0 -6
  200. package/dist/common/slugToTitle.js +0 -10
  201. package/dist/constants/prism-languages.js +0 -19
  202. package/dist/contexts/ApiPlaygroundInputsContext.js +0 -17
  203. package/dist/contexts/MDXContentContext.js +0 -17
  204. package/dist/hooks/useApiPlaygroundInputs.js +0 -6
  205. package/dist/hooks/useApiPlaygroundPrefillExamples.js +0 -39
  206. package/dist/hooks/useBaseUrlOptions.js +0 -18
  207. package/dist/hooks/useComponentSchemas.js +0 -9
  208. package/dist/hooks/useGenerateNextAdditionalProperties.js +0 -11
  209. package/dist/hooks/useGenerateNextItems.js +0 -11
  210. package/dist/hooks/useGenerateNextProperties.js +0 -11
  211. package/dist/hooks/useMDXContent.js +0 -6
  212. package/dist/hooks/useMDXContentController/useApiPlaygroundInputs.js +0 -9
  213. package/dist/hooks/useMDXContentController/useMDXContentCallbacks/useSetApiBaseIndexCallback.js +0 -15
  214. package/dist/hooks/useMDXContentController/useMDXContentCallbacks/useSetApiPlaygroundInputsCallback.js +0 -15
  215. package/dist/hooks/usePlaygroundSchemaOptions.js +0 -42
  216. package/dist/hooks/usePrefilledInputs/index.js +0 -65
  217. package/dist/hooks/usePrefilledInputs/storedServerVariables.js +0 -29
  218. package/dist/hooks/useSecurityOption.js +0 -10
  219. package/dist/hooks/useSetDefaultValue.js +0 -63
  220. package/dist/openapi/filterEnums.js +0 -20
  221. package/dist/openapi/generateNextAdditionalProperties.js +0 -7
  222. package/dist/openapi/generateNextItems.js +0 -7
  223. package/dist/openapi/generateNextProperties.js +0 -23
  224. package/dist/openapi/generateOptionLabels.js +0 -20
  225. package/dist/openapi/generateSimpleLabels.js +0 -4
  226. package/dist/openapi/getAuthFilteredSchemaArray.js +0 -18
  227. package/dist/paths/isEqualIgnoringLeadingSlash.js +0 -21
  228. package/dist/paths/optionallyRemoveLeadingSlash.js +0 -6
  229. package/dist/paths/optionallyRemoveTrailingSlash.js +0 -6
  230. package/dist/utils/api-playground/defaults.js +0 -15
  231. package/dist/utils/api-playground/paramFieldDefaults.js +0 -10
  232. package/dist/utils/api-reference/getFilteredSecurityOptions.js +0 -4
  233. package/dist/utils/api-reference/getNextPropertiesByType.js +0 -5
  234. package/dist/utils/flattenObject.js +0 -10
@@ -1,100 +1,197 @@
1
- import { useRef as k, useEffect as W } from "react";
2
- import { apiPlaygroundInputKeys as q } from "../constants/index.js";
3
- import { escapeDots as O, getSchemaDefault as P, mapParamInToPlaygroundInputKey as w, getParametersPerSection as B, getRequestBodyContentType as G, isSchemaObject as H, getBodyDefaultsFromSchema as J } from "../schemaGraph/utils.js";
4
- import { usePlaygroundInputsStore as A } from "./usePlaygroundInputsStore.js";
5
- function X({
6
- apiReferenceData: e,
7
- selectedBaseUrlIndex: d,
8
- selectedExampleIndex: a,
9
- selectedRequestBodyContentTypeIndex: p
1
+ import { useRef as b, useEffect as x } from "react";
2
+ import { apiPlaygroundInputKeys as m } from "../constants/index.js";
3
+ import { getRequestBodyContentType as K, getSchemaDefault as g, isSchemaObject as A, getBodyDefaultsFromSchema as T, getParametersPerSection as W, mapParamInToPlaygroundInputKey as v, escapeDots as y, getSecurityOptionInputKeyPrefix as B, isBasicAuth as S } from "../schemaGraph/utils.js";
4
+ import { usePlaygroundInputsStore as d } from "./usePlaygroundInputsStore.js";
5
+ function Z({
6
+ apiReferenceData: n,
7
+ selectedBaseUrlIndex: o,
8
+ selectedExampleIndex: c,
9
+ selectedRequestBodyContentTypeIndex: s,
10
+ locallyStoredCredentials: i,
11
+ serverInputs: t
10
12
  }) {
11
- const r = k(null), { reset: y, initialize: t, getApiPlaygroundInputs: f, inputs: b } = A(), h = k(!1);
12
- W(() => {
13
- const m = window.location.pathname, c = A.getState().selectedSecurityOptionIndex;
14
- if (!h.current && Object.keys(b).length === 0) {
15
- const u = C({
16
- apiReferenceData: e,
17
- inputs: f(),
18
- selectedBaseUrlIndex: d,
19
- selectedSecurityOptionIndex: c,
20
- selectedExampleIndex: a,
21
- selectedContentTypeIndex: p
22
- });
23
- t(u), h.current = !0, r.current = m;
13
+ var u;
14
+ const e = b(!1), r = b(!1), f = b(c);
15
+ x(() => {
16
+ if (e.current) return;
17
+ const h = d.getState();
18
+ h.reset();
19
+ const p = P({
20
+ apiReferenceData: n,
21
+ selectedBaseUrlIndex: o,
22
+ selectedSecurityOptionIndex: 0,
23
+ // Always start with first security option
24
+ selectedExampleIndex: 0,
25
+ // Always start with first example
26
+ selectedContentTypeIndex: s,
27
+ locallyStoredCredentials: i,
28
+ serverInputs: t
29
+ });
30
+ h.initializeInputs(p), h.initializeApiReferenceData(n), e.current = !0, r.current = !!i, f.current = 0;
31
+ }, []), x(() => {
32
+ if (!e.current || r.current || !i)
24
33
  return;
25
- }
26
- if (r.current === null) {
27
- r.current = m;
34
+ const h = d.getState(), p = P({
35
+ apiReferenceData: n,
36
+ selectedBaseUrlIndex: o,
37
+ selectedSecurityOptionIndex: h.selectedSecurityOptionIndex,
38
+ selectedExampleIndex: h.selectedExampleIndex,
39
+ selectedContentTypeIndex: s,
40
+ locallyStoredCredentials: i,
41
+ serverInputs: t
42
+ });
43
+ h.replaceInputs(p), r.current = !0;
44
+ }, [i]), x(() => {
45
+ var E;
46
+ if (!e.current || f.current === c || !((E = n.operation) == null ? void 0 : E.prefillPlaygroundWithExample))
28
47
  return;
48
+ const p = d.getState();
49
+ p.clear();
50
+ const a = P({
51
+ apiReferenceData: n,
52
+ selectedBaseUrlIndex: o,
53
+ selectedSecurityOptionIndex: p.selectedSecurityOptionIndex,
54
+ selectedExampleIndex: c,
55
+ selectedContentTypeIndex: s,
56
+ locallyStoredCredentials: i,
57
+ serverInputs: t
58
+ });
59
+ p.initializeInputs(a), f.current = c;
60
+ }, [c, (u = n.operation) == null ? void 0 : u.prefillPlaygroundWithExample]);
61
+ }
62
+ function P({
63
+ apiReferenceData: n,
64
+ selectedBaseUrlIndex: o,
65
+ selectedSecurityOptionIndex: c,
66
+ selectedExampleIndex: s,
67
+ selectedContentTypeIndex: i,
68
+ locallyStoredCredentials: t,
69
+ serverInputs: e
70
+ }) {
71
+ var u;
72
+ const r = (u = n.operation) == null ? void 0 : u.userInfoPlaygroundInputs, f = {
73
+ server: { ...r == null ? void 0 : r.server, ...e },
74
+ header: { ...r == null ? void 0 : r.header, ...t == null ? void 0 : t.header },
75
+ query: { ...r == null ? void 0 : r.query, ...t == null ? void 0 : t.query },
76
+ cookie: { ...r == null ? void 0 : r.cookie, ...t == null ? void 0 : t.cookie }
77
+ };
78
+ return F({
79
+ apiReferenceData: n,
80
+ selectedBaseUrlIndex: o,
81
+ selectedSecurityOptionIndex: c,
82
+ selectedExampleIndex: s,
83
+ selectedContentTypeIndex: i,
84
+ mergedUserInfo: f
85
+ });
86
+ }
87
+ const F = ({
88
+ apiReferenceData: n,
89
+ selectedBaseUrlIndex: o,
90
+ selectedSecurityOptionIndex: c,
91
+ selectedExampleIndex: s = 0,
92
+ selectedContentTypeIndex: i = 0,
93
+ mergedUserInfo: t
94
+ }) => {
95
+ var O, $, j, l, w, k, q;
96
+ let e = {};
97
+ const r = (O = n.operation) == null ? void 0 : O.prefillPlaygroundWithExample, u = ((($ = n.operation) == null ? void 0 : $.prefillPlaygroundExamples) ?? [])[s], p = (l = Object.values(((j = n.dependencies) == null ? void 0 : j.servers) ?? {})[o]) == null ? void 0 : l.variables, a = (w = n.dependencies) == null ? void 0 : w.processedSecurityOptions, E = a == null ? void 0 : a[c], V = (k = n.dependencies) == null ? void 0 : k.parameters, z = (q = n.dependencies) == null ? void 0 : q.requestBody;
98
+ return r && u ? e = u : e = {
99
+ ...N(p),
100
+ ...G(E),
101
+ ...H({ apiReferenceData: n, parameters: V }),
102
+ ...J({ requestBody: z, apiReferenceData: n, selectedContentTypeIndex: i })
103
+ }, t && (e = {
104
+ ...e,
105
+ ...L({
106
+ mergedUserInfo: t,
107
+ securityOption: E,
108
+ serverVariables: p
109
+ })
110
+ }), e;
111
+ };
112
+ function N(n) {
113
+ const o = {};
114
+ return n && Object.entries(n).forEach(([c, s]) => {
115
+ const i = `${m.server}.${y(c)}`;
116
+ if (typeof s == "object" && s !== null) {
117
+ const t = g(s);
118
+ t && (o[i] = t);
29
119
  }
30
- if (r.current !== m) {
31
- y();
32
- const u = C({
33
- apiReferenceData: e,
34
- inputs: f(),
35
- selectedBaseUrlIndex: d,
36
- selectedSecurityOptionIndex: c,
37
- selectedExampleIndex: a,
38
- selectedContentTypeIndex: p
39
- });
40
- t(u), r.current = m;
120
+ }), o;
121
+ }
122
+ function G(n) {
123
+ const o = {};
124
+ return n && n.schemes.forEach(
125
+ ({
126
+ scheme: c,
127
+ schema: s,
128
+ name: i
129
+ }) => {
130
+ const t = B({ scheme: c, name: i }), e = g(s);
131
+ e && typeof e == "string" && (o[t] = e), e && typeof e == "object" && (o[t + ".username"] = "username" in e && typeof e.username == "string" ? e.username : "", o[t + ".password"] = "password" in e && typeof e.password == "string" ? e.password : "");
41
132
  }
42
- }, [
43
- e,
44
- d,
45
- a,
46
- p,
47
- y,
48
- t,
49
- f,
50
- b
51
- ]);
133
+ ), o;
52
134
  }
53
- const C = ({
54
- apiReferenceData: e,
55
- // eslint-disable-next-line unused-imports/no-unused-vars
56
- inputs: d,
57
- selectedBaseUrlIndex: a,
58
- selectedSecurityOptionIndex: p,
59
- selectedExampleIndex: r = 0,
60
- selectedContentTypeIndex: y = 0
61
- }) => {
62
- var E, V, I, $, j, x, K, z;
63
- let t = {};
64
- const f = (E = e.operation) == null ? void 0 : E.prefillPlaygroundWithExample, h = (((V = e.operation) == null ? void 0 : V.prefillPlaygroundExamples) ?? [])[r], S = ($ = Object.values(((I = e.dependencies) == null ? void 0 : I.servers) ?? {})[a]) == null ? void 0 : $.variables, c = (j = e.dependencies) == null ? void 0 : j.processedSecurityOptions, u = c == null ? void 0 : c[p], F = (x = e.dependencies) == null ? void 0 : x.parameters, v = (K = e.dependencies) == null ? void 0 : K.requestBody;
65
- if (!(f && h)) {
66
- if (S && Object.entries(S).forEach(([n, s]) => {
67
- const o = `${q.server}.${O(n)}`, i = P(s);
68
- i && (t[o] = i);
69
- }), u) {
70
- const { scheme: n, schema: s } = u, o = "in" in n ? n.in : "header", i = "name" in n ? n.name : s.title ?? "", l = `${w(o)}.${O(i)}`, g = P(s);
71
- g && (t[l] = g);
135
+ function H({
136
+ apiReferenceData: n,
137
+ parameters: o
138
+ }) {
139
+ const c = {};
140
+ if (!o) return c;
141
+ const { header: s, path: i, query: t, cookie: e } = W(n);
142
+ return [...s, ...i, ...t, ...e].forEach((r) => {
143
+ if (r.schema) {
144
+ const f = `${v(r.in)}.${y(r.name)}`, u = g(r.schema);
145
+ u && (c[f] = u);
72
146
  }
73
- if (F) {
74
- const { header: n, path: s, query: o, cookie: i } = B(e);
75
- [...n, ...s, ...o, ...i].forEach((l) => {
76
- if (l.schema) {
77
- const g = `${w(l.in)}.${O(l.name)}`, T = P(l.schema);
78
- T && (t[g] = T);
79
- }
80
- });
147
+ }), c;
148
+ }
149
+ function J({
150
+ requestBody: n,
151
+ apiReferenceData: o,
152
+ selectedContentTypeIndex: c
153
+ }) {
154
+ var t;
155
+ const s = {};
156
+ if (!n) return s;
157
+ const i = K(o, c);
158
+ if (i) {
159
+ const e = (t = n.content[i]) == null ? void 0 : t.schema, r = g(e);
160
+ if (r)
161
+ s[`${m.body}`] = r;
162
+ else if (A(e)) {
163
+ const f = T(e);
164
+ return { ...s, ...f };
81
165
  }
82
- if (v) {
83
- const n = G(e, y);
84
- if (n) {
85
- const s = (z = v.content[n]) == null ? void 0 : z.schema, o = P(s);
86
- if (o)
87
- t[`${q.body}`] = o;
88
- else if (H(s)) {
89
- const i = J(s);
90
- t = { ...t, ...i };
91
- }
166
+ }
167
+ return s;
168
+ }
169
+ function L({
170
+ mergedUserInfo: n,
171
+ securityOption: o,
172
+ serverVariables: c
173
+ }) {
174
+ const s = {};
175
+ if (o) {
176
+ const i = {};
177
+ o.schemes.forEach(
178
+ ({ scheme: t, name: e }) => {
179
+ i[e] = t;
92
180
  }
93
- }
181
+ ), Object.entries(n.header ?? {}).forEach(([t, e]) => {
182
+ const r = i[t];
183
+ r && (S(r) ? (typeof e == "object" && e !== null && "username" in e && typeof e.username == "string" && (s[`${m.header}.Authorization.username`] = e.username), typeof e == "object" && e !== null && "password" in e && typeof e.password == "string" && (s[`${m.header}.Authorization.password`] = e.password)) : typeof e == "string" && (s[`${m.header}.${y(t)}`] = e));
184
+ }), Object.entries(n.query ?? {}).forEach(([t, e]) => {
185
+ i[t] && (s[`${m.query}.${y(t)}`] = e);
186
+ }), Object.entries(n.cookie ?? {}).forEach(([t, e]) => {
187
+ i[t] && (s[`${m.cookie}.${y(t)}`] = e);
188
+ });
94
189
  }
95
- return t;
96
- };
190
+ return c && Object.keys(c).length > 0 && n.server && Object.entries(n.server).forEach(([i, t]) => {
191
+ c[i] && (s[`${m.server}.${y(i)}`] = t);
192
+ }), s;
193
+ }
97
194
  export {
98
- C as getInitialPlaygroundValues,
99
- X as useInitializeInputs
195
+ F as getInitialPlaygroundValues,
196
+ Z as useInitializeInputs
100
197
  };
@@ -1,32 +1,77 @@
1
- import { create as s } from "zustand";
2
- import { unflattenInputs as c } from "../schemaGraph/utils.js";
3
- const u = s((e, n) => ({
1
+ import { useState as l, useEffect as I, useMemo as a } from "react";
2
+ import { create as x } from "zustand";
3
+ import { useShallow as f } from "zustand/react/shallow";
4
+ import { unflattenInputs as i } from "../schemaGraph/utils.js";
5
+ const c = x((t, p) => ({
4
6
  inputs: {},
5
- initialize: (t) => e({
6
- inputs: { ...t }
7
+ apiReferenceData: void 0,
8
+ initializeInputs: (e) => t({
9
+ inputs: { ...e }
7
10
  }),
8
- setInput: (t, i) => e((p) => ({
9
- inputs: { ...p.inputs, [t]: i }
10
- })),
11
- setInputs: (t) => e((i) => ({
12
- inputs: { ...i.inputs, ...t }
11
+ initializeApiReferenceData: (e) => t({
12
+ apiReferenceData: e
13
+ }),
14
+ setInput: (e, n) => t((s) => {
15
+ const o = { ...s.inputs, [e]: n }, u = e.match(/^(.+)\.oneOf\.(\d+)$/);
16
+ if (u) {
17
+ const [, r] = u;
18
+ Object.keys(o).forEach((d) => {
19
+ d !== e && d.startsWith(`${r}.oneOf.`) && delete o[d];
20
+ });
21
+ }
22
+ return { inputs: o };
23
+ }),
24
+ setInputs: (e) => t((n) => ({
25
+ inputs: { ...n.inputs, ...e }
13
26
  })),
14
- replaceInputs: (t) => e({ inputs: t }),
15
- getInput: (t) => n().inputs[t],
16
- getApiPlaygroundInputs: () => c(n().inputs),
17
- clear: () => e({ inputs: {} }),
18
- reset: () => e({ inputs: {} }),
27
+ replaceInputs: (e) => t({ inputs: e }),
28
+ deleteInput: (e) => t((n) => {
29
+ const s = { ...n.inputs };
30
+ delete s[e];
31
+ const o = e + ".";
32
+ return Object.keys(s).forEach((u) => {
33
+ u.startsWith(o) && delete s[u];
34
+ }), { inputs: s };
35
+ }),
36
+ getInput: (e) => p().inputs[e],
37
+ getApiPlaygroundInputs: () => i(p().inputs),
38
+ clear: () => t({ inputs: {} }),
39
+ reset: () => t({
40
+ inputs: {},
41
+ selectedSecurityOptionIndex: 0,
42
+ selectedExampleIndex: 0,
43
+ selectedRequestBodyContentTypeIndex: 0,
44
+ selectedResponseContentTypeIndex: 0
45
+ }),
46
+ selectedBaseUrlIndex: 0,
47
+ setSelectedBaseUrlIndex: (e) => t({ selectedBaseUrlIndex: e }),
19
48
  selectedSecurityOptionIndex: 0,
20
- setSelectedSecurityOptionIndex: (t) => e({ selectedSecurityOptionIndex: t })
21
- })), d = () => {
22
- const e = u(
23
- (t) => t.selectedSecurityOptionIndex
24
- ), n = u(
25
- (t) => t.setSelectedSecurityOptionIndex
26
- );
27
- return { selectedSecurityOptionIndex: e, setSelectedSecurityOptionIndex: n };
49
+ setSelectedSecurityOptionIndex: (e) => t({ selectedSecurityOptionIndex: e }),
50
+ // Note: selectedExampleIndex is for prefill example selection (Example 1, Example 2, etc.)
51
+ // NOT for code snippet selection (Python, Node.js, cURL, etc.)
52
+ // Code snippet selection is managed by CodeGroupSelect component's local state
53
+ selectedExampleIndex: 0,
54
+ setSelectedExampleIndex: (e) => t({ selectedExampleIndex: e }),
55
+ selectedRequestBodyContentTypeIndex: 0,
56
+ setSelectedRequestBodyContentTypeIndex: (e) => t({ selectedRequestBodyContentTypeIndex: e }),
57
+ selectedResponseContentTypeIndex: 0,
58
+ setSelectedResponseContentTypeIndex: (e) => t({ selectedResponseContentTypeIndex: e })
59
+ })), T = (t) => {
60
+ const p = c((n) => n.inputs[t]), e = c((n) => n.setInput);
61
+ return { value: p, setInput: e };
62
+ }, O = (t = 300) => {
63
+ const p = c(f((s) => s.inputs)), [e, n] = l(p);
64
+ return I(() => {
65
+ const s = setTimeout(() => {
66
+ n(p);
67
+ }, t);
68
+ return () => {
69
+ clearTimeout(s);
70
+ };
71
+ }, [p, t]), a(() => i(e), [e]);
28
72
  };
29
73
  export {
30
- u as usePlaygroundInputsStore,
31
- d as useSelectedSecurityOption
74
+ O as useDebouncedApiPlaygroundInputs,
75
+ T as usePlaygroundInput,
76
+ c as usePlaygroundInputsStore
32
77
  };
@@ -0,0 +1,13 @@
1
+ import { useContext as c } from "react";
2
+ import { ApiReferenceContext2 as d } from "../../contexts/ConfigContext.js";
3
+ import { usePlaygroundInputsStore as n } from "./usePlaygroundInputsStore.js";
4
+ const x = () => {
5
+ var s, o;
6
+ const t = n((e) => e.selectedBaseUrlIndex), a = n(
7
+ (e) => e.setSelectedBaseUrlIndex
8
+ ), { apiReferenceData2: r } = c(d), l = ((s = r.operation) == null ? void 0 : s.baseUrl) ?? ((o = r.operation) == null ? void 0 : o.baseUrlOptions[t]) ?? "";
9
+ return { selectedBaseUrlIndex: t, setSelectedBaseUrlIndex: a, baseUrl: l };
10
+ };
11
+ export {
12
+ x as useSelectedBaseUrl
13
+ };
@@ -0,0 +1,10 @@
1
+ import { usePlaygroundInputsStore as t } from "./usePlaygroundInputsStore.js";
2
+ const s = () => {
3
+ const l = t((e) => e.selectedExampleIndex), d = t(
4
+ (e) => e.setSelectedExampleIndex
5
+ );
6
+ return { selectedExampleIndex: l, setSelectedExampleIndex: d };
7
+ };
8
+ export {
9
+ s as useSelectedExample
10
+ };
@@ -0,0 +1,12 @@
1
+ import { usePlaygroundInputsStore as t } from "./usePlaygroundInputsStore.js";
2
+ const s = () => {
3
+ const n = t(
4
+ (e) => e.selectedRequestBodyContentTypeIndex
5
+ ), o = t(
6
+ (e) => e.setSelectedRequestBodyContentTypeIndex
7
+ );
8
+ return { selectedRequestBodyContentTypeIndex: n, setSelectedRequestBodyContentTypeIndex: o };
9
+ };
10
+ export {
11
+ s as useSelectedRequestBodyContentType
12
+ };
@@ -0,0 +1,12 @@
1
+ import { usePlaygroundInputsStore as n } from "./usePlaygroundInputsStore.js";
2
+ const p = () => {
3
+ const t = n(
4
+ (e) => e.selectedResponseContentTypeIndex
5
+ ), s = n(
6
+ (e) => e.setSelectedResponseContentTypeIndex
7
+ );
8
+ return { selectedResponseContentTypeIndex: t, setSelectedResponseContentTypeIndex: s };
9
+ };
10
+ export {
11
+ p as useSelectedResponseContentType
12
+ };
@@ -0,0 +1,31 @@
1
+ import { useContext as m, useRef as x, useEffect as O } from "react";
2
+ import { ApiReferenceContext2 as g } from "../../contexts/ConfigContext.js";
3
+ import { getSecurityOptionInputKeyPrefix as y, getSchemaDefault as w } from "../schemaGraph/utils.js";
4
+ import { usePlaygroundInputsStore as p } from "./usePlaygroundInputsStore.js";
5
+ const b = () => {
6
+ var f;
7
+ const { apiReferenceData2: S } = m(g), r = p(
8
+ (c) => c.selectedSecurityOptionIndex
9
+ ), l = p(
10
+ (c) => c.setSelectedSecurityOptionIndex
11
+ ), u = x(r), t = (f = S.dependencies) == null ? void 0 : f.processedSecurityOptions;
12
+ return O(() => {
13
+ if (u.current !== r) {
14
+ const c = t == null ? void 0 : t[u.current], d = t == null ? void 0 : t[r];
15
+ if (c && d) {
16
+ const n = { ...p.getState().inputs };
17
+ c.schemes.forEach(({ scheme: s, name: a }) => {
18
+ const o = y({ scheme: s, name: a });
19
+ s.type === "http" && s.scheme === "basic" ? (delete n[o + ".username"], delete n[o + ".password"]) : delete n[o];
20
+ }), d.schemes.forEach(({ scheme: s, schema: a, name: o }) => {
21
+ const i = y({ scheme: s, name: o }), I = s.type === "http" && s.scheme === "basic", e = w(a);
22
+ I ? e && typeof e == "object" && (n[i + ".username"] = "username" in e && typeof e.username == "string" ? e.username : "", n[i + ".password"] = "password" in e && typeof e.password == "string" ? e.password : "") : e && typeof e == "string" && (n[i] = e);
23
+ }), p.getState().replaceInputs(n);
24
+ }
25
+ u.current = r;
26
+ }
27
+ }, [r, t]), { selectedSecurityOptionIndex: r, setSelectedSecurityOptionIndex: l };
28
+ };
29
+ export {
30
+ b as useSelectedSecurityOption
31
+ };