@scalar/api-client 3.0.0 → 3.1.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 (96) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +41 -0
  3. package/dist/plugins/posthog/index.d.ts +23 -0
  4. package/dist/plugins/posthog/index.d.ts.map +1 -0
  5. package/dist/plugins/posthog/index.js +58 -0
  6. package/dist/plugins/posthog/index.js.map +1 -0
  7. package/dist/style.css +78 -18
  8. package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts.map +1 -1
  9. package/dist/v2/blocks/operation-block/OperationBlock.vue.js.map +1 -1
  10. package/dist/v2/blocks/operation-block/OperationBlock.vue.script.js +14 -12
  11. package/dist/v2/blocks/operation-block/OperationBlock.vue.script.js.map +1 -1
  12. package/dist/v2/blocks/operation-block/helpers/decode-buffer.d.ts +5 -2
  13. package/dist/v2/blocks/operation-block/helpers/decode-buffer.d.ts.map +1 -1
  14. package/dist/v2/blocks/operation-block/helpers/decode-buffer.js +5 -2
  15. package/dist/v2/blocks/operation-block/helpers/decode-buffer.js.map +1 -1
  16. package/dist/v2/blocks/operation-block/helpers/har-to-fetch-request.d.ts +8 -9
  17. package/dist/v2/blocks/operation-block/helpers/har-to-fetch-request.d.ts.map +1 -1
  18. package/dist/v2/blocks/operation-block/helpers/har-to-fetch-request.js +8 -10
  19. package/dist/v2/blocks/operation-block/helpers/har-to-fetch-request.js.map +1 -1
  20. package/dist/v2/blocks/operation-block/helpers/response-cache.d.ts +2 -1
  21. package/dist/v2/blocks/operation-block/helpers/response-cache.d.ts.map +1 -1
  22. package/dist/v2/blocks/operation-block/helpers/response-cache.js.map +1 -1
  23. package/dist/v2/blocks/operation-block/helpers/send-request.d.ts +7 -3
  24. package/dist/v2/blocks/operation-block/helpers/send-request.d.ts.map +1 -1
  25. package/dist/v2/blocks/operation-block/helpers/send-request.js +19 -12
  26. package/dist/v2/blocks/operation-block/helpers/send-request.js.map +1 -1
  27. package/dist/v2/blocks/request-block/RequestBlock.vue.script.js +1 -1
  28. package/dist/v2/blocks/request-block/RequestBlock.vue.script.js.map +1 -1
  29. package/dist/v2/blocks/request-block/helpers/get-default-headers.js +1 -1
  30. package/dist/v2/blocks/response-block/ResponseBlock.vue.d.ts +3 -2
  31. package/dist/v2/blocks/response-block/ResponseBlock.vue.d.ts.map +1 -1
  32. package/dist/v2/blocks/response-block/ResponseBlock.vue.js +1 -1
  33. package/dist/v2/blocks/response-block/ResponseBlock.vue.js.map +1 -1
  34. package/dist/v2/blocks/response-block/ResponseBlock.vue.script.js +12 -6
  35. package/dist/v2/blocks/response-block/ResponseBlock.vue.script.js.map +1 -1
  36. package/dist/v2/blocks/response-block/components/ResponseBody.vue.d.ts +2 -0
  37. package/dist/v2/blocks/response-block/components/ResponseBody.vue.d.ts.map +1 -1
  38. package/dist/v2/blocks/response-block/components/ResponseBody.vue.js +1 -1
  39. package/dist/v2/blocks/response-block/components/ResponseBody.vue.js.map +1 -1
  40. package/dist/v2/blocks/response-block/components/ResponseBody.vue.script.js +34 -14
  41. package/dist/v2/blocks/response-block/components/ResponseBody.vue.script.js.map +1 -1
  42. package/dist/v2/blocks/response-block/helpers/process-response-body.d.ts +1 -1
  43. package/dist/v2/blocks/response-block/helpers/process-response-body.js +2 -3
  44. package/dist/v2/blocks/response-block/helpers/process-response-body.js.map +1 -1
  45. package/dist/v2/blocks/response-block/helpers/resolve-response-body-handler.d.ts +11 -0
  46. package/dist/v2/blocks/response-block/helpers/resolve-response-body-handler.d.ts.map +1 -0
  47. package/dist/v2/blocks/response-block/helpers/resolve-response-body-handler.js +44 -0
  48. package/dist/v2/blocks/response-block/helpers/resolve-response-body-handler.js.map +1 -0
  49. package/dist/v2/blocks/response-block/helpers/resolve-response-content-type.d.ts +14 -0
  50. package/dist/v2/blocks/response-block/helpers/resolve-response-content-type.d.ts.map +1 -0
  51. package/dist/v2/blocks/response-block/helpers/resolve-response-content-type.js +13 -0
  52. package/dist/v2/blocks/response-block/helpers/resolve-response-content-type.js.map +1 -0
  53. package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.script.js.map +1 -1
  54. package/dist/v2/constants.js +1 -1
  55. package/dist/v2/features/app/App.vue.d.ts.map +1 -1
  56. package/dist/v2/features/app/App.vue.js.map +1 -1
  57. package/dist/v2/features/app/App.vue.script.js +15 -3
  58. package/dist/v2/features/app/App.vue.script.js.map +1 -1
  59. package/dist/v2/features/app/helpers/create-temp-operation.d.ts.map +1 -1
  60. package/dist/v2/features/app/helpers/create-temp-operation.js +4 -1
  61. package/dist/v2/features/app/helpers/create-temp-operation.js.map +1 -1
  62. package/dist/v2/features/collection/components/Runner/hooks/use-runner-execution.js +1 -1
  63. package/dist/v2/features/collection/components/Runner/hooks/use-runner-execution.js.map +1 -1
  64. package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.d.ts.map +1 -1
  65. package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.js.map +1 -1
  66. package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.script.js +1 -1
  67. package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.script.js.map +1 -1
  68. package/dist/v2/features/command-palette/components/CommandPaletteImportPostman.vue.d.ts.map +1 -1
  69. package/dist/v2/features/command-palette/components/CommandPaletteImportPostman.vue.js.map +1 -1
  70. package/dist/v2/features/command-palette/components/CommandPaletteImportPostman.vue.script.js +26 -21
  71. package/dist/v2/features/command-palette/components/CommandPaletteImportPostman.vue.script.js.map +1 -1
  72. package/dist/v2/features/command-palette/components/PostmanImportPreview.vue.js +1 -1
  73. package/dist/v2/features/command-palette/components/PostmanImportPreview.vue.js.map +1 -1
  74. package/dist/v2/features/command-palette/components/PostmanImportPreview.vue.script.js +1 -1
  75. package/dist/v2/features/command-palette/components/PostmanImportPreview.vue.script.js.map +1 -1
  76. package/dist/v2/features/command-palette/helpers/get-postman-convert-options.d.ts +14 -0
  77. package/dist/v2/features/command-palette/helpers/get-postman-convert-options.d.ts.map +1 -0
  78. package/dist/v2/features/command-palette/helpers/get-postman-convert-options.js +19 -0
  79. package/dist/v2/features/command-palette/helpers/get-postman-convert-options.js.map +1 -0
  80. package/dist/v2/features/command-palette/helpers/get-postman-document-details.js +1 -1
  81. package/dist/v2/features/command-palette/helpers/get-postman-document-details.js.map +1 -1
  82. package/dist/v2/features/command-palette/helpers/load-document-from-source.d.ts.map +1 -1
  83. package/dist/v2/features/command-palette/helpers/load-document-from-source.js +1 -1
  84. package/dist/v2/features/command-palette/helpers/load-document-from-source.js.map +1 -1
  85. package/dist/v2/features/modal/helpers/create-api-client-modal.d.ts.map +1 -1
  86. package/dist/v2/features/modal/helpers/create-api-client-modal.js +11 -0
  87. package/dist/v2/features/modal/helpers/create-api-client-modal.js.map +1 -1
  88. package/package.json +19 -14
  89. package/dist/v2/features/command-palette/helpers/is-postman-collection.d.ts +0 -11
  90. package/dist/v2/features/command-palette/helpers/is-postman-collection.d.ts.map +0 -1
  91. package/dist/v2/features/command-palette/helpers/is-postman-collection.js +0 -24
  92. package/dist/v2/features/command-palette/helpers/is-postman-collection.js.map +0 -1
  93. package/dist/v2/posthog.d.ts +0 -3
  94. package/dist/v2/posthog.d.ts.map +0 -1
  95. package/dist/v2/posthog.js +0 -20
  96. package/dist/v2/posthog.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"OperationBlock.vue.script.js","names":[],"sources":["../../../../src/v2/blocks/operation-block/OperationBlock.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * OperationBlock\n *\n * Orchestrates the operation view by wiring together the Header, OperationBlock,\n * and ResponseBlock. Forwards user interactions to the workspace event bus and\n * passes through configuration such as auth, servers, plugins, and environment.\n * This component keeps the Operation page lean by centralizing event emission\n * and prop wiring between the blocks.\n *\n * Notable behavior:\n * - Uses operation['x-scalar-method'] and operation['x-scalar-path'] to provide\n * draft overrides for the UI when present.\n */\nexport default {\n name: 'OperationBlock',\n}\n\nexport type OperationBlockProps = {\n /** Event bus */\n eventBus: WorkspaceEventBus\n /** Application version */\n appVersion: string\n /** Openapi document */\n document: OpenApiDocument\n /** Workspace cookies */\n workspaceCookies: XScalarCookie[]\n /** Document cookies */\n documentCookies: XScalarCookie[]\n /** Current request path */\n path: string\n /** Current request method */\n method: HttpMethodType\n /** HTTP clients */\n httpClients: AvailableClients\n /** The history for the operation */\n history?: HistoryEntry[]\n /** Client layout */\n layout: ClientLayout\n /** Currently selected server */\n server: ServerObject | null\n /** Currently selected client */\n selectedClient: WorkspaceStore['workspace']['x-scalar-default-client']\n /** Server list available for operation/document */\n servers: ServerObject[]\n /** Meta information for the server */\n serverMeta: ServerMeta\n /** Hides the client button on the header */\n hideClientButton?: boolean\n /** Client integration */\n integration?: string | null\n /** Openapi document url for `modal` mode to open the client app */\n documentUrl?: string\n /** Client source */\n source?: 'gitbook' | 'api-reference'\n /** Operation object */\n operation: OperationObject\n /** Currently selected example key for the current operation */\n exampleKey: string\n /** Meta information for the auth update */\n authMeta: AuthMeta\n /** Document defined security schemes */\n securitySchemes: MergedSecuritySchemes\n /** Client plugins */\n plugins: ClientPlugin[]\n /** Environment list */\n environments?: string[]\n /** Currently selected environment */\n activeEnvironment?: string\n /** For environment variables in the inputs */\n environment: XScalarEnvironment\n /** The proxy URL for sending requests */\n proxyUrl: string\n /** Currently selected security */\n selectedSecurity: SelectedSecurity\n /** Currently selected security schemes */\n selectedSecuritySchemes: SecuritySchemeObjectSecret[]\n /** Security requirements */\n securityRequirements: OpenApiDocument['security']\n /** Default headers */\n defaultHeaders: Record<string, string>\n /** Selected anyOf/oneOf request-body variants keyed by schema path */\n requestBodyCompositionSelection?: Record<string, number>\n /** Subset of config options for the modal */\n options?: ModalProps['options']\n}\n</script>\n<script setup lang=\"ts\">\nimport { ERRORS } from '@scalar/helpers/errors/normalize-error'\nimport { isElectron } from '@scalar/helpers/general/is-electron'\nimport type { HttpMethod as HttpMethodType } from '@scalar/helpers/http/http-methods'\nimport { executeHook, type ClientPlugin } from '@scalar/oas-utils/helpers'\nimport {\n AVAILABLE_CLIENTS,\n type AvailableClients,\n} from '@scalar/types/snippetz'\nimport { useToasts } from '@scalar/use-toasts'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport type { SelectedSecurity } from '@scalar/workspace-store/entities/auth'\nimport type { HistoryEntry } from '@scalar/workspace-store/entities/history/schema'\nimport type {\n AuthMeta,\n ServerMeta,\n WorkspaceEventBus,\n} from '@scalar/workspace-store/events'\nimport {\n buildRequest,\n createVariablesStoreForRequest,\n getEnvironmentVariables,\n requestFactory,\n type MergedSecuritySchemes,\n type SecuritySchemeObjectSecret,\n} from '@scalar/workspace-store/request-example'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport type {\n OpenApiDocument,\n ServerObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport type { OperationObject } from '@scalar/workspace-store/schemas/v3.1/strict/operation'\nimport { computed, onBeforeUnmount, onMounted, ref, toValue, watch } from 'vue'\n\nimport ViewLayout from '@/components/ViewLayout/ViewLayout.vue'\nimport ViewLayoutContent from '@/components/ViewLayout/ViewLayoutContent.vue'\nimport { harToFetchRequest } from '@/v2/blocks/operation-block/helpers/har-to-fetch-request'\nimport { harToFetchResponse } from '@/v2/blocks/operation-block/helpers/har-to-fetch-response'\nimport {\n getOperationExampleKey,\n isStreamingResponse,\n responseCache,\n} from '@/v2/blocks/operation-block/helpers/response-cache'\nimport {\n sendRequest,\n type ResponseInstance,\n} from '@/v2/blocks/operation-block/helpers/send-request'\nimport { validatePathParameters } from '@/v2/blocks/operation-block/helpers/validate-path-parameters'\nimport { generateClientOptions } from '@/v2/blocks/operation-code-sample'\nimport { RequestBlock } from '@/v2/blocks/request-block'\nimport { ResponseBlock } from '@/v2/blocks/response-block'\nimport { type History } from '@/v2/blocks/scalar-address-bar-block'\nimport type { ModalProps } from '@/v2/features/modal/Modal.vue'\nimport type { ClientLayout } from '@/v2/types/layout'\n\nimport Header from './components/Header.vue'\n\nconst {\n authMeta,\n environment,\n eventBus,\n exampleKey,\n document,\n workspaceCookies = [],\n documentCookies = [],\n hideClientButton,\n httpClients = AVAILABLE_CLIENTS,\n history = [],\n method,\n operation,\n path,\n plugins = [],\n proxyUrl,\n requestBodyCompositionSelection,\n securitySchemes,\n selectedClient,\n server,\n environments,\n options,\n activeEnvironment,\n serverMeta,\n selectedSecurity,\n selectedSecuritySchemes,\n securityRequirements,\n defaultHeaders,\n} = defineProps<OperationBlockProps>()\n\n/** Hoist up client generation so it doesn't get re-generated on every operation */\nconst clientOptions = computed(() => generateClientOptions(httpClients))\n\nconst { toast } = useToasts()\n\n// Refs\nconst abortController = ref<AbortController | null>(null)\nconst response = ref<ResponseInstance | null>(null)\nconst request = ref<Request | null>(null)\n\n/** Cancel the request */\nconst cancelRequest = () => abortController.value?.abort(ERRORS.REQUEST_ABORTED)\n\n/** Execute the current operation example */\nconst handleExecute = async () => {\n const pathValidation = validatePathParameters(\n operation.parameters ?? [],\n exampleKey,\n )\n if (pathValidation.ok === false) {\n toast('Path parameters must have values.', 'error')\n return\n }\n\n const globalCookies = [...workspaceCookies, ...documentCookies]\n\n const { request: requestBuilder } = requestFactory({\n defaultHeaders,\n environment,\n exampleName: exampleKey,\n globalCookies,\n method,\n operation,\n path,\n proxyUrl,\n server,\n selectedSecuritySchemes,\n isElectron: isElectron(),\n requestBodyCompositionSelection,\n })\n\n // Stop any previous streaming response\n if (response.value && 'reader' in response.value) {\n response.value.reader.cancel()\n }\n\n const variablesStore = createVariablesStoreForRequest()\n\n // Execute the beforeRequest hook (plugins receive RequestFactory, not fetch Request)\n await executeHook(\n {\n requestBuilder,\n document,\n operation,\n variablesStore,\n },\n 'beforeRequest',\n plugins,\n )\n\n const envVariables = {\n ...getEnvironmentVariables(environment),\n ...variablesStore.getVariables(),\n }\n\n // Build the fetch Request after hooks may have mutated the factory\n const requestResult = (() => {\n try {\n return {\n ok: true,\n result: buildRequest(requestBuilder, {\n envVariables,\n }),\n } as const\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n return {\n ok: false,\n error: message,\n } as const\n }\n })()\n\n if (requestResult.ok === false) {\n toast(requestResult.error, 'error')\n return\n }\n\n // Store the abort controller for cancellation\n abortController.value = requestResult.result.controller\n\n // Execute the hooks\n eventBus.emit('hooks:on:request:sent', {\n meta: {\n method,\n path,\n exampleKey,\n },\n })\n\n /** Execute the request */\n const [sendError, sendResult] = await sendRequest({\n isUsingProxy: requestResult.result.isUsingProxy,\n request: requestResult.result.request,\n })\n\n if (sendResult) {\n // Execute the responseReceived hook\n await executeHook(\n {\n response: sendResult.originalResponse.clone(),\n requestBuilder,\n request: sendResult.request.clone(),\n document,\n operation,\n variablesStore,\n },\n 'responseReceived',\n plugins,\n )\n }\n\n // Execute the hooks\n eventBus.emit('hooks:on:request:complete', {\n payload: sendResult\n ? {\n response: sendResult.originalResponse.clone(),\n request: sendResult.request.clone(),\n duration: sendResult.response.duration,\n timestamp: sendResult.timestamp,\n }\n : undefined,\n meta: {\n method,\n path,\n exampleKey,\n },\n })\n\n if (sendError) {\n // clean up the response and request\n response.value = null\n request.value = null\n abortController.value = null\n\n toast(sendError.message, 'error')\n return\n }\n\n // Store the response\n response.value = sendResult.response\n request.value = sendResult.request\n\n // Cache non-streaming responses so they can be restored when navigating back\n if (!isStreamingResponse(sendResult.response)) {\n responseCache.set(getOperationExampleKey(method, path, exampleKey), {\n response: sendResult.response,\n request: sendResult.request,\n })\n }\n}\n\nonMounted(() => {\n eventBus.on('operation:send:request:hotkey', handleExecute)\n eventBus.on('operation:cancel:request', cancelRequest)\n})\nonBeforeUnmount(() => {\n eventBus.off('operation:send:request:hotkey', handleExecute)\n eventBus.off('operation:cancel:request', cancelRequest)\n})\n\nconst operationHistory = computed<History[]>(() =>\n history\n .map((entry) => ({\n method: entry.request.method as HttpMethodType,\n path: entry.request.url,\n duration: entry.time,\n status: entry.response.status,\n }))\n .reverse(),\n)\n\nconst handleSelectHistoryItem = ({ index }: { index: number }) => {\n const transformedIndex = (history.length ?? 0) - index - 1\n const historyItem = history[transformedIndex]\n if (!historyItem) {\n return\n }\n\n const navigate = () =>\n eventBus.emit('ui:navigate', {\n page: 'example',\n method,\n path,\n exampleName: 'draft',\n callback: (status) => {\n // Do not replace the response if the navigation was not successful\n if (status !== 'success') {\n return\n }\n // Reconstruct the response\n const fetchResponse = harToFetchResponse({\n harResponse: historyItem.response,\n url: historyItem.request.url,\n method,\n path,\n duration: historyItem.time,\n })\n\n // Reconstruct the request\n const fetchRequest = harToFetchRequest({\n harRequest: historyItem.request,\n })\n\n // Update the response and request\n response.value = fetchResponse\n request.value = fetchRequest\n },\n })\n\n eventBus.emit('operation:reload:history', {\n meta: {\n path,\n method,\n },\n index: transformedIndex,\n callback: navigate,\n })\n}\n\n/**\n * When the path, method, or example key changes: save current response to\n * cache (so it can be restored when navigating back), then restore from cache\n * for the new operation or clear if no cached response. Response is only\n * cleared on page refresh or when making a new request for that operation.\n */\nwatch(\n [() => path, () => method, () => exampleKey],\n ([newPath, newMethod, newExampleKey]) => {\n const newKey = getOperationExampleKey(newMethod, newPath, newExampleKey)\n const cached = responseCache.get(newKey)\n if (cached) {\n response.value = cached.response\n request.value = cached.request\n } else {\n response.value = null\n request.value = null\n }\n\n // Cancel any in-flight request\n cancelRequest()\n },\n { immediate: true },\n)\n\nonBeforeUnmount(() => {\n // We cancel the request if the component is unmounted\n cancelRequest()\n})\n</script>\n<template>\n <div class=\"bg-b-1 flex h-full flex-col\">\n <div\n class=\"lg:min-h-header flex w-full flex-wrap items-center justify-center p-2 lg:p-0\">\n <!-- Address Bar -->\n <Header\n :activeEnvironment\n :documentUrl\n :environment\n :environments\n :eventBus\n :hideClientButton\n :history=\"operationHistory\"\n :integration\n :layout\n :method\n :path\n :server\n :serverMeta\n :servers\n :source\n @execute=\"handleExecute\"\n @select:history:item=\"handleSelectHistoryItem\" />\n </div>\n\n <ViewLayout class=\"border-t\">\n <ViewLayoutContent class=\"flex-1\">\n <!-- Request Section -->\n <RequestBlock\n :authMeta\n :clientOptions\n :defaultHeaders\n :documentCookies\n :environment\n :eventBus\n :exampleKey\n :layout\n :method\n :operation\n :options=\"toValue(options)\"\n :path\n :plugins\n :proxyUrl\n :requestBodyCompositionSelection\n :securityRequirements\n :securitySchemes\n :selectedClient\n :selectedSecurity\n :selectedSecuritySchemes\n :server\n :workspaceCookies />\n\n <!-- Response Section -->\n <ResponseBlock\n :appVersion\n :eventBus\n :layout\n :plugins\n :request\n :response\n :totalPerformedRequests=\"operationHistory.length\" />\n </ViewLayoutContent>\n </ViewLayout>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;CAeE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiKR,MAAM,gBAAgB,eAAe,sBAAsB,QAAA,YAAY,CAAA;EAEvE,MAAM,EAAE,UAAU,WAAU;EAG5B,MAAM,kBAAkB,IAA4B,KAAI;EACxD,MAAM,WAAW,IAA6B,KAAI;EAClD,MAAM,UAAU,IAAoB,KAAI;;EAGxC,MAAM,sBAAsB,gBAAgB,OAAO,MAAM,OAAO,gBAAe;;EAG/E,MAAM,gBAAgB,YAAY;AAKhC,OAJuB,uBACrB,QAAA,UAAU,cAAc,EAAE,EAC1B,QAAA,WACF,CACmB,OAAO,OAAO;AAC/B,UAAM,qCAAqC,QAAO;AAClD;;GAGF,MAAM,gBAAgB,CAAC,GAAG,QAAA,kBAAkB,GAAG,QAAA,gBAAe;GAE9D,MAAM,EAAE,SAAS,mBAAmB,eAAe;IACjD,gBAAa,QAAA;IACb,aAAU,QAAA;IACV,aAAa,QAAA;IACb;IACA,QAAK,QAAA;IACL,WAAQ,QAAA;IACR,MAAG,QAAA;IACH,UAAO,QAAA;IACP,QAAK,QAAA;IACL,yBAAsB,QAAA;IACtB,YAAY,YAAY;IACxB,iCAA8B,QAAA;IAC/B,CAAA;AAGD,OAAI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AAA;MACA,iCAAA,QAAA;MACA,sBAAA,QAAA;MACA,iBAAA,QAAA;MACA,gBAAA,QAAA;MACA,kBAAA,QAAA;MACA,yBAAA,QAAA;MACA,QAAA,QAAA;MACA,kBAAA,QAAA;;;;;;;;;;;;;;;;;;;;;;;;SAGH,YAOsD,MAAA,sBAAA,EAAA;MANnD,YAAA,QAAA;MACA,UAAA,QAAA;MACA,QAAA,QAAA;MACA,SAAA,QAAA;MACA,SAAA,QAAA;MACA,UAAA,SAAA;MACA,wBAAwB,iBAAA,MAAiB"}
