@scalar/blocks 0.2.0 → 0.3.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 +26 -0
- package/dist/code-example/components/CodeExample.vue.d.ts +3 -2
- package/dist/code-example/components/CodeExample.vue.d.ts.map +1 -1
- package/dist/code-example/components/CodeExample.vue.js +1 -1
- package/dist/code-example/components/CodeExample.vue.js.map +1 -1
- package/dist/code-example/components/CodeExample.vue.script.js +87 -82
- package/dist/code-example/components/CodeExample.vue.script.js.map +1 -1
- package/dist/code-example/components/HttpMethod.vue.d.ts +1 -2
- package/dist/code-example/components/HttpMethod.vue.d.ts.map +1 -1
- package/dist/code-example/components/HttpMethod.vue.js.map +1 -1
- package/dist/code-example/components/HttpMethod.vue.script.js +15 -11
- package/dist/code-example/components/HttpMethod.vue.script.js.map +1 -1
- package/dist/code-example/helpers/generate-client-options.d.ts +1 -0
- package/dist/code-example/helpers/generate-client-options.d.ts.map +1 -1
- package/dist/code-example/helpers/generate-client-options.js +7 -3
- package/dist/code-example/helpers/generate-client-options.js.map +1 -1
- package/dist/code-example/helpers/generate-code-snippet.d.ts +3 -4
- package/dist/code-example/helpers/generate-code-snippet.d.ts.map +1 -1
- package/dist/code-example/helpers/generate-code-snippet.js +24 -18
- package/dist/code-example/helpers/generate-code-snippet.js.map +1 -1
- package/dist/code-example/helpers/get-clients.d.ts.map +1 -1
- package/dist/code-example/helpers/get-clients.js +4 -2
- package/dist/code-example/helpers/get-clients.js.map +1 -1
- package/dist/code-example/helpers/operation-to-har/operation-to-har.d.ts +1 -2
- package/dist/code-example/helpers/operation-to-har/operation-to-har.d.ts.map +1 -1
- package/dist/code-example/helpers/operation-to-har/operation-to-har.js +22 -14
- package/dist/code-example/helpers/operation-to-har/operation-to-har.js.map +1 -1
- package/dist/code-example/helpers/operation-to-har/process-parameters.d.ts +2 -0
- package/dist/code-example/helpers/operation-to-har/process-parameters.d.ts.map +1 -1
- package/dist/code-example/helpers/operation-to-har/process-parameters.js +163 -95
- package/dist/code-example/helpers/operation-to-har/process-parameters.js.map +1 -1
- package/dist/code-example/mount.d.ts +3 -2
- package/dist/code-example/mount.d.ts.map +1 -1
- package/dist/code-example/mount.js +32 -28
- package/dist/code-example/mount.js.map +1 -1
- package/dist/constants.js +1 -1
- package/dist/style.css +1 -1
- package/dist/vue-styles.css +1 -1
- package/package.json +6 -6
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { HttpMethod } from '@scalar/helpers/http/http-methods';
|
|
2
1
|
import { type Component } from 'vue';
|
|
3
2
|
type __VLS_Props = {
|
|
4
3
|
/** The type of element to render as, defaults to `span` */
|
|
@@ -8,7 +7,7 @@ type __VLS_Props = {
|
|
|
8
7
|
/** Whether or not to abbreviated the slot content */
|
|
9
8
|
short?: boolean;
|
|
10
9
|
/** The HTTP method to show */
|
|
11
|
-
method:
|
|
10
|
+
method: string;
|
|
12
11
|
};
|
|
13
12
|
declare var __VLS_8: {};
|
|
14
13
|
type __VLS_Slots = {} & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpMethod.vue.d.ts","sourceRoot":"","sources":["../../../src/code-example/components/HttpMethod.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HttpMethod.vue.d.ts","sourceRoot":"","sources":["../../../src/code-example/components/HttpMethod.vue"],"names":[],"mappings":"AA6CA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,KAAK,CAAA;AAE9C,KAAK,WAAW,GAAG;IACjB,2DAA2D;IAC3D,EAAE,CAAC,EAAE,SAAS,GAAG,MAAM,CAAA;IACvB,2GAA2G;IAC3G,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,qDAAqD;IACrD,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,8BAA8B;IAC9B,MAAM,EAAE,MAAM,CAAA;CACf,CAAC;AAwDF,QAAA,IAAI,OAAO,IAAW,CAAE;AACxB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,CAAC;AAK/C,QAAA,MAAM,UAAU,kSAEd,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AACzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpMethod.vue.js","names":[],"sources":["../../../src/code-example/components/HttpMethod.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { getHttpMethodInfo } from '@scalar/helpers/http/http-info'\nimport
|
|
1
|
+
{"version":3,"file":"HttpMethod.vue.js","names":[],"sources":["../../../src/code-example/components/HttpMethod.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { getHttpMethodInfo } from '@scalar/helpers/http/http-info'\nimport { isHttpMethod } from '@scalar/helpers/http/is-http-method'\nimport { computed, type Component } from 'vue'\n\nconst props = defineProps<{\n /** The type of element to render as, defaults to `span` */\n as?: Component | string\n /** The css style property or variable that will be set to the request method color, defaults to `color` */\n property?: string\n /** Whether or not to abbreviated the slot content */\n short?: boolean\n /** The HTTP method to show */\n method: string\n}>()\n\n/** Grabs the method info object which contains abbreviation, color, and background color etc */\nconst httpMethodInfo = computed(() =>\n getHttpMethodInfo(String(props.method || '')),\n)\n\n/** Full method name */\nconst normalized = computed(() => {\n if (typeof props.method !== 'string' || !props.method.trim()) {\n return 'get'\n }\n const method = props.method.trim()\n return isHttpMethod(method.toLowerCase()) ? method.toLowerCase() : method\n})\n</script>\n\n<template>\n <component\n :is=\"as ?? 'span'\"\n :class=\"{ uppercase: isHttpMethod(normalized) }\"\n :style=\"{ [property || 'color']: httpMethodInfo.colorVar }\">\n <slot />\n {{ short ? httpMethodInfo.short : normalized }}\n </component>\n</template>\n"],"mappings":""}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { computed as e, createBlock as t, createTextVNode as n, defineComponent as r,
|
|
2
|
-
import { getHttpMethodInfo as
|
|
3
|
-
import {
|
|
1
|
+
import { computed as e, createBlock as t, createTextVNode as n, defineComponent as r, normalizeClass as i, normalizeStyle as a, openBlock as o, renderSlot as s, resolveDynamicComponent as c, toDisplayString as l, unref as u, withCtx as d } from "vue";
|
|
2
|
+
import { getHttpMethodInfo as f } from "@scalar/helpers/http/http-info";
|
|
3
|
+
import { isHttpMethod as p } from "@scalar/helpers/http/is-http-method";
|
|
4
4
|
//#region src/code-example/components/HttpMethod.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
-
var
|
|
5
|
+
var m = /*@__PURE__*/ r({
|
|
6
6
|
__name: "HttpMethod",
|
|
7
7
|
props: {
|
|
8
8
|
as: {},
|
|
@@ -11,17 +11,21 @@ var f = /*@__PURE__*/ r({
|
|
|
11
11
|
method: {}
|
|
12
12
|
},
|
|
13
13
|
setup(r) {
|
|
14
|
-
let
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
let m = r, h = e(() => f(String(m.method || ""))), g = e(() => {
|
|
15
|
+
if (typeof m.method != "string" || !m.method.trim()) return "get";
|
|
16
|
+
let e = m.method.trim();
|
|
17
|
+
return p(e.toLowerCase()) ? e.toLowerCase() : e;
|
|
18
|
+
});
|
|
19
|
+
return (e, f) => (o(), t(c(r.as ?? "span"), {
|
|
20
|
+
class: i({ uppercase: u(p)(g.value) }),
|
|
21
|
+
style: a({ [r.property || "color"]: h.value.colorVar })
|
|
18
22
|
}, {
|
|
19
|
-
default:
|
|
23
|
+
default: d(() => [s(e.$slots, "default"), n(" " + l(r.short ? h.value.short : g.value), 1)]),
|
|
20
24
|
_: 3
|
|
21
|
-
}, 8, ["style"]));
|
|
25
|
+
}, 8, ["class", "style"]));
|
|
22
26
|
}
|
|
23
27
|
});
|
|
24
28
|
//#endregion
|
|
25
|
-
export {
|
|
29
|
+
export { m as default };
|
|
26
30
|
|
|
27
31
|
//# sourceMappingURL=HttpMethod.vue.script.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpMethod.vue.script.js","names":[],"sources":["../../../src/code-example/components/HttpMethod.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { getHttpMethodInfo } from '@scalar/helpers/http/http-info'\nimport
|
|
1
|
+
{"version":3,"file":"HttpMethod.vue.script.js","names":[],"sources":["../../../src/code-example/components/HttpMethod.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { getHttpMethodInfo } from '@scalar/helpers/http/http-info'\nimport { isHttpMethod } from '@scalar/helpers/http/is-http-method'\nimport { computed, type Component } from 'vue'\n\nconst props = defineProps<{\n /** The type of element to render as, defaults to `span` */\n as?: Component | string\n /** The css style property or variable that will be set to the request method color, defaults to `color` */\n property?: string\n /** Whether or not to abbreviated the slot content */\n short?: boolean\n /** The HTTP method to show */\n method: string\n}>()\n\n/** Grabs the method info object which contains abbreviation, color, and background color etc */\nconst httpMethodInfo = computed(() =>\n getHttpMethodInfo(String(props.method || '')),\n)\n\n/** Full method name */\nconst normalized = computed(() => {\n if (typeof props.method !== 'string' || !props.method.trim()) {\n return 'get'\n }\n const method = props.method.trim()\n return isHttpMethod(method.toLowerCase()) ? method.toLowerCase() : method\n})\n</script>\n\n<template>\n <component\n :is=\"as ?? 'span'\"\n :class=\"{ uppercase: isHttpMethod(normalized) }\"\n :style=\"{ [property || 'color']: httpMethodInfo.colorVar }\">\n <slot />\n {{ short ? httpMethodInfo.short : normalized }}\n </component>\n</template>\n"],"mappings":";;;;;;;;;;;;;EAKA,IAAM,IAAQ,GAYR,IAAiB,QACrB,EAAkB,OAAO,EAAM,UAAU,EAAE,CAAC,CAC9C,GAGM,IAAa,QAAe;GAChC,IAAI,OAAO,EAAM,UAAW,YAAY,CAAC,EAAM,OAAO,KAAK,GACzD,OAAO;GAET,IAAM,IAAS,EAAM,OAAO,KAAK;GACjC,OAAO,EAAa,EAAO,YAAY,CAAC,IAAI,EAAO,YAAY,IAAI;EACrE,CAAC;yBAIC,EAMY,EALL,EAAA,MAAE,MAAA,GAAA;GACN,OAAK,EAAA,EAAA,WAAe,EAAA,CAAA,CAAY,CAAC,EAAA,KAAU,EAAA,CAAA;GAC3C,OAAK,EAAA,GAAK,EAAA,YAAQ,UAAc,EAAA,MAAe,SAAQ,CAAA;;oBAChD,CAAR,EAAQ,EAAA,QAAA,SAAA,GAAA,EAAA,MACR,EAAG,EAAA,QAAQ,EAAA,MAAe,QAAQ,EAAA,KAAU,GAAA,CAAA,CAAA,CAAA"}
|
|
@@ -11,6 +11,7 @@ export type CustomCodeSampleId = `custom/${string}`;
|
|
|
11
11
|
* key the id by language rather than by position: the first sample of a language
|
|
12
12
|
* becomes `custom/<lang>`, and any further samples that repeat a language fall back
|
|
13
13
|
* to `custom/<lang>/<n>` so they stay individually selectable within the operation.
|
|
14
|
+
* Linked request examples with the same language and label share an id.
|
|
14
15
|
*
|
|
15
16
|
* The language is lower-cased so a selection still matches when operations (or
|
|
16
17
|
* extensions) spell the same language with different casing (e.g. `Python` vs
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-client-options.d.ts","sourceRoot":"","sources":["../../../src/code-example/helpers/generate-client-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,gBAAgB,EAAY,MAAM,kBAAkB,CAAA;AACrF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sDAAsD,CAAA;AAGvF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAEjD,qCAAqC;AACrC,MAAM,MAAM,kBAAkB,GAAG,UAAU,MAAM,EAAE,CAAA;AAEnD
|
|
1
|
+
{"version":3,"file":"generate-client-options.d.ts","sourceRoot":"","sources":["../../../src/code-example/helpers/generate-client-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,gBAAgB,EAAY,MAAM,kBAAkB,CAAA;AACrF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sDAAsD,CAAA;AAGvF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAEjD,qCAAqC;AACrC,MAAM,MAAM,kBAAkB,GAAG,UAAU,MAAM,EAAE,CAAA;AAEnD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,WAAW,EAAE,KAAG,kBAAkB,EAkB7E,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,iBAAgB,gBAAoC,KAAG,iBAAiB,EAuC7G,CAAA"}
|
|
@@ -2,10 +2,14 @@ import { capitalize as e } from "vue";
|
|
|
2
2
|
import { AVAILABLE_CLIENTS as t, snippetz as n } from "@scalar/snippetz";
|
|
3
3
|
//#region src/code-example/helpers/generate-client-options.ts
|
|
4
4
|
var r = (e) => {
|
|
5
|
-
let t = /* @__PURE__ */ new Map();
|
|
5
|
+
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
6
6
|
return e.map((e) => {
|
|
7
|
-
let
|
|
8
|
-
|
|
7
|
+
let r = (e.lang || "plaintext").toLowerCase(), i = JSON.stringify([r, e.label ?? ""]), a = e.example === void 0 ? void 0 : n.get(i);
|
|
8
|
+
if (a) return a;
|
|
9
|
+
let o = t.get(r) ?? 0;
|
|
10
|
+
t.set(r, o + 1);
|
|
11
|
+
let s = o === 0 ? `custom/${r}` : `custom/${r}/${o}`;
|
|
12
|
+
return e.example !== void 0 && n.set(i, s), s;
|
|
9
13
|
});
|
|
10
14
|
}, i = (r = t) => {
|
|
11
15
|
let i = new Set(r);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-client-options.js","names":[],"sources":["../../../src/code-example/helpers/generate-client-options.ts"],"sourcesContent":["import { AVAILABLE_CLIENTS, type AvailableClients, snippetz } from '@scalar/snippetz'\nimport type { XCodeSample } from '@scalar/workspace-store/schemas/extensions/operation'\nimport { capitalize } from 'vue'\n\nimport type { ClientOptionGroup } from '../types'\n\n/** Type of custom code sample IDs */\nexport type CustomCodeSampleId = `custom/${string}`\n\n/**\n * Build stable, language-keyed ids for an operation's custom code samples.\n *\n * Custom samples are defined per operation, but a selection (e.g. the Python SDK\n * example) should sync across every operation that ships the same language. So we\n * key the id by language rather than by position: the first sample of a language\n * becomes `custom/<lang>`, and any further samples that repeat a language fall back\n * to `custom/<lang>/<n>` so they stay individually selectable within the operation.\n *\n * The language is lower-cased so a selection still matches when operations (or\n * extensions) spell the same language with different casing (e.g. `Python` vs\n * `python`).\n *\n * @param samples - The custom code samples for a single operation\n * @returns A list of ids aligned by index with the input samples\n */\nexport const getCustomClientIds = (samples: XCodeSample[]): CustomCodeSampleId[] => {\n const countByLang = new Map<string, number>()\n\n return samples.map((sample): CustomCodeSampleId => {\n const lang = (sample.lang || 'plaintext').toLowerCase()\n const seen = countByLang.get(lang) ?? 0\n countByLang.set(lang, seen + 1)\n\n
|
|
1
|
+
{"version":3,"file":"generate-client-options.js","names":[],"sources":["../../../src/code-example/helpers/generate-client-options.ts"],"sourcesContent":["import { AVAILABLE_CLIENTS, type AvailableClients, snippetz } from '@scalar/snippetz'\nimport type { XCodeSample } from '@scalar/workspace-store/schemas/extensions/operation'\nimport { capitalize } from 'vue'\n\nimport type { ClientOptionGroup } from '../types'\n\n/** Type of custom code sample IDs */\nexport type CustomCodeSampleId = `custom/${string}`\n\n/**\n * Build stable, language-keyed ids for an operation's custom code samples.\n *\n * Custom samples are defined per operation, but a selection (e.g. the Python SDK\n * example) should sync across every operation that ships the same language. So we\n * key the id by language rather than by position: the first sample of a language\n * becomes `custom/<lang>`, and any further samples that repeat a language fall back\n * to `custom/<lang>/<n>` so they stay individually selectable within the operation.\n * Linked request examples with the same language and label share an id.\n *\n * The language is lower-cased so a selection still matches when operations (or\n * extensions) spell the same language with different casing (e.g. `Python` vs\n * `python`).\n *\n * @param samples - The custom code samples for a single operation\n * @returns A list of ids aligned by index with the input samples\n */\nexport const getCustomClientIds = (samples: XCodeSample[]): CustomCodeSampleId[] => {\n const countByLang = new Map<string, number>()\n const linkedGroups = new Map<string, CustomCodeSampleId>()\n\n return samples.map((sample): CustomCodeSampleId => {\n const lang = (sample.lang || 'plaintext').toLowerCase()\n const group = JSON.stringify([lang, sample.label ?? ''])\n const existing = sample.example !== undefined ? linkedGroups.get(group) : undefined\n if (existing) return existing\n\n const seen = countByLang.get(lang) ?? 0\n countByLang.set(lang, seen + 1)\n\n const id: CustomCodeSampleId = seen === 0 ? `custom/${lang}` : `custom/${lang}/${seen}`\n // Named request examples share one language option; legacy samples remain separate.\n if (sample.example !== undefined) linkedGroups.set(group, id)\n return id\n })\n}\n\n/**\n * Generate client options for the request example block by filtering by allowed clients\n *\n * @param allowedClients - The list of allowed clients to include in the options\n * @returns A list of client option groups\n */\nexport const generateClientOptions = (allowedClients: AvailableClients = AVAILABLE_CLIENTS): ClientOptionGroup[] => {\n /** Create set of allowlist for quicker lookups */\n const allowedClientsSet = new Set(allowedClients)\n\n const options = snippetz()\n .clients()\n .flatMap((group) => {\n const options = group.clients.flatMap((plugin) => {\n const id: AvailableClients[number] = `${group.key}/${plugin.client}`\n\n // If the client is not allowed, skip it\n if (!allowedClientsSet.has(id)) {\n return []\n }\n\n return {\n id,\n lang: plugin.client === 'curl' ? ('curl' as const) : group.key,\n title: `${capitalize(group.title)} ${plugin.title}`,\n label: plugin.title,\n targetKey: group.key,\n targetTitle: group.title,\n clientKey: plugin.client,\n }\n })\n\n // If no clients are allowed, skip this group\n if (options.length === 0) {\n return []\n }\n\n return {\n label: group.title,\n key: group.key,\n options,\n }\n })\n\n return options\n}\n"],"mappings":";;;AA0BA,IAAa,KAAsB,MAAiD;CAClF,IAAM,oBAAc,IAAI,IAAoB,GACtC,oBAAe,IAAI,IAAgC;CAEzD,OAAO,EAAQ,KAAK,MAA+B;EACjD,IAAM,KAAQ,EAAO,QAAQ,YAAA,CAAa,YAAY,GAChD,IAAQ,KAAK,UAAU,CAAC,GAAM,EAAO,SAAS,EAAE,CAAC,GACjD,IAAW,EAAO,YAAY,KAAA,IAAsC,KAAA,IAA1B,EAAa,IAAI,CAAK;EACtE,IAAI,GAAU,OAAO;EAErB,IAAM,IAAO,EAAY,IAAI,CAAI,KAAK;EACtC,EAAY,IAAI,GAAM,IAAO,CAAC;EAE9B,IAAM,IAAyB,MAAS,IAAI,UAAU,MAAS,UAAU,EAAK,GAAG;EAGjF,OADI,EAAO,YAAY,KAAA,KAAW,EAAa,IAAI,GAAO,CAAE,GACrD;CACT,CAAC;AACH,GAQa,KAAyB,IAAmC,MAA2C;CAElH,IAAM,IAAoB,IAAI,IAAI,CAAc;CAoChD,OAlCgB,EAAS,CAAC,CACvB,QAAQ,CAAC,CACT,SAAS,MAAU;EAClB,IAAM,IAAU,EAAM,QAAQ,SAAS,MAAW;GAChD,IAAM,IAA+B,GAAG,EAAM,IAAI,GAAG,EAAO;GAO5D,OAJK,EAAkB,IAAI,CAAE,IAItB;IACL;IACA,MAAM,EAAO,WAAW,SAAU,SAAmB,EAAM;IAC3D,OAAO,GAAG,EAAW,EAAM,KAAK,EAAE,GAAG,EAAO;IAC5C,OAAO,EAAO;IACd,WAAW,EAAM;IACjB,aAAa,EAAM;IACnB,WAAW,EAAO;GACpB,IAXS,CAAC;EAYZ,CAAC;EAOD,OAJI,EAAQ,WAAW,IACd,CAAC,IAGH;GACL,OAAO,EAAM;GACb,KAAK,EAAM;GACX;EACF;CACF,CAEK;AACT"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { HttpMethod } from '@scalar/helpers/http/http-methods';
|
|
2
1
|
import type { AvailableClient } from '@scalar/snippetz';
|
|
3
2
|
import type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example';
|
|
4
3
|
import type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies';
|
|
@@ -15,7 +14,7 @@ type GenerateCodeSnippetProps = {
|
|
|
15
14
|
/** The specific example value to use when generating the code snippet. */
|
|
16
15
|
example: string | undefined;
|
|
17
16
|
/** The HTTP method for the operation (e.g., GET, POST, PUT). */
|
|
18
|
-
method:
|
|
17
|
+
method: string;
|
|
19
18
|
/** The OpenAPI operation object containing request/response details. */
|
|
20
19
|
operation: OperationObject;
|
|
21
20
|
/** The API endpoint path (e.g., '/users/{id}'). */
|
|
@@ -33,7 +32,7 @@ type GenerateCodeSnippetProps = {
|
|
|
33
32
|
/** Whether to disable parameters by default. */
|
|
34
33
|
defaultDisabledParameters?: boolean;
|
|
35
34
|
};
|
|
36
|
-
/** Generate the code snippet for the selected example OR operation */
|
|
37
|
-
export declare const generateCodeSnippet: ({ clientId, customCodeSamples, includeDefaultHeaders, operation, method, path, example, contentType, server, securitySchemes, globalCookies, requestBodyCompositionSelection, defaultDisabledParameters, }: GenerateCodeSnippetProps) => string;
|
|
35
|
+
/** Generate the code snippet for the selected example OR operation, or null when a linked sample is unavailable. */
|
|
36
|
+
export declare const generateCodeSnippet: ({ clientId, customCodeSamples, includeDefaultHeaders, operation, method, path, example, contentType, server, securitySchemes, globalCookies, requestBodyCompositionSelection, defaultDisabledParameters, }: GenerateCodeSnippetProps) => string | null;
|
|
38
37
|
export {};
|
|
39
38
|
//# sourceMappingURL=generate-code-snippet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-code-snippet.d.ts","sourceRoot":"","sources":["../../../src/code-example/helpers/generate-code-snippet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"generate-code-snippet.d.ts","sourceRoot":"","sources":["../../../src/code-example/helpers/generate-code-snippet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAsB,MAAM,kBAAkB,CAAA;AAE3E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAA;AACzF,O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{ operationToHar as n } from "./operation-to-har/operation-to-har.js";
|
|
4
|
+
import { getResolvedRef as r } from "@scalar/workspace-store/helpers/get-resolved-ref";
|
|
4
5
|
//#region src/code-example/helpers/generate-code-snippet.ts
|
|
5
|
-
var
|
|
6
|
+
var i = ({ clientId: i, customCodeSamples: a, includeDefaultHeaders: o = !1, operation: s, method: c, path: l, example: u, contentType: d, server: f, securitySchemes: p, globalCookies: m, requestBodyCompositionSelection: h, defaultDisabledParameters: g }) => {
|
|
6
7
|
try {
|
|
7
|
-
if (!
|
|
8
|
-
if (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
8
|
+
if (!i) return "";
|
|
9
|
+
if (i.startsWith("custom")) {
|
|
10
|
+
let t = e(a), n = a.filter((e, n) => t[n] === i);
|
|
11
|
+
if (!n.some((e) => e.example !== void 0)) return n[0]?.source ?? "Custom example not found";
|
|
12
|
+
let o = r(s.requestBody)?.content ?? {}, c = d ?? Object.keys(o)[0], l = u ?? Object.keys(o[c ?? ""]?.examples ?? {})[0];
|
|
13
|
+
return (n.find((e) => e.example === l && e.contentType === c) ?? n.find((e) => e.example === l && e.contentType === void 0))?.source ?? null;
|
|
14
|
+
}
|
|
15
|
+
let _ = n({
|
|
16
|
+
operation: s,
|
|
17
|
+
contentType: d,
|
|
18
|
+
method: c,
|
|
19
|
+
path: l,
|
|
20
|
+
server: f,
|
|
21
|
+
securitySchemes: p,
|
|
22
|
+
example: u,
|
|
23
|
+
globalCookies: m,
|
|
24
|
+
includeDefaultHeaders: o,
|
|
25
|
+
requestBodyCompositionSelection: h,
|
|
26
|
+
defaultDisabledParameters: g
|
|
27
|
+
}), [v, y] = i.split("/"), [b, x] = t(v, y, _);
|
|
28
|
+
return b ? (console.error("[generateCodeSnippet]", b), b.message ?? "Error generating code snippet") : x;
|
|
23
29
|
} catch (e) {
|
|
24
30
|
return console.error("[generateCodeSnippet]", e), "Error generating code snippet";
|
|
25
31
|
}
|
|
26
32
|
};
|
|
27
33
|
//#endregion
|
|
28
|
-
export {
|
|
34
|
+
export { i as generateCodeSnippet };
|
|
29
35
|
|
|
30
36
|
//# sourceMappingURL=generate-code-snippet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-code-snippet.js","names":[],"sources":["../../../src/code-example/helpers/generate-code-snippet.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"generate-code-snippet.js","names":[],"sources":["../../../src/code-example/helpers/generate-code-snippet.ts"],"sourcesContent":["import type { AvailableClient, ClientId, TargetId } from '@scalar/snippetz'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport type { XCodeSample } from '@scalar/workspace-store/schemas/extensions/operation'\nimport type { OperationObject, ServerObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\n\nimport { type CustomCodeSampleId, getCustomClientIds } from './generate-client-options'\nimport { getSnippet } from './get-snippet'\nimport { operationToHar } from './operation-to-har/operation-to-har'\n\ntype GenerateCodeSnippetProps = {\n /** The selected client/language for code generation (e.g., 'node/fetch') or a custom code sample ID. */\n clientId: AvailableClient | CustomCodeSampleId | undefined\n /** The Content-Type header value for the request body (e.g., 'application/json'). */\n contentType: string | undefined\n /** Array of custom code samples defined in the OpenAPI x-codeSamples extension. */\n customCodeSamples: XCodeSample[]\n /** The specific example value to use when generating the code snippet. */\n example: string | undefined\n /** The HTTP method for the operation (e.g., GET, POST, PUT). */\n method: string\n /** The OpenAPI operation object containing request/response details. */\n operation: OperationObject\n /** The API endpoint path (e.g., '/users/{id}'). */\n path: string\n /** Array of security schemes to apply to the request (e.g., API keys, OAuth). */\n securitySchemes: SecuritySchemeObjectSecret[]\n /** The server object defining the base URL for the API request. */\n server: ServerObject | null\n /** Workspace + document cookies */\n globalCookies?: XScalarCookie[]\n /** Whether to include default headers (e.g., Accept, Content-Type) automatically. */\n includeDefaultHeaders?: boolean\n /** Selected oneOf/anyOf variants for nested request body example generation. */\n requestBodyCompositionSelection?: Record<string, number>\n /** Whether to disable parameters by default. */\n defaultDisabledParameters?: boolean\n}\n\n/** Generate the code snippet for the selected example OR operation, or null when a linked sample is unavailable. */\nexport const generateCodeSnippet = ({\n clientId,\n customCodeSamples,\n includeDefaultHeaders = false,\n operation,\n method,\n path,\n example,\n contentType,\n server,\n securitySchemes,\n globalCookies,\n requestBodyCompositionSelection,\n defaultDisabledParameters,\n}: GenerateCodeSnippetProps): string | null => {\n try {\n if (!clientId) {\n return ''\n }\n\n // Use the selected custom example, matched by its language-keyed id\n if (clientId.startsWith('custom')) {\n const ids = getCustomClientIds(customCodeSamples)\n const samples = customCodeSamples.filter((_, index) => ids[index] === clientId)\n if (!samples.some((sample) => sample.example !== undefined)) {\n return samples[0]?.source ?? 'Custom example not found'\n }\n\n const content = getResolvedRef(operation.requestBody)?.content ?? {}\n const mediaType = contentType ?? Object.keys(content)[0]\n const exampleKey = example ?? Object.keys(content[mediaType ?? '']?.examples ?? {})[0]\n const sample =\n samples.find((sample) => sample.example === exampleKey && sample.contentType === mediaType) ??\n samples.find((sample) => sample.example === exampleKey && sample.contentType === undefined)\n return sample?.source ?? null\n }\n\n const harRequest = operationToHar({\n operation,\n contentType,\n method,\n path,\n server,\n securitySchemes,\n example,\n globalCookies,\n includeDefaultHeaders,\n requestBodyCompositionSelection,\n defaultDisabledParameters,\n })\n\n const [targetKey, clientKey] = clientId.split('/') as [TargetId, ClientId<TargetId>]\n\n const [error, payload] = getSnippet(targetKey, clientKey, harRequest)\n if (error) {\n console.error('[generateCodeSnippet]', error)\n return error.message ?? 'Error generating code snippet'\n }\n\n return payload\n } catch (error) {\n console.error('[generateCodeSnippet]', error)\n return 'Error generating code snippet'\n }\n}\n"],"mappings":";;;;;AAyCA,IAAa,KAAuB,EAClC,aACA,sBACA,2BAAwB,IACxB,cACA,WACA,SACA,YACA,gBACA,WACA,oBACA,kBACA,oCACA,mCAC6C;CAC7C,IAAI;EACF,IAAI,CAAC,GACH,OAAO;EAIT,IAAI,EAAS,WAAW,QAAQ,GAAG;GACjC,IAAM,IAAM,EAAmB,CAAiB,GAC1C,IAAU,EAAkB,QAAQ,GAAG,MAAU,EAAI,OAAW,CAAQ;GAC9E,IAAI,CAAC,EAAQ,MAAM,MAAW,EAAO,YAAY,KAAA,CAAS,GACxD,OAAO,EAAQ,EAAE,EAAE,UAAU;GAG/B,IAAM,IAAU,EAAe,EAAU,WAAW,CAAC,EAAE,WAAW,CAAC,GAC7D,IAAY,KAAe,OAAO,KAAK,CAAO,CAAC,CAAC,IAChD,IAAa,KAAW,OAAO,KAAK,EAAQ,KAAa,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;GAIpF,QAFE,EAAQ,MAAM,MAAW,EAAO,YAAY,KAAc,EAAO,gBAAgB,CAAS,KAC1F,EAAQ,MAAM,MAAW,EAAO,YAAY,KAAc,EAAO,gBAAgB,KAAA,CAAS,EAAA,EAC7E,UAAU;EAC3B;EAEA,IAAM,IAAa,EAAe;GAChC;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAAC,GAEK,CAAC,GAAW,KAAa,EAAS,MAAM,GAAG,GAE3C,CAAC,GAAO,KAAW,EAAW,GAAW,GAAW,CAAU;EAMpE,OALI,KACF,QAAQ,MAAM,yBAAyB,CAAK,GACrC,EAAM,WAAW,mCAGnB;CACT,SAAS,GAAO;EAEd,OADA,QAAQ,MAAM,yBAAyB,CAAK,GACrC;CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-clients.d.ts","sourceRoot":"","sources":["../../../src/code-example/helpers/get-clients.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sDAAsD,CAAA;
|
|
1
|
+
{"version":3,"file":"get-clients.d.ts","sourceRoot":"","sources":["../../../src/code-example/helpers/get-clients.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sDAAsD,CAAA;AAEvF,OAAO,KAAK,EAAE,iBAAiB,EAAsB,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAK9F;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,GACrB,mBAAmB,WAAW,EAAE,EAChC,eAAe,iBAAiB,EAAE,EAClC,QAAO,MAAkC,KACxC,uBAAuB,EAgCzB,CAAA"}
|
|
@@ -8,8 +8,10 @@ var r = (r, i, a = n) => {
|
|
|
8
8
|
return [{
|
|
9
9
|
label: a,
|
|
10
10
|
key: "custom",
|
|
11
|
-
options: r.
|
|
12
|
-
let i = n[r] ?? `custom/${r}
|
|
11
|
+
options: r.flatMap((e, r) => {
|
|
12
|
+
let i = n[r] ?? `custom/${r}`;
|
|
13
|
+
if (n.indexOf(i) !== r) return [];
|
|
14
|
+
let a = e.label || t(e.lang) || i;
|
|
13
15
|
return {
|
|
14
16
|
id: i,
|
|
15
17
|
lang: e.lang || "plaintext",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-clients.js","names":[],"sources":["../../../src/code-example/helpers/get-clients.ts"],"sourcesContent":["import type { TargetId } from '@scalar/types/snippetz'\nimport type { XCodeSample } from '@scalar/workspace-store/schemas/extensions/operation'\n\nimport { formatLanguage } from './format-language'\nimport { getCustomClientIds } from './generate-client-options'\nimport { CODE_EXAMPLES_GROUP_LABEL } from './get-custom-code-samples'\
|
|
1
|
+
{"version":3,"file":"get-clients.js","names":[],"sources":["../../../src/code-example/helpers/get-clients.ts"],"sourcesContent":["import type { TargetId } from '@scalar/types/snippetz'\nimport type { XCodeSample } from '@scalar/workspace-store/schemas/extensions/operation'\n\nimport type { ClientOptionGroup, CustomClientOption, CustomClientOptionGroup } from '../types'\nimport { formatLanguage } from './format-language'\nimport { getCustomClientIds } from './generate-client-options'\nimport { CODE_EXAMPLES_GROUP_LABEL } from './get-custom-code-samples'\n\n/**\n * Merges custom code samples with the client options\n *\n * @param customCodeSamples - The custom code samples from the operation to merge with the client options\n * @param clientOptions - The client options to merge with the custom code samples\n * @param label - The label for the custom samples group (e.g. \"SDK\" or \"Code Examples\")\n * @returns A list of client option groups\n */\nexport const getClients = (\n customCodeSamples: XCodeSample[],\n clientOptions: ClientOptionGroup[],\n label: string = CODE_EXAMPLES_GROUP_LABEL,\n): CustomClientOptionGroup[] => {\n // Handle custom code examples\n if (customCodeSamples.length) {\n // Language-keyed ids so the same sample can be selected across operations\n const ids = getCustomClientIds(customCodeSamples)\n\n const customClients = customCodeSamples.flatMap((sample, index) => {\n const id = ids[index] ?? `custom/${index}`\n if (ids.indexOf(id) !== index) return []\n const label = sample.label || formatLanguage(sample.lang) || id\n const lang = (sample.lang as TargetId) || 'plaintext'\n\n return {\n id,\n lang,\n title: label,\n label,\n clientKey: 'custom',\n } satisfies CustomClientOption\n })\n\n return [\n {\n label,\n key: 'custom',\n options: customClients,\n },\n ...clientOptions,\n ]\n }\n\n return clientOptions\n}\n"],"mappings":";;;;AAgBA,IAAa,KACX,GACA,GACA,IAAgB,MACc;CAE9B,IAAI,EAAkB,QAAQ;EAE5B,IAAM,IAAM,EAAmB,CAAiB;EAiBhD,OAAO,CACL;GACE;GACA,KAAK;GACL,SAnBkB,EAAkB,SAAS,GAAQ,MAAU;IACjE,IAAM,IAAK,EAAI,MAAU,UAAU;IACnC,IAAI,EAAI,QAAQ,CAAE,MAAM,GAAO,OAAO,CAAC;IACvC,IAAM,IAAQ,EAAO,SAAS,EAAe,EAAO,IAAI,KAAK;IAG7D,OAAO;KACL;KACA,MAJY,EAAO,QAAqB;KAKxC,OAAO;KACP;KACA,WAAW;IACb;GACF,CAMa;EACX,GACA,GAAG,CACL;CACF;CAEA,OAAO;AACT"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { HttpMethod } from '@scalar/helpers/http/http-methods';
|
|
2
1
|
import { type SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example';
|
|
3
2
|
import type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies';
|
|
4
3
|
import type { OperationObject, ServerObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
|
|
@@ -7,7 +6,7 @@ export type OperationToHarProps = {
|
|
|
7
6
|
/** OpenAPI Operation object */
|
|
8
7
|
operation: OperationObject;
|
|
9
8
|
/** HTTP method of the operation */
|
|
10
|
-
method:
|
|
9
|
+
method: string;
|
|
11
10
|
/** Path of the operation */
|
|
12
11
|
path: string;
|
|
13
12
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-to-har.d.ts","sourceRoot":"","sources":["../../../../src/code-example/helpers/operation-to-har/operation-to-har.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"operation-to-har.d.ts","sourceRoot":"","sources":["../../../../src/code-example/helpers/operation-to-har/operation-to-har.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,0BAA0B,EAIhC,MAAM,yCAAyC,CAAA;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AACxG,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AACjH,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AASvD,MAAM,MAAM,mBAAmB,GAAG;IAChC,+BAA+B;IAC/B,SAAS,EAAE,eAAe,CAAA;IAC1B,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,4BAA4B;IAC5B,MAAM,CAAC,EAAE,YAAY,GAAG,IAAI,CAAA;IAC5B,2EAA2E;IAC3E,eAAe,CAAC,EAAE,0BAA0B,EAAE,CAAA;IAC9C,mCAAmC;IACnC,aAAa,CAAC,EAAE,aAAa,EAAE,CAAA;IAC/B;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B;;;OAGG;IACH,+BAA+B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACxD;;;OAGG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAA;CACpC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc,GAAI,+KAY5B,mBAAmB,KAAG,UAwJxB,CAAA"}
|
|
@@ -31,14 +31,14 @@ var u = ({ includeDefaultHeaders: u = !1, operation: d, contentType: f, method:
|
|
|
31
31
|
cookies: [],
|
|
32
32
|
headersSize: -1,
|
|
33
33
|
bodySize: -1
|
|
34
|
-
}, w = !1;
|
|
34
|
+
}, w = !1, T = !1;
|
|
35
35
|
if (d.parameters) {
|
|
36
|
-
let { url: e, headers: t, queryString: r, cookies: i, hasCookieStyleEntries: a } = n({
|
|
36
|
+
let { url: e, headers: t, queryString: r, cookies: i, hasCookieStyleEntries: a, hasSerializedQuery: o } = n({
|
|
37
37
|
harRequest: C,
|
|
38
38
|
parameters: d.parameters,
|
|
39
39
|
example: g,
|
|
40
40
|
defaultDisabled: b
|
|
41
|
-
}),
|
|
41
|
+
}), c = v?.filter((t) => s({
|
|
42
42
|
cookie: t,
|
|
43
43
|
url: e,
|
|
44
44
|
disabledGlobalCookies: S
|
|
@@ -46,12 +46,12 @@ var u = ({ includeDefaultHeaders: u = !1, operation: d, contentType: f, method:
|
|
|
46
46
|
name: e.name,
|
|
47
47
|
value: e.value
|
|
48
48
|
})) ?? [];
|
|
49
|
-
w = a, C.url = e, C.headers = t, C.queryString = r, C.cookies = [...
|
|
49
|
+
w = a, T = o ?? !1, C.url = e, C.headers = t, C.queryString = r, C.cookies = [...c, ...i];
|
|
50
50
|
}
|
|
51
|
-
let
|
|
52
|
-
if (
|
|
51
|
+
let E = a(d.requestBody);
|
|
52
|
+
if (E?.content) {
|
|
53
53
|
let e = t({
|
|
54
|
-
requestBody:
|
|
54
|
+
requestBody: E,
|
|
55
55
|
contentType: f,
|
|
56
56
|
example: g,
|
|
57
57
|
requestBodyCompositionSelection: y
|
|
@@ -64,18 +64,26 @@ var u = ({ includeDefaultHeaders: u = !1, operation: d, contentType: f, method:
|
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
+
let D = T || d.parameters?.some((e) => a(e)?.in === "querystring");
|
|
67
68
|
if (_) {
|
|
68
69
|
let { headers: e, queryString: t, cookies: n } = r(_);
|
|
69
|
-
C.headers.push(...e), C.queryString.push(...t
|
|
70
|
+
C.headers.push(...e), C.queryString.push(...t.map((e) => D ? {
|
|
71
|
+
...e,
|
|
72
|
+
value: encodeURIComponent(e.value)
|
|
73
|
+
} : e)), C.cookies.push(...n);
|
|
70
74
|
}
|
|
71
|
-
let
|
|
72
|
-
if (w &&
|
|
75
|
+
let O = C.headers.find((e) => e.name.toLowerCase() === "cookie");
|
|
76
|
+
if (w && O && C.cookies.length) {
|
|
73
77
|
let e = C.cookies.map((e) => `${encodeURIComponent(e.name)}=${encodeURIComponent(e.value)}`).join("; ");
|
|
74
|
-
|
|
78
|
+
O.value = O.value ? `${O.value}; ${e}` : e, C.cookies = [];
|
|
75
79
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
80
|
+
if (D && C.queryString.length) {
|
|
81
|
+
let e = C.url.indexOf("#"), t = e === -1 ? "" : C.url.slice(e), n = e === -1 ? C.url : C.url.slice(0, e), r = C.queryString.map(({ name: e, value: t }) => `${encodeURIComponent(e)}=${t}`).join("&");
|
|
82
|
+
C.url = `${n}${n.includes("?") ? "&" : "?"}${r}${t}`, C.queryString = [];
|
|
83
|
+
}
|
|
84
|
+
let k = 0;
|
|
85
|
+
for (let e of C.headers) k += (e.name?.length ?? 0) + 2 + (e.value?.length ?? 0) + 2;
|
|
86
|
+
return C.headersSize = k, C;
|
|
79
87
|
};
|
|
80
88
|
//#endregion
|
|
81
89
|
export { u as operationToHar };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-to-har.js","names":[],"sources":["../../../../src/code-example/helpers/operation-to-har/operation-to-har.ts"],"sourcesContent":["import { isElectron } from '@scalar/helpers/general/is-electron'\nimport type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n type SecuritySchemeObjectSecret,\n filterGlobalCookie,\n getDefaultHeaders,\n restoreConventionalDefaultHeaderNames,\n} from '@scalar/workspace-store/request-example'\nimport type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport type { OperationObject, ServerObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport type { Request as HarRequest } from 'har-format'\n\nimport { APP_VERSION } from '@/constants'\n\nimport { processBody } from './process-body'\nimport { processParameters } from './process-parameters'\nimport { processSecuritySchemes } from './process-security-schemes'\nimport { processServerUrl } from './process-server-url'\n\nexport type OperationToHarProps = {\n /** OpenAPI Operation object */\n operation: OperationObject\n /** HTTP method of the operation */\n method: HttpMethod\n /** Path of the operation */\n path: string\n /**\n * Name of the currently selected operation example\n *\n * Applies to both the body and the parameters\n */\n example?: string\n /**\n * Content type of the operation\n *\n * Applies to both the body and the parameters (if applicable)\n * @defaults to the first content type in the MediaTypeObject\n */\n contentType?: string\n /** OpenAPI Server object */\n server?: ServerObject | null\n /** OpenAPI SecurityScheme objects which are applicable to the operation */\n securitySchemes?: SecuritySchemeObjectSecret[]\n /** Workspace + document cookies */\n globalCookies?: XScalarCookie[]\n /**\n * Whether to include default headers (e.g., Accept, Content-Type) automatically.\n * If false, default headers will be omitted from the HAR request.\n * @default true\n */\n includeDefaultHeaders?: boolean\n /**\n * Selected oneOf/anyOf variants for nested request body example generation\n * (e.g. from the schema dropdowns in the API reference).\n */\n requestBodyCompositionSelection?: Record<string, number>\n /**\n * Whether to disable parameters by default.\n * @default false\n */\n defaultDisabledParameters?: boolean\n}\n\n/**\n * Converts an OpenAPI Operation to a HarRequest format for generating HTTP request snippets.\n *\n * This function transforms OpenAPI 3.1 operation objects into HAR (HTTP Archive) format requests,\n * which can be used to generate code snippets for various programming languages and HTTP clients.\n *\n * The conversion handles:\n * - Server URL processing and path parameter substitution\n * - Query parameter formatting based on OpenAPI parameter styles\n * - Request body processing with content type handling\n * - Security scheme integration (API keys, etc.)\n *\n * The resulting HarRequest object follows the HAR specification and includes:\n * - HTTP method and URL\n * - Headers and query parameters\n * - Request body (if present)\n * - Cookie information\n * - Size calculations for headers and body\n *\n * @see https://w3c.github.io/web-performance/specs/HAR/Overview.html\n * @see https://spec.openapis.org/oas/v3.1.0#operation-object\n */\nexport const operationToHar = ({\n includeDefaultHeaders = false,\n operation,\n contentType,\n method,\n path,\n server = null,\n example,\n securitySchemes,\n globalCookies,\n requestBodyCompositionSelection,\n defaultDisabledParameters = false,\n}: OperationToHarProps): HarRequest => {\n const defaultHeaders = includeDefaultHeaders\n ? getDefaultHeaders({\n method,\n operation,\n exampleName: example ?? 'default',\n hideDisabledHeaders: true,\n hideOverriddenHeaders: true,\n options: { isElectron: isElectron(), appVersion: APP_VERSION },\n })\n : {}\n const defaultHeadersWithConventionalNames = restoreConventionalDefaultHeaderNames(defaultHeaders)\n\n const disabledGlobalCookies =\n operation['x-scalar-disable-parameters']?.['global-cookies']?.[example ?? 'default'] ?? {}\n\n const serverUrl = processServerUrl(server, path)\n\n // Initialize the HAR request with basic properties\n const harRequest: HarRequest = {\n method,\n url: serverUrl,\n headers: Object.entries(defaultHeadersWithConventionalNames).map(([name, value]) => ({ name, value })),\n queryString: [],\n postData: undefined,\n httpVersion: 'HTTP/1.1',\n cookies: [],\n headersSize: -1,\n bodySize: -1,\n }\n\n let hasCookieStyleEntries = false\n\n // Handle parameters\n if (operation.parameters) {\n const {\n url,\n headers,\n queryString,\n cookies,\n hasCookieStyleEntries: processedCookieStyleEntries,\n } = processParameters({\n harRequest,\n parameters: operation.parameters,\n example,\n defaultDisabled: defaultDisabledParameters,\n })\n\n // Correctly filter the global cookies by the processed url\n const filteredGlobalCookies =\n globalCookies\n ?.filter((cookie) => filterGlobalCookie({ cookie, url, disabledGlobalCookies }))\n ?.map((cookie) => ({ name: cookie.name, value: cookie.value })) ?? []\n\n hasCookieStyleEntries = processedCookieStyleEntries\n harRequest.url = url\n harRequest.headers = headers\n harRequest.queryString = queryString\n harRequest.cookies = [...filteredGlobalCookies, ...cookies]\n }\n\n const body = getResolvedRef(operation.requestBody)\n\n // Handle request body\n if (body?.content) {\n const postData = processBody({\n requestBody: body,\n contentType,\n example,\n requestBodyCompositionSelection,\n })\n\n if (postData) {\n harRequest.postData = postData\n harRequest.bodySize = postData.text?.length ?? -1\n\n // Add or update Content-Type header\n if (postData.mimeType) {\n const existingContentTypeHeader = harRequest.headers.find(\n (header) => header.name.toLowerCase() === 'content-type',\n )\n // Update existing header if it has an empty value\n if (\n existingContentTypeHeader &&\n (!existingContentTypeHeader.value ||\n (postData.mimeType.startsWith('multipart/') &&\n postData.mimeType.includes('boundary=') &&\n postData.text !== undefined))\n ) {\n existingContentTypeHeader.value = postData.mimeType\n }\n // Add new header if none exists\n else if (!existingContentTypeHeader) {\n harRequest.headers.push({\n name: 'Content-Type',\n value: postData.mimeType,\n })\n }\n }\n }\n }\n\n // Handle security schemes\n if (securitySchemes) {\n const { headers, queryString, cookies } = processSecuritySchemes(securitySchemes)\n harRequest.headers.push(...headers)\n harRequest.queryString.push(...queryString)\n harRequest.cookies.push(...cookies)\n }\n\n // Keep authentication and global cookies in the explicit header as well, so\n // snippet generators cannot replace cookie-style parameters with their own header.\n const cookieHeader = harRequest.headers.find((header) => header.name.toLowerCase() === 'cookie')\n if (hasCookieStyleEntries && cookieHeader && harRequest.cookies.length) {\n const extraCookies = harRequest.cookies\n .map((cookie) => `${encodeURIComponent(cookie.name)}=${encodeURIComponent(cookie.value)}`)\n .join('; ')\n cookieHeader.value = cookieHeader.value ? `${cookieHeader.value}; ${extraCookies}` : extraCookies\n harRequest.cookies = []\n }\n\n // Calculate headers size without allocating a large joined string\n let headersSize = 0\n for (const h of harRequest.headers) {\n // name + \": \" + value + \"\\r\\n\"\n headersSize += (h.name?.length ?? 0) + 2 + (h.value?.length ?? 0) + 2\n }\n harRequest.headersSize = headersSize\n\n return harRequest\n}\n"],"mappings":";;;;;;;;;AAsFA,IAAa,KAAkB,EAC7B,2BAAwB,IACxB,cACA,gBACA,WACA,SACA,YAAS,MACT,YACA,oBACA,kBACA,oCACA,+BAA4B,SACS;CAWrC,IAAM,IAAsC,EAVrB,IACnB,EAAkB;EAChB;EACA;EACA,aAAa,KAAW;EACxB,qBAAqB;EACrB,uBAAuB;EACvB,SAAS;GAAE,YAAY,EAAW;GAAG,YAAY;EAAY;CAC/D,CAAC,IACD,CAAC,CAC2F,GAE1F,IACJ,EAAU,8BAA8B,GAAG,iBAAiB,GAAG,KAAW,cAAc,CAAC,GAKrF,IAAyB;EAC7B;EACA,KALgB,EAAiB,GAAQ,CAKpC;EACL,SAAS,OAAO,QAAQ,CAAmC,CAAC,CAAC,KAAK,CAAC,GAAM,QAAY;GAAE;GAAM;EAAM,EAAE;EACrG,aAAa,CAAC;EACd,UAAU,KAAA;EACV,aAAa;EACb,SAAS,CAAC;EACV,aAAa;EACb,UAAU;CACZ,GAEI,IAAwB;CAG5B,IAAI,EAAU,YAAY;EACxB,IAAM,EACJ,QACA,YACA,gBACA,YACA,uBAAuB,MACrB,EAAkB;GACpB;GACA,YAAY,EAAU;GACtB;GACA,iBAAiB;EACnB,CAAC,GAGK,IACJ,GACI,QAAQ,MAAW,EAAmB;GAAE;GAAQ;GAAK;EAAsB,CAAC,CAAC,CAAC,EAC9E,KAAK,OAAY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,UAAU,CAAC;CACxB;CAGA,IAAI,IAAc;CAClB,KAAK,IAAM,KAAK,EAAW,SAEzB,MAAgB,EAAE,MAAM,UAAU,KAAK,KAAK,EAAE,OAAO,UAAU,KAAK;CAItE,OAFA,EAAW,cAAc,GAElB;AACT"}
|
|
1
|
+
{"version":3,"file":"operation-to-har.js","names":[],"sources":["../../../../src/code-example/helpers/operation-to-har/operation-to-har.ts"],"sourcesContent":["import { isElectron } from '@scalar/helpers/general/is-electron'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n type SecuritySchemeObjectSecret,\n filterGlobalCookie,\n getDefaultHeaders,\n restoreConventionalDefaultHeaderNames,\n} from '@scalar/workspace-store/request-example'\nimport type { XScalarCookie } from '@scalar/workspace-store/schemas/extensions/general/x-scalar-cookies'\nimport type { OperationObject, ServerObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport type { Request as HarRequest } from 'har-format'\n\nimport { APP_VERSION } from '@/constants'\n\nimport { processBody } from './process-body'\nimport { processParameters } from './process-parameters'\nimport { processSecuritySchemes } from './process-security-schemes'\nimport { processServerUrl } from './process-server-url'\n\nexport type OperationToHarProps = {\n /** OpenAPI Operation object */\n operation: OperationObject\n /** HTTP method of the operation */\n method: string\n /** Path of the operation */\n path: string\n /**\n * Name of the currently selected operation example\n *\n * Applies to both the body and the parameters\n */\n example?: string\n /**\n * Content type of the operation\n *\n * Applies to both the body and the parameters (if applicable)\n * @defaults to the first content type in the MediaTypeObject\n */\n contentType?: string\n /** OpenAPI Server object */\n server?: ServerObject | null\n /** OpenAPI SecurityScheme objects which are applicable to the operation */\n securitySchemes?: SecuritySchemeObjectSecret[]\n /** Workspace + document cookies */\n globalCookies?: XScalarCookie[]\n /**\n * Whether to include default headers (e.g., Accept, Content-Type) automatically.\n * If false, default headers will be omitted from the HAR request.\n * @default true\n */\n includeDefaultHeaders?: boolean\n /**\n * Selected oneOf/anyOf variants for nested request body example generation\n * (e.g. from the schema dropdowns in the API reference).\n */\n requestBodyCompositionSelection?: Record<string, number>\n /**\n * Whether to disable parameters by default.\n * @default false\n */\n defaultDisabledParameters?: boolean\n}\n\n/**\n * Converts an OpenAPI Operation to a HarRequest format for generating HTTP request snippets.\n *\n * This function transforms OpenAPI 3.1 operation objects into HAR (HTTP Archive) format requests,\n * which can be used to generate code snippets for various programming languages and HTTP clients.\n *\n * The conversion handles:\n * - Server URL processing and path parameter substitution\n * - Query parameter formatting based on OpenAPI parameter styles\n * - Request body processing with content type handling\n * - Security scheme integration (API keys, etc.)\n *\n * The resulting HarRequest object follows the HAR specification and includes:\n * - HTTP method and URL\n * - Headers and query parameters\n * - Request body (if present)\n * - Cookie information\n * - Size calculations for headers and body\n *\n * @see https://w3c.github.io/web-performance/specs/HAR/Overview.html\n * @see https://spec.openapis.org/oas/v3.1.0#operation-object\n */\nexport const operationToHar = ({\n includeDefaultHeaders = false,\n operation,\n contentType,\n method,\n path,\n server = null,\n example,\n securitySchemes,\n globalCookies,\n requestBodyCompositionSelection,\n defaultDisabledParameters = false,\n}: OperationToHarProps): HarRequest => {\n const defaultHeaders = includeDefaultHeaders\n ? getDefaultHeaders({\n method,\n operation,\n exampleName: example ?? 'default',\n hideDisabledHeaders: true,\n hideOverriddenHeaders: true,\n options: { isElectron: isElectron(), appVersion: APP_VERSION },\n })\n : {}\n const defaultHeadersWithConventionalNames = restoreConventionalDefaultHeaderNames(defaultHeaders)\n\n const disabledGlobalCookies =\n operation['x-scalar-disable-parameters']?.['global-cookies']?.[example ?? 'default'] ?? {}\n\n const serverUrl = processServerUrl(server, path)\n\n // Initialize the HAR request with basic properties\n const harRequest: HarRequest = {\n method,\n url: serverUrl,\n headers: Object.entries(defaultHeadersWithConventionalNames).map(([name, value]) => ({ name, value })),\n queryString: [],\n postData: undefined,\n httpVersion: 'HTTP/1.1',\n cookies: [],\n headersSize: -1,\n bodySize: -1,\n }\n\n let hasCookieStyleEntries = false\n let hasSerializedQuery = false\n\n // Handle parameters\n if (operation.parameters) {\n const {\n url,\n headers,\n queryString,\n cookies,\n hasCookieStyleEntries: processedCookieStyleEntries,\n hasSerializedQuery: processedSerializedQuery,\n } = processParameters({\n harRequest,\n parameters: operation.parameters,\n example,\n defaultDisabled: defaultDisabledParameters,\n })\n\n // Correctly filter the global cookies by the processed url\n const filteredGlobalCookies =\n globalCookies\n ?.filter((cookie) => filterGlobalCookie({ cookie, url, disabledGlobalCookies }))\n ?.map((cookie) => ({ name: cookie.name, value: cookie.value })) ?? []\n\n hasCookieStyleEntries = processedCookieStyleEntries\n hasSerializedQuery = processedSerializedQuery ?? false\n harRequest.url = url\n harRequest.headers = headers\n harRequest.queryString = queryString\n harRequest.cookies = [...filteredGlobalCookies, ...cookies]\n }\n\n const body = getResolvedRef(operation.requestBody)\n\n // Handle request body\n if (body?.content) {\n const postData = processBody({\n requestBody: body,\n contentType,\n example,\n requestBodyCompositionSelection,\n })\n\n if (postData) {\n harRequest.postData = postData\n harRequest.bodySize = postData.text?.length ?? -1\n\n // Add or update Content-Type header\n if (postData.mimeType) {\n const existingContentTypeHeader = harRequest.headers.find(\n (header) => header.name.toLowerCase() === 'content-type',\n )\n // Update existing header if it has an empty value\n if (\n existingContentTypeHeader &&\n (!existingContentTypeHeader.value ||\n (postData.mimeType.startsWith('multipart/') &&\n postData.mimeType.includes('boundary=') &&\n postData.text !== undefined))\n ) {\n existingContentTypeHeader.value = postData.mimeType\n }\n // Add new header if none exists\n else if (!existingContentTypeHeader) {\n harRequest.headers.push({\n name: 'Content-Type',\n value: postData.mimeType,\n })\n }\n }\n }\n }\n\n const hasUriReadyQuery =\n hasSerializedQuery || operation.parameters?.some((parameter) => getResolvedRef(parameter)?.in === 'querystring')\n\n // Handle security schemes\n if (securitySchemes) {\n const { headers, queryString, cookies } = processSecuritySchemes(securitySchemes)\n harRequest.headers.push(...headers)\n // Named parameter values are already serialized, but authentication values are still raw.\n harRequest.queryString.push(\n ...queryString.map((parameter) =>\n hasUriReadyQuery ? { ...parameter, value: encodeURIComponent(parameter.value) } : parameter,\n ),\n )\n harRequest.cookies.push(...cookies)\n }\n\n // Keep authentication and global cookies in the explicit header as well, so\n // snippet generators cannot replace cookie-style parameters with their own header.\n const cookieHeader = harRequest.headers.find((header) => header.name.toLowerCase() === 'cookie')\n if (hasCookieStyleEntries && cookieHeader && harRequest.cookies.length) {\n const extraCookies = harRequest.cookies\n .map((cookie) => `${encodeURIComponent(cookie.name)}=${encodeURIComponent(cookie.value)}`)\n .join('; ')\n cookieHeader.value = cookieHeader.value ? `${cookieHeader.value}; ${extraCookies}` : extraCookies\n harRequest.cookies = []\n }\n\n // Whole-query content and serialized examples must retain their authored URI encoding.\n // Keeping all query data in the URL avoids snippet generators introducing a second question mark.\n if (hasUriReadyQuery && harRequest.queryString.length) {\n const hashIndex = harRequest.url.indexOf('#')\n const hash = hashIndex === -1 ? '' : harRequest.url.slice(hashIndex)\n const url = hashIndex === -1 ? harRequest.url : harRequest.url.slice(0, hashIndex)\n const query = harRequest.queryString.map(({ name, value }) => `${encodeURIComponent(name)}=${value}`).join('&')\n harRequest.url = `${url}${url.includes('?') ? '&' : '?'}${query}${hash}`\n harRequest.queryString = []\n }\n\n // Calculate headers size without allocating a large joined string\n let headersSize = 0\n for (const h of harRequest.headers) {\n // name + \": \" + value + \"\\r\\n\"\n headersSize += (h.name?.length ?? 0) + 2 + (h.value?.length ?? 0) + 2\n }\n harRequest.headersSize = headersSize\n\n return harRequest\n}\n"],"mappings":";;;;;;;;;AAqFA,IAAa,KAAkB,EAC7B,2BAAwB,IACxB,cACA,gBACA,WACA,SACA,YAAS,MACT,YACA,oBACA,kBACA,oCACA,+BAA4B,SACS;CAWrC,IAAM,IAAsC,EAVrB,IACnB,EAAkB;EAChB;EACA;EACA,aAAa,KAAW;EACxB,qBAAqB;EACrB,uBAAuB;EACvB,SAAS;GAAE,YAAY,EAAW;GAAG,YAAY;EAAY;CAC/D,CAAC,IACD,CAAC,CAC2F,GAE1F,IACJ,EAAU,8BAA8B,G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EAAW,SAEzB,MAAgB,EAAE,MAAM,UAAU,KAAK,KAAK,EAAE,OAAO,UAAU,KAAK;CAItE,OAFA,EAAW,cAAc,GAElB;AACT"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { OperationObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
|
|
2
2
|
import type { Request as HarRequest } from 'har-format';
|
|
3
3
|
type ProcessedParameters = {
|
|
4
|
+
/** Named serialized examples already embedded in the URL. */
|
|
5
|
+
hasSerializedQuery?: boolean;
|
|
4
6
|
url: string;
|
|
5
7
|
headers: HarRequest['headers'];
|
|
6
8
|
queryString: HarRequest['queryString'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-parameters.d.ts","sourceRoot":"","sources":["../../../../src/code-example/helpers/operation-to-har/process-parameters.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"process-parameters.d.ts","sourceRoot":"","sources":["../../../../src/code-example/helpers/operation-to-har/process-parameters.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,8DAA8D,CAAA;AACpH,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvD,KAAK,mBAAmB,GAAG;IACzB,6DAA6D;IAC7D,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IAC9B,WAAW,EAAE,UAAU,CAAC,aAAa,CAAC,CAAA;IACtC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IAC9B,+EAA+E;IAC/E,qBAAqB,EAAE,OAAO,CAAA;CAC/B,CAAA;AAyFD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,uDAK/B;IACD,UAAU,EAAE,UAAU,CAAA;IACtB,UAAU,EAAE,eAAe,CAAC,YAAY,CAAC,CAAA;IACzC,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,gDAAgD;IAChD,eAAe,EAAE,OAAO,CAAA;CACzB,KAAG,mBA0NH,CAAA"}
|