@scalar/api-client 3.8.5 → 3.10.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.
- package/CHANGELOG.md +41 -0
- package/dist/plugins/posthog/sanitize-event-payload.d.ts.map +1 -1
- package/dist/plugins/posthog/sanitize-event-payload.js +2 -0
- package/dist/plugins/posthog/sanitize-event-payload.js.map +1 -1
- package/dist/style.css +16 -19
- package/dist/v2/blocks/channel-operation-block/helpers/connect-websocket.d.ts +46 -0
- package/dist/v2/blocks/channel-operation-block/helpers/connect-websocket.d.ts.map +1 -0
- package/dist/v2/blocks/channel-operation-block/helpers/websocket-session.d.ts +59 -0
- package/dist/v2/blocks/channel-operation-block/helpers/websocket-session.d.ts.map +1 -0
- package/dist/v2/blocks/channel-operation-block/index.d.ts +3 -0
- package/dist/v2/blocks/channel-operation-block/index.d.ts.map +1 -0
- package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue.js.map +1 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue.script.js +4 -0
- package/dist/v2/blocks/operation-block/OperationBlock.vue.script.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.d.ts +7 -4
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.js +1 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.script.js +28 -15
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.script.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/find-client.d.ts +31 -31
- package/dist/v2/blocks/operation-code-sample/helpers/find-client.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/find-client.js +32 -39
- package/dist/v2/blocks/operation-code-sample/helpers/find-client.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/format-language.d.ts +8 -0
- package/dist/v2/blocks/operation-code-sample/helpers/format-language.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/helpers/format-language.js +70 -0
- package/dist/v2/blocks/operation-code-sample/helpers/format-language.js.map +1 -0
- package/dist/v2/blocks/operation-code-sample/helpers/generate-client-options.d.ts +17 -2
- package/dist/v2/blocks/operation-code-sample/helpers/generate-client-options.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/generate-client-options.js +26 -3
- package/dist/v2/blocks/operation-code-sample/helpers/generate-client-options.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.js +2 -2
- package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-clients.d.ts +2 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-clients.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-clients.js +23 -17
- package/dist/v2/blocks/operation-code-sample/helpers/get-clients.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-custom-code-samples.d.ts +38 -3
- package/dist/v2/blocks/operation-code-sample/helpers/get-custom-code-samples.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-custom-code-samples.js +74 -8
- package/dist/v2/blocks/operation-code-sample/helpers/get-custom-code-samples.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.js +12 -87
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/index.d.ts +1 -1
- package/dist/v2/blocks/operation-code-sample/index.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/index.js +2 -2
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.script.js +11 -6
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.script.js.map +1 -1
- package/dist/v2/constants.js +1 -1
- package/dist/v2/workspace-events.d.ts.map +1 -1
- package/dist/v2/workspace-events.js +2 -0
- package/dist/v2/workspace-events.js.map +1 -1
- package/dist/vue-styles.css +7 -7
- package/package.json +19 -14
|
@@ -1 +1 @@
|
|
|
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 serializeDeepObjectStyle,\n serializeFormStyle,\n serializePipeDelimitedStyle,\n serializeSpaceDelimitedStyle,\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 * Stringify a value emitted by `serializeFormStyle` into a HAR param value.\n *\n * Form-style serialization only addresses one level of nesting per RFC6570;\n * deeper structures (an object or array still sitting in `entry.value`) are\n * spec-undefined. JSON-stringify them so authors get readable output instead\n * of `String(value)` returning `\"[object Object]\"`. Primitives pass through\n * `String()` to preserve the existing wire shape (e.g. `true` → `\"true\"`).\n */\nconst stringifyEntryValue = (value: unknown): string =>\n value !== null && typeof value === 'object' ? JSON.stringify(value) : String(value)\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 * Per OpenAPI 3.1.x Encoding Object: when style/explode/allowReserved is set on a\n * `multipart/form-data` or `application/x-www-form-urlencoded` part, the value is\n * serialized as if it were a query-style parameter and contentType is ignored. For\n * multipart the query delimiters are stripped per §Appendix C; HAR represents both\n * content types via `PostData.params`, so the same shape works for both.\n *\n * Primitives skip this branch and fall through to the String(value) path below since\n * style is a no-op for primitives. Files skip too, as do arrays containing Files —\n * RFC6570 expansion of binary data is undefined per §Appendix C, and the array branch\n * below already emits one `@filename` part per File.\n *\n * allowReserved only affects percent-encoding, which is a no-op at the HAR layer per\n * OAS 3.1.2 (\"`allowReserved` has no effect\" for multipart); its presence still opts\n * into this branch per spec.\n */\n if (\n !parentKey &&\n hasFormStyle &&\n typeof value === 'object' &&\n value !== null &&\n !(value instanceof File) &&\n !(Array.isArray(value) && value.some((item) => item instanceof File))\n ) {\n const unpacked = unpackProxyObject(value)\n /**\n * OAS 3.1.x Encoding Object: encoding follows query-parameter defaults — when no\n * `style` is set, the default is \"form\"; when no `explode` is set, the default is\n * `true` for \"form\" and `false` for every other style.\n */\n const style = partEncoding?.style ?? 'form'\n const explode = partEncoding?.explode ?? style === 'form'\n\n if (style === 'deepObject') {\n if (Array.isArray(unpacked)) {\n /**\n * OAS 3.1.1 marks deepObject-on-array as n/a; fall back to the form/explode:true\n * shape so the array still reaches the wire instead of being silently dropped.\n */\n const serialized = serializeFormStyle(unpacked, true)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n params.push({ name: entry.key || key, value: stringifyEntryValue(entry.value) })\n }\n } else {\n params.push({ name: key, value: String(serialized) })\n }\n } else {\n /**\n * explode:false with deepObject is undefined per spec; we invoke the serializer\n * either way so authors get useful output instead of nothing.\n */\n for (const entry of serializeDeepObjectStyle(key, unpacked)) {\n params.push({ name: entry.key, value: String(entry.value) })\n }\n }\n } else if (style === 'spaceDelimited') {\n params.push({ name: key, value: String(serializeSpaceDelimitedStyle(unpacked)) })\n } else if (style === 'pipeDelimited') {\n params.push({ name: key, value: String(serializePipeDelimitedStyle(unpacked)) })\n } else {\n const serialized = serializeFormStyle(unpacked, explode)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n /**\n * Arrays: entry.key === '' → fall back to the outer name.\n * Objects: entry.key is the inner property name (spec strips the outer name).\n *\n * Nested objects/arrays inside entry.value are spec-undefined (RFC6570 form-style\n * only addresses one level of nesting); JSON-stringify them instead of letting\n * String() emit \"[object Object]\". The escape hatch for cleaner output is\n * style: deepObject + explode: true.\n */\n params.push({ name: entry.key || key, value: stringifyEntryValue(entry.value) })\n }\n } else {\n params.push({ name: key, value: String(serialized) })\n }\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":";;;;;;;;;;;;;;;AAoCA,IAAM,uBAAuB,UAC3B,UAAU,QAAQ,OAAO,UAAU,WAAW,KAAK,UAAU,MAAM,GAAG,OAAO,MAAM;;;;;;;;;;;;;;;;;;;;;;AAuBrF,IAAM,sBACJ,KACA,UACA,WACA,cAAc,UACF;CACZ,MA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AGH,SAAO;GACL,UAAU;GACV,MAAM,OAAO,iBAAiB,WAAW,eAAe,KAAK,UAAU,aAAa;GACrF;;CAIH,MAAM,gBAAgB,eAAe,YAAY,QAAQ,eAAe,OAAO;AAC/E,KAAI,OAAO,kBAAkB,aAAa;EAExC,MAAM,mBAAmB,qBADK,mBAAmB,cAAc,EAG7D;GACE,sBAAsB;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
|
+
{"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,K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,iBAAiB,WAAW,eAAe,KAAK,UAAU,aAAa;GACrF;;CAIH,MAAM,gBAAgB,eAAe,YAAY,QAAQ,eAAe,OAAO;AAC/E,KAAI,OAAO,kBAAkB,aAAa;EAExC,MAAM,mBAAmB,qBADK,mBAAmB,cAAc,EAG7D;GACE,sBAAsB;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"}
|
|
@@ -2,7 +2,7 @@ export { default as ExamplePicker } from './components/ExamplePicker.vue.js';
|
|
|
2
2
|
export { default as HttpMethod } from './components/HttpMethod.vue.js';
|
|
3
3
|
export { default as OperationCodeSample } from './components/OperationCodeSample.vue.js';
|
|
4
4
|
export { filterClientsByQuery } from './helpers/filter-clients-by-query.js';
|
|
5
|
-
export { DEFAULT_CLIENT, findClient, isClient } from './helpers/find-client.js';
|
|
5
|
+
export { DEFAULT_CLIENT, type SelectedClientId, findClient, isClient, isSelectedClient } from './helpers/find-client.js';
|
|
6
6
|
export { generateClientOptions } from './helpers/generate-client-options.js';
|
|
7
7
|
export { getResolvedRefDeep } from './helpers/get-resolved-ref-deep.js';
|
|
8
8
|
export type { ClientOption, ClientOptionGroup, CustomClientOption, CustomClientOptionGroup } from './types';
|
|
@@ -1 +1 @@
|
|
|
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,UAAU,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;
|
|
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,MAAM,mCAAmC,CAAA;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AACpE,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -2,7 +2,7 @@ import ExamplePicker_default from "./components/ExamplePicker.vue.js";
|
|
|
2
2
|
import HttpMethod_default from "./components/HttpMethod.vue.js";
|
|
3
3
|
import { getResolvedRefDeep } from "./helpers/get-resolved-ref-deep.js";
|
|
4
4
|
import { filterClientsByQuery } from "./helpers/filter-clients-by-query.js";
|
|
5
|
-
import { DEFAULT_CLIENT, findClient, isClient } from "./helpers/find-client.js";
|
|
5
|
+
import { DEFAULT_CLIENT, findClient, isClient, isSelectedClient } from "./helpers/find-client.js";
|
|
6
6
|
import { generateClientOptions } from "./helpers/generate-client-options.js";
|
|
7
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, getResolvedRefDeep, isClient };
|
|
8
|
+
export { DEFAULT_CLIENT, ExamplePicker_default as ExamplePicker, HttpMethod_default as HttpMethod, OperationCodeSample_default as OperationCodeSample, filterClientsByQuery, findClient, generateClientOptions, getResolvedRefDeep, isClient, isSelectedClient };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestCodeSnippet.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/request-block/components/RequestCodeSnippet.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RequestCodeSnippet.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/request-block/components/RequestCodeSnippet.vue"],"names":[],"mappings":"AAuKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAQvE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sEAAsE,CAAA;AAQpH,KAAK,WAAW,GAAG,wBAAwB,GAAG;IAAE,QAAQ,EAAE,iBAAiB,CAAA;CAAE,CAAC;AA2S9E,QAAA,MAAM,YAAY,kSAEhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestCodeSnippet.vue.js","names":[],"sources":["../../../../../src/v2/blocks/request-block/components/RequestCodeSnippet.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport { ScalarCodeBlock } from '@scalar/components/code-block'\nimport { ScalarCombobox } from '@scalar/components/combobox'\nimport { ScalarErrorBoundary } from '@scalar/components/error-boundary'\nimport { ScalarIconCaretDown } from '@scalar/icons'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { computed, ref, watch } from 'vue'\n\nimport {\n findClient,\n type ClientOption,\n type CustomClientOption,\n} from '@/v2/blocks/operation-code-sample'\nimport type { OperationCodeSampleProps } from '@/v2/blocks/operation-code-sample/components/OperationCodeSample.vue'\nimport { generateCodeSnippet } from '@/v2/blocks/operation-code-sample/helpers/generate-code-snippet'\nimport { getClients } from '@/v2/blocks/operation-code-sample/helpers/get-clients'\nimport { getCustomCodeSamples } from '@/v2/blocks/operation-code-sample/helpers/get-custom-code-samples'\nimport { getSecrets } from '@/v2/blocks/operation-code-sample/helpers/get-secrets'\nimport { DataTable, DataTableRow } from '@/v2/components/data-table'\nimport { CollapsibleSection } from '@/v2/components/layout'\n\nconst {\n clientOptions,\n eventBus,\n operation,\n method,\n path,\n selectedContentType,\n selectedServer = null,\n selectedExample,\n securitySchemes,\n selectedClient,\n globalCookies,\n integration,\n} = defineProps<OperationCodeSampleProps & { eventBus: WorkspaceEventBus }>()\n\n/** Grab any custom code samples from the operation */\nconst customCodeSamples = computed(() => getCustomCodeSamples(operation))\n\n/** Merge custom code samples with the client options */\nconst clients = computed(() =>\n getClients(customCodeSamples.value
|
|
1
|
+
{"version":3,"file":"RequestCodeSnippet.vue.js","names":[],"sources":["../../../../../src/v2/blocks/request-block/components/RequestCodeSnippet.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport { ScalarCodeBlock } from '@scalar/components/code-block'\nimport { ScalarCombobox } from '@scalar/components/combobox'\nimport { ScalarErrorBoundary } from '@scalar/components/error-boundary'\nimport { ScalarIconCaretDown } from '@scalar/icons'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { computed, ref, watch } from 'vue'\n\nimport {\n findClient,\n type ClientOption,\n type CustomClientOption,\n} from '@/v2/blocks/operation-code-sample'\nimport type { OperationCodeSampleProps } from '@/v2/blocks/operation-code-sample/components/OperationCodeSample.vue'\nimport { generateCodeSnippet } from '@/v2/blocks/operation-code-sample/helpers/generate-code-snippet'\nimport { getClients } from '@/v2/blocks/operation-code-sample/helpers/get-clients'\nimport { getCustomCodeSamples } from '@/v2/blocks/operation-code-sample/helpers/get-custom-code-samples'\nimport { getSecrets } from '@/v2/blocks/operation-code-sample/helpers/get-secrets'\nimport { DataTable, DataTableRow } from '@/v2/components/data-table'\nimport { CollapsibleSection } from '@/v2/components/layout'\n\nconst {\n clientOptions,\n eventBus,\n operation,\n method,\n path,\n selectedContentType,\n selectedServer = null,\n selectedExample,\n securitySchemes,\n selectedClient,\n globalCookies,\n integration,\n} = defineProps<OperationCodeSampleProps & { eventBus: WorkspaceEventBus }>()\n\n/** Grab any custom code samples from the operation */\nconst customCodeSamples = computed(() => getCustomCodeSamples(operation))\n\n/** Merge custom code samples with the client options */\nconst clients = computed(() =>\n getClients(\n customCodeSamples.value.samples,\n clientOptions,\n customCodeSamples.value.label,\n ),\n)\n\n/**\n * The locally selected client which would include code samples from this operation only\n * Must be local state because it contains custom code samples from this operation only\n */\nconst localSelectedClient = ref<ClientOption | CustomClientOption | undefined>(\n findClient(clients.value, selectedClient),\n)\n\n/**\n * Re-resolve the local client whenever the global selection or the available\n * clients change. Watching `clients` matters when navigating between operations:\n * the stored id stays the same, but the matching option (e.g. a custom sample)\n * differs per operation, so without this the snippet could go stale.\n */\nwatch([() => selectedClient, clients], ([newClient]) => {\n const client = findClient(clients.value, newClient)\n if (client) {\n localSelectedClient.value = client\n }\n})\n\n/** Block secrets from being shown in the code block */\nconst secretCredentials = computed(() => getSecrets(securitySchemes ?? []))\n\n/** Handle client change */\nconst handleClientChange = (option: ClientOption | undefined) => {\n localSelectedClient.value = option\n\n // Sync the selection globally (built-in client or custom sample keyed by language)\n if (option) {\n eventBus.emit('workspace:update:selected-client', option.id)\n }\n}\n\n/** Generate the code snippet for the selected example */\nconst generatedCode = computed<string>(() =>\n generateCodeSnippet({\n defaultDisabledParameters: true,\n clientId: localSelectedClient.value?.id,\n customCodeSamples: customCodeSamples.value.samples,\n operation,\n method,\n path,\n contentType: selectedContentType,\n server: selectedServer,\n securitySchemes,\n example: selectedExample,\n globalCookies,\n includeDefaultHeaders: integration === 'client',\n }),\n)\n\n/** Check if there are any clients available (built-in or custom code samples) */\nconst hasClients = computed(() =>\n clients.value.some((group) => group.options.length > 0),\n)\n</script>\n\n<template>\n <CollapsibleSection\n v-show=\"hasClients\"\n class=\"group/preview w-full border-t\"\n :defaultOpen=\"false\">\n <template #title>Code Snippet</template>\n\n <!-- Client selector -->\n <template #actions>\n <div class=\"flex flex-1\">\n <ScalarCombobox\n :modelValue=\"localSelectedClient\"\n :options=\"clients\"\n placement=\"bottom-end\"\n @update:modelValue=\"\n (ev) => handleClientChange(ev as ClientOption | undefined)\n \">\n <template #default=\"{ open }\">\n <ScalarButton\n class=\"text-c-2 hover:text-c-1 flex h-full w-fit gap-1.5 px-0.5 py-0 text-base font-normal\"\n data-testid=\"client-picker\"\n variant=\"ghost\">\n {{ localSelectedClient?.title }}\n <ScalarIconCaretDown\n class=\"mt-0.25 size-3 transition-transform duration-100\"\n :class=\"open && 'rotate-180'\"\n weight=\"bold\" />\n </ScalarButton>\n </template>\n </ScalarCombobox>\n </div>\n </template>\n\n <!-- Code snippet -->\n <ScalarErrorBoundary>\n <DataTable\n :columns=\"['']\"\n presentational>\n <DataTableRow>\n <div class=\"overflow-hidden\">\n <ScalarCodeBlock\n class=\"text-base\"\n :content=\"generatedCode\"\n :hideCredentials=\"secretCredentials\"\n :lang=\"localSelectedClient?.lang ?? 'plaintext'\"\n lineNumbers />\n </div>\n </DataTableRow>\n </DataTable>\n </ScalarErrorBoundary>\n </CollapsibleSection>\n</template>\n"],"mappings":""}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import DataTable_default from "../../../components/data-table/DataTable.vue.js";
|
|
2
2
|
import DataTableRow_default from "../../../components/data-table/DataTableRow.vue.js";
|
|
3
3
|
import { findClient } from "../../operation-code-sample/helpers/find-client.js";
|
|
4
|
-
import { getClients } from "../../operation-code-sample/helpers/get-clients.js";
|
|
5
4
|
import { getCustomCodeSamples } from "../../operation-code-sample/helpers/get-custom-code-samples.js";
|
|
5
|
+
import { getClients } from "../../operation-code-sample/helpers/get-clients.js";
|
|
6
6
|
import { getSecrets } from "../../operation-code-sample/helpers/get-secrets.js";
|
|
7
7
|
import { generateCodeSnippet } from "../../operation-code-sample/helpers/generate-code-snippet.js";
|
|
8
8
|
import CollapsibleSection_default from "../../../components/layout/CollapsibleSection.vue.js";
|
|
@@ -39,14 +39,19 @@ var RequestCodeSnippet_vue_vue_type_script_setup_true_lang_default = /* @__PURE_
|
|
|
39
39
|
/** Grab any custom code samples from the operation */
|
|
40
40
|
const customCodeSamples = computed(() => getCustomCodeSamples(__props.operation));
|
|
41
41
|
/** Merge custom code samples with the client options */
|
|
42
|
-
const clients = computed(() => getClients(customCodeSamples.value, __props.clientOptions));
|
|
42
|
+
const clients = computed(() => getClients(customCodeSamples.value.samples, __props.clientOptions, customCodeSamples.value.label));
|
|
43
43
|
/**
|
|
44
44
|
* The locally selected client which would include code samples from this operation only
|
|
45
45
|
* Must be local state because it contains custom code samples from this operation only
|
|
46
46
|
*/
|
|
47
47
|
const localSelectedClient = ref(findClient(clients.value, __props.selectedClient));
|
|
48
|
-
/**
|
|
49
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Re-resolve the local client whenever the global selection or the available
|
|
50
|
+
* clients change. Watching `clients` matters when navigating between operations:
|
|
51
|
+
* the stored id stays the same, but the matching option (e.g. a custom sample)
|
|
52
|
+
* differs per operation, so without this the snippet could go stale.
|
|
53
|
+
*/
|
|
54
|
+
watch([() => __props.selectedClient, clients], ([newClient]) => {
|
|
50
55
|
const client = findClient(clients.value, newClient);
|
|
51
56
|
if (client) localSelectedClient.value = client;
|
|
52
57
|
});
|
|
@@ -55,13 +60,13 @@ var RequestCodeSnippet_vue_vue_type_script_setup_true_lang_default = /* @__PURE_
|
|
|
55
60
|
/** Handle client change */
|
|
56
61
|
const handleClientChange = (option) => {
|
|
57
62
|
localSelectedClient.value = option;
|
|
58
|
-
if (option
|
|
63
|
+
if (option) __props.eventBus.emit("workspace:update:selected-client", option.id);
|
|
59
64
|
};
|
|
60
65
|
/** Generate the code snippet for the selected example */
|
|
61
66
|
const generatedCode = computed(() => generateCodeSnippet({
|
|
62
67
|
defaultDisabledParameters: true,
|
|
63
68
|
clientId: localSelectedClient.value?.id,
|
|
64
|
-
customCodeSamples: customCodeSamples.value,
|
|
69
|
+
customCodeSamples: customCodeSamples.value.samples,
|
|
65
70
|
operation: __props.operation,
|
|
66
71
|
method: __props.method,
|
|
67
72
|
path: __props.path,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestCodeSnippet.vue.script.js","names":[],"sources":["../../../../../src/v2/blocks/request-block/components/RequestCodeSnippet.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport { ScalarCodeBlock } from '@scalar/components/code-block'\nimport { ScalarCombobox } from '@scalar/components/combobox'\nimport { ScalarErrorBoundary } from '@scalar/components/error-boundary'\nimport { ScalarIconCaretDown } from '@scalar/icons'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { computed, ref, watch } from 'vue'\n\nimport {\n findClient,\n type ClientOption,\n type CustomClientOption,\n} from '@/v2/blocks/operation-code-sample'\nimport type { OperationCodeSampleProps } from '@/v2/blocks/operation-code-sample/components/OperationCodeSample.vue'\nimport { generateCodeSnippet } from '@/v2/blocks/operation-code-sample/helpers/generate-code-snippet'\nimport { getClients } from '@/v2/blocks/operation-code-sample/helpers/get-clients'\nimport { getCustomCodeSamples } from '@/v2/blocks/operation-code-sample/helpers/get-custom-code-samples'\nimport { getSecrets } from '@/v2/blocks/operation-code-sample/helpers/get-secrets'\nimport { DataTable, DataTableRow } from '@/v2/components/data-table'\nimport { CollapsibleSection } from '@/v2/components/layout'\n\nconst {\n clientOptions,\n eventBus,\n operation,\n method,\n path,\n selectedContentType,\n selectedServer = null,\n selectedExample,\n securitySchemes,\n selectedClient,\n globalCookies,\n integration,\n} = defineProps<OperationCodeSampleProps & { eventBus: WorkspaceEventBus }>()\n\n/** Grab any custom code samples from the operation */\nconst customCodeSamples = computed(() => getCustomCodeSamples(operation))\n\n/** Merge custom code samples with the client options */\nconst clients = computed(() =>\n getClients(customCodeSamples.value
|
|
1
|
+
{"version":3,"file":"RequestCodeSnippet.vue.script.js","names":[],"sources":["../../../../../src/v2/blocks/request-block/components/RequestCodeSnippet.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport { ScalarCodeBlock } from '@scalar/components/code-block'\nimport { ScalarCombobox } from '@scalar/components/combobox'\nimport { ScalarErrorBoundary } from '@scalar/components/error-boundary'\nimport { ScalarIconCaretDown } from '@scalar/icons'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { computed, ref, watch } from 'vue'\n\nimport {\n findClient,\n type ClientOption,\n type CustomClientOption,\n} from '@/v2/blocks/operation-code-sample'\nimport type { OperationCodeSampleProps } from '@/v2/blocks/operation-code-sample/components/OperationCodeSample.vue'\nimport { generateCodeSnippet } from '@/v2/blocks/operation-code-sample/helpers/generate-code-snippet'\nimport { getClients } from '@/v2/blocks/operation-code-sample/helpers/get-clients'\nimport { getCustomCodeSamples } from '@/v2/blocks/operation-code-sample/helpers/get-custom-code-samples'\nimport { getSecrets } from '@/v2/blocks/operation-code-sample/helpers/get-secrets'\nimport { DataTable, DataTableRow } from '@/v2/components/data-table'\nimport { CollapsibleSection } from '@/v2/components/layout'\n\nconst {\n clientOptions,\n eventBus,\n operation,\n method,\n path,\n selectedContentType,\n selectedServer = null,\n selectedExample,\n securitySchemes,\n selectedClient,\n globalCookies,\n integration,\n} = defineProps<OperationCodeSampleProps & { eventBus: WorkspaceEventBus }>()\n\n/** Grab any custom code samples from the operation */\nconst customCodeSamples = computed(() => getCustomCodeSamples(operation))\n\n/** Merge custom code samples with the client options */\nconst clients = computed(() =>\n getClients(\n customCodeSamples.value.samples,\n clientOptions,\n customCodeSamples.value.label,\n ),\n)\n\n/**\n * The locally selected client which would include code samples from this operation only\n * Must be local state because it contains custom code samples from this operation only\n */\nconst localSelectedClient = ref<ClientOption | CustomClientOption | undefined>(\n findClient(clients.value, selectedClient),\n)\n\n/**\n * Re-resolve the local client whenever the global selection or the available\n * clients change. Watching `clients` matters when navigating between operations:\n * the stored id stays the same, but the matching option (e.g. a custom sample)\n * differs per operation, so without this the snippet could go stale.\n */\nwatch([() => selectedClient, clients], ([newClient]) => {\n const client = findClient(clients.value, newClient)\n if (client) {\n localSelectedClient.value = client\n }\n})\n\n/** Block secrets from being shown in the code block */\nconst secretCredentials = computed(() => getSecrets(securitySchemes ?? []))\n\n/** Handle client change */\nconst handleClientChange = (option: ClientOption | undefined) => {\n localSelectedClient.value = option\n\n // Sync the selection globally (built-in client or custom sample keyed by language)\n if (option) {\n eventBus.emit('workspace:update:selected-client', option.id)\n }\n}\n\n/** Generate the code snippet for the selected example */\nconst generatedCode = computed<string>(() =>\n generateCodeSnippet({\n defaultDisabledParameters: true,\n clientId: localSelectedClient.value?.id,\n customCodeSamples: customCodeSamples.value.samples,\n operation,\n method,\n path,\n contentType: selectedContentType,\n server: selectedServer,\n securitySchemes,\n example: selectedExample,\n globalCookies,\n includeDefaultHeaders: integration === 'client',\n }),\n)\n\n/** Check if there are any clients available (built-in or custom code samples) */\nconst hasClients = computed(() =>\n clients.value.some((group) => group.options.length > 0),\n)\n</script>\n\n<template>\n <CollapsibleSection\n v-show=\"hasClients\"\n class=\"group/preview w-full border-t\"\n :defaultOpen=\"false\">\n <template #title>Code Snippet</template>\n\n <!-- Client selector -->\n <template #actions>\n <div class=\"flex flex-1\">\n <ScalarCombobox\n :modelValue=\"localSelectedClient\"\n :options=\"clients\"\n placement=\"bottom-end\"\n @update:modelValue=\"\n (ev) => handleClientChange(ev as ClientOption | undefined)\n \">\n <template #default=\"{ open }\">\n <ScalarButton\n class=\"text-c-2 hover:text-c-1 flex h-full w-fit gap-1.5 px-0.5 py-0 text-base font-normal\"\n data-testid=\"client-picker\"\n variant=\"ghost\">\n {{ localSelectedClient?.title }}\n <ScalarIconCaretDown\n class=\"mt-0.25 size-3 transition-transform duration-100\"\n :class=\"open && 'rotate-180'\"\n weight=\"bold\" />\n </ScalarButton>\n </template>\n </ScalarCombobox>\n </div>\n </template>\n\n <!-- Code snippet -->\n <ScalarErrorBoundary>\n <DataTable\n :columns=\"['']\"\n presentational>\n <DataTableRow>\n <div class=\"overflow-hidden\">\n <ScalarCodeBlock\n class=\"text-base\"\n :content=\"generatedCode\"\n :hideCredentials=\"secretCredentials\"\n :lang=\"localSelectedClient?.lang ?? 'plaintext'\"\n lineNumbers />\n </div>\n </DataTableRow>\n </DataTable>\n </ScalarErrorBoundary>\n </CollapsibleSection>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsCA,MAAM,oBAAoB,eAAe,qBAAqB,QAAA,UAAU,CAAA;;EAGxE,MAAM,UAAU,eACd,WACE,kBAAkB,MAAM,SACxB,QAAA,eACA,kBAAkB,MAAM,MACzB,CACH;;;;;EAMA,MAAM,sBAAsB,IAC1B,WAAW,QAAQ,OAAO,QAAA,eAAe,CAC3C;;;;;;;AAQA,QAAM,OAAO,QAAA,gBAAgB,QAAQ,GAAG,CAAC,eAAe;GACtD,MAAM,SAAS,WAAW,QAAQ,OAAO,UAAS;AAClD,OAAI,OACF,qBAAoB,QAAQ;IAE/B;;EAGD,MAAM,oBAAoB,eAAe,WAAW,QAAA,mBAAmB,EAAE,CAAC,CAAA;;EAG1E,MAAM,sBAAsB,WAAqC;AAC/D,uBAAoB,QAAQ;AAG5B,OAAI,OACF,SAAA,SAAS,KAAK,oCAAoC,OAAO,GAAE;;;EAK/D,MAAM,gBA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QACT,iBAAiB,kBAAA;QACjB,MAAM,oBAAA,OAAqB,QAAI;QAChC,aAAA;;;;;;;;;;;;;sBA3CF,WAAA,MAAU,CAAA,CAAA"}
|
package/dist/v2/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/v2/constants.ts
|
|
2
2
|
/** The version number taken from the package.json. Consumers can override at build time via define (e.g. OVERRIDE_PACKAGE_VERSION: JSON.stringify('1.2.3')). */
|
|
3
|
-
var APP_VERSION = typeof OVERRIDE_PACKAGE_VERSION !== "undefined" ? OVERRIDE_PACKAGE_VERSION : "3.
|
|
3
|
+
var APP_VERSION = typeof OVERRIDE_PACKAGE_VERSION !== "undefined" ? OVERRIDE_PACKAGE_VERSION : "3.10.0";
|
|
4
4
|
//#endregion
|
|
5
5
|
export { APP_VERSION };
|
|
6
6
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-events.d.ts","sourceRoot":"","sources":["../../src/v2/workspace-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,KAAK,EAAE,kBAAkB,EAAkB,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAE3G,OAAO,EAAE,KAAK,GAAG,EAAY,MAAM,KAAK,CAAA;AAExC,KAAK,IAAI,CAAC,CAAC,SAAS,MAAM,kBAAkB,IAAI,OAAO,CAAC;IACtD,eAAe,EAAE,CACf,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC,KAC3B,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAA;IAClF,cAAc,EAAE,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACzE,CAAC,CAAA;AAEF,KAAK,KAAK,GAAG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E,GAAG,CAAC,cAAc,GAAG,IAAI,CAAC,CAAA;IACjC,KAAK,EAAE,KAAK,CAAA;CACb,QA+TA"}
|
|
@@ -77,6 +77,8 @@ function initializeWorkspaceEventHandlers({ eventBus, store, hooks }) {
|
|
|
77
77
|
eventBus.on("server:clear:servers", (payload) => withHook("server:clear:servers", mutators.value.active().server.clearServers, hooks)(payload));
|
|
78
78
|
eventBus.on("server:update:variables", (payload) => withHook("server:update:variables", mutators.value.active().server.updateServerVariables, hooks)(payload));
|
|
79
79
|
eventBus.on("server:update:selected", (payload) => withHook("server:update:selected", mutators.value.active().server.updateSelectedServer, hooks)(payload));
|
|
80
|
+
eventBus.on("asyncapi-server:update:selected", (payload) => withHook("asyncapi-server:update:selected", mutators.value.active().server.updateSelectedAsyncApiServer, hooks)(payload));
|
|
81
|
+
eventBus.on("asyncapi-server:update:variables", (payload) => withHook("asyncapi-server:update:variables", mutators.value.active().server.updateAsyncApiServerVariables, hooks)(payload));
|
|
80
82
|
eventBus.on("operation:create:operation", (payload) => withHook("operation:create:operation", mutators.value.active().operation.createOperation, hooks)(payload));
|
|
81
83
|
eventBus.on("operation:update:pathMethod", (payload) => withHook("operation:update:pathMethod", mutators.value.active().operation.updateOperationPathMethod, hooks)(payload));
|
|
82
84
|
eventBus.on("operation:update:meta", (payload) => withHook("operation:update:meta", mutators.value.active().operation.updateOperationMeta, hooks)(payload));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-events.js","names":[],"sources":["../../src/v2/workspace-events.ts"],"sourcesContent":["import type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport type { ApiReferenceEvents, CollectionType, WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { generateClientMutators } from '@scalar/workspace-store/mutators'\nimport { type Ref, computed } from 'vue'\n\ntype Hook<T extends keyof ApiReferenceEvents> = Partial<{\n onBeforeExecute: (\n payload: ApiReferenceEvents[T],\n ) => void | Promise<void> | ApiReferenceEvents[T] | Promise<ApiReferenceEvents[T]>\n onAfterExecute: (payload: ApiReferenceEvents[T]) => void | Promise<void>\n}>\n\ntype Hooks = {\n [key in keyof ApiReferenceEvents]?: Hook<key>\n}\n\n/**\n * Wraps a given function with optional before/after execution hooks for a specific event.\n * - Calls onBeforeExecute hook before executing the main function.\n * - Calls onAfterExecute hook after executing the main function.\n *\n * @template T The event key from ApiReferenceEvents\n * @param event The event name\n * @param fn The main function to execute\n * @param hooks The hooks object containing before/after hooks for events\n * @returns An async function that runs hooks around the main function\n */\nconst withHook = <T extends keyof ApiReferenceEvents>(\n event: T,\n fn: (args: ApiReferenceEvents[T]) => unknown | Promise<unknown>,\n hooks: Hooks,\n) => {\n return async (args: ApiReferenceEvents[T]) => {\n // Call the before execution hook for this event, if any\n const result = (await hooks[event]?.onBeforeExecute?.(args)) ?? args\n // Execute the main function\n await fn(result)\n // Call the after execution hook for this event, if any\n await hooks[event]?.onAfterExecute?.(result)\n return result\n }\n}\n\n/**\n * Initializes all Workspace Event Handlers by subscribing eventBus listeners\n * to each relevant mutator operation. Hooks are used for before/after execution.\n *\n * @param eventBus The WorkspaceEventBus to subscribe to\n * @param store The WorkspaceStore instance\n * @param hooks Object containing optional before/after hooks for each event\n */\nexport function initializeWorkspaceEventHandlers({\n eventBus,\n store,\n hooks,\n}: {\n eventBus: WorkspaceEventBus\n store: Ref<WorkspaceStore | null>\n hooks: Hooks\n}) {\n // Generate all client mutators for the current workspace store\n const mutators = computed(() => generateClientMutators(store.value))\n\n /**\n * Returns the appropriate mutators depending on the collectionType.\n * If collectionType is 'document', gets the active document mutator,\n * otherwise, gets the workspace mutator.\n */\n const getMutators = ({ collectionType }: CollectionType) => {\n if (collectionType === 'document') {\n return mutators.value.active()\n }\n return mutators.value.workspace()\n }\n\n //------------------------------------------------------------------------------------\n // Workspace Event Handlers\n //------------------------------------------------------------------------------------\n eventBus.on('workspace:update:active-proxy', (payload) =>\n withHook('workspace:update:active-proxy', mutators.value.workspace().workspace.updateActiveProxy, hooks)(payload),\n )\n eventBus.on('workspace:update:color-mode', (payload) =>\n withHook('workspace:update:color-mode', mutators.value.workspace().workspace.updateColorMode, hooks)(payload),\n )\n eventBus.on('workspace:update:theme', (payload) =>\n withHook('workspace:update:theme', mutators.value.workspace().workspace.updateTheme, hooks)(payload),\n )\n eventBus.on('workspace:update:selected-client', (payload) =>\n withHook(\n 'workspace:update:selected-client',\n mutators.value.workspace().workspace.updateSelectedClient,\n hooks,\n )(payload),\n )\n eventBus.on('workspace:update:active-environment', (payload) =>\n withHook(\n 'workspace:update:active-environment',\n mutators.value.workspace().workspace.updateActiveEnvironment,\n hooks,\n )(payload),\n )\n\n //------------------------------------------------------------------------------------\n // Document Event Handlers\n //------------------------------------------------------------------------------------\n eventBus.on('document:update:extension', (payload) =>\n withHook('document:update:extension', mutators.value.active().document.updateDocumentExtension, hooks)(payload),\n )\n eventBus.on('document:update:icon', (payload) =>\n withHook('document:update:icon', mutators.value.active().document.updateDocumentIcon, hooks)(payload),\n )\n eventBus.on('document:update:info', (payload) =>\n withHook('document:update:info', mutators.value.active().document.updateDocumentInfo, hooks)(payload),\n )\n eventBus.on('document:update:watch-mode', (payload) =>\n withHook('document:update:watch-mode', mutators.value.active().document.updateWatchMode, hooks)(payload),\n )\n eventBus.on('document:create:empty-document', (payload) =>\n withHook('document:create:empty-document', mutators.value.active().document.createEmptyDocument, hooks)(payload),\n )\n eventBus.on('document:delete:document', (payload) =>\n withHook('document:delete:document', mutators.value.active().document.deleteDocument, hooks)(payload),\n )\n\n //------------------------------------------------------------------------------------\n // Environment Event Handlers\n //------------------------------------------------------------------------------------\n eventBus.on('environment:upsert:environment', (payload) =>\n withHook('environment:upsert:environment', getMutators(payload).environment.upsertEnvironment, hooks)(payload),\n )\n eventBus.on('environment:delete:environment', (payload) =>\n withHook('environment:delete:environment', getMutators(payload).environment.deleteEnvironment, hooks)(payload),\n )\n eventBus.on('environment:upsert:environment-variable', (payload) =>\n withHook(\n 'environment:upsert:environment-variable',\n getMutators(payload).environment.upsertEnvironmentVariable,\n hooks,\n )(payload),\n )\n eventBus.on('environment:delete:environment-variable', (payload) =>\n withHook(\n 'environment:delete:environment-variable',\n getMutators(payload).environment.deleteEnvironmentVariable,\n hooks,\n )(payload),\n )\n\n //------------------------------------------------------------------------------------\n // Cookie Related Event Handlers\n //------------------------------------------------------------------------------------\n eventBus.on('cookie:upsert:cookie', async (payload) => {\n await withHook('cookie:upsert:cookie', getMutators(payload).cookie.upsertCookie, hooks)(payload)\n })\n eventBus.on('cookie:delete:cookie', async (payload) => {\n await withHook('cookie:delete:cookie', getMutators(payload).cookie.deleteCookie, hooks)(payload)\n })\n\n //------------------------------------------------------------------------------------\n // Auth Related Event Handlers\n //------------------------------------------------------------------------------------\n eventBus.on('auth:delete:security-scheme', (payload) =>\n withHook('auth:delete:security-scheme', mutators.value.active().auth.deleteSecurityScheme, hooks)(payload),\n )\n eventBus.on('auth:update:active-index', (payload) =>\n withHook('auth:update:active-index', mutators.value.active().auth.updateSelectedAuthTab, hooks)(payload),\n )\n eventBus.on('auth:update:security-scheme', (payload) =>\n withHook('auth:update:security-scheme', mutators.value.active().auth.updateSecurityScheme, hooks)(payload),\n )\n eventBus.on('auth:update:selected-scopes', (payload) =>\n withHook('auth:update:selected-scopes', mutators.value.active().auth.updateSelectedScopes, hooks)(payload),\n )\n eventBus.on('auth:upsert:scopes', (payload) =>\n withHook('auth:upsert:scopes', mutators.value.active().auth.upsertScope, hooks)(payload),\n )\n eventBus.on('auth:delete:scopes', (payload) =>\n withHook('auth:delete:scopes', mutators.value.active().auth.deleteScope, hooks)(payload),\n )\n eventBus.on('auth:update:selected-security-schemes', (payload) =>\n withHook(\n 'auth:update:selected-security-schemes',\n mutators.value.active().auth.updateSelectedSecuritySchemes,\n hooks,\n )(payload),\n )\n eventBus.on('auth:clear:selected-security-schemes', (payload) =>\n withHook(\n 'auth:clear:selected-security-schemes',\n mutators.value.active().auth.clearSelectedSecuritySchemes,\n hooks,\n )(payload),\n )\n eventBus.on('auth:update:security-scheme-secrets', (payload) =>\n withHook(\n 'auth:update:security-scheme-secrets',\n mutators.value.active().auth.updateSecuritySchemeSecrets,\n hooks,\n )(payload),\n )\n eventBus.on('auth:clear:security-scheme-secrets', (payload) =>\n withHook(\n 'auth:clear:security-scheme-secrets',\n mutators.value.active().auth.clearSecuritySchemeSecrets,\n hooks,\n )(payload),\n )\n\n //------------------------------------------------------------------------------------\n // Server Related Event Handlers\n //------------------------------------------------------------------------------------\n eventBus.on('server:initialize:servers', (payload) =>\n withHook('server:initialize:servers', mutators.value.active().server.initializeServers, hooks)(payload),\n )\n eventBus.on('server:add:server', (payload) =>\n withHook('server:add:server', mutators.value.active().server.addServer, hooks)(payload),\n )\n eventBus.on('server:update:server', (payload) =>\n withHook('server:update:server', mutators.value.active().server.updateServer, hooks)(payload),\n )\n eventBus.on('server:delete:server', (payload) =>\n withHook('server:delete:server', mutators.value.active().server.deleteServer, hooks)(payload),\n )\n eventBus.on('server:clear:servers', (payload) =>\n withHook('server:clear:servers', mutators.value.active().server.clearServers, hooks)(payload),\n )\n eventBus.on('server:update:variables', (payload) =>\n withHook('server:update:variables', mutators.value.active().server.updateServerVariables, hooks)(payload),\n )\n eventBus.on('server:update:selected', (payload) =>\n withHook('server:update:selected', mutators.value.active().server.updateSelectedServer, hooks)(payload),\n )\n\n //------------------------------------------------------------------------------------\n // Operation Related Event Handlers\n //------------------------------------------------------------------------------------\n eventBus.on('operation:create:operation', (payload) =>\n withHook('operation:create:operation', mutators.value.active().operation.createOperation, hooks)(payload),\n )\n eventBus.on('operation:update:pathMethod', (payload) =>\n withHook(\n 'operation:update:pathMethod',\n mutators.value.active().operation.updateOperationPathMethod,\n hooks,\n )(payload),\n )\n eventBus.on('operation:update:meta', (payload) =>\n withHook('operation:update:meta', mutators.value.active().operation.updateOperationMeta, hooks)(payload),\n )\n eventBus.on('operation:delete:operation', (payload) =>\n withHook('operation:delete:operation', mutators.value.active().operation.deleteOperation, hooks)(payload),\n )\n eventBus.on('operation:create:draft-example', (payload) =>\n withHook(\n 'operation:create:draft-example',\n mutators.value.active().operation.createOperationDraftExample,\n hooks,\n )(payload),\n )\n eventBus.on('operation:delete:example', (payload) =>\n withHook('operation:delete:example', mutators.value.active().operation.deleteOperationExample, hooks)(payload),\n )\n eventBus.on('operation:rename:example', (payload) =>\n withHook('operation:rename:example', mutators.value.active().operation.renameOperationExample, hooks)(payload),\n )\n eventBus.on('operation:upsert:parameter', (payload) =>\n withHook('operation:upsert:parameter', mutators.value.active().operation.upsertOperationParameter, hooks)(payload),\n )\n eventBus.on('operation:update:extra-parameters', (payload) =>\n withHook(\n 'operation:update:extra-parameters',\n mutators.value.active().operation.updateOperationExtraParameters,\n hooks,\n )(payload),\n )\n eventBus.on('operation:delete:parameter', (payload) =>\n withHook('operation:delete:parameter', mutators.value.active().operation.deleteOperationParameter, hooks)(payload),\n )\n eventBus.on('operation:delete-all:parameters', (payload) =>\n withHook(\n 'operation:delete-all:parameters',\n mutators.value.active().operation.deleteAllOperationParameters,\n hooks,\n )(payload),\n )\n eventBus.on('operation:update:extension', (payload) =>\n withHook('operation:update:extension', mutators.value.active().operation.updateOperationExtension, hooks)(payload),\n )\n\n //------------------------------------------------------------------------------------\n // Operation Request Body Related Event Handlers\n //------------------------------------------------------------------------------------\n eventBus.on('operation:update:requestBody:contentType', (payload) =>\n withHook(\n 'operation:update:requestBody:contentType',\n mutators.value.active().operation.updateOperationRequestBodyContentType,\n hooks,\n )(payload),\n )\n eventBus.on('operation:update:requestBody:value', (payload) =>\n withHook(\n 'operation:update:requestBody:value',\n mutators.value.active().operation.updateOperationRequestBodyExample,\n hooks,\n )(payload),\n )\n eventBus.on('operation:update:requestBody:formValue', (payload) =>\n withHook(\n 'operation:update:requestBody:formValue',\n mutators.value.active().operation.updateOperationRequestBodyFormValue,\n hooks,\n )(payload),\n )\n eventBus.on('operation:reload:history', (payload) =>\n withHook('operation:reload:history', mutators.value.active().operation.reloadOperationHistory, hooks)(payload),\n )\n\n //------------------------------------------------------------------------------------\n // Tag Related Event Handlers\n //------------------------------------------------------------------------------------\n eventBus.on('tag:create:tag', (payload) =>\n withHook('tag:create:tag', mutators.value.active().tag.createTag, hooks)(payload),\n )\n eventBus.on('tag:edit:tag', (payload) =>\n withHook('tag:edit:tag', mutators.value.active().tag.editTag, hooks)(payload),\n )\n eventBus.on('tag:delete:tag', (payload) =>\n withHook('tag:delete:tag', mutators.value.active().tag.deleteTag, hooks)(payload),\n )\n\n //------------------------------------------------------------------------------------\n // Tabs Related Event Handlers\n //------------------------------------------------------------------------------------\n eventBus.on('tabs:add:tab', (payload) =>\n withHook('tabs:add:tab', mutators.value.workspace().tabs.addTab, hooks)(payload),\n )\n eventBus.on('tabs:close:tab', (payload) =>\n withHook('tabs:close:tab', mutators.value.workspace().tabs.closeTab, hooks)(payload),\n )\n eventBus.on('tabs:close:other-tabs', (payload) =>\n withHook('tabs:close:other-tabs', mutators.value.workspace().tabs.closeOtherTabs, hooks)(payload),\n )\n eventBus.on('tabs:focus:tab', (payload) =>\n withHook('tabs:focus:tab', mutators.value.workspace().tabs.focusTab, hooks)(payload),\n )\n eventBus.on('tabs:focus:tab-last', (payload) =>\n withHook('tabs:focus:tab-last', mutators.value.workspace().tabs.focusLastTab, hooks)(payload),\n )\n eventBus.on('tabs:navigate:previous', (payload) =>\n withHook('tabs:navigate:previous', mutators.value.workspace().tabs.navigatePreviousTab, hooks)(payload),\n )\n eventBus.on('tabs:navigate:next', (payload) =>\n withHook('tabs:navigate:next', mutators.value.workspace().tabs.navigateNextTab, hooks)(payload),\n )\n eventBus.on('tabs:update:tabs', (payload) =>\n withHook('tabs:update:tabs', mutators.value.workspace().tabs.updateTabs, hooks)(payload),\n )\n\n //------------------------------------------------------------------------------------\n // Hooks Related Event Handlers\n //------------------------------------------------------------------------------------\n eventBus.on('hooks:on:request:complete', (payload) =>\n withHook('hooks:on:request:complete', mutators.value.active().operation.addResponseToHistory, hooks)(payload),\n )\n}\n"],"mappings":";;;;;;;;;;;;;;A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CAAC,IAAI,WAAW,MAAM,CAAC,QAAQ,CAClF;AAKD,UAAS,GAAG,iBAAiB,YAC3B,SAAS,gBAAgB,SAAS,MAAM,WAAW,CAAC,KAAK,QAAQ,MAAM,CAAC,QAAQ,CACjF;AACD,UAAS,GAAG,mBAAmB,YAC7B,SAAS,kBAAkB,SAAS,MAAM,WAAW,CAAC,KAAK,UAAU,MAAM,CAAC,QAAQ,CACrF;AACD,UAAS,GAAG,0BAA0B,YACpC,SAAS,yBAAyB,SAAS,MAAM,WAAW,CAAC,KAAK,gBAAgB,MAAM,CAAC,QAAQ,CAClG;AACD,UAAS,GAAG,mBAAmB,YAC7B,SAAS,kBAAkB,SAAS,MAAM,WAAW,CAAC,KAAK,UAAU,MAAM,CAAC,QAAQ,CACrF;AACD,UAAS,GAAG,wBAAwB,YAClC,SAAS,uBAAuB,SAAS,MAAM,WAAW,CAAC,KAAK,cAAc,MAAM,CAAC,QAAQ,CAC9F;AACD,UAAS,GAAG,2BAA2B,YACrC,SAAS,0BAA0B,SAAS,MAAM,WAAW,CAAC,KAAK,qBAAqB,MAAM,CAAC,QAAQ,CACxG;AACD,UAAS,GAAG,uBAAuB,YACjC,SAAS,sBAAsB,SAAS,MAAM,WAAW,CAAC,KAAK,iBAAiB,MAAM,CAAC,QAAQ,CAChG;AACD,UAAS,GAAG,qBAAqB,YAC/B,SAAS,oBAAoB,SAAS,MAAM,WAAW,CAAC,KAAK,YAAY,MAAM,CAAC,QAAQ,CACzF;AAKD,UAAS,GAAG,8BAA8B,YACxC,SAAS,6BAA6B,SAAS,MAAM,QAAQ,CAAC,UAAU,sBAAsB,MAAM,CAAC,QAAQ,CAC9G"}
|
|
1
|
+
{"version":3,"file":"workspace-events.js","names":[],"sources":["../../src/v2/workspace-events.ts"],"sourcesContent":["import type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport type { ApiReferenceEvents, CollectionType, WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { generateClientMutators } from '@scalar/workspace-store/mutators'\nimport { type Ref, computed } from 'vue'\n\ntype Hook<T extends keyof ApiReferenceEvents> = Partial<{\n onBeforeExecute: (\n payload: ApiReferenceEvents[T],\n ) => void | Promise<void> | ApiReferenceEvents[T] | Promise<ApiReferenceEvents[T]>\n onAfterExecute: (payload: ApiReferenceEvents[T]) => void | Promise<void>\n}>\n\ntype Hooks = {\n [key in keyof ApiReferenceEvents]?: Hook<key>\n}\n\n/**\n * Wraps a given function with optional before/after execution hooks for a specific event.\n * - Calls onBeforeExecute hook before executing the main function.\n * - Calls onAfterExecute hook after executing the main function.\n *\n * @template T The event key from ApiReferenceEvents\n * @param event The event name\n * @param fn The main function to execute\n * @param hooks The hooks object containing before/after hooks for events\n * @returns An async function that runs hooks around the main function\n */\nconst withHook = <T extends keyof ApiReferenceEvents>(\n event: T,\n fn: (args: ApiReferenceEvents[T]) => unknown | Promise<unknown>,\n hooks: Hooks,\n) => {\n return async (args: ApiReferenceEvents[T]) => {\n // Call the before execution hook for this event, if any\n const result = (await hooks[event]?.onBeforeExecute?.(args)) ?? args\n // Execute the main function\n await fn(result)\n // Call the after execution hook for this event, if any\n await hooks[event]?.onAfterExecute?.(result)\n return result\n }\n}\n\n/**\n * Initializes all Workspace Event Handlers by subscribing eventBus listeners\n * to each relevant mutator operation. Hooks are used for before/after execution.\n *\n * @param eventBus The WorkspaceEventBus to subscribe to\n * @param store The WorkspaceStore instance\n * @param hooks Object containing optional before/after hooks for each event\n */\nexport function initializeWorkspaceEventHandlers({\n eventBus,\n store,\n hooks,\n}: {\n eventBus: WorkspaceEventBus\n store: Ref<WorkspaceStore | null>\n hooks: Hooks\n}) {\n // Generate all client mutators for the current workspace store\n const mutators = computed(() => generateClientMutators(store.value))\n\n /**\n * Returns the appropriate mutators depending on the collectionType.\n * If collectionType is 'document', gets the active document mutator,\n * otherwise, gets the workspace mutator.\n */\n const getMutators = ({ collectionType }: CollectionType) => {\n if (collectionType === 'document') {\n return mutators.value.active()\n }\n return mutators.value.workspace()\n }\n\n //------------------------------------------------------------------------------------\n // Workspace Event Handlers\n //------------------------------------------------------------------------------------\n eventBus.on('workspace:update:active-proxy', (payload) =>\n withHook('workspace:update:active-proxy', mutators.value.workspace().workspace.updateActiveProxy, hooks)(payload),\n )\n eventBus.on('workspace:update:color-mode', (payload) =>\n withHook('workspace:update:color-mode', mutators.value.workspace().workspace.updateColorMode, hooks)(payload),\n )\n eventBus.on('workspace:update:theme', (payload) =>\n withHook('workspace:update:theme', mutators.value.workspace().workspace.updateTheme, hooks)(payload),\n )\n eventBus.on('workspace:update:selected-client', (payload) =>\n withHook(\n 'workspace:update:selected-client',\n mutators.value.workspace().workspace.updateSelectedClient,\n hooks,\n )(payload),\n )\n eventBus.on('workspace:update:active-environment', (payload) =>\n withHook(\n 'workspace:update:active-environment',\n mutators.value.workspace().workspace.updateActiveEnvironment,\n hooks,\n )(payload),\n )\n\n //------------------------------------------------------------------------------------\n // Document Event Handlers\n //------------------------------------------------------------------------------------\n eventBus.on('document:update:extension', (payload) =>\n withHook('document:update:extension', mutators.value.active().document.updateDocumentExtension, hooks)(payload),\n )\n eventBus.on('document:update:icon', (payload) =>\n withHook('document:update:icon', mutators.value.active().document.updateDocumentIcon, hooks)(payload),\n )\n eventBus.on('document:update:info', (payload) =>\n withHook('document:update:info', mutators.value.active().document.updateDocumentInfo, hooks)(payload),\n )\n eventBus.on('document:update:watch-mode', (payload) =>\n withHook('document:update:watch-mode', mutators.value.active().document.updateWatchMode, hooks)(payload),\n )\n eventBus.on('document:create:empty-document', (payload) =>\n withHook('document:create:empty-document', mutators.value.active().document.createEmptyDocument, hooks)(payload),\n )\n eventBus.on('document:delete:document', (payload) =>\n withHook('document:delete:document', mutators.value.active().document.deleteDocument, hooks)(payload),\n )\n\n //------------------------------------------------------------------------------------\n // Environment Event Handlers\n //------------------------------------------------------------------------------------\n eventBus.on('environment:upsert:environment', (payload) =>\n withHook('environment:upsert:environment', getMutators(payload).environment.upsertEnvironment, hooks)(payload),\n )\n eventBus.on('environment:delete:environment', (payload) =>\n withHook('environment:delete:environment', getMutators(payload).environment.deleteEnvironment, hooks)(payload),\n )\n eventBus.on('environment:upsert:environment-variable', (payload) =>\n withHook(\n 'environment:upsert:environment-variable',\n getMutators(payload).environment.upsertEnvironmentVariable,\n hooks,\n )(payload),\n )\n eventBus.on('environment:delete:environment-variable', (payload) =>\n withHook(\n 'environment:delete:environment-variable',\n getMutators(payload).environment.deleteEnvironmentVariable,\n hooks,\n )(payload),\n )\n\n //------------------------------------------------------------------------------------\n // Cookie Related Event Handlers\n //------------------------------------------------------------------------------------\n eventBus.on('cookie:upsert:cookie', async (payload) => {\n await withHook('cookie:upsert:cookie', getMutators(payload).cookie.upsertCookie, hooks)(payload)\n })\n eventBus.on('cookie:delete:cookie', async (payload) => {\n await withHook('cookie:delete:cookie', getMutators(payload).cookie.deleteCookie, hooks)(payload)\n })\n\n //------------------------------------------------------------------------------------\n // Auth Related Event Handlers\n //------------------------------------------------------------------------------------\n eventBus.on('auth:delete:security-scheme', (payload) =>\n withHook('auth:delete:security-scheme', mutators.value.active().auth.deleteSecurityScheme, hooks)(payload),\n )\n eventBus.on('auth:update:active-index', (payload) =>\n withHook('auth:update:active-index', mutators.value.active().auth.updateSelectedAuthTab, hooks)(payload),\n )\n eventBus.on('auth:update:security-scheme', (payload) =>\n withHook('auth:update:security-scheme', mutators.value.active().auth.updateSecurityScheme, hooks)(payload),\n )\n eventBus.on('auth:update:selected-scopes', (payload) =>\n withHook('auth:update:selected-scopes', mutators.value.active().auth.updateSelectedScopes, hooks)(payload),\n )\n eventBus.on('auth:upsert:scopes', (payload) =>\n withHook('auth:upsert:scopes', mutators.value.active().auth.upsertScope, hooks)(payload),\n )\n eventBus.on('auth:delete:scopes', (payload) =>\n withHook('auth:delete:scopes', mutators.value.active().auth.deleteScope, hooks)(payload),\n )\n eventBus.on('auth:update:selected-security-schemes', (payload) =>\n withHook(\n 'auth:update:selected-security-schemes',\n mutators.value.active().auth.updateSelectedSecuritySchemes,\n hooks,\n )(payload),\n )\n eventBus.on('auth:clear:selected-security-schemes', (payload) =>\n withHook(\n 'auth:clear:selected-security-schemes',\n mutators.value.active().auth.clearSelectedSecuritySchemes,\n hooks,\n )(payload),\n )\n eventBus.on('auth:update:security-scheme-secrets', (payload) =>\n withHook(\n 'auth:update:security-scheme-secrets',\n mutators.value.active().auth.updateSecuritySchemeSecrets,\n hooks,\n )(payload),\n )\n eventBus.on('auth:clear:security-scheme-secrets', (payload) =>\n withHook(\n 'auth:clear:security-scheme-secrets',\n mutators.value.active().auth.clearSecuritySchemeSecrets,\n hooks,\n )(payload),\n )\n\n //------------------------------------------------------------------------------------\n // Server Related Event Handlers\n //------------------------------------------------------------------------------------\n eventBus.on('server:initialize:servers', (payload) =>\n withHook('server:initialize:servers', mutators.value.active().server.initializeServers, hooks)(payload),\n )\n eventBus.on('server:add:server', (payload) =>\n withHook('server:add:server', mutators.value.active().server.addServer, hooks)(payload),\n )\n eventBus.on('server:update:server', (payload) =>\n withHook('server:update:server', mutators.value.active().server.updateServer, hooks)(payload),\n )\n eventBus.on('server:delete:server', (payload) =>\n withHook('server:delete:server', mutators.value.active().server.deleteServer, hooks)(payload),\n )\n eventBus.on('server:clear:servers', (payload) =>\n withHook('server:clear:servers', mutators.value.active().server.clearServers, hooks)(payload),\n )\n eventBus.on('server:update:variables', (payload) =>\n withHook('server:update:variables', mutators.value.active().server.updateServerVariables, hooks)(payload),\n )\n eventBus.on('server:update:selected', (payload) =>\n withHook('server:update:selected', mutators.value.active().server.updateSelectedServer, hooks)(payload),\n )\n eventBus.on('asyncapi-server:update:selected', (payload) =>\n withHook(\n 'asyncapi-server:update:selected',\n mutators.value.active().server.updateSelectedAsyncApiServer,\n hooks,\n )(payload),\n )\n eventBus.on('asyncapi-server:update:variables', (payload) =>\n withHook(\n 'asyncapi-server:update:variables',\n mutators.value.active().server.updateAsyncApiServerVariables,\n hooks,\n )(payload),\n )\n\n //------------------------------------------------------------------------------------\n // Operation Related Event Handlers\n //------------------------------------------------------------------------------------\n eventBus.on('operation:create:operation', (payload) =>\n withHook('operation:create:operation', mutators.value.active().operation.createOperation, hooks)(payload),\n )\n eventBus.on('operation:update:pathMethod', (payload) =>\n withHook(\n 'operation:update:pathMethod',\n mutators.value.active().operation.updateOperationPathMethod,\n hooks,\n )(payload),\n )\n eventBus.on('operation:update:meta', (payload) =>\n withHook('operation:update:meta', mutators.value.active().operation.updateOperationMeta, hooks)(payload),\n )\n eventBus.on('operation:delete:operation', (payload) =>\n withHook('operation:delete:operation', mutators.value.active().operation.deleteOperation, hooks)(payload),\n )\n eventBus.on('operation:create:draft-example', (payload) =>\n withHook(\n 'operation:create:draft-example',\n mutators.value.active().operation.createOperationDraftExample,\n hooks,\n )(payload),\n )\n eventBus.on('operation:delete:example', (payload) =>\n withHook('operation:delete:example', mutators.value.active().operation.deleteOperationExample, hooks)(payload),\n )\n eventBus.on('operation:rename:example', (payload) =>\n withHook('operation:rename:example', mutators.value.active().operation.renameOperationExample, hooks)(payload),\n )\n eventBus.on('operation:upsert:parameter', (payload) =>\n withHook('operation:upsert:parameter', mutators.value.active().operation.upsertOperationParameter, hooks)(payload),\n )\n eventBus.on('operation:update:extra-parameters', (payload) =>\n withHook(\n 'operation:update:extra-parameters',\n mutators.value.active().operation.updateOperationExtraParameters,\n hooks,\n )(payload),\n )\n eventBus.on('operation:delete:parameter', (payload) =>\n withHook('operation:delete:parameter', mutators.value.active().operation.deleteOperationParameter, hooks)(payload),\n )\n eventBus.on('operation:delete-all:parameters', (payload) =>\n withHook(\n 'operation:delete-all:parameters',\n mutators.value.active().operation.deleteAllOperationParameters,\n hooks,\n )(payload),\n )\n eventBus.on('operation:update:extension', (payload) =>\n withHook('operation:update:extension', mutators.value.active().operation.updateOperationExtension, hooks)(payload),\n )\n\n //------------------------------------------------------------------------------------\n // Operation Request Body Related Event Handlers\n //------------------------------------------------------------------------------------\n eventBus.on('operation:update:requestBody:contentType', (payload) =>\n withHook(\n 'operation:update:requestBody:contentType',\n mutators.value.active().operation.updateOperationRequestBodyContentType,\n hooks,\n )(payload),\n )\n eventBus.on('operation:update:requestBody:value', (payload) =>\n withHook(\n 'operation:update:requestBody:value',\n mutators.value.active().operation.updateOperationRequestBodyExample,\n hooks,\n )(payload),\n )\n eventBus.on('operation:update:requestBody:formValue', (payload) =>\n withHook(\n 'operation:update:requestBody:formValue',\n mutators.value.active().operation.updateOperationRequestBodyFormValue,\n hooks,\n )(payload),\n )\n eventBus.on('operation:reload:history', (payload) =>\n withHook('operation:reload:history', mutators.value.active().operation.reloadOperationHistory, hooks)(payload),\n )\n\n //------------------------------------------------------------------------------------\n // Tag Related Event Handlers\n //------------------------------------------------------------------------------------\n eventBus.on('tag:create:tag', (payload) =>\n withHook('tag:create:tag', mutators.value.active().tag.createTag, hooks)(payload),\n )\n eventBus.on('tag:edit:tag', (payload) =>\n withHook('tag:edit:tag', mutators.value.active().tag.editTag, hooks)(payload),\n )\n eventBus.on('tag:delete:tag', (payload) =>\n withHook('tag:delete:tag', mutators.value.active().tag.deleteTag, hooks)(payload),\n )\n\n //------------------------------------------------------------------------------------\n // Tabs Related Event Handlers\n //------------------------------------------------------------------------------------\n eventBus.on('tabs:add:tab', (payload) =>\n withHook('tabs:add:tab', mutators.value.workspace().tabs.addTab, hooks)(payload),\n )\n eventBus.on('tabs:close:tab', (payload) =>\n withHook('tabs:close:tab', mutators.value.workspace().tabs.closeTab, hooks)(payload),\n )\n eventBus.on('tabs:close:other-tabs', (payload) =>\n withHook('tabs:close:other-tabs', mutators.value.workspace().tabs.closeOtherTabs, hooks)(payload),\n )\n eventBus.on('tabs:focus:tab', (payload) =>\n withHook('tabs:focus:tab', mutators.value.workspace().tabs.focusTab, hooks)(payload),\n )\n eventBus.on('tabs:focus:tab-last', (payload) =>\n withHook('tabs:focus:tab-last', mutators.value.workspace().tabs.focusLastTab, hooks)(payload),\n )\n eventBus.on('tabs:navigate:previous', (payload) =>\n withHook('tabs:navigate:previous', mutators.value.workspace().tabs.navigatePreviousTab, hooks)(payload),\n )\n eventBus.on('tabs:navigate:next', (payload) =>\n withHook('tabs:navigate:next', mutators.value.workspace().tabs.navigateNextTab, hooks)(payload),\n )\n eventBus.on('tabs:update:tabs', (payload) =>\n withHook('tabs:update:tabs', mutators.value.workspace().tabs.updateTabs, hooks)(payload),\n )\n\n //------------------------------------------------------------------------------------\n // Hooks Related Event Handlers\n //------------------------------------------------------------------------------------\n eventBus.on('hooks:on:request:complete', (payload) =>\n withHook('hooks:on:request:complete', mutators.value.active().operation.addResponseToHistory, hooks)(payload),\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AA2BA,IAAM,YACJ,OACA,IACA,UACG;AACH,QAAO,OAAO,SAAgC;EAE5C,MAAM,SAAU,MAAM,MAAM,QAAQ,kBAAkB,KAAK,IAAK;AAEhE,QAAM,GAAG,OAAO;AAEhB,QAAM,MAAM,QAAQ,iBAAiB,OAAO;AAC5C,SAAO;;;;;;;;;;;AAYX,SAAgB,iCAAiC,EAC/C,UACA,OACA,SAKC;CAED,MAAM,WAAW,eAAe,uBAAuB,MAAM,MAAM,CAAC;;;;;;CAOpE,MAAM,eAAe,EAAE,qBAAqC;AAC1D,MAAI,mBAAmB,WACrB,QAAO,SAAS,MAAM,QAAQ;AAEhC,SAAO,SAAS,MAAM,WAAW;;AAMnC,UAAS,GAAG,kCAAkC,YAC5C,SAAS,iCAAiC,SAAS,MAAM,WAAW,CAAC,UAAU,mBAAmB,MAAM,CAAC,QAAQ,CAClH;AACD,UAAS,GAAG,gCAAgC,YAC1C,SAAS,+BAA+B,SAAS,MAAM,WAAW,CAAC,UAAU,iBAAiB,MAAM,CAAC,QAAQ,CAC9G;AACD,UAAS,GAAG,2BAA2B,YACrC,SAAS,0BAA0B,SAAS,MAAM,WAAW,CAAC,UAAU,aAAa,MAAM,CAAC,QAAQ,CACrG;AACD,UAAS,GAAG,qCAAqC,YAC/C,SACE,oCACA,SAAS,MAAM,WAAW,CAAC,UAAU,sBACrC,MACD,CAAC,QAAQ,CACX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AW,CAAC,KAAK,qBAAqB,MAAM,CAAC,QAAQ,CACxG;AACD,UAAS,GAAG,uBAAuB,YACjC,SAAS,sBAAsB,SAAS,MAAM,WAAW,CAAC,KAAK,iBAAiB,MAAM,CAAC,QAAQ,CAChG;AACD,UAAS,GAAG,qBAAqB,YAC/B,SAAS,oBAAoB,SAAS,MAAM,WAAW,CAAC,KAAK,YAAY,MAAM,CAAC,QAAQ,CACzF;AAKD,UAAS,GAAG,8BAA8B,YACxC,SAAS,6BAA6B,SAAS,MAAM,QAAQ,CAAC,UAAU,sBAAsB,MAAM,CAAC,QAAQ,CAC9G"}
|
package/dist/vue-styles.css
CHANGED
|
@@ -647,34 +647,34 @@ to {
|
|
|
647
647
|
}
|
|
648
648
|
}
|
|
649
649
|
|
|
650
|
-
.request-card[data-v-
|
|
650
|
+
.request-card[data-v-70ede25b] {
|
|
651
651
|
color: var(--scalar-color-1);
|
|
652
652
|
font-size: var(--scalar-font-size-3);
|
|
653
653
|
}
|
|
654
|
-
.request-method[data-v-
|
|
654
|
+
.request-method[data-v-70ede25b] {
|
|
655
655
|
font-family: var(--scalar-font-code);
|
|
656
656
|
text-transform: uppercase;
|
|
657
657
|
margin-right: 6px;
|
|
658
658
|
}
|
|
659
|
-
.request-card-footer[data-v-
|
|
659
|
+
.request-card-footer[data-v-70ede25b] {
|
|
660
660
|
display: flex;
|
|
661
661
|
justify-content: flex-end;
|
|
662
662
|
padding: 6px;
|
|
663
663
|
flex-shrink: 0;
|
|
664
664
|
position: relative;
|
|
665
665
|
}
|
|
666
|
-
.request-card-footer-addon[data-v-
|
|
666
|
+
.request-card-footer-addon[data-v-70ede25b] {
|
|
667
667
|
display: flex;
|
|
668
668
|
align-items: center;
|
|
669
669
|
|
|
670
670
|
flex: 1;
|
|
671
671
|
min-width: 0;
|
|
672
672
|
}
|
|
673
|
-
.request-editor-section[data-v-
|
|
673
|
+
.request-editor-section[data-v-70ede25b] {
|
|
674
674
|
display: flex;
|
|
675
675
|
flex: 1;
|
|
676
676
|
}
|
|
677
|
-
.request-card-simple[data-v-
|
|
677
|
+
.request-card-simple[data-v-70ede25b] {
|
|
678
678
|
display: flex;
|
|
679
679
|
align-items: center;
|
|
680
680
|
justify-content: space-between;
|
|
@@ -683,7 +683,7 @@ to {
|
|
|
683
683
|
|
|
684
684
|
font-size: var(--scalar-small);
|
|
685
685
|
}
|
|
686
|
-
.code-snippet[data-v-
|
|
686
|
+
.code-snippet[data-v-70ede25b] {
|
|
687
687
|
display: flex;
|
|
688
688
|
flex-direction: column;
|
|
689
689
|
width: 100%;
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"rest",
|
|
19
19
|
"testing"
|
|
20
20
|
],
|
|
21
|
-
"version": "3.
|
|
21
|
+
"version": "3.10.0",
|
|
22
22
|
"engines": {
|
|
23
23
|
"node": ">=22"
|
|
24
24
|
},
|
|
@@ -277,6 +277,11 @@
|
|
|
277
277
|
"types": "./dist/v2/features/modal/index.d.ts",
|
|
278
278
|
"default": "./dist/v2/features/modal/index.js"
|
|
279
279
|
},
|
|
280
|
+
"./modal/map-hidden-clients-config": {
|
|
281
|
+
"import": "./dist/v2/features/modal/helpers/map-hidden-clients-config.js",
|
|
282
|
+
"types": "./dist/v2/features/modal/helpers/map-hidden-clients-config.d.ts",
|
|
283
|
+
"default": "./dist/v2/features/modal/helpers/map-hidden-clients-config.js"
|
|
284
|
+
},
|
|
280
285
|
"./features/operation": {
|
|
281
286
|
"import": "./dist/v2/features/operation/index.js",
|
|
282
287
|
"types": "./dist/v2/features/operation/index.d.ts",
|
|
@@ -316,20 +321,20 @@
|
|
|
316
321
|
"vue": "^3.5.30",
|
|
317
322
|
"yaml": "^2.8.3",
|
|
318
323
|
"zod": "^4.3.5",
|
|
319
|
-
"@scalar/components": "0.
|
|
320
|
-
"@scalar/
|
|
321
|
-
"@scalar/
|
|
322
|
-
"@scalar/
|
|
323
|
-
"@scalar/
|
|
324
|
-
"@scalar/sidebar": "0.9.
|
|
325
|
-
"@scalar/
|
|
326
|
-
"@scalar/
|
|
327
|
-
"@scalar/
|
|
328
|
-
"@scalar/
|
|
324
|
+
"@scalar/components": "0.27.0",
|
|
325
|
+
"@scalar/icons": "0.7.3",
|
|
326
|
+
"@scalar/json-magic": "0.12.15",
|
|
327
|
+
"@scalar/oas-utils": "0.18.1",
|
|
328
|
+
"@scalar/openapi-types": "0.9.1",
|
|
329
|
+
"@scalar/sidebar": "0.9.19",
|
|
330
|
+
"@scalar/themes": "0.16.0",
|
|
331
|
+
"@scalar/helpers": "0.8.1",
|
|
332
|
+
"@scalar/snippetz": "0.9.13",
|
|
333
|
+
"@scalar/types": "0.13.0",
|
|
329
334
|
"@scalar/use-codemirror": "0.14.11",
|
|
330
|
-
"@scalar/use-toasts": "0.10.2",
|
|
331
335
|
"@scalar/use-hooks": "0.4.6",
|
|
332
|
-
"@scalar/
|
|
336
|
+
"@scalar/use-toasts": "0.10.2",
|
|
337
|
+
"@scalar/workspace-store": "0.54.0"
|
|
333
338
|
},
|
|
334
339
|
"devDependencies": {
|
|
335
340
|
"@tailwindcss/cli": "^4.2.4",
|
|
@@ -346,7 +351,7 @@
|
|
|
346
351
|
},
|
|
347
352
|
"scripts": {
|
|
348
353
|
"build": "vite build && pnpm build:styles && vue-tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|
|
349
|
-
"build:styles": "cp -r src/styles dist && tailwindcss --optimize -i src/style.css -o dist/style.css && cat dist/vue-styles.css >> dist/style.css",
|
|
354
|
+
"build:styles": "shx cp -r src/styles dist && tailwindcss --optimize -i src/style.css -o dist/style.css && cat dist/vue-styles.css >> dist/style.css",
|
|
350
355
|
"dev": "vite ./playground/modal -c ./vite.config.ts",
|
|
351
356
|
"preview": "vite preview",
|
|
352
357
|
"test": "vitest --run",
|