1
+ {"version":3,"file":"OperationBlock.vue.script.js","names":[],"sources":["../../../../src/v2/blocks/operation-block/OperationBlock.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * OperationBlock\n *\n * Orchestrates the operation view by wiring together the Header, OperationBlock,\n * and ResponseBlock. Forwards user interactions to the workspace event bus and\n * passes through configuration such as auth, servers, plugins, and environment.\n * This component keeps the Operation page lean by centralizing event emission\n * and prop wiring between the blocks.\n *\n * Notable behavior:\n * - Uses operation['x-scalar-method'] and operation['x-scalar-path'] to provide\n * draft overrides for the UI when present.\n */\nexport default {\n name: 'OperationBlock',\n}\n\nexport type OperationBlockProps = {\n /** Event bus */\n eventBus: WorkspaceEventBus\n /** Application version */\n appVersion: string\n /** Openapi document */\n document: OpenApiDocument\n /** Workspace cookies */\n workspaceCookies: XScalarCookie[]\n /** Document cookies */\n documentCookies: XScalarCookie[]\n /** Current request path */\n path: string\n /** Current request method */\n method: HttpMethodType\n /** HTTP clients */\n httpClients: AvailableClients\n /** The history for the operation */\n history?: HistoryEntry[]\n /** Client layout */\n layout: ClientLayout\n /** Currently selected server */\n server: ServerObject | null\n /** Currently selected client */\n selectedClient: WorkspaceStore['workspace']['x-scalar-default-client']\n /** Server list available for operation/document */\n servers: ServerObject[]\n /** Meta information for the server */\n serverMeta: ServerMeta\n /** Hides the client button on the header */\n hideClientButton?: boolean\n /** Client integration */\n integration?: string | null\n /** Openapi document url for `modal` mode to open the client app */\n documentUrl?: string\n /** Client source */\n source?: 'gitbook' | 'api-reference'\n /** Operation object */\n operation: OperationObject\n /** Currently selected example key for the current operation */\n exampleKey: string\n /** Meta information for the auth update */\n authMeta: AuthMeta\n /** Document defined security schemes */\n securitySchemes: MergedSecuritySchemes\n /** Client plugins */\n plugins: ClientPlugin[]\n /** Environment list */\n environments?: string[]\n /** Currently selected environment */\n activeEnvironment?: string\n /** For environment variables in the inputs */\n environment: XScalarEnvironment\n /** The proxy URL for sending requests */\n proxyUrl: string\n /** Currently selected security */\n selectedSecurity: SelectedSecurity\n /** Currently selected security schemes */\n selectedSecuritySchemes: SecuritySchemeObjectSecret[]\n /** Security requirements */\n securityRequirements: OpenApiDocument['security']\n /** Default headers */\n defaultHeaders: Record<string, string>\n /** Selected anyOf/oneOf request-body variants keyed by schema path */\n requestBodyCompositionSelection?: Record<string, number>\n /** Subset of config options for the modal */\n options?: ModalProps['options']\n}\n</script>\n<script setup lang=\"ts\">\nimport { ERRORS } from '@scalar/helpers/errors/normalize-error'\nimport { isElectron } from '@scalar/helpers/general/is-electron'\nimport { buildSafeBodyRequest } from '@scalar/helpers/http/can-method-have-body'\nimport type { HttpMethod as HttpMethodType } from '@scalar/helpers/http/http-methods'\nimport { executeHook, type ClientPlugin } from '@scalar/oas-utils/helpers'\nimport {\n AVAILABLE_CLIENTS,\n type AvailableClients,\n} from '@scalar/types/snippetz'\nimport { useToasts } from '@scalar/use-toasts'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport type { SelectedSecurity } from '@scalar/workspace-store/entities/auth'\nimport type { HistoryEntry } from '@scalar/workspace-store/entities/history/schema'\nimport type {\n AuthMeta,\n ServerMeta,\n WorkspaceEventBus,\n} from '@scalar/workspace-store/events'\nimport {\n buildRequest,\n createVariablesStoreForRequest,\n getEnvironmentVariables,\n requestFactory,\n type MergedSecuritySchemes,\n type RequestPayload,\n type SecuritySchemeObjectSecret,\n} from '@scalar/workspace-store/request-example'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport type {\n OpenApiDocument,\n ServerObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport type { OperationObject } from '@scalar/workspace-store/schemas/v3.1/strict/operation'\nimport { computed, onBeforeUnmount, onMounted, ref, toValue, watch } from 'vue'\n\nimport ViewLayout from '@/components/ViewLayout/ViewLayout.vue'\nimport ViewLayoutContent from '@/components/ViewLayout/ViewLayoutContent.vue'\nimport { harToFetchRequest } from '@/v2/blocks/operation-block/helpers/har-to-fetch-request'\nimport { harToFetchResponse } from '@/v2/blocks/operation-block/helpers/har-to-fetch-response'\nimport {\n getOperationExampleKey,\n isStreamingResponse,\n responseCache,\n} from '@/v2/blocks/operation-block/helpers/response-cache'\nimport {\n sendRequest,\n type ResponseInstance,\n} from '@/v2/blocks/operation-block/helpers/send-request'\nimport { validatePathParameters } from '@/v2/blocks/operation-block/helpers/validate-path-parameters'\nimport { generateClientOptions } from '@/v2/blocks/operation-code-sample'\nimport { RequestBlock } from '@/v2/blocks/request-block'\nimport { ResponseBlock } from '@/v2/blocks/response-block'\nimport { type History } from '@/v2/blocks/scalar-address-bar-block'\nimport type { ModalProps } from '@/v2/features/modal/Modal.vue'\nimport type { ClientLayout } from '@/v2/types/layout'\n\nimport Header from './components/Header.vue'\n\nconst {\n authMeta,\n environment,\n eventBus,\n exampleKey,\n document,\n workspaceCookies = [],\n documentCookies = [],\n hideClientButton,\n httpClients = AVAILABLE_CLIENTS,\n history = [],\n method,\n operation,\n path,\n plugins = [],\n proxyUrl,\n requestBodyCompositionSelection,\n securitySchemes,\n selectedClient,\n server,\n environments,\n options,\n activeEnvironment,\n serverMeta,\n selectedSecurity,\n selectedSecuritySchemes,\n securityRequirements,\n defaultHeaders,\n} = defineProps<OperationBlockProps>()\n\n/** Hoist up client generation so it doesn't get re-generated on every operation */\nconst clientOptions = computed(() => generateClientOptions(httpClients))\n\nconst { toast } = useToasts()\n\n// Refs\nconst abortController = ref<AbortController | null>(null)\nconst response = ref<ResponseInstance | null>(null)\nconst requestPayload = ref<RequestPayload | null>(null)\n\n/** Cancel the request */\nconst cancelRequest = () => abortController.value?.abort(ERRORS.REQUEST_ABORTED)\n\n/** Execute the current operation example */\nconst handleExecute = async () => {\n const pathValidation = validatePathParameters(\n operation.parameters ?? [],\n exampleKey,\n )\n if (pathValidation.ok === false) {\n toast('Path parameters must have values.', 'error')\n return\n }\n\n const globalCookies = [...workspaceCookies, ...documentCookies]\n\n const { request: requestBuilder } = requestFactory({\n defaultHeaders,\n environment,\n exampleName: exampleKey,\n globalCookies,\n method,\n operation,\n path,\n proxyUrl,\n server,\n selectedSecuritySchemes,\n isElectron: isElectron(),\n requestBodyCompositionSelection,\n })\n\n // Stop any previous streaming response\n if (response.value && 'reader' in response.value) {\n response.value.reader.cancel()\n }\n\n const variablesStore = createVariablesStoreForRequest()\n\n // Execute the beforeRequest hook (plugins receive RequestFactory, not fetch Request)\n await executeHook(\n {\n requestBuilder,\n document,\n operation,\n variablesStore,\n },\n 'beforeRequest',\n plugins,\n )\n\n const envVariables = {\n ...getEnvironmentVariables(environment),\n ...variablesStore.getVariables(),\n }\n\n // Build the fetch Request after hooks may have mutated the factory\n const requestResult = (() => {\n try {\n return {\n ok: true,\n result: buildRequest(requestBuilder, {\n envVariables,\n }),\n } as const\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n return {\n ok: false,\n error: message,\n } as const\n }\n })()\n\n if (requestResult.ok === false) {\n toast(requestResult.error, 'error')\n return\n }\n\n // Store the abort controller for cancellation\n abortController.value = requestResult.result.controller\n\n // Execute the hooks\n eventBus.emit('hooks:on:request:sent', {\n meta: {\n method,\n path,\n exampleKey,\n },\n })\n\n /** Execute the request */\n const [sendError, sendResult] = await sendRequest({\n isUsingProxy: requestResult.result.isUsingProxy,\n requestPayload: requestResult.result.requestPayload,\n plugins,\n })\n\n if (sendResult) {\n // Execute the responseReceived hook\n await executeHook(\n {\n response: sendResult.originalResponse.clone(),\n requestBuilder,\n request: buildSafeBodyRequest(...sendResult.requestPayload),\n document,\n operation,\n variablesStore,\n },\n 'responseReceived',\n plugins,\n )\n }\n\n // Execute the hooks\n eventBus.emit('hooks:on:request:complete', {\n payload: sendResult\n ? {\n response: sendResult.originalResponse.clone(),\n requestPayload: sendResult.requestPayload,\n duration: sendResult.response.duration,\n timestamp: sendResult.timestamp,\n }\n : undefined,\n meta: {\n method,\n path,\n exampleKey,\n },\n })\n\n if (sendError) {\n // clean up the response and request\n response.value = null\n requestPayload.value = null\n abortController.value = null\n\n toast(sendError.message, 'error')\n return\n }\n\n // Store the response\n response.value = sendResult.response\n requestPayload.value = sendResult.requestPayload\n\n // Cache non-streaming responses so they can be restored when navigating back\n if (!isStreamingResponse(sendResult.response)) {\n responseCache.set(getOperationExampleKey(method, path, exampleKey), {\n response: sendResult.response,\n requestPayload: sendResult.requestPayload,\n })\n }\n}\n\nonMounted(() => {\n eventBus.on('operation:send:request:hotkey', handleExecute)\n eventBus.on('operation:cancel:request', cancelRequest)\n})\nonBeforeUnmount(() => {\n eventBus.off('operation:send:request:hotkey', handleExecute)\n eventBus.off('operation:cancel:request', cancelRequest)\n})\n\nconst operationHistory = computed<History[]>(() =>\n history\n .map((entry) => ({\n method: entry.request.method as HttpMethodType,\n path: entry.request.url,\n duration: entry.time,\n status: entry.response.status,\n }))\n .reverse(),\n)\n\nconst handleSelectHistoryItem = ({ index }: { index: number }) => {\n const transformedIndex = (history.length ?? 0) - index - 1\n const historyItem = history[transformedIndex]\n if (!historyItem) {\n return\n }\n\n const navigate = () =>\n eventBus.emit('ui:navigate', {\n page: 'example',\n method,\n path,\n exampleName: 'draft',\n callback: (status) => {\n // Do not replace the response if the navigation was not successful\n if (status !== 'success') {\n return\n }\n // Reconstruct the response\n const fetchResponse = harToFetchResponse({\n harResponse: historyItem.response,\n url: historyItem.request.url,\n method,\n path,\n duration: historyItem.time,\n })\n\n // Reconstruct the request\n const fetchRequest = harToFetchRequest({\n harRequest: historyItem.request,\n })\n\n // Update the response and request\n response.value = fetchResponse\n requestPayload.value = fetchRequest\n },\n })\n\n eventBus.emit('operation:reload:history', {\n meta: {\n path,\n method,\n },\n index: transformedIndex,\n callback: navigate,\n })\n}\n\n/**\n * When the path, method, or example key changes: save current response to\n * cache (so it can be restored when navigating back), then restore from cache\n * for the new operation or clear if no cached response. Response is only\n * cleared on page refresh or when making a new request for that operation.\n */\nwatch(\n [() => path, () => method, () => exampleKey],\n ([newPath, newMethod, newExampleKey]) => {\n const newKey = getOperationExampleKey(newMethod, newPath, newExampleKey)\n const cached = responseCache.get(newKey)\n if (cached) {\n response.value = cached.response\n requestPayload.value = cached.requestPayload\n } else {\n response.value = null\n requestPayload.value = null\n }\n\n // Cancel any in-flight request\n cancelRequest()\n },\n { immediate: true },\n)\n\nonBeforeUnmount(() => {\n // We cancel the request if the component is unmounted\n cancelRequest()\n})\n</script>\n<template>\n <div class=\"bg-b-1 flex h-full flex-col\">\n <div\n class=\"lg:min-h-header flex w-full flex-wrap items-center justify-center p-2 lg:p-0\">\n <!-- Address Bar -->\n <Header\n :activeEnvironment\n :documentUrl\n :environment\n :environments\n :eventBus\n :hideClientButton\n :history=\"operationHistory\"\n :integration\n :layout\n :method\n :path\n :server\n :serverMeta\n :servers\n :source\n @execute=\"handleExecute\"\n @select:history:item=\"handleSelectHistoryItem\" />\n </div>\n\n <ViewLayout class=\"border-t\">\n <ViewLayoutContent class=\"flex-1\">\n <!-- Request Section -->\n <RequestBlock\n :authMeta\n :clientOptions\n :defaultHeaders\n :documentCookies\n :environment\n :eventBus\n :exampleKey\n :layout\n :method\n :operation\n :options=\"toValue(options)\"\n :path\n :plugins\n :proxyUrl\n :requestBodyCompositionSelection\n :securityRequirements\n :securitySchemes\n :selectedClient\n :selectedSecurity\n :selectedSecuritySchemes\n :server\n :workspaceCookies />\n\n <!-- Response Section -->\n <ResponseBlock\n :appVersion\n :eventBus\n :layout\n :plugins\n :requestPayload\n :response\n :totalPerformedRequests=\"operationHistory.length\" />\n </ViewLayoutContent>\n </ViewLayout>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;CAeE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmKR,MAAM,gBAAgB,eAAe,sBAAsB,QAAA,YAAY,CAAA;EAEvE,MAAM,EAAE,UAAU,WAAU;EAG5B,MAAM,kBAAkB,IAA4B,KAAI;EACxD,MAAM,WAAW,IAA6B,KAAI;EAClD,MAAM,iBAAiB,IAA2B,KAAI;;EAGtD,MAAM,sBAAsB,gBAAgB,OAAO,MAAM,OAAO,gBAAe;;EAG/E,MAAM,gBAAgB,YAAY;AAKhC,OAJuB,uBACrB,QAAA,UAAU,cAAc,EAAE,EAC1B,QAAA,WACF,CACmB,OAAO,OAAO;AAC/B,UAAM,qCAAqC,QAAO;AAClD;;GAGF,MAAM,gBAAgB,CAAC,GAAG,QAAA,kBAAkB,GAAG,QAAA,gBAAe;GAE9D,MAAM,EAAE,SAAS,mBAAmB,eAAe;IACjD,gBAAa,QAAA;IACb,aAAU,QAAA;IACV,aAAa,QAAA;IACb;IACA,QAAK,QAAA;IACL,WAAQ,QAAA;IACR,MAAG,QAAA;IACH,UAAO,QAAA;IACP,QAAK,QAAA;IACL,yBAAsB,QAAA;IACtB,YAAY,YAAY;IACxB,iCAA8B,QAAA;IAC/B,CAAA;AAGD,OAAI,SAAS,SAAS,YAAY,SAAS,MACzC,UAAS,MAAM,OAAO,QAAO;GAG/B,MAAM,iBAAiB,gCAA+B;AAGtD,SAAM,YACJ;IACE;IACA,UAAO,QAAA;IACP,WAAQ,QAAA;IACR;IACD,EACD,iBACA,QAAA,QACF;GAEA,MAAM,eAAe;IACnB,GAAG,wBAAwB,QAAA,YAAY;IACvC,GAAG,eAAe,cAAc;IAClC;GAGA,MAAM,uBAAuB;AAC3B,QAAI;AACF,YAAO;MACL,IAAI;MACJ,QAA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AAA,SAAA;MACA,wBAAwB,iBAAA,MAAiB"}
@@ -1,7 +1,10 @@
1
+ import type { ResponseBodyHandler } from '@scalar/oas-utils/helpers';
1
2
  /**
2
- * Decode the buffer according to its content-type
3
+ * Decode the buffer according to its content-type.
4
+ * When a plugin handler with a custom `decode` function is provided, it takes priority
5
+ * over the default text/binary decoding.
3
6
  *
4
7
  * @returns The decoded string or Blob
5
8
  */
6
- export declare const decodeBuffer: (buffer: ArrayBuffer, contentType: string) => string | Blob;
9
+ export declare const decodeBuffer: (buffer: ArrayBuffer, contentType: string, pluginHandler?: ResponseBodyHandler) => Promise<string | Blob>;
7
10
  //# sourceMappingURL=decode-buffer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"decode-buffer.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-block/helpers/decode-buffer.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,WAAW,EAAE,aAAa,MAAM,KAAG,MAAM,GAAG,IAWhF,CAAA"}
1
+ {"version":3,"file":"decode-buffer.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-block/helpers/decode-buffer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAIpE;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GACvB,QAAQ,WAAW,EACnB,aAAa,MAAM,EACnB,gBAAgB,mBAAmB,KAClC,OAAO,CAAC,MAAM,GAAG,IAAI,CAevB,CAAA"}
@@ -2,12 +2,15 @@ import { isTextMediaType } from "../../response-block/helpers/media-types.js";
2
2
  import { parseMimeType } from "@scalar/helpers/http/mime-type";
3
3
  //#region src/v2/blocks/operation-block/helpers/decode-buffer.ts
4
4
  /**
5
- * Decode the buffer according to its content-type
5
+ * Decode the buffer according to its content-type.
6
+ * When a plugin handler with a custom `decode` function is provided, it takes priority
7
+ * over the default text/binary decoding.
6
8
  *
7
9
  * @returns The decoded string or Blob
8
10
  */
9
- var decodeBuffer = (buffer, contentType) => {
11
+ var decodeBuffer = async (buffer, contentType, pluginHandler) => {
10
12
  const mimeType = parseMimeType(contentType);
13
+ if (pluginHandler?.decode) return await pluginHandler.decode(buffer, contentType);
11
14
  if (isTextMediaType(mimeType.essence)) return new TextDecoder(mimeType.parameters.get("charset")).decode(buffer);
12
15
  return new Blob([buffer], { type: mimeType.essence });
13
16
  };
@@ -1 +1 @@
1
- {"version":3,"file":"decode-buffer.js","names":[],"sources":["../../../../../src/v2/blocks/operation-block/helpers/decode-buffer.ts"],"sourcesContent":["import { parseMimeType } from '@scalar/helpers/http/mime-type'\n\nimport { isTextMediaType } from '@/v2/blocks/response-block/helpers/media-types'\n\n/**\n * Decode the buffer according to its content-type\n *\n * @returns The decoded string or Blob\n */\nexport const decodeBuffer = (buffer: ArrayBuffer, contentType: string): string | Blob => {\n const mimeType = parseMimeType(contentType)\n\n // Text\n if (isTextMediaType(mimeType.essence)) {\n const decoder = new TextDecoder(mimeType.parameters.get('charset'))\n return decoder.decode(buffer)\n }\n\n // Binary\n return new Blob([buffer], { type: mimeType.essence })\n}\n"],"mappings":";;;;;;;;AASA,IAAa,gBAAgB,QAAqB,gBAAuC;CACvF,MAAM,WAAW,cAAc,YAAY;AAG3C,KAAI,gBAAgB,SAAS,QAAQ,CAEnC,QADgB,IAAI,YAAY,SAAS,WAAW,IAAI,UAAU,CAAC,CACpD,OAAO,OAAO;AAI/B,QAAO,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE,MAAM,SAAS,SAAS,CAAC"}
1
+ {"version":3,"file":"decode-buffer.js","names":[],"sources":["../../../../../src/v2/blocks/operation-block/helpers/decode-buffer.ts"],"sourcesContent":["import { parseMimeType } from '@scalar/helpers/http/mime-type'\nimport type { ResponseBodyHandler } from '@scalar/oas-utils/helpers'\n\nimport { isTextMediaType } from '@/v2/blocks/response-block/helpers/media-types'\n\n/**\n * Decode the buffer according to its content-type.\n * When a plugin handler with a custom `decode` function is provided, it takes priority\n * over the default text/binary decoding.\n *\n * @returns The decoded string or Blob\n */\nexport const decodeBuffer = async (\n buffer: ArrayBuffer,\n contentType: string,\n pluginHandler?: ResponseBodyHandler,\n): Promise<string | Blob> => {\n const mimeType = parseMimeType(contentType)\n\n if (pluginHandler?.decode) {\n return await pluginHandler.decode(buffer, contentType)\n }\n\n // Text\n if (isTextMediaType(mimeType.essence)) {\n const decoder = new TextDecoder(mimeType.parameters.get('charset'))\n return decoder.decode(buffer)\n }\n\n // Binary\n return new Blob([buffer], { type: mimeType.essence })\n}\n"],"mappings":";;;;;;;;;;AAYA,IAAa,eAAe,OAC1B,QACA,aACA,kBAC2B;CAC3B,MAAM,WAAW,cAAc,YAAY;AAE3C,KAAI,eAAe,OACjB,QAAO,MAAM,cAAc,OAAO,QAAQ,YAAY;AAIxD,KAAI,gBAAgB,SAAS,QAAQ,CAEnC,QADgB,IAAI,YAAY,SAAS,WAAW,IAAI,UAAU,CAAC,CACpD,OAAO,OAAO;AAI/B,QAAO,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE,MAAM,SAAS,SAAS,CAAC"}
@@ -1,13 +1,14 @@
1
1
  import type { HarRequest } from '@scalar/snippetz';
2
+ import type { RequestPayload } from '@scalar/workspace-store/request-example';
2
3
  type HarToFetchRequestProps = {
3
4
  /** The HAR Request object to convert */
4
5
  harRequest: HarRequest;
5
6
  };
6
7
  /**
7
- * Converts a HAR (HTTP Archive) Request to a Fetch API Request object.
8
+ * Converts a HAR (HTTP Archive) Request to a RequestPayload [url, RequestInit] tuple for use with fetch().
8
9
  *
9
10
  * This function is the reverse of fetchRequestToHar - it takes a HAR request
10
- * and converts it into a standard JavaScript Fetch API Request object.
11
+ * and converts it into a [url, RequestInit] tuple that maps directly to the fetch() argument list.
11
12
  *
12
13
  * The conversion handles:
13
14
  * - Request method and URL reconstruction
@@ -25,18 +26,16 @@ type HarToFetchRequestProps = {
25
26
  * - Request caching and restoration
26
27
  * - Re-executing historical API calls
27
28
  *
28
- * Note: The Fetch API Request object does not support setting the HTTP version,
29
- * so that information from the HAR is not preserved in the returned Request.
30
- * Query parameters are expected to be already part of the URL in the HAR.
29
+ * Note: Query parameters are expected to be already part of the URL in the HAR.
31
30
  *
32
31
  * @see https://w3c.github.io/web-performance/specs/HAR/Overview.html
33
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Request
32
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/fetch
34
33
  *
35
34
  * @example
36
35
  * const harRequest = { method: 'POST', url: 'https://api.example.com', ... }
37
- * const request = harToFetchRequest({ harRequest })
38
- * const response = await fetch(request)
36
+ * const [url, init] = harToFetchRequest({ harRequest })
37
+ * const response = await fetch(url, init)
39
38
  */
40
- export declare const harToFetchRequest: ({ harRequest }: HarToFetchRequestProps) => Request;
39
+ export declare const harToFetchRequest: ({ harRequest }: HarToFetchRequestProps) => RequestPayload;
41
40
  export {};
42
41
  //# sourceMappingURL=har-to-fetch-request.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"har-to-fetch-request.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-block/helpers/har-to-fetch-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAElD,KAAK,sBAAsB,GAAG;IAC5B,wCAAwC;IACxC,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,iBAAiB,GAAI,gBAAgB,sBAAsB,KAAG,OAS1E,CAAA"}
1
+ {"version":3,"file":"har-to-fetch-request.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-block/helpers/har-to-fetch-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAA;AAE7E,KAAK,sBAAsB,GAAG;IAC5B,wCAAwC;IACxC,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,iBAAiB,GAAI,gBAAgB,sBAAsB,KAAG,cAY1E,CAAA"}
@@ -1,9 +1,9 @@
1
1
  //#region src/v2/blocks/operation-block/helpers/har-to-fetch-request.ts
2
2
  /**
3
- * Converts a HAR (HTTP Archive) Request to a Fetch API Request object.
3
+ * Converts a HAR (HTTP Archive) Request to a RequestPayload [url, RequestInit] tuple for use with fetch().
4
4
  *
5
5
  * This function is the reverse of fetchRequestToHar - it takes a HAR request
6
- * and converts it into a standard JavaScript Fetch API Request object.
6
+ * and converts it into a [url, RequestInit] tuple that maps directly to the fetch() argument list.
7
7
  *
8
8
  * The conversion handles:
9
9
  * - Request method and URL reconstruction
@@ -21,26 +21,24 @@
21
21
  * - Request caching and restoration
22
22
  * - Re-executing historical API calls
23
23
  *
24
- * Note: The Fetch API Request object does not support setting the HTTP version,
25
- * so that information from the HAR is not preserved in the returned Request.
26
- * Query parameters are expected to be already part of the URL in the HAR.
24
+ * Note: Query parameters are expected to be already part of the URL in the HAR.
27
25
  *
28
26
  * @see https://w3c.github.io/web-performance/specs/HAR/Overview.html
29
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Request
27
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/fetch
30
28
  *
31
29
  * @example
32
30
  * const harRequest = { method: 'POST', url: 'https://api.example.com', ... }
33
- * const request = harToFetchRequest({ harRequest })
34
- * const response = await fetch(request)
31
+ * const [url, init] = harToFetchRequest({ harRequest })
32
+ * const response = await fetch(url, init)
35
33
  */
36
34
  var harToFetchRequest = ({ harRequest }) => {
37
35
  const headers = buildHeaders(harRequest);
38
36
  const body = buildBody(harRequest.postData);
39
- return new Request(harRequest.url, {
37
+ return [harRequest.url, {
40
38
  method: harRequest.method,
41
39
  headers,
42
40
  body
43
- });
41
+ }];
44
42
  };
45
43
  /**
46
44
  * Builds Headers object from HAR request headers and cookies.
@@ -1 +1 @@
1
- {"version":3,"file":"har-to-fetch-request.js","names":[],"sources":["../../../../../src/v2/blocks/operation-block/helpers/har-to-fetch-request.ts"],"sourcesContent":["import type { HarRequest } from '@scalar/snippetz'\n\ntype HarToFetchRequestProps = {\n /** The HAR Request object to convert */\n harRequest: HarRequest\n}\n\n/**\n * Converts a HAR (HTTP Archive) Request to a Fetch API Request object.\n *\n * This function is the reverse of fetchRequestToHar - it takes a HAR request\n * and converts it into a standard JavaScript Fetch API Request object.\n *\n * The conversion handles:\n * - Request method and URL reconstruction\n * - Headers reconstruction from HAR headers array\n * - Cookies conversion to Cookie header\n * - Form data (params) conversion to FormData or URLSearchParams\n * - Body decoding\n * - Content-Type and other header restoration\n * - Query parameters (already embedded in the URL)\n *\n * Use cases:\n * - Replaying recorded HTTP requests\n * - Creating mock requests from HAR files\n * - Testing with fixtures\n * - Request caching and restoration\n * - Re-executing historical API calls\n *\n * Note: The Fetch API Request object does not support setting the HTTP version,\n * so that information from the HAR is not preserved in the returned Request.\n * Query parameters are expected to be already part of the URL in the HAR.\n *\n * @see https://w3c.github.io/web-performance/specs/HAR/Overview.html\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Request\n *\n * @example\n * const harRequest = { method: 'POST', url: 'https://api.example.com', ... }\n * const request = harToFetchRequest({ harRequest })\n * const response = await fetch(request)\n */\nexport const harToFetchRequest = ({ harRequest }: HarToFetchRequestProps): Request => {\n const headers = buildHeaders(harRequest)\n const body = buildBody(harRequest.postData)\n\n return new Request(harRequest.url, {\n method: harRequest.method,\n headers,\n body,\n })\n}\n\n/**\n * Builds Headers object from HAR request headers and cookies.\n */\nconst buildHeaders = (harRequest: HarRequest): Headers => {\n const headers = new Headers()\n\n // Add all headers from HAR\n harRequest.headers.forEach(({ name, value }) => {\n headers.append(name, value)\n })\n\n // Convert cookies to Cookie header\n if (harRequest.cookies?.length) {\n const cookieString = harRequest.cookies.map(({ name, value }) => `${name}=${value}`).join('; ')\n headers.append('Cookie', cookieString)\n }\n\n return headers\n}\n\n/**\n * Builds request body from HAR postData.\n * Returns FormData for multipart forms, URLSearchParams for URL-encoded forms,\n * or encoded text for other content types.\n */\nconst buildBody = (postData: HarRequest['postData']): BodyInit | null => {\n if (!postData) {\n return null\n }\n\n const { params, text, mimeType } = postData\n\n // Handle form data parameters\n if (params?.length) {\n const isMultipart = mimeType?.includes('multipart/form-data')\n const form = isMultipart ? new FormData() : new URLSearchParams()\n\n params.forEach(({ name, value }) => {\n form.append(name, value || '')\n })\n\n return form\n }\n\n // Handle text body\n if (text) {\n return new TextEncoder().encode(text)\n }\n\n return null\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAa,qBAAqB,EAAE,iBAAkD;CACpF,MAAM,UAAU,aAAa,WAAW;CACxC,MAAM,OAAO,UAAU,WAAW,SAAS;AAE3C,QAAO,IAAI,QAAQ,WAAW,KAAK;EACjC,QAAQ,WAAW;EACnB;EACA;EACD,CAAC;;;;;AAMJ,IAAM,gBAAgB,eAAoC;CACxD,MAAM,UAAU,IAAI,SAAS;AAG7B,YAAW,QAAQ,SAAS,EAAE,MAAM,YAAY;AAC9C,UAAQ,OAAO,MAAM,MAAM;GAC3B;AAGF,KAAI,WAAW,SAAS,QAAQ;EAC9B,MAAM,eAAe,WAAW,QAAQ,KAAK,EAAE,MAAM,YAAY,GAAG,KAAK,GAAG,QAAQ,CAAC,KAAK,KAAK;AAC/F,UAAQ,OAAO,UAAU,aAAa;;AAGxC,QAAO;;;;;;;AAQT,IAAM,aAAa,aAAsD;AACvE,KAAI,CAAC,SACH,QAAO;CAGT,MAAM,EAAE,QAAQ,MAAM,aAAa;AAGnC,KAAI,QAAQ,QAAQ;EAElB,MAAM,OADc,UAAU,SAAS,sBAAsB,GAClC,IAAI,UAAU,GAAG,IAAI,iBAAiB;AAEjE,SAAO,SAAS,EAAE,MAAM,YAAY;AAClC,QAAK,OAAO,MAAM,SAAS,GAAG;IAC9B;AAEF,SAAO;;AAIT,KAAI,KACF,QAAO,IAAI,aAAa,CAAC,OAAO,KAAK;AAGvC,QAAO"}
1
+ {"version":3,"file":"har-to-fetch-request.js","names":[],"sources":["../../../../../src/v2/blocks/operation-block/helpers/har-to-fetch-request.ts"],"sourcesContent":["import type { HarRequest } from '@scalar/snippetz'\nimport type { RequestPayload } from '@scalar/workspace-store/request-example'\n\ntype HarToFetchRequestProps = {\n /** The HAR Request object to convert */\n harRequest: HarRequest\n}\n\n/**\n * Converts a HAR (HTTP Archive) Request to a RequestPayload [url, RequestInit] tuple for use with fetch().\n *\n * This function is the reverse of fetchRequestToHar - it takes a HAR request\n * and converts it into a [url, RequestInit] tuple that maps directly to the fetch() argument list.\n *\n * The conversion handles:\n * - Request method and URL reconstruction\n * - Headers reconstruction from HAR headers array\n * - Cookies conversion to Cookie header\n * - Form data (params) conversion to FormData or URLSearchParams\n * - Body decoding\n * - Content-Type and other header restoration\n * - Query parameters (already embedded in the URL)\n *\n * Use cases:\n * - Replaying recorded HTTP requests\n * - Creating mock requests from HAR files\n * - Testing with fixtures\n * - Request caching and restoration\n * - Re-executing historical API calls\n *\n * Note: Query parameters are expected to be already part of the URL in the HAR.\n *\n * @see https://w3c.github.io/web-performance/specs/HAR/Overview.html\n * @see https://developer.mozilla.org/en-US/docs/Web/API/fetch\n *\n * @example\n * const harRequest = { method: 'POST', url: 'https://api.example.com', ... }\n * const [url, init] = harToFetchRequest({ harRequest })\n * const response = await fetch(url, init)\n */\nexport const harToFetchRequest = ({ harRequest }: HarToFetchRequestProps): RequestPayload => {\n const headers = buildHeaders(harRequest)\n const body = buildBody(harRequest.postData)\n\n return [\n harRequest.url,\n {\n method: harRequest.method,\n headers,\n body,\n },\n ]\n}\n\n/**\n * Builds Headers object from HAR request headers and cookies.\n */\nconst buildHeaders = (harRequest: HarRequest): Headers => {\n const headers = new Headers()\n\n // Add all headers from HAR\n harRequest.headers.forEach(({ name, value }) => {\n headers.append(name, value)\n })\n\n // Convert cookies to Cookie header\n if (harRequest.cookies?.length) {\n const cookieString = harRequest.cookies.map(({ name, value }) => `${name}=${value}`).join('; ')\n headers.append('Cookie', cookieString)\n }\n\n return headers\n}\n\n/**\n * Builds request body from HAR postData.\n * Returns FormData for multipart forms, URLSearchParams for URL-encoded forms,\n * or encoded text for other content types.\n */\nconst buildBody = (postData: HarRequest['postData']): BodyInit | null => {\n if (!postData) {\n return null\n }\n\n const { params, text, mimeType } = postData\n\n // Handle form data parameters\n if (params?.length) {\n const isMultipart = mimeType?.includes('multipart/form-data')\n const form = isMultipart ? new FormData() : new URLSearchParams()\n\n params.forEach(({ name, value }) => {\n form.append(name, value || '')\n })\n\n return form\n }\n\n // Handle text body\n if (text) {\n return new TextEncoder().encode(text)\n }\n\n return null\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,IAAa,qBAAqB,EAAE,iBAAyD;CAC3F,MAAM,UAAU,aAAa,WAAW;CACxC,MAAM,OAAO,UAAU,WAAW,SAAS;AAE3C,QAAO,CACL,WAAW,KACX;EACE,QAAQ,WAAW;EACnB;EACA;EACD,CACF;;;;;AAMH,IAAM,gBAAgB,eAAoC;CACxD,MAAM,UAAU,IAAI,SAAS;AAG7B,YAAW,QAAQ,SAAS,EAAE,MAAM,YAAY;AAC9C,UAAQ,OAAO,MAAM,MAAM;GAC3B;AAGF,KAAI,WAAW,SAAS,QAAQ;EAC9B,MAAM,eAAe,WAAW,QAAQ,KAAK,EAAE,MAAM,YAAY,GAAG,KAAK,GAAG,QAAQ,CAAC,KAAK,KAAK;AAC/F,UAAQ,OAAO,UAAU,aAAa;;AAGxC,QAAO;;;;;;;AAQT,IAAM,aAAa,aAAsD;AACvE,KAAI,CAAC,SACH,QAAO;CAGT,MAAM,EAAE,QAAQ,MAAM,aAAa;AAGnC,KAAI,QAAQ,QAAQ;EAElB,MAAM,OADc,UAAU,SAAS,sBAAsB,GAClC,IAAI,UAAU,GAAG,IAAI,iBAAiB;AAEjE,SAAO,SAAS,EAAE,MAAM,YAAY;AAClC,QAAK,OAAO,MAAM,SAAS,GAAG;IAC9B;AAEF,SAAO;;AAIT,KAAI,KACF,QAAO,IAAI,aAAa,CAAC,OAAO,KAAK;AAGvC,QAAO"}
@@ -1,3 +1,4 @@
1
+ import type { RequestPayload } from '@scalar/workspace-store/request-example';
1
2
  import type { ResponseInstance } from '../../../../v2/blocks/operation-block/helpers/send-request.js';
2
3
  /**
3
4
  * In-memory cache of operation example id → { response, request }.
@@ -6,7 +7,7 @@ import type { ResponseInstance } from '../../../../v2/blocks/operation-block/hel
6
7
  */
7
8
  export declare const responseCache: Map<string, {
8
9
  response: ResponseInstance;
9
- request: Request;
10
+ requestPayload: RequestPayload;
10
11
  }>;
11
12
  /**
12
13
  * Constructs a unique cache key for a specific operation/example.
@@ -1 +1 @@
1
- {"version":3,"file":"response-cache.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-block/helpers/response-cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kDAAkD,CAAA;AAExF;;;;GAIG;AACH,eAAO,MAAM,aAAa;cAA+B,gBAAgB;aAAW,OAAO;EAAK,CAAA;AAEhG;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAE/F;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAEvE"}
1
+ {"version":3,"file":"response-cache.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-block/helpers/response-cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAA;AAE7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kDAAkD,CAAA;AAExF;;;;GAIG;AACH,eAAO,MAAM,aAAa;cAA+B,gBAAgB;oBAAkB,cAAc;EAAK,CAAA;AAE9G;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAE/F;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAEvE"}
@@ -1 +1 @@
1
- {"version":3,"file":"response-cache.js","names":[],"sources":["../../../../../src/v2/blocks/operation-block/helpers/response-cache.ts"],"sourcesContent":["import type { ResponseInstance } from '@/v2/blocks/operation-block/helpers/send-request'\n\n/**\n * In-memory cache of operation example id → { response, request }.\n * Restores the last response when navigating back to an operation until\n * the user refreshes the page or makes a new request.\n */\nexport const responseCache = new Map<string, { response: ResponseInstance; request: Request }>()\n\n/**\n * Constructs a unique cache key for a specific operation/example.\n * The key is composed of the HTTP method, request path, and the example key,\n * delimited by \"|\", e.g. \"GET|/pets|123\".\n *\n * @param method - HTTP method (e.g., \"GET\", \"POST\")\n * @param path - The request path (e.g., \"/pets\")\n * @param exampleKey - A unique key identifying the example/request variant\n * @returns The constructed cache key string\n */\nexport function getOperationExampleKey(method: string, path: string, exampleKey: string): string {\n return `${method}|${path}|${exampleKey}`\n}\n\n/**\n * Determines if a response is a streaming response (e.g., server-sent events).\n * Assumes streaming responses include a 'reader' property.\n *\n * @param response - The response instance to check\n * @returns True if response is streaming, otherwise false\n */\nexport function isStreamingResponse(response: ResponseInstance): boolean {\n return 'reader' in response\n}\n"],"mappings":";;;;;;AAOA,IAAa,gCAAgB,IAAI,KAA+D;;;;;;;;;;;AAYhG,SAAgB,uBAAuB,QAAgB,MAAc,YAA4B;AAC/F,QAAO,GAAG,OAAO,GAAG,KAAK,GAAG;;;;;;;;;AAU9B,SAAgB,oBAAoB,UAAqC;AACvE,QAAO,YAAY"}
1
+ {"version":3,"file":"response-cache.js","names":[],"sources":["../../../../../src/v2/blocks/operation-block/helpers/response-cache.ts"],"sourcesContent":["import type { RequestPayload } from '@scalar/workspace-store/request-example'\n\nimport type { ResponseInstance } from '@/v2/blocks/operation-block/helpers/send-request'\n\n/**\n * In-memory cache of operation example id → { response, request }.\n * Restores the last response when navigating back to an operation until\n * the user refreshes the page or makes a new request.\n */\nexport const responseCache = new Map<string, { response: ResponseInstance; requestPayload: RequestPayload }>()\n\n/**\n * Constructs a unique cache key for a specific operation/example.\n * The key is composed of the HTTP method, request path, and the example key,\n * delimited by \"|\", e.g. \"GET|/pets|123\".\n *\n * @param method - HTTP method (e.g., \"GET\", \"POST\")\n * @param path - The request path (e.g., \"/pets\")\n * @param exampleKey - A unique key identifying the example/request variant\n * @returns The constructed cache key string\n */\nexport function getOperationExampleKey(method: string, path: string, exampleKey: string): string {\n return `${method}|${path}|${exampleKey}`\n}\n\n/**\n * Determines if a response is a streaming response (e.g., server-sent events).\n * Assumes streaming responses include a 'reader' property.\n *\n * @param response - The response instance to check\n * @returns True if response is streaming, otherwise false\n */\nexport function isStreamingResponse(response: ResponseInstance): boolean {\n return 'reader' in response\n}\n"],"mappings":";;;;;;AASA,IAAa,gCAAgB,IAAI,KAA6E;;;;;;;;;;;AAY9G,SAAgB,uBAAuB,QAAgB,MAAc,YAA4B;AAC/F,QAAO,GAAG,OAAO,GAAG,KAAK,GAAG;;;;;;;;;AAU9B,SAAgB,oBAAoB,UAAqC;AACvE,QAAO,YAAY"}
@@ -1,5 +1,7 @@
1
1
  import { type ErrorResponse } from '@scalar/helpers/errors/normalize-error';
2
2
  import type { HttpMethod } from '@scalar/helpers/http/http-methods';
3
+ import type { ClientPlugin } from '@scalar/oas-utils/helpers';
4
+ import type { RequestPayload } from '@scalar/workspace-store/request-example';
3
5
  /** A single set of populated values for a sent request */
4
6
  export type ResponseInstance = Omit<Response, 'headers'> & {
5
7
  /** Store headers as an object to match what we had with axios */
@@ -38,12 +40,14 @@ export type ResponseInstance = Omit<Response, 'headers'> & {
38
40
  * @param isUsingProxy - Whether the request is being proxied for header handling
39
41
  * @returns A tuple with either an error or the response data
40
42
  */
41
- export declare const sendRequest: ({ isUsingProxy, request, }: {
43
+ export declare const sendRequest: ({ isUsingProxy, requestPayload, plugins, }: {
42
44
  isUsingProxy: boolean;
43
- request: Request;
45
+ requestPayload: RequestPayload;
46
+ /** Registered client plugins for custom content type handling */
47
+ plugins?: ClientPlugin[];
44
48
  }) => Promise<ErrorResponse<{
45
49
  response: ResponseInstance;
46
- request: Request;
50
+ requestPayload: RequestPayload;
47
51
  timestamp: number;
48
52
  originalResponse: Response;
49
53
  }>>;
@@ -1 +1 @@
1
- {"version":3,"file":"send-request.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-block/helpers/send-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,aAAa,EAAkB,MAAM,wCAAwC,CAAA;AACnG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAYnE,0DAA0D;AAC1D,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG;IACzD,iEAAiE;IACjE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,wCAAwC;IACxC,gBAAgB,EAAE,MAAM,EAAE,CAAA;IAC1B,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAA;IAChB,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,+BAA+B;IAC/B,UAAU,EAAE,MAAM,CAAA;IAClB,0BAA0B;IAC1B,MAAM,EAAE,UAAU,CAAA;IAClB,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAA;CACb,GAAG,CACE;IACE,wBAAwB;IACxB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAA;CACb,GACD;IACE,qDAAqD;IACrD,MAAM,EAAE,2BAA2B,CAAC,UAAU,CAAC,CAAA;CAChD,CACJ,CAAA;AAKH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,WAAW,GAAU,4BAG/B;IACD,YAAY,EAAE,OAAO,CAAA;IACrB,OAAO,EAAE,OAAO,CAAA;CACjB,KAAG,OAAO,CACT,aAAa,CAAC;IACZ,QAAQ,EAAE,gBAAgB,CAAA;IAC1B,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,gBAAgB,EAAE,QAAQ,CAAA;CAC3B,CAAC,CAoDH,CAAA"}
1
+ {"version":3,"file":"send-request.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-block/helpers/send-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,aAAa,EAAkB,MAAM,wCAAwC,CAAA;AAGnG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAGnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAA;AAe7E,0DAA0D;AAC1D,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG;IACzD,iEAAiE;IACjE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,wCAAwC;IACxC,gBAAgB,EAAE,MAAM,EAAE,CAAA;IAC1B,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAA;IAChB,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,+BAA+B;IAC/B,UAAU,EAAE,MAAM,CAAA;IAClB,0BAA0B;IAC1B,MAAM,EAAE,UAAU,CAAA;IAClB,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAA;CACb,GAAG,CACE;IACE,wBAAwB;IACxB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAA;CACb,GACD;IACE,qDAAqD;IACrD,MAAM,EAAE,2BAA2B,CAAC,UAAU,CAAC,CAAA;CAChD,CACJ,CAAA;AAKH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,WAAW,GAAU,4CAI/B;IACD,YAAY,EAAE,OAAO,CAAA;IACrB,cAAc,EAAE,cAAc,CAAA;IAC9B,iEAAiE;IACjE,OAAO,CAAC,EAAE,YAAY,EAAE,CAAA;CACzB,KAAG,OAAO,CACT,aAAa,CAAC;IACZ,QAAQ,EAAE,gBAAgB,CAAA;IAC1B,cAAc,EAAE,cAAc,CAAA;IAC9B,SAAS,EAAE,MAAM,CAAA;IACjB,gBAAgB,EAAE,QAAQ,CAAA;CAC3B,CAAC,CA2DH,CAAA"}
@@ -1,9 +1,13 @@
1
1
  import { getCookieHeaderKeys } from "./get-cookie-header-keys.js";
2
+ import { resolveResponseBodyHandler } from "../../response-block/helpers/resolve-response-body-handler.js";
3
+ import { resolveResponseContentType, resolveResponseMimeType } from "../../response-block/helpers/resolve-response-content-type.js";
2
4
  import { decodeBuffer } from "./decode-buffer.js";
3
5
  import { ERRORS, normalizeError } from "@scalar/helpers/errors/normalize-error";
6
+ import { isElectron } from "@scalar/helpers/general/is-electron";
7
+ import { buildSafeBodyRequest } from "@scalar/helpers/http/can-method-have-body";
4
8
  import { httpStatusCodes } from "@scalar/helpers/http/http-status-codes";
5
9
  import { normalizeHeaders } from "@scalar/helpers/http/normalize-headers";
6
- import cookie from "cookie";
10
+ import * as cookie from "cookie";
7
11
  import { parseSetCookie } from "set-cookie-parser";
8
12
  //#region src/v2/blocks/operation-block/helpers/send-request.ts
9
13
  var CUSTOM_COOKIE_HEADER = "x-scalar-set-cookie";
@@ -26,10 +30,10 @@ var NO_BODY_STATUS_CODES = [
26
30
  * @param isUsingProxy - Whether the request is being proxied for header handling
27
31
  * @returns A tuple with either an error or the response data
28
32
  */
29
- var sendRequest = async ({ isUsingProxy, request }) => {
33
+ var sendRequest = async ({ isUsingProxy, requestPayload, plugins = [] }) => {
30
34
  try {
31
35
  const startTime = performance.now();
32
- const response = await fetch(request.clone());
36
+ const response = isElectron() && window.proxiedFetch ? await window.proxiedFetch?.(...requestPayload) : await fetch(buildSafeBodyRequest(...requestPayload));
33
37
  const endTime = performance.now();
34
38
  const timestamp = Date.now();
35
39
  const duration = endTime - startTime;
@@ -38,7 +42,7 @@ var sendRequest = async ({ isUsingProxy, request }) => {
38
42
  const responseUrl = new URL(response.url);
39
43
  const fullPath = responseUrl.pathname + responseUrl.search;
40
44
  const statusText = response.statusText || httpStatusCodes[response.status]?.name || "";
41
- const method = request.method;
45
+ const method = requestPayload[1].method ?? "GET";
42
46
  const shouldSkipBody = NO_BODY_STATUS_CODES.includes(response.status);
43
47
  /**
44
48
  * Handle server-sent event streams separately.
@@ -47,7 +51,7 @@ var sendRequest = async ({ isUsingProxy, request }) => {
47
51
  */
48
52
  if (contentType?.startsWith("text/event-stream") && response.body) return buildStreamingResponse({
49
53
  response,
50
- request,
54
+ requestPayload,
51
55
  timestamp,
52
56
  duration,
53
57
  responseHeaders,
@@ -57,7 +61,7 @@ var sendRequest = async ({ isUsingProxy, request }) => {
57
61
  });
58
62
  return buildStandardResponse({
59
63
  response,
60
- request,
64
+ requestPayload,
61
65
  timestamp,
62
66
  duration,
63
67
  responseHeaders,
@@ -65,7 +69,8 @@ var sendRequest = async ({ isUsingProxy, request }) => {
65
69
  method,
66
70
  fullPath,
67
71
  contentType,
68
- shouldSkipBody
72
+ shouldSkipBody,
73
+ plugins
69
74
  });
70
75
  } catch (error) {
71
76
  return [normalizeError(error, ERRORS.REQUEST_FAILED), null];
@@ -93,7 +98,7 @@ var getCustomCookie = (response) => {
93
98
  * Build a streaming response for server-sent events.
94
99
  * Streaming responses use a reader instead of buffering the entire body.
95
100
  */
96
- var buildStreamingResponse = ({ response, request, timestamp, duration, responseHeaders, statusText, method, fullPath }) => {
101
+ var buildStreamingResponse = ({ response, requestPayload, timestamp, duration, responseHeaders, statusText, method, fullPath }) => {
97
102
  const normalizedResponse = new Response(null, {
98
103
  status: response.status,
99
104
  statusText,
@@ -102,7 +107,7 @@ var buildStreamingResponse = ({ response, request, timestamp, duration, response
102
107
  const cookieHeaderKeys = getCustomCookie(normalizedResponse) ?? getCookieHeaderKeys(normalizedResponse.headers);
103
108
  return [null, {
104
109
  timestamp,
105
- request,
110
+ requestPayload,
106
111
  response: {
107
112
  ...normalizedResponse,
108
113
  headers: responseHeaders,
@@ -119,9 +124,11 @@ var buildStreamingResponse = ({ response, request, timestamp, duration, response
119
124
  * Build a standard response with buffered body data.
120
125
  * This handles all non-streaming responses including JSON, text, and binary data.
121
126
  */
122
- var buildStandardResponse = async ({ response, request, timestamp, duration, responseHeaders, statusText, method, fullPath, contentType, shouldSkipBody }) => {
127
+ var buildStandardResponse = async ({ response, requestPayload, timestamp, duration, responseHeaders, statusText, method, fullPath, contentType, shouldSkipBody, plugins }) => {
123
128
  const arrayBuffer = await response.clone().arrayBuffer();
124
- const responseData = decodeBuffer(arrayBuffer, contentType ?? "text/plain;charset=UTF-8");
129
+ const responseType = resolveResponseContentType(contentType);
130
+ const mimeEssence = resolveResponseMimeType(contentType).essence;
131
+ const responseData = await decodeBuffer(arrayBuffer, responseType, resolveResponseBodyHandler(mimeEssence, plugins));
125
132
  /**
126
133
  * Create a new Response using the arrayBuffer we already read.
127
134
  * ArrayBuffers can be reused to create new Response objects without additional memory.
@@ -134,7 +141,7 @@ var buildStandardResponse = async ({ response, request, timestamp, duration, res
134
141
  const cookieHeaderKeys = getCustomCookie(normalizedResponse) ?? getCookieHeaderKeys(normalizedResponse.headers);
135
142
  return [null, {
136
143
  timestamp,
137
- request,
144
+ requestPayload,
138
145
  response: {
139
146
  ...normalizedResponse,
140
147
  headers: responseHeaders,
@@ -1 +1 @@
1
- {"version":3,"file":"send-request.js","names":[],"sources":["../../../../../src/v2/blocks/operation-block/helpers/send-request.ts"],"sourcesContent":["import { ERRORS, type ErrorResponse, normalizeError } from '@scalar/helpers/errors/normalize-error'\nimport type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport { httpStatusCodes } from '@scalar/helpers/http/http-status-codes'\nimport { normalizeHeaders } from '@scalar/helpers/http/normalize-headers'\nimport cookie from 'cookie'\nimport { parseSetCookie } from 'set-cookie-parser'\n\nimport { getCookieHeaderKeys } from '@/v2/blocks/operation-block/helpers/get-cookie-header-keys'\n\nimport { decodeBuffer } from './decode-buffer'\n\nconst CUSTOM_COOKIE_HEADER = 'x-scalar-set-cookie'\n\n/** A single set of populated values for a sent request */\nexport type ResponseInstance = Omit<Response, 'headers'> & {\n /** Store headers as an object to match what we had with axios */\n headers: Record<string, string>\n /** Keys of headers which set cookies */\n cookieHeaderKeys: string[]\n /** Time in ms the request took */\n duration: number\n /** The response status */\n status: number\n /** The response status text */\n statusText: string\n /** The response method */\n method: HttpMethod\n /** The request path */\n path: string\n} & (\n | {\n /** The response data */\n data: string | Blob\n /** The response size in bytes */\n size: number\n }\n | {\n /** A stream reader for a streamable response body */\n reader: ReadableStreamDefaultReader<Uint8Array>\n }\n )\n\n/** HTTP status codes that should not include a response body */\nconst NO_BODY_STATUS_CODES = [204, 205, 304]\n\n/**\n * Execute the built fetch request and return a structured response.\n *\n * This function handles the complete request lifecycle including plugin hooks,\n * response processing, streaming detection, and error handling. It supports both\n * standard responses and server-sent event streams.\n *\n * @param request - The request built by the buildRequest helper\n * @param operation - The OpenAPI operation being executed\n * @param plugins - Array of client plugins to execute hooks\n * @param isUsingProxy - Whether the request is being proxied for header handling\n * @returns A tuple with either an error or the response data\n */\nexport const sendRequest = async ({\n isUsingProxy,\n request,\n}: {\n isUsingProxy: boolean\n request: Request\n}): Promise<\n ErrorResponse<{\n response: ResponseInstance\n request: Request\n timestamp: number\n originalResponse: Response\n }>\n> => {\n try {\n // Execute the request and measure duration\n const startTime = performance.now()\n const response = await fetch(request.clone())\n const endTime = performance.now()\n const timestamp = Date.now()\n const duration = endTime - startTime\n\n // Extract response metadata early for reuse\n const contentType = response.headers.get('content-type')\n const responseHeaders = normalizeHeaders(response.headers, isUsingProxy)\n const responseUrl = new URL(response.url)\n const fullPath = responseUrl.pathname + responseUrl.search\n const statusText = response.statusText || httpStatusCodes[response.status]?.name || ''\n const method = request.method as HttpMethod\n const shouldSkipBody = NO_BODY_STATUS_CODES.includes(response.status)\n\n /**\n * Handle server-sent event streams separately.\n * These responses need a reader instead of buffered data.\n * We check this early to avoid unnecessary body reading.\n */\n if (contentType?.startsWith('text/event-stream') && response.body) {\n return buildStreamingResponse({\n response,\n request,\n timestamp,\n duration,\n responseHeaders,\n statusText,\n method,\n fullPath,\n })\n }\n\n return buildStandardResponse({\n response,\n request,\n timestamp,\n duration,\n responseHeaders,\n statusText,\n method,\n fullPath,\n contentType,\n shouldSkipBody,\n })\n } catch (error) {\n return [normalizeError(error, ERRORS.REQUEST_FAILED), null]\n }\n}\n\n/**\n * Extracts and serializes custom cookies from the response using the custom cookie header.\n *\n * This function parses the custom cookie header (if present), serializes each cookie using the\n * 'cookie' library, and then deletes the custom cookie header from the response.\n * Returns an array of serialized cookie strings, or null if no cookies were found.\n *\n * The @ts-expect-error is present due to a type mismatch between the 'cookie' parsing and serialization libraries.\n */\nconst getCustomCookie = (response: Response): string[] | null => {\n const result = parseSetCookie(response.headers.get(CUSTOM_COOKIE_HEADER) ?? '').map((c) =>\n cookie.serialize(c.name, c.value, {\n ...c,\n sameSite: c.sameSite as boolean | 'lax' | 'strict' | 'none' | undefined,\n encode: (str: string) => str,\n }),\n )\n\n if (result.length) {\n return result\n }\n\n return null\n}\n\n/**\n * Build a streaming response for server-sent events.\n * Streaming responses use a reader instead of buffering the entire body.\n */\nconst buildStreamingResponse = ({\n response,\n request,\n timestamp,\n duration,\n responseHeaders,\n statusText,\n method,\n fullPath,\n}: {\n response: Response\n request: Request\n timestamp: number\n duration: number\n responseHeaders: Record<string, string>\n statusText: string\n method: HttpMethod\n fullPath: string\n}): ErrorResponse<{\n response: ResponseInstance\n request: Request\n timestamp: number\n originalResponse: Response\n}> => {\n const normalizedResponse = new Response(null, {\n status: response.status,\n statusText,\n headers: response.headers,\n })\n\n const customCookie = getCustomCookie(normalizedResponse)\n const cookieHeaderKeys = customCookie ?? getCookieHeaderKeys(normalizedResponse.headers)\n\n return [\n null,\n {\n timestamp,\n request: request,\n response: {\n ...normalizedResponse,\n headers: responseHeaders,\n cookieHeaderKeys,\n reader: response.body!.getReader(),\n duration,\n method,\n path: fullPath,\n },\n originalResponse: normalizedResponse.clone(),\n },\n ]\n}\n\n/**\n * Build a standard response with buffered body data.\n * This handles all non-streaming responses including JSON, text, and binary data.\n */\nconst buildStandardResponse = async ({\n response,\n request,\n timestamp,\n duration,\n responseHeaders,\n statusText,\n method,\n fullPath,\n contentType,\n shouldSkipBody,\n}: {\n response: Response\n request: Request\n timestamp: number\n duration: number\n responseHeaders: Record<string, string>\n statusText: string\n method: HttpMethod\n fullPath: string\n contentType: string | null\n shouldSkipBody: boolean\n}): Promise<\n ErrorResponse<{\n response: ResponseInstance\n request: Request\n timestamp: number\n originalResponse: Response\n }>\n> => {\n /**\n * Clone the response to preserve the original for body reading.\n * Read the body once and reuse the buffer for both decoding and creating a new Response.\n */\n const clonedResponse = response.clone()\n const arrayBuffer = await clonedResponse.arrayBuffer()\n const responseType = contentType ?? 'text/plain;charset=UTF-8'\n const responseData = decodeBuffer(arrayBuffer, responseType)\n\n /**\n * Create a new Response using the arrayBuffer we already read.\n * ArrayBuffers can be reused to create new Response objects without additional memory.\n */\n const normalizedResponse = new Response(shouldSkipBody ? null : arrayBuffer, {\n status: response.status,\n statusText,\n headers: response.headers,\n })\n\n const customCookie = getCustomCookie(normalizedResponse)\n const cookieHeaderKeys = customCookie ?? getCookieHeaderKeys(normalizedResponse.headers)\n\n return [\n null,\n {\n timestamp,\n request: request,\n response: {\n ...normalizedResponse,\n headers: responseHeaders,\n cookieHeaderKeys,\n data: responseData,\n size: arrayBuffer.byteLength,\n duration,\n method,\n status: response.status,\n path: fullPath,\n },\n originalResponse: response.clone(),\n },\n ]\n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eAeI;CACJ,MAAM,qBAAqB,IAAI,SAAS,MAAM;EAC5C,QAAQ,SAAS;EACjB;EACA,SAAS,SAAS;EACnB,CAAC;CAGF,MAAM,mBADe,gBAAgB,mBAAmB,IACf,oBAAoB,mBAAmB,QAAQ;AAExF,QAAO,CACL,MACA;EACE;EACS;EACT,UAAU;GACR,GAAG;GACH,SAAS;GACT;GACA,QAAQ,SAAS,KAAM,WAAW;GAClC;GACA;GACA,MAAM;GACP;EACD,kBAAkB,mBAAmB,OAAO;EAC7C,CACF;;;;;;AAOH,IAAM,wBAAwB,OAAO,EACnC,UACA,SACA,WACA,UACA,iBACA,YACA,QACA,UACA,aACA,qBAmBG;CAMH,MAAM,cAAc,MADG,SAAS,OAAO,CACE,aAAa;CAEtD,MAAM,eAAe,aAAa,aADb,eAAe,2BACwB;;;;;CAM5D,MAAM,qBAAqB,IAAI,SAAS,iBAAiB,OAAO,aAAa;EAC3E,QAAQ,SAAS;EACjB;EACA,SAAS,SAAS;EACnB,CAAC;CAGF,MAAM,mBADe,gBAAgB,mBAAmB,IACf,oBAAoB,mBAAmB,QAAQ;AAExF,QAAO,CACL,MACA;EACE;EACS;EACT,UAAU;GACR,GAAG;GACH,SAAS;GACT;GACA,MAAM;GACN,MAAM,YAAY;GAClB;GACA;GACA,QAAQ,SAAS;GACjB,MAAM;GACP;EACD,kBAAkB,SAAS,OAAO;EACnC,CACF"}
1
+ {"version":3,"file":"send-request.js","names":[],"sources":["../../../../../src/v2/blocks/operation-block/helpers/send-request.ts"],"sourcesContent":["import { ERRORS, type ErrorResponse, normalizeError } from '@scalar/helpers/errors/normalize-error'\nimport { isElectron } from '@scalar/helpers/general/is-electron'\nimport { buildSafeBodyRequest } from '@scalar/helpers/http/can-method-have-body'\nimport type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport { httpStatusCodes } from '@scalar/helpers/http/http-status-codes'\nimport { normalizeHeaders } from '@scalar/helpers/http/normalize-headers'\nimport type { ClientPlugin } from '@scalar/oas-utils/helpers'\nimport type { RequestPayload } from '@scalar/workspace-store/request-example'\nimport * as cookie from 'cookie'\nimport { parseSetCookie } from 'set-cookie-parser'\n\nimport { getCookieHeaderKeys } from '@/v2/blocks/operation-block/helpers/get-cookie-header-keys'\nimport { resolveResponseBodyHandler } from '@/v2/blocks/response-block/helpers/resolve-response-body-handler'\nimport {\n resolveResponseContentType,\n resolveResponseMimeType,\n} from '@/v2/blocks/response-block/helpers/resolve-response-content-type'\n\nimport { decodeBuffer } from './decode-buffer'\n\nconst CUSTOM_COOKIE_HEADER = 'x-scalar-set-cookie'\n\n/** A single set of populated values for a sent request */\nexport type ResponseInstance = Omit<Response, 'headers'> & {\n /** Store headers as an object to match what we had with axios */\n headers: Record<string, string>\n /** Keys of headers which set cookies */\n cookieHeaderKeys: string[]\n /** Time in ms the request took */\n duration: number\n /** The response status */\n status: number\n /** The response status text */\n statusText: string\n /** The response method */\n method: HttpMethod\n /** The request path */\n path: string\n} & (\n | {\n /** The response data */\n data: string | Blob\n /** The response size in bytes */\n size: number\n }\n | {\n /** A stream reader for a streamable response body */\n reader: ReadableStreamDefaultReader<Uint8Array>\n }\n )\n\n/** HTTP status codes that should not include a response body */\nconst NO_BODY_STATUS_CODES = [204, 205, 304]\n\n/**\n * Execute the built fetch request and return a structured response.\n *\n * This function handles the complete request lifecycle including plugin hooks,\n * response processing, streaming detection, and error handling. It supports both\n * standard responses and server-sent event streams.\n *\n * @param request - The request built by the buildRequest helper\n * @param operation - The OpenAPI operation being executed\n * @param plugins - Array of client plugins to execute hooks\n * @param isUsingProxy - Whether the request is being proxied for header handling\n * @returns A tuple with either an error or the response data\n */\nexport const sendRequest = async ({\n isUsingProxy,\n requestPayload,\n plugins = [],\n}: {\n isUsingProxy: boolean\n requestPayload: RequestPayload\n /** Registered client plugins for custom content type handling */\n plugins?: ClientPlugin[]\n}): Promise<\n ErrorResponse<{\n response: ResponseInstance\n requestPayload: RequestPayload\n timestamp: number\n originalResponse: Response\n }>\n> => {\n try {\n // Execute the request and measure duration\n const startTime = performance.now()\n\n // We may use a custom fetch function on electron\n const response =\n isElectron() && window.proxiedFetch\n ? await window.proxiedFetch?.(...requestPayload)\n : await fetch(buildSafeBodyRequest(...requestPayload))\n\n const endTime = performance.now()\n const timestamp = Date.now()\n const duration = endTime - startTime\n\n // Extract response metadata early for reuse\n const contentType = response.headers.get('content-type')\n const responseHeaders = normalizeHeaders(response.headers, isUsingProxy)\n const responseUrl = new URL(response.url)\n const fullPath = responseUrl.pathname + responseUrl.search\n const statusText = response.statusText || httpStatusCodes[response.status]?.name || ''\n const method = (requestPayload[1].method ?? 'GET') as HttpMethod\n const shouldSkipBody = NO_BODY_STATUS_CODES.includes(response.status)\n\n /**\n * Handle server-sent event streams separately.\n * These responses need a reader instead of buffered data.\n * We check this early to avoid unnecessary body reading.\n */\n if (contentType?.startsWith('text/event-stream') && response.body) {\n return buildStreamingResponse({\n response,\n requestPayload,\n timestamp,\n duration,\n responseHeaders,\n statusText,\n method,\n fullPath,\n })\n }\n\n return buildStandardResponse({\n response,\n requestPayload,\n timestamp,\n duration,\n responseHeaders,\n statusText,\n method,\n fullPath,\n contentType,\n shouldSkipBody,\n plugins,\n })\n } catch (error) {\n return [normalizeError(error, ERRORS.REQUEST_FAILED), null]\n }\n}\n\n/**\n * Extracts and serializes custom cookies from the response using the custom cookie header.\n *\n * This function parses the custom cookie header (if present), serializes each cookie using the\n * 'cookie' library, and then deletes the custom cookie header from the response.\n * Returns an array of serialized cookie strings, or null if no cookies were found.\n *\n * The @ts-expect-error is present due to a type mismatch between the 'cookie' parsing and serialization libraries.\n */\nconst getCustomCookie = (response: Response): string[] | null => {\n const result = parseSetCookie(response.headers.get(CUSTOM_COOKIE_HEADER) ?? '').map((c) =>\n cookie.serialize(c.name, c.value, {\n ...c,\n sameSite: c.sameSite as boolean | 'lax' | 'strict' | 'none' | undefined,\n encode: (str: string) => str,\n }),\n )\n\n if (result.length) {\n return result\n }\n\n return null\n}\n\n/**\n * Build a streaming response for server-sent events.\n * Streaming responses use a reader instead of buffering the entire body.\n */\nconst buildStreamingResponse = ({\n response,\n requestPayload,\n timestamp,\n duration,\n responseHeaders,\n statusText,\n method,\n fullPath,\n}: {\n response: Response\n requestPayload: RequestPayload\n timestamp: number\n duration: number\n responseHeaders: Record<string, string>\n statusText: string\n method: HttpMethod\n fullPath: string\n}): ErrorResponse<{\n response: ResponseInstance\n requestPayload: RequestPayload\n timestamp: number\n originalResponse: Response\n}> => {\n const normalizedResponse = new Response(null, {\n status: response.status,\n statusText,\n headers: response.headers,\n })\n\n const customCookie = getCustomCookie(normalizedResponse)\n const cookieHeaderKeys = customCookie ?? getCookieHeaderKeys(normalizedResponse.headers)\n\n return [\n null,\n {\n timestamp,\n requestPayload,\n response: {\n ...normalizedResponse,\n headers: responseHeaders,\n cookieHeaderKeys,\n reader: response.body!.getReader(),\n duration,\n method,\n path: fullPath,\n },\n originalResponse: normalizedResponse.clone(),\n },\n ]\n}\n\n/**\n * Build a standard response with buffered body data.\n * This handles all non-streaming responses including JSON, text, and binary data.\n */\nconst buildStandardResponse = async ({\n response,\n requestPayload,\n timestamp,\n duration,\n responseHeaders,\n statusText,\n method,\n fullPath,\n contentType,\n shouldSkipBody,\n plugins,\n}: {\n response: Response\n requestPayload: RequestPayload\n timestamp: number\n duration: number\n responseHeaders: Record<string, string>\n statusText: string\n method: HttpMethod\n fullPath: string\n contentType: string | null\n shouldSkipBody: boolean\n plugins: ClientPlugin[]\n}): Promise<\n ErrorResponse<{\n response: ResponseInstance\n requestPayload: RequestPayload\n timestamp: number\n originalResponse: Response\n }>\n> => {\n /**\n * Clone the response to preserve the original for body reading.\n * Read the body once and reuse the buffer for both decoding and creating a new Response.\n */\n const clonedResponse = response.clone()\n const arrayBuffer = await clonedResponse.arrayBuffer()\n const responseType = resolveResponseContentType(contentType)\n const mimeEssence = resolveResponseMimeType(contentType).essence\n const pluginHandler = resolveResponseBodyHandler(mimeEssence, plugins)\n const responseData = await decodeBuffer(arrayBuffer, responseType, pluginHandler)\n\n /**\n * Create a new Response using the arrayBuffer we already read.\n * ArrayBuffers can be reused to create new Response objects without additional memory.\n */\n const normalizedResponse = new Response(shouldSkipBody ? null : arrayBuffer, {\n status: response.status,\n statusText,\n headers: response.headers,\n })\n\n const customCookie = getCustomCookie(normalizedResponse)\n const cookieHeaderKeys = customCookie ?? getCookieHeaderKeys(normalizedResponse.headers)\n\n return [\n null,\n {\n timestamp,\n requestPayload,\n response: {\n ...normalizedResponse,\n headers: responseHeaders,\n cookieHeaderKeys,\n data: responseData,\n size: arrayBuffer.byteLength,\n duration,\n method,\n status: response.status,\n path: fullPath,\n },\n originalResponse: response.clone(),\n },\n ]\n}\n"],"mappings":";;;;;;;;;;;;AAoBA,IAAM,uBAAuB;;AAgC7B,IAAM,uBAAuB;CAAC;CAAK;CAAK;CAAI;;;;;;;;;;;;;;AAe5C,IAAa,cAAc,OAAO,EAChC,cACA,gBACA,UAAU,EAAE,OAaT;AACH,KAAI;EAEF,MAAM,YAAY,YAAY,KAAK;EAGnC,MAAM,WACJ,YAAY,IAAI,OAAO,eACnB,MAAM,OAAO,eAAe,GAAG,eAAe,GAC9C,MAAM,MAAM,qBAAqB,GAAG,eAAe,CAAC;EAE1D,MAAM,UAAU,YAAY,KAAK;EACjC,MAAM,YAAY,KAAK,KAAK;EAC5B,MAAM,WAAW,UAAU;EAG3B,MAAM,cAAc,SAAS,QAAQ,IAAI,eAAe;EACxD,MAAM,kBAAkB,iBAAiB,SAAS,SAAS,aAAa;EACxE,MAAM,cAAc,IAAI,IAAI,SAAS,IAAI;EACzC,MAAM,WAAW,YAAY,WAAW,YAAY;EACpD,MAAM,aAAa,SAAS,cAAc,gBAAgB,SAAS,SAAS,QAAQ;EACpF,MAAM,SAAU,eAAe,GAAG,UAAU;EAC5C,MAAM,iBAAiB,qBAAqB,SAAS,SAAS,OAAO;;;;;;AAOrE,MAAI,aAAa,WAAW,oBAAoB,IAAI,SAAS,KAC3D,QAAO,uBAAuB;GAC5B;GAC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ACA,SAAS,SAAS;EACnB,CAAC;CAGF,MAAM,mBADe,gBAAgB,mBAAmB,IACf,oBAAoB,mBAAmB,QAAQ;AAExF,QAAO,CACL,MACA;EACE;EACA;EACA,UAAU;GACR,GAAG;GACH,SAAS;GACT;GACA,MAAM;GACN,MAAM,YAAY;GAClB;GACA;GACA,QAAQ,SAAS;GACjB,MAAM;GACP;EACD,kBAAkB,SAAS,OAAO;EACnC,CACF"}
@@ -10,9 +10,9 @@ import { groupBy } from "./helpers/group-by.js";
10
10
  import AuthSelector_default from "../scalar-auth-selector-block/components/AuthSelector.vue.js";
11
11
  import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, mergeProps, openBlock, ref, renderList, resolveDynamicComponent, toDisplayString, toHandlers, unref, useId, vShow, watch, withCtx, withDirectives } from "vue";
12
12
  import { ScalarErrorBoundary } from "@scalar/components";
13
+ import { canMethodHaveBody } from "@scalar/helpers/http/can-method-have-body";
13
14
  import { filterGlobalCookie, getEnvironmentVariables, getExample, getResolvedUrl } from "@scalar/workspace-store/request-example";
14
15
  import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref";
15
- import { canMethodHaveBody } from "@scalar/helpers/http/can-method-have-body";
16
16
  import { unpackProxyObject } from "@scalar/workspace-store/helpers/unpack-proxy";
17
17
  import { replaceEnvVariables } from "@scalar/helpers/regex/replace-variables";
18
18
  import { REGEX } from "@scalar/helpers/regex/regex-helpers";