@scalar/api-client 2.5.34 → 2.6.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 +38 -0
- package/dist/components/CodeInput/CodeInput.vue.d.ts +0 -3
- package/dist/components/CodeInput/CodeInput.vue.d.ts.map +1 -1
- package/dist/components/CodeInput/CodeInput.vue.js +2 -2
- package/dist/components/CodeInput/CodeInput.vue2.js +60 -62
- package/dist/components/CodeInput/codeVariableWidget.d.ts +1 -3
- package/dist/components/CodeInput/codeVariableWidget.d.ts.map +1 -1
- package/dist/components/CodeInput/codeVariableWidget.js +25 -32
- package/dist/components/DataTable/DataTableInput.vue.d.ts +0 -2
- package/dist/components/DataTable/DataTableInput.vue.d.ts.map +1 -1
- package/dist/components/DataTable/DataTableInput.vue.js +2 -2
- package/dist/components/DataTable/DataTableInput.vue2.js +17 -19
- package/dist/layouts/App/create-api-client-app.d.ts +20 -20
- package/dist/layouts/App/create-api-client-app.d.ts.map +1 -1
- package/dist/layouts/Modal/create-api-client-modal.d.ts +40 -40
- package/dist/layouts/Modal/create-api-client-modal.d.ts.map +1 -1
- package/dist/layouts/Web/create-api-client-web.d.ts +20 -20
- package/dist/layouts/Web/create-api-client-web.d.ts.map +1 -1
- package/dist/libs/create-client.d.ts +20 -20
- package/dist/libs/create-client.d.ts.map +1 -1
- package/dist/libs/send-request/create-request-operation.test.d.ts +1 -1
- package/dist/libs/send-request/create-request-operation.test.d.ts.map +1 -1
- package/dist/store/active-entities.d.ts +1 -1
- package/dist/store/request-example.d.ts +10 -10
- package/dist/store/security-schemes.d.ts +10 -10
- package/dist/store/security-schemes.d.ts.map +1 -1
- package/dist/store/store.d.ts +20 -20
- package/dist/store/store.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/dist/v2/blocks/operation-code-sample/components/ExamplePicker.test.d.ts +2 -0
- package/dist/v2/blocks/operation-code-sample/components/ExamplePicker.test.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/components/ExamplePicker.vue.d.ts +14 -0
- package/dist/v2/blocks/operation-code-sample/components/ExamplePicker.vue.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/components/ExamplePicker.vue.js +55 -0
- package/dist/v2/blocks/operation-code-sample/components/ExamplePicker.vue2.js +4 -0
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.test.d.ts +2 -0
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.test.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.d.ts +104 -0
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.js +7 -0
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue2.js +237 -0
- package/dist/v2/blocks/operation-code-sample/helpers/find-client.d.ts +41 -0
- package/dist/v2/blocks/operation-code-sample/helpers/find-client.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/helpers/find-client.js +20 -0
- package/dist/v2/blocks/operation-code-sample/helpers/find-client.test.d.ts +2 -0
- package/dist/v2/blocks/operation-code-sample/helpers/find-client.test.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/helpers/generate-client-options.d.ts +20 -0
- package/dist/v2/blocks/operation-code-sample/helpers/generate-client-options.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/helpers/generate-client-options.js +4 -0
- package/dist/v2/blocks/operation-code-sample/helpers/generate-client-options.test.d.ts +2 -0
- package/dist/v2/blocks/operation-code-sample/helpers/generate-client-options.test.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.d.ts +17 -0
- package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.js +30 -0
- package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.test.d.ts +2 -0
- package/dist/v2/blocks/operation-code-sample/helpers/generate-code-snippet.test.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/helpers/get-example-from-schema.d.ts +29 -0
- package/dist/v2/blocks/operation-code-sample/helpers/get-example-from-schema.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/helpers/get-example-from-schema.js +209 -0
- package/dist/v2/blocks/operation-code-sample/helpers/get-example-from-schema.test.d.ts +2 -0
- package/dist/v2/blocks/operation-code-sample/helpers/get-example-from-schema.test.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/helpers/get-resolved-ref-deep.d.ts +26 -0
- package/dist/v2/blocks/operation-code-sample/helpers/get-resolved-ref-deep.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/helpers/get-resolved-ref-deep.js +29 -0
- package/dist/v2/blocks/operation-code-sample/helpers/get-resolved-ref-deep.test.d.ts +2 -0
- package/dist/v2/blocks/operation-code-sample/helpers/get-resolved-ref-deep.test.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/helpers/get-secrets.d.ts +4 -0
- package/dist/v2/blocks/operation-code-sample/helpers/get-secrets.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/helpers/get-secrets.js +10 -0
- package/dist/v2/blocks/operation-code-sample/helpers/get-secrets.test.d.ts +2 -0
- package/dist/v2/blocks/operation-code-sample/helpers/get-secrets.test.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/get-example-value.d.ts +7 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/get-example-value.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/get-example-value.js +28 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/get-example-value.test.d.ts +2 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/get-example-value.test.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.d.ts +52 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.js +59 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.test.d.ts +2 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.test.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.d.ts +12 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.js +57 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.test.d.ts +2 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.test.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.d.ts +25 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.js +212 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.test.d.ts +2 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.test.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.d.ts +15 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.js +55 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.test.d.ts +2 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-security-schemes.test.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-server-url.d.ts +6 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-server-url.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-server-url.js +18 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-server-url.test.d.ts +2 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-server-url.test.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/index.d.ts +3 -0
- package/dist/v2/blocks/operation-code-sample/index.d.ts.map +1 -0
- package/dist/v2/blocks/operation-code-sample/index.js +6 -0
- package/dist/v2/blocks/operation-code-sample/types.d.ts +29 -0
- package/dist/v2/blocks/operation-code-sample/types.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.test.d.ts +2 -0
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.test.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.d.ts +65 -0
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.js +7 -0
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue2.js +122 -0
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.test.d.ts +2 -0
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.test.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.d.ts +25 -0
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue.js +7 -0
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBarHistory.vue2.js +90 -0
- package/dist/v2/blocks/scalar-address-bar-block/components/httpStatusCodeColors.d.ts +55 -0
- package/dist/v2/blocks/scalar-address-bar-block/components/httpStatusCodeColors.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-address-bar-block/components/httpStatusCodeColors.js +39 -0
- package/dist/v2/blocks/scalar-address-bar-block/index.d.ts +2 -0
- package/dist/v2/blocks/scalar-address-bar-block/index.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-address-bar-block/index.js +4 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.test.d.ts +2 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.test.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.d.ts +49 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.js +7 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue2.js +172 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/DeleteRequestAuthModal.test.d.ts +2 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/DeleteRequestAuthModal.test.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/DeleteRequestAuthModal.vue.d.ts +17 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/DeleteRequestAuthModal.vue.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/DeleteRequestAuthModal.vue.js +52 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/DeleteRequestAuthModal.vue2.js +4 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.test.d.ts +2 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.test.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.d.ts +45 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.js +254 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue2.js +4 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuthScopesInput.test.d.ts +2 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuthScopesInput.test.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuthScopesInput.vue.d.ts +16 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuthScopesInput.vue.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuthScopesInput.vue.js +134 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuthScopesInput.vue2.js +4 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTable.test.d.ts +2 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTable.test.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTable.vue.d.ts +33 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTable.vue.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTable.vue.js +7 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTable.vue2.js +82 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTableInput.vue.d.ts +48 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTableInput.vue.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTableInput.vue.js +48 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTableInput.vue2.js +4 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.test.d.ts +2 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.test.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.d.ts +29 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.js +232 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue2.js +4 -0
- package/dist/v2/blocks/scalar-auth-selector-block/event-types.d.ts +29 -0
- package/dist/v2/blocks/scalar-auth-selector-block/event-types.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/auth-options.d.ts +9 -0
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/auth-options.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/auth-options.js +121 -0
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.d.ts +34 -0
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.js +111 -0
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.test.d.ts +2 -0
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.test.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/security-scheme.d.ts +39 -0
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/security-scheme.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/security-scheme.js +52 -0
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/security-scheme.test.d.ts +2 -0
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/security-scheme.test.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-auth-selector-block/index.d.ts +2 -0
- package/dist/v2/blocks/scalar-auth-selector-block/index.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-auth-selector-block/index.js +4 -0
- package/dist/v2/components/server/ServerDropdown.test.d.ts +2 -0
- package/dist/v2/components/server/ServerDropdown.test.d.ts.map +1 -0
- package/dist/v2/components/server/ServerDropdown.vue.d.ts +33 -0
- package/dist/v2/components/server/ServerDropdown.vue.d.ts.map +1 -0
- package/dist/v2/components/server/ServerDropdown.vue.js +87 -0
- package/dist/v2/components/server/ServerDropdown.vue2.js +4 -0
- package/dist/v2/components/server/ServerDropdownItem.test.d.ts +2 -0
- package/dist/v2/components/server/ServerDropdownItem.test.d.ts.map +1 -0
- package/dist/v2/components/server/ServerDropdownItem.vue.d.ts +21 -0
- package/dist/v2/components/server/ServerDropdownItem.vue.d.ts.map +1 -0
- package/dist/v2/components/server/ServerDropdownItem.vue.js +7 -0
- package/dist/v2/components/server/ServerDropdownItem.vue2.js +51 -0
- package/dist/v2/components/server/index.d.ts +2 -0
- package/dist/v2/components/server/index.d.ts.map +1 -0
- package/dist/v2/components/server/index.js +4 -0
- package/dist/views/Request/Request.vue.js +1 -1
- package/dist/views/Request/Request.vue2.js +4 -4
- package/dist/views/Request/RequestSection/RequestAuth/RequestAuth.vue.d.ts +2 -2
- package/dist/views/Request/RequestSection/RequestAuth/RequestAuth.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestAuth/RequestAuthDataTable.vue.d.ts +2 -2
- package/dist/views/Request/RequestSection/RequestAuth/RequestAuthDataTable.vue.d.ts.map +1 -1
- package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
- package/dist/vitest.setup.d.ts.map +1 -1
- package/package.json +16 -12
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-example-from-schema.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-code-sample/helpers/get-example-from-schema.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AA8XhG;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,YAAY,EACpB,UAAU;IACR,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,4CAA4C;IAC5C,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACvB,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,qDAAqD;IACrD,8BAA8B,CAAC,EAAE,OAAO,CAAA;CACzC,EACD,QAAO,MAAU,EACjB,eAAe,YAAY,EAC3B,OAAO,MAAM,KACZ,OAkHF,CAAA"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { isDefined as x } from "@scalar/helpers/array/is-defined";
|
|
2
|
+
import { getResolvedRef as l } from "@scalar/workspace-store/helpers/get-resolved-ref";
|
|
3
|
+
const N = 10, A = 10, E = "propertyName*", O = (/* @__PURE__ */ new Date()).toISOString(), S = O.split("T")[0], R = O.split("T")[1].split(".")[0], T = {
|
|
4
|
+
"date-time": O,
|
|
5
|
+
date: S,
|
|
6
|
+
email: "hello@example.com",
|
|
7
|
+
hostname: "example.com",
|
|
8
|
+
// https://tools.ietf.org/html/rfc6531#section-3.3
|
|
9
|
+
"idn-email": "jane.doe@example.com",
|
|
10
|
+
// https://tools.ietf.org/html/rfc5890#section-2.3.2.3
|
|
11
|
+
"idn-hostname": "example.com",
|
|
12
|
+
ipv4: "127.0.0.1",
|
|
13
|
+
ipv6: "51d4:7fab:bfbf:b7d7:b2cb:d4b4:3dad:d998",
|
|
14
|
+
"iri-reference": "/entitiy/1",
|
|
15
|
+
// https://tools.ietf.org/html/rfc3987
|
|
16
|
+
iri: "https://example.com/entity/123",
|
|
17
|
+
"json-pointer": "/nested/objects",
|
|
18
|
+
password: "super-secret",
|
|
19
|
+
regex: "/[a-z]/",
|
|
20
|
+
// https://tools.ietf.org/html/draft-handrews-relative-json-pointer-01
|
|
21
|
+
"relative-json-pointer": "1/nested/objects",
|
|
22
|
+
// full-time in https://tools.ietf.org/html/rfc3339#section-5.6
|
|
23
|
+
time: R,
|
|
24
|
+
// either a URI or relative-reference https://tools.ietf.org/html/rfc3986#section-4.1
|
|
25
|
+
"uri-reference": "../folder",
|
|
26
|
+
"uri-template": "https://example.com/{id}",
|
|
27
|
+
uri: "https://example.com",
|
|
28
|
+
uuid: "123e4567-e89b-12d3-a456-426614174000",
|
|
29
|
+
"object-id": "6592008029c8c3e4dc76256c"
|
|
30
|
+
}, v = (t, r = !1, o = "") => "type" in t && t.type === "string" && "format" in t && t.format === "binary" ? new File([""], "filename") : r && "format" in t && t.format ? T[t.format] ?? o : o, g = /* @__PURE__ */ new WeakMap(), j = /* @__PURE__ */ new WeakMap(), D = (t) => {
|
|
31
|
+
if (!t)
|
|
32
|
+
return;
|
|
33
|
+
const r = j.get(t);
|
|
34
|
+
if (r)
|
|
35
|
+
return r;
|
|
36
|
+
if ("required" in t) {
|
|
37
|
+
const o = t.required;
|
|
38
|
+
if (Array.isArray(o) && o.length > 0) {
|
|
39
|
+
const i = new Set(o);
|
|
40
|
+
return j.set(t, i), i;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}, p = (t, r) => (typeof r != "object" || r === null || g.set(t, r), r), q = (t) => !!(t.allOf || t.oneOf || t.anyOf), w = (t, r, o, i) => {
|
|
44
|
+
if (i?.omitEmptyAndOptionalProperties !== !0 || "type" in t && (t.type === "object" || t.type === "array") || q(t) || "examples" in t && Array.isArray(t.examples) && t.examples.length > 0 || "example" in t && t.example !== void 0 || "default" in t && t.default !== void 0 || "const" in t && t.const !== void 0 || "enum" in t && Array.isArray(t.enum) && t.enum.length > 0)
|
|
45
|
+
return !1;
|
|
46
|
+
const e = o ?? t.title ?? "", u = D(r);
|
|
47
|
+
return !(u ? u.has(e) : !1);
|
|
48
|
+
}, P = (t, r) => Array.isArray(t) && Array.isArray(r) ? [...t, ...r] : t && typeof t == "object" && r && typeof r == "object" ? { ...t, ...r } : r, I = (t, r, o) => {
|
|
49
|
+
const i = {};
|
|
50
|
+
if ("properties" in t && t.properties) {
|
|
51
|
+
const n = Object.keys(t.properties), e = o > 3 ? Math.min(A, n.length) : n.length;
|
|
52
|
+
for (let u = 0; u < e; u++) {
|
|
53
|
+
const s = n[u], a = l(t.properties[s]);
|
|
54
|
+
if (!a)
|
|
55
|
+
continue;
|
|
56
|
+
const y = r?.xml && "xml" in a ? a.xml?.name : void 0, f = d(a, r, o + 1, t, s);
|
|
57
|
+
typeof f < "u" && (i[y ?? s] = f);
|
|
58
|
+
}
|
|
59
|
+
o > 3 && n.length > A && (i["..."] = "[Additional Properties Truncated]");
|
|
60
|
+
}
|
|
61
|
+
if ("patternProperties" in t && t.patternProperties)
|
|
62
|
+
for (const n of Object.keys(t.patternProperties)) {
|
|
63
|
+
const e = l(t.patternProperties[n]);
|
|
64
|
+
e && (i[n] = d(e, r, o + 1, t, n));
|
|
65
|
+
}
|
|
66
|
+
if ("additionalProperties" in t && t.additionalProperties !== void 0) {
|
|
67
|
+
const n = l(t.additionalProperties), e = t.additionalProperties === !0 || typeof t.additionalProperties == "object" && Object.keys(t.additionalProperties).length === 0, u = typeof n == "object" && "x-additionalPropertiesName" in n && typeof n["x-additionalPropertiesName"] == "string" && n["x-additionalPropertiesName"].trim().length > 0 ? `${n["x-additionalPropertiesName"].trim()}*` : E;
|
|
68
|
+
i[u] = e ? "anything" : typeof n == "object" ? d(n, r, o + 1) : "anything";
|
|
69
|
+
}
|
|
70
|
+
if (t.oneOf?.[0])
|
|
71
|
+
Object.assign(i, d(l(t.oneOf[0]), r, o + 1));
|
|
72
|
+
else if (t.anyOf?.[0])
|
|
73
|
+
Object.assign(i, d(l(t.anyOf[0]), r, o + 1));
|
|
74
|
+
else if (Array.isArray(t.allOf) && t.allOf.length > 0) {
|
|
75
|
+
let n = i;
|
|
76
|
+
for (const e of t.allOf) {
|
|
77
|
+
const u = d(l(e), r, o + 1, t);
|
|
78
|
+
n = P(n, u);
|
|
79
|
+
}
|
|
80
|
+
n && typeof n == "object" && Object.assign(i, n);
|
|
81
|
+
}
|
|
82
|
+
if (r?.xml && "xml" in t && t.xml?.name && o === 0) {
|
|
83
|
+
const n = {};
|
|
84
|
+
return n[t.xml.name] = i, p(t, n);
|
|
85
|
+
}
|
|
86
|
+
return p(t, i);
|
|
87
|
+
}, M = (t, r, o) => {
|
|
88
|
+
const i = "items" in t ? l(t.items) : void 0, n = i && typeof i == "object" && "xml" in i ? i.xml?.name : void 0, e = !!(r?.xml && "xml" in t && t.xml?.wrapped && n);
|
|
89
|
+
if (t.example !== void 0)
|
|
90
|
+
return p(t, e ? { [n]: t.example } : t.example);
|
|
91
|
+
if (i && typeof i == "object") {
|
|
92
|
+
if (Array.isArray(i.allOf) && i.allOf.length > 0) {
|
|
93
|
+
const y = i.allOf.filter(x), f = l(y[0]);
|
|
94
|
+
if (f && typeof f == "object" && "type" in f && f.type === "object") {
|
|
95
|
+
const c = d({ type: "object", allOf: y }, r, o + 1, t);
|
|
96
|
+
return p(t, e ? [{ [n]: c }] : [c]);
|
|
97
|
+
}
|
|
98
|
+
const m = y.map((b) => d(l(b), r, o + 1, t)).filter(x);
|
|
99
|
+
return p(
|
|
100
|
+
t,
|
|
101
|
+
e ? m.map((b) => ({ [n]: b })) : m
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
const a = i.anyOf || i.oneOf;
|
|
105
|
+
if (a && a.length > 0) {
|
|
106
|
+
const y = a[0], f = d(l(y), r, o + 1, t);
|
|
107
|
+
return p(t, e ? [{ [n]: f }] : [f]);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const u = i && typeof i == "object" && ("type" in i && i.type === "object" || "properties" in i), s = i && typeof i == "object" && ("type" in i && i.type === "array" || "items" in i);
|
|
111
|
+
if (i && typeof i == "object" && ("type" in i && i.type || u || s)) {
|
|
112
|
+
const a = d(i, r, o + 1);
|
|
113
|
+
return p(t, e ? [{ [n]: a }] : [a]);
|
|
114
|
+
}
|
|
115
|
+
return p(t, []);
|
|
116
|
+
}, _ = (t, r, o) => {
|
|
117
|
+
if ("type" in t && t.type && !Array.isArray(t.type))
|
|
118
|
+
switch (t.type) {
|
|
119
|
+
case "string":
|
|
120
|
+
return v(t, r, o ?? "");
|
|
121
|
+
case "boolean":
|
|
122
|
+
return !0;
|
|
123
|
+
case "integer":
|
|
124
|
+
return "minimum" in t && typeof t.minimum == "number" ? t.minimum : 1;
|
|
125
|
+
case "number":
|
|
126
|
+
return "minimum" in t && typeof t.minimum == "number" ? t.minimum : 1;
|
|
127
|
+
case "array":
|
|
128
|
+
return [];
|
|
129
|
+
default:
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
}, k = (t, r, o) => {
|
|
133
|
+
if ("type" in t && Array.isArray(t.type)) {
|
|
134
|
+
if (t.type.includes("null"))
|
|
135
|
+
return null;
|
|
136
|
+
const i = t.type[0];
|
|
137
|
+
if (i)
|
|
138
|
+
switch (i) {
|
|
139
|
+
case "string":
|
|
140
|
+
return v(t, r, o ?? "");
|
|
141
|
+
case "boolean":
|
|
142
|
+
return !0;
|
|
143
|
+
case "integer":
|
|
144
|
+
return "minimum" in t && typeof t.minimum == "number" ? t.minimum : 1;
|
|
145
|
+
case "number":
|
|
146
|
+
return "minimum" in t && typeof t.minimum == "number" ? t.minimum : 1;
|
|
147
|
+
case "null":
|
|
148
|
+
return null;
|
|
149
|
+
default:
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}, d = (t, r, o = 0, i, n) => {
|
|
154
|
+
const e = l(t);
|
|
155
|
+
if (!x(e))
|
|
156
|
+
return;
|
|
157
|
+
if (g.has(e))
|
|
158
|
+
return g.get(e);
|
|
159
|
+
if (o > N)
|
|
160
|
+
return "[Max Depth Exceeded]";
|
|
161
|
+
const u = !!r?.emptyString;
|
|
162
|
+
if (e.deprecated || r?.mode === "write" && e.readOnly || r?.mode === "read" && e.writeOnly || w(e, i, n, r))
|
|
163
|
+
return;
|
|
164
|
+
if ("x-variable" in e && e["x-variable"]) {
|
|
165
|
+
const f = r?.variables?.[e["x-variable"]];
|
|
166
|
+
if (f !== void 0)
|
|
167
|
+
return "type" in e && (e.type === "number" || e.type === "integer") ? p(e, Number(f)) : p(e, f);
|
|
168
|
+
}
|
|
169
|
+
if (Array.isArray(e.examples) && e.examples.length > 0)
|
|
170
|
+
return p(e, e.examples[0]);
|
|
171
|
+
if (e.example !== void 0)
|
|
172
|
+
return p(e, e.example);
|
|
173
|
+
if (e.default !== void 0)
|
|
174
|
+
return p(e, e.default);
|
|
175
|
+
if (e.const !== void 0)
|
|
176
|
+
return p(e, e.const);
|
|
177
|
+
if (Array.isArray(e.enum) && e.enum.length > 0)
|
|
178
|
+
return p(e, e.enum[0]);
|
|
179
|
+
if ("properties" in e || "type" in e && e.type === "object")
|
|
180
|
+
return I(t, r, o);
|
|
181
|
+
if ("type" in e && e.type === "array" || "items" in e)
|
|
182
|
+
return M(e, r, o);
|
|
183
|
+
const s = _(e, u, r?.emptyString);
|
|
184
|
+
if (s !== void 0)
|
|
185
|
+
return p(e, s);
|
|
186
|
+
const a = e.oneOf || e.anyOf;
|
|
187
|
+
if (Array.isArray(a) && a.length > 0) {
|
|
188
|
+
for (const f of a) {
|
|
189
|
+
const m = l(f);
|
|
190
|
+
if (m && (!("type" in m) || m.type !== "null"))
|
|
191
|
+
return p(e, d(m, r, o + 1));
|
|
192
|
+
}
|
|
193
|
+
return p(e, null);
|
|
194
|
+
}
|
|
195
|
+
if (Array.isArray(e.allOf) && e.allOf.length > 0) {
|
|
196
|
+
let f;
|
|
197
|
+
const m = e.allOf;
|
|
198
|
+
for (const b of m) {
|
|
199
|
+
const c = d(b, r, o + 1, e);
|
|
200
|
+
f === void 0 ? f = c : f && typeof f == "object" && c && typeof c == "object" ? f = P(f, c) : c !== void 0 && (f = c);
|
|
201
|
+
}
|
|
202
|
+
return p(e, f ?? null);
|
|
203
|
+
}
|
|
204
|
+
const y = k(e, u, r?.emptyString);
|
|
205
|
+
return y !== void 0 ? p(e, y) : p(e, null);
|
|
206
|
+
};
|
|
207
|
+
export {
|
|
208
|
+
d as getExampleFromSchema
|
|
209
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-example-from-schema.test.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-code-sample/helpers/get-example-from-schema.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Dereference } from '@scalar/workspace-store/helpers/get-resolved-ref';
|
|
2
|
+
export type RefNode<Node> = Partial<Node> & {
|
|
3
|
+
$ref: string;
|
|
4
|
+
'$ref-value': Node | RefNode<Node>;
|
|
5
|
+
};
|
|
6
|
+
export type NodeInput<Node> = Node | RefNode<Node>;
|
|
7
|
+
/**
|
|
8
|
+
* Recursively resolves $ref objects
|
|
9
|
+
* This type helper ensures proper typing for deeply nested ref resolution.
|
|
10
|
+
* Properties that could contain $ref objects may resolve to '[circular]' if we have a circular reference.
|
|
11
|
+
*/
|
|
12
|
+
export type DeepDereference<T> = Dereference<T> extends T ? T extends readonly (infer U)[] ? DeepDereference<U>[] : T extends object ? {
|
|
13
|
+
[K in keyof T]: T[K] extends RefNode<any> ? DeepDereference<T[K]> | '[circular]' : DeepDereference<T[K]>;
|
|
14
|
+
} : T : Dereference<T> extends object ? {
|
|
15
|
+
[K in keyof Dereference<T>]: Dereference<T>[K] extends RefNode<any> ? DeepDereference<Dereference<T>[K]> | '[circular]' : DeepDereference<Dereference<T>[K]>;
|
|
16
|
+
} : Dereference<T>;
|
|
17
|
+
/**
|
|
18
|
+
* Recursively resolves all $ref objects in a data structure to their actual values.
|
|
19
|
+
* Traverses through objects, arrays, and nested structures to find and resolve
|
|
20
|
+
* any $ref references at any depth level.
|
|
21
|
+
*
|
|
22
|
+
* Handles circular references gracefully by detecting them and returning '[circular]'
|
|
23
|
+
* to prevent infinite loops.
|
|
24
|
+
*/
|
|
25
|
+
export declare const getResolvedRefDeep: <Node>(node: NodeInput<Node>) => DeepDereference<NodeInput<Node>>;
|
|
26
|
+
//# sourceMappingURL=get-resolved-ref-deep.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-resolved-ref-deep.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-code-sample/helpers/get-resolved-ref-deep.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kDAAkD,CAAA;AAEnF,MAAM,MAAM,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAAA;AAChG,MAAM,MAAM,SAAS,CAAC,IAAI,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;AAElD;;;;GAIG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,GACrD,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAC5B,eAAe,CAAC,CAAC,CAAC,EAAE,GACpB,CAAC,SAAS,MAAM,GACd;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,OAAO,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,YAAY,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAC5G,CAAC,GACL,WAAW,CAAC,CAAC,CAAC,SAAS,MAAM,GAC3B;KACG,CAAC,IAAI,MAAM,WAAW,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,OAAO,CAAC,GAAG,CAAC,GAC/D,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,YAAY,GACjD,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACvC,GACD,WAAW,CAAC,CAAC,CAAC,CAAA;AAEpB;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAAI,IAAI,EAAE,MAAM,SAAS,CAAC,IAAI,CAAC,KAAG,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAoD/F,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { getRaw as i } from "@scalar/json-magic/magic-proxy";
|
|
2
|
+
const n = (a) => {
|
|
3
|
+
const o = /* @__PURE__ */ new WeakSet(), f = (e) => {
|
|
4
|
+
if (e == null || typeof e != "object")
|
|
5
|
+
return e;
|
|
6
|
+
const t = i(e);
|
|
7
|
+
if (o.has(t))
|
|
8
|
+
return "[circular]";
|
|
9
|
+
if (o.add(t), typeof e == "object" && e !== null && "$ref" in e) {
|
|
10
|
+
const l = e["$ref-value"], s = f(l);
|
|
11
|
+
return o.delete(t), s;
|
|
12
|
+
}
|
|
13
|
+
if (Array.isArray(e)) {
|
|
14
|
+
const l = e.map((s) => f(s));
|
|
15
|
+
return o.delete(t), l;
|
|
16
|
+
}
|
|
17
|
+
if (typeof e == "object" && e !== null) {
|
|
18
|
+
const l = {};
|
|
19
|
+
for (const [s, d] of Object.entries(e))
|
|
20
|
+
l[s] = f(d);
|
|
21
|
+
return o.delete(t), l;
|
|
22
|
+
}
|
|
23
|
+
return o.delete(t), e;
|
|
24
|
+
};
|
|
25
|
+
return f(a);
|
|
26
|
+
};
|
|
27
|
+
export {
|
|
28
|
+
n as getResolvedRefDeep
|
|
29
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-resolved-ref-deep.test.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-code-sample/helpers/get-resolved-ref-deep.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SecuritySchemeObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
|
|
2
|
+
/** Extract secrets from security schemes */
|
|
3
|
+
export declare const getSecrets: (securitySchemes: SecuritySchemeObject[]) => string[];
|
|
4
|
+
//# sourceMappingURL=get-secrets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-secrets.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-code-sample/helpers/get-secrets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8DAA8D,CAAA;AAGxG,4CAA4C;AAC5C,eAAO,MAAM,UAAU,GAAI,iBAAiB,oBAAoB,EAAE,KAAG,MAAM,EAqBvD,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { encode as e } from "js-base64";
|
|
2
|
+
const l = (t) => t.flatMap((r) => r.type === "apiKey" ? r["x-scalar-secret-token"] : r?.type === "http" ? [
|
|
3
|
+
r["x-scalar-secret-token"],
|
|
4
|
+
r["x-scalar-secret-username"],
|
|
5
|
+
r["x-scalar-secret-password"],
|
|
6
|
+
e(`${r["x-scalar-secret-username"]}:${r["x-scalar-secret-password"]}`)
|
|
7
|
+
] : r.type === "oauth2" ? Object.values(r.flows).map((a) => a["x-scalar-secret-token"]) : []).filter(Boolean);
|
|
8
|
+
export {
|
|
9
|
+
l as getSecrets
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-secrets.test.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-code-sample/helpers/get-secrets.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ParameterObject, RequestBodyObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve an example value for a parameter or requestBody from either `examples` or `content.*.examples`.
|
|
4
|
+
* Or the [deprecated] `example` field.
|
|
5
|
+
*/
|
|
6
|
+
export declare const getExampleValue: (param: ParameterObject | RequestBodyObject, example?: string, contentType?: string) => unknown;
|
|
7
|
+
//# sourceMappingURL=get-example-value.d.ts.map
|
package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/get-example-value.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-example-value.d.ts","sourceRoot":"","sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/get-example-value.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,8DAA8D,CAAA;AAItH;;;GAGG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,eAAe,GAAG,iBAAiB,EAC1C,UAAU,MAAM,EAChB,cAAc,MAAM,KACnB,OA8CF,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { getResolvedRefDeep as l } from "../get-resolved-ref-deep.js";
|
|
2
|
+
const f = (e, s, i) => {
|
|
3
|
+
if (s && "examples" in e && e.examples) {
|
|
4
|
+
const n = l(e.examples[s])?.value;
|
|
5
|
+
if (n)
|
|
6
|
+
return n;
|
|
7
|
+
}
|
|
8
|
+
if ("content" in e && e.content) {
|
|
9
|
+
const n = i ?? Object.keys(e.content)[0], t = e.content[n ?? ""];
|
|
10
|
+
if (t?.examples) {
|
|
11
|
+
const x = s ?? Object.keys(t.examples)[0], o = l(t.examples[x ?? ""]);
|
|
12
|
+
if (o)
|
|
13
|
+
return o.value;
|
|
14
|
+
}
|
|
15
|
+
if (t?.example !== void 0)
|
|
16
|
+
return t.example;
|
|
17
|
+
}
|
|
18
|
+
if ("example" in e && e.example !== void 0)
|
|
19
|
+
return e.example;
|
|
20
|
+
if ("examples" in e && e.examples) {
|
|
21
|
+
const n = Object.keys(e.examples)[0] ?? "", t = l(e.examples[n])?.value;
|
|
22
|
+
if (t)
|
|
23
|
+
return t;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
f as getExampleValue
|
|
28
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-example-value.test.d.ts","sourceRoot":"","sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/get-example-value.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { HttpMethod } from '@scalar/helpers/http/http-methods';
|
|
2
|
+
import type { OperationObject, SecuritySchemeObject, ServerObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
|
|
3
|
+
import type { Request as HarRequest } from 'har-format';
|
|
4
|
+
export type OperationToHarProps = {
|
|
5
|
+
/** OpenAPI Operation object */
|
|
6
|
+
operation: OperationObject;
|
|
7
|
+
/** HTTP method of the operation */
|
|
8
|
+
method: HttpMethod;
|
|
9
|
+
/** Path of the operation */
|
|
10
|
+
path: string;
|
|
11
|
+
/**
|
|
12
|
+
* Name of the currently selected operation example
|
|
13
|
+
*
|
|
14
|
+
* Applies to both the body and the parameters
|
|
15
|
+
*/
|
|
16
|
+
example?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Content type of the operation
|
|
19
|
+
*
|
|
20
|
+
* Applies to both the body and the parameters (if applicable)
|
|
21
|
+
* @defaults to the first content type in the MediaTypeObject
|
|
22
|
+
*/
|
|
23
|
+
contentType?: string;
|
|
24
|
+
/** OpenAPI Server object */
|
|
25
|
+
server?: ServerObject | undefined;
|
|
26
|
+
/** OpenAPI SecurityScheme objects which are applicable to the operation */
|
|
27
|
+
securitySchemes?: SecuritySchemeObject[];
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Converts an OpenAPI Operation to a HarRequest format for generating HTTP request snippets.
|
|
31
|
+
*
|
|
32
|
+
* This function transforms OpenAPI 3.1 operation objects into HAR (HTTP Archive) format requests,
|
|
33
|
+
* which can be used to generate code snippets for various programming languages and HTTP clients.
|
|
34
|
+
*
|
|
35
|
+
* The conversion handles:
|
|
36
|
+
* - Server URL processing and path parameter substitution
|
|
37
|
+
* - Query parameter formatting based on OpenAPI parameter styles
|
|
38
|
+
* - Request body processing with content type handling
|
|
39
|
+
* - Security scheme integration (API keys, etc.)
|
|
40
|
+
*
|
|
41
|
+
* The resulting HarRequest object follows the HAR specification and includes:
|
|
42
|
+
* - HTTP method and URL
|
|
43
|
+
* - Headers and query parameters
|
|
44
|
+
* - Request body (if present)
|
|
45
|
+
* - Cookie information
|
|
46
|
+
* - Size calculations for headers and body
|
|
47
|
+
*
|
|
48
|
+
* @see https://w3c.github.io/web-performance/specs/HAR/Overview.html
|
|
49
|
+
* @see https://spec.openapis.org/oas/v3.1.0#operation-object
|
|
50
|
+
*/
|
|
51
|
+
export declare const operationToHar: ({ operation, contentType, method, path, server, example, securitySchemes, }: OperationToHarProps) => HarRequest;
|
|
52
|
+
//# sourceMappingURL=operation-to-har.d.ts.map
|
package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-to-har.d.ts","sourceRoot":"","sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,YAAY,EACb,MAAM,8DAA8D,CAAA;AACrE,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAOvD,MAAM,MAAM,mBAAmB,GAAG;IAChC,+BAA+B;IAC/B,SAAS,EAAE,eAAe,CAAA;IAC1B,mCAAmC;IACnC,MAAM,EAAE,UAAU,CAAA;IAClB,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,4BAA4B;IAC5B,MAAM,CAAC,EAAE,YAAY,GAAG,SAAS,CAAA;IACjC,2EAA2E;IAC3E,eAAe,CAAC,EAAE,oBAAoB,EAAE,CAAA;CACzC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc,GAAI,6EAQ5B,mBAAmB,KAAG,UA6ExB,CAAA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { getResolvedRef as y } from "@scalar/workspace-store/helpers/get-resolved-ref";
|
|
2
|
+
import { processBody as f } from "./process-body.js";
|
|
3
|
+
import { processParameters as l } from "./process-parameters.js";
|
|
4
|
+
import { processSecuritySchemes as S } from "./process-security-schemes.js";
|
|
5
|
+
import { processServerUrl as g } from "./process-server-url.js";
|
|
6
|
+
const b = ({
|
|
7
|
+
operation: t,
|
|
8
|
+
contentType: a,
|
|
9
|
+
method: h,
|
|
10
|
+
path: i,
|
|
11
|
+
server: n,
|
|
12
|
+
example: p,
|
|
13
|
+
securitySchemes: m
|
|
14
|
+
}) => {
|
|
15
|
+
const e = {
|
|
16
|
+
method: h,
|
|
17
|
+
url: i,
|
|
18
|
+
headers: [],
|
|
19
|
+
queryString: [],
|
|
20
|
+
postData: void 0,
|
|
21
|
+
httpVersion: "HTTP/1.1",
|
|
22
|
+
cookies: [],
|
|
23
|
+
headersSize: -1,
|
|
24
|
+
bodySize: -1
|
|
25
|
+
};
|
|
26
|
+
if (n?.url && (e.url = g(n, i)), t.parameters) {
|
|
27
|
+
const { url: r, headers: o, queryString: s, cookies: c } = l({
|
|
28
|
+
harRequest: e,
|
|
29
|
+
parameters: t.parameters,
|
|
30
|
+
example: p,
|
|
31
|
+
contentType: a
|
|
32
|
+
});
|
|
33
|
+
e.url = r, e.headers = o, e.queryString = s, e.cookies = c;
|
|
34
|
+
}
|
|
35
|
+
const u = y(t.requestBody);
|
|
36
|
+
if (u?.content) {
|
|
37
|
+
const r = f({ requestBody: u, contentType: a, example: p });
|
|
38
|
+
if (e.postData = r, e.bodySize = r.text?.length ?? -1, r.mimeType) {
|
|
39
|
+
const o = e.headers.find(
|
|
40
|
+
(s) => s.name.toLowerCase() === "content-type"
|
|
41
|
+
);
|
|
42
|
+
o && !o.value ? o.value = r.mimeType : e.headers.push({
|
|
43
|
+
name: "Content-Type",
|
|
44
|
+
value: r.mimeType
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (m) {
|
|
49
|
+
const { headers: r, queryString: o, cookies: s } = S(m);
|
|
50
|
+
e.headers.push(...r), e.queryString.push(...o), e.cookies.push(...s);
|
|
51
|
+
}
|
|
52
|
+
let d = 0;
|
|
53
|
+
for (const r of e.headers)
|
|
54
|
+
d += (r.name?.length ?? 0) + 2 + (r.value?.length ?? 0) + 2;
|
|
55
|
+
return e.headersSize = d, e;
|
|
56
|
+
};
|
|
57
|
+
export {
|
|
58
|
+
b as operationToHar
|
|
59
|
+
};
|
package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.test.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-to-har.test.d.ts","sourceRoot":"","sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/operation-to-har.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RequestBodyObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
|
|
2
|
+
import type { PostData } from 'har-format';
|
|
3
|
+
import type { OperationToHarProps } from './operation-to-har.js';
|
|
4
|
+
type ProcessBodyProps = Pick<OperationToHarProps, 'contentType' | 'example'> & {
|
|
5
|
+
requestBody: RequestBodyObject;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Processes the request body and returns the processed data
|
|
9
|
+
*/
|
|
10
|
+
export declare const processBody: ({ requestBody, contentType, example }: ProcessBodyProps) => PostData;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=process-body.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-body.d.ts","sourceRoot":"","sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8DAA8D,CAAA;AAErG,OAAO,KAAK,EAAS,QAAQ,EAAE,MAAM,YAAY,CAAA;AAGjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE7D,KAAK,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,EAAE,aAAa,GAAG,SAAS,CAAC,GAAG;IAC7E,WAAW,EAAE,iBAAiB,CAAA;CAC/B,CAAA;AAoCD;;GAEG;AACH,eAAO,MAAM,WAAW,GAAI,uCAAuC,gBAAgB,KAAG,QAoErF,CAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { json2xml as s } from "@scalar/helpers/file/json2xml";
|
|
2
|
+
import { getResolvedRef as c } from "@scalar/workspace-store/helpers/get-resolved-ref";
|
|
3
|
+
import { getExampleFromSchema as l } from "../get-example-from-schema.js";
|
|
4
|
+
import { getExampleValue as u } from "./get-example-value.js";
|
|
5
|
+
const p = (i) => {
|
|
6
|
+
const n = [];
|
|
7
|
+
for (const [a, e] of Object.entries(i))
|
|
8
|
+
if (e != null)
|
|
9
|
+
if (Array.isArray(e))
|
|
10
|
+
for (const m of e)
|
|
11
|
+
n.push({ name: a, value: String(m) });
|
|
12
|
+
else if (typeof e == "object") {
|
|
13
|
+
const m = p(e);
|
|
14
|
+
for (const r of m)
|
|
15
|
+
n.push({ name: `${a}.${r.name}`, value: r.value });
|
|
16
|
+
} else
|
|
17
|
+
n.push({ name: a, value: String(e) });
|
|
18
|
+
return n;
|
|
19
|
+
}, b = ({ requestBody: i, contentType: n, example: a }) => {
|
|
20
|
+
const e = n || Object.keys(i.content)[0] || "", m = e === "multipart/form-data" || e === "application/x-www-form-urlencoded", r = e === "application/xml", t = u(i, a, n);
|
|
21
|
+
if (typeof t < "u")
|
|
22
|
+
return m && typeof t == "object" && t !== null ? {
|
|
23
|
+
mimeType: e,
|
|
24
|
+
params: p(t)
|
|
25
|
+
} : r && typeof t == "object" && t !== null ? {
|
|
26
|
+
mimeType: e,
|
|
27
|
+
text: s(t)
|
|
28
|
+
} : {
|
|
29
|
+
mimeType: e,
|
|
30
|
+
text: JSON.stringify(t)
|
|
31
|
+
};
|
|
32
|
+
const f = c(i.content[e]?.schema);
|
|
33
|
+
if (typeof f < "u") {
|
|
34
|
+
const o = l(f, {
|
|
35
|
+
mode: "write",
|
|
36
|
+
xml: r
|
|
37
|
+
});
|
|
38
|
+
if (o !== void 0)
|
|
39
|
+
return m && typeof o == "object" && o !== null ? {
|
|
40
|
+
mimeType: e,
|
|
41
|
+
params: p(o)
|
|
42
|
+
} : r && typeof o == "object" && o !== null ? {
|
|
43
|
+
mimeType: e,
|
|
44
|
+
text: s(o)
|
|
45
|
+
} : {
|
|
46
|
+
mimeType: e,
|
|
47
|
+
text: JSON.stringify(o)
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
mimeType: e,
|
|
52
|
+
text: "null"
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
export {
|
|
56
|
+
b as processBody
|
|
57
|
+
};
|
package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.test.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-body.test.d.ts","sourceRoot":"","sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-body.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { OperationObject, ParameterObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
|
|
2
|
+
import type { Request as HarRequest } from 'har-format';
|
|
3
|
+
type ProcessedParameters = {
|
|
4
|
+
url: string;
|
|
5
|
+
headers: HarRequest['headers'];
|
|
6
|
+
queryString: HarRequest['queryString'];
|
|
7
|
+
cookies: HarRequest['cookies'];
|
|
8
|
+
};
|
|
9
|
+
/** Ensures we don't have any references in the parameters */
|
|
10
|
+
export declare const deReferenceParams: (params: OperationObject["parameters"]) => ParameterObject[];
|
|
11
|
+
/**
|
|
12
|
+
* Process OpenAPI parameters and return the updated properties.
|
|
13
|
+
* Handles path, query, and header parameters with various styles and explode options.
|
|
14
|
+
*
|
|
15
|
+
* @see https://spec.openapis.org/oas/latest.html#style-values
|
|
16
|
+
*/
|
|
17
|
+
export declare const processParameters: ({ harRequest, parameters, example, contentType, }: {
|
|
18
|
+
harRequest: HarRequest;
|
|
19
|
+
parameters: OperationObject["parameters"];
|
|
20
|
+
/** The name of the example to use */
|
|
21
|
+
example?: string | undefined;
|
|
22
|
+
contentType?: string | undefined;
|
|
23
|
+
}) => ProcessedParameters;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=process-parameters.d.ts.map
|
package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-parameters.d.ts","sourceRoot":"","sources":["../../../../../../src/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,8DAA8D,CAAA;AAEpH,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAIvD,KAAK,mBAAmB,GAAG;IACzB,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IAC9B,WAAW,EAAE,UAAU,CAAC,aAAa,CAAC,CAAA;IACtC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;CAC/B,CAAA;AAED,6DAA6D;AAC7D,eAAO,MAAM,iBAAiB,GAAI,QAAQ,eAAe,CAAC,YAAY,CAAC,KAAG,eAAe,EACnC,CAAA;AA0DtD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,mDAK/B;IACD,UAAU,EAAE,UAAU,CAAA;IACtB,UAAU,EAAE,eAAe,CAAC,YAAY,CAAC,CAAA;IACzC,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACjC,KAAG,mBAsNH,CAAA"}
|