@scalar/api-client 2.23.2 → 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.
Files changed (24) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/style.css +1 -1
  3. package/dist/v2/blocks/operation-block/helpers/build-request-parameters.d.ts.map +1 -1
  4. package/dist/v2/blocks/operation-block/helpers/build-request-parameters.js +54 -53
  5. package/dist/v2/blocks/operation-code-sample/helpers/get-example-from-schema.d.ts.map +1 -1
  6. package/dist/v2/blocks/operation-code-sample/helpers/get-example-from-schema.js +78 -78
  7. package/dist/v2/blocks/request-block/components/RequestTableRow.vue.d.ts.map +1 -1
  8. package/dist/v2/blocks/request-block/components/RequestTableRow.vue.js +63 -51
  9. package/dist/v2/blocks/request-block/helpers/get-default-headers.js +1 -1
  10. package/dist/v2/blocks/response-block/components/ResponseBody.vue.js +2 -2
  11. package/dist/v2/blocks/scalar-auth-selector-block/helpers/extract-security-scheme-secrets.d.ts +5 -1
  12. package/dist/v2/blocks/scalar-auth-selector-block/helpers/extract-security-scheme-secrets.d.ts.map +1 -1
  13. package/dist/v2/blocks/scalar-auth-selector-block/helpers/extract-security-scheme-secrets.js +61 -61
  14. package/dist/v2/features/modal/Modal.vue.d.ts.map +1 -1
  15. package/dist/v2/features/modal/Modal.vue.js +2 -2
  16. package/dist/v2/features/modal/Modal.vue2.js +15 -17
  17. package/dist/v2/features/modal/helpers/create-api-client-modal.d.ts.map +1 -1
  18. package/dist/v2/features/modal/helpers/create-api-client-modal.js +58 -41
  19. package/dist/v2/features/modal/helpers/restore-workspace-state.d.ts +18 -0
  20. package/dist/v2/features/modal/helpers/restore-workspace-state.d.ts.map +1 -0
  21. package/dist/v2/features/modal/helpers/restore-workspace-state.js +36 -0
  22. package/dist/v2/features/operation/Operation.vue.js +1 -1
  23. package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
  24. package/package.json +11 -11
@@ -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.2";
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.2";
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.2",
21
+ "version": "2.23.4",
22
22
  "engines": {
23
23
  "node": ">=20"
24
24
  },
@@ -327,25 +327,25 @@
327
327
  "yaml": "^2.8.0",
328
328
  "zod": "^4.3.5",
329
329
  "@scalar/analytics-client": "1.0.1",
330
- "@scalar/components": "0.17.3",
330
+ "@scalar/components": "0.17.5",
331
331
  "@scalar/draggable": "0.3.0",
332
332
  "@scalar/helpers": "0.2.11",
333
- "@scalar/icons": "0.5.2",
334
333
  "@scalar/import": "0.4.48",
334
+ "@scalar/icons": "0.5.2",
335
335
  "@scalar/json-magic": "0.9.6",
336
- "@scalar/oas-utils": "0.6.33",
337
- "@scalar/openapi-parser": "0.24.7",
338
- "@scalar/postman-to-openapi": "0.4.3",
339
- "@scalar/openapi-types": "0.5.3",
340
336
  "@scalar/object-utils": "1.2.25",
341
- "@scalar/sidebar": "0.7.26",
342
- "@scalar/snippetz": "0.6.11",
337
+ "@scalar/oas-utils": "0.6.35",
338
+ "@scalar/openapi-types": "0.5.3",
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
- "@scalar/use-codemirror": "0.13.30",
346
346
  "@scalar/use-hooks": "0.3.7",
347
347
  "@scalar/use-toasts": "0.9.1",
348
- "@scalar/workspace-store": "0.28.2"
348
+ "@scalar/workspace-store": "0.28.4"
349
349
  },
350
350
  "devDependencies": {
351
351
  "@tailwindcss/vite": "^4.1.18",