@scalar/api-client 2.17.8 → 2.18.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.
Files changed (87) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/style.css +1 -1
  3. package/dist/v2/blocks/operation-block/helpers/build-request.d.ts.map +1 -1
  4. package/dist/v2/blocks/operation-block/helpers/build-request.js +46 -51
  5. package/dist/v2/blocks/operation-block/helpers/get-environment-variables.d.ts +9 -0
  6. package/dist/v2/blocks/operation-block/helpers/get-environment-variables.d.ts.map +1 -0
  7. package/dist/v2/blocks/operation-block/helpers/get-environment-variables.js +7 -0
  8. package/dist/v2/blocks/operation-block/helpers/get-example.d.ts.map +1 -1
  9. package/dist/v2/blocks/operation-block/helpers/get-example.js +12 -10
  10. package/dist/v2/blocks/operation-block/helpers/get-server-url.d.ts +3 -0
  11. package/dist/v2/blocks/operation-block/helpers/get-server-url.d.ts.map +1 -0
  12. package/dist/v2/blocks/operation-block/helpers/get-server-url.js +12 -0
  13. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.d.ts.map +1 -1
  14. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.js +1 -1
  15. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue2.js +87 -65
  16. package/dist/v2/components/code-input/CodeInput.vue.d.ts +115 -144
  17. package/dist/v2/components/code-input/CodeInput.vue.d.ts.map +1 -1
  18. package/dist/v2/components/code-input/CodeInput.vue.js +2 -2
  19. package/dist/v2/components/code-input/CodeInput.vue2.js +120 -107
  20. package/dist/v2/components/data-table/DataTableInput.vue.d.ts +3 -3
  21. package/dist/v2/components/data-table/DataTableInput.vue.d.ts.map +1 -1
  22. package/dist/v2/components/data-table/DataTableInput.vue.js +2 -2
  23. package/dist/v2/components/data-table/DataTableInput.vue2.js +27 -27
  24. package/dist/v2/components/data-table/DataTableInputSelect.vue.d.ts +3 -2
  25. package/dist/v2/components/data-table/DataTableInputSelect.vue.d.ts.map +1 -1
  26. package/dist/v2/components/data-table/DataTableInputSelect.vue.js +42 -39
  27. package/dist/v2/components/sidebar/Sidebar.vue.d.ts +5 -3
  28. package/dist/v2/components/sidebar/Sidebar.vue.d.ts.map +1 -1
  29. package/dist/v2/components/sidebar/SidebarMenu.vue.d.ts +5 -3
  30. package/dist/v2/components/sidebar/SidebarMenu.vue.d.ts.map +1 -1
  31. package/dist/v2/components/sidebar/SidebarMenu.vue.js +25 -30
  32. package/dist/v2/features/app/App.vue.d.ts.map +1 -1
  33. package/dist/v2/features/app/App.vue.js +89 -141
  34. package/dist/v2/features/app/app-events.d.ts +22 -0
  35. package/dist/v2/features/app/app-events.d.ts.map +1 -0
  36. package/dist/v2/features/app/app-events.js +136 -0
  37. package/dist/v2/features/app/app-state.d.ts +135 -0
  38. package/dist/v2/features/app/app-state.d.ts.map +1 -0
  39. package/dist/v2/features/app/app-state.js +316 -0
  40. package/dist/v2/features/app/components/AppSidebar.vue.d.ts +6 -3
  41. package/dist/v2/features/app/components/AppSidebar.vue.d.ts.map +1 -1
  42. package/dist/v2/features/app/components/AppSidebar.vue.js +3 -3
  43. package/dist/v2/features/app/components/AppSidebar.vue2.js +4 -4
  44. package/dist/v2/features/app/components/DesktopTabs.vue.d.ts +4 -2
  45. package/dist/v2/features/app/components/DesktopTabs.vue.d.ts.map +1 -1
  46. package/dist/v2/features/app/components/DesktopTabs.vue.js +25 -22
  47. package/dist/v2/features/app/components/WebTopNav.vue.d.ts +9 -5
  48. package/dist/v2/features/app/components/WebTopNav.vue.d.ts.map +1 -1
  49. package/dist/v2/features/app/helpers/create-api-client-app.d.ts +62 -1
  50. package/dist/v2/features/app/helpers/create-api-client-app.d.ts.map +1 -1
  51. package/dist/v2/features/app/helpers/create-api-client-app.js +14 -10
  52. package/dist/v2/features/app/helpers/routes.d.ts +5 -2
  53. package/dist/v2/features/app/helpers/routes.d.ts.map +1 -1
  54. package/dist/v2/features/collection/WorkspaceCollection.vue.js +7 -7
  55. package/dist/v2/features/collection/components/Form.vue.d.ts +1 -1
  56. package/dist/v2/features/collection/components/Form.vue.d.ts.map +1 -1
  57. package/dist/v2/features/collection/components/Servers.vue.d.ts.map +1 -1
  58. package/dist/v2/features/modal/Modal.vue.d.ts.map +1 -1
  59. package/dist/v2/features/modal/Modal.vue.js +2 -2
  60. package/dist/v2/features/modal/Modal.vue2.js +40 -41
  61. package/dist/v2/features/operation/Operation.vue.d.ts.map +1 -1
  62. package/dist/v2/features/operation/Operation.vue.js +38 -28
  63. package/dist/v2/features/operation/helpers/combine-params.d.ts +4 -0
  64. package/dist/v2/features/operation/helpers/combine-params.d.ts.map +1 -0
  65. package/dist/v2/features/operation/helpers/combine-params.js +13 -0
  66. package/dist/v2/features/operation/index.d.ts +1 -0
  67. package/dist/v2/features/operation/index.d.ts.map +1 -1
  68. package/dist/v2/features/operation/index.js +10 -8
  69. package/dist/v2/helpers/get-tab-details.d.ts +2 -2
  70. package/dist/v2/helpers/get-tab-details.d.ts.map +1 -1
  71. package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
  72. package/package.json +16 -16
  73. package/dist/v2/features/app/hooks/use-app-sidebar.d.ts +0 -40
  74. package/dist/v2/features/app/hooks/use-app-sidebar.d.ts.map +0 -1
  75. package/dist/v2/features/app/hooks/use-app-sidebar.js +0 -134
  76. package/dist/v2/features/app/hooks/use-sync-path.d.ts +0 -11
  77. package/dist/v2/features/app/hooks/use-sync-path.d.ts.map +0 -1
  78. package/dist/v2/features/app/hooks/use-sync-path.js +0 -52
  79. package/dist/v2/features/app/hooks/use-tabs.d.ts +0 -31
  80. package/dist/v2/features/app/hooks/use-tabs.d.ts.map +0 -1
  81. package/dist/v2/features/app/hooks/use-tabs.js +0 -44
  82. package/dist/v2/features/app/hooks/use-workspace-client-app-events.d.ts +0 -18
  83. package/dist/v2/features/app/hooks/use-workspace-client-app-events.d.ts.map +0 -1
  84. package/dist/v2/features/app/hooks/use-workspace-client-app-events.js +0 -156
  85. package/dist/v2/features/app/hooks/use-workspace-selector.d.ts +0 -28
  86. package/dist/v2/features/app/hooks/use-workspace-selector.d.ts.map +0 -1
  87. package/dist/v2/features/app/hooks/use-workspace-selector.js +0 -81
