@scalar/api-reference 1.43.4 → 1.43.7
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 +85 -0
- package/dist/blocks/scalar-client-selector-block/components/ClientDropdown.vue2.js +7 -7
- package/dist/blocks/scalar-client-selector-block/components/ClientSelector.vue2.js +5 -5
- package/dist/blocks/scalar-info-block/components/DownloadLink.vue.js +1 -1
- package/dist/blocks/scalar-info-block/components/DownloadLink.vue2.js +5 -5
- package/dist/blocks/scalar-info-block/components/InfoBlock.vue.js +11 -11
- package/dist/blocks/scalar-info-block/components/InfoDescription.vue2.js +2 -2
- package/dist/blocks/scalar-info-block/components/InfoLinks.vue.js +7 -7
- package/dist/blocks/scalar-info-block/components/InfoMarkdownSection.vue.js +2 -2
- package/dist/blocks/scalar-info-block/components/IntroductionCard.vue2.js +1 -1
- package/dist/blocks/scalar-info-block/components/IntroductionLayout.vue2.js +16 -16
- package/dist/blocks/scalar-info-block/components/OpenApiVersion.vue.js +2 -2
- package/dist/blocks/scalar-server-selector-block/components/Selector.vue.js +1 -1
- package/dist/blocks/scalar-server-selector-block/components/ServerSelector.vue.js +7 -7
- package/dist/browser/standalone.js +18486 -18113
- package/dist/browser/webpack-stats.json +1 -1
- package/dist/components/Anchor/WithBreadcrumb.vue.js +3 -3
- package/dist/components/ApiReference.vue.d.ts.map +1 -1
- package/dist/components/ApiReference.vue.js +1 -1
- package/dist/components/ApiReference.vue2.js +16 -11
- package/dist/components/Content/Auth/Auth.vue.js +7 -7
- package/dist/components/Content/Content.vue.js +28 -28
- package/dist/components/Content/Models/Model.vue.js +14 -14
- package/dist/components/Content/Models/ModelTag.vue.js +8 -8
- package/dist/components/Content/Models/components/ClassicLayout.vue2.js +15 -15
- package/dist/components/Content/Models/components/ModernLayout.vue.js +11 -11
- package/dist/components/Content/Operations/TraversedEntry.vue.js +51 -51
- package/dist/components/Content/Schema/Schema.vue2.js +40 -40
- package/dist/components/Content/Schema/SchemaComposition.vue.js +17 -17
- package/dist/components/Content/Schema/SchemaEnumPropertyItem.vue2.js +3 -3
- package/dist/components/Content/Schema/SchemaHeading.vue2.js +7 -7
- package/dist/components/Content/Schema/SchemaObjectProperties.vue.js +31 -31
- package/dist/components/Content/Schema/SchemaProperty.vue.d.ts +2 -2
- package/dist/components/Content/Schema/SchemaProperty.vue.d.ts.map +1 -1
- package/dist/components/Content/Schema/SchemaProperty.vue.js +1 -1
- package/dist/components/Content/Schema/SchemaProperty.vue2.js +88 -147
- package/dist/components/Content/Schema/SchemaPropertyDetail.vue2.js +2 -2
- package/dist/components/Content/Schema/SchemaPropertyExamples.vue2.js +6 -6
- package/dist/components/Content/Schema/helpers/get-compositions-to-render.d.ts +14 -0
- package/dist/components/Content/Schema/helpers/get-compositions-to-render.d.ts.map +1 -0
- package/dist/components/Content/Schema/helpers/get-compositions-to-render.js +31 -0
- package/dist/components/Content/Schema/helpers/get-enum-values.d.ts +9 -0
- package/dist/components/Content/Schema/helpers/get-enum-values.d.ts.map +1 -0
- package/dist/components/Content/Schema/helpers/get-enum-values.js +20 -0
- package/dist/components/Content/Schema/helpers/get-property-description.d.ts +9 -0
- package/dist/components/Content/Schema/helpers/get-property-description.d.ts.map +1 -0
- package/dist/components/Content/Schema/helpers/get-property-description.js +34 -0
- package/dist/components/Content/Schema/helpers/has-complex-array-items.d.ts +10 -0
- package/dist/components/Content/Schema/helpers/has-complex-array-items.d.ts.map +1 -0
- package/dist/components/Content/Schema/helpers/has-complex-array-items.js +48 -0
- package/dist/components/Content/Schema/helpers/should-display-description.d.ts +10 -0
- package/dist/components/Content/Schema/helpers/should-display-description.d.ts.map +1 -0
- package/dist/components/Content/Schema/helpers/should-display-description.js +12 -0
- package/dist/components/Content/Schema/helpers/should-display-heading.d.ts +11 -0
- package/dist/components/Content/Schema/helpers/should-display-heading.d.ts.map +1 -0
- package/dist/components/Content/Schema/helpers/should-display-heading.js +12 -0
- package/dist/components/Content/Schema/helpers/should-render-array-item-composition.d.ts +10 -0
- package/dist/components/Content/Schema/helpers/should-render-array-item-composition.d.ts.map +1 -0
- package/dist/components/Content/Schema/helpers/should-render-array-item-composition.js +15 -0
- package/dist/components/Content/Tags/Tag.vue.js +11 -11
- package/dist/components/Content/Tags/components/ClassicLayout.vue2.js +6 -6
- package/dist/components/Content/Tags/components/ModernLayout.vue2.js +10 -10
- package/dist/components/Content/Tags/components/TagSection.vue.js +14 -14
- package/dist/components/Content/index.d.ts +1 -0
- package/dist/components/Content/index.d.ts.map +1 -1
- package/dist/components/GettingStarted.vue2.js +1 -1
- package/dist/components/HttpMethod/HttpMethod.vue.js +3 -3
- package/dist/components/IntersectionObserver.vue.js +2 -2
- package/dist/components/LoadingSkeleton.vue2.js +2 -2
- package/dist/components/MobileHeader.vue.js +6 -6
- package/dist/components/OperationPath.vue2.js +1 -1
- package/dist/components/OperationsList/OperationsList.vue2.js +5 -5
- package/dist/components/OperationsList/OperationsListItem.vue2.js +8 -8
- package/dist/components/RenderPlugins/RenderPlugins.vue.js +2 -2
- package/dist/components/Section/CompactSection.vue2.js +9 -9
- package/dist/components/Section/SectionAccordion.vue2.js +5 -5
- package/dist/components/Section/SectionContainer.vue2.js +1 -1
- package/dist/components/Section/SectionContainerAccordion.vue2.js +3 -3
- package/dist/components/Section/SectionContent.vue2.js +1 -1
- package/dist/components/Section/SectionHeader.vue2.js +2 -2
- package/dist/components/Section/SectionHeaderTag.vue2.js +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +18 -16
- package/dist/features/Operation/Operation.vue.js +18 -18
- package/dist/features/Operation/components/Header.vue.js +8 -8
- package/dist/features/Operation/components/Headers.vue2.js +5 -5
- package/dist/features/Operation/components/OperationParameters.vue.js +17 -17
- package/dist/features/Operation/components/OperationResponses.vue.js +6 -6
- package/dist/features/Operation/components/ParameterList.vue.js +6 -6
- package/dist/features/Operation/components/ParameterListItem.vue2.js +16 -16
- package/dist/features/Operation/components/RequestBody.vue2.js +17 -17
- package/dist/features/Operation/components/callbacks/Callback.vue2.js +10 -10
- package/dist/features/Operation/components/callbacks/Callbacks.vue.js +3 -3
- package/dist/features/Operation/layouts/ClassicLayout.vue2.js +49 -49
- package/dist/features/Operation/layouts/ModernLayout.vue2.js +50 -50
- package/dist/features/Search/components/SearchButton.vue.js +5 -5
- package/dist/features/Search/components/SearchModal.vue2.js +1 -1
- package/dist/features/Search/components/SearchResult.vue.js +14 -14
- package/dist/features/example-responses/ExampleResponse.vue2.js +3 -3
- package/dist/features/external-docs/ExternalDocs.vue.js +3 -3
- package/dist/features/info-object/Contact.vue.js +6 -6
- package/dist/features/info-object/License.vue.js +4 -4
- package/dist/features/info-object/TermsOfService.vue.js +2 -2
- package/dist/features/multiple-documents/DocumentSelector.vue.js +1 -1
- package/dist/features/specification-extension/SpecificationExtension.vue2.js +3 -3
- package/dist/features/test-request-button/TestRequestButton.vue2.js +2 -2
- package/dist/features/toolbar/ApiReferenceToolbar.vue.js +4 -4
- package/dist/features/toolbar/ApiReferenceToolbarConfig.vue.js +1 -1
- package/dist/features/toolbar/ApiReferenceToolbarSdks.vue.js +1 -1
- package/dist/features/toolbar/ApiReferenceToolbarShare.vue.js +2 -2
- package/dist/features/toolbar/ApiReferenceToolbarShareRegister.vue.js +1 -1
- package/dist/helpers/id-routing.d.ts.map +1 -1
- package/dist/helpers/id-routing.js +7 -1
- package/dist/helpers/load-from-perssistance.d.ts +32 -0
- package/dist/helpers/load-from-perssistance.d.ts.map +1 -0
- package/dist/helpers/load-from-perssistance.js +74 -0
- package/dist/helpers/map-config-plugins.d.ts +17 -2
- package/dist/helpers/map-config-plugins.d.ts.map +1 -1
- package/dist/helpers/map-config-plugins.js +20 -22
- package/dist/helpers/map-config-to-workspace-store.d.ts.map +1 -1
- package/dist/helpers/map-config-to-workspace-store.js +1 -8
- package/dist/helpers/storage.d.ts +6 -6
- package/dist/helpers/storage.d.ts.map +1 -1
- package/dist/helpers/storage.js +15 -10
- package/dist/plugins/hooks/usePluginManager.js +1 -1
- package/dist/style.css +133 -116
- package/package.json +31 -31
|
@@ -12,10 +12,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
12
12
|
},
|
|
13
13
|
setup(__props) {
|
|
14
14
|
return (_ctx, _cache) => {
|
|
15
|
-
return
|
|
15
|
+
return __props.value ? (openBlock(), createElementBlock("div", _hoisted_1, [
|
|
16
16
|
createElementVNode("a", {
|
|
17
17
|
class: "text-c-1 hover:bg-b-2 mr-2 flex min-h-7 min-w-7 items-center rounded-lg border px-2 py-1 no-underline group-last:mr-0 xl:border-none",
|
|
18
|
-
href:
|
|
18
|
+
href: __props.value,
|
|
19
19
|
target: "_blank",
|
|
20
20
|
rel: "noopener noreferrer"
|
|
21
21
|
}, [
|
|
@@ -27,7 +27,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
27
27
|
() => formattedOptions.value.find((o) => o.id === props.modelValue)
|
|
28
28
|
);
|
|
29
29
|
return (_ctx, _cache) => {
|
|
30
|
-
return
|
|
30
|
+
return __props.options.length > 1 ? (openBlock(), createElementBlock("div", _hoisted_1, [
|
|
31
31
|
createVNode(unref(ScalarListbox), {
|
|
32
32
|
modelValue: selected.value,
|
|
33
33
|
options: formattedOptions.value,
|
|
@@ -25,7 +25,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
25
25
|
() => getCustomOpenApiExtensionComponents(customExtensionNames.value)
|
|
26
26
|
);
|
|
27
27
|
return (_ctx, _cache) => {
|
|
28
|
-
return typeof
|
|
28
|
+
return typeof __props.value === "object" && customExtensions.value.length ? (openBlock(), createElementBlock("div", _hoisted_1, [
|
|
29
29
|
(openBlock(true), createElementBlock(Fragment, null, renderList(customExtensions.value, (extension) => {
|
|
30
30
|
return openBlock(), createBlock(unref(ScalarErrorBoundary), null, {
|
|
31
31
|
default: withCtx(() => [
|
|
@@ -33,12 +33,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
33
33
|
key: 0,
|
|
34
34
|
ref_for: true
|
|
35
35
|
}, {
|
|
36
|
-
[extension.name]:
|
|
36
|
+
[extension.name]: __props.value?.[extension.name],
|
|
37
37
|
component: extension.component
|
|
38
38
|
}), null, 16)) : (openBlock(), createBlock(resolveDynamicComponent(extension.component), mergeProps({
|
|
39
39
|
key: 1,
|
|
40
40
|
ref_for: true
|
|
41
|
-
}, { [extension.name]:
|
|
41
|
+
}, { [extension.name]: __props.value?.[extension.name] }), null, 16))
|
|
42
42
|
]),
|
|
43
43
|
_: 2
|
|
44
44
|
}, 1024);
|
|
@@ -15,7 +15,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
15
15
|
return (_ctx, _cache) => {
|
|
16
16
|
return openBlock(), createElementBlock("button", {
|
|
17
17
|
class: "show-api-client-button",
|
|
18
|
-
method:
|
|
18
|
+
method: __props.method,
|
|
19
19
|
type: "button",
|
|
20
20
|
onClick: withModifiers(handleClick, ["stop"])
|
|
21
21
|
}, [
|
|
@@ -26,7 +26,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
26
26
|
_cache[0] || (_cache[0] = createElementVNode("span", null, "Test Request", -1)),
|
|
27
27
|
createVNode(ScreenReader, null, {
|
|
28
28
|
default: withCtx(() => [
|
|
29
|
-
createTextVNode("(" + toDisplayString(
|
|
29
|
+
createTextVNode("(" + toDisplayString(__props.method) + " " + toDisplayString(__props.path) + ")", 1)
|
|
30
30
|
]),
|
|
31
31
|
_: 1
|
|
32
32
|
})
|
|
@@ -41,14 +41,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
41
41
|
createElementVNode("div", _hoisted_3, [
|
|
42
42
|
createVNode(_sfc_main$1)
|
|
43
43
|
]),
|
|
44
|
-
|
|
45
|
-
createVNode(_sfc_main$2, { workspace:
|
|
46
|
-
createVNode(_sfc_main$3, { workspace:
|
|
44
|
+
__props.workspace ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
45
|
+
createVNode(_sfc_main$2, { workspace: __props.workspace }, null, 8, ["workspace"]),
|
|
46
|
+
createVNode(_sfc_main$3, { workspace: __props.workspace }, null, 8, ["workspace"])
|
|
47
47
|
], 64)) : createCommentVNode("", true),
|
|
48
48
|
createVNode(_sfc_main$4, {
|
|
49
49
|
overrides: overrides.value,
|
|
50
50
|
"onUpdate:overrides": _cache[0] || (_cache[0] = ($event) => overrides.value = $event),
|
|
51
|
-
configuration:
|
|
51
|
+
configuration: __props.configuration
|
|
52
52
|
}, null, 8, ["overrides", "configuration"])
|
|
53
53
|
])
|
|
54
54
|
])) : createCommentVNode("", true);
|
|
@@ -86,7 +86,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
86
86
|
createVNode(_sfc_main$4, {
|
|
87
87
|
modelValue: overrides.value,
|
|
88
88
|
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => overrides.value = $event),
|
|
89
|
-
configuration:
|
|
89
|
+
configuration: __props.configuration
|
|
90
90
|
}, null, 8, ["modelValue", "configuration"])
|
|
91
91
|
]),
|
|
92
92
|
_: 1
|
|
@@ -62,7 +62,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
62
62
|
}),
|
|
63
63
|
createVNode(_sfc_main$2, {
|
|
64
64
|
sdks: selectedLanguages.value,
|
|
65
|
-
workspace:
|
|
65
|
+
workspace: __props.workspace
|
|
66
66
|
}, null, 8, ["sdks", "workspace"]),
|
|
67
67
|
createVNode(ApiReferenceToolbarBlurb, null, {
|
|
68
68
|
default: withCtx(() => [..._cache[2] || (_cache[2] = [
|
|
@@ -20,7 +20,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
20
20
|
createTextVNode("Temporary Link", -1)
|
|
21
21
|
])]),
|
|
22
22
|
default: withCtx(() => [
|
|
23
|
-
createVNode(_sfc_main$2, { workspace:
|
|
23
|
+
createVNode(_sfc_main$2, { workspace: __props.workspace }, null, 8, ["workspace"])
|
|
24
24
|
]),
|
|
25
25
|
_: 1
|
|
26
26
|
}),
|
|
@@ -29,7 +29,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
29
29
|
createTextVNode("Cloud Hosting", -1)
|
|
30
30
|
])]),
|
|
31
31
|
default: withCtx(() => [
|
|
32
|
-
createVNode(_sfc_main$3, { workspace:
|
|
32
|
+
createVNode(_sfc_main$3, { workspace: __props.workspace }, null, 8, ["workspace"])
|
|
33
33
|
]),
|
|
34
34
|
_: 1
|
|
35
35
|
})
|
|
@@ -33,7 +33,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
33
33
|
]);
|
|
34
34
|
}), 64))
|
|
35
35
|
]),
|
|
36
|
-
createVNode(_sfc_main$1, { workspace:
|
|
36
|
+
createVNode(_sfc_main$1, { workspace: __props.workspace }, {
|
|
37
37
|
default: withCtx(() => [..._cache[0] || (_cache[0] = [
|
|
38
38
|
createTextVNode(" Deploy on Scalar ", -1)
|
|
39
39
|
])]),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"id-routing.d.ts","sourceRoot":"","sources":["../../src/helpers/id-routing.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,GAAI,UAAU,MAAM,WAEhD,CAAA;AAED,mEAAmE;AACnE,eAAO,MAAM,aAAa,GAAI,UAAU,MAAM,GAAG,GAAG,EAAE,YAAY,MAAM,GAAG,SAAS,WAMnF,CAAA;AACD,mEAAmE;AACnE,eAAO,MAAM,aAAa,GAAI,UAAU,MAAM,GAAG,GAAG,EAAE,UAAU,MAAM,EAAE,YAAY,MAAM,GAAG,SAAS,WAqBrG,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GAAI,KAAK,MAAM,GAAG,GAAG,EAAE,UAAU,MAAM,GAAG,SAAS,EAAE,YAAY,MAAM,GAAG,SAAS,WAE3G,CAAA;
|
|
1
|
+
{"version":3,"file":"id-routing.d.ts","sourceRoot":"","sources":["../../src/helpers/id-routing.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,GAAI,UAAU,MAAM,WAEhD,CAAA;AAED,mEAAmE;AACnE,eAAO,MAAM,aAAa,GAAI,UAAU,MAAM,GAAG,GAAG,EAAE,YAAY,MAAM,GAAG,SAAS,WAMnF,CAAA;AACD,mEAAmE;AACnE,eAAO,MAAM,aAAa,GAAI,UAAU,MAAM,GAAG,GAAG,EAAE,UAAU,MAAM,EAAE,YAAY,MAAM,GAAG,SAAS,WAqBrG,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GAAI,KAAK,MAAM,GAAG,GAAG,EAAE,UAAU,MAAM,GAAG,SAAS,EAAE,YAAY,MAAM,GAAG,SAAS,WAE3G,CAAA;AAmBD;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM,EAAE,UAAU,MAAM,GAAG,SAAS,EAAE,iBAAiB,OAAO,oBAiBhG,CAAA;AAED,qEAAqE;AACrE,eAAO,MAAM,qBAAqB,GAAI,IAAI,MAAM,KAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAajF,CAAA"}
|
|
@@ -20,11 +20,17 @@ const getIdFromPath = (location, basePath, slugPrefix) => {
|
|
|
20
20
|
const getIdFromUrl = (url, basePath, slugPrefix) => {
|
|
21
21
|
return typeof basePath === "string" ? getIdFromPath(url, basePath, slugPrefix) : getIdFromHash(url, slugPrefix);
|
|
22
22
|
};
|
|
23
|
+
const stripFirstSegment = (id) => {
|
|
24
|
+
const hasTrailingSlash = id.endsWith("/");
|
|
25
|
+
const segments = id.split("/").filter(Boolean).slice(1);
|
|
26
|
+
const result = segments.join("/");
|
|
27
|
+
return hasTrailingSlash && result ? `${result}/` : result;
|
|
28
|
+
};
|
|
23
29
|
const makeUrlFromId = (_id, basePath, isMultiDocument) => {
|
|
24
30
|
if (typeof window === "undefined") {
|
|
25
31
|
return void 0;
|
|
26
32
|
}
|
|
27
|
-
const id = isMultiDocument ? _id : _id
|
|
33
|
+
const id = isMultiDocument ? _id : stripFirstSegment(_id);
|
|
28
34
|
const url = new URL(window.location.href);
|
|
29
35
|
if (typeof basePath === "string") {
|
|
30
36
|
const base = sanitizeBasePath(basePath);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { WorkspaceStore } from '@scalar/workspace-store/client';
|
|
2
|
+
/**
|
|
3
|
+
* Loads the default HTTP client from storage and applies it to the workspace.
|
|
4
|
+
* Only updates if no default client is already set.
|
|
5
|
+
*/
|
|
6
|
+
export declare const loadClientFromStorage: (store: WorkspaceStore) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Checks if a key is a Scalar secret key.
|
|
9
|
+
* Secret keys start with 'x-scalar-secret-' prefix.
|
|
10
|
+
*/
|
|
11
|
+
export declare const isSecretKey: (key: string) => boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Recursively merges secret values from stored data into the current schema.
|
|
14
|
+
* Only merges secrets if the corresponding structure exists in the current schema.
|
|
15
|
+
*
|
|
16
|
+
* This function walks through both objects in parallel, copying any keys that
|
|
17
|
+
* start with 'x-scalar-secret-' from the stored object to the current object,
|
|
18
|
+
* but only if the path exists in the current schema.
|
|
19
|
+
*
|
|
20
|
+
* @param current - The current schema object (source of truth for structure)
|
|
21
|
+
* @param stored - The stored object containing secret values to restore
|
|
22
|
+
*/
|
|
23
|
+
export declare const mergeSecrets: (current: unknown, stored: unknown) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Loads authentication schemes and selected security settings from local storage.
|
|
26
|
+
*
|
|
27
|
+
* This function restores both the available security schemes and the user's
|
|
28
|
+
* selected security configuration for the active document. It validates that
|
|
29
|
+
* the stored schemes still exist in the current document before restoring them.
|
|
30
|
+
*/
|
|
31
|
+
export declare const loadAuthSchemesFromStorage: (store: WorkspaceStore) => void;
|
|
32
|
+
//# sourceMappingURL=load-from-perssistance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-from-perssistance.d.ts","sourceRoot":"","sources":["../../src/helpers/load-from-perssistance.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAYpE;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAAI,OAAO,cAAc,KAAG,IAM7D,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,KAAG,OAA4C,CAAA;AAEtF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,OAAO,EAAE,QAAQ,OAAO,KAAG,IAgBhE,CAAA;AA4CD;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,GAAI,OAAO,cAAc,KAAG,IAkClE,CAAA"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { isClient } from "@scalar/api-client/v2/blocks/operation-code-sample";
|
|
2
|
+
import { isObject } from "@scalar/helpers/object/is-object";
|
|
3
|
+
import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref";
|
|
4
|
+
import { clientStorage, authStorage } from "./storage.js";
|
|
5
|
+
const SECRET_KEY_PREFIX = "x-scalar-secret-";
|
|
6
|
+
const loadClientFromStorage = (store) => {
|
|
7
|
+
const storedClient = clientStorage().get();
|
|
8
|
+
if (isClient(storedClient) && !store.workspace["x-scalar-default-client"]) {
|
|
9
|
+
store.update("x-scalar-default-client", storedClient);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
const isSecretKey = (key) => key.startsWith(SECRET_KEY_PREFIX);
|
|
13
|
+
const mergeSecrets = (current, stored) => {
|
|
14
|
+
if (!isObject(current) || !isObject(stored)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
for (const [key, storedValue] of Object.entries(stored)) {
|
|
18
|
+
if (isSecretKey(key) && storedValue && current[key] === "") {
|
|
19
|
+
current[key] = storedValue;
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
mergeSecrets(getResolvedRef(current[key]), storedValue);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const restoreAuthSecretsFromStorage = (store) => {
|
|
26
|
+
const slug = store.workspace["x-scalar-active-document"];
|
|
27
|
+
const activeDocument = store.workspace.activeDocument;
|
|
28
|
+
if (!activeDocument || !slug) {
|
|
29
|
+
console.warn("Active document not found in workspace, skipping auth secrets loading");
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const securitySchemes = activeDocument.components?.securitySchemes ?? {};
|
|
33
|
+
const storedAuthSchemes = authStorage().getSchemas(slug);
|
|
34
|
+
for (const [key, storedScheme] of Object.entries(storedAuthSchemes)) {
|
|
35
|
+
const currentScheme = getResolvedRef(securitySchemes[key]);
|
|
36
|
+
if (isObject(currentScheme)) {
|
|
37
|
+
mergeSecrets(currentScheme, storedScheme);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const isSchemeValid = (scheme, availableSchemes) => Object.keys(scheme).every((key) => availableSchemes.has(key));
|
|
42
|
+
const clampSelectedIndex = (selectedIndex, schemesLength) => selectedIndex >= schemesLength ? schemesLength - 1 : selectedIndex;
|
|
43
|
+
const loadAuthSchemesFromStorage = (store) => {
|
|
44
|
+
const slug = store.workspace["x-scalar-active-document"];
|
|
45
|
+
const activeDocument = store.workspace.activeDocument;
|
|
46
|
+
if (!activeDocument || !slug) {
|
|
47
|
+
console.warn("Active document not found in workspace, skipping auth schemes loading");
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (activeDocument["x-scalar-selected-security"]) {
|
|
51
|
+
restoreAuthSecretsFromStorage(store);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const authPersistence = authStorage();
|
|
55
|
+
const storedSelectedAuthSchemes = authPersistence.getSelectedSchemes(slug);
|
|
56
|
+
const availableSchemes = new Set(Object.keys(activeDocument.components?.securitySchemes ?? {}));
|
|
57
|
+
const selectedSchemes = storedSelectedAuthSchemes["x-scalar-selected-security"]?.selectedSchemes;
|
|
58
|
+
const validSchemes = selectedSchemes?.filter((scheme) => isSchemeValid(scheme, availableSchemes));
|
|
59
|
+
if (validSchemes && validSchemes.length > 0) {
|
|
60
|
+
const selectedIndex = storedSelectedAuthSchemes["x-scalar-selected-security"]?.selectedIndex ?? 0;
|
|
61
|
+
const clampedIndex = clampSelectedIndex(selectedIndex, validSchemes.length);
|
|
62
|
+
activeDocument["x-scalar-selected-security"] = {
|
|
63
|
+
selectedIndex: clampedIndex,
|
|
64
|
+
selectedSchemes: validSchemes
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
restoreAuthSecretsFromStorage(store);
|
|
68
|
+
};
|
|
69
|
+
export {
|
|
70
|
+
isSecretKey,
|
|
71
|
+
loadAuthSchemesFromStorage,
|
|
72
|
+
loadClientFromStorage,
|
|
73
|
+
mergeSecrets
|
|
74
|
+
};
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import type { ClientPlugin } from '@scalar/api-client/v2/helpers';
|
|
2
2
|
import type { ApiReferenceConfigurationRaw } from '@scalar/types/api-reference';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { type ComputedRef } from 'vue';
|
|
4
|
+
/**
|
|
5
|
+
* Maps API reference configuration callbacks to client plugins.
|
|
6
|
+
*
|
|
7
|
+
* This function transforms the legacy onBeforeRequest and onRequestSent callbacks
|
|
8
|
+
* into the new plugin hook system. The mapping is reactive, so changes to the
|
|
9
|
+
* configuration will automatically update the plugin hooks.
|
|
10
|
+
*
|
|
11
|
+
* Note: onRequestSent is mapped to responseReceived hook. This is not a perfect
|
|
12
|
+
* one-to-one mapping, but it maintains backward compatibility with the old API.
|
|
13
|
+
* The old callback receives only the URL string, while the new hook receives
|
|
14
|
+
* the full response object.
|
|
15
|
+
*
|
|
16
|
+
* @param config - Reactive configuration object containing optional hook callbacks
|
|
17
|
+
* @returns Array containing a single plugin with the mapped hooks
|
|
18
|
+
*/
|
|
19
|
+
export declare const mapConfigPlugins: (config: ComputedRef<ApiReferenceConfigurationRaw>) => ClientPlugin[];
|
|
5
20
|
//# sourceMappingURL=map-config-plugins.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-config-plugins.d.ts","sourceRoot":"","sources":["../../src/helpers/map-config-plugins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"map-config-plugins.d.ts","sourceRoot":"","sources":["../../src/helpers/map-config-plugins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAA;AAC/E,OAAO,EAAE,KAAK,WAAW,EAAS,MAAM,KAAK,CAAA;AAE7C;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,WAAW,CAAC,4BAA4B,CAAC,KAAG,YAAY,EAwChG,CAAA"}
|
|
@@ -1,28 +1,26 @@
|
|
|
1
|
+
import { watch } from "vue";
|
|
1
2
|
const mapConfigPlugins = (config) => {
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (result) {
|
|
9
|
-
return result;
|
|
10
|
-
}
|
|
11
|
-
return payload;
|
|
12
|
-
}
|
|
3
|
+
const plugin = { hooks: {} };
|
|
4
|
+
watch(
|
|
5
|
+
[() => config.value.onBeforeRequest, () => config.value.onRequestSent],
|
|
6
|
+
([onBeforeRequest, onRequestSent]) => {
|
|
7
|
+
if (!plugin.hooks) {
|
|
8
|
+
plugin.hooks = {};
|
|
13
9
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
hooks: {
|
|
19
|
-
responseReceived: (payload) => {
|
|
20
|
-
config.onRequestSent?.(payload.request.url);
|
|
10
|
+
plugin.hooks.beforeRequest = onBeforeRequest ? async (payload) => {
|
|
11
|
+
const result = await onBeforeRequest(payload);
|
|
12
|
+
if (result === void 0) {
|
|
13
|
+
return payload;
|
|
21
14
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
return result;
|
|
16
|
+
} : void 0;
|
|
17
|
+
plugin.hooks.responseReceived = onRequestSent ? (payload) => {
|
|
18
|
+
onRequestSent(payload.request.url);
|
|
19
|
+
} : void 0;
|
|
20
|
+
},
|
|
21
|
+
{ immediate: true }
|
|
22
|
+
);
|
|
23
|
+
return [plugin];
|
|
26
24
|
};
|
|
27
25
|
export {
|
|
28
26
|
mapConfigPlugins
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-config-to-workspace-store.d.ts","sourceRoot":"","sources":["../../src/helpers/map-config-to-workspace-store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"map-config-to-workspace-store.d.ts","sourceRoot":"","sources":["../../src/helpers/map-config-to-workspace-store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAA;AAC/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAGpE,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,GAAG,EAA4B,MAAM,KAAK,CAAA;AAE/E,eAAO,MAAM,yBAAyB,GAAI,gCAIvC;IACD,MAAM,EAAE,gBAAgB,CAAC,4BAA4B,CAAC,CAAA;IACtD,KAAK,EAAE,cAAc,CAAA;IACrB,UAAU,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;CACzB,SA2CA,CAAA"}
|
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
import { isClient } from "@scalar/api-client/v2/blocks/operation-code-sample";
|
|
2
|
-
import { safeLocalStorage, REFERENCE_LS_KEYS } from "@scalar/helpers/object/local-storage";
|
|
3
2
|
import { useSeoMeta } from "@unhead/vue";
|
|
4
3
|
import { useFavicon } from "@vueuse/core";
|
|
5
|
-
import {
|
|
4
|
+
import { watch, toValue, computed } from "vue";
|
|
6
5
|
const mapConfigToWorkspaceStore = ({
|
|
7
6
|
config,
|
|
8
7
|
store,
|
|
9
8
|
isDarkMode
|
|
10
9
|
}) => {
|
|
11
|
-
onBeforeMount(() => {
|
|
12
|
-
const storedClient = safeLocalStorage().getItem(REFERENCE_LS_KEYS.SELECTED_CLIENT);
|
|
13
|
-
if (isClient(storedClient) && !store.workspace["x-scalar-default-client"]) {
|
|
14
|
-
store.update("x-scalar-default-client", storedClient);
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
10
|
watch(
|
|
18
11
|
() => toValue(config).defaultHttpClient,
|
|
19
12
|
(newValue) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { XScalarSelectedSecurity } from '@scalar/workspace-store/schemas/extensions/security/x-scalar-selected-security';
|
|
2
2
|
import { type SecuritySchemes } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
|
|
3
3
|
/**
|
|
4
4
|
* Provides an interface to store and retrieve the selected client value
|
|
@@ -24,7 +24,7 @@ export declare const authStorage: () => {
|
|
|
24
24
|
/**
|
|
25
25
|
* Retrieves and coerces the authentication schemes stored in local storage.
|
|
26
26
|
*/
|
|
27
|
-
getSchemas: () => {
|
|
27
|
+
getSchemas: (slug: string) => {
|
|
28
28
|
[x: string]: ({
|
|
29
29
|
description?: string | undefined;
|
|
30
30
|
} & {
|
|
@@ -324,20 +324,20 @@ export declare const authStorage: () => {
|
|
|
324
324
|
* Stores the authentication schemes in local storage.
|
|
325
325
|
* @param value The SecuritySchemes object to stringify and store.
|
|
326
326
|
*/
|
|
327
|
-
setSchemas: (
|
|
327
|
+
setSchemas: (slug: string, value: SecuritySchemes) => void;
|
|
328
328
|
/**
|
|
329
329
|
* Retrieves and coerces the selected authentication schemes stored in local storage.
|
|
330
330
|
*/
|
|
331
|
-
getSelectedSchemes: () => {
|
|
331
|
+
getSelectedSchemes: (slug: string) => {
|
|
332
332
|
'x-scalar-selected-security'?: {
|
|
333
333
|
selectedIndex: number;
|
|
334
|
-
selectedSchemes:
|
|
334
|
+
selectedSchemes: {}[];
|
|
335
335
|
} | undefined;
|
|
336
336
|
};
|
|
337
337
|
/**
|
|
338
338
|
* Stores the user's selected authentication schemes in local storage.
|
|
339
339
|
* @param value The XScalarSelectedSecurity object to stringify and store.
|
|
340
340
|
*/
|
|
341
|
-
setSelectedSchemes: (
|
|
341
|
+
setSelectedSchemes: (slug: string, value: XScalarSelectedSecurity) => void;
|
|
342
342
|
};
|
|
343
343
|
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/helpers/storage.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/helpers/storage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gFAAgF,CAAA;AAE7H,OAAO,EACL,KAAK,eAAe,EAGrB,MAAM,8DAA8D,CAAA;AAKrE;;;GAGG;AACH,eAAO,MAAM,aAAa;IAGtB;;OAEG;;IAIH;;;OAGG;iBACU,MAAM;CAItB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,WAAW;IAYpB;;OAEG;uBACgB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAIzB;;;OAGG;uBACgB,MAAM,SAAS,eAAe;IAGjD;;OAEG;+BACwB,MAAM;;;;;;IAIjC;;;OAGG;+BACwB,MAAM,SAAS,uBAAuB;CAIpE,CAAA"}
|
package/dist/helpers/storage.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { REFERENCE_LS_KEYS, safeLocalStorage } from "@scalar/helpers/object/local-storage";
|
|
2
|
-
import { XScalarSelectedSecuritySchema } from "@scalar/workspace-store/schemas/extensions/security/x-scalar-selected-security";
|
|
3
2
|
import { coerceValue } from "@scalar/workspace-store/schemas/typebox-coerce";
|
|
4
|
-
import { SecuritySchemesSchema } from "@scalar/workspace-store/schemas/v3.1/strict/openapi-document";
|
|
3
|
+
import { XScalarSelectedSecuritySchema, SecuritySchemesSchema } from "@scalar/workspace-store/schemas/v3.1/strict/openapi-document";
|
|
5
4
|
const storage = safeLocalStorage();
|
|
6
5
|
const clientStorage = () => {
|
|
7
6
|
const key = REFERENCE_LS_KEYS.SELECTED_CLIENT;
|
|
@@ -24,34 +23,40 @@ const clientStorage = () => {
|
|
|
24
23
|
const authStorage = () => {
|
|
25
24
|
const schemasKey = REFERENCE_LS_KEYS.AUTH_SCHEMES;
|
|
26
25
|
const selectedSchemesKey = REFERENCE_LS_KEYS.SELECTED_AUTH_SCHEMES;
|
|
26
|
+
const getAuthId = (type, prefix) => {
|
|
27
|
+
const getKey = (type2) => {
|
|
28
|
+
return type2 === "schemas" ? schemasKey : selectedSchemesKey;
|
|
29
|
+
};
|
|
30
|
+
return `${prefix}-${getKey(type)}`;
|
|
31
|
+
};
|
|
27
32
|
return {
|
|
28
33
|
/**
|
|
29
34
|
* Retrieves and coerces the authentication schemes stored in local storage.
|
|
30
35
|
*/
|
|
31
|
-
getSchemas: () => {
|
|
32
|
-
const parsed = JSON.parse(storage.getItem(
|
|
36
|
+
getSchemas: (slug) => {
|
|
37
|
+
const parsed = JSON.parse(storage.getItem(getAuthId("schemas", slug)) ?? "{}");
|
|
33
38
|
return coerceValue(SecuritySchemesSchema, parsed);
|
|
34
39
|
},
|
|
35
40
|
/**
|
|
36
41
|
* Stores the authentication schemes in local storage.
|
|
37
42
|
* @param value The SecuritySchemes object to stringify and store.
|
|
38
43
|
*/
|
|
39
|
-
setSchemas: (
|
|
40
|
-
storage.setItem(
|
|
44
|
+
setSchemas: (slug, value) => {
|
|
45
|
+
storage.setItem(getAuthId("schemas", slug), JSON.stringify(value));
|
|
41
46
|
},
|
|
42
47
|
/**
|
|
43
48
|
* Retrieves and coerces the selected authentication schemes stored in local storage.
|
|
44
49
|
*/
|
|
45
|
-
getSelectedSchemes: () => {
|
|
46
|
-
const parsed = JSON.parse(storage.getItem(
|
|
50
|
+
getSelectedSchemes: (slug) => {
|
|
51
|
+
const parsed = JSON.parse(storage.getItem(getAuthId("selectedSchemes", slug)) ?? "{}");
|
|
47
52
|
return coerceValue(XScalarSelectedSecuritySchema, parsed);
|
|
48
53
|
},
|
|
49
54
|
/**
|
|
50
55
|
* Stores the user's selected authentication schemes in local storage.
|
|
51
56
|
* @param value The XScalarSelectedSecurity object to stringify and store.
|
|
52
57
|
*/
|
|
53
|
-
setSelectedSchemes: (
|
|
54
|
-
storage.setItem(
|
|
58
|
+
setSelectedSchemes: (slug, value) => {
|
|
59
|
+
storage.setItem(getAuthId("selectedSchemes", slug), JSON.stringify(value));
|
|
55
60
|
}
|
|
56
61
|
};
|
|
57
62
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createPluginManager } from "../plugin-manager.js";
|
|
2
2
|
import { inject } from "vue";
|
|
3
|
-
const PLUGIN_MANAGER_SYMBOL = Symbol();
|
|
3
|
+
const PLUGIN_MANAGER_SYMBOL = /* @__PURE__ */ Symbol();
|
|
4
4
|
const usePluginManager = () => {
|
|
5
5
|
const manager = inject(PLUGIN_MANAGER_SYMBOL);
|
|
6
6
|
if (!manager) {
|