@scalar/api-client 3.11.0 → 3.12.0

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 (128) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/plugins/posthog/sanitize-event-payload.d.ts.map +1 -1
  3. package/dist/plugins/posthog/sanitize-event-payload.js +1 -0
  4. package/dist/plugins/posthog/sanitize-event-payload.js.map +1 -1
  5. package/dist/style.css +15 -69
  6. package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts.map +1 -1
  7. package/dist/v2/blocks/operation-block/OperationBlock.vue.js.map +1 -1
  8. package/dist/v2/blocks/operation-block/OperationBlock.vue.script.js +1 -1
  9. package/dist/v2/blocks/operation-block/OperationBlock.vue.script.js.map +1 -1
  10. package/dist/v2/blocks/operation-block/helpers/validate-path-parameters.d.ts.map +1 -1
  11. package/dist/v2/blocks/operation-block/helpers/validate-path-parameters.js +1 -2
  12. package/dist/v2/blocks/operation-block/helpers/validate-path-parameters.js.map +1 -1
  13. package/dist/v2/blocks/request-block/RequestBlock.vue.d.ts +1 -1
  14. package/dist/v2/blocks/request-block/RequestBlock.vue.d.ts.map +1 -1
  15. package/dist/v2/blocks/request-block/RequestBlock.vue.js +1 -1
  16. package/dist/v2/blocks/request-block/RequestBlock.vue.js.map +1 -1
  17. package/dist/v2/blocks/request-block/RequestBlock.vue.script.js +2 -2
  18. package/dist/v2/blocks/request-block/RequestBlock.vue.script.js.map +1 -1
  19. package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.d.ts +2 -2
  20. package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.d.ts.map +1 -1
  21. package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.js.map +1 -1
  22. package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.script.js +2 -6
  23. package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.script.js.map +1 -1
  24. package/dist/v2/blocks/request-block/helpers/create-parameter-handlers.d.ts.map +1 -1
  25. package/dist/v2/blocks/request-block/helpers/create-parameter-handlers.js +17 -3
  26. package/dist/v2/blocks/request-block/helpers/create-parameter-handlers.js.map +1 -1
  27. package/dist/v2/blocks/request-block/helpers/create-parameter-rows.d.ts.map +1 -1
  28. package/dist/v2/blocks/request-block/helpers/create-parameter-rows.js +28 -17
  29. package/dist/v2/blocks/request-block/helpers/create-parameter-rows.js.map +1 -1
  30. package/dist/v2/blocks/request-block/helpers/get-form-body-rows.js +1 -1
  31. package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.js +1 -1
  32. package/dist/v2/components/data-table/DataTableInput.vue.d.ts +1 -1
  33. package/dist/v2/components/data-table/DataTableInput.vue.d.ts.map +1 -1
  34. package/dist/v2/constants.js +1 -1
  35. package/dist/v2/features/modal/helpers/create-api-client-modal.js +1 -1
  36. package/dist/v2/features/operation/Operation.vue.script.js +1 -1
  37. package/dist/v2/workspace-events.d.ts.map +1 -1
  38. package/dist/v2/workspace-events.js +1 -0
  39. package/dist/v2/workspace-events.js.map +1 -1
  40. package/dist/vue-styles.css +6 -48
  41. package/package.json +11 -22
  42. package/dist/v2/blocks/operation-code-sample/components/ExamplePicker.vue.d.ts +0 -16
  43. package/dist/v2/blocks/operation-code-sample/components/ExamplePicker.vue.d.ts.map +0 -1
  44. package/dist/v2/blocks/operation-code-sample/components/ExamplePicker.vue.js +0 -7
  45. package/dist/v2/blocks/operation-code-sample/components/ExamplePicker.vue.js.map +0 -1
  46. package/dist/v2/blocks/operation-code-sample/components/ExamplePicker.vue.script.js +0 -53
  47. package/dist/v2/blocks/operation-code-sample/components/ExamplePicker.vue.script.js.map +0 -1
  48. package/dist/v2/blocks/operation-code-sample/components/HttpMethod.vue.d.ts +0 -26
  49. package/dist/v2/blocks/operation-code-sample/components/HttpMethod.vue.d.ts.map +0 -1
  50. package/dist/v2/blocks/operation-code-sample/components/HttpMethod.vue.js +0 -7
  51. package/dist/v2/blocks/operation-code-sample/components/HttpMethod.vue.js.map +0 -1
  52. package/dist/v2/blocks/operation-code-sample/components/HttpMethod.vue.script.js +0 -33
  53. package/dist/v2/blocks/operation-code-sample/components/HttpMethod.vue.script.js.map +0 -1
  54. package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.d.ts +0 -141
  55. package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.d.ts.map +0 -1
  56. package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.js +0 -9
  57. package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.js.map +0 -1
  58. package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.script.js +0 -272
  59. package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.script.js.map +0 -1
  60. package/dist/v2/blocks/operation-code-sample/helpers/filter-clients-by-query.d.ts +0 -9
  61. package/dist/v2/blocks/operation-code-sample/helpers/filter-clients-by-query.d.ts.map +0 -1
  62. package/dist/v2/blocks/operation-code-sample/helpers/filter-clients-by-query.js +0 -37
  63. package/dist/v2/blocks/operation-code-sample/helpers/filter-clients-by-query.js.map +0 -1
  64. package/dist/v2/blocks/operation-code-sample/helpers/find-client.d.ts +0 -41
  65. package/dist/v2/blocks/operation-code-sample/helpers/find-client.d.ts.map +0 -1
  66. package/dist/v2/blocks/operation-code-sample/helpers/find-client.js +0 -48
  67. package/dist/v2/blocks/operation-code-sample/helpers/find-client.js.map +0 -1
  68. package/dist/v2/blocks/operation-code-sample/helpers/format-language.d.ts +0 -8
  69. package/dist/v2/blocks/operation-code-sample/helpers/format-language.d.ts.map +0 -1
  70. package/dist/v2/blocks/operation-code-sample/helpers/format-language.js +0 -70
  71. package/dist/v2/blocks/operation-code-sample/helpers/format-language.js.map +0 -1
  72. package/dist/v2/blocks/operation-code-sample/helpers/generate-client-options.d.ts +0 -30
  73. package/dist/v2/blocks/operation-code-sample/helpers/generate-client-options.d.ts.map +0 -1
  74. package/dist/v2/blocks/operation-code-sample/helpers/generate-client-options.js +0 -63
  75. package/dist/v2/blocks/operation-code-sample/helpers/generate-client-options.js.map +0 -1
  76. package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.d.ts +0 -39
  77. package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.d.ts.map +0 -1
  78. package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.js +0 -38
  79. package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.js.map +0 -1
  80. package/dist/v2/blocks/operation-code-sample/helpers/get-clients.d.ts +0 -13
  81. package/dist/v2/blocks/operation-code-sample/helpers/get-clients.d.ts.map +0 -1
  82. package/dist/v2/blocks/operation-code-sample/helpers/get-clients.js +0 -37
  83. package/dist/v2/blocks/operation-code-sample/helpers/get-clients.js.map +0 -1
  84. package/dist/v2/blocks/operation-code-sample/helpers/get-custom-code-samples.d.ts +0 -45
  85. package/dist/v2/blocks/operation-code-sample/helpers/get-custom-code-samples.d.ts.map +0 -1
  86. package/dist/v2/blocks/operation-code-sample/helpers/get-custom-code-samples.js +0 -84
  87. package/dist/v2/blocks/operation-code-sample/helpers/get-custom-code-samples.js.map +0 -1
  88. package/dist/v2/blocks/operation-code-sample/helpers/get-resolved-ref-deep.d.ts +0 -27
  89. package/dist/v2/blocks/operation-code-sample/helpers/get-resolved-ref-deep.d.ts.map +0 -1
  90. package/dist/v2/blocks/operation-code-sample/helpers/get-resolved-ref-deep.js +0 -41
  91. package/dist/v2/blocks/operation-code-sample/helpers/get-resolved-ref-deep.js.map +0 -1
  92. package/dist/v2/blocks/operation-code-sample/helpers/get-secrets.d.ts +0 -4
  93. package/dist/v2/blocks/operation-code-sample/helpers/get-secrets.d.ts.map +0 -1
  94. package/dist/v2/blocks/operation-code-sample/helpers/get-secrets.js +0 -18
  95. package/dist/v2/blocks/operation-code-sample/helpers/get-secrets.js.map +0 -1
  96. package/dist/v2/blocks/operation-code-sample/helpers/get-snippet.d.ts +0 -8
  97. package/dist/v2/blocks/operation-code-sample/helpers/get-snippet.d.ts.map +0 -1
  98. package/dist/v2/blocks/operation-code-sample/helpers/get-snippet.js +0 -38
  99. package/dist/v2/blocks/operation-code-sample/helpers/get-snippet.js.map +0 -1
  100. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.d.ts +0 -72
  101. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.d.ts.map +0 -1
  102. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.js +0 -114
  103. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.js.map +0 -1
  104. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.d.ts +0 -13
  105. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.d.ts.map +0 -1
  106. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.js +0 -196
  107. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.js.map +0 -1
  108. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.d.ts +0 -24
  109. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.d.ts.map +0 -1
  110. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.js +0 -237
  111. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.js.map +0 -1
  112. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.d.ts +0 -15
  113. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.d.ts.map +0 -1
  114. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.js +0 -65
  115. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.js.map +0 -1
  116. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-server-url.d.ts +0 -6
  117. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-server-url.d.ts.map +0 -1
  118. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-server-url.js +0 -19
  119. package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-server-url.js.map +0 -1
  120. package/dist/v2/blocks/operation-code-sample/index.d.ts +0 -9
  121. package/dist/v2/blocks/operation-code-sample/index.d.ts.map +0 -1
  122. package/dist/v2/blocks/operation-code-sample/index.js +0 -8
  123. package/dist/v2/blocks/operation-code-sample/types.d.ts +0 -46
  124. package/dist/v2/blocks/operation-code-sample/types.d.ts.map +0 -1
  125. package/dist/v2/blocks/request-block/helpers/is-param-disabled.d.ts +0 -13
  126. package/dist/v2/blocks/request-block/helpers/is-param-disabled.d.ts.map +0 -1
  127. package/dist/v2/blocks/request-block/helpers/is-param-disabled.js +0 -21
  128. package/dist/v2/blocks/request-block/helpers/is-param-disabled.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"process-body.js","names":[],"sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.ts"],"sourcesContent":["import { json2xml } from '@scalar/helpers/file/json2xml'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport { unpackProxyObject } from '@scalar/workspace-store/helpers/unpack-proxy'\nimport {\n getExample,\n getExampleFromSchema,\n serializeFormPropertyWithEncoding,\n} from '@scalar/workspace-store/request-example'\nimport type {\n MediaTypeObject,\n RequestBodyObject,\n SchemaObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { getResolvedRefDeep } from '@v2/blocks/operation-code-sample/helpers/get-resolved-ref-deep'\nimport type { Param, PostData } from 'har-format'\n\nimport type { OperationToHarProps } from './operation-to-har'\n\ntype ProcessBodyProps = Pick<OperationToHarProps, 'contentType' | 'example' | 'requestBodyCompositionSelection'> & {\n requestBody: RequestBodyObject\n}\n\ntype MultipartEncodingMap = MediaTypeObject['encoding']\n\n/**\n * Converts a form-data body into HAR `Param[]` entries for `multipart/form-data`\n * and `application/x-www-form-urlencoded` requests.\n *\n * Per OpenAPI 3.1.x Encoding Object, each property's serialization is governed\n * by an optional Encoding entry. When `style` / `explode` / `allowReserved` is\n * set, the value is serialized RFC6570-style and `contentType` is ignored.\n * When only `contentType` is set, the property becomes a single part with that\n * type. Otherwise spec defaults apply (object → `application/json` for multipart,\n * primitives → `text/plain`).\n *\n * @param obj - The form-data payload, either an object keyed by property name\n * or a HAR-style `{ name, value, isDisabled }[]` array.\n * @param encoding - The `encoding` map from the Media Type Object, if any.\n * Used only at the top level (`parentKey` undefined).\n * @param parentKey - When set, we are flattening a nested object inside another\n * property; encoding is ignored and keys are joined with `.` (legacy default).\n * @param isMultipart - True for `multipart/form-data`. Gates the spec defaults\n * for object/array properties that should become a single `application/json`\n * part. Urlencoded bodies skip those branches and fall through to flattening.\n */\nconst objectToFormParams = (\n obj: object | { name: string; value: unknown; isDisabled: boolean }[],\n encoding?: MultipartEncodingMap,\n parentKey?: string,\n isMultipart = false,\n): Param[] => {\n const params: Param[] = []\n\n /** Ensure we do not include disabled items */\n const entries: [string, unknown][] = Array.isArray(obj)\n ? obj.filter((item) => !item.isDisabled).map((item) => [String(item.name), item.value])\n : Object.entries(obj)\n\n for (const [key, value] of entries) {\n if (value === undefined || value === null) {\n continue\n }\n\n const partEncoding = parentKey ? undefined : encoding?.[key]\n /**\n * Per OpenAPI 3.1.1: when style, explode, or allowReserved is explicitly set on the\n * encoding entry, contentType (implicit or explicit) is ignored and the value is\n * serialized as if it were a query-style parameter.\n */\n const hasFormStyle =\n partEncoding &&\n (partEncoding.style !== undefined ||\n partEncoding.explode !== undefined ||\n partEncoding.allowReserved !== undefined)\n /**\n * Per OAS 3.1.x Encoding Object: `contentType` SHALL be ignored if the request body\n * media type is not a multipart. For `application/x-www-form-urlencoded` we still\n * honor `style`/`explode`/`allowReserved` (handled above), but a `contentType`-only\n * entry has no effect — values fall through to the dotted-key flattening default.\n */\n const explicitContentType = hasFormStyle || !isMultipart ? undefined : partEncoding?.contentType\n\n /**\n * When the encoding sets style/explode/allowReserved, serialize the value RFC6570-style\n * (bracket/exploded notation) and ignore contentType. See `serializeFormPropertyWithEncoding`\n * for the per-style rules; it returns null for primitives, Files, and arrays of Files, which\n * then fall through to the dedicated branches below. HAR represents multipart and urlencoded\n * the same way via `PostData.params`, so the resulting parts work for both.\n */\n const styleParams = parentKey ? null : serializeFormPropertyWithEncoding(key, value, partEncoding)\n if (styleParams) {\n for (const param of styleParams) {\n params.push({ name: param.key, value: param.value })\n }\n } else if (value instanceof File) {\n /**\n * File values render as `@filename` references, the conventional cURL syntax for an\n * attached file. Picked up by snippet renderers downstream (e.g. `--form 'x=@file.png'`).\n */\n const file = unpackProxyObject(value)\n params.push({\n name: key,\n value: `@${file.name}`,\n ...(explicitContentType ? { contentType: explicitContentType } : {}),\n })\n } else if (explicitContentType && typeof value === 'object') {\n /**\n * Per OAS 3.1.x Encoding Object: an explicit `encoding[key].contentType` on a\n * complex value overrides the default and emits a single part containing the value\n * JSON-stringified into that media type. Only reachable when style/explode/allowReserved\n * are unset (otherwise contentType is ignored — see the style branch above).\n */\n params.push({\n name: key,\n value: JSON.stringify(unpackProxyObject(value)),\n contentType: explicitContentType,\n })\n } else if (isMultipart && !parentKey && !hasFormStyle && typeof value === 'object' && !Array.isArray(value)) {\n /**\n * Per OpenAPI 3.x: a top-level multipart property whose value is an object (and not a File)\n * defaults to a single part encoded as application/json, rather than being flattened\n * into multiple parts with dotted keys.\n */\n params.push({\n name: key,\n value: JSON.stringify(unpackProxyObject(value)),\n contentType: 'application/json',\n })\n } else if (Array.isArray(value)) {\n for (const item of value) {\n if (item instanceof File) {\n const file = unpackProxyObject(item)\n params.push({ name: key, value: `@${file.name}` })\n } else if (isMultipart && !parentKey && !hasFormStyle && typeof item === 'object' && item !== null) {\n /**\n * Per OpenAPI 3.x: a top-level multipart array of complex items defaults each part\n * to application/json, instead of flattening object items into dotted keys.\n */\n params.push({\n name: key,\n value: JSON.stringify(unpackProxyObject(item)),\n contentType: 'application/json',\n })\n } else {\n params.push({ name: key, value: String(item) })\n }\n }\n } else if (typeof value === 'object') {\n /**\n * Legacy fallback: flatten nested objects into dotted-key parts. Reached when the\n * multipart JSON-default branches above don't apply — i.e. either inside a recursive\n * call (`parentKey` set) or on `application/x-www-form-urlencoded` bodies without an\n * explicit encoding entry. Strict OAS 3.1.x would use `style: form, explode: true` as\n * the urlencoded default (inner keys become top-level params); we keep dotted keys for\n * backwards compatibility with consumers that already parse this shape.\n */\n const nestedParams = objectToFormParams(value, undefined, key)\n\n for (const param of nestedParams) {\n params.push({ name: `${key}.${param.name}`, value: param.value })\n }\n } else {\n params.push({\n name: key,\n value: String(value),\n ...(explicitContentType ? { contentType: explicitContentType } : {}),\n })\n }\n }\n\n return params\n}\n\n/**\n * Processes the request body and returns the processed data\n * Returns undefined if no example is found\n */\nexport const processBody = ({\n requestBody,\n contentType,\n example,\n requestBodyCompositionSelection,\n}: ProcessBodyProps): PostData | undefined => {\n const _contentType = contentType || Object.keys(requestBody.content)[0] || ''\n /** Empty when \"Other\" is selected so snippets do not inject `Content-Type: other`. */\n const harMimeType = _contentType === 'other' ? '' : _contentType\n const formatBinaryFile = (file: File) => {\n const unwrappedFile = unpackProxyObject(file)\n return `@${unwrappedFile.name || 'filename'}`\n }\n const encoding = requestBody.content[_contentType]?.encoding\n\n // Check if this is a form data content type\n const isFormData = _contentType === 'multipart/form-data' || _contentType === 'application/x-www-form-urlencoded'\n\n // Check if this is an XML content type\n const isXml = _contentType === 'application/xml'\n\n // Get the example value\n const _example = getExample(requestBody, example, contentType)?.value\n\n // Return the provided top level example\n if (typeof _example !== 'undefined') {\n const exampleValue = _example !== null && typeof _example === 'object' ? unpackProxyObject(_example) : _example\n\n if (isFormData && typeof exampleValue === 'object' && exampleValue !== null) {\n return {\n mimeType: harMimeType,\n params: objectToFormParams(exampleValue, encoding, undefined, _contentType === 'multipart/form-data'),\n }\n }\n\n if (isXml && typeof exampleValue === 'object' && exampleValue !== null) {\n return {\n mimeType: harMimeType,\n text: json2xml(exampleValue),\n }\n }\n\n if (exampleValue instanceof File) {\n return {\n mimeType: harMimeType,\n text: formatBinaryFile(exampleValue),\n }\n }\n\n return {\n mimeType: harMimeType,\n text: typeof exampleValue === 'string' ? exampleValue : JSON.stringify(exampleValue),\n }\n }\n\n // Try to extract examples from the schema\n const contentSchema = getResolvedRef(requestBody.content[_contentType]?.schema)\n if (typeof contentSchema !== 'undefined') {\n const resolvedContentSchema = getResolvedRefDeep(contentSchema) as SchemaObject\n const extractedExample = getExampleFromSchema(\n resolvedContentSchema,\n {\n compositionSelection: requestBodyCompositionSelection,\n mode: 'write',\n xml: isXml,\n },\n {\n schemaPath: ['requestBody'],\n },\n )\n\n if (extractedExample !== undefined) {\n if (isFormData && typeof extractedExample === 'object' && extractedExample !== null) {\n return {\n mimeType: harMimeType,\n params: objectToFormParams(extractedExample, encoding, undefined, _contentType === 'multipart/form-data'),\n }\n }\n\n if (isXml && typeof extractedExample === 'object' && extractedExample !== null) {\n return {\n mimeType: harMimeType,\n text: json2xml(extractedExample),\n }\n }\n\n return {\n mimeType: harMimeType,\n text: typeof extractedExample === 'string' ? extractedExample : JSON.stringify(extractedExample),\n }\n }\n }\n\n return undefined\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,IAAM,sBACJ,KACA,UACA,WACA,cAAc,UACF;CACZ,MAAM,SAAkB,EAAE;;CAG1B,MAAM,UAA+B,MAAM,QAAQ,IAAI,GACnD,IAAI,QAAQ,SAAS,CAAC,KAAK,WAAW,CAAC,KAAK,SAAS,CAAC,OAAO,KAAK,KAAK,EAAE,KAAK,MAAM,CAAC,GACrF,OAAO,QAAQ,IAAI;AAEvB,MAAK,MAAM,CAAC,KAAK,UAAU,SAAS;AAClC,MAAI,UAAU,KAAA,KAAa,UAAU,KACnC;EAGF,MAAM,eAAe,YAAY,KAAA,IAAY,WAAW;;;;;;EAMxD,MAAM,eACJ,iBACC,aAAa,UAAU,KAAA,KACtB,aAAa,YAAY,KAAA,KACzB,aAAa,kBAAkB,KAAA;;;;;;;EAOnC,MAAM,sBAAsB,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AAsB;GACtB,MAAM;GACN,KAAK;GACN,EACD,EACE,YAAY,CAAC,cAAc,EAC5B,CACF;AAED,MAAI,qBAAqB,KAAA,GAAW;AAClC,OAAI,cAAc,OAAO,qBAAqB,YAAY,qBAAqB,KAC7E,QAAO;IACL,UAAU;IACV,QAAQ,mBAAmB,kBAAkB,UAAU,KAAA,GAAW,iBAAiB,sBAAsB;IAC1G;AAGH,OAAI,SAAS,OAAO,qBAAqB,YAAY,qBAAqB,KACxE,QAAO;IACL,UAAU;IACV,MAAM,SAAS,iBAAiB;IACjC;AAGH,UAAO;IACL,UAAU;IACV,MAAM,OAAO,qBAAqB,WAAW,mBAAmB,KAAK,UAAU,iBAAiB;IACjG"}