@@ -1,156 +0,0 @@
1
- import { mergeObjects as g } from "@scalar/workspace-store/helpers/merge-object";
2
- import { updateActiveProxy as x, updateColorMode as y, updateTheme as T, updateSelectedClient as w, updateDocumentIcon as R, toggleSecurity as O, updateWatchMode as N, createEmptyDocument as C, deleteDocument as E, upsertEnvironment as q, upsertEnvironmentVariable as P, upsertCookie as I, deleteCookie as k, deleteSecurityScheme as A, updateSelectedAuthTab as M, updateSecurityScheme as D, updateSelectedScopes as F, updateSelectedSecuritySchemes as U, addServer as V, updateServer as K, deleteServer as L, updateServerVariables as W, updateSelectedServer as j, createOperation as z, updateOperationPathMethod as G, updateOperationSummary as H, deleteOperation as J, deleteOperationExample as Q, addOperationParameter as S, updateOperationParameter as X, deleteOperationParameter as Y, deleteAllOperationParameters as Z, updateOperationRequestBodyContentType as _, updateOperationRequestBodyExample as $, addOperationRequestBodyFormRow as B, updateOperationRequestBodyFormRow as ee, deleteOperationRequestBodyFormRow as ae, createTag as te, deleteTag as oe, addTab as re, closeTab as ne, closeOtherTabs as le, focusTab as ie, focusLastTab as ue, navigatePreviousTab as pe, navigateNextTab as ce, updateTabs as me } from "@scalar/workspace-store/mutators";
3
- import { toValue as f } from "vue";
4
- import { useRouter as de, useRoute as se } from "vue-router";
5
- const ge = ({
6
- eventBus: a,
7
- document: t,
8
- workspaceStore: o,
9
- isSidebarOpen: d,
10
- commandPaletteState: s,
11
- sidebarState: v
12
- }) => {
13
- const i = de(), u = se(), c = (e, r) => {
14
- const n = f(o);
15
- return n ? r === "document" ? e.value : n.workspace : null;
16
- }, l = async () => {
17
- const e = f(o);
18
- if (!e)
19
- return;
20
- const r = e.workspace["x-scalar-active-tab"] ?? 0, n = e.workspace["x-scalar-tabs"]?.[r];
21
- n && await i.replace(n.path);
22
- }, p = (e) => {
23
- e && o.value?.buildSidebar(e);
24
- }, m = (e) => {
25
- const r = t.value?.["x-scalar-navigation"]?.name;
26
- if (!r)
27
- return;
28
- const n = v.getEntryByLocation({
29
- document: r,
30
- path: e.path,
31
- method: e.method,
32
- example: e.exampleKey
33
- });
34
- (!n || n.type !== "example") && p(r);
35
- }, h = ({
36
- documentName: e,
37
- path: r,
38
- method: n,
39
- exampleName: b
40
- }) => !(e !== void 0 && e !== u.params.documentSlug || r !== void 0 && encodeURIComponent(r) !== u.params.pathEncoded || n !== void 0 && n !== u.params.method || b !== void 0 && b !== u.params.exampleName);
41
- a.on("scroll-to:nav-item", ({ id: e }) => v.handleSelectItem(e)), a.on(
42
- "workspace:update:active-proxy",
43
- (e) => x(o.value?.workspace ?? null, e)
44
- ), a.on(
45
- "workspace:update:color-mode",
46
- (e) => y(o.value?.workspace ?? null, e)
47
- ), a.on("workspace:update:theme", (e) => T(o.value?.workspace ?? null, e)), a.on(
48
- "workspace:update:selected-client",
49
- (e) => w(o.value?.workspace, e)
50
- ), a.on("document:update:icon", (e) => R(t.value, e)), a.on("document:update:info", (e) => t.value && g(t.value.info, e)), a.on("document:toggle:security", () => O(t.value)), a.on("document:update:watch-mode", (e) => N(t.value, e)), a.on("document:create:empty-document", (e) => C(o.value, e)), a.on("document:delete:document", async (e) => {
51
- E(o.value, e), u.params.documentSlug === e.name && await i.push({
52
- name: "workspace.environment"
53
- });
54
- }), a.on("environment:upsert:environment", (e) => {
55
- o.value && q(t.value, o.value.workspace, e);
56
- }), a.on(
57
- "environment:delete:environment",
58
- ({ environmentName: e, collectionType: r }) => delete c(t, r)?.["x-scalar-environments"]?.[e]
59
- ), a.on("environment:upsert:environment-variable", (e) => {
60
- const r = c(t, e.collectionType);
61
- P(r, e);
62
- }), a.on(
63
- "environment:delete:environment-variable",
64
- ({ environmentName: e, index: r, collectionType: n }) => c(t, n)?.["x-scalar-environments"]?.[e]?.variables?.splice(r, 1)
65
- ), a.on("cookie:upsert:cookie", (e) => {
66
- const r = c(t, e.collectionType);
67
- I(r, e);
68
- }), a.on("cookie:delete:cookie", (e) => {
69
- const r = c(t, e.collectionType);
70
- k(r, e);
71
- }), a.on("auth:delete:security-scheme", (e) => A(t.value, e)), a.on("auth:update:active-index", (e) => M(t.value, e)), a.on("auth:update:security-scheme", (e) => D(t.value, e)), a.on("auth:update:selected-scopes", (e) => F(t.value, e)), a.on(
72
- "auth:update:selected-security-schemes",
73
- async (e) => await U(t.value, e)
74
- ), a.on("server:add:server", () => V(t.value)), a.on("server:update:server", (e) => K(t.value, e)), a.on("server:delete:server", (e) => L(t.value, e)), a.on("server:update:variables", (e) => W(t.value, e)), a.on("server:update:selected", (e) => j(t.value, e)), a.on("operation:create:operation", (e) => z(o.value, e)), a.on(
75
- "operation:update:pathMethod",
76
- (e) => G(t.value, o.value, e, async (r) => {
77
- r === "success" && (await i.replace({
78
- name: "example",
79
- params: {
80
- method: e.payload.method,
81
- pathEncoded: encodeURIComponent(e.payload.path),
82
- exampleName: u.params.exampleName
83
- }
84
- }), p(t.value?.["x-scalar-navigation"]?.name)), e.callback(r);
85
- })
86
- ), a.on("operation:update:summary", (e) => H(t.value, e)), a.on("operation:delete:operation", async (e) => {
87
- J(o.value, e), p(e.documentName), h({
88
- documentName: e.documentName,
89
- path: e.meta.path,
90
- method: e.meta.method
91
- }) && await i.replace({
92
- name: "document.overview",
93
- params: {
94
- documentSlug: e.documentName
95
- }
96
- });
97
- }), a.on("operation:delete:example", async (e) => {
98
- Q(o.value, e), p(e.documentName), h({
99
- documentName: e.documentName,
100
- path: e.meta.path,
101
- method: e.meta.method,
102
- exampleName: e.meta.exampleKey
103
- }) && await i.replace({
104
- name: "example",
105
- params: {
106
- pathEncoded: encodeURIComponent(e.meta.path),
107
- method: e.meta.method,
108
- documentSlug: e.documentName,
109
- exampleName: "default"
110
- }
111
- });
112
- }), a.on("operation:add:parameter", (e) => {
113
- S(t.value, e), m(e.meta);
114
- }), a.on("operation:update:parameter", (e) => {
115
- X(t.value, e), m(e.meta);
116
- }), a.on("operation:delete:parameter", (e) => Y(t.value, e)), a.on("operation:delete-all:parameters", (e) => Z(t.value, e)), a.on(
117
- "operation:update:requestBody:contentType",
118
- (e) => _(t.value, e)
119
- ), a.on("operation:update:requestBody:value", (e) => {
120
- $(t.value, e), m(e.meta);
121
- }), a.on("operation:add:requestBody:formRow", (e) => {
122
- B(t.value, e), m(e.meta);
123
- }), a.on(
124
- "operation:update:requestBody:formRow",
125
- (e) => ee(t.value, e)
126
- ), a.on(
127
- "operation:delete:requestBody:formRow",
128
- (e) => ae(t.value, e)
129
- ), a.on("tag:create:tag", (e) => {
130
- te(o.value, e), p(e.documentName);
131
- }), a.on("tag:delete:tag", (e) => {
132
- oe(o.value, e), p(e.documentName);
133
- }), a.on("ui:toggle:sidebar", () => d.value = !d.value), a.on(
134
- "ui:open:command-palette",
135
- (e) => {
136
- e ? s.open(e.action, e.payload) : s.open();
137
- }
138
- ), a.on("ui:route:page", ({ name: e }) => i.push({ name: e })), a.on("tabs:add:tab", async (e) => {
139
- re(o.value?.workspace ?? null, e), await l();
140
- }), a.on("tabs:close:tab", async (e) => {
141
- ne(o.value?.workspace ?? null, e), await l();
142
- }), a.on("tabs:close:other-tabs", (e) => le(o.value?.workspace ?? null, e)), a.on("tabs:focus:tab", async (e) => {
143
- ie(o.value?.workspace ?? null, e), await l();
144
- }), a.on("tabs:focus:tab-last", async (e) => {
145
- ue(o.value?.workspace ?? null, e), await l();
146
- }), a.on("tabs:navigate:previous", async (e) => {
147
- pe(o.value?.workspace ?? null, e), await l();
148
- }), a.on("tabs:navigate:next", async (e) => {
149
- ce(o.value?.workspace ?? null, e), await l();
150
- }), a.on("tabs:update:tabs", async (e) => {
151
- me(o.value?.workspace ?? null, e), await l();
152
- });
153
- };
154
- export {
155
- ge as useWorkspaceClientAppEvents
156
- };
@@ -1,28 +0,0 @@
1
- import { type WorkspaceStore } from '@scalar/workspace-store/client';
2
- import { type Ref } from 'vue';
3
- /**
4
- * Default workspace meta used when we need to create or navigate to a fallback workspace.
5
- * Keep in sync with the persisted workspace structure.
6
- */
7
- export declare const DEFAULT_WORKSPACE: Workspace;
8
- export type Workspace = {
9
- name: string;
10
- id: string;
11
- };
12
- export type UseWorkspaceSelectorReturn = {
13
- activeWorkspace: Ref<Workspace | null>;
14
- workspaces: Ref<Workspace[]>;
15
- store: Ref<WorkspaceStore | null>;
16
- setWorkspaceId: (id: string) => Promise<void>;
17
- createWorkspace: (props: {
18
- name: string;
19
- }) => Promise<Workspace | undefined>;
20
- loadWorkspace: (id: string) => Promise<{
21
- success: true;
22
- workspace: WorkspaceStore;
23
- } | {
24
- success: false;
25
- }>;
26
- };
27
- export declare const useWorkspaceSelector: () => UseWorkspaceSelectorReturn;
28
- //# sourceMappingURL=use-workspace-selector.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-workspace-selector.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/app/hooks/use-workspace-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,gCAAgC,CAAA;AAK1F,OAAO,EAAE,KAAK,GAAG,EAAO,MAAM,KAAK,CAAA;AAOnC;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAG/B,CAAA;AA0BD,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;CACX,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,eAAe,EAAE,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,CAAA;IACtC,UAAU,EAAE,GAAG,CAAC,SAAS,EAAE,CAAC,CAAA;IAC5B,KAAK,EAAE,GAAG,CAAC,cAAc,GAAG,IAAI,CAAC,CAAA;IACjC,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC7C,eAAe,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAAA;IAC5E,aAAa,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,IAAI,CAAC;QAAC,SAAS,EAAE,cAAc,CAAA;KAAE,GAAG;QAAE,OAAO,EAAE,KAAK,CAAA;KAAE,CAAC,CAAA;CAC1G,CAAA;AAED,eAAO,MAAM,oBAAoB,QAAO,0BA8HvC,CAAA"}
@@ -1,81 +0,0 @@
1
- import { createWorkspaceStore as l } from "@scalar/workspace-store/client";
2
- import { generateUniqueValue as W } from "@scalar/workspace-store/helpers/generate-unique-value";
3
- import { createWorkspaceStorePersistence as v } from "@scalar/workspace-store/persistence";
4
- import { persistencePlugin as D } from "@scalar/workspace-store/plugins/client";
5
- import { ref as i } from "vue";
6
- import { useRouter as g } from "vue-router";
7
- import { slugify as y } from "../../../helpers/slugify.js";
8
- const S = 1e3, R = {
9
- name: "Default Workspace",
10
- id: "default"
11
- }, h = {
12
- openapi: "3.1.0",
13
- info: {
14
- title: "Drafts",
15
- version: "1.0.0"
16
- },
17
- paths: {
18
- "/": {
19
- get: {}
20
- }
21
- },
22
- "x-scalar-original-document-hash": "drafts",
23
- "x-scalar-icon": "interface-edit-tool-pencil"
24
- }, A = async ({ workspaceId: r }) => l({
25
- plugins: [await D({ workspaceId: r, debounceDelay: S })]
26
- }), _ = () => {
27
- const r = i(null), c = i([]), n = i(null), o = v(), w = g(), m = async (e) => {
28
- const a = await (await o).workspace.getItem(e);
29
- if (!a)
30
- return {
31
- success: !1
32
- };
33
- const s = await A({ workspaceId: e });
34
- return s.loadWorkspace(a.workspace), r.value = { id: e, name: a.name }, n.value = s, {
35
- success: !0,
36
- workspace: s
37
- };
38
- }, k = async ({ id: e, name: t }) => {
39
- const a = l();
40
- await a.addDocument({
41
- name: "drafts",
42
- document: h
43
- }), await (await o).workspace.setItem(e, {
44
- name: t,
45
- workspace: a.exportWorkspace()
46
- }), c.value.push({ id: e, name: t });
47
- }, p = async (e) => {
48
- await w.push({
49
- name: "workspace.environment",
50
- params: { workspaceSlug: e }
51
- });
52
- }, f = async ({ id: e, name: t }) => {
53
- n.value = null;
54
- const a = await o, s = await W({
55
- defaultValue: e ?? t,
56
- // Use the provided id if it exists, otherwise use the name
57
- validation: async (d) => !await a.workspace.has(d),
58
- maxRetries: 100,
59
- transformation: y
60
- });
61
- if (!s)
62
- return;
63
- const u = { id: s, name: t };
64
- return await k(u), await p(s), u;
65
- };
66
- return (async () => {
67
- const t = await (await o).workspace.getAll();
68
- c.value = t;
69
- })(), {
70
- store: n,
71
- activeWorkspace: r,
72
- workspaces: c,
73
- setWorkspaceId: p,
74
- createWorkspace: f,
75
- loadWorkspace: m
76
- };
77
- };
78
- export {
79
- R as DEFAULT_WORKSPACE,
80
- _ as useWorkspaceSelector
81
- };