@scalar/api-client 2.23.3 → 2.23.4

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.
@@ -1,7 +1,7 @@
1
1
  import { canMethodHaveBody as p } from "@scalar/helpers/http/can-method-have-body";
2
2
  import { getResolvedRef as n } from "@scalar/workspace-store/helpers/get-resolved-ref";
3
3
  import { isElectron as u } from "../../../../libs/electron.js";
4
- const i = "2.23.3", m = "application/json", h = "*/*", c = (r, t, o) => ({
4
+ const i = "2.23.4", m = "application/json", h = "*/*", c = (r, t, o) => ({
5
5
  name: r,
6
6
  defaultValue: t,
7
7
  isOverridden: o.has(r.toLowerCase())
@@ -1,6 +1,10 @@
1
+ import type { SecurityScheme } from '@scalar/types/entities';
1
2
  import type { AuthStore } from '@scalar/workspace-store/entities/auth';
3
+ import type { DeepPartial } from '@scalar/workspace-store/helpers/overrides-proxy';
2
4
  import type { SecuritySchemeObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
3
5
  import type { SecuritySchemeObjectSecret } from './secret-types';
6
+ /** A combined scheme that includes both the auth store secrets and a deep partial of the config auth */
7
+ export type ConfigAuthScheme = SecuritySchemeObject & DeepPartial<SecurityScheme>;
4
8
  /** Extract the secrets from the config and the auth store */
5
- export declare const extractSecuritySchemeSecrets: (scheme: SecuritySchemeObject, authStore: AuthStore, name: string, documentSlug: string) => SecuritySchemeObjectSecret;
9
+ export declare const extractSecuritySchemeSecrets: (scheme: SecuritySchemeObject & DeepPartial<SecurityScheme>, authStore: AuthStore, name: string, documentSlug: string) => SecuritySchemeObjectSecret;
6
10
  //# sourceMappingURL=extract-security-scheme-secrets.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"extract-security-scheme-secrets.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/scalar-auth-selector-block/helpers/extract-security-scheme-secrets.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,uCAAuC,CAAA;AAOnF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8DAA8D,CAAA;AAExG,OAAO,KAAK,EAUV,0BAA0B,EAC3B,MAAM,gBAAgB,CAAA;AA+CvB,6DAA6D;AAC7D,eAAO,MAAM,4BAA4B,GAEvC,QAAQ,oBAAoB,EAC5B,WAAW,SAAS,EACpB,MAAM,MAAM,EACZ,cAAc,MAAM,KACnB,0BA0GF,CAAA"}
1
+ {"version":3,"file":"extract-security-scheme-secrets.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/scalar-auth-selector-block/helpers/extract-security-scheme-secrets.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAA;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iDAAiD,CAAA;AAOlF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8DAA8D,CAAA;AAExG,OAAO,KAAK,EAUV,0BAA0B,EAC3B,MAAM,gBAAgB,CAAA;AAEvB,wGAAwG;AACxG,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,GAAG,WAAW,CAAC,cAAc,CAAC,CAAA;AAoCjF,6DAA6D;AAC7D,eAAO,MAAM,4BAA4B,GAEvC,QAAQ,oBAAoB,GAAG,WAAW,CAAC,cAAc,CAAC,EAC1D,WAAW,SAAS,EACpB,MAAM,MAAM,EACZ,cAAc,MAAM,KACnB,0BAgHF,CAAA"}
@@ -1,81 +1,81 @@
1
- import { objectEntries as d } from "@scalar/helpers/object/object-entries";
2
- const o = ({
3
- schemeName: e,
4
- authStore: s,
5
- documentSlug: c,
6
- type: a
7
- }) => {
8
- const r = s.getAuthSecrets(c, e);
9
- if (r?.type === a)
10
- return r;
11
- }, u = {
12
- clientSecret: "x-scalar-secret-client-secret",
13
- password: "x-scalar-secret-password",
14
- token: "x-scalar-secret-token",
15
- username: "x-scalar-secret-username",
16
- value: "x-scalar-secret-token",
17
- "x-scalar-client-id": "x-scalar-secret-client-id",
18
- "x-scalar-redirect-uri": "x-scalar-secret-redirect-uri"
19
- }, l = (e) => d(u).reduce((s, [c, a]) => {
20
- const r = e[c];
21
- return r !== void 0 && typeof r == "string" && (s[a] = r), s;
22
- }, {}), f = (e, s, c, a) => {
1
+ import { objectEntries as p } from "@scalar/helpers/object/object-entries";
2
+ const u = {
3
+ "x-scalar-secret-client-id": "x-scalar-client-id",
4
+ "x-scalar-secret-client-secret": "clientSecret",
5
+ "x-scalar-secret-password": "password",
6
+ "x-scalar-secret-redirect-uri": "x-scalar-redirect-uri",
7
+ "x-scalar-secret-token": "token",
8
+ "x-scalar-secret-username": "username"
9
+ }, o = (e, l, d = {}) => {
10
+ const i = {};
11
+ for (const s of e) {
12
+ const r = d[s], n = l[u[s]];
13
+ i[s] = r || n || "";
14
+ }
15
+ return i;
16
+ }, f = (e, l, d, i) => {
17
+ const s = l.getAuthSecrets(i, d);
23
18
  if (e.type === "apiKey") {
24
- const r = o({ schemeName: c, type: "apiKey", authStore: s, documentSlug: a });
19
+ const r = s?.type === "apiKey" ? s : void 0;
25
20
  return {
26
21
  ...e,
27
- "x-scalar-secret-token": "",
28
- ...l(e),
29
- ...r
22
+ "x-scalar-secret-token": r?.["x-scalar-secret-token"] || e.value || ""
30
23
  };
31
24
  }
32
25
  if (e.type === "http") {
33
- const r = o({ schemeName: c, type: "http", authStore: s, documentSlug: a });
26
+ const r = s?.type === "http" ? s : void 0;
34
27
  return {
35
28
  ...e,
36
- "x-scalar-secret-password": "",
37
- "x-scalar-secret-token": "",
38
- "x-scalar-secret-username": "",
39
- ...l(e),
40
- ...r
29
+ "x-scalar-secret-token": r?.["x-scalar-secret-token"] || e.token || "",
30
+ "x-scalar-secret-username": r?.["x-scalar-secret-username"] || e.username || "",
31
+ "x-scalar-secret-password": r?.["x-scalar-secret-password"] || e.password || ""
41
32
  };
42
33
  }
43
34
  if (e.type === "oauth2") {
44
- const r = o({ schemeName: c, type: "oauth2", authStore: s, documentSlug: a }), x = /* @__PURE__ */ new Set();
35
+ const r = s?.type === "oauth2" ? s : void 0, n = /* @__PURE__ */ new Set();
45
36
  return {
46
37
  ...e,
47
- flows: d(e?.flows ?? {}).reduce((n, [i, t]) => (t && ("selectedScopes" in t && Array.isArray(t.selectedScopes) && t.selectedScopes?.forEach((p) => x.add(p)), i === "implicit" && (n.implicit = {
38
+ flows: p(e?.flows ?? {}).reduce((a, [c, t]) => (t && ("selectedScopes" in t && Array.isArray(t.selectedScopes) && t.selectedScopes?.forEach((x) => x && n.add(x)), c === "implicit" && (a.implicit = {
48
39
  ...t,
49
- "x-scalar-secret-client-id": "",
50
- "x-scalar-secret-redirect-uri": "",
51
- "x-scalar-secret-token": "",
52
- ...l(t),
53
- ...r?.implicit
54
- }), i === "password" && (n[i] = {
40
+ ...o(
41
+ ["x-scalar-secret-client-id", "x-scalar-secret-redirect-uri", "x-scalar-secret-token"],
42
+ t,
43
+ r?.implicit
44
+ )
45
+ }), c === "password" && (a[c] = {
55
46
  ...t,
56
- "x-scalar-secret-client-id": "",
57
- "x-scalar-secret-client-secret": "",
58
- "x-scalar-secret-username": "",
59
- "x-scalar-secret-password": "",
60
- "x-scalar-secret-token": "",
61
- ...l(t),
62
- ...r?.password
63
- }), i === "clientCredentials" && (n[i] = {
47
+ ...o(
48
+ [
49
+ "x-scalar-secret-client-id",
50
+ "x-scalar-secret-client-secret",
51
+ "x-scalar-secret-username",
52
+ "x-scalar-secret-password",
53
+ "x-scalar-secret-token"
54
+ ],
55
+ t,
56
+ r?.password
57
+ )
58
+ }), c === "clientCredentials" && (a[c] = {
64
59
  ...t,
65
- "x-scalar-secret-client-id": "",
66
- "x-scalar-secret-client-secret": "",
67
- "x-scalar-secret-token": "",
68
- ...l(t),
69
- ...r?.clientCredentials
70
- }), i === "authorizationCode" && (n[i] = {
60
+ ...o(
61
+ ["x-scalar-secret-client-id", "x-scalar-secret-client-secret", "x-scalar-secret-token"],
62
+ t,
63
+ r?.clientCredentials
64
+ )
65
+ }), c === "authorizationCode" && (a[c] = {
71
66
  ...t,
72
- "x-scalar-secret-client-id": "",
73
- "x-scalar-secret-client-secret": "",
74
- "x-scalar-secret-redirect-uri": "",
75
- "x-scalar-secret-token": "",
76
- ...r?.authorizationCode
77
- })), n), {}),
78
- "x-default-scopes": Array.from(x)
67
+ ...o(
68
+ [
69
+ "x-scalar-secret-client-id",
70
+ "x-scalar-secret-client-secret",
71
+ "x-scalar-secret-redirect-uri",
72
+ "x-scalar-secret-token"
73
+ ],
74
+ t,
75
+ r?.authorizationCode
76
+ )
77
+ })), a), {}),
78
+ "x-default-scopes": Array.from(n)
79
79
  };
80
80
  }
81
81
  return e.type === "openIdConnect", e;
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.vue.d.ts","sourceRoot":"","sources":["../../../../src/v2/features/modal/Modal.vue"],"names":[],"mappings":"AAoZA,OAAO,EAGL,KAAK,UAAU,EAEhB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAA;AAE/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AACvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AAExE,OAAO,EASL,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACtB,MAAM,KAAK,CAAA;AAIZ,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,6CAA6C,CAAA;AAIxF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAKxD,MAAM,MAAM,UAAU,GAAG;IACvB,4DAA4D;IAC5D,cAAc,EAAE,cAAc,CAAA;IAC9B,qDAAqD;IACrD,QAAQ,EAAE,WAAW,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAA;IAC/C,iDAAiD;IACjD,IAAI,EAAE,WAAW,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IACrC,4CAA4C;IAC5C,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,mDAAmD;IACnD,MAAM,EAAE,WAAW,CAAC,UAAU,GAAG,SAAS,CAAC,CAAA;IAC3C,yDAAyD;IACzD,WAAW,EAAE,WAAW,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IAC5C,2CAA2C;IAC3C,UAAU,EAAE,UAAU,CAAA;IACtB,0DAA0D;IAC1D,YAAY,EAAE,qBAAqB,CAAA;IACnC,iDAAiD;IACjD,OAAO,EAAE,YAAY,EAAE,CAAA;IACvB,wDAAwD;IACxD,OAAO,EAAE,gBAAgB,CACvB,OAAO,CACL,IAAI,CACF,4BAA4B,EAC1B,gBAAgB,GAChB,eAAe,GACf,kBAAkB,GAClB,eAAe,GACf,SAAS,CACZ,CACF,CACF,CAAA;CACF,CAAA;AAED;;;;GAIG;;;;;AACH,wBA4WC"}
1
+ {"version":3,"file":"Modal.vue.d.ts","sourceRoot":"","sources":["../../../../src/v2/features/modal/Modal.vue"],"names":[],"mappings":"AA+YA,OAAO,EAGL,KAAK,UAAU,EAEhB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAA;AAE/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AACvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AAExE,OAAO,EASL,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACtB,MAAM,KAAK,CAAA;AAIZ,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,6CAA6C,CAAA;AAIxF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAKxD,MAAM,MAAM,UAAU,GAAG;IACvB,4DAA4D;IAC5D,cAAc,EAAE,cAAc,CAAA;IAC9B,qDAAqD;IACrD,QAAQ,EAAE,WAAW,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAA;IAC/C,iDAAiD;IACjD,IAAI,EAAE,WAAW,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IACrC,4CAA4C;IAC5C,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,mDAAmD;IACnD,MAAM,EAAE,WAAW,CAAC,UAAU,GAAG,SAAS,CAAC,CAAA;IAC3C,yDAAyD;IACzD,WAAW,EAAE,WAAW,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IAC5C,2CAA2C;IAC3C,UAAU,EAAE,UAAU,CAAA;IACtB,0DAA0D;IAC1D,YAAY,EAAE,qBAAqB,CAAA;IACnC,iDAAiD;IACjD,OAAO,EAAE,YAAY,EAAE,CAAA;IACvB,wDAAwD;IACxD,OAAO,EAAE,gBAAgB,CACvB,OAAO,CACL,IAAI,CACF,4BAA4B,EAC1B,gBAAgB,GAChB,eAAe,GACf,kBAAkB,GAClB,eAAe,GACf,SAAS,CACZ,CACF,CACF,CAAA;CACF,CAAA;AAED;;;;GAIG;;;;;AACH,wBAuWC"}
@@ -1,7 +1,7 @@
1
1
  import o from "./Modal.vue2.js";
2
2
  /* empty css */
3
3
  import t from "../../../_virtual/_plugin-vue_export-helper.js";
4
- const p = /* @__PURE__ */ t(o, [["__scopeId", "data-v-dbc80a57"]]);
4
+ const m = /* @__PURE__ */ t(o, [["__scopeId", "data-v-6027a07f"]]);
5
5
  export {
6
- p as default
6
+ m as default
7
7
  };
@@ -1,4 +1,4 @@
1
- import { defineComponent as W, ref as w, useId as D, watch as I, nextTick as N, onBeforeMount as E, onBeforeUnmount as F, computed as u, toValue as U, withDirectives as k, createElementBlock as d, openBlock as m, createElementVNode as s, unref as o, createVNode as l, withCtx as V, vShow as b } from "vue";
1
+ import { defineComponent as C, ref as w, useId as I, watch as N, nextTick as D, onBeforeMount as E, onBeforeUnmount as F, computed as d, toValue as U, withDirectives as k, createElementBlock as u, openBlock as m, createElementVNode as s, unref as o, createVNode as l, withCtx as V, vShow as b } from "vue";
2
2
  import { addScalarClassesToHeadless as $, ScalarTeleportRoot as A } from "@scalar/components";
3
3
  import { ScalarToasts as z } from "@scalar/use-toasts";
4
4
  import { useFocusTrap as H } from "@vueuse/integrations/useFocusTrap";
@@ -16,7 +16,7 @@ const P = { class: "scalar scalar-app" }, J = { class: "scalar-container" }, Q =
16
16
  }, Y = {
17
17
  key: 1,
18
18
  class: "flex h-full w-full items-center justify-center"
19
- }, Z = {}, me = /* @__PURE__ */ W({
19
+ }, Z = {}, me = /* @__PURE__ */ C({
20
20
  ...Z,
21
21
  __name: "Modal",
22
22
  props: {
@@ -44,25 +44,23 @@ const P = { class: "scalar scalar-app" }, J = { class: "scalar-container" }, Q =
44
44
  modalState: e.modalState,
45
45
  store: e.workspaceStore
46
46
  }), j(e.eventBus, "modal");
47
- const v = w(null), f = D(), { activate: y, deactivate: B } = H(v, {
47
+ const v = w(null), f = I(), { activate: y, deactivate: B } = H(v, {
48
48
  allowOutsideClick: !0,
49
49
  fallbackFocus: `#${f}`
50
50
  }), S = () => {
51
- B(), e.eventBus.emit("operation:cancel:request"), e.workspaceStore.revertDocumentChanges(
52
- e.document.value?.["x-scalar-navigation"]?.name ?? ""
53
- );
54
- }, g = q(() => typeof window < "u" ? window.document.body : null);
55
- I(
51
+ B(), e.eventBus.emit("operation:cancel:request");
52
+ }, p = q(() => typeof window < "u" ? window.document.body : null);
53
+ N(
56
54
  () => e.modalState.open,
57
55
  (a) => {
58
- g.value = a, a ? y({ checkCanFocusTrap: () => N() }) : S();
56
+ p.value = a, a ? y({ checkCanFocusTrap: () => D() }) : S();
59
57
  }
60
58
  ), E(() => $()), F(() => S());
61
- const p = 288, c = u(
62
- () => e.workspaceStore?.workspace?.["x-scalar-sidebar-width"] ?? p
63
- ), T = (a) => e.workspaceStore?.update("x-scalar-sidebar-width", a), h = u(
59
+ const g = 288, c = d(
60
+ () => e.workspaceStore?.workspace?.["x-scalar-sidebar-width"] ?? g
61
+ ), T = (a) => e.workspaceStore?.update("x-scalar-sidebar-width", a), h = d(
64
62
  () => R(e.workspaceStore, e.document.value)
65
- ), C = u(
63
+ ), W = d(
66
64
  () => L(
67
65
  e.document.value?.components?.securitySchemes,
68
66
  U(e.options)?.authentication?.securitySchemes,
@@ -73,7 +71,7 @@ const P = { class: "scalar scalar-app" }, J = { class: "scalar-container" }, Q =
73
71
  return x({
74
72
  sidebarWidth: c,
75
73
  environment: h
76
- }), (a, t) => k((m(), d("div", P, [
74
+ }), (a, t) => k((m(), u("div", P, [
77
75
  s("div", J, [
78
76
  s("div", {
79
77
  id: o(f),
@@ -88,7 +86,7 @@ const P = { class: "scalar scalar-app" }, J = { class: "scalar-container" }, Q =
88
86
  l(o(A), null, {
89
87
  default: V(() => [
90
88
  l(o(z)),
91
- e.document.value && e.path?.value && e.method?.value ? (m(), d("main", X, [
89
+ e.document.value && e.path?.value && e.method?.value ? (m(), u("main", X, [
92
90
  l(o(G), {
93
91
  modelValue: n.value,
94
92
  "onUpdate:modelValue": t[0] || (t[0] = (i) => n.value = i),
@@ -125,10 +123,10 @@ const P = { class: "scalar scalar-app" }, J = { class: "scalar-container" }, Q =
125
123
  options: e.options,
126
124
  path: e.path?.value,
127
125
  plugins: e.plugins,
128
- securitySchemes: C.value,
126
+ securitySchemes: W.value,
129
127
  workspaceStore: e.workspaceStore
130
128
  }, null, 8, ["document", "documentSlug", "environment", "eventBus", "exampleName", "method", "options", "path", "plugins", "securitySchemes", "workspaceStore"])
131
- ])) : (m(), d("div", Y, [...t[3] || (t[3] = [
129
+ ])) : (m(), u("div", Y, [...t[3] || (t[3] = [
132
130
  s("span", { class: "text-c-3" }, "No document selected", -1)
133
131
  ])]))
134
132
  ]),
@@ -1 +1 @@
1
- {"version":3,"file":"create-api-client-modal.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/modal/helpers/create-api-client-modal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAY,MAAM,oBAAoB,CAAA;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,EAAE,KAAK,iBAAiB,EAA2B,MAAM,gCAAgC,CAAA;AAChG,OAAO,EAAE,KAAK,GAAG,EAAiC,MAAM,KAAK,CAAA;AAE7D,OAAO,EAEL,KAAK,YAAY,EAElB,MAAM,sDAAsD,CAAA;AAE7D,OAAc,EAAE,KAAK,UAAU,EAAE,MAAM,+BAA+B,CAAA;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAExD,KAAK,2BAA2B,GAAG;IACjC,4CAA4C;IAC5C,EAAE,EAAE,WAAW,GAAG,IAAI,CAAA;IACtB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,kFAAkF;IAClF,QAAQ,CAAC,EAAE,iBAAiB,CAAA;IAC5B,6DAA6D;IAC7D,cAAc,EAAE,cAAc,CAAA;IAC9B,iDAAiD;IACjD,OAAO,CAAC,EAAE,YAAY,EAAE,CAAA;IACxB,wGAAwG;IACxG,OAAO,CAAC,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;CAChC,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,GAAG,CAAA;IACR,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,YAAY,KAAK,IAAI,CAAA;IACtC,KAAK,EAAE,CAAC,UAAU,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAA;IAC/C,KAAK,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAA;IACtC,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,wEASlC,2BAA2B,KAAG,cAsFhC,CAAA"}
1
+ {"version":3,"file":"create-api-client-modal.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/modal/helpers/create-api-client-modal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAY,MAAM,oBAAoB,CAAA;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,EAAE,KAAK,iBAAiB,EAA2B,MAAM,gCAAgC,CAAA;AAEhG,OAAO,EAAE,KAAK,GAAG,EAA6C,MAAM,KAAK,CAAA;AAEzE,OAAO,EAEL,KAAK,YAAY,EAElB,MAAM,sDAAsD,CAAA;AAG7D,OAAc,EAAE,KAAK,UAAU,EAAE,MAAM,+BAA+B,CAAA;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAExD,KAAK,2BAA2B,GAAG;IACjC,4CAA4C;IAC5C,EAAE,EAAE,WAAW,GAAG,IAAI,CAAA;IACtB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,kFAAkF;IAClF,QAAQ,CAAC,EAAE,iBAAiB,CAAA;IAC5B,6DAA6D;IAC7D,cAAc,EAAE,cAAc,CAAA;IAC9B,iDAAiD;IACjD,OAAO,CAAC,EAAE,YAAY,EAAE,CAAA;IACxB,wGAAwG;IACxG,OAAO,CAAC,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;CAChC,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,GAAG,CAAA;IACR,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,YAAY,KAAK,IAAI,CAAA;IACtC,KAAK,EAAE,CAAC,UAAU,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAA;IAC/C,KAAK,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAA;IACtC,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,wEASlC,2BAA2B,KAAG,cAqHhC,CAAA"}
@@ -1,47 +1,64 @@
1
1
  import { useModal as P } from "@scalar/components";
2
- import { createWorkspaceEventBus as A } from "@scalar/workspace-store/events";
3
- import { reactive as C, computed as t, createApp as I } from "vue";
4
- import { resolveRouteParameters as R } from "./resolve-route-parameters.js";
5
- import { useModalSidebar as S } from "../hooks/use-modal-sidebar.js";
6
- import j from "../Modal.vue.js";
7
- const T = ({
8
- el: f,
9
- eventBus: v = A({
2
+ import { createWorkspaceEventBus as S } from "@scalar/workspace-store/events";
3
+ import { ref as A, reactive as W, computed as o, createApp as I, watch as N } from "vue";
4
+ import { resolveRouteParameters as O } from "./resolve-route-parameters.js";
5
+ import { restoreWorkspaceState as R } from "./restore-workspace-state.js";
6
+ import { useModalSidebar as j } from "../hooks/use-modal-sidebar.js";
7
+ import B from "../Modal.vue.js";
8
+ const D = ({
9
+ el: v,
10
+ eventBus: h = S({
10
11
  debug: !1
11
12
  }),
12
- mountOnInitialize: h = !0,
13
+ mountOnInitialize: M = !0,
13
14
  plugins: g = [],
14
- workspaceStore: a,
15
+ workspaceStore: t,
15
16
  options: x = {}
16
17
  }) => {
17
- const n = {
18
+ const u = {
18
19
  path: "default",
19
20
  method: "default",
20
21
  example: "default",
21
- documentSlug: a.workspace["x-scalar-active-document"] || "default"
22
- }, m = C({ ...n }), r = (e) => {
23
- Object.assign(m, n, e);
24
- }, o = t(() => R(a, m)), s = t(() => o.value.documentSlug), u = t(() => o.value.path), d = t(() => o.value.method), i = t(() => o.value.example), M = t(() => a.workspace.documents[s.value ?? ""] ?? null), b = S({
25
- workspaceStore: a,
26
- documentSlug: s,
27
- path: u,
28
- method: d,
29
- exampleName: i,
30
- route: r
31
- }), c = P(), l = I(j, {
32
- document: M,
33
- eventBus: v,
34
- exampleName: i,
35
- method: d,
36
- modalState: c,
37
- path: u,
22
+ documentSlug: t.workspace["x-scalar-active-document"] || "default"
23
+ }, n = A(null), m = W({ ...u }), s = (e) => {
24
+ Object.assign(m, u, e);
25
+ }, a = o(() => O(t, m)), l = o(() => a.value.documentSlug), d = o(() => a.value.path), i = o(() => a.value.method), p = o(() => a.value.example), b = o(() => t.workspace.documents[l.value ?? ""] ?? null), k = j({
26
+ workspaceStore: t,
27
+ documentSlug: l,
28
+ path: d,
29
+ method: i,
30
+ exampleName: p,
31
+ route: s
32
+ }), r = P(), c = I(B, {
33
+ document: b,
34
+ eventBus: h,
35
+ exampleName: p,
36
+ method: i,
37
+ modalState: r,
38
+ path: d,
38
39
  plugins: g,
39
- sidebarState: b,
40
- workspaceStore: a,
40
+ sidebarState: k,
41
+ workspaceStore: t,
41
42
  options: x
42
- });
43
- l.config.idPrefix = "scalar-client";
44
- const p = (e = f) => {
43
+ }), w = () => {
44
+ n.value = window.structuredClone(t.exportWorkspace());
45
+ }, C = () => {
46
+ if (!n.value) {
47
+ console.warn("No workspace store snapshot to restore");
48
+ return;
49
+ }
50
+ const e = R({
51
+ workspaceStore: t,
52
+ workspaceState: n.value,
53
+ name: l.value ?? ""
54
+ });
55
+ e.ok || console.error("Failed to restore workspace state", e.error);
56
+ };
57
+ N(
58
+ () => r.open,
59
+ (e) => e ? w() : C()
60
+ ), c.config.idPrefix = "scalar-client";
61
+ const f = (e = v) => {
45
62
  if (!e) {
46
63
  console.error(
47
64
  "[@scalar/api-client] Could not create the API client Modal.",
@@ -50,23 +67,23 @@ const T = ({
50
67
  );
51
68
  return;
52
69
  }
53
- l.mount(e);
70
+ c.mount(e);
54
71
  };
55
- return h && p(), {
72
+ return M && f(), {
56
73
  /** The Vue app instance for the modal. Use with caution. */
57
- app: l,
74
+ app: c,
58
75
  /** Open the modal and optionally navigate to a specific route. */
59
76
  open: (e) => {
60
- c.open = !0, e && r(e);
77
+ r.open = !0, e && s(e);
61
78
  },
62
79
  /** Mount the modal to a given element. */
63
- mount: p,
80
+ mount: f,
64
81
  /** Navigate to the specified path, method, and example. */
65
- route: r,
82
+ route: s,
66
83
  /** Controls the visibility of the modal. */
67
- modalState: c
84
+ modalState: r
68
85
  };
69
86
  };
70
87
  export {
71
- T as createApiClientModal
88
+ D as createApiClientModal
72
89
  };
@@ -0,0 +1,18 @@
1
+ import type { WorkspaceStore } from '@scalar/workspace-store/client';
2
+ import type { InMemoryWorkspace } from '@scalar/workspace-store/schemas/inmemory-workspace';
3
+ /**
4
+ * Restores the state of a workspace document by reverting its state
5
+ * to the specified import, while preserving certain live properties
6
+ * such as servers, security schemes, and selected server.
7
+ */
8
+ export declare const restoreWorkspaceState: ({ workspaceStore, workspaceState, name, }: {
9
+ workspaceStore: WorkspaceStore | null;
10
+ workspaceState: InMemoryWorkspace;
11
+ name: string;
12
+ }) => {
13
+ ok: true;
14
+ } | {
15
+ ok: false;
16
+ error: string;
17
+ };
18
+ //# sourceMappingURL=restore-workspace-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restore-workspace-state.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/modal/helpers/restore-workspace-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAEpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oDAAoD,CAAA;AAE3F;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,2CAInC;IACD,cAAc,EAAE,cAAc,GAAG,IAAI,CAAA;IACrC,cAAc,EAAE,iBAAiB,CAAA;IACjC,IAAI,EAAE,MAAM,CAAA;CACb,KAAG;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAoD5C,CAAA"}
@@ -0,0 +1,36 @@
1
+ import { unpackProxyObject as c } from "@scalar/workspace-store/helpers/unpack-proxy";
2
+ const m = ({
3
+ workspaceStore: r,
4
+ workspaceState: u,
5
+ name: s
6
+ }) => {
7
+ if (!r)
8
+ return { ok: !1, error: "Workspace store is not available" };
9
+ const t = c(r.workspace.documents[s]);
10
+ if (!t)
11
+ return { ok: !1, error: "Current document not found in workspace store" };
12
+ const n = u.documents[s];
13
+ if (!n)
14
+ return { ok: !1, error: "Importing document not found in workspace state" };
15
+ const o = {
16
+ selectedServer: t["x-scalar-selected-server"],
17
+ securitySchemes: t.components?.securitySchemes,
18
+ servers: t.servers
19
+ };
20
+ r.loadWorkspace({
21
+ meta: {},
22
+ documents: {
23
+ [s]: n
24
+ },
25
+ intermediateDocuments: {},
26
+ originalDocuments: {},
27
+ overrides: {},
28
+ history: {},
29
+ auth: {}
30
+ });
31
+ const e = c(r.workspace.documents[s]);
32
+ return e ? (e["x-scalar-selected-server"] = o.selectedServer, e.servers = o.servers, e.components ??= {}, e.components.securitySchemes = o.securitySchemes, { ok: !0 }) : { ok: !1, error: "New document not found in workspace store" };
33
+ };
34
+ export {
35
+ m as restoreWorkspaceState
36
+ };
@@ -69,7 +69,7 @@ const b = {
69
69
  type: "document"
70
70
  }), v = n(
71
71
  () => C(r(e.options)?.hiddenClients)
72
- ), S = "2.23.3";
72
+ ), S = "2.23.4";
73
73
  return (t, a) => e.path && e.method && e.exampleName && c.value ? (l(), g(i(N), {
74
74
  key: 0,
75
75
  appVersion: i(S),
@@ -33,7 +33,7 @@ const W = { class: "flex-center relative flex flex-1 flex-col gap-6 p-2 capitali
33
33
  }));
34
34
  }, f = (u) => {
35
35
  u?.createNew && g.name === "request" && p();
36
- }, v = "2.23.3";
36
+ }, v = "2.23.4";
37
37
  return q(() => a.hotKeys.on(f)), R(() => a.hotKeys.off(f)), (u, e) => (l(), n("div", W, [
38
38
  s("div", {
39
39
  class: y(["flex h-[calc(100%_-_50px)] flex-col items-center justify-center", {
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "rest",
19
19
  "testing"
20
20
  ],
21
- "version": "2.23.3",
21
+ "version": "2.23.4",
22
22
  "engines": {
23
23
  "node": ">=20"
24
24
  },
@@ -326,26 +326,26 @@
326
326
  "whatwg-mimetype": "4.0.0",
327
327
  "yaml": "^2.8.0",
328
328
  "zod": "^4.3.5",
329
- "@scalar/draggable": "0.3.0",
330
- "@scalar/components": "0.17.4",
331
329
  "@scalar/analytics-client": "1.0.1",
332
- "@scalar/icons": "0.5.2",
330
+ "@scalar/components": "0.17.5",
331
+ "@scalar/draggable": "0.3.0",
332
+ "@scalar/helpers": "0.2.11",
333
333
  "@scalar/import": "0.4.48",
334
+ "@scalar/icons": "0.5.2",
334
335
  "@scalar/json-magic": "0.9.6",
335
- "@scalar/helpers": "0.2.11",
336
- "@scalar/oas-utils": "0.6.34",
337
336
  "@scalar/object-utils": "1.2.25",
338
- "@scalar/openapi-parser": "0.24.7",
339
- "@scalar/sidebar": "0.7.27",
337
+ "@scalar/oas-utils": "0.6.35",
340
338
  "@scalar/openapi-types": "0.5.3",
341
- "@scalar/snippetz": "0.6.11",
342
339
  "@scalar/postman-to-openapi": "0.4.3",
340
+ "@scalar/openapi-parser": "0.24.7",
343
341
  "@scalar/themes": "0.14.0",
342
+ "@scalar/sidebar": "0.7.28",
343
+ "@scalar/snippetz": "0.6.11",
344
+ "@scalar/use-codemirror": "0.13.32",
344
345
  "@scalar/types": "0.6.2",
345
346
  "@scalar/use-hooks": "0.3.7",
346
- "@scalar/use-codemirror": "0.13.31",
347
347
  "@scalar/use-toasts": "0.9.1",
348
- "@scalar/workspace-store": "0.28.3"
348
+ "@scalar/workspace-store": "0.28.4"
349
349
  },
350
350
  "devDependencies": {
351
351
  "@tailwindcss/vite": "^4.1.18",
@@ -360,8 +360,8 @@
360
360
  "vite": "^7.3.1",
361
361
  "vite-svg-loader": "5.1.0",
362
362
  "vitest": "4.0.16",
363
- "@scalar/galaxy": "0.5.12",
364
- "@scalar/build-tooling": "0.4.1"
363
+ "@scalar/build-tooling": "0.4.1",
364
+ "@scalar/galaxy": "0.5.12"
365
365
  },
366
366
  "scripts": {
367
367
  "build": "scalar-build-vite",