@scalar/blocks 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/code-example/components/CodeExample.vue.d.ts +5 -2
  3. package/dist/code-example/components/CodeExample.vue.d.ts.map +1 -1
  4. package/dist/code-example/components/CodeExample.vue.js +1 -1
  5. package/dist/code-example/components/CodeExample.vue.js.map +1 -1
  6. package/dist/code-example/components/CodeExample.vue.script.js +90 -82
  7. package/dist/code-example/components/CodeExample.vue.script.js.map +1 -1
  8. package/dist/code-example/components/HttpMethod.vue.d.ts +1 -2
  9. package/dist/code-example/components/HttpMethod.vue.d.ts.map +1 -1
  10. package/dist/code-example/components/HttpMethod.vue.js.map +1 -1
  11. package/dist/code-example/components/HttpMethod.vue.script.js +15 -11
  12. package/dist/code-example/components/HttpMethod.vue.script.js.map +1 -1
  13. package/dist/code-example/helpers/generate-client-options.d.ts +1 -0
  14. package/dist/code-example/helpers/generate-client-options.d.ts.map +1 -1
  15. package/dist/code-example/helpers/generate-client-options.js +7 -3
  16. package/dist/code-example/helpers/generate-client-options.js.map +1 -1
  17. package/dist/code-example/helpers/generate-code-snippet.d.ts +5 -4
  18. package/dist/code-example/helpers/generate-code-snippet.d.ts.map +1 -1
  19. package/dist/code-example/helpers/generate-code-snippet.js +25 -18
  20. package/dist/code-example/helpers/generate-code-snippet.js.map +1 -1
  21. package/dist/code-example/helpers/get-clients.d.ts.map +1 -1
  22. package/dist/code-example/helpers/get-clients.js +4 -2
  23. package/dist/code-example/helpers/get-clients.js.map +1 -1
  24. package/dist/code-example/helpers/operation-to-har/operation-to-har.d.ts +4 -3
  25. package/dist/code-example/helpers/operation-to-har/operation-to-har.d.ts.map +1 -1
  26. package/dist/code-example/helpers/operation-to-har/operation-to-har.js +35 -26
  27. package/dist/code-example/helpers/operation-to-har/operation-to-har.js.map +1 -1
  28. package/dist/code-example/helpers/operation-to-har/process-body.d.ts +2 -2
  29. package/dist/code-example/helpers/operation-to-har/process-body.d.ts.map +1 -1
  30. package/dist/code-example/helpers/operation-to-har/process-body.js +63 -62
  31. package/dist/code-example/helpers/operation-to-har/process-body.js.map +1 -1
  32. package/dist/code-example/helpers/operation-to-har/process-parameters.d.ts +2 -0
  33. package/dist/code-example/helpers/operation-to-har/process-parameters.d.ts.map +1 -1
  34. package/dist/code-example/helpers/operation-to-har/process-parameters.js +163 -95
  35. package/dist/code-example/helpers/operation-to-har/process-parameters.js.map +1 -1
  36. package/dist/code-example/mount.d.ts +3 -2
  37. package/dist/code-example/mount.d.ts.map +1 -1
  38. package/dist/code-example/mount.js +32 -28
  39. package/dist/code-example/mount.js.map +1 -1
  40. package/dist/constants.js +1 -1
  41. package/dist/style.css +1 -1
  42. package/dist/vue-styles.css +1 -1
  43. package/package.json +6 -6
@@ -1,8 +1,10 @@
1
1
  import { getResolvedRef as e } from "@scalar/workspace-store/helpers/get-resolved-ref";
2
- import { deSerializeParameter as t, getExample as n, getExampleFromSchema as r, isParamDisabled as i, serializeContentValue as a, serializeCookieStyle as o, serializeDeepObjectStyle as s, serializeFormStyle as c, serializeFormStyleForCookies as l, serializePipeDelimitedStyle as u, serializeSimpleStyle as d, serializeSpaceDelimitedStyle as f } from "@scalar/workspace-store/request-example";
3
- import { isObjectLike as p } from "@scalar/helpers/object/is-object";
2
+ import { deSerializeParameter as t, getExampleFromSchema as n, isParamDisabled as r, serializeContentValue as i, serializeCookieStyle as a, serializeDeepObjectStyle as o, serializeFormStyle as s, serializeFormStyleForCookies as c, serializePipeDelimitedStyle as l, serializeSimpleStyle as u, serializeSpaceDelimitedStyle as d } from "@scalar/workspace-store/request-example";
3
+ import { isObjectLike as f } from "@scalar/helpers/object/is-object";
4
+ import { getParameterExample as p } from "@scalar/workspace-store/helpers/get-parameter-example";
5
+ import { getQuerystringParameter as m, serializeQuerystringParameter as h } from "@scalar/workspace-store/helpers/querystring-parameter";
4
6
  //#region src/code-example/helpers/operation-to-har/process-parameters.ts