@@ -1,24 +0,0 @@
1
- import type { OperationObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
2
- import type { Request as HarRequest } from 'har-format';
3
- type ProcessedParameters = {
4
- url: string;
5
- headers: HarRequest['headers'];
6
- queryString: HarRequest['queryString'];
7
- cookies: HarRequest['cookies'];
8
- };
9
- /**
10
- * Process OpenAPI parameters and return the updated properties.
11
- * Handles path, query, and header parameters with various styles and explode options.
12
- *
13
- * @see https://spec.openapis.org/oas/latest.html#style-values
14
- */
15
- export declare const processParameters: ({ harRequest, parameters, example, defaultDisabled, }: {
16
- harRequest: HarRequest;
17
- parameters: OperationObject["parameters"];
18
- /** The name of the example to use */
19
- example?: string | undefined;
20
- /** Whether to disable parameters by default. */
21
- defaultDisabled: boolean;
22
- }) => ProcessedParameters;
23
- export {};
24
- //# sourceMappingURL=process-parameters.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"process-parameters.d.ts","sourceRoot":"","sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,8DAA8D,CAAA;AACpH,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAIvD,KAAK,mBAAmB,GAAG;IACzB,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IAC9B,WAAW,EAAE,UAAU,CAAC,aAAa,CAAC,CAAA;IACtC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;CAC/B,CAAA;AA2FD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,uDAK/B;IACD,UAAU,EAAE,UAAU,CAAA;IACtB,UAAU,EAAE,eAAe,CAAC,YAAY,CAAC,CAAA;IACzC,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,gDAAgD;IAChD,eAAe,EAAE,OAAO,CAAA;CACzB,KAAG,mBAqIH,CAAA"}
@@ -1,237 +0,0 @@
1
- import { isParamDisabled } from "../../../request-block/helpers/is-param-disabled.js";
2
- import { deSerializeParameter, getExample, getExampleFromSchema, serializeContentValue, serializeDeepObjectStyle, serializeFormStyle, serializeFormStyleForCookies, serializePipeDelimitedStyle, serializeSimpleStyle, serializeSpaceDelimitedStyle } from "@scalar/workspace-store/request-example";
3
- import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref";
4
- //#region src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.ts
5
- /** Ensures we don't have any references in the parameters */
6
- var deReferenceParams = (params) => (params ?? []).map((param) => getResolvedRef(param));
7
- /** Whether the parameter allows reserved characters (from param or schema). */
8
- var isAllowReserved = (param) => {
9
- if ("allowReserved" in param && param.allowReserved !== void 0) return param.allowReserved;
10
- if ("schema" in param && param.schema && typeof param.schema === "object" && "allowReserved" in param.schema) return param.schema.allowReserved === true;
11
- return false;
12
- };
13
- /** URL encode a value if allowReserved is not set to true. */
14
- var encodeQueryValue = (value, param) => {
15
- if (isAllowReserved(param)) return value;
16
- return encodeURIComponent(value);
17
- };
18
- /**
19
- * Get the style and explode values for a parameter according to OpenAPI 3.1.1 specification.
20
- * Handles defaults and validation for parameter location restrictions.
21
- */
22
- var getParameterStyleAndExplode = (param) => {
23
- if (param.in === "header") return {
24
- style: "simple",
25
- explode: "explode" in param && param.explode !== void 0 ? param.explode : false
26
- };
27
- if (param.in === "cookie") return {
28
- style: "form",
29
- explode: "explode" in param && param.explode !== void 0 ? param.explode : true
30
- };
31
- const defaultStyle = {
32
- path: "simple",
33
- query: "form",
34
- header: "simple",
35
- cookie: "form"
36
- }[param.in];
37
- const style = "style" in param && param.style ? param.style : defaultStyle;
38
- return {
39
- style,
40
- explode: "explode" in param && param.explode !== void 0 ? param.explode : style === "form"
41
- };
42
- };
43
- /**
44
- * Extract the value for a parameter from example data or schema.
45
- * Prioritizes example data over schema examples.
46
- * Returns null if the parameter is disabled so we can skip it.
47
- */
48
- var getParameterValue = (param, example, contentType, defaultDisabled) => {
49
- const exampleValue = getExample(param, example, contentType);
50
- if (isParamDisabled(param, exampleValue, defaultDisabled)) return;
51
- if (exampleValue?.value !== void 0) return deSerializeParameter(exampleValue.value, param);
52
- if (!("schema" in param) || !param.schema) return;
53
- const options = param.in === "path" ? { emptyString: `{${param.name}}` } : {};
54
- return getExampleFromSchema(getResolvedRef(param.schema), options);
55
- };
56
- /**
57
- * Process OpenAPI parameters and return the updated properties.
58
- * Handles path, query, and header parameters with various styles and explode options.
59
- *
60
- * @see https://spec.openapis.org/oas/latest.html#style-values
61
- */
62
- var processParameters = ({ harRequest, parameters, example, defaultDisabled }) => {
63
- const newHeaders = [...harRequest.headers];
64
- const newQueryString = [...harRequest.queryString];
65
- let newUrl = harRequest.url;
66
- const deReferencedParams = deReferenceParams(parameters);
67
- for (const param of deReferencedParams) {
68
- if (!param.in || !param.name) continue;
69
- const paramValue = getParameterValue(param, example, void 0, defaultDisabled);
70
- if (paramValue === void 0) continue;
71
- const { style, explode } = getParameterStyleAndExplode(param);
72
- switch (param.in) {
73
- case "path":
74
- newUrl = processPathParameters(newUrl, param, paramValue, style, explode);
75
- break;
76
- case "query":
77
- if ("content" in param && param.content) {
78
- const serializedValue = serializeContentValue(paramValue, Object.keys(param.content)[0] ?? "application/json");
79
- newQueryString.push({
80
- name: param.name,
81
- value: encodeQueryValue(serializedValue, param)
82
- });
83
- break;
84
- }
85
- switch (style) {
86
- case "form": {
87
- const serialized = serializeFormStyle(paramValue, explode);
88
- if (Array.isArray(serialized)) for (const entry of serialized) {
89
- const key = entry.key || param.name;
90
- newQueryString.push({
91
- name: key,
92
- value: encodeQueryValue(String(entry.value), param)
93
- });
94
- }
95
- else newQueryString.push({
96
- name: param.name,
97
- value: encodeQueryValue(String(serialized), param)
98
- });
99
- break;
100
- }
101
- case "spaceDelimited": {
102
- const serialized = serializeSpaceDelimitedStyle(paramValue);
103
- newQueryString.push({
104
- name: param.name,
105
- value: encodeQueryValue(serialized, param)
106
- });
107
- break;
108
- }
109
- case "pipeDelimited": {
110
- const serialized = serializePipeDelimitedStyle(paramValue);
111
- newQueryString.push({
112
- name: param.name,
113
- value: encodeQueryValue(serialized, param)
114
- });
115
- break;
116
- }
117
- case "deepObject":
118
- if (Array.isArray(paramValue)) {
119
- const serialized = serializeFormStyle(paramValue, true);
120
- if (Array.isArray(serialized)) for (const entry of serialized) {
121
- const key = entry.key || param.name;
122
- newQueryString.push({
123
- name: key,
124
- value: encodeQueryValue(String(entry.value), param)
125
- });
126
- }
127
- else newQueryString.push({
128
- name: param.name,
129
- value: encodeQueryValue(String(serialized), param)
130
- });
131
- } else {
132
- const entries = serializeDeepObjectStyle(param.name, paramValue);
133
- for (const entry of entries) newQueryString.push({
134
- name: entry.key,
135
- value: encodeQueryValue(entry.value, param)
136
- });
137
- }
138
- break;
139
- default: newQueryString.push({
140
- name: param.name,
141
- value: encodeQueryValue(String(paramValue), param)
142
- });
143
- }
144
- break;
145
- case "header": {
146
- const serialized = serializeSimpleStyle(paramValue, explode);
147
- newHeaders.push({
148
- name: param.name,
149
- value: String(serialized)
150
- });
151
- break;
152
- }
153
- case "cookie": {
154
- const serialized = serializeFormStyleForCookies(paramValue, explode);
155
- if (Array.isArray(serialized)) for (const entry of serialized) {
156
- const key = entry.key || param.name;
157
- const value = entry.value === null ? "null" : String(entry.value);
158
- harRequest.cookies.push({
159
- name: key,
160
- value
161
- });
162
- }
163
- else {
164
- const value = serialized === null ? "null" : String(serialized);
165
- harRequest.cookies.push({
166
- name: param.name,
167
- value
168
- });
169
- }
170
- break;
171
- }
172
- }
173
- }
174
- return {
175
- url: newUrl,
176
- headers: newHeaders,
177
- queryString: newQueryString,
178
- cookies: harRequest.cookies
179
- };
180
- };
181
- /**
182
- * Process path parameters according to OpenAPI specification.
183
- * Handles matrix, label, and simple styles with explode options.
184
- *
185
- * @param url - The URL to process
186
- * @param param - The parameter object
187
- * @param paramValue - The value of the parameter
188
- * @param style - The style of the parameter (matrix, label, simple)
189
- * @param explode - Whether to explode the parameter
190
- * @returns The updated URL with processed path parameters
191
- */
192
- var processPathParameters = (url, param, paramValue, style, explode) => {
193
- switch (style) {
194
- case "matrix":
195
- if (explode) {
196
- if (Array.isArray(paramValue)) {
197
- const values = paramValue.map((v) => `${param.name}=${v}`).join(";");
198
- return url.replace(`{;${param.name}}`, `;${values}`);
199
- }
200
- if (typeof paramValue === "object" && paramValue !== null) {
201
- const values = Object.entries(paramValue).map(([k, v]) => `${k}=${v}`).join(";");
202
- return url.replace(`{;${param.name}}`, `;${values}`);
203
- }
204
- return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue}`);
205
- }
206
- if (Array.isArray(paramValue)) return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue.join(",")}`);
207
- if (typeof paramValue === "object" && paramValue !== null) {
208
- const values = Object.entries(paramValue).map(([k, v]) => `${k},${v}`).join(",");
209
- return url.replace(`{;${param.name}}`, `;${param.name}=${values}`);
210
- }
211
- return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue}`);
212
- case "label":
213
- if (explode) {
214
- if (Array.isArray(paramValue)) return url.replace(`{.${param.name}}`, `.${paramValue.join(".")}`);
215
- if (typeof paramValue === "object" && paramValue !== null) {
216
- const values = Object.entries(paramValue).map(([k, v]) => `${k}=${v}`).join(".");
217
- return url.replace(`{.${param.name}}`, `.${values}`);
218
- }
219
- return url.replace(`{.${param.name}}`, `.${paramValue}`);
220
- }
221
- if (Array.isArray(paramValue)) return url.replace(`{.${param.name}}`, `.${paramValue.join(",")}`);
222
- if (typeof paramValue === "object" && paramValue !== null) {
223
- const values = Object.entries(paramValue).map(([k, v]) => `${k},${v}`).join(",");
224
- return url.replace(`{.${param.name}}`, `.${values}`);
225
- }
226
- return url.replace(`{.${param.name}}`, `.${paramValue}`);
227
- case "simple": {
228
- const serialized = serializeSimpleStyle(paramValue, explode);
229
- return url.replace(`{${param.name}}`, String(serialized));
230
- }
231
- default: return url.replace(`{${param.name}}`, String(paramValue));
232
- }
233
- };
234
- //#endregion
235
- export { processParameters };
236
-
237
- //# sourceMappingURL=process-parameters.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"process-parameters.js","names":[],"sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.ts"],"sourcesContent":["import { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n deSerializeParameter,\n getExample,\n getExampleFromSchema,\n serializeContentValue,\n serializeDeepObjectStyle,\n serializeFormStyle,\n serializeFormStyleForCookies,\n serializePipeDelimitedStyle,\n serializeSimpleStyle,\n serializeSpaceDelimitedStyle,\n} from '@scalar/workspace-store/request-example'\nimport type { OperationObject, ParameterObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport type { Request as HarRequest } from 'har-format'\n\nimport { isParamDisabled } from '@/v2/blocks/request-block/helpers/is-param-disabled'\n\ntype ProcessedParameters = {\n url: string\n headers: HarRequest['headers']\n queryString: HarRequest['queryString']\n cookies: HarRequest['cookies']\n}\n\n/** Ensures we don't have any references in the parameters */\nconst deReferenceParams = (params: OperationObject['parameters']): ParameterObject[] =>\n (params ?? []).map((param) => getResolvedRef(param))\n\n/** Whether the parameter allows reserved characters (from param or schema). */\nconst isAllowReserved = (param: ParameterObject): boolean => {\n if ('allowReserved' in param && param.allowReserved !== undefined) {\n return param.allowReserved\n }\n if ('schema' in param && param.schema && typeof param.schema === 'object' && 'allowReserved' in param.schema) {\n return (param.schema as { allowReserved?: boolean }).allowReserved === true\n }\n return false\n}\n\n/** URL encode a value if allowReserved is not set to true. */\nconst encodeQueryValue = (value: string, param: ParameterObject): string => {\n if (isAllowReserved(param)) {\n return value\n }\n return encodeURIComponent(value)\n}\n\n/**\n * Get the style and explode values for a parameter according to OpenAPI 3.1.1 specification.\n * Handles defaults and validation for parameter location restrictions.\n */\nconst getParameterStyleAndExplode = (param: ParameterObject): { style: string; explode: boolean } => {\n // Headers only support 'simple' style\n if (param.in === 'header') {\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : false\n return { style: 'simple', explode }\n }\n\n // Cookies only support 'form' style\n if (param.in === 'cookie') {\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : true\n return { style: 'form', explode }\n }\n\n const defaultStyle = {\n path: 'simple',\n query: 'form',\n header: 'simple',\n cookie: 'form',\n }[param.in]\n\n // Use provided style or default based on location\n const style = 'style' in param && param.style ? param.style : defaultStyle\n\n // Determine explode value: use provided value or default based on style\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : style === 'form'\n\n return { style, explode }\n}\n\n/**\n * Extract the value for a parameter from example data or schema.\n * Prioritizes example data over schema examples.\n * Returns null if the parameter is disabled so we can skip it.\n */\nconst getParameterValue = (\n param: ParameterObject,\n example: string | undefined,\n contentType: string | undefined,\n defaultDisabled: boolean,\n): unknown => {\n // Try to get value from example first\n const exampleValue = getExample(param, example, contentType)\n\n // If the parameter is disabled, return undefined so we can skip it.\n if (isParamDisabled(param, exampleValue, defaultDisabled)) {\n return undefined\n }\n\n // If the example value is set, return it.\n if (exampleValue?.value !== undefined) {\n return deSerializeParameter(exampleValue.value, param)\n }\n\n // Fall back to schema example if available\n if (!('schema' in param) || !param.schema) {\n return undefined\n }\n\n const options = param.in === 'path' ? { emptyString: `{${param.name}}` } : {}\n return getExampleFromSchema(getResolvedRef(param.schema), options)\n}\n\n/**\n * Process OpenAPI parameters and return the updated properties.\n * Handles path, query, and header parameters with various styles and explode options.\n *\n * @see https://spec.openapis.org/oas/latest.html#style-values\n */\nexport const processParameters = ({\n harRequest,\n parameters,\n example,\n defaultDisabled,\n}: {\n harRequest: HarRequest\n parameters: OperationObject['parameters']\n /** The name of the example to use */\n example?: string | undefined\n /** Whether to disable parameters by default. */\n defaultDisabled: boolean\n}): ProcessedParameters => {\n // Create copies of the arrays to avoid modifying the input\n const newHeaders = [...harRequest.headers]\n const newQueryString = [...harRequest.queryString]\n let newUrl = harRequest.url\n\n // Filter out references\n const deReferencedParams = deReferenceParams(parameters)\n\n for (const param of deReferencedParams) {\n if (!param.in || !param.name) {\n continue\n }\n\n const paramValue = getParameterValue(param, example, undefined, defaultDisabled)\n if (paramValue === undefined) {\n continue\n }\n\n const { style, explode } = getParameterStyleAndExplode(param)\n\n switch (param.in) {\n case 'path': {\n newUrl = processPathParameters(newUrl, param, paramValue, style, explode)\n break\n }\n\n case 'query': {\n // Content type parameters should be serialized according to the parameter's own content type\n if ('content' in param && param.content) {\n // We grab the first for now but eventually we should support selecting the content type per parameter\n const paramContentType = Object.keys(param.content)[0] ?? 'application/json'\n const serializedValue = serializeContentValue(paramValue, paramContentType)\n newQueryString.push({ name: param.name, value: encodeQueryValue(serializedValue, param) })\n break\n }\n\n // Handle query parameters\n switch (style) {\n case 'form': {\n const serialized = serializeFormStyle(paramValue, explode)\n\n // If serialized is an array of key-value pairs (exploded object or array)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || param.name\n newQueryString.push({ name: key, value: encodeQueryValue(String(entry.value), param) })\n }\n }\n // Otherwise, convert to string\n else {\n newQueryString.push({ name: param.name, value: encodeQueryValue(String(serialized), param) })\n }\n break\n }\n case 'spaceDelimited': {\n const serialized = serializeSpaceDelimitedStyle(paramValue)\n newQueryString.push({ name: param.name, value: encodeQueryValue(serialized, param) })\n break\n }\n case 'pipeDelimited': {\n const serialized = serializePipeDelimitedStyle(paramValue)\n newQueryString.push({ name: param.name, value: encodeQueryValue(serialized, param) })\n break\n }\n case 'deepObject': {\n // OAS marks deepObject-on-array and deepObject+explode:false as undefined.\n // Mirror process-body: fall back to form/explode:true for arrays and always\n // invoke the serializer for objects so authors get useful output instead of\n // a silently-dropped parameter.\n if (Array.isArray(paramValue)) {\n const serialized = serializeFormStyle(paramValue, true)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || param.name\n newQueryString.push({ name: key, value: encodeQueryValue(String(entry.value), param) })\n }\n } else {\n newQueryString.push({ name: param.name, value: encodeQueryValue(String(serialized), param) })\n }\n } else {\n const entries = serializeDeepObjectStyle(param.name, paramValue)\n for (const entry of entries) {\n newQueryString.push({ name: entry.key, value: encodeQueryValue(entry.value, param) })\n }\n }\n break\n }\n\n // Default to form style\n default:\n newQueryString.push({ name: param.name, value: encodeQueryValue(String(paramValue), param) })\n }\n break\n }\n\n // Headers only support 'simple' style according to OpenAPI 3.1.1\n // For arrays, simple style always produces comma-separated values regardless of explode\n // The explode parameter only affects object serialization\n case 'header': {\n const serialized = serializeSimpleStyle(paramValue, explode)\n newHeaders.push({ name: param.name, value: String(serialized) })\n break\n }\n\n // Cookies only support 'form' style according to OpenAPI 3.1.1\n case 'cookie': {\n const serialized = serializeFormStyleForCookies(paramValue, explode)\n\n // If serialized is an array of key-value pairs (exploded object or array)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || param.name\n const value = entry.value === null ? 'null' : String(entry.value)\n harRequest.cookies.push({ name: key, value })\n }\n }\n // Otherwise, convert to string\n else {\n const value = serialized === null ? 'null' : String(serialized)\n harRequest.cookies.push({ name: param.name, value })\n }\n break\n }\n }\n }\n\n return {\n url: newUrl,\n headers: newHeaders,\n queryString: newQueryString,\n cookies: harRequest.cookies,\n }\n}\n\n/**\n * Process path parameters according to OpenAPI specification.\n * Handles matrix, label, and simple styles with explode options.\n *\n * @param url - The URL to process\n * @param param - The parameter object\n * @param paramValue - The value of the parameter\n * @param style - The style of the parameter (matrix, label, simple)\n * @param explode - Whether to explode the parameter\n * @returns The updated URL with processed path parameters\n */\nconst processPathParameters = (\n url: string,\n param: ParameterObject,\n paramValue: unknown,\n style: string,\n explode: boolean,\n): string => {\n switch (style) {\n case 'matrix': {\n if (explode) {\n // Matrix explode array: ;color=blue;color=black;color=brown\n if (Array.isArray(paramValue)) {\n const values = (paramValue as unknown[]).map((v) => `${param.name}=${v}`).join(';')\n return url.replace(`{;${param.name}}`, `;${values}`)\n }\n\n // Matrix explode object: ;R=100;G=200;B=150\n if (typeof paramValue === 'object' && paramValue !== null) {\n const values = Object.entries(paramValue as Record<string, unknown>)\n .map(([k, v]) => `${k}=${v}`)\n .join(';')\n return url.replace(`{;${param.name}}`, `;${values}`)\n }\n\n // Matrix explode primitive: ;color=blue\n return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue}`)\n }\n\n // Matrix no explode array: ;color=blue,black,brown\n if (Array.isArray(paramValue)) {\n return url.replace(`{;${param.name}}`, `;${param.name}=${(paramValue as unknown[]).join(',')}`)\n }\n\n // Matrix no explode object: ;color=R,100,G,200,B,150\n if (typeof paramValue === 'object' && paramValue !== null) {\n const values = Object.entries(paramValue as Record<string, unknown>)\n .map(([k, v]) => `${k},${v}`)\n .join(',')\n return url.replace(`{;${param.name}}`, `;${param.name}=${values}`)\n }\n\n // Matrix no explode primitive: ;color=blue\n return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue}`)\n }\n case 'label': {\n if (explode) {\n // Label explode array: .blue.black.brown\n if (Array.isArray(paramValue)) {\n return url.replace(`{.${param.name}}`, `.${(paramValue as unknown[]).join('.')}`)\n }\n\n // Label explode object: .R=100.G=200.B=150\n if (typeof paramValue === 'object' && paramValue !== null) {\n const values = Object.entries(paramValue as Record<string, unknown>)\n .map(([k, v]) => `${k}=${v}`)\n .join('.')\n\n return url.replace(`{.${param.name}}`, `.${values}`)\n }\n\n // Label explode primitive: .blue\n return url.replace(`{.${param.name}}`, `.${paramValue}`)\n }\n\n // Label no explode array: .blue,black,brown\n if (Array.isArray(paramValue)) {\n return url.replace(`{.${param.name}}`, `.${(paramValue as unknown[]).join(',')}`)\n }\n\n // Label no explode object: .R,100,G,200,B,150\n if (typeof paramValue === 'object' && paramValue !== null) {\n const values = Object.entries(paramValue as Record<string, unknown>)\n .map(([k, v]) => `${k},${v}`)\n .join(',')\n\n return url.replace(`{.${param.name}}`, `.${values}`)\n }\n\n // Label no explode primitive: .blue\n return url.replace(`{.${param.name}}`, `.${paramValue}`)\n }\n\n case 'simple': {\n const serialized = serializeSimpleStyle(paramValue, explode)\n return url.replace(`{${param.name}}`, String(serialized))\n }\n\n // Default to simple style\n default:\n return url.replace(`{${param.name}}`, String(paramValue))\n }\n}\n"],"mappings":";;;;;AA0BA,IAAM,qBAAqB,YACxB,UAAU,EAAE,EAAE,KAAK,UAAU,eAAe,MAAM,CAAC;;AAGtD,IAAM,mBAAmB,UAAoC;AAC3D,KAAI,mBAAmB,SAAS,MAAM,kBAAkB,KAAA,EACtD,QAAO,MAAM;AAEf,KAAI,YAAY,SAAS,MAAM,UAAU,OAAO,MAAM,WAAW,YAAY,mBAAmB,MAAM,OACpG,QAAQ,MAAM,OAAuC,kBAAkB;AAEzE,QAAO;;;AAIT,IAAM,oBAAoB,OAAe,UAAmC;AAC1E,KAAI,gBAAgB,MAAM,CACxB,QAAO;AAET,QAAO,mBAAmB,MAAM;;;;;;AAOlC,IAAM,+BAA+B,UAAgE;AAEnG,KAAI,MAAM,OAAO,SAEf,QAAO;EAAE,OAAO;EAAU,SADV,aAAa,SAAS,MAAM,YAAY,KAAA,IAAY,MAAM,UAAU;EACjD;AAIrC,KAAI,MAAM,OAAO,SAEf,QAAO;EAAE,OAAO;EAAQ,SADR,aAAa,SAAS,MAAM,YAAY,KAAA,IAAY,MAAM,UAAU;EACnD;CAGnC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S,OAAO,QAAQ,WAAsC,CACjE,KAAK,CAAC,GAAG,OAAO,GAAG,EAAE,GAAG,IAAI,CAC5B,KAAK,IAAI;AAEZ,WAAO,IAAI,QAAQ,KAAK,MAAM,KAAK,IAAI,IAAI,SAAS;;AAItD,UAAO,IAAI,QAAQ,KAAK,MAAM,KAAK,IAAI,IAAI,aAAa;EAG1D,KAAK,UAAU;GACb,MAAM,aAAa,qBAAqB,YAAY,QAAQ;AAC5D,UAAO,IAAI,QAAQ,IAAI,MAAM,KAAK,IAAI,OAAO,WAAW,CAAC;;EAI3D,QACE,QAAO,IAAI,QAAQ,IAAI,MAAM,KAAK,IAAI,OAAO,WAAW,CAAC"}
@@ -1,15 +0,0 @@
1
- import type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example';
2
- import type { Request as HarRequest } from 'har-format';
3
- type ProcessedSecuritySchemesReturn = {
4
- headers: HarRequest['headers'];
5
- queryString: HarRequest['queryString'];
6
- cookies: HarRequest['cookies'];
7
- };
8
- /**
9
- * Process security schemes into whichever parameters they are applicable to
10
- *
11
- * TODO: we probably want to be able to disable YOUR_SECRET_TOKEN placeholder text + or allow it to be customzied
12
- */
13
- export declare const processSecuritySchemes: (securitySchemes: SecuritySchemeObjectSecret[]) => ProcessedSecuritySchemesReturn;
14
- export {};
15
- //# sourceMappingURL=process-security-schemes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"process-security-schemes.d.ts","sourceRoot":"","sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAA;AACzF,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAGvD,KAAK,8BAA8B,GAAG;IACpC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IAC9B,WAAW,EAAE,UAAU,CAAC,aAAa,CAAC,CAAA;IACtC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;CAC/B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GACjC,iBAAiB,0BAA0B,EAAE,KAC5C,8BA2EF,CAAA"}
@@ -1,65 +0,0 @@
1
- import { encode } from "js-base64";
2
- //#region src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.ts
3
- /**
4
- * Process security schemes into whichever parameters they are applicable to
5
- *
6
- * TODO: we probably want to be able to disable YOUR_SECRET_TOKEN placeholder text + or allow it to be customzied
7
- */
8
- var processSecuritySchemes = (securitySchemes) => {
9
- const result = {
10
- headers: [],
11
- queryString: [],
12
- cookies: []
13
- };
14
- for (const scheme of securitySchemes) {
15
- if (scheme.type === "apiKey") {
16
- const value = scheme["x-scalar-secret-token"] || "YOUR_SECRET_TOKEN";
17
- if (!scheme.name) continue;
18
- const param = {
19
- name: scheme.name,
20
- value
21
- };
22
- switch (scheme.in) {
23
- case "header":
24
- result.headers.push(param);
25
- break;
26
- case "query":
27
- result.queryString.push(param);
28
- break;
29
- case "cookie":
30
- result.cookies.push(param);
31
- break;
32
- }
33
- continue;
34
- }
35
- if (scheme.type === "http") {
36
- if (scheme.scheme === "basic") {
37
- const value = `${scheme["x-scalar-secret-username"] || ""}:${scheme["x-scalar-secret-password"] || ""}`;
38
- const auth = value === ":" ? "username:password" : encode(value);
39
- result.headers.push({
40
- name: "Authorization",
41
- value: `Basic ${auth}`
42
- });
43
- } else if (scheme.scheme === "bearer") {
44
- const token = scheme["x-scalar-secret-token"] || "YOUR_SECRET_TOKEN";
45
- result.headers.push({
46
- name: "Authorization",
47
- value: `Bearer ${token}`
48
- });
49
- }
50
- continue;
51
- }
52
- if (scheme.type === "oauth2" && scheme.flows) {
53
- const token = Object.values(scheme.flows).find((f) => f["x-scalar-secret-token"])?.["x-scalar-secret-token"] || "YOUR_SECRET_TOKEN";
54
- result.headers.push({
55
- name: "Authorization",
56
- value: `Bearer ${token}`
57
- });
58
- }
59
- }
60
- return result;
61
- };
62
- //#endregion
63
- export { processSecuritySchemes };
64
-
65
- //# sourceMappingURL=process-security-schemes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"process-security-schemes.js","names":[],"sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.ts"],"sourcesContent":["import type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport type { Request as HarRequest } from 'har-format'\nimport { encode } from 'js-base64'\n\ntype ProcessedSecuritySchemesReturn = {\n headers: HarRequest['headers']\n queryString: HarRequest['queryString']\n cookies: HarRequest['cookies']\n}\n\n/**\n * Process security schemes into whichever parameters they are applicable to\n *\n * TODO: we probably want to be able to disable YOUR_SECRET_TOKEN placeholder text + or allow it to be customzied\n */\nexport const processSecuritySchemes = (\n securitySchemes: SecuritySchemeObjectSecret[],\n): ProcessedSecuritySchemesReturn => {\n const result: ProcessedSecuritySchemesReturn = {\n headers: [],\n queryString: [],\n cookies: [],\n }\n\n for (const scheme of securitySchemes) {\n // Handle apiKey type\n if (scheme.type === 'apiKey') {\n const value = scheme['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n if (!scheme.name) {\n continue\n }\n\n const param = { name: scheme.name, value }\n\n switch (scheme.in) {\n case 'header':\n result.headers.push(param)\n break\n case 'query':\n result.queryString.push(param)\n break\n case 'cookie':\n result.cookies.push(param)\n break\n }\n continue\n }\n\n // Handle http type\n if (scheme.type === 'http') {\n if (scheme.scheme === 'basic') {\n const username = scheme['x-scalar-secret-username'] || ''\n const password = scheme['x-scalar-secret-password'] || ''\n\n // The snippet is documentation, so we always show an Authorization header. When both\n // fields are empty we render a readable `username:password` placeholder, mirroring the\n // `YOUR_SECRET_TOKEN` placeholder used by the other schemes. (The real request omits the\n // header entirely in that case — see buildRequestSecurity.)\n const value = `${username}:${password}`\n const auth = value === ':' ? 'username:password' : encode(value)\n\n result.headers.push({\n name: 'Authorization',\n value: `Basic ${auth}`,\n })\n } else if (scheme.scheme === 'bearer') {\n const token = scheme['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n\n result.headers.push({\n name: 'Authorization',\n value: `Bearer ${token}`,\n })\n }\n continue\n }\n\n // Handle oauth2 type\n if (scheme.type === 'oauth2' && scheme.flows) {\n const flows = Object.values(scheme.flows)\n\n // Find the first flow with a token\n const flow = flows.find((f) => f['x-scalar-secret-token'])\n const token = flow?.['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n\n result.headers.push({\n name: 'Authorization',\n value: `Bearer ${token}`,\n })\n }\n }\n\n return result\n}\n"],"mappings":";;;;;;;AAeA,IAAa,0BACX,oBACmC;CACnC,MAAM,SAAyC;EAC7C,SAAS,EAAE;EACX,aAAa,EAAE;EACf,SAAS,EAAE;EACZ;AAED,MAAK,MAAM,UAAU,iBAAiB;AAEpC,MAAI,OAAO,SAAS,UAAU;GAC5B,MAAM,QAAQ,OAAO,4BAA4B;AACjD,OAAI,CAAC,OAAO,KACV;GAGF,MAAM,QAAQ;IAAE,MAAM,OAAO;IAAM;IAAO;AAE1C,WAAQ,OAAO,IAAf;IACE,KAAK;AACH,YAAO,QAAQ,KAAK,MAAM;AAC1B;IACF,KAAK;AACH,YAAO,YAAY,KAAK,MAAM;AAC9B;IACF,KAAK;AACH,YAAO,QAAQ,KAAK,MAAM;AAC1B;;AAEJ;;AAIF,MAAI,OAAO,SAAS,QAAQ;AAC1B,OAAI,OAAO,WAAW,SAAS;IAQ7B,MAAM,QAAQ,GAPG,OAAO,+BAA+B,GAO7B,GANT,OAAO,+BAA+B;IAOvD,MAAM,OAAO,UAAU,MAAM,sBAAsB,OAAO,MAAM;AAEhE,WAAO,QAAQ,KAAK;KAClB,MAAM;KACN,OAAO,SAAS;KACjB,CAAC;cACO,OAAO,WAAW,UAAU;IACrC,MAAM,QAAQ,OAAO,4BAA4B;AAEjD,WAAO,QAAQ,KAAK;KAClB,MAAM;KACN,OAAO,UAAU;KAClB,CAAC;;AAEJ;;AAIF,MAAI,OAAO,SAAS,YAAY,OAAO,OAAO;GAK5C,MAAM,QAJQ,OAAO,OAAO,OAAO,MAAM,CAGtB,MAAM,MAAM,EAAE,yBAAyB,GACrC,4BAA4B;AAEjD,UAAO,QAAQ,KAAK;IAClB,MAAM;IACN,OAAO,UAAU;IAClB,CAAC;;;AAIN,QAAO"}
@@ -1,6 +0,0 @@
1
- import type { ServerObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
2
- /**
3
- * Processes a server URL by replacing variables with their default values and merging with the path
4
- */
5
- export declare const processServerUrl: (server: ServerObject | null, path: string) => string;
6
- //# sourceMappingURL=process-server-url.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"process-server-url.d.ts","sourceRoot":"","sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-server-url.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAEhG;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,YAAY,GAAG,IAAI,EAAE,MAAM,MAAM,KAAG,MA4B5E,CAAA"}
@@ -1,19 +0,0 @@
1
- import { replaceVariables } from "@scalar/helpers/regex/replace-variables";
2
- import { mergeUrls } from "@scalar/helpers/url/merge-urls";
3
- //#region src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-server-url.ts
4
- /**
5
- * Processes a server URL by replacing variables with their default values and merging with the path
6
- */
7
- var processServerUrl = (server, path) => {
8
- if (!server?.url) return path;
9
- const serverUrl = server.url;
10
- if (server.variables) return mergeUrls(replaceVariables(serverUrl, Object.entries(server.variables).reduce((defaults, [variableName, variableConfig]) => {
11
- if (variableConfig.default !== void 0) defaults[variableName] = variableConfig.default;
12
- return defaults;
13
- }, {})), path);
14
- return mergeUrls(serverUrl, path);
15
- };
16
- //#endregion
17
- export { processServerUrl };
18
-
19
- //# sourceMappingURL=process-server-url.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"process-server-url.js","names":[],"sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-server-url.ts"],"sourcesContent":["import { replaceVariables } from '@scalar/helpers/regex/replace-variables'\nimport { mergeUrls } from '@scalar/helpers/url/merge-urls'\nimport type { ServerObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\n/**\n * Processes a server URL by replacing variables with their default values and merging with the path\n */\nexport const processServerUrl = (server: ServerObject | null, path: string): string => {\n if (!server?.url) {\n return path\n }\n const serverUrl = server.url\n\n // Replace server variables with their default values\n if (server.variables) {\n const variables = Object.entries(server.variables)\n\n // Extract default values from server variables\n const defaultValues = variables.reduce(\n (defaults, [variableName, variableConfig]) => {\n if (variableConfig.default !== undefined) {\n defaults[variableName] = variableConfig.default\n }\n return defaults\n },\n {} as Record<string, string | number>,\n )\n\n // Replace variables in the server URL with their default values\n const serverUrlWithVars = replaceVariables(serverUrl, defaultValues)\n\n return mergeUrls(serverUrlWithVars, path)\n }\n\n return mergeUrls(serverUrl, path)\n}\n"],"mappings":";;;;;;AAOA,IAAa,oBAAoB,QAA6B,SAAyB;AACrF,KAAI,CAAC,QAAQ,IACX,QAAO;CAET,MAAM,YAAY,OAAO;AAGzB,KAAI,OAAO,UAiBT,QAAO,UAFmB,iBAAiB,WAdzB,OAAO,QAAQ,OAAO,UAAU,CAGlB,QAC7B,UAAU,CAAC,cAAc,oBAAoB;AAC5C,MAAI,eAAe,YAAY,KAAA,EAC7B,UAAS,gBAAgB,eAAe;AAE1C,SAAO;IAET,EAAE,CACH,CAGmE,EAEhC,KAAK;AAG3C,QAAO,UAAU,WAAW,KAAK"}
@@ -1,9 +0,0 @@
1
- export { default as ExamplePicker } from './components/ExamplePicker.vue.js';
2
- export { default as HttpMethod } from './components/HttpMethod.vue.js';
3
- export { default as OperationCodeSample } from './components/OperationCodeSample.vue.js';
4
- export { filterClientsByQuery } from './helpers/filter-clients-by-query.js';
5
- export { DEFAULT_CLIENT, type SelectedClientId, findClient, isClient, isSelectedClient } from './helpers/find-client.js';
6
- export { generateClientOptions, getCustomClientIds } from './helpers/generate-client-options.js';
7
- export { getResolvedRefDeep } from './helpers/get-resolved-ref-deep.js';
8
- export type { ClientOption, ClientOptionGroup, CustomClientOption, CustomClientOptionGroup } from './types';
9
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/v2/blocks/operation-code-sample/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,gCAAgC,CAAA;AACzE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,6BAA6B,CAAA;AACnE,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;AACxE,OAAO,EAAE,cAAc,EAAE,KAAK,gBAAgB,EAAE,UAAU,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACrH,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AAC7F,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AACpE,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA"}
@@ -1,8 +0,0 @@
1
- import ExamplePicker_default from "./components/ExamplePicker.vue.js";
2
- import HttpMethod_default from "./components/HttpMethod.vue.js";
3
- import { getResolvedRefDeep } from "./helpers/get-resolved-ref-deep.js";
4
- import { filterClientsByQuery } from "./helpers/filter-clients-by-query.js";
5
- import { DEFAULT_CLIENT, findClient, isClient, isSelectedClient } from "./helpers/find-client.js";
6
- import { generateClientOptions, getCustomClientIds } from "./helpers/generate-client-options.js";
7
- import OperationCodeSample_default from "./components/OperationCodeSample.vue.js";
8
- export { DEFAULT_CLIENT, ExamplePicker_default as ExamplePicker, HttpMethod_default as HttpMethod, OperationCodeSample_default as OperationCodeSample, filterClientsByQuery, findClient, generateClientOptions, getCustomClientIds, getResolvedRefDeep, isClient, isSelectedClient };
@@ -1,46 +0,0 @@
1
- import type { ScalarComboboxOption, ScalarComboboxOptionGroup } from '@scalar/components/combobox';
2
- import type { AvailableClients, ClientId, TargetId } from '@scalar/snippetz';
3
- /**
4
- * Represents a client option in the request example block.
5
- * Extends the base combobox option with language-specific information
6
- * for generating code examples in different programming languages.
7
- */
8
- export type ClientOption = ScalarComboboxOption & {
9
- /** A more specific ID */
10
- id: AvailableClients[number];
11
- /** Programming language or tool for code generation (e.g., 'javascript', 'python', 'curl') */
12
- lang: TargetId | 'curl' | 'plaintext';
13
- /** Title shows when the client is selected in the dropdown */
14
- title: string;
15
- /** Target key for the client, differs from the lang due to the curl thing */
16
- targetKey: TargetId;
17
- /** Title of the target */
18
- targetTitle: string;
19
- /** Client key for the client */
20
- clientKey: ClientId<TargetId>;
21
- };
22
- /**
23
- * Augments the base combobox option group with ClientOptions
24
- */
25
- export type ClientOptionGroup = ScalarComboboxOptionGroup<ClientOption> & {
26
- /** Key of the group */
27
- key: TargetId;
28
- };
29
- /** Better type safety when we have custom clients in the selector */
30
- export type CustomClientOption = ScalarComboboxOption & {
31
- /** A custom ID */
32
- id: `custom/${string}`;
33
- /** Programming language or tool for code generation (e.g., 'javascript', 'python', 'curl') */
34
- lang: TargetId | 'curl' | 'plaintext';
35
- /** Title shows when the client is selected in the dropdown */
36
- title: string;
37
- /** Client key for the client */
38
- clientKey: 'custom';
39
- };
40
- export type CustomOrDefaultClientOption = ClientOption | CustomClientOption;
41
- /** Augments the base combobox option group with CustomClientOptions */
42
- export type CustomClientOptionGroup = ScalarComboboxOptionGroup<CustomOrDefaultClientOption> & {
43
- /** Key of the group */
44
- key: 'custom' | TargetId;
45
- };
46
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/v2/bl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B,CAAA"}
@@ -1,13 +0,0 @@
1
- import type { ExampleObject, ParameterObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
2
- /**
3
- * Determines if a parameter is disabled
4
- *
5
- * First we explicitly check if its been disabled via the `x-disabled` extension.
6
- * Then we check if its an optional parameter and not a path parameter.
7
- *
8
- * @param param - The parameter to check.
9
- * @param example - The example to check.
10
- * @returns true if the parameter is disabled, false otherwise.
11
- */
12
- export declare const isParamDisabled: (param: ParameterObject, example: ExampleObject | undefined, defaultDisabled?: boolean) => boolean;
13
- //# sourceMappingURL=is-param-disabled.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-param-disabled.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/request-block/helpers/is-param-disabled.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,8DAA8D,CAAA;AAElH;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,eAAe,EACtB,SAAS,aAAa,GAAG,SAAS,EAClC,kBAAiB,OAAc,YAgBhC,CAAA"}
@@ -1,21 +0,0 @@
1
- //#region src/v2/blocks/request-block/helpers/is-param-disabled.ts
2
- /**
3
- * Determines if a parameter is disabled
4
- *
5
- * First we explicitly check if its been disabled via the `x-disabled` extension.
6
- * Then we check if its an optional parameter and not a path parameter.
7
- *
8
- * @param param - The parameter to check.
9
- * @param example - The example to check.
10
- * @returns true if the parameter is disabled, false otherwise.
11
- */
12
- var isParamDisabled = (param, example, defaultDisabled = true) => {
13
- const xDisabled = example?.["x-disabled"];
14
- if (typeof xDisabled === "boolean") return xDisabled;
15
- if (!defaultDisabled) return false;
16
- return !param.required && param.in !== "path";
17
- };
18
- //#endregion
19
- export { isParamDisabled };
20
-
21
- //# sourceMappingURL=is-param-disabled.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-param-disabled.js","names":[],"sources":["../../../../../src/v2/blocks/request-block/helpers/is-param-disabled.ts"],"sourcesContent":["import type { ExampleObject, ParameterObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\n/**\n * Determines if a parameter is disabled\n *\n * First we explicitly check if its been disabled via the `x-disabled` extension.\n * Then we check if its an optional parameter and not a path parameter.\n *\n * @param param - The parameter to check.\n * @param example - The example to check.\n * @returns true if the parameter is disabled, false otherwise.\n */\nexport const isParamDisabled = (\n param: ParameterObject,\n example: ExampleObject | undefined,\n defaultDisabled: boolean = true,\n) => {\n const xDisabled = example?.['x-disabled']\n\n // If x-disabled is explicitly set (true or false), use that value\n if (typeof xDisabled === 'boolean') {\n return xDisabled\n }\n\n // If the parameter is not disabled by default, return false\n if (!defaultDisabled) {\n return false\n }\n\n // Otherwise, disable optional parameters (except path parameters which are always required)\n return !param.required && param.in !== 'path'\n}\n"],"mappings":";;;;;;;;;;;AAYA,IAAa,mBACX,OACA,SACA,kBAA2B,SACxB;CACH,MAAM,YAAY,UAAU;AAG5B,KAAI,OAAO,cAAc,UACvB,QAAO;AAIT,KAAI,CAAC,gBACH,QAAO;AAIT,QAAO,CAAC,MAAM,YAAY,MAAM,OAAO"}