@scalar/api-client 3.10.4 → 3.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/dist/plugins/posthog/sanitize-event-payload.d.ts.map +1 -1
- package/dist/plugins/posthog/sanitize-event-payload.js +1 -0
- package/dist/plugins/posthog/sanitize-event-payload.js.map +1 -1
- package/dist/style.css +25 -74
- package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue.js.map +1 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue.script.js +10 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue.script.js.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/send-request.d.ts +7 -1
- package/dist/v2/blocks/operation-block/helpers/send-request.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/send-request.js +2 -2
- package/dist/v2/blocks/operation-block/helpers/send-request.js.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/validate-path-parameters.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/validate-path-parameters.js +1 -2
- package/dist/v2/blocks/operation-block/helpers/validate-path-parameters.js.map +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.d.ts +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.js +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.script.js +48 -11
- package/dist/v2/blocks/request-block/RequestBlock.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.d.ts +2 -2
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.script.js +2 -6
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestParams.vue.d.ts +4 -0
- package/dist/v2/blocks/request-block/components/RequestParams.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestParams.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestParams.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTable.vue.d.ts +3 -11
- package/dist/v2/blocks/request-block/components/RequestTable.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTable.vue.js +1 -1
- package/dist/v2/blocks/request-block/components/RequestTable.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTable.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.d.ts +8 -10
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.script.js +27 -11
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/helpers/create-parameter-handlers.d.ts +9 -6
- package/dist/v2/blocks/request-block/helpers/create-parameter-handlers.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/helpers/create-parameter-handlers.js +45 -4
- package/dist/v2/blocks/request-block/helpers/create-parameter-handlers.js.map +1 -1
- package/dist/v2/blocks/request-block/helpers/create-parameter-rows.d.ts +4 -0
- package/dist/v2/blocks/request-block/helpers/create-parameter-rows.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/helpers/create-parameter-rows.js +94 -10
- package/dist/v2/blocks/request-block/helpers/create-parameter-rows.js.map +1 -1
- package/dist/v2/blocks/request-block/helpers/get-form-body-rows.js +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.js +1 -1
- package/dist/v2/components/data-table/DataTableInput.vue.d.ts +1 -1
- package/dist/v2/components/data-table/DataTableInput.vue.d.ts.map +1 -1
- package/dist/v2/constants.js +1 -1
- package/dist/v2/features/modal/Modal.vue.js.map +1 -1
- package/dist/v2/features/modal/Modal.vue.script.js +1 -1
- package/dist/v2/features/modal/Modal.vue.script.js.map +1 -1
- package/dist/v2/features/modal/helpers/create-api-client-modal.js +1 -1
- package/dist/v2/features/operation/Operation.vue.script.js +1 -1
- package/dist/v2/workspace-events.d.ts.map +1 -1
- package/dist/v2/workspace-events.js +1 -0
- package/dist/v2/workspace-events.js.map +1 -1
- package/dist/vue-styles.css +10 -52
- package/package.json +13 -24
- package/dist/v2/blocks/operation-code-sample/components/ExamplePicker.vue.d.ts +0 -16
- package/dist/v2/blocks/operation-code-sample/components/ExamplePicker.vue.d.ts.map +0 -1
- package/dist/v2/blocks/operation-code-sample/components/ExamplePicker.vue.js +0 -7
- package/dist/v2/blocks/operation-code-sample/components/ExamplePicker.vue.js.map +0 -1
- package/dist/v2/blocks/operation-code-sample/components/ExamplePicker.vue.script.js +0 -53
- package/dist/v2/blocks/operation-code-sample/components/ExamplePicker.vue.script.js.map +0 -1
- package/dist/v2/blocks/operation-code-sample/components/HttpMethod.vue.d.ts +0 -26
- package/dist/v2/blocks/operation-code-sample/components/HttpMethod.vue.d.ts.map +0 -1
- package/dist/v2/blocks/operation-code-sample/components/HttpMethod.vue.js +0 -7
- package/dist/v2/blocks/operation-code-sample/components/HttpMethod.vue.js.map +0 -1
- package/dist/v2/blocks/operation-code-sample/components/HttpMethod.vue.script.js +0 -33
- package/dist/v2/blocks/operation-code-sample/components/HttpMethod.vue.script.js.map +0 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.d.ts +0 -141
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.d.ts.map +0 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.js +0 -9
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.js.map +0 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.script.js +0 -272
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.script.js.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/filter-clients-by-query.d.ts +0 -9
- package/dist/v2/blocks/operation-code-sample/helpers/filter-clients-by-query.d.ts.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/filter-clients-by-query.js +0 -37
- package/dist/v2/blocks/operation-code-sample/helpers/filter-clients-by-query.js.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/find-client.d.ts +0 -41
- package/dist/v2/blocks/operation-code-sample/helpers/find-client.d.ts.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/find-client.js +0 -48
- package/dist/v2/blocks/operation-code-sample/helpers/find-client.js.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/format-language.d.ts +0 -8
- package/dist/v2/blocks/operation-code-sample/helpers/format-language.d.ts.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/format-language.js +0 -70
- package/dist/v2/blocks/operation-code-sample/helpers/format-language.js.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/generate-client-options.d.ts +0 -30
- package/dist/v2/blocks/operation-code-sample/helpers/generate-client-options.d.ts.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/generate-client-options.js +0 -63
- package/dist/v2/blocks/operation-code-sample/helpers/generate-client-options.js.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.d.ts +0 -39
- package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.d.ts.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.js +0 -38
- package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.js.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-clients.d.ts +0 -13
- package/dist/v2/blocks/operation-code-sample/helpers/get-clients.d.ts.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-clients.js +0 -37
- package/dist/v2/blocks/operation-code-sample/helpers/get-clients.js.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-custom-code-samples.d.ts +0 -45
- package/dist/v2/blocks/operation-code-sample/helpers/get-custom-code-samples.d.ts.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-custom-code-samples.js +0 -84
- package/dist/v2/blocks/operation-code-sample/helpers/get-custom-code-samples.js.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-resolved-ref-deep.d.ts +0 -27
- package/dist/v2/blocks/operation-code-sample/helpers/get-resolved-ref-deep.d.ts.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-resolved-ref-deep.js +0 -41
- package/dist/v2/blocks/operation-code-sample/helpers/get-resolved-ref-deep.js.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-secrets.d.ts +0 -4
- package/dist/v2/blocks/operation-code-sample/helpers/get-secrets.d.ts.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-secrets.js +0 -18
- package/dist/v2/blocks/operation-code-sample/helpers/get-secrets.js.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-snippet.d.ts +0 -8
- package/dist/v2/blocks/operation-code-sample/helpers/get-snippet.d.ts.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/get-snippet.js +0 -38
- package/dist/v2/blocks/operation-code-sample/helpers/get-snippet.js.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.d.ts +0 -72
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.d.ts.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.js +0 -114
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.js.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.d.ts +0 -13
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.d.ts.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.js +0 -196
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.js.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.d.ts +0 -24
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.d.ts.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.js +0 -237
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.js.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.d.ts +0 -15
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.d.ts.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.js +0 -65
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.js.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-server-url.d.ts +0 -6
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-server-url.d.ts.map +0 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-server-url.js +0 -19
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-server-url.js.map +0 -1
- package/dist/v2/blocks/operation-code-sample/index.d.ts +0 -9
- package/dist/v2/blocks/operation-code-sample/index.d.ts.map +0 -1
- package/dist/v2/blocks/operation-code-sample/index.js +0 -8
- package/dist/v2/blocks/operation-code-sample/types.d.ts +0 -46
- package/dist/v2/blocks/operation-code-sample/types.d.ts.map +0 -1
- package/dist/v2/blocks/request-block/helpers/is-param-disabled.d.ts +0 -13
- package/dist/v2/blocks/request-block/helpers/is-param-disabled.d.ts.map +0 -1
- package/dist/v2/blocks/request-block/helpers/is-param-disabled.js +0 -21
- package/dist/v2/blocks/request-block/helpers/is-param-disabled.js.map +0 -1
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import { isParamDisabled } from "../../../request-block/helpers/is-param-disabled.js";
|
|
2
|
-
import { deSerializeParameter, getExample, getExampleFromSchema, serializeContentValue, serializeDeepObjectStyle, serializeFormStyle, serializeFormStyleForCookies, serializePipeDelimitedStyle, serializeSimpleStyle, serializeSpaceDelimitedStyle } from "@scalar/workspace-store/request-example";
|
|
3
|
-
import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref";
|
|
4
|
-
//#region src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.ts
|
|
5
|
-
/** Ensures we don't have any references in the parameters */
|
|
6
|
-
var deReferenceParams = (params) => (params ?? []).map((param) => getResolvedRef(param));
|
|
7
|
-
/** Whether the parameter allows reserved characters (from param or schema). */
|
|
8
|
-
var isAllowReserved = (param) => {
|
|
9
|
-
if ("allowReserved" in param && param.allowReserved !== void 0) return param.allowReserved;
|
|
10
|
-
if ("schema" in param && param.schema && typeof param.schema === "object" && "allowReserved" in param.schema) return param.schema.allowReserved === true;
|
|
11
|
-
return false;
|
|
12
|
-
};
|
|
13
|
-
/** URL encode a value if allowReserved is not set to true. */
|
|
14
|
-
var encodeQueryValue = (value, param) => {
|
|
15
|
-
if (isAllowReserved(param)) return value;
|
|
16
|
-
return encodeURIComponent(value);
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Get the style and explode values for a parameter according to OpenAPI 3.1.1 specification.
|
|
20
|
-
* Handles defaults and validation for parameter location restrictions.
|
|
21
|
-
*/
|
|
22
|
-
var getParameterStyleAndExplode = (param) => {
|
|
23
|
-
if (param.in === "header") return {
|
|
24
|
-
style: "simple",
|
|
25
|
-
explode: "explode" in param && param.explode !== void 0 ? param.explode : false
|
|
26
|
-
};
|
|
27
|
-
if (param.in === "cookie") return {
|
|
28
|
-
style: "form",
|
|
29
|
-
explode: "explode" in param && param.explode !== void 0 ? param.explode : true
|
|
30
|
-
};
|
|
31
|
-
const defaultStyle = {
|
|
32
|
-
path: "simple",
|
|
33
|
-
query: "form",
|
|
34
|
-
header: "simple",
|
|
35
|
-
cookie: "form"
|
|
36
|
-
}[param.in];
|
|
37
|
-
const style = "style" in param && param.style ? param.style : defaultStyle;
|
|
38
|
-
return {
|
|
39
|
-
style,
|
|
40
|
-
explode: "explode" in param && param.explode !== void 0 ? param.explode : style === "form"
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Extract the value for a parameter from example data or schema.
|
|
45
|
-
* Prioritizes example data over schema examples.
|
|
46
|
-
* Returns null if the parameter is disabled so we can skip it.
|
|
47
|
-
*/
|
|
48
|
-
var getParameterValue = (param, example, contentType, defaultDisabled) => {
|
|
49
|
-
const exampleValue = getExample(param, example, contentType);
|
|
50
|
-
if (isParamDisabled(param, exampleValue, defaultDisabled)) return;
|
|
51
|
-
if (exampleValue?.value !== void 0) return deSerializeParameter(exampleValue.value, param);
|
|
52
|
-
if (!("schema" in param) || !param.schema) return;
|
|
53
|
-
const options = param.in === "path" ? { emptyString: `{${param.name}}` } : {};
|
|
54
|
-
return getExampleFromSchema(getResolvedRef(param.schema), options);
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* Process OpenAPI parameters and return the updated properties.
|
|
58
|
-
* Handles path, query, and header parameters with various styles and explode options.
|
|
59
|
-
*
|
|
60
|
-
* @see https://spec.openapis.org/oas/latest.html#style-values
|
|
61
|
-
*/
|
|
62
|
-
var processParameters = ({ harRequest, parameters, example, defaultDisabled }) => {
|
|
63
|
-
const newHeaders = [...harRequest.headers];
|
|
64
|
-
const newQueryString = [...harRequest.queryString];
|
|
65
|
-
let newUrl = harRequest.url;
|
|
66
|
-
const deReferencedParams = deReferenceParams(parameters);
|
|
67
|
-
for (const param of deReferencedParams) {
|
|
68
|
-
if (!param.in || !param.name) continue;
|
|
69
|
-
const paramValue = getParameterValue(param, example, void 0, defaultDisabled);
|
|
70
|
-
if (paramValue === void 0) continue;
|
|
71
|
-
const { style, explode } = getParameterStyleAndExplode(param);
|
|
72
|
-
switch (param.in) {
|
|
73
|
-
case "path":
|
|
74
|
-
newUrl = processPathParameters(newUrl, param, paramValue, style, explode);
|
|
75
|
-
break;
|
|
76
|
-
case "query":
|
|
77
|
-
if ("content" in param && param.content) {
|
|
78
|
-
const serializedValue = serializeContentValue(paramValue, Object.keys(param.content)[0] ?? "application/json");
|
|
79
|
-
newQueryString.push({
|
|
80
|
-
name: param.name,
|
|
81
|
-
value: encodeQueryValue(serializedValue, param)
|
|
82
|
-
});
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
switch (style) {
|
|
86
|
-
case "form": {
|
|
87
|
-
const serialized = serializeFormStyle(paramValue, explode);
|
|
88
|
-
if (Array.isArray(serialized)) for (const entry of serialized) {
|
|
89
|
-
const key = entry.key || param.name;
|
|
90
|
-
newQueryString.push({
|
|
91
|
-
name: key,
|
|
92
|
-
value: encodeQueryValue(String(entry.value), param)
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
else newQueryString.push({
|
|
96
|
-
name: param.name,
|
|
97
|
-
value: encodeQueryValue(String(serialized), param)
|
|
98
|
-
});
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
case "spaceDelimited": {
|
|
102
|
-
const serialized = serializeSpaceDelimitedStyle(paramValue);
|
|
103
|
-
newQueryString.push({
|
|
104
|
-
name: param.name,
|
|
105
|
-
value: encodeQueryValue(serialized, param)
|
|
106
|
-
});
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
case "pipeDelimited": {
|
|
110
|
-
const serialized = serializePipeDelimitedStyle(paramValue);
|
|
111
|
-
newQueryString.push({
|
|
112
|
-
name: param.name,
|
|
113
|
-
value: encodeQueryValue(serialized, param)
|
|
114
|
-
});
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
case "deepObject":
|
|
118
|
-
if (Array.isArray(paramValue)) {
|
|
119
|
-
const serialized = serializeFormStyle(paramValue, true);
|
|
120
|
-
if (Array.isArray(serialized)) for (const entry of serialized) {
|
|
121
|
-
const key = entry.key || param.name;
|
|
122
|
-
newQueryString.push({
|
|
123
|
-
name: key,
|
|
124
|
-
value: encodeQueryValue(String(entry.value), param)
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
else newQueryString.push({
|
|
128
|
-
name: param.name,
|
|
129
|
-
value: encodeQueryValue(String(serialized), param)
|
|
130
|
-
});
|
|
131
|
-
} else {
|
|
132
|
-
const entries = serializeDeepObjectStyle(param.name, paramValue);
|
|
133
|
-
for (const entry of entries) newQueryString.push({
|
|
134
|
-
name: entry.key,
|
|
135
|
-
value: encodeQueryValue(entry.value, param)
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
break;
|
|
139
|
-
default: newQueryString.push({
|
|
140
|
-
name: param.name,
|
|
141
|
-
value: encodeQueryValue(String(paramValue), param)
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
break;
|
|
145
|
-
case "header": {
|
|
146
|
-
const serialized = serializeSimpleStyle(paramValue, explode);
|
|
147
|
-
newHeaders.push({
|
|
148
|
-
name: param.name,
|
|
149
|
-
value: String(serialized)
|
|
150
|
-
});
|
|
151
|
-
break;
|
|
152
|
-
}
|
|
153
|
-
case "cookie": {
|
|
154
|
-
const serialized = serializeFormStyleForCookies(paramValue, explode);
|
|
155
|
-
if (Array.isArray(serialized)) for (const entry of serialized) {
|
|
156
|
-
const key = entry.key || param.name;
|
|
157
|
-
const value = entry.value === null ? "null" : String(entry.value);
|
|
158
|
-
harRequest.cookies.push({
|
|
159
|
-
name: key,
|
|
160
|
-
value
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
const value = serialized === null ? "null" : String(serialized);
|
|
165
|
-
harRequest.cookies.push({
|
|
166
|
-
name: param.name,
|
|
167
|
-
value
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
break;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
return {
|
|
175
|
-
url: newUrl,
|
|
176
|
-
headers: newHeaders,
|
|
177
|
-
queryString: newQueryString,
|
|
178
|
-
cookies: harRequest.cookies
|
|
179
|
-
};
|
|
180
|
-
};
|
|
181
|
-
/**
|
|
182
|
-
* Process path parameters according to OpenAPI specification.
|
|
183
|
-
* Handles matrix, label, and simple styles with explode options.
|
|
184
|
-
*
|
|
185
|
-
* @param url - The URL to process
|
|
186
|
-
* @param param - The parameter object
|
|
187
|
-
* @param paramValue - The value of the parameter
|
|
188
|
-
* @param style - The style of the parameter (matrix, label, simple)
|
|
189
|
-
* @param explode - Whether to explode the parameter
|
|
190
|
-
* @returns The updated URL with processed path parameters
|
|
191
|
-
*/
|
|
192
|
-
var processPathParameters = (url, param, paramValue, style, explode) => {
|
|
193
|
-
switch (style) {
|
|
194
|
-
case "matrix":
|
|
195
|
-
if (explode) {
|
|
196
|
-
if (Array.isArray(paramValue)) {
|
|
197
|
-
const values = paramValue.map((v) => `${param.name}=${v}`).join(";");
|
|
198
|
-
return url.replace(`{;${param.name}}`, `;${values}`);
|
|
199
|
-
}
|
|
200
|
-
if (typeof paramValue === "object" && paramValue !== null) {
|
|
201
|
-
const values = Object.entries(paramValue).map(([k, v]) => `${k}=${v}`).join(";");
|
|
202
|
-
return url.replace(`{;${param.name}}`, `;${values}`);
|
|
203
|
-
}
|
|
204
|
-
return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue}`);
|
|
205
|
-
}
|
|
206
|
-
if (Array.isArray(paramValue)) return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue.join(",")}`);
|
|
207
|
-
if (typeof paramValue === "object" && paramValue !== null) {
|
|
208
|
-
const values = Object.entries(paramValue).map(([k, v]) => `${k},${v}`).join(",");
|
|
209
|
-
return url.replace(`{;${param.name}}`, `;${param.name}=${values}`);
|
|
210
|
-
}
|
|
211
|
-
return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue}`);
|
|
212
|
-
case "label":
|
|
213
|
-
if (explode) {
|
|
214
|
-
if (Array.isArray(paramValue)) return url.replace(`{.${param.name}}`, `.${paramValue.join(".")}`);
|
|
215
|
-
if (typeof paramValue === "object" && paramValue !== null) {
|
|
216
|
-
const values = Object.entries(paramValue).map(([k, v]) => `${k}=${v}`).join(".");
|
|
217
|
-
return url.replace(`{.${param.name}}`, `.${values}`);
|
|
218
|
-
}
|
|
219
|
-
return url.replace(`{.${param.name}}`, `.${paramValue}`);
|
|
220
|
-
}
|
|
221
|
-
if (Array.isArray(paramValue)) return url.replace(`{.${param.name}}`, `.${paramValue.join(",")}`);
|
|
222
|
-
if (typeof paramValue === "object" && paramValue !== null) {
|
|
223
|
-
const values = Object.entries(paramValue).map(([k, v]) => `${k},${v}`).join(",");
|
|
224
|
-
return url.replace(`{.${param.name}}`, `.${values}`);
|
|
225
|
-
}
|
|
226
|
-
return url.replace(`{.${param.name}}`, `.${paramValue}`);
|
|
227
|
-
case "simple": {
|
|
228
|
-
const serialized = serializeSimpleStyle(paramValue, explode);
|
|
229
|
-
return url.replace(`{${param.name}}`, String(serialized));
|
|
230
|
-
}
|
|
231
|
-
default: return url.replace(`{${param.name}}`, String(paramValue));
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
//#endregion
|
|
235
|
-
export { processParameters };
|
|
236
|
-
|
|
237
|
-
//# sourceMappingURL=process-parameters.js.map
|
package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"process-parameters.js","names":[],"sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.ts"],"sourcesContent":["import { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n deSerializeParameter,\n getExample,\n getExampleFromSchema,\n serializeContentValue,\n serializeDeepObjectStyle,\n serializeFormStyle,\n serializeFormStyleForCookies,\n serializePipeDelimitedStyle,\n serializeSimpleStyle,\n serializeSpaceDelimitedStyle,\n} from '@scalar/workspace-store/request-example'\nimport type { OperationObject, ParameterObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport type { Request as HarRequest } from 'har-format'\n\nimport { isParamDisabled } from '@/v2/blocks/request-block/helpers/is-param-disabled'\n\ntype ProcessedParameters = {\n url: string\n headers: HarRequest['headers']\n queryString: HarRequest['queryString']\n cookies: HarRequest['cookies']\n}\n\n/** Ensures we don't have any references in the parameters */\nconst deReferenceParams = (params: OperationObject['parameters']): ParameterObject[] =>\n (params ?? []).map((param) => getResolvedRef(param))\n\n/** Whether the parameter allows reserved characters (from param or schema). */\nconst isAllowReserved = (param: ParameterObject): boolean => {\n if ('allowReserved' in param && param.allowReserved !== undefined) {\n return param.allowReserved\n }\n if ('schema' in param && param.schema && typeof param.schema === 'object' && 'allowReserved' in param.schema) {\n return (param.schema as { allowReserved?: boolean }).allowReserved === true\n }\n return false\n}\n\n/** URL encode a value if allowReserved is not set to true. */\nconst encodeQueryValue = (value: string, param: ParameterObject): string => {\n if (isAllowReserved(param)) {\n return value\n }\n return encodeURIComponent(value)\n}\n\n/**\n * Get the style and explode values for a parameter according to OpenAPI 3.1.1 specification.\n * Handles defaults and validation for parameter location restrictions.\n */\nconst getParameterStyleAndExplode = (param: ParameterObject): { style: string; explode: boolean } => {\n // Headers only support 'simple' style\n if (param.in === 'header') {\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : false\n return { style: 'simple', explode }\n }\n\n // Cookies only support 'form' style\n if (param.in === 'cookie') {\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : true\n return { style: 'form', explode }\n }\n\n const defaultStyle = {\n path: 'simple',\n query: 'form',\n header: 'simple',\n cookie: 'form',\n }[param.in]\n\n // Use provided style or default based on location\n const style = 'style' in param && param.style ? param.style : defaultStyle\n\n // Determine explode value: use provided value or default based on style\n const explode = 'explode' in param && param.explode !== undefined ? param.explode : style === 'form'\n\n return { style, explode }\n}\n\n/**\n * Extract the value for a parameter from example data or schema.\n * Prioritizes example data over schema examples.\n * Returns null if the parameter is disabled so we can skip it.\n */\nconst getParameterValue = (\n param: ParameterObject,\n example: string | undefined,\n contentType: string | undefined,\n defaultDisabled: boolean,\n): unknown => {\n // Try to get value from example first\n const exampleValue = getExample(param, example, contentType)\n\n // If the parameter is disabled, return undefined so we can skip it.\n if (isParamDisabled(param, exampleValue, defaultDisabled)) {\n return undefined\n }\n\n // If the example value is set, return it.\n if (exampleValue?.value !== undefined) {\n return deSerializeParameter(exampleValue.value, param)\n }\n\n // Fall back to schema example if available\n if (!('schema' in param) || !param.schema) {\n return undefined\n }\n\n const options = param.in === 'path' ? { emptyString: `{${param.name}}` } : {}\n return getExampleFromSchema(getResolvedRef(param.schema), options)\n}\n\n/**\n * Process OpenAPI parameters and return the updated properties.\n * Handles path, query, and header parameters with various styles and explode options.\n *\n * @see https://spec.openapis.org/oas/latest.html#style-values\n */\nexport const processParameters = ({\n harRequest,\n parameters,\n example,\n defaultDisabled,\n}: {\n harRequest: HarRequest\n parameters: OperationObject['parameters']\n /** The name of the example to use */\n example?: string | undefined\n /** Whether to disable parameters by default. */\n defaultDisabled: boolean\n}): ProcessedParameters => {\n // Create copies of the arrays to avoid modifying the input\n const newHeaders = [...harRequest.headers]\n const newQueryString = [...harRequest.queryString]\n let newUrl = harRequest.url\n\n // Filter out references\n const deReferencedParams = deReferenceParams(parameters)\n\n for (const param of deReferencedParams) {\n if (!param.in || !param.name) {\n continue\n }\n\n const paramValue = getParameterValue(param, example, undefined, defaultDisabled)\n if (paramValue === undefined) {\n continue\n }\n\n const { style, explode } = getParameterStyleAndExplode(param)\n\n switch (param.in) {\n case 'path': {\n newUrl = processPathParameters(newUrl, param, paramValue, style, explode)\n break\n }\n\n case 'query': {\n // Content type parameters should be serialized according to the parameter's own content type\n if ('content' in param && param.content) {\n // We grab the first for now but eventually we should support selecting the content type per parameter\n const paramContentType = Object.keys(param.content)[0] ?? 'application/json'\n const serializedValue = serializeContentValue(paramValue, paramContentType)\n newQueryString.push({ name: param.name, value: encodeQueryValue(serializedValue, param) })\n break\n }\n\n // Handle query parameters\n switch (style) {\n case 'form': {\n const serialized = serializeFormStyle(paramValue, explode)\n\n // If serialized is an array of key-value pairs (exploded object or array)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || param.name\n newQueryString.push({ name: key, value: encodeQueryValue(String(entry.value), param) })\n }\n }\n // Otherwise, convert to string\n else {\n newQueryString.push({ name: param.name, value: encodeQueryValue(String(serialized), param) })\n }\n break\n }\n case 'spaceDelimited': {\n const serialized = serializeSpaceDelimitedStyle(paramValue)\n newQueryString.push({ name: param.name, value: encodeQueryValue(serialized, param) })\n break\n }\n case 'pipeDelimited': {\n const serialized = serializePipeDelimitedStyle(paramValue)\n newQueryString.push({ name: param.name, value: encodeQueryValue(serialized, param) })\n break\n }\n case 'deepObject': {\n // OAS marks deepObject-on-array and deepObject+explode:false as undefined.\n // Mirror process-body: fall back to form/explode:true for arrays and always\n // invoke the serializer for objects so authors get useful output instead of\n // a silently-dropped parameter.\n if (Array.isArray(paramValue)) {\n const serialized = serializeFormStyle(paramValue, true)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || param.name\n newQueryString.push({ name: key, value: encodeQueryValue(String(entry.value), param) })\n }\n } else {\n newQueryString.push({ name: param.name, value: encodeQueryValue(String(serialized), param) })\n }\n } else {\n const entries = serializeDeepObjectStyle(param.name, paramValue)\n for (const entry of entries) {\n newQueryString.push({ name: entry.key, value: encodeQueryValue(entry.value, param) })\n }\n }\n break\n }\n\n // Default to form style\n default:\n newQueryString.push({ name: param.name, value: encodeQueryValue(String(paramValue), param) })\n }\n break\n }\n\n // Headers only support 'simple' style according to OpenAPI 3.1.1\n // For arrays, simple style always produces comma-separated values regardless of explode\n // The explode parameter only affects object serialization\n case 'header': {\n const serialized = serializeSimpleStyle(paramValue, explode)\n newHeaders.push({ name: param.name, value: String(serialized) })\n break\n }\n\n // Cookies only support 'form' style according to OpenAPI 3.1.1\n case 'cookie': {\n const serialized = serializeFormStyleForCookies(paramValue, explode)\n\n // If serialized is an array of key-value pairs (exploded object or array)\n if (Array.isArray(serialized)) {\n for (const entry of serialized) {\n const key = entry.key || param.name\n const value = entry.value === null ? 'null' : String(entry.value)\n harRequest.cookies.push({ name: key, value })\n }\n }\n // Otherwise, convert to string\n else {\n const value = serialized === null ? 'null' : String(serialized)\n harRequest.cookies.push({ name: param.name, value })\n }\n break\n }\n }\n }\n\n return {\n url: newUrl,\n headers: newHeaders,\n queryString: newQueryString,\n cookies: harRequest.cookies,\n }\n}\n\n/**\n * Process path parameters according to OpenAPI specification.\n * Handles matrix, label, and simple styles with explode options.\n *\n * @param url - The URL to process\n * @param param - The parameter object\n * @param paramValue - The value of the parameter\n * @param style - The style of the parameter (matrix, label, simple)\n * @param explode - Whether to explode the parameter\n * @returns The updated URL with processed path parameters\n */\nconst processPathParameters = (\n url: string,\n param: ParameterObject,\n paramValue: unknown,\n style: string,\n explode: boolean,\n): string => {\n switch (style) {\n case 'matrix': {\n if (explode) {\n // Matrix explode array: ;color=blue;color=black;color=brown\n if (Array.isArray(paramValue)) {\n const values = (paramValue as unknown[]).map((v) => `${param.name}=${v}`).join(';')\n return url.replace(`{;${param.name}}`, `;${values}`)\n }\n\n // Matrix explode object: ;R=100;G=200;B=150\n if (typeof paramValue === 'object' && paramValue !== null) {\n const values = Object.entries(paramValue as Record<string, unknown>)\n .map(([k, v]) => `${k}=${v}`)\n .join(';')\n return url.replace(`{;${param.name}}`, `;${values}`)\n }\n\n // Matrix explode primitive: ;color=blue\n return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue}`)\n }\n\n // Matrix no explode array: ;color=blue,black,brown\n if (Array.isArray(paramValue)) {\n return url.replace(`{;${param.name}}`, `;${param.name}=${(paramValue as unknown[]).join(',')}`)\n }\n\n // Matrix no explode object: ;color=R,100,G,200,B,150\n if (typeof paramValue === 'object' && paramValue !== null) {\n const values = Object.entries(paramValue as Record<string, unknown>)\n .map(([k, v]) => `${k},${v}`)\n .join(',')\n return url.replace(`{;${param.name}}`, `;${param.name}=${values}`)\n }\n\n // Matrix no explode primitive: ;color=blue\n return url.replace(`{;${param.name}}`, `;${param.name}=${paramValue}`)\n }\n case 'label': {\n if (explode) {\n // Label explode array: .blue.black.brown\n if (Array.isArray(paramValue)) {\n return url.replace(`{.${param.name}}`, `.${(paramValue as unknown[]).join('.')}`)\n }\n\n // Label explode object: .R=100.G=200.B=150\n if (typeof paramValue === 'object' && paramValue !== null) {\n const values = Object.entries(paramValue as Record<string, unknown>)\n .map(([k, v]) => `${k}=${v}`)\n .join('.')\n\n return url.replace(`{.${param.name}}`, `.${values}`)\n }\n\n // Label explode primitive: .blue\n return url.replace(`{.${param.name}}`, `.${paramValue}`)\n }\n\n // Label no explode array: .blue,black,brown\n if (Array.isArray(paramValue)) {\n return url.replace(`{.${param.name}}`, `.${(paramValue as unknown[]).join(',')}`)\n }\n\n // Label no explode object: .R,100,G,200,B,150\n if (typeof paramValue === 'object' && paramValue !== null) {\n const values = Object.entries(paramValue as Record<string, unknown>)\n .map(([k, v]) => `${k},${v}`)\n .join(',')\n\n return url.replace(`{.${param.name}}`, `.${values}`)\n }\n\n // Label no explode primitive: .blue\n return url.replace(`{.${param.name}}`, `.${paramValue}`)\n }\n\n case 'simple': {\n const serialized = serializeSimpleStyle(paramValue, explode)\n return url.replace(`{${param.name}}`, String(serialized))\n }\n\n // Default to simple style\n default:\n return url.replace(`{${param.name}}`, String(paramValue))\n }\n}\n"],"mappings":";;;;;AA0BA,IAAM,qBAAqB,YACxB,UAAU,EAAE,EAAE,KAAK,UAAU,eAAe,MAAM,CAAC;;AAGtD,IAAM,mBAAmB,UAAoC;AAC3D,KAAI,mBAAmB,SAAS,MAAM,kBAAkB,KAAA,EACtD,QAAO,MAAM;AAEf,KAAI,YAAY,SAAS,MAAM,UAAU,OAAO,MAAM,WAAW,YAAY,mBAAmB,MAAM,OACpG,QAAQ,MAAM,OAAuC,kBAAkB;AAEzE,QAAO;;;AAIT,IAAM,oBAAoB,OAAe,UAAmC;AAC1E,KAAI,gBAAgB,MAA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KAAK,IAAI;AAEZ,YAAO,IAAI,QAAQ,KAAK,MAAM,KAAK,IAAI,IAAI,SAAS;;AAItD,WAAO,IAAI,QAAQ,KAAK,MAAM,KAAK,IAAI,IAAI,aAAa;;AAI1D,OAAI,MAAM,QAAQ,WAAW,CAC3B,QAAO,IAAI,QAAQ,KAAK,MAAM,KAAK,IAAI,IAAK,WAAyB,KAAK,IAAI,GAAG;AAInF,OAAI,OAAO,eAAe,YAAY,eAAe,MAAM;IACzD,MAAM,SAAS,OAAO,QAAQ,WAAsC,CACjE,KAAK,CAAC,GAAG,OAAO,GAAG,EAAE,GAAG,IAAI,CAC5B,KAAK,IAAI;AAEZ,WAAO,IAAI,QAAQ,KAAK,MAAM,KAAK,IAAI,IAAI,SAAS;;AAItD,UAAO,IAAI,QAAQ,KAAK,MAAM,KAAK,IAAI,IAAI,aAAa;EAG1D,KAAK,UAAU;GACb,MAAM,aAAa,qBAAqB,YAAY,QAAQ;AAC5D,UAAO,IAAI,QAAQ,IAAI,MAAM,KAAK,IAAI,OAAO,WAAW,CAAC;;EAI3D,QACE,QAAO,IAAI,QAAQ,IAAI,MAAM,KAAK,IAAI,OAAO,WAAW,CAAC"}
|
package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example';
|
|
2
|
-
import type { Request as HarRequest } from 'har-format';
|
|
3
|
-
type ProcessedSecuritySchemesReturn = {
|
|
4
|
-
headers: HarRequest['headers'];
|
|
5
|
-
queryString: HarRequest['queryString'];
|
|
6
|
-
cookies: HarRequest['cookies'];
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Process security schemes into whichever parameters they are applicable to
|
|
10
|
-
*
|
|
11
|
-
* TODO: we probably want to be able to disable YOUR_SECRET_TOKEN placeholder text + or allow it to be customzied
|
|
12
|
-
*/
|
|
13
|
-
export declare const processSecuritySchemes: (securitySchemes: SecuritySchemeObjectSecret[]) => ProcessedSecuritySchemesReturn;
|
|
14
|
-
export {};
|
|
15
|
-
//# sourceMappingURL=process-security-schemes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"process-security-schemes.d.ts","sourceRoot":"","sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAA;AACzF,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAGvD,KAAK,8BAA8B,GAAG;IACpC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IAC9B,WAAW,EAAE,UAAU,CAAC,aAAa,CAAC,CAAA;IACtC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;CAC/B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GACjC,iBAAiB,0BAA0B,EAAE,KAC5C,8BA2EF,CAAA"}
|
package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { encode } from "js-base64";
|
|
2
|
-
//#region src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.ts
|
|
3
|
-
/**
|
|
4
|
-
* Process security schemes into whichever parameters they are applicable to
|
|
5
|
-
*
|
|
6
|
-
* TODO: we probably want to be able to disable YOUR_SECRET_TOKEN placeholder text + or allow it to be customzied
|
|
7
|
-
*/
|
|
8
|
-
var processSecuritySchemes = (securitySchemes) => {
|
|
9
|
-
const result = {
|
|
10
|
-
headers: [],
|
|
11
|
-
queryString: [],
|
|
12
|
-
cookies: []
|
|
13
|
-
};
|
|
14
|
-
for (const scheme of securitySchemes) {
|
|
15
|
-
if (scheme.type === "apiKey") {
|
|
16
|
-
const value = scheme["x-scalar-secret-token"] || "YOUR_SECRET_TOKEN";
|
|
17
|
-
if (!scheme.name) continue;
|
|
18
|
-
const param = {
|
|
19
|
-
name: scheme.name,
|
|
20
|
-
value
|
|
21
|
-
};
|
|
22
|
-
switch (scheme.in) {
|
|
23
|
-
case "header":
|
|
24
|
-
result.headers.push(param);
|
|
25
|
-
break;
|
|
26
|
-
case "query":
|
|
27
|
-
result.queryString.push(param);
|
|
28
|
-
break;
|
|
29
|
-
case "cookie":
|
|
30
|
-
result.cookies.push(param);
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
if (scheme.type === "http") {
|
|
36
|
-
if (scheme.scheme === "basic") {
|
|
37
|
-
const value = `${scheme["x-scalar-secret-username"] || ""}:${scheme["x-scalar-secret-password"] || ""}`;
|
|
38
|
-
const auth = value === ":" ? "username:password" : encode(value);
|
|
39
|
-
result.headers.push({
|
|
40
|
-
name: "Authorization",
|
|
41
|
-
value: `Basic ${auth}`
|
|
42
|
-
});
|
|
43
|
-
} else if (scheme.scheme === "bearer") {
|
|
44
|
-
const token = scheme["x-scalar-secret-token"] || "YOUR_SECRET_TOKEN";
|
|
45
|
-
result.headers.push({
|
|
46
|
-
name: "Authorization",
|
|
47
|
-
value: `Bearer ${token}`
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
if (scheme.type === "oauth2" && scheme.flows) {
|
|
53
|
-
const token = Object.values(scheme.flows).find((f) => f["x-scalar-secret-token"])?.["x-scalar-secret-token"] || "YOUR_SECRET_TOKEN";
|
|
54
|
-
result.headers.push({
|
|
55
|
-
name: "Authorization",
|
|
56
|
-
value: `Bearer ${token}`
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return result;
|
|
61
|
-
};
|
|
62
|
-
//#endregion
|
|
63
|
-
export { processSecuritySchemes };
|
|
64
|
-
|
|
65
|
-
//# sourceMappingURL=process-security-schemes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"process-security-schemes.js","names":[],"sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.ts"],"sourcesContent":["import type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport type { Request as HarRequest } from 'har-format'\nimport { encode } from 'js-base64'\n\ntype ProcessedSecuritySchemesReturn = {\n headers: HarRequest['headers']\n queryString: HarRequest['queryString']\n cookies: HarRequest['cookies']\n}\n\n/**\n * Process security schemes into whichever parameters they are applicable to\n *\n * TODO: we probably want to be able to disable YOUR_SECRET_TOKEN placeholder text + or allow it to be customzied\n */\nexport const processSecuritySchemes = (\n securitySchemes: SecuritySchemeObjectSecret[],\n): ProcessedSecuritySchemesReturn => {\n const result: ProcessedSecuritySchemesReturn = {\n headers: [],\n queryString: [],\n cookies: [],\n }\n\n for (const scheme of securitySchemes) {\n // Handle apiKey type\n if (scheme.type === 'apiKey') {\n const value = scheme['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n if (!scheme.name) {\n continue\n }\n\n const param = { name: scheme.name, value }\n\n switch (scheme.in) {\n case 'header':\n result.headers.push(param)\n break\n case 'query':\n result.queryString.push(param)\n break\n case 'cookie':\n result.cookies.push(param)\n break\n }\n continue\n }\n\n // Handle http type\n if (scheme.type === 'http') {\n if (scheme.scheme === 'basic') {\n const username = scheme['x-scalar-secret-username'] || ''\n const password = scheme['x-scalar-secret-password'] || ''\n\n // The snippet is documentation, so we always show an Authorization header. When both\n // fields are empty we render a readable `username:password` placeholder, mirroring the\n // `YOUR_SECRET_TOKEN` placeholder used by the other schemes. (The real request omits the\n // header entirely in that case — see buildRequestSecurity.)\n const value = `${username}:${password}`\n const auth = value === ':' ? 'username:password' : encode(value)\n\n result.headers.push({\n name: 'Authorization',\n value: `Basic ${auth}`,\n })\n } else if (scheme.scheme === 'bearer') {\n const token = scheme['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n\n result.headers.push({\n name: 'Authorization',\n value: `Bearer ${token}`,\n })\n }\n continue\n }\n\n // Handle oauth2 type\n if (scheme.type === 'oauth2' && scheme.flows) {\n const flows = Object.values(scheme.flows)\n\n // Find the first flow with a token\n const flow = flows.find((f) => f['x-scalar-secret-token'])\n const token = flow?.['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n\n result.headers.push({\n name: 'Authorization',\n value: `Bearer ${token}`,\n })\n }\n }\n\n return result\n}\n"],"mappings":";;;;;;;AAeA,IAAa,0BACX,oBACmC;CACnC,MAAM,SAAyC;EAC7C,SAAS,EAAE;EACX,aAAa,EAAE;EACf,SAAS,EAAE;EACZ;AAED,MAAK,MAAM,UAAU,iBAAiB;AAEpC,MAAI,OAAO,SAAS,UAAU;GAC5B,MAAM,QAAQ,OAAO,4BAA4B;AACjD,OAAI,CAAC,OAAO,KACV;GAGF,MAAM,QAAQ;IAAE,MAAM,OAAO;IAAM;IAAO;AAE1C,WAAQ,OAAO,IAAf;IACE,KAAK;AACH,YAAO,QAAQ,KAAK,MAAM;AAC1B;IACF,KAAK;AACH,YAAO,YAAY,KAAK,MAAM;AAC9B;IACF,KAAK;AACH,YAAO,QAAQ,KAAK,MAAM;AAC1B;;AAEJ;;AAIF,MAAI,OAAO,SAAS,QAAQ;AAC1B,OAAI,OAAO,WAAW,SAAS;IAQ7B,MAAM,QAAQ,GAPG,OAAO,+BAA+B,GAO7B,GANT,OAAO,+BAA+B;IAOvD,MAAM,OAAO,UAAU,MAAM,sBAAsB,OAAO,MAAM;AAEhE,WAAO,QAAQ,KAAK;KAClB,MAAM;KACN,OAAO,SAAS;KACjB,CAAC;cACO,OAAO,WAAW,UAAU;IACrC,MAAM,QAAQ,OAAO,4BAA4B;AAEjD,WAAO,QAAQ,KAAK;KAClB,MAAM;KACN,OAAO,UAAU;KAClB,CAAC;;AAEJ;;AAIF,MAAI,OAAO,SAAS,YAAY,OAAO,OAAO;GAK5C,MAAM,QAJQ,OAAO,OAAO,OAAO,MAAM,CAGtB,MAAM,MAAM,EAAE,yBAAyB,GACrC,4BAA4B;AAEjD,UAAO,QAAQ,KAAK;IAClB,MAAM;IACN,OAAO,UAAU;IAClB,CAAC;;;AAIN,QAAO"}
|
package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-server-url.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { ServerObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
|
|
2
|
-
/**
|
|
3
|
-
* Processes a server URL by replacing variables with their default values and merging with the path
|
|
4
|
-
*/
|
|
5
|
-
export declare const processServerUrl: (server: ServerObject | null, path: string) => string;
|
|
6
|
-
//# sourceMappingURL=process-server-url.d.ts.map
|
package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-server-url.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"process-server-url.d.ts","sourceRoot":"","sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-server-url.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAEhG;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,YAAY,GAAG,IAAI,EAAE,MAAM,MAAM,KAAG,MA4B5E,CAAA"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { replaceVariables } from "@scalar/helpers/regex/replace-variables";
|
|
2
|
-
import { mergeUrls } from "@scalar/helpers/url/merge-urls";
|
|
3
|
-
//#region src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-server-url.ts
|
|
4
|
-
/**
|
|
5
|
-
* Processes a server URL by replacing variables with their default values and merging with the path
|
|
6
|
-
*/
|
|
7
|
-
var processServerUrl = (server, path) => {
|
|
8
|
-
if (!server?.url) return path;
|
|
9
|
-
const serverUrl = server.url;
|
|
10
|
-
if (server.variables) return mergeUrls(replaceVariables(serverUrl, Object.entries(server.variables).reduce((defaults, [variableName, variableConfig]) => {
|
|
11
|
-
if (variableConfig.default !== void 0) defaults[variableName] = variableConfig.default;
|
|
12
|
-
return defaults;
|
|
13
|
-
}, {})), path);
|
|
14
|
-
return mergeUrls(serverUrl, path);
|
|
15
|
-
};
|
|
16
|
-
//#endregion
|
|
17
|
-
export { processServerUrl };
|
|
18
|
-
|
|
19
|
-
//# sourceMappingURL=process-server-url.js.map
|
package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-server-url.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"process-server-url.js","names":[],"sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-server-url.ts"],"sourcesContent":["import { replaceVariables } from '@scalar/helpers/regex/replace-variables'\nimport { mergeUrls } from '@scalar/helpers/url/merge-urls'\nimport type { ServerObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\n/**\n * Processes a server URL by replacing variables with their default values and merging with the path\n */\nexport const processServerUrl = (server: ServerObject | null, path: string): string => {\n if (!server?.url) {\n return path\n }\n const serverUrl = server.url\n\n // Replace server variables with their default values\n if (server.variables) {\n const variables = Object.entries(server.variables)\n\n // Extract default values from server variables\n const defaultValues = variables.reduce(\n (defaults, [variableName, variableConfig]) => {\n if (variableConfig.default !== undefined) {\n defaults[variableName] = variableConfig.default\n }\n return defaults\n },\n {} as Record<string, string | number>,\n )\n\n // Replace variables in the server URL with their default values\n const serverUrlWithVars = replaceVariables(serverUrl, defaultValues)\n\n return mergeUrls(serverUrlWithVars, path)\n }\n\n return mergeUrls(serverUrl, path)\n}\n"],"mappings":";;;;;;AAOA,IAAa,oBAAoB,QAA6B,SAAyB;AACrF,KAAI,CAAC,QAAQ,IACX,QAAO;CAET,MAAM,YAAY,OAAO;AAGzB,KAAI,OAAO,UAiBT,QAAO,UAFmB,iBAAiB,WAdzB,OAAO,QAAQ,OAAO,UAAU,CAGlB,QAC7B,UAAU,CAAC,cAAc,oBAAoB;AAC5C,MAAI,eAAe,YAAY,KAAA,EAC7B,UAAS,gBAAgB,eAAe;AAE1C,SAAO;IAET,EAAE,CACH,CAGmE,EAEhC,KAAK;AAG3C,QAAO,UAAU,WAAW,KAAK"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export { default as ExamplePicker } from './components/ExamplePicker.vue.js';
|
|
2
|
-
export { default as HttpMethod } from './components/HttpMethod.vue.js';
|
|
3
|
-
export { default as OperationCodeSample } from './components/OperationCodeSample.vue.js';
|
|
4
|
-
export { filterClientsByQuery } from './helpers/filter-clients-by-query.js';
|
|
5
|
-
export { DEFAULT_CLIENT, type SelectedClientId, findClient, isClient, isSelectedClient } from './helpers/find-client.js';
|
|
6
|
-
export { generateClientOptions, getCustomClientIds } from './helpers/generate-client-options.js';
|
|
7
|
-
export { getResolvedRefDeep } from './helpers/get-resolved-ref-deep.js';
|
|
8
|
-
export type { ClientOption, ClientOptionGroup, CustomClientOption, CustomClientOptionGroup } from './types';
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/v2/blocks/operation-code-sample/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,gCAAgC,CAAA;AACzE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,6BAA6B,CAAA;AACnE,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;AACxE,OAAO,EAAE,cAAc,EAAE,KAAK,gBAAgB,EAAE,UAAU,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACrH,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AAC7F,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AACpE,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import ExamplePicker_default from "./components/ExamplePicker.vue.js";
|
|
2
|
-
import HttpMethod_default from "./components/HttpMethod.vue.js";
|
|
3
|
-
import { getResolvedRefDeep } from "./helpers/get-resolved-ref-deep.js";
|
|
4
|
-
import { filterClientsByQuery } from "./helpers/filter-clients-by-query.js";
|
|
5
|
-
import { DEFAULT_CLIENT, findClient, isClient, isSelectedClient } from "./helpers/find-client.js";
|
|
6
|
-
import { generateClientOptions, getCustomClientIds } from "./helpers/generate-client-options.js";
|
|
7
|
-
import OperationCodeSample_default from "./components/OperationCodeSample.vue.js";
|
|
8
|
-
export { DEFAULT_CLIENT, ExamplePicker_default as ExamplePicker, HttpMethod_default as HttpMethod, OperationCodeSample_default as OperationCodeSample, filterClientsByQuery, findClient, generateClientOptions, getCustomClientIds, getResolvedRefDeep, isClient, isSelectedClient };
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { ScalarComboboxOption, ScalarComboboxOptionGroup } from '@scalar/components/combobox';
|
|
2
|
-
import type { AvailableClients, ClientId, TargetId } from '@scalar/snippetz';
|
|
3
|
-
/**
|
|
4
|
-
* Represents a client option in the request example block.
|
|
5
|
-
* Extends the base combobox option with language-specific information
|
|
6
|
-
* for generating code examples in different programming languages.
|
|
7
|
-
*/
|
|
8
|
-
export type ClientOption = ScalarComboboxOption & {
|
|
9
|
-
/** A more specific ID */
|
|
10
|
-
id: AvailableClients[number];
|
|
11
|
-
/** Programming language or tool for code generation (e.g., 'javascript', 'python', 'curl') */
|
|
12
|
-
lang: TargetId | 'curl' | 'plaintext';
|
|
13
|
-
/** Title shows when the client is selected in the dropdown */
|
|
14
|
-
title: string;
|
|
15
|
-
/** Target key for the client, differs from the lang due to the curl thing */
|
|
16
|
-
targetKey: TargetId;
|
|
17
|
-
/** Title of the target */
|
|
18
|
-
targetTitle: string;
|
|
19
|
-
/** Client key for the client */
|
|
20
|
-
clientKey: ClientId<TargetId>;
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Augments the base combobox option group with ClientOptions
|
|
24
|
-
*/
|
|
25
|
-
export type ClientOptionGroup = ScalarComboboxOptionGroup<ClientOption> & {
|
|
26
|
-
/** Key of the group */
|
|
27
|
-
key: TargetId;
|
|
28
|
-
};
|
|
29
|
-
/** Better type safety when we have custom clients in the selector */
|
|
30
|
-
export type CustomClientOption = ScalarComboboxOption & {
|
|
31
|
-
/** A custom ID */
|
|
32
|
-
id: `custom/${string}`;
|
|
33
|
-
/** Programming language or tool for code generation (e.g., 'javascript', 'python', 'curl') */
|
|
34
|
-
lang: TargetId | 'curl' | 'plaintext';
|
|
35
|
-
/** Title shows when the client is selected in the dropdown */
|
|
36
|
-
title: string;
|
|
37
|
-
/** Client key for the client */
|
|
38
|
-
clientKey: 'custom';
|
|
39
|
-
};
|
|
40
|
-
export type CustomOrDefaultClientOption = ClientOption | CustomClientOption;
|
|
41
|
-
/** Augments the base combobox option group with CustomClientOptions */
|
|
42
|
-
export type CustomClientOptionGroup = ScalarComboboxOptionGroup<CustomOrDefaultClientOption> & {
|
|
43
|
-
/** Key of the group */
|
|
44
|
-
key: 'custom' | TargetId;
|
|
45
|
-
};
|
|
46
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/v2/blocks/operation-code-sample/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AAClG,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAE5E;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,oBAAoB,GAAG;IAChD,yBAAyB;IACzB,EAAE,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;IAC5B,8FAA8F;IAC9F,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAA;IACrC,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAA;IACb,6EAA6E;IAC7E,SAAS,EAAE,QAAQ,CAAA;IACnB,0BAA0B;IAC1B,WAAW,EAAE,MAAM,CAAA;IACnB,gCAAgC;IAChC,SAAS,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAA;CAC9B,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,yBAAyB,CAAC,YAAY,CAAC,GAAG;IACxE,uBAAuB;IACvB,GAAG,EAAE,QAAQ,CAAA;CACd,CAAA;AAED,qEAAqE;AACrE,MAAM,MAAM,kBAAkB,GAAG,oBAAoB,GAAG;IACtD,kBAAkB;IAClB,EAAE,EAAE,UAAU,MAAM,EAAE,CAAA;IACtB,8FAA8F;IAC9F,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAA;IACrC,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAA;IACb,gCAAgC;IAChC,SAAS,EAAE,QAAQ,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG,YAAY,GAAG,kBAAkB,CAAA;AAE3E,uEAAuE;AACvE,MAAM,MAAM,uBAAuB,GAAG,yBAAyB,CAAC,2BAA2B,CAAC,GAAG;IAC7F,uBAAuB;IACvB,GAAG,EAAE,QAAQ,GAAG,QAAQ,CAAA;CACzB,CAAA"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { ExampleObject, ParameterObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
|
|
2
|
-
/**
|
|
3
|
-
* Determines if a parameter is disabled
|
|
4
|
-
*
|
|
5
|
-
* First we explicitly check if its been disabled via the `x-disabled` extension.
|
|
6
|
-
* Then we check if its an optional parameter and not a path parameter.
|
|
7
|
-
*
|
|
8
|
-
* @param param - The parameter to check.
|
|
9
|
-
* @param example - The example to check.
|
|
10
|
-
* @returns true if the parameter is disabled, false otherwise.
|
|
11
|
-
*/
|
|
12
|
-
export declare const isParamDisabled: (param: ParameterObject, example: ExampleObject | undefined, defaultDisabled?: boolean) => boolean;
|
|
13
|
-
//# sourceMappingURL=is-param-disabled.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-param-disabled.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/request-block/helpers/is-param-disabled.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,8DAA8D,CAAA;AAElH;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,eAAe,EACtB,SAAS,aAAa,GAAG,SAAS,EAClC,kBAAiB,OAAc,YAgBhC,CAAA"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
//#region src/v2/blocks/request-block/helpers/is-param-disabled.ts
|
|
2
|
-
/**
|
|
3
|
-
* Determines if a parameter is disabled
|
|
4
|
-
*
|
|
5
|
-
* First we explicitly check if its been disabled via the `x-disabled` extension.
|
|
6
|
-
* Then we check if its an optional parameter and not a path parameter.
|
|
7
|
-
*
|
|
8
|
-
* @param param - The parameter to check.
|
|
9
|
-
* @param example - The example to check.
|
|
10
|
-
* @returns true if the parameter is disabled, false otherwise.
|
|
11
|
-
*/
|
|
12
|
-
var isParamDisabled = (param, example, defaultDisabled = true) => {
|
|
13
|
-
const xDisabled = example?.["x-disabled"];
|
|
14
|
-
if (typeof xDisabled === "boolean") return xDisabled;
|
|
15
|
-
if (!defaultDisabled) return false;
|
|
16
|
-
return !param.required && param.in !== "path";
|
|
17
|
-
};
|
|
18
|
-
//#endregion
|
|
19
|
-
export { isParamDisabled };
|
|
20
|
-
|
|
21
|
-
//# sourceMappingURL=is-param-disabled.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-param-disabled.js","names":[],"sources":["../../../../../src/v2/blocks/request-block/helpers/is-param-disabled.ts"],"sourcesContent":["import type { ExampleObject, ParameterObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\n/**\n * Determines if a parameter is disabled\n *\n * First we explicitly check if its been disabled via the `x-disabled` extension.\n * Then we check if its an optional parameter and not a path parameter.\n *\n * @param param - The parameter to check.\n * @param example - The example to check.\n * @returns true if the parameter is disabled, false otherwise.\n */\nexport const isParamDisabled = (\n param: ParameterObject,\n example: ExampleObject | undefined,\n defaultDisabled: boolean = true,\n) => {\n const xDisabled = example?.['x-disabled']\n\n // If x-disabled is explicitly set (true or false), use that value\n if (typeof xDisabled === 'boolean') {\n return xDisabled\n }\n\n // If the parameter is not disabled by default, return false\n if (!defaultDisabled) {\n return false\n }\n\n // Otherwise, disable optional parameters (except path parameters which are always required)\n return !param.required && param.in !== 'path'\n}\n"],"mappings":";;;;;;;;;;;AAYA,IAAa,mBACX,OACA,SACA,kBAA2B,SACxB;CACH,MAAM,YAAY,UAAU;AAG5B,KAAI,OAAO,cAAc,UACvB,QAAO;AAIT,KAAI,CAAC,gBACH,QAAO;AAIT,QAAO,CAAC,MAAM,YAAY,MAAM,OAAO"}
|