5
- var m = (t) => (t ?? []).map((t) => e(t)).filter((e) => e !== void 0), h = (e) => "allowReserved" in e && e.allowReserved !== void 0 ? e.allowReserved : "schema" in e && e.schema && typeof e.schema == "object" && "allowReserved" in e.schema ? e.schema.allowReserved === !0 : !1, g = (e, t) => h(t) ? e : encodeURIComponent(e), _ = (e) => {
7
+ var g = (t) => (t ?? []).map((t) => e(t)).filter((e) => e !== void 0), _ = (e) => "allowReserved" in e && e.allowReserved !== void 0 ? e.allowReserved : "schema" in e && e.schema && typeof e.schema == "object" && "allowReserved" in e.schema ? e.schema.allowReserved === !0 : !1, v = (e, t) => _(t) ? e : encodeURIComponent(e), y = (e) => {
6
8
  if (e.in === "header") return {
7
9
  style: "simple",
8
10
  explode: "explode" in e && e.explode !== void 0 && e.explode
@@ -17,151 +19,217 @@ var m = (t) => (t ?? []).map((t) => e(t)).filter((e) => e !== void 0), h = (e) =
17
19
  let t = {
18
20
  path: "simple",
19
21
  query: "form",
22
+ querystring: "form",
20
23
  header: "simple",
21
24
  cookie: "form"
22
- }[e.in] ?? "form", n = "style" in e && e.style ? e.style : t;
25
+ }[e.in], n = "style" in e && e.style ? e.style : t;
23
26
  return {
24
27
  style: n,
25
28
  explode: "explode" in e && e.explode !== void 0 ? e.explode : n === "form"
26
29
  };
27
- }, v = (a, o, s, c) => {
28
- let l = n(a, o, s);
29
- if (i(a, l, c)) return;
30
- if (l?.value !== void 0) return t(l.value, a);
31
- if (!("schema" in a) || !a.schema) return;
32
- let u = a.in === "path" ? { emptyString: `{${a.name}}` } : {}, d = e(a.schema);
33
- return d ? r(d, u) : void 0;
34
- }, y = ({ harRequest: e, parameters: t, example: n, defaultDisabled: r }) => {
35
- let i = [...e.headers], p = [...e.queryString], h = [], y = e.url, x = m(t);
36
- for (let t of x) {
37
- if (!t.in || !t.name) continue;
38
- let m = v(t, n, void 0, r);
39
- if (m === void 0) continue;
40
- let { style: x, explode: S } = _(t);
41
- switch (t.in) {
30
+ }, b = (i, a, o) => {
31
+ let s = p(i, a), c = s.example;
32
+ if (r(i, c, o)) return;
33
+ if (s.value !== void 0) return t(s.value, i);
34
+ if (!("schema" in i) || !i.schema) return;
35
+ let l = i.in === "path" ? { emptyString: `{${i.name}}` } : {}, u = e(i.schema);
36
+ return u ? n(u, l) : void 0;
37
+ }, x = ({ harRequest: e, parameters: t, example: n, defaultDisabled: f }) => {
38
+ let _ = [...e.headers], x = [...e.queryString], C = [...e.cookies], w = [], T = e.url, E = [], D = [], O = g(t);
39
+ for (let e of O) {
40
+ if (!e.in || !e.name) continue;
41
+ if (e.in === "querystring") {
42
+ let t = m(e, n, { defaultDisabled: f });
43
+ if (t) {
44
+ let e = T.indexOf("#"), n = e === -1 ? "" : T.slice(e), r = (e === -1 ? T : T.slice(0, e)).split("?")[0], i = h(t);
45
+ T = `${r}${i ? `?${i}` : ""}${n}`;
46
+ }
47
+ continue;
48
+ }
49
+ let t = p(e, n);
50
+ if (t.serialized && !r(e, t.example, f)) {
51
+ let n = String(t.value);
52
+ switch (e.in) {
53
+ case "path":
54
+ T = T.replaceAll(`{${e.name}}`, () => n);
55
+ break;
56
+ case "query":
57
+ E.push(n);
58
+ break;
59
+ case "header":
60
+ _.push({
61
+ name: e.name,
62
+ value: n
63
+ });
64
+ break;
65
+ case "cookie":
66
+ D.push(n);
67
+ break;
68
+ }
69
+ continue;
70
+ }
71
+ if (t.mediaSerialized && !r(e, t.example, f)) {
72
+ let n = String(t.value);
73
+ switch (e.in) {
74
+ case "query":
75
+ x.push({
76
+ name: e.name,
77
+ value: v(n, e)
78
+ });
79
+ break;
80
+ case "header":
81
+ _.push({
82
+ name: e.name,
83
+ value: n
84
+ });
85
+ break;
86
+ case "path":
87
+ T = T.replaceAll(`{${e.name}}`, () => encodeURIComponent(n));
88
+ break;
89
+ case "cookie":
90
+ C.push({
91
+ name: e.name,
92
+ value: n
93
+ });
94
+ break;
95
+ }
96
+ continue;
97
+ }
98
+ let g = b(e, n, f);
99
+ if (g === void 0) continue;
100
+ let { style: O, explode: k } = y(e);
101
+ switch (e.in) {
42
102
  case "path":
43
- y = b(y, t, m, x, S);
103
+ T = S(T, e, g, O, k);
44
104
  break;
45
105
  case "query":
46
- case "querystring":
47
- if ("content" in t && t.content) {
48
- let e = a(m, Object.keys(t.content)[0] ?? "application/json");
49
- p.push({
50
- name: t.name,
51
- value: g(e, t)
106
+ if ("content" in e && e.content) {
107
+ let t = i(g, Object.keys(e.content)[0] ?? "application/json");
108
+ x.push({
109
+ name: e.name,
110
+ value: v(t, e)
52
111
  });
53
112
  break;
54
113
  }
55
- switch (x) {
114
+ switch (O) {
56
115
  case "form": {
57
- let e = c(m, S);
58
- if (Array.isArray(e)) for (let n of e) {
59
- let e = n.key || t.name;
60
- p.push({
61
- name: e,
62
- value: g(String(n.value), t)
116
+ let t = s(g, k);
117
+ if (Array.isArray(t)) for (let n of t) {
118
+ let t = n.key || e.name;
119
+ x.push({
120
+ name: t,
121
+ value: v(String(n.value), e)
63
122
  });
64
123
  }
65
- else p.push({
66
- name: t.name,
67
- value: g(String(e), t)
124
+ else x.push({
125
+ name: e.name,
126
+ value: v(String(t), e)
68
127
  });
69
128
  break;
70
129
  }
71
130
  case "spaceDelimited": {
72
- let e = f(m);
73
- p.push({
74
- name: t.name,
75
- value: g(e, t)
131
+ let t = d(g);
132
+ x.push({
133
+ name: e.name,
134
+ value: v(t, e)
76
135
  });
77
136
  break;
78
137
  }
79
138
  case "pipeDelimited": {
80
- let e = u(m);
81
- p.push({
82
- name: t.name,
83
- value: g(e, t)
139
+ let t = l(g);
140
+ x.push({
141
+ name: e.name,
142
+ value: v(t, e)
84
143
  });
85
144
  break;
86
145
  }
87
146
  case "deepObject":
88
- if (Array.isArray(m)) {
89
- let e = c(m, !0);
90
- if (Array.isArray(e)) for (let n of e) {
91
- let e = n.key || t.name;
92
- p.push({
93
- name: e,
94
- value: g(String(n.value), t)
147
+ if (Array.isArray(g)) {
148
+ let t = s(g, !0);
149
+ if (Array.isArray(t)) for (let n of t) {
150
+ let t = n.key || e.name;
151
+ x.push({
152
+ name: t,
153
+ value: v(String(n.value), e)
95
154
  });
96
155
  }
97
- else p.push({
98
- name: t.name,
99
- value: g(String(e), t)
156
+ else x.push({
157
+ name: e.name,
158
+ value: v(String(t), e)
100
159
  });
101
160
  } else {
102
- let e = s(t.name, m);
103
- for (let n of e) p.push({
161
+ let t = o(e.name, g);
162
+ for (let n of t) x.push({
104
163
  name: n.key,
105
- value: g(n.value, t)
164
+ value: v(n.value, e)
106
165
  });
107
166
  }
108
167
  break;
109
- default: p.push({
110
- name: t.name,
111
- value: g(String(m), t)
168
+ default: x.push({
169
+ name: e.name,
170
+ value: v(String(g), e)
112
171
  });
113
172
  }
114
173
  break;
115
174
  case "header": {
116
- let e = d(m, S);
117
- i.push({
118
- name: t.name,
119
- value: String(e)
175
+ let t = u(g, k);
176
+ _.push({
177
+ name: e.name,
178
+ value: String(t)
120
179
  });
121
180
  break;
122
181
  }
123
182
  case "cookie": {
124
- if (x === "cookie") {
125
- h.push(...o(t.name, m, S));
183
+ if (O === "cookie") {
184
+ w.push(...a(e.name, g, k));
126
185
  break;
127
186
  }
128
- let n = l(m, S);
129
- if (Array.isArray(n)) for (let r of n) {
130
- let n = r.key || t.name, i = r.value === null ? "null" : String(r.value);
131
- e.cookies.push({
132
- name: n,
133
- value: i
187
+ let t = c(g, k);
188
+ if (Array.isArray(t)) for (let n of t) {
189
+ let t = n.key || e.name, r = n.value === null ? "null" : String(n.value);
190
+ C.push({
191
+ name: t,
192
+ value: r
134
193
  });
135
194
  }
136
195
  else {
137
- let r = n === null ? "null" : String(n);
138
- e.cookies.push({
139
- name: t.name,
140
- value: r
196
+ let n = t === null ? "null" : String(t);
197
+ C.push({
198
+ name: e.name,
199
+ value: n
141
200
  });
142
201
  }
143
202
  break;
144
203
  }
145
204
  }
146
205
  }
147
- if (h.length) {
148
- let t = [...e.cookies.map((e) => `${encodeURIComponent(e.name)}=${encodeURIComponent(e.value)}`), ...h.map((e) => `${e.name}=${e.value}`)].join("; "), n = i.find((e) => e.name.toLowerCase() === "cookie");
149
- n ? i.splice(i.indexOf(n), 1, {
150
- ...n,
151
- value: n.value ? `${n.value}; ${t}` : t
152
- }) : i.push({
206
+ if (w.length || D.length) {
207
+ let e = [
208
+ ...C.map((e) => `${encodeURIComponent(e.name)}=${encodeURIComponent(e.value)}`),
209
+ ...w.map((e) => `${e.name}=${e.value}`),
210
+ ...D
211
+ ].join("; "), t = _.find((e) => e.name.toLowerCase() === "cookie");
212
+ t ? _.splice(_.indexOf(t), 1, {
213
+ ...t,
214
+ value: t.value ? `${t.value}; ${e}` : e
215
+ }) : _.push({
153
216
  name: "Cookie",
154
- value: t
217
+ value: e
155
218
  });
156
219
  }
220
+ if (E.length) {
221
+ let e = T.indexOf("#"), t = e < 0 ? "" : T.slice(e), n = e < 0 ? T : T.slice(0, e);
222
+ T = `${n}${n.includes("?") ? "&" : "?"}${E.join("&")}${t}`;
223
+ }
157
224
  return {
158
- url: y,
159
- headers: i,
160
- queryString: p,
161
- cookies: h.length ? [] : e.cookies,
162
- hasCookieStyleEntries: h.length > 0
225
+ url: T,
226
+ headers: _,
227
+ queryString: x,
228
+ cookies: w.length || D.length ? [] : C,
229
+ hasCookieStyleEntries: w.length > 0 || D.length > 0,
230
+ ...E.length ? { hasSerializedQuery: !0 } : {}
163
231
  };
164
- }, b = (e, t, n, r, i) => {
232
+ }, S = (e, t, n, r, i) => {
165
233
  switch (r) {
166
234
  case "matrix":
167
235
  if (i) {
@@ -169,14 +237,14 @@ var m = (t) => (t ?? []).map((t) => e(t)).filter((e) => e !== void 0), h = (e) =
169
237
  let r = n.map((e) => `${t.name}=${e}`).join(";");
170
238
  return e.replace(`{;${t.name}}`, `;${r}`);
171
239
  }
172
- if (p(n)) {
240
+ if (f(n)) {
173
241
  let r = Object.entries(n).map(([e, t]) => `${e}=${t}`).join(";");
174
242
  return e.replace(`{;${t.name}}`, `;${r}`);
175
243
  }
176
244
  return e.replace(`{;${t.name}}`, `;${t.name}=${n}`);
177
245
  }
178
246
  if (Array.isArray(n)) return e.replace(`{;${t.name}}`, `;${t.name}=${n.join(",")}`);
179
- if (p(n)) {
247
+ if (f(n)) {
180
248
  let r = Object.entries(n).map(([e, t]) => `${e},${t}`).join(",");
181
249
  return e.replace(`{;${t.name}}`, `;${t.name}=${r}`);
182
250
  }
@@ -184,26 +252,26 @@ var m = (t) => (t ?? []).map((t) => e(t)).filter((e) => e !== void 0), h = (e) =
184
252
  case "label":
185
253
  if (i) {
186
254
  if (Array.isArray(n)) return e.replace(`{.${t.name}}`, `.${n.join(".")}`);
187
- if (p(n)) {
255
+ if (f(n)) {
188
256
  let r = Object.entries(n).map(([e, t]) => `${e}=${t}`).join(".");
189
257
  return e.replace(`{.${t.name}}`, `.${r}`);
190
258
  }
191
259
  return e.replace(`{.${t.name}}`, `.${n}`);
192
260
  }
193
261
  if (Array.isArray(n)) return e.replace(`{.${t.name}}`, `.${n.join(",")}`);
194
- if (p(n)) {
262
+ if (f(n)) {
195
263
  let r = Object.entries(n).map(([e, t]) => `${e},${t}`).join(",");
196
264
  return e.replace(`{.${t.name}}`, `.${r}`);
197
265
  }
198
266
  return e.replace(`{.${t.name}}`, `.${n}`);
199
267
  case "simple": {
200
- let r = d(n, i);
268
+ let r = u(n, i);
201
269
  return e.replace(`{${t.name}}`, String(r));
202
270
  }
203
271
  default: return e.replace(`{${t.name}}`, String(n));
204
272
  }
205
273
  };
206
274
  //#endregion
207
- export { y as processParameters };
275
+ export { x as processParameters };
208
276
 
209
277
  //# sourceMappingURL=process-parameters.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"process-parameters.js","names":[],"sources":["../../../../src/code-example/helpers/operation-to-har/process-parameters.ts"],"sourcesContent":["import { isObjectLike } from '@scalar/helpers/object/is-object'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n deSerializeParameter,\n getExample,\n getExampleFromSchema,\n isParamDisabled,\n serializeContentValue,\n serializeCookieStyle,\n serializeDeepObjectStyle,\n serializeFormStyle,\n serializeFormStyleForCookies,\n serializePipeDelimitedStyle,\n serializeSimpleStyle,\n serializeSpaceDelimitedStyle,\n} from '@scalar/workspace-store/request-example'\nimport type { OperationObject, ParameterObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport type { Request as HarRequest } from 'har-format'\n\ntype ProcessedParameters = {\n url: string\n headers: HarRequest['headers']\n queryString: HarRequest['queryString']\n cookies: HarRequest['cookies']\n /** Whether serialized cookie-style values require a complete Cookie header. */\n hasCookieStyleEntries: boolean\n}\n\n/** Ensures we don't have any references in the parameters */\nconst deReferenceParams = (params: OperationObject['parameters']): ParameterObject[] =>\n (params ?? []).map((param) => getResolvedRef(param)).filter((param) => param !== undefined)\n\n/** Whether the parameter allows reserved characters (from param or schema). */\nconst isAllowReserved = (param: ParameterObject): boolean => {\n if ('allowReserved' in param && param.allowReserved !== undefined) {\n return param.allowReserved\n }\n if ('schema' in param && param.schema && typeof param.schema === 'object' && 'allowReserved' in param.schema) {\n return (param.schema as { allowReserved?: boolean }).allowReserved === true\n }\n return false\n}\n\n/** URL encode a value if allowReserved is not set to true. */\nconst encodeQueryValue = (value: string, param: ParameterObject): string => {\n if (isAllowReserved(param)) {\n return value\n }\n return encodeURIComponent(value)\n}\n\n/**\n * Get the style and explode values for a parameter according to OpenAPI 3.1.1 specification.\n * Handles defaults and validation for parameter location restrictions.\n */\nconst getParameterStyleAndExplode = (param: ParameterObject): { style: string; explode: boolean } => {\n // Headers only support 'simple' style\n if (param.in === 'header') {\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : false\n return { style: 'simple', explode }\n }\n\n // Cookies default to form for compatibility and also support cookie style.\n if (param.in === 'cookie') {\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : true\n return { style: 'style' in param && param.style === 'cookie' ? 'cookie' : 'form', explode }\n }\n\n // The 3.2 `querystring` location has no style/explode of its own, so it falls through to the\n // `form` default here and is then serialized like a regular query parameter (see the switch below).\n const defaultStyle =\n (\n {\n path: 'simple',\n query: 'form',\n header: 'simple',\n cookie: 'form',\n } as Record<string, string>\n )[param.in] ?? 'form'\n\n // Use provided style or default based on location\n const style = 'style' in param && param.style ? param.style : defaultStyle\n\n // Determine explode value: use provided value or default based on style\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : style === 'form'\n\n return { style, explode }\n}\n\n/**\n * Extract the value for a parameter from example data or schema.\n * Prioritizes example data over schema examples.\n * Returns null if the parameter is disabled so we can skip it.\n */\nconst getParameterValue = (\n param: ParameterObject,\n example: string | undefined,\n contentType: string | undefined,\n defaultDisabled: boolean,\n): unknown => {\n // Try to get value from example first\n const exampleValue = getExample(param, example, contentType)\n\n // If the parameter is disabled, return undefined so we can skip it.\n if (isParamDisabled(param, exampleValue, defaultDisabled)) {\n return undefined\n }\n\n // If the example value is set, return it.\n if (exampleValue?.value !== undefined) {\n return deSerializeParameter(exampleValue.value, param)\n }\n\n // Fall back to schema example if available\n if (!('schema' in param) || !param.schema) {\n return undefined\n }\n\n const options = param.in === 'path' ? { emptyString: `{${param.name}}` } : {}\n const schema = getResolvedRef(param.schema)\n return schema ? getExampleFromSchema(schema, options) : undefined\n}\n\n/**\n * Process OpenAPI parameters and return the updated properties.\n * Handles path, query, and header parameters with various styles and explode options.\n *\n * @see https://spec.openapis.org/oas/latest.html#style-values\n */\nexport const processParameters = ({\n harRequest,\n parameters,\n example,\n defaultDisabled,\n}: {\n harRequest: HarRequest\n parameters: OperationObject['parameters']\n /** The name of the example to use */\n example?: string | undefined\n /** Whether to disable parameters by default. */\n defaultDisabled: boolean\n}): ProcessedParameters => {\n // Create copies of the arrays to avoid modifying the input\n const newHeaders = [...harRequest.headers]\n const newQueryString = [...harRequest.queryString]\n const cookieStyleEntries: HarRequest['cookies'] = []\n let newUrl = harRequest.url\n\n // Filter out references\n const deReferencedParams = deReferenceParams(parameters)\n\n for (const param of deReferencedParams) {\n if (!param.in || !param.name) {\n continue\n }\n\n const paramValue = getParameterValue(param, example, undefined, defaultDisabled)\n if (paramValue === undefined) {\n continue\n }\n\n const { style, explode } = getParameterStyleAndExplode(param)\n\n switch (param.in) {\n case 'path': {\n newUrl = processPathParameters(newUrl, param, paramValue, style, explode)\n break\n }\n\n // The 3.2 `querystring` location represents the whole query string. Handle it like a\n // regular query parameter so its value still lands in the query string instead of\n // being silently dropped.\n case 'query':\n case 'querystring': {\n // Content type parameters should be serialized according to the parameter's own content type\n if ('content' in param && param.content) {\n // We grab the first for now but eventually we should support selecting the content type per parameter\n const paramContentType = Object.keys(param.content)[0] ?? 'application/json'\n const serializedValue = serializeContentValue(paramValue, paramContentType)\n newQueryString.push({ name: param.name, value: encodeQueryValue(serializedValue, param) })\n break\n }\n\n // Handle query parameters\n switch (style) {\n case 'form': {\n const serialized = serializeFormStyle(paramValue, explode)\n\n // If serialized is an array of key-value pairs (exploded object or array)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || param.name\n newQueryString.push({ name: key, value: encodeQueryValue(String(entry.value), param) })\n }\n }\n // Otherwise, convert to string\n else {\n newQueryString.push({ name: param.name, value: encodeQueryValue(String(serialized), param) })\n }\n break\n }\n case 'spaceDelimited': {\n const serialized = serializeSpaceDelimitedStyle(paramValue)\n newQueryString.push({ name: param.name, value: encodeQueryValue(serialized, param) })\n break\n }\n case 'pipeDelimited': {\n const serialized = serializePipeDelimitedStyle(paramValue)\n newQueryString.push({ name: param.name, value: encodeQueryValue(serialized, param) })\n break\n }\n case 'deepObject': {\n // OAS marks deepObject-on-array and deepObject+explode:false as undefined.\n // Mirror process-body: fall back to form/explode:true for arrays and always\n // invoke the serializer for objects so authors get useful output instead of\n // a silently-dropped parameter.\n if (Array.isArray(paramValue)) {\n const serialized = serializeFormStyle(paramValue, true)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || param.name\n newQueryString.push({ name: key, value: encodeQueryValue(String(entry.value), param) })\n }\n } else {\n newQueryString.push({ name: param.name, value: encodeQueryValue(String(serialized), param) })\n }\n } else {\n const entries = serializeDeepObjectStyle(param.name, paramValue)\n for (const entry of entries) {\n newQueryString.push({ name: entry.key, value: encodeQueryValue(entry.value, param) })\n }\n }\n break\n }\n\n // Default to form style\n default:\n newQueryString.push({ name: param.name, value: encodeQueryValue(String(paramValue), param) })\n }\n break\n }\n\n // Headers only support 'simple' style according to OpenAPI 3.1.1\n // For arrays, simple style always produces comma-separated values regardless of explode\n // The explode parameter only affects object serialization\n case 'header': {\n const serialized = serializeSimpleStyle(paramValue, explode)\n newHeaders.push({ name: param.name, value: String(serialized) })\n break\n }\n\n // Keep cookie style separate so snippet generators cannot percent-encode it.\n case 'cookie': {\n if (style === 'cookie') {\n cookieStyleEntries.push(...serializeCookieStyle(param.name, paramValue, explode))\n break\n }\n const serialized = serializeFormStyleForCookies(paramValue, explode)\n\n // If serialized is an array of key-value pairs (exploded object or array)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || param.name\n const value = entry.value === null ? 'null' : String(entry.value)\n harRequest.cookies.push({ name: key, value })\n }\n }\n // Otherwise, convert to string\n else {\n const value = serialized === null ? 'null' : String(serialized)\n harRequest.cookies.push({ name: param.name, value })\n }\n break\n }\n }\n }\n\n // HAR cookie entries are encoded by snippet generators. Use a complete header\n // when cookie style is present, preserving legacy encoding for other cookies.\n if (cookieStyleEntries.length) {\n const cookieValue = [\n ...harRequest.cookies.map((cookie) => `${encodeURIComponent(cookie.name)}=${encodeURIComponent(cookie.value)}`),\n ...cookieStyleEntries.map((cookie) => `${cookie.name}=${cookie.value}`),\n ].join('; ')\n const existing = newHeaders.find((header) => header.name.toLowerCase() === 'cookie')\n if (existing) {\n newHeaders.splice(newHeaders.indexOf(existing), 1, {\n ...existing,\n value: existing.value ? `${existing.value}; ${cookieValue}` : cookieValue,\n })\n } else {\n newHeaders.push({ name: 'Cookie', value: cookieValue })\n }\n }\n\n return {\n url: newUrl,\n headers: newHeaders,\n queryString: newQueryString,\n cookies: cookieStyleEntries.length ? [] : harRequest.cookies,\n hasCookieStyleEntries: cookieStyleEntries.length > 0,\n }\n}\n\n/**\n * Process path parameters according to OpenAPI specification.\n * Handles matrix, label, and simple styles with explode options.\n *\n * @param url - The URL to process\n * @param param - The parameter object\n * @param paramValue - The value of the parameter\n * @param style - The style of the parameter (matrix, label, simple)\n * @param explode - Whether to explode the parameter\n * @returns The updated URL with processed path parameters\n */\nconst processPathParameters = (\n url: string,\n param: ParameterObject,\n paramValue: unknown,\n style: string,\n explode: boolean,\n): string => {\n switch (style) {\n case 'matrix': {\n if (explode) {\n // Matrix explode array: ;color=blue;color=black;color=brown\n if (Array.isArray(paramValue)) {\n const values = paramValue.map((v: unknown) => `${param.name}=${v}`).join(';')\n return url.replace(`{;${param.name}}`, `;${values}`)\n }\n\n // Matrix explode object: ;R=100;G=200;B=150\n if (isObjectLike(paramValue)) {\n const values = Object.entries(paramValue)\n .map(([k, v]) => `${k}=${v}`)\n .join(';')\n return url.replace(`{;${param.name}}`, `;${values}`)\n }\n\n // Matrix explode primitive: ;color=blue\n return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue}`)\n }\n\n // Matrix no explode array: ;color=blue,black,brown\n if (Array.isArray(paramValue)) {\n return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue.join(',')}`)\n }\n\n // Matrix no explode object: ;color=R,100,G,200,B,150\n if (isObjectLike(paramValue)) {\n const values = Object.entries(paramValue)\n .map(([k, v]) => `${k},${v}`)\n .join(',')\n return url.replace(`{;${param.name}}`, `;${param.name}=${values}`)\n }\n\n // Matrix no explode primitive: ;color=blue\n return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue}`)\n }\n case 'label': {\n if (explode) {\n // Label explode array: .blue.black.brown\n if (Array.isArray(paramValue)) {\n return url.replace(`{.${param.name}}`, `.${paramValue.join('.')}`)\n }\n\n // Label explode object: .R=100.G=200.B=150\n if (isObjectLike(paramValue)) {\n const values = Object.entries(paramValue)\n .map(([k, v]) => `${k}=${v}`)\n .join('.')\n\n return url.replace(`{.${param.name}}`, `.${values}`)\n }\n\n // Label explode primitive: .blue\n return url.replace(`{.${param.name}}`, `.${paramValue}`)\n }\n\n // Label no explode array: .blue,black,brown\n if (Array.isArray(paramValue)) {\n return url.replace(`{.${param.name}}`, `.${paramValue.join(',')}`)\n }\n\n // Label no explode object: .R,100,G,200,B,150\n if (isObjectLike(paramValue)) {\n const values = Object.entries(paramValue)\n .map(([k, v]) => `${k},${v}`)\n .join(',')\n\n return url.replace(`{.${param.name}}`, `.${values}`)\n }\n\n // Label no explode primitive: .blue\n return url.replace(`{.${param.name}}`, `.${paramValue}`)\n }\n\n case 'simple': {\n const serialized = serializeSimpleStyle(paramValue, explode)\n return url.replace(`{${param.name}}`, String(serialized))\n }\n\n // Default to simple style\n default:\n return url.replace(`{${param.name}}`, String(paramValue))\n }\n}\n"],"mappings":";;;;AA6BA,IAAM,KAAqB,OACxB,KAAU,CAAC,EAAA,CAAG,KAAK,MAAU,EAAe,CAAK,CAAC,CAAC,CAAC,QAAQ,MAAU,MAAU,KAAA,CAAS,GAGtF,KAAmB,MACnB,mBAAmB,KAAS,EAAM,kBAAkB,KAAA,IAC/C,EAAM,gBAEX,YAAY,KAAS,EAAM,UAAU,OAAO,EAAM,UAAW,YAAY,mBAAmB,EAAM,SAC5F,EAAM,OAAuC,kBAAkB,KAElE,IAIH,KAAoB,GAAe,MACnC,EAAgB,CAAK,IAChB,IAEF,mBAAmB,CAAK,GAO3B,KAA+B,MAAgE;CAEnG,IAAI,EAAM,OAAO,UAEf,OAAO;EAAE,OAAO;EAAU,SADV,aAAa,KAAS,EAAM,YAAY,KAAA,KAAY,EAAM;CACxC;CAIpC,IAAI,EAAM,OAAO,UAAU;EACzB,IAAM,IAAU,aAAa,KAAS,EAAM,YAAY,KAAA,IAAY,EAAM,UAAU;EACpF,OAAO;GAAE,OAAO,WAAW,KAAS,EAAM,UAAU,WAAW,WAAW;GAAQ;EAAQ;CAC5F;CAIA,IAAM,IA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OAAO,EAAI,QAAQ,KAAK,EAAM,KAAK,IAAI,IAAI,EAAM,KAAK,GAAG,GAAY;EAEvE,KAAK;GACH,IAAI,GAAS;IAEX,IAAI,MAAM,QAAQ,CAAU,GAC1B,OAAO,EAAI,QAAQ,KAAK,EAAM,KAAK,IAAI,IAAI,EAAW,KAAK,GAAG,GAAG;IAInE,IAAI,EAAa,CAAU,GAAG;KAC5B,IAAM,IAAS,OAAO,QAAQ,CAAU,CAAC,CACtC,KAAK,CAAC,GAAG,OAAO,GAAG,EAAE,GAAG,GAAG,CAAC,CAC5B,KAAK,GAAG;KAEX,OAAO,EAAI,QAAQ,KAAK,EAAM,KAAK,IAAI,IAAI,GAAQ;IACrD;IAGA,OAAO,EAAI,QAAQ,KAAK,EAAM,KAAK,IAAI,IAAI,GAAY;GACzD;GAGA,IAAI,MAAM,QAAQ,CAAU,GAC1B,OAAO,EAAI,QAAQ,KAAK,EAAM,KAAK,IAAI,IAAI,EAAW,KAAK,GAAG,GAAG;GAInE,IAAI,EAAa,CAAU,GAAG;IAC5B,IAAM,IAAS,OAAO,QAAQ,CAAU,CAAC,CACtC,KAAK,CAAC,GAAG,OAAO,GAAG,EAAE,GAAG,GAAG,CAAC,CAC5B,KAAK,GAAG;IAEX,OAAO,EAAI,QAAQ,KAAK,EAAM,KAAK,IAAI,IAAI,GAAQ;GACrD;GAGA,OAAO,EAAI,QAAQ,KAAK,EAAM,KAAK,IAAI,IAAI,GAAY;EAGzD,KAAK,UAAU;GACb,IAAM,IAAa,EAAqB,GAAY,CAAO;GAC3D,OAAO,EAAI,QAAQ,IAAI,EAAM,KAAK,IAAI,OAAO,CAAU,CAAC;EAC1D;EAGA,SACE,OAAO,EAAI,QAAQ,IAAI,EAAM,KAAK,IAAI,OAAO,CAAU,CAAC;CAC5D;AACF"}
1
+ {"version":3,"file":"process-parameters.js","names":[],"sources":["../../../../src/code-example/helpers/operation-to-har/process-parameters.ts"],"sourcesContent":["import { isObjectLike } from '@scalar/helpers/object/is-object'\nimport { getParameterExample } from '@scalar/workspace-store/helpers/get-parameter-example'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n getQuerystringParameter,\n serializeQuerystringParameter,\n} from '@scalar/workspace-store/helpers/querystring-parameter'\nimport {\n deSerializeParameter,\n getExampleFromSchema,\n isParamDisabled,\n serializeContentValue,\n serializeCookieStyle,\n serializeDeepObjectStyle,\n serializeFormStyle,\n serializeFormStyleForCookies,\n serializePipeDelimitedStyle,\n serializeSimpleStyle,\n serializeSpaceDelimitedStyle,\n} from '@scalar/workspace-store/request-example'\nimport type { OperationObject, ParameterObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport type { Request as HarRequest } from 'har-format'\n\ntype ProcessedParameters = {\n /** Named serialized examples already embedded in the URL. */\n hasSerializedQuery?: boolean\n url: string\n headers: HarRequest['headers']\n queryString: HarRequest['queryString']\n cookies: HarRequest['cookies']\n /** Whether serialized cookie-style values require a complete Cookie header. */\n hasCookieStyleEntries: boolean\n}\n\n/** Ensures we don't have any references in the parameters */\nconst deReferenceParams = (params: OperationObject['parameters']): ParameterObject[] =>\n (params ?? []).map((param) => getResolvedRef(param)).filter((param) => param !== undefined)\n\n/** Whether the parameter allows reserved characters (from param or schema). */\nconst isAllowReserved = (param: ParameterObject): boolean => {\n if ('allowReserved' in param && param.allowReserved !== undefined) {\n return param.allowReserved\n }\n if ('schema' in param && param.schema && typeof param.schema === 'object' && 'allowReserved' in param.schema) {\n return (param.schema as { allowReserved?: boolean }).allowReserved === true\n }\n return false\n}\n\n/** URL encode a value if allowReserved is not set to true. */\nconst encodeQueryValue = (value: string, param: ParameterObject): string => {\n if (isAllowReserved(param)) {\n return value\n }\n return encodeURIComponent(value)\n}\n\n/**\n * Get the style and explode values for a parameter according to OpenAPI 3.1.1 specification.\n * Handles defaults and validation for parameter location restrictions.\n */\nconst getParameterStyleAndExplode = (param: ParameterObject): { style: string; explode: boolean } => {\n // Headers only support 'simple' style\n if (param.in === 'header') {\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : false\n return { style: 'simple', explode }\n }\n\n // Cookies default to form for compatibility and also support cookie style.\n if (param.in === 'cookie') {\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : true\n return { style: 'style' in param && param.style === 'cookie' ? 'cookie' : 'form', explode }\n }\n\n const defaultStyle = {\n path: 'simple',\n query: 'form',\n querystring: 'form',\n header: 'simple',\n cookie: 'form',\n }[param.in]\n\n // Use provided style or default based on location\n const style = 'style' in param && param.style ? param.style : defaultStyle\n\n // Determine explode value: use provided value or default based on style\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : style === 'form'\n\n return { style, explode }\n}\n\n/**\n * Extract the value for a parameter from example data or schema.\n * Prioritizes example data over schema examples.\n * Returns null if the parameter is disabled so we can skip it.\n */\nconst getParameterValue = (param: ParameterObject, example: string | undefined, defaultDisabled: boolean): unknown => {\n // Try to get value from example first\n const selected = getParameterExample(param, example)\n const exampleValue = selected.example\n\n // If the parameter is disabled, return undefined so we can skip it.\n if (isParamDisabled(param, exampleValue, defaultDisabled)) {\n return undefined\n }\n\n // If the example value is set, return it.\n if (selected.value !== undefined) {\n return deSerializeParameter(selected.value, param)\n }\n\n // Fall back to schema example if available\n if (!('schema' in param) || !param.schema) {\n return undefined\n }\n\n const options = param.in === 'path' ? { emptyString: `{${param.name}}` } : {}\n const schema = getResolvedRef(param.schema)\n return schema ? getExampleFromSchema(schema, options) : undefined\n}\n\n/**\n * Process OpenAPI parameters and return the updated properties.\n * Handles path, query, and header parameters with various styles and explode options.\n *\n * @see https://spec.openapis.org/oas/latest.html#style-values\n */\nexport const processParameters = ({\n harRequest,\n parameters,\n example,\n defaultDisabled,\n}: {\n harRequest: HarRequest\n parameters: OperationObject['parameters']\n /** The name of the example to use */\n example?: string | undefined\n /** Whether to disable parameters by default. */\n defaultDisabled: boolean\n}): ProcessedParameters => {\n // Create copies of the arrays to avoid modifying the input\n const newHeaders = [...harRequest.headers]\n const newQueryString = [...harRequest.queryString]\n const newCookies = [...harRequest.cookies]\n const cookieStyleEntries: HarRequest['cookies'] = []\n let newUrl = harRequest.url\n const serializedQuery: string[] = []\n const serializedCookies: string[] = []\n\n // Filter out references\n const deReferencedParams = deReferenceParams(parameters)\n\n for (const param of deReferencedParams) {\n if (!param.in || !param.name) {\n continue\n }\n\n if (param.in === 'querystring') {\n const querystring = getQuerystringParameter(param, example, { defaultDisabled })\n if (querystring) {\n const hashIndex = newUrl.indexOf('#')\n const hash = hashIndex === -1 ? '' : newUrl.slice(hashIndex)\n const base = (hashIndex === -1 ? newUrl : newUrl.slice(0, hashIndex)).split('?')[0]\n const query = serializeQuerystringParameter(querystring)\n newUrl = `${base}${query ? `?${query}` : ''}${hash}`\n }\n continue\n }\n\n const selected = getParameterExample(param, example)\n if (selected.serialized && !isParamDisabled(param, selected.example, defaultDisabled)) {\n const wireValue = String(selected.value)\n switch (param.in) {\n case 'path':\n newUrl = newUrl.replaceAll(`{${param.name}}`, () => wireValue)\n break\n case 'query':\n serializedQuery.push(wireValue)\n break\n case 'header':\n newHeaders.push({ name: param.name, value: wireValue })\n break\n case 'cookie':\n serializedCookies.push(wireValue)\n break\n }\n continue\n }\n if (selected.mediaSerialized && !isParamDisabled(param, selected.example, defaultDisabled)) {\n const text = String(selected.value)\n switch (param.in) {\n case 'query':\n newQueryString.push({ name: param.name, value: encodeQueryValue(text, param) })\n break\n case 'header':\n newHeaders.push({ name: param.name, value: text })\n break\n case 'path':\n newUrl = newUrl.replaceAll(`{${param.name}}`, () => encodeURIComponent(text))\n break\n case 'cookie':\n newCookies.push({ name: param.name, value: text })\n break\n }\n continue\n }\n const paramValue = getParameterValue(param, example, defaultDisabled)\n if (paramValue === undefined) {\n continue\n }\n\n const { style, explode } = getParameterStyleAndExplode(param)\n\n switch (param.in) {\n case 'path': {\n newUrl = processPathParameters(newUrl, param, paramValue, style, explode)\n break\n }\n\n case 'query': {\n // Content type parameters should be serialized according to the parameter's own content type\n if ('content' in param && param.content) {\n // We grab the first for now but eventually we should support selecting the content type per parameter\n const paramContentType = Object.keys(param.content)[0] ?? 'application/json'\n const serializedValue = serializeContentValue(paramValue, paramContentType)\n newQueryString.push({ name: param.name, value: encodeQueryValue(serializedValue, param) })\n break\n }\n\n // Handle query parameters\n switch (style) {\n case 'form': {\n const serialized = serializeFormStyle(paramValue, explode)\n\n // If serialized is an array of key-value pairs (exploded object or array)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || param.name\n newQueryString.push({ name: key, value: encodeQueryValue(String(entry.value), param) })\n }\n }\n // Otherwise, convert to string\n else {\n newQueryString.push({ name: param.name, value: encodeQueryValue(String(serialized), param) })\n }\n break\n }\n case 'spaceDelimited': {\n const serialized = serializeSpaceDelimitedStyle(paramValue)\n newQueryString.push({ name: param.name, value: encodeQueryValue(serialized, param) })\n break\n }\n case 'pipeDelimited': {\n const serialized = serializePipeDelimitedStyle(paramValue)\n newQueryString.push({ name: param.name, value: encodeQueryValue(serialized, param) })\n break\n }\n case 'deepObject': {\n // OAS marks deepObject-on-array and deepObject+explode:false as undefined.\n // Mirror process-body: fall back to form/explode:true for arrays and always\n // invoke the serializer for objects so authors get useful output instead of\n // a silently-dropped parameter.\n if (Array.isArray(paramValue)) {\n const serialized = serializeFormStyle(paramValue, true)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || param.name\n newQueryString.push({ name: key, value: encodeQueryValue(String(entry.value), param) })\n }\n } else {\n newQueryString.push({ name: param.name, value: encodeQueryValue(String(serialized), param) })\n }\n } else {\n const entries = serializeDeepObjectStyle(param.name, paramValue)\n for (const entry of entries) {\n newQueryString.push({ name: entry.key, value: encodeQueryValue(entry.value, param) })\n }\n }\n break\n }\n\n // Default to form style\n default:\n newQueryString.push({ name: param.name, value: encodeQueryValue(String(paramValue), param) })\n }\n break\n }\n\n // Headers only support 'simple' style according to OpenAPI 3.1.1\n // For arrays, simple style always produces comma-separated values regardless of explode\n // The explode parameter only affects object serialization\n case 'header': {\n const serialized = serializeSimpleStyle(paramValue, explode)\n newHeaders.push({ name: param.name, value: String(serialized) })\n break\n }\n\n // Keep cookie style separate so snippet generators cannot percent-encode it.\n case 'cookie': {\n if (style === 'cookie') {\n cookieStyleEntries.push(...serializeCookieStyle(param.name, paramValue, explode))\n break\n }\n const serialized = serializeFormStyleForCookies(paramValue, explode)\n\n // If serialized is an array of key-value pairs (exploded object or array)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || param.name\n const value = entry.value === null ? 'null' : String(entry.value)\n newCookies.push({ name: key, value })\n }\n }\n // Otherwise, convert to string\n else {\n const value = serialized === null ? 'null' : String(serialized)\n newCookies.push({ name: param.name, value })\n }\n break\n }\n }\n }\n\n // HAR cookie entries are encoded by snippet generators. Use a complete header\n // when cookie style is present, preserving legacy encoding for other cookies.\n if (cookieStyleEntries.length || serializedCookies.length) {\n const cookieValue = [\n ...newCookies.map((cookie) => `${encodeURIComponent(cookie.name)}=${encodeURIComponent(cookie.value)}`),\n ...cookieStyleEntries.map((cookie) => `${cookie.name}=${cookie.value}`),\n ...serializedCookies,\n ].join('; ')\n const existing = newHeaders.find((header) => header.name.toLowerCase() === 'cookie')\n if (existing) {\n newHeaders.splice(newHeaders.indexOf(existing), 1, {\n ...existing,\n value: existing.value ? `${existing.value}; ${cookieValue}` : cookieValue,\n })\n } else {\n newHeaders.push({ name: 'Cookie', value: cookieValue })\n }\n }\n\n if (serializedQuery.length) {\n const hashIndex = newUrl.indexOf('#')\n const hash = hashIndex < 0 ? '' : newUrl.slice(hashIndex)\n const base = hashIndex < 0 ? newUrl : newUrl.slice(0, hashIndex)\n newUrl = `${base}${base.includes('?') ? '&' : '?'}${serializedQuery.join('&')}${hash}`\n }\n\n return {\n url: newUrl,\n headers: newHeaders,\n queryString: newQueryString,\n cookies: cookieStyleEntries.length || serializedCookies.length ? [] : newCookies,\n hasCookieStyleEntries: cookieStyleEntries.length > 0 || serializedCookies.length > 0,\n ...(serializedQuery.length ? { hasSerializedQuery: true } : {}),\n }\n}\n\n/**\n * Process path parameters according to OpenAPI specification.\n * Handles matrix, label, and simple styles with explode options.\n *\n * @param url - The URL to process\n * @param param - The parameter object\n * @param paramValue - The value of the parameter\n * @param style - The style of the parameter (matrix, label, simple)\n * @param explode - Whether to explode the parameter\n * @returns The updated URL with processed path parameters\n */\nconst processPathParameters = (\n url: string,\n param: ParameterObject,\n paramValue: unknown,\n style: string,\n explode: boolean,\n): string => {\n switch (style) {\n case 'matrix': {\n if (explode) {\n // Matrix explode array: ;color=blue;color=black;color=brown\n if (Array.isArray(paramValue)) {\n const values = paramValue.map((v: unknown) => `${param.name}=${v}`).join(';')\n return url.replace(`{;${param.name}}`, `;${values}`)\n }\n\n // Matrix explode object: ;R=100;G=200;B=150\n if (isObjectLike(paramValue)) {\n const values = Object.entries(paramValue)\n .map(([k, v]) => `${k}=${v}`)\n .join(';')\n return url.replace(`{;${param.name}}`, `;${values}`)\n }\n\n // Matrix explode primitive: ;color=blue\n return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue}`)\n }\n\n // Matrix no explode array: ;color=blue,black,brown\n if (Array.isArray(paramValue)) {\n return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue.join(',')}`)\n }\n\n // Matrix no explode object: ;color=R,100,G,200,B,150\n if (isObjectLike(paramValue)) {\n const values = Object.entries(paramValue)\n .map(([k, v]) => `${k},${v}`)\n .join(',')\n return url.replace(`{;${param.name}}`, `;${param.name}=${values}`)\n }\n\n // Matrix no explode primitive: ;color=blue\n return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue}`)\n }\n case 'label': {\n if (explode) {\n // Label explode array: .blue.black.brown\n if (Array.isArray(paramValue)) {\n return url.replace(`{.${param.name}}`, `.${paramValue.join('.')}`)\n }\n\n // Label explode object: .R=100.G=200.B=150\n if (isObjectLike(paramValue)) {\n const values = Object.entries(paramValue)\n .map(([k, v]) => `${k}=${v}`)\n .join('.')\n\n return url.replace(`{.${param.name}}`, `.${values}`)\n }\n\n // Label explode primitive: .blue\n return url.replace(`{.${param.name}}`, `.${paramValue}`)\n }\n\n // Label no explode array: .blue,black,brown\n if (Array.isArray(paramValue)) {\n return url.replace(`{.${param.name}}`, `.${paramValue.join(',')}`)\n }\n\n // Label no explode object: .R,100,G,200,B,150\n if (isObjectLike(paramValue)) {\n const values = Object.entries(paramValue)\n .map(([k, v]) => `${k},${v}`)\n .join(',')\n\n return url.replace(`{.${param.name}}`, `.${values}`)\n }\n\n // Label no explode primitive: .blue\n return url.replace(`{.${param.name}}`, `.${paramValue}`)\n }\n\n case 'simple': {\n const serialized = serializeSimpleStyle(paramValue, explode)\n return url.replace(`{${param.name}}`, String(serialized))\n }\n\n // Default to simple style\n default:\n return url.replace(`{${param.name}}`, String(paramValue))\n }\n}\n"],"mappings":";;;;;;AAmCA,IAAM,KAAqB,OACxB,KAAU,CAAC,EAAA,CAAG,KAAK,MAAU,EAAe,CAAK,CAAC,CAAC,CAAC,QAAQ,MAAU,MAAU,KAAA,CAAS,GAGtF,KAAmB,MACnB,mBAAmB,KAAS,EAAM,kBAAkB,KAAA,IAC/C,EAAM,gBAEX,YAAY,KAAS,EAAM,UAAU,OAAO,EAAM,UAAW,YAAY,mBAAmB,EAAM,SAC5F,EAAM,OAAuC,kBAAkB,KAElE,IAIH,KAAoB,GAAe,MACnC,EAAgB,CAAK,IAChB,IAEF,mBAAmB,CAAK,GAO3B,KAA+B,MAAgE;CAEnG,IAAI,EAAM,OAAO,UAEf,OAAO;EAAE,OAAO;EAAU,SADV,aAAa,KAAS,EAAM,YAAY,KAAA,KAAY,EAAM;CACxC;CAIpC,IAAI,EAAM,OAAO,UAAU;EACzB,IAAM,IAAU,aAAa,KAAS,EAAM,YAAY,KAAA,IAAY,EAAM,UAAU;EACpF,OAAO;GAAE,OAAO,WAAW,KAAS,EAAM,UAAU,WAAW,WAAW;GAAQ;EAAQ;CAC5F;CAEA,IAAM,IAAe;EACnB,MAAM;EACN,OAAO;EACP,aAAa;EACb,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AI,IAAI,GAAQ;GACrD;GAGA,OAAO,EAAI,QAAQ,KAAK,EAAM,KAAK,IAAI,IAAI,GAAY;EAGzD,KAAK,UAAU;GACb,IAAM,IAAa,EAAqB,GAAY,CAAO;GAC3D,OAAO,EAAI,QAAQ,IAAI,EAAM,KAAK,IAAI,OAAO,CAAU,CAAC;EAC1D;EAGA,SACE,OAAO,EAAI,QAAQ,IAAI,EAAM,KAAK,IAAI,OAAO,CAAU,CAAC;CAC5D;AACF"}
@@ -1,15 +1,16 @@
1
- import type { HttpMethod } from '@scalar/helpers/http/http-methods';
2
1
  import type { AvailableClients } from '@scalar/snippetz';
3
2
  import type { WorkspaceStore } from '@scalar/workspace-store/client';
4
3
  import type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example';
5
4
  import type { ServerObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
6
5
  export type CreateCodeExampleOptions = {
6
+ /** Localized status text shown when the selected example has no linked code sample. */
7
+ codeSampleUnavailable?: string;
7
8
  /** Workspace store that holds the OpenAPI document(s) to render from. */
8
9
  store: WorkspaceStore;
9
10
  /** Path of the operation to render, e.g. '/users/{id}'. */
10
11
  path: string;
11
12
  /** HTTP method of the operation to render. */
12
- method: HttpMethod;
13
+ method: string;
13
14
  /** Pre-selected client ID, e.g. 'shell/curl'. */
14
15
  selectedClient?: AvailableClients[number];
15
16
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../src/code-example/mount.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAMpE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAA;AACzF,OAAO,KAAK,EAAmB,YAAY,EAAE,MAAM,8DAA8D,CAAA;A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E,YAAY,GAAG,IAAI,CAAA;IACpC;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,oDAAoD;IACpD,eAAe,CAAC,EAAE,0BAA0B,EAAE,CAAA;IAC9C;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAWD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,IAAI,WAAW,GAAG,MAAM,EAAE,SAAS,wBAAwB;;;CAyI5F,CAAA"}
@@ -5,58 +5,62 @@ import { createWorkspaceEventBus as a } from "@scalar/workspace-store/events";
5
5
  import { getResolvedRef as o } from "@scalar/workspace-store/helpers/get-resolved-ref";
6
6
  import { EXTERNAL_EXAMPLES as s } from "@scalar/workspace-store/helpers/use-external-examples";
7
7
  import { ScalarTeleportRoot as c } from "@scalar/components/teleport";
8
- import { getFirstServer as l } from "@scalar/workspace-store/helpers/get-first-server";
9
- import { generateClientMutators as u } from "@scalar/workspace-store/mutators";
8
+ import { getPathItemOperation as l } from "@scalar/workspace-store/helpers/for-each-path-item-operation";
9
+ import { getFirstServer as u } from "@scalar/workspace-store/helpers/get-first-server";
10
+ import { generateClientMutators as d } from "@scalar/workspace-store/mutators";
10
11
  //#region src/code-example/mount.ts
11
- var d = (e) => ["scalar-app", e === !0 ? "dark-mode" : e === !1 ? "light-mode" : ""].filter(Boolean).join(" "), f = (f, p) => {
12
- let m = typeof f == "string" ? document.querySelector(f) : f;
13
- if (!m) throw Error(`Element not found: ${f}`);
14
- let h = a(), g = e(), _ = u(p.store), v = h.on("workspace:update:selected-client", (e) => _.workspace().workspace.updateSelectedClient(e)), y = h.on("workspace:update:selected-example", (e) => _.workspace().workspace.updateSelectedExample(e)), b = () => {
15
- let e = p.store.workspace.activeDocument;
12
+ var f = (e) => ["scalar-app", e === !0 ? "dark-mode" : e === !1 ? "light-mode" : ""].filter(Boolean).join(" "), p = (p, m) => {
13
+ let h = typeof p == "string" ? document.querySelector(p) : p;
14
+ if (!h) throw Error(`Element not found: ${p}`);
15
+ let g = a(), _ = e(), v = d(m.store), y = g.on("workspace:update:selected-client", (e) => v.workspace().workspace.updateSelectedClient(e)), b = g.on("workspace:update:selected-example", (e) => v.workspace().workspace.updateSelectedExample(e)), x = () => {
16
+ let e = m.store.workspace.activeDocument;
16
17
  if (!e || !("paths" in e)) return;
17
- let t = o(e.paths?.[p.path]), n = o(t?.[p.method]);
18
+ let t = o(e.paths?.[m.path]), n = o(l(t, m.method));
18
19
  if (n) return {
19
20
  operation: n,
20
- server: l(n.servers ?? null, t?.servers ?? null, e.servers ?? null)
21
+ server: u(n.servers ?? null, t?.servers ?? null, e.servers ?? null)
21
22
  };
22
23
  };
23
- if (!b()) throw Error(`Operation not found: ${p.method.toUpperCase()} ${p.path}`);
24
- let x, S = () => {
25
- let e = b();
26
- return e && (x = e), e ?? x;
27
- }, C = i({
24
+ if (!x()) throw Error(`Operation not found: ${m.method.toUpperCase()} ${m.path}`);
25
+ let S, C = () => {
26
+ let e = x();
27
+ return e && (S = e), e ?? S;
28
+ }, w = i({
29
+ get codeSampleUnavailable() {
30
+ return m.codeSampleUnavailable;
31
+ },
28
32
  get operation() {
29
- return S().operation;
33
+ return C().operation;
30
34
  },
31
35
  get method() {
32
- return p.method;
36
+ return m.method;
33
37
  },
34
38
  get path() {
35
- return p.path;
39
+ return m.path;
36
40
  },
37
- clientOptions: g,
38
- eventBus: h,
41
+ clientOptions: _,
42
+ eventBus: g,
39
43
  get securitySchemes() {
40
- return p.securitySchemes ?? [];
44
+ return m.securitySchemes ?? [];
41
45
  },
42
46
  get selectedClient() {
43
- return p.store.workspace["x-scalar-default-client"] ?? p.selectedClient;
47
+ return m.store.workspace["x-scalar-default-client"] ?? m.selectedClient;
44
48
  },
45
49
  get selectedExample() {
46
- return p.store.workspace["x-scalar-default-example"] ?? p.selectedExample;
50
+ return m.store.workspace["x-scalar-default-example"] ?? m.selectedExample;
47
51
  },
48
52
  get selectedServer() {
49
- return p.selectedServer === void 0 ? S().server : p.selectedServer;
53
+ return m.selectedServer === void 0 ? C().server : m.selectedServer;
50
54
  }
51
- }), w = () => r("span", { class: "font-code text-c-2 min-w-0 truncate" }, p.path), T = n(() => r("div", { class: d(p.darkMode) }, [r(c, null, { default: () => r(t, C, { header: w }) })]));
52
- return T.provide(s, () => p.store.externalExamples()), T.mount(m), {
53
- app: T,
55
+ }), T = () => r("span", { class: "font-code text-c-2 min-w-0 truncate" }, m.path), E = n(() => r("div", { class: f(m.darkMode) }, [r(c, null, { default: () => r(t, w, { header: T }) })]));
56
+ return E.provide(s, () => m.store.externalExamples()), E.mount(h), {
57
+ app: E,
54
58
  destroy: () => {
55
- v(), y(), T.unmount();
59
+ y(), b(), E.unmount();
56
60
  }
57
61
  };
58
62
  };
59
63
  //#endregion
60
- export { f as createCodeExample };
64
+ export { p as createCodeExample };
61
65
 
62
66
  //# sourceMappingURL=mount.js.map